Advertisement
alchymyth

wp-caption on top

Feb 27th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. remove_shortcode('wp_caption');
  2. remove_shortcode('caption');
  3. add_shortcode('wp_caption', 'top_caption_shortcode');
  4. add_shortcode('caption', 'top_caption_shortcode');
  5. //
  6. // move captions to top of image
  7. // alchymyth 2011
  8. //
  9. //reshuffling of the original caption shortcode in /wp-includes/media.php line 707
  10. //
  11. function top_caption_shortcode($attr, $content = null) {
  12.         // Allow plugins/themes to override the default caption template.
  13.         $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  14.         if ( $output != '' ) return $output;
  15.         extract(shortcode_atts(array(
  16.                 'id'=> '',
  17.                 'align' => 'alignnone',
  18.                 'width' => '',
  19.                 'caption' => ''), $attr));
  20.         if ( 1 > (int) $width || empty($caption) )
  21.         return $content;
  22.         if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  23.         return '<div ' . $id . 'class="wp-caption ' . esc_attr($align)
  24.         . '" style="width: ' . ((int) $width+ 10) . 'px">'
  25.         . '<p class="wp-caption-text">' . $caption . '</p>'
  26.         . do_shortcode( $content )
  27.         . '</div>';
  28.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement