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;
// Exit if no meta
if (!$meta) return;
$count = 0;
?>
<table id='meta-list' cellpadding="3">
<tr>
@ -269,9 +270,12 @@ function list_meta($meta) {
<?php
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 "
<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><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>
@ -326,11 +330,11 @@ function meta_form() {
<?php endif; ?>
</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>
</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
}
@ -801,29 +805,30 @@ function get_real_file_to_edit($file) {
return $real_file;
}
$wp_file_descriptions = array('index.php' => __('Main Template'),
'wp-layout.css' => __('Stylesheet'),
'style.css' => __('Stylesheet'),
'wp-comments.php' => __('Comments Template'),
'comments.php' => __('Comments Template'),
'wp-comments-popup.php' => __('Popup Comments Template'),
'comments-popup.php' => __('Popup Comments Template'),
'wp-footer.php' => __('Footer Template'),
'footer.php' => __('Footer Template'),
'wp-header.php' => __('Header Template'),
'header.php' => __('Header Template'),
'wp-sidebar.php' => __('Sidebar Template'),
'sidebar.php' => __('Sidebar Template'),
'archive.php' => __('Archive Template'),
'category.php' => __('Category Template'),
'page.php' => __('Page Template'),
'search.php' => __('Search Template'),
'single.php' => __('Post Template'),
'404.php' => __('404 Template'),
'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
'.htaccess' => __('.htaccess (for rewrite rules)')
);
$wp_file_descriptions =
array(
'index.php' => __('Main Template'),
'wp-layout.css' => __('Stylesheet'),
'style.css' => __('Stylesheet'),
'wp-comments.php' => __('Comments Template'),
'comments.php' => __('Comments Template'),
'wp-comments-popup.php' => __('Popup Comments Template'),
'comments-popup.php' => __('Popup Comments Template'),
'wp-footer.php' => __('Footer Template'),
'footer.php' => __('Footer Template'),
'wp-header.php' => __('Header Template'),
'header.php' => __('Header Template'),
'wp-sidebar.php' => __('Sidebar Template'),
'sidebar.php' => __('Sidebar Template'),
'archive.php' => __('Archive Template'),
'category.php' => __('Category Template'),
'page.php' => __('Page Template'),
'search.php' => __('Search Template'),
'single.php' => __('Post Template'),
'404.php' => __('404 Template'),
'my-hacks.php' => __('my-hacks.php (legacy hacks support)'),
'.htaccess' => __('.htaccess (for rewrite rules)')
);
function get_file_description($file) {
global $wp_file_descriptions;

View File

@ -8,16 +8,34 @@
<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'); ?>" />
<?php if ( isset($xfn) ) : ?>
<script type="text/javascript">
//<![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) {
var allElements = document.getElementsByTagName(elementName);
var elemColl = new Array();
for (i = 0; i < allElements.length; i++) {
if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i];
}
if (allElements[i].className == className) {
elemColl[elemColl.length] = allElements[i];
}
}
return elemColl;
}
@ -57,9 +75,10 @@ function blurry() {
}
window.onload = blurry;
<?php endif; ?>
//]]>
</script>
<?php endif; ?>
<?php do_action('admin_head', ''); ?>
</head>

View File

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

View File

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