Edit File by line
/home/barbar84/public_h.../wp-inclu.../block-su...
File: align.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Align block support flag.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Registers the align block attribute for block types that support it.
[8] Fix | Delete
*
[9] Fix | Delete
* @access private
[10] Fix | Delete
*
[11] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[12] Fix | Delete
*/
[13] Fix | Delete
function wp_register_alignment_support( $block_type ) {
[14] Fix | Delete
$has_align_support = false;
[15] Fix | Delete
if ( property_exists( $block_type, 'supports' ) ) {
[16] Fix | Delete
$has_align_support = _wp_array_get( $block_type->supports, array( 'align' ), false );
[17] Fix | Delete
}
[18] Fix | Delete
if ( $has_align_support ) {
[19] Fix | Delete
if ( ! $block_type->attributes ) {
[20] Fix | Delete
$block_type->attributes = array();
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
if ( ! array_key_exists( 'align', $block_type->attributes ) ) {
[24] Fix | Delete
$block_type->attributes['align'] = array(
[25] Fix | Delete
'type' => 'string',
[26] Fix | Delete
'enum' => array( 'left', 'center', 'right', 'wide', 'full', '' ),
[27] Fix | Delete
);
[28] Fix | Delete
}
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Add CSS classes for block alignment to the incoming attributes array.
[34] Fix | Delete
* This will be applied to the block markup in the front-end.
[35] Fix | Delete
*
[36] Fix | Delete
* @access private
[37] Fix | Delete
*
[38] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[39] Fix | Delete
* @param array $block_attributes Block attributes.
[40] Fix | Delete
*
[41] Fix | Delete
* @return array Block alignment CSS classes and inline styles.
[42] Fix | Delete
*/
[43] Fix | Delete
function wp_apply_alignment_support( $block_type, $block_attributes ) {
[44] Fix | Delete
$attributes = array();
[45] Fix | Delete
$has_align_support = false;
[46] Fix | Delete
if ( property_exists( $block_type, 'supports' ) ) {
[47] Fix | Delete
$has_align_support = _wp_array_get( $block_type->supports, array( 'align' ), false );
[48] Fix | Delete
}
[49] Fix | Delete
if ( $has_align_support ) {
[50] Fix | Delete
$has_block_alignment = array_key_exists( 'align', $block_attributes );
[51] Fix | Delete
[52] Fix | Delete
if ( $has_block_alignment ) {
[53] Fix | Delete
$attributes['class'] = sprintf( 'align%s', $block_attributes['align'] );
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
return $attributes;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
// Register the block support.
[61] Fix | Delete
WP_Block_Supports::get_instance()->register(
[62] Fix | Delete
'align',
[63] Fix | Delete
array(
[64] Fix | Delete
'register_attribute' => 'wp_register_alignment_support',
[65] Fix | Delete
'apply' => 'wp_apply_alignment_support',
[66] Fix | Delete
)
[67] Fix | Delete
);
[68] Fix | Delete
[69] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function