WP Options Importer

WordPress can presently export all of its content via WXR, and then import that through the WordPress Importer plugin. That process includes all posts, terms, menus, comments, and users, but it doesn’t touch options. In addition to general settings, options can include widget configurations, plugin settings, theme settings, and lots more. This can be very time-consuming to migrate manually. WP Options Importer aims to fill that void and save us all a lot of time.

WP Options Importer allows you to export all options to a JSON file, and then you can selectively import them into another WordPress installation. The import process is very transparent, and it even shows you what data you’ll be importing. Lastly, it gives you the option to override existing settings or to skip options that already exist.

To activate the WP Options Importer, include a call like this in your site’s theme: wpcom_vip_load_plugin( 'options-importer' );

Shortcake

Description

Used alongside add_shortcode, Shortcake supplies a user-friendly interface for adding a shortcode to a post, and viewing and editing it from within the content editor.

Once you’ve installed the plugin, you’ll need to register UI for your shortcodes. For inspiration, check out examples of Shortcake in the wild.

To report bugs or feature requests, please use Github issues.

Installation

Shortcake can be installed like any other WordPress plugin.

Once you’ve done so, you’ll need to register the UI for your code.

Screenshots

1. Without Shortcake, shortcodes have a minimal UI.

687474703a2f2f732e776f726470726573732e6f72672f657874656e642f706c7567696e732f73686f7274636f64652d75692f73637265656e73686f742d312e706e67

2. But with Shortcake, TinyMCE will render the shortcode in a TinyMCE view.

687474703a2f2f732e776f726470726573732e6f72672f657874656e642f706c7567696e732f73686f7274636f64652d75692f73637265656e73686f742d322e706e67

3. And add a user-friendly UI to edit shortcode content and attributes.

687474703a2f2f732e776f726470726573732e6f72672f657874656e642f706c7567696e732f73686f7274636f64652d75692f73637265656e73686f742d332e706e67

4. Add new shortcodes to your post through “Add Media”.

687474703a2f2f732e776f726470726573732e6f72672f657874656e642f706c7567696e732f73686f7274636f64652d75692f73637265656e73686f742d342e706e67

Fieldmanager

Fieldmanager is a comprehensive toolkit for building forms, meta boxes, and custom admin screens for WordPress.

Field Types

  • Autocomplete
    Text fields that responds to user input with autocomplete suggestions (optionally via an ajax request).
  • Checkbox
    Single boolean checkbox.
  • Checkboxes
    A set of multiple checkboxes which stores as an array of the checked values.
  • Colorpicker
    Color picker interface.
  • Datepicker
    Text fields that uses the jQuery UI Datepicker to allow the user to select a date from a calendar. Optionally adds fields for time.
  • Grid
    Data grids (spreadsheets).
  • Hidden
    Hidden input fields.
  • Link
    Text fields that sanitize values as URLs.
  • Media
    Allow users to select an attachment via the Media popup.
  • Password
    Password text fields (hides user input).
  • Radios
    A set of radio buttons. Often accompanied by a datasource to populate the radio buttons.
  • RichTextArea
    Produces a visual editor (TinyMCE) field.
  • Select
    Select dropdowns.
  • TextArea
    Textarea (multi-line text) fields.
  • TextField
    Basic single-line text fields.

Contexts

With Fieldmanager, you can add fields to different contexts.  For example, you might want to add a new option in the user profiles, which you can do through the User Context.

Available Contexts:

  • Post Context
    Adds a meta box to the new/edit post screen (for any post type), and saves data to post meta.
  • Term Context
    Adds fields to the new and/or edit term screen, and saves data to term meta.
  • Submenu Context
    Adds a new screen to the WordPress admin, and saves data to options.
  • User Context
    Adds fields to the edit user (profile) screen, and saves data to user meta.
  • Quickedit Context
    Adds fields to the Quickedit box in the post list screen, and saves data to post meta.

Grouping Fields

Fieldmanager lets you group one or more fields together to help with organizing content. You can have single-level groups, tabbed groups, and multi-level groups.

Image of a Single-Level Field Group
Single-Level Group of fields
Image of a Tabbed Field Group
Tabbed Field Group
Image of a Vertical Tabbed Field Group
Vertical Tabbed Field Group
Image of a Multi-Level Field Group
Multi-Level Field Group

Repeating and Sorting Fields

Fields or Groups of fields can repeat and be sorted.

  • The limit key is used to determine how many times a field can repeat. Use 0 if you want to allow unlimited fields
  • The sortable key is used to make a field sortable. This might be useful in a case where you are building a slider or other content that needs to be moved around.

Example:

$fm = new Fieldmanager_Group( array(
			'name'           => 'repeatable_meta_fields',
			'limit'          => 0,
			'add_more_label' => 'Add another set of fields',
			'sortable'       => true,
			'collapsible'    => true,
			'label'          => 'Fields',
			'children'       => array(
				'text'         => new Fieldmanager_Textfield( 'Text Field' ),
				'media'        => new Fieldmanager_Media( 'Media File' ),
			)
		) );
$fm->add_meta_box( 'Field Group', 'demo-group' );

Repeatale, Sortable, and User-generated

You might want to have the option to create pages with different types of fields in different arrangements. The same post type might be configured for multiple images, a text field, and a button – or no images, a text field, and a form.

To accomplish these kinds of layout options, take a look at our Custom Blocks demo plugin:
https://github.com/Automattic/fieldmanager-custom-blocks-demo

Seen in action:

Fieldmanager Demos

To see more demos, check out the Fieldmanager Demos plugin from Alley Interactive:
https://github.com/alleyinteractive/fieldmanager-demos

Once you install and activate the plugin, you will see new post types that demonstrate different field types.

More Information

Official Site: http://fieldmanager.org/
API Docs: http://api.fieldmanager.org/index.html

WPCOM Legacy Redirector

The WPCOM Legacy Redirector is a plugin on WordPress.com VIP that allows you to set up redirects for legacy content on your WordPress.com site in a scalable manner.

Redirects are stored as a custom post type and use the following fields:

  • post_name: contains the md5 hash of the “from” path or URL
  • post_title: contains the “from” path or URL (without being hashed)
  • post_parent (if we’re redirecting to another post ID) OR post_excerpt (if we’re redirecting to another URI or absolute URL)

All interaction with this plugin is done via the command line, and all data about redirects needs to be bulk-loaded via wp-cli commands.

Redirect data can be stored in a CSV file OR in a post meta field. With the post meta field method, the resulting redirect is then attached to an existing post (and follows the post through future updates) whereas with the CSV method, the redirect is attached to a hardcoded URL.

This plugin will not redirect valid URLs. If the URL does not return a 404, the redirect will not trigger, which means it won’t redirect live pages.

If you have questions about how this plugin will work on your site or if you’d like to have us review your redirect strategy, please contact us before using this plugin.

Activating the Plugin

WPCOM Legacy Redirector can be activated through your site Dashboard like other plugins, but it’s preferable to instead add the following to your theme’s functions.php file:

wpcom_vip_load_plugin( 'wpcom-legacy-redirector' );

Activating the plugin will make its wp-cli functions available on the command line but does not otherwise make any changes or create menu items or settings in the Dashboard.

Adding Redirects from Post Meta Fields

You can add redirects from post meta fields using this command:
wp wpcom-legacy-redirector import-from-meta --meta_key=my-post-meta-key

The plugin will search for all posts that have a post meta field named “my-post-meta-key” (or whatever key name you decide to use) and create a redirect from the address found in the meta field to the post that has that meta field. The meta field can contain relative or absolute URLs, but we recommend specifying absolute URLs where possible.

So, for example, if you wanted to redirect all requests to http://old-domain.com/old/legacy/path/ to post ID 5, you would set the value of the post meta field named “my-post-meta-key” to http://old-domain.com/old/legacy/path/ on the post with ID 5.

If you only want to process a certain number of posts at a time, you can add these optional command line parameters:

[--start=start-offset] [--end=end-offset]

where, for example, start-offset might be “1” and end-offset might be “1000”.

Adding Redirects from a CSV File

You can add redirects from a CSV file using this command:
wp wpcom-legacy-redirector import-from-csv --csv=/tmp/my_redirects.csv

The CSV file (in this example, /tmp/my_redirects.csv) should consist of the from url (without domain, and including preceding slash), followed by the destination address:

/old/legacy/path,/shiny/new/path
/another-legacy-path,http://my-other-domain.com/other-path

The plugin will create a redirect from each source/legacy path to the destination address specified.

Destination Addresses

The destination address in the CSV import method can be one of: a Post ID, a relative path, or an absolute URL.

The destination value is passed to wp_safe_redirect internally, so be sure it’s a valid local address. If you want to redirect to other external domains, you can whitelist that domain by filtering allowed_redirect_hosts in your theme:


add_filter( 'allowed_redirect_hosts', function( $hosts ) {
    $hosts[] = 'my-other-domain.com';
    $hosts[] = 'www.my-other-domain.com';

    return $hosts;
});

Testing and Production Runs

Before creating redirects on your production WordPress.com site, please test out the legacy redirect import process in your development environment to ensure the redirects are created as expected.

Once you’ve verified that the process works as expected, you can request a run of the redirector import command of your choosing by opening a new support ticket with WordPress.com VIP. Please make sure to include:

  • the URL of the site where you want to run the import
  • the CSV file containing your redirects (if using the CSV import method)
  • the name of the meta key containing your redirect destinations (if using the post meta import method)
  • Confirmation that you’ve run the import as a test in a development environment
  • An example URL on your site that is not currently redirected, and where it should redirect to when the import is complete (for testing)
  • Your desired timing for when the redirects are created

Once we receive your support request with all of the above information and have resolved any questions, we will proceed with running the import command.

Frequently Asked Questions

Q: Shouldn’t I just use the Safe Redirect Manager for redirects?
A: The Safe Redirect Manager allows you to create and update up to 300 redirects via your Dashboard. Above that number the redirect management becomes too slow for optimal performance, and so for redirect creation above that amount, you should use this plugin, which can handle as many redirects as needed.

Q: Can I create redirects for only a certain post type? 
A: At this time, the redirector plugin operates on all post types. But, in the case of adding redirects from post meta fields, it will only create redirects where it detects the existence of the specified meta key.

Q: Are there performance implications when running the import on a production site?
A: When we create a redirect for an existing URL, we clear the cache of any content that existed at that address. Importing thousands of redirects can temporarily decrease the performance of your site while that caching is cleared and then rebuilt. In general, creating redirects has a small performance impact on your site.

Q: Will the redirector automatically detect “from” URLs with and without trailing slashes?
A: No – you will need to add a redirect for each version of a “from” URL that you want to redirect, e.g. one with and one without a trailing slash.

Q: Will the redirector handle domains/URLs not mapped to my WordPress.com site?
A: The redirector can only handle “from” URLs that use one of the domains mapped to your WordPress.com site. If you want to set up redirects on domains hosted elsewhere, that would be configured where those domains are hosted. Alternatively, you can point and map the domain to your WordPress.com site and then set up redirects for it.

Q: Can I use the plugin to dynamically create redirects (e.g. for a custom promotional URLs, link shortening, etc)?
A: Yes. The plugin has a basic API with two functions you can use: WPCOM_Legacy_Redirector::insert_legacy_redirect( $from_url, $redirect_to ) and WPCOM_Legacy_Redirector::get_redirect_post_id( $id ).

 

Maintenance Mode

Usage

On the VIP Go platform

1. Commit the plugin to your repo. Add it to the Plugins directory.
2. Add the VIP_MAINTENANCE_MODE constant to vip-config/vip-config.php or in your theme and set to true.

 define( 'VIP_MAINTENANCE_MODE', true );

3. Load the plugin in client-mu-plugins/plugin-loader.php

wpcom_vip_load_plugin( 'maintenance-mode' );

If you are using this plugin on a multisite, you may need to include a conditional check to select only a single subsite, or theme, depending on your needs.

On the WordPress.com VIP platform
The maintenance mode plugin is enabled by default. To activate the plugin, simply:

1. Add the VIP_MAINTENANCE_MODE constant to your theme and set to true
2. Load the plugin in your theme

define( 'VIP_MAINTENANCE_MODE', true );
...
// And be sure to load the plugin itself!
wpcom_vip_load_plugin( 'maintenance-mode' );

Regardless of the platform you’re on, please remember to always test locally before committing your code or submitting your PR to us for review. Once this code has been committed, you can open a browser page which you are not logged-in to view the maintenance mode page.

IMPORTANT: if you’re not seeing maintenance mode enabled on the frontend of your site, check the (WordPress.com) logged-in vs. logged-out experience…they’re different, by design! In the backend, you won’t see much as this is a code-only plugin.

Custom Template

To add a custom template / messaging:

  • Add a template to your theme’s root folder called template-maintenance-mode.php.
  • This should be a simple HTML page that should include the message(s) you want to show your visitors.
  • Note: the template should include wp_head() and wp_footer() calls. You can find an example file here.

Custom Metadata Manager

An easy way to add custom fields to your object types (post, pages, custom post types, users).

The goal of this plugin is to help you rapidly build familiar, intuitive interfaces for your users in a very WordPress-native way.

The custom field panel is nice, but not quite the easiest thing for users to work with. Adding your own metaboxes and fields involves a lot of time and repetitive code that could be better used elsewhere.

This plugin handles all that heavy-lifting for you behind-the-scenes, so that you can focus on more on building out and connecting your data rather than all the minor details. To add a custom field, simply register it like so:

add_action( 'custom_metadata_manager_init_metadata', function() {
    x_add_metadata_field( 'my-field-name', 'post' );
} );

The above generates a metabox with a text field inside it, with the necessary hooks to save the entered values.

The API is similar to that used for registering custom post types and taxonomies so it should be familiar territory.

WP Large Options

You may wish to store a larger option value than is recommended on WordPress.com. If your option data will exceed 400K, or is of an unpredictable size (such as an HTML fragment etc.) you should use the wp_large_options plugin to store the option in a cache-safe manner. Failure to do this could result in the option not being cached, and instead fetched repeatedly from the DB, which could cause performance problems.

The API is very similar to the WordPress Options API:

Safe Redirect Manager

What does this plugin do?

Safe Redirect Manager is an HTTP redirect manager for WordPress. An easy-to-use UI allows you to redirect locations to new URLs with the HTTP status codes of your choosing. The plugin uses the wp_safe_redirect function, which only allows redirects to whitelisted hosts for security purposes. The plugin automatically handles whitelisting hosts for you.

(Note that this plugin will not allow you to redirect visits to your site’s home/front page. To achieve this, you’ll need to modify your theme code to hook into an early action and with a conditional is_front_page(), call wp_safe_redirect().)

How do I set it up?

Once you’ve activated the plugin, you’ll see a new option, Tools→Safe Redirect Manager in the sidebar menu of your Dashboard. Click the “Create Redirect Rule” button at the top:

Add New Rule

There, you’ll see a form to add and publish the redirect.

Redirect Example

After publishing, there may be a delay of several minutes before the changes take effect. If a redirect isn’t working as expected after 10 minutes, just let us know.

For more information, please see the full plugin documentation here.

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.