WordPress-Developers-Custom-Fields
WordPress-Developers-Custom-Fields copied to clipboard
A plugin to provide WordPress developers with tools for managing custom fields. Check the WP repository link below for the source - GitHub currently only used for issue tracking.
=== Developer's Custom Fields === Contributors: gyrus, adriantoll, saurabhshukla Donate link: http://www.babyloniantimes.co.uk/index.php?page=donate Tags: admin, administration, custom, meta, page, pages, post, posts, attachments, custom fields, form, user, profile Requires at least: 3.5 Tested up to: 5.1.1 Stable tag: 1.3.4
Provides developers with powerful and flexible tools for managing post and user custom fields.
== Description ==
NOTE: This plugin is still maintained and supported, but is disabled for new installations on wordpress.org, isn't being actively developed. Gutenberg is not supported - use Classic Editor if possible.
This plugin is aimed at plugin and theme developers who want a set of tools that allows them to easily and flexibly define custom fields for all post types, and for user profiles.
Full documentation at http://sltaylor.co.uk/wordpress/developers-custom-fields-docs/.
Code on GitHub.
Issue tracking on GitHub.
Please note that this plugin isn't suitable for non-developers. It has been intentionally designed without a user interface for defining fields, and some aspects may be "unfriendly" to anyone not comfortable with hands-on WordPress development.
If you think this plugin doesn't quite suit your needs, there is a comparison chart of similar plugins to find something that will!
== Installation ==
- Upload the
developers-custom-fieldsdirectory into the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Register your boxes and fields with
slt_cf_register_box(full documentation at sltaylor.co.uk
== Getting started ==
Because this code began life just managing custom fields for posts by defining meta boxes for post edit screens, the basic unit here is "the box". However, a "box" can also refer to a section in the user profile screen, or on media attachment edit screens.
A box is defined containing one of more custom fields, each with their own settings. You set a box to be associated with posts (in the generic sense, including pages and custom post types!), users or attachments using the type parameter.
Say you've defined film as a Custom Post Type, and you want to create custom fields to set the director and writer for film posts. You would add something like this to your theme's functions.php (or indeed your plugin code):
<?php
if ( function_exists( 'slt_cf_register_box') )
add_action( 'init', 'register_my_custom_fields' );
function register_my_custom_fields() {
slt_cf_register_box( array(
'type' => 'post',
'title' => 'Credits',
'id' => 'credits-box',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'director',
'label' => 'Director',
'type' => 'text',
'scope' => array( 'film' ),
'capabilities' => array( 'edit_posts' )
),
array(
'name' => 'writer',
'label' => 'Writer',
'type' => 'text',
'scope' => array( 'film' ),
'capabilities' => array( 'edit_posts' )
)
)
));
}
?>
Then, when you want to output these values in a loop:
<?php
echo '<p>Director: ' . slt_cf_field_value( "director" ) . '</p>';
echo '<p>Writer: ' . slt_cf_field_value( "writer" ) . '</p>';
?>
This is just the beginning! Check the documentation for registering boxes and fields, especially the parameters for fields. The most immediately interesting parameters for fields to check out are: type, scope, options_type.
There are some option query placeholders, for creating dynamic queries to populate select, radio and checkbox fields.
There are also a few hooks. If the plugin currently lacks something you need, odds are you'll be able to hack it using a hook!
If you create a plugin that is dependent on this plugin, use the slt_cf_init hook to intialize your plugin (see this Trac comment).
Note that the internal Google Maps and file selection functionality is designed to be leveraged by theme options pages and other plugins.
Please raise any issues via GitHub. If you're not sure if you've found a genuine issue or not, please start a thread on the WP forum.
NOTE: Some people have found compatibility issues between the WPMU DEV Events+ plugin and this plugin (see here and here). If you find an apparent issue with this plugin and you're also using WPMU DEV Events+, please check for incompatibilities before posting an issue.
== Changelog ==
= 1.3.4 (2019-05-07) =
- Version fix
= 1.3.3 (2019-05-07) =
- Fixed wrong value for 'Use location map?' = 'no'
= 1.3.2 (2018-12-19) =
- Set version when registering Google Maps API script to
null - Fixed an issue where option values with spaces used for multiple checkbox fields don't get saved if selected
- Fixed an issue where multiple maps on a single post would all display and hide at the same time when only one radio button changed
- Fixed defaulting issues with
slt_cf_file_select_button_enqueue() - Updated readme.txt (plugin now disabled for new installations but still supported)
= 1.3.1 (2015-08-25) =
- Fixed issue with
slt_cf_gmaphandling of new$location_markersinteger default
= 1.3 =
user_new_formhook used to add fields to new user form (to include fields in new user form, set scope as per including them in registration form, e.g.array( 'registration', 'subscriber' )- the latter being the default user role)group_by_post_typenow includes option group label even if there's only one post type in the options- Changed
location_markerfield parameter to accept integers, to control how many markers can be set (default is one) - Google Maps JavaScript: Reworked code for more efficiency, prevent addition of more markers to a map than set in
location_marker, variable instructions based on maximum number of markers, geocode moves single map marker (as in previous single-marker releases) or adds new markers on maps with multiple markers - Fix to enqueue
jquery-ui-autocompleteeven if Use Google Libraries is present
= 1.2.2 =
- Changed admin notices so they only show for admins
= 1.2.1 =
- Better version suffixes for styles
= 1.2 =
- Changed Google maps integration to allow multiple markers (thanks adriantoll!) - please read the release notes
- Changed query filtering for Simple Events date fields to use WP 4.1+ syntax to better handle start and end dates
- Added
dcf_query_string_matchingflags forWP_Query, to control how multiple values for single query vars are matched - Added dismissable admin notices based on new version warnings file
= 1.1.1 =
- Fixed issue with max-width: 100% messing up Google controls
= 1.1 =
- Added
slt_cf_file_select_button_enqueue(), for using file select button outside this plugin - Added ability to automatically manage query string vars for custom queries, with the
make_query_varfield parameter, and thedcf_use_query_stringanddcf_custom_field_query_vars_onlyflags forWP_Query. Includes integration with Simple Events date field. - Added
esc_url()around uses ofadd_query_arg() - Added management of 'term splitting' for WordPress 4.2 - not activated by default, please read the release notes
- Added version-specific update warnings functionality
= 1.0.1 =
- Made plugin translatable
- Added Serbian translation (thanks Ogi Djuraskovic!)
= 1.0 =
- Dropped support for WP < 3.5 (please update WP, or stick with DCF 0.9.1 if you really have to!)
- Updated
filefield type andslt_cf_file_select_buttonfunction to use WP 3.5+ media upload API - Added
file_restrict_to_typeparameter for file upload fields - Added
file_dialog_titleparameter for file upload fields - Changed
file_removeableto work server-side instead of client side wiping of hidden input value - Added
tabindexparameter - Added
$fieldas parameter forslt_cf_checkboxes_thumbnail_sizefilter - Added post formats to scoping
- Fixed small bug in all post meta output box, which showed
0asnull - Added Google Maps API key support with
SLT_CF_GMAPS_API_KEY
= 0.9.1 =
- Fix for conflict with other plugins that add media upload buttons to taxonomies (thanks juicboxint!)
- Fix for
wp_get_attachment_image_src()array elements not able to be referenced directly - Added
checkboxes_thumbnailparameter, to include a thumbnail when listing image attachments with multiple checkboxes - Added
slt_cf_checkboxes_thumbnail_sizefilter - Added
colorpickerfield type, using http://www.eyecon.ro/colorpicker
= 0.9 =
- Fixed issue with sortable checkboxes where new options don't appear in list
- Added
group_by_post_typeparameter, to group multiple post type queries by post type - Added
attachments_listfield type - Added
slt_cf_attachments_list_queryfilter - Improved file preview icon handling for file types without an icon
- User fields can now be added to the registration form - see the docs for the
scopeparameter - Sortable checkboxes can now set default to
force-allto just use a field for sorting, not selecting - Retired "0.7 cleanup" and other redundant database tools
- Fixed "remove old fields" database tool
- Better enqueueing of scripts and styles
- Test to delete empty values changed to exactly match empty strings (numeric 0 gets stored)
= 0.8.4 =
- Added
abbreviate_option_labelsfield parameter - Added
sortableparameter for multiple checkboxes - Fixed error in handling default ID, depending on context (admin / front-end) in
slt_cf_default_id() - Using LESS for CSS
= 0.8.3.1 =
- Fixed minor bug in new placeholder code that was causing issues with option queries
= 0.8.3 =
- Added
[PARENT_ID]option query placeholder - Revamped option query placeholder checking to allow for values inside array parameters
= 0.8.2 =
- Added post meta output (inspired by Post Meta Inspector plugin)
= 0.8.1 =
- Added
slt_cf_strip_prefix() - Added more hooks to allow some standard functions to be overtaken
- Updated
slt-cf-gmaps.min.js(this was omitted from 0.8 and resulted in the geocoder fixes not being active on live sites)
= 0.8 =
- NOTE: The
datepicker_css_urlsetting, to account for additional UI elements, is nowui_css_url - NOTE: The defaults for the
ui_css_urlandcss_urlsettings have been moved inside theslt_cf_initfunction. If these values are being changed by theslt_cf_settingfunction, this must be hooked toinitwith a priority of 11 or above to ensure they aren't re-set to the defaults. These defaults have been moved insideslt_cf_initbecause they useplugins_url. Now they are exposed to any filters that other plugins might attach to theplugins_urlfilter - Added support for WordPress 3.5 media handling; attachments now accept all custom field types except
file - Added
timeanddatetimefield types (thanks saurabhshukla!) - Added
slt_cf_default_valuefilter - Fixed issue with deleting a cleared text field on an attachment (thanks Sean Hawkridge!)
- Minor fixes to dynamic options data initialization
- Adjusted output of box and field descriptions to fit with user profile screen markup better
- Made geocoder bounds update when map bounds change so only addresses / locations from within the current map display are suggested
- Moved enqueuing of Google maps JS inside the
slt_cf_gmap()function, so the scripts are only used where necessary. This is made possible by registering them to be included in the footer - see http://scribu.net/wordpress/conditional-script-loading-revisited.html - Added version numbers to scripts to prevent caching issues in future versions
- Improved PHPDocs for key functions to aid development
= 0.7.2.2 =
- Changed the way the file select JS detects being inside the Media Library overlay, in order to be compatible with the Inline Attachments plugin
- Added the
edit_on_profileflag, to signal that even if a user doesn't have the right capabilities to edit a user profile field, they can edit it on their own profile (thanks jbalyo!) - Improved error messages
- Fixed init errors when creating a post and there's no post ID
- Code now on GitHub!
= 0.7.2.1 =
- Fixed a bug in checkbox / select fields where
singleis set tofalseand no value is selected (thanks Dave Kellam!)
= 0.7.2 =
- Made the Gmap 'Find an address' geocoder work with 3.3's inclusion of jQuery UI autocomplete
- Made File Select functionality compatible with new WP 3.3 Plupload interface
- Added
allowed_htmlfield parameter; text field sanitization is now based on usingwp_ksesand testing for theunfiltered_htmluser capability - The
allowtagsfield parameter is now deprecated - Fixed bug in
slt_cf_gmapthat failed to initialize properly when called via shortcode in a loop
= 0.7.1 =
- For 3.3 and above, switched inclusion of
wysiwygfield to use newwp_editorfunction; also includedwysiwyg_settingsparameter to be passed towp_editor(thanks katoen!) - Changed the way the user ID is set up in
slt_cf_default_id- now it tries to get ID of author whose archive page is being shown first - Fixed bug in
slt_cf_init_options; new version in upgrade wasn't being stored - Fixed problem with Gmap shortcode not working even when
SLT_CF_USE_GMAPSis set totrue
= 0.7 =
- Added
termsas anoptions_typefor populating multiple value fields with taxonomy terms - Added
autopparameter toslt_cf_simple_formattingfunction - Fields are only created when there's a value to enter; when there's an empty value, fields are deleted
- Made the field
scopeparameter default to an empty array, which will apply the field to all items within the box's scope - Added
noticefield type for text-only notices to the user - Changed
slt_cf_gmapso you can pass the name of the field without the prefix, which will be automatically added - Added an
above-contentsetting for the boxcontextparameter - Added
except_postsandexcept_usersoptions to thescopefield parameter - Added admin menu for database clean-up operations
- Added
slt_cf_get_field_namesfunction - Added
$multiple_fieldsparameter toslt_cf_all_field_valuesfunction, to deal with values stored in multiple fields - Added
$file_attach_to_postparameter forfilefield types - Set the
gmapoptionscrollwheelto false (to prevent accidental zooming when scrolling the page) - Changed internal file naming
- Upgraded jQuery UI Datepicker to 1.8.16
- Included the admin gmap geoencoder field via JS, on the condition that jQuery autocomplete is present (until we switch to suggest)
- Added
SLT_CF_USE_GMAPSandSLT_CF_USE_FILE_SELECT - Minified JS and CSS (full versions loaded when SCRIPT_DEBUG is true)
- Moved documentation to http://sltaylor.co.uk/wordpress/developers-custom-fields-docs/
- Issue tracking at https://github.com/gyrus/WordPress-Developers-Custom-Fields/issues
= 0.6.1 =
- Fixed bug where fields init check for capability to edit was being applied when a Google Map is displayed on the front end, so anyone not able to edit the field, including anyone not logged in, can't see the map
- Fixed syntax bug in calls to textile formatting function
- Made sure absent (unchecked) single checkboxes have a boolean false value stored, to avoid something that defaults to true getting re-checked after it's been unchecked
- Changed single checkboxes to store value as "1" and "0" instead of "yes" and "no" ("0" evaluates to false, but "no" evaluates to true!)
= 0.6 =
- Added
attachmentas an possible value of the boxtypeparameter - custom fields for attachments! (Though accepted field types are limited to text and select for now.) Includes many minor changes to plugin code. Thanks to Frank at http://wpengineer.com/2076/add-custom-field-attachment-in-wordpress/ - Added
slt_cf_inithook; changed initialization to allow dependent plugins to hook in - Added
slt_cf_get_current_fields - Branched scope checking out from initialization code into separate
slt_cf_check_scopefunction - Added
gmapfield type - Folded the functionality from the SLT File Select plugin into this plugin's code, leaving the functionality exposed for use in theme options pages etc.
- Added
singlefield parameter, to allow storing multiple-choice values in separate postmeta fields instead of in a serialized array - this is for easiermeta_querymatching - Added
templateoption for the fieldscopeparameter, to match page templates - Added ctype functions for better validation
- Added
slt_cf_reverse_datefunction - Added
slt_cf_pre_saveaction hook - Added
$to_timestampparameter forslt_cf_reverse_datefunction
= 0.5.2 =
- Adjusted
options_querydefault to includeposts_per_page=-1is included in query if not specified
= 0.5.1 =
- Changed selection of users to use new WP 3.1
get_usersfunction - Made the
scopeparameter for fields required - Added parameter type validation
= 0.5 =
- Added
slt_cf_get_posts_by_custom_firstfunction - Changed behaviour of
required, so the empty option isn't included for multiple selects - Added
descriptionparameter for boxes - Added
[TERM_IDS]placeholder - Added "No options" alert and
no_optionsparameter for fields - Added
exclude_currentparameter for fields - Changed
filefield type to use SLT File Select plugin (with interface to Media Library) - Added
file_button_labelandfile_removeableparameters for fields - Changed the way
slt_cf_display_postchecks to exclude link and comment screens in case custom post types 'link' or 'comment' are registered
= 0.4.2 =
- Fixed display of block labels when width is set (thanks Daniele!)
- Empty option only displayed for non-static selects (thanks Daniele!)
- A bunch of changes to how input prefixes and suffixes are handled (thanks again Daniele!)
- For clarity, the field settings
prefixandsuffixhave been renamedinput_prefixandinput_suffix
= 0.4.1 =
- Added
requiredandempty_option_textsettings for fields
= 0.4 =
- Decreased priority of
show_user_profileandedit_user_profileactions, to let other plugins (e.g. User Photo) put their bits in the 'About the user'-headed section - Added
slt_cf_field_keyfunction - Added
slt_cf_all_field_valuesfunction - Added
slt_cf_populate_optionsfilter for custom option types - Added
prefixandsuffixsettings for fields - Added
slt_cf_default_idfunction for better default ID handling - Changed datepicker formatting setting so it can be overridden on a per-field basis
- Added
OBJECT_IDplaceholder foroptions_query - Fixed bug that creates an
optgrouptag when an options value is zero (thanks Daniele!)
= 0.3.1 =
- Fixed an error in
slt_cf_check_scopehandling
= 0.3 =
- Added support for assigning fields to posts with certain taxonomy terms assigned to them
- Added
group_optionssetting for fields - Added jQuery datepicker for date field type
- Altered interaction with AJAX requests to prevent 'undefined function' errors
- Added
slt_cf_check_scopeandslt_cf_pre_save_valuefilter hooks - New built-in scope matches against post or user IDs
- Multiple values allowed for box type
= 0.2 =
- Added support for user profile custom fields
- Added check for duplicate field names in post meta boxes
- Improved initialization and interaction with hooks
- Added
usersvalue foroptions_type, to populate a field with users - Added output options for
slt_cf_field_value - Added
css_urlsetting to override default styles
= 0.1 =
- First version