Customize Posts
This is a feature plugin intended to implement #34923: Introduce basic content authorship in the Customizer. The goal for this plugin is to be able to expose the editing of posts and pages in the Customizer, allowing you to edit post data and postmeta for any number of posts, and preview the changes before saving them for others to see. This plugin was birthed out of the Widget Customizer feature-as-plugin project which was merged into WordPress Core: as widgets (in 3.9) and nav menus (4.3) can now be managed in the Customizer, so too should posts and pages be editable in the Customizer as well. Did you know that changing the featured image actually makes the change live even before you save the post? This is very surprising/unexpected behavior. The only way to truly preview a change to a featured image is to use something like Customize Posts. Likewise, did you know that changing a page template cannot be previewed from the post editor? When you change the selected page template, the change will not show up when you preview the page (see #11049). However, in Customize Posts you can preview changes to the page template just by changing the dropdown selection, and then you can see what your page would look like with the new template after the preview refreshes. Most other changes to metaboxes containing data that gets saved to custom fields (postmeta) also get written when clicking the Preview button. The Customize Posts plugin provides a framework to edit postmeta in the Customizer with a live preview of the changes. (Fixing this underlying issue of incorrectly persisting postmeta when doing a preview is captured in #20299.) As much as possible, the previewing of changes in Customize Posts utilizes the selective refresh capabilities introduced in WordPress 4.5. Not only does this mean it is faster to preview changes to posts and postmeta, but it also allows you to shift-click on an element to focus on the corresponding control in the Customizer pane. For example you can shift-click on the post title in the preview to focus on the post title control’s input field, or shift-click on a featured image to focus on the control’s button to open the media library. Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum. (This Customize Posts plugin is not to be confused with 10up’s Post Customizer.) Demo Videos The following are listed in reverse chronological order. The first, more recent videos, show more polish. [2016-04-28] New features in 0.5.0. [2016-03-28] Previewing post from Post Edit screen. [2016-03-05] Opening a draft post in the Customizer to preview title wrapping. [2016-03-04] Demo featuring the WP visual rich text editor (TinyMCE), including the insertion of images from the media library. Post content can be edited in the Customizer and previewed in multiple contexts. For example, this allows you to preview how a Read More tag will appear when the post appears on a post list page, and you can navigate to the single post to continue previewing subsequent paragraphs. You can expand the editor into a full-screen mode to focus on writing and then quickly preview the changes on the site by toggling the editor. You can make changes to as many posts as you want, but none of the changes will go live until you hit Save & Publish: everything is previewed so there is no “save and surprise”. [2016-03-03] Demonstration of integration with Customize Setting Validation (#34893) to gracefully handle failures to save due to post locking and concurrent user editing: [2016-03-01] Demonstration of hooking into edit post links so that they actually work in the Customizer and expand the section to edit the given post (as opposed to the link doing nothing at all when clicked), as well as shift-clicking on the title and content (needs better discovery UI, see #27403):
Top keywords
- post16×2.42%
- preview13×1.97%
- customizer11×1.67%
- posts10×1.52%
- changes9×1.36%
- customize6×0.91%
- page6×0.91%
- customize posts5×0.76%
- edit5×0.76%
- postmeta5×0.76%
- see5×0.76%
- change4×0.61%
Global Meta Box Order
Intuitively harmonize meta box positions and screen column layout for all backend users of your WordPress installation. Quick Overview Install and activate the plugin Switch to a post, a page, a custom post type, or the dashboard Change the order and position of a meta box (or all of them) Change the column layout Switch to a different user (maybe with the help of the User Switching plugin) See your changes applied Installation Download and unpack, then move the folder ‘global-meta-box-order’ into your ‘plugins’ folder. Head over to your WordPress installation and activate the plugin in the admin area. Rollback The plugin doesn’t write anything to the database, it just reads. So it never touches any user settings, but instead filters them on a per request basis. Though all applied changes appear to be permanent from a user’s perspective, they are not. Just deactivate the plugin and see all changes disappear. Activate it again, and they will all be reapplied. How It Works The plugin operates on a blueprint user whose screen settings for meta boxes (visibility, position and ordering), and column layout are cloned for all other backend users on the fly. By default, this blueprint user is the first admin user found, so you’ll need to be logged in as that user to globally change screen settings. For how to change the default blueprint user as well as other settings, please refer to the Configuration section below. Where It Works By default, the plugin kicks in when a user: edits a post edits a page edits a custom post type hits the dashboard What It Changes It will always change the meta boxes visibility, ordering, and column positions the column layout When told so, it will also remove the screen options box immobilize all boxes, so they can’t be moved around by your users anymore Usage Log in as your blueprint user. By default, the is the first admin user found in your system. Select an editing screen (post, page, custom post type) or the dashboard, move the meta boxes around, change their screen settings and the screen’s column layout. Switch to some user to review your settings, switch back to adjust them. When done, you might want to lock your views down by removing the screen options box and by locking the boxes’ sort order. Your blueprint user, of course, wil not be affected by this. Configuration The backend integration is kept to a minimum. No navigation entry, no options page, no entry in the database. Instead, the place to go to configure the plugin is your theme’s functions.php. By the way: You don’t need to configure the plugin. As long as it finds an admin user, it will work just fine. Preparation Fire up an editor, load your functions.php, and copy and paste the following code into it. The idea is to have some sort of container to do the configuration in, but do it any way you like. For brevity, we’ll assume the plugin is loaded and active, so we won’t check for that (see this nice write-up on QueryLoop on some ways to do it, though). if (is_admin()) { // The path to the configuation is rather long, so let's // make us a shorthand. class_alias('\GlobalMetaBoxOrder\Config', 'MetaBoxConfig'); // Add MetaBoxConfig below this line ... } Now we are ready to add some of the configuration settings below to adjust the plugin’s default behaviour. You might also want to have a look at the example configuration near the end of this document. Please keep in mind that you need to be logged in as any user but your blueprint user to see a setting applied. Again, the User Switching plugin might come in handy. Screens To Operate On By default, the plugin operates on the post, page, and custom post type editing screens, and the dashboard. You can change this as follows: // Operate on post and page screens only, leave the dashboard alone. // This will still include custom post types. MetaBoxConfig::$filter = array('post', 'page'); // Exclude custom post types MetaBoxConfig::$include_cpts = false; // Allow custom post types... MetaBoxConfig::$include_cpts = true; // ...but not all of them MetaBoxConfig::$exclude = array('acme_product'); MetaBoxConfig in the example above is assumed to be an alias to \GlobalMetaBoxOrder\Config as shown in the preparation section above. Changing the Blueprint User Register a function that returns a user id, like so: MetaBoxConfig::$getBlueprintUserId = function () { return 1; }; Or, more involved: MetaBoxConfig::$getBlueprintUserId = function () { $user = get_user_by('slug', 'jane'); return $user ? $user->ID : false; }; MetaBoxConfig in the example above is assumed to be an alias to \GlobalMetaBoxOrder\Config as shown in the preparation section above. Locking Views By default, all users will be able to interact with the screen options box, and to move around the meta boxes themselves. There is a rationale behind it, but to cut things short, this is how you might want to change it: // No screen options MetaBoxConfig::$remove_screen_options = true; // Meta boxes can't be moved anymore MetaBoxConfig::$lock_meta_box_order = true; MetaBoxConfig in the example above is assumed to be an alias to \GlobalMetaBoxOrder\Config as shown in the preparation section above. Example Configuration if (is_admin()) { // Make sure plugin is active if (class_exists('\GlobalMetaBoxOrder\Config')) { // Make a long name short. class_alias('\GlobalMetaBoxOrder\Config', 'MetaBoxConfig'); // Settings MetaBoxConfig::$filter = array('post', 'page', 'dashboard'); // default MetaBoxConfig::$include_cpts = true; // default MetaBoxConfig::$getBlueprintUserId = function () { return 1; }; MetaBoxConfig::$exclude = array('acme_product'); MetaBoxConfig::$remove_screen_options = true; MetaBoxConfig::$lock_meta_box_order = true; } } On Moving the WYSIWYG Editor The position of WordPress’ WYSIWYG editor is fixed, and can’t be changed out of the box (mostly because it lacks a box around it). There are reasons for this, but if you want to have a positionable editor anyway, you might want to have a look at our very own Movable Editor plugin. If, on the other hand, if you want to place one specific box above the editor, you might want to check out this answer on stackexchange.