Skip to content

Commit

Permalink
Add a new shortcode for copyright year
Browse files Browse the repository at this point in the history
Add a new, automatically updating copyright year shortcode.
  • Loading branch information
nickpagz committed Jan 12, 2024
1 parent 5210cf3 commit 057b28d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ Change WordPress link text to be “Proudly designed with WordPress”:
<!-- /wp:shortcode -->
```

Add a copyright year in the format “© 2024”:

```html
<!-- wp:shortcode -->
[team51-copyright-year]
<!-- /wp:shortcode -->
```



Installation
Expand Down Expand Up @@ -122,3 +130,8 @@ git submodule add https://github.com/a8cteam51/colophon mu-plugins/colophon
```

Then we create a pull request as needed and integrate it as above.


### Updates

* v1.2.0 Add a new shortcode for showing the copyright year.
24 changes: 23 additions & 1 deletion colophon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Colophon
Plugin URI: https://github.com/a8cteam51/colophon
Description: Sets Team 51 footer links to WordPress.com and Pressable.
Version: 1.1.0
Version: 1.2.0
Author: WordPress.com Special Projects
Author URI: https://wpspecialprojects.wordpress.com/
License: GPLv3
Expand Down Expand Up @@ -128,3 +128,25 @@ function () {
}
);
endif;

if ( ! function_exists( 'team51_copyright_shortcode' ) ) :

/**
* The Shortcode for `[team51-copyright-year]`.
*
* Can also be used in the Shortcode block.
*
* @return string
*/
function team51_copyright_shortcode() {
$current_year = gmdate( 'Y' );
$output = "&copy; $current_year";
return esc_html( $output );
}
add_action(
'init',
function () {
add_shortcode( 'team51-copyright-year', 'team51_copyright_shortcode' );
}
);
endif;

0 comments on commit 057b28d

Please sign in to comment.