WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

Automattic\WooCommerce\Admin\Notes

NavigationNudge{} WC 1.0

Navigation Nudge.

Хуков нет.

Возвращает

null. Ничего.

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

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

Методы

  1. __construct()
  2. action_note( $old_value, $value )
  3. get_note()

Код NavigationNudge{} WC 5.4.1

<?php
class NavigationNudge {
	/**
	 * Note traits.
	 */
	use NoteTraits;

	/**
	 * Name of the note for use in the database.
	 */
	const NOTE_NAME = 'wc-admin-navigation-nudge';

	/**
	 * Attach hooks.
	 */
	public function __construct() {
		add_action( 'update_option_' . Navigation::TOGGLE_OPTION_NAME, array( $this, 'action_note' ), 10, 2 );
	}

	/**
	 * Get the note.
	 *
	 * @return Note
	 */
	public static function get_note() {
		if ( Features::is_enabled( 'navigation' ) || ! Features::exists( 'navigation' ) ) {
			return;
		}

		$note = new Note();
		$note->set_title( __( 'You now have access to the WooCommerce navigation', 'woocommerce' ) );
		$note->set_content( __( 'We’re introducing a new navigation for a more intuitive and improved user experience. You can enable the beta version of the new experience in the Advanced Settings. Enable it now for your store.', 'woocommerce' ) );
		$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
		$note->set_name( self::NOTE_NAME );
		$note->set_source( 'woocommerce-admin' );
		$note->add_action(
			'enable-navigation',
			__( 'Enable in Settings', 'woocommerce' ),
			admin_url( 'admin.php?page=wc-settings&tab=advanced&section=features' )
		);
		return $note;
	}

	/**
	 * Actions the note when the option is toggled.
	 *
	 * @param string $old_value Old value.
	 * @param string $value     New value.
	 */
	public static function action_note( $old_value, $value ) {
		if ( 'yes' !== $value ) {
			return;
		}

		$data_store = \WC_Data_Store::load( 'admin-note' );
		$note_ids   = $data_store->get_notes_with_name( self::NOTE_NAME );

		if ( ! empty( $note_ids ) ) {
			$note = Notes::get_note( $note_ids[0] );

			if ( Note::E_WC_ADMIN_NOTE_ACTIONED === $note->get_status() ) {
				return;
			}

			$note->set_status( Note::E_WC_ADMIN_NOTE_ACTIONED );
			$note->save();
		}

	}
}