Fix list block style interferences
Should have done that the first time.
This commit is contained in:
parent
9a0ad252ad
commit
a4f8f5aa98
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1187,4 +1187,45 @@ function fictioneer_prevent_track_and_ping_updates( $data ) {
|
|||||||
}
|
}
|
||||||
add_filter( 'wp_insert_post_data', 'fictioneer_prevent_track_and_ping_updates', 1 );
|
add_filter( 'wp_insert_post_data', 'fictioneer_prevent_track_and_ping_updates', 1 );
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// ADD CLASSES TO BLOCKS
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add default class to list blocks
|
||||||
|
*
|
||||||
|
* @since 5.12.0
|
||||||
|
*
|
||||||
|
* @param string $block_content HTML content of the block being rendered.
|
||||||
|
* @param array $block The full block array.
|
||||||
|
*
|
||||||
|
* @return string The modified block content.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function fictioneer_add_class_to_list_blocks( $block_content, $block ) {
|
||||||
|
if ( $block['blockName'] === 'core/list' ) {
|
||||||
|
$pattern = '/<(ul|ol)([^>]*)>/i';
|
||||||
|
|
||||||
|
$block_content = preg_replace_callback( $pattern, function ( $matches ) {
|
||||||
|
$current_attributes = $matches[2];
|
||||||
|
$new_class = 'block-list';
|
||||||
|
|
||||||
|
if ( strpos( $current_attributes, 'class="' ) !== false ) {
|
||||||
|
$modified_tag = preg_replace(
|
||||||
|
'/class="([^"]*)"/i',
|
||||||
|
'class="$1 ' . $new_class . '"',
|
||||||
|
$current_attributes
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$modified_tag = $current_attributes . ' class="' . $new_class . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<' . $matches[1] . $modified_tag . '>';
|
||||||
|
}, $block_content );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $block_content;
|
||||||
|
}
|
||||||
|
add_filter( 'render_block', 'fictioneer_add_class_to_list_blocks', 10, 2 );
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -223,7 +223,7 @@ p a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content-section {
|
.content-section {
|
||||||
:where(.list, :is(ul, ol):not(.chapter-group__list, .grid-columns, .card__link-list, .profile__admin-notes)) {
|
:where(.list, .block-list) {
|
||||||
list-style: initial;
|
list-style: initial;
|
||||||
padding-left: 1.75rem;
|
padding-left: 1.75rem;
|
||||||
margin: 1.5rem 0 0;
|
margin: 1.5rem 0 0;
|
||||||
@ -243,21 +243,21 @@ p a,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:where(.list, ul:not(.chapter-group__list, .grid-columns, .card__link-list, .profile__admin-notes)) {
|
:where(.list, ul.block-list) {
|
||||||
li::marker {
|
li::marker {
|
||||||
color: var(--list-marker-color, var(--fg-700)); // Done
|
color: var(--list-marker-color, var(--fg-700)); // Done
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
:where(ul, .list) > li > ul:not(.chapter-group__list, .grid-columns, .card__link-list, .profile__admin-notes) {
|
:where(ul, .list) > li > ul.block-list {
|
||||||
list-style: circle;
|
list-style: circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
:where(ul, .list) > li > ul > li > ul:not(.chapter-group__list, .grid-columns, .card__link-list, .profile__admin-notes) {
|
:where(ul, .list) > li > ul > li > ul.block-list {
|
||||||
list-style: square;
|
list-style: square;
|
||||||
}
|
}
|
||||||
|
|
||||||
:where(.list, ol:not(.chapter-group__list, .grid-columns, .card__link-list, .profile__admin-notes)) {
|
:where(.list, ol.block-list) {
|
||||||
list-style: ordered-list;
|
list-style: ordered-list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user