Edit File by line
/home/zeestwma/richards.../wp-inclu.../block-su...
File: layout.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Layout block support flag.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 5.8.0
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Returns layout definitions, keyed by layout type.
[9] Fix | Delete
*
[10] Fix | Delete
* Provides a common definition of slugs, classnames, base styles, and spacing styles for each layout type.
[11] Fix | Delete
* When making changes or additions to layout definitions, the corresponding JavaScript definitions should
[12] Fix | Delete
* also be updated.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 6.3.0
[15] Fix | Delete
* @since 6.6.0 Updated specificity for compatibility with 0-1-0 global styles specificity.
[16] Fix | Delete
* @access private
[17] Fix | Delete
*
[18] Fix | Delete
* @return array[] Layout definitions.
[19] Fix | Delete
*/
[20] Fix | Delete
function wp_get_layout_definitions() {
[21] Fix | Delete
$layout_definitions = array(
[22] Fix | Delete
'default' => array(
[23] Fix | Delete
'name' => 'default',
[24] Fix | Delete
'slug' => 'flow',
[25] Fix | Delete
'className' => 'is-layout-flow',
[26] Fix | Delete
'baseStyles' => array(
[27] Fix | Delete
array(
[28] Fix | Delete
'selector' => ' > .alignleft',
[29] Fix | Delete
'rules' => array(
[30] Fix | Delete
'float' => 'left',
[31] Fix | Delete
'margin-inline-start' => '0',
[32] Fix | Delete
'margin-inline-end' => '2em',
[33] Fix | Delete
),
[34] Fix | Delete
),
[35] Fix | Delete
array(
[36] Fix | Delete
'selector' => ' > .alignright',
[37] Fix | Delete
'rules' => array(
[38] Fix | Delete
'float' => 'right',
[39] Fix | Delete
'margin-inline-start' => '2em',
[40] Fix | Delete
'margin-inline-end' => '0',
[41] Fix | Delete
),
[42] Fix | Delete
),
[43] Fix | Delete
array(
[44] Fix | Delete
'selector' => ' > .aligncenter',
[45] Fix | Delete
'rules' => array(
[46] Fix | Delete
'margin-left' => 'auto !important',
[47] Fix | Delete
'margin-right' => 'auto !important',
[48] Fix | Delete
),
[49] Fix | Delete
),
[50] Fix | Delete
),
[51] Fix | Delete
'spacingStyles' => array(
[52] Fix | Delete
array(
[53] Fix | Delete
'selector' => ' > :first-child',
[54] Fix | Delete
'rules' => array(
[55] Fix | Delete
'margin-block-start' => '0',
[56] Fix | Delete
),
[57] Fix | Delete
),
[58] Fix | Delete
array(
[59] Fix | Delete
'selector' => ' > :last-child',
[60] Fix | Delete
'rules' => array(
[61] Fix | Delete
'margin-block-end' => '0',
[62] Fix | Delete
),
[63] Fix | Delete
),
[64] Fix | Delete
array(
[65] Fix | Delete
'selector' => ' > *',
[66] Fix | Delete
'rules' => array(
[67] Fix | Delete
'margin-block-start' => null,
[68] Fix | Delete
'margin-block-end' => '0',
[69] Fix | Delete
),
[70] Fix | Delete
),
[71] Fix | Delete
),
[72] Fix | Delete
),
[73] Fix | Delete
'constrained' => array(
[74] Fix | Delete
'name' => 'constrained',
[75] Fix | Delete
'slug' => 'constrained',
[76] Fix | Delete
'className' => 'is-layout-constrained',
[77] Fix | Delete
'baseStyles' => array(
[78] Fix | Delete
array(
[79] Fix | Delete
'selector' => ' > .alignleft',
[80] Fix | Delete
'rules' => array(
[81] Fix | Delete
'float' => 'left',
[82] Fix | Delete
'margin-inline-start' => '0',
[83] Fix | Delete
'margin-inline-end' => '2em',
[84] Fix | Delete
),
[85] Fix | Delete
),
[86] Fix | Delete
array(
[87] Fix | Delete
'selector' => ' > .alignright',
[88] Fix | Delete
'rules' => array(
[89] Fix | Delete
'float' => 'right',
[90] Fix | Delete
'margin-inline-start' => '2em',
[91] Fix | Delete
'margin-inline-end' => '0',
[92] Fix | Delete
),
[93] Fix | Delete
),
[94] Fix | Delete
array(
[95] Fix | Delete
'selector' => ' > .aligncenter',
[96] Fix | Delete
'rules' => array(
[97] Fix | Delete
'margin-left' => 'auto !important',
[98] Fix | Delete
'margin-right' => 'auto !important',
[99] Fix | Delete
),
[100] Fix | Delete
),
[101] Fix | Delete
array(
[102] Fix | Delete
'selector' => ' > :where(:not(.alignleft):not(.alignright):not(.alignfull))',
[103] Fix | Delete
'rules' => array(
[104] Fix | Delete
'max-width' => 'var(--wp--style--global--content-size)',
[105] Fix | Delete
'margin-left' => 'auto !important',
[106] Fix | Delete
'margin-right' => 'auto !important',
[107] Fix | Delete
),
[108] Fix | Delete
),
[109] Fix | Delete
array(
[110] Fix | Delete
'selector' => ' > .alignwide',
[111] Fix | Delete
'rules' => array(
[112] Fix | Delete
'max-width' => 'var(--wp--style--global--wide-size)',
[113] Fix | Delete
),
[114] Fix | Delete
),
[115] Fix | Delete
),
[116] Fix | Delete
'spacingStyles' => array(
[117] Fix | Delete
array(
[118] Fix | Delete
'selector' => ' > :first-child',
[119] Fix | Delete
'rules' => array(
[120] Fix | Delete
'margin-block-start' => '0',
[121] Fix | Delete
),
[122] Fix | Delete
),
[123] Fix | Delete
array(
[124] Fix | Delete
'selector' => ' > :last-child',
[125] Fix | Delete
'rules' => array(
[126] Fix | Delete
'margin-block-end' => '0',
[127] Fix | Delete
),
[128] Fix | Delete
),
[129] Fix | Delete
array(
[130] Fix | Delete
'selector' => ' > *',
[131] Fix | Delete
'rules' => array(
[132] Fix | Delete
'margin-block-start' => null,
[133] Fix | Delete
'margin-block-end' => '0',
[134] Fix | Delete
),
[135] Fix | Delete
),
[136] Fix | Delete
),
[137] Fix | Delete
),
[138] Fix | Delete
'flex' => array(
[139] Fix | Delete
'name' => 'flex',
[140] Fix | Delete
'slug' => 'flex',
[141] Fix | Delete
'className' => 'is-layout-flex',
[142] Fix | Delete
'displayMode' => 'flex',
[143] Fix | Delete
'baseStyles' => array(
[144] Fix | Delete
array(
[145] Fix | Delete
'selector' => '',
[146] Fix | Delete
'rules' => array(
[147] Fix | Delete
'flex-wrap' => 'wrap',
[148] Fix | Delete
'align-items' => 'center',
[149] Fix | Delete
),
[150] Fix | Delete
),
[151] Fix | Delete
array(
[152] Fix | Delete
'selector' => ' > :is(*, div)', // :is(*, div) instead of just * increases the specificity by 001.
[153] Fix | Delete
'rules' => array(
[154] Fix | Delete
'margin' => '0',
[155] Fix | Delete
),
[156] Fix | Delete
),
[157] Fix | Delete
),
[158] Fix | Delete
'spacingStyles' => array(
[159] Fix | Delete
array(
[160] Fix | Delete
'selector' => '',
[161] Fix | Delete
'rules' => array(
[162] Fix | Delete
'gap' => null,
[163] Fix | Delete
),
[164] Fix | Delete
),
[165] Fix | Delete
),
[166] Fix | Delete
),
[167] Fix | Delete
'grid' => array(
[168] Fix | Delete
'name' => 'grid',
[169] Fix | Delete
'slug' => 'grid',
[170] Fix | Delete
'className' => 'is-layout-grid',
[171] Fix | Delete
'displayMode' => 'grid',
[172] Fix | Delete
'baseStyles' => array(
[173] Fix | Delete
array(
[174] Fix | Delete
'selector' => ' > :is(*, div)', // :is(*, div) instead of just * increases the specificity by 001.
[175] Fix | Delete
'rules' => array(
[176] Fix | Delete
'margin' => '0',
[177] Fix | Delete
),
[178] Fix | Delete
),
[179] Fix | Delete
),
[180] Fix | Delete
'spacingStyles' => array(
[181] Fix | Delete
array(
[182] Fix | Delete
'selector' => '',
[183] Fix | Delete
'rules' => array(
[184] Fix | Delete
'gap' => null,
[185] Fix | Delete
),
[186] Fix | Delete
),
[187] Fix | Delete
),
[188] Fix | Delete
),
[189] Fix | Delete
);
[190] Fix | Delete
[191] Fix | Delete
return $layout_definitions;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/**
[195] Fix | Delete
* Registers the layout block attribute for block types that support it.
[196] Fix | Delete
*
[197] Fix | Delete
* @since 5.8.0
[198] Fix | Delete
* @since 6.3.0 Check for layout support via the `layout` key with fallback to `__experimentalLayout`.
[199] Fix | Delete
* @access private
[200] Fix | Delete
*
[201] Fix | Delete
* @param WP_Block_Type $block_type Block Type.
[202] Fix | Delete
*/
[203] Fix | Delete
function wp_register_layout_support( $block_type ) {
[204] Fix | Delete
$support_layout = block_has_support( $block_type, 'layout', false ) || block_has_support( $block_type, '__experimentalLayout', false );
[205] Fix | Delete
if ( $support_layout ) {
[206] Fix | Delete
if ( ! $block_type->attributes ) {
[207] Fix | Delete
$block_type->attributes = array();
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
if ( ! array_key_exists( 'layout', $block_type->attributes ) ) {
[211] Fix | Delete
$block_type->attributes['layout'] = array(
[212] Fix | Delete
'type' => 'object',
[213] Fix | Delete
);
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
/**
[219] Fix | Delete
* Generates the CSS corresponding to the provided layout.
[220] Fix | Delete
*
[221] Fix | Delete
* @since 5.9.0
[222] Fix | Delete
* @since 6.1.0 Added `$block_spacing` param, use style engine to enqueue styles.
[223] Fix | Delete
* @since 6.3.0 Added grid layout type.
[224] Fix | Delete
* @since 6.6.0 Removed duplicated selector from layout styles.
[225] Fix | Delete
* Enabled negative margins for alignfull children of blocks with custom padding.
[226] Fix | Delete
* @access private
[227] Fix | Delete
*
[228] Fix | Delete
* @param string $selector CSS selector.
[229] Fix | Delete
* @param array $layout Layout object. The one that is passed has already checked
[230] Fix | Delete
* the existence of default block layout.
[231] Fix | Delete
* @param bool $has_block_gap_support Optional. Whether the theme has support for the block gap. Default false.
[232] Fix | Delete
* @param string|string[]|null $gap_value Optional. The block gap value to apply. Default null.
[233] Fix | Delete
* @param bool $should_skip_gap_serialization Optional. Whether to skip applying the user-defined value set in the editor. Default false.
[234] Fix | Delete
* @param string $fallback_gap_value Optional. The block gap value to apply. Default '0.5em'.
[235] Fix | Delete
* @param array|null $block_spacing Optional. Custom spacing set on the block. Default null.
[236] Fix | Delete
* @return string CSS styles on success. Else, empty string.
[237] Fix | Delete
*/
[238] Fix | Delete
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em', $block_spacing = null ) {
[239] Fix | Delete
$layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';
[240] Fix | Delete
$layout_styles = array();
[241] Fix | Delete
[242] Fix | Delete
if ( 'default' === $layout_type ) {
[243] Fix | Delete
if ( $has_block_gap_support ) {
[244] Fix | Delete
if ( is_array( $gap_value ) ) {
[245] Fix | Delete
$gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null;
[246] Fix | Delete
}
[247] Fix | Delete
if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
[248] Fix | Delete
// Get spacing CSS variable from preset value if provided.
[249] Fix | Delete
if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) {
[250] Fix | Delete
$index_to_splice = strrpos( $gap_value, '|' ) + 1;
[251] Fix | Delete
$slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) );
[252] Fix | Delete
$gap_value = "var(--wp--preset--spacing--$slug)";
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
array_push(
[256] Fix | Delete
$layout_styles,
[257] Fix | Delete
array(
[258] Fix | Delete
'selector' => "$selector > *",
[259] Fix | Delete
'declarations' => array(
[260] Fix | Delete
'margin-block-start' => '0',
[261] Fix | Delete
'margin-block-end' => '0',
[262] Fix | Delete
),
[263] Fix | Delete
),
[264] Fix | Delete
array(
[265] Fix | Delete
'selector' => "$selector > * + *",
[266] Fix | Delete
'declarations' => array(
[267] Fix | Delete
'margin-block-start' => $gap_value,
[268] Fix | Delete
'margin-block-end' => '0',
[269] Fix | Delete
),
[270] Fix | Delete
)
[271] Fix | Delete
);
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
} elseif ( 'constrained' === $layout_type ) {
[275] Fix | Delete
$content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : '';
[276] Fix | Delete
$wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : '';
[277] Fix | Delete
$justify_content = isset( $layout['justifyContent'] ) ? $layout['justifyContent'] : 'center';
[278] Fix | Delete
[279] Fix | Delete
$all_max_width_value = $content_size ? $content_size : $wide_size;
[280] Fix | Delete
$wide_max_width_value = $wide_size ? $wide_size : $content_size;
[281] Fix | Delete
[282] Fix | Delete
// Make sure there is a single CSS rule, and all tags are stripped for security.
[283] Fix | Delete
$all_max_width_value = safecss_filter_attr( explode( ';', $all_max_width_value )[0] );
[284] Fix | Delete
$wide_max_width_value = safecss_filter_attr( explode( ';', $wide_max_width_value )[0] );
[285] Fix | Delete
[286] Fix | Delete
$margin_left = 'left' === $justify_content ? '0 !important' : 'auto !important';
[287] Fix | Delete
$margin_right = 'right' === $justify_content ? '0 !important' : 'auto !important';
[288] Fix | Delete
[289] Fix | Delete
if ( $content_size || $wide_size ) {
[290] Fix | Delete
array_push(
[291] Fix | Delete
$layout_styles,
[292] Fix | Delete
array(
[293] Fix | Delete
'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
[294] Fix | Delete
'declarations' => array(
[295] Fix | Delete
'max-width' => $all_max_width_value,
[296] Fix | Delete
'margin-left' => $margin_left,
[297] Fix | Delete
'margin-right' => $margin_right,
[298] Fix | Delete
),
[299] Fix | Delete
),
[300] Fix | Delete
array(
[301] Fix | Delete
'selector' => "$selector > .alignwide",
[302] Fix | Delete
'declarations' => array( 'max-width' => $wide_max_width_value ),
[303] Fix | Delete
),
[304] Fix | Delete
array(
[305] Fix | Delete
'selector' => "$selector .alignfull",
[306] Fix | Delete
'declarations' => array( 'max-width' => 'none' ),
[307] Fix | Delete
)
[308] Fix | Delete
);
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
if ( isset( $block_spacing ) ) {
[312] Fix | Delete
$block_spacing_values = wp_style_engine_get_styles(
[313] Fix | Delete
array(
[314] Fix | Delete
'spacing' => $block_spacing,
[315] Fix | Delete
)
[316] Fix | Delete
);
[317] Fix | Delete
[318] Fix | Delete
/*
[319] Fix | Delete
* Handle negative margins for alignfull children of blocks with custom padding set.
[320] Fix | Delete
* They're added separately because padding might only be set on one side.
[321] Fix | Delete
*/
[322] Fix | Delete
if ( isset( $block_spacing_values['declarations']['padding-right'] ) ) {
[323] Fix | Delete
$padding_right = $block_spacing_values['declarations']['padding-right'];
[324] Fix | Delete
// Add unit if 0.
[325] Fix | Delete
if ( '0' === $padding_right ) {
[326] Fix | Delete
$padding_right = '0px';
[327] Fix | Delete
}
[328] Fix | Delete
$layout_styles[] = array(
[329] Fix | Delete
'selector' => "$selector > .alignfull",
[330] Fix | Delete
'declarations' => array( 'margin-right' => "calc($padding_right * -1)" ),
[331] Fix | Delete
);
[332] Fix | Delete
}
[333] Fix | Delete
if ( isset( $block_spacing_values['declarations']['padding-left'] ) ) {
[334] Fix | Delete
$padding_left = $block_spacing_values['declarations']['padding-left'];
[335] Fix | Delete
// Add unit if 0.
[336] Fix | Delete
if ( '0' === $padding_left ) {
[337] Fix | Delete
$padding_left = '0px';
[338] Fix | Delete
}
[339] Fix | Delete
$layout_styles[] = array(
[340] Fix | Delete
'selector' => "$selector > .alignfull",
[341] Fix | Delete
'declarations' => array( 'margin-left' => "calc($padding_left * -1)" ),
[342] Fix | Delete
);
[343] Fix | Delete
}
[344] Fix | Delete
}
[345] Fix | Delete
[346] Fix | Delete
if ( 'left' === $justify_content ) {
[347] Fix | Delete
$layout_styles[] = array(
[348] Fix | Delete
'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
[349] Fix | Delete
'declarations' => array( 'margin-left' => '0 !important' ),
[350] Fix | Delete
);
[351] Fix | Delete
}
[352] Fix | Delete
[353] Fix | Delete
if ( 'right' === $justify_content ) {
[354] Fix | Delete
$layout_styles[] = array(
[355] Fix | Delete
'selector' => "$selector > :where(:not(.alignleft):not(.alignright):not(.alignfull))",
[356] Fix | Delete
'declarations' => array( 'margin-right' => '0 !important' ),
[357] Fix | Delete
);
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
if ( $has_block_gap_support ) {
[361] Fix | Delete
if ( is_array( $gap_value ) ) {
[362] Fix | Delete
$gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null;
[363] Fix | Delete
}
[364] Fix | Delete
if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
[365] Fix | Delete
// Get spacing CSS variable from preset value if provided.
[366] Fix | Delete
if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) {
[367] Fix | Delete
$index_to_splice = strrpos( $gap_value, '|' ) + 1;
[368] Fix | Delete
$slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) );
[369] Fix | Delete
$gap_value = "var(--wp--preset--spacing--$slug)";
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
array_push(
[373] Fix | Delete
$layout_styles,
[374] Fix | Delete
array(
[375] Fix | Delete
'selector' => "$selector > *",
[376] Fix | Delete
'declarations' => array(
[377] Fix | Delete
'margin-block-start' => '0',
[378] Fix | Delete
'margin-block-end' => '0',
[379] Fix | Delete
),
[380] Fix | Delete
),
[381] Fix | Delete
array(
[382] Fix | Delete
'selector' => "$selector > * + *",
[383] Fix | Delete
'declarations' => array(
[384] Fix | Delete
'margin-block-start' => $gap_value,
[385] Fix | Delete
'margin-block-end' => '0',
[386] Fix | Delete
),
[387] Fix | Delete
)
[388] Fix | Delete
);
[389] Fix | Delete
}
[390] Fix | Delete
}
[391] Fix | Delete
} elseif ( 'flex' === $layout_type ) {
[392] Fix | Delete
$layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal';
[393] Fix | Delete
[394] Fix | Delete
$justify_content_options = array(
[395] Fix | Delete
'left' => 'flex-start',
[396] Fix | Delete
'right' => 'flex-end',
[397] Fix | Delete
'center' => 'center',
[398] Fix | Delete
);
[399] Fix | Delete
[400] Fix | Delete
$vertical_alignment_options = array(
[401] Fix | Delete
'top' => 'flex-start',
[402] Fix | Delete
'center' => 'center',
[403] Fix | Delete
'bottom' => 'flex-end',
[404] Fix | Delete
);
[405] Fix | Delete
[406] Fix | Delete
if ( 'horizontal' === $layout_orientation ) {
[407] Fix | Delete
$justify_content_options += array( 'space-between' => 'space-between' );
[408] Fix | Delete
$vertical_alignment_options += array( 'stretch' => 'stretch' );
[409] Fix | Delete
} else {
[410] Fix | Delete
$justify_content_options += array( 'stretch' => 'stretch' );
[411] Fix | Delete
$vertical_alignment_options += array( 'space-between' => 'space-between' );
[412] Fix | Delete
}
[413] Fix | Delete
[414] Fix | Delete
if ( ! empty( $layout['flexWrap'] ) && 'nowrap' === $layout['flexWrap'] ) {
[415] Fix | Delete
$layout_styles[] = array(
[416] Fix | Delete
'selector' => $selector,
[417] Fix | Delete
'declarations' => array( 'flex-wrap' => 'nowrap' ),
[418] Fix | Delete
);
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
if ( $has_block_gap_support && isset( $gap_value ) ) {
[422] Fix | Delete
$combined_gap_value = '';
[423] Fix | Delete
$gap_sides = is_array( $gap_value ) ? array( 'top', 'left' ) : array( 'top' );
[424] Fix | Delete
[425] Fix | Delete
foreach ( $gap_sides as $gap_side ) {
[426] Fix | Delete
$process_value = $gap_value;
[427] Fix | Delete
if ( is_array( $gap_value ) ) {
[428] Fix | Delete
$process_value = isset( $gap_value[ $gap_side ] ) ? $gap_value[ $gap_side ] : $fallback_gap_value;
[429] Fix | Delete
}
[430] Fix | Delete
// Get spacing CSS variable from preset value if provided.
[431] Fix | Delete
if ( is_string( $process_value ) && str_contains( $process_value, 'var:preset|spacing|' ) ) {
[432] Fix | Delete
$index_to_splice = strrpos( $process_value, '|' ) + 1;
[433] Fix | Delete
$slug = _wp_to_kebab_case( substr( $process_value, $index_to_splice ) );
[434] Fix | Delete
$process_value = "var(--wp--preset--spacing--$slug)";
[435] Fix | Delete
}
[436] Fix | Delete
$combined_gap_value .= "$process_value ";
[437] Fix | Delete
}
[438] Fix | Delete
$gap_value = trim( $combined_gap_value );
[439] Fix | Delete
[440] Fix | Delete
if ( null !== $gap_value && ! $should_skip_gap_serialization ) {
[441] Fix | Delete
$layout_styles[] = array(
[442] Fix | Delete
'selector' => $selector,
[443] Fix | Delete
'declarations' => array( 'gap' => $gap_value ),
[444] Fix | Delete
);
[445] Fix | Delete
}
[446] Fix | Delete
}
[447] Fix | Delete
[448] Fix | Delete
if ( 'horizontal' === $layout_orientation ) {
[449] Fix | Delete
/*
[450] Fix | Delete
* Add this style only if is not empty for backwards compatibility,
[451] Fix | Delete
* since we intend to convert blocks that had flex layout implemented
[452] Fix | Delete
* by custom css.
[453] Fix | Delete
*/
[454] Fix | Delete
if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) {
[455] Fix | Delete
$layout_styles[] = array(
[456] Fix | Delete
'selector' => $selector,
[457] Fix | Delete
'declarations' => array( 'justify-content' => $justify_content_options[ $layout['justifyContent'] ] ),
[458] Fix | Delete
);
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
if ( ! empty( $layout['verticalAlignment'] ) && array_key_exists( $layout['verticalAlignment'], $vertical_alignment_options ) ) {
[462] Fix | Delete
$layout_styles[] = array(
[463] Fix | Delete
'selector' => $selector,
[464] Fix | Delete
'declarations' => array( 'align-items' => $vertical_alignment_options[ $layout['verticalAlignment'] ] ),
[465] Fix | Delete
);
[466] Fix | Delete
}
[467] Fix | Delete
} else {
[468] Fix | Delete
$layout_styles[] = array(
[469] Fix | Delete
'selector' => $selector,
[470] Fix | Delete
'declarations' => array( 'flex-direction' => 'column' ),
[471] Fix | Delete
);
[472] Fix | Delete
if ( ! empty( $layout['justifyContent'] ) && array_key_exists( $layout['justifyContent'], $justify_content_options ) ) {
[473] Fix | Delete
$layout_styles[] = array(
[474] Fix | Delete
'selector' => $selector,
[475] Fix | Delete
'declarations' => array( 'align-items' => $justify_content_options[ $layout['justifyContent'] ] ),
[476] Fix | Delete
);
[477] Fix | Delete
} else {
[478] Fix | Delete
$layout_styles[] = array(
[479] Fix | Delete
'selector' => $selector,
[480] Fix | Delete
'declarations' => array( 'align-items' => 'flex-start' ),
[481] Fix | Delete
);
[482] Fix | Delete
}
[483] Fix | Delete
if ( ! empty( $layout['verticalAlignment'] ) && array_key_exists( $layout['verticalAlignment'], $vertical_alignment_options ) ) {
[484] Fix | Delete
$layout_styles[] = array(
[485] Fix | Delete
'selector' => $selector,
[486] Fix | Delete
'declarations' => array( 'justify-content' => $vertical_alignment_options[ $layout['verticalAlignment'] ] ),
[487] Fix | Delete
);
[488] Fix | Delete
}
[489] Fix | Delete
}
[490] Fix | Delete
} elseif ( 'grid' === $layout_type ) {
[491] Fix | Delete
if ( ! empty( $layout['columnCount'] ) ) {
[492] Fix | Delete
$layout_styles[] = array(
[493] Fix | Delete
'selector' => $selector,
[494] Fix | Delete
'declarations' => array( 'grid-template-columns' => 'repeat(' . $layout['columnCount'] . ', minmax(0, 1fr))' ),
[495] Fix | Delete
);
[496] Fix | Delete
} else {
[497] Fix | Delete
$minimum_column_width = ! empty( $layout['minimumColumnWidth'] ) ? $layout['minimumColumnWidth'] : '12rem';
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function