Block Editor: Updated the WordPress packages to include Gutenberg 15.1.0 changes.

In addition to all the packages being updated to the latest versions, 
this commit also includes some mandatory changes to avoid editor breakage:

 - Update React to to 18.2.0.
 - Add the right stylesheets to support iframed block editors.

Props ntsekouras, mamaduka, flixos90, desrosj, peterwilsoncc.
See #57471.


git-svn-id: https://develop.svn.wordpress.org/trunk@55246 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella 2023-02-07 07:01:56 +00:00
parent d46dc08342
commit 07fc9b2d74
122 changed files with 3752 additions and 3687 deletions

6022
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,10 @@
"devDependencies": {
"@lodder/grunt-postcss": "^3.1.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@wordpress/babel-preset-default": "7.1.1",
"@wordpress/dependency-extraction-webpack-plugin": "4.0.2",
"@wordpress/e2e-test-utils": "8.1.1",
"@wordpress/scripts": "24.1.2",
"@wordpress/babel-preset-default": "7.10.1",
"@wordpress/dependency-extraction-webpack-plugin": "4.9.1",
"@wordpress/e2e-test-utils": "9.3.1",
"@wordpress/scripts": "25.3.1",
"autoprefixer": "^10.4.13",
"chalk": "5.2.0",
"check-node-version": "4.2.1",
@ -77,62 +77,63 @@
"webpack-livereload-plugin": "3.0.2"
},
"dependencies": {
"@wordpress/a11y": "3.17.1",
"@wordpress/annotations": "2.17.3",
"@wordpress/api-fetch": "6.14.1",
"@wordpress/autop": "3.17.1",
"@wordpress/blob": "3.17.1",
"@wordpress/block-directory": "3.15.12",
"@wordpress/block-editor": "10.0.10",
"@wordpress/block-library": "7.14.12",
"@wordpress/block-serialization-default-parser": "4.17.1",
"@wordpress/blocks": "11.16.4",
"@wordpress/components": "21.0.7",
"@wordpress/compose": "5.15.2",
"@wordpress/core-data": "5.0.4",
"@wordpress/customize-widgets": "3.14.12",
"@wordpress/data": "7.1.3",
"@wordpress/data-controls": "2.17.3",
"@wordpress/date": "4.17.1",
"@wordpress/deprecated": "3.17.1",
"@wordpress/dom": "3.17.2",
"@wordpress/dom-ready": "3.17.1",
"@wordpress/edit-post": "6.14.12",
"@wordpress/edit-site": "4.14.14",
"@wordpress/edit-widgets": "4.14.12",
"@wordpress/editor": "12.16.10",
"@wordpress/element": "4.15.1",
"@wordpress/escape-html": "2.17.1",
"@wordpress/format-library": "3.15.10",
"@wordpress/hooks": "3.17.1",
"@wordpress/html-entities": "3.17.1",
"@wordpress/i18n": "4.17.1",
"@wordpress/icons": "9.8.1",
"@wordpress/interface": "4.16.7",
"@wordpress/is-shallow-equal": "4.17.1",
"@wordpress/keyboard-shortcuts": "3.15.3",
"@wordpress/keycodes": "3.17.1",
"@wordpress/list-reusable-blocks": "3.15.7",
"@wordpress/media-utils": "4.8.1",
"@wordpress/notices": "3.17.3",
"@wordpress/nux": "5.15.7",
"@wordpress/plugins": "4.15.2",
"@wordpress/preferences": "2.9.7",
"@wordpress/preferences-persistence": "1.9.1",
"@wordpress/primitives": "3.15.1",
"@wordpress/priority-queue": "2.17.2",
"@wordpress/redux-routine": "4.17.1",
"@wordpress/reusable-blocks": "3.15.10",
"@wordpress/rich-text": "5.15.3",
"@wordpress/server-side-render": "3.15.7",
"@wordpress/shortcode": "3.17.1",
"@wordpress/style-engine": "1.0.3",
"@wordpress/token-list": "2.17.1",
"@wordpress/url": "3.18.1",
"@wordpress/viewport": "4.15.3",
"@wordpress/warning": "2.17.1",
"@wordpress/widgets": "2.15.10",
"@wordpress/wordcount": "3.17.1",
"@wordpress/a11y": "3.26.1",
"@wordpress/annotations": "2.26.1",
"@wordpress/api-fetch": "6.23.1",
"@wordpress/autop": "3.26.1",
"@wordpress/blob": "3.26.1",
"@wordpress/block-directory": "4.3.1",
"@wordpress/block-editor": "11.3.1",
"@wordpress/block-library": "8.3.1",
"@wordpress/block-serialization-default-parser": "4.26.1",
"@wordpress/blocks": "12.3.1",
"@wordpress/components": "23.3.1",
"@wordpress/compose": "6.3.1",
"@wordpress/core-data": "6.3.1",
"@wordpress/customize-widgets": "4.3.1",
"@wordpress/data": "8.3.1",
"@wordpress/data-controls": "2.26.1",
"@wordpress/date": "4.26.1",
"@wordpress/deprecated": "3.26.1",
"@wordpress/dom": "3.26.1",
"@wordpress/dom-ready": "3.26.1",
"@wordpress/edit-post": "7.3.1",
"@wordpress/edit-site": "5.3.1",
"@wordpress/edit-widgets": "5.3.1",
"@wordpress/editor": "13.3.1",
"@wordpress/element": "5.3.1",
"@wordpress/escape-html": "2.26.1",
"@wordpress/experiments": "0.8.1",
"@wordpress/format-library": "4.3.1",
"@wordpress/hooks": "3.26.1",
"@wordpress/html-entities": "3.26.1",
"@wordpress/i18n": "4.26.1",
"@wordpress/icons": "9.17.1",
"@wordpress/interface": "5.3.1",
"@wordpress/is-shallow-equal": "4.26.1",
"@wordpress/keyboard-shortcuts": "4.3.1",
"@wordpress/keycodes": "3.26.1",
"@wordpress/list-reusable-blocks": "4.3.1",
"@wordpress/media-utils": "4.17.1",
"@wordpress/notices": "3.26.1",
"@wordpress/nux": "6.0.0",
"@wordpress/plugins": "5.3.1",
"@wordpress/preferences": "3.3.1",
"@wordpress/preferences-persistence": "1.18.1",
"@wordpress/primitives": "3.24.1",
"@wordpress/priority-queue": "2.26.1",
"@wordpress/redux-routine": "4.26.1",
"@wordpress/reusable-blocks": "4.3.1",
"@wordpress/rich-text": "6.3.1",
"@wordpress/server-side-render": "4.3.1",
"@wordpress/shortcode": "3.26.1",
"@wordpress/style-engine": "1.9.1",
"@wordpress/token-list": "2.26.1",
"@wordpress/url": "3.27.1",
"@wordpress/viewport": "5.3.1",
"@wordpress/warning": "2.26.1",
"@wordpress/widgets": "3.3.1",
"@wordpress/wordcount": "3.26.1",
"backbone": "1.4.1",
"clipboard": "2.0.11",
"core-js-url-browser": "3.6.4",
@ -150,8 +151,8 @@
"moment": "2.29.4",
"objectFitPolyfill": "2.3.5",
"polyfill-library": "4.4.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"regenerator-runtime": "0.13.9",
"underscore": "1.13.6",
"whatwg-fetch": "3.6.2",

File diff suppressed because one or more lines are too long

View File

@ -17,11 +17,12 @@
function render_block_core_archives( $attributes ) {
$show_post_count = ! empty( $attributes['showPostCounts'] );
$type = isset( $attributes['type'] ) ? $attributes['type'] : 'monthly';
$class = '';
$class = 'wp-block-archives-list';
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$class .= ' wp-block-archives-dropdown';
$class = 'wp-block-archives-dropdown';
$dropdown_id = wp_unique_id( 'wp-block-archives-' );
$title = __( 'Archives' );
@ -40,9 +41,7 @@ function render_block_core_archives( $attributes ) {
$archives = wp_get_archives( $dropdown_args );
$classnames = esc_attr( $class );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
switch ( $dropdown_args['type'] ) {
case 'yearly':
@ -75,8 +74,6 @@ function render_block_core_archives( $attributes ) {
);
}
$class .= ' wp-block-archives-list';
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
$archives_args = apply_filters(
'widget_archives_args',

View File

@ -26,6 +26,7 @@
},
"supports": {
"align": true,
"anchor": true,
"html": false,
"spacing": {
"margin": true,

View File

@ -100,7 +100,7 @@ function render_block_core_avatar( $attributes, $content, $block ) {
$label = 'aria-label="' . sprintf( esc_attr__( '(%s author archive, opens in a new tab)' ), $author_name ) . '"';
}
// translators: %1$s: Author archive link. %2$s: Link target. %3$s Aria label. %4$s Avatar image.
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( get_author_posts_url( $author_id ) ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}

View File

@ -4,7 +4,7 @@
"name": "core/avatar",
"title": "Avatar",
"category": "theme",
"description": "Add a user's avatar.",
"description": "Add a users avatar.",
"textdomain": "default",
"attributes": {
"userId": {
@ -25,6 +25,7 @@
},
"usesContext": [ "postType", "postId", "commentId" ],
"supports": {
"anchor": true,
"html": false,
"align": true,
"alignWide": false,

View File

@ -27,8 +27,7 @@ function render_block_core_block( $attributes ) {
if ( isset( $seen_refs[ $attributes['ref'] ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.

View File

@ -15,6 +15,5 @@
"customClassName": false,
"html": false,
"inserter": false
},
"editorStyle": "wp-block-editor"
}
}

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,9 @@
"keywords": [ "link" ],
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
},
"url": {
"type": "string",
"source": "attribute",
@ -56,7 +59,7 @@
},
"supports": {
"anchor": true,
"align": true,
"align": false,
"alignWide": false,
"color": {
"__experimentalSkipSerialization": true,
@ -80,6 +83,7 @@
}
},
"reusable": false,
"shadow": true,
"spacing": {
"__experimentalSkipSerialization": true,
"padding": [ "horizontal", "vertical" ],

View File

@ -40,11 +40,34 @@ function render_block_core_calendar( $attributes ) {
}
}
$color_block_styles = array();
// Text color.
$preset_text_color = array_key_exists( 'textColor', $attributes ) ? "var:preset|color|{$attributes['textColor']}" : null;
$custom_text_color = _wp_array_get( $attributes, array( 'style', 'color', 'text' ), null );
$color_block_styles['text'] = $preset_text_color ? $preset_text_color : $custom_text_color;
// Background Color.
$preset_background_color = array_key_exists( 'backgroundColor', $attributes ) ? "var:preset|color|{$attributes['backgroundColor']}" : null;
$custom_background_color = _wp_array_get( $attributes, array( 'style', 'color', 'background' ), null );
$color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color;
// Generate color styles and classes.
$styles = wp_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) );
$inline_styles = empty( $styles['css'] ) ? '' : sprintf( ' style="%s"', esc_attr( $styles['css'] ) );
$classnames = empty( $styles['classnames'] ) ? '' : ' ' . esc_attr( $styles['classnames'] );
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classnames .= ' has-link-color';
}
// Apply color classes and styles to the calendar.
$calendar = str_replace( '<table', '<table' . $inline_styles, get_calendar( true, false ) );
$calendar = str_replace( 'class="wp-calendar-table', 'class="wp-calendar-table' . $classnames, $calendar );
$wrapper_attributes = get_block_wrapper_attributes();
$output = sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
get_calendar( true, false )
$calendar
);
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited

View File

@ -17,6 +17,16 @@
},
"supports": {
"align": true,
"anchor": true,
"color": {
"link": true,
"__experimentalSkipSerialization": [ "text", "background" ],
"__experimentalDefaultControls": {
"background": true,
"text": true
},
"__experimentalSelector": "table, th"
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -14,7 +14,7 @@
*/
function render_block_core_categories( $attributes ) {
static $block_id = 0;
$block_id++;
++$block_id;
$args = array(
'echo' => false,

View File

@ -30,6 +30,7 @@
},
"supports": {
"align": true,
"anchor": true,
"html": false,
"spacing": {
"margin": true,

View File

@ -25,12 +25,15 @@ function render_block_core_comment_author_name( $attributes, $content, $block )
return '';
}
$classes = '';
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
$comment_author = get_comment_author( $comment );
$link = get_comment_author_url( $comment );

View File

@ -22,6 +22,7 @@
},
"usesContext": [ "commentId" ],
"supports": {
"anchor": true,
"html": false,
"spacing": {
"margin": true,

View File

@ -49,12 +49,15 @@ function render_block_core_comment_content( $attributes, $content, $block ) {
}
}
$classes = '';
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf(
'<div %1$s>%2$s%3$s</div>',

View File

@ -14,6 +14,7 @@
}
},
"supports": {
"anchor": true,
"color": {
"gradients": true,
"link": true,

View File

@ -23,7 +23,7 @@ function render_block_core_comment_date( $attributes, $content, $block ) {
return '';
}
$classes = '';
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$formatted_date = get_comment_date(

View File

@ -18,6 +18,7 @@
},
"usesContext": [ "commentId" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,

View File

@ -27,12 +27,15 @@ function render_block_core_comment_edit_link( $attributes, $content, $block ) {
$link_atts .= sprintf( 'target="%s"', esc_attr( $attributes['linkTarget'] ) );
}
$classes = '';
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf(
'<div %1$s><a href="%2$s" %3$s>%4$s</a></div>',

View File

@ -18,6 +18,7 @@
}
},
"supports": {
"anchor": true,
"html": false,
"color": {
"link": true,

View File

@ -34,7 +34,7 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
// Compute comment's depth iterating over its ancestors.
while ( ! empty( $parent_id ) ) {
$depth++;
++$depth;
$parent_id = get_comment( $parent_id )->comment_parent;
}
@ -51,12 +51,15 @@ function render_block_core_comment_reply_link( $attributes, $content, $block ) {
return;
}
$classes = '';
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes .= 'has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf(
'<div %1$s>%2$s</div>',

View File

@ -14,6 +14,7 @@
}
},
"supports": {
"anchor": true,
"color": {
"gradients": true,
"link": true,

View File

@ -50,13 +50,13 @@ function block_core_comment_template_render_comments( $comments, $block ) {
// comments.
if ( ! empty( $children ) && ! empty( $thread_comments ) ) {
if ( $comment_depth < $thread_comments_depth ) {
$comment_depth += 1;
++$comment_depth;
$inner_content = block_core_comment_template_render_comments(
$children,
$block
);
$block_content .= sprintf( '<ol>%1$s</ol>', $inner_content );
$comment_depth -= 1;
--$comment_depth;
} else {
$inner_content = block_core_comment_template_render_comments(
$children,
@ -70,7 +70,6 @@ function block_core_comment_template_render_comments( $comments, $block ) {
}
return $content;
}
/**

View File

@ -9,9 +9,14 @@
"textdomain": "default",
"usesContext": [ "postId" ],
"supports": {
"reusable": false,
"html": false,
"align": true,
"anchor": true,
"html": false,
"reusable": false,
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -14,6 +14,7 @@
},
"usesContext": [ "postId", "comments/paginationArrow" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {

View File

@ -9,8 +9,16 @@
"textdomain": "default",
"usesContext": [ "postId" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {
"gradients": true,
"text": false,
"__experimentalDefaultControls": {
"background": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -14,6 +14,7 @@
},
"usesContext": [ "postId", "comments/paginationArrow" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {

View File

@ -22,9 +22,12 @@ function render_block_core_comments_pagination( $attributes, $content ) {
return;
}
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
return sprintf(
'<div %1$s>%2$s</div>',
get_block_wrapper_attributes(),
$wrapper_attributes,
$content
);
}

View File

@ -17,6 +17,7 @@
"comments/paginationArrow": "paginationArrow"
},
"supports": {
"anchor": true,
"align": true,
"reusable": false,
"html": false,

View File

@ -202,7 +202,6 @@ function register_legacy_post_comments_block() {
'wp-block-buttons',
'wp-block-button',
),
'editorStyle' => 'wp-block-post-comments-editor',
'render_callback' => 'render_block_core_comments',
'skip_inner_blocks' => true,
);

View File

@ -18,6 +18,7 @@
},
"supports": {
"align": [ "wide", "full" ],
"anchor": true,
"html": false,
"color": {
"gradients": true,
@ -28,6 +29,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -25,7 +25,7 @@ function render_block_core_cover( $attributes, $content ) {
);
if ( isset( $attributes['focalPoint'] ) ) {
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
$attr['data-object-position'] = $object_position;
$attr['style'] = 'object-position: ' . $object_position;
}

View File

@ -74,6 +74,10 @@
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", "contentOnly", false ]
},
"tagName": {
"type": "string",
"default": "div"
}
},
"usesContext": [ "postId", "postType" ],

View File

@ -8,18 +8,22 @@
"textdomain": "default",
"attributes": {
"url": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"caption": {
"type": "string",
"source": "html",
"selector": "figcaption"
"selector": "figcaption",
"__experimentalRole": "content"
},
"type": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"providerNameSlug": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"allowResponsive": {
"type": "boolean",
@ -27,11 +31,13 @@
},
"responsive": {
"type": "boolean",
"default": false
"default": false,
"__experimentalRole": "content"
},
"previewable": {
"type": "boolean",
"default": true
"default": true,
"__experimentalRole": "content"
}
},
"supports": {

View File

@ -76,13 +76,10 @@ function block_core_gallery_render( $attributes, $content ) {
}
}
$class = wp_unique_id( 'wp-block-gallery-' );
$content = preg_replace(
'/' . preg_quote( 'class="', '/' ) . '/',
'class="' . $class . ' ',
$content,
1
);
$unique_gallery_classname = wp_unique_id( 'wp-block-gallery-' );
$processed_content = new WP_HTML_Tag_Processor( $content );
$processed_content->next_tag();
$processed_content->add_class( $unique_gallery_classname );
// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
// gap on the gallery.
@ -102,10 +99,22 @@ function block_core_gallery_render( $attributes, $content ) {
}
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
$style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
$gallery_styles = array();
$gallery_styles[] = array(
'selector' => ".wp-block-gallery.{$unique_gallery_classname}",
'declarations' => array(
'--wp--style--unstable-gallery-gap' => $gap_column,
'gap' => $gap_value,
),
);
wp_enqueue_block_support_styles( $style, 11 );
return $content;
wp_style_engine_get_stylesheet_from_css_rules(
$gallery_styles,
array(
'context' => 'block-supports',
)
);
return (string) $processed_content;
}
/**
* Registers the `core/gallery` block on server.

View File

@ -41,6 +41,9 @@
"blockGap": true
}
},
"dimensions": {
"minHeight": true
},
"__experimentalBorder": {
"color": true,
"radius": true,
@ -53,6 +56,9 @@
"width": true
}
},
"position": {
"sticky": true
},
"typography": {
"fontSize": true,
"lineHeight": true,
@ -66,7 +72,9 @@
"fontSize": true
}
},
"__experimentalLayout": true
"__experimentalLayout": {
"allowSizingOnChildren": true
}
},
"editorStyle": "wp-block-group-editor",
"style": "wp-block-group"

View File

@ -0,0 +1,52 @@
<?php
/**
* Appending the wp-block-heading to before rendering the stored `core/heading` block contents.
*
* @package WordPress
*/
/**
* Adds a wp-block-heading class to the heading block content.
*
* For example, the following block content:
* <h2 class="align-left">Hello World</h2>
*
* Would be transformed to:
* <h2 class="align-left wp-block-heading">Hello World</h2>
*
* @param array $attributes Attributes of the block being rendered.
* @param string $content Content of the block being rendered.
*
* @return string The content of the block being rendered.
*/
function block_core_heading_render( $attributes, $content ) {
if ( ! $content ) {
return $content;
}
$p = new WP_HTML_Tag_Processor( $content );
$header_tags = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' );
while ( $p->next_tag() ) {
if ( in_array( $p->get_tag(), $header_tags, true ) ) {
$p->add_class( 'wp-block-heading' );
break;
}
}
return $p->get_updated_html();
}
/**
* Registers the `core/heading` block on server.
*/
function register_block_core_heading() {
register_block_type_from_metadata(
__DIR__ . '/heading',
array(
'render_callback' => 'block_core_heading_render',
)
);
}
add_action( 'init', 'register_block_core_heading' );

View File

@ -29,7 +29,7 @@
"supports": {
"align": [ "wide", "full" ],
"anchor": true,
"className": false,
"className": true,
"color": {
"gradients": true,
"link": true,
@ -57,7 +57,6 @@
"textTransform": true
}
},
"__experimentalSelector": "h1,h2,h3,h4,h5,h6",
"__unstablePasteTextInline": true,
"__experimentalSlashInserter": true
},

View File

@ -128,7 +128,7 @@ function render_block_core_home_link( $attributes, $content, $block ) {
$aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';
return sprintf(
'<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" "rel="home"%3$s>%4$s</a></li>',
'<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
block_core_home_link_build_li_wrapper_attributes( $block->context ),
esc_url( home_url() ),
$aria_current,

View File

@ -22,6 +22,7 @@
"style"
],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"typography": {

View File

@ -10,7 +10,7 @@
"attributes": {
"content": {
"type": "string",
"source": "html"
"source": "raw"
}
},
"supports": {

View File

@ -29,7 +29,12 @@
},
"supports": {
"align": true,
"html": false
"anchor": true,
"html": false,
"spacing": {
"margin": true,
"padding": true
}
},
"editorStyle": "wp-block-latest-comments-editor",
"style": "wp-block-latest-comments"

View File

@ -55,7 +55,7 @@ function render_block_core_latest_posts( $attributes ) {
$args['author'] = $attributes['selectedAuthor'];
}
$query = new WP_Query;
$query = new WP_Query();
$recent_posts = $query->query( $args );
if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
@ -173,25 +173,24 @@ function render_block_core_latest_posts( $attributes ) {
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
$class = 'wp-block-latest-posts__list';
$classes = array( 'wp-block-latest-posts__list' );
if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {
$class .= ' is-grid';
$classes[] = 'is-grid';
}
if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) {
$class .= ' columns-' . $attributes['columns'];
$classes[] = 'columns-' . $attributes['columns'];
}
if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) {
$class .= ' has-dates';
$classes[] = 'has-dates';
}
if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) {
$class .= ' has-author';
$classes[] = 'has-author';
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf(
'<ul %1$s>%2$s</ul>',

View File

@ -84,7 +84,21 @@
},
"supports": {
"align": true,
"anchor": true,
"html": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -21,6 +21,19 @@
},
"supports": {
"className": false,
"__experimentalSelector": "li"
"__experimentalSelector": "li",
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -18,6 +18,7 @@
}
},
"supports": {
"anchor": true,
"className": true,
"typography": {
"fontSize": false

View File

@ -120,6 +120,33 @@ function block_core_navigation_link_render_submenu_icon() {
return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
}
/**
* Decodes a url if it's encoded, returning the same url if not.
*
* @param string $url The url to decode.
*
* @return string $url Returns the decoded url.
*/
function block_core_navigation_link_maybe_urldecode( $url ) {
$is_url_encoded = false;
$query = parse_url( $url, PHP_URL_QUERY );
$query_params = wp_parse_args( $query );
foreach ( $query_params as $query_param ) {
if ( rawurldecode( $query_param ) !== $query_param ) {
$is_url_encoded = true;
break;
}
}
if ( $is_url_encoded ) {
return rawurldecode( $url );
}
return $url;
}
/**
* Renders the `core/navigation-link` block.
*
@ -171,7 +198,7 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
// Start appending HTML attributes to anchor tag.
if ( isset( $attributes['url'] ) ) {
$html .= ' href="' . esc_url( $attributes['url'] ) . '"';
$html .= ' href="' . esc_url( block_core_navigation_link_maybe_urldecode( $attributes['url'] ) ) . '"';
}
if ( $is_active ) {
@ -344,3 +371,35 @@ function register_block_core_navigation_link() {
);
}
add_action( 'init', 'register_block_core_navigation_link' );
/**
* Enables animation of the block inspector for the Navigation Link block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_link_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation-link' =>
array(
'enterDirection' => 'rightToLeft',
),
)
);
return $settings;
}
add_filter( 'block_editor_settings_all', 'block_core_navigation_link_enable_inspector_animation' );

View File

@ -155,7 +155,7 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$css_classes = trim( implode( ' ', $classes ) );
$has_submenu = count( $block->inner_blocks ) > 0;
$is_active = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
$is_active = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );
$show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
$open_on_click = isset( $block->context['openSubmenusOnClick'] ) && $block->context['openSubmenusOnClick'];
@ -255,6 +255,14 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
$inner_blocks_html .= $inner_block->render();
}
if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
$tag_processor = new WP_HTML_Tag_Processor( $html );
while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) {
$tag_processor->add_class( 'current-menu-ancestor' );
}
$html = $tag_processor->get_updated_html();
}
$html .= sprintf(
'<ul class="wp-block-navigation__submenu-container">%s</ul>',
$inner_blocks_html
@ -281,3 +289,35 @@ function register_block_core_navigation_submenu() {
);
}
add_action( 'init', 'register_block_core_navigation_submenu' );
/**
* Enables animation of the block inspector for the Navigation Submenu block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_submenu_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation-submenu' =>
array(
'enterDirection' => 'rightToLeft',
),
)
);
return $settings;
}
add_filter( 'block_editor_settings_all', 'block_core_navigation_submenu_enable_inspector_animation' );

View File

@ -248,6 +248,121 @@ function block_core_navigation_render_submenu_icon() {
return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
}
/**
* Get the classic navigation menu to use as a fallback.
*
* @return object WP_Term The classic navigation.
*/
function block_core_navigation_get_classic_menu_fallback() {
$classic_nav_menus = wp_get_nav_menus();
// If menus exist.
if ( $classic_nav_menus && ! is_wp_error( $classic_nav_menus ) ) {
// Handles simple use case where user has a classic menu and switches to a block theme.
// Returns the menu assigned to location `primary`.
$locations = get_nav_menu_locations();
if ( isset( $locations['primary'] ) ) {
$primary_menu = wp_get_nav_menu_object( $locations['primary'] );
if ( $primary_menu ) {
return $primary_menu;
}
}
// Returns a menu if `primary` is its slug.
foreach ( $classic_nav_menus as $classic_nav_menu ) {
if ( 'primary' === $classic_nav_menu->slug ) {
return $classic_nav_menu;
}
}
// Otherwise return the most recently created classic menu.
usort(
$classic_nav_menus,
function( $a, $b ) {
return $b->term_id - $a->term_id;
}
);
return $classic_nav_menus[0];
}
}
/**
* Converts a classic navigation to blocks.
*
* @param object $classic_nav_menu WP_Term The classic navigation object to convert.
* @return array the normalized parsed blocks.
*/
function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu ) {
// BEGIN: Code that already exists in wp_nav_menu().
$menu_items = wp_get_nav_menu_items( $classic_nav_menu->term_id, array( 'update_post_term_cache' => false ) );
// Set up the $menu_item variables.
_wp_menu_item_classes_by_context( $menu_items );
$sorted_menu_items = array();
foreach ( (array) $menu_items as $menu_item ) {
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
}
unset( $menu_items, $menu_item );
// END: Code that already exists in wp_nav_menu().
$menu_items_by_parent_id = array();
foreach ( $sorted_menu_items as $menu_item ) {
$menu_items_by_parent_id[ $menu_item->menu_item_parent ][] = $menu_item;
}
$inner_blocks = block_core_navigation_parse_blocks_from_menu_items(
isset( $menu_items_by_parent_id[0] )
? $menu_items_by_parent_id[0]
: array(),
$menu_items_by_parent_id
);
return serialize_blocks( $inner_blocks );
}
/**
* If there's a the classic menu then use it as a fallback.
*
* @return array the normalized parsed blocks.
*/
function block_core_navigation_maybe_use_classic_menu_fallback() {
// See if we have a classic menu.
$classic_nav_menu = block_core_navigation_get_classic_menu_fallback();
if ( ! $classic_nav_menu ) {
return;
}
// If we have a classic menu then convert it to blocks.
$classic_nav_menu_blocks = block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu );
if ( empty( $classic_nav_menu_blocks ) ) {
return;
}
// Create a new navigation menu from the classic menu.
$wp_insert_post_result = wp_insert_post(
array(
'post_content' => $classic_nav_menu_blocks,
'post_title' => $classic_nav_menu->slug,
'post_name' => $classic_nav_menu->slug,
'post_status' => 'publish',
'post_type' => 'wp_navigation',
),
true // So that we can check whether the result is an error.
);
if ( is_wp_error( $wp_insert_post_result ) ) {
return;
}
// Fetch the most recently published navigation which will be the classic one created above.
return block_core_navigation_get_most_recently_published_navigation();
}
/**
* Finds the most recently published `wp_navigation` Post.
@ -255,7 +370,8 @@ function block_core_navigation_render_submenu_icon() {
* @return WP_Post|null the first non-empty Navigation or null.
*/
function block_core_navigation_get_most_recently_published_navigation() {
// We default to the most recently created menu.
// Default to the most recently created menu.
$parsed_args = array(
'post_type' => 'wp_navigation',
'no_found_rows' => true,
@ -294,6 +410,25 @@ function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
return array_values( $filtered );
}
/**
* Returns true if the navigation block contains a nested navigation block.
*
* @param WP_Block_List $inner_blocks Inner block instance to be normalized.
* @return bool true if the navigation block contains a nested navigation block.
*/
function block_core_navigation_block_contains_core_navigation( $inner_blocks ) {
foreach ( $inner_blocks as $block ) {
if ( 'core/navigation' === $block->name ) {
return true;
}
if ( $block->inner_blocks && block_core_navigation_block_contains_core_navigation( $block->inner_blocks ) ) {
return true;
}
}
return false;
}
/**
* Retrieves the appropriate fallback to be used on the front of the
* site when there is no menu assigned to the Nav block.
@ -319,9 +454,16 @@ function block_core_navigation_get_fallback_blocks() {
$navigation_post = block_core_navigation_get_most_recently_published_navigation();
// Prefer using the first non-empty Navigation as fallback if available.
// If there are no navigation posts then try to find a classic menu
// and convert it into a block based navigation menu.
if ( ! $navigation_post ) {
$navigation_post = block_core_navigation_maybe_use_classic_menu_fallback();
}
// Use the first non-empty Navigation as fallback if available.
if ( $navigation_post ) {
$maybe_fallback = block_core_navigation_filter_out_empty_blocks( parse_blocks( $navigation_post->post_content ) );
$parsed_blocks = parse_blocks( $navigation_post->post_content );
$maybe_fallback = block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
// Normalizing blocks may result in an empty array of blocks if they were all `null` blocks.
// In this case default to the (Page List) fallback.
@ -501,6 +643,10 @@ function render_block_core_navigation( $attributes, $content, $block ) {
$inner_blocks = new WP_Block_List( $fallback_blocks, $attributes );
}
if ( block_core_navigation_block_contains_core_navigation( $inner_blocks ) ) {
return '';
}
/**
* Filter navigation block $inner_blocks.
* Allows modification of a navigation block menu items.
@ -551,22 +697,41 @@ function render_block_core_navigation( $attributes, $content, $block ) {
_prime_post_caches( $post_ids, false, false );
}
$list_item_nav_blocks = array(
'core/navigation-link',
'core/home-link',
'core/site-title',
'core/site-logo',
'core/navigation-submenu',
);
$needs_list_item_wrapper = array(
'core/site-title',
'core/site-logo',
);
$inner_blocks_html = '';
$is_list_open = false;
foreach ( $inner_blocks as $inner_block ) {
if ( ( 'core/navigation-link' === $inner_block->name || 'core/home-link' === $inner_block->name || 'core/site-title' === $inner_block->name || 'core/site-logo' === $inner_block->name || 'core/navigation-submenu' === $inner_block->name ) && ! $is_list_open ) {
$is_list_item = in_array( $inner_block->name, $list_item_nav_blocks, true );
if ( $is_list_item && ! $is_list_open ) {
$is_list_open = true;
$inner_blocks_html .= '<ul class="wp-block-navigation__container">';
}
if ( 'core/navigation-link' !== $inner_block->name && 'core/home-link' !== $inner_block->name && 'core/site-title' !== $inner_block->name && 'core/site-logo' !== $inner_block->name && 'core/navigation-submenu' !== $inner_block->name && $is_list_open ) {
if ( ! $is_list_item && $is_list_open ) {
$is_list_open = false;
$inner_blocks_html .= '</ul>';
}
$inner_block_content = $inner_block->render();
if ( 'core/site-title' === $inner_block->name || ( 'core/site-logo' === $inner_block->name && $inner_block_content ) ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
} else {
$inner_blocks_html .= $inner_block_content;
if ( ! empty( $inner_block_content ) ) {
if ( in_array( $inner_block->name, $needs_list_item_wrapper, true ) ) {
$inner_blocks_html .= '<li class="wp-block-navigation-item">' . $inner_block_content . '</li>';
} else {
$inner_blocks_html .= $inner_block_content;
}
}
}
@ -709,3 +874,35 @@ function block_core_navigation_typographic_presets_backcompatibility( $parsed_bl
}
add_filter( 'render_block_data', 'block_core_navigation_typographic_presets_backcompatibility' );
/**
* Enables animation of the block inspector for the Navigation block.
*
* See:
* - https://github.com/WordPress/gutenberg/pull/46342
* - https://github.com/WordPress/gutenberg/issues/45884
*
* @param array $settings Default editor settings.
* @return array Filtered editor settings.
*/
function block_core_navigation_enable_inspector_animation( $settings ) {
$current_animation_settings = _wp_array_get(
$settings,
array( '__experimentalBlockInspectorAnimation' ),
array()
);
$settings['__experimentalBlockInspectorAnimation'] = array_merge(
$current_animation_settings,
array(
'core/navigation' =>
array(
'enterDirection' => 'leftToRight',
),
)
);
return $settings;
}
add_filter( 'block_editor_settings_all', 'block_core_navigation_enable_inspector_animation' );

View File

@ -67,6 +67,10 @@
"maxNestingLevel": {
"type": "number",
"default": 5
},
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", "contentOnly", false ]
}
},
"providesContext": {
@ -88,6 +92,7 @@
},
"supports": {
"align": [ "wide", "full" ],
"anchor": true,
"html": false,
"inserter": true,
"typography": {
@ -115,6 +120,7 @@
"allowSwitching": false,
"allowInheriting": false,
"allowVerticalAlignment": false,
"allowSizingOnChildren": true,
"default": {
"type": "flex"
}

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '6d574d0390bc333487cb');
<?php return array('dependencies' => array(), 'version' => 'd09326a9acd3f6992aae');

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '45f05135277abf0b0408');
<?php return array('dependencies' => array(), 'version' => 'f51363b18f0497ec84da');

View File

@ -0,0 +1,52 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/page-list-item",
"title": "Page List Item",
"category": "widgets",
"parent": [ "core/page-list" ],
"description": "Displays a page inside a list of all pages.",
"keywords": [ "page", "menu", "navigation" ],
"textdomain": "default",
"attributes": {
"id": {
"type": "number"
},
"label": {
"type": "string"
},
"title": {
"type": "string"
},
"link": {
"type": "string"
},
"hasChildren": {
"type": "boolean"
}
},
"usesContext": [
"textColor",
"customTextColor",
"backgroundColor",
"customBackgroundColor",
"overlayTextColor",
"customOverlayTextColor",
"overlayBackgroundColor",
"customOverlayBackgroundColor",
"fontSize",
"customFontSize",
"showSubmenuIcon",
"style",
"openSubmenusOnClick"
],
"supports": {
"reusable": false,
"html": false,
"lock": false,
"inserter": false,
"__experimentalToolbar": false
},
"editorStyle": "wp-block-page-list-editor",
"style": "wp-block-page-list"
}

View File

@ -139,13 +139,14 @@ function block_core_page_list_build_css_font_sizes( $context ) {
* @param boolean $show_submenu_icons Whether to show submenu indicator icons.
* @param boolean $is_navigation_child If block is a child of Navigation block.
* @param array $nested_pages The array of nested pages.
* @param boolean $is_nested Whether the submenu is nested or not.
* @param array $active_page_ancestor_ids An array of ancestor ids for active page.
* @param array $colors Color information for overlay styles.
* @param integer $depth The nesting depth.
*
* @return string List markup.
*/
function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) {
function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) {
if ( empty( $nested_pages ) ) {
return;
}
@ -173,7 +174,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
$navigation_child_content_class = $is_navigation_child ? ' wp-block-navigation-item__content' : '';
// If this is the first level of submenus, include the overlay colors.
if ( 1 === $depth && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) {
if ( ( ( 0 < $depth && ! $is_nested ) || $is_nested ) && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) {
$css_class .= ' ' . trim( implode( ' ', $colors['overlay_css_classes'] ) );
if ( '' !== $colors['overlay_inline_styles'] ) {
$style_attribute = sprintf( ' style="%s"', esc_attr( $colors['overlay_inline_styles'] ) );
@ -196,7 +197,7 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) {
$markup .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="' . esc_attr( $navigation_child_content_class ) . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . esc_html( $title ) .
'</button>' . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
'</button><span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>';
} else {
$markup .= '<a class="wp-block-pages-list__item__link' . esc_attr( $navigation_child_content_class ) . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . $title . '</a>';
}
@ -207,12 +208,9 @@ function block_core_page_list_render_nested_page_list( $open_submenus_on_click,
$markup .= '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
$markup .= '</button>';
}
$markup .= '<ul class="submenu-container';
// Extra classname is added when the block is a child of Navigation.
if ( $is_navigation_child ) {
$markup .= ' wp-block-navigation__submenu-container';
}
$markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $active_page_ancestor_ids, $colors, $depth + 1 ) . '</ul>';
$markup .= '<ul class="wp-block-navigation__submenu-container">';
$markup .= block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $is_nested, $active_page_ancestor_ids, $colors, $depth + 1 );
$markup .= '</ul>';
}
$markup .= '</li>';
}
@ -250,7 +248,10 @@ function block_core_page_list_nest_pages( $current_level, $children ) {
*/
function render_block_core_page_list( $attributes, $content, $block ) {
static $block_id = 0;
$block_id++;
++$block_id;
$parent_page_id = $attributes['parentPageID'];
$is_nested = $attributes['isNested'];
$all_pages = get_pages(
array(
@ -271,7 +272,7 @@ function render_block_core_page_list( $attributes, $content, $block ) {
$active_page_ancestor_ids = array();
foreach ( (array) $all_pages as $page ) {
$is_active = ! empty( $page->ID ) && ( get_the_ID() === $page->ID );
$is_active = ! empty( $page->ID ) && ( get_queried_object_id() === $page->ID );
if ( $is_active ) {
$active_page_ancestor_ids = get_post_ancestors( $page->ID );
@ -306,15 +307,27 @@ function render_block_core_page_list( $attributes, $content, $block ) {
$nested_pages = block_core_page_list_nest_pages( $top_level_pages, $pages_with_children );
if ( 0 !== $parent_page_id ) {
// If the parent page has no child pages, there is nothing to show.
if ( ! array_key_exists( $parent_page_id, $pages_with_children ) ) {
return;
}
$nested_pages = block_core_page_list_nest_pages(
$pages_with_children[ $parent_page_id ],
$pages_with_children
);
}
$is_navigation_child = array_key_exists( 'showSubmenuIcon', $block->context );
$open_submenus_on_click = array_key_exists( 'openSubmenusOnClick', $block->context ) ? $block->context['openSubmenusOnClick'] : false;
$show_submenu_icons = array_key_exists( 'showSubmenuIcon', $block->context ) ? $block->context['showSubmenuIcon'] : false;
$wrapper_markup = '<ul %1$s>%2$s</ul>';
$wrapper_markup = $is_nested ? '%2$s' : '<ul %1$s>%2$s</ul>';
$items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors );
$items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids, $colors );
$wrapper_attributes = get_block_wrapper_attributes(
array(

View File

@ -7,7 +7,16 @@
"description": "Display a list of all pages.",
"keywords": [ "menu", "navigation" ],
"textdomain": "default",
"attributes": {},
"attributes": {
"parentPageID": {
"type": "integer",
"default": 0
},
"isNested": {
"type": "boolean",
"default": false
}
},
"usesContext": [
"textColor",
"customTextColor",
@ -24,8 +33,22 @@
"openSubmenusOnClick"
],
"supports": {
"anchor": true,
"reusable": false,
"html": false
"html": false,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"editorStyle": "wp-block-page-list-editor",
"style": "wp-block-page-list"

View File

@ -13,6 +13,7 @@
},
"usesContext": [ "postType", "postId" ],
"supports": {
"anchor": true,
"spacing": {
"margin": true,
"padding": true

View File

@ -0,0 +1,54 @@
<?php
/**
* Server-side rendering of the `core/post-author-name` block.
*
* @package WordPress
*/
/**
* Renders the `core/post-author-name` 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 post author name block.
*/
function render_block_core_post_author_name( $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$author_id = get_post_field( 'post_author', $block->context['postId'] );
if ( empty( $author_id ) ) {
return '';
}
$author_name = get_the_author_meta( 'display_name', $author_id );
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$author_name = sprintf( '<a href="%1$s" target="%2$s" class="wp-block-post-author-name__link">%3$s</a>', get_author_posts_url( $author_id ), esc_attr( $attributes['linkTarget'] ), $author_name );
}
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $author_name );
}
/**
* Registers the `core/post-author-name` block on the server.
*/
function register_block_core_post_author_name() {
register_block_type_from_metadata(
__DIR__ . '/post-author-name',
array(
'render_callback' => 'render_block_core_post_author_name',
)
);
}
add_action( 'init', 'register_block_core_post_author_name' );

View File

@ -0,0 +1,53 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "core/post-author-name",
"title": "Post Author Name",
"category": "theme",
"description": "The author name.",
"textdomain": "default",
"attributes": {
"textAlign": {
"type": "string"
},
"isLink": {
"type": "boolean",
"default": false
},
"linkTarget": {
"type": "string",
"default": "_self"
}
},
"usesContext": [ "postType", "postId" ],
"supports": {
"anchor": true,
"html": false,
"spacing": {
"margin": true,
"padding": true
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
}
}

View File

@ -29,11 +29,23 @@ function render_block_core_post_author( $attributes, $content, $block ) {
$attributes['avatarSize']
) : null;
$link = get_author_posts_url( $author_id );
$author_name = get_the_author_meta( 'display_name', $author_id );
if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
$author_name = sprintf( '<a href="%1s" target="%2s">%2s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
}
$byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
$classes = array_merge(
isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(),
isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array()
);
$classes = array();
if ( isset( $attributes['itemsJustification'] ) ) {
$classes[] = 'items-justified-' . $attributes['itemsJustification'];
}
if ( isset( $attributes['textAlign'] ) ) {
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
@ -41,7 +53,7 @@ function render_block_core_post_author( $attributes, $content, $block ) {
( ! 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">' . wp_kses_post( $byline ) . '</p>' : '' ) .
'<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
'<p class="wp-block-post-author__name">' . $author_name . '</p>' .
( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
'</div>' .
'</div>';

View File

@ -23,10 +23,19 @@
},
"byline": {
"type": "string"
},
"isLink": {
"type": "boolean",
"default": false
},
"linkTarget": {
"type": "string",
"default": "_self"
}
},
"usesContext": [ "postType", "postId", "queryId" ],
"supports": {
"anchor": true,
"html": false,
"spacing": {
"margin": true,

View File

@ -22,12 +22,14 @@ function render_block_core_post_comments_form( $attributes, $content, $block ) {
return;
}
$classes = 'comment-respond'; // See comment further below.
$classes = array( 'comment-respond' ); // See comment further below.
if ( isset( $attributes['textAlign'] ) ) {
$classes .= ' has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
add_filter( 'comment_form_defaults', 'post_comments_form_block_form_defaults' );

View File

@ -13,6 +13,7 @@
},
"usesContext": [ "postId", "postType" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,
@ -22,6 +23,10 @@
"text": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -25,8 +25,7 @@ function render_block_core_post_content( $attributes, $content, $block ) {
if ( isset( $seen_ids[ $post_id ] ) ) {
// WP_DEBUG_DISPLAY must only be honored when WP_DEBUG. This precedent
// is set in `wp_debug_mode()`.
$is_debug = defined( 'WP_DEBUG' ) && WP_DEBUG &&
defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY;
$is_debug = WP_DEBUG && WP_DEBUG_DISPLAY;
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.

View File

@ -8,9 +8,13 @@
"textdomain": "default",
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"anchor": true,
"align": [ "wide", "full" ],
"html": false,
"__experimentalLayout": true,
"dimensions": {
"minHeight": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -18,9 +18,16 @@ function render_block_core_post_date( $attributes, $content, $block ) {
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 ) );
$post_ID = $block->context['postId'];
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
if ( isset( $attributes['displayType'] ) && 'modified' === $attributes['displayType'] ) {
$formatted_date = get_the_modified_date( empty( $attributes['format'] ) ? '' : $attributes['format'], $post_ID );

View File

@ -24,6 +24,7 @@
},
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,

View File

@ -38,11 +38,14 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
* result in showing only one `read more` link at a time.
*/
add_filter( 'excerpt_more', $filter_excerpt_more );
$classes = '';
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes .= "has-text-align-{$attributes['textAlign']}";
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
$content = '<p class="wp-block-post-excerpt__excerpt">' . $excerpt;
$show_more_on_new_line = ! isset( $attributes['showMoreOnNewLine'] ) || $attributes['showMoreOnNewLine'];

View File

@ -20,6 +20,7 @@
},
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,

View File

@ -27,12 +27,19 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
$is_link = isset( $attributes['isLink'] ) && $attributes['isLink'];
$size_slug = isset( $attributes['sizeSlug'] ) ? $attributes['sizeSlug'] : 'post-thumbnail';
$post_title = trim( strip_tags( get_the_title( $post_ID ) ) );
$attr = get_block_core_post_featured_image_border_attributes( $attributes );
$overlay_markup = get_block_core_post_featured_image_overlay_element_markup( $attributes );
if ( $is_link ) {
$attr['alt'] = $post_title;
if ( get_the_title( $post_ID ) ) {
$attr['alt'] = trim( strip_tags( get_the_title( $post_ID ) ) );
} else {
$attr['alt'] = sprintf(
// translators: %d is the post ID.
__( 'Untitled post %d' ),
$post_ID
);
}
}
if ( ! empty( $attributes['height'] ) ) {
@ -50,11 +57,13 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
if ( $is_link ) {
$link_target = $attributes['linkTarget'];
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$height = ! empty( $attributes['height'] ) ? 'style="' . esc_attr( safecss_filter_attr( 'height:' . $attributes['height'] ) ) . '"' : '';
$featured_image = sprintf(
'<a href="%1$s" target="%2$s" %3$s>%4$s%5$s</a>',
'<a href="%1$s" target="%2$s" %3$s %4$s>%5$s%6$s</a>',
get_the_permalink( $post_ID ),
esc_attr( $link_target ),
$rel,
$height,
$featured_image,
$overlay_markup
);
@ -62,10 +71,13 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
$featured_image = $featured_image . $overlay_markup;
}
$wrapper_attributes = empty( $attributes['width'] )
? get_block_wrapper_attributes()
: get_block_wrapper_attributes( array( 'style' => "width:{$attributes['width']};" ) );
$width = ! empty( $attributes['width'] ) ? esc_attr( safecss_filter_attr( 'width:' . $attributes['width'] ) ) . ';' : '';
$height = ! empty( $attributes['height'] ) ? esc_attr( safecss_filter_attr( 'height:' . $attributes['height'] ) ) . ';' : '';
if ( ! $height && ! $width ) {
$wrapper_attributes = get_block_wrapper_attributes();
} else {
$wrapper_attributes = get_block_wrapper_attributes( array( 'style' => $width . $height ) );
}
return "<figure {$wrapper_attributes}>{$featured_image}</figure>";
}

View File

@ -53,6 +53,7 @@
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"align": [ "left", "right", "center", "wide", "full" ],
"anchor": true,
"color": {
"__experimentalDuotone": "img, .wp-block-post-featured-image__placeholder, .components-placeholder__illustration, .components-placeholder::before",
"text": false,

View File

@ -34,6 +34,18 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
$link = 'next' === $navigation_type ? _x( 'Next', 'label for next post link' ) : _x( 'Previous', 'label for previous post link' );
$label = '';
$arrow_map = array(
'none' => '',
'arrow' => array(
'next' => '→',
'previous' => '←',
),
'chevron' => array(
'next' => '»',
'previous' => '«',
),
);
// If a custom label is provided, make this a link.
// `$label` is used to prepend the provided label, if we want to show the page title as well.
if ( isset( $attributes['label'] ) && ! empty( $attributes['label'] ) ) {
@ -71,6 +83,17 @@ function render_block_core_post_navigation_link( $attributes, $content ) {
}
}
// Display arrows.
if ( isset( $attributes['arrow'] ) && ! empty( $attributes['arrow'] ) && 'none' !== $attributes['arrow'] ) {
$arrow = $arrow_map[ $attributes['arrow'] ][ $navigation_type ];
if ( 'next' === $navigation_type ) {
$format = '%link <span class="wp-block-post-navigation-link__arrow-next is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span>';
} else {
$format = '<span class="wp-block-post-navigation-link__arrow-previous is-arrow-' . $attributes['arrow'] . '" aria-hidden="true">' . $arrow . '</span> %link';
}
}
// The dynamic portion of the function name, `$navigation_type`,
// refers to the type of adjacency, 'next' or 'previous'.
$get_link_function = "get_{$navigation_type}_post_link";

View File

@ -24,9 +24,14 @@
"linkLabel": {
"type": "boolean",
"default": false
},
"arrow": {
"type": "string",
"default": "none"
}
},
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {
@ -45,5 +50,6 @@
"fontSize": true
}
}
}
},
"style": "wp-block-post-navigation-link"
}

View File

@ -68,8 +68,11 @@ function render_block_core_post_template( $attributes, $content, $block ) {
$classnames = "is-flex-container columns-{$block->context['displayLayout']['columns']}";
}
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classnames .= ' has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classnames ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) );
$content = '';
while ( $query->have_posts() ) {

View File

@ -19,9 +19,18 @@
"reusable": false,
"html": false,
"align": true,
"anchor": true,
"__experimentalLayout": {
"allowEditing": false
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -27,14 +27,17 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
return '';
}
$classes = 'taxonomy-' . $attributes['term'];
$classes = array( 'taxonomy-' . $attributes['term'] );
if ( isset( $attributes['textAlign'] ) ) {
$classes .= ' has-text-align-' . $attributes['textAlign'];
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator'];
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
$prefix = "<div $wrapper_attributes>";
if ( isset( $attributes['prefix'] ) && $attributes['prefix'] ) {

View File

@ -28,6 +28,7 @@
},
"usesContext": [ "postId", "postType" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,
@ -38,6 +39,10 @@
"link": true
}
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"lineHeight": true,

View File

@ -26,9 +26,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
return '';
}
$tag_name = 'h2';
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
$tag_name = 'h2';
if ( isset( $attributes['level'] ) ) {
$tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level'];
}
@ -37,7 +35,15 @@ function render_block_core_post_title( $attributes, $content, $block ) {
$rel = ! empty( $attributes['rel'] ) ? 'rel="' . esc_attr( $attributes['rel'] ) . '"' : '';
$title = sprintf( '<a href="%1$s" target="%2$s" %3$s>%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), $rel, $title );
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
$classes = array();
if ( isset( $attributes['textAlign'] ) ) {
$classes[] = 'has-text-align-' . $attributes['textAlign'];
}
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
$classes[] = 'has-link-color';
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
return sprintf(
'<%1$s %2$s>%3$s</%1$s>',

View File

@ -31,6 +31,7 @@
},
"supports": {
"align": [ "wide", "full" ],
"anchor": true,
"html": false,
"color": {
"gradients": true,

View File

@ -40,9 +40,11 @@ function render_block_core_query_no_results( $attributes, $content, $block ) {
wp_reset_postdata();
}
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
return sprintf(
'<div %1$s>%2$s</div>',
get_block_wrapper_attributes(),
$wrapper_attributes,
$content
);
}

View File

@ -9,6 +9,7 @@
"textdomain": "default",
"usesContext": [ "queryId", "query" ],
"supports": {
"anchor": true,
"align": true,
"reusable": false,
"html": false,

View File

@ -14,6 +14,7 @@
},
"usesContext": [ "queryId", "query", "paginationArrow" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {

View File

@ -9,6 +9,7 @@
"textdomain": "default",
"usesContext": [ "queryId", "query" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {

View File

@ -14,6 +14,7 @@
},
"usesContext": [ "queryId", "query", "paginationArrow" ],
"supports": {
"anchor": true,
"reusable": false,
"html": false,
"color": {

View File

@ -18,9 +18,11 @@ function render_block_core_query_pagination( $attributes, $content ) {
return '';
}
$classes = ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) ? 'has-link-color' : '';
$wrapper_attributes = get_block_wrapper_attributes(
array(
'aria-label' => __( 'Pagination' ),
'class' => $classes,
)
);

View File

@ -18,6 +18,7 @@
"paginationArrow": "paginationArrow"
},
"supports": {
"anchor": true,
"align": true,
"reusable": false,
"html": false,

View File

@ -27,6 +27,7 @@
}
},
"supports": {
"anchor": true,
"align": [ "wide", "full" ],
"html": false,
"color": {

View File

@ -49,15 +49,8 @@
},
"supports": {
"align": [ "wide", "full" ],
"anchor": true,
"html": false,
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"__experimentalLayout": true
},
"editorStyle": "wp-block-query-editor"

View File

@ -19,15 +19,22 @@ function render_block_core_read_more( $attributes, $content, $block ) {
}
$post_ID = $block->context['postId'];
$post_title = get_the_title( $post_ID );
$screen_reader_text = sprintf(
/* translators: %s is either the post title or post ID to describe the link for screen readers. */
__( ': %s' ),
'' !== $post_title ? $post_title : __( 'untitled post ' ) . $post_ID
);
$justify_class_name = empty( $attributes['justifyContent'] ) ? '' : "is-justified-{$attributes['justifyContent']}";
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $justify_class_name ) );
$more_text = ! empty( $attributes['content'] ) ? wp_kses_post( $attributes['content'] ) : __( 'Read more' );
return sprintf(
'<a %1s href="%2s" target="%3s">%4s</a>',
'<a %1s href="%2s" target="%3s">%4s<span class="screen-reader-text">%5s</span></a>',
$wrapper_attributes,
get_the_permalink( $post_ID ),
esc_attr( $attributes['linkTarget'] ),
$more_text
$more_text,
$screen_reader_text
);
}

View File

@ -17,6 +17,7 @@
},
"usesContext": [ "postId" ],
"supports": {
"anchor": true,
"html": false,
"color": {
"gradients": true,

View File

@ -22,6 +22,7 @@ require_once ABSPATH . WPINC . '/blocks/comments-title.php';
require_once ABSPATH . WPINC . '/blocks/cover.php';
require_once ABSPATH . WPINC . '/blocks/file.php';
require_once ABSPATH . WPINC . '/blocks/gallery.php';
require_once ABSPATH . WPINC . '/blocks/heading.php';
require_once ABSPATH . WPINC . '/blocks/home-link.php';
require_once ABSPATH . WPINC . '/blocks/image.php';
require_once ABSPATH . WPINC . '/blocks/latest-comments.php';
@ -34,6 +35,7 @@ require_once ABSPATH . WPINC . '/blocks/page-list.php';
require_once ABSPATH . WPINC . '/blocks/pattern.php';
require_once ABSPATH . WPINC . '/blocks/post-author.php';
require_once ABSPATH . WPINC . '/blocks/post-author-biography.php';
require_once ABSPATH . WPINC . '/blocks/post-author-name.php';
require_once ABSPATH . WPINC . '/blocks/post-comments-form.php';
require_once ABSPATH . WPINC . '/blocks/post-content.php';
require_once ABSPATH . WPINC . '/blocks/post-date.php';

View File

@ -12,7 +12,6 @@ return array(
'embed',
'freeform',
'group',
'heading',
'html',
'list',
'list-item',
@ -20,6 +19,7 @@ return array(
'missing',
'more',
'nextpage',
'page-list-item',
'paragraph',
'preformatted',
'pullquote',

View File

@ -48,7 +48,7 @@ function render_block_core_rss( $attributes ) {
if ( $date ) {
$date = sprintf(
'<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
esc_attr( date_i18n( get_option( 'c' ), $date ) ),
esc_attr( date_i18n( 'c', $date ) ),
esc_attr( date_i18n( get_option( 'date_format' ), $date ) )
);
}

View File

@ -43,6 +43,7 @@
},
"supports": {
"align": true,
"anchor": true,
"html": false
},
"editorStyle": "wp-block-rss-editor",

View File

@ -66,14 +66,14 @@ function render_block_core_search( $attributes ) {
if ( $show_input ) {
$input_classes = array( 'wp-block-search__input' );
if ( $is_button_inside ) {
if ( ! $is_button_inside && ! empty( $border_color_classes ) ) {
$input_classes[] = $border_color_classes;
}
if ( ! empty( $typography_classes ) ) {
$input_classes[] = $typography_classes;
}
$input_markup = sprintf(
'<input type="search" id="%s" class="wp-block-search__input %s" name="s" value="%s" placeholder="%s" %s required />',
'<input type="search" id="%s" class="%s" name="s" value="%s" placeholder="%s" %s required />',
$input_id,
esc_attr( implode( ' ', $input_classes ) ),
get_search_query(),

View File

@ -46,6 +46,7 @@
},
"supports": {
"align": [ "left", "center", "right" ],
"anchor": true,
"color": {
"gradients": true,
"__experimentalSkipSerialization": true,

View File

@ -31,6 +31,7 @@
},
"supports": {
"html": false,
"anchor": true,
"align": true,
"alignWide": false,
"color": {

View File

@ -4,7 +4,7 @@
"name": "core/site-tagline",
"title": "Site Tagline",
"category": "theme",
"description": "Describe in a few words what the site is about. The tagline can be used in search results or when sharing on social networks even if it's not displayed in the theme design.",
"description": "Describe in a few words what the site is about. The tagline can be used in search results or when sharing on social networks even if its not displayed in the theme design.",
"keywords": [ "description" ],
"textdomain": "default",
"attributes": {
@ -13,6 +13,7 @@
}
},
"supports": {
"anchor": true,
"align": [ "wide", "full" ],
"html": false,
"color": {

Some files were not shown because too many files have changed in this diff Show More