cliff
2/29/2016 - 10:42 PM

Adds the visual copyright notice, dynamic for current year. Snagged from Genesis theme.

Adds the visual copyright notice, dynamic for current year. Snagged from Genesis theme.

<?php
/*
  *
  * Snagged from Genesis!
  * /wp-content/themes/genesis/lib/shortcodes/footer.php
  *
  */
add_shortcode( 'tk-copyright', 'tk_copyright_shortcode' );
/**
 * Adds the visual copyright notice.
 *
 * Supported shortcode attributes are:
 *   after (output after notice, default is empty string),
 *   before (output before notice, default is empty string),
 *   copyright (copyright notice, default is copyright character like (c) ),
 *   first (year copyright first applies, default is empty string).
 *
 * If the 'first' attribute is not empty, and not equal to the current year, then
 * output will be formatted as first-current year (e.g. 1998-2020).
 * Otherwise, output is just given as the current year.
 *
 * @param array|string $atts Shortcode attributes. Empty string if no attributes.
 * @return string Shortcode output
 */
function tk_copyright_shortcode( $atts ) {

	$defaults = array(
		'after'     => '',
		'before'    => '',
		'copyright' => '&#x000A9;',
		'first'     => '',
	);
	$atts = shortcode_atts( $defaults, $atts, 'tk-copyright' );

	$output = $atts['before'] . $atts['copyright'] . '&nbsp;';

	if ( '' != $atts['first'] && date( 'Y' ) != $atts['first'] )
		$output .= $atts['first'] . '&#x02013;';

	$output .= date( 'Y' ) . $atts['after'];

	return $output;

}