diff options
Diffstat (limited to 'plugins/jetpack/modules/videopress/class.videopress-gutenberg.php')
-rw-r--r-- | plugins/jetpack/modules/videopress/class.videopress-gutenberg.php | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php index 19a29699..34aa1b60 100644 --- a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php +++ b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php @@ -35,6 +35,7 @@ class VideoPress_Gutenberg { add_action( 'init', array( $this, 'register_video_block_with_videopress' ) ); add_action( 'jetpack_register_gutenberg_extensions', array( $this, 'set_extension_availability' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'override_video_upload' ) ); + add_action( 'enqueue_block_editor_assets', array( $this, 'add_resumable_upload_support' ) ); } /** @@ -69,58 +70,30 @@ class VideoPress_Gutenberg { * unavailable (key `unavailable_reason`) */ public function check_videopress_availability() { - if ( - defined( 'IS_WPCOM' ) && IS_WPCOM && - function_exists( 'require_lib' ) - ) { - require_lib( 'wpforteams' ); - - if ( WPForTeams\Workspace\is_part_of_active_workspace( self::get_blog_id() ) ) { - return array( 'available' => true ); - } + if ( ! Jetpack_Plan::supports( 'videopress' ) ) { + return array( + 'available' => false, + 'unavailable_reason' => 'missing_plan', + ); } - // It is available on Simple Sites having the appropriate a plan. - if ( - defined( 'IS_WPCOM' ) && IS_WPCOM - && method_exists( 'Store_Product_List', 'get_site_specific_features_data' ) - ) { - $features = Store_Product_List::get_site_specific_features_data(); - if ( in_array( 'videopress', $features['active'], true ) ) { - return array( 'available' => true ); + if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) { + if ( Jetpack::is_connection_ready() ) { + if ( ! Jetpack::is_module_active( 'videopress' ) ) { + return array( + 'available' => false, + 'unavailable_reason' => 'missing_module', + ); + } } else { return array( 'available' => false, - 'unavailable_reason' => 'missing_plan', + 'unavailable_reason' => 'unknown', ); } } - // It is available on Jetpack Sites having the module active. - if ( - method_exists( 'Jetpack', 'is_connection_ready' ) && Jetpack::is_connection_ready() - && method_exists( 'Jetpack', 'is_module_active' ) - && method_exists( 'Jetpack_Plan', 'supports' ) - ) { - if ( Jetpack::is_module_active( 'videopress' ) ) { - return array( 'available' => true ); - } elseif ( ! Jetpack_Plan::supports( 'videopress' ) ) { - return array( - 'available' => false, - 'unavailable_reason' => 'missing_plan', - ); - } else { - return array( - 'available' => false, - 'unavailable_reason' => 'missing_module', - ); - } - } - - return array( - 'available' => false, - 'unavailable_reason' => 'unknown', - ); + return array( 'available' => true ); } /** @@ -192,6 +165,19 @@ class VideoPress_Gutenberg { } /** + * Temporary method to enable resumable uploads for testing by Automatticians + */ + public function add_resumable_upload_support() { + wp_enqueue_script( + 'videopress-add-resumable-upload-support', + plugins_url( 'js/videopress-add-resumable-upload-support.js', __FILE__ ), + null, + '1', + false + ); + } + + /** * Replaces the video uploaded in the block editor. * * Enqueues a script that registers an API fetch middleware replacing the video uploads in Gutenberg so they are @@ -213,6 +199,17 @@ class VideoPress_Gutenberg { JETPACK__VERSION, false ); + + wp_enqueue_script( + 'jetpack-videopress-gutenberg-playback-jwt', + Assets::get_file_url_for_environment( + 'modules/videopress/js/videopress-token-bridge.js', + 'modules/videopress/js/videopress-token-bridge.js' + ), + array(), + JETPACK__VERSION, + false + ); } } |