WC_Helper::_helper_subscription_activate()private staticWC 1.0

Active a product subscription.

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

Хуков нет.

Возвращает

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

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

$result = WC_Helper::_helper_subscription_activate();

Код WC_Helper::_helper_subscription_activate() WC 8.7.0

private static function _helper_subscription_activate() {
	$product_key = isset( $_GET['wc-helper-product-key'] ) ? wc_clean( wp_unslash( $_GET['wc-helper-product-key'] ) ) : '';
	$product_id  = isset( $_GET['wc-helper-product-id'] ) ? absint( $_GET['wc-helper-product-id'] ) : 0;

	if ( empty( $_GET['wc-helper-nonce'] ) || ! wp_verify_nonce( wp_unslash( $_GET['wc-helper-nonce'] ), 'activate:' . $product_key ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		self::log( 'Could not verify nonce in _helper_subscription_activate' );
		wp_die( 'Could not verify nonce' );
	}

	try {
		$activated = self::activate_helper_subscription( $product_key, $product_id );
	} catch ( Exception $e ) {
		$activated = false;
	}

	$redirect_uri = add_query_arg(
		array(
			'page'                 => 'wc-addons',
			'section'              => 'helper',
			'filter'               => self::get_current_filter(),
			'wc-helper-status'     => $activated ? 'activate-success' : 'activate-error',
			'wc-helper-product-id' => $product_id,
		),
		admin_url( 'admin.php' )
	);

	wp_safe_redirect( $redirect_uri );
	die();
}