| 1 |
<?php |
| 2 |
require_once (dirname(__FILE__) . '/adsense.php'); |
| 3 |
|
| 4 |
$adsense = new AdSense(); |
| 5 |
$adsenseStatus = false; |
| 6 |
|
| 7 |
function wp_insert_adsense_page() { |
| 8 |
global $screen_layout_columns; |
| 9 |
|
| 10 |
add_meta_box('wp_insert_adsense_login_credentials', 'Adsense Username and Password', 'wp_insert_adsense_login_credentials_HTML', 'col_1'); |
| 11 |
|
| 12 |
global $adsense; |
| 13 |
global $adsenseStatus; |
| 14 |
if(get_option('wp_insert_adsense_username') != '') { |
| 15 |
if ($adsense->connect(get_option('wp_insert_adsense_username'), get_option('wp_insert_adsense_password'))) { |
| 16 |
$adsenseStatus = true; |
| 17 |
add_meta_box('wp_insert_adsense_sincelastpayment', 'Adsense : Total Since Last Payment', 'wp_insert_adsense_sincelastpayment_HTML', 'col_1'); |
| 18 |
add_meta_box('wp_insert_adsense_today', 'Adsense : Today', 'wp_insert_adsense_today_HTML', 'col_1'); |
| 19 |
add_meta_box('wp_insert_adsense_yesterday', 'Adsense : Yesterday', 'wp_insert_adsense_yesterday_HTML', 'col_1'); |
| 20 |
add_meta_box('wp_insert_adsense_last7days', 'Adsense : Last 7 Days', 'wp_insert_adsense_last7days', 'col_1'); |
| 21 |
add_meta_box('wp_insert_adsense_thismonth', 'Adsense : This Month', 'wp_insert_adsense_thismonth_HTML', 'col_1'); |
| 22 |
add_meta_box('wp_insert_adsense_lastmonth', 'Adsense : Last Month', 'wp_insert_adsense_lastmonth_HTML', 'col_1'); |
| 23 |
} else { |
| 24 |
$adsenseStatus = false; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
$parameters = 'wp_insert_adsense_username, wp_insert_adsense_password'; |
| 29 |
wp_insert_settings_page_layout($parameters, 'WP-INSERT : Monitor Adsense', 'adsense'); |
| 30 |
} |
| 31 |
|
| 32 |
function wp_insert_adsense_login_credentials_HTML() { ?> |
| 33 |
<div> |
| 34 |
<p> |
| 35 |
<label for="wp_insert_adsense_username">Adsense Username :</label> |
| 36 |
<input id="wp_insert_adsense_username" class="widefat" type="text" value="<?php echo get_option('wp_insert_adsense_username'); ?>" name="wp_insert_adsense_username"/> |
| 37 |
</p> |
| 38 |
<p> |
| 39 |
<label for="wp_insert_adsense_password">Adsense Password:</label> |
| 40 |
<input id="wp_insert_adsense_password" class="widefat" type="password" value="<?php echo get_option('wp_insert_adsense_password'); ?>" name="wp_insert_adsense_password"/> |
| 41 |
</p> |
| 42 |
<p> |
| 43 |
<?php global $adsenseStatus; if($adsenseStatus == true) { echo "<span style='color:green'>Adsense - Remote Login : Successful</span>"; } else { echo "<span style='color:red'>Adsense - Remote Login : Failed</span>"; } ?> |
| 44 |
</p> |
| 45 |
<p> |
| 46 |
<small>Data Retrieval Based on <a href="http://www.webtoolkit.info/php-adsense-account-monitor.html">PHP AdSense account monitor class</a></small><br/> |
| 47 |
</p> |
| 48 |
</div> |
| 49 |
<?php } |
| 50 |
|
| 51 |
function wp_insert_get_adsense_result_HTML($data) { ?> |
| 52 |
<p> |
| 53 |
<span class="earnings"><?php echo $data['earnings']; ?></span> |
| 54 |
<span class="bigbold">Impressions : <?php echo $data['impressions']; ?></span><br/> |
| 55 |
<span class="bigbold">Clicks : <?php echo $data['clicks']; ?></span><br/> |
| 56 |
<span class="bigbold">CTR : <?php echo $data['ctr']; ?></span><br/> |
| 57 |
<span class="bigbold">eCPM : <?php echo $data['ecpm']; ?></span> |
| 58 |
</p> |
| 59 |
<div class="clear"></div> |
| 60 |
<?php } |
| 61 |
|
| 62 |
function wp_insert_adsense_sincelastpayment_HTML() { ?> |
| 63 |
<div> |
| 64 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->sincelastpayment()); ?> |
| 65 |
</div> |
| 66 |
<?php } |
| 67 |
|
| 68 |
function wp_insert_adsense_today_HTML() { ?> |
| 69 |
<div> |
| 70 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->today()); ?> |
| 71 |
</div> |
| 72 |
<?php } |
| 73 |
|
| 74 |
function wp_insert_adsense_yesterday_HTML() { ?> |
| 75 |
<div> |
| 76 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->yesterday()); ?> |
| 77 |
</div> |
| 78 |
<?php } |
| 79 |
|
| 80 |
function wp_insert_adsense_last7days() { ?> |
| 81 |
<div> |
| 82 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->last7days()); ?> |
| 83 |
</div> |
| 84 |
<?php } |
| 85 |
|
| 86 |
function wp_insert_adsense_thismonth_HTML() { ?> |
| 87 |
<div> |
| 88 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->thismonth()); ?> |
| 89 |
</div> |
| 90 |
<?php } |
| 91 |
|
| 92 |
function wp_insert_adsense_lastmonth_HTML() { ?> |
| 93 |
<div> |
| 94 |
<?php global $adsense; wp_insert_get_adsense_result_HTML($adsense->lastmonth()); ?> |
| 95 |
</div> |
| 96 |
<?php $adsense->log_out(); |
| 97 |
} |
| 98 |
?> |