Wordpress-seo: Remove ad on post delete

Created on 2 Jul 2018  路  6Comments  路  Source: Yoast/wordpress-seo

I updated to the latest version of Yoast SEO and noticed that when you delete a post, from version 7.7.0 and above, a notification message was added which essentially is just an advert to buy the premium version. I totally understand the intention, but to unsuspecting users, this is just blatant spam.

The file it's located in is admin/watchers/class-slug-change-watcher.php.

Specifically this line within the register_hooks() function:

// Detect a post delete.
add_action( 'before_delete_post', array( $this, 'detect_post_delete' ) );

That calls this function when a post is binned (trashed) which adds the advertisement to the admin notices section of the dashboard.

    public function detect_post_delete( $post_id ) {
        if ( ! $this->is_post_viewable( $post_id ) ) {
            return;
        }

        /* translators: %1$s expands to the translated name of the post type. */
        $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $this->get_post_type_label( get_post_type( $post_id ) ) );
        $message        = $this->get_message( $first_sentence );

        $this->add_notification( $message );
    }

Please remove this, or at least change it so it's not as invasive as it currently is.


Edit:

Further to all of this, I spotted that this change was referenced in the change log (quite far down) as the following:

Adds a notification when a post is removed.

There was a notification when a post slug was changed to remind you to update the permalink in your redirects. This change seems to have somewhat replaced that old notice with this advert.

Most helpful comment

Same thing shows up on every bulk delete, are you that desperate? have some dignity please. People that want to buy premium will buy premium no need to shove your crap on people's throats on every chance. I'm seriously thinking on ditching Yoast altogether. Not that you care what people think obviously.

All 6 comments

Thank you for reporting this issue. We agree that we should not throw multiple warnings if you delete more than one post. We've already made sure that in the future update we will only show this message once on bulk deletion, that's addressed in #10203

Any news on this being fixed? When deleting large amounts of posts it create an incredibly long page, aside from the fact that deleting a post shows an advertisement.

Don't you think this is a bit too much, a bit heavy on the advertisements?

@danieltj27 - you should only receive one notification if you delete multiple posts with the last release of Yoast SEO. If not, could you please open a new issue with the steps to reproduce your issue?

Same thing shows up on every bulk delete, are you that desperate? have some dignity please. People that want to buy premium will buy premium no need to shove your crap on people's throats on every chance. I'm seriously thinking on ditching Yoast altogether. Not that you care what people think obviously.

Completely agree with @MediaMaquina, this is just useless, intrusive SPAM. Given the history of Yoast with how they handled spam in admin interfaces in the past, I'm not hopeful this will ever change.

I won't pay Yoast merely for removing their ads. Just developed a little solution, try this in your theme's functions.php:

/**
 * Removes YOAST SEO ads from WordPress Admin
 * Tested with Yoast SEO Version 14.4.1
 * 
 * @date 2020/06/25
 * @return void
 */
function remove_yoast_ads() {
  // check if class Yoast_Notification_Center exists
  if( !class_exists('Yoast_Notification_Center') ) return;
  $notification_center = Yoast_Notification_Center::get();
  // get all notifications
  $notifications = $notification_center->get_sorted_notifications();
  // loop through all YOAST notifications
  foreach( $notifications as $notification ) {
    // transform the notification to an array, so that we can access the message
    $notification_array = $notification->to_array();
    // get message from array
    $notification_message = $notification_array['message'] ?? null;
    // continue to next notification if no message in array
    if( !$notification_message ) continue;
    // Remove the notification if it contains a string. 
    // You could also check for $notification_array['options']['yoast_branding'] === true
    if( stripos($notification_message, 'Get Yoast SEO Premium') !== false ) {
      $notification_center->remove_notification($notification);
    }
  }
}
add_action('admin_notices', 'remove_yoast_ads', 8);

It basically removes all YOAST notices that contain the string 'Get Yoast SEO Premium' :)

Was this page helpful?
0 / 5 - 0 ratings