Created
March 15, 2022 12:47
-
-
Save lgedeon/7c9b6c60aebbba9bc4cf4e2a9585c1bb to your computer and use it in GitHub Desktop.
All the things you can hide in Yoast
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 | |
/** | |
* Remove Settings submenu in admin bar | |
*/ | |
add_action( | |
'admin_bar_menu', | |
function() { | |
global $wp_admin_bar; | |
$nodes = array_keys( $wp_admin_bar->get_nodes() ); | |
foreach ( $nodes as $node ) { | |
if ( false !== strpos( $node, 'wpseo' ) ) { | |
$wp_admin_bar->remove_node( $node ); | |
} | |
} | |
}, | |
999 | |
); | |
/** | |
* Remove dashboard widget | |
*/ | |
add_action( | |
'wp_dashboard_setup', | |
function() { | |
remove_meta_box( 'wpseo-dashboard-overview', 'dashboard', 'side' ); | |
} | |
); | |
/** | |
* Remove "Primary Category Feature" | |
*/ | |
add_filter( 'wpseo_primary_term_taxonomies', '__return_empty_array' ); | |
/** | |
* Remove Search Console | |
* | |
* @since v3.10.0 | |
*/ | |
add_action( | |
'admin_menu', | |
function () { | |
// Google has discontinued its Crawl Errors API so the Search Console page in Yoast is useless now; thanks [@Dibbyo456](https://github.com/senlin/so-clean-up-wp-seo/issues/69); @since v3.12.0 | |
remove_submenu_page( 'wpseo_dashboard', 'wpseo_search_console' ); | |
}, | |
999 | |
); | |
/** | |
* Removes the frontend HTML comments left by Yoast | |
*/ | |
add_filter( 'wpseo_debug_markers', '__return_false' ); | |
/** | |
* Remove admin columns | |
*/ | |
add_action( | |
'admin_menu', | |
function() { | |
$all_post_types = array_merge( [ 'post', 'page' ], get_post_types( [ '_builtin' => false ] ) ); | |
foreach ( $all_post_types as $post_type ) { | |
add_filter( | |
'manage_edit-' . $post_type . '_columns', | |
function ( $columns ) { | |
unset( $columns['wpseo-score'] ); | |
unset( $columns['wpseo-score-readability'] ); | |
unset( $columns['wpseo-title'] ); | |
unset( $columns['wpseo-metadesc'] ); | |
unset( $columns['wpseo-focuskw'] ); // focus keyword column | |
unset( $columns['wpseo-links'] ); // outgoing internal links column | |
unset( $columns['wpseo-linked'] ); | |
return $columns; | |
}, | |
10, | |
1 | |
); | |
} | |
}, | |
11 | |
); | |
/** | |
* Remove (as opposed to hide) SEO/readability Scores dropdown filters on edit posts screens | |
*/ | |
add_action( | |
'admin_init', | |
function () { | |
global $wpseo_meta_columns; | |
if ( $wpseo_meta_columns ) { | |
remove_action( 'restrict_manage_posts', [ $wpseo_meta_columns, 'posts_filter_dropdown' ] ); | |
remove_action( 'restrict_manage_posts', [ $wpseo_meta_columns, 'posts_filter_dropdown_readability' ] ); | |
} | |
}, | |
20 | |
); | |
/** | |
* CSS to hide the various options | |
* | |
* Todo: Move this to a css file after deciding what we actually want to hide. | |
*/ | |
add_action( | |
'admin_head', | |
function () { | |
echo '<style> | |
/* sidebar ads */ | |
#sidebar-container.wpseo_content_cell{display:none!important;} | |
/* tagline nag */ | |
#wpseo-dismiss-tagline-notice{display:none;} | |
/* robots nag */ | |
#wpseo-dismiss-blog-public-notice,#wpseo_advanced .error-message{display:none;} | |
/* hide upsell notice in Yoast SEO Dashboard */ | |
#yoast-warnings #wpseo-upsell-notice,#yoast-additional-keyphrase-collapsible-metabox,.wpseo-keyword-synonyms,.wpseo-multiple-keywords{display:none !important;} | |
/* hide premium upsell admin block */ | |
.yoast_premium_upsell,.yoast_premium_upsell_admin_block,#wpseo-local-seo-upsell,div[class^="SocialUpsell__PremiumInfoText"],.fBWRwy{display:none} | |
/* hide "Premium" submenu in its entirety include hiding "Workouts" submenu in its entirety */ | |
li#toplevel_page_wpseo_dashboard>ul>li:nth-child(6),li#toplevel_page_wpseo_dashboard>ul>li:nth-child(7){display:none;} | |
/* hide Post/Page/Taxonomy Deletion Premium Ad */ | |
body.edit-php .yoast-alert.notice.notice-warning,body.edit-tags-php .yoast-alert.notice.notice-warning{display:none;} | |
/* Problems/Notification boxes */ | |
.yoast-container.yoast-container__error{display:none;} | |
.yoast-container.yoast-container__warning{display:none;} | |
/* image warning nag */ | |
#yst_opengraph_image_warning{display:none;}#postimagediv.postbox{border:1px solid #e5e5e5!important;} | |
/* hide issue counter */ | |
#wpadminbar .yoast-issue-counter,#toplevel_page_wpseo_dashboard .wp-menu-name .update-plugins{display:none;} | |
/* hide Configuration Wizard on every screen in the Yoast admin */ | |
.yoast-alerts .yoast-container__configuration-wizard{display:none;} | |
/** | |
* Hide admin columns | |
*/ | |
/* seo score column */ | |
.column-wpseo-score,.column-wpseo_score{display:none;} | |
/* readability column */ | |
.column-wpseo-score-readability,.column-wpseo_score_readability{display:none;} | |
/* title column */ | |
.column-wpseo-title{display:none;} | |
/* meta description column */ | |
.column-wpseo-metadesc{display:none;} | |
/* focus keyword column */ | |
.column-wpseo-focuskw{display:none;} | |
/* outgoing internal links column */ | |
.column-wpseo-links{display:none;} | |
/* help center */ | |
.wpseo-tab-video__panel.wpseo-tab-video__panel--text,#tab-link-dashboard_dashboard__contact-support,#tab-link-dashboard_general__contact-support,#tab-link-dashboard_features__contact-support,#tab-link-dashboard_knowledge-graph__contact-support,#tab-link-dashboard_webmaster-tools__contact-support,#tab-link-dashboard_security__contact-support,#tab-link-metabox_metabox__contact-support,.yoast-video-tutorial__description:first-child,#yoast-helpscout-beacon{display:none;} /* @since v2.2.0 hide help center ad for premium version or help center entirely; @modified v2.5.5 hide email support/ad as it is a premium only feature; @modified v2.6.0 different tabs gave different classes; @modified v3.3.0 due to Yoast 5.6 update this has all changed; @modified v3.6.0; @modified v3.13.3 */ | |
.yoast-help-center__button{display:none !important;} | |
/* seo settings profile page */ | |
.profile-php .yoast.yoast-settings{display:none;} | |
/* hide content/keyword score on Publish/Update Post metabox */ | |
#misc-publishing-actions #content-score, | |
#misc-publishing-actions #keyword-score | |
{display:none;} | |
/* hide Premium ad after deleting content (post, page, wc product, cpt) */ | |
body.edit-php .yoast-notification.notice.notice-warning.is-dismissible, | |
body[class*="taxonomy-"] .yoast-notification.notice.notice-warning.is-dismissible | |
{display:none;} | |
</style>'; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment