This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,94 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion-heading",
"title": "Accordion Heading",
"category": "design",
"description": "Displays a heading that toggles the accordion panel.",
"parent": [ "core/accordion-item" ],
"usesContext": [
"core/accordion-icon-position",
"core/accordion-show-icon",
"core/accordion-heading-level"
],
"supports": {
"anchor": true,
"color": {
"background": true,
"gradients": true
},
"align": false,
"interactivity": true,
"spacing": {
"padding": true,
"__experimentalDefaultControls": {
"padding": true
},
"__experimentalSkipSerialization": true,
"__experimentalSelector": ".wp-block-accordion-heading__toggle"
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"typography": {
"__experimentalSkipSerialization": [
"textDecoration",
"letterSpacing"
],
"fontSize": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true,
"fontFamily": true
}
},
"shadow": true,
"visibility": false,
"lock": false
},
"selectors": {
"typography": {
"letterSpacing": ".wp-block-accordion-heading .wp-block-accordion-heading__toggle-title",
"textDecoration": ".wp-block-accordion-heading .wp-block-accordion-heading__toggle-title"
}
},
"attributes": {
"openByDefault": {
"type": "boolean",
"default": false
},
"title": {
"type": "rich-text",
"source": "rich-text",
"selector": ".wp-block-accordion-heading__toggle-title",
"role": "content"
},
"level": {
"type": "number"
},
"iconPosition": {
"type": "string",
"enum": [ "left", "right" ],
"default": "right"
},
"showIcon": {
"type": "boolean",
"default": true
}
},
"textdomain": "default"
}
@@ -0,0 +1,39 @@
.wp-block-accordion-heading__toggle {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
letter-spacing: inherit;
text-transform: inherit;
text-decoration: inherit;
word-spacing: inherit;
font-style: inherit;
background: none;
border: none;
color: inherit;
padding: var(--wp--preset--spacing--20, 1em) 0;
cursor: pointer;
overflow: hidden;
display: flex;
align-items: center;
text-align: inherit;
width: 100%;
}
.wp-block-accordion-heading__toggle:not(:focus-visible) {
outline: none;
}
.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
text-decoration: underline;
}
.wp-block-accordion-heading__toggle-title {
flex: 1;
}
.wp-block-accordion-heading__toggle-icon {
width: 1.2em;
height: 1.2em;
display: flex;
align-items: center;
justify-content: center;
}
@@ -0,0 +1 @@
.wp-block-accordion-heading__toggle{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;overflow:hidden;padding:var(--wp--preset--spacing--20,1em) 0;text-align:inherit;text-decoration:inherit;text-transform:inherit;width:100%;word-spacing:inherit}.wp-block-accordion-heading__toggle:not(:focus-visible){outline:none}.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title{text-decoration:underline}.wp-block-accordion-heading__toggle-title{flex:1}.wp-block-accordion-heading__toggle-icon{align-items:center;display:flex;height:1.2em;justify-content:center;width:1.2em}
@@ -0,0 +1,39 @@
.wp-block-accordion-heading__toggle {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
line-height: inherit;
letter-spacing: inherit;
text-transform: inherit;
text-decoration: inherit;
word-spacing: inherit;
font-style: inherit;
background: none;
border: none;
color: inherit;
padding: var(--wp--preset--spacing--20, 1em) 0;
cursor: pointer;
overflow: hidden;
display: flex;
align-items: center;
text-align: inherit;
width: 100%;
}
.wp-block-accordion-heading__toggle:not(:focus-visible) {
outline: none;
}
.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
text-decoration: underline;
}
.wp-block-accordion-heading__toggle-title {
flex: 1;
}
.wp-block-accordion-heading__toggle-icon {
width: 1.2em;
height: 1.2em;
display: flex;
align-items: center;
justify-content: center;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion-heading__toggle{align-items:center;background:none;border:none;color:inherit;cursor:pointer;display:flex;font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;overflow:hidden;padding:var(--wp--preset--spacing--20,1em) 0;text-align:inherit;text-decoration:inherit;text-transform:inherit;width:100%;word-spacing:inherit}.wp-block-accordion-heading__toggle:not(:focus-visible){outline:none}.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title{text-decoration:underline}.wp-block-accordion-heading__toggle-title{flex:1}.wp-block-accordion-heading__toggle-icon{align-items:center;display:flex;height:1.2em;justify-content:center;width:1.2em}
+87
View File
@@ -0,0 +1,87 @@
<?php
/**
* Server-side rendering of the `core/accordion-item` block.
*
* @package WordPress
* @since 6.9.0
*
* @param array{ openByDefault: bool } $attributes The block attributes.
* @param string $content The block content.
* @return string Returns the updated markup.
*/
function block_core_accordion_item_render( array $attributes, string $content ): string {
if ( '' === $content ) {
return $content;
}
$p = new WP_HTML_Tag_Processor( $content );
$unique_id = wp_unique_id( 'accordion-item-' );
// Initialize the state of the item on the server using a closure,
// since we need to get derived state based on the current context.
wp_interactivity_state(
'core/accordion',
array(
'isOpen' => function () {
$context = wp_interactivity_get_context();
return $context['openByDefault'];
},
)
);
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-item' ) ) ) {
$open_by_default = $attributes['openByDefault'] ? 'true' : 'false';
$p->set_attribute( 'data-wp-context', '{ "id": "' . $unique_id . '", "openByDefault": ' . $open_by_default . ' }' );
$p->set_attribute( 'data-wp-class--is-open', 'state.isOpen' );
$p->set_attribute( 'data-wp-init', 'callbacks.initAccordionItems' );
$p->set_attribute( 'data-wp-on-window--hashchange', 'callbacks.hashChange' );
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-heading__toggle' ) ) ) {
$p->set_attribute( 'data-wp-on--click', 'actions.toggle' );
$p->set_attribute( 'data-wp-on--keydown', 'actions.handleKeyDown' );
$p->set_attribute( 'id', $unique_id );
$p->set_attribute( 'aria-controls', $unique_id . '-panel' );
$p->set_attribute( 'data-wp-bind--aria-expanded', 'state.isOpen' );
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-panel' ) ) ) {
$p->set_attribute( 'id', $unique_id . '-panel' );
$p->set_attribute( 'aria-labelledby', $unique_id );
$p->set_attribute( 'data-wp-bind--inert', '!state.isOpen' );
// Only modify content if all directives have been set.
$content = $p->get_updated_html();
}
}
}
/*
* If an Accordion Item is collapsed by default, ensure any contained IMG has fetchpriority=low to deprioritize it
* from contending with resources in the critical rendering path. In contrast, remove the loading attribute to
* prevent the image from not being available when the item is expanded.
*/
if ( ! $attributes['openByDefault'] ) {
$processor = new WP_HTML_Tag_Processor( $content );
while ( $processor->next_tag( 'IMG' ) ) {
$processor->set_attribute( 'fetchpriority', 'low' );
}
$content = $processor->get_updated_html();
}
return $content;
}
/**
* Registers the `core/accordion-item` block on server.
*
* @since 6.9.0
*/
function register_block_core_accordion_item() {
register_block_type_from_metadata(
__DIR__ . '/accordion-item',
array(
'render_callback' => 'block_core_accordion_item_render',
)
);
}
add_action( 'init', 'register_block_core_accordion_item' );
@@ -0,0 +1,63 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion-item",
"title": "Accordion Item",
"category": "design",
"description": "Wraps the heading and panel in one unit.",
"parent": [ "core/accordion" ],
"allowedBlocks": [ "core/accordion-heading", "core/accordion-panel" ],
"supports": {
"html": false,
"color": {
"background": true,
"gradients": true
},
"interactivity": true,
"spacing": {
"margin": [ "top", "bottom" ],
"blockGap": true
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"shadow": true,
"layout": {
"allowEditing": false
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"contentRole": true
},
"attributes": {
"openByDefault": {
"type": "boolean",
"default": false
}
},
"providesContext": {
"core/accordion-open-by-default": "openByDefault"
},
"textdomain": "default",
"style": "wp-block-accordion-item"
}
@@ -0,0 +1,14 @@
.wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
transform: rotate(-45deg);
}
.wp-block-accordion-item {
/* Add transitions only for users who do not prefer reduced motion */
}
@media (prefers-reduced-motion: no-preference) {
.wp-block-accordion-item {
transition: grid-template-rows 0.3s ease-out;
}
.wp-block-accordion-item > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
transition: transform 0.2s ease-in-out;
}
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion-item.is-open>.wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon{transform:rotate(-45deg)}@media (prefers-reduced-motion:no-preference){.wp-block-accordion-item{transition:grid-template-rows .3s ease-out}.wp-block-accordion-item>.wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon{transition:transform .2s ease-in-out}}
@@ -0,0 +1,14 @@
.wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
transform: rotate(45deg);
}
.wp-block-accordion-item {
/* Add transitions only for users who do not prefer reduced motion */
}
@media (prefers-reduced-motion: no-preference) {
.wp-block-accordion-item {
transition: grid-template-rows 0.3s ease-out;
}
.wp-block-accordion-item > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
transition: transform 0.2s ease-in-out;
}
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion-item.is-open>.wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon{transform:rotate(45deg)}@media (prefers-reduced-motion:no-preference){.wp-block-accordion-item{transition:grid-template-rows .3s ease-out}.wp-block-accordion-item>.wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon{transition:transform .2s ease-in-out}}
@@ -0,0 +1,68 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion-panel",
"title": "Accordion Panel",
"category": "design",
"description": "Contains the hidden or revealed content beneath the heading.",
"parent": [ "core/accordion-item" ],
"usesContext": [ "core/accordion-open-by-default" ],
"supports": {
"html": false,
"color": {
"background": true,
"gradients": true
},
"interactivity": true,
"spacing": {
"padding": true,
"blockGap": true,
"__experimentalDefaultControls": {
"padding": true,
"blockGap": true
}
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"shadow": true,
"layout": {
"allowEditing": false
},
"visibility": false,
"contentRole": true,
"allowedBlocks": true,
"lock": false
},
"attributes": {
"templateLock": {
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", "contentOnly", false ],
"default": false
}
},
"textdomain": "default",
"style": "wp-block-accordion-panel"
}
@@ -0,0 +1,4 @@
.wp-block-accordion-panel[inert], .wp-block-accordion-panel[aria-hidden=true] {
display: none;
margin-block-start: 0;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion-panel[aria-hidden=true],.wp-block-accordion-panel[inert]{display:none;margin-block-start:0}
@@ -0,0 +1,4 @@
.wp-block-accordion-panel[inert], .wp-block-accordion-panel[aria-hidden=true] {
display: none;
margin-block-start: 0;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion-panel[aria-hidden=true],.wp-block-accordion-panel[inert]{display:none;margin-block-start:0}
+45
View File
@@ -0,0 +1,45 @@
<?php
/**
* Server-side rendering of the `core/accordion` block.
*
* @package WordPress
* @since 6.9.0
*
* @param array $attributes The block attributes.
* @param string $content The block content.
*
* @return string Returns the updated markup.
*/
function render_block_core_accordion( $attributes, $content ) {
if ( ! $content ) {
return $content;
}
$p = new WP_HTML_Tag_Processor( $content );
$autoclose = $attributes['autoclose'] ? 'true' : 'false';
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion' ) ) ) {
$p->set_attribute( 'data-wp-interactive', 'core/accordion' );
$p->set_attribute( 'data-wp-context', '{ "autoclose": ' . $autoclose . ', "accordionItems": [] }' );
// Only modify content if directives have been set.
$content = $p->get_updated_html();
}
return $content;
}
/**
* Registers the `core/accordion` block on server.
*
* @since 6.9.0
*/
function register_block_core_accordion() {
register_block_type_from_metadata(
__DIR__ . '/accordion',
array(
'render_callback' => 'render_block_core_accordion',
)
);
}
add_action( 'init', 'register_block_core_accordion' );
+90
View File
@@ -0,0 +1,90 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/accordion",
"title": "Accordion",
"category": "design",
"description": "Displays a foldable layout that groups content in collapsible sections.",
"example": {},
"supports": {
"anchor": true,
"html": false,
"align": [ "wide", "full" ],
"background": {
"backgroundImage": true,
"backgroundSize": true,
"__experimentalDefaultControls": {
"backgroundImage": true
}
},
"color": {
"background": true,
"gradients": true
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"spacing": {
"padding": true,
"margin": [ "top", "bottom" ],
"blockGap": true
},
"shadow": true,
"layout": true,
"ariaLabel": true,
"interactivity": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"contentRole": true,
"listView": true
},
"attributes": {
"iconPosition": {
"type": "string",
"default": "right"
},
"showIcon": {
"type": "boolean",
"default": true
},
"autoclose": {
"type": "boolean",
"default": false
},
"headingLevel": {
"type": "number",
"default": 3
},
"levelOptions": {
"type": "array"
}
},
"providesContext": {
"core/accordion-icon-position": "iconPosition",
"core/accordion-show-icon": "showIcon",
"core/accordion-heading-level": "headingLevel"
},
"allowedBlocks": [ "core/accordion-item" ],
"textdomain": "default",
"viewScriptModule": "@wordpress/block-library/accordion/view"
}
@@ -0,0 +1,3 @@
.wp-block-accordion {
box-sizing: border-box;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion{box-sizing:border-box}
+3
View File
@@ -0,0 +1,3 @@
.wp-block-accordion {
box-sizing: border-box;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-accordion{box-sizing:border-box}
+174
View File
@@ -0,0 +1,174 @@
<?php
/**
* Server-side rendering of the `core/archives` block.
*
* @package WordPress
*/
/**
* Renders the `core/archives` block on server.
*
* @since 5.0.0
*
* @see WP_Widget_Archives
*
* @param array $attributes The block attributes.
*
* @return string Returns the post content with archives added.
*/
function render_block_core_archives( $attributes ) {
$show_post_count = ! empty( $attributes['showPostCounts'] );
$type = $attributes['type'] ?? 'monthly';
$class = 'wp-block-archives-list';
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$class = 'wp-block-archives-dropdown';
$dropdown_id = wp_unique_id( 'wp-block-archives-' );
$title = __( 'Archives' );
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
$dropdown_args = apply_filters(
'widget_archives_dropdown_args',
array(
'type' => $type,
'format' => 'option',
'show_post_count' => $show_post_count,
)
);
$dropdown_args['echo'] = 0;
$archives = wp_get_archives( $dropdown_args );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
switch ( $dropdown_args['type'] ) {
case 'yearly':
$label = __( 'Select Year' );
break;
case 'monthly':
$label = __( 'Select Month' );
break;
case 'daily':
$label = __( 'Select Day' );
break;
case 'weekly':
$label = __( 'Select Week' );
break;
default:
$label = __( 'Select Post' );
break;
}
$show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
$block_content = '<label for="' . $dropdown_id . '" class="wp-block-archives__label' . $show_label . '">' . esc_html( $title ) . '</label>
<select id="' . esc_attr( $dropdown_id ) . '" name="archive-dropdown">
<option value="">' . esc_html( $label ) . '</option>' . $archives . '</select>';
// Inject the dropdown script immediately after the select dropdown.
$block_content .= block_core_archives_build_dropdown_script( $dropdown_id );
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$block_content
);
}
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
$archives_args = apply_filters(
'widget_archives_args',
array(
'type' => $type,
'show_post_count' => $show_post_count,
)
);
$archives_args['echo'] = 0;
$archives = wp_get_archives( $archives_args );
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) );
if ( empty( $archives ) ) {
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
__( 'No archives to show.' )
);
}
return sprintf(
'<ul %1$s>%2$s</ul>',
$wrapper_attributes,
$archives
);
}
/**
* Generates the inline script for an archives dropdown field.
*
* @since 6.9.0
*
* @param string $dropdown_id ID of the dropdown field.
*
* @return string Returns the dropdown onChange redirection script.
*/
function block_core_archives_build_dropdown_script( $dropdown_id ) {
ob_start();
$exports = array( $dropdown_id, home_url() );
?>
<script>
( ( [ dropdownId, homeUrl ] ) => {
const dropdown = document.getElementById( dropdownId );
function onSelectChange() {
setTimeout( () => {
if ( 'escape' === dropdown.dataset.lastkey ) {
return;
}
if ( dropdown.value ) {
location.href = dropdown.value;
}
}, 250 );
}
function onKeyUp( event ) {
if ( 'Escape' === event.key ) {
dropdown.dataset.lastkey = 'escape';
} else {
delete dropdown.dataset.lastkey;
}
}
function onClick() {
delete dropdown.dataset.lastkey;
}
dropdown.addEventListener( 'keyup', onKeyUp );
dropdown.addEventListener( 'click', onClick );
dropdown.addEventListener( 'change', onSelectChange );
} )( <?php echo wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
</script>
<?php
return wp_get_inline_script_tag(
trim( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) ) .
"\n//# sourceURL=" . rawurlencode( __FUNCTION__ )
);
}
/**
* Register archives block.
*
* @since 5.0.0
*/
function register_block_core_archives() {
register_block_type_from_metadata(
__DIR__ . '/archives',
array(
'render_callback' => 'render_block_core_archives',
)
);
}
add_action( 'init', 'register_block_core_archives' );
+71
View File
@@ -0,0 +1,71 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/archives",
"title": "Archives",
"category": "widgets",
"description": "Display a date archive of your posts.",
"textdomain": "default",
"attributes": {
"displayAsDropdown": {
"type": "boolean",
"default": false
},
"showLabel": {
"type": "boolean",
"default": true
},
"showPostCounts": {
"type": "boolean",
"default": false
},
"type": {
"type": "string",
"default": "monthly"
}
},
"supports": {
"anchor": true,
"align": true,
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true
},
"html": false,
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"interactivity": {
"clientNavigation": true
}
}
}
@@ -0,0 +1,7 @@
.wp-block-archives {
box-sizing: border-box;
}
.wp-block-archives-dropdown label {
display: block;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-archives{box-sizing:border-box}.wp-block-archives-dropdown label{display:block}
+7
View File
@@ -0,0 +1,7 @@
.wp-block-archives {
box-sizing: border-box;
}
.wp-block-archives-dropdown label {
display: block;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-archives{box-sizing:border-box}.wp-block-archives-dropdown label{display:block}
+68
View File
@@ -0,0 +1,68 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/audio",
"title": "Audio",
"category": "media",
"description": "Embed a simple audio player.",
"keywords": [ "music", "sound", "podcast", "recording" ],
"textdomain": "default",
"attributes": {
"blob": {
"type": "string",
"role": "local"
},
"src": {
"type": "string",
"source": "attribute",
"selector": "audio",
"attribute": "src",
"role": "content"
},
"caption": {
"type": "rich-text",
"source": "rich-text",
"selector": "figcaption",
"role": "content"
},
"id": {
"type": "number",
"role": "content"
},
"autoplay": {
"type": "boolean",
"source": "attribute",
"selector": "audio",
"attribute": "autoplay"
},
"loop": {
"type": "boolean",
"source": "attribute",
"selector": "audio",
"attribute": "loop"
},
"preload": {
"type": "string",
"source": "attribute",
"selector": "audio",
"attribute": "preload"
}
},
"supports": {
"anchor": true,
"align": true,
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"interactivity": {
"clientNavigation": true
}
},
"editorStyle": "wp-block-audio-editor",
"style": "wp-block-audio"
}
+15
View File
@@ -0,0 +1,15 @@
.wp-block-audio {
margin-right: 0;
margin-left: 0;
position: relative;
}
.wp-block-audio.is-transient audio {
opacity: 0.3;
}
.wp-block-audio .components-spinner {
position: absolute;
top: 50%;
right: 50%;
margin-top: -9px;
margin-right: -9px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio{margin-left:0;margin-right:0;position:relative}.wp-block-audio.is-transient audio{opacity:.3}.wp-block-audio .components-spinner{margin-right:-9px;margin-top:-9px;position:absolute;right:50%;top:50%}
+15
View File
@@ -0,0 +1,15 @@
.wp-block-audio {
margin-left: 0;
margin-right: 0;
position: relative;
}
.wp-block-audio.is-transient audio {
opacity: 0.3;
}
.wp-block-audio .components-spinner {
position: absolute;
top: 50%;
left: 50%;
margin-top: -9px;
margin-left: -9px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio{margin-left:0;margin-right:0;position:relative}.wp-block-audio.is-transient audio{opacity:.3}.wp-block-audio .components-spinner{left:50%;margin-left:-9px;margin-top:-9px;position:absolute;top:50%}
+100
View File
@@ -0,0 +1,100 @@
/**
* Typography
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Typography
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Radius scale.
*/
/**
* Elevation scale.
*/
/**
* Dimensions.
*/
/**
* Mobile specific styles
*/
/**
* Editor styles.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Breakpoints & Media Queries
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Breakpoint mixins
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
/**
* Creates a checkerboard pattern background to indicate transparency.
* @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
*/
.wp-block-audio {
box-sizing: border-box;
}
.wp-block-audio :where(figcaption) {
margin-top: 0.5em;
margin-bottom: 1em;
}
.wp-block-audio audio {
width: 100%;
min-width: 300px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio{box-sizing:border-box}.wp-block-audio :where(figcaption){margin-bottom:1em;margin-top:.5em}.wp-block-audio audio{min-width:300px;width:100%}
+100
View File
@@ -0,0 +1,100 @@
/**
* Typography
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Typography
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Radius scale.
*/
/**
* Elevation scale.
*/
/**
* Dimensions.
*/
/**
* Mobile specific styles
*/
/**
* Editor styles.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Breakpoints & Media Queries
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Breakpoint mixins
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
/**
* Creates a checkerboard pattern background to indicate transparency.
* @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
*/
.wp-block-audio {
box-sizing: border-box;
}
.wp-block-audio :where(figcaption) {
margin-top: 0.5em;
margin-bottom: 1em;
}
.wp-block-audio audio {
width: 100%;
min-width: 300px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio{box-sizing:border-box}.wp-block-audio :where(figcaption){margin-bottom:1em;margin-top:.5em}.wp-block-audio audio{min-width:300px;width:100%}
+101
View File
@@ -0,0 +1,101 @@
/**
* Typography
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Typography
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Radius scale.
*/
/**
* Elevation scale.
*/
/**
* Dimensions.
*/
/**
* Mobile specific styles
*/
/**
* Editor styles.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Breakpoints & Media Queries
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Breakpoint mixins
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
/**
* Creates a checkerboard pattern background to indicate transparency.
* @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
*/
.wp-block-audio :where(figcaption) {
color: #555;
font-size: 13px;
text-align: center;
}
.is-dark-theme .wp-block-audio :where(figcaption) {
color: rgba(255, 255, 255, 0.65);
}
.wp-block-audio {
margin: 0 0 1em 0;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio :where(figcaption){color:#555;font-size:13px;text-align:center}.is-dark-theme .wp-block-audio :where(figcaption){color:#ffffffa6}.wp-block-audio{margin:0 0 1em}
+101
View File
@@ -0,0 +1,101 @@
/**
* Typography
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Typography
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Radius scale.
*/
/**
* Elevation scale.
*/
/**
* Dimensions.
*/
/**
* Mobile specific styles
*/
/**
* Editor styles.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Breakpoints & Media Queries
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Breakpoint mixins
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
/**
* Creates a checkerboard pattern background to indicate transparency.
* @param {String} $size - The size of the squares in the checkerboard pattern. Default is 12px.
*/
.wp-block-audio :where(figcaption) {
color: #555;
font-size: 13px;
text-align: center;
}
.is-dark-theme .wp-block-audio :where(figcaption) {
color: rgba(255, 255, 255, 0.65);
}
.wp-block-audio {
margin: 0 0 1em 0;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-audio :where(figcaption){color:#555;font-size:13px;text-align:center}.is-dark-theme .wp-block-audio :where(figcaption){color:#ffffffa6}.wp-block-audio{margin:0 0 1em}
+166
View File
@@ -0,0 +1,166 @@
<?php
/**
* Server-side rendering of the `core/avatar` block.
*
* @package WordPress
*/
/**
* Renders the `core/avatar` block on the server.
*
* @since 6.0.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
* @return string Return the avatar.
*/
function render_block_core_avatar( $attributes, $content, $block ) {
$size = $attributes['size'] ?? 96;
$wrapper_attributes = get_block_wrapper_attributes();
$border_attributes = get_block_core_avatar_border_attributes( $attributes );
// Class gets passed through `esc_attr` via `get_avatar`.
$image_classes = ! empty( $border_attributes['class'] )
? "wp-block-avatar__image {$border_attributes['class']}"
: 'wp-block-avatar__image';
// Unlike class, `get_avatar` doesn't filter the styles via `esc_attr`.
// The style engine does pass the border styles through
// `safecss_filter_attr` however.
$image_styles = ! empty( $border_attributes['style'] )
? sprintf( ' style="%s"', esc_attr( $border_attributes['style'] ) )
: '';
if ( ! isset( $block->context['commentId'] ) ) {
if ( isset( $attributes['userId'] ) ) {
$author_id = $attributes['userId'];
} elseif ( isset( $block->context['postId'] ) ) {
$author_id = get_post_field( 'post_author', $block->context['postId'] );
} else {
$author_id = get_query_var( 'author' );
}
if ( empty( $author_id ) ) {
return '';
}
$author_name = get_the_author_meta( 'display_name', $author_id );
// translators: %s: Author name.
$alt = sprintf( __( '%s Avatar' ), $author_name );
$avatar_block = get_avatar(
$author_id,
$size,
'',
$alt,
array(
'extra_attr' => $image_styles,
'class' => $image_classes,
)
);
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s is the Author name.
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s author archive, opens in a new tab)' ), $author_name ) ) . '"';
}
// translators: 1: Author archive link. 2: 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>', 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 );
}
$comment = get_comment( $block->context['commentId'] );
if ( ! $comment ) {
return '';
}
/* translators: %s: Author name. */
$alt = sprintf( __( '%s Avatar' ), $comment->comment_author );
$avatar_block = get_avatar(
$comment,
$size,
'',
$alt,
array(
'extra_attr' => $image_styles,
'class' => $image_classes,
)
);
if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) {
$label = '';
if ( '_blank' === $attributes['linkTarget'] ) {
// translators: %s: Comment author name.
$label = 'aria-label="' . esc_attr( sprintf( __( '(%s website link, opens in a new tab)' ), $comment->comment_author ) ) . '"';
}
$avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block );
}
return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block );
}
/**
* Generates class names and styles to apply the border support styles for
* the Avatar block.
*
* @since 6.3.0
*
* @param array $attributes The block attributes.
* @return array The border-related classnames and styles for the block.
*/
function get_block_core_avatar_border_attributes( $attributes ) {
$border_styles = array();
$sides = array( 'top', 'right', 'bottom', 'left' );
// Border radius.
if ( isset( $attributes['style']['border']['radius'] ) ) {
$border_styles['radius'] = $attributes['style']['border']['radius'];
}
// Border style.
if ( isset( $attributes['style']['border']['style'] ) ) {
$border_styles['style'] = $attributes['style']['border']['style'];
}
// Border width.
if ( isset( $attributes['style']['border']['width'] ) ) {
$border_styles['width'] = $attributes['style']['border']['width'];
}
// Border color.
$preset_color = array_key_exists( 'borderColor', $attributes ) ? "var:preset|color|{$attributes['borderColor']}" : null;
$custom_color = $attributes['style']['border']['color'] ?? null;
$border_styles['color'] = $preset_color ? $preset_color : $custom_color;
// Individual border styles e.g. top, left etc.
foreach ( $sides as $side ) {
$border = $attributes['style']['border'][ $side ] ?? null;
$border_styles[ $side ] = array(
'color' => $border['color'] ?? null,
'style' => $border['style'] ?? null,
'width' => $border['width'] ?? null,
);
}
$styles = wp_style_engine_get_styles( array( 'border' => $border_styles ) );
$attributes = array();
if ( ! empty( $styles['classnames'] ) ) {
$attributes['class'] = $styles['classnames'];
}
if ( ! empty( $styles['css'] ) ) {
$attributes['style'] = $styles['css'];
}
return $attributes;
}
/**
* Registers the `core/avatar` block on the server.
*
* @since 6.0.0
*/
function register_block_core_avatar() {
register_block_type_from_metadata(
__DIR__ . '/avatar',
array(
'render_callback' => 'render_block_core_avatar',
)
);
}
add_action( 'init', 'register_block_core_avatar' );
+69
View File
@@ -0,0 +1,69 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/avatar",
"title": "Avatar",
"category": "theme",
"description": "Add a users avatar.",
"textdomain": "default",
"attributes": {
"userId": {
"type": "number"
},
"size": {
"type": "number",
"default": 96
},
"isLink": {
"type": "boolean",
"default": false
},
"linkTarget": {
"type": "string",
"default": "_self"
}
},
"usesContext": [ "postType", "postId", "commentId" ],
"supports": {
"anchor": true,
"html": false,
"align": true,
"alignWide": false,
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"__experimentalBorder": {
"__experimentalSkipSerialization": true,
"radius": true,
"width": true,
"color": true,
"style": true,
"__experimentalDefaultControls": {
"radius": true
}
},
"color": {
"text": false,
"background": false
},
"filter": {
"duotone": true
},
"interactivity": {
"clientNavigation": true
}
},
"selectors": {
"border": ".wp-block-avatar img",
"filter": {
"duotone": ".wp-block-avatar img"
}
},
"editorStyle": "wp-block-avatar-editor",
"style": "wp-block-avatar"
}
+7
View File
@@ -0,0 +1,7 @@
.wp-block-avatar__image img {
width: 100%;
}
.wp-block-avatar.aligncenter .components-resizable-box__container {
margin: 0 auto;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-avatar__image img{width:100%}.wp-block-avatar.aligncenter .components-resizable-box__container{margin:0 auto}
+7
View File
@@ -0,0 +1,7 @@
.wp-block-avatar__image img {
width: 100%;
}
.wp-block-avatar.aligncenter .components-resizable-box__container {
margin: 0 auto;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-avatar__image img{width:100%}.wp-block-avatar.aligncenter .components-resizable-box__container{margin:0 auto}
+10
View File
@@ -0,0 +1,10 @@
.wp-block-avatar {
box-sizing: border-box;
line-height: 0;
}
.wp-block-avatar img {
box-sizing: border-box;
}
.wp-block-avatar.aligncenter {
text-align: center;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-avatar{line-height:0}.wp-block-avatar,.wp-block-avatar img{box-sizing:border-box}.wp-block-avatar.aligncenter{text-align:center}
+10
View File
@@ -0,0 +1,10 @@
.wp-block-avatar {
box-sizing: border-box;
line-height: 0;
}
.wp-block-avatar img {
box-sizing: border-box;
}
.wp-block-avatar.aligncenter {
text-align: center;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-avatar{line-height:0}.wp-block-avatar,.wp-block-avatar img{box-sizing:border-box}.wp-block-avatar.aligncenter{text-align:center}
+131
View File
@@ -0,0 +1,131 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName // Needed for WP_Block_Cloner helper class.
/**
* Server-side rendering of the `core/block` block.
*
* @package WordPress
*/
/**
* Renders the `core/block` block on server.
*
* @since 5.0.0
*
* @global WP_Embed $wp_embed
*
* @param array $attributes The block attributes.
*
* @return string Rendered HTML of the referenced block.
*/
function render_block_core_block( $attributes, $content, $block_instance ) {
static $seen_refs = array();
if ( empty( $attributes['ref'] ) ) {
return '';
}
$reusable_block = get_post( $attributes['ref'] );
if ( ! $reusable_block || 'wp_block' !== $reusable_block->post_type ) {
return '';
}
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 = WP_DEBUG && WP_DEBUG_DISPLAY;
return $is_debug ?
// translators: Visible only in the front end, this warning takes the place of a faulty block.
__( '[block rendering halted]' ) :
'';
}
if ( 'publish' !== $reusable_block->post_status || ! empty( $reusable_block->post_password ) ) {
return '';
}
$seen_refs[ $attributes['ref'] ] = true;
// Handle embeds for reusable blocks.
global $wp_embed;
$content = $wp_embed->run_shortcode( $reusable_block->post_content );
$content = $wp_embed->autoembed( $content );
// Back compat.
// For blocks that have not been migrated in the editor, add some back compat
// so that front-end rendering continues to work.
// This matches the `v2` deprecation. Removes the inner `values` property
// from every item.
if ( isset( $attributes['content'] ) ) {
foreach ( $attributes['content'] as &$content_data ) {
if ( isset( $content_data['values'] ) ) {
$is_assoc_array = is_array( $content_data['values'] ) && ! wp_is_numeric_array( $content_data['values'] );
if ( $is_assoc_array ) {
$content_data = $content_data['values'];
}
}
}
}
// This matches the `v1` deprecation. Rename `overrides` to `content`.
if ( isset( $attributes['overrides'] ) && ! isset( $attributes['content'] ) ) {
$attributes['content'] = $attributes['overrides'];
}
// Apply Block Hooks.
$content = apply_block_hooks_to_content_from_post_object( $content, $reusable_block );
/**
* We attach the blocks from $content as inner blocks to the Synced Pattern block instance.
* This ensures that block context available to the Synced Pattern block instance is provided to
* those blocks.
*/
$block_instance->parsed_block['innerBlocks'] = parse_blocks( $content );
$block_instance->parsed_block['innerContent'] = array_fill( 0, count( $block_instance->parsed_block['innerBlocks'] ), null );
if ( method_exists( $block_instance, 'refresh_context_dependents' ) ) {
// WP_Block::refresh_context_dependents() was introduced in WordPress 6.8.
$block_instance->refresh_context_dependents();
} else {
// This branch can be removed once Gutenberg requires WordPress 6.8 or later.
if ( ! class_exists( 'WP_Block_Cloner' ) ) {
// phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
class WP_Block_Cloner extends WP_Block {
/**
* Static methods of subclasses have access to protected properties
* of instances of the parent class.
* In this case, this gives us access to `available_context` and `registry`.
*/
// phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
public static function clone_instance( $instance ) {
return new WP_Block(
$instance->parsed_block,
$instance->available_context,
$instance->registry
);
}
}
}
$block_instance = WP_Block_Cloner::clone_instance( $block_instance );
}
$content = $block_instance->render( array( 'dynamic' => false ) );
unset( $seen_refs[ $attributes['ref'] ] );
return $content;
}
/**
* Registers the `core/block` block.
*
* @since 5.3.0
*/
function register_block_core_block() {
register_block_type_from_metadata(
__DIR__ . '/block',
array(
'render_callback' => 'render_block_core_block',
)
);
}
add_action( 'init', 'register_block_core_block' );
+32
View File
@@ -0,0 +1,32 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/block",
"title": "Pattern",
"category": "reusable",
"description": "Reuse this design across your site.",
"keywords": [ "reusable" ],
"textdomain": "default",
"attributes": {
"ref": {
"type": "number"
},
"content": {
"type": "object",
"default": {}
}
},
"providesContext": {
"pattern/overrides": "content"
},
"supports": {
"customClassName": false,
"html": false,
"inserter": false,
"renaming": false,
"interactivity": {
"clientNavigation": true
},
"customCSS": false
}
}
File diff suppressed because it is too large Load Diff
+611
View File
@@ -0,0 +1,611 @@
<?php
/**
* Server-side rendering of the `core/breadcrumbs` block.
*
* @package WordPress
*/
/**
* Renders the `core/breadcrumbs` block on the server.
*
* @since 7.0.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the post breadcrumb for hierarchical post types.
*/
function render_block_core_breadcrumbs( $attributes, $content, $block ) {
$is_front_page = is_front_page();
if ( ! $attributes['showOnHomePage'] && $is_front_page ) {
return '';
}
$is_home = is_home();
$page_for_posts = get_option( 'page_for_posts' );
$breadcrumb_items = array();
if ( $attributes['showHomeItem'] ) {
// We make `home` a link if not on front page, or if front page
// is set to a custom page and is paged.
if ( ! $is_front_page || ( 'page' === get_option( 'show_on_front' ) && (int) get_query_var( 'page' ) > 1 ) ) {
$breadcrumb_items[] = array(
'label' => __( 'Home' ),
'url' => home_url( '/' ),
);
} else {
$breadcrumb_items[] = block_core_breadcrumbs_create_item( __( 'Home' ), block_core_breadcrumbs_is_paged() );
}
}
// Handle home.
if ( $is_home ) {
// These checks are explicitly nested in order not to execute the `else` branch.
if ( $page_for_posts ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_item( block_core_breadcrumbs_get_post_title( $page_for_posts ), block_core_breadcrumbs_is_paged() );
}
if ( block_core_breadcrumbs_is_paged() ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
}
} elseif ( $is_front_page ) {
// Handle front page.
// This check is explicitly nested in order not to execute the `else` branch.
// If front page is set to custom page and is paged, add the page number.
if ( (int) get_query_var( 'page' ) > 1 ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
}
} elseif ( is_search() ) {
// Handle search results.
$is_paged = block_core_breadcrumbs_is_paged();
/* translators: %s: search query */
$text = sprintf( __( 'Search results for: "%s"' ), wp_trim_words( get_search_query(), 10 ) );
$breadcrumb_items[] = block_core_breadcrumbs_create_item( $text, $is_paged );
// Add the "Page X" as the current page if paginated.
if ( $is_paged ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
}
} elseif ( is_404() ) {
// Handle 404 pages.
$breadcrumb_items[] = array(
'label' => __( 'Page not found' ),
);
} elseif ( is_archive() ) {
// Handle archive pages (taxonomy, post type, date, author archives).
$archive_breadcrumbs = block_core_breadcrumbs_get_archive_breadcrumbs();
if ( ! empty( $archive_breadcrumbs ) ) {
$breadcrumb_items = array_merge( $breadcrumb_items, $archive_breadcrumbs );
}
} else {
// Handle single post/page breadcrumbs.
if ( ! isset( $block->context['postId'] ) || ! isset( $block->context['postType'] ) ) {
return '';
}
$post_id = $block->context['postId'];
$post_type = $block->context['postType'];
$post = get_post( $post_id );
if ( ! $post ) {
return '';
}
// For non-hierarchical post types with parents (e.g., attachments), build trail for the parent.
$post_parent = $post->post_parent;
$parent_post = null;
if ( ! is_post_type_hierarchical( $post_type ) && $post_parent ) {
$parent_post = get_post( $post_parent );
if ( $parent_post ) {
$post_id = $parent_post->ID;
$post_type = $parent_post->post_type;
$post_parent = $parent_post->post_parent;
}
}
// Determine breadcrumb type.
// Some non-hierarchical post types (e.g., attachments) can have parents.
// Use hierarchical breadcrumbs if a parent exists, otherwise use taxonomy breadcrumbs.
$show_terms = false;
if ( ! is_post_type_hierarchical( $post_type ) && ! $post_parent ) {
$show_terms = true;
} elseif ( empty( get_object_taxonomies( $post_type, 'objects' ) ) ) {
$show_terms = false;
} else {
$show_terms = $attributes['prefersTaxonomy'];
}
// Add post type archive link if applicable.
$post_type_object = get_post_type_object( $post_type );
$archive_link = get_post_type_archive_link( $post_type );
if ( $archive_link && untrailingslashit( home_url() ) !== untrailingslashit( $archive_link ) ) {
$label = $post_type_object->labels->archives;
if ( 'post' === $post_type && $page_for_posts ) {
$label = block_core_breadcrumbs_get_post_title( $page_for_posts );
}
$breadcrumb_items[] = array(
'label' => $label,
'url' => $archive_link,
);
}
// Build breadcrumb trail based on hierarchical structure or taxonomy terms.
if ( ! $show_terms ) {
$breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
} else {
$breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) );
}
// Add post title: linked when viewing a paginated page, plain text otherwise.
$is_paged = (int) get_query_var( 'page' ) > 1 || (int) get_query_var( 'cpage' ) > 1;
$title = block_core_breadcrumbs_get_post_title( $post );
if ( $is_paged ) {
$breadcrumb_items[] = array(
'label' => $title,
'url' => get_permalink( $post ),
'allow_html' => true,
);
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( (int) get_query_var( 'cpage' ) > 1 ? 'cpage' : 'page' );
} else {
$breadcrumb_items[] = array(
'label' => $title,
'allow_html' => true,
);
}
}
// Remove current item if disabled.
if ( ! $attributes['showCurrentItem'] && ! empty( $breadcrumb_items ) ) {
array_pop( $breadcrumb_items );
}
/**
* Filters the breadcrumb items array before rendering.
*
* Allows developers to modify, add, or remove breadcrumb items.
*
* @since 7.0.0
*
* @param array[] $breadcrumb_items {
* Array of breadcrumb item data.
*
* @type string $label The breadcrumb text.
* @type string $url Optional. The breadcrumb link URL.
* @type bool $allow_html Optional. Whether to allow HTML in the label.
* When true, the label will be sanitized with wp_kses_post(),
* allowing only safe HTML tags. When false or omitted, all HTML
* will be escaped with esc_html(). Default false.
* }
*/
$breadcrumb_items = apply_filters( 'block_core_breadcrumbs_items', $breadcrumb_items );
if ( empty( $breadcrumb_items ) ) {
return '';
}
$wrapper_attributes = get_block_wrapper_attributes(
array(
'style' => '--separator: "' . addcslashes( $attributes['separator'], '\\"' ) . '";',
'aria-label' => __( 'Breadcrumbs' ),
)
);
$breadcrumb_html = sprintf(
'<nav %s><ol>%s</ol></nav>',
$wrapper_attributes,
implode(
'',
array_map(
static function ( $item ) {
$label = ! empty( $item['allow_html'] ) ? wp_kses_post( $item['label'] ) : esc_html( $item['label'] );
if ( ! empty( $item['url'] ) ) {
return '<li><a href="' . esc_url( $item['url'] ) . '">' . $label . '</a></li>';
}
return '<li><span aria-current="page">' . $label . '</span></li>';
},
$breadcrumb_items
)
)
);
return $breadcrumb_html;
}
/**
* Checks if we're on a paginated view (page 2 or higher).
*
* @since 7.0.0
*
* @return bool True if paged > 1, false otherwise.
*/
function block_core_breadcrumbs_is_paged() {
$paged = (int) get_query_var( 'paged' );
return $paged > 1;
}
/**
* Creates a "Page X" breadcrumb item for paginated views.
*
* @since 7.0.0
* @param string $query_var Optional. Query variable to get current page number. Default 'paged'.
* @return array The "Page X" breadcrumb item data.
*/
function block_core_breadcrumbs_create_page_number_item( $query_var = 'paged' ) {
$paged = (int) get_query_var( $query_var );
if ( 'cpage' === $query_var ) {
return array(
'label' => sprintf(
/* translators: %s: comment page number */
__( 'Comments Page %s' ),
number_format_i18n( $paged )
),
);
}
return array(
'label' => sprintf(
/* translators: %s: page number */
__( 'Page %s' ),
number_format_i18n( $paged )
),
);
}
/**
* Creates a breadcrumb item that's either a link or current page item.
*
* When paginated (is_paged is true), creates a link to page 1.
* Otherwise, creates a span marked as the current page.
*
* @since 7.0.0
*
* @param string $text The text content.
* @param bool $is_paged Whether we're on a paginated view.
*
* @return array The breadcrumb item data.
*/
function block_core_breadcrumbs_create_item( $text, $is_paged = false ) {
$item = array( 'label' => $text );
if ( $is_paged ) {
$item['url'] = get_pagenum_link( 1 );
}
return $item;
}
/**
* Gets a post title with fallback for empty titles.
*
* @since 7.0.0
*
* @param int|WP_Post $post_id_or_object The post ID or post object.
*
* @return string The post title or fallback text.
*/
function block_core_breadcrumbs_get_post_title( $post_id_or_object ) {
$title = get_the_title( $post_id_or_object );
if ( strlen( $title ) === 0 ) {
$title = __( '(no title)' );
}
return $title;
}
/**
* Generates breadcrumb items from hierarchical post type ancestors.
*
* @since 7.0.0
*
* @param int $post_id The post ID.
*
* @return array Array of breadcrumb item data.
*/
function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) {
$breadcrumb_items = array();
$ancestors = get_post_ancestors( $post_id );
$ancestors = array_reverse( $ancestors );
foreach ( $ancestors as $ancestor_id ) {
$breadcrumb_items[] = array(
'label' => block_core_breadcrumbs_get_post_title( $ancestor_id ),
'url' => get_permalink( $ancestor_id ),
'allow_html' => true,
);
}
return $breadcrumb_items;
}
/**
* Generates breadcrumb items for hierarchical term ancestors.
*
* For hierarchical taxonomies, retrieves and formats ancestor terms as breadcrumb links.
*
* @since 7.0.0
*
* @param int $term_id The term ID.
* @param string $taxonomy The taxonomy name.
*
* @return array Array of breadcrumb item data for ancestors.
*/
function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
$breadcrumb_items = array();
// Check if taxonomy is hierarchical and add ancestor term links.
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
$term_ancestors = get_ancestors( $term_id, $taxonomy, 'taxonomy' );
$term_ancestors = array_reverse( $term_ancestors );
foreach ( $term_ancestors as $ancestor_id ) {
$ancestor_term = get_term( $ancestor_id, $taxonomy );
if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
$breadcrumb_items[] = array(
'label' => $ancestor_term->name,
'url' => get_term_link( $ancestor_term ),
);
}
}
}
return $breadcrumb_items;
}
/**
* Generates breadcrumb items for archive pages.
*
* Handles taxonomy archives, post type archives, date archives, and author archives.
* For hierarchical taxonomies, includes ancestor terms in the breadcrumb trail.
*
* @since 7.0.0
*
* @return array Array of breadcrumb item data.
*/
function block_core_breadcrumbs_get_archive_breadcrumbs() {
$breadcrumb_items = array();
// Date archive (check first since it doesn't have a queried object).
if ( is_date() ) {
$year = get_query_var( 'year' );
$month = get_query_var( 'monthnum' );
$day = get_query_var( 'day' );
// Fallback to 'm' query var for plain permalinks.
// Plain permalinks use ?m=YYYYMMDD format instead of separate query vars.
if ( ! $year ) {
$m = get_query_var( 'm' );
if ( $m ) {
$year = substr( $m, 0, 4 );
$month = substr( $m, 4, 2 );
$day = (int) substr( $m, 6, 2 );
}
}
$is_paged = block_core_breadcrumbs_is_paged();
if ( $year ) {
if ( $month ) {
// Year is linked if we have month.
$breadcrumb_items[] = array(
'label' => $year,
'url' => get_year_link( $year ),
);
if ( $day ) {
// Month is linked if we have day.
$breadcrumb_items[] = array(
'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
'url' => get_month_link( $year, $month ),
);
// Add day (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
$day,
$is_paged
);
} else {
// Add month (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
$is_paged
);
}
} else {
// Add year (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
$year,
$is_paged
);
}
}
// Add pagination breadcrumb if on a paged date archive.
if ( $is_paged ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
}
return $breadcrumb_items;
}
// For other archive types, we need a queried object.
$queried_object = get_queried_object();
if ( ! $queried_object ) {
return array();
}
$is_paged = block_core_breadcrumbs_is_paged();
// Taxonomy archive (category, tag, custom taxonomy).
if ( $queried_object instanceof WP_Term ) {
$term = $queried_object;
$taxonomy = $term->taxonomy;
// Add hierarchical term ancestors if applicable.
$breadcrumb_items = array_merge(
$breadcrumb_items,
block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy )
);
// Add current term (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
$term->name,
$is_paged
);
} elseif ( is_post_type_archive() ) {
// Post type archive.
$post_type = get_query_var( 'post_type' );
if ( is_array( $post_type ) ) {
$post_type = reset( $post_type );
}
$post_type_object = get_post_type_object( $post_type );
/** This filter is documented in wp-includes/general-template.php */
$title = apply_filters( 'post_type_archive_title', $post_type_object->labels->archives, $post_type ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
if ( $post_type_object ) {
// Add post type (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
$title ? $title : $post_type_object->labels->archives,
$is_paged
);
}
} elseif ( is_author() ) {
// Author archive.
$author = $queried_object;
// Add author (current if not paginated, link if paginated).
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
$author->display_name,
$is_paged
);
}
// Add pagination breadcrumb if on a paged archive.
if ( $is_paged ) {
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
}
return $breadcrumb_items;
}
/**
* Generates breadcrumb items from taxonomy terms.
*
* Finds the first publicly queryable taxonomy with terms assigned to the post
* and generates breadcrumb links, including hierarchical term ancestors if applicable.
*
* @since 7.0.0
*
* @param int $post_id The post ID.
* @param string $post_type The post type name.
*
* @return array Array of breadcrumb item data.
*/
function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
$breadcrumb_items = array();
// Get public taxonomies for this post type.
$taxonomies = wp_filter_object_list(
get_object_taxonomies( $post_type, 'objects' ),
array(
'publicly_queryable' => true,
'show_in_rest' => true,
)
);
if ( empty( $taxonomies ) ) {
return $breadcrumb_items;
}
/**
* Filters breadcrumb settings (taxonomy and term selection) for a post or post type.
*
* Allows developers to specify which taxonomy and term should be used in the
* breadcrumb trail when a post type has multiple taxonomies or when a post is
* assigned to multiple terms within a taxonomy.
*
* @since 7.0.0
*
* @param array $settings {
* Array of breadcrumb settings. Default empty array.
*
* @type string $taxonomy Optional. Taxonomy slug to use for breadcrumbs.
* The taxonomy must be registered for the post type and have
* terms assigned to the post. If not found or has no terms,
* fall back to the first available taxonomy with terms.
* @type string $term Optional. Term slug to use when the post has multiple terms
* in the selected taxonomy. If the term is not found or not
* assigned to the post, fall back to the first term. If the
* post has only one term, that term is used regardless.
* }
* @param string $post_type The post type slug.
* @param int $post_id The post ID.
*/
$settings = apply_filters( 'block_core_breadcrumbs_post_type_settings', array(), $post_type, $post_id );
$taxonomy_name = null;
$terms = array();
// Try preferred taxonomy first if specified.
if ( ! empty( $settings['taxonomy'] ) ) {
foreach ( $taxonomies as $taxonomy ) {
if ( $taxonomy->name === $settings['taxonomy'] ) {
$post_terms = get_the_terms( $post_id, $taxonomy->name );
if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
$taxonomy_name = $taxonomy->name;
$terms = $post_terms;
}
break;
}
}
}
// If no preferred taxonomy or it didn't have terms, find the first taxonomy with terms.
if ( empty( $terms ) ) {
foreach ( $taxonomies as $taxonomy ) {
$post_terms = get_the_terms( $post_id, $taxonomy->name );
if ( ! empty( $post_terms ) && ! is_wp_error( $post_terms ) ) {
$taxonomy_name = $taxonomy->name;
$terms = $post_terms;
break;
}
}
}
if ( ! empty( $terms ) ) {
// Select which term to use.
$term = reset( $terms );
// Try preferred term if specified and post has multiple terms.
if ( ! empty( $settings['term'] ) && count( $terms ) > 1 ) {
foreach ( $terms as $candidate_term ) {
if ( $candidate_term->slug === $settings['term'] ) {
$term = $candidate_term;
break;
}
}
}
// Add hierarchical term ancestors if applicable.
$breadcrumb_items = array_merge(
$breadcrumb_items,
block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
);
$breadcrumb_items[] = array(
'label' => $term->name,
'url' => get_term_link( $term ),
);
}
return $breadcrumb_items;
}
/**
* Registers the `core/breadcrumbs` block on the server.
*
* @since 7.0.0
*/
function register_block_core_breadcrumbs() {
register_block_type_from_metadata(
__DIR__ . '/breadcrumbs',
array(
'render_callback' => 'render_block_core_breadcrumbs',
)
);
}
add_action( 'init', 'register_block_core_breadcrumbs' );
+78
View File
@@ -0,0 +1,78 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/breadcrumbs",
"title": "Breadcrumbs",
"category": "theme",
"description": "Display a breadcrumb trail showing the path to the current page.",
"textdomain": "default",
"attributes": {
"prefersTaxonomy": {
"type": "boolean",
"default": false
},
"separator": {
"type": "string",
"default": "/"
},
"showHomeItem": {
"type": "boolean",
"default": true
},
"showCurrentItem": {
"type": "boolean",
"default": true
},
"showOnHomePage": {
"type": "boolean",
"default": false
}
},
"usesContext": [ "postId", "postType", "templateSlug" ],
"supports": {
"anchor": true,
"html": false,
"align": [ "wide", "full" ],
"spacing": {
"margin": true,
"padding": true
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true,
"__experimentalDefaultControls": {
"radius": false,
"color": true,
"width": true,
"style": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"interactivity": {
"clientNavigation": true
}
},
"style": "wp-block-breadcrumbs"
}
@@ -0,0 +1,25 @@
.wp-block-breadcrumbs {
box-sizing: border-box;
}
.wp-block-breadcrumbs ol {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
}
.wp-block-breadcrumbs li {
margin: 0;
padding: 0;
display: flex;
align-items: center;
}
.wp-block-breadcrumbs li:not(:last-child)::after {
content: var(--separator, "/");
margin: 0 0.5em;
opacity: 0.7;
}
.wp-block-breadcrumbs span {
color: inherit;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-breadcrumbs{box-sizing:border-box}.wp-block-breadcrumbs ol{flex-wrap:wrap;list-style:none}.wp-block-breadcrumbs li,.wp-block-breadcrumbs ol{align-items:center;display:flex;margin:0;padding:0}.wp-block-breadcrumbs li:not(:last-child):after{content:var(--separator,"/");margin:0 .5em;opacity:.7}.wp-block-breadcrumbs span{color:inherit}
+25
View File
@@ -0,0 +1,25 @@
.wp-block-breadcrumbs {
box-sizing: border-box;
}
.wp-block-breadcrumbs ol {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
}
.wp-block-breadcrumbs li {
margin: 0;
padding: 0;
display: flex;
align-items: center;
}
.wp-block-breadcrumbs li:not(:last-child)::after {
content: var(--separator, "/");
margin: 0 0.5em;
opacity: 0.7;
}
.wp-block-breadcrumbs span {
color: inherit;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-breadcrumbs{box-sizing:border-box}.wp-block-breadcrumbs ol{flex-wrap:wrap;list-style:none}.wp-block-breadcrumbs li,.wp-block-breadcrumbs ol{align-items:center;display:flex;margin:0;padding:0}.wp-block-breadcrumbs li:not(:last-child):after{content:var(--separator,"/");margin:0 .5em;opacity:.7}.wp-block-breadcrumbs span{color:inherit}
+79
View File
@@ -0,0 +1,79 @@
<?php
/**
* Server-side rendering of the `core/button` block.
*
* @package WordPress
*/
/**
* Renders the `core/button` block on the server,
*
* @since 6.6.0
*
* @param array $attributes The block attributes.
* @param string $content The block content.
*
* @return string The block content.
*/
function render_block_core_button( $attributes, $content ) {
$p = new WP_HTML_Tag_Processor( $content );
/*
* The button block can render an `<a>` or `<button>` and also has a
* `<div>` wrapper. Find the a or button tag.
*/
$tag = null;
while ( $p->next_tag() ) {
$tag = $p->get_tag();
if ( 'A' === $tag || 'BUTTON' === $tag ) {
break;
}
}
/*
* If this happens, the likelihood is there's no block content,
* or the block has been modified by a plugin.
*/
if ( null === $tag ) {
return $content;
}
// If the next token is the closing tag, the button is empty.
$is_empty = true;
while ( $p->next_token() && $tag !== $p->get_token_name() && $is_empty ) {
if ( '#comment' !== $p->get_token_type() ) {
/**
* Anything else implies this is not empty.
* This might include any text content (including a space),
* inline images or other HTML.
*/
$is_empty = false;
}
}
/*
* When there's no text, render nothing for the block.
* See https://github.com/WordPress/gutenberg/issues/17221 for the
* reasoning behind this.
*/
if ( $is_empty ) {
return '';
}
return $content;
}
/**
* Registers the `core/button` block on server.
*
* @since 6.6.0
*/
function register_block_core_button() {
register_block_type_from_metadata(
__DIR__ . '/button',
array(
'render_callback' => 'render_block_core_button',
)
);
}
add_action( 'init', 'register_block_core_button' );
+150
View File
@@ -0,0 +1,150 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/button",
"title": "Button",
"category": "design",
"parent": [ "core/buttons" ],
"description": "Prompt visitors to take action with a button-style link.",
"keywords": [ "link" ],
"textdomain": "default",
"attributes": {
"tagName": {
"type": "string",
"enum": [ "a", "button" ],
"default": "a"
},
"type": {
"type": "string",
"default": "button"
},
"url": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "href",
"role": "content"
},
"title": {
"type": "string",
"source": "attribute",
"selector": "a,button",
"attribute": "title",
"role": "content"
},
"text": {
"type": "rich-text",
"source": "rich-text",
"selector": "a,button",
"role": "content"
},
"linkTarget": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "target",
"role": "content"
},
"rel": {
"type": "string",
"source": "attribute",
"selector": "a",
"attribute": "rel",
"role": "content"
},
"placeholder": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
"textColor": {
"type": "string"
},
"gradient": {
"type": "string"
},
"width": {
"type": "number"
}
},
"supports": {
"anchor": true,
"splitting": true,
"align": false,
"alignWide": false,
"color": {
"__experimentalSkipSerialization": true,
"gradients": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"typography": {
"__experimentalSkipSerialization": [
"fontSize",
"lineHeight",
"textAlign",
"fontFamily",
"fontWeight",
"fontStyle",
"textTransform",
"textDecoration",
"letterSpacing"
],
"fontSize": true,
"lineHeight": true,
"textAlign": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalWritingMode": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"reusable": false,
"shadow": {
"__experimentalSkipSerialization": true
},
"spacing": {
"__experimentalSkipSerialization": true,
"padding": [ "horizontal", "vertical" ],
"__experimentalDefaultControls": {
"padding": true
}
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalSkipSerialization": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"interactivity": {
"clientNavigation": true
}
},
"styles": [
{ "name": "fill", "label": "Fill", "isDefault": true },
{ "name": "outline", "label": "Outline" }
],
"editorStyle": "wp-block-button-editor",
"style": "wp-block-button",
"selectors": {
"root": ".wp-block-button .wp-block-button__link",
"typography": {
"writingMode": ".wp-block-button"
}
}
}
+29
View File
@@ -0,0 +1,29 @@
/**
* Colors
*/
.wp-block[data-align=center] > .wp-block-button {
text-align: center;
margin-right: auto;
margin-left: auto;
}
.wp-block[data-align=right] > .wp-block-button {
text-align: right;
}
.wp-block-button {
position: relative;
cursor: text;
}
.wp-block-button:focus {
box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--wp-admin-theme-color);
outline: 2px solid transparent;
outline-offset: -2px;
}
.wp-block-button[data-rich-text-placeholder]::after {
opacity: 0.8;
}
div[data-type="core/button"] {
display: table;
}
+1
View File
@@ -0,0 +1 @@
.wp-block[data-align=center]>.wp-block-button{margin-left:auto;margin-right:auto;text-align:center}.wp-block[data-align=right]>.wp-block-button{text-align:right}.wp-block-button{cursor:text;position:relative}.wp-block-button:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px var(--wp-admin-theme-color);outline:2px solid #0000;outline-offset:-2px}.wp-block-button[data-rich-text-placeholder]:after{opacity:.8}div[data-type="core/button"]{display:table}
+30
View File
@@ -0,0 +1,30 @@
/**
* Colors
*/
.wp-block[data-align=center] > .wp-block-button {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.wp-block[data-align=right] > .wp-block-button {
/*!rtl:ignore*/
text-align: right;
}
.wp-block-button {
position: relative;
cursor: text;
}
.wp-block-button:focus {
box-shadow: 0 0 0 1px #fff, 0 0 0 3px var(--wp-admin-theme-color);
outline: 2px solid transparent;
outline-offset: -2px;
}
.wp-block-button[data-rich-text-placeholder]::after {
opacity: 0.8;
}
div[data-type="core/button"] {
display: table;
}
+1
View File
@@ -0,0 +1 @@
.wp-block[data-align=center]>.wp-block-button{margin-left:auto;margin-right:auto;text-align:center}.wp-block[data-align=right]>.wp-block-button{text-align:right}.wp-block-button{cursor:text;position:relative}.wp-block-button:focus{box-shadow:0 0 0 1px #fff,0 0 0 3px var(--wp-admin-theme-color);outline:2px solid #0000;outline-offset:-2px}.wp-block-button[data-rich-text-placeholder]:after{opacity:.8}div[data-type="core/button"]{display:table}
+84
View File
@@ -0,0 +1,84 @@
.wp-block-button__link {
cursor: pointer;
display: inline-block;
text-align: center;
word-break: break-word;
box-sizing: border-box;
height: 100%;
align-content: center;
}
.wp-block-button__link.aligncenter {
text-align: center;
}
.wp-block-button__link.alignright {
text-align: right;
}
:where(.wp-block-button__link) {
box-shadow: none;
text-decoration: none;
border-radius: 9999px;
padding: calc(0.667em + 2px) calc(1.333em + 2px);
}
.wp-block-button[style*=text-decoration] .wp-block-button__link {
text-decoration: inherit;
}
.wp-block-buttons > .wp-block-button.has-custom-width {
max-width: none;
}
.wp-block-buttons > .wp-block-button.has-custom-width .wp-block-button__link {
width: 100%;
}
.wp-block-buttons > .wp-block-button.has-custom-font-size .wp-block-button__link {
font-size: inherit;
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-25 {
width: calc(25% - var(--wp--style--block-gap, 0.5em) * 0.75);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-50 {
width: calc(50% - var(--wp--style--block-gap, 0.5em) * 0.5);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-75 {
width: calc(75% - var(--wp--style--block-gap, 0.5em) * 0.25);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-100 {
width: 100%;
flex-basis: 100%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-25 {
width: 25%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-50 {
width: 50%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-75 {
width: 75%;
}
.wp-block-button.is-style-squared,
.wp-block-button__link.wp-block-button.is-style-squared {
border-radius: 0;
}
.wp-block-button.no-border-radius,
.wp-block-button__link.no-border-radius {
border-radius: 0 !important;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline) {
border: 2px solid currentColor;
padding: 0.667em 1.333em;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color)),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)) {
color: currentColor;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background)),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)) {
background-color: transparent;
background-image: none;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-button__link{align-content:center;box-sizing:border-box;cursor:pointer;display:inline-block;height:100%;text-align:center;word-break:break-word}.wp-block-button__link.aligncenter{text-align:center}.wp-block-button__link.alignright{text-align:right}:where(.wp-block-button__link){border-radius:9999px;box-shadow:none;padding:calc(.667em + 2px) calc(1.333em + 2px);text-decoration:none}.wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons>.wp-block-button.has-custom-width{max-width:none}.wp-block-buttons>.wp-block-button.has-custom-width .wp-block-button__link{width:100%}.wp-block-buttons>.wp-block-button.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons>.wp-block-button.wp-block-button__width-25{width:calc(25% - var(--wp--style--block-gap, .5em)*.75)}.wp-block-buttons>.wp-block-button.wp-block-button__width-50{width:calc(50% - var(--wp--style--block-gap, .5em)*.5)}.wp-block-buttons>.wp-block-button.wp-block-button__width-75{width:calc(75% - var(--wp--style--block-gap, .5em)*.25)}.wp-block-buttons>.wp-block-button.wp-block-button__width-100{flex-basis:100%;width:100%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-25{width:25%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-50{width:50%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-75{width:75%}.wp-block-button.is-style-squared,.wp-block-button__link.wp-block-button.is-style-squared{border-radius:0}.wp-block-button.no-border-radius,.wp-block-button__link.no-border-radius{border-radius:0!important}:root :where(.wp-block-button .wp-block-button__link.is-style-outline),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link){border:2px solid;padding:.667em 1.333em}:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-text-color)){color:currentColor}:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-background)){background-color:initial;background-image:none}
+85
View File
@@ -0,0 +1,85 @@
.wp-block-button__link {
cursor: pointer;
display: inline-block;
text-align: center;
word-break: break-word;
box-sizing: border-box;
height: 100%;
align-content: center;
}
.wp-block-button__link.aligncenter {
text-align: center;
}
.wp-block-button__link.alignright {
/*rtl:ignore*/
text-align: right;
}
:where(.wp-block-button__link) {
box-shadow: none;
text-decoration: none;
border-radius: 9999px;
padding: calc(0.667em + 2px) calc(1.333em + 2px);
}
.wp-block-button[style*=text-decoration] .wp-block-button__link {
text-decoration: inherit;
}
.wp-block-buttons > .wp-block-button.has-custom-width {
max-width: none;
}
.wp-block-buttons > .wp-block-button.has-custom-width .wp-block-button__link {
width: 100%;
}
.wp-block-buttons > .wp-block-button.has-custom-font-size .wp-block-button__link {
font-size: inherit;
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-25 {
width: calc(25% - var(--wp--style--block-gap, 0.5em) * 0.75);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-50 {
width: calc(50% - var(--wp--style--block-gap, 0.5em) * 0.5);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-75 {
width: calc(75% - var(--wp--style--block-gap, 0.5em) * 0.25);
}
.wp-block-buttons > .wp-block-button.wp-block-button__width-100 {
width: 100%;
flex-basis: 100%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-25 {
width: 25%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-50 {
width: 50%;
}
.wp-block-buttons.is-vertical > .wp-block-button.wp-block-button__width-75 {
width: 75%;
}
.wp-block-button.is-style-squared,
.wp-block-button__link.wp-block-button.is-style-squared {
border-radius: 0;
}
.wp-block-button.no-border-radius,
.wp-block-button__link.no-border-radius {
border-radius: 0 !important;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline) {
border: 2px solid currentColor;
padding: 0.667em 1.333em;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-text-color)),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)) {
color: currentColor;
}
:root :where(.wp-block-button.is-style-outline > .wp-block-button__link:not(.has-background)),
:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)) {
background-color: transparent;
background-image: none;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-button__link{align-content:center;box-sizing:border-box;cursor:pointer;display:inline-block;height:100%;text-align:center;word-break:break-word}.wp-block-button__link.aligncenter{text-align:center}.wp-block-button__link.alignright{text-align:right}:where(.wp-block-button__link){border-radius:9999px;box-shadow:none;padding:calc(.667em + 2px) calc(1.333em + 2px);text-decoration:none}.wp-block-button[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons>.wp-block-button.has-custom-width{max-width:none}.wp-block-buttons>.wp-block-button.has-custom-width .wp-block-button__link{width:100%}.wp-block-buttons>.wp-block-button.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons>.wp-block-button.wp-block-button__width-25{width:calc(25% - var(--wp--style--block-gap, .5em)*.75)}.wp-block-buttons>.wp-block-button.wp-block-button__width-50{width:calc(50% - var(--wp--style--block-gap, .5em)*.5)}.wp-block-buttons>.wp-block-button.wp-block-button__width-75{width:calc(75% - var(--wp--style--block-gap, .5em)*.25)}.wp-block-buttons>.wp-block-button.wp-block-button__width-100{flex-basis:100%;width:100%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-25{width:25%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-50{width:50%}.wp-block-buttons.is-vertical>.wp-block-button.wp-block-button__width-75{width:75%}.wp-block-button.is-style-squared,.wp-block-button__link.wp-block-button.is-style-squared{border-radius:0}.wp-block-button.no-border-radius,.wp-block-button__link.no-border-radius{border-radius:0!important}:root :where(.wp-block-button .wp-block-button__link.is-style-outline),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link){border:2px solid;padding:.667em 1.333em}:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-text-color)),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-text-color)){color:currentColor}:root :where(.wp-block-button .wp-block-button__link.is-style-outline:not(.has-background)),:root :where(.wp-block-button.is-style-outline>.wp-block-button__link:not(.has-background)){background-color:initial;background-image:none}
+71
View File
@@ -0,0 +1,71 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/buttons",
"title": "Buttons",
"category": "design",
"allowedBlocks": [ "core/button" ],
"description": "Prompt visitors to take action with a group of button-style links.",
"keywords": [ "link" ],
"textdomain": "default",
"supports": {
"anchor": true,
"align": [ "wide", "full" ],
"html": false,
"__experimentalExposeControlsToChildren": true,
"color": {
"gradients": true,
"text": false,
"__experimentalDefaultControls": {
"background": true
}
},
"spacing": {
"blockGap": [ "horizontal", "vertical" ],
"padding": true,
"margin": [ "top", "bottom" ],
"__experimentalDefaultControls": {
"blockGap": true
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"__experimentalBorder": {
"color": true,
"radius": true,
"style": true,
"width": true,
"__experimentalDefaultControls": {
"color": true,
"radius": true,
"style": true,
"width": true
}
},
"layout": {
"allowSwitching": false,
"allowInheriting": false,
"default": {
"type": "flex"
}
},
"interactivity": {
"clientNavigation": true
},
"listView": true,
"contentRole": true
},
"editorStyle": "wp-block-buttons-editor",
"style": "wp-block-buttons"
}
+44
View File
@@ -0,0 +1,44 @@
.wp-block-buttons > .wp-block {
margin: 0;
}
.wp-block-buttons > .wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button {
margin: 0;
}
.wp-block-buttons > .block-list-appender {
display: inline-flex;
align-items: center;
}
.wp-block-buttons.is-vertical > .block-list-appender .block-list-appender__toggle {
justify-content: flex-start;
}
.wp-block-buttons > .wp-block-button:focus {
box-shadow: none;
}
.wp-block-buttons {
/* stylelint-disable @stylistic/indentation -- Disable the stylelint rule, otherwise this selector is ugly! */
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block[data-align=center] {
/* stylelint-enable @stylistic/indentation */
margin-right: auto;
margin-left: auto;
margin-top: 0;
width: 100%;
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block[data-align=center] .wp-block-button {
margin-bottom: 0;
}
.wp-block[data-align=center] > .wp-block-buttons {
align-items: center;
justify-content: center;
}
.wp-block[data-align=right] > .wp-block-buttons {
justify-content: flex-end;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-buttons>.wp-block,.wp-block-buttons>.wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button{margin:0}.wp-block-buttons>.block-list-appender{align-items:center;display:inline-flex}.wp-block-buttons.is-vertical>.block-list-appender .block-list-appender__toggle{justify-content:flex-start}.wp-block-buttons>.wp-block-button:focus{box-shadow:none}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center]{margin-left:auto;margin-right:auto;margin-top:0;width:100%}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center] .wp-block-button{margin-bottom:0}.wp-block[data-align=center]>.wp-block-buttons{align-items:center;justify-content:center}.wp-block[data-align=right]>.wp-block-buttons{justify-content:flex-end}
+44
View File
@@ -0,0 +1,44 @@
.wp-block-buttons > .wp-block {
margin: 0;
}
.wp-block-buttons > .wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button {
margin: 0;
}
.wp-block-buttons > .block-list-appender {
display: inline-flex;
align-items: center;
}
.wp-block-buttons.is-vertical > .block-list-appender .block-list-appender__toggle {
justify-content: flex-start;
}
.wp-block-buttons > .wp-block-button:focus {
box-shadow: none;
}
.wp-block-buttons {
/* stylelint-disable @stylistic/indentation -- Disable the stylelint rule, otherwise this selector is ugly! */
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block[data-align=center] {
/* stylelint-enable @stylistic/indentation */
margin-left: auto;
margin-right: auto;
margin-top: 0;
width: 100%;
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block[data-align=center] .wp-block-button {
margin-bottom: 0;
}
.wp-block[data-align=center] > .wp-block-buttons {
align-items: center;
justify-content: center;
}
.wp-block[data-align=right] > .wp-block-buttons {
justify-content: flex-end;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-buttons>.wp-block,.wp-block-buttons>.wp-block-button.wp-block-button.wp-block-button.wp-block-button.wp-block-button{margin:0}.wp-block-buttons>.block-list-appender{align-items:center;display:inline-flex}.wp-block-buttons.is-vertical>.block-list-appender .block-list-appender__toggle{justify-content:flex-start}.wp-block-buttons>.wp-block-button:focus{box-shadow:none}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center]{margin-left:auto;margin-right:auto;margin-top:0;width:100%}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block[data-align=center] .wp-block-button{margin-bottom:0}.wp-block[data-align=center]>.wp-block-buttons{align-items:center;justify-content:center}.wp-block[data-align=right]>.wp-block-buttons{justify-content:flex-end}
+63
View File
@@ -0,0 +1,63 @@
.wp-block-buttons {
box-sizing: border-box;
}
.wp-block-buttons.is-vertical {
flex-direction: column;
}
.wp-block-buttons.is-vertical > .wp-block-button:last-child {
margin-bottom: 0;
}
.wp-block-buttons > .wp-block-button {
display: inline-block;
margin: 0;
}
.wp-block-buttons.is-content-justification-left {
justify-content: flex-start;
}
.wp-block-buttons.is-content-justification-left.is-vertical {
align-items: flex-start;
}
.wp-block-buttons.is-content-justification-center {
justify-content: center;
}
.wp-block-buttons.is-content-justification-center.is-vertical {
align-items: center;
}
.wp-block-buttons.is-content-justification-right {
justify-content: flex-end;
}
.wp-block-buttons.is-content-justification-right.is-vertical {
align-items: flex-end;
}
.wp-block-buttons.is-content-justification-space-between {
justify-content: space-between;
}
.wp-block-buttons.aligncenter {
text-align: center;
}
.wp-block-buttons {
/* stylelint-disable @stylistic/indentation -- Disable the stylelint rule, otherwise this selector is ugly! */
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block-button.aligncenter {
/* stylelint-enable @stylistic/indentation */
margin-right: auto;
margin-left: auto;
width: 100%;
}
.wp-block-buttons[style*=text-decoration] .wp-block-button,
.wp-block-buttons[style*=text-decoration] .wp-block-button__link {
text-decoration: inherit;
}
.wp-block-buttons.has-custom-font-size .wp-block-button__link {
font-size: inherit;
}
.wp-block-buttons .wp-block-button__link {
width: 100%;
}
.wp-block-button.aligncenter {
text-align: center;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-buttons{box-sizing:border-box}.wp-block-buttons.is-vertical{flex-direction:column}.wp-block-buttons.is-vertical>.wp-block-button:last-child{margin-bottom:0}.wp-block-buttons>.wp-block-button{display:inline-block;margin:0}.wp-block-buttons.is-content-justification-left{justify-content:flex-start}.wp-block-buttons.is-content-justification-left.is-vertical{align-items:flex-start}.wp-block-buttons.is-content-justification-center{justify-content:center}.wp-block-buttons.is-content-justification-center.is-vertical{align-items:center}.wp-block-buttons.is-content-justification-right{justify-content:flex-end}.wp-block-buttons.is-content-justification-right.is-vertical{align-items:flex-end}.wp-block-buttons.is-content-justification-space-between{justify-content:space-between}.wp-block-buttons.aligncenter{text-align:center}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block-button.aligncenter{margin-left:auto;margin-right:auto;width:100%}.wp-block-buttons[style*=text-decoration] .wp-block-button,.wp-block-buttons[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons .wp-block-button__link{width:100%}.wp-block-button.aligncenter{text-align:center}
+63
View File
@@ -0,0 +1,63 @@
.wp-block-buttons {
box-sizing: border-box;
}
.wp-block-buttons.is-vertical {
flex-direction: column;
}
.wp-block-buttons.is-vertical > .wp-block-button:last-child {
margin-bottom: 0;
}
.wp-block-buttons > .wp-block-button {
display: inline-block;
margin: 0;
}
.wp-block-buttons.is-content-justification-left {
justify-content: flex-start;
}
.wp-block-buttons.is-content-justification-left.is-vertical {
align-items: flex-start;
}
.wp-block-buttons.is-content-justification-center {
justify-content: center;
}
.wp-block-buttons.is-content-justification-center.is-vertical {
align-items: center;
}
.wp-block-buttons.is-content-justification-right {
justify-content: flex-end;
}
.wp-block-buttons.is-content-justification-right.is-vertical {
align-items: flex-end;
}
.wp-block-buttons.is-content-justification-space-between {
justify-content: space-between;
}
.wp-block-buttons.aligncenter {
text-align: center;
}
.wp-block-buttons {
/* stylelint-disable @stylistic/indentation -- Disable the stylelint rule, otherwise this selector is ugly! */
}
.wp-block-buttons:not(.is-content-justification-space-between,
.is-content-justification-right,
.is-content-justification-left,
.is-content-justification-center) .wp-block-button.aligncenter {
/* stylelint-enable @stylistic/indentation */
margin-left: auto;
margin-right: auto;
width: 100%;
}
.wp-block-buttons[style*=text-decoration] .wp-block-button,
.wp-block-buttons[style*=text-decoration] .wp-block-button__link {
text-decoration: inherit;
}
.wp-block-buttons.has-custom-font-size .wp-block-button__link {
font-size: inherit;
}
.wp-block-buttons .wp-block-button__link {
width: 100%;
}
.wp-block-button.aligncenter {
text-align: center;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-buttons{box-sizing:border-box}.wp-block-buttons.is-vertical{flex-direction:column}.wp-block-buttons.is-vertical>.wp-block-button:last-child{margin-bottom:0}.wp-block-buttons>.wp-block-button{display:inline-block;margin:0}.wp-block-buttons.is-content-justification-left{justify-content:flex-start}.wp-block-buttons.is-content-justification-left.is-vertical{align-items:flex-start}.wp-block-buttons.is-content-justification-center{justify-content:center}.wp-block-buttons.is-content-justification-center.is-vertical{align-items:center}.wp-block-buttons.is-content-justification-right{justify-content:flex-end}.wp-block-buttons.is-content-justification-right.is-vertical{align-items:flex-end}.wp-block-buttons.is-content-justification-space-between{justify-content:space-between}.wp-block-buttons.aligncenter{text-align:center}.wp-block-buttons:not(.is-content-justification-space-between,.is-content-justification-right,.is-content-justification-left,.is-content-justification-center) .wp-block-button.aligncenter{margin-left:auto;margin-right:auto;width:100%}.wp-block-buttons[style*=text-decoration] .wp-block-button,.wp-block-buttons[style*=text-decoration] .wp-block-button__link{text-decoration:inherit}.wp-block-buttons.has-custom-font-size .wp-block-button__link{font-size:inherit}.wp-block-buttons .wp-block-button__link{width:100%}.wp-block-button.aligncenter{text-align:center}
+189
View File
@@ -0,0 +1,189 @@
<?php
/**
* Server-side rendering of the `core/calendar` block.
*
* @package WordPress
*/
/**
* Renders the `core/calendar` block on server.
*
* @since 5.2.0
*
* @global int $monthnum.
* @global int $year.
*
* @param array $attributes The block attributes.
*
* @return string Returns the block content.
*/
function render_block_core_calendar( $attributes ) {
global $monthnum, $year;
// Calendar shouldn't be rendered
// when there are no published posts on the site.
if ( ! block_core_calendar_has_published_posts() ) {
if ( is_user_logged_in() ) {
return '<div>' . __( 'The calendar block is hidden because there are no published posts.' ) . '</div>';
}
return '';
}
$previous_monthnum = $monthnum;
$previous_year = $year;
if ( isset( $attributes['month'] ) && isset( $attributes['year'] ) ) {
$permalink_structure = get_option( 'permalink_structure' );
if (
str_contains( $permalink_structure, '%monthnum%' ) &&
str_contains( $permalink_structure, '%year%' )
) {
$monthnum = $attributes['month'];
$year = $attributes['year'];
}
}
$color_block_styles = array();
// Text color.
$preset_text_color = array_key_exists( 'textColor', $attributes ) ? "var:preset|color|{$attributes['textColor']}" : null;
$custom_text_color = $attributes['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 = $attributes['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,
$calendar
);
$monthnum = $previous_monthnum;
$year = $previous_year;
return $output;
}
/**
* Registers the `core/calendar` block on server.
*
* @since 5.2.0
*/
function register_block_core_calendar() {
register_block_type_from_metadata(
__DIR__ . '/calendar',
array(
'render_callback' => 'render_block_core_calendar',
)
);
}
add_action( 'init', 'register_block_core_calendar' );
/**
* Returns whether or not there are any published posts.
*
* Used to hide the calendar block when there are no published posts.
* This compensates for a known Core bug: https://core.trac.wordpress.org/ticket/12016
*
* @since 5.9.0
*
* @return bool Has any published posts or not.
*/
function block_core_calendar_has_published_posts() {
// Multisite already has an option that stores the count of the published posts.
// Let's use that for multisites.
if ( is_multisite() ) {
return 0 < (int) get_option( 'post_count' );
}
// On single sites we try our own cached option first.
$has_published_posts = get_option( 'wp_calendar_block_has_published_posts', null );
if ( null !== $has_published_posts ) {
return (bool) $has_published_posts;
}
// No cache hit, let's update the cache and return the cached value.
return block_core_calendar_update_has_published_posts();
}
/**
* Queries the database for any published post and saves
* a flag whether any published post exists or not.
*
* @since 5.9.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @return bool Has any published posts or not.
*/
function block_core_calendar_update_has_published_posts() {
global $wpdb;
$has_published_posts = (bool) $wpdb->get_var( "SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
update_option( 'wp_calendar_block_has_published_posts', $has_published_posts );
return $has_published_posts;
}
// We only want to register these functions and actions when
// we are on single sites. On multi sites we use `post_count` option.
if ( ! is_multisite() ) {
/**
* Handler for updating the has published posts flag when a post is deleted.
*
* @since 5.9.0
*
* @param int $post_id Deleted post ID.
*/
function block_core_calendar_update_has_published_post_on_delete( $post_id ) {
$post = get_post( $post_id );
if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
return;
}
block_core_calendar_update_has_published_posts();
}
/**
* Handler for updating the has published posts flag when a post status changes.
*
* @since 5.9.0
*
* @param string $new_status The status the post is changing to.
* @param string $old_status The status the post is changing from.
* @param WP_Post $post Post object.
*/
function block_core_calendar_update_has_published_post_on_transition_post_status( $new_status, $old_status, $post ) {
if ( $new_status === $old_status ) {
return;
}
if ( 'post' !== get_post_type( $post ) ) {
return;
}
if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
return;
}
block_core_calendar_update_has_published_posts();
}
add_action( 'delete_post', 'block_core_calendar_update_has_published_post_on_delete' );
add_action( 'transition_post_status', 'block_core_calendar_update_has_published_post_on_transition_post_status', 10, 3 );
}
+48
View File
@@ -0,0 +1,48 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/calendar",
"title": "Calendar",
"category": "widgets",
"description": "A calendar of your sites posts.",
"keywords": [ "posts", "archive" ],
"textdomain": "default",
"attributes": {
"month": {
"type": "integer"
},
"year": {
"type": "integer"
}
},
"supports": {
"anchor": true,
"align": true,
"html": false,
"color": {
"link": true,
"__experimentalSkipSerialization": [ "text", "background" ],
"__experimentalDefaultControls": {
"background": true,
"text": true
},
"__experimentalSelector": "table, th"
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"interactivity": {
"clientNavigation": true
}
},
"style": "wp-block-calendar"
}
+38
View File
@@ -0,0 +1,38 @@
/**
* Colors
*/
.wp-block-calendar {
text-align: center;
}
.wp-block-calendar th,
.wp-block-calendar td {
padding: 0.25em;
border: 1px solid;
}
.wp-block-calendar th {
font-weight: 400;
}
.wp-block-calendar caption {
background-color: inherit;
}
.wp-block-calendar table {
width: 100%;
border-collapse: collapse;
}
.wp-block-calendar table.has-background th {
background-color: inherit;
}
.wp-block-calendar table.has-text-color th {
color: inherit;
}
.wp-block-calendar :where(table:not(.has-text-color)) {
color: #40464d;
}
.wp-block-calendar :where(table:not(.has-text-color)) th,
.wp-block-calendar :where(table:not(.has-text-color)) td {
border-color: #ddd;
}
:where(.wp-block-calendar table:not(.has-background) th) {
background: #ddd;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-calendar{text-align:center}.wp-block-calendar td,.wp-block-calendar th{border:1px solid;padding:.25em}.wp-block-calendar th{font-weight:400}.wp-block-calendar caption{background-color:inherit}.wp-block-calendar table{border-collapse:collapse;width:100%}.wp-block-calendar table.has-background th{background-color:inherit}.wp-block-calendar table.has-text-color th{color:inherit}.wp-block-calendar :where(table:not(.has-text-color)){color:#40464d}.wp-block-calendar :where(table:not(.has-text-color)) td,.wp-block-calendar :where(table:not(.has-text-color)) th{border-color:#ddd}:where(.wp-block-calendar table:not(.has-background) th){background:#ddd}
+38
View File
@@ -0,0 +1,38 @@
/**
* Colors
*/
.wp-block-calendar {
text-align: center;
}
.wp-block-calendar th,
.wp-block-calendar td {
padding: 0.25em;
border: 1px solid;
}
.wp-block-calendar th {
font-weight: 400;
}
.wp-block-calendar caption {
background-color: inherit;
}
.wp-block-calendar table {
width: 100%;
border-collapse: collapse;
}
.wp-block-calendar table.has-background th {
background-color: inherit;
}
.wp-block-calendar table.has-text-color th {
color: inherit;
}
.wp-block-calendar :where(table:not(.has-text-color)) {
color: #40464d;
}
.wp-block-calendar :where(table:not(.has-text-color)) th,
.wp-block-calendar :where(table:not(.has-text-color)) td {
border-color: #ddd;
}
:where(.wp-block-calendar table:not(.has-background) th) {
background: #ddd;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-calendar{text-align:center}.wp-block-calendar td,.wp-block-calendar th{border:1px solid;padding:.25em}.wp-block-calendar th{font-weight:400}.wp-block-calendar caption{background-color:inherit}.wp-block-calendar table{border-collapse:collapse;width:100%}.wp-block-calendar table.has-background th{background-color:inherit}.wp-block-calendar table.has-text-color th{color:inherit}.wp-block-calendar :where(table:not(.has-text-color)){color:#40464d}.wp-block-calendar :where(table:not(.has-text-color)) td,.wp-block-calendar :where(table:not(.has-text-color)) th{border-color:#ddd}:where(.wp-block-calendar table:not(.has-background) th){background:#ddd}
+159
View File
@@ -0,0 +1,159 @@
<?php
/**
* Server-side rendering of the `core/categories` block.
*
* @package WordPress
*/
/**
* Renders the `core/categories` block on server.
*
* @since 5.0.0
* @since 6.7.0 Enable client-side rendering if enhancedPagination context is true.
*
* @param array $attributes The block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
*
* @return string Returns the categories list/dropdown markup.
*/
function render_block_core_categories( $attributes, $content, $block ) {
static $block_id = 0;
++$block_id;
$taxonomy = get_taxonomy( $attributes['taxonomy'] );
$args = array(
'echo' => false,
'hierarchical' => ! empty( $attributes['showHierarchy'] ),
'orderby' => 'name',
'show_count' => ! empty( $attributes['showPostCounts'] ),
'taxonomy' => $attributes['taxonomy'],
'title_li' => '',
'hide_empty' => empty( $attributes['showEmpty'] ),
);
if ( ! empty( $attributes['showOnlyTopLevel'] ) && $attributes['showOnlyTopLevel'] ) {
$args['parent'] = 0;
}
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$id = 'wp-block-categories-' . $block_id;
$args['id'] = $id;
$args['name'] = $taxonomy->query_var;
$args['value_field'] = 'slug';
$args['show_option_none'] = sprintf(
/* translators: %s: taxonomy's singular name */
__( 'Select %s' ),
$taxonomy->labels->singular_name
);
// Pre-select the current term using query var.
$args['selected'] = get_query_var( $taxonomy->query_var );
$show_label = empty( $attributes['showLabel'] ) ? ' screen-reader-text' : '';
$default_label = $taxonomy->label;
$label_text = ! empty( $attributes['label'] ) ? wp_kses_post( $attributes['label'] ) : $default_label;
$wrapper_markup = '<div %1$s><label class="wp-block-categories__label' . $show_label . '" for="' . esc_attr( $id ) . '">' . $label_text . '</label>%2$s</div>';
$items_markup = wp_dropdown_categories( $args );
$type = 'dropdown';
if ( ! is_admin() ) {
// 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 {
$args['show_option_none'] = $taxonomy->labels->no_terms;
$wrapper_markup = '<ul %1$s>%2$s</ul>';
$items_markup = wp_list_categories( $args );
$type = 'list';
if ( ! empty( $block->context['enhancedPagination'] ) ) {
$p = new WP_HTML_Tag_Processor( $items_markup );
while ( $p->next_tag( 'a' ) ) {
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
}
$items_markup = $p->get_updated_html();
}
}
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => "wp-block-categories-{$type} wp-block-categories-taxonomy-{$attributes['taxonomy']}" ) );
return sprintf(
$wrapper_markup,
$wrapper_attributes,
$items_markup
);
}
/**
* Generates the inline script for a categories dropdown field.
*
* @since 5.0.0
*
* @param string $dropdown_id ID of the dropdown field.
*
* @return string Returns the dropdown onChange redirection script.
*/
function build_dropdown_script_block_core_categories( $dropdown_id ) {
ob_start();
$exports = array( $dropdown_id, home_url() );
?>
<script>
( ( [ dropdownId, homeUrl ] ) => {
const dropdown = document.getElementById( dropdownId );
function onSelectChange() {
setTimeout( () => {
if ( 'escape' === dropdown.dataset.lastkey ) {
return;
}
// Only navigate if a valid term is selected (not the default "Select [taxonomy]" option)
if ( dropdown.value && dropdown.value !== '-1' && dropdown instanceof HTMLSelectElement ) {
const url = new URL( homeUrl );
url.searchParams.set( dropdown.name, dropdown.value );
location.href = url.href;
}
}, 250 );
}
function onKeyUp( event ) {
if ( 'Escape' === event.key ) {
dropdown.dataset.lastkey = 'escape';
} else {
delete dropdown.dataset.lastkey;
}
}
function onClick() {
delete dropdown.dataset.lastkey;
}
dropdown.addEventListener( 'keyup', onKeyUp );
dropdown.addEventListener( 'click', onClick );
dropdown.addEventListener( 'change', onSelectChange );
} )( <?php echo wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
</script>
<?php
return wp_get_inline_script_tag(
trim( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) ) .
"\n//# sourceURL=" . rawurlencode( __FUNCTION__ )
);
}
/**
* Registers the `core/categories` block on server.
*
* @since 5.0.0
*/
function register_block_core_categories() {
register_block_type_from_metadata(
__DIR__ . '/categories',
array(
'render_callback' => 'render_block_core_categories',
)
);
}
add_action( 'init', 'register_block_core_categories' );
+97
View File
@@ -0,0 +1,97 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/categories",
"title": "Terms List",
"category": "widgets",
"description": "Display a list of all terms of a given taxonomy.",
"keywords": [ "categories" ],
"textdomain": "default",
"attributes": {
"taxonomy": {
"type": "string",
"default": "category"
},
"displayAsDropdown": {
"type": "boolean",
"default": false
},
"showHierarchy": {
"type": "boolean",
"default": false
},
"showPostCounts": {
"type": "boolean",
"default": false
},
"showOnlyTopLevel": {
"type": "boolean",
"default": false
},
"showEmpty": {
"type": "boolean",
"default": false
},
"label": {
"type": "string",
"role": "content"
},
"showLabel": {
"type": "boolean",
"default": true
}
},
"usesContext": [ "enhancedPagination" ],
"supports": {
"anchor": true,
"align": true,
"html": false,
"spacing": {
"margin": true,
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"color": {
"gradients": true,
"link": true,
"__experimentalDefaultControls": {
"background": true,
"text": true,
"link": true
}
},
"interactivity": {
"clientNavigation": true
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true,
"__experimentalDefaultControls": {
"radius": true,
"color": true,
"width": true,
"style": true
}
}
},
"editorStyle": "wp-block-categories-editor",
"style": "wp-block-categories"
}
@@ -0,0 +1,15 @@
.wp-block-categories ul {
padding-right: 2.5em;
}
.wp-block-categories ul ul {
margin-top: 6px;
}
/* Center alignment for classic themes. */
[data-align=center] .wp-block-categories {
text-align: center;
}
.wp-block-categories__indentation {
padding-right: 16px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-categories ul{padding-right:2.5em}.wp-block-categories ul ul{margin-top:6px}[data-align=center] .wp-block-categories{text-align:center}.wp-block-categories__indentation{padding-right:16px}
+15
View File
@@ -0,0 +1,15 @@
.wp-block-categories ul {
padding-left: 2.5em;
}
.wp-block-categories ul ul {
margin-top: 6px;
}
/* Center alignment for classic themes. */
[data-align=center] .wp-block-categories {
text-align: center;
}
.wp-block-categories__indentation {
padding-left: 16px;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-categories ul{padding-left:2.5em}.wp-block-categories ul ul{margin-top:6px}[data-align=center] .wp-block-categories{text-align:center}.wp-block-categories__indentation{padding-left:16px}
@@ -0,0 +1,19 @@
.wp-block-categories {
box-sizing: border-box;
}
.wp-block-categories.alignleft {
margin-right: 2em;
}
.wp-block-categories.alignright {
margin-left: 2em;
}
.wp-block-categories {
/* Only apply the text align on dropdowns, not lists. */
}
.wp-block-categories.wp-block-categories-dropdown.aligncenter {
text-align: center;
}
.wp-block-categories .wp-block-categories__label:not(.screen-reader-text) {
width: 100%;
display: block;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-categories{box-sizing:border-box}.wp-block-categories.alignleft{margin-right:2em}.wp-block-categories.alignright{margin-left:2em}.wp-block-categories.wp-block-categories-dropdown.aligncenter{text-align:center}.wp-block-categories .wp-block-categories__label:not(.screen-reader-text){display:block;width:100%}
+21
View File
@@ -0,0 +1,21 @@
.wp-block-categories {
box-sizing: border-box;
}
.wp-block-categories.alignleft {
/*rtl:ignore*/
margin-right: 2em;
}
.wp-block-categories.alignright {
/*rtl:ignore*/
margin-left: 2em;
}
.wp-block-categories {
/* Only apply the text align on dropdowns, not lists. */
}
.wp-block-categories.wp-block-categories-dropdown.aligncenter {
text-align: center;
}
.wp-block-categories .wp-block-categories__label:not(.screen-reader-text) {
width: 100%;
display: block;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-categories{box-sizing:border-box}.wp-block-categories.alignleft{margin-right:2em}.wp-block-categories.alignright{margin-left:2em}.wp-block-categories.wp-block-categories-dropdown.aligncenter{text-align:center}.wp-block-categories .wp-block-categories__label:not(.screen-reader-text){display:block;width:100%}
+66
View File
@@ -0,0 +1,66 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "core/code",
"title": "Code",
"category": "text",
"description": "Display code snippets that respect your spacing and tabs.",
"textdomain": "default",
"attributes": {
"content": {
"type": "rich-text",
"source": "rich-text",
"selector": "code",
"__unstablePreserveWhiteSpace": true,
"role": "content"
}
},
"supports": {
"align": [ "wide" ],
"anchor": true,
"typography": {
"fontSize": true,
"lineHeight": true,
"__experimentalFontFamily": true,
"__experimentalFontWeight": true,
"__experimentalFontStyle": true,
"__experimentalTextTransform": true,
"__experimentalTextDecoration": true,
"__experimentalLetterSpacing": true,
"__experimentalDefaultControls": {
"fontSize": true
}
},
"spacing": {
"margin": [ "top", "bottom" ],
"padding": true,
"__experimentalDefaultControls": {
"margin": false,
"padding": false
}
},
"__experimentalBorder": {
"radius": true,
"color": true,
"width": true,
"style": true,
"__experimentalDefaultControls": {
"width": true,
"color": true
}
},
"color": {
"text": true,
"background": true,
"gradients": true,
"__experimentalDefaultControls": {
"background": true,
"text": true
}
},
"interactivity": {
"clientNavigation": true
}
},
"style": "wp-block-code"
}
+3
View File
@@ -0,0 +1,3 @@
.wp-block-code code {
background: none;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-code code{background:none}
+3
View File
@@ -0,0 +1,3 @@
.wp-block-code code {
background: none;
}
+1
View File
@@ -0,0 +1 @@
.wp-block-code code{background:none}

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