WordPress Trac: Ticket #18979: Add $post_type parameter and a filter to meta_form()https://core.trac.wordpress.org/ticket/18979
<p>
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.
</p>
<p>
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.
</p>
en-usWordPress Trachttps://core.trac.wordpress.org/chrome/site/your_project_logo.pnghttps://core.trac.wordpress.org/ticket/18979
Trac 1.0.1takayukisterTue, 18 Oct 2011 03:57:12 GMTattachment sethttps://core.trac.wordpress.org/ticket/18979
https://core.trac.wordpress.org/ticket/18979
<ul>
<li><strong>attachment</strong>
set to <em>meta_form.diff</em>
</li>
</ul>
<p>
a patch for meta_form()
</p>
TicketnacinTue, 15 Nov 2011 00:43:03 GMThttps://core.trac.wordpress.org/ticket/18979#comment:1
https://core.trac.wordpress.org/ticket/18979#comment:1
<p>
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).
</p>
TicketmichelwppiSun, 01 Apr 2012 12:29:54 GMTcc sethttps://core.trac.wordpress.org/ticket/18979#comment:2
https://core.trac.wordpress.org/ticket/18979#comment:2
<ul>
<li><strong>cc</strong>
<em>contact@…</em> added
</li>
</ul>
<p>
Just a short contribution to improve - old - meta_form() function according filtering and protecting rules of meta_key and custom post type:
</p>
<p>
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().
</p>
<p>
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
</p>
<pre class="wiki">&lt;td id="newmetaleft" class="left"&gt;
&lt;?php if ($keys){
</pre><pre class="wiki"> &lt;td id="newmetaleft" class="left"&gt;
&lt;?php
$keys = apply_filters( 'post_meta_key_subselect', $keys, $limit);
if ($keys){
</pre><p>
Inside the filter, it will be easy to re-query keys (l<em>ike described above by takayukister</em>) 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.
</p>
<p>
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.
</p>
<p>
note: don't need to add post_type parameter. the filter can use global $post and
</p>
<pre class="wiki">$post_type = get_post_type ( $post-&gt;ID );
</pre><p>
Hope that help to review.
</p>
Ticketchriscct7Sat, 25 Oct 2014 22:13:43 GMTkeywords sethttps://core.trac.wordpress.org/ticket/18979#comment:3
https://core.trac.wordpress.org/ticket/18979#comment:3
<ul>
<li><strong>keywords</strong>
<em>needs-refresh</em> added
</li>
</ul>
Ticketchriscct7Tue, 28 Jul 2015 18:12:36 GMTstatus, component changed; focuses, resolution set; milestone, keywords deletedhttps://core.trac.wordpress.org/ticket/18979#comment:4
https://core.trac.wordpress.org/ticket/18979#comment:4
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>focuses</strong>
<em>performance</em> added
</li>
<li><strong>component</strong>
changed from <em>Editor</em> to <em>Administration</em>
</li>
<li><strong>milestone</strong>
<em>Awaiting Review</em> deleted
</li>
<li><strong>keywords</strong>
<em>needs-refresh</em> removed
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
</ul>
<p>
Duplicate of <a class="closed ticket" href="https://core.trac.wordpress.org/ticket/24498" title="enhancement: Improving performance of meta_form() (closed: fixed)">#24498</a>.
</p>
Ticket