Upgrading to v3
How to update
Follow the install instructions to get the latest version.
Breaking changes
select-with-custom
Use the normal select type with prop creatable set to true.
media
The valueAsObject prop is now detailed.
media-detailed
Use the normal media type with props multiple and detailed set to true. Or a section with a media type for one of the inputs.
media-multiple
Use the normal media type with prop multiple set to true.
The allowMultiples prop is now allowDuplicates.
datepicker
Is now called date.
The format prop is deprecated. All dates are saved in YYYYMMDD, e.g. 20180511 - 11th May, 2018.
If you need the format prompt, contact help.
select-icon
Is now called icon.
select-order
The way in which data is saved has been changed, you are now returned a flat array containing post ids.
$posts_in_order = fx_get_meta('id');
// old
// [{ id: 23, title: 'My Post' }, { id: 38, title: 'Another Post' }]
// new
// [23, 38]
To help migrate, you should update your code to use assume you have the new output. You can then wrap your fx_get_meta call in the migrate helper to ensure any old data is converted to the new form.
$posts_in_order = fx_migrate_select_meta(fx_get_meta('id'));
// Now you can use the ids to get the posts
$query = new WP_Query([
'posts_per_page' => -1,
'post__in' => $posts_in_order,
'ignore_sticky_posts' => true,
'orderby' => 'post__in',
]);
sections
The way in which data is saved has been changed, data is only serialized once, you no longer need to json_decode each step. This was a common problem when using sections with other dynamic inputs, e.g. select-order.
In the example below, the meta is a section which contains a input and select-order.
$section_data = json_decode(fx_get_meta('id'), true);
// old
// [{ title: 'Section Title', posts: "[{\"id\":23,\"title\":\"My Post\"}, {\"id\":38,\"title\":\"Another Post\"}]" }]
$section_posts = json_decode($section_data['posts'], true);
// Then to get just the ids
$section_post_ids = array_map(function($P) {
return $p['id'];
});
// new
// [{ title: 'Section Title', posts: [23, 38]]
// You automatically have the ids, no need to json_decode or map
$section_post_ids = $section_data['posts'];
To help migrate, you should update your code to use assume you have the new output.
You can use the fx_migrate_select_meta to help handle old data.
$section_data = json_decode(fx_get_meta('id'), true);
$section_post_ids = fx_migrate_select_meta($section_data['posts']);
// Now you can use the ids to get the posts
$query = new WP_Query([
'posts_per_page' => -1,
'post__in' => $posts_in_order,
'ignore_sticky_posts' => true,
'orderby' => 'post__in',
]);
New Meta Types
color
Color picker
link
WP link picker with title support