@wordpress/block-library 9.28.0 → 9.29.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/edit.js +123 -0
- package/build/accordion/edit.js.map +1 -0
- package/build/accordion/icon.js +33 -0
- package/build/accordion/icon.js.map +1 -0
- package/build/accordion/index.js +100 -0
- package/build/accordion/index.js.map +1 -0
- package/build/accordion/init.js +12 -0
- package/build/accordion/init.js.map +1 -0
- package/build/accordion/save.js +36 -0
- package/build/accordion/save.js.map +1 -0
- package/build/accordion/view.js +49 -0
- package/build/accordion/view.js.map +1 -0
- package/build/accordion-content/edit.js +129 -0
- package/build/accordion-content/edit.js.map +1 -0
- package/build/accordion-content/icon.js +35 -0
- package/build/accordion-content/icon.js.map +1 -0
- package/build/accordion-content/icons.js +30 -0
- package/build/accordion-content/icons.js.map +1 -0
- package/build/accordion-content/index.js +76 -0
- package/build/accordion-content/index.js.map +1 -0
- package/build/accordion-content/init.js +12 -0
- package/build/accordion-content/init.js.map +1 -0
- package/build/accordion-content/save.js +37 -0
- package/build/accordion-content/save.js.map +1 -0
- package/build/accordion-header/edit.js +118 -0
- package/build/accordion-header/edit.js.map +1 -0
- package/build/accordion-header/icon.js +25 -0
- package/build/accordion-header/icon.js.map +1 -0
- package/build/accordion-header/index.js +121 -0
- package/build/accordion-header/index.js.map +1 -0
- package/build/accordion-header/init.js +12 -0
- package/build/accordion-header/init.js.map +1 -0
- package/build/accordion-header/save.js +81 -0
- package/build/accordion-header/save.js.map +1 -0
- package/build/accordion-panel/edit.js +59 -0
- package/build/accordion-panel/edit.js.map +1 -0
- package/build/accordion-panel/icon.js +22 -0
- package/build/accordion-panel/icon.js.map +1 -0
- package/build/accordion-panel/index.js +105 -0
- package/build/accordion-panel/index.js.map +1 -0
- package/build/accordion-panel/init.js +12 -0
- package/build/accordion-panel/init.js.map +1 -0
- package/build/accordion-panel/save.js +46 -0
- package/build/accordion-panel/save.js.map +1 -0
- package/build/cover/index.js +2 -1
- package/build/cover/index.js.map +1 -1
- package/build/freeform/edit.js +6 -0
- package/build/freeform/edit.js.map +1 -1
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/media-text/media-container.js +2 -1
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/transforms.js +7 -3
- package/build/media-text/transforms.js.map +1 -1
- package/build/post-comments-link/edit.js +6 -1
- package/build/post-comments-link/edit.js.map +1 -1
- package/build/query-title/edit.js +52 -2
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +1 -0
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/use-post-type-label.js +42 -0
- package/build/query-title/use-post-type-label.js.map +1 -0
- package/build/query-title/variations.js +10 -0
- package/build/query-title/variations.js.map +1 -1
- package/build/site-logo/edit.js +56 -41
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/edit.js +9 -3
- package/build/site-title/edit.js.map +1 -1
- package/build/video/edit-common-settings.js +6 -3
- package/build/video/edit-common-settings.js.map +1 -1
- package/build-module/accordion/edit.js +116 -0
- package/build-module/accordion/edit.js.map +1 -0
- package/build-module/accordion/icon.js +27 -0
- package/build-module/accordion/icon.js.map +1 -0
- package/build-module/accordion/index.js +92 -0
- package/build-module/accordion/index.js.map +1 -0
- package/build-module/accordion/init.js +6 -0
- package/build-module/accordion/init.js.map +1 -0
- package/build-module/accordion/save.js +27 -0
- package/build-module/accordion/save.js.map +1 -0
- package/build-module/accordion/view.js +46 -0
- package/build-module/accordion/view.js.map +1 -0
- package/build-module/accordion-content/edit.js +120 -0
- package/build-module/accordion-content/edit.js.map +1 -0
- package/build-module/accordion-content/icon.js +29 -0
- package/build-module/accordion-content/icon.js.map +1 -0
- package/build-module/accordion-content/icons.js +22 -0
- package/build-module/accordion-content/icons.js.map +1 -0
- package/build-module/accordion-content/index.js +68 -0
- package/build-module/accordion-content/index.js.map +1 -0
- package/build-module/accordion-content/init.js +6 -0
- package/build-module/accordion-content/init.js.map +1 -0
- package/build-module/accordion-content/save.js +28 -0
- package/build-module/accordion-content/save.js.map +1 -0
- package/build-module/accordion-header/edit.js +108 -0
- package/build-module/accordion-header/edit.js.map +1 -0
- package/build-module/accordion-header/icon.js +19 -0
- package/build-module/accordion-header/icon.js.map +1 -0
- package/build-module/accordion-header/index.js +113 -0
- package/build-module/accordion-header/index.js.map +1 -0
- package/build-module/accordion-header/init.js +6 -0
- package/build-module/accordion-header/init.js.map +1 -0
- package/build-module/accordion-header/save.js +71 -0
- package/build-module/accordion-header/save.js.map +1 -0
- package/build-module/accordion-panel/edit.js +50 -0
- package/build-module/accordion-panel/edit.js.map +1 -0
- package/build-module/accordion-panel/icon.js +16 -0
- package/build-module/accordion-panel/icon.js.map +1 -0
- package/build-module/accordion-panel/index.js +97 -0
- package/build-module/accordion-panel/index.js.map +1 -0
- package/build-module/accordion-panel/init.js +6 -0
- package/build-module/accordion-panel/init.js.map +1 -0
- package/build-module/accordion-panel/save.js +37 -0
- package/build-module/accordion-panel/save.js.map +1 -0
- package/build-module/cover/index.js +2 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/freeform/edit.js +6 -0
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/index.js +10 -0
- package/build-module/index.js.map +1 -1
- package/build-module/media-text/media-container.js +2 -1
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/transforms.js +7 -3
- package/build-module/media-text/transforms.js.map +1 -1
- package/build-module/post-comments-link/edit.js +6 -1
- package/build-module/post-comments-link/edit.js.map +1 -1
- package/build-module/query-title/edit.js +52 -2
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +1 -0
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/use-post-type-label.js +36 -0
- package/build-module/query-title/use-post-type-label.js.map +1 -0
- package/build-module/query-title/variations.js +10 -0
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/site-logo/edit.js +57 -42
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/edit.js +10 -4
- package/build-module/site-title/edit.js.map +1 -1
- package/build-module/video/edit-common-settings.js +6 -3
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-style/accordion/style-rtl.css +223 -0
- package/build-style/accordion/style.css +223 -0
- package/build-style/style-rtl.css +88 -0
- package/build-style/style.css +88 -0
- package/package.json +36 -35
- package/src/accordion/block.json +69 -0
- package/src/accordion/edit.js +133 -0
- package/src/accordion/icon.js +23 -0
- package/src/accordion/index.js +21 -0
- package/src/accordion/index.php +61 -0
- package/src/accordion/init.js +6 -0
- package/src/accordion/save.js +23 -0
- package/src/accordion/style.scss +91 -0
- package/src/accordion/view.js +38 -0
- package/src/accordion-content/block.json +45 -0
- package/src/accordion-content/edit.js +149 -0
- package/src/accordion-content/icon.js +28 -0
- package/src/accordion-content/icons.js +23 -0
- package/src/accordion-content/index.js +21 -0
- package/src/accordion-content/index.php +73 -0
- package/src/accordion-content/init.js +6 -0
- package/src/accordion-content/save.js +25 -0
- package/src/accordion-header/block.json +93 -0
- package/src/accordion-header/edit.js +131 -0
- package/src/accordion-header/icon.js +16 -0
- package/src/accordion-header/index.js +21 -0
- package/src/accordion-header/init.js +6 -0
- package/src/accordion-header/save.js +79 -0
- package/src/accordion-panel/block.json +74 -0
- package/src/accordion-panel/edit.js +61 -0
- package/src/accordion-panel/icon.js +15 -0
- package/src/accordion-panel/index.js +21 -0
- package/src/accordion-panel/init.js +6 -0
- package/src/accordion-panel/save.js +51 -0
- package/src/block/index.php +16 -14
- package/src/cover/block.json +2 -1
- package/src/file/index.php +28 -22
- package/src/freeform/edit.js +7 -0
- package/src/index.js +12 -0
- package/src/media-text/media-container.js +1 -0
- package/src/media-text/transforms.js +5 -1
- package/src/navigation/edit/test/navigation-menu-selector.js +2 -2
- package/src/post-comments-link/edit.js +7 -1
- package/src/post-excerpt/index.php +16 -12
- package/src/query-title/block.json +1 -0
- package/src/query-title/edit.js +58 -1
- package/src/query-title/index.php +30 -5
- package/src/query-title/use-post-type-label.js +34 -0
- package/src/query-title/variations.js +13 -0
- package/src/site-logo/edit.js +33 -12
- package/src/site-title/edit.js +24 -16
- package/src/social-link/README.md +4 -1
- package/src/social-link/index.php +1 -1
- package/src/style.scss +1 -0
- package/src/video/edit-common-settings.js +14 -5
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "core/accordion-panel",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"title": "Accordion Panel",
|
|
7
|
+
"category": "design",
|
|
8
|
+
"description": "Displays an accordion panel.",
|
|
9
|
+
"example": {},
|
|
10
|
+
"__experimental": true,
|
|
11
|
+
"parent": [ "core/accordion-content" ],
|
|
12
|
+
"supports": {
|
|
13
|
+
"color": {
|
|
14
|
+
"background": true,
|
|
15
|
+
"gradient": true
|
|
16
|
+
},
|
|
17
|
+
"border": true,
|
|
18
|
+
"interactivity": true,
|
|
19
|
+
"spacing": {
|
|
20
|
+
"padding": true,
|
|
21
|
+
"margin": [ "top", "bottom" ],
|
|
22
|
+
"blockGap": true,
|
|
23
|
+
"__experimentalDefaultControls": {
|
|
24
|
+
"padding": true,
|
|
25
|
+
"blockGap": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"__experimentalBorder": {
|
|
29
|
+
"color": true,
|
|
30
|
+
"radius": true,
|
|
31
|
+
"style": true,
|
|
32
|
+
"width": true,
|
|
33
|
+
"__experimentalDefaultControls": {
|
|
34
|
+
"color": true,
|
|
35
|
+
"radius": true,
|
|
36
|
+
"style": true,
|
|
37
|
+
"width": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"typography": {
|
|
41
|
+
"fontSize": true,
|
|
42
|
+
"lineHeight": true,
|
|
43
|
+
"__experimentalFontFamily": true,
|
|
44
|
+
"__experimentalFontWeight": true,
|
|
45
|
+
"__experimentalFontStyle": true,
|
|
46
|
+
"__experimentalTextTransform": true,
|
|
47
|
+
"__experimentalTextDecoration": true,
|
|
48
|
+
"__experimentalLetterSpacing": true,
|
|
49
|
+
"__experimentalDefaultControls": {
|
|
50
|
+
"fontSize": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"shadow": true
|
|
54
|
+
},
|
|
55
|
+
"attributes": {
|
|
56
|
+
"allowedBlocks": {
|
|
57
|
+
"type": "array"
|
|
58
|
+
},
|
|
59
|
+
"templateLock": {
|
|
60
|
+
"type": [ "string", "boolean" ],
|
|
61
|
+
"enum": [ "all", "insert", "contentOnly", false ],
|
|
62
|
+
"default": false
|
|
63
|
+
},
|
|
64
|
+
"openByDefault": {
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"default": false
|
|
67
|
+
},
|
|
68
|
+
"isSelected": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"default": false
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"textdomain": "default"
|
|
74
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useBlockProps,
|
|
6
|
+
useInnerBlocksProps,
|
|
7
|
+
__experimentalUseBorderProps as useBorderProps,
|
|
8
|
+
__experimentalUseColorProps as useColorProps,
|
|
9
|
+
__experimentalGetSpacingClassesAndStyles as useSpacingProps,
|
|
10
|
+
__experimentalGetShadowClassesAndStyles as useShadowProps,
|
|
11
|
+
} from '@wordpress/block-editor';
|
|
12
|
+
/**
|
|
13
|
+
* External dependencies
|
|
14
|
+
*/
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
|
|
17
|
+
export default function Edit( { attributes } ) {
|
|
18
|
+
const { allowedBlocks, templateLock, openByDefault, isSelected } =
|
|
19
|
+
attributes;
|
|
20
|
+
const borderProps = useBorderProps( attributes );
|
|
21
|
+
const colorProps = useColorProps( attributes );
|
|
22
|
+
const spacingProps = useSpacingProps( attributes );
|
|
23
|
+
const shadowProps = useShadowProps( attributes );
|
|
24
|
+
|
|
25
|
+
const blockProps = useBlockProps();
|
|
26
|
+
const innerBlocksProps = useInnerBlocksProps(
|
|
27
|
+
{
|
|
28
|
+
className: 'accordion-content__wrapper',
|
|
29
|
+
style: {
|
|
30
|
+
...spacingProps.style,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
allowedBlocks,
|
|
35
|
+
template: [ [ 'core/paragraph', {} ] ],
|
|
36
|
+
templateLock,
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
{ ...blockProps }
|
|
43
|
+
className={ clsx(
|
|
44
|
+
blockProps.className,
|
|
45
|
+
colorProps.className,
|
|
46
|
+
borderProps.className,
|
|
47
|
+
{
|
|
48
|
+
[ `has-custom-font-size` ]: blockProps?.style?.fontSize,
|
|
49
|
+
}
|
|
50
|
+
) }
|
|
51
|
+
style={ {
|
|
52
|
+
...borderProps.style,
|
|
53
|
+
...colorProps.style,
|
|
54
|
+
...shadowProps.style,
|
|
55
|
+
} }
|
|
56
|
+
aria-hidden={ ! isSelected && ! openByDefault }
|
|
57
|
+
>
|
|
58
|
+
<div { ...innerBlocksProps } />
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { SVG, Path } from '@wordpress/primitives';
|
|
5
|
+
|
|
6
|
+
export default (
|
|
7
|
+
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
8
|
+
<Path
|
|
9
|
+
fillRule="evenodd"
|
|
10
|
+
clipRule="evenodd"
|
|
11
|
+
d="M8.10417 6.00024H6.5C5.39543 6.00024 4.5 6.89567 4.5 8.00024V10.3336H6V8.00024C6 7.7241 6.22386 7.50024 6.5 7.50024H8.10417V6.00024ZM4.5 13.6669V16.0002C4.5 17.1048 5.39543 18.0002 6.5 18.0002H8.10417V16.5002H6.5C6.22386 16.5002 6 16.2764 6 16.0002V13.6669H4.5ZM10.3958 6.00024V7.50024H13.6042V6.00024H10.3958ZM15.8958 6.00024V7.50024H17.5C17.7761 7.50024 18 7.7241 18 8.00024V10.3336H19.5V8.00024C19.5 6.89567 18.6046 6.00024 17.5 6.00024H15.8958ZM19.5 13.6669H18V16.0002C18 16.2764 17.7761 16.5002 17.5 16.5002H15.8958V18.0002H17.5C18.6046 18.0002 19.5 17.1048 19.5 16.0002V13.6669ZM13.6042 18.0002V16.5002H10.3958V18.0002H13.6042Z"
|
|
12
|
+
fill="currentColor"
|
|
13
|
+
/>
|
|
14
|
+
</SVG>
|
|
15
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import edit from './edit';
|
|
5
|
+
import save from './save';
|
|
6
|
+
import metadata from './block.json';
|
|
7
|
+
import initBlock from '../utils/init-block';
|
|
8
|
+
import icon from './icon';
|
|
9
|
+
|
|
10
|
+
const { name } = metadata;
|
|
11
|
+
|
|
12
|
+
export { metadata, name };
|
|
13
|
+
|
|
14
|
+
export const settings = {
|
|
15
|
+
icon,
|
|
16
|
+
example: {},
|
|
17
|
+
edit,
|
|
18
|
+
save,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
InnerBlocks,
|
|
6
|
+
useBlockProps,
|
|
7
|
+
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
8
|
+
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
9
|
+
__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,
|
|
10
|
+
__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
|
|
11
|
+
} from '@wordpress/block-editor';
|
|
12
|
+
/**
|
|
13
|
+
* External dependencies
|
|
14
|
+
*/
|
|
15
|
+
import clsx from 'clsx';
|
|
16
|
+
|
|
17
|
+
export default function save( { attributes } ) {
|
|
18
|
+
const blockProps = useBlockProps.save();
|
|
19
|
+
const borderProps = getBorderClassesAndStyles( attributes );
|
|
20
|
+
const colorProps = getColorClassesAndStyles( attributes );
|
|
21
|
+
const spacingProps = getSpacingClassesAndStyles( attributes );
|
|
22
|
+
const shadowProps = getShadowClassesAndStyles( attributes );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div
|
|
26
|
+
{ ...blockProps }
|
|
27
|
+
className={ clsx(
|
|
28
|
+
blockProps.className,
|
|
29
|
+
colorProps.className,
|
|
30
|
+
borderProps.className,
|
|
31
|
+
{
|
|
32
|
+
[ `has-custom-font-size` ]: blockProps?.style?.fontSize,
|
|
33
|
+
}
|
|
34
|
+
) }
|
|
35
|
+
style={ {
|
|
36
|
+
...borderProps.style,
|
|
37
|
+
...colorProps.style,
|
|
38
|
+
...shadowProps.style,
|
|
39
|
+
} }
|
|
40
|
+
>
|
|
41
|
+
<div
|
|
42
|
+
className="accordion-content__wrapper"
|
|
43
|
+
style={ {
|
|
44
|
+
...spacingProps.style,
|
|
45
|
+
} }
|
|
46
|
+
>
|
|
47
|
+
<InnerBlocks.Content />
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
package/src/block/index.php
CHANGED
|
@@ -88,20 +88,22 @@ function render_block_core_block( $attributes, $content, $block_instance ) {
|
|
|
88
88
|
$block_instance->refresh_context_dependents();
|
|
89
89
|
} else {
|
|
90
90
|
// This branch can be removed once Gutenberg requires WordPress 6.8 or later.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
if ( ! class_exists( 'WP_Block_Cloner' ) ) {
|
|
92
|
+
// phpcs:ignore Gutenberg.Commenting.SinceTag.MissingClassSinceTag
|
|
93
|
+
class WP_Block_Cloner extends WP_Block {
|
|
94
|
+
/**
|
|
95
|
+
* Static methods of subclasses have access to protected properties
|
|
96
|
+
* of instances of the parent class.
|
|
97
|
+
* In this case, this gives us access to `available_context` and `registry`.
|
|
98
|
+
*/
|
|
99
|
+
// phpcs:ignore Gutenberg.Commenting.SinceTag.MissingMethodSinceTag
|
|
100
|
+
public static function clone_instance( $instance ) {
|
|
101
|
+
return new WP_Block(
|
|
102
|
+
$instance->parsed_block,
|
|
103
|
+
$instance->available_context,
|
|
104
|
+
$instance->registry
|
|
105
|
+
);
|
|
106
|
+
}
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
$block_instance = WP_Block_Cloner::clone_instance( $block_instance );
|
package/src/cover/block.json
CHANGED
package/src/file/index.php
CHANGED
|
@@ -16,33 +16,39 @@
|
|
|
16
16
|
* @return string Returns the block content.
|
|
17
17
|
*/
|
|
18
18
|
function render_block_core_file( $attributes, $content ) {
|
|
19
|
+
if ( empty( $attributes['displayPreview'] ) ) {
|
|
20
|
+
return $content;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
// If it's interactive, enqueue the script module and add the directives.
|
|
20
|
-
|
|
21
|
-
wp_enqueue_script_module( '@wordpress/block-library/file/view' );
|
|
24
|
+
wp_enqueue_script_module( '@wordpress/block-library/file/view' );
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
$processor = new WP_HTML_Tag_Processor( $content );
|
|
27
|
+
if ( $processor->next_tag() ) {
|
|
25
28
|
$processor->set_attribute( 'data-wp-interactive', 'core/file' );
|
|
26
|
-
$processor->next_tag( 'object' );
|
|
27
|
-
$processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
|
|
28
|
-
$processor->set_attribute( 'hidden', true );
|
|
29
|
-
|
|
30
|
-
$filename = $processor->get_attribute( 'aria-label' );
|
|
31
|
-
$has_filename = ! empty( $filename ) && 'PDF embed' !== $filename;
|
|
32
|
-
$label = $has_filename ? sprintf(
|
|
33
|
-
/* translators: %s: filename. */
|
|
34
|
-
__( 'Embed of %s.' ),
|
|
35
|
-
$filename
|
|
36
|
-
) : __( 'PDF embed' );
|
|
37
|
-
|
|
38
|
-
// Update object's aria-label attribute if present in block HTML.
|
|
39
|
-
// Match an aria-label attribute from an object tag.
|
|
40
|
-
$processor->set_attribute( 'aria-label', $label );
|
|
41
|
-
|
|
42
|
-
return $processor->get_updated_html();
|
|
43
29
|
}
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
// If there are no OBJECT elements, something might have already modified the block.
|
|
32
|
+
if ( ! $processor->next_tag( 'OBJECT' ) ) {
|
|
33
|
+
return $content;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
$processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' );
|
|
37
|
+
$processor->set_attribute( 'hidden', true );
|
|
38
|
+
|
|
39
|
+
$filename = $processor->get_attribute( 'aria-label' );
|
|
40
|
+
$has_filename = is_string( $filename ) && ! empty( $filename ) && 'PDF embed' !== $filename;
|
|
41
|
+
$label = $has_filename ? sprintf(
|
|
42
|
+
/* translators: %s: filename. */
|
|
43
|
+
__( 'Embed of %s.' ),
|
|
44
|
+
$filename
|
|
45
|
+
) : __( 'PDF embed' );
|
|
46
|
+
|
|
47
|
+
// Update object's aria-label attribute if present in block HTML.
|
|
48
|
+
// Match an aria-label attribute from an object tag.
|
|
49
|
+
$processor->set_attribute( 'aria-label', $label );
|
|
50
|
+
|
|
51
|
+
return $processor->get_updated_html();
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
/**
|
package/src/freeform/edit.js
CHANGED
|
@@ -188,6 +188,13 @@ function ClassicEdit( {
|
|
|
188
188
|
}
|
|
189
189
|
} );
|
|
190
190
|
|
|
191
|
+
editor.on( 'paste', ( event ) => {
|
|
192
|
+
// TinyMCE selection isn’t synced with the block editor selection store.
|
|
193
|
+
// This event handler prevents paste from bubbling so the useClipboardHandler
|
|
194
|
+
// won’t replace the block.
|
|
195
|
+
event.stopPropagation();
|
|
196
|
+
} );
|
|
197
|
+
|
|
191
198
|
editor.on( 'init', () => {
|
|
192
199
|
const rootNode = editor.getBody();
|
|
193
200
|
|
package/src/index.js
CHANGED
|
@@ -20,6 +20,10 @@ import {
|
|
|
20
20
|
// production build to make the final bundle smaller.
|
|
21
21
|
//
|
|
22
22
|
// See https://github.com/WordPress/gutenberg/pull/40655 for more context.
|
|
23
|
+
import * as accordion from './accordion';
|
|
24
|
+
import * as accordionContent from './accordion-content';
|
|
25
|
+
import * as accordionHeader from './accordion-header';
|
|
26
|
+
import * as accordionPanel from './accordion-panel';
|
|
23
27
|
import * as archives from './archives';
|
|
24
28
|
import * as avatar from './avatar';
|
|
25
29
|
import * as audio from './audio';
|
|
@@ -234,6 +238,14 @@ const getAllBlocks = () => {
|
|
|
234
238
|
queryTitle,
|
|
235
239
|
postAuthorBiography,
|
|
236
240
|
];
|
|
241
|
+
|
|
242
|
+
if ( window?.__experimentalEnableBlockExperiments ) {
|
|
243
|
+
blocks.push( accordion );
|
|
244
|
+
blocks.push( accordionContent );
|
|
245
|
+
blocks.push( accordionHeader );
|
|
246
|
+
blocks.push( accordionPanel );
|
|
247
|
+
}
|
|
248
|
+
|
|
237
249
|
if ( window?.__experimentalEnableFormBlocks ) {
|
|
238
250
|
blocks.push( form );
|
|
239
251
|
blocks.push( formInput );
|
|
@@ -200,6 +200,7 @@ function MediaContainer( props, ref ) {
|
|
|
200
200
|
}
|
|
201
201
|
mediaId={ mediaId }
|
|
202
202
|
toggleUseFeaturedImage={ toggleUseFeaturedImage }
|
|
203
|
+
useFeaturedImage={ useFeaturedImage }
|
|
203
204
|
/>
|
|
204
205
|
{ ( mediaTypeRenderers[ mediaType ] || noop )() }
|
|
205
206
|
{ isTemporaryMedia && <Spinner /> }
|
|
@@ -45,6 +45,7 @@ const transforms = {
|
|
|
45
45
|
style,
|
|
46
46
|
textColor,
|
|
47
47
|
url,
|
|
48
|
+
useFeaturedImage,
|
|
48
49
|
},
|
|
49
50
|
innerBlocks
|
|
50
51
|
) => {
|
|
@@ -90,6 +91,7 @@ const transforms = {
|
|
|
90
91
|
mediaType: backgroundType,
|
|
91
92
|
mediaUrl: url,
|
|
92
93
|
textColor,
|
|
94
|
+
useFeaturedImage,
|
|
93
95
|
...additionalAttributes,
|
|
94
96
|
},
|
|
95
97
|
innerBlocks
|
|
@@ -143,6 +145,7 @@ const transforms = {
|
|
|
143
145
|
mediaUrl,
|
|
144
146
|
style,
|
|
145
147
|
textColor,
|
|
148
|
+
useFeaturedImage,
|
|
146
149
|
},
|
|
147
150
|
innerBlocks
|
|
148
151
|
) => {
|
|
@@ -169,13 +172,14 @@ const transforms = {
|
|
|
169
172
|
alt: mediaAlt,
|
|
170
173
|
anchor,
|
|
171
174
|
backgroundType: mediaType,
|
|
172
|
-
dimRatio: !! mediaUrl ? 50 : 100,
|
|
175
|
+
dimRatio: !! mediaUrl || useFeaturedImage ? 50 : 100,
|
|
173
176
|
focalPoint,
|
|
174
177
|
gradient,
|
|
175
178
|
id: mediaId,
|
|
176
179
|
overlayColor: backgroundColor,
|
|
177
180
|
textColor,
|
|
178
181
|
url: mediaUrl,
|
|
182
|
+
useFeaturedImage,
|
|
179
183
|
...additionalAttributes,
|
|
180
184
|
};
|
|
181
185
|
|
|
@@ -295,7 +295,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
295
295
|
screen.queryByRole( 'menuitem', {
|
|
296
296
|
name: 'Create new Menu',
|
|
297
297
|
} )
|
|
298
|
-
).
|
|
298
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
299
299
|
|
|
300
300
|
// once the menu is created
|
|
301
301
|
// no more network activity to wait on
|
|
@@ -619,7 +619,7 @@ describe( 'NavigationMenuSelector', () => {
|
|
|
619
619
|
// Check all menu items are present but disabled.
|
|
620
620
|
screen.getAllByRole( 'menuitem' ).forEach( ( item ) => {
|
|
621
621
|
// // Check all menu items are present but disabled.
|
|
622
|
-
expect( item ).
|
|
622
|
+
expect( item ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
623
623
|
} );
|
|
624
624
|
|
|
625
625
|
// once the menu is imported
|
|
@@ -60,7 +60,13 @@ function PostCommentsLinkEdit( { context, attributes, setAttributes } ) {
|
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
if ( ! post ) {
|
|
63
|
-
return
|
|
63
|
+
return (
|
|
64
|
+
<div { ...blockProps }>
|
|
65
|
+
<Warning>
|
|
66
|
+
{ __( 'Post Comments Link block: post not found.' ) }
|
|
67
|
+
</Warning>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
const { link } = post;
|
|
@@ -20,18 +20,6 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
|
|
|
20
20
|
return '';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/*
|
|
24
|
-
* The purpose of the excerpt length setting is to limit the length of both
|
|
25
|
-
* automatically generated and user-created excerpts.
|
|
26
|
-
* Because the excerpt_length filter only applies to auto generated excerpts,
|
|
27
|
-
* wp_trim_words is used instead.
|
|
28
|
-
*/
|
|
29
|
-
$excerpt_length = $attributes['excerptLength'];
|
|
30
|
-
$excerpt = get_the_excerpt( $block->context['postId'] );
|
|
31
|
-
if ( isset( $excerpt_length ) ) {
|
|
32
|
-
$excerpt = wp_trim_words( $excerpt, $excerpt_length );
|
|
33
|
-
}
|
|
34
|
-
|
|
35
23
|
$more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';
|
|
36
24
|
$filter_excerpt_more = static function ( $more ) use ( $more_text ) {
|
|
37
25
|
return empty( $more_text ) ? $more : '';
|
|
@@ -44,8 +32,24 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
|
|
|
44
32
|
* So if the block's attribute is not empty override the
|
|
45
33
|
* `excerpt_more` filter and return nothing. This will
|
|
46
34
|
* result in showing only one `read more` link at a time.
|
|
35
|
+
*
|
|
36
|
+
* This hook needs to be applied before the excerpt is retrieved with get_the_excerpt.
|
|
37
|
+
* Otherwise, the read more link filter from the theme is not removed.
|
|
47
38
|
*/
|
|
48
39
|
add_filter( 'excerpt_more', $filter_excerpt_more );
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
* The purpose of the excerpt length setting is to limit the length of both
|
|
43
|
+
* automatically generated and user-created excerpts.
|
|
44
|
+
* Because the excerpt_length filter only applies to auto generated excerpts,
|
|
45
|
+
* wp_trim_words is used instead.
|
|
46
|
+
*/
|
|
47
|
+
$excerpt_length = $attributes['excerptLength'];
|
|
48
|
+
$excerpt = get_the_excerpt( $block->context['postId'] );
|
|
49
|
+
if ( isset( $excerpt_length ) ) {
|
|
50
|
+
$excerpt = wp_trim_words( $excerpt, $excerpt_length );
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
$classes = array();
|
|
50
54
|
if ( isset( $attributes['textAlign'] ) ) {
|
|
51
55
|
$classes[] = 'has-text-align-' . $attributes['textAlign'];
|
package/src/query-title/edit.js
CHANGED
|
@@ -25,9 +25,10 @@ import { __, _x, sprintf } from '@wordpress/i18n';
|
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
import { useArchiveLabel } from './use-archive-label';
|
|
28
|
+
import { usePostTypeLabel } from './use-post-type-label';
|
|
28
29
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
29
30
|
|
|
30
|
-
const SUPPORTED_TYPES = [ 'archive', 'search' ];
|
|
31
|
+
const SUPPORTED_TYPES = [ 'archive', 'search', 'post-type' ];
|
|
31
32
|
|
|
32
33
|
export default function QueryTitleEdit( {
|
|
33
34
|
attributes: {
|
|
@@ -39,8 +40,10 @@ export default function QueryTitleEdit( {
|
|
|
39
40
|
showSearchTerm,
|
|
40
41
|
},
|
|
41
42
|
setAttributes,
|
|
43
|
+
context: { query },
|
|
42
44
|
} ) {
|
|
43
45
|
const { archiveTypeLabel, archiveNameLabel } = useArchiveLabel();
|
|
46
|
+
const { postTypeLabel } = usePostTypeLabel( query?.postType );
|
|
44
47
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
45
48
|
|
|
46
49
|
const TagName = `h${ level }`;
|
|
@@ -174,6 +177,60 @@ export default function QueryTitleEdit( {
|
|
|
174
177
|
);
|
|
175
178
|
}
|
|
176
179
|
|
|
180
|
+
if ( type === 'post-type' ) {
|
|
181
|
+
let title;
|
|
182
|
+
if ( postTypeLabel ) {
|
|
183
|
+
if ( showPrefix ) {
|
|
184
|
+
title = sprintf(
|
|
185
|
+
/* translators: %s: Singular post type name of the queried object */
|
|
186
|
+
__( 'Post Type: "%s"' ),
|
|
187
|
+
postTypeLabel
|
|
188
|
+
);
|
|
189
|
+
} else {
|
|
190
|
+
title = postTypeLabel;
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
title = showPrefix ? __( 'Post Type: Name' ) : __( 'Name' );
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
titleElement = (
|
|
197
|
+
<>
|
|
198
|
+
<InspectorControls>
|
|
199
|
+
<ToolsPanel
|
|
200
|
+
label={ __( 'Settings' ) }
|
|
201
|
+
resetAll={ () =>
|
|
202
|
+
setAttributes( {
|
|
203
|
+
showPrefix: true,
|
|
204
|
+
} )
|
|
205
|
+
}
|
|
206
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
207
|
+
>
|
|
208
|
+
<ToolsPanelItem
|
|
209
|
+
hasValue={ () => ! showPrefix }
|
|
210
|
+
label={ __( 'Show post type label' ) }
|
|
211
|
+
onDeselect={ () =>
|
|
212
|
+
setAttributes( { showPrefix: true } )
|
|
213
|
+
}
|
|
214
|
+
isShownByDefault
|
|
215
|
+
>
|
|
216
|
+
<ToggleControl
|
|
217
|
+
__nextHasNoMarginBottom
|
|
218
|
+
label={ __( 'Show post type label' ) }
|
|
219
|
+
onChange={ () =>
|
|
220
|
+
setAttributes( {
|
|
221
|
+
showPrefix: ! showPrefix,
|
|
222
|
+
} )
|
|
223
|
+
}
|
|
224
|
+
checked={ showPrefix }
|
|
225
|
+
/>
|
|
226
|
+
</ToolsPanelItem>
|
|
227
|
+
</ToolsPanel>
|
|
228
|
+
</InspectorControls>
|
|
229
|
+
<TagName { ...blockProps }>{ title }</TagName>
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
177
234
|
return (
|
|
178
235
|
<>
|
|
179
236
|
<BlockControls group="block">
|
|
@@ -7,23 +7,28 @@
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders the `core/query-title` block on the server.
|
|
10
|
-
* For now it
|
|
10
|
+
* For now it supports Archive title, Search title, and Post Type Label,
|
|
11
11
|
* using queried object information
|
|
12
12
|
*
|
|
13
13
|
* @since 5.8.0
|
|
14
14
|
*
|
|
15
|
-
* @param array
|
|
15
|
+
* @param array $attributes Block attributes.
|
|
16
|
+
* @param array $_content Block content.
|
|
17
|
+
* @param object $block Block instance.
|
|
16
18
|
*
|
|
17
19
|
* @return string Returns the query title based on the queried object.
|
|
18
20
|
*/
|
|
19
|
-
function render_block_core_query_title( $attributes ) {
|
|
21
|
+
function render_block_core_query_title( $attributes, $content, $block ) {
|
|
20
22
|
$type = isset( $attributes['type'] ) ? $attributes['type'] : null;
|
|
21
23
|
$is_archive = is_archive();
|
|
22
24
|
$is_search = is_search();
|
|
25
|
+
$post_type = isset( $block->context['query']['postType'] ) ? $block->context['query']['postType'] : get_post_type();
|
|
26
|
+
|
|
23
27
|
if ( ! $type ||
|
|
24
28
|
( 'archive' === $type && ! $is_archive ) ||
|
|
25
|
-
( 'search' === $type && ! $is_search )
|
|
26
|
-
)
|
|
29
|
+
( 'search' === $type && ! $is_search ) ||
|
|
30
|
+
( 'post-type' === $type && ! $post_type )
|
|
31
|
+
) {
|
|
27
32
|
return '';
|
|
28
33
|
}
|
|
29
34
|
$title = '';
|
|
@@ -48,6 +53,26 @@ function render_block_core_query_title( $attributes ) {
|
|
|
48
53
|
);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
56
|
+
if ( 'post-type' === $type ) {
|
|
57
|
+
$post_type_object = get_post_type_object( $post_type );
|
|
58
|
+
|
|
59
|
+
if ( ! $post_type_object ) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
$post_type_name = $post_type_object->labels->singular_name;
|
|
64
|
+
$show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true;
|
|
65
|
+
|
|
66
|
+
if ( $show_prefix ) {
|
|
67
|
+
$title = sprintf(
|
|
68
|
+
/* translators: %s is the post type name. */
|
|
69
|
+
__( 'Post Type: "%s"' ),
|
|
70
|
+
$post_type_name
|
|
71
|
+
);
|
|
72
|
+
} else {
|
|
73
|
+
$title = $post_type_name;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
51
76
|
|
|
52
77
|
$tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1';
|
|
53
78
|
$align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}";
|