gglstmp_settings_page

The Google Sitemap by BestWebSoft gglstmp settings page function.

Description

gglstmp_settings_page(); 

Usage

  1. if ( !function_exists( 'gglstmp_settings_page' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-sitemap-by-bestwebsoft/google-sitemap-plugin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = gglstmp_settings_page(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/google-sitemap-plugin.php  
  1. function gglstmp_settings_page() { 
  2. global $gglstmp_url_home, $gglstmp_settings, $gglstmp_option_defaults, $gglstmp_url, $wp_version, $gglstmp_plugin_info; 
  3.  
  4. if ( ! isset( $_GET['action'] ) || 'go_pro' != $_GET['action'] ) 
  5. require_once( dirname( __FILE__ ) . '/includes/pro_banners.php' ); 
  6.  
  7. $message = $error = ""; 
  8. $gglstmp_robots = get_option( 'gglstmp_robots' ); 
  9. $gglstmp_url_robot = ABSPATH . "robots.txt"; 
  10. $plugin_basename = plugin_basename( __FILE__ ); 
  11.  
  12. /** Check htaccess plugin */ 
  13. $gglstmp_htaccess_active = false; 
  14. if ( is_multisite() && ! is_subdomain_install() ) { 
  15. $all_plugins = get_plugins(); 
  16. $is_network = is_network_admin(); 
  17. $admin_url = $is_network ? network_admin_url( '/' ) : admin_url( '/' ); 
  18. $gglstmp_htaccess = gglstmp_plugin_status( array( 'htaccess/htaccess.php', 'htaccess-pro/htaccess-pro.php' ), $all_plugins, $is_network ); 
  19. $gglstmp_htaccess_options = false; 
  20.  
  21. if ( $gglstmp_htaccess['status'] == 'actived' ) { 
  22.  
  23. if ( $gglstmp_htaccess['plugin'] == 'htaccess/htaccess.php' ) { 
  24. global $htccss_options; 
  25. register_htccss_settings(); 
  26. $gglstmp_htaccess_options = &$htccss_options; 
  27. $gglstmp_htaccess_prefix = 'htccss'; 
  28.  
  29. if ( $gglstmp_htaccess['plugin'] == 'htaccess-pro/htaccess-pro.php' ) { 
  30. global $htccsspr_options; 
  31. register_htccsspr_settings(); 
  32. $gglstmp_htaccess_options = &$htccsspr_options; 
  33. $gglstmp_htaccess_prefix = 'htccsspr'; 
  34.  
  35. $gglstmp_htaccess_active = true; 
  36. $gglstmp_htaccess_options_name = "{$gglstmp_htaccess_prefix}_options"; 
  37. $gglstmp_htaccess_function_generate = "{$gglstmp_htaccess_prefix}_generate_htaccess"; 
  38. $gglstmp_htaccess_function_check = "{$gglstmp_htaccess_prefix}_check_xml_access"; 
  39.  
  40. if ( function_exists( $gglstmp_htaccess_function_check ) ) { 
  41. $gglstmp_htaccess_check = $gglstmp_htaccess_function_check(); 
  42. if ( $gglstmp_htaccess_check != $gglstmp_htaccess_options['allow_xml'] ) { 
  43. $gglstmp_htaccess_options['allow_xml'] = $gglstmp_htaccess_check; 
  44. update_site_option( $gglstmp_htaccess_options_name, $gglstmp_htaccess_options ); 
  45.  
  46. if ( is_multisite() ) { 
  47. $home_url = preg_replace( "/[^a-zA-Z*-**-*0-9\s]/", "_", str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ) ); 
  48. $gglstmp_url_sitemap = ABSPATH . "sitemap_" . $home_url .".xml"; 
  49. } else { 
  50. $gglstmp_url_sitemap = ABSPATH . "sitemap.xml"; 
  51.  
  52. if ( isset( $_REQUEST['gglstmp_submit'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { 
  53. if ( isset( $_POST['bws_hide_premium_options'] ) ) { 
  54. $hide_result = bws_hide_premium_options( $gglstmp_settings ); 
  55. $gglstmp_settings = $hide_result['options']; 
  56.  
  57. if ( $gglstmp_htaccess_active && $gglstmp_htaccess_options && function_exists( $gglstmp_htaccess_function_generate ) ) { 
  58. $gglstmp_allow_xml = ( isset( $_POST[ 'gglstmp_allow_xml' ] ) && $_POST[ 'gglstmp_allow_xml' ] == 1 ) ? 1 : 0; 
  59. if ( $gglstmp_allow_xml != $gglstmp_htaccess_options['allow_xml'] ) { 
  60. $gglstmp_htaccess_options['allow_xml'] = $gglstmp_allow_xml; 
  61. update_site_option( $gglstmp_htaccess_options_name, $gglstmp_htaccess_options ); 
  62. $gglstmp_htaccess_function_generate(); 
  63.  
  64. $gglstmp_settings['post_type'] = isset( $_REQUEST['gglstmp_post_types'] ) ? $_REQUEST['gglstmp_post_types'] : array(); 
  65. $gglstmp_settings['taxonomy'] = isset( $_REQUEST['gglstmp_taxonomies'] ) ? $_REQUEST['gglstmp_taxonomies'] : array(); 
  66. /**============================ Adding location of sitemap file to the robots.txt =============*/ 
  67. $gglstmp_robots_flag = isset( $_POST['gglstmp_checkbox'] ) ? 1 : 0; 
  68. if ( file_exists( $gglstmp_url_robot ) && ! is_multisite() ) { 
  69. if ( ! is_writable( $gglstmp_url_robot ) ) 
  70. @chmod( $gglstmp_url_robot, 0755 ); 
  71. if ( is_writable( $gglstmp_url_robot ) ) { 
  72. $file_content = file_get_contents( $gglstmp_url_robot ); 
  73. if ( isset( $_POST['gglstmp_checkbox'] ) && ! preg_match( '|Sitemap: ' . $gglstmp_url_home . 'sitemap.xml|', $file_content ) ) { 
  74. file_put_contents( $gglstmp_url_robot, $file_content . "\nSitemap: " . $gglstmp_url_home . "sitemap.xml" ); 
  75. } elseif ( preg_match( "|Sitemap: " . $gglstmp_url_home . "sitemap.xml|", $file_content ) && ! isset( $_POST['gglstmp_checkbox'] ) ) { 
  76. $file_content = preg_replace( "|\nSitemap: " . $gglstmp_url_home . "sitemap.xml|", '', $file_content ); 
  77. file_put_contents( $gglstmp_url_robot, $file_content ); 
  78. } else { 
  79. $error = __( 'Cannot edit "robots.txt". Check your permissions', 'google-sitemap-plugin' ); 
  80. $gglstmp_robots_flag = 0; 
  81. if ( false === get_option( 'gglstmp_robots' ) ) 
  82. add_option( 'gglstmp_robots', $gglstmp_robots_flag ); 
  83. else 
  84. update_option( 'gglstmp_robots', $gglstmp_robots_flag ); 
  85. $gglstmp_robots = get_option( 'gglstmp_robots' ); 
  86. update_option( 'gglstmp_settings', $gglstmp_settings ); 
  87. if ( ! isset( $_POST['gglstmp_authorize'] ) && ! isset( $_POST['gglstmp_logout'] ) && ! isset( $_POST['gglstmp_menu'] ) ) { 
  88. $message .= " " . __( "Settings saved" , 'google-sitemap-plugin' ); 
  89.  
  90. /**## check banner */ 
  91. $bws_hide_premium_options_check = bws_hide_premium_options_check( $gglstmp_settings ); 
  92.  
  93. if ( isset( $_POST['gglstmp_new'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { 
  94. $message = __( "Your Sitemap file has been created in the site root directory", 'google-sitemap-plugin' ); 
  95.  
  96.  
  97. $gglstmp_result = get_post_types( '', 'names' ); 
  98. unset( $gglstmp_result['revision'] ); 
  99. unset( $gglstmp_result['attachment'] ); 
  100. unset( $gglstmp_result['nav_menu_item'] ); 
  101.  
  102. $gglstmp_result_taxonomies = array( 
  103. 'category' => 'Post category',  
  104. 'post_tag' => 'Post tag' 
  105. ); 
  106.  
  107. /** GO PRO */ 
  108. if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) { 
  109. $go_pro_result = bws_go_pro_tab_check( $plugin_basename, 'gglstmp_settings' ); 
  110. if ( ! empty( $go_pro_result[error] ) ) 
  111. $error = $go_pro_result[error]; 
  112. elseif ( ! empty( $go_pro_result['message'] ) ) 
  113. $message = $go_pro_result['message']; 
  114.  
  115. if ( isset( $_REQUEST['bws_restore_confirm'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) { 
  116. $gglstmp_settings = $gglstmp_option_defaults; 
  117. @unlink( $gglstmp_url_sitemap );/** remove sitemap.xml */ 
  118. /** clear robots.txt */ 
  119. if ( file_exists( $gglstmp_url_robot ) && ! is_multisite() ) { 
  120. if ( ! is_writable( $gglstmp_url_robot ) ) 
  121. @chmod( $gglstmp_url_robot, 0755 ); 
  122. if ( is_writable( $gglstmp_url_robot ) ) { 
  123. $file_content = file_get_contents( $gglstmp_url_robot ); 
  124. if ( preg_match( "|Sitemap: " . $gglstmp_url_home . "sitemap.xml|", $file_content ) ) { 
  125. $file_content = preg_replace( "|\nSitemap: " . $gglstmp_url_home . "sitemap.xml|", '', $file_content ); 
  126. file_put_contents( $gglstmp_url_robot, $file_content ); 
  127. } else { 
  128. $error = __( 'Cannot edit "robot.txt". Check your permissions', 'google-sitemap-plugin' ); 
  129. if ( false === get_option( 'gglstmp_robots' ) ) 
  130. add_option( 'gglstmp_robots', 0 ); 
  131. else 
  132. update_option( 'gglstmp_robots', 0 ); 
  133. $gglstmp_robots = get_option( 'gglstmp_robots' ); 
  134. update_option( 'gglstmp_settings', $gglstmp_settings ); 
  135. $message = __( 'All plugin settings were restored.', 'google-sitemap-plugin' ); 
  136. } ?> 
  137. <div class="wrap"> 
  138. <h1 style="line-height: normal;"><?php _e( "Google Sitemap Settings", 'google-sitemap-plugin' ); ?></h1> 
  139. <h2 class="nav-tab-wrapper"> 
  140. <a class="nav-tab<?php if ( !isset( $_GET['action'] ) ) echo ' nav-tab-active'; ?>" href="admin.php?page=google-sitemap-plugin.php"><?php _e( 'Settings', 'google-sitemap-plugin' ); ?></a> 
  141. <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'custom_links' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=google-sitemap-plugin.php&action=custom_links"><?php _e( 'Custom links', 'google-sitemap-plugin' ); ?></a> 
  142. <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'extra' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=google-sitemap-plugin.php&action=extra"><?php _e( 'Extra settings', 'google-sitemap-plugin' ); ?></a> 
  143. <a class="nav-tab bws_go_pro_tab<?php if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) echo ' nav-tab-active'; ?>" href="admin.php?page=google-sitemap-plugin.php&action=go_pro"><?php _e( 'Go PRO', 'google-sitemap-plugin' ); ?></a> 
  144. </h2> 
  145. <?php if ( ! isset( $_GET['action'] ) && is_multisite() && ! is_subdomain_install() && count( glob( ABSPATH . "sitemap*.xml" ) ) > 0 && ( ! $gglstmp_htaccess_active || $gglstmp_htaccess_options['allow_xml'] == 0 ) ) { ?> 
  146. <div id="gglstmp_check_sitemap_block" class="error below-h2"> 
  147. <p> 
  148. <?php printf( '<strong>%s</strong> %s',  
  149. __( 'Warning:', 'google-sitemap-plugin' ),  
  150. sprintf( 
  151. __( 'To have an access to subsites XML files, please add the following rule %s to your %s file in %s after line %s or you can use option %s', 'google-sitemap-plugin' ) . '.',  
  152. '<code>RewriteRule ([^/]+\.xml)$ $1 [L]</code>',  
  153. '<strong>.htaccess</strong>',  
  154. sprintf( '<strong>"%s"</strong>', ABSPATH ),  
  155. '<strong>"RewriteBase"</strong>',  
  156. sprintf( '<strong>"%s"</strong>', __( 'Allow access to XML files', 'google-sitemap-plugin' ) ) 
  157. ); ?> 
  158. </p> 
  159. <div style="margin: .5em 0; padding: 2px;"> 
  160. <form action="admin.php?page=google-sitemap-plugin.php" method='post' id="gglstmp_check_sitemap"> 
  161. <input type="submit" class="button-secondary" name="gglstmp_check_sitemap" value="<?php _e( '*heck Access', 'google-sitemap-plugin' ) ?>" /> 
  162. <?php wp_nonce_field( $plugin_basename, 'gglstmp_nonce_sitemap' ); ?> 
  163. </form> 
  164. <?php if ( isset( $_POST['gglstmp_check_sitemap'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_sitemap' ) ) { 
  165. $gglstmp_background = array( 
  166. '200' => '#f8fdf5',  
  167. '404' => '#fdf6f6' 
  168. ); 
  169. if ( $gglstmp_settings['sitemap'] && file_exists( $gglstmp_settings['sitemap']['path'] ) ) { 
  170. $gglstmp_status = gglstmp_check_sitemap( $gglstmp_settings['sitemap']['loc'] ); 
  171. printf( '<div style="margin: 10px 0 0; padding: 2px 5px; background-color: %s;"><a href="%s">%s</a> - %s</div>', $gglstmp_background[ $gglstmp_status['code'] ], $gglstmp_settings['sitemap']['loc'], $gglstmp_settings['sitemap']['file'], $gglstmp_status['message'] ); 
  172. } ?> 
  173. </div> 
  174. </div> 
  175. <?php } 
  176. <div class="updated fade below-h2" <?php if ( "" != $error || $message == "" ) echo "style=\"display:none\""; ?>><p><strong><?php echo $message; ?>.</strong></p></div> 
  177. <div class="error below-h2" <?php if ( "" == $error ) echo "style=\"display:none\""; ?>><p><strong><?php echo $error; ?>.</strong></p></div> 
  178. <?php if ( ! isset( $_GET['action'] ) ) { 
  179. if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) { 
  180. bws_form_restore_default_confirm( $plugin_basename ); 
  181. } else { ?> 
  182. <form class="bws_form" action="admin.php?page=google-sitemap-plugin.php" method='post' name="gglstmp_auth"> 
  183. <?php /**=============================== Creating sitemap file ====================================*/ 
  184. if ( file_exists( $gglstmp_url_sitemap ) ) { 
  185. if ( is_multisite() ) { 
  186. echo '<p><a href="' . $gglstmp_url_home . "sitemap_" . $home_url . '.xml" target="_new">' . __( "The Sitemap file", 'google-sitemap-plugin' ) . "</a> " . __( "already exists. If you would like to replace it with a new one, please choose the necessary box below", 'google-sitemap-plugin' ) . ".</p>"; 
  187. } else { 
  188. echo '<p><a href="' . $gglstmp_url_home . 'sitemap.xml" target="_new">' . __( "The Sitemap file", 'google-sitemap-plugin' ) . "</a> " . __( "already exists. If you would like to replace it with a new one, please choose the necessary box below", 'google-sitemap-plugin' ) . ".</p>"; 
  189. } else { 
  190. if ( is_multisite() ) { 
  191. echo '<p><a href="' . $gglstmp_url_home . "sitemap_" . $home_url . '.xml" target="_new">' . __( "Your Sitemap file", 'google-sitemap-plugin' ) . "</a> " . __( "has been created in the site root directory", 'google-sitemap-plugin' ) . ".</p>"; 
  192. } else { 
  193. echo '<p><a href="' . $gglstmp_url_home . 'sitemap.xml" target="_new">' . __( "Your Sitemap file", 'google-sitemap-plugin' ) . "</a> " . __( "has been created in the site root directory", 'google-sitemap-plugin' ) . ".</p>"; 
  194. } ?> 
  195. <table class="form-table"> 
  196. <tr valign="top"> 
  197. <td colspan="2"> 
  198. <label><input type='checkbox' name='gglstmp_new' value="1" /> <?php _e( "create a new sitemap file or update the existing one", 'google-sitemap-plugin' ); ?></label> 
  199. </td> 
  200. </tr> 
  201. <?php if ( is_multisite() ) { ?> 
  202. <tr valign="top"> 
  203. <td colspan="2"> 
  204. <label><input type='checkbox' disabled="disabled" name='gglstmp_checkbox' value="1" <?php if ( 1 == $gglstmp_robots ) echo 'checked="checked"'; ?> /> <?php _e( "add sitemap file path in robots.txt", 'google-sitemap-plugin' );?></label> 
  205. <p style="color:red"><?php _e( "Since you are using multisiting, the plugin does not allow to add a sitemap to robots.txt", 'google-sitemap-plugin' ); ?></div> 
  206. </td> 
  207. </tr> 
  208. <?php } else { ?> 
  209. <tr valign="top"> 
  210. <td colspan="2"> 
  211. <!-- for robots.txt we need to use site_url instead home_url ! --> 
  212. <label><input type='checkbox' name='gglstmp_checkbox' value="1" <?php if ( 1 == $gglstmp_robots ) echo 'checked="checked"'; ?> /> <?php _e( "add sitemap file path in", 'google-sitemap-plugin' ); ?> <a href="<?php echo site_url( '/' ); ?>robots.txt" target="_new">robots.txt</a></label> 
  213. </td> 
  214. </tr> 
  215. <?php } ?> 
  216. <tr valign="top"> 
  217. <th scope="row" colspan="2"><?php _e( 'Add post types and taxonomies links to the sitemap', 'google-sitemap-plugin' ); ?>:</th> 
  218. </tr> 
  219. <tr valign="top"> 
  220. <td colspan="2"> 
  221. <fieldset> 
  222. <?php foreach ( $gglstmp_result as $key => $value ) { ?> 
  223. <label><input type="checkbox" <?php if ( in_array( $value, $gglstmp_settings['post_type'] ) ) echo 'checked="checked"'; ?> name="gglstmp_post_types[]" value="<?php echo $value; ?>"/><span style="text-transform: capitalize; padding-left: 5px;"><?php echo $value; ?></span></label><br /> 
  224. <?php } ?> 
  225. </fieldset> 
  226. </td> 
  227. </tr> 
  228. <tr valign="top"> 
  229. <td colspan="2"> 
  230. <fieldset> 
  231. <?php foreach ( $gglstmp_result_taxonomies as $key => $value ) { ?> 
  232. <label><input type="checkbox" <?php if ( in_array( $key, $gglstmp_settings['taxonomy'] ) ) echo 'checked="checked"'; ?> name="gglstmp_taxonomies[]" value="<?php echo $key; ?>"/><span style="padding-left: 5px;"><?php echo $value; ?></span></label><br /> 
  233. <?php } ?> 
  234. </fieldset> 
  235. </td> 
  236. </tr> 
  237. <?php if ( is_multisite() && ! is_subdomain_install() ) { 
  238. $gglstmp_plugin_name = ( isset( $gglstmp_htaccess['plugin_info']['Name'] ) ) ? $gglstmp_htaccess['plugin_info']['Name'] : 'Htaccess by BestWebSoft'; 
  239. $gglstmp_attr_checked = $gglstmp_attr_disabled = ''; 
  240. $gglstmp_plugin_notice = sprintf( __( 'This option will be applied to all websites in the network', 'google-sitemap-plugin' ) ); 
  241. if ( 'deactivated' == $gglstmp_htaccess['status'] ) { 
  242. $gglstmp_attr_disabled = 'disabled="disabled"'; 
  243. $gglstmp_plugin_notice = sprintf( __( 'You should %s to use this functionality', 'google-sitemap-plugin' ),  
  244. sprintf( '<a href="%splugins.php">%s%s %s</a>', $admin_url, __( 'activate', 'google-sitemap-plugin' ), ( is_network_admin() ? ' ' . __( 'for network', 'google-sitemap-plugin' ) : '' ), $gglstmp_plugin_name ) 
  245. ); 
  246. } elseif ( 'not_installed' == $gglstmp_htaccess['status'] ) { 
  247. $gglstmp_attr_disabled = 'disabled="disabled"'; 
  248. $gglstmp_plugin_notice = sprintf( __( 'You should %s to use this functionality', 'google-sitemap-plugin' ),  
  249. sprintf( '<a href="http://bestwebsoft.com/products/htaccess/?k=bc745b0c9d4b19ba95ae2c861418e0df&pn=83&v=%s&wp_v=%s">%s %s</a>', $gglstmp_plugin_info["Version"], $wp_version, __( 'download', 'google-sitemap-plugin' ), $gglstmp_plugin_name ) 
  250. ); 
  251. if ( '1' == $gglstmp_htaccess_options['allow_xml'] && $gglstmp_attr_disabled == '' ) { 
  252. $gglstmp_attr_checked = 'checked="checked"'; 
  253. } ?> 
  254. <tr valign="top" id="gglstmp_allow_xml_block"> 
  255. <th scope="row"><?php _e( 'Allow access to XML files', 'google-sitemap-plugin' ); ?></th> 
  256. <td> 
  257. <label><input <?php printf( "%s %s", $gglstmp_attr_checked, $gglstmp_attr_disabled ); ?> type="checkbox" name="gglstmp_allow_xml" value="1" /></label> 
  258. <div class="bws_help_box dashicons dashicons-editor-help"> 
  259. <div class="bws_hidden_help_text" style="min-width: 270px;"> 
  260. <p><?php _e( 'The following string will be added to your .htaccess file', 'google-sitemap-plugin' ); ?>:</p> 
  261. <code>RewriteRule ([^/]+\.xml)$ $1 [L]</code> 
  262. </div> 
  263. </div> 
  264. <span class="bws_info"><?php echo $gglstmp_plugin_notice; ?></span><br /> 
  265. </td> 
  266. </tr> 
  267. <?php } ?> 
  268. </table> 
  269. if ( ! function_exists( 'curl_init' ) ) { ?> 
  270. <p class="gglstmp_error"> 
  271. <strong><?php _e( "This hosting does not support *URL, so you cannot add a sitemap file automatically", 'google-sitemap-plugin' ); ?>.</strong> 
  272. <br /> 
  273. <span class="bws_info"> 
  274. <?php echo __( 'You can always add your sitemap to Google Webmaster Tools manually. For more info see', 'google-sitemap-plugin' ) . 
  275. ' <a target="_blank" href="https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/edit">' . __( 'the instruction', 'google-sitemap-plugin' ) . '</a>.'; ?> 
  276. </span> 
  277. </p> 
  278. <?php } else { ?> 
  279. <table class="form-table"> 
  280. <tr id="gglstmp_google_webmaster" valign="top"> 
  281. <th scope="row"><?php _e( 'Remote work with Google Webmaster Tools', 'google-sitemap-plugin' ); ?></th> 
  282. <td> 
  283. <?php $gglstmp_client = gglstmp_client(); 
  284. $gglstmp_blog_prefix = '_' . get_current_blog_id(); 
  285. if ( isset( $_POST['gglstmp_logout'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { 
  286. unset( $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] ); 
  287. unset( $gglstmp_settings['authorization_code'] ); 
  288. update_option( 'gglstmp_settings', $gglstmp_settings ); 
  289. if ( isset( $_POST['gglstmp_authorization_code'] ) && ! empty( $_POST['gglstmp_authorization_code'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { 
  290. try { 
  291. $gglstmp_client->authenticate( $_POST['gglstmp_authorization_code'] ); 
  292. $gglstmp_settings['authorization_code'] = $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] = $gglstmp_client->getAccessToken(); 
  293. update_option( 'gglstmp_settings', $gglstmp_settings ); 
  294. } catch ( Exception $e ) {} 
  295. if ( ! isset( $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] ) && isset( $gglstmp_settings['authorization_code'] ) ) { 
  296. $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] = $gglstmp_settings['authorization_code']; 
  297. if ( isset( $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] ) ) { 
  298. $gglstmp_client->setAccessToken( $_SESSION[ 'gglstmp_authorization_code' . $gglstmp_blog_prefix ] ); 
  299. if ( $gglstmp_client->getAccessToken() ) { ?> 
  300. <div id="gglstmp_logout_button"> 
  301. <input class="button-secondary" name="gglstmp_logout" type="submit" value="<?php _e( 'Log out from Google Webmaster Tools', 'google-sitemap-plugin' ); ?>" /> 
  302. </div> 
  303. <?php $gglstmp_menu_ad = __( "add this site to Google Webmaster Tools", 'google-sitemap-plugin' ); 
  304. $gglstmp_menu_del = __( "delete this site from Google Webmaster Tools", 'google-sitemap-plugin' ); 
  305. $gglstmp_menu_inf = __( "get info about this site in Google Webmaster Tools", 'google-sitemap-plugin' ); ?> 
  306. <fieldset> 
  307. <label><input type='radio' name='gglstmp_menu' value="ad" /> <?php echo $gglstmp_menu_ad; ?></label><br /> 
  308. <label><input type='radio' name='gglstmp_menu' value="del" /> <?php echo $gglstmp_menu_del; ?></label><br /> 
  309. <label><input type='radio' name='gglstmp_menu' value="inf" /> <?php echo $gglstmp_menu_inf; ?></label> 
  310. </fieldset> 
  311. <?php if ( isset( $_POST['gglstmp_menu'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { 
  312. $gglstmp_wmt = new Google_Service_Webmasters( $gglstmp_client ); 
  313. $gglstmp_sv = new Google_Service_SiteVerification( $gglstmp_client ); 
  314. switch ( $_POST['gglstmp_menu'] ) { 
  315. case 'inf': 
  316. gglstmp_info_site( $gglstmp_wmt, $gglstmp_sv ); 
  317. break; 
  318. case 'ad': 
  319. gglstmp_add_site( $gglstmp_wmt, $gglstmp_sv ); 
  320. break; 
  321. case 'del': 
  322. gglstmp_del_site( $gglstmp_wmt, $gglstmp_sv ); 
  323. break; 
  324. default: 
  325. break; 
  326. } else { 
  327. $gglstmp_state = mt_rand(); 
  328. $gglstmp_client->setState( $gglstmp_state ); 
  329. $_SESSION[ 'gglstmp_state' . $gglstmp_blog_prefix ] = $gglstmp_client; 
  330. $gglstmp_auth_url = $gglstmp_client->createAuthUrl(); ?> 
  331. <p><?php _e( "Please authorize via your Google Account in order to add or delete a site and a sitemap file automatically or get information about this site in Google Webmaster Tools", 'google-sitemap-plugin' ); ?>.</p> 
  332. <a id="gglstmp_authorization_button" class="button-primary" href="<?php echo $gglstmp_auth_url; ?>" target="_blank" onclick="window.open(this.href, '', 'top='+(screen.height/2-560/2)+', left='+(screen.width/2-640/2)+', width=640, height=560, resizable=0, scrollbars=0, menubar=0, toolbar=0, status=1, location=0').focus(); return false;"><?php _e( 'Get Authorization Code', 'google-sitemap-plugin' ); ?></a> 
  333. <div id="gglstmp_authorization_form"> 
  334. <input id="gglstmp_authorization_code" name="gglstmp_authorization_code" type="text" autocomplete="off" maxlength="100" /> 
  335. <input id="gglstmp_authorize" class="button-primary" name="gglstmp_authorize" type="submit" value="<?php _e( 'Authorize', 'google-sitemap-plugin' ); ?>"> 
  336. </div> 
  337. <?php if ( isset( $_POST['gglstmp_authorization_code'] ) && isset( $_POST['gglstmp_authorize'] ) && check_admin_referer( $plugin_basename, 'gglstmp_nonce_name' ) ) { ?> 
  338. <div id="gglstmp_authorize_error"><?php _e( 'Invalid authorization code. Please, try again', 'google-sitemap-plugin' ); ?>.</div> 
  339. <?php } 
  340. } ?> 
  341. <br /> 
  342. <span class="bws_info"> 
  343. <?php echo __( 'You can always add your sitemap to Google Webmaster Tools manually. For more info see', 'google-sitemap-plugin' ) . 
  344. ' <a target="_blank" href="https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/edit">' . __( 'the instruction', 'google-sitemap-plugin' ) . '</a>.'; ?> 
  345. </span> 
  346. </td> 
  347. </tr> 
  348. </table> 
  349. <?php } ?> 
  350. <input type="hidden" name="gglstmp_submit" value="submit" /> 
  351. <p class="submit"> 
  352. <input id="bws-submit-button" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'google-sitemap-plugin' ); ?>" /> 
  353. </p> 
  354. <?php wp_nonce_field( $plugin_basename, 'gglstmp_nonce_name' ); ?> 
  355. </form> 
  356. <?php bws_form_restore_default_settings( $plugin_basename ); ?> 
  357. <div class="clear"></div> 
  358. <?php } 
  359. } elseif ( in_array( $_GET['action'], array( 'extra', 'custom_links' ) ) ) { 
  360. gglstmp_pro_block( "gglstmp_{$_GET['action']}_block", false ); 
  361. } elseif ( 'go_pro' == $_GET['action'] ) { 
  362. bws_go_pro_tab_show( $bws_hide_premium_options_check, $gglstmp_plugin_info, $plugin_basename, 'google-sitemap-plugin.php', 'google-sitemap-pro.php', 'google-sitemap-pro/google-sitemap-pro.php', 'google-sitemap', '28d4cf0b4ab6f56e703f46f60d34d039', '83', isset( $go_pro_result['pro_plugin_is_activated'] ) ); 
  363. bws_plugin_reviews_block( $gglstmp_plugin_info['Name'], 'google-sitemap-plugin' ); ?> 
  364. </div> 
  365. <?php }