![](https://i-blog.csdnimg.cn/blog_migrate/b935f78bcb4b73d7a6f3a65217910206.png)
wordpress弹窗通知
As a consultant, developer, or designer, sometimes you just get hired to do the project and leave. Often in these circumstances, many developers customize the WordPress admin area and remove all the main settings options, so the client cannot break the site. However, it is really frustrating when another developer comes in just to find out that he has to take out bunch of code to see the settings. Or even if the owner decides they want to do things themselves, they don’t have the freedom to do so. The whole point of WordPress is to empower the publisher and give them freedom to publish content the way they want. Therefore in this article, we will show you how to give your clients full administrative access, but include warning notices for them, so they know the consequences of their actions. By simply hooking into WordPress admin_notices hook, we can display a notice that may say “Warning – changing settings on this page may cause problem with your website’s design”.
作为顾问,开发人员或设计师,有时您只是被雇用去做项目并离开。 通常,在这种情况下,许多开发人员自定义WordPress管理区域并删除所有主要设置选项,因此客户端无法破坏该站点。 但是,当另一个开发人员进来只是发现他必须拿出一大堆代码来查看设置时,这确实令人沮丧。 或者,即使所有者决定要自己做某事,他们也没有这样做的自由。 WordPress的全部目的是赋予发布者权力,让他们自由地按自己想要的方式发布内容。 因此,在本文中,我们将向您展示如何授予客户完整的管理访问权限,但包括对他们的警告通知,以便他们知道其操作的后果。 通过简单地插入WordPress admin_notices钩子,我们可以显示一条通知,其中可能显示“警告-更改此页面上的设置可能会导致您的网站设计出现问题”。
![Warning Notices for your Clients in WordPress](https://i-blog.csdnimg.cn/blog_migrate/ddad18654a3341c11d7ca744386a6650.png)
First open your theme’s functions.php file, and then paste the following:
首先打开您主题的functions.php文件,然后粘贴以下内容:
add_action( 'admin_notices', 'my_admin_notice' );
function my_admin_notice(){
global $current_screen;</div>
if ( $current_screen->parent_base == 'options-general' )
echo '<div><p>Warning - changing settings on these pages may cause problems with your website’s design!</p></div>';
}
You can modify the notices for each screen.
您可以修改每个屏幕的通知。
Thanks to Jacob Goldman for pointing this trick out. This will be great for our clients.
感谢Jacob Goldman指出这一技巧。 这将对我们的客户非常有用。
翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-add-warning-notices-for-your-clients-in-wordpress/
wordpress弹窗通知