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