コード例 #1
0
 /**
  * Register actions for our hook
  */
 public static function setup()
 {
     define('MSM_INTERVAL_PER_GENERATION_EVENT', 60);
     // how far apart should full cron generation events be spaced
     add_filter('cron_schedules', array(__CLASS__, 'sitemap_15_min_cron_interval'));
     // A cron schedule for creating/updating sitemap posts based on updated content since the last run
     add_action('init', array(__CLASS__, 'sitemap_init'));
     add_action('admin_init', array(__CLASS__, 'sitemap_init_cron'));
     add_action('redirect_canonical', array(__CLASS__, 'disable_canonical_redirects_for_sitemap_xml'), 10, 2);
     add_action('init', array(__CLASS__, 'create_post_type'));
     add_filter('template_include', array(__CLASS__, 'load_sitemap_template'));
     // By default, we use wp-cron to help generate the full sitemap.
     // However, this will let us override it, if necessary, like on WP.com
     if (true === apply_filters('msm_sitemap_use_cron_builder', true)) {
         require dirname(__FILE__) . '/includes/msm-sitemap-builder-cron.php';
         MSM_Sitemap_Builder_Cron::setup();
     }
 }
コード例 #2
0
 /**
  * Generate sitemaps; pretends to run cron six times
  */
 function build_sitemaps()
 {
     MSM_Sitemap_Builder_Cron::reset_sitemap_data();
     delete_option('msm_stop_processing');
     MSM_Sitemap_Builder_Cron::generate_full_sitemap();
     update_option('msm_sitemap_create_in_progress', true);
     $days_being_processed = (array) get_option('msm_days_to_process', array());
     $months_being_processed = (array) get_option('msm_months_to_process', array());
     $years_being_processed = (array) get_option('msm_years_to_process', array());
     while (count($days_being_processed) || count($months_being_processed) || count($years_being_processed)) {
         $this->fake_cron();
         $this->fake_cron();
         $this->fake_cron();
         $days_being_processed = (array) get_option('msm_days_to_process', array());
         $months_being_processed = (array) get_option('msm_months_to_process', array());
         $years_being_processed = (array) get_option('msm_years_to_process', array());
     }
 }