diff options
Diffstat (limited to '')
-rw-r--r-- | wp-includes/blocks/term-description.php | 49 | ||||
-rw-r--r-- | wp-includes/blocks/term-description/block.json | 42 | ||||
-rw-r--r-- | wp-includes/blocks/term-description/style-rtl.css | 9 | ||||
-rw-r--r-- | wp-includes/blocks/term-description/style-rtl.min.css | 1 | ||||
-rw-r--r-- | wp-includes/blocks/term-description/style.css | 9 | ||||
-rw-r--r-- | wp-includes/blocks/term-description/style.min.css | 1 |
6 files changed, 111 insertions, 0 deletions
diff --git a/wp-includes/blocks/term-description.php b/wp-includes/blocks/term-description.php new file mode 100644 index 0000000..011ec28 --- /dev/null +++ b/wp-includes/blocks/term-description.php @@ -0,0 +1,49 @@ +<?php +/** + * Server-side rendering of the `core/term-description` block. + * + * @package WordPress + */ + +/** + * Renders the `core/term-description` block on the server. + * + * @param array $attributes Block attributes. + * + * @return string Returns the description of the current taxonomy term, if available + */ +function render_block_core_term_description( $attributes ) { + $term_description = ''; + + if ( is_category() || is_tag() || is_tax() ) { + $term_description = term_description(); + } + + if ( empty( $term_description ) ) { + return ''; + } + + $classes = array(); + if ( isset( $attributes['textAlign'] ) ) { + $classes[] = 'has-text-align-' . $attributes['textAlign']; + } + if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { + $classes[] = 'has-link-color'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); + + return '<div ' . $wrapper_attributes . '>' . $term_description . '</div>'; +} + +/** + * Registers the `core/term-description` block on the server. + */ +function register_block_core_term_description() { + register_block_type_from_metadata( + __DIR__ . '/term-description', + array( + 'render_callback' => 'render_block_core_term_description', + ) + ); +} +add_action( 'init', 'register_block_core_term_description' ); diff --git a/wp-includes/blocks/term-description/block.json b/wp-includes/blocks/term-description/block.json new file mode 100644 index 0000000..fc91a4a --- /dev/null +++ b/wp-includes/blocks/term-description/block.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 3, + "name": "core/term-description", + "title": "Term Description", + "category": "theme", + "description": "Display the description of categories, tags and custom taxonomies when viewing an archive.", + "textdomain": "default", + "attributes": { + "textAlign": { + "type": "string" + } + }, + "supports": { + "align": [ "wide", "full" ], + "html": false, + "color": { + "link": true, + "__experimentalDefaultControls": { + "background": true, + "text": true + } + }, + "spacing": { + "padding": true, + "margin": true + }, + "typography": { + "fontSize": true, + "lineHeight": true, + "__experimentalFontFamily": true, + "__experimentalFontWeight": true, + "__experimentalFontStyle": true, + "__experimentalTextTransform": true, + "__experimentalTextDecoration": true, + "__experimentalLetterSpacing": true, + "__experimentalDefaultControls": { + "fontSize": true + } + } + } +} diff --git a/wp-includes/blocks/term-description/style-rtl.css b/wp-includes/blocks/term-description/style-rtl.css new file mode 100644 index 0000000..f7c75cb --- /dev/null +++ b/wp-includes/blocks/term-description/style-rtl.css @@ -0,0 +1,9 @@ +:where(.wp-block-term-description){ + margin-bottom:var(--wp--style--block-gap); + margin-top:var(--wp--style--block-gap); +} + +.wp-block-term-description p{ + margin-bottom:0; + margin-top:0; +}
\ No newline at end of file diff --git a/wp-includes/blocks/term-description/style-rtl.min.css b/wp-includes/blocks/term-description/style-rtl.min.css new file mode 100644 index 0000000..a31628b --- /dev/null +++ b/wp-includes/blocks/term-description/style-rtl.min.css @@ -0,0 +1 @@ +:where(.wp-block-term-description){margin-bottom:var(--wp--style--block-gap);margin-top:var(--wp--style--block-gap)}.wp-block-term-description p{margin-bottom:0;margin-top:0}
\ No newline at end of file diff --git a/wp-includes/blocks/term-description/style.css b/wp-includes/blocks/term-description/style.css new file mode 100644 index 0000000..f7c75cb --- /dev/null +++ b/wp-includes/blocks/term-description/style.css @@ -0,0 +1,9 @@ +:where(.wp-block-term-description){ + margin-bottom:var(--wp--style--block-gap); + margin-top:var(--wp--style--block-gap); +} + +.wp-block-term-description p{ + margin-bottom:0; + margin-top:0; +}
\ No newline at end of file diff --git a/wp-includes/blocks/term-description/style.min.css b/wp-includes/blocks/term-description/style.min.css new file mode 100644 index 0000000..a31628b --- /dev/null +++ b/wp-includes/blocks/term-description/style.min.css @@ -0,0 +1 @@ +:where(.wp-block-term-description){margin-bottom:var(--wp--style--block-gap);margin-top:var(--wp--style--block-gap)}.wp-block-term-description p{margin-bottom:0;margin-top:0}
\ No newline at end of file |