From 2c9d35ab7f9ea8a50bb0894dadbc3fe0cf4015e4 Mon Sep 17 00:00:00 2001 From: MickeyKay Date: Tue, 25 Nov 2014 13:47:18 -0800 Subject: [PATCH] Add date shortcode - thanks Braad! --- includes/shortcodes/shortcodes.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/includes/shortcodes/shortcodes.php b/includes/shortcodes/shortcodes.php index 1c9cb09..3463e3f 100644 --- a/includes/shortcodes/shortcodes.php +++ b/includes/shortcodes/shortcodes.php @@ -18,7 +18,7 @@ function trestle_shortcode_empty_paragraph_fix($content) '

[' => '[', ']

' => ']', ']
' => ']' - ); + ); $content = strtr($content, $array); @@ -40,7 +40,7 @@ add_filter('the_content', 'trestle_shortcode_empty_paragraph_fix'); function trestle_column( $atts, $content = null ) { extract( shortcode_atts( array( 'class' => '', - ), $atts ) ); + ), $atts ) ); return '
' . do_shortcode( $content ) . '
'; } add_shortcode( 'col', 'trestle_column' ); @@ -56,13 +56,13 @@ function trestle_button( $atts, $content = null ) { 'href' => '#', 'title' => '', 'class' => '', - ), $atts ) ); + ), $atts ) ); return '' . do_shortcode( $content ) . ''; } add_shortcode( 'button', 'trestle_button' ); /** - * Buttons + * Button * * Example: * [button href="url" title="title" target="target" class="class"]Text[/button] @@ -73,7 +73,26 @@ function trestle_button( $atts, $content = null ) { 'target' => '', 'title' => '', 'class' => '', - ), $atts ) ); + ), $atts ) ); return '' . do_shortcode( $content ) . ''; } add_shortcode( 'button', 'trestle_button' ); + +/** + * Date + * + * Example: [date format="M d, Y"] + * + */ +function trestle_date( $atts ) { + extract( shortcode_atts( array( + 'format' => 'M d, Y', + ), $format ) ); + + if ( ! $format ) { + $format = 'M d, Y'; + } + + return date( $format ); +} +add_shortcode( 'date', 'trestle_date' );