function gglstmp_settings_page()
    {
        global $gglstmppr_url_home, $gglstmp_settings, $gglstmp_option_defaults, $gglstmppr_url, $wp_version, $gglstmp_plugin_info;
        $message = $error = "";
        $gglstmp_robots = get_option('gglstmp_robots');
        $gglstmppr_url_robot = ABSPATH . "robots.txt";
        $plugin_basename = plugin_basename(__FILE__);
        if (is_multisite()) {
            $home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\\s]/", "_", str_replace('http://', '', str_replace('https://', '', home_url())));
            $gglstmppr_url_sitemap = ABSPATH . "sitemap_" . $home_url . ".xml";
        } else {
            $gglstmppr_url_sitemap = ABSPATH . "sitemap.xml";
        }
        if (isset($_REQUEST['gglstmp_submit']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
            $gglstmp_settings['post_type'] = isset($_REQUEST['gglstmp_post_types']) ? $_REQUEST['gglstmp_post_types'] : array();
            $gglstmp_settings['taxonomy'] = isset($_REQUEST['gglstmp_taxonomies']) ? $_REQUEST['gglstmp_taxonomies'] : array();
            /*============================ Adding location of sitemap file to the robots.txt =============*/
            $gglstmp_robots_flag = isset($_POST['gglstmp_checkbox']) ? 1 : 0;
            if (file_exists($gglstmppr_url_robot) && !is_multisite()) {
                if (!is_writable($gglstmppr_url_robot)) {
                    @chmod($gglstmppr_url_robot, 0755);
                }
                if (is_writable($gglstmppr_url_robot)) {
                    $file_content = file_get_contents($gglstmppr_url_robot);
                    if (isset($_POST['gglstmp_checkbox']) && !preg_match('|Sitemap: ' . $gglstmppr_url_home . 'sitemap.xml|', $file_content)) {
                        file_put_contents($gglstmppr_url_robot, $file_content . "\nSitemap: " . $gglstmppr_url_home . "sitemap.xml");
                    } elseif (preg_match("|Sitemap: " . $gglstmppr_url_home . "sitemap.xml|", $file_content) && !isset($_POST['gglstmp_checkbox'])) {
                        $file_content = preg_replace("|\nSitemap: " . $gglstmppr_url_home . "sitemap.xml|", '', $file_content);
                        file_put_contents($gglstmppr_url_robot, $file_content);
                    }
                } else {
                    $error = __('Cannot edit "robots.txt". Check your permissions.', 'sitemap');
                    $gglstmp_robots_flag = 0;
                }
            }
            if (false === get_option('gglstmp_robots')) {
                add_option('gglstmp_robots', $gglstmp_robots_flag);
            } else {
                update_option('gglstmp_robots', $gglstmp_robots_flag);
            }
            $gglstmp_robots = get_option('gglstmp_robots');
            update_option('gglstmp_settings', $gglstmp_settings);
            if (!isset($_POST['gglstmp_authorize']) && !isset($_POST['gglstmp_logout']) && !isset($_POST['gglstmp_menu'])) {
                $message .= " " . __("Settings saved.", 'sitemap');
            }
        }
        if (isset($_POST['gglstmp_new']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
            $message = __("Your Sitemap file is created in the site root directory.", 'sitemap');
            gglstmp_sitemapcreate();
        }
        $gglstmp_result = get_post_types('', 'names');
        unset($gglstmp_result['revision']);
        unset($gglstmp_result['attachment']);
        unset($gglstmp_result['nav_menu_item']);
        $gglstmp_result_taxonomies = array('category' => 'Post category', 'post_tag' => 'Post tag');
        /* GO PRO */
        if (isset($_GET['action']) && 'go_pro' == $_GET['action']) {
            $go_pro_result = bws_go_pro_tab_check($plugin_basename);
            if (!empty($go_pro_result['error'])) {
                $error = $go_pro_result['error'];
            }
        }
        if (isset($_REQUEST['bws_restore_confirm']) && check_admin_referer($plugin_basename, 'bws_settings_nonce_name')) {
            $gglstmp_settings = $gglstmp_option_defaults;
            @unlink($gglstmppr_url_sitemap);
            /* remove sitemap.xml */
            /* clear robots.txt */
            if (file_exists($gglstmppr_url_robot) && !is_multisite()) {
                if (!is_writable($gglstmppr_url_robot)) {
                    @chmod($gglstmppr_url_robot, 0755);
                }
                if (is_writable($gglstmppr_url_robot)) {
                    $file_content = file_get_contents($gglstmppr_url_robot);
                    if (preg_match("|Sitemap: " . $gglstmppr_url_home . "sitemap.xml|", $file_content)) {
                        $file_content = preg_replace("|\nSitemap: " . $gglstmppr_url_home . "sitemap.xml|", '', $file_content);
                        file_put_contents($gglstmppr_url_robot, $file_content);
                    }
                } else {
                    $error = __('Cannot edit "robot.txt". Check your permissions.', 'sitemap');
                }
            }
            if (false === get_option('gglstmp_robots')) {
                add_option('gglstmp_robots', 0);
            } else {
                update_option('gglstmp_robots', 0);
            }
            $gglstmp_robots = get_option('gglstmp_robots');
            update_option('gglstmp_settings', $gglstmp_settings);
            $message = __('All plugin settings were restored.', 'sitemap');
        }
        ?>
		<div class="wrap">
			<div class="icon32 icon32-bws" id="icon-options-general"></div>
			<h2><?php 
        _e("Google Sitemap Settings", 'sitemap');
        ?>
</h2>
			<h2 class="nav-tab-wrapper">
				<a class="nav-tab<?php 
        if (!isset($_GET['action'])) {
            echo ' nav-tab-active';
        }
        ?>
" href="admin.php?page=google-sitemap-plugin.php"><?php 
        _e('Settings', 'sitemap');
        ?>
</a>
				<a class="nav-tab<?php 
        if (isset($_GET['action']) && 'extra' == $_GET['action']) {
            echo ' nav-tab-active';
        }
        ?>
" href="admin.php?page=google-sitemap-plugin.php&amp;action=extra"><?php 
        _e('Extra settings', 'sitemap');
        ?>
</a>
				<a class="nav-tab" href="http://bestwebsoft.com/products/google-sitemap/faq/" target="_blank"><?php 
        _e('FAQ', 'sitemap');
        ?>
</a>
				<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&amp;action=go_pro"><?php 
        _e('Go PRO', 'sitemap');
        ?>
</a>
			</h2>
			<?php 
        if (!isset($_GET['action']) && is_multisite() && !is_subdomain_install()) {
            ?>
				<div id="gglstmp_check_sitemap_block" class="error">
					<p>
						<?php 
            printf('<strong>%s</strong> %s', __('Warning:', 'sitemap'), sprintf(__('To have an access to subsites XML files, please add the following rule %s to your %s file in %s after line %s.', 'sitemap'), '<code>RewriteRule ([^/]+\\.xml)$ $1 [L]</code>', '<strong>.htaccess</strong>', sprintf('<strong>"%s"</strong>', ABSPATH), '<strong>"RewriteBase"</strong>'));
            ?>
					</p>
					<div style="margin: .5em 0; padding: 2px;">
						<form action="admin.php?page=google-sitemap-plugin.php" method='post' id="gglstmp_check_sitemap">
							<input type="submit" class="button-secondary" name="gglstmp_check_sitemap" value="<?php 
            _e('Сheck Access', 'sitemap');
            ?>
" />
							<?php 
            wp_nonce_field($plugin_basename, 'gglstmp_nonce_sitemap');
            ?>
						</form>
						<?php 
            if (isset($_POST['gglstmp_check_sitemap']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_sitemap')) {
                $gglstmp_background = array('200' => '#f8fdf5', '404' => '#fdf6f6');
                if ($gglstmp_settings['sitemap'] && file_exists($gglstmp_settings['sitemap']['path'])) {
                    $gglstmp_status = gglstmp_check_sitemap($gglstmp_settings['sitemap']['loc']);
                    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']);
                }
            }
            ?>
					</div>
				</div>
			<?php 
        }
        ?>
			<div id="gglstmp_settings_notice" class="updated fade" style="display:none"><p><strong><?php 
        _e("Notice:", 'sitemap');
        ?>
</strong> <?php 
        _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'sitemap');
        ?>
</p></div>
			<div class="updated fade" <?php 
        if ("" != $error || $message == "") {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $message;
        ?>
</strong></p></div>
			<div class="error" <?php 
        if ("" == $error) {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $error;
        ?>
</strong></p></div>
			<?php 
        if (!isset($_GET['action'])) {
            if (isset($_REQUEST['bws_restore_default']) && check_admin_referer($plugin_basename, 'bws_settings_nonce_name')) {
                bws_form_restore_default_confirm($plugin_basename);
            } else {
                ?>
					<form action="admin.php?page=google-sitemap-plugin.php" method='post' id="gglstmp_auth" name="gglstmp_auth">
						<?php 
                /*=============================== Creating sitemap file ====================================*/
                if (file_exists($gglstmppr_url_sitemap)) {
                    if (is_multisite()) {
                        echo '<p><a href="' . $gglstmppr_url_home . "sitemap_" . $home_url . '.xml" target="_new">' . __("The Sitemap file", 'sitemap') . "</a> " . __("already exists. If you would like to replace it with a new one, please choose the necessary box below.", 'sitemap') . "</p>";
                    } else {
                        echo '<p><a href="' . $gglstmppr_url_home . 'sitemap.xml" target="_new">' . __("The Sitemap file", 'sitemap') . "</a> " . __("already exists. If you would like to replace it with a new one, please choose the necessary box below.", 'sitemap') . "</p>";
                    }
                } else {
                    gglstmp_sitemapcreate();
                    if (is_multisite()) {
                        echo '<p><a href="' . $gglstmppr_url_home . "sitemap_" . $home_url . '.xml" target="_new">' . __("Your Sitemap file", 'sitemap') . "</a> " . __("is created in the site root directory.", 'sitemap') . "</p>";
                    } else {
                        echo '<p><a href="' . $gglstmppr_url_home . 'sitemap.xml" target="_new">' . __("Your Sitemap file", 'sitemap') . "</a> " . __("is created in the site root directory.", 'sitemap') . "</p>";
                    }
                }
                /*========================================== Recreating sitemap file ====================================*/
                if (is_multisite()) {
                    echo '<p>' . __("If you do not want a sitemap file to be added to Google Webmaster Tools automatically, you can do it using", 'sitemap') . " <a href=\"https://www.google.com/webmasters/tools/home?hl=en\">" . __("this", 'sitemap') . "</a> " . __("link - sign in, choose the necessary site, go to 'Sitemaps' and fill out the mandatory field", 'sitemap') . " - '" . $gglstmppr_url_home . "sitemap_" . $home_url . ".xml'.</p>";
                } else {
                    echo '<p>' . __("If you do not want a sitemap file to be added to Google Webmaster Tools automatically, you can do it using", 'sitemap') . " <a href=\"https://www.google.com/webmasters/tools/home?hl=en\">" . __("this", 'sitemap') . "</a> " . __("link - sign in, choose the necessary site, go to 'Sitemaps' and fill out the mandatory field", 'sitemap') . " - '" . $gglstmppr_url_home . "sitemap.xml'.</p>";
                }
                ?>
						<table class="form-table">
							<tr valign="top">
								<td colspan="2">
									<label><input type='checkbox' name='gglstmp_new' value="1" /> <?php 
                _e("I want to create a new sitemap file or update the existing one", 'sitemap');
                ?>
</label>
								</td>
							</tr>
							<?php 
                if (is_multisite()) {
                    ?>
								<tr valign="top">
									<td colspan="2">
										<label><input type='checkbox' disabled="disabled" name='gglstmp_checkbox' value="1" <?php 
                    if (1 == $gglstmp_robots) {
                        echo 'checked="checked"';
                    }
                    ?>
 /> <?php 
                    _e("I want to add sitemap file path in robots.txt", 'sitemap');
                    ?>
</label>
										<p style="color:red"><?php 
                    _e("Since you are using multisiting, the plugin does not allow to add a sitemap to robots.txt", 'sitemap');
                    ?>
</div>
									</td>
								</tr>
							<?php 
                } else {
                    ?>
								<tr valign="top">
									<td colspan="2">
										<label><input type='checkbox' name='gglstmp_checkbox' value="1" <?php 
                    if (1 == $gglstmp_robots) {
                        echo 'checked="checked"';
                    }
                    ?>
 /> <?php 
                    _e("I want to add sitemap file path in", 'sitemap');
                    ?>
 <a href="<?php 
                    echo $gglstmppr_url_home;
                    ?>
robots.txt" target="_new">robots.txt</a></label>
									</td>
								</tr>
							<?php 
                }
                ?>
							<tr valign="top">
								<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:', 'sitemap');
                ?>
 </th>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<fieldset>
										<?php 
                foreach ($gglstmp_result as $key => $value) {
                    ?>
											<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 />
										<?php 
                }
                ?>
									</fieldset>
								</td>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<fieldset>
										<?php 
                foreach ($gglstmp_result_taxonomies as $key => $value) {
                    ?>
											<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 />
										<?php 
                }
                ?>
									</fieldset>
								</td>
							</tr>
						</table>
						<div class="bws_pro_version_bloc">
							<div class="bws_pro_version_table_bloc">
								<div class="bws_table_bg"></div>
								<table class="form-table bws_pro_version">
									<tr valign="top">
										<th><?php 
                _e('XML Sitemap "Change Frequency" parameter', 'sitemap');
                ?>
</th>
										<td>
											<select name="gglstmp_sitemap_change_frequency">
												<option value="always"><?php 
                _e('Always', 'sitemap');
                ?>
</option>
												<option value="hourly"><?php 
                _e('Hourly', 'sitemap');
                ?>
</option>
												<option value="daily"><?php 
                _e('Daily', 'sitemap');
                ?>
</option>
												<option value="weekly"><?php 
                _e('Weekly', 'sitemap');
                ?>
</option>
												<option selected value="monthly"><?php 
                _e('Monthly', 'sitemap');
                ?>
</option>
												<option value="yearly"><?php 
                _e('Yearly', 'sitemap');
                ?>
</option>
												<option value="never"><?php 
                _e('Never', 'sitemap');
                ?>
</option>
											</select><br />
											<span style="color: #888888;font-size: 10px;"><?php 
                _e('This value is used in the sitemap file and provides general information to search engines. The sitemap itself is generated once and will be re-generated when you create or update any post or page.', 'sitemap');
                ?>
</span>
										</td>
									</tr>
								</table>
							</div>
							<div class="bws_pro_version_tooltip">
								<div class="bws_info">
									<?php 
                _e('Unlock premium options by upgrading to PRO version.', 'sitemap');
                ?>
									<a href="http://bestwebsoft.com/products/google-sitemap/?k=28d4cf0b4ab6f56e703f46f60d34d039&pn=83&v=<?php 
                echo $gglstmp_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
" target="_blank" title="Google Sitemap Pro"><?php 
                _e('Learn More', 'sitemap');
                ?>
</a>
								</div>
								<a class="bws_button" href="http://bestwebsoft.com/products/google-sitemap/buy/?k=28d4cf0b4ab6f56e703f46f60d34d039&pn=83&v=<?php 
                echo $gglstmp_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
" target="_blank" title="Google Sitemap Pro">
									<?php 
                _e('Go', 'sitemap');
                ?>
 <strong>PRO</strong>
								</a>
								<div class="clear"></div>
							</div>
						</div>
						<table class="form-table">
							<?php 
                if (!function_exists('curl_init')) {
                    ?>
								<tr valign="top">
									<td colspan="2" class="gglstmp_error">
										<?php 
                    _e("This hosting does not support сURL, so you cannot add a sitemap file automatically.", 'sitemap');
                    ?>
									</td>
								</tr>
							<?php 
                } else {
                    ?>
								<tr id="gglstmp_google_webmaster" valign="top">
									<th scope="row"><?php 
                    _e('Remote work with Google Webmaster Tools', 'sitemap');
                    ?>
</th>									
									<td>
										<?php 
                    $gglstmp_client = gglstmp_client();
                    $gglstmp_blog_prefix = '_' . get_current_blog_id();
                    if (isset($_POST['gglstmp_logout']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                        unset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]);
                        unset($gglstmp_settings['authorization_code']);
                        update_option('gglstmp_settings', $gglstmp_settings);
                    }
                    if (isset($_POST['gglstmp_authorization_code']) && !empty($_POST['gglstmp_authorization_code']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                        try {
                            $gglstmp_client->authenticate($_POST['gglstmp_authorization_code']);
                            $gglstmp_settings['authorization_code'] = $_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix] = $gglstmp_client->getAccessToken();
                            update_option('gglstmp_settings', $gglstmp_settings);
                        } catch (Exception $e) {
                        }
                    }
                    if (!isset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]) && isset($gglstmp_settings['authorization_code'])) {
                        $_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix] = $gglstmp_settings['authorization_code'];
                    }
                    if (isset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix])) {
                        $gglstmp_client->setAccessToken($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]);
                    }
                    if ($gglstmp_client->getAccessToken()) {
                        ?>
											<div id="gglstmp_logout_button">
												<input class="button-secondary" name="gglstmp_logout" type="submit" value="<?php 
                        _e('Log out from Google Webmaster Tools', 'sitemap');
                        ?>
" />
											</div>
											<?php 
                        $gglstmp_menu_ad = __("I want to add this site to Google Webmaster Tools", 'sitemap');
                        $gglstmp_menu_del = __("I want to delete this site from Google Webmaster Tools", 'sitemap');
                        $gglstmp_menu_inf = __("I want to get info about this site in Google Webmaster Tools", 'sitemap');
                        ?>
											<fieldset>
												<label><input type='radio' name='gglstmp_menu' value="ad" /> <?php 
                        echo $gglstmp_menu_ad;
                        ?>
</label><br />
												<label><input type='radio' name='gglstmp_menu' value="del" /> <?php 
                        echo $gglstmp_menu_del;
                        ?>
</label><br />
												<label><input type='radio' name='gglstmp_menu' value="inf" /> <?php 
                        echo $gglstmp_menu_inf;
                        ?>
</label><br />
												<span class="gglstmp_span">
													<?php 
                        _e('In case you failed to add a sitemap to Google automatically using this plugin, it is possible to do it manually', 'sitemap');
                        ?>
:
													<a target="_blank" href="https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/edit"><?php 
                        _e('View the Instruction', 'sitemap');
                        ?>
</a>
												</span>
											</fieldset>
											<?php 
                        if (isset($_POST['gglstmp_menu']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                            $gglstmp_wmt = new Google_Service_Webmasters($gglstmp_client);
                            $gglstmp_sv = new Google_Service_SiteVerification($gglstmp_client);
                            switch ($_POST['gglstmp_menu']) {
                                case 'inf':
                                    gglstmp_info_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                case 'ad':
                                    gglstmp_add_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                case 'del':
                                    gglstmp_del_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                default:
                                    break;
                            }
                        }
                    } else {
                        $gglstmp_state = mt_rand();
                        $gglstmp_client->setState($gglstmp_state);
                        $_SESSION['gglstmp_state' . $gglstmp_blog_prefix] = $gglstmp_client;
                        $gglstmp_auth_url = $gglstmp_client->createAuthUrl();
                        ?>
											<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.", 'sitemap');
                        ?>
</p>
											<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', 'sitemap');
                        ?>
</a>
											<div id="gglstmp_authorization_form">
												<input id="gglstmp_authorization_code" name="gglstmp_authorization_code" type="text" autocomplete="off" maxlength="100" />
												<input id="gglstmp_authorize" class="button-primary" name="gglstmp_authorize" type="submit" value="<?php 
                        _e('Authorize', 'sitemap');
                        ?>
">
											</div>
											<?php 
                        if (isset($_POST['gglstmp_authorization_code']) && isset($_POST['gglstmp_authorize']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                            ?>
												<div id="gglstmp_authorize_error"><?php 
                            _e('Invalid authorization code. Please, try again.', 'sitemap');
                            ?>
</div>
											<?php 
                        }
                    }
                    ?>
									</td>
								</tr>
							<?php 
                }
                ?>
						</table>
						<input type="hidden" name="gglstmp_submit" value="submit" />
						<p class="submit">
							<input type="submit" class="button-primary" value="<?php 
                _e('Save Changes', 'sitemap');
                ?>
" />
						</p>
						<?php 
                wp_nonce_field($plugin_basename, 'gglstmp_nonce_name');
                ?>
					</form>
					<?php 
                bws_form_restore_default_settings($plugin_basename);
                ?>
					<div class="clear"></div>
			<?php 
            }
        } elseif ('extra' == $_GET['action']) {
            ?>
				<div class="bws_pro_version_bloc">
					<div class="bws_pro_version_table_bloc">
						<div class="bws_table_bg"></div>
						<table class="form-table bws_pro_version">
							<tr valign="top">
								<td colspan="2">
									<?php 
            _e('Please choose the necessary post types and taxonomies the links to which are to be added to the sitemap:', 'sitemap');
            ?>
								</td>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<label>
										<input disabled="disabled" checked="checked" id="gglstmp_jstree_url" type="checkbox" name="gglstmp_jstree_url" value="1" />
										<?php 
            _e("Show URL for pages", 'sitemap');
            ?>
									</label>
								</td>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<img src="<?php 
            echo plugins_url('images/pro_screen_1.png', __FILE__);
            ?>
" alt="<?php 
            _e("Example of site pages' tree", 'sitemap');
            ?>
" title="<?php 
            _e("Example of site pages' tree", 'sitemap');
            ?>
" />
								</td>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<input disabled="disabled" type="submit" class="button-primary" value="<?php 
            _e('Save Changes', 'sitemap');
            ?>
" />
								</td>
							</tr>
						</table>
					</div>
					<div class="bws_pro_version_tooltip">
						<div class="bws_info">
							<?php 
            _e('Unlock premium options by upgrading to PRO version.', 'sitemap');
            ?>
							<a href="http://bestwebsoft.com/products/google-sitemap/?k=28d4cf0b4ab6f56e703f46f60d34d039&pn=83&v=<?php 
            echo $gglstmp_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
" target="_blank" title="Google Sitemap Pro"><?php 
            _e('Learn More', 'sitemap');
            ?>
</a>
						</div>
						<a class="bws_button" href="http://bestwebsoft.com/products/google-sitemap/buy/?k=28d4cf0b4ab6f56e703f46f60d34d039&pn=83&v=<?php 
            echo $gglstmp_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
" target="_blank" title="Google Sitemap Pro">
							<?php 
            _e('Go', 'sitemap');
            ?>
 <strong>PRO</strong>
						</a>
						<div class="clear"></div>
					</div>
				</div>
			<?php 
        } elseif ('go_pro' == $_GET['action']) {
            bws_go_pro_tab($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']));
        }
        bws_plugin_reviews_block($gglstmp_plugin_info['Name'], 'google-sitemap-plugin');
        ?>
		</div>
	<?php 
    }
    function gglstmp_settings_page()
    {
        global $gglstmp_url_home, $gglstmp_settings, $gglstmp_option_defaults, $gglstmp_url, $wp_version, $gglstmp_plugin_info;
        if (!isset($_GET['action']) || 'go_pro' != $_GET['action']) {
            require_once dirname(__FILE__) . '/includes/pro_banners.php';
        }
        $message = $error = "";
        $gglstmp_robots = get_option('gglstmp_robots');
        $gglstmp_url_robot = ABSPATH . "robots.txt";
        $plugin_basename = plugin_basename(__FILE__);
        /* Check htaccess plugin */
        $gglstmp_htaccess_active = false;
        if (is_multisite() && !is_subdomain_install()) {
            $all_plugins = get_plugins();
            $is_network = is_network_admin();
            $admin_url = $is_network ? network_admin_url('/') : admin_url('/');
            $gglstmp_htaccess = gglstmp_plugin_status(array('htaccess/htaccess.php', 'htaccess-pro/htaccess-pro.php'), $all_plugins, $is_network);
            $gglstmp_htaccess_options = false;
            if ($gglstmp_htaccess['status'] == 'actived') {
                if ($gglstmp_htaccess['plugin'] == 'htaccess/htaccess.php') {
                    global $htccss_options;
                    register_htccss_settings();
                    $gglstmp_htaccess_options =& $htccss_options;
                    $gglstmp_htaccess_prefix = 'htccss';
                }
                if ($gglstmp_htaccess['plugin'] == 'htaccess-pro/htaccess-pro.php') {
                    global $htccsspr_options;
                    register_htccsspr_settings();
                    $gglstmp_htaccess_options =& $htccsspr_options;
                    $gglstmp_htaccess_prefix = 'htccsspr';
                }
                $gglstmp_htaccess_active = true;
                $gglstmp_htaccess_options_name = "{$gglstmp_htaccess_prefix}_options";
                $gglstmp_htaccess_function_generate = "{$gglstmp_htaccess_prefix}_generate_htaccess";
                $gglstmp_htaccess_function_check = "{$gglstmp_htaccess_prefix}_check_xml_access";
                if (function_exists($gglstmp_htaccess_function_check)) {
                    $gglstmp_htaccess_check = $gglstmp_htaccess_function_check();
                    if ($gglstmp_htaccess_check != $gglstmp_htaccess_options['allow_xml']) {
                        $gglstmp_htaccess_options['allow_xml'] = $gglstmp_htaccess_check;
                        update_site_option($gglstmp_htaccess_options_name, $gglstmp_htaccess_options);
                    }
                }
            }
        }
        if (is_multisite()) {
            $home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
            $gglstmp_url_sitemap = ABSPATH . "sitemap_" . $home_url . ".xml";
        } else {
            $gglstmp_url_sitemap = ABSPATH . "sitemap.xml";
        }
        if (isset($_REQUEST['gglstmp_submit']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
            if (isset($_POST['bws_hide_premium_options'])) {
                $hide_result = bws_hide_premium_options($gglstmp_settings);
                $gglstmp_settings = $hide_result['options'];
            }
            if ($gglstmp_htaccess_active && $gglstmp_htaccess_options && function_exists($gglstmp_htaccess_function_generate)) {
                $gglstmp_allow_xml = isset($_POST['gglstmp_allow_xml']) && $_POST['gglstmp_allow_xml'] == 1 ? 1 : 0;
                if ($gglstmp_allow_xml != $gglstmp_htaccess_options['allow_xml']) {
                    $gglstmp_htaccess_options['allow_xml'] = $gglstmp_allow_xml;
                    update_site_option($gglstmp_htaccess_options_name, $gglstmp_htaccess_options);
                    $gglstmp_htaccess_function_generate();
                }
            }
            $gglstmp_settings['post_type'] = isset($_REQUEST['gglstmp_post_types']) ? $_REQUEST['gglstmp_post_types'] : array();
            $gglstmp_settings['taxonomy'] = isset($_REQUEST['gglstmp_taxonomies']) ? $_REQUEST['gglstmp_taxonomies'] : array();
            /*============================ Adding location of sitemap file to the robots.txt =============*/
            $gglstmp_robots_flag = isset($_POST['gglstmp_checkbox']) ? 1 : 0;
            if (file_exists($gglstmp_url_robot) && !is_multisite()) {
                if (!is_writable($gglstmp_url_robot)) {
                    @chmod($gglstmp_url_robot, 0755);
                }
                if (is_writable($gglstmp_url_robot)) {
                    $file_content = file_get_contents($gglstmp_url_robot);
                    if (isset($_POST['gglstmp_checkbox']) && !preg_match('|Sitemap: ' . $gglstmp_url_home . 'sitemap.xml|', $file_content)) {
                        file_put_contents($gglstmp_url_robot, $file_content . "\nSitemap: " . $gglstmp_url_home . "sitemap.xml");
                    } elseif (preg_match("|Sitemap: " . $gglstmp_url_home . "sitemap.xml|", $file_content) && !isset($_POST['gglstmp_checkbox'])) {
                        $file_content = preg_replace("|\nSitemap: " . $gglstmp_url_home . "sitemap.xml|", '', $file_content);
                        file_put_contents($gglstmp_url_robot, $file_content);
                    }
                } else {
                    $error = __('Cannot edit "robots.txt". Check your permissions', 'google-sitemap-plugin');
                    $gglstmp_robots_flag = 0;
                }
            }
            if (false === get_option('gglstmp_robots')) {
                add_option('gglstmp_robots', $gglstmp_robots_flag);
            } else {
                update_option('gglstmp_robots', $gglstmp_robots_flag);
            }
            $gglstmp_robots = get_option('gglstmp_robots');
            update_option('gglstmp_settings', $gglstmp_settings);
            if (!isset($_POST['gglstmp_authorize']) && !isset($_POST['gglstmp_logout']) && !isset($_POST['gglstmp_menu'])) {
                $message .= " " . __("Settings saved", 'google-sitemap-plugin');
            }
        }
        /*## check banner */
        $bws_hide_premium_options_check = bws_hide_premium_options_check($gglstmp_settings);
        if (isset($_POST['gglstmp_new']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
            $message = __("Your Sitemap file has been created in the site root directory", 'google-sitemap-plugin');
            gglstmp_sitemapcreate();
        }
        $gglstmp_result = get_post_types('', 'names');
        unset($gglstmp_result['revision']);
        unset($gglstmp_result['attachment']);
        unset($gglstmp_result['nav_menu_item']);
        $gglstmp_result_taxonomies = array('category' => 'Post category', 'post_tag' => 'Post tag');
        /* GO PRO */
        if (isset($_GET['action']) && 'go_pro' == $_GET['action']) {
            $go_pro_result = bws_go_pro_tab_check($plugin_basename, 'gglstmp_settings');
            if (!empty($go_pro_result['error'])) {
                $error = $go_pro_result['error'];
            } elseif (!empty($go_pro_result['message'])) {
                $message = $go_pro_result['message'];
            }
        }
        if (isset($_REQUEST['bws_restore_confirm']) && check_admin_referer($plugin_basename, 'bws_settings_nonce_name')) {
            $gglstmp_settings = $gglstmp_option_defaults;
            @unlink($gglstmp_url_sitemap);
            /* remove sitemap.xml */
            /* clear robots.txt */
            if (file_exists($gglstmp_url_robot) && !is_multisite()) {
                if (!is_writable($gglstmp_url_robot)) {
                    @chmod($gglstmp_url_robot, 0755);
                }
                if (is_writable($gglstmp_url_robot)) {
                    $file_content = file_get_contents($gglstmp_url_robot);
                    if (preg_match("|Sitemap: " . $gglstmp_url_home . "sitemap.xml|", $file_content)) {
                        $file_content = preg_replace("|\nSitemap: " . $gglstmp_url_home . "sitemap.xml|", '', $file_content);
                        file_put_contents($gglstmp_url_robot, $file_content);
                    }
                } else {
                    $error = __('Cannot edit "robot.txt". Check your permissions', 'google-sitemap-plugin');
                }
            }
            if (false === get_option('gglstmp_robots')) {
                add_option('gglstmp_robots', 0);
            } else {
                update_option('gglstmp_robots', 0);
            }
            $gglstmp_robots = get_option('gglstmp_robots');
            update_option('gglstmp_settings', $gglstmp_settings);
            $message = __('All plugin settings were restored.', 'google-sitemap-plugin');
        }
        ?>
		<div class="wrap">
			<h1 style="line-height: normal;"><?php 
        _e("Google Sitemap Settings", 'google-sitemap-plugin');
        ?>
</h1>
			<h2 class="nav-tab-wrapper">
				<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>
				<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&amp;action=custom_links"><?php 
        _e('Custom links', 'google-sitemap-plugin');
        ?>
</a>
				<a class="nav-tab<?php 
        if (isset($_GET['action']) && 'extra' == $_GET['action']) {
            echo ' nav-tab-active';
        }
        ?>
" href="admin.php?page=google-sitemap-plugin.php&amp;action=extra"><?php 
        _e('Extra settings', 'google-sitemap-plugin');
        ?>
</a>
				<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&amp;action=go_pro"><?php 
        _e('Go PRO', 'google-sitemap-plugin');
        ?>
</a>
			</h2>
			<?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)) {
            ?>
				<div id="gglstmp_check_sitemap_block" class="error below-h2">
					<p>
						<?php 
            printf('<strong>%s</strong> %s', __('Warning:', 'google-sitemap-plugin'), sprintf(__('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') . '.', '<code>RewriteRule ([^/]+\\.xml)$ $1 [L]</code>', '<strong>.htaccess</strong>', sprintf('<strong>"%s"</strong>', ABSPATH), '<strong>"RewriteBase"</strong>', sprintf('<strong>"%s"</strong>', __('Allow access to XML files', 'google-sitemap-plugin'))));
            ?>
					</p>
					<div style="margin: .5em 0; padding: 2px;">
						<form action="admin.php?page=google-sitemap-plugin.php" method='post' id="gglstmp_check_sitemap">
							<input type="submit" class="button-secondary" name="gglstmp_check_sitemap" value="<?php 
            _e('Сheck Access', 'google-sitemap-plugin');
            ?>
" />
							<?php 
            wp_nonce_field($plugin_basename, 'gglstmp_nonce_sitemap');
            ?>
						</form>
						<?php 
            if (isset($_POST['gglstmp_check_sitemap']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_sitemap')) {
                $gglstmp_background = array('200' => '#f8fdf5', '404' => '#fdf6f6');
                if ($gglstmp_settings['sitemap'] && file_exists($gglstmp_settings['sitemap']['path'])) {
                    $gglstmp_status = gglstmp_check_sitemap($gglstmp_settings['sitemap']['loc']);
                    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']);
                }
            }
            ?>
					</div>
				</div>
			<?php 
        }
        bws_show_settings_notice();
        ?>
			<div class="updated fade below-h2" <?php 
        if ("" != $error || $message == "") {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $message;
        ?>
.</strong></p></div>
			<div class="error below-h2" <?php 
        if ("" == $error) {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $error;
        ?>
.</strong></p></div>
			<?php 
        if (!isset($_GET['action'])) {
            if (isset($_REQUEST['bws_restore_default']) && check_admin_referer($plugin_basename, 'bws_settings_nonce_name')) {
                bws_form_restore_default_confirm($plugin_basename);
            } else {
                ?>
					<form class="bws_form" action="admin.php?page=google-sitemap-plugin.php" method='post' name="gglstmp_auth">
						<?php 
                /*=============================== Creating sitemap file ====================================*/
                if (file_exists($gglstmp_url_sitemap)) {
                    if (is_multisite()) {
                        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>";
                    } else {
                        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>";
                    }
                } else {
                    gglstmp_sitemapcreate();
                    if (is_multisite()) {
                        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>";
                    } else {
                        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>";
                    }
                }
                ?>
						<table class="form-table">
							<tr valign="top">
								<td colspan="2">
									<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>
								</td>
							</tr>
							<?php 
                if (is_multisite()) {
                    ?>
								<tr valign="top">
									<td colspan="2">
										<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>
										<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>
									</td>
								</tr>
							<?php 
                } else {
                    ?>
								<tr valign="top">
									<td colspan="2">
										<!-- for robots.txt we need to use site_url instead home_url ! -->
										<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>
									</td>
								</tr>
							<?php 
                }
                ?>
							<tr valign="top">
								<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>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<fieldset>
										<?php 
                foreach ($gglstmp_result as $key => $value) {
                    ?>
											<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 />
										<?php 
                }
                ?>
									</fieldset>
								</td>
							</tr>
							<tr valign="top">
								<td colspan="2">
									<fieldset>
										<?php 
                foreach ($gglstmp_result_taxonomies as $key => $value) {
                    ?>
											<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 />
										<?php 
                }
                ?>
									</fieldset>
								</td>
							</tr>
							<?php 
                if (is_multisite() && !is_subdomain_install()) {
                    $gglstmp_plugin_name = isset($gglstmp_htaccess['plugin_info']['Name']) ? $gglstmp_htaccess['plugin_info']['Name'] : 'Htaccess by BestWebSoft';
                    $gglstmp_attr_checked = $gglstmp_attr_disabled = '';
                    $gglstmp_plugin_notice = sprintf(__('This option will be applied to all websites in the network', 'google-sitemap-plugin'));
                    if ('deactivated' == $gglstmp_htaccess['status']) {
                        $gglstmp_attr_disabled = 'disabled="disabled"';
                        $gglstmp_plugin_notice = sprintf(__('You should %s to use this functionality', 'google-sitemap-plugin'), 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));
                    } elseif ('not_installed' == $gglstmp_htaccess['status']) {
                        $gglstmp_attr_disabled = 'disabled="disabled"';
                        $gglstmp_plugin_notice = sprintf(__('You should %s to use this functionality', 'google-sitemap-plugin'), 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));
                    }
                    if ('1' == $gglstmp_htaccess_options['allow_xml'] && $gglstmp_attr_disabled == '') {
                        $gglstmp_attr_checked = 'checked="checked"';
                    }
                    ?>
								<tr valign="top" id="gglstmp_allow_xml_block">
									<th scope="row"><?php 
                    _e('Allow access to XML files', 'google-sitemap-plugin');
                    ?>
</th>
									<td>
										<label><input <?php 
                    printf("%s %s", $gglstmp_attr_checked, $gglstmp_attr_disabled);
                    ?>
 type="checkbox" name="gglstmp_allow_xml" value="1" /></label>
										<div class="bws_help_box dashicons dashicons-editor-help">
											<div class="bws_hidden_help_text" style="min-width: 270px;">
												<p><?php 
                    _e('The following string will be added to your .htaccess file', 'google-sitemap-plugin');
                    ?>
:</p>
												<code>RewriteRule ([^/]+\.xml)$ $1 [L]</code>
											</div>
										</div>
										<span class="bws_info"><?php 
                    echo $gglstmp_plugin_notice;
                    ?>
</span><br />
									</td>
								</tr>
							<?php 
                }
                ?>
						</table>
						<?php 
                gglstmp_pro_block('gglstmp_frequency_block');
                if (!function_exists('curl_init')) {
                    ?>
							<p class="gglstmp_error">
								<strong><?php 
                    _e("This hosting does not support сURL, so you cannot add a sitemap file automatically", 'google-sitemap-plugin');
                    ?>
.</strong>
								<br />
								<span class="bws_info">
									<?php 
                    echo __('You can always add your sitemap to Google Webmaster Tools manually. For more info see', 'google-sitemap-plugin') . '&nbsp;<a target="_blank" href="https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/edit">' . __('the instruction', 'google-sitemap-plugin') . '</a>.';
                    ?>
								</span>
							</p>
						<?php 
                } else {
                    ?>
							<table class="form-table">
								<tr id="gglstmp_google_webmaster" valign="top">
									<th scope="row"><?php 
                    _e('Remote work with Google Webmaster Tools', 'google-sitemap-plugin');
                    ?>
</th>
									<td>
										<?php 
                    $gglstmp_client = gglstmp_client();
                    $gglstmp_blog_prefix = '_' . get_current_blog_id();
                    if (isset($_POST['gglstmp_logout']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                        unset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]);
                        unset($gglstmp_settings['authorization_code']);
                        update_option('gglstmp_settings', $gglstmp_settings);
                    }
                    if (isset($_POST['gglstmp_authorization_code']) && !empty($_POST['gglstmp_authorization_code']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                        try {
                            $gglstmp_client->authenticate($_POST['gglstmp_authorization_code']);
                            $gglstmp_settings['authorization_code'] = $_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix] = $gglstmp_client->getAccessToken();
                            update_option('gglstmp_settings', $gglstmp_settings);
                        } catch (Exception $e) {
                        }
                    }
                    if (!isset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]) && isset($gglstmp_settings['authorization_code'])) {
                        $_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix] = $gglstmp_settings['authorization_code'];
                    }
                    if (isset($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix])) {
                        $gglstmp_client->setAccessToken($_SESSION['gglstmp_authorization_code' . $gglstmp_blog_prefix]);
                    }
                    if ($gglstmp_client->getAccessToken()) {
                        ?>
											<div id="gglstmp_logout_button">
												<input class="button-secondary" name="gglstmp_logout" type="submit" value="<?php 
                        _e('Log out from Google Webmaster Tools', 'google-sitemap-plugin');
                        ?>
" />
											</div>
											<?php 
                        $gglstmp_menu_ad = __("add this site to Google Webmaster Tools", 'google-sitemap-plugin');
                        $gglstmp_menu_del = __("delete this site from Google Webmaster Tools", 'google-sitemap-plugin');
                        $gglstmp_menu_inf = __("get info about this site in Google Webmaster Tools", 'google-sitemap-plugin');
                        ?>
											<fieldset>
												<label><input type='radio' name='gglstmp_menu' value="ad" /> <?php 
                        echo $gglstmp_menu_ad;
                        ?>
</label><br />
												<label><input type='radio' name='gglstmp_menu' value="del" /> <?php 
                        echo $gglstmp_menu_del;
                        ?>
</label><br />
												<label><input type='radio' name='gglstmp_menu' value="inf" /> <?php 
                        echo $gglstmp_menu_inf;
                        ?>
</label>
											</fieldset>
											<?php 
                        if (isset($_POST['gglstmp_menu']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                            $gglstmp_wmt = new Google_Service_Webmasters($gglstmp_client);
                            $gglstmp_sv = new Google_Service_SiteVerification($gglstmp_client);
                            switch ($_POST['gglstmp_menu']) {
                                case 'inf':
                                    gglstmp_info_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                case 'ad':
                                    gglstmp_add_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                case 'del':
                                    gglstmp_del_site($gglstmp_wmt, $gglstmp_sv);
                                    break;
                                default:
                                    break;
                            }
                        }
                    } else {
                        $gglstmp_state = mt_rand();
                        $gglstmp_client->setState($gglstmp_state);
                        $_SESSION['gglstmp_state' . $gglstmp_blog_prefix] = $gglstmp_client;
                        $gglstmp_auth_url = $gglstmp_client->createAuthUrl();
                        ?>
											<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>
											<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>
											<div id="gglstmp_authorization_form">
												<input id="gglstmp_authorization_code" name="gglstmp_authorization_code" type="text" autocomplete="off" maxlength="100" />
												<input id="gglstmp_authorize" class="button-primary" name="gglstmp_authorize" type="submit" value="<?php 
                        _e('Authorize', 'google-sitemap-plugin');
                        ?>
">
											</div>
											<?php 
                        if (isset($_POST['gglstmp_authorization_code']) && isset($_POST['gglstmp_authorize']) && check_admin_referer($plugin_basename, 'gglstmp_nonce_name')) {
                            ?>
												<div id="gglstmp_authorize_error"><?php 
                            _e('Invalid authorization code. Please, try again', 'google-sitemap-plugin');
                            ?>
.</div>
											<?php 
                        }
                    }
                    ?>
										<br />
										<span class="bws_info">
											<?php 
                    echo __('You can always add your sitemap to Google Webmaster Tools manually. For more info see', 'google-sitemap-plugin') . '&nbsp;<a target="_blank" href="https://docs.google.com/document/d/1VOJx_OaasVskCqi9fsAbUmxfsckoagPU5Py97yjha9w/edit">' . __('the instruction', 'google-sitemap-plugin') . '</a>.';
                    ?>
										</span>
									</td>
								</tr>
							</table>
						<?php 
                }
                ?>
						<input type="hidden" name="gglstmp_submit" value="submit" />
						<p class="submit">
							<input id="bws-submit-button" type="submit" class="button-primary" value="<?php 
                _e('Save Changes', 'google-sitemap-plugin');
                ?>
" />
						</p>
						<?php 
                wp_nonce_field($plugin_basename, 'gglstmp_nonce_name');
                ?>
					</form>
					<?php 
                bws_form_restore_default_settings($plugin_basename);
                ?>
					<div class="clear"></div>
			<?php 
            }
        } elseif (in_array($_GET['action'], array('extra', 'custom_links'))) {
            gglstmp_pro_block("gglstmp_{$_GET['action']}_block", false);
        } elseif ('go_pro' == $_GET['action']) {
            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']));
        }
        bws_plugin_reviews_block($gglstmp_plugin_info['Name'], 'google-sitemap-plugin');
        ?>
		</div>
	<?php 
    }