Editor: Update WordPress packages published for Gutenberg 10.6

It contains several changes in addition to regular update to WordPress packages:
- All newly exposed blocks are now registered on the server.
- Dutone block support was added.
- Border block support was updated.
- New shared function `construct_wp_query_args` was added for the family of Query blocks - it might need some further work.

Props youknowriad.
See #52991.




git-svn-id: https://develop.svn.wordpress.org/trunk@50929 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski
2021-05-19 15:07:55 +00:00
parent a805b90f45
commit 585f62ad8c
89 changed files with 3728 additions and 1320 deletions
+1 -1
View File
@@ -1003,7 +1003,7 @@ module.exports = function(grunt) {
WORKING_DIR + 'wp-{admin,includes}/**/*.js',
WORKING_DIR + 'wp-content/themes/twenty*/**/*.js',
'!' + WORKING_DIR + 'wp-content/themes/twenty*/node_modules/**/*.js',
'!' + WORKING_DIR + 'wp-includes/js/dist/vendor/*.js',
'!' + WORKING_DIR + 'wp-includes/js/dist/**/*.js',
]
}
},
+1465 -1206
View File
File diff suppressed because it is too large Load Diff
+54 -54
View File
@@ -24,11 +24,11 @@
"last 2 Opera versions"
],
"devDependencies": {
"@wordpress/custom-templated-path-webpack-plugin": "2.0.3",
"@wordpress/dependency-extraction-webpack-plugin": "3.1.2",
"@wordpress/e2e-test-utils": "5.1.3",
"@wordpress/library-export-default-webpack-plugin": "2.0.3",
"@wordpress/scripts": "15.0.1",
"@wordpress/custom-templated-path-webpack-plugin": "2.0.4",
"@wordpress/dependency-extraction-webpack-plugin": "3.1.3",
"@wordpress/e2e-test-utils": "5.1.4",
"@wordpress/library-export-default-webpack-plugin": "2.0.4",
"@wordpress/scripts": "16.0.0",
"autoprefixer": "^9.8.6",
"chalk": "4.1.0",
"check-node-version": "4.1.0",
@@ -77,55 +77,55 @@
},
"dependencies": {
"@babel/polyfill": "7.10.1",
"@wordpress/a11y": "2.15.3",
"@wordpress/annotations": "1.25.3",
"@wordpress/api-fetch": "4.0.0",
"@wordpress/autop": "2.12.2",
"@wordpress/blob": "2.13.2",
"@wordpress/block-directory": "1.19.3",
"@wordpress/block-editor": "5.3.3",
"@wordpress/block-library": "2.29.3",
"@wordpress/block-serialization-default-parser": "3.10.2",
"@wordpress/blocks": "8.0.3",
"@wordpress/components": "13.0.3",
"@wordpress/compose": "3.25.3",
"@wordpress/core-data": "2.26.3",
"@wordpress/data": "4.27.3",
"@wordpress/data-controls": "1.21.3",
"@wordpress/date": "3.15.1",
"@wordpress/deprecated": "2.12.3",
"@wordpress/dom": "2.18.0",
"@wordpress/dom-ready": "2.13.2",
"@wordpress/edit-post": "3.27.3",
"@wordpress/editor": "9.26.3",
"@wordpress/element": "2.20.3",
"@wordpress/escape-html": "1.12.2",
"@wordpress/format-library": "1.27.3",
"@wordpress/hooks": "2.12.3",
"@wordpress/html-entities": "2.11.2",
"@wordpress/i18n": "3.20.0",
"@wordpress/icons": "2.10.3",
"@wordpress/interface": "2.0.2",
"@wordpress/is-shallow-equal": "3.1.3",
"@wordpress/keyboard-shortcuts": "1.14.3",
"@wordpress/keycodes": "2.19.3",
"@wordpress/list-reusable-blocks": "1.26.3",
"@wordpress/media-utils": "1.20.3",
"@wordpress/notices": "2.13.3",
"@wordpress/nux": "3.25.3",
"@wordpress/plugins": "2.25.3",
"@wordpress/primitives": "1.12.3",
"@wordpress/priority-queue": "1.11.2",
"@wordpress/redux-routine": "3.14.2",
"@wordpress/reusable-blocks": "1.2.3",
"@wordpress/rich-text": "3.25.3",
"@wordpress/server-side-render": "1.21.3",
"@wordpress/shortcode": "2.13.2",
"@wordpress/token-list": "1.15.3",
"@wordpress/url": "2.22.2",
"@wordpress/viewport": "2.26.3",
"@wordpress/warning": "1.4.2",
"@wordpress/wordcount": "2.15.2",
"@wordpress/a11y": "3.0.0",
"@wordpress/annotations": "2.0.0",
"@wordpress/api-fetch": "5.0.0",
"@wordpress/autop": "3.0.0",
"@wordpress/blob": "3.0.0",
"@wordpress/block-directory": "2.0.0",
"@wordpress/block-editor": "6.0.0",
"@wordpress/block-library": "3.0.0",
"@wordpress/block-serialization-default-parser": "4.0.0",
"@wordpress/blocks": "9.0.0",
"@wordpress/components": "14.0.0",
"@wordpress/compose": "4.0.0",
"@wordpress/core-data": "3.0.0",
"@wordpress/data": "5.0.0",
"@wordpress/data-controls": "2.0.0",
"@wordpress/date": "4.0.0",
"@wordpress/deprecated": "3.0.0",
"@wordpress/dom": "3.0.0",
"@wordpress/dom-ready": "3.0.0",
"@wordpress/edit-post": "4.0.0",
"@wordpress/editor": "10.0.0",
"@wordpress/element": "3.0.0",
"@wordpress/escape-html": "2.0.0",
"@wordpress/format-library": "2.0.0",
"@wordpress/hooks": "3.0.0",
"@wordpress/html-entities": "3.0.0",
"@wordpress/i18n": "4.0.0",
"@wordpress/icons": "3.0.0",
"@wordpress/interface": "3.0.0",
"@wordpress/is-shallow-equal": "4.0.0",
"@wordpress/keyboard-shortcuts": "2.0.0",
"@wordpress/keycodes": "3.0.0",
"@wordpress/list-reusable-blocks": "2.0.0",
"@wordpress/media-utils": "2.0.0",
"@wordpress/notices": "3.0.0",
"@wordpress/nux": "4.0.0",
"@wordpress/plugins": "3.0.0",
"@wordpress/primitives": "2.0.0",
"@wordpress/priority-queue": "2.0.0",
"@wordpress/redux-routine": "4.0.0",
"@wordpress/reusable-blocks": "2.0.0",
"@wordpress/rich-text": "4.0.0",
"@wordpress/server-side-render": "2.0.0",
"@wordpress/shortcode": "3.0.0",
"@wordpress/token-list": "2.0.0",
"@wordpress/url": "3.0.0",
"@wordpress/viewport": "3.0.0",
"@wordpress/warning": "2.0.0",
"@wordpress/wordcount": "3.0.0",
"backbone": "1.4.0",
"clipboard": "2.0.8",
"core-js-url-browser": "3.6.4",
File diff suppressed because one or more lines are too long
+36 -5
View File
@@ -18,7 +18,7 @@
function wp_register_border_support( $block_type ) {
// Determine if any border related features are supported.
$has_border_support = block_has_support( $block_type, array( '__experimentalBorder' ) );
$has_border_color_support = block_has_support( $block_type, array( '__experimentalBorder', 'color' ) );
$has_border_color_support = wp_has_border_feature_support( $block_type, 'color' );
// Setup attributes and styles within that if needed.
if ( ! $block_type->attributes ) {
@@ -60,7 +60,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
// Border radius.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'radius' ) ) &&
wp_has_border_feature_support( $block_type, 'radius' ) &&
isset( $block_attributes['style']['border']['radius'] )
) {
$border_radius = (int) $block_attributes['style']['border']['radius'];
@@ -69,7 +69,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
// Border style.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'style' ) ) &&
wp_has_border_feature_support( $block_type, 'style' ) &&
isset( $block_attributes['style']['border']['style'] )
) {
$border_style = $block_attributes['style']['border']['style'];
@@ -78,7 +78,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
// Border width.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'width' ) ) &&
wp_has_border_feature_support( $block_type, 'width' ) &&
isset( $block_attributes['style']['border']['width'] )
) {
$border_width = intval( $block_attributes['style']['border']['width'] );
@@ -86,7 +86,7 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
}
// Border color.
if ( block_has_support( $block_type, array( '__experimentalBorder', 'color' ) ) ) {
if ( wp_has_border_feature_support( $block_type, 'color' ) ) {
$has_named_border_color = array_key_exists( 'borderColor', $block_attributes );
$has_custom_border_color = isset( $block_attributes['style']['border']['color'] );
@@ -135,6 +135,37 @@ function wp_skip_border_serialization( $block_type ) {
$border_support['__experimentalSkipSerialization'];
}
/**
* Checks whether the current block type supports the border feature requested.
*
* If the `__experimentalBorder` support flag is a boolean `true` all border
* support features are available. Otherwise, the specific feature's support
* flag nested under `experimentalBorder` must be enabled for the feature
* to be opted into.
*
* @since 5.8.0
* @access private
*
* @param WP_Block_Type $block_type Block type to check for support.
* @param string $feature Name of the feature to check support for.
* @param mixed $default Fallback value for feature support, defaults to false.
*
* @return boolean Whether or not the feature is supported.
*/
function wp_has_border_feature_support( $block_type, $feature, $default = false ) {
// Check if all border support features have been opted into via `"__experimentalBorder": true`.
if (
property_exists( $block_type, 'supports' ) &&
( true === _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), $default ) )
) {
return true;
}
// Check if the specific feature has been opted into individually
// via nested flag under `__experimentalBorder`.
return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default );
}
// Register the block support.
WP_Block_Supports::get_instance()->register(
'border',
+432
View File
@@ -0,0 +1,432 @@
<?php
/**
* Duotone block support flag.
*
* Parts of this source were derived and modified from TinyColor,
* released under the MIT license.
*
* https://github.com/bgrins/TinyColor
*
* Copyright (c), Brian Grinstead, http://briangrinstead.com
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @package WordPress
* @since 5.8.0
*/
/**
* Takes input from [0, n] and returns it as [0, 1].
*
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
*
* @see https://github.com/bgrins/TinyColor
*
* @since 5.8.0
* @access private
*
* @param mixed $n Number of unknown type.
* @param int $max Upper value of the range to bound to.
*
* @return float Value in the range [0, 1].
*/
function wp_tinycolor_bound01( $n, $max ) {
if ( 'string' === gettype( $n ) && false !== strpos( $n, '.' ) && 1 === (float) $n ) {
$n = '100%';
}
$n = min( $max, max( 0, (float) $n ) );
// Automatically convert percentage into number.
if ( 'string' === gettype( $n ) && false !== strpos( $n, '%' ) ) {
$n = (int) ( $n * $max ) / 100;
}
// Handle floating point rounding errors.
if ( ( abs( $n - $max ) < 0.000001 ) ) {
return 1.0;
}
// Convert into [0, 1] range if it isn't already.
return ( $n % $max ) / (float) $max;
}
/**
* Round and convert values of an RGB object.
*
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
*
* @see https://github.com/bgrins/TinyColor
*
* @since 5.8.0
* @access private
*
* @param array $rgb_color RGB object.
*
* @return array Rounded and converted RGB object.
*/
function wp_tinycolor_rgb_to_rgb( $rgb_color ) {
return array(
'r' => wp_tinycolor_bound01( $rgb_color['r'], 255 ) * 255,
'g' => wp_tinycolor_bound01( $rgb_color['g'], 255 ) * 255,
'b' => wp_tinycolor_bound01( $rgb_color['b'], 255 ) * 255,
);
}
/**
* Helper function for hsl to rgb conversion.
*
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
*
* @see https://github.com/bgrins/TinyColor
*
* @since 5.8.0
* @access private
*
* @param float $p first component.
* @param float $q second component.
* @param float $t third component.
*
* @return float R, G, or B component.
*/
function wp_tinycolor_hue_to_rgb( $p, $q, $t ) {
if ( $t < 0 ) {
$t += 1;
}
if ( $t > 1 ) {
$t -= 1;
}
if ( $t < 1 / 6 ) {
return $p + ( $q - $p ) * 6 * $t;
}
if ( $t < 1 / 2 ) {
return $q;
}
if ( $t < 2 / 3 ) {
return $p + ( $q - $p ) * ( 2 / 3 - $t ) * 6;
}
return $p;
}
/**
* Convert an HSL object to an RGB object with converted and rounded values.
*
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
*
* @see https://github.com/bgrins/TinyColor
*
* @since 5.8.0
* @access private
*
* @param array $hsl_color HSL object.
*
* @return array Rounded and converted RGB object.
*/
function wp_tinycolor_hsl_to_rgb( $hsl_color ) {
$h = wp_tinycolor_bound01( $hsl_color['h'], 360 );
$s = wp_tinycolor_bound01( $hsl_color['s'], 100 );
$l = wp_tinycolor_bound01( $hsl_color['l'], 100 );
if ( 0 === $s ) {
// Achromatic.
$r = $l;
$g = $l;
$b = $l;
} else {
$q = $l < 0.5 ? $l * ( 1 + $s ) : $l + $s - $l * $s;
$p = 2 * $l - $q;
$r = wp_tinycolor_hue_to_rgb( $p, $q, $h + 1 / 3 );
$g = wp_tinycolor_hue_to_rgb( $p, $q, $h );
$b = wp_tinycolor_hue_to_rgb( $p, $q, $h - 1 / 3 );
}
return array(
'r' => $r * 255,
'g' => $g * 255,
'b' => $b * 255,
);
}
/**
* Parses hex, hsl, and rgb CSS strings using the same regex as TinyColor v1.4.2
* used in the JavaScript. Only colors output from react-color are implemented
* and the alpha value is ignored as it is not used in duotone.
*
* Direct port of TinyColor's function, lightly simplified to maintain
* consistency with TinyColor.
*
* @see https://github.com/bgrins/TinyColor
* @see https://github.com/casesandberg/react-color/
*
* @since 5.8.0
* @access private
*
* @param string $color_str CSS color string.
*
* @return array RGB object.
*/
function wp_tinycolor_string_to_rgb( $color_str ) {
$color_str = strtolower( trim( $color_str ) );
$css_integer = '[-\\+]?\\d+%?';
$css_number = '[-\\+]?\\d*\\.\\d+%?';
$css_unit = '(?:' . $css_number . ')|(?:' . $css_integer . ')';
$permissive_match3 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
$permissive_match4 = '[\\s|\\(]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')[,|\\s]+(' . $css_unit . ')\\s*\\)?';
$rgb_regexp = '/^rgb' . $permissive_match3 . '$/';
if ( preg_match( $rgb_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => $match[1],
'g' => $match[2],
'b' => $match[3],
)
);
}
$rgba_regexp = '/^rgba' . $permissive_match4 . '$/';
if ( preg_match( $rgba_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => $match[1],
'g' => $match[2],
'b' => $match[3],
)
);
}
$hsl_regexp = '/^hsl' . $permissive_match3 . '$/';
if ( preg_match( $hsl_regexp, $color_str, $match ) ) {
return wp_tinycolor_hsl_to_rgb(
array(
'h' => $match[1],
's' => $match[2],
'l' => $match[3],
)
);
}
$hsla_regexp = '/^hsla' . $permissive_match4 . '$/';
if ( preg_match( $hsla_regexp, $color_str, $match ) ) {
return wp_tinycolor_hsl_to_rgb(
array(
'h' => $match[1],
's' => $match[2],
'l' => $match[3],
)
);
}
$hex8_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
if ( preg_match( $hex8_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => base_convert( $match[1], 16, 10 ),
'g' => base_convert( $match[2], 16, 10 ),
'b' => base_convert( $match[3], 16, 10 ),
)
);
}
$hex6_regexp = '/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/';
if ( preg_match( $hex6_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => base_convert( $match[1], 16, 10 ),
'g' => base_convert( $match[2], 16, 10 ),
'b' => base_convert( $match[3], 16, 10 ),
)
);
}
$hex4_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
if ( preg_match( $hex4_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
)
);
}
$hex3_regexp = '/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/';
if ( preg_match( $hex3_regexp, $color_str, $match ) ) {
return wp_tinycolor_rgb_to_rgb(
array(
'r' => base_convert( $match[1] . $match[1], 16, 10 ),
'g' => base_convert( $match[2] . $match[2], 16, 10 ),
'b' => base_convert( $match[3] . $match[3], 16, 10 ),
)
);
}
}
/**
* Registers the style and colors block attributes for block types that support it.
*
* @since 5.8.0
* @access private
*
* @param WP_Block_Type $block_type Block Type.
*/
function wp_register_duotone_support( $block_type ) {
$has_duotone_support = false;
if ( property_exists( $block_type, 'supports' ) ) {
$has_duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false );
}
if ( $has_duotone_support ) {
if ( ! $block_type->attributes ) {
$block_type->attributes = array();
}
if ( ! array_key_exists( 'style', $block_type->attributes ) ) {
$block_type->attributes['style'] = array(
'type' => 'object',
);
}
}
}
/**
* Render out the duotone stylesheet and SVG.
*
* @since 5.8.0
* @access private
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
*
* @return string Filtered block content.
*/
function wp_render_duotone_support( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$duotone_support = false;
if ( $block_type && property_exists( $block_type, 'supports' ) ) {
$duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false );
}
$has_duotone_attribute = isset( $block['attrs']['style']['color']['duotone'] );
if (
! $duotone_support ||
! $has_duotone_attribute
) {
return $block_content;
}
$duotone_colors = $block['attrs']['style']['color']['duotone'];
$duotone_values = array(
'r' => array(),
'g' => array(),
'b' => array(),
);
foreach ( $duotone_colors as $color_str ) {
$color = wp_tinycolor_string_to_rgb( $color_str );
$duotone_values['r'][] = $color['r'] / 255;
$duotone_values['g'][] = $color['g'] / 255;
$duotone_values['b'][] = $color['b'] / 255;
}
$duotone_id = 'wp-duotone-filter-' . uniqid();
$selectors = explode( ',', $duotone_support );
$selectors_scoped = array_map(
function ( $selector ) use ( $duotone_id ) {
return '.' . $duotone_id . ' ' . trim( $selector );
},
$selectors
);
$selectors_group = implode( ', ', $selectors_scoped );
ob_start();
?>
<style>
<?php echo $selectors_group; ?> {
filter: url( <?php echo esc_url( '#' . $duotone_id ); ?> );
}
</style>
<svg
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 0 0"
width="0"
height="0"
focusable="false"
role="none"
style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"
>
<defs>
<filter id="<?php echo esc_attr( $duotone_id ); ?>">
<feColorMatrix
type="matrix"
<?php // phpcs:disable Generic.WhiteSpace.DisallowSpaceIndent ?>
values=".299 .587 .114 0 0
.299 .587 .114 0 0
.299 .587 .114 0 0
0 0 0 1 0"
<?php // phpcs:enable Generic.WhiteSpace.DisallowSpaceIndent ?>
/>
<feComponentTransfer color-interpolation-filters="sRGB" >
<feFuncR type="table" tableValues="<?php echo esc_attr( implode( ' ', $duotone_values['r'] ) ); ?>" />
<feFuncG type="table" tableValues="<?php echo esc_attr( implode( ' ', $duotone_values['g'] ) ); ?>" />
<feFuncB type="table" tableValues="<?php echo esc_attr( implode( ' ', $duotone_values['b'] ) ); ?>" />
</feComponentTransfer>
</filter>
</defs>
</svg>
<?php
$duotone = ob_get_clean();
// Like the layout hook, this assumes the hook only applies to blocks with a single wrapper.
$content = preg_replace(
'/' . preg_quote( 'class="', '/' ) . '/',
'class="' . $duotone_id . ' ',
$block_content,
1
);
return $content . $duotone;
}
// Register the block support.
WP_Block_Supports::get_instance()->register(
'duotone',
array(
'register_attribute' => 'wp_register_duotone_support',
)
);
add_filter( 'render_block', 'wp_render_duotone_support', 10, 2 );
+5 -3
View File
@@ -14,13 +14,15 @@
* @since 5.8.0
* @access private
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
* @return string Filtered block content.
* @param string $block_content Rendered block content.
* @param array $block Block object.
*
* @return string Filtered block content.
*/
function wp_restore_group_inner_container( $block_content, $block ) {
$group_with_inner_container_regex = '/(^\s*<div\b[^>]*wp-block-group(\s|")[^>]*>)(\s*<div\b[^>]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/';
// TODO: Add check for theme.json presence.
if (
'core/group' !== $block['blockName'] ||
1 === preg_match( $group_with_inner_container_regex, $block_content )
@@ -79,8 +79,10 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
$has_text_decoration_support = _wp_array_get( $block_type->supports, array( '__experimentalTextDecoration' ), false );
$has_text_transform_support = _wp_array_get( $block_type->supports, array( '__experimentalTextTransform' ), false );
$skip_font_size_support_serialization = _wp_array_get( $block_type->supports, array( '__experimentalSkipFontSizeSerialization' ), false );
// Font Size.
if ( $has_font_size_support ) {
if ( $has_font_size_support && ! $skip_font_size_support_serialization ) {
$has_named_font_size = array_key_exists( 'fontSize', $block_attributes );
$has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] );
+62
View File
@@ -961,3 +961,65 @@ function block_has_support( $block_type, $feature, $default = false ) {
return true === $block_support || is_array( $block_support );
}
/**
* Helper function that constructs a WP_Query args array from
* a `Query` block properties.
*
* It's used in Query Loop, Query Pagination Numbers and Query Pagination Next blocks.
*
* @since 5.8.0
*
* @param WP_Block $block Block instance.
* @param int $page Current query's page.
*
* @return array Returns the constructed WP_Query arguments.
*/
function construct_wp_query_args( $block, $page ) {
$query = array(
'post_type' => 'post',
'order' => 'DESC',
'orderby' => 'date',
'post__not_in' => array(),
);
if ( isset( $block->context['query'] ) ) {
if ( isset( $block->context['query']['postType'] ) ) {
$query['post_type'] = $block->context['query']['postType'];
}
if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) {
$sticky = get_option( 'sticky_posts' );
if ( 'only' === $block->context['query']['sticky'] ) {
$query['post__in'] = $sticky;
} else {
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
}
}
if ( isset( $block->context['query']['exclude'] ) ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $block->context['query']['exclude'] );
}
if ( isset( $block->context['query']['perPage'] ) ) {
$query['offset'] = ( $block->context['query']['perPage'] * ( $page - 1 ) ) + $block->context['query']['offset'];
$query['posts_per_page'] = $block->context['query']['perPage'];
}
if ( isset( $block->context['query']['categoryIds'] ) ) {
$query['category__in'] = $block->context['query']['categoryIds'];
}
if ( isset( $block->context['query']['tagIds'] ) ) {
$query['tag__in'] = $block->context['query']['tagIds'];
}
if ( isset( $block->context['query']['order'] ) ) {
$query['order'] = strtoupper( $block->context['query']['order'] );
}
if ( isset( $block->context['query']['orderBy'] ) ) {
$query['orderby'] = $block->context['query']['orderBy'];
}
if ( isset( $block->context['query']['author'] ) ) {
$query['author'] = $block->context['query']['author'];
}
if ( isset( $block->context['query']['search'] ) ) {
$query['s'] = $block->context['query']['search'];
}
}
return $query;
}
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/archives",
"title": "Archives",
"category": "widgets",
"description": "Display a monthly archive of your posts.",
"textdomain": "default",
"attributes": {
"displayAsDropdown": {
"type": "boolean",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/audio",
"title": "Audio",
"category": "media",
"description": "Embed a simple audio player.",
"keywords": [ "music", "sound", "podcast", "recording" ],
"textdomain": "default",
"attributes": {
"src": {
"type": "string",
+3
View File
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/block",
"title": "Reusable block",
"category": "reusable",
"description": "Create and save content to reuse across your site. Update the block, and the changes apply everywhere its used.",
"textdomain": "default",
"attributes": {
"ref": {
"type": "number"
+8
View File
@@ -1,8 +1,12 @@
{
"apiVersion": 2,
"name": "core/button",
"title": "Button",
"category": "design",
"parent": [ "core/buttons" ],
"description": "Prompt visitors to take action with a button-style link.",
"keywords": [ "link" ],
"textdomain": "default",
"attributes": {
"url": {
"type": "string",
@@ -66,6 +70,10 @@
"__experimentalFontFamily": true,
"__experimentalSelector": ".wp-block-button__link"
},
"styles": [
{ "name": "fill", "label": "Fill", "isDefault": true },
{ "name": "outline", "label": "Outline" }
],
"editorStyle": "wp-block-button-editor",
"style": "wp-block-button"
}
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/buttons",
"title": "Buttons",
"category": "design",
"description": "Prompt visitors to take action with a group of button-style links.",
"keywords": [ "link" ],
"textdomain": "default",
"attributes": {
"contentJustification": {
"type": "string"
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/calendar",
"title": "Calendar",
"category": "widgets",
"description": "A calendar of your sites posts.",
"keywords": [ "posts", "archive" ],
"textdomain": "default",
"attributes": {
"month": {
"type": "integer"
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/categories",
"title": "Categories",
"category": "widgets",
"description": "Display a list of all categories.",
"textdomain": "default",
"attributes": {
"displayAsDropdown": {
"type": "boolean",
+3
View File
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/code",
"title": "Code",
"category": "text",
"description": "Display code snippets that respect your spacing and tabs.",
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
+4 -1
View File
@@ -1,8 +1,11 @@
{
"apiVersion": 2,
"name": "core/column",
"title": "Column",
"category": "text",
"parent": [ "core/columns" ],
"description": "A single column within a columns block.",
"textdomain": "default",
"attributes": {
"verticalAlignment": {
"type": "string"
@@ -11,7 +14,7 @@
"type": "string"
},
"templateLock": {
"type": "string"
"enum": [ "all", "insert", false ]
}
},
"supports": {
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/columns",
"title": "Columns",
"category": "design",
"description": "Add a block that displays content in multiple columns, then add whatever content blocks youd like.",
"textdomain": "default",
"attributes": {
"verticalAlignment": {
"type": "string"
+8
View File
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/cover",
"title": "Cover",
"category": "media",
"description": "Add an image or video with a text overlay — great for headers.",
"textdomain": "default",
"attributes": {
"url": {
"type": "string"
@@ -56,6 +59,11 @@
"html": false,
"spacing": {
"padding": true
},
"color": {
"__experimentalDuotone": "> .wp-block-cover__image-background, > .wp-block-cover__video-background",
"text": false,
"background": false
}
},
"editorStyle": "wp-block-cover-editor",
+3
View File
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/embed",
"title": "Embed",
"category": "embed",
"description": "Add a block that displays content pulled from other sites, like Twitter, Instagram or YouTube.",
"textdomain": "default",
"attributes": {
"url": {
"type": "string"
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/file",
"title": "File",
"category": "media",
"description": "Add a link to a downloadable file.",
"keywords": [ "document", "pdf", "download" ],
"textdomain": "default",
"attributes": {
"id": {
"type": "number"
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/freeform",
"title": "Classic",
"category": "text",
"description": "Use the classic WordPress editor.",
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/gallery",
"title": "Gallery",
"category": "media",
"description": "Display multiple images in a rich gallery.",
"keywords": [ "images", "photos" ],
"textdomain": "default",
"attributes": {
"images": {
"type": "array",
+5 -1
View File
@@ -1,14 +1,18 @@
{
"apiVersion": 2,
"name": "core/group",
"title": "Group",
"category": "design",
"description": "Combine blocks into a group.",
"keywords": [ "container", "wrapper", "row", "section" ],
"textdomain": "default",
"attributes": {
"tagName": {
"type": "string",
"default": "div"
},
"templateLock": {
"type": "string"
"enum": [ "all", "insert", false ]
}
},
"supports": {
+5 -44
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/heading",
"title": "Heading",
"category": "text",
"description": "Introduce new sections and organize content to help visitors (and search engines) understand the structure of your content.",
"keywords": [ "title", "subtitle" ],
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
@@ -30,50 +34,7 @@
},
"fontSize": true,
"lineHeight": true,
"__experimentalSelector": {
"core/heading/h1": {
"selector": "h1",
"title": "h1",
"attributes": {
"level": 1
}
},
"core/heading/h2": {
"selector": "h2",
"title": "h2",
"attributes": {
"level": 2
}
},
"core/heading/h3": {
"selector": "h3",
"title": "h3",
"attributes": {
"level": 3
}
},
"core/heading/h4": {
"selector": "h4",
"title": "h4",
"attributes": {
"level": 4
}
},
"core/heading/h5": {
"selector": "h5",
"title": "h5",
"attributes": {
"level": 5
}
},
"core/heading/h6": {
"selector": "h6",
"title": "h6",
"attributes": {
"level": 6
}
}
},
"__experimentalSelector": "h1,h2,h3,h4,h5,h6",
"__unstablePasteTextInline": true
},
"editorStyle": "wp-block-heading-editor",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/html",
"title": "Custom HTML",
"category": "widgets",
"description": "Add custom HTML code and preview it as you edit.",
"keywords": [ "embed" ],
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
+17
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/image",
"title": "Image",
"category": "media",
"description": "Insert an image to make a visual statement.",
"keywords": [ "img", "photo", "picture" ],
"textdomain": "default",
"attributes": {
"align": {
"type": "string"
@@ -72,10 +76,23 @@
},
"supports": {
"anchor": true,
"color": {
"__experimentalDuotone": "img",
"text": false,
"background": false
},
"__experimentalBorder": {
"radius": true
}
},
"styles": [
{
"name": "default",
"label": "Default",
"isDefault": true
},
{ "name": "rounded", "label": "Rounded" }
],
"editorStyle": "wp-block-image-editor",
"style": "wp-block-image"
}
+17
View File
@@ -13,9 +13,26 @@ require ABSPATH . WPINC . '/blocks/categories.php';
require ABSPATH . WPINC . '/blocks/file.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/loginout.php';
require ABSPATH . WPINC . '/blocks/post-author.php';
require ABSPATH . WPINC . '/blocks/post-content.php';
require ABSPATH . WPINC . '/blocks/post-date.php';
require ABSPATH . WPINC . '/blocks/post-excerpt.php';
require ABSPATH . WPINC . '/blocks/post-featured-image.php';
require ABSPATH . WPINC . '/blocks/post-terms.php';
require ABSPATH . WPINC . '/blocks/post-title.php';
require ABSPATH . WPINC . '/blocks/query.php';
require ABSPATH . WPINC . '/blocks/query-loop.php';
require ABSPATH . WPINC . '/blocks/query-pagination.php';
require ABSPATH . WPINC . '/blocks/query-pagination-next.php';
require ABSPATH . WPINC . '/blocks/query-pagination-numbers.php';
require ABSPATH . WPINC . '/blocks/query-pagination-previous.php';
require ABSPATH . WPINC . '/blocks/query-title.php';
require ABSPATH . WPINC . '/blocks/rss.php';
require ABSPATH . WPINC . '/blocks/search.php';
require ABSPATH . WPINC . '/blocks/shortcode.php';
require ABSPATH . WPINC . '/blocks/site-tagline.php';
require ABSPATH . WPINC . '/blocks/site-title.php';
require ABSPATH . WPINC . '/blocks/social-link.php';
require ABSPATH . WPINC . '/blocks/tag-cloud.php';
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/latest-comments",
"title": "Latest Comments",
"category": "widgets",
"description": "Display a list of your most recent comments.",
"keywords": [ "recent comments" ],
"textdomain": "default",
"attributes": {
"commentsToShow": {
"type": "number",
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/latest-posts",
"title": "Latest Posts",
"category": "widgets",
"description": "Display a list of your most recent posts.",
"keywords": [ "recent posts" ],
"textdomain": "default",
"attributes": {
"categories": {
"type": "array",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/list",
"title": "List",
"category": "text",
"description": "Create a bulleted or numbered list.",
"keywords": [ "bullet list", "ordered list", "numbered list" ],
"textdomain": "default",
"attributes": {
"ordered": {
"type": "boolean",
+51
View File
@@ -0,0 +1,51 @@
<?php
/**
* Server-side rendering of the `core/loginout` block.
*
* @package WordPress
*/
/**
* Renders the `core/loginout` block on server.
*
* @param array $attributes The block attributes.
*
* @return string Returns the login-out link or form.
*/
function render_block_core_loginout( $attributes ) {
// Build the redirect URL.
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$classes = is_user_logged_in() ? 'logged-in' : 'logged-out';
$contents = wp_loginout(
isset( $attributes['redirectToCurrent'] ) && $attributes['redirectToCurrent'] ? $current_url : '',
false
);
// If logged-out and displayLoginAsForm is true, show the login form.
if ( ! is_user_logged_in() && ! empty( $attributes['displayLoginAsForm'] ) ) {
// Add a class.
$classes .= ' has-login-form';
// Get the form.
$contents = wp_login_form( array( 'echo' => false ) );
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
return '<div ' . $wrapper_attributes . '>' . $contents . '</div>';
}
/**
* Registers the `core/latest-posts` block on server.
*/
function register_block_core_loginout() {
register_block_type_from_metadata(
__DIR__ . '/loginout',
array(
'render_callback' => 'render_block_core_loginout',
)
);
}
add_action( 'init', 'register_block_core_loginout' );
@@ -0,0 +1,23 @@
{
"apiVersion": 2,
"name": "core/loginout",
"title": "Login/out",
"category": "design",
"description": "Show login & logout links.",
"keywords": [ "login", "logout", "form" ],
"textdomain": "default",
"attributes": {
"displayLoginAsForm": {
"type": "boolean",
"default": false
},
"redirectToCurrent": {
"type": "boolean",
"default": true
}
},
"supports": {
"className": true,
"fontSize": false
}
}
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/media-text",
"title": "Media & Text",
"category": "media",
"description": "Set media and words side-by-side for a richer layout.",
"keywords": [ "image", "video" ],
"textdomain": "default",
"attributes": {
"align": {
"type": "string",
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/missing",
"title": "Unsupported",
"category": "text",
"description": "Your site doesnt include support for this block.",
"textdomain": "default",
"attributes": {
"originalName": {
"type": "string"
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/more",
"title": "More",
"category": "design",
"description": "Content before this block will be shown in the excerpt on your archives page.",
"keywords": [ "read more" ],
"textdomain": "default",
"attributes": {
"customText": {
"type": "string"
@@ -1,8 +1,12 @@
{
"apiVersion": 2,
"name": "core/nextpage",
"title": "Page Break",
"category": "design",
"description": "Separate your content into a multi-page experience.",
"keywords": [ "next page", "pagination" ],
"parent": [ "core/post-content" ],
"textdomain": "default",
"supports": {
"customClassName": false,
"className": false,
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/paragraph",
"title": "Paragraph",
"category": "text",
"description": "Start with the building block of all narrative.",
"keywords": [ "text" ],
"textdomain": "default",
"attributes": {
"align": {
"type": "string"
+61
View File
@@ -0,0 +1,61 @@
<?php
/**
* Server-side rendering of the `core/post-author` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-author` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the rendered author block.
*/
function render_block_core_post_author( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$author_id = get_post_field( 'post_author', $block->context['postId'] );
if ( empty( $author_id ) ) {
return '';
}
$avatar = ! empty( $attributes['avatarSize'] ) ? get_avatar(
$author_id,
$attributes['avatarSize']
) : null;
$byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
$classes = array_merge(
isset( $attributes['className'] ) ? array( $attributes['className'] ) : array(),
isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(),
isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array()
);
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf( '<div %1$s>', $wrapper_attributes ) .
( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
'<div class="wp-block-post-author__content">' .
( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . $byline . '</p>' : '' ) .
'<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
'</div>' .
'</div>';
}
/**
* Registers the `core/post-author` block on the server.
*/
function register_block_core_post_author() {
register_block_type_from_metadata(
__DIR__ . '/post-author',
array(
'render_callback' => 'render_block_core_post_author',
)
);
}
add_action( 'init', 'register_block_core_post_author' );
@@ -0,0 +1,39 @@
{
"apiVersion": 2,
"name": "core/post-author",
"title": "Post Author",
"category": "design",
"description": "Add the author of this post.",
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
},
"avatarSize": {
"type": "number",
"default": 48
},
"showAvatar": {
"type": "boolean",
"default": true
},
"showBio": {
"type": "boolean"
},
"byline": {
"type": "string"
}
},
"usesContext": [ "postType", "postId" ],
"supports": {
"html": false,
"fontSize": true,
"color": {
"gradients": true,
"link": true
},
"lineHeight": true
},
"editorStyle": "wp-block-post-author-editor",
"style": "wp-block-post-author"
}
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* Server-side rendering of the `core/post-content` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-content` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post content of the current post.
*/
function render_block_core_post_content( $attributes, $content, $block ) {
static $seen_ids = array();
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$post_id = $block->context['postId'];
if ( isset( $seen_ids[ $post_id ] ) ) {
if ( ! is_admin() ) {
trigger_error(
sprintf(
// translators: %s is a post ID (integer).
__( 'Could not render Post Content block with post ID: <code>%s</code>. Block cannot be rendered inside itself.' ),
$post_id
),
E_USER_WARNING
);
}
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.
__( '[block rendering halted]' ) :
'';
}
$seen_ids[ $post_id ] = true;
if ( ! in_the_loop() ) {
the_post();
}
$content = get_the_content( null, false, $post_id );
if ( empty( $content ) ) {
unset( $seen_ids[ $post_id ] );
return '';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) );
/** This filter is documented in wp-includes/post-template.php */
$content = apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', $content ) );
unset( $seen_ids[ $post_id ] );
return (
'<div ' . $wrapper_attributes . '>' .
$content .
'</div>'
);
}
/**
* Registers the `core/post-content` block on the server.
*/
function register_block_core_post_content() {
register_block_type_from_metadata(
__DIR__ . '/post-content',
array(
'render_callback' => 'render_block_core_post_content',
)
);
}
add_action( 'init', 'register_block_core_post_content' );
@@ -0,0 +1,15 @@
{
"apiVersion": 2,
"name": "core/post-content",
"title": "Post Content",
"category": "design",
"description": "Displays the contents of a post or page.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"supports": {
"align": [ "wide", "full" ],
"html": false,
"__experimentalLayout": true
},
"editorStyle": "wp-block-post-content-editor"
}
+48
View File
@@ -0,0 +1,48 @@
<?php
/**
* Server-side rendering of the `core/post-date` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-date` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post date for the current post wrapped inside "time" tags.
*/
function render_block_core_post_date( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$post_ID = $block->context['postId'];
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
$formatted_date = get_the_date( isset( $attributes['format'] ) ? $attributes['format'] : '', $post_ID );
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$formatted_date = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $formatted_date );
}
return sprintf(
'<div %1$s><time datetime="%2$s">%3$s</time></div>',
$wrapper_attributes,
get_the_date( 'c', $post_ID ),
$formatted_date
);
}
/**
* Registers the `core/post-date` block on the server.
*/
function register_block_core_post_date() {
register_block_type_from_metadata(
__DIR__ . '/post-date',
array(
'render_callback' => 'render_block_core_post_date',
)
);
}
add_action( 'init', 'register_block_core_post_date' );
@@ -0,0 +1,30 @@
{
"apiVersion": 2,
"name": "core/post-date",
"title": "Post Date",
"category": "design",
"description": "Add the date of this post.",
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
},
"format": {
"type": "string"
},
"isLink": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"color": {
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
/**
* Server-side rendering of the `core/post-excerpt` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-excerpt` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post excerpt for the current post wrapped inside "p" tags.
*/
function render_block_core_post_excerpt( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$more_text = isset( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . $attributes['moreText'] . '</a>' : '';
$filter_excerpt_length = function() use ( $attributes ) {
return isset( $attributes['wordCount'] ) ? $attributes['wordCount'] : 55;
};
add_filter(
'excerpt_length',
$filter_excerpt_length
);
$classes = '';
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$content = '<p class="wp-block-post-excerpt__excerpt">' . get_the_excerpt( $block->context['postId'] );
if ( ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine'] ) {
$content .= '</p><p class="wp-block-post-excerpt__more-text">' . $more_text . '</p>';
} else {
$content .= " $more_text</p>";
}
remove_filter(
'excerpt_length',
$filter_excerpt_length
);
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $content );
}
/**
* Registers the `core/post-excerpt` block on the server.
*/
function register_block_core_post_excerpt() {
register_block_type_from_metadata(
__DIR__ . '/post-excerpt',
array(
'render_callback' => 'render_block_core_post_excerpt',
)
);
}
add_action( 'init', 'register_block_core_post_excerpt' );
@@ -0,0 +1,36 @@
{
"apiVersion": 2,
"name": "core/post-excerpt",
"title": "Post Excerpt",
"category": "design",
"description": "Display a post's excerpt.",
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
},
"wordCount": {
"type": "number",
"default": 55
},
"moreText": {
"type": "string"
},
"showMoreOnNewLine": {
"type": "boolean",
"default": true
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"fontSize": true,
"color": {
"gradients": true,
"link": true
},
"lineHeight": true
},
"editorStyle": "wp-block-post-excerpt-editor",
"style": "wp-block-post-excerpt"
}
@@ -0,0 +1,47 @@
<?php
/**
* Server-side rendering of the `core/post-featured-image` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-featured-image` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the featured image for the current post.
*/
function render_block_core_post_featured_image( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$post_ID = $block->context['postId'];
$featured_image = get_the_post_thumbnail( $post_ID );
if ( ! $featured_image ) {
return '';
}
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$featured_image = sprintf( '<a href="%1s">%2s</a>', get_the_permalink( $post_ID ), $featured_image );
}
$wrapper_attributes = get_block_wrapper_attributes();
return '<p ' . $wrapper_attributes . '>' . $featured_image . '</p>';
}
/**
* Registers the `core/post-featured-image` block on the server.
*/
function register_block_core_post_featured_image() {
register_block_type_from_metadata(
__DIR__ . '/post-featured-image',
array(
'render_callback' => 'render_block_core_post_featured_image',
)
);
}
add_action( 'init', 'register_block_core_post_featured_image' );
@@ -0,0 +1,21 @@
{
"apiVersion": 2,
"name": "core/post-featured-image",
"title": "Post Featured Image",
"category": "design",
"description": "Display a post's featured image.",
"textdomain": "default",
"attributes": {
"isLink": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"align": [ "left", "right", "center", "wide", "full" ],
"html": false
},
"editorStyle": "wp-block-post-featured-image-editor",
"style": "wp-block-post-featured-image"
}
+60
View File
@@ -0,0 +1,60 @@
<?php
/**
* Server-side rendering of the `core/post-terms` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-terms` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Returns the filtered post terms for the current post wrapped inside "a" tags.
*/
function render_block_core_post_terms( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) || ! isset( $attributes['term'] ) ) {
return '';
}
$post_terms = get_the_terms( $block->context['postId'], $attributes['term'] );
if ( is_wp_error( $post_terms ) ) {
return '';
}
if ( empty( $post_terms ) ) {
return '';
}
$align_class_name = empty( $attributes['textAlign'] ) ? '' : ' ' . "has-text-align-{$attributes['textAlign']}";
$terms_links = '';
foreach ( $post_terms as $term ) {
$terms_links .= sprintf(
'<a href="%1$s">%2$s</a> | ',
get_term_link( $term->term_id ),
esc_html( $term->name )
);
}
$terms_links = trim( $terms_links, ' | ' );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$terms_links
);
}
/**
* Registers the `core/post-terms` block on the server.
*/
function register_block_core_post_terms() {
register_block_type_from_metadata(
__DIR__ . '/post-terms',
array(
'render_callback' => 'render_block_core_post_terms',
)
);
}
add_action( 'init', 'register_block_core_post_terms' );
@@ -0,0 +1,26 @@
{
"apiVersion": 2,
"name": "core/post-terms",
"title": "Post Terms",
"category": "design",
"description": "Post terms.",
"textdomain": "default",
"attributes": {
"term": {
"type": "string"
},
"textAlign": {
"type": "string"
}
},
"usesContext": [ "postId", "postType" ],
"supports": {
"html": false,
"fontSize": true,
"color": {
"gradients": true,
"link": true
},
"lineHeight": true
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* Server-side rendering of the `core/post-title` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-title` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the filtered post title for the current post wrapped inside "h1" tags.
*/
function render_block_core_post_title( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$post_ID = $block->context['postId'];
$tag_name = 'h2';
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
if ( isset( $attributes['level'] ) ) {
$tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level'];
}
$title = get_the_title( $post_ID );
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$title = sprintf( '<a href="%1s" target="%2s" rel="%3s">%4s</a>', get_the_permalink( $post_ID ), $attributes['linkTarget'], $attributes['rel'], $title );
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
return sprintf(
'<%1$s %2$s>%3$s</%1$s>',
$tag_name,
$wrapper_attributes,
$title
);
}
/**
* Registers the `core/post-title` block on the server.
*/
function register_block_core_post_title() {
register_block_type_from_metadata(
__DIR__ . '/post-title',
array(
'render_callback' => 'render_block_core_post_title',
)
);
}
add_action( 'init', 'register_block_core_post_title' );
@@ -0,0 +1,43 @@
{
"apiVersion": 2,
"name": "core/post-title",
"title": "Post Title",
"category": "design",
"description": "Displays the title of a post, page, or any other content-type.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"attributes": {
"textAlign": {
"type": "string"
},
"level": {
"type": "number",
"default": 2
},
"isLink": {
"type": "boolean",
"default": false
},
"rel": {
"type": "string",
"attribute": "rel",
"default": ""
},
"linkTarget": {
"type": "string",
"default": "_self"
}
},
"supports": {
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true
},
"style": "wp-block-post-title"
}
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/preformatted",
"title": "Preformatted",
"category": "text",
"description": "Add text that respects your spacing and tabs, and also allows styling.",
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/pullquote",
"title": "Pullquote",
"category": "text",
"description": "Give special visual emphasis to a quote from your text.",
"textdomain": "default",
"attributes": {
"value": {
"type": "string",
@@ -34,6 +37,14 @@
"anchor": true,
"align": [ "left", "right", "wide", "full" ]
},
"styles": [
{
"name": "default",
"label": "Default",
"isDefault": true
},
{ "name": "solid-color", "label": "Solid color" }
],
"editorStyle": "wp-block-pullquote-editor",
"style": "wp-block-pullquote"
}
+88
View File
@@ -0,0 +1,88 @@
<?php
/**
* Server-side rendering of the `core/query-loop` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-loop` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the output of the query, structured using the layout defined by the block's inner blocks.
*/
function render_block_core_query_loop( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$query_args = construct_wp_query_args( $block, $page );
// Override the custom query with the global query if needed.
$use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] );
if ( $use_global_query ) {
global $wp_query;
if ( $wp_query && isset( $wp_query->query_vars ) && is_array( $wp_query->query_vars ) ) {
// Unset `offset` because if is set, $wp_query overrides/ignores the paged parameter and breaks pagination.
unset( $query_args['offset'] );
$query_args = wp_parse_args( $wp_query->query_vars, $query_args );
if ( empty( $query_args['post_type'] ) && is_singular() ) {
$query_args['post_type'] = get_post_type( get_the_ID() );
}
}
}
$query = new WP_Query( $query_args );
if ( ! $query->have_posts() ) {
return '';
}
$classnames = '';
if ( isset( $block->context['layout'] ) && isset( $block->context['query'] ) ) {
if ( isset( $block->context['layout']['type'] ) && 'flex' === $block->context['layout']['type'] ) {
$classnames = "is-flex-container columns-{$block->context['layout']['columns']}";
}
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$content = '';
while ( $query->have_posts() ) {
$query->the_post();
$block_content = (
new WP_Block(
$block->parsed_block,
array(
'postType' => get_post_type(),
'postId' => get_the_ID(),
)
)
)->render( array( 'dynamic' => false ) );
$content .= "<li>{$block_content}</li>";
}
wp_reset_postdata();
return sprintf(
'<ul %1$s>%2$s</ul>',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/query-loop` block on the server.
*/
function register_block_core_query_loop() {
register_block_type_from_metadata(
__DIR__ . '/query-loop',
array(
'render_callback' => 'render_block_core_query_loop',
'skip_inner_blocks' => true,
)
);
}
add_action( 'init', 'register_block_core_query_loop' );
@@ -0,0 +1,22 @@
{
"apiVersion": 2,
"name": "core/query-loop",
"title": "Query Loop",
"category": "design",
"parent": [ "core/query" ],
"description": "Query loop.",
"textdomain": "default",
"usesContext": [
"queryId",
"query",
"queryContext",
"layout",
"templateSlug"
],
"supports": {
"reusable": false,
"html": false
},
"style": "wp-block-query-loop",
"editorStyle": "wp-block-query-loop-editor"
}
@@ -0,0 +1,67 @@
<?php
/**
* Server-side rendering of the `core/query-pagination-next` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-pagination-next` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the next posts link for the query pagination.
*/
function render_block_core_query_pagination_next( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
$wrapper_attributes = get_block_wrapper_attributes();
$default_label = __( 'Next Page &raquo;', 'gutenberg' );
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
$content = '';
// Check if the pagination is for Query that inherits the global context.
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
$filter_link_attributes = function() use ( $wrapper_attributes ) {
return $wrapper_attributes;
};
add_filter( 'next_posts_link_attributes', $filter_link_attributes );
// Take into account if we have set a bigger `max page`
// than what the query has.
global $wp_query;
if ( $max_page > $wp_query->max_num_pages ) {
$max_page = $wp_query->max_num_pages;
}
$content = get_next_posts_link( $label, $max_page );
remove_filter( 'next_posts_link_attributes', $filter_link_attributes );
} elseif ( ! $max_page || $max_page > $page ) {
$custom_query = new WP_Query( construct_wp_query_args( $block, $page ) );
if ( (int) $custom_query->max_num_pages !== $page ) {
$content = sprintf(
'<a href="%1$s" %2$s>%3$s</a>',
esc_url( add_query_arg( $page_key, $page + 1 ) ),
$wrapper_attributes,
$label
);
}
wp_reset_postdata(); // Restore original Post Data.
}
return $content;
}
/**
* Registers the `core/query-pagination-next` block on the server.
*/
function register_block_core_query_pagination_next() {
register_block_type_from_metadata(
__DIR__ . '/query-pagination-next',
array(
'render_callback' => 'render_block_core_query_pagination_next',
)
);
}
add_action( 'init', 'register_block_core_query_pagination_next' );
@@ -0,0 +1,25 @@
{
"apiVersion": 2,
"name": "core/query-pagination-next",
"title": "Query Pagination Next",
"category": "design",
"parent": [ "core/query-pagination" ],
"description": "Displays the next posts page link.",
"textdomain": "default",
"attributes": {
"label": {
"type": "string"
}
},
"usesContext": [ "queryId", "query" ],
"supports": {
"reusable": false,
"html": false,
"color": {
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
}
}
@@ -0,0 +1,79 @@
<?php
/**
* Server-side rendering of the `core/query-pagination-numbers` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-pagination-numbers` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the pagination numbers for the Query.
*/
function render_block_core_query_pagination_numbers( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$max_page = isset( $block->context['query']['pages'] ) ? (int) $block->context['query']['pages'] : 0;
$wrapper_attributes = get_block_wrapper_attributes();
$content = '';
global $wp_query;
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
// Take into account if we have set a bigger `max page`
// than what the query has.
$total = ! $max_page || $max_page > $wp_query->max_num_pages ? $wp_query->max_num_pages : $max_page;
$paginate_args = array(
'prev_next' => false,
'total' => $total,
);
$content = paginate_links( $paginate_args );
} else {
$block_query = new WP_Query( construct_wp_query_args( $block, $page ) );
// `paginate_links` works with the global $wp_query, so we have to
// temporarily switch it with our custom query.
$prev_wp_query = $wp_query;
$wp_query = $block_query;
$total = ! $max_page || $max_page > $wp_query->max_num_pages ? $wp_query->max_num_pages : $max_page;
$paginate_args = array(
'base' => '%_%',
'format' => "?$page_key=%#%",
'current' => max( 1, $page ),
'total' => $total,
'prev_next' => false,
);
// We still need to preserve `paged` query param if exists, as is used
// for Queries that inherit from global context.
$paged = empty( $_GET['paged'] ) ? null : (int) $_GET['paged'];
if ( $paged ) {
$paginate_args['add_args'] = array( 'paged' => $paged );
}
$content = paginate_links( $paginate_args );
wp_reset_postdata(); // Restore original Post Data.
$wp_query = $prev_wp_query;
}
if ( empty( $content ) ) {
return '';
}
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$content
);
}
/**
* Registers the `core/query-pagination-numbers` block on the server.
*/
function register_block_core_query_pagination_numbers() {
register_block_type_from_metadata(
__DIR__ . '/query-pagination-numbers',
array(
'render_callback' => 'render_block_core_query_pagination_numbers',
)
);
}
add_action( 'init', 'register_block_core_query_pagination_numbers' );
@@ -0,0 +1,15 @@
{
"apiVersion": 2,
"name": "core/query-pagination-numbers",
"title": "Query Pagination Numbers",
"category": "design",
"parent": [ "core/query-pagination" ],
"description": "Displays a list of page numbers for pagination",
"textdomain": "default",
"usesContext": [ "queryId", "query" ],
"supports": {
"reusable": false,
"html": false
},
"editorStyle": "query-pagination-numbers-editor"
}
@@ -0,0 +1,56 @@
<?php
/**
* Server-side rendering of the `core/query-pagination-previous` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-pagination-previous` block on the server.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the previous posts link for the query.
*/
function render_block_core_query_pagination_previous( $attributes, $content, $block ) {
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : filter_var( $_GET[ $page_key ], FILTER_VALIDATE_INT );
$wrapper_attributes = get_block_wrapper_attributes();
$default_label = __( '&laquo; Previous Page', 'gutenberg' );
$label = isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ? $attributes['label'] : $default_label;
$content = '';
// Check if the pagination is for Query that inherits the global context
// and handle appropriately.
if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
$filter_link_attributes = function() use ( $wrapper_attributes ) {
return $wrapper_attributes;
};
add_filter( 'previous_posts_link_attributes', $filter_link_attributes );
$content = get_previous_posts_link( $label );
remove_filter( 'previous_posts_link_attributes', $filter_link_attributes );
} elseif ( 1 !== $page ) {
$content = sprintf(
'<a href="%1$s" %2$s>%3$s</a>',
esc_url( add_query_arg( $page_key, $page - 1 ) ),
$wrapper_attributes,
$label
);
}
return $content;
}
/**
* Registers the `core/query-pagination-previous` block on the server.
*/
function register_block_core_query_pagination_previous() {
register_block_type_from_metadata(
__DIR__ . '/query-pagination-previous',
array(
'render_callback' => 'render_block_core_query_pagination_previous',
)
);
}
add_action( 'init', 'register_block_core_query_pagination_previous' );
@@ -0,0 +1,25 @@
{
"apiVersion": 2,
"name": "core/query-pagination-previous",
"title": "Query Pagination Previous",
"category": "design",
"parent": [ "core/query-pagination" ],
"description": "Displays the previous posts page link.",
"textdomain": "default",
"attributes": {
"label": {
"type": "string"
}
},
"usesContext": [ "queryId", "query" ],
"supports": {
"reusable": false,
"html": false,
"color": {
"gradients": true,
"link": true
},
"fontSize": true,
"lineHeight": true
}
}
@@ -0,0 +1,16 @@
<?php
/**
* Server-side rendering of the `core/query-pagination` block.
*
* @package WordPress
*/
/**
* Registers the `core/query-pagination` block on the server.
*/
function register_block_core_query_pagination() {
register_block_type_from_metadata(
__DIR__ . '/query-pagination'
);
}
add_action( 'init', 'register_block_core_query_pagination' );
@@ -0,0 +1,17 @@
{
"apiVersion": 2,
"name": "core/query-pagination",
"title": "Query Pagination",
"category": "design",
"parent": [ "core/query" ],
"description": "Displays a paginated navigation to next/previous set of posts, when applicable.",
"textdomain": "default",
"usesContext": [ "queryId", "query" ],
"supports": {
"align": true,
"reusable": false,
"html": false
},
"editorStyle": "wp-block-query-pagination-editor",
"style": "wp-block-query-pagination"
}
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* Server-side rendering of the `core/query-title` block.
*
* @package WordPress
*/
/**
* Renders the `core/query-title` block on the server.
* For now it only supports Archive title,
* using queried object information
*
* @param array $attributes Block attributes.
*
* @return string Returns the query title based on the queried object.
*/
function render_block_core_query_title( $attributes ) {
$type = isset( $attributes['type'] ) ? $attributes['type'] : null;
$is_archive = is_archive();
if ( ! $type || ( 'archive' === $type && ! $is_archive ) ) {
return '';
}
$title = '';
if ( $is_archive ) {
$title = get_the_archive_title();
}
$tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
return sprintf(
'<%1$s %2$s>%3$s</%1$s>',
$tag_name,
$wrapper_attributes,
$title
);
}
/**
* Registers the `core/query-title` block on the server.
*/
function register_block_core_query_title() {
register_block_type_from_metadata(
__DIR__ . '/query-title',
array(
'render_callback' => 'render_block_core_query_title',
)
);
}
add_action( 'init', 'register_block_core_query_title' );
@@ -0,0 +1,31 @@
{
"apiVersion": 2,
"name": "core/query-title",
"title": "Query Title",
"category": "design",
"description": "Display the query title.",
"textdomain": "default",
"attributes": {
"type": {
"type": "string"
},
"textAlign": {
"type": "string"
},
"level": {
"type": "number",
"default": 1
}
},
"supports": {
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true
},
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true
},
"editorStyle": "wp-block-query-title-editor"
}
+16
View File
@@ -0,0 +1,16 @@
<?php
/**
* Server-side rendering of the `core/query` block.
*
* @package WordPress
*/
/**
* Registers the `core/query` block on the server.
*/
function register_block_core_query() {
register_block_type_from_metadata(
__DIR__ . '/query'
);
}
add_action( 'init', 'register_block_core_query' );
+51
View File
@@ -0,0 +1,51 @@
{
"apiVersion": 2,
"name": "core/query",
"title": "Query",
"category": "design",
"description": "Displays a list of posts as a result of a query.",
"textdomain": "default",
"attributes": {
"queryId": {
"type": "number"
},
"query": {
"type": "object",
"default": {
"perPage": null,
"pages": 0,
"offset": 0,
"postType": "post",
"categoryIds": [],
"tagIds": [],
"order": "desc",
"orderBy": "date",
"author": "",
"search": "",
"exclude": [],
"sticky": "",
"inherit": true
}
},
"tagName": {
"type": "string",
"default": "div"
},
"layout": {
"type": "object",
"default": {
"type": "list"
}
}
},
"providesContext": {
"queryId": "queryId",
"query": "query",
"layout": "layout"
},
"supports": {
"align": [ "wide", "full" ],
"html": false
},
"editorStyle": "wp-block-query-editor"
}
+12
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/quote",
"title": "Quote",
"category": "text",
"description": "Give quoted text visual emphasis. \"In quoting others, we cite ourselves.\" — Julio Cortázar",
"keywords": [ "blockquote", "cite" ],
"textdomain": "default",
"attributes": {
"value": {
"type": "string",
@@ -25,6 +29,14 @@
"supports": {
"anchor": true
},
"styles": [
{
"name": "default",
"label": "Default",
"isDefault": true
},
{ "name": "large", "label": "Large" }
],
"editorStyle": "wp-block-quote-editor",
"style": "wp-block-quote"
}
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/rss",
"title": "RSS",
"category": "widgets",
"description": "Display entries from any RSS or Atom feed.",
"keywords": [ "atom", "feed" ],
"textdomain": "default",
"attributes": {
"columns": {
"type": "number",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/search",
"title": "Search",
"category": "widgets",
"description": "Help visitors find your content.",
"keywords": [ "find" ],
"textdomain": "default",
"attributes": {
"label": {
"type": "string",
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/separator",
"title": "Separator",
"category": "design",
"description": "Create a break between ideas or sections with a horizontal separator.",
"keywords": [ "horizontal-line", "hr", "divider" ],
"textdomain": "default",
"attributes": {
"color": {
"type": "string"
@@ -14,6 +18,11 @@
"anchor": true,
"align": [ "center", "wide", "full" ]
},
"styles": [
{ "name": "default", "label": "Default", "isDefault": true },
{ "name": "wide", "label": "Wide Line" },
{ "name": "dots", "label": "Dots" }
],
"editorStyle": "wp-block-separator-editor",
"style": "wp-block-separator"
}
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/shortcode",
"title": "Shortcode",
"category": "widgets",
"description": "Insert additional custom elements with a WordPress shortcode.",
"textdomain": "default",
"attributes": {
"text": {
"type": "string",
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* Server-side rendering of the `core/site-tagline` block.
*
* @package WordPress
*/
/**
* Renders the `core/site-tagline` block on the server.
*
* @param array $attributes The block attributes.
*
* @return string The render.
*/
function render_block_core_site_tagline( $attributes ) {
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
return sprintf(
'<p %1$s>%2$s</p>',
$wrapper_attributes,
get_bloginfo( 'description' )
);
}
/**
* Registers the `core/site-tagline` block on the server.
*/
function register_block_core_site_tagline() {
register_block_type_from_metadata(
__DIR__ . '/site-tagline',
array(
'render_callback' => 'render_block_core_site_tagline',
)
);
}
add_action( 'init', 'register_block_core_site_tagline' );
@@ -0,0 +1,27 @@
{
"apiVersion": 2,
"name": "core/site-tagline",
"title": "Site Tagline",
"category": "design",
"description": "In a few words, what this site is about.",
"keywords": [ "description" ],
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
}
},
"supports": {
"html": false,
"color": {
"gradients": true
},
"spacing": {
"padding": true
},
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalTextTransform": true
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
/**
* Server-side rendering of the `core/site-title` block.
*
* @package WordPress
*/
/**
* Renders the `core/site-title` block on the server.
*
* @param array $attributes The block attributes.
*
* @return string The render.
*/
function render_block_core_site_title( $attributes ) {
$tag_name = 'h1';
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
if ( isset( $attributes['level'] ) ) {
$tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level'];
}
$link = sprintf( '<a href="%1$s" rel="home">%2$s</a>', get_bloginfo( 'url' ), get_bloginfo( 'name' ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
return sprintf(
'<%1$s %2$s>%3$s</%1$s>',
$tag_name,
$wrapper_attributes,
$link
);
}
/**
* Registers the `core/site-title` block on the server.
*/
function register_block_core_site_title() {
register_block_type_from_metadata(
__DIR__ . '/site-title',
array(
'render_callback' => 'render_block_core_site_title',
)
);
}
add_action( 'init', 'register_block_core_site_title' );
@@ -0,0 +1,33 @@
{
"apiVersion": 2,
"name": "core/site-title",
"title": "Site Title",
"category": "design",
"description": "Displays and allows editing the name of the site. The site title usually appears in the browser title bar, in search results, and more. Also available in Settings > General.",
"textdomain": "default",
"attributes": {
"level": {
"type": "number",
"default": 1
},
"textAlign": {
"type": "string"
}
},
"supports": {
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true,
"text": false,
"link": true
},
"spacing": {
"padding": true
},
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalTextTransform": true
}
}
@@ -1,8 +1,11 @@
{
"apiVersion": 2,
"name": "core/social-link",
"title": "Social Icon",
"category": "widgets",
"parent": [ "core/social-links" ],
"description": "Display an icon linking to a social media profile or website.",
"textdomain": "default",
"attributes": {
"url": {
"type": "string"
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/social-links",
"title": "Social Icons",
"category": "widgets",
"description": "Display icons linking to your social media profiles or websites.",
"keywords": [ "links" ],
"textdomain": "default",
"attributes": {
"iconColor": {
"type": "string"
@@ -38,6 +42,11 @@
"align": [ "left", "center", "right" ],
"anchor": true
},
"styles": [
{ "name": "default", "label": "Default", "isDefault": true },
{ "name": "logos-only", "label": "Logos Only" },
{ "name": "pill-shape", "label": "Pill Shape" }
],
"editorStyle": "wp-block-social-links-editor",
"style": "wp-block-social-links"
}
+3
View File
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/spacer",
"title": "Spacer",
"category": "design",
"description": "Add white space between blocks and customize its height.",
"textdomain": "default",
"attributes": {
"height": {
"type": "number",
+21 -3
View File
@@ -1,15 +1,15 @@
{
"apiVersion": 2,
"name": "core/table",
"title": "Table",
"category": "text",
"description": "Insert a table — perfect for sharing charts and data.",
"textdomain": "default",
"attributes": {
"hasFixedLayout": {
"type": "boolean",
"default": false
},
"backgroundColor": {
"type": "string"
},
"caption": {
"type": "string",
"source": "html",
@@ -125,8 +125,26 @@
"supports": {
"anchor": true,
"align": true,
"color": {
"__experimentalSkipSerialization": true,
"gradients": true
},
"__experimentalBorder": {
"__experimentalSkipSerialization": true,
"color": true,
"style": true,
"width": true
},
"__experimentalSelector": ".wp-block-table > table"
},
"styles": [
{
"name": "regular",
"label": "Default",
"isDefault": true
},
{ "name": "stripes", "label": "Stripes" }
],
"editorStyle": "wp-block-table-editor",
"style": "wp-block-table"
}
@@ -1,7 +1,10 @@
{
"apiVersion": 2,
"name": "core/tag-cloud",
"title": "Tag Cloud",
"category": "widgets",
"description": "A cloud of your most used tags.",
"textdomain": "default",
"attributes": {
"taxonomy": {
"type": "string",
@@ -1,8 +1,11 @@
{
"apiVersion": 2,
"name": "core/text-columns",
"title": "Text Columns (deprecated)",
"icon": "columns",
"category": "design",
"description": "This block is deprecated. Please use the Columns block instead.",
"textdomain": "default",
"attributes": {
"content": {
"type": "array",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/verse",
"title": "Verse",
"category": "text",
"description": "Insert poetry. Use special spacing formats. Or quote song lyrics.",
"keywords": [ "poetry", "poem" ],
"textdomain": "default",
"attributes": {
"content": {
"type": "string",
+4
View File
@@ -1,7 +1,11 @@
{
"apiVersion": 2,
"name": "core/video",
"title": "Video",
"category": "media",
"description": "Embed a video from your media library or upload a new one.",
"keywords": [ "movie" ],
"textdomain": "default",
"attributes": {
"autoplay": {
"type": "boolean",
+1
View File
@@ -301,6 +301,7 @@ require ABSPATH . WPINC . '/block-supports/align.php';
require ABSPATH . WPINC . '/block-supports/border.php';
require ABSPATH . WPINC . '/block-supports/colors.php';
require ABSPATH . WPINC . '/block-supports/custom-classname.php';
require ABSPATH . WPINC . '/block-supports/duotone.php';
require ABSPATH . WPINC . '/block-supports/generated-classname.php';
require ABSPATH . WPINC . '/block-supports/layout.php';
require ABSPATH . WPINC . '/block-supports/padding.php';
+17
View File
@@ -307,11 +307,28 @@ function _unhook_block_registration() {
remove_action( 'init', 'register_block_core_calendar' );
remove_action( 'init', 'register_block_core_categories' );
remove_action( 'init', 'register_block_core_file' );
remove_action( 'init', 'register_block_core_loginout' );
remove_action( 'init', 'register_block_core_latest_comments' );
remove_action( 'init', 'register_block_core_latest_posts' );
remove_action( 'init', 'register_block_core_post_author' );
remove_action( 'init', 'register_block_core_post_content' );
remove_action( 'init', 'register_block_core_post_date' );
remove_action( 'init', 'register_block_core_post_excerpt' );
remove_action( 'init', 'register_block_core_post_featured_image' );
remove_action( 'init', 'register_block_core_post_terms' );
remove_action( 'init', 'register_block_core_post_title' );
remove_action( 'init', 'register_block_core_query' );
remove_action( 'init', 'register_block_core_query_loop' );
remove_action( 'init', 'register_block_core_query_pagination' );
remove_action( 'init', 'register_block_core_query_pagination_next' );
remove_action( 'init', 'register_block_core_query_pagination_numbers' );
remove_action( 'init', 'register_block_core_query_pagination_previous' );
remove_action( 'init', 'register_block_core_query_title' );
remove_action( 'init', 'register_block_core_rss' );
remove_action( 'init', 'register_block_core_search' );
remove_action( 'init', 'register_block_core_shortcode' );
remove_action( 'init', 'register_block_core_site_tagline' );
remove_action( 'init', 'register_block_core_site_title' );
remove_action( 'init', 'register_block_core_social_link' );
remove_action( 'init', 'register_block_core_social_link' );
remove_action( 'init', 'register_block_core_tag_cloud' );
+17
View File
@@ -112,9 +112,26 @@ module.exports = function( env = { environment: 'production', watch: false, buil
'file',
'latest-comments',
'latest-posts',
'loginout',
'post-author',
'post-content',
'post-date',
'post-excerpt',
'post-featured-image',
'post-terms',
'post-title',
'query',
'query-loop',
'query-pagination',
'query-pagination-next',
'query-pagination-numbers',
'query-pagination-previous',
'query-title',
'rss',
'search',
'shortcode',
'site-tagline',
'site-title',
'social-link',
'tag-cloud',
];