A shell wrapper that can help you upgrade the entire wordpress site and its supporting components.

Tool installation

  • Downloading the Phar file is our recommended installation method.
  • Check your environment meets the minimum requirements
    1. UNIX-like environment; limited support in Windows environment
    2. PHP 5.3.29 or later
    3. WordPress 3.7 or later
  • Once verified, download the wp-cli.phar file using curl or wget.
#> curl -s -X GET https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/bin/wp
#> chmod +x  /usr/bin/wp

Create the wrapper script

Create a file name “wordpress.sh” with following code pasted

#!/bin/bash

status() {
    echo "Core Version Check"
    /usr/bin/wp core version --allow-root

    echo "Theme status check"
    /usr/bin/wp theme status --allow-root

    echo "Plugin Version Check"
    /usr/bin/wp plugin status --allow-root
}

update() {
    echo "Core Version Check"
    /usr/bin/wp core update --allow-root

    echo "Theme status check"
    /usr/bin/wp theme update --all --allow-root

    echo "Plugin Version Check"
    /usr/bin/wp plugin update --all --allow-root
}

# See how we were called.
case "$1" in
  status)
        status
        ;;
  update)
        update
        ;;
  *)
        echo $"Usage: $0 {status|update}"
        exit 2
esac

Script execution

  1. Switch to the wordpress <root> directory
  2. Execute your script with relative path ( Eg:- bash /tmp/wordpress.sh )
Core Version Check
Updating to version 4.7 (en_US)...
Downloading update from https://downloads.wordpress.org/release/wordpress-4.7-new-bundled.zip...
Unpacking the update...
Cleaning up files...
No files found that need cleaned up.
Success: WordPress updated successfully.
Theme status check
Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/theme/astrid.1.13.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
Downloading update from https://downloads.wordpress.org/theme/twentyfifteen.1.7.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
Downloading update from https://downloads.wordpress.org/theme/twentyfourteen.1.9.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
Disabling Maintenance mode...
Success: Updated 3/3 themes.
+----------------+-------------+-------------+---------+
| name           | old_version | new_version | status  |
+----------------+-------------+-------------+---------+
| astrid         | 1.11        | 1.13        | Updated |
| twentyfifteen  | 1.6         | 1.7         | Updated |
| twentyfourteen | 1.8         | 1.9         | Updated |
+----------------+-------------+-------------+---------+
Plugin Version Check
Enabling Maintenance mode...
Downloading update from https://downloads.wordpress.org/plugin/contact-form-7.4.6.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Downloading update from https://downloads.wordpress.org/plugin/woocommerce.2.6.11.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Downloading update from https://downloads.wordpress.org/plugin/wp-mail-smtp.0.10.1.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the plugin...
Plugin updated successfully.
Disabling Maintenance mode...
Success: Updated 3/3 plugins.
+----------------+-------------+-------------+---------+
| name           | old_version | new_version | status  |
+----------------+-------------+-------------+---------+
| contact-form-7 | 4.5.1       | 4.6         | Updated |
| woocommerce    | 2.6.8       | 2.6.11      | Updated |
| wp-mail-smtp   | 0.9.5       | 0.10.1      | Updated |
+----------------+-------------+-------------+---------+