Skip to content

Updating WordPress plugins and templates with script and SSH

Updating WordPress plugins and themes using an FTP zip unzip script is one of the fastest and most convenient methods to update multiple plugins or themes at once with one click. For the method to work, our hosting must have SSH access (standard for normal hosting). If it is not available, we recommend changing it to the one we use hosting. The description will be for Windows configuration, you can also achieve the same effect on other systems. Configuration involves simple editing of 2 files at one time.

  1. We must configure the free FileZilla program in such a way that after logging in to FTP it automatically goes to the directory with plugins or templates of our WordPress installation. If we have several pages, it is worth creating a separate login for each page in this way. You can read how to do it here tutorial in "Specifying the Default Directory After FTP Login". Depending on the needs, we create logging of plugins, templates, or both separately.
  2. We make sure that SSH on the hosting is turned on and has an assigned login and password. In case of problems, the technical support of our hosting will be helpful.
  3. You will need the free Putty program for an SSH connection. This is a client that allows you to log in to an SSH terminal. The description of installing this program can be found here here.
  4. Now we will also need an update script. We download it here.
  • The folder with the script can be placed anywhere on the disk.
  • If we rename a folder, it cannot have spaces in its name.
  • All files in the folder must remain unchanged in the same place in the folder.
  • The folder with the script must be separate for updating plugins and templates (different configuration). If we need it for both of these things for one page, we make a copy of the script folder along with the contents. Similarly, each subsequent website (domain) must have its own directory for updating plugins and templates for the same reason.

5. First open the file using a notepad or other text program script-unzip.sh We are only interested in the line:

cd PAGE-DIRECTORY / public_html / wp-content / plugins

This command goes to the appropriate folder on SSH after running the script. It works the same way as in FileZilla, moving to the set remote login directory. The address should be identical to that in the FileZilla program, assuming that our SSH login takes us to the same directory as the FTP login after logging in. If we use the main FTP and SSH login for hosting, it will take us to the same place, to the main root directory. The easiest way to check this is to log into SSH using Putty and type the command ls . After approval, you should see a list of the main directories of our sites. In the case of FTP, after logging in, you should see the same in the right window of the program.

In this file we only change "CATALOG-PAGES" to the name of our website's directory (where it is installed on the hosting). In the case of our store and plug-in configuration it will be allkeystore.pl and the configuration will look like this:

Aktualizacja wtyczek i szablonów WordPress za pomocą skryptu i SSH | Sklep z dodatkami premium WP Allkeystore.pl
Configuration for plugin updates. In the case of templates, only the URL ending changes from "plugins" to "themes"

It is also best to check on FTP that the public_html directory is definitely present. In the case of some hosting services, it is not present, and the public content of the website is located directly in the website directory (usually with the domain name). If it's not there, we only remove "public_html" from the URL, making sure there is no double "//".

The above configuration is for plugin updates. In the case of templates it looks the same, we only change the "plugins" at the end to "themes". Of course, this should be done in a separate copy of this template update folder.

We can also modify this code in such a way that after unpacking all zip files with overwriting files, the script leaves the "plugins" directory, goes to the "themes" directory and performs the operation again. The code will look like this.

Aktualizacja wtyczek i szablonów WordPress za pomocą skryptu i SSH | Sklep z dodatkami premium WP Allkeystore.pl
The script above will update both plugins and templates simultaneously for a given page.

Please note that in a situation where we do not have any zip files in the plugins or templates directory, an error will appear. It is not verified in this script so as not to complicate it, however, do not worry about it in such a situation. Of course, you can extend this script further to update all our pages, etc.

6. After editing, script-unzip.sh and saving changes we edit start.bat in the notebook. This is a Windows executable that will run the PLINK utility that comes with Putty, which in turn will run the script we just edited. In this file, we only change "YOUR-LOGIN-SSH" to our SSH login and "YOUR-PASSWORD-SSH" to the SSH password.

Be careful that all spaces are kept exactly as they are in the original file. We save the changes.

7. At this point, our script is ready. The last thing is to create a shortcut to the start.bat file. We can name this shortcut anything we want, e.g. "UPDATE PLUGINS MYSTRONA.PL" and move it anywhere so that it is convenient for us to run it. If we have several pages and we create several shortcuts, it is worth moving them all to one folder for convenient use.

8. If we haven't migrated the plugins or templates zip files to update yet, we're moving them now. The description of how to do this is here .

IMPORTANT DIFFERENCES AND CHANGES AS THE DESCRIPTION ABOVE:

  • This description is about updating plugins and templates via FTP, and we only want to move the zip files to the right places. We do not transfer unpacked directories with plugins or templates to the "plugins" and "themes" directories on FTP as described in this article, but zipped zip archives with plugins and templates from us, in exactly the same way.
  • We need to make sure that we are copying the zip files of plugins and templates that are suitable for installation. Sometimes developers pack plugins and templates together with documentation, demos, etc., and the plugin or template is just one of the zip files. If we unpack something like that on FTP, the update will fail and we will have to manually delete all incorrectly unpacked files. There is no such problem if we update plugins and templates downloaded from us. If the plugin or template from us is packed with something, such a file always has "UnpackMe" in its name. It is then necessary to unpack it, and transfer the correct zip files of plugins and templates. It is best to click on them and check the contents. If there is only one directory in the zip archive with the name plugin / template or similar, this is the zip file for update / installation. If we are not sure, we can try to install this file through the WP panel. If the error "No properly prepared plugins (or templates) found" appears, it means that this is not the right file. There may also be a "__MACOS" directory for Mac OS systems, but our script deletes it automatically.

9. We run the script by clicking on the shortcut. A black console window will appear where the commands will be executed, then the window will disappear and the log.txt text file will be opened automatically to which the warnings and errors have been moved from the console. If everything is successful, you should see the message "X archives were successfully processed"

10. Check in the WP admin panel whether plugins / templates have changed versions.

If we have several pages, we can also create a .bat file that will run all our bat files at once. This allows us to update all plugins and templates on multiple sites with one click.

FINAL ADVICE:

When moving zip files by dragging them to FileZilla, be careful not to move these zip files to the directory of any installed plugin and template. The best way to solve this problem is to create, for example, 3 files named 'aaa', 'bbb', 'ccc' without any extension, and move them to the plugin or template directory of our site. Then, when sorting by name in FileZilla, click on "Filename" and our 3 files will always be at the top when sorting. We drag our zip files onto these 3 files. Then they will always be moved correctly to the main directory of files and templates.

Aktualizacja wtyczek i szablonów WordPress za pomocą skryptu i SSH | Sklep z dodatkami premium WP Allkeystore.pl
Files for easy transfer of zip files

Check out the offer of 1500+ Premium WordPress plugins and themes!