Changeset 53404
- Timestamp:
- 05/17/2022 02:36:22 PM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/edit-form-blocks.php
r53197 r53404 210 210 ); 211 211 212 // Add additional back-compat patterns registered by `current_screen` et al. 213 $editor_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true ); 214 $editor_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true ); 215 212 216 $autosave = wp_get_post_autosave( $post->ID ); 213 217 if ( $autosave ) { -
trunk/src/wp-admin/site-editor.php
r53197 r53404 69 69 '__unstableHomeTemplate' => $home_template, 70 70 ); 71 72 // Add additional back-compat patterns registered by `current_screen` et al. 73 $custom_settings['__experimentalAdditionalBlockPatterns'] = WP_Block_Patterns_Registry::get_instance()->get_all_registered( true ); 74 $custom_settings['__experimentalAdditionalBlockPatternCategories'] = WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered( true ); 75 71 76 $editor_settings = get_block_editor_settings( $custom_settings, $block_editor_context ); 72 77 -
trunk/src/wp-includes/class-wp-block-pattern-categories-registry.php
r53299 r53404 19 19 */ 20 20 private $registered_categories = array(); 21 22 /** 23 * Pattern categories registered outside the `init` action. 24 * 25 * @since 6.0.0 26 * @var array[] 27 */ 28 private $registered_categories_outside_init = array(); 21 29 22 30 /** … … 51 59 } 52 60 53 $ this->registered_categories[ $category_name ]= array_merge(61 $category = array_merge( 54 62 array( 'name' => $category_name ), 55 63 $category_properties 56 64 ); 65 66 $this->registered_categories[ $category_name ] = $category; 67 68 // If the category is registered inside an action other than `init`, store it 69 // also to a dedicated array. Used to detect deprecated registrations inside 70 // `admin_init` or `current_screen`. 71 if ( current_action() && 'init' !== current_action() ) { 72 $this->registered_categories_outside_init[ $category_name ] = $category; 73 } 57 74 58 75 return true; … … 79 96 80 97 unset( $this->registered_categories[ $category_name ] ); 98 unset( $this->registered_categories_outside_init[ $category_name ] ); 81 99 82 100 return true; … … 104 122 * @since 5.5.0 105 123 * 124 * @param bool $outside_init_only Return only categories registered outside the `init` action. 106 125 * @return array[] Array of arrays containing the registered pattern categories properties. 107 126 */ 108 public function get_all_registered() { 109 return array_values( $this->registered_categories ); 127 public function get_all_registered( $outside_init_only = false ) { 128 return array_values( 129 $outside_init_only 130 ? $this->registered_categories_outside_init 131 : $this->registered_categories 132 ); 110 133 } 111 134 -
trunk/src/wp-includes/class-wp-block-patterns-registry.php
r53299 r53404 21 21 */ 22 22 private $registered_patterns = array(); 23 24 /** 25 * Patterns registered outside the `init` action. 26 * 27 * @since 6.0.0 28 * @var array[] 29 */ 30 private $registered_patterns_outside_init = array(); 23 31 24 32 /** … … 93 101 } 94 102 95 $ this->registered_patterns[ $pattern_name ]= array_merge(103 $pattern = array_merge( 96 104 $pattern_properties, 97 105 array( 'name' => $pattern_name ) 98 106 ); 107 $this->registered_patterns[ $pattern_name ] = $pattern; 108 109 // If the pattern is registered inside an action other than `init`, store it 110 // also to a dedicated array. Used to detect deprecated registrations inside 111 // `admin_init` or `current_screen`. 112 if ( current_action() && 'init' !== current_action() ) { 113 $this->registered_patterns_outside_init[ $pattern_name ] = $pattern; 114 } 99 115 100 116 return true; … … 121 137 122 138 unset( $this->registered_patterns[ $pattern_name ] ); 139 unset( $this->registered_patterns_outside_init[ $pattern_name ] ); 123 140 124 141 return true; … … 146 163 * @since 5.5.0 147 164 * 165 * @param bool $outside_init_only Return only patterns registered outside the `init` action. 148 166 * @return array[] Array of arrays containing the registered block patterns properties, 149 167 * and per style. 150 168 */ 151 public function get_all_registered() { 152 return array_values( $this->registered_patterns ); 169 public function get_all_registered( $outside_init_only = false ) { 170 return array_values( 171 $outside_init_only 172 ? $this->registered_patterns_outside_init 173 : $this->registered_patterns 174 ); 153 175 } 154 176
Note: See TracChangeset
for help on using the changeset viewer.