@wordpress/block-library 8.12.9 → 8.12.11

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.11",
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.9",
41
+ "@wordpress/blocks": "^12.12.5",
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.9",
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.9",
60
+ "@wordpress/rich-text": "^6.12.5",
61
+ "@wordpress/server-side-render": "^4.12.9",
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": "ec0ed708e46a598ab2cf8e18bf2591b0102b5bb3"
87
87
  }
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Function that recursively renders a list of nested comments.
10
10
  *
11
+ * @since 6.3.0 Changed render_block_context priority to `1`.
12
+ *
11
13
  * @global int $comment_depth
12
14
  *
13
15
  * @param WP_Comment[] $comments The array of comments.
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/footnotes` block on the server.
10
10
  *
11
+ * @since 6.3.0
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  * @param string $content Block default content.
13
15
  * @param WP_Block $block Block instance.
@@ -57,6 +59,8 @@ function render_block_core_footnotes( $attributes, $content, $block ) {
57
59
 
58
60
  /**
59
61
  * Registers the `core/footnotes` block on the server.
62
+ *
63
+ * @since 6.3.0
60
64
  */
61
65
  function register_block_core_footnotes() {
62
66
  foreach ( array( 'post', 'page' ) as $post_type ) {
@@ -78,3 +82,137 @@ function register_block_core_footnotes() {
78
82
  );
79
83
  }
80
84
  add_action( 'init', 'register_block_core_footnotes' );
85
+
86
+ add_action(
87
+ 'wp_after_insert_post',
88
+ /**
89
+ * Saves the footnotes meta value to the revision.
90
+ *
91
+ * @since 6.3.0
92
+ *
93
+ * @param int $revision_id The revision ID.
94
+ */
95
+ static function( $revision_id ) {
96
+ $post_id = wp_is_post_revision( $revision_id );
97
+
98
+ if ( $post_id ) {
99
+ $footnotes = get_post_meta( $post_id, 'footnotes', true );
100
+
101
+ if ( $footnotes ) {
102
+ // Can't use update_post_meta() because it doesn't allow revisions.
103
+ update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
104
+ }
105
+ }
106
+ }
107
+ );
108
+
109
+ add_action(
110
+ '_wp_put_post_revision',
111
+ /**
112
+ * Keeps track of the revision ID for "rest_after_insert_{$post_type}".
113
+ *
114
+ * @param int $revision_id The revision ID.
115
+ */
116
+ static function( $revision_id ) {
117
+ global $_gutenberg_revision_id;
118
+ $_gutenberg_revision_id = $revision_id;
119
+ }
120
+ );
121
+
122
+ foreach ( array( 'post', 'page' ) as $post_type ) {
123
+ add_action(
124
+ "rest_after_insert_{$post_type}",
125
+ /**
126
+ * This is a specific fix for the REST API. The REST API doesn't update
127
+ * the post and post meta in one go (through `meta_input`). While it
128
+ * does fix the `wp_after_insert_post` hook to be called correctly after
129
+ * updating meta, it does NOT fix hooks such as post_updated and
130
+ * save_post, which are normally also fired after post meta is updated
131
+ * in `wp_insert_post()`. Unfortunately, `wp_save_post_revision` is
132
+ * added to the `post_updated` action, which means the meta is not
133
+ * available at the time, so we have to add it afterwards through the
134
+ * `"rest_after_insert_{$post_type}"` action.
135
+ *
136
+ * @since 6.3.0
137
+ *
138
+ * @param WP_Post $post The post object.
139
+ */
140
+ static function( $post ) {
141
+ global $_gutenberg_revision_id;
142
+
143
+ if ( $_gutenberg_revision_id ) {
144
+ $revision = get_post( $_gutenberg_revision_id );
145
+ $post_id = $revision->post_parent;
146
+
147
+ // Just making sure we're updating the right revision.
148
+ if ( $post->ID === $post_id ) {
149
+ $footnotes = get_post_meta( $post_id, 'footnotes', true );
150
+
151
+ if ( $footnotes ) {
152
+ // Can't use update_post_meta() because it doesn't allow revisions.
153
+ update_metadata( 'post', $_gutenberg_revision_id, 'footnotes', $footnotes );
154
+ }
155
+ }
156
+ }
157
+ }
158
+ );
159
+ }
160
+
161
+ add_action(
162
+ 'wp_restore_post_revision',
163
+ /**
164
+ * Restores the footnotes meta value from the revision.
165
+ *
166
+ * @since 6.3.0
167
+ *
168
+ * @param int $post_id The post ID.
169
+ * @param int $revision_id The revision ID.
170
+ */
171
+ static function( $post_id, $revision_id ) {
172
+ $footnotes = get_post_meta( $revision_id, 'footnotes', true );
173
+
174
+ if ( $footnotes ) {
175
+ update_post_meta( $post_id, 'footnotes', $footnotes );
176
+ } else {
177
+ delete_post_meta( $post_id, 'footnotes' );
178
+ }
179
+ },
180
+ 10,
181
+ 2
182
+ );
183
+
184
+ add_filter(
185
+ '_wp_post_revision_fields',
186
+ /**
187
+ * Adds the footnotes field to the revision.
188
+ *
189
+ * @since 6.3.0
190
+ *
191
+ * @param array $fields The revision fields.
192
+ * @return array The revision fields.
193
+ */
194
+ static function( $fields ) {
195
+ $fields['footnotes'] = __( 'Footnotes' );
196
+ return $fields;
197
+ }
198
+ );
199
+
200
+ add_filter(
201
+ 'wp_post_revision_field_footnotes',
202
+ /**
203
+ * Gets the footnotes field from the revision.
204
+ *
205
+ * @since 6.3.0
206
+ *
207
+ * @param string $revision_field The field value, but $revision->$field
208
+ * (footnotes) does not exist.
209
+ * @param string $field The field name, in this case "footnotes".
210
+ * @param object $revision The revision object to compare against.
211
+ * @return string The field value.
212
+ */
213
+ static function( $revision_field, $field, $revision ) {
214
+ return get_metadata( 'post', $revision->ID, $field, true );
215
+ },
216
+ 10,
217
+ 3
218
+ );
@@ -22,6 +22,8 @@ function register_block_core_pattern() {
22
22
  /**
23
23
  * Renders the `core/pattern` block on the server.
24
24
  *
25
+ * @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
26
+ *
25
27
  * @param array $attributes Block attributes.
26
28
  *
27
29
  * @return string Returns the output of the pattern.
@@ -34,6 +34,8 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
34
34
  /**
35
35
  * Renders the `core/post-template` block on the server.
36
36
  *
37
+ * @since 6.3.0 Changed render_block_context priority to `1`.
38
+ *
37
39
  * @param array $attributes Block attributes.
38
40
  * @param string $content Block default content.
39
41
  * @param WP_Block $block Block instance.
@@ -8,6 +8,8 @@
8
8
  /**
9
9
  * Renders the `core/post-title` block on the server.
10
10
  *
11
+ * @since 6.3.0 Omitting the $post argument from the `get_the_title`.
12
+ *
11
13
  * @param array $attributes Block attributes.
12
14
  * @param string $content Block default content.
13
15
  * @param WP_Block $block Block instance.
@@ -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,15 @@
8
8
  /**
9
9
  * Dynamically renders the `core/search` block.
10
10
  *
11
- * @param array $attributes The block attributes.
11
+ * @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
12
+ *
13
+ * @param array $attributes The block attributes.
14
+ * @param string $content The saved content.
15
+ * @param WP_Block $block The parsed block.
12
16
  *
13
17
  * @return string The search block markup.
14
18
  */
15
- function render_block_core_search( $attributes ) {
19
+ function render_block_core_search( $attributes, $content, $block ) {
16
20
  // Older versions of the Search block defaulted the label and buttonText
17
21
  // attributes to `__( 'Search' )` meaning that many posts contain `<!--
18
22
  // wp:search /-->`. Support these by defaulting an undefined label and
@@ -70,10 +74,26 @@ function render_block_core_search( $attributes ) {
70
74
  $input->set_attribute( 'id', $input_id );
71
75
  $input->set_attribute( 'value', get_search_query() );
72
76
  $input->set_attribute( 'placeholder', $attributes['placeholder'] );
73
- if ( 'button-only' === $button_position && 'expand-searchfield' === $button_behavior ) {
77
+
78
+ $is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
79
+ if ( $is_expandable_searchfield ) {
74
80
  $input->set_attribute( 'aria-hidden', 'true' );
75
81
  $input->set_attribute( 'tabindex', '-1' );
76
- wp_enqueue_script( 'wp-block--search-view', plugins_url( 'search/view.min.js', __FILE__ ) );
82
+ }
83
+
84
+ // If the script already exists, there is no point in removing it from viewScript.
85
+ $view_js_file = 'wp-block-search-view';
86
+ if ( ! wp_script_is( $view_js_file ) ) {
87
+ $script_handles = $block->block_type->view_script_handles;
88
+
89
+ // If the script is not needed, and it is still in the `view_script_handles`, remove it.
90
+ if ( ! $is_expandable_searchfield && in_array( $view_js_file, $script_handles, true ) ) {
91
+ $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
92
+ }
93
+ // If the script is needed, but it was previously removed, add it again.
94
+ if ( $is_expandable_searchfield && ! in_array( $view_js_file, $script_handles, true ) ) {
95
+ $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
96
+ }
77
97
  }
78
98
  }
79
99
 
@@ -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
  }