Advertisement
singhnsk

WooThemes Post_Date Shortcode

Apr 29th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. /**
  2.  * 3. Post Date
  3.  *
  4.  * This function produces the date the post in question was published.
  5.  *
  6.  * @example <code>[post_date]</code> is the default usage
  7.  */
  8. if ( ! function_exists( 'woo_shortcode_post_date' ) ) {
  9. function woo_shortcode_post_date ( $atts ) {
  10.     $defaults = array(
  11.         'format' => get_option( 'date_format' ),
  12.         'before' => '',
  13.         'after' => '',
  14.         'label' => ''
  15.     );
  16.     $atts = shortcode_atts( $defaults, $atts );
  17.  
  18.     $atts = array_map( 'wp_kses_post', $atts );
  19.  
  20.     $output = sprintf( '<abbr class="date time published updated" title="%5$s">%1$s%3$s%4$s%2$s</abbr> ', $atts['before'], $atts['after'], $atts['label'], get_the_time($atts['format']), get_the_time('Y-m-d\TH:i:sO') );
  21.     return apply_filters( 'woo_shortcode_post_date', $output, $atts );
  22. } // End woo_shortcode_post_date()
  23. }
  24.  
  25. add_shortcode( 'post_date', 'woo_shortcode_post_date' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement