PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 8.0
Jetpack – WP Security, Backup, Speed, & Growth v8.0
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / _inc / lib / debugger / debug-functions.php

debug-functions.php in Jetpack – WP Security, Backup, Speed, & Growth 8.0, at _inc/lib/debugger/debug-functions.php

93 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WP Site Health functionality temporarily stored in this file until all of Jetpack is PHP 5.3+
4 *
5 * @package Jetpack.
6 */
7
8 /**
9 * Test runner for Core's Site Health module.
10 *
11 * @since 7.3.0
12 */
13 function jetpack_debugger_ajax_local_testing_suite() {
14 check_ajax_referer( 'health-check-site-status' );
15 if ( ! current_user_can( 'jetpack_manage_modules' ) ) {
16 wp_send_json_error();
17 }
18 $tests = new Jetpack_Cxn_Tests();
19 wp_send_json_success( $tests->output_results_for_core_async_site_health() );
20 }
21 /**
22 * Adds the Jetpack Local Testing Suite to the Core Site Health system.
23 *
24 * @since 7.3.0
25 *
26 * @param array $core_tests Array of tests from Core's Site Health.
27 *
28 * @return array $core_tests Array of tests for Core's Site Health.
29 */
30 function jetpack_debugger_site_status_tests( $core_tests ) {
31 $cxn_tests = new Jetpack_Cxn_Tests();
32 $tests = $cxn_tests->list_tests( 'direct' );
33 foreach ( $tests as $test ) {
34 $core_tests['direct'][ $test['name'] ] = array(
35 'label' => __( 'Jetpack: ', 'jetpack' ) . $test['name'],
36 'test' => function() use ( $test, $cxn_tests ) { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewClosure.Found
37 $results = $cxn_tests->run_test( $test['name'] );
38 // Test names are, by default, `test__some_string_of_text`. Let's convert to "Some String Of Text" for humans.
39 $label = ucwords(
40 str_replace(
41 '_',
42 ' ',
43 str_replace( 'test__', '', $test['name'] )
44 )
45 );
46 $return = array(
47 'label' => $label,
48 'status' => 'good',
49 'badge' => array(
50 'label' => __( 'Jetpack', 'jetpack' ),
51 'color' => 'green',
52 ),
53 'description' => sprintf(
54 '<p>%s</p>',
55 __( 'This test successfully passed!', 'jetpack' )
56 ),
57 'actions' => '',
58 'test' => 'jetpack_' . $test['name'],
59 );
60 if ( is_wp_error( $results ) ) {
61 return;
62 }
63 if ( false === $results['pass'] ) {
64 $return['label'] = $results['message'];
65 $return['status'] = $results['severity'];
66 $return['description'] = sprintf(
67 '<p>%s</p>',
68 $results['resolution']
69 );
70 if ( ! empty( $results['action'] ) ) {
71 $return['actions'] = sprintf(
72 '<a class="button button-primary" href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
73 esc_url( $results['action'] ),
74 __( 'Resolve', 'jetpack' ),
75 /* translators: accessibility text */
76 __( '(opens in a new tab)', 'jetpack' )
77 );
78 }
79 }
80
81 return $return;
82 },
83 );
84 }
85 $core_tests['async']['jetpack_test_suite'] = array(
86 'label' => __( 'Jetpack Tests', 'jetpack' ),
87 'test' => 'jetpack_local_testing_suite',
88 );
89
90 return $core_tests;
91 }
92
93