/gads_dash_admin.php

  1. <?php 
  2. /** 
  3. * Author: Alin Marcu 
  4. * Author URI: https://deconf.com 
  5. * License: GPLv2 or later 
  6. * License URI: http://www.gnu.org/licenses/gpl-2.0.html 
  7. */ 
  8. require_once 'functions.php'; 
  9.  
  10. if (! current_user_can('manage_options')) { 
  11. return; 
  12.  
  13. if (isset($_POST['Clear']) && isset($_POST['gads_security']) && wp_verify_nonce($_POST['gads_security'], 'gads_dash_form')) { 
  14. $auth = new AdSenseAuth(); 
  15. $auth->gads_dash_clear_cache(); 
  16. ?><div class="updated"> 
  17. <p> 
  18. <strong><?php _e('Cleared Cache.', 'gads-dash' ); ?></strong> 
  19. </p> 
  20. </div> 
  21. <?php 
  22. if (isset($_POST['Reset']) && isset($_POST['gads_security']) && wp_verify_nonce($_POST['gads_security'], 'gads_dash_form')) { 
  23. $auth = new AdSenseAuth(); 
  24. $auth->gads_dash_clear_cache(); 
  25. $auth->gads_dash_reset_token(); 
  26. ?><div class="updated"> 
  27. <p> 
  28. <strong><?php _e('Token Reseted.', 'gads-dash'); ?></strong> 
  29. </p> 
  30. </div> 
  31. <?php 
  32. } else  
  33. if (gads_dash_safe_get('gads_dash_hidden') == 'Y' && isset($_POST['gads_security']) && wp_verify_nonce($_POST['gads_security'], 'gads_dash_form')) { 
  34. // Form data sent 
  35. $apikey = gads_dash_safe_get('gads_dash_apikey'); 
  36. if ($apikey) { 
  37. update_option('gads_dash_apikey', sanitize_text_field($apikey)); 
  38.  
  39. $clientid = gads_dash_safe_get('gads_dash_clientid'); 
  40. if ($clientid) { 
  41. update_option('gads_dash_clientid', sanitize_text_field($clientid)); 
  42.  
  43. $clientsecret = gads_dash_safe_get('gads_dash_clientsecret'); 
  44. if ($clientsecret) { 
  45. update_option('gads_dash_clientsecret', sanitize_text_field($clientsecret)); 
  46.  
  47. $dashaccess = gads_dash_safe_get('gads_dash_access'); 
  48. update_option('gads_dash_access', $dashaccess); 
  49.  
  50. $gads_dash_channels = gads_dash_safe_get('gads_dash_channels'); 
  51. update_option('gads_dash_channels', $gads_dash_channels); 
  52.  
  53. $gads_dash_ads = gads_dash_safe_get('gads_dash_ads'); 
  54. update_option('gads_dash_ads', $gads_dash_ads); 
  55.  
  56. $gads_dash_style = gads_dash_safe_get('gads_dash_style'); 
  57. update_option('gads_dash_style', $gads_dash_style); 
  58.  
  59. $gads_dash_cachetime = gads_dash_safe_get('gads_dash_cachetime'); 
  60. update_option('gads_dash_cachetime', $gads_dash_cachetime); 
  61.  
  62. $gads_dash_timezone = gads_dash_safe_get('gads_dash_timezone'); 
  63. update_option('gads_dash_timezone', (bool) $gads_dash_timezone); 
  64.  
  65. $gads_dash_userapi = gads_dash_safe_get('gads_dash_userapi'); 
  66. update_option('gads_dash_userapi', $gads_dash_userapi); 
  67.  
  68. if (! isset($_POST['Clear']) and ! isset($_POST['Reset'])) { 
  69. ?> 
  70. <div class="updated"> 
  71. <p> 
  72. <strong><?php _e('Options saved.', 'gads-dash'); ?></strong> 
  73. </p> 
  74. </div> 
  75. <?php 
  76. } else  
  77. if (gads_dash_safe_get('gads_dash_hidden') == 'A' && isset($_POST['gads_security']) && wp_verify_nonce($_POST['gads_security'], 'gads_dash_form')) { 
  78. $apikey = gads_dash_safe_get('gads_dash_apikey'); 
  79. if ($apikey) { 
  80. update_option('gads_dash_apikey', sanitize_text_field($apikey)); 
  81.  
  82. $clientid = gads_dash_safe_get('gads_dash_clientid'); 
  83. if ($clientid) { 
  84. update_option('gads_dash_clientid', sanitize_text_field($clientid)); 
  85.  
  86. $clientsecret = gads_dash_safe_get('gads_dash_clientsecret'); 
  87. if ($clientsecret) { 
  88. update_option('gads_dash_clientsecret', sanitize_text_field($clientsecret)); 
  89.  
  90. $gads_dash_userapi = gads_dash_safe_get('gads_dash_userapi'); 
  91. update_option('gads_dash_userapi', $gads_dash_userapi); 
  92.  
  93. if (isset($_POST['Authorize'])) { 
  94. $adminurl = admin_url("#gads-dash-widget"); 
  95. echo '<script> window.location="' . $adminurl . '"; </script> '; 
  96.  
  97. if (! get_option('gads_dash_access')) { 
  98. update_option('gads_dash_access', "manage_options"); 
  99.  
  100. if (! get_option('gads_dash_style')) { 
  101. update_option('gads_dash_style', "green"); 
  102.  
  103. $apikey = get_option('gads_dash_apikey'); 
  104. $clientid = get_option('gads_dash_clientid'); 
  105. $clientsecret = get_option('gads_dash_clientsecret'); 
  106. $dashaccess = get_option('gads_dash_access'); 
  107. $gads_dash_channels = get_option('gads_dash_channels'); 
  108. $gads_dash_ads = get_option('gads_dash_ads'); 
  109. $gads_dash_style = get_option('gads_dash_style'); 
  110. $gads_dash_cachetime = get_option('gads_dash_cachetime'); 
  111. $gads_dash_timezone = get_option('gads_dash_timezone'); 
  112. $gads_dash_userapi = get_option('gads_dash_userapi'); 
  113.  
  114. if (is_rtl()) { 
  115. $float_main = "right"; 
  116. $float_note = "left"; 
  117. } else { 
  118. $float_main = "left"; 
  119. $float_note = "right"; 
  120.  
  121. ?> 
  122. <div class="wrap"> 
  123. <?php echo "<h2>" . __( "Earnings Dashboard Settings", 'gads-dash' ) . "</h2>"; ?><hr> 
  124. </div> 
  125.  
  126. <div id="poststuff"> 
  127. <div id="post-body" class="metabox-holder columns-2"> 
  128. <div id="post-body-content"> 
  129. <div class="settings-wrapper"> 
  130. <div class="inside"> 
  131. <form name="gads_dash_form" method="post" 
  132. action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>"> 
  133. <?php wp_nonce_field('gads_dash_form', 'gads_security'); ?>  
  134. <h2><?php _e( 'Google Adsense API', 'gads-dash' ); ?></h2> 
  135. <p><?php echo __("You should read/watch this step by step", 'gads-dash')." <a href='https://deconf.com/earnings-dashboard-google-adsense-wordpress/' target='_blank'> ". __("video tutorial")."</a> ".__("before proceeding to authorization", 'gads-dash');?></p> 
  136. <p> 
  137. <input name="gads_dash_userapi" type="checkbox" 
  138. id="gads_dash_userapi" onchange="this.form.submit()" value="1" 
  139. <?php checked(get_option('gads_dash_userapi'), 1); ?> /><strong><?php _e(" use your own API Project credentials", 'gads-dash' )?></strong> 
  140. </p> 
  141. <?php 
  142. if (get_option('gads_dash_userapi')) { 
  143. ?> 
  144. <p> 
  145. <strong><?php _e("API Key:", 'gads-dash');?></strong> <input 
  146. type="text" name="gads_dash_apikey" 
  147. value="<?php echo esc_attr($apikey); ?>" size="60"> 
  148. </p> 
  149. <p> 
  150. <strong><?php _e("Client ID:", 'gads-dash');?></strong><input 
  151. type="text" name="gads_dash_clientid" 
  152. value="<?php echo esc_attr($clientid); ?>" size="60"> 
  153. </p> 
  154. <p> 
  155. <strong><?php _e("Client Secret:", 'gads-dash');?></strong><input 
  156. type="text" name="gads_dash_clientsecret" 
  157. value="<?php echo esc_attr($clientsecret); ?>" size="60"> 
  158. </p>  
  159. <?php 
  160. ?> 
  161. <p><?php 
  162. if (get_option('gads_dash_token')) { 
  163. ?> 
  164. <input type="submit" name="Reset" class="button button-secondary" 
  165. value="<?php _e( "Clear Authorization", 'gads-dash' );?>" /> <input 
  166. type="submit" name="Clear" class="button button-secondary" 
  167. value="<?php _e('Clear Cache', 'gads-dash' ) ?>" /> <input 
  168. type="hidden" name="gads_dash_hidden" value="Y"> 
  169. <?php 
  170. } else { 
  171. ?> 
  172. <input type="submit" name="Authorize" class="button button-secondary" 
  173. value="<?php _e( "Authorize Application", 'gads-dash' );?>" /> <input 
  174. type="submit" name="Clear" class="button button-secondary" 
  175. value="<?php _e('Clear Cache', 'gads-dash' ) ?>" /> <input 
  176. type="hidden" name="gads_dash_hidden" value="A"> 
  177.  
  178. </p> 
  179. </form> 
  180. <?php _e ( "(the rest of the settings will show up after completing the authorization process)", 'gads-dash' ); ?> 
  181. </div> 
  182. <?php 
  183.  
  184. deconfsidebar(); 
  185. return; 
  186. ?> 
  187. <hr> 
  188. <h2> <?php _e( 'Access Level', 'gads-dash' );?></h2> 
  189. <p><?php _e("View Access Level: ", 'gads-dash' ); ?> 
  190. <select id="gads_dash_access" name="gads_dash_access"> 
  191. <option value="manage_options" 
  192. <?php selected( $dashaccess, "manage_options" ); ?>><?php echo __("Administrators", 'clicky-analytics');?></option> 
  193. <option value="edit_pages" 
  194. <?php selected( $dashaccess, "edit_pages" ); ?>><?php echo __("Editors", 'clicky-analytics');?></option> 
  195. <option value="publish_posts" 
  196. <?php selected( $dashaccess, "publish_posts" ); ?>><?php echo __("Authors", 'clicky-analytics');?></option> 
  197. <option value="edit_posts" 
  198. <?php selected( $dashaccess, "edit_posts" ); ?>><?php echo __("Contributors", 'clicky-analytics');?></option> 
  199. </select> 
  200. </p> 
  201. <hr> 
  202. <h2><?php _e( 'Additional Settings', 'gads-dash' );?></h2> 
  203. <p> 
  204. <input name="gads_dash_channels" type="checkbox" 
  205. id="gads_dash_channels" value="1" 
  206. <?php checked(get_option('gads_dash_channels'), 1); ?> /><?php _e(" show Custom Channels performance report", 'gads-dash' ); ?></p> 
  207. <p> 
  208. <input name="gads_dash_ads" type="checkbox" id="gads_dash_ads" 
  209. value="1" <?php checked(get_option('gads_dash_ads'), 1);?> /><?php _e(" show Ad Units performance report", 'gads-dash' ); ?></p> 
  210. <p><?php _e("CSS Settings: ", 'gads-dash' ); ?> 
  211. <select id="gads_dash_style" name="gads_dash_style"> 
  212. <option value="green" <?php selected($gads_dash_style, 'green');?>> <?php _e("Green Theme", 'gads-dash');?></option> 
  213. <option value="light" <?php selected($gads_dash_style, 'light');?>> <?php _e("Light Theme", 'gads-dash');?></option> 
  214. </select> 
  215. </p> 
  216. <hr> 
  217. <h2><?php _e( 'Cache Settings', 'gads-dash' );?></h2> 
  218. <p><?php _e("Cache Time: ", 'gads-dash' ); ?> 
  219. <select id="gads_dash_cachetime" name="gads_dash_cachetime"> 
  220. <option value="900" <?php selected($gads_dash_cachetime, 900);?>><?php _e("15 minutes", 'gads-dash');?></option> 
  221. <option value="1800" <?php selected($gads_dash_cachetime, 1800);?>><?php _e("30 minutes", 'gads-dash');?></option> 
  222. <option value="3600" <?php selected($gads_dash_cachetime, 3600);?>><?php _e("1 hour", 'gads-dash');?></option> 
  223. <option value="7200" <?php selected($gads_dash_cachetime, 7200);?>><?php _e("2 hours", 'gads-dash');?></option> 
  224. </select> 
  225. </p> 
  226. <hr> 
  227. <h2><?php _e( 'Google Adsense Time Zone', 'gads-dash' );?></h2> 
  228.  
  229. <p><?php _e("Time Zone: ", 'gads-dash' ); ?> 
  230. <select id="gads_dash_timezone" name="gads_dash_timezone"> 
  231. <option value="0" <?php selected($gads_dash_timezone, 0);?>><?php _e("Billing time zone (PST)", 'gads-dash');?></option> 
  232. <option value="1" <?php selected($gads_dash_timezone, 1);?>><?php _e("Account time zone", 'gads-dash');?></option> 
  233. </select> 
  234. </p> 
  235.  
  236. <p class="submit"> 
  237. <input type="submit" name="Submit" class="button button-primary" 
  238. value="<?php _e('Update Options', 'gads-dash' ) ?>" /> 
  239. </p> 
  240. </form> 
  241. </div> 
  242.  
  243. <?php 
  244.  
  245. deconfsidebar(); 
  246.  
  247. function deconfsidebar() 
  248. ?> 
  249.  
  250. </div> 
  251. </div> 
  252.  
  253. <div id="postbox-container-1" class="postbox-container"> 
  254. <div class="meta-box-sortables"> 
  255. <div class="postbox"> 
  256. <h3> 
  257. <span><?php _e("Setup Tutorial & Demo", 'gads-dash') ?></span> 
  258. </h3> 
  259. <div class="inside"> 
  260. <a 
  261. href="https://deconf.com/earnings-dashboard-google-adsense-wordpress/?utm_source=gadswp_config&utm_medium=link&utm_content=video&utm_campaign=gadswp" 
  262. target="_blank"><img 
  263. src="<?php echo plugins_url( 'images/earnings-dashboard.png' , __FILE__ );?>" 
  264. width="100%" alt="" /></a> 
  265. </div> 
  266. </div> 
  267. <div class="postbox"> 
  268. <h3> 
  269. <span><?php _e("Support & Reviews", 'gads-dash')?></span> 
  270. </h3> 
  271. <div class="inside"> 
  272. <div class="deconf-title"> 
  273. <a 
  274. href="https://deconf.com/earnings-dashboard-google-adsense-wordpress/?utm_source=gadswp_config&utm_medium=link&utm_content=support&utm_campaign=gadswp"><img 
  275. src="<?php echo plugins_url( 'images/help.png' , __FILE__ ); ?>" /></a> 
  276. </div> 
  277. <div class="deconf-desc"><?php echo __('Plugin documentation and support on', 'gads-dash') . ' <a href="https://deconf.com/earnings-dashboard-google-adsense-wordpress/?utm_source=gadswp_config&utm_medium=link&utm_content=support&utm_campaign=gadswp">deconf.com</a>.'; ?></div> 
  278. <br /> 
  279. <div class="deconf-title"> 
  280. <a 
  281. href="https://wordpress.org/support/view/plugin-reviews/google-adsense-dashboard-for-wp#plugin-info"><img 
  282. src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a> 
  283. </div> 
  284. <div class="deconf-desc"><?php echo __('Your feedback and review are both important, ', 'gads-dash').' <a href="https://wordpress.org/support/view/plugin-reviews/google-adsense-dashboard-for-wp#plugin-info">'.__('rate this plugin', 'gads-dash').'</a>!'; ?></div> 
  285. </div> 
  286. </div> 
  287. <div class="postbox"> 
  288. <h3> 
  289. <span><?php _e("Further Reading", 'gads-dash')?></span> 
  290. </h3> 
  291. <div class="inside"> 
  292. <div class="deconf-title"> 
  293. <a 
  294. href="https://deconf.com/move-website-https-ssl/?utm_source=gadswp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadswp"><img 
  295. src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a> 
  296. </div> 
  297. <div class="deconf-desc"><?php echo '<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadswp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadswp">'.__('Improve search rankings', 'gads-dash').'</a> '.__('by moving your website to HTTPS/SSL.', 'gads-dash'); ?></div> 
  298. <br /> 
  299. <div class="deconf-title"> 
  300. <a 
  301. href="https://deconf.com/wordpress/?utm_source=gadswp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadswp"><img 
  302. src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a> 
  303. </div> 
  304. <div class="deconf-desc"><?php echo __('Other', 'gads-dash').' <a href="https://deconf.com/wordpress/?utm_source=gadswp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadswp">'.__('WordPress Plugins', 'gads-dash').'</a> '.__('written by the same author', 'gads-dash').'.'; ?></div> 
  305. </div> 
  306. </div> 
  307. <div class="postbox"> 
  308. <h3> 
  309. <span><?php _e("Other Services", 'gads-dash')?></span> 
  310. </h3> 
  311. <div class="inside"> 
  312. <div class="deconf-title"> 
  313. <a href="http://tracking.maxcdn.com/c/94142/36539/378"><img 
  314. src="<?php echo plugins_url( 'images/mcdn.png' , __FILE__ ); ?>" /></a> 
  315. </div> 
  316. <div class="deconf-desc"><?php echo __('Speed up your website and plug into a whole', 'gads-dash').' <a href="http://tracking.maxcdn.com/c/94142/36539/378">'.__('new level of site speed', 'gads-dash').'</a>.'; ?></div> 
  317. <br /> 
  318. <div class="deconf-title"> 
  319. <a 
  320. href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadswp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadswp"><img 
  321. src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a> 
  322. </div> 
  323. <div class="deconf-desc"><?php echo '<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadswp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadswp">'.__('Web Analytics', 'gads-dash').'</a> '.__('service with users tracking at IP level.', 'gads-dash'); ?></div> 
  324. </div> 
  325. </div> 
  326. </div> 
  327. </div> 
  328.  
  329. </div> 
  330.  
  331. <?php }?> 
.