开发者 | coffee2code |
---|---|
更新时间 | 2021年6月19日 17:18 |
捐献地址: | 去捐款 |
PHP版本: | 4.6 及以上 |
WordPress版本: | 5.7 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
c2c_blog_time()
.
NOTE: For the front-end widget, if the "Use dynamic clock?" configuration option is unchecked, this plugin generates a timestamp and NOT a clock. The time being displayed is the time of the page load, or if clicked, the time when the widget last retrieved the time. It won't actively increment time on the display. By default the widget displays a dynamic clock that does increment time.
This is most useful to see the server/blog time to judge when a time sensitive post, comment, or action would be dated by the blog (i.e. such as monitoring for when to close comments on a contest post, or just accounting for the server being hosted in a different timezone). Or, when used statically as a timestamp and not a clock, it can indicate/preserve when the page was loaded.
Thanks to Moment.js for the JavaScript date handling library.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
blog-time.zip
inside the plugins directory for your site (typically wp-content/plugins/
)c2c_blog_time()
in a theme template file to display the blog's time at the time of the page's rendering.Under the site's general admin settings -- at Settings -> General -- you'll find a "Blog Time Format" setting that accepts any valid PHP time format token. See https://www.php.net/manual/en/datetime.format.php for more information regarding valid time format tokens.
The widget and template tag also allow you to specify a time format directly.
The default value for the time format, and the one used by the display of the blog time in the static admin widget, can be overridden by hooking the c2c_blog_time_format
filter and returning the desired time format. This takes precedence over the setting's value.
The widget's "Use dynamic clock?" configuration setting may not be checked (which it is by default). Or JavaScript could be disabled in the browser.
Your machine may well be synced with the server's clock. One test you can perform is to change the blog's time zone (under Settings -> General). The blog's time will then be set to a different hour, which should then be reflected by the widget. Remember to change the time zone back to its proper value!
Yes, but only programmatically at the moment. Check out the docs for the 'c2c_blog_time_toolbar_widget_for_user'
filter for more information and a code example.
See the Filters section for the 'c2c_blog_time_active_clock'
filter, which includes an example line of code you'll need to add to your theme.
Via Settings -> General, you can set the "Blog Time Format" value to something like M d, Y
, which results in a time format like "Jun 21, 2021". See https://www.php.net/manual/en/datetime.format.php for other month, day, and year time format tokens.
Yes.
initialize_setting()
, allowed_options()
, display_option()
, plugin_action_links()
, and is_wp_55_or_later()
'blog_time_format'
filter. Use 'c2c_blog_time_format'
instead.wp_add_inline_script()
instead of wp_localize_script()
$exit
arg to report_time()
to allow not exiting after outputting the timetests/
top-level directorybin/
into tests/
tests/bootstrap.php
into tests/phpunit/
tests/*.php
into tests/phpunit/tests/
phpunit.xml
to phpunit.xml.dist
per best practicesenqueue_js()
, report_time()
, admin_bar_menu()
is_wp_login()
since it is no longer necessaryenqueue_js()
that is already performed in show_in_toolbar_for_user()
display_time()
get_time_format()
tearDown()