Opened 3 years ago
Last modified 2 months ago
#54339 new defect (bug)
unique $keys array when add custom key from Several places with postmeta_form_keys
Reported by: | myousefi08 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8.1 |
Component: | Options, Meta APIs | Keywords: | reporter-feedback |
Focuses: | administration | Cc: |
Description
I added two similar custom key from my theme and a plugin with postmeta_form_keys filter.
but now display both of theme in custom-fields name's select box (custom-fields metabox - post.php or post-new.php)
I think is better to unique $keys before options are printed.
wp-admin/includes/template.php
line ~730
before:
foreach ( $keys as $key ) {
after:
$keys = array_unique($keys);
foreach ( $keys as $key ) {
Change History (1)
Note: See
TracTickets for help on using
tickets.
Hi @myousefi08 and welcome to Trac!
My apologies that it took so long to receive a response.
To make sure I understand the report. You're saying you have a filter in both your plugin and theme that adds two identical meta keys to the list of keys to display using
postmeta_form_keys
?If that's the case, that should not result in duplicates. They should be filtered out since the meta query performed includes
DISTINCT
. If this is what you're seeing, could you please provide some more details and maybe a code snippet that another contributor could use to reproduce the problem?I'm marking as this a
close
candidate with aworksforme
resolution because I've been unable to reproduce the report as I understand it.