Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gutenblocks: Try Module Activation State based Visibility #10243

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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";
Expand All @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions modules/tiled-gallery/tiled-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,6 @@ function setting_html() {
}

add_action( 'init', array( 'Jetpack_Tiled_Gallery', 'init' ) );
add_action( 'init', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this could be merged, it would need to be converted to a function. Anonymous functions aren't allowed in PHP 5.2.

Jetpack::load_jetpack_gutenberg( '/tiled-gallery' );
} );