Changeset 57683
- Timestamp:
- 02/21/2024 06:48:30 PM (6 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-patterns.php
r57353 r57683 392 392 } 393 393 394 // The actual pattern content is the output of the file. 395 ob_start(); 396 include $file_path; 397 $pattern_data['content'] = ob_get_clean(); 398 if ( ! $pattern_data['content'] ) { 399 continue; 400 } 394 $pattern_data['file_path'] = $file_path; 401 395 402 396 // Translate the pattern metadata. -
trunk/src/wp-includes/class-wp-block-patterns-registry.php
r56960 r57683 102 102 } 103 103 104 if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) { 105 _doing_it_wrong( 106 __METHOD__, 107 __( 'Pattern content must be a string.' ), 108 '5.5.0' 109 ); 110 return false; 104 if ( ! isset( $pattern_properties['file_path'] ) ) { 105 if ( ! isset( $pattern_properties['content'] ) || ! is_string( $pattern_properties['content'] ) ) { 106 _doing_it_wrong( 107 __METHOD__, 108 __( 'Pattern content must be a string.' ), 109 '5.5.0' 110 ); 111 return false; 112 } 111 113 } 112 114 … … 179 181 180 182 /** 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 181 207 * Retrieves an array containing the properties of a registered block pattern. 182 208 * … … 192 218 193 219 $pattern = $this->registered_patterns[ $pattern_name ]; 220 194 221 $pattern['content'] = $this->prepare_content( $pattern, get_hooked_blocks() ); 195 222 … … 207 234 */ 208 235 public function get_all_registered( $outside_init_only = false ) { 209 $patterns = array_values( 210 $outside_init_only 236 $patterns = $outside_init_only 211 237 ? $this->registered_patterns_outside_init 212 : $this->registered_patterns 213 ); 238 : $this->registered_patterns; 214 239 $hooked_blocks = get_hooked_blocks(); 240 215 241 foreach ( $patterns as $index => $pattern ) { 242 216 243 $patterns[ $index ]['content'] = $this->prepare_content( $pattern, $hooked_blocks ); 217 244 } 218 return $patterns; 245 246 return array_values( $patterns ); 219 247 } 220 248
Note: See TracChangeset
for help on using the changeset viewer.