ID ) ); // Set orientation and image constraint classes if ( isset( $image_meta['width'], $image_meta['height'] ) ) { // Use small classes when original image size is too small if ( $image_meta['width'] <= $image_size_threshhold || $image_meta['height'] <= $image_size_threshhold ) { $classes[] = 'grid-item-small'; } // Use small class to make the grid-item images size conform to post-title size instead of image size if ( ( $image_meta['width'] > $image_meta['height'] ) && ( ( $image_meta['width'] / $image_meta['height'] ) <= 1 ) ) { $classes[] = 'grid-item-small'; } // Landscape images if ( $image_meta['width'] >= $image_meta['height'] ) { $classes[] = 'grid-item-landscape'; // Portrait images } else { $classes[] = 'grid-item-portrait'; } } // Get featured content settings and options $featured_options = get_option( 'featured-content' ); $featured_tag_name = isset( $featured_options['tag-name'] ) ? $featured_options['tag-name'] : ''; if ( ! empty( $featured_tag_name ) && has_tag( $featured_tag_name, $post->ID ) ) { $classes[] = 'grid-item-featured'; } } return $classes; } add_filter( 'post_class', 'altofocus_post_classes' ); /** * Add a pingback url auto-discovery header for singularly identifiable articles. */ function altofocus_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'altofocus_pingback_header' ); /** * Slideshow Gallery Filter * * Replaces the default gallery when type=slideshow is used * See: componenets/post/content-single.php * Source: https://wordpress.stackexchange.com/a/64022 */ function altofocus_slideshow_gallery_filter( $output, $attr ) { $id = null; $order = null; $size = null; global $post; static $count = 0; if ( $count > 0 ) { return $output; // Ensure the gallery output is replaced once. } static $instance = 0; $instance++; // 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'] ); } } $short_atts = shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'li', 'icontag' => null, 'captiontag' => 'p', 'columns' => 3, 'size' => 'large', 'include' => '', 'exclude' => '' ), $attr); extract( $short_atts ); $id = intval($id); if ( 'RAND' == $order ) { $orderby = 'none'; } 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 = 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) ); } if ( empty( $attachments ) ) { return ''; } // The gallery output $selector = "gallery-{$instance}"; $size_class = sanitize_html_class( $size ); $output = "
'; $count++; // Update counter after successful replacement. return $output; }