Editor: update packages; Port block supports to WordPress core.
The following package versions were changed: @wordpress/a11y: 2.11.0 -> 2.13.0 @wordpress/annotations: 1.20.4 -> 1.22.0 @wordpress/api-fetch: 3.18.0 -> 3.20.0 @wordpress/autop: 2.9.0 -> 2.10.0 @wordpress/blob: 2.9.0 -> 2.10.0 @wordpress/block-directory: 1.13.7 -> 1.16.0 @wordpress/block-editor: 4.3.7 -> 5.0.0 @wordpress/block-library: 2.22.7 -> 2.25.0 @wordpress/block-serialization-default-parser: 3.7.0 -> 3.8.0 @wordpress/blocks: 6.20.3 -> 6.23.0 @wordpress/components: 10.0.6 -> 11.0.0 @wordpress/compose: 3.19.3 -> 3.21.0 @wordpress/core-data: 2.20.3 -> 2.23.0 @wordpress/data: 4.22.3 -> 4.24.0 @wordpress/data-controls: 1.16.3 -> 1.18.0 @wordpress/date: 3.10.0 -> 3.12.0 @wordpress/deprecated: 2.9.0 -> 2.10.0 @wordpress/dom: 2.13.1 -> 2.15.0 @wordpress/dom-ready: 2.10.0 -> 2.11.0 @wordpress/e2e-test-utils: 4.11.2 -> 4.14.0 @wordpress/edit-post: 3.21.7 -> 3.24.0 @wordpress/editor: 9.20.7 -> 9.23.0 @wordpress/element: 2.16.0 -> 2.18.0 @wordpress/escape-html: 1.9.0 -> 1.10.0 @wordpress/format-library: 1.22.7 -> 1.24.0 @wordpress/hooks: 2.9.0 -> 2.10.0 @wordpress/html-entities: 2.8.0 -> 2.9.0 @wordpress/i18n: 3.14.0 -> 3.16.0 @wordpress/icons: 2.4.0 -> 2.7.0 @wordpress/is-shallow-equal: 2.1.0 -> 2.3.0 @wordpress/keyboard-shortcuts: 1.9.3 -> 1.11.0 @wordpress/keycodes: 2.14.0 -> 2.16.0 @wordpress/library-export-default-webpack-plugin: 1.7.0 -> 1.9.0 @wordpress/list-reusable-blocks: 1.21.6 -> 1.23.0 @wordpress/media-utils: 1.15.0 -> 1.17.0 @wordpress/notices: 2.8.3 -> 2.10.0 @wordpress/nux: 3.20.6 -> 3.22.0 @wordpress/plugins: 2.20.3 -> 2.22.0 @wordpress/primitives: 1.7.0 -> 1.9.0 @wordpress/priority-queue: 1.7.0 -> 1.9.0 @wordpress/redux-routine: 3.10.0 -> 3.12.0 @wordpress/rich-text: 3.20.4 -> 3.22.0 @wordpress/scripts: 12.1.1 -> 12.3.0 @wordpress/server-side-render: 1.16.6 -> 1.18.0 @wordpress/shortcode: 2.9.0 -> 2.11.0 @wordpress/token-list: 1.11.0 -> 1.13.0 @wordpress/url: 2.17.0 -> 2.19.0 @wordpress/viewport: 2.21.3 -> 2.23.0 @wordpress/warning: 1.2.0 -> 1.3.0 @wordpress/wordcount: 2.10.0 -> 2.12.0 Props isabel_brison, youknowriad, mcsf. Fixes #51461. git-svn-id: https://develop.svn.wordpress.org/trunk@49135 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
011cd72394
commit
27ad65df4d
3380
package-lock.json
generated
3380
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
100
package.json
100
package.json
@ -27,9 +27,9 @@
|
||||
"devDependencies": {
|
||||
"@wordpress/custom-templated-path-webpack-plugin": "1.7.0",
|
||||
"@wordpress/dependency-extraction-webpack-plugin": "2.8.0",
|
||||
"@wordpress/e2e-test-utils": "4.11.2",
|
||||
"@wordpress/library-export-default-webpack-plugin": "1.7.0",
|
||||
"@wordpress/scripts": "12.1.1",
|
||||
"@wordpress/e2e-test-utils": "4.14.0",
|
||||
"@wordpress/library-export-default-webpack-plugin": "1.9.0",
|
||||
"@wordpress/scripts": "12.3.0",
|
||||
"autoprefixer": "9.6.2",
|
||||
"chalk": "4.1.0",
|
||||
"check-node-version": "4.0.1",
|
||||
@ -79,53 +79,53 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "7.10.1",
|
||||
"@wordpress/a11y": "2.11.0",
|
||||
"@wordpress/annotations": "1.20.4",
|
||||
"@wordpress/api-fetch": "3.18.0",
|
||||
"@wordpress/autop": "2.9.0",
|
||||
"@wordpress/blob": "2.9.0",
|
||||
"@wordpress/block-directory": "1.13.7",
|
||||
"@wordpress/block-editor": "4.3.7",
|
||||
"@wordpress/block-library": "2.22.7",
|
||||
"@wordpress/block-serialization-default-parser": "3.7.0",
|
||||
"@wordpress/blocks": "6.20.3",
|
||||
"@wordpress/components": "10.0.6",
|
||||
"@wordpress/compose": "3.19.3",
|
||||
"@wordpress/core-data": "2.20.3",
|
||||
"@wordpress/data": "4.22.3",
|
||||
"@wordpress/data-controls": "1.16.3",
|
||||
"@wordpress/date": "3.10.0",
|
||||
"@wordpress/deprecated": "2.9.0",
|
||||
"@wordpress/dom": "2.13.1",
|
||||
"@wordpress/dom-ready": "2.10.0",
|
||||
"@wordpress/edit-post": "3.21.7",
|
||||
"@wordpress/editor": "9.20.7",
|
||||
"@wordpress/element": "2.16.0",
|
||||
"@wordpress/escape-html": "1.9.0",
|
||||
"@wordpress/format-library": "1.22.7",
|
||||
"@wordpress/hooks": "2.9.0",
|
||||
"@wordpress/html-entities": "2.8.0",
|
||||
"@wordpress/i18n": "3.14.0",
|
||||
"@wordpress/icons": "2.4.0",
|
||||
"@wordpress/is-shallow-equal": "2.1.0",
|
||||
"@wordpress/keyboard-shortcuts": "1.9.3",
|
||||
"@wordpress/keycodes": "2.14.0",
|
||||
"@wordpress/list-reusable-blocks": "1.21.6",
|
||||
"@wordpress/media-utils": "1.15.0",
|
||||
"@wordpress/notices": "2.8.3",
|
||||
"@wordpress/nux": "3.20.6",
|
||||
"@wordpress/plugins": "2.20.3",
|
||||
"@wordpress/primitives": "1.7.0",
|
||||
"@wordpress/priority-queue": "1.7.0",
|
||||
"@wordpress/redux-routine": "3.10.0",
|
||||
"@wordpress/rich-text": "3.20.4",
|
||||
"@wordpress/server-side-render": "1.16.6",
|
||||
"@wordpress/shortcode": "2.9.0",
|
||||
"@wordpress/token-list": "1.11.0",
|
||||
"@wordpress/url": "2.17.0",
|
||||
"@wordpress/viewport": "2.21.3",
|
||||
"@wordpress/warning": "1.2.0",
|
||||
"@wordpress/wordcount": "2.10.0",
|
||||
"@wordpress/a11y": "2.13.0",
|
||||
"@wordpress/annotations": "1.22.0",
|
||||
"@wordpress/api-fetch": "3.20.0",
|
||||
"@wordpress/autop": "2.10.0",
|
||||
"@wordpress/blob": "2.10.0",
|
||||
"@wordpress/block-directory": "1.16.1",
|
||||
"@wordpress/block-editor": "5.0.1",
|
||||
"@wordpress/block-library": "2.25.1",
|
||||
"@wordpress/block-serialization-default-parser": "3.8.0",
|
||||
"@wordpress/blocks": "6.23.0",
|
||||
"@wordpress/components": "11.0.0",
|
||||
"@wordpress/compose": "3.21.0",
|
||||
"@wordpress/core-data": "2.23.0",
|
||||
"@wordpress/data": "4.24.0",
|
||||
"@wordpress/data-controls": "1.18.0",
|
||||
"@wordpress/date": "3.12.0",
|
||||
"@wordpress/deprecated": "2.10.0",
|
||||
"@wordpress/dom": "2.15.0",
|
||||
"@wordpress/dom-ready": "2.11.0",
|
||||
"@wordpress/edit-post": "3.24.1",
|
||||
"@wordpress/editor": "9.23.1",
|
||||
"@wordpress/element": "2.18.0",
|
||||
"@wordpress/escape-html": "1.10.0",
|
||||
"@wordpress/format-library": "1.24.1",
|
||||
"@wordpress/hooks": "2.10.0",
|
||||
"@wordpress/html-entities": "2.9.0",
|
||||
"@wordpress/i18n": "3.16.0",
|
||||
"@wordpress/icons": "2.7.0",
|
||||
"@wordpress/is-shallow-equal": "2.3.0",
|
||||
"@wordpress/keyboard-shortcuts": "1.11.0",
|
||||
"@wordpress/keycodes": "2.16.0",
|
||||
"@wordpress/list-reusable-blocks": "1.23.0",
|
||||
"@wordpress/media-utils": "1.17.0",
|
||||
"@wordpress/notices": "2.10.0",
|
||||
"@wordpress/nux": "3.22.0",
|
||||
"@wordpress/plugins": "2.22.0",
|
||||
"@wordpress/primitives": "1.9.0",
|
||||
"@wordpress/priority-queue": "1.9.0",
|
||||
"@wordpress/redux-routine": "3.12.0",
|
||||
"@wordpress/rich-text": "3.22.0",
|
||||
"@wordpress/server-side-render": "1.18.0",
|
||||
"@wordpress/shortcode": "2.11.0",
|
||||
"@wordpress/token-list": "1.13.0",
|
||||
"@wordpress/url": "2.19.0",
|
||||
"@wordpress/viewport": "2.23.0",
|
||||
"@wordpress/warning": "1.3.0",
|
||||
"@wordpress/wordcount": "2.12.0",
|
||||
"backbone": "1.4.0",
|
||||
"clipboard": "2.0.6",
|
||||
"core-js-url-browser": "3.6.4",
|
||||
|
34
src/wp-includes/array.php
Normal file
34
src/wp-includes/array.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Array API: WordPress array utilities.
|
||||
*
|
||||
* @package WordPress
|
||||
* @since 5.6.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Accesses an array in depth based on a path of keys.
|
||||
* It is the PHP equivalent of JavaScript's lodash.get, and mirroring it may help other components
|
||||
* retain some symmetry between client and server implementations.
|
||||
*
|
||||
* @param array $array An array from which we want to retrieve some information.
|
||||
* @param array $path An array of keys describing the path with which to retrieve information.
|
||||
* @param array $default The return value if the path is not set on the array or if the types of array and path are not arrays.
|
||||
*
|
||||
* @return array An array matching the path specified.
|
||||
*/
|
||||
function wp_array_get( $array, $path, $default = array() ) {
|
||||
// Confirm input values are expected type to avoid notice warnings.
|
||||
if ( ! is_array( $array ) || ! is_array( $path ) ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
$path_length = count( $path );
|
||||
for ( $i = 0; $i < $path_length; ++$i ) {
|
||||
if ( ! isset( $array[ $path[ $i ] ] ) ) {
|
||||
return $default;
|
||||
}
|
||||
$array = $array[ $path[ $i ] ];
|
||||
}
|
||||
return $array;
|
||||
}
|
File diff suppressed because one or more lines are too long
56
src/wp-includes/block-supports/align.php
Normal file
56
src/wp-includes/block-supports/align.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Align block support flag.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers the align block attribute for block types that support it.
|
||||
*
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*/
|
||||
function wp_register_alignment_support( $block_type ) {
|
||||
$has_align_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_align_support = wp_array_get( $block_type->supports, array( 'align' ), false );
|
||||
}
|
||||
if ( $has_align_support ) {
|
||||
if ( ! $block_type->attributes ) {
|
||||
$block_type->attributes = array();
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( 'align', $block_type->attributes ) ) {
|
||||
$block_type->attributes['align'] = array(
|
||||
'type' => 'string',
|
||||
'enum' => array( 'left', 'center', 'right', 'wide', 'full', '' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSS classes for block alignment to the incoming attributes array.
|
||||
* This will be applied to the block markup in the front-end.
|
||||
*
|
||||
* @param array $attributes Comprehensive list of attributes to be applied.
|
||||
* @param array $block_attributes Block attributes.
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*
|
||||
* @return array Block alignment CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_alignment_support( $attributes, $block_attributes, $block_type ) {
|
||||
$has_align_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_align_support = wp_array_get( $block_type->supports, array( 'align' ), false );
|
||||
}
|
||||
if ( $has_align_support ) {
|
||||
$has_block_alignment = array_key_exists( 'align', $block_attributes );
|
||||
|
||||
if ( $has_block_alignment ) {
|
||||
$attributes['css_classes'][] = sprintf( 'align%s', $block_attributes['align'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
139
src/wp-includes/block-supports/colors.php
Normal file
139
src/wp-includes/block-supports/colors.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* Colors block support flag.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers the style and colors block attributes for block types that support it.
|
||||
*
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*/
|
||||
function wp_register_colors_support( $block_type ) {
|
||||
$color_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$color_support = wp_array_get( $block_type->supports, array( '__experimentalColor' ), false );
|
||||
}
|
||||
$has_text_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'text' ), true ) );
|
||||
$has_background_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'background' ), true ) );
|
||||
$has_gradients_support = wp_array_get( $color_support, array( 'gradients' ), false );
|
||||
|
||||
if ( ! $block_type->attributes ) {
|
||||
$block_type->attributes = array();
|
||||
}
|
||||
|
||||
if ( $has_text_colors_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
|
||||
$block_type->attributes['style'] = array(
|
||||
'type' => 'object',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $has_background_colors_support && ! array_key_exists( 'backgroundColor', $block_type->attributes ) ) {
|
||||
$block_type->attributes['backgroundColor'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $has_text_colors_support && ! array_key_exists( 'textColor', $block_type->attributes ) ) {
|
||||
$block_type->attributes['textColor'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $has_gradients_support && ! array_key_exists( 'gradient', $block_type->attributes ) ) {
|
||||
$block_type->attributes['gradient'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add CSS classes and inline styles for colors to the incoming attributes array.
|
||||
* This will be applied to the block markup in the front-end.
|
||||
*
|
||||
* @param array $attributes Comprehensive list of attributes to be applied.
|
||||
* @param array $block_attributes Block attributes.
|
||||
* @param WP_Block_Type $block_type Block type.
|
||||
*
|
||||
* @return array Colors CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_colors_support( $attributes, $block_attributes, $block_type ) {
|
||||
$color_support = wp_array_get( $block_type->supports, array( '__experimentalColor' ), false );
|
||||
$has_text_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'text' ), true ) );
|
||||
$has_background_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'background' ), true ) );
|
||||
$has_link_colors_support = wp_array_get( $color_support, array( 'linkColor' ), false );
|
||||
$has_gradients_support = wp_array_get( $color_support, array( 'gradients' ), false );
|
||||
|
||||
// Text Colors.
|
||||
// Check support for text colors.
|
||||
if ( $has_text_colors_support ) {
|
||||
$has_named_text_color = array_key_exists( 'textColor', $block_attributes );
|
||||
$has_custom_text_color = isset( $block_attributes['style']['color']['text'] );
|
||||
|
||||
// Apply required generic class.
|
||||
if ( $has_custom_text_color || $has_named_text_color ) {
|
||||
$attributes['css_classes'][] = 'has-text-color';
|
||||
}
|
||||
// Apply color class or inline style.
|
||||
if ( $has_named_text_color ) {
|
||||
$attributes['css_classes'][] = sprintf( 'has-%s-color', $block_attributes['textColor'] );
|
||||
} elseif ( $has_custom_text_color ) {
|
||||
$attributes['inline_styles'][] = sprintf( 'color: %s;', $block_attributes['style']['color']['text'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Link Colors.
|
||||
if ( $has_link_colors_support ) {
|
||||
$has_link_color = isset( $block_attributes['style']['color']['link'] );
|
||||
// Apply required class and style.
|
||||
if ( $has_link_color ) {
|
||||
$attributes['css_classes'][] = 'has-link-color';
|
||||
// If link is a named color.
|
||||
if ( strpos( $block_attributes['style']['color']['link'], 'var:preset|color|' ) !== false ) {
|
||||
// Get the name from the string and add proper styles.
|
||||
$index_to_splice = strrpos( $block_attributes['style']['color']['link'], '|' ) + 1;
|
||||
$link_color_name = substr( $block_attributes['style']['color']['link'], $index_to_splice );
|
||||
$attributes['inline_styles'][] = sprintf( '--wp--style--color--link:var(--wp--preset--color--%s);', $link_color_name );
|
||||
} else {
|
||||
$attributes['inline_styles'][] = sprintf( '--wp--style--color--link: %s;', $block_attributes['style']['color']['link'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Background Colors.
|
||||
if ( $has_background_colors_support ) {
|
||||
$has_named_background_color = array_key_exists( 'backgroundColor', $block_attributes );
|
||||
$has_custom_background_color = isset( $block_attributes['style']['color']['background'] );
|
||||
|
||||
// Apply required background class.
|
||||
if ( $has_custom_background_color || $has_named_background_color ) {
|
||||
$attributes['css_classes'][] = 'has-background';
|
||||
}
|
||||
// Apply background color classes or styles.
|
||||
if ( $has_named_background_color ) {
|
||||
$attributes['css_classes'][] = sprintf( 'has-%s-background-color', $block_attributes['backgroundColor'] );
|
||||
} elseif ( $has_custom_background_color ) {
|
||||
$attributes['inline_styles'][] = sprintf( 'background-color: %s;', $block_attributes['style']['color']['background'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Gradients.
|
||||
if ( $has_gradients_support ) {
|
||||
$has_named_gradient = array_key_exists( 'gradient', $block_attributes );
|
||||
$has_custom_gradient = isset( $block_attributes['style']['color']['gradient'] );
|
||||
|
||||
if ( $has_named_gradient || $has_custom_gradient ) {
|
||||
$attributes['css_classes'][] = 'has-background';
|
||||
}
|
||||
// Apply required background class.
|
||||
if ( $has_named_gradient ) {
|
||||
$attributes['css_classes'][] = sprintf( 'has-%s-gradient-background', $block_attributes['gradient'] );
|
||||
} elseif ( $has_custom_gradient ) {
|
||||
$attributes['inline_styles'][] = sprintf( 'background: %s;', $block_attributes['style']['color']['gradient'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
54
src/wp-includes/block-supports/custom-classname.php
Normal file
54
src/wp-includes/block-supports/custom-classname.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Custom classname block support flag.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers the custom classname block attribute for block types that support it.
|
||||
*
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*/
|
||||
function wp_register_custom_classname_support( $block_type ) {
|
||||
$has_custom_classname_support = true;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_custom_classname_support = wp_array_get( $block_type->supports, array( 'customClassName' ), true );
|
||||
}
|
||||
if ( $has_custom_classname_support ) {
|
||||
if ( ! $block_type->attributes ) {
|
||||
$block_type->attributes = array();
|
||||
}
|
||||
|
||||
if ( ! array_key_exists( 'className', $block_type->attributes ) ) {
|
||||
$block_type->attributes['className'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the custom classnames to the output.
|
||||
*
|
||||
* @param array $attributes Comprehensive list of attributes to be applied.
|
||||
* @param array $block_attributes Block attributes.
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*
|
||||
* @return array Block CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_custom_classname_support( $attributes, $block_attributes, $block_type ) {
|
||||
$has_custom_classname_support = true;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_custom_classname_support = wp_array_get( $block_type->supports, array( 'customClassName' ), true );
|
||||
}
|
||||
if ( $has_custom_classname_support ) {
|
||||
$has_custom_classnames = array_key_exists( 'className', $block_attributes );
|
||||
|
||||
if ( $has_custom_classnames ) {
|
||||
$attributes['css_classes'][] = $block_attributes['className'];
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
57
src/wp-includes/block-supports/generated-classname.php
Normal file
57
src/wp-includes/block-supports/generated-classname.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Generated classname block support flag.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the generated classname from a given block name.
|
||||
*
|
||||
* @param string $block_name Block Name.
|
||||
* @return string Generated classname.
|
||||
*/
|
||||
function wp_get_block_default_classname( $block_name ) {
|
||||
// Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature.
|
||||
// Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
|
||||
$classname = 'wp-block-' . preg_replace(
|
||||
'/^core-/',
|
||||
'',
|
||||
str_replace( '/', '-', $block_name )
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the default block className for server rendered blocks.
|
||||
*
|
||||
* @param string $class_name The current applied classname.
|
||||
* @param string $block_name The block name.
|
||||
*/
|
||||
$classname = apply_filters( 'block_default_classname', $classname, $block_name );
|
||||
|
||||
return $classname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the generated classnames to the output.
|
||||
*
|
||||
* @param array $attributes Comprehensive list of attributes to be applied.
|
||||
* @param array $block_attributes Block attributes.
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*
|
||||
* @return array Block CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_generated_classname_support( $attributes, $block_attributes, $block_type ) {
|
||||
$has_generated_classname_support = true;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_generated_classname_support = wp_array_get( $block_type->supports, array( 'className' ), true );
|
||||
}
|
||||
if ( $has_generated_classname_support ) {
|
||||
$block_classname = wp_get_block_default_classname( $block_type->name );
|
||||
|
||||
if ( $block_classname ) {
|
||||
$attributes['css_classes'][] = $block_classname;
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
137
src/wp-includes/block-supports/index.php
Normal file
137
src/wp-includes/block-supports/index.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Block support flags.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// Require all the block supports mechanisms.
|
||||
require __DIR__ . '/align.php';
|
||||
require __DIR__ . '/colors.php';
|
||||
require __DIR__ . '/custom-classname.php';
|
||||
require __DIR__ . '/generated-classname.php';
|
||||
require __DIR__ . '/typography.php';
|
||||
|
||||
/**
|
||||
* Filter the registered blocks to apply the block supports attributes registration.
|
||||
*/
|
||||
function wp_register_block_supports() {
|
||||
$block_registry = WP_Block_Type_Registry::get_instance();
|
||||
$registered_block_types = $block_registry->get_all_registered();
|
||||
// Ideally we need a hook to extend the block registration
|
||||
// instead of mutating the block type.
|
||||
foreach ( $registered_block_types as $block_type ) {
|
||||
wp_register_alignment_support( $block_type );
|
||||
wp_register_colors_support( $block_type );
|
||||
wp_register_typography_support( $block_type );
|
||||
wp_register_custom_classname_support( $block_type );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'init', 'wp_register_block_supports', 21 );
|
||||
|
||||
/**
|
||||
* Filters the frontend output of blocks and apply the block support flags transformations.
|
||||
*
|
||||
* @param string $block_content rendered block content.
|
||||
* @param array $block block object.
|
||||
* @return string filtered block content.
|
||||
*/
|
||||
function wp_apply_block_supports( $block_content, $block ) {
|
||||
if ( ! isset( $block['attrs'] ) ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
|
||||
// If no render_callback, assume styles have been previously handled.
|
||||
if ( ! $block_type || ! $block_type->render_callback ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$attributes = array();
|
||||
$attributes = wp_apply_generated_classname_support( $attributes, $block['attrs'], $block_type );
|
||||
$attributes = wp_apply_colors_support( $attributes, $block['attrs'], $block_type );
|
||||
$attributes = wp_apply_typography_support( $attributes, $block['attrs'], $block_type );
|
||||
$attributes = wp_apply_alignment_support( $attributes, $block['attrs'], $block_type );
|
||||
$attributes = wp_apply_custom_classname_support( $attributes, $block['attrs'], $block_type );
|
||||
|
||||
if ( ! count( $attributes ) ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
$dom = new DOMDocument( '1.0', 'utf-8' );
|
||||
|
||||
// Suppress DOMDocument::loadHTML warnings from polluting the front-end.
|
||||
$previous = libxml_use_internal_errors( true );
|
||||
|
||||
// We need to wrap the block in order to handle UTF-8 properly.
|
||||
$wrapped_block_html =
|
||||
'<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>'
|
||||
. $block_content
|
||||
. '</body></html>';
|
||||
|
||||
$success = $dom->loadHTML( $wrapped_block_html, LIBXML_HTML_NODEFDTD | LIBXML_COMPACT );
|
||||
|
||||
// Clear errors and reset the use_errors setting.
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors( $previous );
|
||||
|
||||
if ( ! $success ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
// Structure is like `<html><head/><body/></html>`, so body is the `lastChild` of our document.
|
||||
$body_element = $dom->documentElement->lastChild; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
||||
|
||||
$xpath = new DOMXPath( $dom );
|
||||
$block_root = $xpath->query( './*', $body_element )[0];
|
||||
|
||||
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
||||
if ( empty( $block_root ) ) {
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
// Merge and dedupe new and existing classes and styles.
|
||||
$current_classes = explode( ' ', trim( $block_root->getAttribute( 'class' ) ) );
|
||||
$classes_to_add = array_key_exists( 'css_classes', $attributes ) ? $attributes['css_classes'] : array();
|
||||
$new_classes = array_unique( array_filter( array_merge( $current_classes, $classes_to_add ) ) );
|
||||
|
||||
$current_styles = preg_split( '/\s*;\s*/', trim( $block_root->getAttribute( 'style' ) ) );
|
||||
$styles_to_add = array_key_exists( 'inline_styles', $attributes ) ? $attributes['inline_styles'] : array();
|
||||
$new_styles = array_unique( array_map( 'wp_normalize_css_rule', array_filter( array_merge( $current_styles, $styles_to_add ) ) ) );
|
||||
|
||||
// Apply new styles and classes.
|
||||
if ( ! empty( $new_classes ) ) {
|
||||
// `DOMElement::setAttribute` handles attribute value escaping.
|
||||
$block_root->setAttribute( 'class', implode( ' ', $new_classes ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $new_styles ) ) {
|
||||
// `DOMElement::setAttribute` handles attribute value escaping.
|
||||
$block_root->setAttribute( 'style', implode( '; ', $new_styles ) . ';' );
|
||||
}
|
||||
|
||||
// Avoid using `$dom->saveHtml( $node )` because the node results may not produce consistent
|
||||
// whitespace for PHP < 7.3. Saving the root HTML `$dom->saveHtml()` prevents this behavior.
|
||||
$full_html = $dom->saveHtml();
|
||||
|
||||
// Find the <body> open/close tags. The open tag needs to be adjusted so we get inside the tag
|
||||
// and not the tag itself.
|
||||
$start = strpos( $full_html, '<body>', 0 ) + strlen( '<body>' );
|
||||
$end = strpos( $full_html, '</body>', $start );
|
||||
return trim( substr( $full_html, $start, $end - $start ) );
|
||||
}
|
||||
add_filter( 'render_block', 'wp_apply_block_supports', 10, 2 );
|
||||
|
||||
/**
|
||||
* Normalizes spacing in a string representing a CSS rule
|
||||
*
|
||||
* @example
|
||||
* 'color :red;' becomes 'color:red'
|
||||
*
|
||||
* @param string $css_rule_string CSS rule.
|
||||
* @return string Normalized CSS rule.
|
||||
*/
|
||||
function wp_normalize_css_rule( $css_rule_string ) {
|
||||
return trim( implode( ': ', preg_split( '/\s*:\s*/', $css_rule_string, 2 ) ), ';' );
|
||||
}
|
121
src/wp-includes/block-supports/typography.php
Normal file
121
src/wp-includes/block-supports/typography.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* Typography block support flag.
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers the style and typography block attributes for block types that support it.
|
||||
*
|
||||
* @param WP_Block_Type $block_type Block Type.
|
||||
*/
|
||||
function wp_register_typography_support( $block_type ) {
|
||||
$has_font_size_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_font_size_support = wp_array_get( $block_type->supports, array( '__experimentalFontSize' ), false );
|
||||
}
|
||||
|
||||
$has_font_style_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_font_style_support = wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
|
||||
}
|
||||
|
||||
$has_line_height_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_line_height_support = wp_array_get( $block_type->supports, array( '__experimentalLineHeight' ), false );
|
||||
}
|
||||
|
||||
if ( ! $block_type->attributes ) {
|
||||
$block_type->attributes = array();
|
||||
}
|
||||
|
||||
if ( ( $has_font_size_support || $has_font_style_support || $has_line_height_support ) && ! array_key_exists( 'style', $block_type->attributes ) ) {
|
||||
$block_type->attributes['style'] = array(
|
||||
'type' => 'object',
|
||||
);
|
||||
}
|
||||
|
||||
if ( $has_font_size_support && ! array_key_exists( 'fontSize', $block_type->attributes ) ) {
|
||||
$block_type->attributes['fontSize'] = array(
|
||||
'type' => 'string',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSS classes and inline styles for font sizes to the incoming attributes array.
|
||||
* This will be applied to the block markup in the front-end.
|
||||
*
|
||||
* @param array $attributes Comprehensive list of attributes to be applied.
|
||||
* @param array $block_attributes Block attributes.
|
||||
* @param WP_Block_Type $block_type Block type.
|
||||
*
|
||||
* @return array Font size CSS classes and inline styles.
|
||||
*/
|
||||
function wp_apply_typography_support( $attributes, $block_attributes, $block_type ) {
|
||||
$has_font_size_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_font_size_support = wp_array_get( $block_type->supports, array( '__experimentalFontSize' ), false );
|
||||
}
|
||||
|
||||
$has_font_style_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_font_style_support = wp_array_get( $block_type->supports, array( '__experimentalFontStyle' ), false );
|
||||
}
|
||||
|
||||
$has_line_height_support = false;
|
||||
if ( property_exists( $block_type, 'supports' ) ) {
|
||||
$has_line_height_support = wp_array_get( $block_type->supports, array( '__experimentalLineHeight' ), false );
|
||||
}
|
||||
|
||||
// Font Size.
|
||||
if ( $has_font_size_support ) {
|
||||
$has_named_font_size = array_key_exists( 'fontSize', $block_attributes );
|
||||
$has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] );
|
||||
|
||||
// Apply required class or style.
|
||||
if ( $has_named_font_size ) {
|
||||
$attributes['css_classes'][] = sprintf( 'has-%s-font-size', $block_attributes['fontSize'] );
|
||||
} elseif ( $has_custom_font_size ) {
|
||||
$attributes['inline_styles'][] = sprintf( 'font-size: %spx;', $block_attributes['style']['typography']['fontSize'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Font Styles e.g. bold, italic, underline & strikethrough.
|
||||
if ( $has_font_style_support ) {
|
||||
$has_font_styles = isset( $block_attributes['style']['typography']['fontStyles'] );
|
||||
|
||||
// Apply required CSS classes.
|
||||
if ( $has_font_styles ) {
|
||||
$attributes['css_classes'][] = 'has-font-style';
|
||||
|
||||
// CSS class names chosen to be more explicit than generic `has-<something>-font-style`.
|
||||
$font_style_classes = array(
|
||||
'bold' => 'has-bold-font-weight',
|
||||
'italic' => 'has-italic-font-style',
|
||||
'underline' => 'has-underline-text-decoration',
|
||||
'strikethrough' => 'has-strikethrough-text-decoration',
|
||||
);
|
||||
|
||||
$style_selections = $block_attributes['style']['typography']['fontStyles'];
|
||||
|
||||
foreach ( $style_selections as $style => $turned_on ) {
|
||||
if ( $turned_on ) {
|
||||
$attributes['css_classes'][] = $font_style_classes[ $style ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Line Height.
|
||||
if ( $has_line_height_support ) {
|
||||
$has_line_height = isset( $block_attributes['style']['typography']['lineHeight'] );
|
||||
// Add the style (no classes for line-height).
|
||||
if ( $has_line_height ) {
|
||||
$attributes['inline_styles'][] = sprintf( 'line-height: %s;', $block_attributes['style']['typography']['lineHeight'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
@ -17,15 +17,7 @@
|
||||
function render_block_core_archives( $attributes ) {
|
||||
$show_post_count = ! empty( $attributes['showPostCounts'] );
|
||||
|
||||
$class = 'wp-block-archives';
|
||||
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= " align{$attributes['align']}";
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= " {$attributes['className']}";
|
||||
}
|
||||
$class = '';
|
||||
|
||||
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
|
||||
|
||||
@ -66,7 +58,7 @@ function render_block_core_archives( $attributes ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$label = esc_attr( $label );
|
||||
$label = esc_html( $label );
|
||||
|
||||
$block_content = '<label class="screen-reader-text" for="' . $dropdown_id . '">' . $title . '</label>
|
||||
<select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/archives",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayAsDropdown": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
|
@ -31,12 +31,8 @@ function render_block_core_calendar( $attributes ) {
|
||||
}
|
||||
}
|
||||
|
||||
$custom_class_name = empty( $attributes['className'] ) ? '' : ' ' . $attributes['className'];
|
||||
$align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "align{$attributes['align']}";
|
||||
|
||||
$output = sprintf(
|
||||
'<div class="%1$s">%2$s</div>',
|
||||
esc_attr( 'wp-block-calendar' . $custom_class_name . $align_class_name ),
|
||||
'<div>%1$s</div>',
|
||||
get_calendar( true, false )
|
||||
);
|
||||
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/calendar",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"month": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -33,7 +33,13 @@ function render_block_core_categories( $attributes ) {
|
||||
$type = 'dropdown';
|
||||
|
||||
if ( ! is_admin() ) {
|
||||
$wrapper_markup .= build_dropdown_script_block_core_categories( $id );
|
||||
// Inject the dropdown script immediately after the select dropdown.
|
||||
$items_markup = preg_replace(
|
||||
'#(?<=</select>)#',
|
||||
build_dropdown_script_block_core_categories( $id ),
|
||||
$items_markup,
|
||||
1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$wrapper_markup = '<ul class="%1$s">%2$s</ul>';
|
||||
@ -41,15 +47,7 @@ function render_block_core_categories( $attributes ) {
|
||||
$type = 'list';
|
||||
}
|
||||
|
||||
$class = "wp-block-categories wp-block-categories-{$type}";
|
||||
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= " align{$attributes['align']}";
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= " {$attributes['className']}";
|
||||
}
|
||||
$class = "wp-block-categories-{$type}";
|
||||
|
||||
return sprintf(
|
||||
$wrapper_markup,
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/categories",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"displayAsDropdown": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
|
@ -4,13 +4,12 @@
|
||||
"attributes": {
|
||||
"content": {
|
||||
"type": "string",
|
||||
"source": "text",
|
||||
"source": "html",
|
||||
"selector": "code"
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"html": false,
|
||||
"lightBlockWrapper": true
|
||||
}
|
||||
}
|
||||
|
@ -68,8 +68,7 @@
|
||||
"default": true
|
||||
},
|
||||
"linkTo": {
|
||||
"type": "string",
|
||||
"default": "none"
|
||||
"type": "string"
|
||||
},
|
||||
"sizeSlug": {
|
||||
"type": "string",
|
||||
|
@ -18,6 +18,7 @@
|
||||
"__experimentalColor": {
|
||||
"gradients": true,
|
||||
"linkColor": true
|
||||
}
|
||||
},
|
||||
"__experimentalPadding": true
|
||||
}
|
||||
}
|
||||
|
@ -60,8 +60,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"linkDestination": {
|
||||
"type": "string",
|
||||
"default": "none"
|
||||
"type": "string"
|
||||
},
|
||||
"linkTarget": {
|
||||
"type": "string",
|
||||
|
@ -116,34 +116,28 @@ function render_block_core_latest_comments( $attributes = array() ) {
|
||||
}
|
||||
}
|
||||
|
||||
$class = 'wp-block-latest-comments';
|
||||
if ( ! empty( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= " align{$attributes['align']}";
|
||||
}
|
||||
$classnames = array();
|
||||
if ( $attributes['displayAvatar'] ) {
|
||||
$class .= ' has-avatars';
|
||||
$classnames[] = 'has-avatars';
|
||||
}
|
||||
if ( $attributes['displayDate'] ) {
|
||||
$class .= ' has-dates';
|
||||
$classnames[] = 'has-dates';
|
||||
}
|
||||
if ( $attributes['displayExcerpt'] ) {
|
||||
$class .= ' has-excerpts';
|
||||
$classnames[] = 'has-excerpts';
|
||||
}
|
||||
if ( empty( $comments ) ) {
|
||||
$class .= ' no-comments';
|
||||
$classnames[] = 'no-comments';
|
||||
}
|
||||
$classnames = esc_attr( $class );
|
||||
$class = esc_attr( implode( ' ', $classnames ) );
|
||||
|
||||
return ! empty( $comments ) ? sprintf(
|
||||
'<ol class="%1$s">%2$s</ol>',
|
||||
$classnames,
|
||||
$class,
|
||||
$list_items_markup
|
||||
) : sprintf(
|
||||
'<div class="%1$s">%2$s</div>',
|
||||
$classnames,
|
||||
$class,
|
||||
__( 'No comments to show.' )
|
||||
);
|
||||
}
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/latest-comments",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"commentsToShow": {
|
||||
"type": "number",
|
||||
"default": 5,
|
||||
|
@ -58,6 +58,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$list_items_markup = '';
|
||||
|
||||
foreach ( $recent_posts as $post ) {
|
||||
$post_link = esc_url( get_permalink( $post ) );
|
||||
|
||||
$list_items_markup .= '<li>';
|
||||
|
||||
@ -75,16 +76,24 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$image_classes .= ' align' . $attributes['featuredImageAlign'];
|
||||
}
|
||||
|
||||
$featured_image = get_the_post_thumbnail(
|
||||
$post,
|
||||
$attributes['featuredImageSizeSlug'],
|
||||
array(
|
||||
'style' => $image_style,
|
||||
)
|
||||
);
|
||||
if ( $attributes['addLinkToFeaturedImage'] ) {
|
||||
$featured_image = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
$post_link,
|
||||
$featured_image
|
||||
);
|
||||
}
|
||||
$list_items_markup .= sprintf(
|
||||
'<div class="%1$s">%2$s</div>',
|
||||
$image_classes,
|
||||
get_the_post_thumbnail(
|
||||
$post,
|
||||
$attributes['featuredImageSizeSlug'],
|
||||
array(
|
||||
'style' => $image_style,
|
||||
)
|
||||
)
|
||||
$featured_image
|
||||
);
|
||||
}
|
||||
|
||||
@ -94,7 +103,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
}
|
||||
$list_items_markup .= sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url( get_permalink( $post ) ),
|
||||
$post_link,
|
||||
$title
|
||||
);
|
||||
|
||||
@ -144,10 +153,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
|
||||
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
$class = 'wp-block-latest-posts wp-block-latest-posts__list';
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= ' align' . $attributes['align'];
|
||||
}
|
||||
$class = 'wp-block-latest-posts__list';
|
||||
|
||||
if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {
|
||||
$class .= ' is-grid';
|
||||
@ -165,10 +171,6 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$class .= ' has-author';
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<ul class="%1$s">%2$s</ul>',
|
||||
esc_attr( $class ),
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/latest-posts",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"categories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@ -87,6 +74,10 @@
|
||||
"featuredImageSizeHeight": {
|
||||
"type": "number",
|
||||
"default": null
|
||||
},
|
||||
"addLinkToFeaturedImage": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
|
@ -11,10 +11,7 @@
|
||||
"source": "html",
|
||||
"selector": "ol,ul",
|
||||
"multiline": "li",
|
||||
"__unstableMultilineWrapperTags": [
|
||||
"ol",
|
||||
"ul"
|
||||
],
|
||||
"__unstableMultilineWrapperTags": [ "ol", "ul" ],
|
||||
"default": ""
|
||||
},
|
||||
"type": {
|
||||
@ -30,6 +27,9 @@
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"className": false,
|
||||
"__experimentalColor": {
|
||||
"gradients": true
|
||||
},
|
||||
"__unstablePasteTextInline": true,
|
||||
"lightBlockWrapper": true
|
||||
}
|
||||
|
@ -63,6 +63,9 @@
|
||||
"type": "number",
|
||||
"default": 50
|
||||
},
|
||||
"mediaSizeSlug": {
|
||||
"type": "string"
|
||||
},
|
||||
"isStackedOnMobile": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
@ -79,10 +82,7 @@
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"align": [
|
||||
"wide",
|
||||
"full"
|
||||
],
|
||||
"align": [ "wide", "full" ],
|
||||
"html": false,
|
||||
"lightBlockWrapper": true,
|
||||
"__experimentalColor": {
|
||||
|
@ -35,11 +35,6 @@
|
||||
},
|
||||
"__experimentalFontSize": true,
|
||||
"__experimentalLineHeight": true,
|
||||
"__experimentalFeatures": {
|
||||
"typography": {
|
||||
"dropCap": true
|
||||
}
|
||||
},
|
||||
"__experimentalSelector": "p",
|
||||
"__unstablePasteTextInline": true
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true
|
||||
"anchor": true,
|
||||
"lightBlockWrapper": true
|
||||
}
|
||||
}
|
||||
|
@ -79,24 +79,16 @@ function render_block_core_rss( $attributes ) {
|
||||
$list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>";
|
||||
}
|
||||
|
||||
$class = 'wp-block-rss';
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= ' align' . $attributes['align'];
|
||||
}
|
||||
|
||||
$classnames = array();
|
||||
if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) {
|
||||
$class .= ' is-grid';
|
||||
$classnames[] = 'is-grid';
|
||||
}
|
||||
|
||||
if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) {
|
||||
$class .= ' columns-' . $attributes['columns'];
|
||||
$classnames[] = 'columns-' . $attributes['columns'];
|
||||
}
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
|
||||
return sprintf( '<ul class="%s">%s</ul>', esc_attr( $class ), $list_items );
|
||||
return sprintf( '<ul class="%s">%s</ul>', esc_attr( implode( ' ', $classnames ) ), $list_items );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,19 +2,6 @@
|
||||
"name": "core/rss",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"columns": {
|
||||
"type": "number",
|
||||
"default": 2
|
||||
|
@ -27,51 +27,79 @@ function render_block_core_search( $attributes ) {
|
||||
)
|
||||
);
|
||||
|
||||
$input_id = 'wp-block-search__input-' . ++$instance_id;
|
||||
$label_markup = '';
|
||||
$button_markup = '';
|
||||
$input_id = 'wp-block-search__input-' . ++$instance_id;
|
||||
$classnames = classnames_for_block_core_search( $attributes );
|
||||
$show_label = ( ! empty( $attributes['showLabel'] ) ) ? true : false;
|
||||
$use_icon_button = ( ! empty( $attributes['buttonUseIcon'] ) ) ? true : false;
|
||||
$show_input = ( ! empty( $attributes['buttonPosition'] ) && 'button-only' === $attributes['buttonPosition'] ) ? false : true;
|
||||
$show_button = ( ! empty( $attributes['buttonPosition'] ) && 'no-button' === $attributes['buttonPosition'] ) ? false : true;
|
||||
$label_markup = '';
|
||||
$input_markup = '';
|
||||
$button_markup = '';
|
||||
$width_styles = '';
|
||||
|
||||
if ( ! empty( $attributes['label'] ) ) {
|
||||
$label_markup = sprintf(
|
||||
'<label for="%s" class="wp-block-search__label">%s</label>',
|
||||
if ( $show_label ) {
|
||||
if ( ! empty( $attributes['label'] ) ) {
|
||||
$label_markup = sprintf(
|
||||
'<label for="%s" class="wp-block-search__label">%s</label>',
|
||||
$input_id,
|
||||
$attributes['label']
|
||||
);
|
||||
} else {
|
||||
$label_markup = sprintf(
|
||||
'<label for="%s" class="wp-block-search__label screen-reader-text">%s</label>',
|
||||
$input_id,
|
||||
__( 'Search' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $show_input ) {
|
||||
$input_markup = sprintf(
|
||||
'<input type="search" id="%s" class="wp-block-search__input" name="s" value="%s" placeholder="%s" required />',
|
||||
$input_id,
|
||||
$attributes['label']
|
||||
);
|
||||
} else {
|
||||
$label_markup = sprintf(
|
||||
'<label for="%s" class="wp-block-search__label screen-reader-text">%s</label>',
|
||||
$input_id,
|
||||
__( 'Search' )
|
||||
esc_attr( get_search_query() ),
|
||||
esc_attr( $attributes['placeholder'] )
|
||||
);
|
||||
}
|
||||
|
||||
$input_markup = sprintf(
|
||||
'<input type="search" id="%s" class="wp-block-search__input" name="s" value="%s" placeholder="%s" required />',
|
||||
$input_id,
|
||||
esc_attr( get_search_query() ),
|
||||
esc_attr( $attributes['placeholder'] )
|
||||
);
|
||||
if ( $show_button ) {
|
||||
$button_internal_markup = '';
|
||||
|
||||
if ( ! $use_icon_button ) {
|
||||
if ( ! empty( $attributes['buttonText'] ) ) {
|
||||
$button_internal_markup = $attributes['buttonText'];
|
||||
}
|
||||
} else {
|
||||
$button_internal_markup =
|
||||
'<svg id="search-icon" class="search-icon" viewBox="0 0 24 24">
|
||||
<path d="M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"></path>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( ! empty( $attributes['buttonText'] ) ) {
|
||||
$button_markup = sprintf(
|
||||
'<button type="submit" class="wp-block-search__button">%s</button>',
|
||||
$attributes['buttonText']
|
||||
$button_internal_markup
|
||||
);
|
||||
}
|
||||
|
||||
$class = 'wp-block-search';
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= ' align' . $attributes['align'];
|
||||
if ( ! empty( $attributes['width'] ) && ! empty( $attributes['widthUnit'] ) ) {
|
||||
if ( ! empty( $attributes['buttonPosition'] ) && 'button-only' !== $attributes['buttonPosition'] ) {
|
||||
$width_styles = ' style="width: ' . $attributes['width'] . $attributes['widthUnit'] . ';"';
|
||||
}
|
||||
}
|
||||
|
||||
$field_markup = sprintf(
|
||||
'<div class="wp-block-search__inside-wrapper"%s>%s</div>',
|
||||
$width_styles,
|
||||
$input_markup . $button_markup
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
'<form class="%s" role="search" method="get" action="%s">%s</form>',
|
||||
esc_attr( $class ),
|
||||
'<form role="search" method="get" action="%s" class="%s">%s</form>',
|
||||
esc_url( home_url( '/' ) ),
|
||||
$label_markup . $input_markup . $button_markup
|
||||
$classnames,
|
||||
$label_markup . $field_markup
|
||||
);
|
||||
}
|
||||
|
||||
@ -87,3 +115,44 @@ function register_block_core_search() {
|
||||
);
|
||||
}
|
||||
add_action( 'init', 'register_block_core_search' );
|
||||
|
||||
/**
|
||||
* Builds the correct top level classnames for the 'core/search' block.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string The classnames used in the block.
|
||||
*/
|
||||
function classnames_for_block_core_search( $attributes ) {
|
||||
$classnames = array();
|
||||
|
||||
if ( ! empty( $attributes['buttonPosition'] ) ) {
|
||||
if ( 'button-inside' === $attributes['buttonPosition'] ) {
|
||||
$classnames[] = 'wp-block-search__button-inside';
|
||||
}
|
||||
|
||||
if ( 'button-outside' === $attributes['buttonPosition'] ) {
|
||||
$classnames[] = 'wp-block-search__button-outside';
|
||||
}
|
||||
|
||||
if ( 'no-button' === $attributes['buttonPosition'] ) {
|
||||
$classnames[] = 'wp-block-search__no-button';
|
||||
}
|
||||
|
||||
if ( 'button-only' === $attributes['buttonPosition'] ) {
|
||||
$classnames[] = 'wp-block-search__button-only';
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $attributes['buttonUseIcon'] ) ) {
|
||||
if ( ! empty( $attributes['buttonPosition'] ) && 'no-button' !== $attributes['buttonPosition'] ) {
|
||||
if ( $attributes['buttonUseIcon'] ) {
|
||||
$classnames[] = 'wp-block-search__icon-button';
|
||||
} else {
|
||||
$classnames[] = 'wp-block-search__text-button';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode( ' ', $classnames );
|
||||
}
|
||||
|
@ -2,32 +2,38 @@
|
||||
"name": "core/search",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"align": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"center",
|
||||
"right",
|
||||
"wide",
|
||||
"full"
|
||||
]
|
||||
},
|
||||
"className": {
|
||||
"type": "string"
|
||||
},
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"showLabel": {
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"placeholder": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"widthUnit": {
|
||||
"type": "string"
|
||||
},
|
||||
"buttonText": {
|
||||
"type": "string"
|
||||
},
|
||||
"buttonPosition": {
|
||||
"type": "string",
|
||||
"default": "button-outside"
|
||||
},
|
||||
"buttonUseIcon": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"align": true,
|
||||
"html": false
|
||||
"align": [ "left", "center", "right" ],
|
||||
"html": false,
|
||||
"lightBlockWrapper": true
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,15 @@
|
||||
/**
|
||||
* Renders the `core/social-link` block on server.
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param Array $attributes The block attributes.
|
||||
* @param String $content InnerBlocks content of the Block.
|
||||
* @param WPBlock $block Block object.
|
||||
*
|
||||
* @return string Rendered HTML of the referenced block.
|
||||
*/
|
||||
function render_block_core_social_link( $attributes ) {
|
||||
function render_block_core_social_link( $attributes, $content, $block ) {
|
||||
$open_in_new_tab = $block->context['openInNewTab'];
|
||||
|
||||
$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 );
|
||||
@ -23,8 +27,13 @@ function render_block_core_social_link( $attributes ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$attribute = '';
|
||||
if ( $open_in_new_tab ) {
|
||||
$attribute = 'rel="noopener nofollow" target="_blank"';
|
||||
}
|
||||
|
||||
$icon = block_core_social_link_get_icon( $service );
|
||||
return '<li class="wp-social-link wp-social-link-' . esc_attr( $service ) . esc_attr( $class_name ) . '"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( $label ) . '"> ' . $icon . '</a></li>';
|
||||
return '<li class="wp-social-link wp-social-link-' . esc_attr( $service ) . esc_attr( $class_name ) . '"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( $label ) . '" ' . $attribute . '> ' . $icon . '</a></li>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,9 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"usesContext": [
|
||||
"openInNewTab"
|
||||
],
|
||||
"supports": {
|
||||
"reusable": false,
|
||||
"html": false,
|
||||
|
@ -1,6 +1,15 @@
|
||||
{
|
||||
"name": "core/social-links",
|
||||
"category": "widgets",
|
||||
"attributes": {
|
||||
"openInNewTab": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"providesContext": {
|
||||
"openInNewTab": "openInNewTab"
|
||||
},
|
||||
"supports": {
|
||||
"align": [
|
||||
"left",
|
||||
|
@ -13,20 +13,11 @@
|
||||
* @return string Returns the tag cloud for selected taxonomy.
|
||||
*/
|
||||
function render_block_core_tag_cloud( $attributes ) {
|
||||
$class = isset( $attributes['align'] ) ?
|
||||
"wp-block-tag-cloud align{$attributes['align']}" :
|
||||
'wp-block-tag-cloud';
|
||||
|
||||
if ( isset( $attributes['className'] ) ) {
|
||||
$class .= ' ' . $attributes['className'];
|
||||
}
|
||||
|
||||
$args = array(
|
||||
$args = array(
|
||||
'echo' => false,
|
||||
'taxonomy' => $attributes['taxonomy'],
|
||||
'show_count' => $attributes['showTagCounts'],
|
||||
);
|
||||
|
||||
$tag_cloud = wp_tag_cloud( $args );
|
||||
|
||||
if ( ! $tag_cloud ) {
|
||||
@ -41,8 +32,7 @@ function render_block_core_tag_cloud( $attributes ) {
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<p class="%1$s">%2$s</p>',
|
||||
esc_attr( $class ),
|
||||
'<p>%1$s</p>',
|
||||
$tag_cloud
|
||||
);
|
||||
}
|
||||
|
@ -2,19 +2,6 @@
|
||||
"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"
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
* Holds the block structure in memory
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
*/
|
||||
class WP_Block_Parser_Block {
|
||||
/**
|
||||
@ -18,7 +18,7 @@ class WP_Block_Parser_Block {
|
||||
*
|
||||
* @example "core/paragraph"
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $blockName;
|
||||
@ -29,7 +29,7 @@ class WP_Block_Parser_Block {
|
||||
* @example null
|
||||
* @example array( 'columns' => 3 )
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var array|null
|
||||
*/
|
||||
public $attrs;
|
||||
@ -37,7 +37,7 @@ class WP_Block_Parser_Block {
|
||||
/**
|
||||
* List of inner blocks (of this same class)
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var WP_Block_Parser_Block[]
|
||||
*/
|
||||
public $innerBlocks;
|
||||
@ -48,7 +48,7 @@ class WP_Block_Parser_Block {
|
||||
*
|
||||
* @example "...Just <!-- wp:test /--> testing..." -> "Just testing..."
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $innerHTML;
|
||||
@ -72,7 +72,7 @@ class WP_Block_Parser_Block {
|
||||
*
|
||||
* Will populate object properties from the provided arguments.
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $name Name of block.
|
||||
* @param array $attrs Optional set of attributes from block comment delimiters.
|
||||
@ -95,13 +95,13 @@ class WP_Block_Parser_Block {
|
||||
* Holds partial blocks in memory while parsing
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
*/
|
||||
class WP_Block_Parser_Frame {
|
||||
/**
|
||||
* Full or partial block
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var WP_Block_Parser_Block
|
||||
*/
|
||||
public $block;
|
||||
@ -109,7 +109,7 @@ class WP_Block_Parser_Frame {
|
||||
/**
|
||||
* Byte offset into document for start of parse token
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $token_start;
|
||||
@ -117,7 +117,7 @@ class WP_Block_Parser_Frame {
|
||||
/**
|
||||
* Byte length of entire parse token string
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $token_length;
|
||||
@ -126,7 +126,7 @@ class WP_Block_Parser_Frame {
|
||||
* Byte offset into document for after parse token ends
|
||||
* (used during reconstruction of stack into parse production)
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $prev_offset;
|
||||
@ -134,7 +134,7 @@ class WP_Block_Parser_Frame {
|
||||
/**
|
||||
* Byte offset into document where leading HTML before token starts
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $leading_html_start;
|
||||
@ -144,7 +144,7 @@ class WP_Block_Parser_Frame {
|
||||
*
|
||||
* Will populate object properties from the provided arguments.
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param WP_Block_Parser_Block $block Full or partial block.
|
||||
* @param int $token_start Byte offset into document for start of parse token.
|
||||
@ -166,7 +166,7 @@ class WP_Block_Parser_Frame {
|
||||
*
|
||||
* Parses a document and constructs a list of parsed block objects
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @since 4.0.0 returns arrays not objects, all attributes are arrays
|
||||
*/
|
||||
class WP_Block_Parser {
|
||||
@ -175,7 +175,7 @@ class WP_Block_Parser {
|
||||
*
|
||||
* @example "Pre-text\n<!-- wp:paragraph -->This is inside a block!<!-- /wp:paragraph -->"
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var string
|
||||
*/
|
||||
public $document;
|
||||
@ -183,7 +183,7 @@ class WP_Block_Parser {
|
||||
/**
|
||||
* Tracks parsing progress through document
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var int
|
||||
*/
|
||||
public $offset;
|
||||
@ -191,7 +191,7 @@ class WP_Block_Parser {
|
||||
/**
|
||||
* List of parsed blocks
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var WP_Block_Parser_Block[]
|
||||
*/
|
||||
public $output;
|
||||
@ -199,7 +199,7 @@ class WP_Block_Parser {
|
||||
/**
|
||||
* Stack of partially-parsed structures in memory during parse
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @var WP_Block_Parser_Frame[]
|
||||
*/
|
||||
public $stack;
|
||||
@ -219,7 +219,7 @@ class WP_Block_Parser {
|
||||
* parse. In contrast to the specification parser this does not
|
||||
* return an error on invalid inputs.
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $document Input document being parsed.
|
||||
* @return WP_Block_Parser_Block[]
|
||||
@ -249,7 +249,7 @@ class WP_Block_Parser {
|
||||
* or breaking out of a level of nesting.
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @return bool
|
||||
*/
|
||||
function proceed() {
|
||||
@ -394,7 +394,7 @@ class WP_Block_Parser {
|
||||
* Returns the type of the find: kind of find, block information, attributes
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @since 4.6.1 fixed a bug in attribute parsing which caused catastrophic backtracking on invalid block comments
|
||||
* @return array
|
||||
*/
|
||||
@ -482,7 +482,7 @@ class WP_Block_Parser {
|
||||
* to the output list as a freeform block.
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @param null $length how many bytes of document text to output.
|
||||
*/
|
||||
function add_freeform( $length = null ) {
|
||||
@ -500,7 +500,7 @@ class WP_Block_Parser {
|
||||
* a new block to the output list.
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @param WP_Block_Parser_Block $block The block to add to the output.
|
||||
* @param int $token_start Byte offset into the document where the first token for the block starts.
|
||||
* @param int $token_length Byte length of entire block from start of opening token to end of closing token.
|
||||
@ -524,7 +524,7 @@ class WP_Block_Parser {
|
||||
* Pushes the top block from the parsing stack to the output list.
|
||||
*
|
||||
* @internal
|
||||
* @since 3.8.0
|
||||
* @since 5.0.0
|
||||
* @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML.
|
||||
*/
|
||||
function add_block_from_stack( $end_offset = null ) {
|
||||
|
@ -179,6 +179,7 @@ require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php';
|
||||
require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
|
||||
require ABSPATH . WPINC . '/general-template.php';
|
||||
require ABSPATH . WPINC . '/link-template.php';
|
||||
require ABSPATH . WPINC . '/array.php';
|
||||
require ABSPATH . WPINC . '/author-template.php';
|
||||
require ABSPATH . WPINC . '/post.php';
|
||||
require ABSPATH . WPINC . '/class-walker-page.php';
|
||||
@ -291,6 +292,7 @@ require ABSPATH . WPINC . '/class-wp-block-parser.php';
|
||||
require ABSPATH . WPINC . '/blocks.php';
|
||||
require ABSPATH . WPINC . '/blocks/index.php';
|
||||
require ABSPATH . WPINC . '/block-patterns.php';
|
||||
require ABSPATH . WPINC . '/block-supports/index.php';
|
||||
|
||||
$GLOBALS['wp_embed'] = new WP_Embed();
|
||||
|
||||
|
@ -8,7 +8,7 @@ const childProcess = require( 'child_process' );
|
||||
|
||||
// Config
|
||||
// This should be updated every time we update the WordPress packages.
|
||||
const GUTENBERG_VERSION = '@wordpress/block-editor@4.3.0';
|
||||
const GUTENBERG_VERSION = '@wordpress/block-editor@5.0.1';
|
||||
|
||||
// Utils
|
||||
/**
|
||||
|
@ -1 +1 @@
|
||||
<div class="wp-block-archives wp-block-archives-list">No archives to show.</div>
|
||||
<div class="wp-block-archives-list wp-block-archives">No archives to show.</div>
|
@ -1 +1 @@
|
||||
<div class="wp-block-archives wp-block-archives-list">No archives to show.</div>
|
||||
<div class="wp-block-archives-list wp-block-archives">No archives to show.</div>
|
@ -1 +1 @@
|
||||
<ul class="wp-block-categories wp-block-categories-list"><li class="cat-item-none">No categories</li></ul>
|
||||
<ul class="wp-block-categories-list wp-block-categories"><li class="cat-item-none">No categories</li></ul>
|
||||
|
@ -1 +1 @@
|
||||
<div class="wp-block-latest-comments has-avatars has-dates has-excerpts no-comments">No comments to show.</div>
|
||||
<div class="has-avatars has-dates has-excerpts no-comments wp-block-latest-comments">No comments to show.</div>
|
||||
|
@ -1 +1 @@
|
||||
<ul class="wp-block-latest-posts wp-block-latest-posts__list"></ul>
|
||||
<ul class="wp-block-latest-posts__list wp-block-latest-posts"></ul>
|
||||
|
@ -1 +1 @@
|
||||
<ul class="wp-block-latest-posts wp-block-latest-posts__list has-dates"></ul>
|
||||
<ul class="wp-block-latest-posts__list has-dates wp-block-latest-posts"></ul>
|
||||
|
Loading…
Reference in New Issue
Block a user