Make WordPress Core

Ticket #3237: post_meta_form_limit.diff

File post_meta_form_limit.diff, 1.1 KB (added by markjaquith, 17 years ago)

Move limit to 30, add filter, natcasesort()

  • wp-admin/admin-functions.php

     
    10241024
    10251025function meta_form() {
    10261026        global $wpdb;
     1027        $limit = (int) apply_filters('postmeta_form_limit', 30);
    10271028        $keys = $wpdb->get_col("
    1028                         SELECT meta_key
    1029                         FROM $wpdb->postmeta
    1030                         GROUP BY meta_key
    1031                         ORDER BY meta_id DESC
    1032                         LIMIT 10");
     1029                SELECT meta_key
     1030                FROM $wpdb->postmeta
     1031                GROUP BY meta_key
     1032                ORDER BY meta_id DESC
     1033                LIMIT $limit");
     1034        natcasesort($keys);
    10331035?>
    10341036<h3><?php _e('Add a new custom field:') ?></h3>
    10351037<table id="newmeta" cellspacing="3" cellpadding="3">
     
    10391041</tr>
    10401042        <tr valign="top">
    10411043                <td align="right" width="18%">
    1042 <?php if ($keys) : ?>
     1044<?php if ( $keys ) : ?>
    10431045<select id="metakeyselect" name="metakeyselect" tabindex="7">
    10441046<option value="#NONE#"><?php _e('- Select -'); ?></option>
    10451047<?php
    10461048
    1047         foreach ($keys as $key) {
     1049        foreach ( $keys as $key ) {
    10481050                $key = wp_specialchars($key, 1);
    10491051                echo "\n\t<option value='$key'>$key</option>";
    10501052        }