Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harryfinn/preview-custom-fields-wp-plugin
Preview custom fields WordPress Plugin
https://github.com/harryfinn/preview-custom-fields-wp-plugin
Last synced: about 1 month ago
JSON representation
Preview custom fields WordPress Plugin
- Host: GitHub
- URL: https://github.com/harryfinn/preview-custom-fields-wp-plugin
- Owner: harryfinn
- Created: 2016-05-19T14:57:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-05-20T16:14:12.000Z (over 8 years ago)
- Last Synced: 2024-10-14T20:43:39.163Z (3 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Preview custom fields WordPress Plugin
## About this plugin
This plugin adds support for a missing piece of WordPress functionality
regarding the previewing of post types with custom meta fields.By default, the WordPress CMS only stores revisions and preview data for the
primary title (`post_name`) and content (`post_content`) fields. Meta fields are
not included which results in inconsistencies when attempting to view a preview
version of a post type item.This plugin hooks into the points at which a valid preview revision is made and
enforces the saving of all associated custom fields for the item being
previewed.## Installing
To install, simply download a `.zip` version of this repository and upload to
your WordPress instance via the Admin screens,
`Plugins -> Add New -> Upload Plugin`. Finally, active the plugin.## Usage
Every time a post item is previewed, this plugin will loop through an array of
custom field meta keys and ensure they are saved correctly against the revision
or autosave for the current item.In order to add fields to this process you will need to use the following
class function:```PHP
PreviewCustomFields::add_meta_keys([
'_cmb2_page_author_name',
'_cmb2_page_author_age'
]);
```The code above adds the two example custom fields `_cmb2_page_author_name` and
`_cmb2_page_author_age` fields. You can call this method as many times as
required or all at once.