Advertisement
Guest User

Untitled

a guest
May 25th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function vc_gitem_post_date_demo( $template ) {
  2. $new_template = dirname( __FILE__ ) . '/vc_gitem_post_date_demo.php';
  3. if ( is_file( $new_template ) ) {
  4. return $new_template;
  5. }
  6.  
  7. return $template;
  8. }
  9.  
  10. add_filter( 'vc_shortcode_set_template_vc_gitem_post_date', 'vc_gitem_post_date_demo' );
  11.  
  12. /**
  13. * Get post data. Used as wrapper for others post data attributes.
  14. *
  15. * @param $data
  16. *
  17. * @return mixed|string
  18. */
  19. function vc_gitem_template_attribute_post_date_demo( $value, $data ) {
  20. /**
  21. * @var null|Wp_Post $post ;
  22. * @var string $data ;
  23. */
  24. extract( array_merge( array(
  25. 'post' => null,
  26. 'data' => ''
  27. ), $data ) );
  28. $date = get_post_time( 'U', true, $post );
  29. return 'human' === $data ? human_time_diff( $date, current_time( 'timestamp' ) ) . ' '. __( 'ago' ) : date('d-m-Y', $date);
  30. }
  31. add_filter( 'vc_gitem_template_attribute_post_date_demo', 'vc_gitem_template_attribute_post_date_demo', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement