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

Feature/tabs block json #218

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ vendor
*.log
/yarn.lock
.vscode

/vendor/
build
.wp-env.json
674 changes: 674 additions & 0 deletions 11-tabs-esnext/LICENSE

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions 11-tabs-esnext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# gutenberg-examples/example-11-tabs-esnext



49 changes: 49 additions & 0 deletions 11-tabs-esnext/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* Plugin Name: Gutenberg Example 11 Tabs ESNext
* Plugin URI: https://github.com/WordPress/gutenberg-examples
* Description: This is a plugin demonstrating how to create tabs using the Gutenberg editor.
* Version: 1.0.0
* Author: the Gutenberg Team
*
* @package gutenberg-examples
*/

defined( 'ABSPATH' ) || exit;

add_action( 'init', 'gutenberg_examples_11_esnext_register_block' );
add_action( 'init', 'gutenberg_examples_11_esnext_enqueue_scripts' );
add_filter( 'render_block', 'gutenberg_examples_11_esnext_enqueue_conditionally', 10, 2 );
/**
* Registers all block assets so that they can be enqueued through Gutenberg in
* the corresponding context.
*/
function gutenberg_examples_11_esnext_register_block() {
register_block_type( __DIR__ . '/build' );
}

/**
* Registers frontend JavaScript allowing the tabs
* to function.
*/
function gutenberg_examples_11_esnext_enqueue_scripts() {
wp_register_script(
'gutenberg-examples-11-esnext-frontend',
plugins_url( 'tabs-frontend.js', __FILE__ ),
array( 'jquery' ),
filemtime( plugin_dir_path( __FILE__ ) . '/tabs-frontend.js' ),
true
);
}

/**
* Registers frontend JavaScript allowing the tabs
* to function.
*/
function gutenberg_examples_11_esnext_enqueue_conditionally( $block_content, $block ) {
if ( 'gutenberg-examples/example-11-tabs-esnext' === $block['blockName'] ) {
wp_enqueue_script( 'gutenberg-examples-11-esnext-frontend' );
}
return $block_content;
}

Loading