| 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 |
* |
| 23 |
* @since 4.5.0 |
| 24 |
*/ |
| 25 |
function debug_output() { |
| 26 |
global $wordads, $wordads_status_response; |
| 27 |
$response = $wordads_status_response; |
| 28 |
if ( empty( $response ) ) { |
| 29 |
$response = 'No response from API :('; |
| 30 |
} else { |
| 31 |
$response = print_r( $response, 1 ); |
| 32 |
} |
| 33 |
|
| 34 |
$status = $wordads->option( 'wordads_approved' ) ? |
| 35 |
'<span style="color:green;">Yes</span>' : |
| 36 |
'<span style="color:red;">No</span>'; |
| 37 |
|
| 38 |
$type = $wordads->option( 'wordads_approved' ) ? 'updated' : 'error'; |
| 39 |
echo <<<HTML |
| 40 |
<div class="notice $type is-dismissible"> |
| 41 |
<p>Status: $status</p> |
| 42 |
<pre>$response</pre> |
| 43 |
</div> |
| 44 |
HTML; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
global $wordads_admin; |
| 49 |
$wordads_admin = new WordAds_Admin(); |
| 50 |
|