Make WordPress Core

Ticket #33296: 33296.patch

File 33296.patch, 1.3 KB (added by kitchin, 8 years ago)
  • src/wp-admin/includes/template.php

     
    671671        /**
    672672         * Filter the number of custom fields to retrieve for the drop-down
    673673         * in the Custom Fields meta box.
     674         * If zero, no fields are retrieved, skipping the query.
    674675         *
    675676         * @since 2.1.0
    676677         *
    677678         * @param int $limit Number of custom fields to retrieve. Default 30.
     679         * @param int $post_id The post ID.
    678680         */
    679         $limit = apply_filters( 'postmeta_form_limit', 30 );
    680         $sql = "SELECT DISTINCT meta_key
    681                 FROM $wpdb->postmeta
    682                 WHERE meta_key NOT BETWEEN '_' AND '_z'
    683                 HAVING meta_key NOT LIKE %s
    684                 ORDER BY meta_key
    685                 LIMIT %d";
    686         $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
     681        $limit = apply_filters( 'postmeta_form_limit', 30, $post->ID );
     682        $keys = array();
     683        if ( $limit > 0 ) {
     684                $sql = "SELECT DISTINCT meta_key
     685                        FROM $wpdb->postmeta
     686                        WHERE meta_key NOT BETWEEN '_' AND '_z'
     687                        HAVING meta_key NOT LIKE %s
     688                        ORDER BY meta_key
     689                        LIMIT %d";
     690                $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
     691        }
    687692        if ( $keys ) {
    688693                natcasesort( $keys );
    689694                $meta_key_input_id = 'metakeyselect';