Advertisement
daymobrew

display-posts-shortcode patch to add wrapper ID

Nov 15th, 2013
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. --- display-posts-shortcode.orig.php    2012-12-22 04:03:38.000000000 +0000
  2. +++ display-posts-shortcode.php 2013-11-15 23:29:07.065103200 +0000
  3. @@ -72,6 +72,7 @@
  4.         'tax_term'            => false,
  5.         'taxonomy'            => false,
  6.         'wrapper'             => 'ul',
  7. +       'wrapper_id'          => '',
  8.     ), $atts );
  9.  
  10.     $author = sanitize_text_field( $atts['author'] );
  11. @@ -97,6 +98,7 @@
  12.     $tax_term = sanitize_text_field( $atts['tax_term'] );
  13.     $taxonomy = sanitize_key( $atts['taxonomy'] );
  14.     $wrapper = sanitize_text_field( $atts['wrapper'] );
  15. +   $wrapper_id = sanitize_text_field( $atts['wrapper_id'] );
  16.  
  17.    
  18.     // Set up initial query for post
  19. @@ -251,7 +253,10 @@
  20.        
  21.     endwhile; wp_reset_postdata();
  22.    
  23. -   $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<' . $wrapper . ' class="display-posts-listing">', $original_atts );
  24. +   if( !empty( $wrapper_id ) )
  25. +       $wrapper_id = ' id="'.$wrapper_id.'"';
  26. +
  27. +   $open = apply_filters( 'display_posts_shortcode_wrapper_open', '<' . $wrapper . ' class="display-posts-listing"' . $wrapper_id . '>', $original_atts );
  28.     $close = apply_filters( 'display_posts_shortcode_wrapper_close', '</' . $wrapper . '>', $original_atts );
  29.     $return = $open . $inner . $close;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement