wp/wp-includes/block-supports/align.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
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_alignment_support( $block_type ) {
    17 function wp_register_alignment_support( $block_type ) {
    18 	$has_align_support = block_has_support( $block_type, array( 'align' ), false );
    18 	$has_align_support = block_has_support( $block_type, 'align', false );
    19 	if ( $has_align_support ) {
    19 	if ( $has_align_support ) {
    20 		if ( ! $block_type->attributes ) {
    20 		if ( ! $block_type->attributes ) {
    21 			$block_type->attributes = array();
    21 			$block_type->attributes = array();
    22 		}
    22 		}
    23 
    23 
    41  * @param array         $block_attributes Block attributes.
    41  * @param array         $block_attributes Block attributes.
    42  * @return array Block alignment CSS classes and inline styles.
    42  * @return array Block alignment CSS classes and inline styles.
    43  */
    43  */
    44 function wp_apply_alignment_support( $block_type, $block_attributes ) {
    44 function wp_apply_alignment_support( $block_type, $block_attributes ) {
    45 	$attributes        = array();
    45 	$attributes        = array();
    46 	$has_align_support = block_has_support( $block_type, array( 'align' ), false );
    46 	$has_align_support = block_has_support( $block_type, 'align', false );
    47 	if ( $has_align_support ) {
    47 	if ( $has_align_support ) {
    48 		$has_block_alignment = array_key_exists( 'align', $block_attributes );
    48 		$has_block_alignment = array_key_exists( 'align', $block_attributes );
    49 
    49 
    50 		if ( $has_block_alignment ) {
    50 		if ( $has_block_alignment ) {
    51 			$attributes['class'] = sprintf( 'align%s', $block_attributes['align'] );
    51 			$attributes['class'] = sprintf( 'align%s', $block_attributes['align'] );