Exemple #1
0
 /**
  * Fetches all Liveblog entries that are to be lazyloaded, and returns them via JSON.
  */
 public static function ajax_lazyload_entries()
 {
     // The URL is of the form "lazyload/optional_max_timestamp/optional_min_timestamp".
     $fragments = explode('/', get_query_var(self::url_endpoint));
     // Get all Liveblog entries that are to be lazyloaded.
     $entries = self::$entry_query->get_for_lazyloading(isset($fragments[1]) ? (int) $fragments[1] : 0, isset($fragments[2]) ? (int) $fragments[2] : 0);
     if (!$entries) {
         do_action('liveblog_entry_request_empty');
         self::json_return(array('entries' => array(), 'index' => (int) filter_input(INPUT_GET, 'index')));
     }
     $entries = array_slice($entries, 0, WPCOM_Liveblog_Lazyloader::get_number_of_entries());
     $entries_for_json = array();
     // Set up an array containing the JSON data for all Liveblog entries.
     foreach ($entries as $entry) {
         $entries_for_json[] = $entry->for_json();
     }
     // Set up the data to be returned via JSON.
     $result_for_json = array('entries' => $entries_for_json, 'index' => (int) filter_input(INPUT_GET, 'index'));
     do_action('liveblog_entry_request', $result_for_json);
     self::$do_not_cache_response = true;
     self::json_return($result_for_json);
 }