WC_Admin_Post_Types::maybe_display_warning_for_password_protected_coupon()privateWC 9.2.0

Shows a warning when editing a password-protected coupon.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->maybe_display_warning_for_password_protected_coupon();

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

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

Код WC_Admin_Post_Types::maybe_display_warning_for_password_protected_coupon() WC 9.4.2

private function maybe_display_warning_for_password_protected_coupon() {
	if ( ! function_exists( 'get_current_screen' ) || 'shop_coupon' !== get_current_screen()->id ) {
		return;
	}

	if ( ! isset( $GLOBALS['post'] ) || 'shop_coupon' !== $GLOBALS['post']->post_type ) {
		return;
	}

	wp_admin_notice(
		__(
			'This coupon is password protected. WooCommerce does not support password protection for coupons. You can temporarily hide a coupon by making it private. Alternatively, usage limits and restrictions can be configured below.',
			'woocommerce'
		),
		array(
			'type'               => 'warning',
			'id'                 => 'wc-password-protected-coupon-warning',
			'additional_classes' => empty( $GLOBALS['post']->post_password ) ? array( 'hidden' ) : array(),
		)
	);
}