Skip to content

Instantly share code, notes, and snippets.

@henshaw
Last active August 3, 2025 20:52
Show Gist options
  • Save henshaw/0cccac8c05b63255a16e5a7175d54fda to your computer and use it in GitHub Desktop.
Save henshaw/0cccac8c05b63255a16e5a7175d54fda to your computer and use it in GitHub Desktop.
Filters and actions to improve WordPress
<?php
// Disable RSS enclosures for media files
add_filter( 'rss_enclosure', '__return_empty_string' );
// Remove Gutenberg block styles, which I don't use
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'wp-block-library' );
} );
// Removes unnecessary links in the <head> area
remove_action ('wp_head', 'rsd_link');
remove_action( 'wp_head', 'wp_shortlink_wp_head');
remove_action( 'wp_head', 'wlwmanifest_link');
// Disable the XMLRPC API for security purposes and because I don't use it
add_filter('xmlrpc_enabled', '__return_false');
// Add the user's name to the Alt text for Gravatar images, which is blank by default
function gravatar_alt($text) {
$alt = get_the_author_meta( 'display_name' );
$text = str_replace('alt=\'\'', 'alt=\'Headshot for '.$alt.'\'',$text);
return $text;
}
add_filter('get_avatar','gravatar_alt');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment