WPSEO_Upgrade::upgrade_49()
Removes the 'wpseo-dismiss-about' notice for every user that still has it.
Метод класса: WPSEO_Upgrade{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->upgrade_49();
Код WPSEO_Upgrade::upgrade_49() WPSEO Upgrade::upgrade 49 Yoast 22.1
private function upgrade_49() { global $wpdb; /* * Using a filter to remove the notification for the current logged in user. The notification center is * initializing the notifications before the upgrade routine has been executedd and is saving the stored * notifications on shutdown. This causes the returning notification. By adding this filter the shutdown * routine on the notification center will remove the notification. */ add_filter( 'yoast_notifications_before_storage', [ $this, 'remove_about_notice' ] ); $meta_key = $wpdb->get_blog_prefix() . Yoast_Notification_Center::STORAGE_KEY; $usermetas = $wpdb->get_results( $wpdb->prepare( ' SELECT user_id, meta_value FROM ' . $wpdb->usermeta . ' WHERE meta_key = %s AND meta_value LIKE %s ', $meta_key, '%wpseo-dismiss-about%' ), ARRAY_A ); if ( empty( $usermetas ) ) { return; } foreach ( $usermetas as $usermeta ) { $notifications = maybe_unserialize( $usermeta['meta_value'] ); foreach ( $notifications as $notification_key => $notification ) { if ( ! empty( $notification['options']['id'] ) && $notification['options']['id'] === 'wpseo-dismiss-about' ) { unset( $notifications[ $notification_key ] ); } } update_user_option( $usermeta['user_id'], Yoast_Notification_Center::STORAGE_KEY, array_values( $notifications ) ); } }