[wordpress插件] Blog Time博客时间

wordpress 插件 文章 2020-03-07 07:00 494 0 全屏看文

AI助手支持GPT4.0

评分
68
描述

This plugin adds a dynamic, functional clock to the the admin bar (at top of all admin pages) to show the server time for the blog.

此插件将动态功能时钟添加到管理栏(在所有管理页面顶部),以显示博客的服务器时间。

The clock automatically updates as time passes, as you would expect of a digital clock.

时钟会随着时间的流逝而自动更新,就像您期望的数字时钟一样。

This plugin also supports a static mode which puts a timestamp string at the top of all admin pages instead of the dynamic clock.

此插件还支持静态模式,该模式将时间戳字符串放在所有管理页面的顶部,而不是动态时钟。

This static admin time widget is AJAX-ified so that if you click the timestamp, it updates in place (without a page reload) to show the new current server time.

此静态管理时间窗口小部件经过AJAX验证,因此,如果您单击时间戳,它将在适当位置更新(无需重新加载页面)以显示新的当前服务器时间。

Also provided is a “Blog Time” widget providing the same functionality as the admin widget, but for your sidebars.

还提供了一个“博客时间”窗口小部件,其功能与管理窗口小部件相同,只不过用于侧边栏。

You may also utilize the plugin’s functionality directly within a theme template via use of the template tag c2c_blog_time().

您还可以通过使用模板标记 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 (ie 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.

感谢 Moment.js 用于JavaScript日期处理库。

Links: Plugin Homepage |

链接:插件主页 |

Plugin Directory Page |

插件目录页面 |

GitHub |

GitHub |

Author Homepage

作者主页

Template Tags

模板标签

The plugin provides one template tag for use in your theme templates, functions.php, or plugins.

该插件提供了一个模板标签,可用于您的主题模板,functions.php或插件。

Functions

功能


    • <?php函数c2c_blog_time($ time_format ='',$ echo = true)吗?>

      Gets the formatted time for the site.

    • 获取网站的格式化时间。

    Arguments

    参数

      • $time_format (string)

        $ time_format (字符串)

        Optional.

        可选的。

        PHP-style time format string.

        PHP样式的时间格式字符串。

        See https://php.net/date for more info.

        有关更多信息,请参见https://php.net/date。

        Default is ” (which, unless otherwise modified, uses the default time forat: ‘g:i A’).

        默认值为”(除非另行修改,否则使用默认时间格式:“ g:i A”)。

      • $echo (bool)

        $ echo (bool)

        Optional.

        可选的。

        Echo the template info?

        回显模板信息?

        Default is true.

        默认值为true。

      Examples

      示例

        • <?php //输出站点的当前时间。

          c2c_blog_time();

          c2c_blog_time();

          ?>

          ?>

        • <?php //检索要在代码中使用的值,因此不要显示/回显它。

          $site_date = c2c_blog_time( 'M d, Y', false );

          $ site_date = c2c_blog_time('M d,Y',false);

          ?>

          ?>

        Hooks

        挂钩

        The plugin exposes four filters for hooking.

        该插件公开了四个用于挂接的过滤器。

        Code using these filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).

        理想情况下,应该将使用这些过滤器的代码放入mu插件或特定于站点的插件中(这不在本自述文件的解释范围内)。

        Less ideally, you could put them in your active theme’s functions.php file.

        不太理想的是,您可以将它们放在活动主题的functions.php文件中。

        c2c_blog_time (filter)

        c2c_blog_time(过滤器)

        The 'c2c_blog_time' hook allows you to use an alternative approach to safely invoke c2c_blog_time() in such a way that if the plugin were deactivated or deleted, then your calls to the function won't

        通过'c2c_blog_time'挂钩,您可以使用另一种方法安全地调用 c2c_blog_time(),这样,如果停用或删除了插件,则对函数的调用不会

        cause errors in your site.

        导致您的网站出现错误。

        Arguments:

        参数:

          • same as for c2c_blog_time()
          • c2c_blog_time()

          Example:

          示例:

          Instead of:

          代替:

            <?php c2c_blog_time(); 

          ?>

          ?>

          Do:

          做:

            <?php echo apply_filters('c2c_blog_time',''); 

          ?>

          ?>

          c2c_blog_time_format (filter)

          c2c_blog_time_format(过滤器)

          The ‘c2c_blog_time_format’ hook allows you to customize the default format for the blog time.

          通过“ c2c_blog_time_format”钩子,您可以自定义博客时间的默认格式。

          By default this is ‘g:i A’ (though this may be different if modified by localization).

          默认情况下,此名称为“ g:i A”(尽管如果通过本地化进行修改,则可能会有所不同)。

          Arguments:

          参数:

            • $format (string): The default format for the blog time.
            • $ format(字符串):博客时间的默认格式。

            Example:

            示例:

            /** 

              / ** 

            * Change the default blog time string 

            *更改默认博客时间字符串 

            * @param string $format The default time format. 

            * @param string $ format默认时间格式。 

            * @return string 

            * @返回字符串 

            */

            * /

            function change_blog_time_format( $format ) {    

            函数change_blog_time_format($ format){    

            return 'b, g:i A';

            返回'b,g:i A';

            }

            }

            add_filter( 'c2c_blog_time_format', 'change_blog_time_format' );

            add_filter('c2c_blog_time_format','change_blog_time_format');

            c2c_blog_time_toolbar_widget_for_user (filter)

            c2c_blog_time_toolbar_widget_for_user(过滤器)

            The ‘c2c_blog_time_toolbar_widget_for_user’ hook allows you to control if the admin toolbar clock widget should be shown, on a per-user basis.

            通过“ c2c_blog_time_toolbar_widget_for_user”钩子,您可以控制是否应按用户显示管理工具栏时钟小部件。

            By default the admin toolbar clock is shown to everyone who can see the admin toolbar.

            默认情况下,向所有可以看到管理工具栏的人显示管理工具栏时钟。

            Arguments:

            参数:

              • $shown (boolean): Whether the admin toolbar clock widget should be shown.

              • $ shown(布尔值):是否应显示管理工具栏时钟小部件。

                Default of true.

              • 默认为true。

              Example:

              示例:

              /** 

                / ** 

              * Only show the admin toolbar clock for the 'boss' user. 

              *仅显示“老板”用户的管理工具栏时钟。 

              * @param $show bool Status of whether the admin toolbar clock should be shown. 

              * @param $ show bool是否显示管理工具栏时钟的状态。 

              * @return bool 

              * @返回布尔 

              */

              * /

              function restrict_blog_time_widget_appearance( $show ) {    

              函数limit_blog_time_widget_appearance($ show){    

              return 'boss' == get_current_user()->user_login;

              return'boss'== get_current_user()-> user_login;

              }

              }

              add_filter( 'c2c_blog_time_toolbar_widget_for_user', 'restrict_blog_time_widget_appearance' );

              add_filter('c2c_blog_time_toolbar_widget_for_user','restrict_blog_time_widget_appearance');

              c2c_blog_time_active_clock (filter)

              c2c_blog_time_active_clock(过滤器)

              The 'c2c_blog_time_active_clock' hook returns the boolean value indicating if the Javascript-powered dynamic clock introduced in v2.0 should be enabled or if instead the v1.x era behavior of a static timestamp that can be clicked to update the timestamp via

              'c2c_blog_time_active_clock'钩子返回布尔值,该布尔值指示是否应启用v2.0中引入的Javascript驱动的动态时钟,或者是否可以单击静态时间戳的v1.x时代行为,以通过单击来更新时间戳

              AJAX should be enabled.

              应该启用AJAX。

              By default the dynamic clock is enabled.

              默认情况下,动态时钟为启用状态。

              Arguments:

              参数:

                • $allow (boolean): Boolean indicating if the admin widget should be a dynamic clock.

                • $ allow(布尔值):布尔值,指示管理窗口小部件是否应为动态时钟。

                  Default is true.

                • 默认值为true。

                Example:

                示例:

                // Disable the dynamic clock and use the static timestamp (whcih can be clicked to update the time via AJAX) instead.

                  //禁用动态时钟并使用静态时间戳(可以单击此时间戳以通过AJAX更新时间)。

                add_filter( 'c2c_blog_time_active_clock', '__return_false' );

                add_filter('c2c_blog_time_active_clock','__return_false');

安装步骤

    1. Install via the built-in WordPress plugin installer or download and unzip blog-time.zip inside the plugins directory for your site (typically wp-content/plugins/

    2. 通过内置的WordPress插件安装程序进行安装,或在您网站的插件目录中下载 blog-time.zip 并解压缩(通常为 wp-content / plugins /

      )

    3. Activate the plugin through the ‘Plugins’ admin menu in WordPress
    4. 通过WordPress中的“插件”管理菜单激活插件

    5. Optionally use the ‘Blog Time’ widget or the template tag c2c_blog_time() in a theme template file to display the blog’s time at the time of the page’s rendering.
    6. (可选)在主题模板文件中使用“博客时间”窗口小部件或模板标签 c2c_blog_time()来显示页面渲染时博客的时间。

下载地址
https://downloads.wordpress.org/plugin/blog-time.3.6.1.zip
-EOF-

AI助手支持GPT4.0