$attachment ) $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; return $output; } $inside_cube = isset( $GLOBALS['vamtam_inside_cube'] ) && $GLOBALS['vamtam_inside_cube']; if ( $inside_cube ) { $output .= '
'; } return $output; } public static function gallery_lightbox( $attr ) { // Allow plugins/child themes to override the default gallery template. $output = apply_filters( 'vamtam_post_gallery_lightbox', '', $attr ); if ( '' != $output ) { return $output; } $attachments = self::get_attachments( $attr ); if ( empty( $attachments ) ) return ''; if ( is_feed() ) { return ''; } foreach ( $attachments as $id => $attachment ) { $image_src = wp_get_attachment_image_src( $id, 'full' ); if ( ! empty( $image_src ) && ! empty( $image_src[0] ) ) { $output .= ''; } } return $output; } public static function get_attachments( $attr ) { extract( self::process_atts( $attr ) ); $id = intval( $id ); if ( 'RAND' == $order ) { $orderby = 'none'; } if ( ! empty( $include ) ) { $_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 ) ) { $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, ) ); } return $attachments; } public static function process_atts( $attr ) { $post = get_post(); if ( ! empty( $attr['ids'] ) ) { // 'ids' is explicitly ordered, unless you specify otherwise. if ( empty( $attr['orderby'] ) ) { $attr['orderby'] = 'post__in'; } $attr['include'] = $attr['ids']; } // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( ! $attr['orderby'] ) { unset( $attr['orderby'] ); } } return shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '', 'pausetime' => 3000, 'direction' => 'none', 'where' => 'single', ), $attr, 'gallery'); } } new Vamtam_Gallery;