The problem

Although we have not yet been able to find the exact cause, we have two customers to whom a more than strange thing happens, which is that they have a plugin, different in both installations, that deactivates when it updates. That is a minor problem in an unimportant plugin, but in a plugin that synchronises WooCommerce orders with an ERP, or a payment method, it is more than a problem that it deactivates and does not reactivate by itself, as should happen naturally, by the way.

In spite of the fact that we have reviewed everything that can be reviewed and that one of the plugins is of the creation of APG, WC – Cetelem payment gateway, so we have its code more than under control and we know that it does not cause any kind of problem in hundreds of other installations, we have not managed to find the cause that makes these two plugins in particular, and no other of those that make up both websites, not reactivate automatically.

The solution

To solve it we have had to create custom code that takes care of automatically reactivating the plugin that we have monitored.

If you come across the same problem you only have to add this small PHP script in the functions.php file of your child theme:

Copy to clipboard

Where you will have to customise the path of the plugin, indicating the one you need to monitor, for example the path of WooCommerce is woocommerce/woocommerce.php, and the name of the plugin that will be shown in the on-screen messages.

But what if the plugin folder changes its name every time it updates?

Here you have a problem, since you cannot monitor it with the PHP code proposed above, and this particular situation is the one that occurs with our plugin WC – Cetelem payment gateway, where the installed version is added after the name of the folder

To solve it we have had to create this other PHP code:

Copy to clipboard

Where the name of the folder in which the plugin is installed is searched for in the plugins directory, starting from the fixed part of its name, so as to be able to reactivate it again whatever the folder is called.

Now then, we do not recommend using this code just as we show it, since it is going to slow down the execution of the WordPress administration panel and the ADMIN-AJAX, but rather we recommend running it every five minutes by adding it to a scheduled event, assuming that you have the WP-CRON under control and you run it every five minutes; if not, you are already late in doing so.

Therefore the best way to use it is like this:

Copy to clipboard

This way you make sure that the plugin will not stay deactivated beyond five minutes and that the performance of your WordPress does not suffer.

You can also use code very similar to the previous one to make sure that your most fundamental plugins do not stay deactivated beyond 5 minutes by adding an array with the list of plugins you want to check, but we leave that to your ingenuity and creativity; as you can see, the possibilities for control over plugins that open up are multiple.

We hope you find this code useful and, as always, we look forward to your comments.

Related posts

Comments

Suscríbete
Notificar de
0 Comments
Más antiguos
Más recientes Más votados

In this post

Products and services

Latest posts

Latest comments

Subscribe!

Lista de correos de APG

DATA PROTECTION: In accordance with data protection regulations, we provide you with the following processing information: (+)

  • Responsible: Art Project Group.
  • Treatment purposes: to respond to queries or any type of request made by the user through any of the forms of contact that are made available on the website. Sending communications about products or services (with your consent).
  • Your rights: access, rectification, portability, deletion, limitation and opposition. More information about the treatment in the Privacy Policy.

What we post on !

Se ha publicado #WooCommerce 11.2.2: actualización de seguridad que refuerza las API REST y Store, mejora la validación de CSV y corrige problemas en pagos y pedidos. Incluye cambios en la base de datos.

¡Actualiza cuanto antes!

November 5, 2026