WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 years ago

#29379 new enhancement

Add a hook to filter gallery classes

Reported by: grosbouff Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.9.2
Component: Gallery Keywords: has-patch needs-docs
Focuses: Cc:

Description

Hi, it would be really great to be allowed to filter the gallery classes.

Here's what I suggest :

instead of :

	$size_class = sanitize_html_class( $atts['size'] );
	$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";

rather use

        $classes_str = null;
        $classes = array(
            'gallery',
            'galleryid-'.$id,
            'gallery-columns-'.$columns,
            'gallery-size-'.sanitize_html_class( $atts['size'] )
        );
        
        $classes = apply_filters('gallery_classes',$classes,$attr);

        if (!empty($classes)){
            $classes = array_filter($classes);
            $classes_str = " class='".implode(' ',$classes)."'";
        }
        

	$size_class = sanitize_html_class( $atts['size'] );
	$gallery_div = "<div id='$selector' $classes_str>";

Attachments (1)

29379.diff (976 bytes) - added by mahype 3 years ago.

Download all attachments as: .zip

Change History (3)

#1 @wonderboymusic
3 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

@mahype
3 years ago

#2 @mahype
3 years ago

  • Keywords has-patch needs-docs added; needs-patch removed

Added actionhook like in example above.

Note: See TracTickets for help on using tickets.