diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2020-01-06 14:32:30 -0500 |
commit | 10ef81bf85ad0a4bad0d204838e14c99ca2526f7 (patch) | |
tree | b4bb36a326d41de12d1a6181d2a2baf34696ac24 /plugins/jetpack/modules/videopress/class.videopress-gutenberg.php | |
parent | Updating script for Update (diff) | |
download | blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.gz blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.tar.bz2 blogs-gentoo-10ef81bf85ad0a4bad0d204838e14c99ca2526f7.zip |
Update jetpack 8.0
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/videopress/class.videopress-gutenberg.php')
-rw-r--r-- | plugins/jetpack/modules/videopress/class.videopress-gutenberg.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php index be0bd1db..55421ee9 100644 --- a/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php +++ b/plugins/jetpack/modules/videopress/class.videopress-gutenberg.php @@ -5,6 +5,8 @@ * @package Jetpack */ +use Automattic\Jetpack\Assets; + /** * Register a VideoPress extension to replace the default Core Video block. */ @@ -31,6 +33,7 @@ class VideoPress_Gutenberg { private function __construct() { 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' ) ); } /** @@ -164,6 +167,30 @@ class VideoPress_Gutenberg { 1 ); } + + /** + * 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 + * uploaded against the WP.com API media endpoint and thus transcoded by VideoPress. + */ + public function override_video_upload() { + // Bail if Jetpack or VideoPress is not active. + if ( ! Jetpack::is_active() || ! Jetpack::is_module_active( 'videopress' ) ) { + return; + } + + wp_enqueue_script( + 'jetpack-videopress-gutenberg-override-video-upload', + Assets::get_file_url_for_environment( + '_inc/build/videopress/js/gutenberg-video-upload.min.js', + 'modules/videopress/js/gutenberg-video-upload.js' + ), + array( 'wp-api-fetch', 'wp-polyfill', 'lodash' ), + JETPACK__VERSION, + false + ); + } } VideoPress_Gutenberg::init(); |