WP administration

by Gisle Hannemyr

This chapter discusses some of the interfaces and tools you may use in the day to day administration of a WordPress website.

Table of contents

WordPress plugins discussed in this chapter: None.

Introduction

[TBA]

Automatic updates

Automatic updates is supposed to be enabled by default.

define( 'WP_AUTO_UPDATE_CORE', true );

Check core version

When logged in as an administrator, press the WordPress logo in the top left corner to see the current version. The number next to round arrow icon indicates the number of pending updates. Click the icon to see details. It will also report uninstalled plugins and themes.

wp-version.png
Press WordPress-logo to see current version..

Check the Releases-page @ WordPress.org to see the most recent release (curently 6.1.1). The Support policy states that security updates will be backported when possible, but there are no guarantee and no timeframe for older releases.

See below for update instructions.

Site health check

[TBA]

Configuration files

The main configuration file is wp-config.php. It is located in the siteroot.

This file contains information about the database, including the name, host, database username, and password. This information allows WordPress to communicate with the database to store and retrieve data (e.g. Posts, Users, Settings, etc).

The file is also used to define advanced options that the use may configure by editing the file in the CLI.

The file wp-config.php does not come in the default download package. Instead, it contains a file called wp-config-sample.php which is copied and using as starting point for the wp-config.php during the GUI installation process.

It also requires a file named wp-settings.php.

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

The file wp-settings.php is used to set up and fix common variables and include the WordPress procedural and class library. It is not usual for end users to edit this file.

Dashboard

If there is no login on the front page, try these:

https://example.com/admin
https://example.com/login
https://example.com/wp-login.php

If you have to resort to the last one, URL rewriting is not working.

The WordPress Dashboard, often called “WP admin” or “WP admin panel”, is essentially the control panel for your entire website. This is where you create and manage content, change settings, etc.

Manage Content:

Manage extensions:

Other functions:

Manage users

User data is kept in two tables {wp_users} and {wp_usermeta}. The latter uses a key to identify some optional user metadata. The user initial login name is stored in two field: {wp_users.user_login} and {wp_users.user_nicename}. Field user_nicename is the sanitized version of user_login, and should be kept in sync. Neither can be changed from the GUI.

There is also a nickname that can be set from the GUI. The display name is also set from the GUI and can either be the username or the nickname. It can be used to avoid displaying the real username of the admin user.

To change the username edit {wp_users.user_login} and {wp_users.user_nicename} directly in the database, using phpMyAdmin.

See alsowpbeginner.com: Change username.

The command line

WordPress comes with a program to manage WordPress through the command-line. See Install CLI program for notes about installing it.

For commands that interact with the site, you need to be in or below the webroot. This is the directory where wp-config.php is located.

If it is installed as described on the linked page, this command will output a manpage for the command.

$ cd /var/www/example.net/web
$ wp

To flush the cache, do this in or below the webroot (the directory containing wp-config.php):

$ wp cache flush
Success: The cache was flushed.

If you're not in or below the webroot, you get this response:

$ wp cache flush
Error: This does not seem to be a WordPress installation.
Pass --path=`path/to/wordpress` or run `wp core download`.

To see the user list and set new password for the admin:

$ wp user list
…
$ wp user update 1 --user_pass=cleartext

To run all cron events due right now:

$ wp cron event run --due-now
Success: Executed a total of 2 cron events.

To inspect scheduled cron runs and when they will run next:

$ wp cron event list
+------------------------------------+---------------------+-----------------------+------------+
| hook                               | next_run_gmt        | next_run_relative     | recurrence |
+------------------------------------+---------------------+-----------------------+------------+
| wp_privacy_delete_old_export_files | 2020-10-26 09:55:36 | 33 minutes 59 seconds | 1 hour     |
| wp_version_check                   | 2020-10-26 11:53:36 | 2 hours 31 minutes    | 12 hours   |
| wp_scheduled_delete                | 2020-10-26 11:58:35 | 2 hours 36 minutes    | 1 day      |
| wp_update_plugins                  | 2020-10-26 12:36:38 | 3 hours 15 minutes    | 12 hours   |
| wp_update_themes                   | 2020-10-26 12:36:38 | 3 hours 15 minutes    | 12 hours   |
| delete_expired_transients          | 2020-10-26 13:14:14 | 3 hours 52 minutes    | 1 day      |
| wp_scheduled_auto_draft_delete     | 2020-10-26 15:50:56 | 6 hours 29 minutes    | 1 day      |
| bvdailyping_daily_event            | 2020-10-26 20:09:43 | 10 hours 48 minutes   | 1 day      |
| wp_slimstat_purge                  | 2020-10-27 02:00:00 | 16 hours 38 minutes   | 1 day      |
| recovery_mode_clean_expired_keys   | 2020-10-27 08:42:24 | 23 hours 20 minutes   | 1 day      |
| wp_site_health_scheduled_check     | 2020-10-29 18:51:14 | 3 days 9 hours        | 1 week     |
+------------------------------------+---------------------+-----------------------+------------+

See alsoKinsta.com: Managing WordPress From the Terminal.

Updating WordPress

All wordpress sites should be set up to automatic update the core and to allow CLI update of the plugins. Permissions for all directories and files should be set to:

rwxrwxr-x 1 gisle www-data 123456 Jul 21 02:50 directory
rw-rw-r-- 1 gisle www-data 123456 Jul 21 02:50 file.php

Use this command to set correct ownership:

$ sudo chown -R gisle.www-data wp-content/

To inspect the core version:

$ wp core version
6.1.1

To update to the latest version of the core and the database cd to the webroot and request a core update and then an update of the database:

$ cd /var/www/example.net/web
$ wp core check-update
…
$ wp core update
Updating to version 6.1.1 (en_US)...
…
Unpacking the update...
Cleaning up files...
No files found that need cleaning up.
Success: WordPress updated successfully.
$ wp core update-db

tipIf you get permission problems during updates, make sure that the directory wp-content/upgrade is writable by your user (CLI) and the web server group.

To update all plugins, themes and translations:

$ wp plugin update --all
…
$ wp language plugin update --all
…
$ wp theme update --all
…
$ wp language theme update --all

You may also update WordPress from the GUI. [Add screenshot].

Backup and migrate

To backup, navigate to the webroot (the folder containing wp-config.php) and use this command:

$ wp db export
Success: Exported to 'wp_semicolon-2021-05-28-d2d75df.sql'.

This will use all the defaults for exporting the database as a backup. This means it will be in the current folder and will have the same name as the database, with a timestamp appended.

To restore, navigate to the webroot and use this command:

$ cd /var/www/example.com/web
$ wp db import /var/private/examplecom/my_wordpress_db.sql

noteWordPress embeds the site URL in the database. To fix this, see the chapter chapter about Migrating from WP engine. In addition, there may be absolute links embedded in the site, the simplest way to fix this is described in the chapter about Migrating from WP engine. HTTP Strict Transport Security (HSTS) may also cause redirects. To clear HSTS-settings, see the chapter about TLS.

Sources: LiquidWeb.com: Backup, LiquidWeb.com: Restore, WordPress.org: Backing Up Your Database, One.com: Move your WordPress site to another domain.

Managing plugins

Plugins are discussed in the chapter: Plugins,

Managing themes

To get the machine and status of themes:

$ wp theme list
+-----------------+----------+-----------+---------+
| name            | status   | update    | version |
+-----------------+----------+-----------+---------+
| twentynineteen  | inactive | available | 1.8     |
| twentyseventeen | inactive | none      | 2.5     |
| twentytwenty    | active   | none      | 1.6     |
+-----------------+----------+-----------+---------+

To update a single theme:

$ wp theme update twentyseventeen
Downloading update from https://downloads.wordpress.org/theme/twentyseventeen.2.7.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the theme...
Theme updated successfully.
Success: Updated 1 of 1 themes.
+-----------------+-------------+-------------+---------+
| name            | old_version | new_version | status  |
+-----------------+-------------+-------------+---------+
| twentyseventeen | 2.2         | 2.7         | Updated |
+-----------------+-------------+-------------+---------+

It is safe to delete inactive themes. Source WordPress.org: Can-I delete-all-inactive-themes.

tipNew themes sometimes ships with new version of the core. Even if inactive, the will require updating. To stop being bugged by this, delete them.

To delete a theme:

$ wp theme delete twentytwenythree
Deleted 'twentytwenythree' theme.
Success: Deleted 1 of 1 themes.

Final word

[TBA]


Last update: 2020-05-07 [gh].