Skip to content

Commit

Permalink
Merge pull request #22 from a8cteam51/add/copyright-year
Browse files Browse the repository at this point in the history
Add a new shortcode for displaying the copyright symbol and year
  • Loading branch information
ahegyes authored Jan 12, 2024
2 parents 5210cf3 + 24194af commit 0176070
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Parameters can be passed in --
* `pressable` -- The text displayed for the backlink to Pressable
Defaults to `Hosted by Pressable.`
Link is skipped if not truthy.
* `format` -- The date format to use with the `[team51-current-year]` shortcode.
Defaults to `Y`.

Customization
=============
Expand Down Expand Up @@ -72,6 +74,15 @@ or
or the like. It will also accept `wpcom` and `pressable` parameters
as well to specify their respective link texts.

For inserting the current year, use this:

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

... will output "2024", or whatever the current year is.


### Examples
Expand All @@ -92,6 +103,14 @@ Change WordPress link text to be “Proudly designed with WordPress”:
<!-- /wp:shortcode -->
```

Add the current year in the format “24”:

```html
<!-- wp:shortcode -->
[team51-current-year format="y"]
<!-- /wp:shortcode -->
```



Installation
Expand Down Expand Up @@ -122,3 +141,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.
33 changes: 32 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,34 @@ function () {
}
);
endif;

if ( ! function_exists( 'team51_current_year_shortcode' ) ) :

/**
* The Shortcode for `[team51-current-year]`.
*
* Can also be used in the Shortcode block.
*
* @param array{format?: string} $atts The Args passed to the function.
*
* @return string
*/
function team51_current_year_shortcode( $atts ) {
$atts = shortcode_atts(
array(
'format' => 'Y',
),
$atts,
'team51-current-year'
);

$current_year = gmdate( $atts['format'] );
return esc_html( $current_year );
}
add_action(
'init',
function () {
add_shortcode( 'team51-current-year', 'team51_current_year_shortcode' );
}
);
endif;

0 comments on commit 0176070

Please sign in to comment.