Skip to content

Instantly share code, notes, and snippets.

@nielsvr
Created October 9, 2020 08:18
Show Gist options
  • Save nielsvr/7a9cd2a542622acc4826ac9e66e4ef03 to your computer and use it in GitHub Desktop.
Save nielsvr/7a9cd2a542622acc4826ac9e66e4ef03 to your computer and use it in GitHub Desktop.
Hide yoast notices and cleanup interface
<?php
/** Hide Yoast SEO alert from everywhere **/
if (is_plugin_active('wordpress-seo/wp-seo.php')) {
/* Remove HTML Comments */
add_action('get_header',function() { ob_start(function ($o) {
return preg_replace('/\n?<.*?Yoast SEO plugin.*?>/mi','',$o); }); });
add_action('wp_head',function() { ob_end_flush(); }, 999);
/* Disable Yoast SEO Notifications */
function ntp_disable_yoast_notifications() {
remove_action('admin_notices', array(Yoast_Notification_Center::get(), 'display_notifications'));
remove_action('all_admin_notices', array(Yoast_Notification_Center::get(), 'display_notifications'));
}
add_action('admin_init', 'ntp_disable_yoast_notifications');
/* Yoast SEO Low Priority */
function ntp_yoast_bottom() {
return 'low';
}
add_filter('wpseo_metabox_prio', 'ntp_yoast_bottom');
/* Disable screen after update */
function ntp_filter_yst_wpseo_option($option) {
if (is_array($option)) {
$option['seen_about'] = true;
}
return $option;
}
add_filter('option_wpseo', 'ntp_filter_yst_wpseo_option');
/* Remove Node in Toolbar */
function ntp_remove_yoast_bar($wp_admin_bar) {
$wp_admin_bar->remove_node('wpseo-menu');
}
add_action('admin_bar_menu', 'ntp_remove_yoast_bar', 99);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment