Support for hidden custom fields (custom fields that start with _)

git-svn-id: http://svn.automattic.com/wordpress/trunk@1935 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-12-09 04:12:20 +00:00
parent d8eca12969
commit 5ba63ff4d5
4 changed files with 62 additions and 34 deletions

View File

@ -259,6 +259,7 @@ function list_meta($meta) {
global $post_ID; global $post_ID;
// Exit if no meta // Exit if no meta
if (!$meta) return; if (!$meta) return;
$count = 0;
?> ?>
<table id='meta-list' cellpadding="3"> <table id='meta-list' cellpadding="3">
<tr> <tr>
@ -269,9 +270,12 @@ function list_meta($meta) {
<?php <?php
foreach ($meta as $entry) { foreach ($meta as $entry) {
$style = ('class="alternate"' == $style) ? '' : 'class="alternate"'; ++$count;
if ( $count % 2 ) $style = 'alternate';
else $style = '';
if ( '_' == $entry['meta_key']{0} ) $style .= ' hidden';
echo " echo "
<tr $style> <tr class='$style'>
<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>
<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>
<td align='center' width='10%'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='" . __('Update') ."' /></td> <td align='center' width='10%'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
@ -326,11 +330,11 @@ function meta_form() {
<?php endif; ?> <?php endif; ?>
</td> </td>
<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td> <td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
<td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="7"></textarea></td> <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
</tr> </tr>
</table> </table>
<p class="submit"><input type="submit" name="updatemeta" tabindex="7" value="<?php _e('Add Custom Field &raquo;') ?>" /></p> <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
<?php <?php
} }
@ -801,7 +805,9 @@ function get_real_file_to_edit($file) {
return $real_file; return $real_file;
} }
$wp_file_descriptions = array('index.php' => __('Main Template'), $wp_file_descriptions =
array(
'index.php' => __('Main Template'),
'wp-layout.css' => __('Stylesheet'), 'wp-layout.css' => __('Stylesheet'),
'style.css' => __('Stylesheet'), 'style.css' => __('Stylesheet'),
'wp-comments.php' => __('Comments Template'), 'wp-comments.php' => __('Comments Template'),
@ -821,7 +827,6 @@ $wp_file_descriptions = array('index.php' => __('Main Template'),
'single.php' => __('Post Template'), 'single.php' => __('Post Template'),
'404.php' => __('404 Template'), '404.php' => __('404 Template'),
'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
'.htaccess' => __('.htaccess (for rewrite rules)') '.htaccess' => __('.htaccess (for rewrite rules)')
); );

View File

@ -8,9 +8,27 @@
<link rel="shortcut icon" href="../wp-images/wp-favicon.png" /> <link rel="shortcut icon" href="../wp-images/wp-favicon.png" />
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_settings('blog_charset'); ?>" />
<?php if ( isset($xfn) ) : ?>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
function customToggleLink() {
// TODO: Only show link if there's a hidden row
document.write('<small>(<a href="javascript:;" id="customtoggle" onclick="toggleHidden()"><?php _e('Show hidden'); ?></a>)</small>');
// TODO: Rotate link to say "show" or "hide"
// TODO: Use DOM
}
function toggleHidden() {
var allElements = document.getElementsByTagName('tr');
for (i = 0; i < allElements.length; i++) {
if ( allElements[i].className.indexOf('hidden') != -1 ) {
allElements[i].className = allElements[i].className.replace('hidden', '');
}
}
}
<?php if ( isset($xfn) ) : ?>
function GetElementsWithClassName(elementName, className) { function GetElementsWithClassName(elementName, className) {
var allElements = document.getElementsByTagName(elementName); var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array(); var elemColl = new Array();
@ -57,9 +75,10 @@ function blurry() {
} }
window.onload = blurry; window.onload = blurry;
<?php endif; ?>
//]]> //]]>
</script> </script>
<?php endif; ?>
<?php do_action('admin_head', ''); ?> <?php do_action('admin_head', ''); ?>
</head> </head>

View File

@ -122,7 +122,7 @@ edCanvas = document.getElementById('content');
</fieldset> </fieldset>
<fieldset id="postcustom"> <fieldset id="postcustom">
<legend><?php _e('Custom Fields') ?></legend> <legend><?php _e('Custom Fields') ?> <script type="text/javascript">customToggleLink();</script></legend>
<div id="postcustomstuff"> <div id="postcustomstuff">
<?php <?php
if($metadata = has_meta($post_ID)) { if($metadata = has_meta($post_ID)) {

View File

@ -153,6 +153,10 @@ textarea, input, select {
padding: 1px; padding: 1px;
} }
.hidden {
display: none;
}
.post-categories { .post-categories {
display: inline; display: inline;
margin: 0; margin: 0;