- Timestamp:
- 05/17/2022 02:36:22 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.