Opened 13 years ago
Closed 9 years ago
#18979 closed enhancement (fixed)
Add $post_type parameter and a filter to meta_form()
Reported by: | takayukister | Owned by: | |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | |
Focuses: | ui | Cc: |
Description
In the current version, meta_form(), the function which outputs Custom Fields form used in Edit Post pages, shows all meta keys you have used regardless of post type. Sometimes this gives users unwanted options.
I'd like to suggest adding $post_type parameter to meta_form() to show only meta keys you have used in the same post type. In addition, it would be better if there were a filter for the meta keys.
Attachments (1)
Change History (11)
#1
@
13 years ago
I would rather the solution just be that a developer disables the Custom Fields box and creates their own meta box. Any improvements here seem like they're a waste of energy (and CPU).
#2
@
13 years ago
- Cc contact@… added
Just a short contribution to improve - old - meta_form() function according filtering and protecting rules of meta_key and custom post type:
In current post_custom_meta_box (displaying custom form fields), list_meta is filtered via is_protected_meta function (and his own available filter 'is_protected_meta'). But it is impossible to filter the content of the popup list populated by $key built by meta_form().
With 'is_protected_meta' filter it is possible to subselect metas according context. To subselect popup menu , I suggest a very simple filter just before
<td id="newmetaleft" class="left"> <?php if ($keys){
<td id="newmetaleft" class="left"> <?php $keys = apply_filters( 'post_meta_key_subselect', $keys, $limit); if ($keys){
Inside the filter, it will be easy to re-query keys (like described above by takayukister) or to subselect and sort the popup list according context an rules (post_type, and more...) without rebuilding a whole custom field metabox UI. It is also a simple way to fixe contamination of keys used buy one post type in another.
This very simple improvement is in concordance with the available filter 'is_protected_meta' where it is possible to not only subselect key with prefix '_' but with another rules.
note: don't need to add post_type parameter. the filter can use global $post and
$post_type = get_post_type ( $post->ID );
Hope that help to review.
#4
@
9 years ago
- Component changed from Editor to Administration
- Focuses performance added
- Keywords needs-refresh removed
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #24498.
#5
@
9 years ago
- Focuses ui added; performance removed
- Resolution duplicate deleted
- Status changed from closed to reopened
The duplicate that was fixed, #24498, did not address this bug. Also, adding UI focus, since the bug is for a behavior improvement, not performance.
a patch for meta_form()