WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
класс не описан

WPSEO_Schema_Person_Upgrade_Notification{} Yoast 1.0

Notifies the user to update the Person on the publish entity in the Configuration Wizard.

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WPSEO_Schema_Person_Upgrade_Notification = new WPSEO_Schema_Person_Upgrade_Notification();
// use class methods

Методы

  1. register_hooks()
  2. handle_notification()
  3. add_notification()
  4. remove_notification()
  5. get_notification()

Код WPSEO_Schema_Person_Upgrade_Notification{} Yoast 15.2

<?php
class WPSEO_Schema_Person_Upgrade_Notification implements WPSEO_WordPress_Integration {

	/**
	 * Registers all hooks to WordPress
	 *
	 * @return void
	 */
	public function register_hooks() {
		add_action( 'admin_init', [ $this, 'handle_notification' ] );
	}

	/**
	 * Handles if the notification should be added or removed.
	 */
	public function handle_notification() {
		$company_or_person_user_id = WPSEO_Options::get( 'company_or_person_user_id', false );
		if ( WPSEO_Options::get( 'company_or_person' ) === 'person' && empty( $company_or_person_user_id ) ) {
			$this->add_notification();
			return;
		}

		$this->remove_notification();
	}

	/**
	 * Adds a notification to the notification center.
	 */
	protected function add_notification() {
		$notification_center = Yoast_Notification_Center::get();
		$notification_center->add_notification( $this->get_notification() );
	}

	/**
	 * Removes a notification to the notification center.
	 */
	protected function remove_notification() {
		$notification_center = Yoast_Notification_Center::get();
		$notification_center->remove_notification( $this->get_notification() );
	}

	/**
	 * Gets the notification object.
	 *
	 * @return Yoast_Notification
	 */
	protected function get_notification() {
		$message = sprintf(
			/* translators: %1$s is a link start tag to the Configuration Wizard, %2$s is the link closing tag. */
			__( 'You have previously set your site to represent a person. We’ve improved our functionality around Schema and the Knowledge Graph, so you should go in and %1$scomplete those settings%2$s.', 'wordpress-seo' ),
			'<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_titles' ) ) . '">',
			'</a>'
		);

		$notification = new Yoast_Notification(
			$message,
			[
				'type'         => Yoast_Notification::WARNING,
				'id'           => 'wpseo-schema-person-upgrade',
				'capabilities' => 'wpseo_manage_options',
				'priority'     => 0.8,
			]
		);

		return $notification;
	}
}