Skip to content

1.3 Convert a standalone install to the WordPress plugin

Greg Ross edited this page Jan 19, 2016 · 11 revisions

Converting from the standalone GlotPress to the WordPress Plugin

Much of the code is shared between the standalone and plugin versions of GlotPress, however there are some differences that make converting between them a manual process.

The basic steps are:

  1. MAKE A BACKUP
  2. Read this entire document at least once
  3. Install WordPress 4.4 or newer
  4. Install the plugin, don't activate it
  5. Update table names (see "Table Names" below for more detail)
  6. Convert your user table if required (see "User Table and Permissions" below for more detail)
  7. Optionally set your base path (see "GlotPress Base Path" below for more detail)
  8. Activate the plugin

Some important items include:

  • Table Names
  • Unused Tables
  • User Table and Permissions
  • Breaking Changes
  • Plugins
  • Configuration Directives
  • GlotPress Base Path
  • Permalinks
  • Templates

Each of the above will be addressed in the following sections.

Table Names

The standalone code uses "gp_" as a prefix for table names in GlotPress. To work better with WordPress and support multi-site, the plugin adopts the WordPress prefix in addition to the "gp_" format.

This means a table from the standalone code, like originals, will be named "gp_originals" but in the plugin will be named "wp_gp_originals" (assuming you haven't changed the WordPress prefix of course).

You have two options to move your standalone code to the plugin:

  1. Rename your tables and add the WordPress prefix on them.
  2. Change the $gp_table_prefix by adding it to the wp-config.php file.

The safest (aka most future proof) way is option 1.

However you can add the following lines to your wp-config.php file (near the end, before the /* That's all, stop editing! Happy blogging. */ line of course):

GLOBAL $gp_table_prefix; $gp_table_prefix = 'gp_';

Note you can set the value to anything you like.

WARNING Do not edit the gp-settings.php file and change this value or it will be overwritten each time you upgrade the plugin.

Unused Tables

There are a few tables in the standalone version that are no longer used in the plugin, these are (using the default gp_ prefix):

  • gp_users
  • gp_api_keys

User Table and Permissions

The standalone user table has been replaced by the WordPress user table. If you were using the standalone user table this will be the hardest part of migrating to the plugin.

If you have already been using the WordPress user table, then you don't need to do anything.

You already have users in WordPress

If you already have users in WordPress, you'll going to have to make a choice of either matching the user id's of WordPress with your old GlotPress table or starting from scratch and re-applying your user permissions.

Either way the first step is to generate a report of your current permissions to work from, you can use the following SQL statement to do so:

SELECT * FROM gp_permissions INNER JOIN gp_users ON gp_permissions.user_id=gp_users.id;

If your feeling adventurous you could use the same basic process to join the above on your WordPress users table as well using a unique key from the gp_users table and then generate a file you could import back in to the permissions table.

Your WordPress users table is empty

This is slightly easier, you can basically export the gp_users table and re-import it the WordPress users table. You do need to be careful you don't re-import your admin user.

Breaking changes

The plugin has several low level API changes to use WordPress instead of BackPress, if you have any custom code (like plugins of theme changes) you may need to update them.

You can find a complete list of breaking changes on the GlotPress Wiki.

Many of these changes are very low level so be careful to understand what they mean.

Plugins

One of the biggest breaking changes from above, is the removal/rewrite of the old GlotPress plugin system. Plugins are now just WordPress plugins that can be submitted to the WordPress plugin directory like any other plugin.

You can find a quick guide on how to convert any of your existing GlotPress plugins to the new format on the GlotPress Wiki.

Configuration Directives

Many of the configuration directives from the standalone code still work in the plugin, however the gp-config.php file no longer exists. Instead you should add any configuration directives to your wp-config.php file so that during upgrades to GlotPress they are not lost.

GlotPress Base Path

The standalone code lived in the root of whatever directory you installed it in, the plugin lives in the "glotpress" virtual path under your WordPress install.

If you wish to have GlotPress take over your entire WordPress site, effectively emulating the old behaviour, you can set the "GP_URL_BASE" configuration directive to your wp-config.php file.

define('GP_URL_BASE', '/');

Permalinks

Make sure when you install WordPress to set the permalink structure to something pretty, the default is not supported in the plugin as we require the rewrite rules to be active.

Templates

If you have created your own templates to use with the standalone version you can still use these in the plugin, they have not changed.

Simply add a configuration directive to your wp-config.php file like:

define( 'GP_TMPL_PATH', '/var/www/example.org/gp-templates' );

You can’t perform that action at this time.