Skip to content

Instantly share code, notes, and snippets.

@strsar
Last active December 1, 2021 01:36
Show Gist options
  • Save strsar/5db5f5e3ea3b9f39963d919ae855ac86 to your computer and use it in GitHub Desktop.
Save strsar/5db5f5e3ea3b9f39963d919ae855ac86 to your computer and use it in GitHub Desktop.
[WP] F*** off to Yoast defaults...
/*
* Yoast SEO Add additional separators to %sep%
* Needed to add pipe "|" back since v17.1
*/
add_filter('wpseo_separator_options', function($separators) {
$additional = array('|');
$separators = array_unique(array_merge($separators, $additional));
return $separators;
}, 10 , 1);
/*
* Yoast SEO Disable Redirect Notifications for
* Posts or Pages: Moved to Trash
*/
add_filter('wpseo_enable_notification_post_trash', '__return_false');
/*
* Yoast SEO Disable Redirect Notifications for
* Posts and Pages: Change URL
*/
add_filter('wpseo_enable_notification_post_slug_change', '__return_false');
/*
* Yoast SEO Disable Redirect Notifications for
* Taxonomies: Moved to Trash
*/
add_filter('wpseo_enable_notification_term_delete','__return_false');
/*
* Yoast SEO Disable Redirect Notifications for
* Taxonomies: Change URL
*/
add_filter('wpseo_enable_notification_term_slug_change','__return_false');
/**
* Disable yoast notifications
*/
add_action('admin_init', 'disable_yoast_notifications', 999);
function disable_yoast_notifications() {
if(class_exists('Yoast_Notification_Center')) {
$notification_center = Yoast_Notification_Center::get();
$notification_center->deactivate_hook();
//remove_action('admin_notices', array($notification_center, 'display_notifications'));
//remove_action('all_admin_notices', array($notification_center, 'display_notifications'));
// Remove all yoast notifications
//$notifications = $notification_center->get_notifications_for_user(get_current_user_id());
//if(!empty($notifications)) {
// foreach($notifications as $notification){
// $notification_center->remove_notification($notification);
// }
//}
//update_user_meta(get_current_user_id(), 'wpseo_ignore_tour', true);
//update_user_meta(get_current_user_id(), 'wpseo-upsell-notice', true);
//update_user_meta(get_current_user_id(), 'wpseo-dismiss-gsc', true);
}
}
/**
* Hide yoast garbage via css : (
*/
add_filter('admin_head', 'hide_yoast_with_styles', 999);
function hide_yoast_with_styles() {
echo "<style>
#adminmenu .toplevel_page_wpseo_dashboard ul li a[href='admin.php?page=wpseo_licenses'],
#yoast-helpscout-beacon, .yoast_premium_upsell,
.wp-admin.toplevel_page_wpseo_dashboard .yoast-sidebar,
.wp-admin.seo_page_wpseo_titles .yoast-sidebar,
.wp-admin.seo_page_wpseo_search_console .yoast-sidebar,
.wp-admin.seo_page_wpseo_social .yoast-sidebar,
.wp-admin.seo_page_wpseo_tools .yoast-sidebar {display:none}
</style>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment