diff --git a/liveblog.php b/liveblog.php index f0a225d5a..562d6e1c4 100644 --- a/liveblog.php +++ b/liveblog.php @@ -57,6 +57,8 @@ final class WPCOM_Liveblog { public static $is_rest_api_call = false; public static $auto_archive_days = null; public static $auto_archive_expiry_key = 'liveblog_autoarchive_expiry_date'; + + public static $supported_post_types = array(); /** Load Methods **********************************************************/ @@ -236,11 +238,19 @@ private static function register_embed_handlers() { */ public static function init() { /** - * Add liveblog support to the 'post' post type. This is done here so - * we can possibly introduce this to other post types later. + * Add liveblog support to the 'post' and 'page' post type. + */ + $post_types = array( 'post', 'page' ); + + /** + * This allows the users to filter their supported post types. */ - add_post_type_support( 'post', self::key ); + self::$supported_post_types = apply_filters( 'liveblog_modify_supported_post_types', $post_types ); + foreach ( self::$supported_post_types as $post_type) { + add_post_type_support($post_type, self::key); + } + /** * Apply a Filter to Setup our Auto Archive Days. * NULL is classed as disabled. @@ -451,14 +461,14 @@ public static function is_liveblog_post( $post_id = null ) { * @return bool */ public static function is_viewing_liveblog_post() { - return (bool) ( is_single() && self::is_liveblog_post() ); + return ( bool ) ( is_singular( self::$supported_post_types ) && self::is_liveblog_post() ); } /** * One of: 'enable', 'archive', false. */ public static function get_liveblog_state( $post_id = null ) { - if ( ! is_single() && ! is_admin() && ! self::$is_rest_api_call) { + if ( !is_singular( self::$supported_post_types ) && !is_admin() && !self::$is_rest_api_call ) { return false; } if ( empty( $post_id ) ) {