-
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.
Merge pull request #2529 from WordPress/update/server-schemas
Block API: Support and bootstrap server-registered block attribute schemas
- Loading branch information
Showing
14 changed files
with
215 additions
and
49 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
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 |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"postsToShow": 5, | ||
"displayPostDate": false, | ||
"layout": "list", | ||
"columns": 3 | ||
"columns": 3, | ||
"align": "center" | ||
} | ||
} | ||
] |
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 |
---|---|---|
|
@@ -7,7 +7,8 @@ | |
"postsToShow": 5, | ||
"displayPostDate": true, | ||
"layout": "list", | ||
"columns": 3 | ||
"columns": 3, | ||
"align": "center" | ||
} | ||
} | ||
] |
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,24 @@ | ||
{ | ||
"core\/latest-posts": { | ||
"postsToShow": { | ||
"type": "number", | ||
"default": 5 | ||
}, | ||
"displayPostDate": { | ||
"type": "boolean", | ||
"default": false | ||
}, | ||
"layout": { | ||
"type": "string", | ||
"default": "list" | ||
}, | ||
"columns": { | ||
"type": "number", | ||
"default": 3 | ||
}, | ||
"align": { | ||
"type": "string", | ||
"default": "center" | ||
} | ||
} | ||
} |
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