/** * edit_options() * * @return void **/ static function edit_options() { $options = xml_sitemaps::get_options(); echo '<div class="wrap">' . "\n" . '<form method="post" action="">' . "\n"; wp_nonce_field('xml_sitemaps'); echo '<h2>' . __('XML Sitemaps Settings', 'xml-sitemaps') . '</h2>' . "\n"; echo '<table class="form-table">' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Include Archive Pages', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="inc_archives"' . checked((bool) $options['inc_archives'], true, false) . ' />' . ' ' . __('Check to include date archive pages, such as YYYY or YYYY/MM, in your sitemap.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Include Author Pages', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="inc_authors"' . checked((bool) $options['inc_authors'], true, false) . ' />' . ' ' . __('Check to include author pages in your sitemap.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Empty Author Pages', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="empty_author"' . checked((bool) $options['empty_author'], true, false) . ' />' . ' ' . __('Check to include author page in your sitemap if the author(s) has not published any pages or posts yet.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Include Category Pages', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="inc_categories"' . checked((bool) $options['inc_categories'], true, false) . ' />' . ' ' . __('Check to include category pages in your sitemap.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr>' . "\n" . '<th scope="row">' . __('Include Tag Pages', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="inc_tags"' . checked((bool) $options['inc_tags'], true, false) . ' />' . ' ' . __('Check to include tag pages in your sitemap.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo '<tr valign="top">' . '<th scope="row">' . __('Exclude Pages', 'xml-sitemaps') . '</th>' . '<td>' . '<p>' . __('IDs of pages you do not wish to include in your sitemap separated by commas (\',\'):', 'xml-sitemaps') . '</p>' . "\n" . '<input type="text" name="exclude_pages"' . ' class="widefat code"' . ' value="' . esc_attr($options['exclude_pages']) . '"' . ' />' . '</td>' . '</tr>'; echo '<tr>' . "\n" . '<th scope="row">' . __('Generate Mobile Sitemap', 'xml-sitemaps') . '</th>' . "\n" . '<td>' . '<label>' . '<input type="checkbox" name="mobile_sitemap"' . checked((bool) $options['mobile_sitemap'], true, false) . ' />' . ' ' . __('Check if this plugin is installed on an mobile-only site, such as m.example.com or example.mobi.', 'xml-sitemaps') . '</label>' . '</td>' . "\n" . '</tr>' . "\n"; echo "</table>\n"; echo '<div class="submit">' . '<input type="submit"' . ' value="' . esc_attr(__('Save Changes', 'xml-sitemaps')) . '"' . " />" . "</div>\n"; echo '</form>' . "\n"; echo '</div>' . "\n"; }
/** * init_options() * * @return array $options **/ static function init_options() { $defaults = array('inc_authors' => true, 'inc_categories' => true, 'inc_tags' => true, 'inc_archives' => true, 'exclude_pages' => '', 'mobile_sitemap' => false, 'version' => xml_sitemaps_version, 'empty_author' => false, 'ortho_defaults_set' => false); $o = get_option('xml_sitemaps'); if ($o === false || !is_array($o)) { $updated_opts = $defaults; } else { $updated_opts = wp_parse_args($o, $defaults); } if (!isset($o['version'])) { xml_sitemaps::clean(WP_CONTENT_DIR . '/sitemaps'); } $hostname = php_uname('n'); if ($updated_opts['ortho_defaults_set'] == false && in_array($hostname, array('orthohost.com', 'vps.orthohosting.com'))) { $updated_opts['inc_authors'] = false; $updated_opts['inc_categories'] = false; $updated_opts['inc_tags'] = false; $updated_opts['inc_archives'] = false; $updated_opts['ortho_defaults_set'] = true; xml_sitemaps::clean(WP_CONTENT_DIR . '/sitemaps'); } $updated_opts['version'] = xml_sitemaps_version; update_option('xml_sitemaps', $updated_opts); return $updated_opts; }
/** * close() * * @return void **/ function close() { if (isset($this->fp) && $this->fp) { global $wp_filter; $wp_filter['option_blog_public'] = $this->filter_backup; $o = '</urlset>'; fwrite($this->fp, $o); fclose($this->fp); $this->fp = null; # compress if (function_exists('gzencode')) { $gzdata = gzencode(file_get_contents($this->file), 9); $fp = fopen($this->file . '.gz', 'w+'); fwrite($fp, $gzdata); fclose($fp); } # move $dir = WP_CONTENT_DIR . '/sitemaps'; if (defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL) { $dir .= '/' . $_SERVER['HTTP_HOST']; } $home_path = parse_url(get_option('home')); $home_path = isset($home_path['path']) ? rtrim($home_path['path'], '/') : ''; $dir .= $home_path; $file = $dir . '/sitemap.xml'; if (!wp_mkdir_p($dir) || !xml_sitemaps::rm($file) || !xml_sitemaps::rm($file . '.gz') || strpos($_SERVER['HTTP_HOST'], '/') !== false) { unlink($this->file); unlink($this->file . '.gz'); } else { rename($this->file, $file); $stat = stat(dirname($file)); $perms = $stat['mode'] & 0666; @chmod($file, $perms); if (function_exists('gzencode')) { rename($this->file . '.gz', $file . '.gz'); @chmod($file . '.gz', $perms); } } } }