| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 4 |
|
| 5 |
add_shortcode( 'wppb-format-date', 'wppb_toolbox_format_date_handler' ); |
| 6 |
function wppb_toolbox_format_date_handler( $atts ){ |
| 7 |
$a = shortcode_atts( array( |
| 8 |
'date' => null, |
| 9 |
'format' => null, |
| 10 |
),$atts ); |
| 11 |
|
| 12 |
if ($a['date'] === null) |
| 13 |
return; |
| 14 |
|
| 15 |
if ($a['format'] === null) |
| 16 |
return $a['date']; |
| 17 |
|
| 18 |
$date = strtotime($a['date']); |
| 19 |
|
| 20 |
return date($a['format'], $date); |
| 21 |
} |
| 22 |
|