| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { |
|---|
| 9 |
if ( !$categories ) |
|---|
| 10 |
$categories = get_categories( 'hide_empty=0' ); |
|---|
| 11 |
|
|---|
| 12 |
$children = _get_term_hierarchy('category'); |
|---|
| 13 |
|
|---|
| 14 |
if ( $categories ) { |
|---|
| 15 |
ob_start(); |
|---|
| 16 |
foreach ( $categories as $category ) { |
|---|
| 17 |
if ( $category->parent == $parent) { |
|---|
| 18 |
echo "\t" . _cat_row( $category, $level ); |
|---|
| 19 |
if ( isset($children[$category->term_id]) ) |
|---|
| 20 |
cat_rows( $category->term_id, $level +1, $categories ); |
|---|
| 21 |
} |
|---|
| 22 |
} |
|---|
| 23 |
$output = ob_get_contents(); |
|---|
| 24 |
ob_end_clean(); |
|---|
| 25 |
|
|---|
| 26 |
$output = apply_filters('cat_rows', $output); |
|---|
| 27 |
|
|---|
| 28 |
echo $output; |
|---|
| 29 |
} else { |
|---|
| 30 |
return false; |
|---|
| 31 |
} |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
function _cat_row( $category, $level, $name_override = false ) { |
|---|
| 35 |
global $class; |
|---|
| 36 |
|
|---|
| 37 |
$pad = str_repeat( '— ', $level ); |
|---|
| 38 |
if ( current_user_can( 'manage_categories' ) ) { |
|---|
| 39 |
$edit = "<a href='categories.php?action=edit&cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; |
|---|
| 40 |
$default_cat_id = (int) get_option( 'default_category' ); |
|---|
| 41 |
$default_link_cat_id = (int) get_option( 'default_link_category' ); |
|---|
| 42 |
|
|---|
| 43 |
if ( $category->term_id != $default_cat_id ) |
|---|
| 44 |
$edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' onclick=\"return deleteSomething( 'cat', $category->term_id, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll posts that were only assigned to this category will be assigned to the '%s' category.\nAll links that were only assigned to this category will be assigned to the '%s' category.\n'OK' to delete, 'Cancel' to stop." ), $category->name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>"; |
|---|
| 45 |
else |
|---|
| 46 |
$edit .= "<td style='text-align:center'>".__( "Default" ); |
|---|
| 47 |
} else |
|---|
| 48 |
$edit = ''; |
|---|
| 49 |
|
|---|
| 50 |
$class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; |
|---|
| 51 |
|
|---|
| 52 |
$category->count = number_format_i18n( $category->count ); |
|---|
| 53 |
$posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count; |
|---|
| 54 |
$output = "<tr id='cat-$category->term_id'$class> |
|---|
| 55 |
<th scope='row' style='text-align: center'>$category->term_id</th> |
|---|
| 56 |
<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td> |
|---|
| 57 |
<td>$category->description</td> |
|---|
| 58 |
<td align='center'>$posts_count</td> |
|---|
| 59 |
<td>$edit</td>\n\t</tr>\n"; |
|---|
| 60 |
|
|---|
| 61 |
return apply_filters('cat_row', $output); |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
function checked( $checked, $current) { |
|---|
| 65 |
if ( $checked == $current) |
|---|
| 66 |
echo ' checked="checked"'; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
function documentation_link( $for ) { |
|---|
| 71 |
return; |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
function selected( $selected, $current) { |
|---|
| 75 |
if ( $selected == $current) |
|---|
| 76 |
echo ' selected="selected"'; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
function sort_cats( $cat1, $cat2 ) { |
|---|
| 84 |
if ( $cat1['checked'] || $cat2['checked'] ) |
|---|
| 85 |
return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1; |
|---|
| 86 |
else |
|---|
| 87 |
return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] ); |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
function get_nested_categories( $default = 0, $parent = 0 ) { |
|---|
| 91 |
global $post_ID, $mode, $wpdb, $checked_categories; |
|---|
| 92 |
|
|---|
| 93 |
if ( empty($checked_categories) ) { |
|---|
| 94 |
if ( $post_ID ) { |
|---|
| 95 |
$checked_categories = wp_get_post_categories($post_ID); |
|---|
| 96 |
|
|---|
| 97 |
if ( count( $checked_categories ) == 0 ) { |
|---|
| 98 |
|
|---|
| 99 |
$checked_categories[] = $default; |
|---|
| 100 |
} |
|---|
| 101 |
} else { |
|---|
| 102 |
$checked_categories[] = $default; |
|---|
| 103 |
} |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
$cats = get_categories("parent=$parent&hide_empty=0&fields=ids"); |
|---|
| 107 |
|
|---|
| 108 |
$result = array (); |
|---|
| 109 |
if ( is_array( $cats ) ) { |
|---|
| 110 |
foreach ( $cats as $cat) { |
|---|
| 111 |
$result[$cat]['children'] = get_nested_categories( $default, $cat); |
|---|
| 112 |
$result[$cat]['cat_ID'] = $cat; |
|---|
| 113 |
$result[$cat]['checked'] = in_array( $cat, $checked_categories ); |
|---|
| 114 |
$result[$cat]['cat_name'] = get_the_category_by_ID( $cat); |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
$result = apply_filters('get_nested_categories', $result); |
|---|
| 119 |
usort( $result, 'sort_cats' ); |
|---|
| 120 |
|
|---|
| 121 |
return $result; |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
function write_nested_categories( $categories ) { |
|---|
| 125 |
foreach ( $categories as $category ) { |
|---|
| 126 |
echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : "" ), '/> ', wp_specialchars( apply_filters('the_category', $category['cat_name'] )), "</label></li>"; |
|---|
| 127 |
|
|---|
| 128 |
if ( $category['children'] ) { |
|---|
| 129 |
echo "<ul>\n"; |
|---|
| 130 |
write_nested_categories( $category['children'] ); |
|---|
| 131 |
echo "</ul>\n"; |
|---|
| 132 |
} |
|---|
| 133 |
} |
|---|
| 134 |
} |
|---|
| 135 |
|
|---|
| 136 |
function dropdown_categories( $default = 0 ) { |
|---|
| 137 |
write_nested_categories( get_nested_categories( $default) ); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
function dropdown_link_categories( $default = 0 ) { |
|---|
| 141 |
global $link_id; |
|---|
| 142 |
|
|---|
| 143 |
if ( $link_id ) { |
|---|
| 144 |
$checked_categories = wp_get_link_cats($link_id); |
|---|
| 145 |
|
|---|
| 146 |
if ( count( $checked_categories ) == 0 ) { |
|---|
| 147 |
|
|---|
| 148 |
$checked_categories[] = $default; |
|---|
| 149 |
} |
|---|
| 150 |
} else { |
|---|
| 151 |
$checked_categories[] = $default; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
$categories = get_terms('link_category', 'orderby=count&hide_empty=0'); |
|---|
| 155 |
|
|---|
| 156 |
if ( empty($categories) ) |
|---|
| 157 |
return; |
|---|
| 158 |
|
|---|
| 159 |
foreach ( $categories as $category ) { |
|---|
| 160 |
$cat_id = $category->term_id; |
|---|
| 161 |
$name = wp_specialchars( apply_filters('the_category', $category->name)); |
|---|
| 162 |
$checked = in_array( $cat_id, $checked_categories ); |
|---|
| 163 |
echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>"; |
|---|
| 164 |
} |
|---|
| 165 |
} |
|---|
| 166 |
|
|---|
| 167 |
function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { |
|---|
| 168 |
global $wpdb, $class, $post; |
|---|
| 169 |
|
|---|
| 170 |
if (!$pages ) |
|---|
| 171 |
$pages = get_pages( 'sort_column=menu_order' ); |
|---|
| 172 |
|
|---|
| 173 |
if (! $pages ) |
|---|
| 174 |
return false; |
|---|
| 175 |
|
|---|
| 176 |
foreach ( $pages as $post) { |
|---|
| 177 |
setup_postdata( $post); |
|---|
| 178 |
if ( $hierarchy && ($post->post_parent != $parent) ) |
|---|
| 179 |
continue; |
|---|
| 180 |
|
|---|
| 181 |
$post->post_title = wp_specialchars( $post->post_title ); |
|---|
| 182 |
$pad = str_repeat( '— ', $level ); |
|---|
| 183 |
$id = (int) $post->ID; |
|---|
| 184 |
$class = ('alternate' == $class ) ? '' : 'alternate'; |
|---|
| 185 |
?> |
|---|
| 186 |
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'> |
|---|
| 187 |
<th scope="row" style="text-align: center"><?php echo $post->ID; ?></th> |
|---|
| 188 |
<td> |
|---|
| 189 |
<?php echo $pad; ?><?php the_title() ?> |
|---|
| 190 |
</td> |
|---|
| 191 |
<td><?php the_author() ?></td> |
|---|
| 192 |
<td><?php if ( '0000-00-00 00:00:00' ==$post->post_modified ) _e('Unpublished'); else echo mysql2date( __('Y-m-d g:i a'), $post->post_modified ); ?></td> |
|---|
| 193 |
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e( 'View' ); ?></a></td> |
|---|
| 194 |
<td><?php if ( current_user_can( 'edit_page', $id ) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __( 'Edit' ) . "</a>"; } ?></td> |
|---|
| 195 |
<td><?php if ( current_user_can( 'delete_page', $id ) ) { echo "<a href='" . wp_nonce_url( "page.php?action=delete&post=$id", 'delete-page_' . $id ) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . js_escape(sprintf( __("You are about to delete the '%s' page.\n'OK' to delete, 'Cancel' to stop." ), get_the_title() ) ) . "' );\">" . __( 'Delete' ) . "</a>"; } ?></td> |
|---|
| 196 |
</tr> |
|---|
| 197 |
|
|---|
| 198 |
<?php |
|---|
| 199 |
if ( $hierarchy ) page_rows( $id, $level + 1, $pages ); |
|---|
| 200 |
} |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
function user_row( $user_object, $style = '' ) { |
|---|
| 204 |
global $current_user; |
|---|
| 205 |
|
|---|
| 206 |
if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) ) |
|---|
| 207 |
$user_object = new WP_User( (int) $user_object ); |
|---|
| 208 |
$email = $user_object->user_email; |
|---|
| 209 |
$url = $user_object->user_url; |
|---|
| 210 |
$short_url = str_replace( 'http://', '', $url ); |
|---|
| 211 |
$short_url = str_replace( 'www.', '', $short_url ); |
|---|
| 212 |
if ('/' == substr( $short_url, -1 )) |
|---|
| 213 |
$short_url = substr( $short_url, 0, -1 ); |
|---|
| 214 |
if ( strlen( $short_url ) > 35 ) |
|---|
| 215 |
$short_url = substr( $short_url, 0, 32 ).'...'; |
|---|
| 216 |
$numposts = get_usernumposts( $user_object->ID ); |
|---|
| 217 |
$r = "<tr id='user-$user_object->ID'$style> |
|---|
| 218 |
<td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td> |
|---|
| 219 |
<td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> |
|---|
| 220 |
<td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> |
|---|
| 221 |
<td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td> |
|---|
| 222 |
<td><a href='$url' title='website: $url'>$short_url</a></td>"; |
|---|
| 223 |
$r .= "\n\t\t<td align='center'>"; |
|---|
| 224 |
if ( $numposts > 0 ) { |
|---|
| 225 |
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; |
|---|
| 226 |
$r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts); |
|---|
| 227 |
$r .= '</a>'; |
|---|
| 228 |
} |
|---|
| 229 |
$r .= "</td>\n\t\t<td>"; |
|---|
| 230 |
if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can( 'edit_user', $user_object->ID ) ) { |
|---|
| 231 |
$edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ); |
|---|
| 232 |
$r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>"; |
|---|
| 233 |
} |
|---|
| 234 |
$r .= "</td>\n\t</tr>"; |
|---|
| 235 |
return $r; |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
function _wp_get_comment_list( $s = false, $start, $num ) { |
|---|
| 239 |
global $wpdb; |
|---|
| 240 |
|
|---|
| 241 |
$start = abs( (int) $start ); |
|---|
| 242 |
$num = (int) $num; |
|---|
| 243 |
|
|---|
| 244 |
if ( $s ) { |
|---|
| 245 |
$s = $wpdb->escape($s); |
|---|
| 246 |
$comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE |
|---|
| 247 |
(comment_author LIKE '%$s%' OR |
|---|
| 248 |
comment_author_email LIKE '%$s%' OR |
|---|
| 249 |
comment_author_url LIKE ('%$s%') OR |
|---|
| 250 |
comment_author_IP LIKE ('%$s%') OR |
|---|
| 251 |
comment_content LIKE ('%$s%') ) AND |
|---|
| 252 |
comment_approved != 'spam' |
|---|
| 253 |
ORDER BY comment_date DESC LIMIT $start, $num"); |
|---|
| 254 |
} else { |
|---|
| 255 |
$comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE comment_approved = '0' OR comment_approved = '1' ORDER BY comment_date DESC LIMIT $start, $num" ); |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
update_comment_cache($comments); |
|---|
| 259 |
|
|---|
| 260 |
$total = $wpdb->get_var( "SELECT FOUND_ROWS()" ); |
|---|
| 261 |
|
|---|
| 262 |
return array($comments, $total); |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
function _wp_comment_list_item( $id, $alt = 0 ) { |
|---|
| 266 |
global $authordata, $comment, $wpdb; |
|---|
| 267 |
$id = (int) $id; |
|---|
| 268 |
$comment =& get_comment( $id ); |
|---|
| 269 |
$class = ''; |
|---|
| 270 |
$post = get_post($comment->comment_post_ID); |
|---|
| 271 |
$authordata = get_userdata($post->post_author); |
|---|
| 272 |
$comment_status = wp_get_comment_status($comment->comment_ID); |
|---|
| 273 |
if ( 'unapproved' == $comment_status ) |
|---|
| 274 |
$class .= ' unapproved'; |
|---|
| 275 |
if ( $alt % 2 ) |
|---|
| 276 |
$class .= ' alternate'; |
|---|
| 277 |
echo "<li id='comment-$comment->comment_ID' class='$class'>"; |
|---|
| 278 |
?> |
|---|
| 279 |
<p><strong><?php comment_author(); ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p> |
|---|
| 280 |
|
|---|
| 281 |
<?php comment_text() ?> |
|---|
| 282 |
|
|---|
| 283 |
<p><?php comment_date(__('M j, g:i A')); ?> — [ |
|---|
| 284 |
<?php |
|---|
| 285 |
if ( current_user_can('edit_post', $comment->comment_post_ID) ) { |
|---|
| 286 |
echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>'; |
|---|
| 287 |
echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . js_escape(sprintf(__("You are about to delete this comment by '%s'.\n'Cancel' to stop, 'OK' to delete."), $comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> '; |
|---|
| 288 |
if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) { |
|---|
| 289 |
echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>'; |
|---|
| 290 |
echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&p=' . $comment->comment_post_ID . '&c=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>'; |
|---|
| 291 |
} |
|---|
| 292 |
echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&dt=spam&p=" . $comment->comment_post_ID . "&c=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . js_escape(sprintf(__("You are about to mark as spam this comment by '%s'.\n'Cancel' to stop, 'OK' to mark as spam."), $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> "; |
|---|
| 293 |
} |
|---|
| 294 |
$post = get_post($comment->comment_post_ID, OBJECT, 'display'); |
|---|
| 295 |
$post_title = wp_specialchars( $post->post_title, 'double' ); |
|---|
| 296 |
$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title; |
|---|
| 297 |
?> |
|---|
| 298 |
] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p> |
|---|
| 299 |
</li> |
|---|
| 300 |
<?php |
|---|
| 301 |
} |
|---|
| 302 |
|
|---|
| 303 |
function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) { |
|---|
| 304 |
global $wpdb; |
|---|
| 305 |
if (!$categories ) |
|---|
| 306 |
$categories = get_categories( 'hide_empty=0' ); |
|---|
| 307 |
|
|---|
| 308 |
if ( $categories ) { |
|---|
| 309 |
foreach ( $categories as $category ) { |
|---|
| 310 |
if ( $currentcat != $category->term_id && $parent == $category->parent) { |
|---|
| 311 |
$pad = str_repeat( '– ', $level ); |
|---|
| 312 |
$category->name = wp_specialchars( $category->name ); |
|---|
| 313 |
echo "\n\t<option value='$category->term_id'"; |
|---|
| 314 |
if ( $currentparent == $category->term_id ) |
|---|
| 315 |
echo " selected='selected'"; |
|---|
| 316 |
echo ">$pad$category->name</option>"; |
|---|
| 317 |
wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories ); |
|---|
| 318 |
} |
|---|
| 319 |
} |
|---|
| 320 |
} else { |
|---|
| 321 |
return false; |
|---|
| 322 |
} |
|---|
| 323 |
} |
|---|
| 324 |
|
|---|
| 325 |
function list_meta( $meta ) { |
|---|
| 326 |
global $post_ID; |
|---|
| 327 |
|
|---|
| 328 |
if (!$meta ) { |
|---|
| 329 |
echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; |
|---|
| 330 |
return; |
|---|
| 331 |
} |
|---|
| 332 |
$count = 0; |
|---|
| 333 |
?> |
|---|
| 334 |
<thead> |
|---|
| 335 |
<tr> |
|---|
| 336 |
<th><?php _e( 'Key' ) ?></th> |
|---|
| 337 |
<th><?php _e( 'Value' ) ?></th> |
|---|
| 338 |
<th colspan='2'><?php _e( 'Action' ) ?></th> |
|---|
| 339 |
</tr> |
|---|
| 340 |
</thead> |
|---|
| 341 |
<?php |
|---|
| 342 |
$r ="\n\t<tbody id='the-list'>"; |
|---|
| 343 |
foreach ( $meta as $entry ) { |
|---|
| 344 |
++ $count; |
|---|
| 345 |
if ( $count % 2 ) |
|---|
| 346 |
$style = 'alternate'; |
|---|
| 347 |
else |
|---|
| 348 |
$style = ''; |
|---|
| 349 |
if ('_' == $entry['meta_key'] { 0 } ) |
|---|
| 350 |
$style .= ' hidden'; |
|---|
| 351 |
|
|---|
| 352 |
if ( is_serialized( $entry['meta_value'] ) ) { |
|---|
| 353 |
if ( is_serialized_string( $entry['meta_value'] ) ) { |
|---|
| 354 |
|
|---|
| 355 |
$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); |
|---|
| 356 |
} else { |
|---|
| 357 |
|
|---|
| 358 |
--$count; |
|---|
| 359 |
continue; |
|---|
| 360 |
} |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
$key_js = js_escape( $entry['meta_key'] ); |
|---|
| 364 |
$entry['meta_key'] = attribute_escape($entry['meta_key']); |
|---|
| 365 |
$entry['meta_value'] = attribute_escape($entry['meta_value']); |
|---|
| 366 |
$entry['meta_id'] = (int) $entry['meta_id']; |
|---|
| 367 |
$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; |
|---|
| 368 |
$r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; |
|---|
| 369 |
$r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; |
|---|
| 370 |
$r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />"; |
|---|
| 371 |
$r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; |
|---|
| 372 |
$r .= js_escape(sprintf( __("You are about to delete the '%s' custom field on this post.\n'OK' to delete, 'Cancel' to stop." ), $key_js ) ); |
|---|
| 373 |
$r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>"; |
|---|
| 374 |
$r .= "\n\t</tr>"; |
|---|
| 375 |
} |
|---|
| 376 |
echo $r; |
|---|
| 377 |
echo "\n\t</tbody>"; |
|---|
| 378 |
} |
|---|
| 379 |
|
|---|
| 380 |
function meta_form() { |
|---|
| 381 |
global $wpdb; |
|---|
| 382 |
$limit = (int) apply_filters( 'postmeta_form_limit', 30 ); |
|---|
| 383 |
$keys = $wpdb->get_col( " |
|---|
| 384 |
SELECT meta_key |
|---|
| 385 |
FROM $wpdb->postmeta |
|---|
| 386 |
WHERE meta_key NOT LIKE '\_%' |
|---|
| 387 |
GROUP BY meta_key |
|---|
| 388 |
ORDER BY meta_id DESC |
|---|
| 389 |
LIMIT $limit" ); |
|---|
| 390 |
if ( $keys ) |
|---|
| 391 |
natcasesort($keys); |
|---|
| 392 |
?> |
|---|
| 393 |
<h3><?php _e( 'Add a new custom field:' ) ?></h3> |
|---|
| 394 |
<table id="newmeta" cellspacing="3" cellpadding="3"> |
|---|
| 395 |
<tr> |
|---|
| 396 |
<th colspan="2"><?php _e( 'Key' ) ?></th> |
|---|
| 397 |
<th><?php _e( 'Value' ) ?></th> |
|---|
| 398 |
</tr> |
|---|
| 399 |
<tr valign="top"> |
|---|
| 400 |
<td align="right" width="18%"> |
|---|
| 401 |
<?php if ( $keys ) : ?> |
|---|
| 402 |
<select id="metakeyselect" name="metakeyselect" tabindex="7"> |
|---|
| 403 |
<option value="#NONE#"><?php _e( '- Select -' ); ?></option> |
|---|
| 404 |
<?php |
|---|
| 405 |
|
|---|
| 406 |
foreach ( $keys as $key ) { |
|---|
| 407 |
$key = attribute_escape( $key ); |
|---|
| 408 |
echo "\n\t<option value='$key'>$key</option>"; |
|---|
| 409 |
} |
|---|
| 410 |
?> |
|---|
| 411 |
</select> <?php _e( 'or' ); ?> |
|---|
| 412 |
<?php endif; ?> |
|---|
| 413 |
</td> |
|---|
| 414 |
<td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td> |
|---|
| 415 |
<td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td> |
|---|
| 416 |
</tr> |
|---|
| 417 |
|
|---|
| 418 |
</table> |
|---|
| 419 |
<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" /></p> |
|---|
| 420 |
<?php |
|---|
| 421 |
|
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) { |
|---|
| 425 |
global $wp_locale, $post, $comment; |
|---|
| 426 |
|
|---|
| 427 |
if ( $for_post ) |
|---|
| 428 |
$edit = ( in_array($post->post_status, array( |
|---|