WC_Helper::get_helper_redirect_url()private staticWC 1.0

Get helper redirect URL.

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

Хуков нет.

Возвращает

Строку.

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

$result = WC_Helper::get_helper_redirect_url( $args );
$args(массив)
Query args.
По умолчанию: array()

Код WC_Helper::get_helper_redirect_url() WC 9.4.2

private static function get_helper_redirect_url( $args = array() ) {
	global $current_screen;

	// phpcs:disable WordPress.Security.NonceVerification.Recommended
	$redirect_admin_url = isset( $_GET['redirect_admin_url'] )
		? esc_url_raw(
			urldecode(
				// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
				wp_unslash( $_GET['redirect_admin_url'] )
			)
		)
		: '';
	$install_product_key = isset( $_GET['install'] ) ? sanitize_text_field( wp_unslash( $_GET['install'] ) ) : '';
	// phpcs:enable WordPress.Security.NonceVerification.Recommended

	if (
		'woocommerce_page_wc-addons' === $current_screen->id &&
		FeaturesUtil::feature_is_enabled( 'marketplace' ) &&
		(
			false === empty( $redirect_admin_url ) ||
			false === empty( $install_product_key )
		)
	) {
		if ( strpos( $redirect_admin_url, admin_url( 'admin.php' ) ) === 0 ) {
			$new_url = $redirect_admin_url;
		} else {
			$new_url = add_query_arg(
				array(
					'page' => 'wc-admin',
					'tab'  => 'my-subscriptions',
					'path' => rawurlencode( '/extensions' ),
				),
				admin_url( 'admin.php' )
			);
		}

		if ( ! empty( $install_product_key ) ) {
			$new_url = add_query_arg(
				array(
					'install' => $install_product_key,
				),
				$new_url
			);
		}
		return $new_url;
	}

	return add_query_arg(
		$args,
		admin_url( 'admin.php' )
	);
}