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

Tiled Galleries: do not rely on the Tiled Gallery module. #11061

Merged
merged 1 commit into from
Jan 3, 2019
Merged
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
32 changes: 32 additions & 0 deletions modules/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,38 @@

jetpack_register_block( 'vr' );

/**
* Tiled Gallery block. Depends on the Photon module.
*
* @since 6.9.0
*/
if ( class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
jetpack_register_block(
'tiled-gallery',
array(
'render_callback' => 'jetpack_tiled_gallery_load_block_assets',
)
);

/**
* Tiled gallery block registration/dependency declaration.
*
* @param array $attr - Array containing the block attributes.
* @param string $content - String containing the block content.
*
* @return string
*/
function jetpack_tiled_gallery_load_block_assets( $attr, $content ) {
$dependencies = array(
'lodash',
'wp-i18n',
'wp-token-list',
);
Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies );
return $content;
}
}

/**
* Map block registration/dependency declaration.
*
Expand Down
25 changes: 0 additions & 25 deletions modules/tiled-gallery/tiled-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,6 @@ public function __construct() {
add_action( 'admin_init', array( $this, 'settings_api_init' ) );
add_filter( 'jetpack_gallery_types', array( $this, 'jetpack_gallery_types' ), 9 );
add_filter( 'jetpack_default_gallery_type', array( $this, 'jetpack_default_gallery_type' ) );

jetpack_register_block(
'tiled-gallery',
array(
'render_callback' => array( $this, 'load_block_assets' ),
)
);
}

/**
* Tiled gallery block registration/dependency declaration.
*
* @param array $attr - Array containing the block attributes.
* @param string $content - String containing the block content.
*
* @return string
*/
public function load_block_assets( $attr, $content ) {
$dependencies = array(
'lodash',
'wp-i18n',
'wp-token-list',
);
Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies );
return $content;
}

public function tiles_enabled() {
Expand Down