Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_action( 'after_setup_theme', function() {
remove_shortcode( 'fl_year' );
add_shortcode( 'fl_year', function( $atts ) {
$atts = shortcode_atts( array(
'format' => 'Y',
), $atts );
$date = date( $atts['format'] );
$tz = get_option( 'timezone_string' );
if ( $tz ) {
$tzdate = new DateTime( date( 'Y-m-d H:i:s' ), new DateTimeZone( 'UTC' ) );
$tzdate->setTimezone( new DateTimeZone( $tz ) );
$date = $tzdate->format( $atts['format'] );
}
return $date;
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.