Site icon Wil Selby

WordPress & Heroku – Updating Website Content, Themes & Plugins

This post follows the post Heroku & WordPress Website Deployment which details how to create and publish a website using WordPress and Heroku. This post details how to update your content, plugins, and themes due to Heroku’s unique file system.

Updating Content, Plugins & Themes

Heroku doesn’t allow for files to be stored permanently on the dyno’s filesystem.This is a problem if we want to include files such as images on the website. The easiest solution is to use a cloud based sotrage service like Amazon AWS to store the files for you. There are multiple plugins that connect your WordPress dashboard to your Amazon AWS accounts. I prefer to just manually upload my files to AWS Simple Storage Service (S3) myself and insert the image from the URL provided by Amazon for that file.

Since Heroku doesn’t allow files to be written and stored on their file system, we have to update and install plugins, themes, and new versions of WordPress locally and then push them to Heroku. Composer is used to provider version control of installed plugins, themes, and the WordPress version. The download and installation instructions for Composer are available here.

To install a theme, first identify the download link where the theme is available. You can search for your plugin or theme on WordPress Packagist at WordPress.org. The link for the decode link is replicated below as an example:

https://downloads.wordpress.org/theme/decode.3.15.2.zip

The syntax for the composer command is below and requires the parsing of the end of the download string to identify the theme name and current version. See the Composer docs for details on variations of this syntax.

$ composer require wpackagist-theme/theme:^version --ignore-platform-reqs

The final command would then be:

$ composer require wpackagist-theme/decode:^3.15.1 --ignore-platform-reqs

Plugins are similar. The download link for the PDF Embedder plugin is

https://downloads.wordpress.org/plugin/pdf-embedder.2.7.5.zip

the Composer syntax is

$ composer require wpackagist-plugin/plugin:^version --ignore-platform-reqs

The final command would then be:

$ composer require wpackagist-plugin/pdf-embedder:^2.7.5 --ignore-platform-reqs

These commands download the files and update the composer.json and composer.lock file. You can view the composer.json file to view the list of themes, plugins, and the WordPress version currently installed.

To finalize the installation, you need to push the new source code to the Heroku repository. Use the code below

$ git add composer.json composer.lock
$ git commit -m "Updated plugin/theme xxx"
$ git push heroku production:master
Updating WordPress

To update WordPress, you can follow the git based method to merge updates from the master branch into the branch you created for installation. Optionally, you can modify the composer.json file. Specifically, update the “version” and “url” fields to reflect the version you want to upgrade to. The relevant code from the composer.json file is shown below for reference.

       {
            "type": "package",
            "package": {
                "name": "WordPress/WordPress",
                "version": "4.6.1",
                "dist": {
                    "type": "zip",
                    "url": "https://github.com/WordPress/WordPress/archive/4.6.1.zip"
		}
            }
        },

After those fields are updated and saved, run the following command to update the file system.

$ composer update --ignore-platform-reqs

After you update WordPress, WordPress needs to update the database. After installing through Composer and pushing the new code through git to Heroku, navigate to:

http://your-app-url.herokuapp.com/wp-admin

WordPress will prompt for updating the database to finalize the upgrade.

See the following posts for more information about securing and customizing your website:

 

Exit mobile version