Make WordPress Core

Changeset 1195


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

How the custom fields should look.

Location:
trunk/wp-admin
Files:
3 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}
  • trunk/wp-admin/edit-form-advanced.php

    r1148 r1195  
    140140}
    141141?>
    142 <fieldset id="postcustom">
    143 <legend><?php _e('Post Custom') ?></legend>
    144 <?php
    145 if($metadata = has_meta($post_ID)) {
    146 ?>
    147 <?php
    148     list_meta($metadata);
    149 ?>
    150 <?php
    151 }
    152     meta_form();
    153 ?>
    154 </fieldset>
    155142
    156143<?php echo $form_pingback ?>
     
    180167    touch_time(($action == 'edit'));
    181168}
    182 if ('edit' == $action) echo "
    183 <p><a href='post.php?action=delete&amp;post=$post_ID' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), addslashes($edited_post_title)) . "')\">" .  __('Delete this post') . "</a></p>";
    184169?>
    185 
     170<fieldset id="postcustom">
     171<legend><?php _e('Custom Fields') ?></legend>
     172<?php
     173if($metadata = has_meta($post_ID)) {
     174?>
     175<?php
     176    list_meta($metadata);
     177?>
     178<?php
     179}
     180    meta_form();
     181?>
     182</fieldset>
    186183</div>
    187184</form>
    188 
     185<?php if ('edit' == $action) echo "
     186<p><a class='delete' href='post.php?action=delete&amp;post=$post_ID' onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), addslashes($edited_post_title)) . "')\">" .  __('Delete this post') . "</a></p>";
     187?>
    189188</div>
  • trunk/wp-admin/wp-admin.css

    r1194 r1195  
    330330    margin: 0.25em;
    331331    padding: 0.25em;
    332     width: 30em;
     332    width: 98%;
    333333}
    334334
     
    338338
    339339#postcustom table {
    340     background-color: #eee;
    341340    border: 1px solid #ccc;
    342     color: #000;
    343     margin-bottom: 1em;
    344     padding: 0px;
     341    margin: .5em;
    345342    width: 100%;
     343   
     344}
     345
     346#postcustom table input, #postcustom table textarea {
     347    width: 97%;
    346348}
    347349
    348350#postcustom td, #postcustom th {
    349351    color: #000;
    350     margin: 1px;
    351     padding: 0.2em;
    352 }
    353 
    354 #postcustomkeys {
    355     float: left;
    356     width: 49%;
    357 }
    358 
    359 #postcustomkeys input, #postcustom select, #postcustom textarea {
    360     width: 95%;
    361 }
     352    margin: 0.2em;
     353    padding: .3em;
     354}
     355
     356#postcustom #updatemeta, #postcustom #deletemeta {
     357    width: 90%;
     358    margin: auto;
     359}
     360
    362361fieldset legend a {
    363362    border-bottom: none;
Note: See TracChangeset for help on using the changeset viewer.