In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to create, disable and delete plug-ins for WordPress plug-in development, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Plug-in storage directory
Wp-content/plugins
Create a plug-in
Create a file plug-in folder in plugins, preferably with a prefix, which can use your name or your own domain name to prevent the plug-in from repeating its name with someone else, and create a PHP file with the same name as your plug-in.
I create a plug-in called yg-footer-copyright here.
Let WordPress recognize our plug-in
After creating the plug-in, the WordPress backend did not recognize our plug-in because we did not write the plug-in information according to his standard.
Write the plug-in information in the header of your plug-in entry yg-footer-copyright.php file.
At this point, go to the WordPress background and you can see the plug-in you created.
Call the method when the plug-in is enabled
Through the register_activation_hook method, you can add callbacks when the plug-in is enabled.
Official document: https://codex.wordpress.org/F...
Function ygcopyright_install () {update_option ("yg-copyright", "
Copyright information
");} / / the method register_activation_hook (_ _ FILE__, 'ygcopyright_install') called when the plug-in is enabled
Here we add a yg-copyright field to the option table at startup.
Call the method when the plug-in is deactivated
The register_deactivation_hook method allows you to add callbacks when the plug-in is deactivated.
Official document: https://codex.wordpress.org/F...
Function ygcopyright_stop () {update_option ("yg-copyright", "yes");} / / method register_deactivation_hook (_ _ FILE__, 'ygcopyright_stop') when the plug-in is deactivated
Here we change the yg-copyright field in the option table to yes when deactivating.
Operation when plug-in is deleted
When the plug-in is deleted, the default is to find the uninstall.php file in the plug-in directory and call the method inside.
Here we'd better add to the uninstall.php file header to determine whether it is called by the WordPress background to prevent others from directly calling the file and delete the plug-in.
Here we delete the yg-copyright field from the option table when it is deactivated.
Thank you for reading this article carefully. I hope the article "how to create, disable and delete plug-ins for WordPress plug-in development" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.