Yoast\WP\SEO\Alerts\Application\Default_SEO_Data
Default_SEO_Data_Alert::add_notifications
Adds notifications (when necessary).
We want to show this notification only when there are enough posts that have the default SEO title or meta description, or both. If this is not the case we will not show the notification at all since it does not serve a purpose yet.
Метод класса: Default_SEO_Data_Alert{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$Default_SEO_Data_Alert = new Default_SEO_Data_Alert(); $Default_SEO_Data_Alert->add_notifications();
Код Default_SEO_Data_Alert::add_notifications() Default SEO Data Alert::add notifications Yoast 28.9
public function add_notifications() {
if ( ! $this->indexable_helper->should_index_indexables() ) {
// Do not show the notification when indexables are disabled.
$this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID );
return;
}
if ( ! $this->post_type_helper->is_indexable( 'post' ) || ! $this->post_type_helper->has_metabox( 'post' ) ) {
// Do not show the notification when posts are not indexable or have no metabox.
$this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID );
return;
}
$posts_with_default_seo_title = $this->default_seo_data_collector->get_posts_with_default_seo_title();
$posts_with_default_seo_description = $this->default_seo_data_collector->get_posts_with_default_seo_description();
$has_enough_posts_with_default_title = \count( $posts_with_default_seo_title ) > 4;
$has_enough_posts_with_default_desc = \count( $posts_with_default_seo_description ) > 4;
if ( ! $has_enough_posts_with_default_title && ! $has_enough_posts_with_default_desc ) {
$this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID );
return;
}
$notification = $this->get_default_seo_data_notification( $has_enough_posts_with_default_title, $has_enough_posts_with_default_desc );
$this->notification_center->add_notification( $notification );
}