/** * Checks if lazyloading is enabled. * * @return bool */ public static function is_enabled() { if (!isset(self::$enabled)) { /** * Enables/Disables lazyloading for Liveblog entries. * * @param bool $enabled Enable lazyloading for Liveblog entries? */ self::$enabled = (bool) apply_filters('liveblog_enable_lazyloader', true); // Disable lazy loading for robots if (self::$enabled && self::is_robot()) { self::$enabled = false; } // Disable lazy loading on archived liveblogs if ('enable' != WPCOM_Liveblog::get_liveblog_state()) { self::$enabled = false; } } return self::$enabled; }
/** * Builds the box to display key entries * * @param $atts * @return mixed */ public static function shortcode($atts) { global $post; if (!is_single()) { return; } // Define the default shortcode attributes. $atts = shortcode_atts(array('title' => 'Key Events'), $atts); // The args to pass into the entry query. $args = array('meta_key' => self::meta_key, 'meta_value' => self::meta_value); $limit = get_post_meta($post->ID, self::meta_key_limit, true); if (isset($limit)) { $args['number'] = $limit; } // Build the entry query. $entry_query = new WPCOM_Liveblog_Entry_Query($post->ID, WPCOM_Liveblog::key); // Execute the entry query with the previously defined args. $entries = (array) $entry_query->get_all($args); // Grab the template to use. $template = self::get_current_template($post->ID); // Only run the shortcode on an archived or enabled post. if (WPCOM_Liveblog::get_liveblog_state($post->ID)) { // Render the actual template. return WPCOM_Liveblog::get_template_part('liveblog-key-events.php', array('entries' => $entries, 'title' => $atts['title'], 'template' => $template[0], 'wrap' => $template[1], 'class' => $template[2])); } }