7 // Dandy new recursive multiple category stuff.
8 function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
10 $categories = get_categories( 'hide_empty=0' );
12 $children = _get_term_hierarchy('category');
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 );
23 $output = ob_get_contents();
26 $output = apply_filters('cat_rows', $output);
34 function _cat_row( $category, $level, $name_override = false ) {
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' );
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>";
46 $edit .= "<td style='text-align:center'>".__( "Default" );
50 $class = ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
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";
61 return apply_filters('cat_row', $output);
64 function checked( $checked, $current) {
65 if ( $checked == $current)
66 echo ' checked="checked"';
70 function documentation_link( $for ) {
74 function selected( $selected, $current) {
75 if ( $selected == $current)
76 echo ' selected="selected"';
80 // Nasty Category Stuff
83 function sort_cats( $cat1, $cat2 ) {
84 if ( $cat1['checked'] || $cat2['checked'] )
85 return ( $cat1['checked'] && !$cat2['checked'] ) ? -1 : 1;
87 return strcasecmp( $cat1['cat_name'], $cat2['cat_name'] );
90 function get_nested_categories( $default = 0, $parent = 0 ) {
91 global $post_ID, $mode, $wpdb, $checked_categories;
93 if ( empty($checked_categories) ) {
95 $checked_categories = wp_get_post_categories($post_ID);
97 if ( count( $checked_categories ) == 0 ) {
98 // No selected categories, strange
99 $checked_categories[] = $default;
102 $checked_categories[] = $default;
106 $cats = get_categories("parent=$parent&hide_empty=0&fields=ids");
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);
118 $result = apply_filters('get_nested_categories', $result);
119 usort( $result, 'sort_cats' );
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>";
128 if ( $category['children'] ) {
130 write_nested_categories( $category['children'] );
136 function dropdown_categories( $default = 0 ) {
137 write_nested_categories( get_nested_categories( $default) );
140 function dropdown_link_categories( $default = 0 ) {
144 $checked_categories = wp_get_link_cats($link_id);
146 if ( count( $checked_categories ) == 0 ) {
147 // No selected categories, strange
148 $checked_categories[] = $default;
151 $checked_categories[] = $default;
154 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
156 if ( empty($categories) )
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>";
167 function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
168 global $wpdb, $class, $post;
171 $pages = get_pages( 'sort_column=menu_order' );
176 foreach ( $pages as $post) {
177 setup_postdata( $post);
178 if ( $hierarchy && ($post->post_parent != $parent) )
181 $post->post_title = wp_specialchars( $post->post_title );
182 $pad = str_repeat( '— ', $level );
183 $id = (int) $post->ID;
184 $class = ('alternate' == $class ) ? '' : 'alternate';
186 <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
187 <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
189 <?php echo $pad; ?><?php the_title() ?>
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>
199 if ( $hierarchy ) page_rows( $id, $level + 1, $pages );
203 function user_row( $user_object, $style = '' ) {
204 if ( !(is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
205 $user_object = new WP_User( (int) $user_object );
206 $email = $user_object->user_email;
207 $url = $user_object->user_url;
208 $short_url = str_replace( 'http://', '', $url );
209 $short_url = str_replace( 'www.', '', $short_url );
210 if ('/' == substr( $short_url, -1 ))
211 $short_url = substr( $short_url, 0, -1 );
212 if ( strlen( $short_url ) > 35 )
213 $short_url = substr( $short_url, 0, 32 ).'...';
214 $numposts = get_usernumposts( $user_object->ID );
215 $r = "<tr id='user-$user_object->ID'$style>
216 <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>
217 <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
218 <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
219 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>
220 <td><a href='$url' title='website: $url'>$short_url</a></td>";
221 $r .= "\n\t\t<td align='center'>";
222 if ( $numposts > 0 ) {
223 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
224 $r .= sprintf(__ngettext( 'View %s post', 'View %s posts', $numposts ), $numposts);
227 $r .= "</td>\n\t\t<td>";
228 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
229 $edit_link = add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
230 $r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
232 $r .= "</td>\n\t</tr>";
236 function _wp_get_comment_list( $s = false, $start, $num ) {
239 $start = abs( (int) $start );
243 $s = $wpdb->escape($s);
244 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
245 (comment_author LIKE '%$s%' OR
246 comment_author_email LIKE '%$s%' OR
247 comment_author_url LIKE ('%$s%') OR
248 comment_author_IP LIKE ('%$s%') OR
249 comment_content LIKE ('%$s%') ) AND
250 comment_approved != 'spam'
251 ORDER BY comment_date DESC LIMIT $start, $num");
253 $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 update_comment_cache($comments);
258 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
260 return array($comments, $total);
263 function _wp_comment_list_item( $id, $alt = 0 ) {
264 global $authordata, $comment, $wpdb;
266 $comment =& get_comment( $id );
268 $post = get_post($comment->comment_post_ID);
269 $authordata = get_userdata($post->post_author);
270 $comment_status = wp_get_comment_status($comment->comment_ID);
271 if ( 'unapproved' == $comment_status )
272 $class .= ' unapproved';
274 $class .= ' alternate';
275 echo "<li id='comment-$comment->comment_ID' class='$class'>";
277 <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>
279 <?php comment_text() ?>
281 <p><?php comment_date(__('M j, g:i A')); ?> — [
283 if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
284 echo " <a href='comment.php?action=editcomment&c=".$comment->comment_ID."'>" . __('Edit') . '</a>';
285 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> ';
286 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
287 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>';
288 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>';
290 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> ";
292 $post = get_post($comment->comment_post_ID, OBJECT, 'display');
293 $post_title = wp_specialchars( $post->post_title, 'double' );
294 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
296 ] — <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo $post_title; ?></a></p>
301 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
304 $categories = get_categories( 'hide_empty=0' );
307 foreach ( $categories as $category ) {
308 if ( $currentcat != $category->term_id && $parent == $category->parent) {
309 $pad = str_repeat( '– ', $level );
310 $category->name = wp_specialchars( $category->name );
311 echo "\n\t<option value='$category->term_id'";
312 if ( $currentparent == $category->term_id )
313 echo " selected='selected'";
314 echo ">$pad$category->name</option>";
315 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
323 function list_meta( $meta ) {
327 echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS
334 <th><?php _e( 'Key' ) ?></th>
335 <th><?php _e( 'Value' ) ?></th>
336 <th colspan='2'><?php _e( 'Action' ) ?></th>
340 $r ="\n\t<tbody id='the-list'>";
341 foreach ( $meta as $entry ) {
344 $style = 'alternate';
347 if ('_' == $entry['meta_key'] { 0 } )
350 if ( is_serialized( $entry['meta_value'] ) ) {
351 if ( is_serialized_string( $entry['meta_value'] ) ) {
352 // this is a serialized string, so we should display it
353 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
355 // this is a serialized array/object so we should NOT display it
361 $key_js = js_escape( $entry['meta_key'] );
362 $entry['meta_key'] = attribute_escape($entry['meta_key']);
363 $entry['meta_value'] = attribute_escape($entry['meta_value']);
364 $entry['meta_id'] = (int) $entry['meta_id'];
365 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
366 $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>";
367 $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
368 $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__( 'Update' ))."' /><br />";
369 $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
370 $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 ) );
371 $r .= "' );\" class='deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' /></td>";
378 function meta_form() {
380 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
381 $keys = $wpdb->get_col( "
384 WHERE meta_key NOT LIKE '\_%'
386 ORDER BY meta_id DESC
391 <h3><?php _e( 'Add a new custom field:' ) ?></h3>
392 <table id="newmeta" cellspacing="3" cellpadding="3">
394 <th colspan="2"><?php _e( 'Key' ) ?></th>
395 <th><?php _e( 'Value' ) ?></th>
398 <td align="right" width="18%">
399 <?php if ( $keys ) : ?>
400 <select id="metakeyselect" name="metakeyselect" tabindex="7">
401 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
404 foreach ( $keys as $key ) {
405 $key = attribute_escape( $key );
406 echo "\n\t<option value='$key'>$key</option>";
409 </select> <?php _e( 'or' ); ?>
412 <td><input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" /></td>
413 <td><textarea id="metavalue" name="metavalue" rows="3" cols="25" tabindex="8"></textarea></td>
417 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e( 'Add Custom Field »' ) ?>" /></p>
422 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0 ) {
423 global $wp_locale, $post, $comment;
426 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date ) ) ? false : true;
428 $tab_index_attribute = '';
429 if ( (int) $tab_index > 0 )
430 $tab_index_attribute = " tabindex=\"$tab_index\"";
432 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> <label for="timestamp">'.__( 'Edit timestamp' ).'</label></legend>';
434 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
435 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
436 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
437 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
438 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
439 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
440 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
441 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
443 echo "<select name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
444 for ( $i = 1; $i < 13; $i = $i +1 ) {
445 echo "\t\t\t<option value=\"$i\"";
447 echo ' selected="selected"';
448 echo '>' . $wp_locale->get_month( $i ) . "</option>\n";
452 <input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> />
453 <input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> @
454 <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> /> :
455 <input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true"<?php echo $tab_index_attribute ?> />
456 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
459 printf( _c( 'Existing timestamp: %1$s %2$s, %3$s @ %4$s:%5$s|1: month, 2: month string, 3: full year, 4: hours, 5: minutes' ), $wp_locale->get_month( $mm ), $jj, $aa, $hh, $mn );
467 function page_template_dropdown( $default = '' ) {
468 $templates = get_page_templates();
470 foreach (array_keys( $templates ) as $template )
471 : if ( $default == $templates[$template] )
472 $selected = " selected='selected'";
475 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
479 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
480 global $wpdb, $post_ID;
481 $items = $wpdb->get_results( "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order" );
484 foreach ( $items as $item ) {
485 // A page cannot be its own parent.
486 if (!empty ( $post_ID ) ) {
487 if ( $item->ID == $post_ID ) {
491 $pad = str_repeat( ' ', $level * 3 );
492 if ( $item->ID == $default)
493 $current = ' selected="selected"';
497 echo "\n\t<option value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
498 parent_dropdown( $default, $item->ID, $level +1 );
505 function browse_happy() {
506 $getit = __( 'WordPress recommends a better browser' );
508 <p id="bh" style="text-align: center;"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></p>
512 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
513 add_action( 'admin_footer', 'browse_happy' );
515 function the_attachment_links( $id = false ) {
517 $post = & get_post( $id );
519 if ( $post->post_type != 'attachment' )
522 $icon = get_attachment_icon( $post->ID );
523 $attachment_data = wp_get_attachment_metadata( $id );
524 $thumb = isset( $attachment_data['thumb'] );
526 <form id="the-attachment-links">
529 <col class="widefat" />
531 <th scope="row"><?php _e( 'URL' ) ?></th>
532 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
534 <?php if ( $icon ) : ?>
536 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
537 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
540 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
541 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
545 <th scope="row"><?php _e( 'Link to file' ) ?></th>
546 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
549 <th scope="row"><?php _e( 'Link to page' ) ?></th>
550 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
558 function wp_dropdown_roles( $default = false ) {
561 foreach( $wp_roles->role_names as $role => $name )
562 if ( $default == $role ) // Make default first in list
563 $p = "\n\t<option selected='selected' value='$role'>$name</option>";
565 $r .= "\n\t<option value='$role'>$name</option>";
569 function wp_convert_hr_to_bytes( $size ) {
570 $size = strtolower($size);
571 $bytes = (int) $size;
572 if ( strpos($size, 'k') !== false )
573 $bytes = intval($size) * 1024;
574 elseif ( strpos($size, 'm') !== false )
575 $bytes = intval($size) * 1024 * 1024;
576 elseif ( strpos($size, 'g') !== false )
577 $bytes = intval($size) * 1024 * 1024 * 1024;
581 function wp_convert_bytes_to_hr( $bytes ) {
582 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
583 $log = log( $bytes, 1024 );
585 $size = pow(1024, $log - $power);
586 return $size . $units[$power];
589 function wp_import_upload_form( $action ) {
590 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
591 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
592 $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
593 $size = wp_convert_bytes_to_hr( $bytes );
595 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
597 <?php wp_nonce_field('import-upload'); ?>
598 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
599 <input type="file" id="upload" name="import" size="25" />
600 <input type="hidden" name="action" value="save" />
601 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
604 <input type="submit" value="<?php _e( 'Upload file and import »' ); ?>" />
610 function wp_remember_old_slug() {
612 $name = attribute_escape($post->post_name); // just in case
614 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';