PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.2 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 All 502 releases
jetpack / modules / wordads / php / class-wordads-admin.php

class-wordads-admin.php in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at modules/wordads/php/class-wordads-admin.php

84 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WordAds Admin.
4 *
5 * @package automattic/jetpack
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit( 0 );
10 }
11
12 /**
13 * The standard set of admin pages for the user if Jetpack is installed
14 */
15 class WordAds_Admin {
16
17 /**
18 * WordAds_Admin Constructor.
19 *
20 * @since 4.5.0
21 */
22 public function __construct() {
23 if ( current_user_can( 'manage_options' ) && isset( $_GET['ads_debug'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
24 WordAds_API::update_wordads_status_from_api();
25 add_action( 'admin_notices', array( $this, 'debug_output' ) );
26 }
27 }
28
29 /**
30 * Output the API connection debug
31 *
32 * @since 4.5.0
33 */
34 public function debug_output() {
35 global $wordads, $wordads_status_response;
36 $response = $wordads_status_response;
37 if ( empty( $response ) ) {
38 $response = 'No response from API :(';
39 } else {
40 $response = print_r( $response, 1 ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
41 }
42
43 $status = $wordads->option( 'wordads_approved' ) ?
44 array(
45 'color' => 'green',
46 'approved' => 'Yes',
47 ) :
48 array(
49 'color' => 'red',
50 'approved' => 'No',
51 );
52
53 $type = $wordads->option( 'wordads_approved' ) ? 'updated' : 'error';
54 $message = sprintf(
55 wp_kses(
56 /* Translators: %1$s is the status color, %2$s is the status, %3$s is the response */
57 __( '<p>Status: <span style="color:%1$s;">%2$s</span></p><pre>%3$s</pre>', 'jetpack' ),
58 array(
59 'p' => array(),
60 'span' => array(
61 'style' => array(),
62 ),
63 'pre' => array(),
64 )
65 ),
66 esc_attr( $status['color'] ),
67 esc_html( $status ),
68 esc_html( $response )
69 );
70
71 wp_admin_notice(
72 $message,
73 array(
74 'type' => $type,
75 'dismissible' => true,
76 'paragraph_wrap' => false,
77 )
78 );
79 }
80 }
81
82 global $wordads_admin;
83 $wordads_admin = new WordAds_Admin();
84