Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: 小插件
- Plugin URI: https://blog.69cdn.com/disable-wordpress-unnecessary-functions/
- Description: 禁用一些毫无用处的功能
- Version: 0.1
- Author: alect
- */
- // Add custom Theme Functions here
- // disable XML-RPC
- add_filter( 'xmlrpc_enabled', '__return_false' );
- // remove RSD Links
- remove_action( 'wp_head', 'rsd_link' ) ;
- // remove wlwmanifest Link
- remove_action('wp_head', 'wlwmanifest_link');
- // remove version from head
- remove_action('wp_head', 'wp_generator');
- // remove version from rss
- add_filter('the_generator', '__return_empty_string');
- // remove version from head
- remove_action('wp_head', 'wp_generator');
- // remove version from rss
- add_filter('the_generator', '__return_empty_string');
- // remove version from scripts and styles
- function shapeSpace_remove_version_scripts_styles($src) {
- if (strpos($src, 'ver=')) {
- $src = remove_query_arg('ver', $src);
- }
- return $src;
- }
- add_filter('style_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999);
- add_filter('script_loader_src', 'shapeSpace_remove_version_scripts_styles', 9999);
- // Remove the Shortlink Tag
- add_filter('after_setup_theme', 'remove_redundant_shortlink');
- function remove_redundant_shortlink() {
- // remove HTML meta tag
- // <link rel='shortlink' href='http://example.com/?p=25' />
- remove_action('wp_head', 'wp_shortlink_wp_head', 10);
- // remove HTTP header
- // Link: <https://example.com/?p=25>; rel=shortlink
- remove_action( 'template_redirect', 'wp_shortlink_header', 11);
- }
- // Disable Self Pingbacks
- function no_self_ping( &$links ) {
- $home = get_option( 'home' );
- foreach ( $links as $l => $link )
- if ( 0 === strpos( $link, $home ) )
- unset($links[$l]);
- }
- add_action( 'pre_ping', 'no_self_ping' );
- // Remove REST API Links
- add_action('after_setup_theme', function(){
- remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
- });
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement