Edit File by line
/home/zeestwma/richards.../wp-inclu.../block-su...
File: shadow.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Shadow block support flag.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 6.3.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Registers the style and shadow block attributes for block types that support it.
[9] Fix | Delete
*
[10] Fix | Delete
* @since 6.3.0
[11] Fix | Delete
* @access private
[12] Fix | Delete
*
[13] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[14] Fix | Delete
*/
[15] Fix | Delete
function wp_register_shadow_support( $block_type ) {
[16] Fix | Delete
$has_shadow_support = block_has_support( $block_type, 'shadow', false );
[17] Fix | Delete
[18] Fix | Delete
if ( ! $has_shadow_support ) {
[19] Fix | Delete
return;
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
if ( ! $block_type->attributes ) {
[23] Fix | Delete
$block_type->attributes = array();
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
if ( array_key_exists( 'style', $block_type->attributes ) ) {
[27] Fix | Delete
$block_type->attributes['style'] = array(
[28] Fix | Delete
'type' => 'object',
[29] Fix | Delete
);
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
if ( array_key_exists( 'shadow', $block_type->attributes ) ) {
[33] Fix | Delete
$block_type->attributes['shadow'] = array(
[34] Fix | Delete
'type' => 'string',
[35] Fix | Delete
);
[36] Fix | Delete
}
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Add CSS classes and inline styles for shadow features to the incoming attributes array.
[41] Fix | Delete
* This will be applied to the block markup in the front-end.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 6.3.0
[44] Fix | Delete
* @since 6.6.0 Return early if __experimentalSkipSerialization is true.
[45] Fix | Delete
* @access private
[46] Fix | Delete
*
[47] Fix | Delete
* @param WP_Block_Type $block_type Block type.
[48] Fix | Delete
* @param array $block_attributes Block attributes.
[49] Fix | Delete
* @return array Shadow CSS classes and inline styles.
[50] Fix | Delete
*/
[51] Fix | Delete
function wp_apply_shadow_support( $block_type, $block_attributes ) {
[52] Fix | Delete
$has_shadow_support = block_has_support( $block_type, 'shadow', false );
[53] Fix | Delete
[54] Fix | Delete
if (
[55] Fix | Delete
! $has_shadow_support ||
[56] Fix | Delete
wp_should_skip_block_supports_serialization( $block_type, 'shadow' )
[57] Fix | Delete
) {
[58] Fix | Delete
return array();
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
$shadow_block_styles = array();
[62] Fix | Delete
[63] Fix | Delete
$custom_shadow = $block_attributes['style']['shadow'] ?? null;
[64] Fix | Delete
$shadow_block_styles['shadow'] = $custom_shadow;
[65] Fix | Delete
[66] Fix | Delete
$attributes = array();
[67] Fix | Delete
$styles = wp_style_engine_get_styles( $shadow_block_styles );
[68] Fix | Delete
[69] Fix | Delete
if ( ! empty( $styles['css'] ) ) {
[70] Fix | Delete
$attributes['style'] = $styles['css'];
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return $attributes;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
// Register the block support.
[77] Fix | Delete
WP_Block_Supports::get_instance()->register(
[78] Fix | Delete
'shadow',
[79] Fix | Delete
array(
[80] Fix | Delete
'register_attribute' => 'wp_register_shadow_support',
[81] Fix | Delete
'apply' => 'wp_apply_shadow_support',
[82] Fix | Delete
)
[83] Fix | Delete
);
[84] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function