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