Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu.../block-su...
File: spacing.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Spacing block support flag.
[2] Fix | Delete
*
[3] Fix | Delete
* For backwards compatibility, this remains separate to the dimensions.php
[4] Fix | Delete
* block support despite both belonging under a single panel in the editor.
[5] Fix | Delete
*
[6] Fix | Delete
* @package WordPress
[7] Fix | Delete
* @since 5.8.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Registers the style block attribute for block types that support it.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 5.8.0
[14] Fix | Delete
* @access private
[15] Fix | Delete
*
[16] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[17] Fix | Delete
*/
[18] Fix | Delete
function wp_register_spacing_support( $block_type ) {
[19] Fix | Delete
$has_spacing_support = block_has_support( $block_type, 'spacing', false );
[20] Fix | Delete
[21] Fix | Delete
// Setup attributes and styles within that if needed.
[22] Fix | Delete
if ( ! $block_type->attributes ) {
[23] Fix | Delete
$block_type->attributes = array();
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
if ( $has_spacing_support && ! 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
[33] Fix | Delete
/**
[34] Fix | Delete
* Adds CSS classes for block spacing to the incoming attributes array.
[35] Fix | Delete
* This will be applied to the block markup in the front-end.
[36] Fix | Delete
*
[37] Fix | Delete
* @since 5.8.0
[38] Fix | Delete
* @since 6.1.0 Implemented the style engine to generate CSS and classnames.
[39] Fix | Delete
* @access private
[40] Fix | Delete
*
[41] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[42] Fix | Delete
* @param array $block_attributes Block attributes.
[43] Fix | Delete
* @return array Block spacing CSS classes and inline styles.
[44] Fix | Delete
*/
[45] Fix | Delete
function wp_apply_spacing_support( $block_type, $block_attributes ) {
[46] Fix | Delete
if ( wp_should_skip_block_supports_serialization( $block_type, 'spacing' ) ) {
[47] Fix | Delete
return array();
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
$attributes = array();
[51] Fix | Delete
$has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
[52] Fix | Delete
$has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false );
[53] Fix | Delete
$block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null;
[54] Fix | Delete
[55] Fix | Delete
if ( ! $block_styles ) {
[56] Fix | Delete
return $attributes;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
$skip_padding = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'padding' );
[60] Fix | Delete
$skip_margin = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'margin' );
[61] Fix | Delete
$spacing_block_styles = array(
[62] Fix | Delete
'padding' => null,
[63] Fix | Delete
'margin' => null,
[64] Fix | Delete
);
[65] Fix | Delete
if ( $has_padding_support && ! $skip_padding ) {
[66] Fix | Delete
$spacing_block_styles['padding'] = isset( $block_styles['spacing']['padding'] ) ? $block_styles['spacing']['padding'] : null;
[67] Fix | Delete
}
[68] Fix | Delete
if ( $has_margin_support && ! $skip_margin ) {
[69] Fix | Delete
$spacing_block_styles['margin'] = isset( $block_styles['spacing']['margin'] ) ? $block_styles['spacing']['margin'] : null;
[70] Fix | Delete
}
[71] Fix | Delete
$styles = wp_style_engine_get_styles( array( 'spacing' => $spacing_block_styles ) );
[72] Fix | Delete
[73] Fix | Delete
if ( ! empty( $styles['css'] ) ) {
[74] Fix | Delete
$attributes['style'] = $styles['css'];
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
return $attributes;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
// Register the block support.
[81] Fix | Delete
WP_Block_Supports::get_instance()->register(
[82] Fix | Delete
'spacing',
[83] Fix | Delete
array(
[84] Fix | Delete
'register_attribute' => 'wp_register_spacing_support',
[85] Fix | Delete
'apply' => 'wp_apply_spacing_support',
[86] Fix | Delete
)
[87] Fix | Delete
);
[88] Fix | Delete
[89] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function