Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report