CSS displayed on page when more than 1 tdb_single_content shortcode used

Posted in: Newspaper
Post count: 3

There is a bug in the common.php locate at td-composer/legacy/common/common.php.

If you have more than 1 tdb_single_content shortcode in a page, the css will end up with an extra </style> markup.

The preg_match capture should be use (\X*):

// find inline css
preg_match_all( ‘/\/\* custom css \*\/(\X*)<\/style>/miU’, $rendered_shortcode_content, $style_matches );

foreach ( $style_matches[ 0 ] as $style_match ) {

It’s using the first index [ 0 ], that include the </style>

Then
$result_style .= preg_replace( ‘/.tdi_(\X*)/miU’, ‘.td-gutenberg-editor .editor-styles-wrapper .wp-block’, $style_match );

will end up with

“first block of css</style>second block of css</style>”

then

$style = ‘<style>’ . $result_style;

will make it
<style>first block of css</style>second block of css</style>

foreach ( $style_matches[ 0 ] as $style_match ) {
should be
foreach ( $style_matches[ 1 ] as $style_match ) {

and

$style = ‘<style>’ . $result_style;
should be
$style = ‘<style>’ . $result_style . ‘</style>’;

Regards

Post count: 3

Might have to change the condition before the loop too.

if ( count( $style_matches ) && is_array( $style_matches[ 0 ] ) ) {
foreach ( $style_matches[ 0 ] as $style_match ) {
// find inline css
$result_style .= preg_replace( ‘/.tdi_(\X*)/miU’, ‘.td-gutenberg-editor .editor-styles-wrapper .wp-block’, $style_match );
}
}

should be

if ( count( $style_matches ) && is_array( $style_matches[ 1 ] ) ) {
foreach ( $style_matches[ 1 ] as $style_match ) {
// find inline css
$result_style .= preg_replace( ‘/.tdi_(\X*)/miU’, ‘.td-gutenberg-editor .editor-styles-wrapper .wp-block’, $style_match );
}
}

Post count: 21065

Hello!

Please make sure you have the latest version of the PHP, WordPress, theme and plugins(11.2). Delete and re-install the TagDiv Composer plugin.
Please check if this code is missing from your htaccess file: https://www.screencast.com/t/iN0R93dD3p from our requirements, make sure you have all the requirements as you can see here: https://forum.tagdiv.com/requirements-for-newspaper/

Thank you!

Post count: 3

Really ?

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.