Make WordPress Core

Changeset 56126


Ignore:
Timestamp:
07/03/2023 06:55:58 AM (21 months ago)
Author:
isabel_brison
Message:

Editor: adds deprecation for deleted block_core_navigation_submenu_build_css_colors function.

Adds the block_core_navigation_submenu_build_css_colors function to wp-includes/deprecated.php. Follow-up to #58623.

Props ramonopoly, peterwilsoncc.
See #58623.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/deprecated.php

    r56112 r56126  
    52915291    }
    52925292}
     5293
     5294/**
     5295 * Build an array with CSS classes and inline styles defining the colors
     5296 * which will be applied to the navigation markup in the front-end.
     5297 *
     5298 * @since 5.9.0
     5299 * @deprecated 6.3.0 This was removed from the Navigation Submenu block in favour of `wp_apply_colors_support()`.
     5300 *                   `wp_apply_colors_support()` returns an array with similar class and style values,
     5301 *                   but with different keys: `class` and `style`.
     5302 *
     5303 * @param  array $context     Navigation block context.
     5304 * @param  array $attributes  Block attributes.
     5305 * @param  bool  $is_sub_menu Whether the block is a sub-menu.
     5306 * @return array Colors CSS classes and inline styles.
     5307 */
     5308function block_core_navigation_submenu_build_css_colors( $context, $attributes, $is_sub_menu = false ) {
     5309    _deprecated_function( __FUNCTION__, '6.3.0' );
     5310    $colors = array(
     5311        'css_classes'   => array(),
     5312        'inline_styles' => '',
     5313    );
     5314
     5315    // Text color.
     5316    $named_text_color  = null;
     5317    $custom_text_color = null;
     5318
     5319    if ( $is_sub_menu && array_key_exists( 'customOverlayTextColor', $context ) ) {
     5320        $custom_text_color = $context['customOverlayTextColor'];
     5321    } elseif ( $is_sub_menu && array_key_exists( 'overlayTextColor', $context ) ) {
     5322        $named_text_color = $context['overlayTextColor'];
     5323    } elseif ( array_key_exists( 'customTextColor', $context ) ) {
     5324        $custom_text_color = $context['customTextColor'];
     5325    } elseif ( array_key_exists( 'textColor', $context ) ) {
     5326        $named_text_color = $context['textColor'];
     5327    } elseif ( isset( $context['style']['color']['text'] ) ) {
     5328        $custom_text_color = $context['style']['color']['text'];
     5329    }
     5330
     5331    // If has text color.
     5332    if ( ! is_null( $named_text_color ) ) {
     5333        // Add the color class.
     5334        array_push( $colors['css_classes'], 'has-text-color', sprintf( 'has-%s-color', $named_text_color ) );
     5335    } elseif ( ! is_null( $custom_text_color ) ) {
     5336        // Add the custom color inline style.
     5337        $colors['css_classes'][]  = 'has-text-color';
     5338        $colors['inline_styles'] .= sprintf( 'color: %s;', $custom_text_color );
     5339    }
     5340
     5341    // Background color.
     5342    $named_background_color  = null;
     5343    $custom_background_color = null;
     5344
     5345    if ( $is_sub_menu && array_key_exists( 'customOverlayBackgroundColor', $context ) ) {
     5346        $custom_background_color = $context['customOverlayBackgroundColor'];
     5347    } elseif ( $is_sub_menu && array_key_exists( 'overlayBackgroundColor', $context ) ) {
     5348        $named_background_color = $context['overlayBackgroundColor'];
     5349    } elseif ( array_key_exists( 'customBackgroundColor', $context ) ) {
     5350        $custom_background_color = $context['customBackgroundColor'];
     5351    } elseif ( array_key_exists( 'backgroundColor', $context ) ) {
     5352        $named_background_color = $context['backgroundColor'];
     5353    } elseif ( isset( $context['style']['color']['background'] ) ) {
     5354        $custom_background_color = $context['style']['color']['background'];
     5355    }
     5356
     5357    // If has background color.
     5358    if ( ! is_null( $named_background_color ) ) {
     5359        // Add the background-color class.
     5360        array_push( $colors['css_classes'], 'has-background', sprintf( 'has-%s-background-color', $named_background_color ) );
     5361    } elseif ( ! is_null( $custom_background_color ) ) {
     5362        // Add the custom background-color inline style.
     5363        $colors['css_classes'][]  = 'has-background';
     5364        $colors['inline_styles'] .= sprintf( 'background-color: %s;', $custom_background_color );
     5365    }
     5366
     5367    return $colors;
     5368}
Note: See TracChangeset for help on using the changeset viewer.