| @@ -1,29 +1,34 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * WP Site Health debugging functions. |
| 4 | 4 | * |
| 5 | + * @deprecated 15.9 Site Health integration is now handled by the connection package. | |
| 5 | 6 | * @package automattic/jetpack |
| 6 | 7 | */ |
| 7 | 8 | |
| 8 | -use Automattic\Jetpack\Sync\Modules; | |
| 9 | 9 | /** |
| 10 | 10 | * Test runner for Core's Site Health module. |
| 11 | 11 | * |
| 12 | 12 | * @since 7.3.0 |
| 13 | + * @deprecated 15.9 Use Automattic\Jetpack\Connection\Site_Health instead. | |
| 13 | 14 | */ |
| 14 | 15 | function jetpack_debugger_ajax_local_testing_suite() { |
| 16 | + _deprecated_function( __FUNCTION__, 'jetpack-15.9' ); | |
| 15 | 17 | check_ajax_referer( 'health-check-site-status' ); |
| 16 | 18 | if ( ! current_user_can( 'jetpack_manage_modules' ) ) { |
| 17 | - wp_send_json_error(); | |
| 19 | + // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int. | |
| 20 | + wp_send_json_error( null, null, JSON_UNESCAPED_SLASHES ); | |
| 18 | 21 | } |
| 19 | - $tests = new Jetpack_Cxn_Tests(); | |
| 20 | - wp_send_json_success( $tests->output_results_for_core_async_site_health() ); | |
| 22 | + $tests = new Automattic\Jetpack\Connection\Connection_Health_Tests(); | |
| 23 | + // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- It takes null, but its phpdoc only says int. | |
| 24 | + wp_send_json_success( $tests->output_results_for_core_async_site_health(), null, JSON_UNESCAPED_SLASHES ); | |
| 21 | 25 | } |
| 22 | 26 | /** |
| 23 | 27 | * Adds the Jetpack Local Testing Suite to the Core Site Health system. |
| 24 | 28 | * |
| 25 | 29 | * @since 7.3.0 |
| 30 | + * @deprecated 15.9 Use Automattic\Jetpack\Connection\Site_Health instead. | |
| 26 | 31 | * |
| 27 | 32 | * @param array $core_tests Array of tests from Core's Site Health. |
| 28 | 33 | * |
| 29 | 34 | * @return array $core_tests Array of tests for Core's Site Health. |
| @@ -28,9 +33,10 @@ | ||
| 28 | 33 | * |
| 29 | 34 | * @return array $core_tests Array of tests for Core's Site Health. |
| 30 | 35 | */ |
| 31 | 36 | function jetpack_debugger_site_status_tests( $core_tests ) { |
| 32 | - $cxn_tests = new Jetpack_Cxn_Tests(); | |
| 37 | + _deprecated_function( __FUNCTION__, 'jetpack-15.9' ); | |
| 38 | + $cxn_tests = new Automattic\Jetpack\Connection\Connection_Health_Tests(); | |
| 33 | 39 | $tests = $cxn_tests->list_tests( 'direct' ); |
| 34 | 40 | foreach ( $tests as $test ) { |
| 35 | 41 | |
| 36 | 42 | $core_tests['direct'][ $test['name'] ] = array( |
| @@ -37,10 +43,10 @@ | ||
| 37 | 43 | 'label' => __( 'Jetpack: ', 'jetpack' ) . $test['name'], |
| 38 | 44 | /** |
| 39 | 45 | * Callable for Core's Site Health system to execute. |
| 40 | 46 | * |
| 41 | - * @param array $test A Jetpack Testing Suite test array. | |
| 42 | - * @param Jetpack_Cxn_Tests $cxn_tests An instance of the Jetpack Test Suite. | |
| 47 | + * @var array $test A Jetpack Testing Suite test array. | |
| 48 | + * @var Automattic\Jetpack\Connection\Connection_Health_Tests $cxn_tests An instance of the connection test suite. | |
| 43 | 49 | * |
| 44 | 50 | * @return array { |
| 45 | 51 | * A results array to match the format expected by WordPress Core. |
| 46 | 52 | * |
| @@ -115,79 +121,5 @@ | ||
| 115 | 121 | 'test' => 'jetpack_local_testing_suite', |
| 116 | 122 | ); |
| 117 | 123 | |
| 118 | 124 | return $core_tests; |
| 119 | -} | |
| 120 | - | |
| 121 | -/** | |
| 122 | - * Loads site health scripts if we are on the site health page. | |
| 123 | - * | |
| 124 | - * @param string $hook The current admin page hook. | |
| 125 | - */ | |
| 126 | -function jetpack_debugger_enqueue_site_health_scripts( $hook ) { | |
| 127 | - if ( 'site-health.php' === $hook ) { | |
| 128 | - $full_sync_module = Modules::get_module( 'full-sync' ); | |
| 129 | - $progress_percent = $full_sync_module ? $full_sync_module->get_sync_progress_percentage() : false; | |
| 130 | - | |
| 131 | - $ajax_nonce = wp_create_nonce( 'jetpack-site-health' ); | |
| 132 | - | |
| 133 | - $wp_scripts = wp_scripts(); | |
| 134 | - wp_enqueue_script( 'jquery-ui-progressbar' ); | |
| 135 | - wp_enqueue_script( | |
| 136 | - 'jetpack_debug_site_health_script', | |
| 137 | - plugins_url( 'jetpack-debugger-site-health.js', __FILE__ ), | |
| 138 | - array( 'jquery', 'jquery-ui-progressbar' ), | |
| 139 | - JETPACK__VERSION, | |
| 140 | - false | |
| 141 | - ); | |
| 142 | - wp_enqueue_style( | |
| 143 | - 'jetpack_debug_site_health_styles', | |
| 144 | - plugins_url( 'jetpack-debugger-site-health.css', __FILE__ ), | |
| 145 | - false, | |
| 146 | - JETPACK__VERSION, | |
| 147 | - false | |
| 148 | - ); | |
| 149 | - /* WordPress is not bundled with jquery UI styles - we need to grab them from the Google API. */ | |
| 150 | - wp_enqueue_style( | |
| 151 | - 'jetpack-jquery-ui-styles', | |
| 152 | - 'https://code.jquery.com/ui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.min.css', | |
| 153 | - false, | |
| 154 | - JETPACK__VERSION, | |
| 155 | - false | |
| 156 | - ); | |
| 157 | - wp_localize_script( | |
| 158 | - 'jetpack_debug_site_health_script', | |
| 159 | - 'jetpackSiteHealth', | |
| 160 | - array( | |
| 161 | - 'ajaxUrl' => admin_url( 'admin-ajax.php' ), | |
| 162 | - 'syncProgressHeading' => __( 'Jetpack is performing a sync of your site', 'jetpack' ), | |
| 163 | - 'progressPercent' => $progress_percent, | |
| 164 | - 'fullSyncNonce' => $ajax_nonce, | |
| 165 | - ) | |
| 166 | - ); | |
| 167 | - } | |
| 168 | -} | |
| 169 | - | |
| 170 | -/** | |
| 171 | - * Responds to ajax calls from the site health page. Echos a full sync percantage to update progress bar. | |
| 172 | - */ | |
| 173 | -function jetpack_debugger_sync_progress_ajax() { | |
| 174 | - $full_sync_module = Modules::get_module( 'full-sync' ); | |
| 175 | - $progress_percent = $full_sync_module ? $full_sync_module->get_sync_progress_percentage() : null; | |
| 176 | - if ( ! $progress_percent ) { | |
| 177 | - echo 'done'; | |
| 178 | - wp_die(); | |
| 179 | - } | |
| 180 | - echo (int) $progress_percent; | |
| 181 | - wp_die(); | |
| 182 | -} | |
| 183 | - | |
| 184 | -/** | |
| 185 | - * Responds to ajax calls from the site health page. Triggers a Full Sync | |
| 186 | - */ | |
| 187 | -function jetpack_debugger_full_sync_start() { | |
| 188 | - check_ajax_referer( 'jetpack-site-health', 'site-health-nonce' ); | |
| 189 | - $full_sync_module = Modules::get_module( 'full-sync' ); | |
| 190 | - $full_sync_module->start(); | |
| 191 | - echo 'requested'; | |
| 192 | - wp_die(); | |
| 193 | 125 | } |