@wordpress/block-library 8.12.9 → 8.12.10

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.
@@ -116,6 +116,7 @@ const metadata = {
116
116
  },
117
117
  html: false
118
118
  },
119
+ viewScript: "file:./view.min.js",
119
120
  editorStyle: "wp-block-search-editor",
120
121
  style: "wp-block-search"
121
122
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/search/index.js"],"names":["name","metadata","settings","icon","example","attributes","buttonText","label","viewportWidth","variations","edit","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,UAAU,EAAE,cAAI,QAAJ,CAAd;AAA8BC,MAAAA,KAAK,EAAE,cAAI,QAAJ;AAArC,KADJ;AAERC,IAAAA,aAAa,EAAE;AAFP,GAFc;AAMvBC,EAAAA,UAAU,EAAVA,mBANuB;AAOvBC,EAAAA,IAAI,EAAJA;AAPuB,CAAjB;;;AAUA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEX,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/search/index.js"],"names":["name","metadata","settings","icon","example","attributes","buttonText","label","viewportWidth","variations","edit","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAEA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,UAAU,EAAE,cAAI,QAAJ,CAAd;AAA8BC,MAAAA,KAAK,EAAE,cAAI,QAAJ;AAArC,KADJ;AAERC,IAAAA,aAAa,EAAE;AAFP,GAFc;AAMvBC,EAAAA,UAAU,EAAVA,mBANuB;AAOvBC,EAAAA,IAAI,EAAJA;AAPuB,CAAjB;;;AAUA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEX,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -100,6 +100,7 @@ const metadata = {
100
100
  },
101
101
  html: false
102
102
  },
103
+ viewScript: "file:./view.min.js",
103
104
  editorStyle: "wp-block-search-editor",
104
105
  style: "wp-block-search"
105
106
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/search/index.js"],"names":["__","search","icon","initBlock","edit","variations","name","metadata","settings","example","attributes","buttonText","label","viewportWidth","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBN,EAAAA,IADuB;AAEvBO,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,UAAU,EAAEX,EAAE,CAAE,QAAF,CAAhB;AAA8BY,MAAAA,KAAK,EAAEZ,EAAE,CAAE,QAAF;AAAvC,KADJ;AAERa,IAAAA,aAAa,EAAE;AAFP,GAFc;AAMvBR,EAAAA,UANuB;AAOvBD,EAAAA;AAPuB,CAAjB;AAUP,OAAO,MAAMU,IAAI,GAAG,MAAMX,SAAS,CAAE;AAAEG,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/search/index.js"],"names":["__","search","icon","initBlock","edit","variations","name","metadata","settings","example","attributes","buttonText","label","viewportWidth","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAM,IAAIC,IAAnB,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AAEA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBN,EAAAA,IADuB;AAEvBO,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,UAAU,EAAEX,EAAE,CAAE,QAAF,CAAhB;AAA8BY,MAAAA,KAAK,EAAEZ,EAAE,CAAE,QAAF;AAAvC,KADJ;AAERa,IAAAA,aAAa,EAAE;AAFP,GAFc;AAMvBR,EAAAA,UANuB;AAOvBD,EAAAA;AAPuB,CAAjB;AAUP,OAAO,MAAMU,IAAI,GAAG,MAAMX,SAAS,CAAE;AAAEG,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { search as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: { buttonText: __( 'Search' ), label: __( 'Search' ) },\n\t\tviewportWidth: 400,\n\t},\n\tvariations,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-library",
3
- "version": "8.12.9",
3
+ "version": "8.12.10",
4
4
  "description": "Block library for the WordPress editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,12 +37,12 @@
37
37
  "@wordpress/api-fetch": "^6.32.1",
38
38
  "@wordpress/autop": "^3.35.1",
39
39
  "@wordpress/blob": "^3.35.1",
40
- "@wordpress/block-editor": "^12.3.7",
41
- "@wordpress/blocks": "^12.12.3",
42
- "@wordpress/components": "^25.1.7",
40
+ "@wordpress/block-editor": "^12.3.8",
41
+ "@wordpress/blocks": "^12.12.4",
42
+ "@wordpress/components": "^25.1.8",
43
43
  "@wordpress/compose": "^6.12.1",
44
- "@wordpress/core-data": "^6.12.7",
45
- "@wordpress/data": "^9.5.3",
44
+ "@wordpress/core-data": "^6.12.8",
45
+ "@wordpress/data": "^9.5.4",
46
46
  "@wordpress/date": "^4.35.1",
47
47
  "@wordpress/deprecated": "^3.35.1",
48
48
  "@wordpress/dom": "^3.35.1",
@@ -53,14 +53,14 @@
53
53
  "@wordpress/i18n": "^4.35.1",
54
54
  "@wordpress/icons": "^9.26.2",
55
55
  "@wordpress/keycodes": "^3.35.1",
56
- "@wordpress/notices": "^4.3.3",
56
+ "@wordpress/notices": "^4.3.4",
57
57
  "@wordpress/primitives": "^3.33.1",
58
- "@wordpress/private-apis": "^0.17.1",
59
- "@wordpress/reusable-blocks": "^4.12.7",
60
- "@wordpress/rich-text": "^6.12.4",
61
- "@wordpress/server-side-render": "^4.12.7",
58
+ "@wordpress/private-apis": "^0.17.2",
59
+ "@wordpress/reusable-blocks": "^4.12.8",
60
+ "@wordpress/rich-text": "^6.12.5",
61
+ "@wordpress/server-side-render": "^4.12.8",
62
62
  "@wordpress/url": "^3.36.1",
63
- "@wordpress/viewport": "^5.12.3",
63
+ "@wordpress/viewport": "^5.12.4",
64
64
  "@wordpress/wordcount": "^3.35.1",
65
65
  "change-case": "^4.1.2",
66
66
  "classnames": "^2.3.1",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "5a52ea1ed29bbf8f3ead96f83b17d2c1cf84c880"
86
+ "gitHead": "cedb8caa943db47c16bdb4fa8880d506ce938fab"
87
87
  }
@@ -90,6 +90,7 @@
90
90
  },
91
91
  "html": false
92
92
  },
93
+ "viewScript": "file:./view.min.js",
93
94
  "editorStyle": "wp-block-search-editor",
94
95
  "style": "wp-block-search"
95
96
  }
@@ -8,11 +8,13 @@
8
8
  /**
9
9
  * Dynamically renders the `core/search` block.
10
10
  *
11
- * @param array $attributes The block attributes.
11
+ * @param array $attributes The block attributes.
12
+ * @param string $content The saved content.
13
+ * @param WP_Block $block The parsed block.
12
14
  *
13
15
  * @return string The search block markup.
14
16
  */
15
- function render_block_core_search( $attributes ) {
17
+ function render_block_core_search( $attributes, $content, $block ) {
16
18
  // Older versions of the Search block defaulted the label and buttonText
17
19
  // attributes to `__( 'Search' )` meaning that many posts contain `<!--
18
20
  // wp:search /-->`. Support these by defaulting an undefined label and
@@ -70,10 +72,26 @@ function render_block_core_search( $attributes ) {
70
72
  $input->set_attribute( 'id', $input_id );
71
73
  $input->set_attribute( 'value', get_search_query() );
72
74
  $input->set_attribute( 'placeholder', $attributes['placeholder'] );
73
- if ( 'button-only' === $button_position && 'expand-searchfield' === $button_behavior ) {
75
+
76
+ $is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
77
+ if ( $is_expandable_searchfield ) {
74
78
  $input->set_attribute( 'aria-hidden', 'true' );
75
79
  $input->set_attribute( 'tabindex', '-1' );
76
- wp_enqueue_script( 'wp-block--search-view', plugins_url( 'search/view.min.js', __FILE__ ) );
80
+ }
81
+
82
+ // If the script already exists, there is no point in removing it from viewScript.
83
+ $view_js_file = 'wp-block-search-view';
84
+ if ( ! wp_script_is( $view_js_file ) ) {
85
+ $script_handles = $block->block_type->view_script_handles;
86
+
87
+ // If the script is not needed, and it is still in the `view_script_handles`, remove it.
88
+ if ( ! $is_expandable_searchfield && in_array( $view_js_file, $script_handles, true ) ) {
89
+ $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
90
+ }
91
+ // If the script is needed, but it was previously removed, add it again.
92
+ if ( $is_expandable_searchfield && ! in_array( $view_js_file, $script_handles, true ) ) {
93
+ $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
94
+ }
77
95
  }
78
96
  }
79
97
 
@@ -18,12 +18,11 @@ function render_block_core_template_part( $attributes ) {
18
18
  $template_part_id = null;
19
19
  $content = null;
20
20
  $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED;
21
- $stylesheet = get_stylesheet();
22
21
 
23
22
  if (
24
23
  isset( $attributes['slug'] ) &&
25
24
  isset( $attributes['theme'] ) &&
26
- $stylesheet === $attributes['theme']
25
+ get_stylesheet() === $attributes['theme']
27
26
  ) {
28
27
  $template_part_id = $attributes['theme'] . '//' . $attributes['slug'];
29
28
  $template_part_query = new WP_Query(
@@ -64,22 +63,17 @@ function render_block_core_template_part( $attributes ) {
64
63
  */
65
64
  do_action( 'render_block_core_template_part_post', $template_part_id, $attributes, $template_part_post, $content );
66
65
  } else {
66
+ $template_part_file_path = '';
67
67
  // Else, if the template part was provided by the active theme,
68
68
  // render the corresponding file content.
69
69
  if ( 0 === validate_file( $attributes['slug'] ) ) {
70
- $themes = array( $stylesheet );
71
- $template = get_template();
72
- if ( $stylesheet !== $template ) {
73
- $themes[] = $template;
74
- }
75
-
76
- foreach ( $themes as $theme ) {
77
- $theme_folders = get_block_theme_folders( $theme );
78
- $template_part_file_path = get_theme_file_path( '/' . $theme_folders['wp_template_part'] . '/' . $attributes['slug'] . '.html' );
79
- if ( file_exists( $template_part_file_path ) ) {
80
- $content = (string) file_get_contents( $template_part_file_path );
81
- $content = '' !== $content ? _inject_theme_attribute_in_block_template_content( $content ) : '';
82
- break;
70
+ $block_template_file = _get_block_template_file( 'wp_template_part', $attributes['slug'] );
71
+ if ( $block_template_file ) {
72
+ $template_part_file_path = $block_template_file['path'];
73
+ $content = (string) file_get_contents( $template_part_file_path );
74
+ $content = '' !== $content ? _inject_theme_attribute_in_block_template_content( $content ) : '';
75
+ if ( isset( $block_template_file['area'] ) ) {
76
+ $area = $block_template_file['area'];
83
77
  }
84
78
  }
85
79
  }