blob: fc1e3751127a2feb1c57f7529745caa45f0a0cb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
/**
* WordAds Admin.
*
* @package automattic/jetpack
*/
/**
* The standard set of admin pages for the user if Jetpack is installed
*/
class WordAds_Admin {
/**
* WordAds_Admin Constructor.
*
* @since 4.5.0
*/
public function __construct() {
if ( current_user_can( 'manage_options' ) && isset( $_GET['ads_debug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
WordAds_API::update_wordads_status_from_api();
add_action( 'admin_notices', array( $this, 'debug_output' ) );
}
}
/**
* Output the API connection debug
*
* @since 4.5.0
*/
public function debug_output() {
global $wordads, $wordads_status_response;
$response = $wordads_status_response;
if ( empty( $response ) ) {
$response = 'No response from API :(';
} else {
$response = print_r( $response, 1 ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
}
$status = $wordads->option( 'wordads_approved' ) ?
array(
'color' => 'green',
'approved' => 'Yes',
) :
array(
'color' => 'red',
'approved' => 'No',
);
$type = $wordads->option( 'wordads_approved' ) ? 'updated' : 'error';
?>
<div class="notice <?php echo esc_attr( $type ); ?> is-dismissible">
<p>Status: <span style="color:<?php echo esc_attr( $status['color'] ); ?>;"><?php echo esc_html( $status ); ?></p>
<pre><?php echo esc_html( $response ); ?></pre>
</div>
<?php
}
}
global $wordads_admin;
$wordads_admin = new WordAds_Admin();
|