[wordpress插件] Always Allow Admin Comments一律允许管理员评论

wordpress 插件 文章 2020-02-17 00:20 532 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

This plugin enables a user with the administrator role the ability to comment on any post or page, even if the comments for that post or page are closed.

此插件使具有管理员角色的用户可以对任何帖子或页面发表评论,即使该帖子或页面的评论已关闭。

When the plugin is active, this behavior is automatically enabled.

当插件处于活动状态时,此行为会自动启用。

Administrators can be explicitly prevented from commenting on specific posts via two approaches:

可以通过两种方法明确禁止管理员对特定帖子发表评论:

    • When creating or editing a post, in the “Prevent Admin Comments” metabox (in the block editor) or the “Discussion” metabox (in the classic editor) there is a checkbox labeled “Prevent administrators from commenting” that only administrators

    • 创建或编辑帖子时,在“阻止管理员评论”元框(在块编辑器中)或“讨论”元框(在经典编辑器中)中有一个复选框,标有“防止管理员发表评论”,仅管理员

      can access.

      可以访问。

      Checking the checkbox will prevent administrators from commenting on the post even though this plugin is active.

      选中此复选框将阻止管理员评论该帖子,即使该插件处于活动状态也是如此。

      (If the metabox isn’t visible for you when using the classic editor, then expand the “Screen Options” slide-down panel on the upper-right of the page.)

    • (如果在使用经典编辑器时看不到元数据框,请展开页面右上方的“屏幕选项”下拉面板。)

    • Programmatically, via the use of the ‘c2c_admin_can_always_comment_disable’ filter.

    • 以编程方式,通过使用“ c2c_admin_can_always_comment_disable”过滤器。

      This can be used be provide more fine-grained access control and contextual handling.

      这可用于提供更细粒度的访问控制和上下文处理。

      See the “Hooks” section for documentation on the filter’s use.

    • 有关过滤器使用的文档,请参见“挂钩”部分。

    Links: Plugin Homepage |

    链接:插件主页 |

    Plugin Directory Page |

    插件目录页面 |

    GitHub |

    GitHub |

    Author Homepage

    作者主页

    Hooks

    挂钩

    The plugin is further customizable via one hook.

    该插件还可以通过一个钩子进行自定义。

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

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

    c2c_always_allow_admin_comments_disable (filter)

    c2c_always_allow_admin_comments_disable(过滤器)

    The ‘c2c_always_allow_admin_comments_disable’ filter allows you to customize whether comments should actually be disabled for a particular admin user.

    通过“ c2c_always_allow_admin_comments_disable”过滤器,您可以自定义是否应针对特定管理员用户实际禁用评论。

    By default, all admin users can always comment on posts and pages.

    默认情况下,所有管理员用户始终可以在帖子和页面上发表评论。

    Using this filter, you have finer-grained controls to override this behavior.

    使用此过滤器,您可以使用更细粒度的控件来覆盖此行为。

    It takes into account the checkbox provided per post to explicitly prevent admin comments.

    它考虑了每个帖子提供的复选框,以明确阻止管理员评论。

    NOTE: This filter is only used if comments for the post are closed and the current user is an admin.

    注意:仅当帖子的评论已关闭并且当前用户是管理员时,才使用此过滤器。

    This filter is only to override the behavior of the plugin and is not a general purpose filter for enabling or disabling comments.

    此过滤器仅用于覆盖插件的行为,不是用于启用或禁用评论的通用过滤器。

    Arguments:

    参数:

      • $status (bool): The comment status of the current post for the current user.
      • $ status(布尔):当前帖子对当前用户的评论状态。

      • $post_id (int): The ID of the post whose comments are being checked.
      • $ post_id(int):正在检查其评论的帖子的ID。

      Return:

      返回:

        • (bool): True if admin commenting is disabled, false if admin can comment.
        • (布尔):如果禁用了管理员评论,则为true;如果管理员可以发表评论,则为false。

        Example:

        示例:

        /** 

          / ** 

        * Only allow certain admins the ability to comment on all posts. 

        *仅允许某些管理员对所有帖子发表评论。 

        * @param bool $status The comment open status. 

        * @param bool $ status注释的打开状态。 

        * @param int $post_id The post id. 

        * @param int $ post_id帖子ID。 

        * @return bool True if admin commenting is disabled, false if not. 

        * @return bool如果禁用了管理员注释,则为true,否则为false。 

        */

        * /

        function restrict_admin_commenting( $status, $post_id ) {    

        function limit_admin_commenting($ status,$ post_id){    

        // User IDs of the admins who can always comment.    

        //可以随时发表评论的管理员的用户ID。    

        $admins_who_can_comment = array( 2, 13 );    

        $ admins_who_can_comment = array(2,13);    

        // Admins not specified above cannot comment when comments are closed.    

        //关闭注释后,上面未指定的管理员无法发表评论。    

        return !

        退货!

        in_array( get_current_user_id(), $admins_who_can_comment );

        in_array(get_current_user_id(),$ admins_who_can_comment);

        }

        }

        add_filter( 'c2c_always_allow_admin_comments_disable', 'restrict_admin_commenting', 10, 2 );

        add_filter('c2c_always_allow_admin_comments_disable','restrict_admin_commenting',10,2);

安装步骤

    1. Install via the built-in WordPress plugin installer.

    2. 通过内置的WordPress插件安装程序进行安装。

      Or download and unzip always-allow-admin-comments.zip inside the plugins directory for your site (typically wp-content/plugins/)

    3. 或在您网站的插件目录中下载 always-allow-admin-comments.zip 并解压缩(通常为 wp-content / plugins /

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

下载地址
https://downloads.wordpress.org/plugin/always-allow-admin-comments.1.2.2.zip
-EOF-

AI助手支持GPT4.0