緊急対応: WordPress 5.9 で追加される自動挿入コードを削除する

<?php

function clean_up_auto_inserted_codes () {
// remove SVG and global styles
remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles');

// remove wp_footer actions which add's global inline styles
remove_action('wp_footer', 'wp_enqueue_global_styles', 1);

// remove render_block filters which adding unnecessary stuff
remove_filter('render_block', 'wp_render_duotone_support');
remove_filter('render_block', 'wp_restore_group_inner_container');
remove_filter('render_block', 'wp_render_layout_support_flag');
}
add_action('after_setup_theme', 'clean_up_auto_inserted_codes');

?>
<?php

function clean_up_auto_inserted_codes () {

/* emoji関連 */
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');

remove_action('wp_head', 'wlwmanifest_link'); /* Windows Live Writer */
remove_action('wp_head', 'wp_generator'); /* WordPressバージョン */
remove_action('wp_head', 'rsd_link'); /* Really Simple Discoveryリンク */
remove_action('wp_head', 'feed_links', 2); /* フィードリンク関連 */
remove_action('wp_head', 'feed_links_extra', 3); /* コメントフィード */
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); /* ページネーション rel="next" / rel="prev" */
remove_action('wp_head', 'parent_post_rel_link'); /* ページネーション rel="up" */
remove_action('wp_head', 'start_post_rel_link'); /* ページネーション rel="start" */
remove_action('wp_head', 'start_post_rel_link'); /* ページネーション rel="index" */
remove_action('wp_head', 'rel_canonical'); /* canonical属性 */
remove_action('wp_head', 'wp_shortlink_wp_head'); /* 短縮URL */

/** =================================================================
* Remove Auto Inseted Codes from WordPress 4.4
* FYI: https://on-ze.com/archives/5127
* --------------------------------------------------------------- */

remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wp_oembed_add_host_js');


/** =================================================================
* Remove Auto Inseted Codes from WordPress 5.9
* FYI: https://github.com/WordPress/gutenberg/issues/38299
* --------------------------------------------------------------- */

// remove SVG and global styles
remove_action('wp_enqueue_scripts', 'wp_enqueue_global_styles');

// remove wp_footer actions which add's global inline styles
remove_action('wp_footer', 'wp_enqueue_global_styles', 1);

// remove render_block filters which adding unnecessary stuff
remove_filter('render_block', 'wp_render_duotone_support');
remove_filter('render_block', 'wp_restore_group_inner_container');
remove_filter('render_block', 'wp_render_layout_support_flag');

}
add_action('after_setup_theme', 'clean_up_auto_inserted_codes');

?>

--

--

💻 Web Design and Develop @ aguije inc. / 🏄‍♂️ Pro Web Surfer / ≡ adidas SAMBA / 🚲 VanMoofer / 🎮 Nintendo Addict / 🇯🇵 nipponcolors.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Takehiko Ono

Takehiko Ono

587 Followers

💻 Web Design and Develop @ aguije inc. / 🏄‍♂️ Pro Web Surfer / ≡ adidas SAMBA / 🚲 VanMoofer / 🎮 Nintendo Addict / 🇯🇵 nipponcolors.com