Software > WordPress > WordPress Plugins >
https://wordpress.org/plugins/code-snippets/
This plugin allows you to add code snippets as an alternative to directly editing a theme’s functions.php.
I used to manually edit functions.php for my child theme Parament-spiralofhope.
![]() |
—
Table of Contents [hide]
blog.spiralofhope.com/wp-admin/admin.php?page=snippets
Disable character filtering, like single quotes becoming curly quotes. ∞
Spoiler
// Disable character filtering, like single quotes becoming curly quotes. // Titles remove_filter( 'the_title', 'wptexturize' ); // Content (the body) remove_filter( 'the_content', 'wptexturize' ); // Excerpts remove_filter( 'the_excerpt', 'wptexturize' ); // Comments remove_filter( 'comment_text', 'wptexturize' );
[TODO] – “Go” search ∞
Spoiler
// Redirect if a case-insensitive search matches. add_action('template_redirect', 'redirect_single_post'); function redirect_single_post() { if (is_search()) { global $wp_query; if ($wp_query->post_count == 1 && $wp_query->max_num_pages == 1) { wp_redirect( get_permalink( $wp_query->posts['0']->ID ) ); exit; } } } /* Old code which didn't work. // This is like Wikipedia's "Go". // With thanks to s_ha_dum: // https://wordpress.stackexchange.com/questions/49208/want-to-redirect-if-search-query-match-exact-title-of-any-post#73061 //TODO - Redirect if only one match was found. //FIXME - This does not work for multiple words. I need to be far more sneaky. function redir_title_match() { if (is_search()) { global $wp_query,$wpdb; $s_str = $wp_query->query_vars['s']; $m = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_title = %s", strtolower($s_str))); if (!empty($m)) { wp_safe_redirect(get_permalink($m)); exit(); } } } add_filter('pre_get_posts','redir_title_match'); */
remove version info from head and feeds ∞
Spoiler
// remove version info from header and footer function complete_version_removal() { return ''; } add_filter('the_generator', 'complete_version_removal');
delay feed update ∞
Spoiler
// delay feed update function publish_later_on_feed($where) { global $wpdb; if (is_feed()) { // timestamp in WP-format $now = gmdate('Y-m-d H:i:s'); // value for wait; + device $wait = '15'; // integer, minutes // https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_timestampdiff [ 2 ] $device = 'MINUTE'; // MINUTE, HOUR, DAY, WEEK, MONTH, YEAR // add SQL-sytax to default $where $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait "; } return $where; } add_filter('posts_where', 'publish_later_on_feed');
Escape HTML entities in comments ∞
Spoiler
// escape html entities in comments function encode_code_in_comment($source) { $encoded = preg_replace_callback('/<code>(.*?)<\/code>/ims', create_function('$matches', '$matches[1] = preg_replace(array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "", $matches[1]); return "<code>" . htmlentities($matches[1]) . "</"."code>";'), $source); if ($encoded) return $encoded; else return $source; } add_filter('pre_comment_content', 'encode_code_in_comment');
Remove fontawesome ∞
This does not remove it from the admin area. Use an ad blocker.
Spoiler
// Remove fontawesome // https://fontawesome.com/ add_action( 'wp_print_styles', 'tn_dequeue_font_awesome_style' ); function tn_dequeue_font_awesome_style() { wp_dequeue_style( 'fontawesome' ); wp_deregister_style( 'fontawesome' ); }
Footnotes
- was https://github.com/sheabunge/code-snippets [ ↩ ]
- was [[archive:https://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff|]] [ ↩ ]


Removing fontawful.
deactivating for now
https://patchstack.com/database/vulnerability/code-snippets/wordpress-code-snippets-plugin-2-14-3-authenticated-reflected-cross-site-scripting-xss-vulnerability