/**
  * used by queue_all cron job to process the queue of all posts
  *
  * @global object $wpdb
  */
 public static function process_queue_all()
 {
     global $wpdb;
     $id_from = get_option(self::QUEUE_ALL_MARKER_OPTION);
     if (!$id_from) {
         wp_clear_scheduled_hook(self::QUEUE_ALL_CRON_HOOK);
         return;
     }
     $post_types = Lift_Search::get_indexed_post_types();
     $query = new WP_Query();
     $alter_query = function ($where, $wp_query) use($query, $id_from) {
         global $wpdb;
         if ($wp_query === $query) {
             //make sure we're not messing with any other queries
             //making sure all post_statii are used since wp_query overrides the requested statii
             $where = $wpdb->prepare(" AND {$wpdb->posts}.post_type in ('" . implode("','", $wp_query->get('post_type')) . "') " . "AND {$wpdb->posts}.ID > %d " . "AND {$wpdb->posts}.post_status <> 'auto-draft'", $id_from);
         }
         return $where;
     };
     add_filter('posts_where', $alter_query, 10, 2);
     $posts = $query->query(array('suppress_filters' => false, 'post_type' => $post_types, 'orderby' => 'ID', 'order' => 'ASC', 'post_status' => array_diff(get_post_stati(), array('auto-draft')), 'posts_per_page' => self::get_queue_all_set_size()));
     remove_filter('posts_where', $alter_query);
     if (empty($posts)) {
         wp_clear_scheduled_hook(self::QUEUE_ALL_CRON_HOOK);
         delete_option(self::QUEUE_ALL_MARKER_OPTION);
         return;
     }
     foreach ($posts as $post) {
         Lift_Post_Update_Watcher::queue_entire_post($post->ID);
     }
     $new_id_from = end($posts)->ID;
     update_option(self::QUEUE_ALL_MARKER_OPTION, $new_id_from);
 }
示例#2
0
 public static function get_watched_post_types()
 {
     return apply_filters('lift_watched_post_types', Lift_Search::get_indexed_post_types());
 }