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 gallery block: load assets #10728

Merged
merged 2 commits into from
Nov 29, 2018
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
1 change: 1 addition & 0 deletions class.jetpack-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public static function enqueue_block_editor_assets() {
'wp-i18n',
'wp-keycodes',
'wp-plugins',
'wp-rich-text',
'wp-token-list',
'wp-url',
),
Expand Down
2 changes: 1 addition & 1 deletion class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private function __construct() {
* Prepare Gutenberg Editor functionality
*/
require_once JETPACK__PLUGIN_DIR . 'class.jetpack-gutenberg.php';
add_action( 'init', array( 'Jetpack_Gutenberg', 'load_blocks' ) ); // Registers all the Jetpack blocks .
add_action( 'init', array( 'Jetpack_Gutenberg', 'load_blocks' ), 99 ); // Registers all the Jetpack blocks .
Copy link
Member

Choose a reason for hiding this comment

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

We need to make sure this or something similar makes its way to WordPress.com

Fusuion won't handle this.

Copy link
Contributor

Choose a reason for hiding this comment

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

good call

Copy link
Contributor

Choose a reason for hiding this comment

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

@simison could you take care of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup 👌

add_action( 'enqueue_block_editor_assets', array( 'Jetpack_Gutenberg', 'enqueue_block_editor_assets' ) );
add_filter( 'jetpack_set_available_blocks', array( 'Jetpack_Gutenberg', 'jetpack_set_available_blocks' ) );

Expand Down
24 changes: 24 additions & 0 deletions modules/tiled-gallery/tiled-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,30 @@ public function __construct() {
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',
Copy link
Member

Choose a reason for hiding this comment

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

We'll try to get this list down: Automattic/wp-calypso#28933

);
Jetpack_Gutenberg::load_assets_as_required( 'tiled-gallery', $dependencies );
return $content;
}

public function tiles_enabled() {
Expand Down