Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the functions of reminding to install plug-ins and hiding plug-ins in WordPress

Shulou Source: shulou.com Published: 2022-06-03 11:07:19 10月01日 Update

This article is about how to implement reminders to install plug-ins and hide plug-ins in WordPress. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Remind users of the plug-ins needed for the current theme

Many topics need to be supported by plug-ins, so you need to remind users of plug-ins that need to be installed. This article will teach you how to remind users of plug-ins to install in a conspicuous position in the background.

The final result is similar to the following figure:

Just use the admin_notices hook, output an alert box under the background title, and then use the is_plugin_active () function to determine whether the plug-in is enabled or not.

/ * WordPress reminds users of the plug-ins needed for the current theme * http://www.endskin.com/plugins-messages/*/function Bing_plugins_messages () {$plugin_messages = array (); include_once (ABSPATH. 'wp-admin/includes/plugin.php'); / / must install the WordPress SEO plug-in if (! is_plugin_active (' wordpress-seo/-seo.php')) $plugin_messages [] = 'the current theme requires that the WordPress SEO plug-in must be installed and enabled, click to download this plug-in' / / must install the Simple URLs plug-in if (! is_plugin_active ('simple-urls/plugin.php')) $plugin_messages [] =' the current theme requires that the Simple URLs plug-in must be installed and enabled. Click to download this plug-in' / / Bing Phone plug-in if (! is_plugin_active ('Bing-Phone/Bing-Phone.php')) $plugin_messages [] =' the current theme requires that the Bing-Phone plug-in must be installed and enabled, click to download this plug-in'; if (count ($plugin_messages) > 0) {echo'; foreach ($plugin_messages as $message) echo'

'. $message. '

'; echo';}} add_action ('admin_notices',' Bing_plugins_messages')

Hide some plug-ins in the plug-in list

When developing a WordPress website for customers, they are usually given an administrator account, so the customer is fully capable of modifying the theme, plug-ins, users, and some key settings of the site.

However, sometimes users will accidentally do something wrong, such as disabling the necessary plug-ins. In this case, we can hide some plug-ins in the plug-in list, when in fact the plug-ins are running normally.

The following code hides the WP Crontrol and User Switching plug-ins in the plug-in list. You can still see the plug-ins when the plug-ins are disabled, and only when the plug-ins are enabled will the plug-ins be hidden from the list.

/ * WordPress hides some plug-ins in the plug-in list * http://www.endskin.com/hide-plugins/*/function Bing_hide_plugins ($plugins) {/ / hide WP Crontrol plug-ins $plugin = 'wp-crontrol/wp-crontrol.php'; if (is_plugin_active ($plugin)) unset ($plugins [$plugin]); / / hide User Switching plug-ins $plugin =' user-switching/user-switching.php' If (is_plugin_active ($plugin)) unset ($plugins [$plugin]); return $plugins;} add_filter ('all_plugins',' Bing_hide_plugins'); Thank you for reading! This is the end of this article on "how to remind to install plug-ins and hide plug-ins in WordPress". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Plug-ins theme user customer time function content background more article website good practical conspicuous following figure two code location key function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology OPPO Reno vpn MariaDB