Last active
August 3, 2025 20:52
-
-
Save henshaw/0cccac8c05b63255a16e5a7175d54fda to your computer and use it in GitHub Desktop.
Filters and actions to improve WordPress
This file contains hidden or 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 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