• Thanks for writing this useful plugin. I was testing it and found out that it does not display Yoast SEO notices in the notification center.

    On a fresh WordPress install if you activate WP Notification Center first and then activate Yoast SEO. All the notices added by Yoast SEO will appear on screen instead of notification center. Yoast SEO is widely used and many developers would like to see these notices nicely tucked away into notification center.

    here is a screenshot:
    https://cldup.com/3VTUK6YHay.png

    Another thing I noticed is that the notification center is not visible on Tablets and mobile screens. It would be nice if notices are displayed under an icon on smaller screens.

    Thanks,

    https://wordpress.org/plugins/wp-notification-center/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Barry Kooij

    (@barrykooij)

    Thanks, for reporting this! I’ll look into it!

    Same here. I think this is a great idea. But Yoast messages are still appearing in the admin area.

    The Yoast messages are exactly what I want to eliminate – they are so annoying. Please help! Thanks

    in AdminNoticeHandler.php add action all_admin_notices

    public function catch_admin_notices() {
    		add_action( 'in_admin_header', array( $this, 'parse_admin_notices' ), - 1 );
    		add_action( 'all_admin_notices', array( $this, 'parse_admin_notices' ), 9999 );
    	}

    in function parse_admin_notices() add some useful trim

    public parse_admin_noticesfunction () {
    								// notification message
    								$message = trim( strip_tags( $matches[2][0], '<strong><a>' ) );
    								$message = preg_replace('/class=".*?"/', '', $message);
    								$message = preg_replace("/<a[^>]*>[\s| ]*<\/a>/", '', $message);

    function.php

    add_action('admin_init', 'catch_yoast', 999);
    function catch_yoast() {
    
        $adminbar = (array) Yoast_Notification_Center::get();
        $notifications = $adminbar[chr(0) . 'Yoast_Notification_Center' . chr(0) . 'notifications'];
    
        $ids = array();
    
        foreach ( $notifications as $key => $notification ) {
    
            $id = $notification->get_id();
    
            if ( in_array( $id, $ids ) ) {
                unset( $notifications[ $key ] );
                continue;
            }
    
            $ids[] = $id;
        }
    
        $notifications = array_unique( $notifications );
    
        // Display notifications.
        if ( count( $notifications ) > 0 ) {
            foreach ( $notifications as $notification ) {
                add_action( 'admin_notices', function() use ($notification) { echo '<div class="updated">' . $notification->message . '</div>'; }, -1 );
            }
        }
    }
    
    add_action( 'plugins_loaded', 'yoast_notifications' );
            function 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'));
    
            }

    in wp-notification-center.css

    #wpadminbar #wp-admin-bar-wp-notification-center li a {
        display: inline;
        padding: 0;
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Yoast SEO Notifications’ is closed to new replies.