diff --git a/inc/extras.php b/inc/extras.php index 58b1e2737..e883d4e01 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -233,3 +233,33 @@ function _s_display_customizer_footer_scripts() { // Otherwise, echo the scripts! echo force_balance_tags( $scripts ); // WPCS XSS OK. } + + +/** + * Shortcode to display copyright year. + * + * @author Haris Zulfiqar + * @param array $atts {. + * @type string $starting_year Optional. Define starting year to show starting year and current year e.g. 2015 - 2018. + * @type string $separator Optional. Separator between starting year and current year. + * } + * @return string + */ +function _s_copyright_year( $atts ) { + + // Setup defaults. + $args = shortcode_atts( array( + 'starting_year' => '', + 'separator' => ' - ', + ), $atts ); + + $current_year = date( 'Y' ); + + // Return current year if starting year is empty. + if ( ! $args['starting_year'] ) { + return $current_year; + } + + return esc_html( $args['starting_year'] . $args['separator'] . $current_year ); +} +add_shortcode( '_s_copyright_year', '_s_copyright_year', 15 ); diff --git a/inc/template-tags.php b/inc/template-tags.php index b3e8faf0c..5fb25f2b6 100755 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -313,7 +313,7 @@ function _s_display_copyright_text() { } ?> - +