From 864dd542865a40dd14167c4d0ed7c0e56abdac26 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 28 Sep 2018 01:05:30 +0200 Subject: [PATCH] Gutenblocks: Try Module Activation State based Visibility --- class.jetpack.php | 18 ++++++++++-------- modules/tiled-gallery/tiled-gallery.php | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/class.jetpack.php b/class.jetpack.php index 6b7ef5758cf83..351f1f05f8f16 100644 --- a/class.jetpack.php +++ b/class.jetpack.php @@ -7299,7 +7299,7 @@ public static function is_gutenberg_available() { * * @return void */ - public static function load_jetpack_gutenberg() { + public static function load_jetpack_gutenberg( $block_slug = '' ) { /** * Filter to turn on loading Gutenberg blocks * @@ -7324,7 +7324,7 @@ public static function load_jetpack_gutenberg() { * @param bool true Whether to load Gutenberg blocks from CDN */ if ( apply_filters( 'jetpack_gutenberg_cdn', true ) ) { - $cdn_base = 'https://s0.wp.com/wp-content/mu-plugins/jetpack/_inc/blocks'; + $cdn_base = 'https://s0.wp.com/wp-content/mu-plugins/jetpack/_inc/blocks' . $block_slug ; $editor_script = "$cdn_base/editor.js"; $editor_style = "$cdn_base/editor$rtl.css"; $view_script = "$cdn_base/view.js"; @@ -7339,12 +7339,14 @@ public static function load_jetpack_gutenberg() { */ $version = apply_filters( 'jetpack_gutenberg_cdn_cache_buster', sprintf( '%s-%s', gmdate( 'd-m-Y' ), JETPACK__VERSION ) ); } else { - $editor_script = plugins_url( '_inc/blocks/editor.js', JETPACK__PLUGIN_FILE ); - $editor_style = plugins_url( "_inc/blocks/editor$rtl.css", JETPACK__PLUGIN_FILE ); - $view_script = plugins_url( '_inc/blocks/view.js', JETPACK__PLUGIN_FILE ); - $view_style = plugins_url( "_inc/blocks/view$rtl.css", JETPACK__PLUGIN_FILE ); - $version = Jetpack::is_development_version() && file_exists( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) - ? filemtime( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) + $plugin_blocks_base = '_inc/blocks' + $block_slug; + + $editor_script = plugins_url( "$plugin_blocks_base/editor.js", JETPACK__PLUGIN_FILE ); + $editor_style = plugins_url( "$plugin_blocks_base/editor$rtl.css", JETPACK__PLUGIN_FILE ); + $view_script = plugins_url( "$plugin_blocks_base/view.js", JETPACK__PLUGIN_FILE ); + $view_style = plugins_url( "$plugin_blocks_base/view$rtl.css", JETPACK__PLUGIN_FILE ); + $version = Jetpack::is_development_version() && file_exists( JETPACK__PLUGIN_DIR . "$plugin_blocks_base/editor.js" ) + ? filemtime( JETPACK__PLUGIN_DIR . "$plugin_blocks_base/editor.js" ) : JETPACK__VERSION; } diff --git a/modules/tiled-gallery/tiled-gallery.php b/modules/tiled-gallery/tiled-gallery.php index 4e81a8c098dce..aee8b2d22a6be 100644 --- a/modules/tiled-gallery/tiled-gallery.php +++ b/modules/tiled-gallery/tiled-gallery.php @@ -294,3 +294,6 @@ function setting_html() { } add_action( 'init', array( 'Jetpack_Tiled_Gallery', 'init' ) ); +add_action( 'init', function() { + Jetpack::load_jetpack_gutenberg( '/tiled-gallery' ); + } ); \ No newline at end of file