/**
  * Returns the number of Liveblog entries used for lazyloading.
  *
  * @return int
  */
 public static function get_number_of_entries()
 {
     if (!isset(self::$number_of_entries)) {
         self::$number_of_entries = 5;
         /**
          * Filters the number of Liveblog entries used for lazyloading.
          *
          * @param int $number_of_entries Number of Liveblog entries.
          */
         $number = (int) apply_filters('liveblog_number_of_entries', self::$number_of_entries);
         if ($number > 0) {
             // Limit the number of Liveblog entries used for lazyloading to 100.
             self::$number_of_entries = min($number, 100);
         }
     }
     return self::$number_of_entries;
 }
Exemple #2
0
<div id="liveblog-entries">

	<?php 
foreach ((array) $entries as $entry) {
    ?>

		<?php 
    echo $entry->render();
    ?>

	<?php 
}
?>

	<?php 
if (WPCOM_Liveblog_Lazyloader::is_enabled()) {
    ?>

		<button class="liveblog-load-more" data-set-index="0"><?php 
    esc_html_e('Load more entries&hellip;', 'liveblog');
    ?>
</button>

	<?php 
}
?>

	<div id="liveblog-fixed-nag">
		<a href="#">
		</a>
	</div>
Exemple #3
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);
 }