Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update [gallery] shortcode

- Roll in changes added from WordPress 3.5

- More minimal code output
  • Loading branch information...
commit 8000e5c6114a7591cab28e8a0d27697da65a5120 1 parent e3f7365
@retlehs retlehs authored
Showing with 20 additions and 36 deletions.
  1. +20 −36 lib/cleanup.php
View
56 lib/cleanup.php
@@ -273,11 +273,18 @@ function roots_caption($output, $attr, $content) {
* @link http://twitter.github.com/bootstrap/components.html#thumbnails
*/
function roots_gallery($attr) {
- global $post, $wp_locale;
+ $post = get_post();
static $instance = 0;
$instance++;
+ if (!empty($attr['ids'])) {
+ if (empty($attr['orderby'])) {
+ $attr['orderby'] = 'post__in';
+ }
+ $attr['include'] = $attr['ids'];
+ }
+
$output = apply_filters('post_gallery', '', $attr);
if ($output != '') {
@@ -295,8 +302,9 @@ function roots_gallery($attr) {
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post->ID,
- 'icontag' => 'li',
- 'captiontag' => 'p',
+ 'itemtag' => '',
+ 'icontag' => '',
+ 'captiontag' => '',
'columns' => 3,
'size' => 'thumbnail',
'include' => '',
@@ -310,15 +318,13 @@ function roots_gallery($attr) {
}
if (!empty($include)) {
- $include = preg_replace( '/[^0-9,]+/', '', $include );
- $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
+ $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
$attachments = array();
foreach ($_attachments as $key => $val) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif (!empty($exclude)) {
- $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
$attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
} else {
$attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
@@ -330,48 +336,26 @@ function roots_gallery($attr) {
if (is_feed()) {
$output = "\n";
- foreach ($attachments as $att_id => $attachment)
+ foreach ($attachments as $att_id => $attachment) {
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
+ }
return $output;
}
- $captiontag = tag_escape($captiontag);
- $columns = intval($columns);
- $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
- $float = is_rtl() ? 'right' : 'left';
- $selector = "gallery-{$instance}";
-
- $gallery_style = $gallery_div = '';
-
- if (apply_filters('use_default_gallery_style', true)) {
- $gallery_style = '';
- }
-
- $size_class = sanitize_html_class($size);
- $gallery_div = "<ul id='$selector' class='thumbnails gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
- $output = apply_filters('gallery_style', $gallery_style . "\n\t\t" . $gallery_div);
+ $output = '<ul class="thumbnails gallery">';
$i = 0;
foreach ($attachments as $id => $attachment) {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
- $output .= "
- <{$icontag} class=\"gallery-item\">
- $link
- ";
- if ($captiontag && trim($attachment->post_excerpt)) {
- $output .= "
- <{$captiontag} class=\"gallery-caption hidden\">
- " . wptexturize($attachment->post_excerpt) . "
- </{$captiontag}>";
- }
- $output .= "</{$icontag}>";
- if ($columns > 0 && ++$i % $columns == 0) {
- $output .= '';
+ $output .= '<li>' . $link;
+ if (trim($attachment->post_excerpt)) {
+ $output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>';
}
+ $output .= '</li>';
}
- $output .= "</ul>\n";
+ $output .= '</ul>';
return $output;
}

0 comments on commit 8000e5c

Please sign in to comment.
Something went wrong with that request. Please try again.