Created
March 28, 2014 03:06
-
-
Save jesgs/0ceebb94fb5d409f202f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress Gallery Modification example | |
* Requires output buffering | |
* | |
* @author Jess Green <jgreen @ psy-dreamer.com> | |
* @package Gallery | |
* @version $Id$ | |
*/ | |
/** | |
* Modify post gallery markup with child-themeable template | |
* | |
* @param string $blank Not used | |
* @param array $attr Attributes array from gallery shortcode | |
* @return string Gallery markup from ob_get_clean() | |
*/ | |
function mytheme_post_gallery_markup($blank, $attr) | |
{ | |
global $post; | |
$attr = shortcode_atts(array( | |
'order' => 'ASC', | |
'orderby' => 'menu_order ID', | |
'id' => $post ? $post->ID : 0, | |
/* Ignore these | |
'itemtag' => $html5 ? 'figure' : 'dl', | |
'icontag' => $html5 ? 'div' : 'dt', | |
'captiontag' => $html5 ? 'figcaption' : 'dd', | |
*/ | |
'columns' => 3, | |
'size' => 'thumbnail', | |
'include' => '', | |
'exclude' => '', | |
'link' => '' | |
), $attr, 'gallery'); | |
extract($attr); | |
// include custom filter for modifying gallery wrapper classes | |
$default_gallery_classes = array( | |
'gallery', | |
"gallery-{$id}", | |
"gallery-columns-{$columns}" | |
); | |
$gallery_class_array = apply_filters('gallery_class', $default_gallery_classes); | |
$gallery_class = 'class="' . implode(" ", $gallery_class_array) . '"'; | |
ob_start(); | |
require_once locate_template(array('parts/gallery.php'), false, false); | |
$gallery_markup = ob_get_clean(); | |
return $gallery_markup; | |
} | |
add_filter('post_gallery', 'mytheme_post_gallery_markup', 555, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment