mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-18 04:25:07 +00:00
Custom fields: Allow for short-circuiting the meta key dropdown.
Adds the `postmeta_form_keys` filter which allows for a potentially expensive query against postmeta to be avoided. props ericmann, tollmanz, nacin. see #33885. Built from https://develop.svn.wordpress.org/trunk@35717 git-svn-id: http://core.svn.wordpress.org/trunk@35681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4341637ba6
commit
e549e56f02
@ -576,6 +576,19 @@ function meta_form( $post = null ) {
|
||||
global $wpdb;
|
||||
$post = get_post( $post );
|
||||
|
||||
/**
|
||||
* Filter values for the meta key dropdown in the Custom Fields meta box.
|
||||
*
|
||||
* Returning a non-null value will effectively short-circuit and avoid a
|
||||
* potentially expensive query against postmeta.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
|
||||
*/
|
||||
$keys = apply_filters( 'postmeta_form_keys', null );
|
||||
|
||||
if ( null === $keys ) {
|
||||
/**
|
||||
* Filter the number of custom fields to retrieve for the drop-down
|
||||
* in the Custom Fields meta box.
|
||||
@ -592,6 +605,8 @@ function meta_form( $post = null ) {
|
||||
ORDER BY meta_key
|
||||
LIMIT %d";
|
||||
$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
|
||||
}
|
||||
|
||||
if ( $keys ) {
|
||||
natcasesort( $keys );
|
||||
$meta_key_input_id = 'metakeyselect';
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-beta4-35716';
|
||||
$wp_version = '4.4-beta4-35717';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user