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

@ -258,7 +258,8 @@ function has_meta($postid) {
function list_meta($meta) { 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,29 +805,30 @@ function get_real_file_to_edit($file) {
return $real_file; return $real_file;
} }
$wp_file_descriptions = array('index.php' => __('Main Template'), $wp_file_descriptions =
'wp-layout.css' => __('Stylesheet'), array(
'style.css' => __('Stylesheet'), 'index.php' => __('Main Template'),
'wp-comments.php' => __('Comments Template'), 'wp-layout.css' => __('Stylesheet'),
'comments.php' => __('Comments Template'), 'style.css' => __('Stylesheet'),
'wp-comments-popup.php' => __('Popup Comments Template'), 'wp-comments.php' => __('Comments Template'),
'comments-popup.php' => __('Popup Comments Template'), 'comments.php' => __('Comments Template'),
'wp-footer.php' => __('Footer Template'), 'wp-comments-popup.php' => __('Popup Comments Template'),
'footer.php' => __('Footer Template'), 'comments-popup.php' => __('Popup Comments Template'),
'wp-header.php' => __('Header Template'), 'wp-footer.php' => __('Footer Template'),
'header.php' => __('Header Template'), 'footer.php' => __('Footer Template'),
'wp-sidebar.php' => __('Sidebar Template'), 'wp-header.php' => __('Header Template'),
'sidebar.php' => __('Sidebar Template'), 'header.php' => __('Header Template'),
'archive.php' => __('Archive Template'), 'wp-sidebar.php' => __('Sidebar Template'),
'category.php' => __('Category Template'), 'sidebar.php' => __('Sidebar Template'),
'page.php' => __('Page Template'), 'archive.php' => __('Archive Template'),
'search.php' => __('Search Template'), 'category.php' => __('Category Template'),
'single.php' => __('Post Template'), 'page.php' => __('Page Template'),
'404.php' => __('404 Template'), 'search.php' => __('Search Template'),
'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), 'single.php' => __('Post Template'),
'404.php' => __('404 Template'),
'.htaccess' => __('.htaccess (for rewrite rules)') 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
); '.htaccess' => __('.htaccess (for rewrite rules)')
);
function get_file_description($file) { function get_file_description($file) {
global $wp_file_descriptions; global $wp_file_descriptions;

View File

@ -8,16 +8,34 @@
<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();
for (i = 0; i < allElements.length; i++) { for (i = 0; i < allElements.length; i++) {
if (allElements[i].className == className) { if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i]; elemColl[elemColl.length] = allElements[i];
} }
} }
return elemColl; return elemColl;
} }
@ -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;