Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-theme-json.php
$schema_styles_blocks[ $block ] = $styles_non_top_level;
[1000] Fix | Delete
$schema_styles_blocks[ $block ]['elements'] = $schema_styles_elements;
[1001] Fix | Delete
}
[1002] Fix | Delete
[1003] Fix | Delete
$block_style_variation_styles = static::VALID_STYLES;
[1004] Fix | Delete
$block_style_variation_styles['blocks'] = $schema_styles_blocks;
[1005] Fix | Delete
$block_style_variation_styles['elements'] = $schema_styles_elements;
[1006] Fix | Delete
[1007] Fix | Delete
foreach ( $valid_block_names as $block ) {
[1008] Fix | Delete
// Build the schema for each block style variation.
[1009] Fix | Delete
$style_variation_names = array();
[1010] Fix | Delete
if (
[1011] Fix | Delete
! empty( $input['styles']['blocks'][ $block ]['variations'] ) &&
[1012] Fix | Delete
is_array( $input['styles']['blocks'][ $block ]['variations'] ) &&
[1013] Fix | Delete
isset( $valid_variations[ $block ] )
[1014] Fix | Delete
) {
[1015] Fix | Delete
$style_variation_names = array_intersect(
[1016] Fix | Delete
array_keys( $input['styles']['blocks'][ $block ]['variations'] ),
[1017] Fix | Delete
$valid_variations[ $block ]
[1018] Fix | Delete
);
[1019] Fix | Delete
}
[1020] Fix | Delete
[1021] Fix | Delete
$schema_styles_variations = array();
[1022] Fix | Delete
if ( ! empty( $style_variation_names ) ) {
[1023] Fix | Delete
$schema_styles_variations = array_fill_keys( $style_variation_names, $block_style_variation_styles );
[1024] Fix | Delete
}
[1025] Fix | Delete
[1026] Fix | Delete
$schema_styles_blocks[ $block ]['variations'] = $schema_styles_variations;
[1027] Fix | Delete
}
[1028] Fix | Delete
[1029] Fix | Delete
$schema['styles'] = static::VALID_STYLES;
[1030] Fix | Delete
$schema['styles']['blocks'] = $schema_styles_blocks;
[1031] Fix | Delete
$schema['styles']['elements'] = $schema_styles_elements;
[1032] Fix | Delete
$schema['settings'] = static::VALID_SETTINGS;
[1033] Fix | Delete
$schema['settings']['blocks'] = $schema_settings_blocks;
[1034] Fix | Delete
$schema['settings']['typography']['fontFamilies'] = static::schema_in_root_and_per_origin( static::FONT_FAMILY_SCHEMA );
[1035] Fix | Delete
[1036] Fix | Delete
// Remove anything that's not present in the schema.
[1037] Fix | Delete
foreach ( array( 'styles', 'settings' ) as $subtree ) {
[1038] Fix | Delete
if ( ! isset( $input[ $subtree ] ) ) {
[1039] Fix | Delete
continue;
[1040] Fix | Delete
}
[1041] Fix | Delete
[1042] Fix | Delete
if ( ! is_array( $input[ $subtree ] ) ) {
[1043] Fix | Delete
unset( $output[ $subtree ] );
[1044] Fix | Delete
continue;
[1045] Fix | Delete
}
[1046] Fix | Delete
[1047] Fix | Delete
$result = static::remove_keys_not_in_schema( $input[ $subtree ], $schema[ $subtree ] );
[1048] Fix | Delete
[1049] Fix | Delete
if ( empty( $result ) ) {
[1050] Fix | Delete
unset( $output[ $subtree ] );
[1051] Fix | Delete
} else {
[1052] Fix | Delete
$output[ $subtree ] = static::resolve_custom_css_format( $result );
[1053] Fix | Delete
}
[1054] Fix | Delete
}
[1055] Fix | Delete
[1056] Fix | Delete
return $output;
[1057] Fix | Delete
}
[1058] Fix | Delete
[1059] Fix | Delete
/**
[1060] Fix | Delete
* Appends a sub-selector to an existing one.
[1061] Fix | Delete
*
[1062] Fix | Delete
* Given the compounded $selector "h1, h2, h3"
[1063] Fix | Delete
* and the $to_append selector ".some-class" the result will be
[1064] Fix | Delete
* "h1.some-class, h2.some-class, h3.some-class".
[1065] Fix | Delete
*
[1066] Fix | Delete
* @since 5.8.0
[1067] Fix | Delete
* @since 6.1.0 Added append position.
[1068] Fix | Delete
* @since 6.3.0 Removed append position parameter.
[1069] Fix | Delete
*
[1070] Fix | Delete
* @param string $selector Original selector.
[1071] Fix | Delete
* @param string $to_append Selector to append.
[1072] Fix | Delete
* @return string The new selector.
[1073] Fix | Delete
*/
[1074] Fix | Delete
protected static function append_to_selector( $selector, $to_append ) {
[1075] Fix | Delete
if ( ! str_contains( $selector, ',' ) ) {
[1076] Fix | Delete
return $selector . $to_append;
[1077] Fix | Delete
}
[1078] Fix | Delete
$new_selectors = array();
[1079] Fix | Delete
$selectors = explode( ',', $selector );
[1080] Fix | Delete
foreach ( $selectors as $sel ) {
[1081] Fix | Delete
$new_selectors[] = $sel . $to_append;
[1082] Fix | Delete
}
[1083] Fix | Delete
return implode( ',', $new_selectors );
[1084] Fix | Delete
}
[1085] Fix | Delete
[1086] Fix | Delete
/**
[1087] Fix | Delete
* Prepends a sub-selector to an existing one.
[1088] Fix | Delete
*
[1089] Fix | Delete
* Given the compounded $selector "h1, h2, h3"
[1090] Fix | Delete
* and the $to_prepend selector ".some-class " the result will be
[1091] Fix | Delete
* ".some-class h1, .some-class h2, .some-class h3".
[1092] Fix | Delete
*
[1093] Fix | Delete
* @since 6.3.0
[1094] Fix | Delete
*
[1095] Fix | Delete
* @param string $selector Original selector.
[1096] Fix | Delete
* @param string $to_prepend Selector to prepend.
[1097] Fix | Delete
* @return string The new selector.
[1098] Fix | Delete
*/
[1099] Fix | Delete
protected static function prepend_to_selector( $selector, $to_prepend ) {
[1100] Fix | Delete
if ( ! str_contains( $selector, ',' ) ) {
[1101] Fix | Delete
return $to_prepend . $selector;
[1102] Fix | Delete
}
[1103] Fix | Delete
$new_selectors = array();
[1104] Fix | Delete
$selectors = explode( ',', $selector );
[1105] Fix | Delete
foreach ( $selectors as $sel ) {
[1106] Fix | Delete
$new_selectors[] = $to_prepend . $sel;
[1107] Fix | Delete
}
[1108] Fix | Delete
return implode( ',', $new_selectors );
[1109] Fix | Delete
}
[1110] Fix | Delete
[1111] Fix | Delete
/**
[1112] Fix | Delete
* Returns the metadata for each block.
[1113] Fix | Delete
*
[1114] Fix | Delete
* Example:
[1115] Fix | Delete
*
[1116] Fix | Delete
* {
[1117] Fix | Delete
* 'core/paragraph': {
[1118] Fix | Delete
* 'selector': 'p',
[1119] Fix | Delete
* 'elements': {
[1120] Fix | Delete
* 'link' => 'link selector',
[1121] Fix | Delete
* 'etc' => 'element selector'
[1122] Fix | Delete
* }
[1123] Fix | Delete
* },
[1124] Fix | Delete
* 'core/heading': {
[1125] Fix | Delete
* 'selector': 'h1',
[1126] Fix | Delete
* 'elements': {}
[1127] Fix | Delete
* },
[1128] Fix | Delete
* 'core/image': {
[1129] Fix | Delete
* 'selector': '.wp-block-image',
[1130] Fix | Delete
* 'duotone': 'img',
[1131] Fix | Delete
* 'elements': {}
[1132] Fix | Delete
* }
[1133] Fix | Delete
* }
[1134] Fix | Delete
*
[1135] Fix | Delete
* @since 5.8.0
[1136] Fix | Delete
* @since 5.9.0 Added `duotone` key with CSS selector.
[1137] Fix | Delete
* @since 6.1.0 Added `features` key with block support feature level selectors.
[1138] Fix | Delete
* @since 6.3.0 Refactored and stabilized selectors API.
[1139] Fix | Delete
* @since 6.6.0 Updated to include block style variations from the block styles registry.
[1140] Fix | Delete
*
[1141] Fix | Delete
* @return array Block metadata.
[1142] Fix | Delete
*/
[1143] Fix | Delete
protected static function get_blocks_metadata() {
[1144] Fix | Delete
$registry = WP_Block_Type_Registry::get_instance();
[1145] Fix | Delete
$blocks = $registry->get_all_registered();
[1146] Fix | Delete
$style_registry = WP_Block_Styles_Registry::get_instance();
[1147] Fix | Delete
[1148] Fix | Delete
// Is there metadata for all currently registered blocks?
[1149] Fix | Delete
$blocks = array_diff_key( $blocks, static::$blocks_metadata );
[1150] Fix | Delete
if ( empty( $blocks ) ) {
[1151] Fix | Delete
/*
[1152] Fix | Delete
* New block styles may have been registered within WP_Block_Styles_Registry.
[1153] Fix | Delete
* Update block metadata for any new block style variations.
[1154] Fix | Delete
*/
[1155] Fix | Delete
$registered_styles = $style_registry->get_all_registered();
[1156] Fix | Delete
foreach ( static::$blocks_metadata as $block_name => $block_metadata ) {
[1157] Fix | Delete
if ( ! empty( $registered_styles[ $block_name ] ) ) {
[1158] Fix | Delete
$style_selectors = $block_metadata['styleVariations'] ?? array();
[1159] Fix | Delete
[1160] Fix | Delete
foreach ( $registered_styles[ $block_name ] as $block_style ) {
[1161] Fix | Delete
if ( ! isset( $style_selectors[ $block_style['name'] ] ) ) {
[1162] Fix | Delete
$style_selectors[ $block_style['name'] ] = static::get_block_style_variation_selector( $block_style['name'], $block_metadata['selector'] );
[1163] Fix | Delete
}
[1164] Fix | Delete
}
[1165] Fix | Delete
[1166] Fix | Delete
static::$blocks_metadata[ $block_name ]['styleVariations'] = $style_selectors;
[1167] Fix | Delete
}
[1168] Fix | Delete
}
[1169] Fix | Delete
return static::$blocks_metadata;
[1170] Fix | Delete
}
[1171] Fix | Delete
[1172] Fix | Delete
foreach ( $blocks as $block_name => $block_type ) {
[1173] Fix | Delete
$root_selector = wp_get_block_css_selector( $block_type );
[1174] Fix | Delete
[1175] Fix | Delete
static::$blocks_metadata[ $block_name ]['selector'] = $root_selector;
[1176] Fix | Delete
static::$blocks_metadata[ $block_name ]['selectors'] = static::get_block_selectors( $block_type, $root_selector );
[1177] Fix | Delete
[1178] Fix | Delete
$elements = static::get_block_element_selectors( $root_selector );
[1179] Fix | Delete
if ( ! empty( $elements ) ) {
[1180] Fix | Delete
static::$blocks_metadata[ $block_name ]['elements'] = $elements;
[1181] Fix | Delete
}
[1182] Fix | Delete
[1183] Fix | Delete
// The block may or may not have a duotone selector.
[1184] Fix | Delete
$duotone_selector = wp_get_block_css_selector( $block_type, 'filter.duotone' );
[1185] Fix | Delete
[1186] Fix | Delete
// Keep backwards compatibility for support.color.__experimentalDuotone.
[1187] Fix | Delete
if ( null === $duotone_selector ) {
[1188] Fix | Delete
$duotone_support = isset( $block_type->supports['color']['__experimentalDuotone'] )
[1189] Fix | Delete
? $block_type->supports['color']['__experimentalDuotone']
[1190] Fix | Delete
: null;
[1191] Fix | Delete
[1192] Fix | Delete
if ( $duotone_support ) {
[1193] Fix | Delete
$root_selector = wp_get_block_css_selector( $block_type );
[1194] Fix | Delete
$duotone_selector = static::scope_selector( $root_selector, $duotone_support );
[1195] Fix | Delete
}
[1196] Fix | Delete
}
[1197] Fix | Delete
[1198] Fix | Delete
if ( null !== $duotone_selector ) {
[1199] Fix | Delete
static::$blocks_metadata[ $block_name ]['duotone'] = $duotone_selector;
[1200] Fix | Delete
}
[1201] Fix | Delete
[1202] Fix | Delete
// If the block has style variations, append their selectors to the block metadata.
[1203] Fix | Delete
$style_selectors = array();
[1204] Fix | Delete
if ( ! empty( $block_type->styles ) ) {
[1205] Fix | Delete
foreach ( $block_type->styles as $style ) {
[1206] Fix | Delete
$style_selectors[ $style['name'] ] = static::get_block_style_variation_selector( $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
[1207] Fix | Delete
}
[1208] Fix | Delete
}
[1209] Fix | Delete
[1210] Fix | Delete
// Block style variations can be registered through the WP_Block_Styles_Registry as well as block.json.
[1211] Fix | Delete
$registered_styles = $style_registry->get_registered_styles_for_block( $block_name );
[1212] Fix | Delete
foreach ( $registered_styles as $style ) {
[1213] Fix | Delete
$style_selectors[ $style['name'] ] = static::get_block_style_variation_selector( $style['name'], static::$blocks_metadata[ $block_name ]['selector'] );
[1214] Fix | Delete
}
[1215] Fix | Delete
[1216] Fix | Delete
if ( ! empty( $style_selectors ) ) {
[1217] Fix | Delete
static::$blocks_metadata[ $block_name ]['styleVariations'] = $style_selectors;
[1218] Fix | Delete
}
[1219] Fix | Delete
}
[1220] Fix | Delete
[1221] Fix | Delete
return static::$blocks_metadata;
[1222] Fix | Delete
}
[1223] Fix | Delete
[1224] Fix | Delete
/**
[1225] Fix | Delete
* Given a tree, removes the keys that are not present in the schema.
[1226] Fix | Delete
*
[1227] Fix | Delete
* It is recursive and modifies the input in-place.
[1228] Fix | Delete
*
[1229] Fix | Delete
* @since 5.8.0
[1230] Fix | Delete
*
[1231] Fix | Delete
* @param array $tree Input to process.
[1232] Fix | Delete
* @param array $schema Schema to adhere to.
[1233] Fix | Delete
* @return array The modified $tree.
[1234] Fix | Delete
*/
[1235] Fix | Delete
protected static function remove_keys_not_in_schema( $tree, $schema ) {
[1236] Fix | Delete
if ( ! is_array( $tree ) ) {
[1237] Fix | Delete
return $tree;
[1238] Fix | Delete
}
[1239] Fix | Delete
[1240] Fix | Delete
foreach ( $tree as $key => $value ) {
[1241] Fix | Delete
// Remove keys not in the schema or with null/empty values.
[1242] Fix | Delete
if ( ! array_key_exists( $key, $schema ) ) {
[1243] Fix | Delete
unset( $tree[ $key ] );
[1244] Fix | Delete
continue;
[1245] Fix | Delete
}
[1246] Fix | Delete
[1247] Fix | Delete
if ( is_array( $schema[ $key ] ) ) {
[1248] Fix | Delete
if ( ! is_array( $value ) ) {
[1249] Fix | Delete
unset( $tree[ $key ] );
[1250] Fix | Delete
} elseif ( wp_is_numeric_array( $value ) ) {
[1251] Fix | Delete
// If indexed, process each item in the array.
[1252] Fix | Delete
foreach ( $value as $item_key => $item_value ) {
[1253] Fix | Delete
if ( isset( $schema[ $key ][0] ) && is_array( $schema[ $key ][0] ) ) {
[1254] Fix | Delete
$tree[ $key ][ $item_key ] = self::remove_keys_not_in_schema( $item_value, $schema[ $key ][0] );
[1255] Fix | Delete
} else {
[1256] Fix | Delete
// If the schema does not define a further structure, keep the value as is.
[1257] Fix | Delete
$tree[ $key ][ $item_key ] = $item_value;
[1258] Fix | Delete
}
[1259] Fix | Delete
}
[1260] Fix | Delete
} else {
[1261] Fix | Delete
// If associative, process as a single object.
[1262] Fix | Delete
$tree[ $key ] = self::remove_keys_not_in_schema( $value, $schema[ $key ] );
[1263] Fix | Delete
[1264] Fix | Delete
if ( empty( $tree[ $key ] ) ) {
[1265] Fix | Delete
unset( $tree[ $key ] );
[1266] Fix | Delete
}
[1267] Fix | Delete
}
[1268] Fix | Delete
}
[1269] Fix | Delete
}
[1270] Fix | Delete
return $tree;
[1271] Fix | Delete
}
[1272] Fix | Delete
[1273] Fix | Delete
/**
[1274] Fix | Delete
* Returns the existing settings for each block.
[1275] Fix | Delete
*
[1276] Fix | Delete
* Example:
[1277] Fix | Delete
*
[1278] Fix | Delete
* {
[1279] Fix | Delete
* 'root': {
[1280] Fix | Delete
* 'color': {
[1281] Fix | Delete
* 'custom': true
[1282] Fix | Delete
* }
[1283] Fix | Delete
* },
[1284] Fix | Delete
* 'core/paragraph': {
[1285] Fix | Delete
* 'spacing': {
[1286] Fix | Delete
* 'customPadding': true
[1287] Fix | Delete
* }
[1288] Fix | Delete
* }
[1289] Fix | Delete
* }
[1290] Fix | Delete
*
[1291] Fix | Delete
* @since 5.8.0
[1292] Fix | Delete
*
[1293] Fix | Delete
* @return array Settings per block.
[1294] Fix | Delete
*/
[1295] Fix | Delete
public function get_settings() {
[1296] Fix | Delete
if ( ! isset( $this->theme_json['settings'] ) ) {
[1297] Fix | Delete
return array();
[1298] Fix | Delete
} else {
[1299] Fix | Delete
return $this->theme_json['settings'];
[1300] Fix | Delete
}
[1301] Fix | Delete
}
[1302] Fix | Delete
[1303] Fix | Delete
/**
[1304] Fix | Delete
* Returns the stylesheet that results of processing
[1305] Fix | Delete
* the theme.json structure this object represents.
[1306] Fix | Delete
*
[1307] Fix | Delete
* @since 5.8.0
[1308] Fix | Delete
* @since 5.9.0 Removed the `$type` parameter, added the `$types` and `$origins` parameters.
[1309] Fix | Delete
* @since 6.3.0 Add fallback layout styles for Post Template when block gap support isn't available.
[1310] Fix | Delete
* @since 6.6.0 Added boolean `skip_root_layout_styles` and `include_block_style_variations` options
[1311] Fix | Delete
* to control styles output as desired.
[1312] Fix | Delete
*
[1313] Fix | Delete
* @param string[] $types Types of styles to load. Will load all by default. It accepts:
[1314] Fix | Delete
* - `variables`: only the CSS Custom Properties for presets & custom ones.
[1315] Fix | Delete
* - `styles`: only the styles section in theme.json.
[1316] Fix | Delete
* - `presets`: only the classes for the presets.
[1317] Fix | Delete
* @param string[] $origins A list of origins to include. By default it includes VALID_ORIGINS.
[1318] Fix | Delete
* @param array $options {
[1319] Fix | Delete
* Optional. An array of options for now used for internal purposes only (may change without notice).
[1320] Fix | Delete
*
[1321] Fix | Delete
* @type string $scope Makes sure all style are scoped to a given selector
[1322] Fix | Delete
* @type string $root_selector Overwrites and forces a given selector to be used on the root node
[1323] Fix | Delete
* @type bool $skip_root_layout_styles Omits root layout styles from the generated stylesheet. Default false.
[1324] Fix | Delete
* @type bool $include_block_style_variations Includes styles for block style variations in the generated stylesheet. Default false.
[1325] Fix | Delete
* }
[1326] Fix | Delete
* @return string The resulting stylesheet.
[1327] Fix | Delete
*/
[1328] Fix | Delete
public function get_stylesheet( $types = array( 'variables', 'styles', 'presets' ), $origins = null, $options = array() ) {
[1329] Fix | Delete
if ( null === $origins ) {
[1330] Fix | Delete
$origins = static::VALID_ORIGINS;
[1331] Fix | Delete
}
[1332] Fix | Delete
[1333] Fix | Delete
if ( is_string( $types ) ) {
[1334] Fix | Delete
// Dispatch error and map old arguments to new ones.
[1335] Fix | Delete
_deprecated_argument( __FUNCTION__, '5.9.0' );
[1336] Fix | Delete
if ( 'block_styles' === $types ) {
[1337] Fix | Delete
$types = array( 'styles', 'presets' );
[1338] Fix | Delete
} elseif ( 'css_variables' === $types ) {
[1339] Fix | Delete
$types = array( 'variables' );
[1340] Fix | Delete
} else {
[1341] Fix | Delete
$types = array( 'variables', 'styles', 'presets' );
[1342] Fix | Delete
}
[1343] Fix | Delete
}
[1344] Fix | Delete
[1345] Fix | Delete
$blocks_metadata = static::get_blocks_metadata();
[1346] Fix | Delete
$style_nodes = static::get_style_nodes( $this->theme_json, $blocks_metadata, $options );
[1347] Fix | Delete
$setting_nodes = static::get_setting_nodes( $this->theme_json, $blocks_metadata );
[1348] Fix | Delete
[1349] Fix | Delete
$root_style_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $style_nodes, 'selector' ), true );
[1350] Fix | Delete
$root_settings_key = array_search( static::ROOT_BLOCK_SELECTOR, array_column( $setting_nodes, 'selector' ), true );
[1351] Fix | Delete
[1352] Fix | Delete
if ( ! empty( $options['scope'] ) ) {
[1353] Fix | Delete
foreach ( $setting_nodes as &$node ) {
[1354] Fix | Delete
$node['selector'] = static::scope_selector( $options['scope'], $node['selector'] );
[1355] Fix | Delete
}
[1356] Fix | Delete
foreach ( $style_nodes as &$node ) {
[1357] Fix | Delete
$node = static::scope_style_node_selectors( $options['scope'], $node );
[1358] Fix | Delete
}
[1359] Fix | Delete
unset( $node );
[1360] Fix | Delete
}
[1361] Fix | Delete
[1362] Fix | Delete
if ( ! empty( $options['root_selector'] ) ) {
[1363] Fix | Delete
if ( false !== $root_settings_key ) {
[1364] Fix | Delete
$setting_nodes[ $root_settings_key ]['selector'] = $options['root_selector'];
[1365] Fix | Delete
}
[1366] Fix | Delete
if ( false !== $root_style_key ) {
[1367] Fix | Delete
$style_nodes[ $root_style_key ]['selector'] = $options['root_selector'];
[1368] Fix | Delete
}
[1369] Fix | Delete
}
[1370] Fix | Delete
[1371] Fix | Delete
$stylesheet = '';
[1372] Fix | Delete
[1373] Fix | Delete
if ( in_array( 'variables', $types, true ) ) {
[1374] Fix | Delete
$stylesheet .= $this->get_css_variables( $setting_nodes, $origins );
[1375] Fix | Delete
}
[1376] Fix | Delete
[1377] Fix | Delete
if ( in_array( 'styles', $types, true ) ) {
[1378] Fix | Delete
if ( false !== $root_style_key && empty( $options['skip_root_layout_styles'] ) ) {
[1379] Fix | Delete
$stylesheet .= $this->get_root_layout_rules( $style_nodes[ $root_style_key ]['selector'], $style_nodes[ $root_style_key ] );
[1380] Fix | Delete
}
[1381] Fix | Delete
$stylesheet .= $this->get_block_classes( $style_nodes );
[1382] Fix | Delete
} elseif ( in_array( 'base-layout-styles', $types, true ) ) {
[1383] Fix | Delete
$root_selector = static::ROOT_BLOCK_SELECTOR;
[1384] Fix | Delete
$columns_selector = '.wp-block-columns';
[1385] Fix | Delete
$post_template_selector = '.wp-block-post-template';
[1386] Fix | Delete
if ( ! empty( $options['scope'] ) ) {
[1387] Fix | Delete
$root_selector = static::scope_selector( $options['scope'], $root_selector );
[1388] Fix | Delete
$columns_selector = static::scope_selector( $options['scope'], $columns_selector );
[1389] Fix | Delete
$post_template_selector = static::scope_selector( $options['scope'], $post_template_selector );
[1390] Fix | Delete
}
[1391] Fix | Delete
if ( ! empty( $options['root_selector'] ) ) {
[1392] Fix | Delete
$root_selector = $options['root_selector'];
[1393] Fix | Delete
}
[1394] Fix | Delete
/*
[1395] Fix | Delete
* Base layout styles are provided as part of `styles`, so only output separately if explicitly requested.
[1396] Fix | Delete
* For backwards compatibility, the Columns block is explicitly included, to support a different default gap value.
[1397] Fix | Delete
*/
[1398] Fix | Delete
$base_styles_nodes = array(
[1399] Fix | Delete
array(
[1400] Fix | Delete
'path' => array( 'styles' ),
[1401] Fix | Delete
'selector' => $root_selector,
[1402] Fix | Delete
),
[1403] Fix | Delete
array(
[1404] Fix | Delete
'path' => array( 'styles', 'blocks', 'core/columns' ),
[1405] Fix | Delete
'selector' => $columns_selector,
[1406] Fix | Delete
'name' => 'core/columns',
[1407] Fix | Delete
),
[1408] Fix | Delete
array(
[1409] Fix | Delete
'path' => array( 'styles', 'blocks', 'core/post-template' ),
[1410] Fix | Delete
'selector' => $post_template_selector,
[1411] Fix | Delete
'name' => 'core/post-template',
[1412] Fix | Delete
),
[1413] Fix | Delete
);
[1414] Fix | Delete
[1415] Fix | Delete
foreach ( $base_styles_nodes as $base_style_node ) {
[1416] Fix | Delete
$stylesheet .= $this->get_layout_styles( $base_style_node, $types );
[1417] Fix | Delete
}
[1418] Fix | Delete
}
[1419] Fix | Delete
[1420] Fix | Delete
if ( in_array( 'presets', $types, true ) ) {
[1421] Fix | Delete
$stylesheet .= $this->get_preset_classes( $setting_nodes, $origins );
[1422] Fix | Delete
}
[1423] Fix | Delete
[1424] Fix | Delete
return $stylesheet;
[1425] Fix | Delete
}
[1426] Fix | Delete
[1427] Fix | Delete
/**
[1428] Fix | Delete
* Processes the CSS, to apply nesting.
[1429] Fix | Delete
*
[1430] Fix | Delete
* @since 6.2.0
[1431] Fix | Delete
* @since 6.6.0 Enforced 0-1-0 specificity for block custom CSS selectors.
[1432] Fix | Delete
*
[1433] Fix | Delete
* @param string $css The CSS to process.
[1434] Fix | Delete
* @param string $selector The selector to nest.
[1435] Fix | Delete
* @return string The processed CSS.
[1436] Fix | Delete
*/
[1437] Fix | Delete
protected function process_blocks_custom_css( $css, $selector ) {
[1438] Fix | Delete
$processed_css = '';
[1439] Fix | Delete
[1440] Fix | Delete
if ( empty( $css ) ) {
[1441] Fix | Delete
return $processed_css;
[1442] Fix | Delete
}
[1443] Fix | Delete
[1444] Fix | Delete
// Split CSS nested rules.
[1445] Fix | Delete
$parts = explode( '&', $css );
[1446] Fix | Delete
foreach ( $parts as $part ) {
[1447] Fix | Delete
if ( empty( $part ) ) {
[1448] Fix | Delete
continue;
[1449] Fix | Delete
}
[1450] Fix | Delete
$is_root_css = ( ! str_contains( $part, '{' ) );
[1451] Fix | Delete
if ( $is_root_css ) {
[1452] Fix | Delete
// If the part doesn't contain braces, it applies to the root level.
[1453] Fix | Delete
$processed_css .= ':root :where(' . trim( $selector ) . '){' . trim( $part ) . '}';
[1454] Fix | Delete
} else {
[1455] Fix | Delete
// If the part contains braces, it's a nested CSS rule.
[1456] Fix | Delete
$part = explode( '{', str_replace( '}', '', $part ) );
[1457] Fix | Delete
if ( count( $part ) !== 2 ) {
[1458] Fix | Delete
continue;
[1459] Fix | Delete
}
[1460] Fix | Delete
$nested_selector = $part[0];
[1461] Fix | Delete
$css_value = $part[1];
[1462] Fix | Delete
[1463] Fix | Delete
/*
[1464] Fix | Delete
* Handle pseudo elements such as ::before, ::after etc. Regex will also
[1465] Fix | Delete
* capture any leading combinator such as >, +, or ~, as well as spaces.
[1466] Fix | Delete
* This allows pseudo elements as descendants e.g. `.parent ::before`.
[1467] Fix | Delete
*/
[1468] Fix | Delete
$matches = array();
[1469] Fix | Delete
$has_pseudo_element = preg_match( '/([>+~\s]*::[a-zA-Z-]+)/', $nested_selector, $matches );
[1470] Fix | Delete
$pseudo_part = $has_pseudo_element ? $matches[1] : '';
[1471] Fix | Delete
$nested_selector = $has_pseudo_element ? str_replace( $pseudo_part, '', $nested_selector ) : $nested_selector;
[1472] Fix | Delete
[1473] Fix | Delete
// Finalize selector and re-append pseudo element if required.
[1474] Fix | Delete
$part_selector = str_starts_with( $nested_selector, ' ' )
[1475] Fix | Delete
? static::scope_selector( $selector, $nested_selector )
[1476] Fix | Delete
: static::append_to_selector( $selector, $nested_selector );
[1477] Fix | Delete
$final_selector = ":root :where($part_selector)$pseudo_part";
[1478] Fix | Delete
[1479] Fix | Delete
$processed_css .= $final_selector . '{' . trim( $css_value ) . '}';
[1480] Fix | Delete
}
[1481] Fix | Delete
}
[1482] Fix | Delete
return $processed_css;
[1483] Fix | Delete
}
[1484] Fix | Delete
[1485] Fix | Delete
/**
[1486] Fix | Delete
* Returns the global styles custom CSS.
[1487] Fix | Delete
*
[1488] Fix | Delete
* @since 6.2.0
[1489] Fix | Delete
*
[1490] Fix | Delete
* @return string The global styles custom CSS.
[1491] Fix | Delete
*/
[1492] Fix | Delete
public function get_custom_css() {
[1493] Fix | Delete
// Add the global styles root CSS.
[1494] Fix | Delete
$stylesheet = isset( $this->theme_json['styles']['css'] ) ? $this->theme_json['styles']['css'] : '';
[1495] Fix | Delete
[1496] Fix | Delete
// Add the global styles block CSS.
[1497] Fix | Delete
if ( isset( $this->theme_json['styles']['blocks'] ) ) {
[1498] Fix | Delete
foreach ( $this->theme_json['styles']['blocks'] as $name => $node ) {
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function