Automattic\WooCommerce\Internal\Admin\Notes

ExtensionsWithoutSubscription::get_note │ public static │ WC 11.3.0

Get the note.

Метод класса: ExtensionsWithoutSubscription{}

Хуков нет.

Возвращает

Note|null.

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

$result = ExtensionsWithoutSubscription::get_note();

Список изменений

С версии 11.3.0 Введена.

Код ExtensionsWithoutSubscription::get_note() WC 11.3.0

public static function get_note() {
	$plugins = self::get_plugins();
	if ( empty( $plugins ) ) {
		return null;
	}

	if ( 1 === count( $plugins ) ) {
		$title = sprintf(
			/* translators: %s: extension name */
			__( '%s doesn\'t have an active subscription', 'woocommerce' ),
			wp_strip_all_tags( current( $plugins )['Name'] )
		);
		$content = __( 'Without one, it won\'t receive security updates, product improvements, or support. Subscribe on WooCommerce.com to keep it protected.', 'woocommerce' );
	} else {
		$title   = __( 'Some of your extensions don\'t have an active subscription', 'woocommerce' );
		$content = __( 'Without one, they won\'t receive security updates, product improvements, or support. Subscribe on WooCommerce.com to keep them protected.', 'woocommerce' );
	}

	$note = new Note();
	$note->set_title( $title );
	$note->set_content( $content );
	$note->set_content_data( (object) array( 'plugins' => array_keys( $plugins ) ) );
	$note->set_type( Note::E_WC_ADMIN_NOTE_WARNING );
	$note->set_name( self::NOTE_NAME );
	$note->set_source( 'woocommerce-admin' );
	$note->add_action(
		'subscribe',
		__( 'Subscribe', 'woocommerce' ),
		add_query_arg(
			array(
				'page'         => 'wc-admin',
				'tab'          => 'my-subscriptions',
				'path'         => rawurlencode( '/extensions' ),
				'utm_source'   => 'inbox_notification',
				'utm_campaign' => 'pu_inbox_purchase',
			),
			admin_url( 'admin.php' )
		)
	);

	return $note;
}