📜 ⬆️ ⬇️

Automate CleanTalk Anti-Spam Updates for WordPress

If you serve a couple of sites, then updating the plugins does not cause any difficulties. Difficulties arise if you serve dozens or even hundreds of sites.

CleanTalk Antispam requires frequent updates (we have to release a new version every 1-2 weeks), there are many reasons for this.

WordPress, as a designer, has a huge variety of plugins, themes, widgets, etc. which are not always designed with WordPress Codex into account, have different architecture and event handling. Therefore, CleanTalk integration errors may occur with different components, especially rare ones.

Each complex service that uses a large amount of data, a change in the backend, changes in logic and a lot of other things require changes in the plugin.
')
With our update frequency for the plugin, the auto-update option is required. If this option is done in the plugin settings, then still the user will need to go to each site in the plugin settings and install it. But what to do in a situation when the user does not want to enable auto-update, and you need to update the plugin immediately on hundreds of sites?

For the convenience of managing the service, the auto-update option was implemented in the Service Control Panel.

Auto-update allows you to update the plugin one-time on one site, group of sites, or enable auto-update on all sites.

How it works


Historically, we control the version of the plug-in used by the client, and when contacting clients and analyzing feedback, we need to know the version of the plug-in used. Each anti-spam plugin, with each request, sends its version in the parameters. The version number is compared with the number in the repository, and if the versions are different, then in the Control Panel we show a warning about the need for updating.

image

Further, when clicking on a link, a modal window opens with options for updates.

image

When selecting the option, the server makes a special request to the plugin on the client's site.

The plug-in, having received the call, checks the call parameters for authenticity and starts work. Auto-update is implemented through a modified class of auto-update plug-ins Wordpress. After completion of the class, the plugin checks the version of the updated files and makes a request for the site (on itself). If the HTTP response code is 200, then it reports to the server by displaying “OK” on the page and makes a special API call, reporting on the new version. If the response code is different from 200, then the plugin rolls back files to the previous version and responds to the north with a line with an error code and technical parameters.

After a successful update, the status in the Service Control Panel changes to “App has been updated”.

Source: https://habr.com/ru/post/350294/


All Articles