Make WordPress Core


Ignore:
Timestamp:
04/28/2004 02:23:46 AM (22 years ago)
Author:
saxmatt
Message:

How the custom fields should look.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r1143 r1195  
    217217        global $post_ID;       
    218218        // Exit if no meta
    219         if (!$meta) return;
    220 
    221        
    222         print "
    223         <table id='meta-list'>
    224                 <tr>
    225                         <th>Key</th>
    226                         <th>Value</th>
    227                         <th>&nbsp</th>
    228                 </tr>\n";
     219        if (!$meta) return;     
     220?>
     221<table id='meta-list' width='98%'>
     222        <tr>
     223                <th><?php _e('Key') ?></th>
     224                <th><?php _e('Value') ?></th>
     225                <th colspan='2'><?php _e('Action') ?></th>
     226        </tr>
     227<?php
    229228               
    230229        foreach ($meta as $entry) {
    231                 // TBD: Still need to add edit/del logic...
    232                 print "
    233                 <tr>
    234                         <td>{$entry['meta_key']}</td>
    235                         <td>{$entry['meta_value']}</td>
    236                         <td><a href=\"?action=deletemeta&amp;meta_id={$entry['meta_id']}&amp;post={$entry['post_id']}\">Delete</a></td>
    237                 </tr>\n";
    238         }
    239         print "
    240         </table>\n";
     230                $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
     231                echo "
     232        <tr $style>
     233                <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' value='{$entry['meta_key']}' /></td>
     234                <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='40'>{$entry['meta_value']}</textarea></td>
     235                <td align='center'><input name='updatemeta' type='submit' id='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
     236                <td align='center'><input name='deletemeta[{$entry['meta_id']}]' type='submit' id='deletemeta' tabindex='6' value='" . __('Delete') ."' /></td>
     237        </tr>
     238";
     239        }
     240        echo "
     241        </table>
     242";
    241243}
    242244
     
    257259        $keys = get_meta_keys();
    258260?>
    259 <h4><?php _e('Add new custom data to this post:') ?></h4>
    260 <div id="postcustomkeys">
    261 <p><?php _e('Select existing key or enter new key') ?></p>
    262 <?php
    263 if ($keys) {
    264 ?>
    265 <select id="metakeyselect" name="metakeyselect">
     261<h3><?php _e('Add new custom data to this post:') ?></h3>
     262<table width="100%" cellspacing="3" cellpadding="3">
     263        <tr>
     264<th colspan="2"><?php _e('Key') ?></th>
     265<th><?php _e('Value') ?></th>
     266<th></th>
     267</tr>
     268        <tr valign="top">
     269                <td align="right"><select id="metakeyselect" name="metakeyselect">
    266270<option value="#NONE#">- Select -</option>
    267271<?php
    268272        foreach($keys as $key) {
    269                 echo "<option value='$key'>$key</option>\n";
     273                echo "\n\t<option value='$key'>$key</option>";
    270274        }
    271275?>
    272 </select>
    273 <?php
    274 } // if ($keys)
    275 ?>
    276 <input type="text" id="metakeyinput" name="metakeyinput" />
    277 </div>
    278 <div id="postcustomvals">
    279 <p><?php _e('Custom Value') ?></p>
    280 
    281 <textarea id="metavalue" name="metavalue" rows="3" cols="25"></textarea>
    282 </div>
    283 <br style="clear: both;" />
    284 <div id="postcustomsubmit">
    285 <input type="submit" id="save" name="save" value="<?php _e('Add Custom') ?>">
    286 </div>
     276</select> or </td><td><input type="text" id="metakeyinput" name="metakeyinput" /></td>
     277                <td><textarea id="metavalue" name="metavalue" rows="3" cols="25"></textarea></td>
     278                <td></td>
     279        </tr>
     280
     281</table>
     282<p class="submit"><input type="submit" id="save" name="save" value="<?php _e('Add Custom Fields &raquo;') ?>"></p>
    287283<?php
    288284}
     
    291287        global $wpdb, $tablepostmeta;
    292288       
    293         $metakeyselect = trim($_POST['metakeyselect']);
    294         $metakeyinput = trim($_POST['metakeyinput']);
    295         $metavalue = trim($_POST['metavalue']);
     289        $metakeyselect = $wpdb->escape( stripslashes( trim($_POST['metakeyselect']) ) );
     290        $metakeyinput  = $wpdb->escape( stripslashes( trim($_POST['metakeyinput']) ) );
     291        $metavalue     = $wpdb->escape( stripslashes( trim($_POST['metavalue']) ) );
    296292
    297293        if (!empty($metavalue) && ((('#NONE#' != $metakeyselect) && !empty($metakeyselect)) || !empty($metakeyinput))) {
     
    315311function del_meta($mid) {
    316312        global $wpdb, $tablepostmeta;
    317        
     313
    318314        $result = $wpdb->query("DELETE FROM $tablepostmeta WHERE meta_id = '$mid'");
    319315}
Note: See TracChangeset for help on using the changeset viewer.