wp/wp-includes/block-supports/custom-classname.php
changeset 21 48c4eec2b7e6
parent 18 be944660c56a
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    13  * @access private
    13  * @access private
    14  *
    14  *
    15  * @param WP_Block_Type $block_type Block Type.
    15  * @param WP_Block_Type $block_type Block Type.
    16  */
    16  */
    17 function wp_register_custom_classname_support( $block_type ) {
    17 function wp_register_custom_classname_support( $block_type ) {
    18 	$has_custom_classname_support = block_has_support( $block_type, array( 'customClassName' ), true );
    18 	$has_custom_classname_support = block_has_support( $block_type, 'customClassName', true );
    19 
    19 
    20 	if ( $has_custom_classname_support ) {
    20 	if ( $has_custom_classname_support ) {
    21 		if ( ! $block_type->attributes ) {
    21 		if ( ! $block_type->attributes ) {
    22 			$block_type->attributes = array();
    22 			$block_type->attributes = array();
    23 		}
    23 		}
    29 		}
    29 		}
    30 	}
    30 	}
    31 }
    31 }
    32 
    32 
    33 /**
    33 /**
    34  * Add the custom classnames to the output.
    34  * Adds the custom classnames to the output.
    35  *
    35  *
    36  * @since 5.6.0
    36  * @since 5.6.0
    37  * @access private
    37  * @access private
    38  *
    38  *
    39  * @param  WP_Block_Type $block_type       Block Type.
    39  * @param  WP_Block_Type $block_type       Block Type.
    40  * @param  array         $block_attributes Block attributes.
    40  * @param  array         $block_attributes Block attributes.
    41  *
    41  *
    42  * @return array Block CSS classes and inline styles.
    42  * @return array Block CSS classes and inline styles.
    43  */
    43  */
    44 function wp_apply_custom_classname_support( $block_type, $block_attributes ) {
    44 function wp_apply_custom_classname_support( $block_type, $block_attributes ) {
    45 	$has_custom_classname_support = block_has_support( $block_type, array( 'customClassName' ), true );
    45 	$has_custom_classname_support = block_has_support( $block_type, 'customClassName', true );
    46 	$attributes                   = array();
    46 	$attributes                   = array();
    47 	if ( $has_custom_classname_support ) {
    47 	if ( $has_custom_classname_support ) {
    48 		$has_custom_classnames = array_key_exists( 'className', $block_attributes );
    48 		$has_custom_classnames = array_key_exists( 'className', $block_attributes );
    49 
    49 
    50 		if ( $has_custom_classnames ) {
    50 		if ( $has_custom_classnames ) {