Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-inclu.../block-su...
File: colors.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Colors block support flag.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 5.6.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Registers the style and colors block attributes for block types that support it.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 5.6.0
[11] Fix | Delete
* @since 6.1.0 Improved $color_support assignment optimization.
[12] Fix | Delete
* @access private
[13] Fix | Delete
*
[14] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[15] Fix | Delete
*/
[16] Fix | Delete
function wp_register_colors_support( $block_type ) {
[17] Fix | Delete
$color_support = false;
[18] Fix | Delete
if ( $block_type instanceof WP_Block_Type ) {
[19] Fix | Delete
$color_support = isset( $block_type->supports['color'] ) ? $block_type->supports['color'] : false;
[20] Fix | Delete
}
[21] Fix | Delete
$has_text_colors_support = true === $color_support ||
[22] Fix | Delete
( isset( $color_support['text'] ) && $color_support['text'] ) ||
[23] Fix | Delete
( is_array( $color_support ) && ! isset( $color_support['text'] ) );
[24] Fix | Delete
$has_background_colors_support = true === $color_support ||
[25] Fix | Delete
( isset( $color_support['background'] ) && $color_support['background'] ) ||
[26] Fix | Delete
( is_array( $color_support ) && ! isset( $color_support['background'] ) );
[27] Fix | Delete
$has_gradients_support = isset( $color_support['gradients'] ) ? $color_support['gradients'] : false;
[28] Fix | Delete
$has_link_colors_support = isset( $color_support['link'] ) ? $color_support['link'] : false;
[29] Fix | Delete
$has_button_colors_support = isset( $color_support['button'] ) ? $color_support['button'] : false;
[30] Fix | Delete
$has_heading_colors_support = isset( $color_support['heading'] ) ? $color_support['heading'] : false;
[31] Fix | Delete
$has_color_support = $has_text_colors_support ||
[32] Fix | Delete
$has_background_colors_support ||
[33] Fix | Delete
$has_gradients_support ||
[34] Fix | Delete
$has_link_colors_support ||
[35] Fix | Delete
$has_button_colors_support ||
[36] Fix | Delete
$has_heading_colors_support;
[37] Fix | Delete
[38] Fix | Delete
if ( ! $block_type->attributes ) {
[39] Fix | Delete
$block_type->attributes = array();
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
if ( $has_color_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
[43] Fix | Delete
$block_type->attributes['style'] = array(
[44] Fix | Delete
'type' => 'object',
[45] Fix | Delete
);
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( $has_background_colors_support && ! array_key_exists( 'backgroundColor', $block_type->attributes ) ) {
[49] Fix | Delete
$block_type->attributes['backgroundColor'] = array(
[50] Fix | Delete
'type' => 'string',
[51] Fix | Delete
);
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( $has_text_colors_support && ! array_key_exists( 'textColor', $block_type->attributes ) ) {
[55] Fix | Delete
$block_type->attributes['textColor'] = array(
[56] Fix | Delete
'type' => 'string',
[57] Fix | Delete
);
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
if ( $has_gradients_support && ! array_key_exists( 'gradient', $block_type->attributes ) ) {
[61] Fix | Delete
$block_type->attributes['gradient'] = array(
[62] Fix | Delete
'type' => 'string',
[63] Fix | Delete
);
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Adds CSS classes and inline styles for colors to the incoming attributes array.
[70] Fix | Delete
* This will be applied to the block markup in the front-end.
[71] Fix | Delete
*
[72] Fix | Delete
* @since 5.6.0
[73] Fix | Delete
* @since 6.1.0 Implemented the style engine to generate CSS and classnames.
[74] Fix | Delete
* @access private
[75] Fix | Delete
*
[76] Fix | Delete
* @param WP_Block_Type $block_type Block type.
[77] Fix | Delete
* @param array $block_attributes Block attributes.
[78] Fix | Delete
*
[79] Fix | Delete
* @return array Colors CSS classes and inline styles.
[80] Fix | Delete
*/
[81] Fix | Delete
function wp_apply_colors_support( $block_type, $block_attributes ) {
[82] Fix | Delete
$color_support = isset( $block_type->supports['color'] ) ? $block_type->supports['color'] : false;
[83] Fix | Delete
[84] Fix | Delete
if (
[85] Fix | Delete
is_array( $color_support ) &&
[86] Fix | Delete
wp_should_skip_block_supports_serialization( $block_type, 'color' )
[87] Fix | Delete
) {
[88] Fix | Delete
return array();
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
$has_text_colors_support = true === $color_support ||
[92] Fix | Delete
( isset( $color_support['text'] ) && $color_support['text'] ) ||
[93] Fix | Delete
( is_array( $color_support ) && ! isset( $color_support['text'] ) );
[94] Fix | Delete
$has_background_colors_support = true === $color_support ||
[95] Fix | Delete
( isset( $color_support['background'] ) && $color_support['background'] ) ||
[96] Fix | Delete
( is_array( $color_support ) && ! isset( $color_support['background'] ) );
[97] Fix | Delete
$has_gradients_support = isset( $color_support['gradients'] ) ? $color_support['gradients'] : false;
[98] Fix | Delete
$color_block_styles = array();
[99] Fix | Delete
[100] Fix | Delete
// Text colors.
[101] Fix | Delete
if ( $has_text_colors_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'text' ) ) {
[102] Fix | Delete
$preset_text_color = array_key_exists( 'textColor', $block_attributes ) ? "var:preset|color|{$block_attributes['textColor']}" : null;
[103] Fix | Delete
$custom_text_color = isset( $block_attributes['style']['color']['text'] ) ? $block_attributes['style']['color']['text'] : null;
[104] Fix | Delete
$color_block_styles['text'] = $preset_text_color ? $preset_text_color : $custom_text_color;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
// Background colors.
[108] Fix | Delete
if ( $has_background_colors_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'background' ) ) {
[109] Fix | Delete
$preset_background_color = array_key_exists( 'backgroundColor', $block_attributes ) ? "var:preset|color|{$block_attributes['backgroundColor']}" : null;
[110] Fix | Delete
$custom_background_color = isset( $block_attributes['style']['color']['background'] ) ? $block_attributes['style']['color']['background'] : null;
[111] Fix | Delete
$color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
// Gradients.
[115] Fix | Delete
if ( $has_gradients_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'gradients' ) ) {
[116] Fix | Delete
$preset_gradient_color = array_key_exists( 'gradient', $block_attributes ) ? "var:preset|gradient|{$block_attributes['gradient']}" : null;
[117] Fix | Delete
$custom_gradient_color = isset( $block_attributes['style']['color']['gradient'] ) ? $block_attributes['style']['color']['gradient'] : null;
[118] Fix | Delete
$color_block_styles['gradient'] = $preset_gradient_color ? $preset_gradient_color : $custom_gradient_color;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
$attributes = array();
[122] Fix | Delete
$styles = wp_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) );
[123] Fix | Delete
[124] Fix | Delete
if ( ! empty( $styles['classnames'] ) ) {
[125] Fix | Delete
$attributes['class'] = $styles['classnames'];
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
if ( ! empty( $styles['css'] ) ) {
[129] Fix | Delete
$attributes['style'] = $styles['css'];
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
return $attributes;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
// Register the block support.
[136] Fix | Delete
WP_Block_Supports::get_instance()->register(
[137] Fix | Delete
'colors',
[138] Fix | Delete
array(
[139] Fix | Delete
'register_attribute' => 'wp_register_colors_support',
[140] Fix | Delete
'apply' => 'wp_apply_colors_support',
[141] Fix | Delete
)
[142] Fix | Delete
);
[143] Fix | Delete
[144] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function