This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Limit the comment length to 6000 characters and a minimum of 50 characters in WordPress | |
add_filter( 'preprocess_comment', 'smartwp_limit_comment_length' ); | |
function smartwp_limit_comment_length( $comment ) { | |
// Limit the comments to 6000 characters | |
if ( strlen( $comment['comment_content'] ) > 6000 ) { | |
wp_die('Comment is too long. Comments must be under 6000 characters.'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//This will prepend your WordPress RSS feed content with the featured image | |
add_filter('the_content', 'smartwp_featured_image_in_rss_feed'); | |
function smartwp_featured_image_in_rss_feed( $content ) { | |
global $post; | |
if( is_feed() ) { | |
if ( has_post_thumbnail( $post->ID ) ){ | |
$prepend = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 10px;' ) ) . '</div>'; | |
$content = $prepend . $content; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Disable emojis in WordPress | |
add_action( 'init', 'smartwp_disable_emojis' ); | |
function smartwp_disable_emojis() { | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Remove Gutenberg Block Library CSS from loading on the frontend | |
function smartwp_remove_wp_block_library_css(){ | |
wp_dequeue_style( 'wp-block-library' ); | |
wp_dequeue_style( 'wp-block-library-theme' ); | |
wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS | |
} | |
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: Twenty Fifteen Child | |
Description: Twenty Fifteen Child Theme | |
Author: John Doe | |
Author URI: http://example.com | |
Template: twentyfifteen | |
Version: 1.0.0 | |
Text Domain: twentyfifteenchild | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Disable the new user notification sent to the site admin | |
function smartwp_disable_new_user_notifications() { | |
//Remove original use created emails | |
remove_action( 'register_new_user', 'wp_send_new_user_notifications' ); | |
remove_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); | |
//Add new function to take over email creation | |
add_action( 'register_new_user', 'smartwp_send_new_user_notifications' ); | |
add_action( 'edit_user_created_user', 'smartwp_send_new_user_notifications', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $product; | |
echo 'The current product ID is: '.$product->get_id(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( shortcode_exists( 'image_gallery' ) ) { | |
echo 'The [image_gallery] shortcode already exists'; | |
} | |
if ( !shortcode_exists( 'image_gallery' ) ) { | |
echo 'The [image_gallery] shortcode does not exist'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Create an admin user | |
function smartwp_create_admin_user(){ | |
$username = 'yourusername'; | |
$password = '2JyAEQJ9B9Jf5T8a'; | |
$email = 'change@me.com'; | |
//This will ensure it only tries to create the user once (based on email/username) | |
if ( !username_exists( $username ) && !email_exists( $email ) ) { | |
$userid = wp_create_user( $username, $password, $email ); | |
$user = new WP_User( $userid ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php_value memory_limit 256M |
NewerOlder