WC_Helper::get_helper_redirect_url()private staticWC 1.0

Get helper redirect URL.

Method of the class: WC_Helper{}

No Hooks.

Return

String.

Usage

$result = WC_Helper::get_helper_redirect_url( $args );
$args(array)
Query args.
Default: array()

WC_Helper::get_helper_redirect_url() code WC 8.9.0

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' )
	);
}