Make WordPress Core


Ignore:
Timestamp:
05/17/2022 03:41:28 PM (4 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages for 6.0 RC 3

[53402] Theme: Use a better method to determine the theme name during export

[53403] Editor: Update WordPress packages for 6.0 RC 3

[53404] Editor: Return additional block patterns to server-generated settings

Props SergeyBiryukov, scruffian, davidbaumwald, jeremyfelt, zieladam, ndiego, jsnajdr, peterwilsoncc, johnstonphilip.
Merges [53402], [53403] and [53404] to the 6.0 branch.
Fixes #55567.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/class-wp-block-patterns-registry.php

    r53299 r53405  
    2121         */
    2222        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();
    2331
    2432        /**
     
    93101                }
    94102
    95                 $this->registered_patterns[ $pattern_name ] = array_merge(
     103                $pattern = array_merge(
    96104                        $pattern_properties,
    97105                        array( 'name' => $pattern_name )
    98106                );
     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                }
    99115
    100116                return true;
     
    121137
    122138                unset( $this->registered_patterns[ $pattern_name ] );
     139                unset( $this->registered_patterns_outside_init[ $pattern_name ] );
    123140
    124141                return true;
     
    146163         * @since 5.5.0
    147164         *
     165         * @param bool $outside_init_only Return only patterns registered outside the `init` action.
    148166         * @return array[] Array of arrays containing the registered block patterns properties,
    149167         *                 and per style.
    150168         */
    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                );
    153175        }
    154176
Note: See TracChangeset for help on using the changeset viewer.