Make WordPress Core

Opened 42 hours ago

Last modified 34 hours ago

#65317 new defect (bug)

Removal of HTML5 script theme support affects older theme gallery layout in frontend

Reported by: ov3rfly's profile Ov3rfly Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 7.0
Component: Script Loader Keywords: close
Focuses: Cc:

Description

This is a follow-up to #64442.

On a website with older theme Renkon 1.0.9 from ElmaStudio the WordPress gallery shortcode causes layout issues after WordPress 7.0 update.

Reason is the removal of gallery shortcode inline CSS by the theme which does not work any more due to missing type attribute in WordPress 7.0 $gallery_style code:

/*-----------------------------------------------------------------------------------*/
/* Remove inline styles printed when the gallery shortcode is used.
/*-----------------------------------------------------------------------------------*/
function renkon_remove_gallery_css( $css ) {
	return preg_replace( "#<style type=\"text/css\">(.*?)</style>#s", '', $css );
}
add_filter( 'gallery_style', 'renkon_remove_gallery_css' );

Out hotfix was updating the older theme code, so their filter works again.

Change History (1)

#1 @sabernhardt
34 hours ago

  • Keywords close added

WordPress 3.1 introduced a more reliable filter than gallery_style for removing the style tag completely.

add_filter( 'use_default_gallery_style', '__return_false' );

Twenty Ten has both filters, keeping gallery_style for backward compatibility with WordPress 3.0.

Several other themes in the directory have a gallery_style filter, and most of them replace
<style type='text/css'>(.*?)</style>. If they do not also have the use_default_gallery_style hook, I expect that those themes already had a problem in WordPress 5.3, when [46164] switched the quotes from single to double.

cc: @elmastudio

Note: See TracTickets for help on using tickets.