/**
  * save_options()
  *
  * @return void
  **/
 function save_options()
 {
     if (!$_POST || !current_user_can('manage_options')) {
         return;
     }
     check_admin_referer('xml_sitemaps');
     foreach (array('inc_archives', 'inc_authors', 'inc_categories', 'inc_tags', 'mobile_sitemap', 'empty_author') as $var) {
         ${$var} = isset($_POST[$var]);
     }
     $exclude_pages = stripslashes($_POST['exclude_pages']);
     $exclude_pages = preg_replace(array('/[^\\d,]/', '/(?<=,),+/', '/^,+/', '/,+$/'), '', (string) $exclude_pages);
     $version = xml_sitemaps_version;
     update_option('xml_sitemaps', compact('inc_archives', 'inc_authors', 'inc_categories', 'inc_tags', 'exclude_pages', 'mobile_sitemap', 'version', 'empty_author'));
     xml_sitemaps::clean(WP_CONTENT_DIR . '/sitemaps');
     echo '<div class="updated fade">' . "\n" . '<p>' . '<strong>' . __('Settings saved.', 'xml-sitemaps') . '</strong>' . '</p>' . "\n" . '</div>' . "\n";
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }