From cedd0cb7a72104f4f7117508199a3c9950fcb1e3 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Mon, 16 Jul 2018 16:05:00 -0600
Subject: [PATCH] revised patch: 1) filter should accept an array (instead of
string) for $classes; 2) filter return value cast to array() (just in case);
3) sanitize_html_class() array_map'd to filter return value; 4)
'gallery-item' added if not already present.
---
src/wp-includes/media.php | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index c93c3db..19c8d1a 100644
a
|
b
|
function gallery_shortcode( $attr ) { |
1863 | 1863 | if ( isset( $image_meta['height'], $image_meta['width'] ) ) { |
1864 | 1864 | $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape'; |
1865 | 1865 | } |
1866 | | $output .= "<{$itemtag} class='gallery-item'>"; |
| 1866 | |
| 1867 | /** |
| 1868 | * Filter the gallery item classes. |
| 1869 | * |
| 1870 | * @since 5.0 |
| 1871 | * |
| 1872 | * @param array $classes Classes applied to gallery item. |
| 1873 | * @param object $attachment Attachment object. |
| 1874 | */ |
| 1875 | $gallery_item_classes = (array) apply_filters( 'gallery_item_classes', array(), $attachment ); |
| 1876 | $gallery_item_classes = array_filter( array_map( 'sanitize_html_class', $gallery_item_classes ) ); |
| 1877 | $gallery_item_classes = array_merge( array( 'gallery-item' ), $gallery_item_classes ); |
| 1878 | $gallery_item_classes = implode( ' ', $gallery_item_classes ); |
| 1879 | |
| 1880 | $output .= "<{$itemtag} class='{$gallery_item_classes}'>"; |
1867 | 1881 | $output .= " |
1868 | 1882 | <{$icontag} class='gallery-icon {$orientation}'> |
1869 | 1883 | $image_output |