Advertisement
Guest User

Untitled

a guest
Sep 5th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. // Custom Gallery Code For Flipboard/Pulse/Google Currents Feeds
  2. if ( is_feed( 'flipboard_feed' ) ) {
  3.     add_filter('post_gallery', 'flipboard_gallery_shortcode', 10, 2);
  4.     function flipboard_gallery_shortcode($output, $attr) {
  5.         global $post;
  6.  
  7.         static $instance = 0;
  8.         $instance++;
  9.  
  10.         // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
  11.         if ( isset( $attr['orderby'] ) ) {
  12.             $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
  13.             if ( !$attr['orderby'] )
  14.                 unset( $attr['orderby'] );
  15.         }
  16.  
  17.         extract(shortcode_atts(array(
  18.             'order'      => 'ASC',
  19.             'orderby'    => 'menu_order ID',
  20.             'id'         => $post->ID,
  21.             'itemtag'    => 'dl',
  22.             'icontag'    => 'dt',
  23.             'captiontag' => 'dd',
  24.             'columns'    => 3,
  25.             'size'       => 'full',
  26.             'include'    => '',
  27.             'exclude'    => ''
  28.         ), $attr));
  29.  
  30.         $id = intval($id);
  31.         if ( 'RAND' == $order )
  32.             $orderby = 'none';
  33.  
  34.         if ( !empty($include) ) {
  35.             $include = preg_replace( '/[^0-9,]+/', '', $include );
  36.             $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
  37.  
  38.             $attachments = array();
  39.             foreach ( $_attachments as $key => $val ) {
  40.                 $attachments[$val->ID] = $_attachments[$key];
  41.             }
  42.         } elseif ( !empty($exclude) ) {
  43.             $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
  44.             $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
  45.         } else {
  46.             $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
  47.         }
  48.  
  49.         if ( empty($attachments) )
  50.             return '';
  51.  
  52.         if ( is_feed() ) {
  53.             $output = '<section class="fl-slideshow">';
  54.             foreach ( $attachments as $att_id => $attachment )
  55.                 $output .= '<figure>' . wp_get_attachment_image($att_id, 'full') . '<figcaption>' . wptexturize($attachment->post_excerpt) . '</figcaption></figure>';
  56.                 $output .= '</section>';
  57.             return $output;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement