diff --git a/includes/classes/AdminNotices.php b/includes/classes/AdminNotices.php index 34e57121bf..da03b779eb 100644 --- a/includes/classes/AdminNotices.php +++ b/includes/classes/AdminNotices.php @@ -175,11 +175,7 @@ protected function process_auto_activate_sync_notice() { return false; } - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - $url = admin_url( 'network/admin.php?page=elasticpress-sync&do_sync=features' ); - } else { - $url = admin_url( 'admin.php?page=elasticpress-sync&do_sync=features' ); - } + $url = Utils\get_sync_url( 'features' ); $feature = Features::factory()->get_registered_feature( $auto_activate_sync ); @@ -250,11 +246,7 @@ protected function process_upgrade_sync_notice() { return false; } - if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { - $url = admin_url( 'network/admin.php?page=elasticpress-sync&do_sync=upgrade' ); - } else { - $url = admin_url( 'admin.php?page=elasticpress-sync&do_sync=upgrade' ); - } + $url = Utils\get_sync_url( 'upgrade' ); if ( defined( 'EP_DASHBOARD_SYNC' ) && ! EP_DASHBOARD_SYNC ) { $html = esc_html__( 'Dashboard sync is disabled. The new version of ElasticPress requires that you delete all data and start a fresh sync using WP-CLI.', 'elasticpress' ); diff --git a/includes/partials/install-page.php b/includes/partials/install-page.php index 5e1320415c..883819e43d 100644 --- a/includes/partials/install-page.php +++ b/includes/partials/install-page.php @@ -12,14 +12,14 @@ if ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) { $setup_url = admin_url( 'network/admin.php?page=elasticpress-settings' ); - $sync_url = admin_url( 'network/admin.php?page=elasticpress-sync&do_sync=install' ); $dashboard_url = admin_url( 'network/admin.php?page=elasticpress' ); } else { $setup_url = admin_url( 'admin.php?page=elasticpress-settings' ); - $sync_url = admin_url( 'admin.php?page=elasticpress-sync&do_sync=install' ); $dashboard_url = admin_url( 'admin.php?page=elasticpress' ); } +$sync_url = \ElasticPress\Utils\get_sync_url( 'install' ); + $skip_install_url = add_query_arg( [ 'ep-skip-install' => 1, diff --git a/includes/utils.php b/includes/utils.php index b4f9ffb45b..e066f143a8 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -767,13 +767,17 @@ function get_asset_info( $slug, $attribute = null ) { * Return the Sync Page URL. * * @since 4.4.0 - * @param boolean $do_sync Whether the link should or should not start a resync. + * @param boolean|string $do_sync Whether the link should or should not start a resync. Pass a string to store the reason of the resync. * @return string */ -function get_sync_url( bool $do_sync = false ) : string { +function get_sync_url( $do_sync = false ) : string { $page = 'admin.php?page=elasticpress-sync'; if ( $do_sync ) { - $page .= '&do_sync&ep_sync_nonce=' . wp_create_nonce( 'ep_sync_nonce' ); + $page .= '&do_sync'; + if ( is_string( $do_sync ) ) { + $page .= '=' . rawurlencode( $do_sync ); + } + $page .= '&ep_sync_nonce=' . wp_create_nonce( 'ep_sync_nonce' ); } return ( defined( 'EP_IS_NETWORK' ) && EP_IS_NETWORK ) ? network_admin_url( $page ) :