-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Framework: Support preloaded server-registered block attributes
- Loading branch information
Showing
10 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Generates server-registered block attributes, writing to standard output. | ||
* | ||
* @package gutenberg-build | ||
*/ | ||
|
||
$attributes = array(); | ||
|
||
/** | ||
* Register a block type. Substitute for core API in lieu of loading full | ||
* WordPress context. | ||
* | ||
* @param string $name Block type name including namespace. | ||
* @param array $args { | ||
* Optional. Array of block type arguments. Any arguments may be defined, however the | ||
* ones described below are supported by default. Default empty array. | ||
* | ||
* @type callable $render_callback Callback used to render blocks of this block type. | ||
* @type array $attributes Block attributes mapping, property name to schema. | ||
* } | ||
*/ | ||
function register_block_type( $name, $args = array() ) { | ||
if ( ! isset( $args['attributes'] ) ) { | ||
return; | ||
} | ||
|
||
global $attributes; | ||
$attributes[ $name ] = $args['attributes']; | ||
} | ||
|
||
// Register server-side code for individual blocks. | ||
foreach ( glob( dirname( dirname( __FILE__ ) ) . '/blocks/library/*/index.php' ) as $block_logic ) { | ||
require_once $block_logic; | ||
} | ||
|
||
echo json_encode( $attributes, JSON_PRETTY_PRINT ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters