Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function vc_gitem_post_date_demo( $template ) {
- $new_template = dirname( __FILE__ ) . '/vc_gitem_post_date_demo.php';
- if ( is_file( $new_template ) ) {
- return $new_template;
- }
- return $template;
- }
- add_filter( 'vc_shortcode_set_template_vc_gitem_post_date', 'vc_gitem_post_date_demo' );
- /**
- * Get post data. Used as wrapper for others post data attributes.
- *
- * @param $data
- *
- * @return mixed|string
- */
- function vc_gitem_template_attribute_post_date_demo( $value, $data ) {
- /**
- * @var null|Wp_Post $post ;
- * @var string $data ;
- */
- extract( array_merge( array(
- 'post' => null,
- 'data' => ''
- ), $data ) );
- $date = get_post_time( 'U', true, $post );
- return 'human' === $data ? human_time_diff( $date, current_time( 'timestamp' ) ) . ' '. __( 'ago' ) : date('d-m-Y', $date);
- }
- 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