Created
October 14, 2022 23:02
-
-
Save richardtape/7dbf943ec0896dce6fa9e455d39b3d24 to your computer and use it in GitHub Desktop.
WP Theme Clean Slate
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 | |
// Add this to your functions.php for example... | |
add_action( 'init', 'rkn_clean_slate__init' ); | |
/** | |
* WP has a lot of initial...err...stuff even with a completely blank theme. Let's remove quite a bit | |
* of that. | |
* | |
* @since 0.1.0 | |
* @return void | |
*/ | |
function rkn_clean_slate__init() { | |
// Remove Emoji. | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
// Remove EditURI as I don't use a 3rd-party editing tool. | |
remove_action ( 'wp_head', 'rsd_link' ); | |
// Remove the manifest link. | |
remove_action( 'wp_head', 'wlwmanifest_link' ); | |
// Remove the shortlink. | |
remove_action( 'wp_head', 'wp_shortlink_wp_head' ); | |
// Remove the Link header for the REST API. | |
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); | |
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); | |
// Remove oEmbed Discovery Links. | |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 ); | |
// Remove WordPress.org Dns-prefetch. | |
remove_action( 'wp_head', 'wp_resource_hints', 2 ); | |
// Remove WP Generator Tag. | |
remove_action( 'wp_head', 'wp_generator' ); | |
// Remove default generated SkipLink. I'll have my own. | |
remove_action( 'wp_footer', 'the_block_template_skip_link' ); | |
// disable comments feed. | |
add_filter( 'feed_links_show_comments_feed', '__return_false' ); | |
// Remove meta robots tag. | |
remove_filter( 'wp_robots', 'wp_robots_max_image_preview_large' ); | |
// Remove unwanted SVG filter injection WP. | |
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' ); | |
remove_action( 'wp_body_open', 'gutenberg_global_styles_render_svg_filters' ); // Gutenberg plugin o_O | |
// Remove default "global" styles. | |
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' ); | |
remove_action( 'wp_enqueue_scripts', 'gutenberg_enqueue_global_styles' ); // Gutenberg plugin o_O | |
// Remove Block Style Library. | |
add_action( 'wp_enqueue_scripts', 'rkn_remove_wp_block_library_css__wp_enqueue_scripts', 10 ); | |
}//end rkn_clean_slate() | |
/** | |
* Specifically remove the CSS that WP enqueues for the block library as we'll be starting clean. | |
* | |
* @since 0.1.0 | |
* @return void | |
*/ | |
function rkn_remove_wp_block_library_css__wp_enqueue_scripts() { | |
wp_dequeue_style( 'wp-block-library' ); | |
wp_dequeue_style( 'wp-block-library-theme' ); | |
}//end rkn_remove_wp_block_library_css__wp_enqueue_scripts() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
here's some i've gathered over the years in case you find them useful – i'll add the ones you have to this list as well: