Add redirect to new In-App marketplace installer (#42010)
* Add redirect to new In-App marketplace installer * Update to shared redirect method * Add changelog * Add feature flag check * reuse get_helper_redirect_url * Remove debug code * Fix linter issues * Add linter exception --------- Co-authored-by: Bero <berislav.grgicak@gmail.com>
This commit is contained in:
parent
23ec020ed9
commit
56d038ff5f
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: add
|
||||
|
||||
Redirect users to new In-app marketplace installer if correct URL parameter is provided
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use Automattic\WooCommerce\Utilities\FeaturesUtil;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
|
@ -648,6 +649,8 @@ class WC_Helper {
|
|||
return;
|
||||
}
|
||||
|
||||
self::maybe_redirect_to_new_marketplace_installer();
|
||||
|
||||
if ( empty( $_GET['section'] ) || 'helper' !== $_GET['section'] ) {
|
||||
return;
|
||||
}
|
||||
|
@ -681,6 +684,29 @@ class WC_Helper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe redirect to the new Marketplace installer.
|
||||
*/
|
||||
private static function maybe_redirect_to_new_marketplace_installer() {
|
||||
// phpcs:disable WordPress.Security.NonceVerification.Recommended
|
||||
// Redirect requires the "install" URL parameter to be passed.
|
||||
if ( empty( $_GET['install'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_safe_redirect(
|
||||
self::get_helper_redirect_url(
|
||||
array(
|
||||
'page' => 'wc-addons',
|
||||
'section' => 'helper',
|
||||
),
|
||||
isset( $_GET['redirect-to-wc-admin'] ),
|
||||
sanitize_text_field( wp_unslash( $_GET['install'] ) )
|
||||
)
|
||||
);
|
||||
// phpcs:enable WordPress.Security.NonceVerification.Recommended
|
||||
}
|
||||
|
||||
/**
|
||||
* Get helper redirect URL.
|
||||
*
|
||||
|
@ -691,7 +717,14 @@ class WC_Helper {
|
|||
*/
|
||||
private static function get_helper_redirect_url( $args = array(), $redirect_to_wc_admin = false, $install_product_key = '' ) {
|
||||
global $current_screen;
|
||||
if ( true === $redirect_to_wc_admin && 'woocommerce_page_wc-addons' === $current_screen->id ) {
|
||||
if (
|
||||
'woocommerce_page_wc-addons' === $current_screen->id &&
|
||||
FeaturesUtil::feature_is_enabled( 'marketplace' ) &&
|
||||
(
|
||||
true === $redirect_to_wc_admin ||
|
||||
false === empty( $install_product_key )
|
||||
)
|
||||
) {
|
||||
$new_url = add_query_arg(
|
||||
array(
|
||||
'page' => 'wc-admin',
|
||||
|
|
Loading…
Reference in New Issue