Month: July 2017

WordPress CLI

WordPress CLI

WordPress CLI

    As a person who is more comfortable in a terminal environment than GUI, I love finding tools that make my life easier and more comfortable. When I started using WordPress I was often aggravated by the fact that I had to move around an interface rather than just typing up some html or a command to get a task done. Obviously, that method works well for small scale projects but less so when one is managing a lot of content and pages. WordPress just makes life easier in that respect. But I still like having lower level access and this is where WordPress CLI comes in. WordPress CLI is a command line interface for managing WordPress sites. Things like updating the core, plugins, or themes is made faster since I SSH often into my site’s box and can type up some commands quickly to do those tasks and much more. As such, I wanted to make a simple collection of commands that everyone will find useful. But first, we need to install the plugin….

Installing WordPress CLI

    As per the sites instructions, it is extremely easy to get up and running. All one simply needs to do is download the file, chmod it, and move it to the proper location.
To download:
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
OR
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Next, let us make it runnable. Simply type:
chmod +x wp-cli.phar
Let’s make sure the file is working properly.
php wp-cli.phar --info
From there, we are ready to move it to its new home. Simply type:
*Note: You might need to use sudo depending on your level of access to the server.
mv wp-cli.phar /usr/local/bin/wp

Using WordPress CLI

    OK, now that WordPress CLI is installed we are set to use it. The first thing to do though is cd to the WordPress directory. This is usually somewhere in /var.
Once there, it’s time to play with some of the commands. First things first, one should know what plugins and themes are installed. To do that, simply type:
wp plugin list && wp theme list
This will list all the slugs associated with the plugins themes. One needs them in order to do things like disable, remove, and install them.
Now, let us say that we got from the above commands:

Plugins:
+--------------------------------+----------+--------+---------+
| name                           | status   | update | version |
+--------------------------------+----------+--------+---------+
| add-from-server                | active   | none   | 3.3.3   |
| akismet                        | active   | none   | 3.3.3   |
| backup                         | inactive | none   | 1.1.46  |
| maintenance-mode-free          | active   | none   | 1.2     |
+--------------------------------+----------+--------+---------+

Themes
+-----------------+----------+--------+---------+
| name            | status   | update | version |
+-----------------+----------+--------+---------+
| twentyfifteen   | active   | none   | 1.8     |
| twentyseventeen | inactive | none   | 1.3     |
| twentysixteen   | inactive | none   | 1.3     |
+-----------------+----------+--------+---------+

We notice that Akismet is installed and know too that we are transitioning to use a different plugin to handle spam fighting. To uninstall it we do the following:
wp plugin deactivate akismet && wp plugin delete akismet
If we want it back, we can do the following:
wp plugin install akismet && wp plugin activate akismet
Now, we should update or at least check to see if there is an update needed.
wp plugin update akismet
The same principles are used with themes as well. Replace akismet with the theme name from the list and you get the same results but for themes. The only differences are that instead of plugin we use theme in the command and to disable a theme one needs to use the term disable rather than deactivate. Like so:
wp theme disable twentyfifteen

Final Thoughts

    As a final thought or two, it is worth noting how to find the slug for a plugin or theme. To do that, go to either https://wordpress.org/plugins/ or https://wordpress.org/themes/. From there, after finding something worth while, look at the end of the url to find what we need. For this example, use the plugin bbpress and look at the end of its URL: https://wordpress.org/plugins/bbpress/. Supplant that information like so:
wp plugin install bbpress && wp plugin activate bbpress
This will then install the plugin and activate it.
    Welp, this covers the basics and gets one started but there are other commands that are available. Simply go to their site to find them. Now that we have an new awesome tool to play with, click the image below to look at quick servers one can setup for WordPress.


https://www.itdominator.com/quick-test-server/

servers with a blue tinted globe

Code.gov

Code.gov

Picture of code dot gov slogan
Code.gov

    I just wanted to make a shout out to Code.gov and the work they do. If one isn’t sure of who or what they are they are the US government’s team working to opensource the code used by the government’s agencies. This post comes on the heals of an email I received from their mailing list which reminded me of their transition to open source their code. I can’t think of any better way to express democracy than through opening up a sizable chunk of ones code base.

Here are 5 projects to keep an eye on


5 — Consumer Financial Protection Bureau’s Owning a Home Project

    Hey, getting a home isn’t always easy but it can be with these tools provided by Consumer Financial Protection Bureau and its Owning a Home project. Everything is looked at from loan options, terminology, and costs.

Link: https://github.com/cfpb/owning-a-home

4 — National Archives and Records Administration’s File Analyzer Project

    So, this project came to my attention because I am programming a CSV file viewer. I’m considering other functions for my application and this file analyzer just might be the thing to give it a cool boost. It says that each file test generates a table of results and that is useful given my CSV viewer dumps a csv file into a GUI table view.

Link: https://github.com/usnationalarchives/File-Analyzer

3 — Department of Agriculture’s RIBD Project

    Ahh leisure…. Who doesn’t want to enjoy time off at beautiful federal lands, historic sites, museums, and/or other attractions?
According to their site, the “Recreation Information Database (RIDB) provides data resources to citizens, offering a single point of access to information about recreational opportunities nationwide.”

Link: https://usda.github.io/RIDB/

2 — NSA’s Unfetter Project

    When not spying on us and the world, the NSA is helping us secure our data by giving tools that analyze gaps in our security posture.

Link: https://iadgov.github.io/unfetter/

1 — NASA’s 3D Resources

    I am a big fan of space and even bigger fan of making beautiful Blender renders. NASA’s 3D model collection is huge and gives great assets to space fans and art lovers alike to play with.

Link: https://github.com/nasa/NASA-3D-Resources