Changeset 49580
- Timestamp:
- 11/12/2020 08:18:08 PM (4 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/align.php
r49226 r49580 16 16 $has_align_support = false; 17 17 if ( property_exists( $block_type, 'supports' ) ) { 18 $has_align_support = wp_array_get( $block_type->supports, array( 'align' ), false );18 $has_align_support = _wp_array_get( $block_type->supports, array( 'align' ), false ); 19 19 } 20 20 if ( $has_align_support ) { … … 47 47 $has_align_support = false; 48 48 if ( property_exists( $block_type, 'supports' ) ) { 49 $has_align_support = wp_array_get( $block_type->supports, array( 'align' ), false );49 $has_align_support = _wp_array_get( $block_type->supports, array( 'align' ), false ); 50 50 } 51 51 if ( $has_align_support ) { -
trunk/src/wp-includes/block-supports/colors.php
r49226 r49580 16 16 $color_support = false; 17 17 if ( property_exists( $block_type, 'supports' ) ) { 18 $color_support = wp_array_get( $block_type->supports, array( '__experimentalColor' ), false );18 $color_support = _wp_array_get( $block_type->supports, array( '__experimentalColor' ), false ); 19 19 } 20 $has_text_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'text' ), true ) );21 $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'background' ), true ) );22 $has_gradients_support = wp_array_get( $color_support, array( 'gradients' ), false );20 $has_text_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'text' ), true ) ); 21 $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) ); 22 $has_gradients_support = _wp_array_get( $color_support, array( 'gradients' ), false ); 23 23 24 24 if ( ! $block_type->attributes ) { … … 64 64 */ 65 65 function wp_apply_colors_support( $block_type, $block_attributes ) { 66 $color_support = wp_array_get( $block_type->supports, array( '__experimentalColor' ), false );67 $has_text_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'text' ), true ) );68 $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && wp_array_get( $color_support, array( 'background' ), true ) );69 $has_link_colors_support = wp_array_get( $color_support, array( 'linkColor' ), false );70 $has_gradients_support = wp_array_get( $color_support, array( 'gradients' ), false );66 $color_support = _wp_array_get( $block_type->supports, array( '__experimentalColor' ), false ); 67 $has_text_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'text' ), true ) ); 68 $has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) ); 69 $has_link_colors_support = _wp_array_get( $color_support, array( 'linkColor' ), false ); 70 $has_gradients_support = _wp_array_get( $color_support, array( 'gradients' ), false ); 71 71 $classes = array(); 72 72 $styles = array(); -
trunk/src/wp-includes/block-supports/custom-classname.php
r49226 r49580 16 16 $has_custom_classname_support = true; 17 17 if ( property_exists( $block_type, 'supports' ) ) { 18 $has_custom_classname_support = wp_array_get( $block_type->supports, array( 'customClassName' ), true );18 $has_custom_classname_support = _wp_array_get( $block_type->supports, array( 'customClassName' ), true ); 19 19 } 20 20 if ( $has_custom_classname_support ) { … … 45 45 $attributes = array(); 46 46 if ( property_exists( $block_type, 'supports' ) ) { 47 $has_custom_classname_support = wp_array_get( $block_type->supports, array( 'customClassName' ), true );47 $has_custom_classname_support = _wp_array_get( $block_type->supports, array( 'customClassName' ), true ); 48 48 } 49 49 if ( $has_custom_classname_support ) { -
trunk/src/wp-includes/block-supports/generated-classname.php
r49226 r49580 48 48 $attributes = array(); 49 49 if ( property_exists( $block_type, 'supports' ) ) { 50 $has_generated_classname_support = wp_array_get( $block_type->supports, array( 'className' ), true );50 $has_generated_classname_support = _wp_array_get( $block_type->supports, array( 'className' ), true ); 51 51 } 52 52 if ( $has_generated_classname_support ) { -
trunk/src/wp-includes/block-supports/typography.php
r49226 r49580 16 16 $has_font_size_support = false; 17 17 if ( property_exists( $block_type, 'supports' ) ) { 18 $has_font_size_support = wp_array_get( $block_type->supports, array( '__experimentalFontSize' ), false );18 $has_font_size_support = _wp_array_get( $block_type->supports, array( '__experimentalFontSize' ), false ); 19 19 } 20 20 21 21 $has_line_height_support = false; 22 22 if ( property_exists( $block_type, 'supports' ) ) { 23 $has_line_height_support = wp_array_get( $block_type->supports, array( '__experimentalLineHeight' ), false );23 $has_line_height_support = _wp_array_get( $block_type->supports, array( '__experimentalLineHeight' ), false ); 24 24 } 25 25 … … 57 57 $styles = array(); 58 58 if ( property_exists( $block_type, 'supports' ) ) { 59 $has_font_size_support = wp_array_get( $block_type->supports, array( 'fontSize' ), false );59 $has_font_size_support = _wp_array_get( $block_type->supports, array( 'fontSize' ), false ); 60 60 } 61 61 62 62 $has_line_height_support = false; 63 63 if ( property_exists( $block_type, 'supports' ) ) { 64 $has_line_height_support = wp_array_get( $block_type->supports, array( 'lineHeight' ), false );64 $has_line_height_support = _wp_array_get( $block_type->supports, array( 'lineHeight' ), false ); 65 65 } 66 66 -
trunk/src/wp-includes/functions.php
r49552 r49580 4529 4529 * Accesses an array in depth based on a path of keys. 4530 4530 * 4531 * It is the PHP equivalent of JavaScript's lodash.get,and mirroring it may help other components4531 * It is the PHP equivalent of JavaScript's `lodash.get()` and mirroring it may help other components 4532 4532 * retain some symmetry between client and server implementations. 4533 4533 * 4534 * Example usage: 4535 * 4536 * $array = array( 4537 * 'a' => array( 4538 * 'b' => array( 4539 * 'c' => 1, 4540 * ), 4541 * ), 4542 * ); 4543 * _wp_array_get( $array, array( 'a', 'b', 'c' ); 4544 * 4545 * @internal 4546 * 4534 4547 * @since 5.6.0 4548 * @access private 4535 4549 * 4536 4550 * @param array $array An array from which we want to retrieve some information. 4537 4551 * @param array $path An array of keys describing the path with which to retrieve information. 4538 * @param array $default The return value if the path is not set on the array,4539 * or if the types of array and pathare not arrays.4540 * @return array An array matchingthe path specified.4541 */ 4542 function wp_array_get( $array, $path, $default = array()) {4543 // Confirm input values are expected type to avoid notice warnings.4544 if ( ! is_array( $ array ) || ! is_array( $path ) ) {4552 * @param mixed $default The return value if the path does not exist within the array, 4553 * or if `$array` or `$path` are not arrays. 4554 * @return mixed The value from the path specified. 4555 */ 4556 function _wp_array_get( $array, $path, $default = null ) { 4557 // Confirm $path is valid. 4558 if ( ! is_array( $path ) || 0 === count( $path ) ) { 4545 4559 return $default; 4546 4560 } 4547 4561 4548 $path_length = count( $path ); 4549 4550 for ( $i = 0; $i < $path_length; ++$i ) { 4551 if ( ! isset( $array[ $path[ $i ] ] ) ) { 4562 foreach ( $path as $path_element ) { 4563 if ( 4564 ! is_array( $array ) || 4565 ( ! is_string( $path_element ) && ! is_integer( $path_element ) && ! is_null( $path_element ) ) || 4566 ! array_key_exists( $path_element, $array ) 4567 ) { 4552 4568 return $default; 4553 4569 } 4554 $array = $array[ $path [ $i ]];4570 $array = $array[ $path_element ]; 4555 4571 } 4556 4572
Note: See TracChangeset
for help on using the changeset viewer.