Completed
Push — update/masterbar-rm-left-nav ( 7930b3...ec0ec1 )
by Jeremy
13:33 queued 06:04
created

0-load.php ➔ jetpack_debugger_ajax_local_testing_suite()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Loading the various functions used for Jetpack Debugging.
4
 *
5
 * @package Jetpack.
6
 */
7
8
/* Jetpack Connection Testing Framework */
9
require_once 'class-jetpack-cxn-test-base.php';
10
/* Jetpack Connection Tests */
11
require_once 'class-jetpack-cxn-tests.php';
12
13
/* Jetpack Debug Data */
14
require_once 'class-jetpack-debug-data.php';
15
/* The "In-Plugin Debugger" admin page. */
16
require_once 'class-jetpack-debugger.php';
17
18
add_filter( 'debug_information', array( 'Jetpack_Debug_Data', 'core_debug_data' ) );
19
add_filter( 'site_status_tests', 'jetpack_debugger_site_status_tests' );
20
add_action( 'wp_ajax_health-check-jetpack-local_testing_suite', 'jetpack_debugger_ajax_local_testing_suite' );
21
22
/**
23
 * Test runner for Core's Site Health module.
24
 *
25
 * @since 7.3.0
26
 */
27
function jetpack_debugger_ajax_local_testing_suite() {
28
	check_ajax_referer( 'health-check-site-status' );
29
	if ( ! current_user_can( 'jetpack_manage_modules' ) ) {
30
		wp_send_json_error();
31
	}
32
	$tests = new Jetpack_Cxn_Tests();
33
	wp_send_json_success( $tests->output_results_for_core_site_health() );
34
}
35
36
/**
37
 * Adds the Jetpack Local Testing Suite to the Core Site Health system.
38
 *
39
 * @since 7.3.0
40
 *
41
 * @param array $tests Array of tests from Core's Site Health.
42
 *
43
 * @return array $tests Array of tests for Core's Site Health.
44
 */
45
function jetpack_debugger_site_status_tests( $tests ) {
46
	$tests['async']['jetpack_test_suite'] = array(
47
		'label' => __( 'Jetpack Tests', 'jetpack' ),
48
		'test'  => 'jetpack_local_testing_suite',
49
	);
50
51
	return $tests;
52
}
53