Editor: update JavaScript packages
Also update default block categories Props youknowriad, gziolo, aduth. Fixes #50420, #50278. Built from https://develop.svn.wordpress.org/trunk@48177 git-svn-id: http://core.svn.wordpress.org/trunk@47946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -116,26 +116,9 @@ function render_block_core_archives( $attributes ) {
|
||||
* Register archives block.
|
||||
*/
|
||||
function register_block_core_archives() {
|
||||
register_block_type(
|
||||
'core/archives',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/archives',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'displayAsDropdown' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showPostCounts' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_archives',
|
||||
)
|
||||
);
|
||||
|
||||
31
wp-includes/blocks/archives/block.json
Normal file
31
wp-includes/blocks/archives/block.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "core/archives",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayAsDropdown": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"showPostCounts": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,9 @@ function render_block_core_block( $attributes ) {
|
||||
* Registers the `core/block` block.
|
||||
*/
|
||||
function register_block_core_block() {
|
||||
register_block_type(
|
||||
'core/block',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/block',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'ref' => array(
|
||||
'type' => 'number',
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_block',
|
||||
)
|
||||
);
|
||||
|
||||
14
wp-includes/blocks/block/block.json
Normal file
14
wp-includes/blocks/block/block.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "core/block",
|
||||
"category": "reusable",
|
||||
"attributes": {
|
||||
"ref": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"customClassName": false,
|
||||
"html": false,
|
||||
"inserter": false
|
||||
}
|
||||
}
|
||||
@@ -52,24 +52,9 @@ function render_block_core_calendar( $attributes ) {
|
||||
* Registers the `core/calendar` block on server.
|
||||
*/
|
||||
function register_block_core_calendar() {
|
||||
register_block_type(
|
||||
'core/calendar',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/calendar',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'month' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
'year' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_calendar',
|
||||
)
|
||||
);
|
||||
|
||||
28
wp-includes/blocks/calendar/block.json
Normal file
28
wp-includes/blocks/calendar/block.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "core/calendar",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"month": {
|
||||
"type": "integer"
|
||||
},
|
||||
"year": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true
|
||||
}
|
||||
}
|
||||
@@ -89,30 +89,9 @@ function build_dropdown_script_block_core_categories( $dropdown_id ) {
|
||||
* Registers the `core/categories` block on server.
|
||||
*/
|
||||
function register_block_core_categories() {
|
||||
register_block_type(
|
||||
'core/categories',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/categories',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'displayAsDropdown' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showHierarchy' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'showPostCounts' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_categories',
|
||||
)
|
||||
);
|
||||
|
||||
35
wp-includes/blocks/categories/block.json
Normal file
35
wp-includes/blocks/categories/block.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "core/categories",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayAsDropdown": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"showHierarchy": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"showPostCounts": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -152,42 +152,9 @@ function render_block_core_latest_comments( $attributes = array() ) {
|
||||
* Registers the `core/latest-comments` block.
|
||||
*/
|
||||
function register_block_core_latest_comments() {
|
||||
register_block_type(
|
||||
'core/latest-comments',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/latest-comments',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array(
|
||||
'left',
|
||||
'center',
|
||||
'right',
|
||||
'wide',
|
||||
'full',
|
||||
),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'commentsToShow' => array(
|
||||
'type' => 'number',
|
||||
'default' => 5,
|
||||
'minimum' => 1,
|
||||
'maximum' => 100,
|
||||
),
|
||||
'displayAvatar' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'displayDate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
'displayExcerpt' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => true,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_latest_comments',
|
||||
)
|
||||
);
|
||||
|
||||
41
wp-includes/blocks/latest-comments/block.json
Normal file
41
wp-includes/blocks/latest-comments/block.json
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "core/latest-comments",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"commentsToShow": {
|
||||
"type": "number",
|
||||
"default": 5,
|
||||
"minimum": 1,
|
||||
"maximum": 100
|
||||
},
|
||||
"displayAvatar": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"displayDate": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"displayExcerpt": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ function block_core_latest_posts_get_excerpt_length() {
|
||||
* @return string Returns the post content with latest posts added.
|
||||
*/
|
||||
function render_block_core_latest_posts( $attributes ) {
|
||||
global $block_core_latest_posts_excerpt_length;
|
||||
global $post, $block_core_latest_posts_excerpt_length;
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => $attributes['postsToShow'],
|
||||
@@ -47,7 +47,10 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
if ( isset( $attributes['categories'] ) ) {
|
||||
$args['category'] = $attributes['categories'];
|
||||
$args['category__in'] = array_column( $attributes['categories'], 'id' );
|
||||
}
|
||||
if ( isset( $attributes['selectedAuthor'] ) ) {
|
||||
$args['author'] = $attributes['selectedAuthor'];
|
||||
}
|
||||
|
||||
$recent_posts = get_posts( $args );
|
||||
@@ -55,6 +58,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$list_items_markup = '';
|
||||
|
||||
foreach ( $recent_posts as $post ) {
|
||||
|
||||
$list_items_markup .= '<li>';
|
||||
|
||||
if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) {
|
||||
@@ -94,6 +98,20 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$title
|
||||
);
|
||||
|
||||
if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
|
||||
$author_display_name = get_the_author_meta( 'display_name', $post->post_author );
|
||||
|
||||
/* translators: byline. %s: current author. */
|
||||
$byline = sprintf( __( 'by %s' ), $author_display_name );
|
||||
|
||||
if ( ! empty( $author_display_name ) ) {
|
||||
$list_items_markup .= sprintf(
|
||||
'<div class="wp-block-latest-posts__post-author">%1$s</div>',
|
||||
esc_html( $byline )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) {
|
||||
$list_items_markup .= sprintf(
|
||||
'<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>',
|
||||
@@ -108,21 +126,9 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$trimmed_excerpt = get_the_excerpt( $post );
|
||||
|
||||
$list_items_markup .= sprintf(
|
||||
'<div class="wp-block-latest-posts__post-excerpt">%1$s',
|
||||
'<div class="wp-block-latest-posts__post-excerpt">%1$s</div>',
|
||||
$trimmed_excerpt
|
||||
);
|
||||
|
||||
if ( strpos( $trimmed_excerpt, ' … ' ) !== false ) {
|
||||
$list_items_markup .= sprintf(
|
||||
'<a href="%1$s">%2$s</a></div>',
|
||||
esc_url( get_permalink( $post ) ),
|
||||
__( 'Read more' )
|
||||
);
|
||||
} else {
|
||||
$list_items_markup .= sprintf(
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent']
|
||||
@@ -155,6 +161,10 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$class .= ' has-dates';
|
||||
}
|
||||
|
||||
if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
|
||||
$class .= ' has-author';
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
@@ -170,79 +180,42 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
* Registers the `core/latest-posts` block on server.
|
||||
*/
|
||||
function register_block_core_latest_posts() {
|
||||
register_block_type(
|
||||
'core/latest-posts',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/latest-posts',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'categories' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'postsToShow' => array(
|
||||
'type' => 'number',
|
||||
'default' => 5,
|
||||
),
|
||||
'displayPostContent' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'displayPostContentRadio' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'excerpt',
|
||||
),
|
||||
'excerptLength' => array(
|
||||
'type' => 'number',
|
||||
'default' => 55,
|
||||
),
|
||||
'displayPostDate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'postLayout' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'list',
|
||||
),
|
||||
'columns' => array(
|
||||
'type' => 'number',
|
||||
'default' => 3,
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'desc',
|
||||
),
|
||||
'orderBy' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'date',
|
||||
),
|
||||
'displayFeaturedImage' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'featuredImageAlign' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right' ),
|
||||
),
|
||||
'featuredImageSizeSlug' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'thumbnail',
|
||||
),
|
||||
'featuredImageSizeWidth' => array(
|
||||
'type' => 'number',
|
||||
'default' => null,
|
||||
),
|
||||
'featuredImageSizeHeight' => array(
|
||||
'type' => 'number',
|
||||
'default' => null,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_latest_posts',
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'register_block_core_latest_posts' );
|
||||
|
||||
/**
|
||||
* Handles outdated versions of the `core/latest-posts` block by converting
|
||||
* attribute `categories` from a numeric string to an array with key `id`.
|
||||
*
|
||||
* This is done to accommodate the changes introduced in #20781 that sought to
|
||||
* add support for multiple categories to the block. However, given that this
|
||||
* block is dynamic, the usual provisions for block migration are insufficient,
|
||||
* as they only act when a block is loaded in the editor.
|
||||
*
|
||||
* TODO: Remove when and if the bottom client-side deprecation for this block
|
||||
* is removed.
|
||||
*
|
||||
* @param array $block A single parsed block object.
|
||||
*
|
||||
* @return array The migrated block object.
|
||||
*/
|
||||
function block_core_latest_posts_migrate_categories( $block ) {
|
||||
if (
|
||||
'core/latest-posts' === $block['blockName'] &&
|
||||
! empty( $block['attrs']['categories'] ) &&
|
||||
is_string( $block['attrs']['categories'] )
|
||||
) {
|
||||
$block['attrs']['categories'] = array(
|
||||
array( 'id' => absint( $block['attrs']['categories'] ) ),
|
||||
);
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
add_filter( 'render_block_data', 'block_core_latest_posts_migrate_categories' );
|
||||
|
||||
96
wp-includes/blocks/latest-posts/block.json
Normal file
96
wp-includes/blocks/latest-posts/block.json
Normal file
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "core/latest-posts",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"categories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"selectedAuthor": {
|
||||
"type": "number"
|
||||
},
|
||||
"postsToShow": {
|
||||
"type": "number",
|
||||
"default": 5
|
||||
},
|
||||
"displayPostContent": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"displayPostContentRadio": {
|
||||
"type": "string",
|
||||
"default": "excerpt"
|
||||
},
|
||||
"excerptLength": {
|
||||
"type": "number",
|
||||
"default": 55
|
||||
},
|
||||
"displayAuthor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"displayPostDate": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"postLayout": {
|
||||
"type": "string",
|
||||
"default": "list"
|
||||
},
|
||||
"columns": {
|
||||
"type": "number",
|
||||
"default": 3
|
||||
},
|
||||
"order": {
|
||||
"type": "string",
|
||||
"default": "desc"
|
||||
},
|
||||
"orderBy": {
|
||||
"type": "string",
|
||||
"default": "date"
|
||||
},
|
||||
"displayFeaturedImage": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"featuredImageAlign": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right"
|
||||
]
|
||||
},
|
||||
"featuredImageSizeSlug": {
|
||||
"type": "string",
|
||||
"default": "thumbnail"
|
||||
},
|
||||
"featuredImageSizeWidth": {
|
||||
"type": "number",
|
||||
"default": null
|
||||
},
|
||||
"featuredImageSizeHeight": {
|
||||
"type": "number",
|
||||
"default": null
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -92,57 +92,16 @@ function render_block_core_rss( $attributes ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
|
||||
return sprintf( "<ul class='%s'>%s</ul>", esc_attr( $class ), $list_items );
|
||||
return sprintf( '<ul class="%s">%s</ul>', esc_attr( $class ), $list_items );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the `core/rss` block on server.
|
||||
*/
|
||||
function register_block_core_rss() {
|
||||
register_block_type(
|
||||
'core/rss',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/rss',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'columns' => array(
|
||||
'type' => 'number',
|
||||
'default' => 2,
|
||||
),
|
||||
'blockLayout' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'list',
|
||||
),
|
||||
'feedURL' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'itemsToShow' => array(
|
||||
'type' => 'number',
|
||||
'default' => 5,
|
||||
),
|
||||
'displayExcerpt' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'displayAuthor' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'displayDate' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
'excerptLength' => array(
|
||||
'type' => 'number',
|
||||
'default' => 55,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_rss',
|
||||
)
|
||||
);
|
||||
|
||||
55
wp-includes/blocks/rss/block.json
Normal file
55
wp-includes/blocks/rss/block.json
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "core/rss",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"columns": {
|
||||
"type": "number",
|
||||
"default": 2
|
||||
},
|
||||
"blockLayout": {
|
||||
"type": "string",
|
||||
"default": "list"
|
||||
},
|
||||
"feedURL": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"itemsToShow": {
|
||||
"type": "number",
|
||||
"default": 5
|
||||
},
|
||||
"displayExcerpt": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"displayAuthor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"displayDate": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"excerptLength": {
|
||||
"type": "number",
|
||||
"default": 55
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -67,30 +67,9 @@ function render_block_core_search( $attributes ) {
|
||||
* Registers the `core/search` block on the server.
|
||||
*/
|
||||
function register_block_core_search() {
|
||||
register_block_type(
|
||||
'core/search',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/search',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'label' => array(
|
||||
'type' => 'string',
|
||||
'default' => __( 'Search' ),
|
||||
),
|
||||
'placeholder' => array(
|
||||
'type' => 'string',
|
||||
'default' => '',
|
||||
),
|
||||
'buttonText' => array(
|
||||
'type' => 'string',
|
||||
'default' => __( 'Search' ),
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_search',
|
||||
)
|
||||
);
|
||||
|
||||
33
wp-includes/blocks/search/block.json
Normal file
33
wp-includes/blocks/search/block.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "core/search",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,10 @@ function render_block_core_shortcode( $attributes, $content ) {
|
||||
* Registers the `core/shortcode` block on server.
|
||||
*/
|
||||
function register_block_core_shortcode() {
|
||||
$path = __DIR__ . '/shortcode/block.json';
|
||||
$metadata = json_decode( file_get_contents( $path ), true );
|
||||
register_block_type(
|
||||
$metadata['name'],
|
||||
array_merge(
|
||||
$metadata,
|
||||
array(
|
||||
'render_callback' => 'render_block_core_shortcode',
|
||||
)
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/shortcode',
|
||||
array(
|
||||
'render_callback' => 'render_block_core_shortcode',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,5 +6,10 @@
|
||||
"type": "string",
|
||||
"source": "html"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"className": false,
|
||||
"customClassName": false,
|
||||
"html": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,9 @@
|
||||
* @return string Rendered HTML of the referenced block.
|
||||
*/
|
||||
function render_block_core_social_link( $attributes ) {
|
||||
$service = ( isset( $attributes['service'] ) ) ? $attributes['service'] : 'Icon';
|
||||
$url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false;
|
||||
$label = ( isset( $attributes['label'] ) ) ?
|
||||
$attributes['label'] :
|
||||
/* translators: %s: Social Link service name */
|
||||
sprintf( __( 'Link to %s' ), block_core_social_link_get_name( $service ) );
|
||||
$service = ( isset( $attributes['service'] ) ) ? $attributes['service'] : 'Icon';
|
||||
$url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false;
|
||||
$label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : block_core_social_link_get_name( $service );
|
||||
$class_name = isset( $attributes['className'] ) ? ' ' . $attributes['className'] : false;
|
||||
|
||||
// Don't render a link if there is no URL set.
|
||||
@@ -34,16 +31,10 @@ function render_block_core_social_link( $attributes ) {
|
||||
* Registers the `core/social-link` blocks.
|
||||
*/
|
||||
function register_block_core_social_link() {
|
||||
$path = __DIR__ . '/social-link/block.json';
|
||||
$metadata = json_decode( file_get_contents( $path ), true );
|
||||
|
||||
register_block_type(
|
||||
$metadata['name'],
|
||||
array_merge(
|
||||
$metadata,
|
||||
array(
|
||||
'render_callback' => 'render_block_core_social_link',
|
||||
)
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/social-link',
|
||||
array(
|
||||
'render_callback' => 'render_block_core_social_link',
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -218,7 +209,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
||||
),
|
||||
'tumblr' => array(
|
||||
'name' => 'Tumblr',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><path d="M16.749,17.396c-0.357,0.17-1.041,0.319-1.551,0.332c-1.539,0.041-1.837-1.081-1.85-1.896V9.847h3.861V6.937h-3.847V2.039 c0,0-2.77,0-2.817,0c-0.046,0-0.127,0.041-0.138,0.144c-0.165,1.499-0.867,4.13-3.783,5.181v2.484h1.945v6.282 c0,2.151,1.587,5.206,5.775,5.135c1.413-0.024,2.982-0.616,3.329-1.126L16.749,17.396z"></path></svg>',
|
||||
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true" focusable="false"><path d="M17.04 21.28h-3.28c-2.84 0-4.94-1.37-4.94-5.02v-5.67H6.08V7.5c2.93-.73 4.11-3.3 4.3-5.48h3.01v4.93h3.47v3.65H13.4v4.93c0 1.47.73 2.01 1.92 2.01h1.73v3.75z" /></path></svg>',
|
||||
),
|
||||
'twitch' => array(
|
||||
'name' => 'Twitch',
|
||||
@@ -250,7 +241,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
||||
),
|
||||
'share' => array(
|
||||
'name' => 'Share Icon',
|
||||
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" role="img" aria-hidden="true" focusable="false"><rect x="0" fill="none" width="20" height="20"/><g><path d="M14.5 12c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3c0-.24.03-.46.09-.69l-4.38-2.3c-.55.61-1.33.99-2.21.99-1.66 0-3-1.34-3-3s1.34-3 3-3c.88 0 1.66.39 2.21.99l4.38-2.3c-.06-.23-.09-.45-.09-.69 0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3c-.88 0-1.66-.39-2.21-.99l-4.38 2.3c.06.23.09.45.09.69s-.03.46-.09.69l4.38 2.3c.55-.61 1.33-.99 2.21-.99z"/></g></svg>',
|
||||
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 11.8l6.1-4.5c.1.4.4.7.9.7h2c.6 0 1-.4 1-1V5c0-.6-.4-1-1-1h-2c-.6 0-1 .4-1 1v.4l-6.4 4.8c-.2-.1-.4-.2-.6-.2H6c-.6 0-1 .4-1 1v2c0 .6.4 1 1 1h2c.2 0 .4-.1.6-.2l6.4 4.8v.4c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-2c0-.6-.4-1-1-1h-2c-.5 0-.8.3-.9.7L9 12.2v-.4z"/></svg>',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"name": "core/social-link",
|
||||
"category": "widgets",
|
||||
"icon": "share",
|
||||
"parent": [
|
||||
"core/social-links"
|
||||
],
|
||||
"attributes": {
|
||||
"url": {
|
||||
"type": "string"
|
||||
@@ -12,5 +14,10 @@
|
||||
"label": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
"lightBlockWrapper": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,26 +51,9 @@ function render_block_core_tag_cloud( $attributes ) {
|
||||
* Registers the `core/tag-cloud` block on server.
|
||||
*/
|
||||
function register_block_core_tag_cloud() {
|
||||
register_block_type(
|
||||
'core/tag-cloud',
|
||||
register_block_type_from_metadata(
|
||||
__DIR__ . '/tag-cloud',
|
||||
array(
|
||||
'attributes' => array(
|
||||
'align' => array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full' ),
|
||||
),
|
||||
'className' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'taxonomy' => array(
|
||||
'type' => 'string',
|
||||
'default' => 'post_tag',
|
||||
),
|
||||
'showTagCounts' => array(
|
||||
'type' => 'boolean',
|
||||
'default' => false,
|
||||
),
|
||||
),
|
||||
'render_callback' => 'render_block_core_tag_cloud',
|
||||
)
|
||||
);
|
||||
|
||||
31
wp-includes/blocks/tag-cloud/block.json
Normal file
31
wp-includes/blocks/tag-cloud/block.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "core/tag-cloud",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"taxonomy": {
|
||||
"type": "string",
|
||||
"default": "post_tag"
|
||||
},
|
||||
"showTagCounts": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"html": false,
|
||||
"align": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user