Changeset 35717
- Timestamp:
- 11/20/2015 06:15:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/template-functions.php
r35484 r35717 578 578 579 579 /** 580 * Filter the number of custom fields to retrieve for the drop-down 581 * in the Custom Fields meta box. 580 * Filter values for the meta key dropdown in the Custom Fields meta box. 582 581 * 583 * @since 2.1.0 582 * Returning a non-null value will effectively short-circuit and avoid a 583 * potentially expensive query against postmeta. 584 584 * 585 * @param int $limit Number of custom fields to retrieve. Default 30. 585 * @since 4.4.0 586 * 587 * @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null. 586 588 */ 587 $limit = apply_filters( 'postmeta_form_limit', 30 ); 588 $sql = "SELECT DISTINCT meta_key 589 FROM $wpdb->postmeta 590 WHERE meta_key NOT BETWEEN '_' AND '_z' 591 HAVING meta_key NOT LIKE %s 592 ORDER BY meta_key 593 LIMIT %d"; 594 $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); 589 $keys = apply_filters( 'postmeta_form_keys', null ); 590 591 if ( null === $keys ) { 592 /** 593 * Filter the number of custom fields to retrieve for the drop-down 594 * in the Custom Fields meta box. 595 * 596 * @since 2.1.0 597 * 598 * @param int $limit Number of custom fields to retrieve. Default 30. 599 */ 600 $limit = apply_filters( 'postmeta_form_limit', 30 ); 601 $sql = "SELECT DISTINCT meta_key 602 FROM $wpdb->postmeta 603 WHERE meta_key NOT BETWEEN '_' AND '_z' 604 HAVING meta_key NOT LIKE %s 605 ORDER BY meta_key 606 LIMIT %d"; 607 $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); 608 } 609 595 610 if ( $keys ) { 596 611 natcasesort( $keys );
Note: See TracChangeset
for help on using the changeset viewer.