Make WordPress Core


Ignore:
Timestamp:
11/12/2020 08:18:08 PM (4 years ago)
Author:
johnbillion
Message:

General: Convert wp_array_get() to a "private" function and add tests.

This function may be promoted in the future if it's deemed useful enough.

Props dd32, jorgefilipecosta, Hareesh Pillai

Fixes #51720

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/colors.php

    r49226 r49580  
    1616    $color_support = false;
    1717    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 );
    1919    }
    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 );
    2323
    2424    if ( ! $block_type->attributes ) {
     
    6464 */
    6565function 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 );
    7171    $classes                       = array();
    7272    $styles                        = array();
Note: See TracChangeset for help on using the changeset viewer.