| 开发者 | ghostlabs |
|---|---|
| 更新时间 | 2026年10月2日 20:17 |
| PHP版本: | 7.4 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
© 2001 – 2026 in English. Set the start year to the current
year and it shows that year on its own rather than a range of one. The format is
translatable, so a locale can set its own separator, numerals or placement for the © symbol.ghostlabs-dynamic-copyright-notice folder to /wp-content/plugins/.No. The year is worked out each time the page is served.
The notice itself is always right — it is worked out when the page is served. What can go stale is a cached copy of the finished page: one cached on 31 December keeps serving last year's notice until that cache is cleared. So the plugin clears it, on four caching plugins by name. The first request of the new year that WordPress actually builds notices the year has changed and clears the cache. There is no scheduled task and nothing to configure — a cached page is served without WordPress ever loading this plugin, so the only thing that can trigger the check is the next request that is not served from cache: an admin opening the dashboard, a logged-in reader, a crawler, or any page the cache is not already holding. Cleared for you: WP Rocket, W3 Total Cache, WP Super Cache and LiteSpeed Cache — those four, and no others. Each is asked for a full flush, so on W3 Total Cache and LiteSpeed that clears their object caches too; once a year, deliberately. Each one ties this plugin to somebody else's code, so the list stays deliberately short; the hook in the next question is what scales. Any other cache: if it expires at least once a year, it corrects itself the next time it expires — which with a twelve-month lifetime can be most of a year. With very long or indefinite lifetimes, clear your page cache once after New Year, or set your caching plugin to purge on a schedule.
Yes — two hooks, both reached on that same first request of the new year. Neither fires on a
brand-new install, which has no previous year on record to compare against.
The ghostlabs_perennial_year_rolled_over action is passed the new year and the year
before it. It fires whether or not this plugin clears anything, so it is the place to purge a
cache, CDN or host layer this plugin does not know about.
add_action( 'ghostlabs_perennial_year_rolled_over', function ( $current, $stored ) { // Clear your own cache here. }, 10, 2 );
The ghostlabs_perennial_purge_on_rollover filter defaults to true. Return false
and the plugin clears nothing itself. The action above still fires, so you can decline the
built-in purge and still handle it your own way.
Your site's, as set in Settings → General → Timezone. Working it out in the visitor's browser instead would mean someone in Auckland and someone in Los Angeles could see different years for a few hours around New Year.
The notice uses your site title, and keeps using it — so if you rename the site later, every notice updates. Type a name only if you want it to differ from the site title.
Yes. Select the block, open the Styles tab, and use Year typography and Year color.
These affect only the year and the © symbol. The rest of the notice uses the block's normal
color and typography controls.
The year's font size is offered in rem, em, ch and % rather than pixels, so it scales
with your theme and with a reader's text-size settings. The block's own font size control offers
whatever units your theme does.
ghostlabs_perennial_year_rolled_over, passed the new and previous
year, so any other cache, CDN or host layer can clear itself.ghostlabs_perennial_purge_on_rollover (default true), to turn the
plugin's own purging off. The action fires either way.