@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/accordion/view.js +46 -4
- package/build/accordion/view.js.map +2 -2
- package/build/accordion-heading/block.json +1 -1
- package/build/accordion-heading/deprecated.js +1 -1
- package/build/accordion-heading/deprecated.js.map +2 -2
- package/build/accordion-panel/block.json +1 -1
- package/build/audio/index.js +12 -9
- package/build/audio/index.js.map +3 -3
- package/build/button/index.js +13 -10
- package/build/button/index.js.map +3 -3
- package/build/code/index.js +9 -6
- package/build/code/index.js.map +3 -3
- package/build/cover/edit/block-controls.js +37 -3
- package/build/cover/edit/block-controls.js.map +3 -3
- package/build/cover/edit/cover-placeholder.js +0 -1
- package/build/cover/edit/cover-placeholder.js.map +2 -2
- package/build/cover/edit/embed-video-url-input.js +83 -0
- package/build/cover/edit/embed-video-url-input.js.map +7 -0
- package/build/cover/edit/index.js +60 -0
- package/build/cover/edit/index.js.map +2 -2
- package/build/cover/embed-video-utils.js +151 -0
- package/build/cover/embed-video-utils.js.map +7 -0
- package/build/cover/index.js +10 -4
- package/build/cover/index.js.map +3 -3
- package/build/cover/save.js +12 -0
- package/build/cover/save.js.map +2 -2
- package/build/cover/shared.js +3 -0
- package/build/cover/shared.js.map +2 -2
- package/build/details/index.js +9 -6
- package/build/details/index.js.map +3 -3
- package/build/file/index.js +14 -14
- package/build/file/index.js.map +3 -3
- package/build/freeform/block.json +1 -1
- package/build/gallery/edit.js +0 -2
- package/build/gallery/edit.js.map +2 -2
- package/build/heading/index.js +9 -6
- package/build/heading/index.js.map +3 -3
- package/build/html/modal.js +127 -118
- package/build/html/modal.js.map +3 -3
- package/build/image/edit.js +0 -1
- package/build/image/edit.js.map +2 -2
- package/build/image/image.js +0 -1
- package/build/image/image.js.map +2 -2
- package/build/image/index.js +18 -18
- package/build/image/index.js.map +3 -3
- package/build/list-item/index.js +8 -6
- package/build/list-item/index.js.map +3 -3
- package/build/math/block.json +28 -1
- package/build/math/edit.js +4 -1
- package/build/math/edit.js.map +2 -2
- package/build/media-text/index.js +15 -8
- package/build/media-text/index.js.map +3 -3
- package/build/media-text/media-container.js +0 -2
- package/build/media-text/media-container.js.map +2 -2
- package/build/missing/block.json +1 -1
- package/build/missing/edit.js +2 -2
- package/build/missing/edit.js.map +1 -1
- package/build/more/index.js +9 -6
- package/build/more/index.js.map +3 -3
- package/build/navigation-link/edit.js +36 -11
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +11 -8
- package/build/navigation-link/index.js.map +3 -3
- package/build/navigation-submenu/index.js +11 -8
- package/build/navigation-submenu/index.js.map +3 -3
- package/build/paragraph/deprecated-attributes.js +68 -0
- package/build/paragraph/deprecated-attributes.js.map +7 -0
- package/build/paragraph/edit.js +2 -0
- package/build/paragraph/edit.js.map +3 -3
- package/build/paragraph/index.js +9 -6
- package/build/paragraph/index.js.map +3 -3
- package/build/pattern/block.json +1 -1
- package/build/preformatted/index.js +9 -6
- package/build/preformatted/index.js.map +3 -3
- package/build/pullquote/index.js +11 -11
- package/build/pullquote/index.js.map +3 -3
- package/build/search/index.js +14 -16
- package/build/search/index.js.map +3 -3
- package/build/social-link/index.js +11 -8
- package/build/social-link/index.js.map +3 -3
- package/build/template-part/edit/index.js +37 -7
- package/build/template-part/edit/index.js.map +2 -2
- package/build/template-part/edit/utils/hooks.js +2 -3
- package/build/template-part/edit/utils/hooks.js.map +2 -2
- package/build/term-count/index.js +1 -0
- package/build/term-count/index.js.map +2 -2
- package/build/term-name/index.js +1 -0
- package/build/term-name/index.js.map +2 -2
- package/build/verse/index.js +9 -6
- package/build/verse/index.js.map +3 -3
- package/build/video/index.js +12 -9
- package/build/video/index.js.map +3 -3
- package/build-module/accordion/view.js +46 -4
- package/build-module/accordion/view.js.map +2 -2
- package/build-module/accordion-heading/block.json +1 -1
- package/build-module/accordion-heading/deprecated.js +1 -1
- package/build-module/accordion-heading/deprecated.js.map +2 -2
- package/build-module/accordion-panel/block.json +1 -1
- package/build-module/audio/index.js +12 -9
- package/build-module/audio/index.js.map +2 -2
- package/build-module/button/index.js +13 -10
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +9 -6
- package/build-module/code/index.js.map +2 -2
- package/build-module/cover/edit/block-controls.js +27 -3
- package/build-module/cover/edit/block-controls.js.map +2 -2
- package/build-module/cover/edit/cover-placeholder.js +0 -1
- package/build-module/cover/edit/cover-placeholder.js.map +2 -2
- package/build-module/cover/edit/embed-video-url-input.js +67 -0
- package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
- package/build-module/cover/edit/index.js +61 -0
- package/build-module/cover/edit/index.js.map +2 -2
- package/build-module/cover/embed-video-utils.js +122 -0
- package/build-module/cover/embed-video-utils.js.map +7 -0
- package/build-module/cover/index.js +10 -4
- package/build-module/cover/index.js.map +2 -2
- package/build-module/cover/save.js +13 -0
- package/build-module/cover/save.js.map +2 -2
- package/build-module/cover/shared.js +2 -0
- package/build-module/cover/shared.js.map +2 -2
- package/build-module/details/index.js +9 -6
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +14 -14
- package/build-module/file/index.js.map +2 -2
- package/build-module/freeform/block.json +1 -1
- package/build-module/gallery/edit.js +0 -2
- package/build-module/gallery/edit.js.map +2 -2
- package/build-module/heading/index.js +9 -6
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +128 -119
- package/build-module/html/modal.js.map +2 -2
- package/build-module/image/edit.js +0 -1
- package/build-module/image/edit.js.map +2 -2
- package/build-module/image/image.js +0 -1
- package/build-module/image/image.js.map +2 -2
- package/build-module/image/index.js +18 -18
- package/build-module/image/index.js.map +2 -2
- package/build-module/list-item/index.js +8 -6
- package/build-module/list-item/index.js.map +2 -2
- package/build-module/math/block.json +28 -1
- package/build-module/math/edit.js +4 -1
- package/build-module/math/edit.js.map +2 -2
- package/build-module/media-text/index.js +15 -8
- package/build-module/media-text/index.js.map +2 -2
- package/build-module/media-text/media-container.js +0 -2
- package/build-module/media-text/media-container.js.map +2 -2
- package/build-module/missing/block.json +1 -1
- package/build-module/missing/edit.js +2 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/more/index.js +9 -6
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation-link/edit.js +37 -12
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +11 -8
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-submenu/index.js +11 -8
- package/build-module/navigation-submenu/index.js.map +2 -2
- package/build-module/paragraph/deprecated-attributes.js +37 -0
- package/build-module/paragraph/deprecated-attributes.js.map +7 -0
- package/build-module/paragraph/edit.js +2 -0
- package/build-module/paragraph/edit.js.map +2 -2
- package/build-module/paragraph/index.js +9 -6
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/pattern/block.json +1 -1
- package/build-module/preformatted/index.js +9 -6
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/index.js +11 -11
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/search/index.js +14 -16
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +11 -8
- package/build-module/social-link/index.js.map +2 -2
- package/build-module/template-part/edit/index.js +37 -7
- package/build-module/template-part/edit/index.js.map +2 -2
- package/build-module/template-part/edit/utils/hooks.js +2 -3
- package/build-module/template-part/edit/utils/hooks.js.map +2 -2
- package/build-module/term-count/index.js +1 -0
- package/build-module/term-count/index.js.map +2 -2
- package/build-module/term-name/index.js +1 -0
- package/build-module/term-name/index.js.map +2 -2
- package/build-module/verse/index.js +9 -6
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +12 -9
- package/build-module/video/index.js.map +2 -2
- package/build-style/accordion/style-rtl.css +3 -0
- package/build-style/accordion/style.css +3 -0
- package/build-style/accordion-heading/style-rtl.css +1 -2
- package/build-style/accordion-heading/style.css +1 -2
- package/build-style/accordion-item/style-rtl.css +0 -7
- package/build-style/accordion-item/style.css +0 -7
- package/build-style/accordion-panel/style-rtl.css +1 -4
- package/build-style/accordion-panel/style.css +1 -4
- package/build-style/cover/style-rtl.css +47 -0
- package/build-style/cover/style.css +47 -0
- package/build-style/editor-rtl.css +11 -13
- package/build-style/editor.css +11 -13
- package/build-style/html/editor-rtl.css +11 -13
- package/build-style/html/editor.css +11 -13
- package/build-style/style-rtl.css +52 -12
- package/build-style/style.css +52 -12
- package/package.json +37 -37
- package/src/accordion/style.scss +4 -0
- package/src/accordion/view.js +60 -3
- package/src/accordion-heading/block.json +1 -1
- package/src/accordion-heading/deprecated.js +1 -1
- package/src/accordion-heading/style.scss +1 -9
- package/src/accordion-item/index.php +1 -0
- package/src/accordion-item/style.scss +2 -9
- package/src/accordion-panel/block.json +1 -1
- package/src/accordion-panel/style.scss +1 -5
- package/src/audio/index.js +13 -9
- package/src/breadcrumbs/index.php +71 -82
- package/src/button/index.js +14 -10
- package/src/code/index.js +10 -6
- package/src/cover/edit/block-controls.js +26 -2
- package/src/cover/edit/cover-placeholder.js +0 -1
- package/src/cover/edit/embed-video-url-input.js +74 -0
- package/src/cover/edit/index.js +81 -0
- package/src/cover/embed-video-utils.js +196 -0
- package/src/cover/index.js +11 -4
- package/src/cover/index.php +106 -0
- package/src/cover/save.js +14 -0
- package/src/cover/shared.js +1 -0
- package/src/cover/style.scss +47 -0
- package/src/details/index.js +10 -6
- package/src/file/index.js +15 -14
- package/src/freeform/block.json +1 -1
- package/src/gallery/edit.js +0 -2
- package/src/heading/index.js +10 -6
- package/src/html/editor.scss +10 -15
- package/src/html/modal.js +15 -10
- package/src/image/edit.js +0 -1
- package/src/image/image.js +0 -1
- package/src/image/index.js +19 -18
- package/src/image/index.php +1 -0
- package/src/list-item/index.js +9 -6
- package/src/math/block.json +28 -1
- package/src/math/edit.js +4 -1
- package/src/media-text/index.js +16 -8
- package/src/media-text/media-container.js +0 -2
- package/src/missing/block.json +1 -1
- package/src/missing/edit.js +2 -2
- package/src/more/index.js +10 -6
- package/src/navigation-link/edit.js +72 -26
- package/src/navigation-link/index.js +12 -8
- package/src/navigation-submenu/index.js +12 -8
- package/src/paragraph/deprecated-attributes.js +45 -0
- package/src/paragraph/edit.js +2 -0
- package/src/paragraph/index.js +10 -6
- package/src/pattern/block.json +1 -1
- package/src/preformatted/index.js +10 -6
- package/src/pullquote/index.js +12 -11
- package/src/search/index.js +14 -15
- package/src/social-link/index.js +12 -8
- package/src/style.scss +1 -0
- package/src/template-part/edit/index.js +44 -6
- package/src/template-part/edit/utils/hooks.js +2 -4
- package/src/term-count/index.js +1 -0
- package/src/term-name/index.js +1 -0
- package/src/verse/index.js +10 -6
- package/src/video/index.js +13 -9
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// potentially applying relatively high specificity (such as `0-1-1`) to
|
|
3
|
-
// heading elements. To properly override those styles, use a selector
|
|
4
|
-
// with a specificity of `0-2-0`.
|
|
5
|
-
.wp-block-accordion-heading.wp-block-accordion-heading {
|
|
6
|
-
// Some themes may have an explicit width. Since it's unpredictable
|
|
7
|
-
// what CSS specificity should be used to override them, ensure 100%
|
|
8
|
-
// width using min-width instead.
|
|
9
|
-
min-width: 100%;
|
|
1
|
+
.wp-block-accordion-heading {
|
|
10
2
|
// Some classic themes apply default margins to heading elements,
|
|
11
3
|
// so those styles need to be reset.
|
|
12
4
|
margin: 0;
|
|
@@ -36,6 +36,7 @@ function block_core_accordion_item_render( $attributes, $content ) {
|
|
|
36
36
|
$p->set_attribute( 'data-wp-context', '{ "id": "' . $unique_id . '", "openByDefault": ' . $open_by_default . ' }' );
|
|
37
37
|
$p->set_attribute( 'data-wp-class--is-open', 'state.isOpen' );
|
|
38
38
|
$p->set_attribute( 'data-wp-init', 'callbacks.initAccordionItems' );
|
|
39
|
+
$p->set_attribute( 'data-wp-on-window--hashchange', 'callbacks.hashChange' );
|
|
39
40
|
|
|
40
41
|
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-heading__toggle' ) ) ) {
|
|
41
42
|
$p->set_attribute( 'data-wp-on--click', 'actions.toggle' );
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
.wp-block-accordion-item {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
&.is-open {
|
|
6
|
-
grid-template-rows: max-content 1fr;
|
|
7
|
-
|
|
8
|
-
> .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
|
|
9
|
-
transform: rotate(45deg);
|
|
10
|
-
}
|
|
2
|
+
&.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
|
|
3
|
+
transform: rotate(45deg);
|
|
11
4
|
}
|
|
12
5
|
|
|
13
6
|
/* Add transitions only for users who do not prefer reduced motion */
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// and apply some kind of width to the blocks. To properly override
|
|
3
|
-
// those styles, use a selector with a specificity of `0-2-0`.
|
|
4
|
-
.wp-block-accordion-panel.wp-block-accordion-panel {
|
|
5
|
-
min-width: 100%;
|
|
1
|
+
.wp-block-accordion-panel {
|
|
6
2
|
|
|
7
3
|
// Prevent blockGap from Accordion Content block from adding extra margin between accordions.
|
|
8
4
|
&[inert],
|
package/src/audio/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { audio as icon } from '@wordpress/icons';
|
|
6
|
+
import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -13,6 +14,9 @@ import edit from './edit';
|
|
|
13
14
|
import metadata from './block.json';
|
|
14
15
|
import save from './save';
|
|
15
16
|
import transforms from './transforms';
|
|
17
|
+
import { unlock } from '../lock-unlock';
|
|
18
|
+
|
|
19
|
+
const { fieldsKey, formKey } = unlock( blocksPrivateApis );
|
|
16
20
|
|
|
17
21
|
const { name } = metadata;
|
|
18
22
|
|
|
@@ -33,14 +37,14 @@ export const settings = {
|
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
36
|
-
settings
|
|
40
|
+
settings[ fieldsKey ] = [
|
|
37
41
|
{
|
|
42
|
+
id: 'audio',
|
|
38
43
|
label: __( 'Audio' ),
|
|
39
|
-
type: '
|
|
40
|
-
shownByDefault: true,
|
|
44
|
+
type: 'media',
|
|
41
45
|
mapping: {
|
|
42
46
|
id: 'id',
|
|
43
|
-
|
|
47
|
+
url: 'src',
|
|
44
48
|
},
|
|
45
49
|
args: {
|
|
46
50
|
allowedTypes: [ 'audio' ],
|
|
@@ -48,14 +52,14 @@ if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
|
48
52
|
},
|
|
49
53
|
},
|
|
50
54
|
{
|
|
55
|
+
id: 'caption',
|
|
51
56
|
label: __( 'Caption' ),
|
|
52
|
-
type: '
|
|
53
|
-
shownByDefault: false,
|
|
54
|
-
mapping: {
|
|
55
|
-
value: 'caption',
|
|
56
|
-
},
|
|
57
|
+
type: 'richtext',
|
|
57
58
|
},
|
|
58
59
|
];
|
|
60
|
+
settings[ formKey ] = {
|
|
61
|
+
fields: [ 'audio' ],
|
|
62
|
+
};
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -26,9 +26,9 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
|
|
|
26
26
|
|
|
27
27
|
if ( $attributes['showHomeLink'] ) {
|
|
28
28
|
if ( ! $is_home_or_front_page ) {
|
|
29
|
-
$breadcrumb_items[] =
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
$breadcrumb_items[] = array(
|
|
30
|
+
'label' => __( 'Home' ),
|
|
31
|
+
'url' => home_url( '/' ),
|
|
32
32
|
);
|
|
33
33
|
} else {
|
|
34
34
|
$breadcrumb_items[] = block_core_breadcrumbs_create_item( __( 'Home' ), block_core_breadcrumbs_is_paged() );
|
|
@@ -53,8 +53,8 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
|
|
|
53
53
|
}
|
|
54
54
|
} elseif ( is_404() ) {
|
|
55
55
|
// Handle 404 pages.
|
|
56
|
-
$breadcrumb_items[] =
|
|
57
|
-
__( 'Page not found' )
|
|
56
|
+
$breadcrumb_items[] = array(
|
|
57
|
+
'label' => __( 'Page not found' ),
|
|
58
58
|
);
|
|
59
59
|
} elseif ( is_archive() ) {
|
|
60
60
|
// Handle archive pages (taxonomy, post type, date, author archives).
|
|
@@ -100,7 +100,23 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
|
|
|
100
100
|
$show_terms = $attributes['prefersTaxonomy'];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
//
|
|
103
|
+
// Add post type archive link if applicable.
|
|
104
|
+
$post_type_object = get_post_type_object( $post_type );
|
|
105
|
+
$archive_link = get_post_type_archive_link( $post_type );
|
|
106
|
+
if ( $archive_link && untrailingslashit( home_url() ) !== untrailingslashit( $archive_link ) ) {
|
|
107
|
+
$label = $post_type_object->labels->archives;
|
|
108
|
+
if ( 'post' === $post_type ) {
|
|
109
|
+
$page_for_posts = get_option( 'page_for_posts' );
|
|
110
|
+
if ( $page_for_posts ) {
|
|
111
|
+
$label = block_core_breadcrumbs_get_post_title( $page_for_posts );
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
$breadcrumb_items[] = array(
|
|
115
|
+
'label' => $label,
|
|
116
|
+
'url' => $archive_link,
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
// Build breadcrumb trail based on hierarchical structure or taxonomy terms.
|
|
104
120
|
if ( ! $show_terms ) {
|
|
105
121
|
$breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
|
|
106
122
|
} else {
|
|
@@ -112,17 +128,17 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
|
|
|
112
128
|
$title = block_core_breadcrumbs_get_post_title( $post );
|
|
113
129
|
|
|
114
130
|
if ( $is_paged ) {
|
|
115
|
-
$breadcrumb_items[] =
|
|
116
|
-
|
|
117
|
-
$
|
|
118
|
-
true
|
|
131
|
+
$breadcrumb_items[] = array(
|
|
132
|
+
'label' => $title,
|
|
133
|
+
'url' => get_permalink( $post ),
|
|
134
|
+
'allow_html' => true,
|
|
119
135
|
);
|
|
120
136
|
|
|
121
137
|
$breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
|
|
122
138
|
} else {
|
|
123
|
-
$breadcrumb_items[] =
|
|
124
|
-
$title,
|
|
125
|
-
true
|
|
139
|
+
$breadcrumb_items[] = array(
|
|
140
|
+
'label' => $title,
|
|
141
|
+
'allow_html' => true,
|
|
126
142
|
);
|
|
127
143
|
}
|
|
128
144
|
}
|
|
@@ -150,7 +166,11 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
|
|
|
150
166
|
'',
|
|
151
167
|
array_map(
|
|
152
168
|
static function ( $item ) {
|
|
153
|
-
|
|
169
|
+
$label = ! empty( $item['allow_html'] ) ? wp_kses_post( $item['label'] ) : esc_html( $item['label'] );
|
|
170
|
+
if ( ! empty( $item['url'] ) ) {
|
|
171
|
+
return '<li><a href="' . esc_url( $item['url'] ) . '">' . $label . '</a></li>';
|
|
172
|
+
}
|
|
173
|
+
return '<li><span aria-current="page">' . $label . '</span></li>';
|
|
154
174
|
},
|
|
155
175
|
$breadcrumb_items
|
|
156
176
|
)
|
|
@@ -177,52 +197,20 @@ function block_core_breadcrumbs_is_paged() {
|
|
|
177
197
|
*
|
|
178
198
|
* @since 7.0.0
|
|
179
199
|
* @param string $query_var Optional. Query variable to get current page number. Default 'paged'.
|
|
180
|
-
* @return
|
|
200
|
+
* @return array The "Page X" breadcrumb item data.
|
|
181
201
|
*/
|
|
182
202
|
function block_core_breadcrumbs_create_page_number_item( $query_var = 'paged' ) {
|
|
183
203
|
$paged = (int) get_query_var( $query_var );
|
|
184
204
|
|
|
185
|
-
return
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Creates a breadcrumb link item.
|
|
193
|
-
*
|
|
194
|
-
* @since 7.0.0
|
|
195
|
-
*
|
|
196
|
-
* @param string $url The URL for the link (will be escaped).
|
|
197
|
-
* @param string $text The link text (will be escaped).
|
|
198
|
-
* @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
|
|
199
|
-
*
|
|
200
|
-
* @return string The breadcrumb link HTML.
|
|
201
|
-
*/
|
|
202
|
-
function block_core_breadcrumbs_create_link( $url, $text, $allow_html = false ) {
|
|
203
|
-
return sprintf(
|
|
204
|
-
'<a href="%s">%s</a>',
|
|
205
|
-
esc_url( $url ),
|
|
206
|
-
$allow_html ? wp_kses_post( $text ) : esc_html( $text )
|
|
205
|
+
return array(
|
|
206
|
+
'label' => sprintf(
|
|
207
|
+
/* translators: %s: page number */
|
|
208
|
+
__( 'Page %s' ),
|
|
209
|
+
number_format_i18n( $paged )
|
|
210
|
+
),
|
|
207
211
|
);
|
|
208
212
|
}
|
|
209
213
|
|
|
210
|
-
/**
|
|
211
|
-
* Creates a breadcrumb current page item.
|
|
212
|
-
*
|
|
213
|
-
* @since 7.0.0
|
|
214
|
-
*
|
|
215
|
-
* @param string $text The text content (will be escaped).
|
|
216
|
-
* @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
|
|
217
|
-
*
|
|
218
|
-
* @return string The breadcrumb current page HTML.
|
|
219
|
-
*/
|
|
220
|
-
function block_core_breadcrumbs_create_current_item( $text, $allow_html = false ) {
|
|
221
|
-
return sprintf(
|
|
222
|
-
'<span aria-current="page">%s</span>',
|
|
223
|
-
$allow_html ? wp_kses_post( $text ) : esc_html( $text )
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
214
|
|
|
227
215
|
/**
|
|
228
216
|
* Creates a breadcrumb item that's either a link or current page item.
|
|
@@ -232,17 +220,17 @@ function block_core_breadcrumbs_create_current_item( $text, $allow_html = false
|
|
|
232
220
|
*
|
|
233
221
|
* @since 7.0.0
|
|
234
222
|
*
|
|
235
|
-
* @param string $text The text content
|
|
223
|
+
* @param string $text The text content.
|
|
236
224
|
* @param bool $is_paged Whether we're on a paginated view.
|
|
237
|
-
* @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
|
|
238
225
|
*
|
|
239
|
-
* @return
|
|
226
|
+
* @return array The breadcrumb item data.
|
|
240
227
|
*/
|
|
241
|
-
function block_core_breadcrumbs_create_item( $text, $is_paged = false
|
|
228
|
+
function block_core_breadcrumbs_create_item( $text, $is_paged = false ) {
|
|
229
|
+
$item = array( 'label' => $text );
|
|
242
230
|
if ( $is_paged ) {
|
|
243
|
-
|
|
231
|
+
$item['url'] = get_pagenum_link( 1 );
|
|
244
232
|
}
|
|
245
|
-
return
|
|
233
|
+
return $item;
|
|
246
234
|
}
|
|
247
235
|
|
|
248
236
|
/**
|
|
@@ -267,9 +255,9 @@ function block_core_breadcrumbs_get_post_title( $post_id_or_object ) {
|
|
|
267
255
|
*
|
|
268
256
|
* @since 7.0.0
|
|
269
257
|
*
|
|
270
|
-
* @param int
|
|
258
|
+
* @param int $post_id The post ID.
|
|
271
259
|
*
|
|
272
|
-
* @return array Array of breadcrumb
|
|
260
|
+
* @return array Array of breadcrumb item data.
|
|
273
261
|
*/
|
|
274
262
|
function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) {
|
|
275
263
|
$breadcrumb_items = array();
|
|
@@ -277,10 +265,10 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
|
|
|
277
265
|
$ancestors = array_reverse( $ancestors );
|
|
278
266
|
|
|
279
267
|
foreach ( $ancestors as $ancestor_id ) {
|
|
280
|
-
$breadcrumb_items[] =
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
true
|
|
268
|
+
$breadcrumb_items[] = array(
|
|
269
|
+
'label' => block_core_breadcrumbs_get_post_title( $ancestor_id ),
|
|
270
|
+
'url' => get_permalink( $ancestor_id ),
|
|
271
|
+
'allow_html' => true,
|
|
284
272
|
);
|
|
285
273
|
}
|
|
286
274
|
return $breadcrumb_items;
|
|
@@ -296,7 +284,7 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
|
|
|
296
284
|
* @param int $term_id The term ID.
|
|
297
285
|
* @param string $taxonomy The taxonomy name.
|
|
298
286
|
*
|
|
299
|
-
* @return array Array of breadcrumb
|
|
287
|
+
* @return array Array of breadcrumb item data for ancestors.
|
|
300
288
|
*/
|
|
301
289
|
function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
|
|
302
290
|
$breadcrumb_items = array();
|
|
@@ -308,9 +296,9 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
|
|
|
308
296
|
foreach ( $term_ancestors as $ancestor_id ) {
|
|
309
297
|
$ancestor_term = get_term( $ancestor_id, $taxonomy );
|
|
310
298
|
if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
|
|
311
|
-
$breadcrumb_items[] =
|
|
312
|
-
|
|
313
|
-
$ancestor_term
|
|
299
|
+
$breadcrumb_items[] = array(
|
|
300
|
+
'label' => $ancestor_term->name,
|
|
301
|
+
'url' => get_term_link( $ancestor_term ),
|
|
314
302
|
);
|
|
315
303
|
}
|
|
316
304
|
}
|
|
@@ -327,7 +315,7 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
|
|
|
327
315
|
*
|
|
328
316
|
* @since 7.0.0
|
|
329
317
|
*
|
|
330
|
-
* @return array Array of breadcrumb
|
|
318
|
+
* @return array Array of breadcrumb item data.
|
|
331
319
|
*/
|
|
332
320
|
function block_core_breadcrumbs_get_archive_breadcrumbs() {
|
|
333
321
|
$breadcrumb_items = array();
|
|
@@ -354,16 +342,16 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
|
|
|
354
342
|
if ( $year ) {
|
|
355
343
|
if ( $month ) {
|
|
356
344
|
// Year is linked if we have month.
|
|
357
|
-
$breadcrumb_items[] =
|
|
358
|
-
|
|
359
|
-
$year
|
|
345
|
+
$breadcrumb_items[] = array(
|
|
346
|
+
'label' => $year,
|
|
347
|
+
'url' => get_year_link( $year ),
|
|
360
348
|
);
|
|
361
349
|
|
|
362
350
|
if ( $day ) {
|
|
363
351
|
// Month is linked if we have day.
|
|
364
|
-
$breadcrumb_items[] =
|
|
365
|
-
|
|
366
|
-
|
|
352
|
+
$breadcrumb_items[] = array(
|
|
353
|
+
'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
|
|
354
|
+
'url' => get_month_link( $year, $month ),
|
|
367
355
|
);
|
|
368
356
|
// Add day (current if not paginated, link if paginated).
|
|
369
357
|
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
|
|
@@ -429,7 +417,7 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
|
|
|
429
417
|
if ( $post_type_object ) {
|
|
430
418
|
// Add post type (current if not paginated, link if paginated).
|
|
431
419
|
$breadcrumb_items[] = block_core_breadcrumbs_create_item(
|
|
432
|
-
$post_type_object->labels->
|
|
420
|
+
$post_type_object->labels->archives,
|
|
433
421
|
$is_paged
|
|
434
422
|
);
|
|
435
423
|
}
|
|
@@ -462,10 +450,11 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
|
|
|
462
450
|
* @param int $post_id The post ID.
|
|
463
451
|
* @param string $post_type The post type name.
|
|
464
452
|
*
|
|
465
|
-
* @return array Array of breadcrumb
|
|
453
|
+
* @return array Array of breadcrumb item data.
|
|
466
454
|
*/
|
|
467
455
|
function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
|
|
468
456
|
$breadcrumb_items = array();
|
|
457
|
+
|
|
469
458
|
// Get public taxonomies for this post type.
|
|
470
459
|
$taxonomies = wp_filter_object_list(
|
|
471
460
|
get_object_taxonomies( $post_type, 'objects' ),
|
|
@@ -476,7 +465,7 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
|
|
|
476
465
|
);
|
|
477
466
|
|
|
478
467
|
if ( empty( $taxonomies ) ) {
|
|
479
|
-
return
|
|
468
|
+
return $breadcrumb_items;
|
|
480
469
|
}
|
|
481
470
|
|
|
482
471
|
/**
|
|
@@ -550,9 +539,9 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
|
|
|
550
539
|
$breadcrumb_items,
|
|
551
540
|
block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
|
|
552
541
|
);
|
|
553
|
-
$breadcrumb_items[] =
|
|
554
|
-
|
|
555
|
-
$term
|
|
542
|
+
$breadcrumb_items[] = array(
|
|
543
|
+
'label' => $term->name,
|
|
544
|
+
'url' => get_term_link( $term ),
|
|
556
545
|
);
|
|
557
546
|
}
|
|
558
547
|
return $breadcrumb_items;
|
package/src/button/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { button as icon } from '@wordpress/icons';
|
|
6
|
+
import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -12,6 +13,9 @@ import deprecated from './deprecated';
|
|
|
12
13
|
import edit from './edit';
|
|
13
14
|
import metadata from './block.json';
|
|
14
15
|
import save from './save';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
17
|
+
|
|
18
|
+
const { fieldsKey, formKey } = unlock( blocksPrivateApis );
|
|
15
19
|
|
|
16
20
|
const { name } = metadata;
|
|
17
21
|
|
|
@@ -35,26 +39,26 @@ export const settings = {
|
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
38
|
-
settings
|
|
42
|
+
settings[ fieldsKey ] = [
|
|
39
43
|
{
|
|
44
|
+
id: 'text',
|
|
40
45
|
label: __( 'Content' ),
|
|
41
|
-
type: '
|
|
42
|
-
shownByDefault: true,
|
|
43
|
-
mapping: {
|
|
44
|
-
value: 'text',
|
|
45
|
-
},
|
|
46
|
+
type: 'richtext',
|
|
46
47
|
},
|
|
47
48
|
{
|
|
49
|
+
id: 'link',
|
|
48
50
|
label: __( 'Link' ),
|
|
49
|
-
type: '
|
|
50
|
-
shownByDefault: false,
|
|
51
|
+
type: 'link',
|
|
51
52
|
mapping: {
|
|
52
|
-
|
|
53
|
+
url: 'url',
|
|
53
54
|
rel: 'rel',
|
|
54
|
-
|
|
55
|
+
linkTarget: 'linkTarget',
|
|
55
56
|
},
|
|
56
57
|
},
|
|
57
58
|
];
|
|
59
|
+
settings[ formKey ] = {
|
|
60
|
+
fields: [ 'text' ],
|
|
61
|
+
};
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/code/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { code as icon } from '@wordpress/icons';
|
|
6
|
+
import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -12,6 +13,9 @@ import edit from './edit';
|
|
|
12
13
|
import metadata from './block.json';
|
|
13
14
|
import save from './save';
|
|
14
15
|
import transforms from './transforms';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
17
|
+
|
|
18
|
+
const { fieldsKey, formKey } = unlock( blocksPrivateApis );
|
|
15
19
|
|
|
16
20
|
const { name } = metadata;
|
|
17
21
|
|
|
@@ -40,16 +44,16 @@ export const settings = {
|
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
43
|
-
settings
|
|
47
|
+
settings[ fieldsKey ] = [
|
|
44
48
|
{
|
|
49
|
+
id: 'content',
|
|
45
50
|
label: __( 'Code' ),
|
|
46
|
-
type: '
|
|
47
|
-
shownByDefault: true,
|
|
48
|
-
mapping: {
|
|
49
|
-
value: 'content',
|
|
50
|
-
},
|
|
51
|
+
type: 'richtext',
|
|
51
52
|
},
|
|
52
53
|
];
|
|
54
|
+
settings[ formKey ] = {
|
|
55
|
+
fields: [ 'content' ],
|
|
56
|
+
};
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -11,12 +11,15 @@ import {
|
|
|
11
11
|
privateApis as blockEditorPrivateApis,
|
|
12
12
|
} from '@wordpress/block-editor';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { MenuItem } from '@wordpress/components';
|
|
15
|
+
import { link } from '@wordpress/icons';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Internal dependencies
|
|
17
19
|
*/
|
|
18
20
|
import { ALLOWED_MEDIA_TYPES } from '../shared';
|
|
19
21
|
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import EmbedVideoUrlInput from './embed-video-url-input';
|
|
20
23
|
|
|
21
24
|
const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
|
|
22
25
|
|
|
@@ -27,6 +30,7 @@ export default function CoverBlockControls( {
|
|
|
27
30
|
currentSettings,
|
|
28
31
|
toggleUseFeaturedImage,
|
|
29
32
|
onClearMedia,
|
|
33
|
+
onSelectEmbedUrl,
|
|
30
34
|
blockEditingMode,
|
|
31
35
|
} ) {
|
|
32
36
|
const { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =
|
|
@@ -36,6 +40,7 @@ export default function CoverBlockControls( {
|
|
|
36
40
|
const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
|
|
37
41
|
const [ prevMinHeightUnit, setPrevMinHeightUnit ] =
|
|
38
42
|
useState( minHeightUnit );
|
|
43
|
+
const [ isEmbedUrlInputOpen, setIsEmbedUrlInputOpen ] = useState( false );
|
|
39
44
|
const isMinFullHeight =
|
|
40
45
|
minHeightUnit === 'vh' &&
|
|
41
46
|
minHeight === 100 &&
|
|
@@ -102,14 +107,33 @@ export default function CoverBlockControls( {
|
|
|
102
107
|
mediaId={ id }
|
|
103
108
|
mediaURL={ url }
|
|
104
109
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
105
|
-
accept="image/*,video/*"
|
|
106
110
|
onSelect={ onSelectMedia }
|
|
107
111
|
onToggleFeaturedImage={ toggleUseFeaturedImage }
|
|
108
112
|
useFeaturedImage={ useFeaturedImage }
|
|
109
113
|
name={ ! url ? __( 'Add media' ) : __( 'Replace' ) }
|
|
110
114
|
onReset={ onClearMedia }
|
|
111
|
-
|
|
115
|
+
>
|
|
116
|
+
{ ( { onClose } ) => (
|
|
117
|
+
<MenuItem
|
|
118
|
+
icon={ link }
|
|
119
|
+
onClick={ () => {
|
|
120
|
+
setIsEmbedUrlInputOpen( true );
|
|
121
|
+
onClose();
|
|
122
|
+
} }
|
|
123
|
+
>
|
|
124
|
+
{ __( 'Embed video from URL' ) }
|
|
125
|
+
</MenuItem>
|
|
126
|
+
) }
|
|
127
|
+
</MediaReplaceFlow>
|
|
112
128
|
</BlockControls>
|
|
129
|
+
{ isEmbedUrlInputOpen && (
|
|
130
|
+
<EmbedVideoUrlInput
|
|
131
|
+
onSubmit={ ( embedUrl ) => {
|
|
132
|
+
onSelectEmbedUrl( embedUrl );
|
|
133
|
+
} }
|
|
134
|
+
onClose={ () => setIsEmbedUrlInputOpen( false ) }
|
|
135
|
+
/>
|
|
136
|
+
) }
|
|
113
137
|
</>
|
|
114
138
|
);
|
|
115
139
|
}
|
|
@@ -25,7 +25,6 @@ export default function CoverPlaceholder( {
|
|
|
25
25
|
title: __( 'Cover' ),
|
|
26
26
|
} }
|
|
27
27
|
onSelect={ onSelectMedia }
|
|
28
|
-
accept="image/*,video/*"
|
|
29
28
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
30
29
|
disableMediaButtons={ disableMediaButtons }
|
|
31
30
|
onToggleFeaturedImage={ toggleUseFeaturedImage }
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalConfirmDialog as ConfirmDialog,
|
|
7
|
+
__experimentalVStack as VStack,
|
|
8
|
+
TextControl,
|
|
9
|
+
Notice,
|
|
10
|
+
} from '@wordpress/components';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { isValidVideoEmbedUrl } from '../embed-video-utils';
|
|
17
|
+
|
|
18
|
+
export default function EmbedVideoUrlInput( { onSubmit, onClose } ) {
|
|
19
|
+
const [ url, setUrl ] = useState( '' );
|
|
20
|
+
const [ error, setError ] = useState( '' );
|
|
21
|
+
|
|
22
|
+
const handleConfirm = () => {
|
|
23
|
+
if ( ! url ) {
|
|
24
|
+
setError( __( 'Please enter a URL.' ) );
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if ( ! isValidVideoEmbedUrl( url ) ) {
|
|
29
|
+
setError(
|
|
30
|
+
__(
|
|
31
|
+
'This URL is not supported. Please enter a valid video link from a supported provider.'
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onSubmit( url );
|
|
38
|
+
onClose();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<ConfirmDialog
|
|
43
|
+
isOpen
|
|
44
|
+
onConfirm={ handleConfirm }
|
|
45
|
+
onCancel={ onClose }
|
|
46
|
+
confirmButtonText={ __( 'Add video' ) }
|
|
47
|
+
size="medium"
|
|
48
|
+
>
|
|
49
|
+
<VStack spacing={ 4 }>
|
|
50
|
+
{ error && (
|
|
51
|
+
<Notice status="error" isDismissible={ false }>
|
|
52
|
+
{ error }
|
|
53
|
+
</Notice>
|
|
54
|
+
) }
|
|
55
|
+
<TextControl
|
|
56
|
+
__next40pxDefaultSize
|
|
57
|
+
label={ __( 'Video URL' ) }
|
|
58
|
+
value={ url }
|
|
59
|
+
onChange={ ( value ) => {
|
|
60
|
+
setUrl( value );
|
|
61
|
+
setError( '' );
|
|
62
|
+
} }
|
|
63
|
+
placeholder={ __(
|
|
64
|
+
'Enter YouTube, Vimeo, or other video URL'
|
|
65
|
+
) }
|
|
66
|
+
__nextHasNoMarginBottom
|
|
67
|
+
help={ __(
|
|
68
|
+
'Add a background video to the cover block that will autoplay in a loop.'
|
|
69
|
+
) }
|
|
70
|
+
/>
|
|
71
|
+
</VStack>
|
|
72
|
+
</ConfirmDialog>
|
|
73
|
+
);
|
|
74
|
+
}
|