3 * Template WordPress Administration API.
5 * A Big Mess. Also some neat functions that are nicely written.
8 * @subpackage Administration
12 * {@internal Missing Short Description}}
16 * Outputs the HTML for the hidden table rows used in Categories, Link Categories and Tags quick edit.
18 * @param string $type "edit-tags", "categoried" or "edit-link-categories"
19 * @param string $taxonomy The taxonomy of the row.
22 function inline_edit_term_row($type, $taxonomy) {
24 $tax = get_taxonomy($taxonomy);
25 if ( ! current_user_can( $tax->cap->edit_terms ) )
28 $columns = get_column_headers($type);
29 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
30 $col_count = count($columns) - count($hidden);
33 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
34 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
36 <fieldset><div class="inline-edit-col">
37 <h4><?php _e( 'Quick Edit' ); ?></h4>
40 <span class="title"><?php _e( 'Name' ); ?></span>
41 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
43 <?php if ( !is_multisite() ) { ?>
45 <span class="title"><?php _e( 'Slug' ); ?></span>
46 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
54 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
56 foreach ( $columns as $column_name => $column_display_name ) {
57 if ( isset( $core_columns[$column_name] ) )
59 do_action( 'quick_edit_custom_box', $column_name, $type, $taxonomy );
64 <p class="inline-edit-save submit">
65 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
66 <?php $update_text = $tax->labels->update_item; ?>
67 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
68 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
69 <span class="error" style="display:none;"></span>
70 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
71 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />
75 </tbody></table></form>
80 * {@internal Missing Short Description}}
84 * @param unknown_type $category
85 * @param unknown_type $name_override
88 function link_cat_row( $category, $name_override = false ) {
89 static $row_class = '';
91 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
93 if ( is_wp_error( $category ) )
96 $default_cat_id = (int) get_option( 'default_link_category' );
97 $name = ( $name_override ? $name_override : $category->name );
98 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
99 if ( current_user_can( 'manage_categories' ) ) {
100 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>$name</a><br />";
102 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
103 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
104 if ( $default_cat_id != $category->term_id )
105 $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
106 $actions = apply_filters('link_cat_row_actions', $actions, $category);
107 $action_count = count($actions);
109 $edit .= '<div class="row-actions">';
110 foreach ( $actions as $action => $link ) {
112 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
113 $edit .= "<span class='$action'>$link$sep</span>";
120 $row_class = 'alternate' == $row_class ? '' : 'alternate';
121 $qe_data = get_term_to_edit($category->term_id, 'link_category');
123 $category->count = number_format_i18n( $category->count );
124 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
125 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
126 $columns = get_column_headers('edit-link-categories');
127 $hidden = get_hidden_columns('edit-link-categories');
128 foreach ( $columns as $column_name => $column_display_name ) {
129 $class = "class=\"$column_name column-$column_name\"";
132 if ( in_array($column_name, $hidden) )
133 $style = ' style="display:none;"';
135 $attributes = "$class$style";
137 switch ($column_name) {
139 $output .= "<th scope='row' class='check-column'>";
140 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
141 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
148 $output .= "<td $attributes>$edit";
149 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
150 $output .= '<div class="name">' . $qe_data->name . '</div>';
151 $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';
152 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
155 $output .= "<td $attributes>$category->description</td>";
158 $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>";
161 $attributes = 'class="links column-links num"' . $style;
162 $output .= "<td $attributes>$count</td>";
165 $output .= "<td $attributes>";
166 $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);
176 // Category Checklists
180 * {@internal Missing Short Description}}
184 class Walker_Category_Checklist extends Walker {
185 var $tree_type = 'category';
186 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
188 function start_lvl(&$output, $depth, $args) {
189 $indent = str_repeat("\t", $depth);
190 $output .= "$indent<ul class='children'>\n";
193 function end_lvl(&$output, $depth, $args) {
194 $indent = str_repeat("\t", $depth);
195 $output .= "$indent</ul>\n";
198 function start_el(&$output, $category, $depth, $args) {
200 if ( empty($taxonomy) )
201 $taxonomy = 'category';
203 if ( $taxonomy == 'category' )
204 $name = 'post_category';
206 $name = 'tax_input['.$taxonomy.']';
208 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
209 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
212 function end_el(&$output, $category, $depth, $args) {
213 $output .= "</li>\n";
218 * {@internal Missing Short Description}}
222 * @param unknown_type $post_id
223 * @param unknown_type $descendants_and_self
224 * @param unknown_type $selected_cats
225 * @param unknown_type $popular_cats
227 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
228 wp_terms_checklist($post_id,
230 'taxonomy' => 'category',
231 'descendants_and_self' => $descendants_and_self,
232 'selected_cats' => $selected_cats,
233 'popular_cats' => $popular_cats,
235 'checked_ontop' => $checked_ontop
240 * Taxonomy independent version of wp_category_checklist
242 * @param int $post_id
245 function wp_terms_checklist($post_id = 0, $args = array()) {
247 'descendants_and_self' => 0,
248 'selected_cats' => false,
249 'popular_cats' => false,
251 'taxonomy' => 'category',
252 'checked_ontop' => true
254 extract( wp_parse_args($args, $defaults), EXTR_SKIP );
256 if ( empty($walker) || !is_a($walker, 'Walker') )
257 $walker = new Walker_Category_Checklist;
259 $descendants_and_self = (int) $descendants_and_self;
261 $args = array('taxonomy' => $taxonomy);
263 $tax = get_taxonomy($taxonomy);
264 $args['disabled'] = !current_user_can($tax->cap->assign_terms);
266 if ( is_array( $selected_cats ) )
267 $args['selected_cats'] = $selected_cats;
269 $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
271 $args['selected_cats'] = array();
273 if ( is_array( $popular_cats ) )
274 $args['popular_cats'] = $popular_cats;
276 $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
278 if ( $descendants_and_self ) {
279 $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
280 $self = get_term( $descendants_and_self, $taxonomy );
281 array_unshift( $categories, $self );
283 $categories = (array) get_terms($taxonomy, array('get' => 'all'));
286 if ( $checked_ontop ) {
287 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
288 $checked_categories = array();
289 $keys = array_keys( $categories );
291 foreach( $keys as $k ) {
292 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
293 $checked_categories[] = $categories[$k];
294 unset( $categories[$k] );
298 // Put checked cats on top
299 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
301 // Then the rest of them
302 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
306 * {@internal Missing Short Description}}
310 * @param unknown_type $taxonomy
311 * @param unknown_type $default
312 * @param unknown_type $number
313 * @param unknown_type $echo
316 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
320 $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
322 $checked_terms = array();
324 $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
326 $tax = get_taxonomy($taxonomy);
327 if ( ! current_user_can($tax->cap->assign_terms) )
328 $disabled = 'disabled="disabled"';
332 $popular_ids = array();
333 foreach ( (array) $terms as $term ) {
334 $popular_ids[] = $term->term_id;
335 if ( !$echo ) // hack for AJAX use
337 $id = "popular-$taxonomy-$term->term_id";
338 $checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
341 <li id="<?php echo $id; ?>" class="popular-category">
342 <label class="selectit">
343 <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
344 <?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
354 * {@internal Missing Short Description}}
358 * @param unknown_type $link_id
360 function wp_link_category_checklist( $link_id = 0 ) {
364 $checked_categories = wp_get_link_cats( $link_id );
365 // No selected categories, strange
366 if ( ! count( $checked_categories ) )
367 $checked_categories[] = $default;
369 $checked_categories[] = $default;
372 $categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
374 if ( empty( $categories ) )
377 foreach ( $categories as $category ) {
378 $cat_id = $category->term_id;
379 $name = esc_html( apply_filters( 'the_category', $category->name ) );
380 $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
381 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, '/> ', $name, "</label></li>";
387 // Returns a single tag row (see tag_rows below)
388 // Note: this is also used in admin-ajax.php!
390 * {@internal Missing Short Description}}
394 * @param unknown_type $tag
395 * @param unknown_type $class
398 function _tag_row( $tag, $level, $taxonomy = 'post_tag' ) {
399 global $post_type, $current_screen;
400 static $row_class = '';
401 $row_class = ($row_class == '' ? ' class="alternate"' : '');
403 $count = number_format_i18n( $tag->count );
404 $tax = get_taxonomy($taxonomy);
406 if ( 'post_tag' == $taxonomy ) {
408 } elseif ( 'category' == $taxonomy ) {
409 $tagsel = 'category_name';
410 } elseif ( ! empty($tax->query_var) ) {
411 $tagsel = $tax->query_var;
416 $pad = str_repeat( '— ', max(0, $level) );
417 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
418 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
419 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&post_type=$post_type&tag_ID=$tag->term_id";
422 $out .= '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
425 $columns = get_column_headers($current_screen);
426 $hidden = get_hidden_columns($current_screen);
427 $default_term = get_option('default_' . $taxonomy);
428 foreach ( $columns as $column_name => $column_display_name ) {
429 $class = "class=\"$column_name column-$column_name\"";
432 if ( in_array($column_name, $hidden) )
433 $style = ' style="display:none;"';
435 $attributes = "$class$style";
437 switch ($column_name) {
439 if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )
440 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
442 $out .= '<th scope="row" class="check-column"> </th>';
445 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />';
447 if ( current_user_can($tax->cap->edit_terms) ) {
448 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
449 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
451 if ( current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term )
452 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
454 $actions = apply_filters('tag_row_actions', $actions, $tag);
455 $actions = apply_filters("${taxonomy}_row_actions", $actions, $tag);
457 $action_count = count($actions);
459 $out .= '<div class="row-actions">';
460 foreach ( $actions as $action => $link ) {
462 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
463 $out .= "<span class='$action'>$link$sep</span>";
466 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
467 $out .= '<div class="name">' . $qe_data->name . '</div>';
468 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';
469 $out .= '<div class="parent">' . $qe_data->parent . '</div></div></td>';
472 $out .= "<td $attributes>$tag->description</td>";
475 $out .= "<td $attributes>" . apply_filters('editable_slug', $tag->slug) . "</td>";
478 $attributes = 'class="posts column-posts num"' . $style;
479 $out .= "<td $attributes><a href='edit.php?$tagsel=$tag->slug&post_type=$post_type'>$count</a></td>";
482 $out .= "<td $attributes>";
483 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
493 // Outputs appropriate rows for the Nth page of the Tag Management screen,
494 // assuming M tags displayed at a time on the page
495 // Returns the number of tags displayed
497 * {@internal Missing Short Description}}
501 * @param unknown_type $page
502 * @param unknown_type $pagesize
503 * @param unknown_type $searchterms
506 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
508 // Get a page worth of tags
509 $start = ($page - 1) * $pagesize;
511 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
513 if ( !empty( $searchterms ) )
514 $args['search'] = $searchterms;
516 // convert it to table rows
519 if ( is_taxonomy_hierarchical($taxonomy) ) {
520 // We'll need the full set of terms then.
521 $args['number'] = $args['offset'] = 0;
523 $terms = get_terms( $taxonomy, $args );
524 if ( !empty( $searchterms ) ) // Ignore children on searches.
527 $children = _get_term_hierarchy($taxonomy);
529 // Some funky recursion to get the job done(Paging & parents mainly) is contained within, Skip it for non-hierarchical taxonomies for performance sake
530 $out .= _term_rows($taxonomy, $terms, $children, $page, $pagesize, $count);
532 $terms = get_terms( $taxonomy, $args );
533 foreach( $terms as $term )
534 $out .= _tag_row( $term, 0, $taxonomy );
535 $count = $pagesize; // Only displaying a single page.
542 function _term_rows( $taxonomy, $terms, &$children, $page = 1, $per_page = 20, &$count, $parent = 0, $level = 0 ) {
544 $start = ($page - 1) * $per_page;
545 $end = $start + $per_page;
548 foreach ( $terms as $key => $term ) {
550 if ( $count >= $end )
553 if ( $term->parent != $parent && empty($_GET['s']) )
556 // If the page starts in a subtree, print the parents.
557 if ( $count == $start && $term->parent > 0 && empty($_GET['s']) ) {
558 $my_parents = $parent_ids = array();
561 $my_parent = get_term( $p, $taxonomy );
562 $my_parents[] = $my_parent;
563 $p = $my_parent->parent;
564 if ( in_array($p, $parent_ids) ) // Prevent parent loops.
570 $num_parents = count($my_parents);
571 while ( $my_parent = array_pop($my_parents) ) {
572 $output .= "\t" . _tag_row( $my_parent, $level - $num_parents, $taxonomy );
577 if ( $count >= $start )
578 $output .= "\t" . _tag_row( $term, $level, $taxonomy );
584 if ( isset($children[$term->term_id]) && empty($_GET['s']) )
585 $output .= _term_rows( $taxonomy, $terms, $children, $page, $per_page, $count, $term->term_id, $level + 1 );
591 // define the columns to display, the syntax is 'internal name' => 'display name'
593 * {@internal Missing Short Description}}
599 function wp_manage_posts_columns( $screen = '') {
600 if ( empty($screen) )
603 $post_type = $screen->post_type;
605 $posts_columns = array();
606 $posts_columns['cb'] = '<input type="checkbox" />';
607 /* translators: manage posts column name */
608 $posts_columns['title'] = _x('Title', 'column name');
609 $posts_columns['author'] = __('Author');
610 if ( empty($post_type) || is_object_in_taxonomy($post_type, 'category') )
611 $posts_columns['categories'] = __('Categories');
612 if ( empty($post_type) || is_object_in_taxonomy($post_type, 'post_tag') )
613 $posts_columns['tags'] = __('Tags');
614 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
615 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) && ( empty($post_type) || post_type_supports($post_type, 'comments') ) )
616 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
617 $posts_columns['date'] = __('Date');
619 if ( 'page' == $post_type )
620 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
622 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
623 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
625 return $posts_columns;
628 // define the columns to display, the syntax is 'internal name' => 'display name'
630 * {@internal Missing Short Description}}
636 function wp_manage_media_columns() {
637 $posts_columns = array();
638 $posts_columns['cb'] = '<input type="checkbox" />';
639 $posts_columns['icon'] = '';
640 /* translators: column name */
641 $posts_columns['media'] = _x('File', 'column name');
642 $posts_columns['author'] = __('Author');
643 //$posts_columns['tags'] = _x('Tags', 'column name');
644 /* translators: column name */
645 $posts_columns['parent'] = _x('Attached to', 'column name');
646 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></div>';
647 //$posts_columns['comments'] = __('Comments');
648 /* translators: column name */
649 $posts_columns['date'] = _x('Date', 'column name');
650 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
652 return $posts_columns;
656 * {@internal Missing Short Description}}
662 function wp_manage_pages_columns() {
663 return wp_manage_posts_columns();
667 * Get the column headers for a screen
671 * @param string|object $screen The screen you want the headers for
672 * @return array Containing the headers in the format id => UI String
674 function get_column_headers($screen) {
675 global $_wp_column_headers;
677 if ( !isset($_wp_column_headers) )
678 $_wp_column_headers = array();
680 if ( is_string($screen) )
681 $screen = convert_to_screen($screen);
683 // Store in static to avoid running filters on each call
684 if ( isset($_wp_column_headers[$screen->id]) )
685 return $_wp_column_headers[$screen->id];
687 switch ($screen->base) {
689 $_wp_column_headers[$screen->id] = wp_manage_posts_columns( $screen );
691 case 'edit-comments':
692 $_wp_column_headers[$screen->id] = array(
693 'cb' => '<input type="checkbox" />',
694 'author' => __('Author'),
695 /* translators: column name */
696 'comment' => _x('Comment', 'column name'),
697 //'date' => __('Submitted'),
698 'response' => __('In Response To')
703 $_wp_column_headers[$screen->id] = array(
704 'cb' => '<input type="checkbox" />',
705 'name' => __('Name'),
707 'categories' => __('Categories'),
708 'rel' => __('Relationship'),
709 'visible' => __('Visible'),
710 'rating' => __('Rating')
715 $_wp_column_headers[$screen->id] = wp_manage_media_columns();
718 $_wp_column_headers[$screen->id] = array(
719 'cb' => '<input type="checkbox" />',
720 'name' => __('Name'),
721 'description' => __('Description'),
722 'slug' => __('Slug'),
723 'posts' => __('Posts')
727 case 'edit-link-categories':
728 $_wp_column_headers[$screen->id] = array(
729 'cb' => '<input type="checkbox" />',
730 'name' => __('Name'),
731 'description' => __('Description'),
732 'slug' => __('Slug'),
733 'links' => __('Links')
738 $_wp_column_headers[$screen->id] = array(
739 'cb' => '<input type="checkbox" />',
740 'name' => __('Name'),
741 'description' => __('Description'),
742 'slug' => __('Slug'),
743 'posts' => __('Posts')
748 $_wp_column_headers[$screen->id] = array(
749 'cb' => '<input type="checkbox" />',
750 'username' => __('Username'),
751 'name' => __('Name'),
752 'email' => __('E-mail'),
753 'role' => __('Role'),
754 'posts' => __('Posts')
758 $_wp_column_headers[$screen->id] = array();
761 $_wp_column_headers[$screen->id] = apply_filters('manage_' . $screen->id . '_columns', $_wp_column_headers[$screen->id]);
762 return $_wp_column_headers[$screen->id];
766 * {@internal Missing Short Description}}
770 * @param unknown_type $screen
771 * @param unknown_type $id
773 function print_column_headers( $screen, $id = true ) {
774 if ( is_string($screen) )
775 $screen = convert_to_screen($screen);
777 $columns = get_column_headers( $screen );
778 $hidden = get_hidden_columns($screen);
781 foreach ( $columns as $column_key => $column_display_name ) {
782 $class = ' class="manage-column';
784 $class .= " column-$column_key";
786 if ( 'cb' == $column_key )
787 $class .= ' check-column';
788 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
794 if ( in_array($column_key, $hidden) )
795 $style = 'display:none;';
797 if ( isset($styles[$screen->id]) && isset($styles[$screen->id][$column_key]) )
798 $style .= ' ' . $styles[$screen>id][$column_key];
799 $style = ' style="' . $style . '"';
801 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
806 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
810 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
811 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
812 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
814 function register_column_headers($screen, $columns) {
815 global $_wp_column_headers;
817 if ( is_string($screen) )
818 $screen = convert_to_screen($screen);
820 if ( !isset($_wp_column_headers) )
821 $_wp_column_headers = array();
823 $_wp_column_headers[$screen->id] = $columns;
827 * {@internal Missing Short Description}}
831 * @param unknown_type $screen
833 function get_hidden_columns($screen) {
834 if ( is_string($screen) )
835 $screen = convert_to_screen($screen);
837 return (array) get_user_option( 'manage' . $screen->id. 'columnshidden' );
841 * {@internal Missing Short Description}}
843 * Outputs the quick edit and bulk edit table rows for posts and pages
847 * @param string $screen
849 function inline_edit_row( $screen ) {
852 if ( is_string($screen) ) {
853 $screen = array('id' => 'edit-' . $screen, 'base' => 'edit', 'post_type' => $screen );
854 $screen = (object) $screen;
857 $post = get_default_post_to_edit( $screen->post_type );
858 $post_type_object = get_post_type_object( $screen->post_type );
860 $taxonomy_names = get_object_taxonomies( $screen->post_type );
861 $hierarchical_taxonomies = array();
862 $flat_taxonomies = array();
863 foreach ( $taxonomy_names as $taxonomy_name ) {
864 $taxonomy = get_taxonomy( $taxonomy_name);
866 if ( !$taxonomy->show_ui )
869 if ( $taxonomy->hierarchical )
870 $hierarchical_taxonomies[] = $taxonomy;
872 $flat_taxonomies[] = $taxonomy;
875 $columns = wp_manage_posts_columns($screen);
876 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
877 $col_count = count($columns) - count($hidden);
878 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
879 $can_publish = current_user_can($post_type_object->cap->publish_posts);
880 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
884 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
886 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
888 while ( $bulk < 2 ) { ?>
890 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
891 echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
892 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
894 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
895 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
900 if ( post_type_supports( $screen->post_type, 'title' ) ) :
902 <div id="bulk-title-div">
903 <div id="bulk-titles"></div>
906 <?php else : // $bulk ?>
909 <span class="title"><?php _e( 'Title' ); ?></span>
910 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
914 <span class="title"><?php _e( 'Slug' ); ?></span>
915 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
918 <?php endif; // $bulk
919 endif; // post_type_supports title ?>
921 <?php if ( !$bulk ) : ?>
922 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
923 <div class="inline-edit-date">
924 <?php touch_time(1, 1, 4, 1); ?>
928 <?php endif; // $bulk
930 if ( post_type_supports( $screen->post_type, 'author' ) ) :
931 $authors = get_editable_user_ids( get_current_user_id(), true, $screen->post_type ); // TODO: ROLE SYSTEM
932 $authors_dropdown = '';
933 if ( $authors && count( $authors ) > 1 ) :
934 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);
936 $users_opt['show_option_none'] = __('— No Change —');
937 $authors_dropdown = '<label>';
938 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
939 $authors_dropdown .= wp_dropdown_users( $users_opt );
940 $authors_dropdown .= '</label>';
945 <?php if ( !$bulk ) echo $authors_dropdown;
946 endif; // post_type_supports author
951 <div class="inline-edit-group">
952 <label class="alignleft">
953 <span class="title"><?php _e( 'Password' ); ?></span>
954 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
957 <em style="margin:5px 10px 0 0" class="alignleft">
959 /* translators: Between password field and private checkbox on post quick edit interface */
960 echo __( '–OR–' );
963 <label class="alignleft inline-edit-private">
964 <input type="checkbox" name="keep_private" value="private" />
965 <span class="checkbox-title"><?php echo __('Private'); ?></span>
973 <?php if ( count($hierarchical_taxonomies) && !$bulk ) : ?>
975 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
977 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
979 <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?>
980 <span class="catshow"><?php _e('[more]'); ?></span>
981 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
983 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]'; ?>" value="0" />
984 <ul class="cat-checklist <?php echo esc_attr($taxonomy->name)?>-checklist">
985 <?php wp_terms_checklist(null, array('taxonomy' => $taxonomy->name)) ?>
988 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
992 <?php endif; // count($hierarchical_taxonomies) && !$bulk ?>
994 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
997 if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
998 echo $authors_dropdown;
1001 <?php if ( $post_type_object->hierarchical ) : ?>
1004 <span class="title"><?php _e( 'Parent' ); ?></span>
1006 $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
1008 $dropdown_args['show_option_no_change'] = __('— No Change —');
1009 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1010 wp_dropdown_pages($dropdown_args);
1014 <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
1018 <span class="title"><?php _e( 'Order' ); ?></span>
1019 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1022 <?php endif; // !$bulk ?>
1025 <span class="title"><?php _e( 'Template' ); ?></span>
1026 <select name="page_template">
1027 <?php if ( $bulk ) : ?>
1028 <option value="-1"><?php _e('— No Change —'); ?></option>
1029 <?php endif; // $bulk ?>
1030 <option value="default"><?php _e( 'Default Template' ); ?></option>
1031 <?php page_template_dropdown() ?>
1036 endif; // post_type_supports page-attributes
1037 endif; // $post_type_object->hierarchical ?>
1039 <?php if ( count($flat_taxonomies) && !$bulk ) : ?>
1041 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
1043 <label class="inline-edit-tags">
1044 <span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span>
1045 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea>
1048 <?php endforeach; //$flat_taxonomies as $taxonomy ?>
1050 <?php endif; // count($flat_taxonomies) && !$bulk ?>
1052 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
1055 <div class="inline-edit-group">
1056 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1057 <label class="alignleft">
1058 <span class="title"><?php _e( 'Comments' ); ?></span>
1059 <select name="comment_status">
1060 <option value=""><?php _e('— No Change —'); ?></option>
1061 <option value="open"><?php _e('Allow'); ?></option>
1062 <option value="closed"><?php _e('Do not allow'); ?></option>
1065 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1066 <label class="alignright">
1067 <span class="title"><?php _e( 'Pings' ); ?></span>
1068 <select name="ping_status">
1069 <option value=""><?php _e('— No Change —'); ?></option>
1070 <option value="open"><?php _e('Allow'); ?></option>
1071 <option value="closed"><?php _e('Do not allow'); ?></option>
1077 <?php else : // $bulk ?>
1079 <div class="inline-edit-group">
1080 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
1081 <label class="alignleft">
1082 <input type="checkbox" name="comment_status" value="open" />
1083 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1085 <?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
1086 <label class="alignleft">
1087 <input type="checkbox" name="ping_status" value="open" />
1088 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1093 <?php endif; // $bulk
1094 endif; // post_type_supports comments or pings ?>
1096 <div class="inline-edit-group">
1097 <label class="inline-edit-status alignleft">
1098 <span class="title"><?php _e( 'Status' ); ?></span>
1099 <select name="_status">
1100 <?php if ( $bulk ) : ?>
1101 <option value="-1"><?php _e('— No Change —'); ?></option>
1102 <?php endif; // $bulk ?>
1103 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1104 <option value="publish"><?php _e( 'Published' ); ?></option>
1105 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1106 <?php if ( $bulk ) : ?>
1107 <option value="private"><?php _e('Private') ?></option>
1108 <?php endif; // $bulk ?>
1110 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1111 <option value="draft"><?php _e( 'Draft' ); ?></option>
1115 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
1117 <?php if ( $bulk ) : ?>
1119 <label class="alignright">
1120 <span class="title"><?php _e( 'Sticky' ); ?></span>
1121 <select name="sticky">
1122 <option value="-1"><?php _e( '— No Change —' ); ?></option>
1123 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1124 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1128 <?php else : // $bulk ?>
1130 <label class="alignleft">
1131 <input type="checkbox" name="sticky" value="sticky" />
1132 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1135 <?php endif; // $bulk ?>
1137 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_cap' ) ?>
1144 foreach ( $columns as $column_name => $column_display_name ) {
1145 if ( isset( $core_columns[$column_name] ) )
1147 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
1150 <p class="submit inline-edit-save">
1151 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
1152 <?php if ( ! $bulk ) {
1153 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1154 $update_text = __( 'Update' );
1156 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
1157 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
1159 $update_text = __( 'Update' );
1161 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
1163 <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
1164 <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
1165 <br class="clear" />
1171 </tbody></table></form>
1175 // adds hidden fields with the data for use in the inline editor for posts and pages
1177 * {@internal Missing Short Description}}
1181 * @param unknown_type $post
1183 function get_inline_data($post) {
1184 $post_type_object = get_post_type_object($post->post_type);
1185 if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
1188 $title = esc_attr( get_the_title( $post->ID ) );
1191 <div class="hidden" id="inline_' . $post->ID . '">
1192 <div class="post_title">' . $title . '</div>
1193 <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
1194 <div class="post_author">' . $post->post_author . '</div>
1195 <div class="comment_status">' . $post->comment_status . '</div>
1196 <div class="ping_status">' . $post->ping_status . '</div>
1197 <div class="_status">' . $post->post_status . '</div>
1198 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
1199 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
1200 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
1201 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
1202 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
1203 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
1204 <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
1206 if ( $post_type_object->hierarchical )
1207 echo '<div class="post_parent">' . $post->post_parent . '</div>';
1209 if ( $post->post_type == 'page' )
1210 echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
1212 if ( $post_type_object->hierarchical )
1213 echo '<div class="menu_order">' . $post->menu_order . '</div>';
1215 $taxonomy_names = get_object_taxonomies( $post->post_type );
1216 foreach ( $taxonomy_names as $taxonomy_name) {
1217 $taxonomy = get_taxonomy( $taxonomy_name );
1219 if ( $taxonomy->hierarchical && $taxonomy->show_ui )
1220 echo '<div class="post_category" id="'.$taxonomy_name.'_'.$post->ID.'">' . implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array('fields'=>'ids')) ) . '</div>';
1221 elseif ( $taxonomy->show_ui )
1222 echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">' . esc_html( str_replace( ',', ', ', get_terms_to_edit($post->ID, $taxonomy_name) ) ) . '</div>';
1225 if ( !$post_type_object->hierarchical )
1226 echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
1232 * {@internal Missing Short Description}}
1236 * @param unknown_type $posts
1238 function post_rows( $posts = array() ) {
1239 global $wp_query, $post, $mode;
1241 add_filter('the_title','esc_html');
1243 // Create array of post IDs.
1244 $post_ids = array();
1246 if ( empty($posts) )
1247 $posts = &$wp_query->posts;
1249 foreach ( $posts as $a_post )
1250 $post_ids[] = $a_post->ID;
1252 $comment_pending_count = get_pending_comments_num($post_ids);
1254 foreach ( $posts as $post ) {
1255 if ( empty($comment_pending_count[$post->ID]) )
1256 $comment_pending_count[$post->ID] = 0;
1258 _post_row($post, $comment_pending_count[$post->ID], $mode);
1263 * {@internal Missing Short Description}}
1267 * @param unknown_type $a_post
1268 * @param unknown_type $pending_comments
1269 * @param unknown_type $mode
1271 function _post_row($a_post, $pending_comments, $mode) {
1272 global $post, $current_screen;
1275 $global_post = $post;
1277 setup_postdata($post);
1279 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1280 $post_owner = ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
1281 $edit_link = get_edit_post_link( $post->ID );
1282 $title = _draft_or_post_title();
1283 $post_type_object = get_post_type_object($post->post_type);
1285 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
1287 $posts_columns = get_column_headers( $current_screen );
1288 $hidden = get_hidden_columns( $current_screen );
1289 foreach ( $posts_columns as $column_name=>$column_display_name ) {
1290 $class = "class=\"$column_name column-$column_name\"";
1293 if ( in_array($column_name, $hidden) )
1294 $style = ' style="display:none;"';
1296 $attributes = "$class$style";
1298 switch ($column_name) {
1302 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
1307 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
1308 $t_time = $h_time = __('Unpublished');
1311 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1312 $m_time = $post->post_date;
1313 $time = get_post_time('G', true, $post);
1315 $time_diff = time() - $time;
1317 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1318 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1320 $h_time = mysql2date(__('Y/m/d'), $m_time);
1323 echo '<td ' . $attributes . '>';
1324 if ( 'excerpt' == $mode )
1325 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
1327 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
1329 if ( 'publish' == $post->post_status ) {
1331 } elseif ( 'future' == $post->post_status ) {
1332 if ( $time_diff > 0 )
1333 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1337 _e('Last Modified');
1343 $attributes = 'class="post-title column-title"' . $style;
1345 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
1347 if ( 'excerpt' == $mode )
1351 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && 'trash' != $post->post_status ) {
1352 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
1353 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick Edit') . '</a>';
1355 if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) {
1356 if ( 'trash' == $post->post_status )
1357 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . "</a>";
1358 elseif ( EMPTY_TRASH_DAYS )
1359 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
1360 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
1361 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
1363 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1364 if ( current_user_can($post_type_object->cap->edit_post, $post->ID) )
1365 $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($post->ID) ) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1366 } elseif ( 'trash' != $post->post_status ) {
1367 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1369 $actions = apply_filters('post_row_actions', $actions, $post);
1370 $action_count = count($actions);
1372 echo '<div class="row-actions">';
1373 foreach ( $actions as $action => $link ) {
1375 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1376 echo "<span class='$action'>$link$sep</span>";
1380 get_inline_data($post);
1388 <td <?php echo $attributes ?>><?php
1389 $categories = get_the_category();
1390 if ( !empty( $categories ) ) {
1392 foreach ( $categories as $c )
1393 $out[] = "<a href='edit.php?post_type={$post->post_type}&category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
1394 echo join( ', ', $out );
1396 _e('Uncategorized');
1404 <td <?php echo $attributes ?>><?php
1405 $tags = get_the_tags($post->ID);
1406 if ( !empty( $tags ) ) {
1408 foreach ( $tags as $c )
1409 $out[] = "<a href='edit.php?post_type={$post->post_type}&tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
1410 echo join( ', ', $out );
1420 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1422 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
1423 if ( $pending_comments )
1425 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
1426 if ( $pending_comments )
1435 <td <?php echo $attributes ?>><a href="edit.php?post_type=<?php echo $post->post_type; ?>&author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1439 case 'control_view':
1441 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
1445 case 'control_edit':
1447 <td><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
1451 case 'control_delete':
1453 <td><?php if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
1459 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
1467 $post = $global_post;
1471 * display one row if the page doesn't have any children
1472 * otherwise, display the row and its children in subsequent rows
1475 * {@internal Missing Short Description}}
1479 * @param unknown_type $page
1480 * @param unknown_type $level
1482 function display_page_row( $page, $level = 0 ) {
1483 global $post, $current_screen;
1487 setup_postdata($page);
1489 if ( 0 == $level && (int)$page->post_parent > 0 ) {
1490 //sent level 0 by accident, by default, or because we don't know the actual level
1491 $find_main_page = (int)$page->post_parent;
1492 while ( $find_main_page > 0 ) {
1493 $parent = get_page($find_main_page);
1495 if ( is_null($parent) )
1499 $find_main_page = (int)$parent->post_parent;
1501 if ( !isset($parent_name) )
1502 $parent_name = $parent->post_title;
1506 $page->post_title = esc_html( $page->post_title );
1507 $pad = str_repeat( '— ', $level );
1508 $id = (int) $page->ID;
1509 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1510 $posts_columns = get_column_headers( $current_screen );
1511 $hidden = get_hidden_columns( $current_screen );
1512 $title = _draft_or_post_title();
1513 $post_type = $page->post_type;
1514 $post_type_object = get_post_type_object($post_type);
1516 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
1519 foreach ( $posts_columns as $column_name => $column_display_name ) {
1520 $class = "class=\"$column_name column-$column_name\"";
1523 if ( in_array($column_name, $hidden) )
1524 $style = ' style="display:none;"';
1526 $attributes = "$class$style";
1528 switch ($column_name) {
1532 <th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $page->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
1536 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
1537 $t_time = $h_time = __('Unpublished');
1540 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1541 $m_time = $page->post_date;
1542 $time = get_post_time('G', true);
1544 $time_diff = time() - $time;
1546 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1547 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1549 $h_time = mysql2date(__('Y/m/d'), $m_time);
1551 echo '<td ' . $attributes . '>';
1552 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
1554 if ( 'publish' == $page->post_status ) {
1556 } elseif ( 'future' == $page->post_status ) {
1557 if ( $time_diff > 0 )
1558 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1562 _e('Last Modified');
1567 $attributes = 'class="post-title page-title column-title"' . $style;
1568 $edit_link = get_edit_post_link( $page->ID );
1570 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name) : ''; ?></strong>
1573 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) {
1574 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
1575 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
1577 if ( current_user_can($post_type_object->cap->delete_post, $page->ID) ) {
1578 if ( $post->post_status == 'trash' )
1579 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=untrash&post=$page->ID", 'untrash-' . $post->post_type . '_' . $page->ID) . "'>" . __('Restore') . "</a>";
1580 elseif ( EMPTY_TRASH_DAYS )
1581 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>";
1582 if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS )
1583 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=delete&post=$page->ID", 'delete-' . $post->post_type . '_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
1585 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1586 if ( current_user_can($post_type_object->cap->edit_post, $page->ID) )
1587 $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink($page->ID) ) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1588 } elseif ( $post->post_status != 'trash' ) {
1589 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1591 $actions = apply_filters('page_row_actions', $actions, $page);
1592 $action_count = count($actions);
1595 echo '<div class="row-actions">';
1596 foreach ( $actions as $action => $link ) {
1598 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1599 echo "<span class='$action'>$link$sep</span>";
1603 get_inline_data($post);
1609 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1611 $left = get_pending_comments_num( $page->ID );
1612 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
1615 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
1625 <td <?php echo $attributes ?>><a href="edit.php?post_type=<?php echo $post_type; ?>&author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1631 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
1644 * displays pages in hierarchical order with paging support
1647 * {@internal Missing Short Description}}
1651 * @param unknown_type $pages
1652 * @param unknown_type $pagenum
1653 * @param unknown_type $per_page
1656 function page_rows($pages, $pagenum = 1, $per_page = 20) {
1662 $pages = get_pages( array('sort_column' => 'menu_order') );
1669 * arrange pages into two parts: top level pages and children_pages
1670 * children_pages is two dimensional array, eg.
1671 * children_pages[10][] contains all sub-pages whose parent is 10.
1672 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
1673 * If searching, ignore hierarchy and treat everything as top level
1675 if ( empty($_GET['s']) ) {
1677 $top_level_pages = array();
1678 $children_pages = array();
1680 foreach ( $pages as $page ) {
1682 // catch and repair bad pages
1683 if ( $page->post_parent == $page->ID ) {
1684 $page->post_parent = 0;
1685 $wpdb->update($wpdb->posts, array('post_parent' => 0), array('ID' => $page->ID));
1686 clean_page_cache( $page->ID );
1689 if ( 0 == $page->post_parent )
1690 $top_level_pages[] = $page;
1692 $children_pages[ $page->post_parent ][] = $page;
1695 $pages = &$top_level_pages;
1699 $start = ($pagenum - 1) * $per_page;
1700 $end = $start + $per_page;
1702 foreach ( $pages as $page ) {
1703 if ( $count >= $end )
1706 if ( $count >= $start )
1707 echo "\t" . display_page_row( $page, $level );
1711 if ( isset($children_pages) )
1712 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1715 // if it is the last pagenum and there are orphaned pages, display them with paging as well
1716 if ( isset($children_pages) && $count < $end ){
1717 foreach( $children_pages as $orphans ){
1718 foreach ( $orphans as $op ) {
1719 if ( $count >= $end )
1721 if ( $count >= $start )
1722 echo "\t" . display_page_row( $op, 0 );
1730 * Given a top level page ID, display the nested hierarchy of sub-pages
1731 * together with paging support
1735 * @param unknown_type $children_pages
1736 * @param unknown_type $count
1737 * @param unknown_type $parent
1738 * @param unknown_type $level
1739 * @param unknown_type $pagenum
1740 * @param unknown_type $per_page
1742 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
1744 if ( ! isset( $children_pages[$parent] ) )
1747 $start = ($pagenum - 1) * $per_page;
1748 $end = $start + $per_page;
1750 foreach ( $children_pages[$parent] as $page ) {
1752 if ( $count >= $end )
1755 // If the page starts in a subtree, print the parents.
1756 if ( $count == $start && $page->post_parent > 0 ) {
1757 $my_parents = array();
1758 $my_parent = $page->post_parent;
1759 while ( $my_parent) {
1760 $my_parent = get_post($my_parent);
1761 $my_parents[] = $my_parent;
1762 if ( !$my_parent->post_parent )
1764 $my_parent = $my_parent->post_parent;
1766 $num_parents = count($my_parents);
1767 while( $my_parent = array_pop($my_parents) ) {
1768 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
1773 if ( $count >= $start )
1774 echo "\t" . display_page_row( $page, $level );
1778 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1781 unset( $children_pages[$parent] ); //required in order to keep track of orphans
1785 * Generate HTML for a single row on the users.php admin panel.
1789 * @param object $user_object
1790 * @param string $style Optional. Attributes added to the TR element. Must be sanitized.
1791 * @param string $role Key for the $wp_roles array.
1792 * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts.
1795 function user_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
1798 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1799 $user_object = new WP_User( (int) $user_object );
1800 $user_object = sanitize_user_object($user_object, 'display');
1801 $email = $user_object->user_email;
1802 $url = $user_object->user_url;
1803 $short_url = str_replace( 'http://', '', $url );
1804 $short_url = str_replace( 'www.', '', $short_url );
1805 if ('/' == substr( $short_url, -1 ))
1806 $short_url = substr( $short_url, 0, -1 );
1807 if ( strlen( $short_url ) > 35 )
1808 $short_url = substr( $short_url, 0, 32 ).'...';
1810 // Check if the user for this row is editable
1811 if ( current_user_can( 'list_users' ) ) {
1812 // Set up the user editing link
1813 // TODO: make profile/user-edit determination a separate function
1814 if ( get_current_user_id() == $user_object->ID) {
1815 $edit_link = 'profile.php';
1817 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
1819 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1821 // Set up the hover actions for this user
1824 if ( current_user_can('edit_user', $user_object->ID) ) {
1825 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1826 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1828 $edit = "<strong>$user_object->user_login</strong><br />";
1831 if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
1832 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1833 if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
1834 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . "</a>";
1835 $actions = apply_filters('user_row_actions', $actions, $user_object);
1836 $action_count = count($actions);
1838 $edit .= '<div class="row-actions">';
1839 foreach ( $actions as $action => $link ) {
1841 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1842 $edit .= "<span class='$action'>$link$sep</span>";
1846 // Set up the checkbox (because the user is editable, otherwise its empty)
1847 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
1850 $edit = '<strong>' . $user_object->user_login . '</strong>';
1852 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
1853 $r = "<tr id='user-$user_object->ID'$style>";
1854 $columns = get_column_headers('users');
1855 $hidden = get_hidden_columns('users');
1856 $avatar = get_avatar( $user_object->ID, 32 );
1857 foreach ( $columns as $column_name => $column_display_name ) {
1858 $class = "class=\"$column_name column-$column_name\"";
1861 if ( in_array($column_name, $hidden) )
1862 $style = ' style="display:none;"';
1864 $attributes = "$class$style";
1866 switch ($column_name) {
1868 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
1871 $r .= "<td $attributes>$avatar $edit</td>";
1874 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1877 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('E-mail: %s' ), $email ) . "'>$email</a></td>";
1880 $r .= "<td $attributes>$role_name</td>";
1883 $attributes = 'class="posts column-posts num"' . $style;
1884 $r .= "<td $attributes>";
1885 if ( $numposts > 0 ) {
1886 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1895 $r .= "<td $attributes>";
1896 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
1906 * {@internal Missing Short Description}}
1910 * @param string $status Comment status (approved, spam, trash, etc)
1911 * @param string $s Term to search for
1912 * @param int $start Offset to start at for pagination
1913 * @param int $num Maximum number of comments to return
1914 * @param int $post Post ID or 0 to return all comments
1915 * @param string $type Comment type (comment, trackback, pingback, etc)
1916 * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num)
1918 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
1921 $start = abs( (int) $start );
1923 $post = (int) $post;
1924 $count = wp_count_comments();
1927 if ( 'moderated' == $status ) {
1928 $approved = "c.comment_approved = '0'";
1929 $total = $count->moderated;
1930 } elseif ( 'approved' == $status ) {
1931 $approved = "c.comment_approved = '1'";
1932 $total = $count->approved;
1933 } elseif ( 'spam' == $status ) {
1934 $approved = "c.comment_approved = 'spam'";
1935 $total = $count->spam;
1936 } elseif ( 'trash' == $status ) {
1937 $approved = "c.comment_approved = 'trash'";
1938 $total = $count->trash;
1940 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
1941 $total = $count->moderated + $count->approved;
1942 $index = 'USE INDEX (c.comment_date_gmt)';
1947 $post = " AND c.comment_post_ID = '$post'";
1952 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
1954 if ( 'comment' == $type )
1955 $typesql = "AND c.comment_type = ''";
1956 elseif ( 'pings' == $type )
1957 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
1958 elseif ( 'all' == $type )
1960 elseif ( !empty($type) )
1961 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
1965 if ( !empty($type) )
1968 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
1971 $s = $wpdb->escape($s);
1973 (c.comment_author LIKE '%$s%' OR
1974 c.comment_author_email LIKE '%$s%' OR
1975 c.comment_author_url LIKE ('%$s%') OR
1976 c.comment_author_IP LIKE ('%$s%') OR
1977 c.comment_content LIKE ('%$s%') ) AND
1981 $query .= "AND $approved $post $typesql";
1984 $comments = $wpdb->get_results("SELECT * $query $orderby");
1985 if ( '' === $total )
1986 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
1988 update_comment_cache($comments);
1990 return array($comments, $total);
1994 * {@internal Missing Short Description}}
1998 * @param unknown_type $comment_id
1999 * @param unknown_type $mode
2000 * @param unknown_type $comment_status
2001 * @param unknown_type $checkbox
2003 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
2004 global $comment, $post, $_comment_pending_count;
2005 $comment = get_comment( $comment_id );
2006 $post = get_post($comment->comment_post_ID);
2007 $the_comment_status = wp_get_comment_status($comment->comment_ID);
2008 $post_type_object = get_post_type_object($post->post_type);
2009 $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID);
2011 $comment_url = esc_url(get_comment_link($comment->comment_ID));
2012 $author_url = get_comment_author_url();
2013 if ( 'http://' == $author_url )
2015 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);
2016 if ( strlen($author_url_display) > 50 )
2017 $author_url_display = substr($author_url_display, 0, 49) . '...';
2019 $ptime = date('G', strtotime( $comment->comment_date ) );
2020 if ( ( abs(time() - $ptime) ) < 86400 )
2021 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
2023 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
2026 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
2027 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
2029 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2030 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2031 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2032 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2033 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2034 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2035 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2038 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2039 $columns = get_column_headers('edit-comments');
2040 $hidden = get_hidden_columns('edit-comments');
2041 foreach ( $columns as $column_name => $column_display_name ) {
2042 $class = "class=\"$column_name column-$column_name\"";
2045 if ( in_array($column_name, $hidden) )
2046 $style = ' style="display:none;"';
2048 $attributes = "$class$style";
2050 switch ($column_name) {
2052 if ( !$checkbox ) break;
2053 echo '<th scope="row" class="check-column">';
2054 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2058 echo "<td $attributes>";
2059 echo '<div id="submitted-on">';
2060 /* translators: 2: comment date, 3: comment time */
2061 printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
2062 /* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ),
2063 /* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
2065 if ( $comment->comment_parent ) {
2066 $parent = get_comment( $comment->comment_parent );
2067 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
2068 $name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this
2069 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
2074 if ( $user_can ) { ?>
2075 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2076 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>
2077 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
2078 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
2079 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2080 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2086 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
2088 'approve' => '', 'unapprove' => '',
2092 'spam' => '', 'unspam' => '',
2093 'trash' => '', 'untrash' => '', 'delete' => ''
2096 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2097 if ( 'approved' == $the_comment_status )
2098 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2099 else if ( 'unapproved' == $the_comment_status )
2100 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2102 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2103 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2106 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
2107 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
2108 } elseif ( 'spam' == $the_comment_status ) {
2109 $actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
2110 } elseif ( 'trash' == $the_comment_status ) {
2111 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
2114 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
2115 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
2117 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
2120 if ( 'trash' != $the_comment_status ) {
2121 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
2122 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
2123 if ( 'spam' != $the_comment_status )
2124 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2127 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
2130 echo '<div class="row-actions">';
2131 foreach ( $actions as $action => $link ) {
2133 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2135 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2136 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2137 $action .= ' hide-if-no-js';
2138 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {
2139 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
2140 $action .= ' approve';
2142 $action .= ' unapprove';
2145 echo "<span class='$action'>$sep$link</span>";
2153 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2154 if ( !empty($author_url) )
2155 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2157 if ( !empty($comment->comment_author_email) ) {
2158 comment_author_email_link();
2161 echo '<a href="edit-comments.php?s=';
2162 comment_author_IP();
2163 echo '&mode=detail';
2164 if ( 'spam' == $comment_status )
2165 echo '&comment_status=spam';
2167 comment_author_IP();
2169 } //current_user_can
2173 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2176 if ( 'single' !== $mode ) {
2177 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2178 $pending_comments = $_comment_pending_count[$post->ID];
2180 $_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
2181 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2184 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2185 $post_link .= get_the_title($post->ID) . '</a>';
2187 $post_link = get_the_title($post->ID);
2189 echo "<td $attributes>\n";
2190 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2191 echo $post_link . '<br />';
2192 $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) ));
2193 if ( $pending_comments )
2195 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
2196 if ( $pending_comments )
2199 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2201 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2207 echo "<td $attributes>\n";
2208 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2217 * {@internal Missing Short Description}}
2221 * @param unknown_type $position
2222 * @param unknown_type $checkbox
2223 * @param unknown_type $mode
2225 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2226 // allow plugin to replace the popup content
2227 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2229 if ( ! empty($content) ) {
2234 $columns = get_column_headers('edit-comments');
2235 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2236 $col_count = count($columns) - count($hidden);
2239 <form method="get" action="">
2240 <?php if ( $table_row ) : ?>
2241 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>">
2243 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
2245 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2247 <div id="edithead" style="display:none;">
2248 <div class="inside">
2249 <label for="author"><?php _e('Name') ?></label>
2250 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2253 <div class="inside">
2254 <label for="author-email"><?php _e('E-mail') ?></label>
2255 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2258 <div class="inside">
2259 <label for="author-url"><?php _e('URL') ?></label>
2260 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2262 <div style="clear:both;"></div>
2265 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2267 <p id="replysubmit" class="submit">
2268 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2269 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2270 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2271 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2272 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
2273 <span class="error" style="display:none;"></span>
2274 <br class="clear" />
2277 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
2278 <input type="hidden" name="action" id="action" value="" />
2279 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2280 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2281 <input type="hidden" name="status" id="status" value="" />
2282 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2283 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2284 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2285 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?>
2286 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2287 <?php if ( $table_row ) : ?>
2288 </td></tr></tbody></table>
2297 * Output 'undo move to trash' text for comments
2301 function wp_comment_trashnotice() {
2303 <div class="hidden" id="trash-undo-holder">
2304 <div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
2306 <div class="hidden" id="spam-undo-holder">
2307 <div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
2313 * {@internal Missing Short Description}}
2317 * @param unknown_type $meta
2319 function list_meta( $meta ) {
2323 <table id="list-table" style="display: none;">
2326 <th class="left">' . __( 'Name' ) . '</th>
2327 <th>' . __( 'Value' ) . '</th>
2330 <tbody id="the-list" class="list:meta">
2333 </table>'; //TBODY needed for list-manipulation JS
2338 <table id="list-table">
2341 <th class="left"><?php _e( 'Name' ) ?></th>
2342 <th><?php _e( 'Value' ) ?></th>
2345 <tbody id='the-list' class='list:meta'>
2347 foreach ( $meta as $entry )
2348 echo _list_meta_row( $entry, $count );
2356 * {@internal Missing Short Description}}
2360 * @param unknown_type $entry
2361 * @param unknown_type $count
2364 function _list_meta_row( $entry, &$count ) {
2365 static $update_nonce = false;
2366 if ( !$update_nonce )
2367 $update_nonce = wp_create_nonce( 'add-meta' );
2372 $style = 'alternate';
2375 if ('_' == $entry['meta_key'] { 0 } )
2376 $style .= ' hidden';
2378 if ( is_serialized( $entry['meta_value'] ) ) {
2379 if ( is_serialized_string( $entry['meta_value'] ) ) {
2380 // this is a serialized string, so we should display it
2381 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2383 // this is a serialized array/object so we should NOT display it
2389 $entry['meta_key'] = esc_attr($entry['meta_key']);
2390 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2391 $entry['meta_id'] = (int) $entry['meta_id'];
2393 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2395 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2396 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
2398 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2399 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2400 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta' /></div>";
2401 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2404 $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
2409 * {@internal Missing Short Description}}
2413 function meta_form() {
2415 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2416 $keys = $wpdb->get_col( "
2418 FROM $wpdb->postmeta
2420 HAVING meta_key NOT LIKE '\_%'
2426 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
2427 <table id="newmeta">
2430 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2431 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2437 <td id="newmetaleft" class="left">
2438 <?php if ( $keys ) { ?>
2439 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2440 <option value="#NONE#"><?php _e( '— Select —' ); ?></option>
2443 foreach ( $keys as $key ) {
2444 echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
2448 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2449 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2450 <span id="enternew"><?php _e('Enter new'); ?></span>
2451 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2453 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2456 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2459 <tr><td colspan="2" class="submit">
2460 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2461 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
2470 * {@internal Missing Short Description}}
2474 * @param unknown_type $edit
2475 * @param unknown_type $for_post
2476 * @param unknown_type $tab_index
2477 * @param unknown_type $multi
2479 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2480 global $wp_locale, $post, $comment;
2483 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
2485 $tab_index_attribute = '';
2486 if ( (int) $tab_index > 0 )
2487 $tab_index_attribute = " tabindex=\"$tab_index\"";
2489 // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
2491 $time_adj = current_time('timestamp');
2492 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2493 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2494 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2495 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2496 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2497 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2498 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2500 $cur_jj = gmdate( 'd', $time_adj );
2501 $cur_mm = gmdate( 'm', $time_adj );
2502 $cur_aa = gmdate( 'Y', $time_adj );
2503 $cur_hh = gmdate( 'H', $time_adj );
2504 $cur_mn = gmdate( 'i', $time_adj );
2506 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2507 for ( $i = 1; $i < 13; $i = $i +1 ) {
2508 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2510 $month .= ' selected="selected"';
2511 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2513 $month .= '</select>';
2515 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2516 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2517 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2518 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2520 echo '<div class="timestamp-wrap">';
2521 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2522 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2524 echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2526 if ( $multi ) return;
2529 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2530 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2531 $cur_timeunit = 'cur_' . $timeunit;
2532 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2537 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2538 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2544 * {@internal Missing Short Description}}
2548 * @param unknown_type $default
2550 function page_template_dropdown( $default = '' ) {
2551 $templates = get_page_templates();
2552 ksort( $templates );
2553 foreach (array_keys( $templates ) as $template )
2554 : if ( $default == $templates[$template] )
2555 $selected = " selected='selected'";
2558 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2563 * {@internal Missing Short Description}}
2567 * @param unknown_type $default
2568 * @param unknown_type $parent
2569 * @param unknown_type $level
2572 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2573 global $wpdb, $post_ID;
2574 $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
2577 foreach ( $items as $item ) {
2578 // A page cannot be its own parent.
2579 if (!empty ( $post_ID ) ) {
2580 if ( $item->ID == $post_ID ) {
2584 $pad = str_repeat( ' ', $level * 3 );
2585 if ( $item->ID == $default)
2586 $current = ' selected="selected"';
2590 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2591 parent_dropdown( $default, $item->ID, $level +1 );
2599 * {@internal Missing Short Description}}
2603 * @param unknown_type $id
2606 function the_attachment_links( $id = false ) {
2608 $post = & get_post( $id );
2610 if ( $post->post_type != 'attachment' )
2613 $icon = wp_get_attachment_image( $post->ID, 'thumbnail', true );
2614 $attachment_data = wp_get_attachment_metadata( $id );
2615 $thumb = isset( $attachment_data['thumb'] );
2617 <form id="the-attachment-links">
2620 <col class="widefat" />
2622 <th scope="row"><?php _e( 'URL' ) ?></th>
2623 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2625 <?php if ( $icon ) : ?>
2627 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2628 <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>
2631 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2632 <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>
2636 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2637 <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>
2640 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2641 <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>
2651 * Print out <option> html elements for role selectors based on $wp_roles
2653 * @package WordPress
2654 * @subpackage Administration
2658 * @param string $default slug for the role that should be already selected
2660 function wp_dropdown_roles( $selected = false ) {
2664 $editable_roles = get_editable_roles();
2666 foreach ( $editable_roles as $role => $details ) {
2667 $name = translate_user_role($details['name'] );
2668 if ( $selected == $role ) // Make default first in list
2669 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2671 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2677 * {@internal Missing Short Description}}
2681 * @param unknown_type $size
2684 function wp_convert_hr_to_bytes( $size ) {
2685 $size = strtolower($size);
2686 $bytes = (int) $size;
2687 if ( strpos($size, 'k') !== false )
2688 $bytes = intval($size) * 1024;
2689 elseif ( strpos($size, 'm') !== false )
2690 $bytes = intval($size) * 1024 * 1024;
2691 elseif ( strpos($size, 'g') !== false )
2692 $bytes = intval($size) * 1024 * 1024 * 1024;
2697 * {@internal Missing Short Description}}
2701 * @param unknown_type $bytes
2704 function wp_convert_bytes_to_hr( $bytes ) {
2705 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2706 $log = log( $bytes, 1024 );
2707 $power = (int) $log;
2708 $size = pow(1024, $log - $power);
2709 return $size . $units[$power];
2713 * {@internal Missing Short Description}}
2719 function wp_max_upload_size() {
2720 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2721 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2722 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2727 * Outputs the form used by the importers to accept the data to be imported
2731 * @param string $action The action attribute for the form.
2733 function wp_import_upload_form( $action ) {
2734 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2735 $size = wp_convert_bytes_to_hr( $bytes );
2736 $upload_dir = wp_upload_dir();
2737 if ( ! empty( $upload_dir['error'] ) ) :
2738 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2739 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2742 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
2744 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2745 <input type="file" id="upload" name="import" size="25" />
2746 <input type="hidden" name="action" value="save" />
2747 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2750 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2758 * Add a meta box to an edit form.
2762 * @param string $id String for use in the 'id' attribute of tags.
2763 * @param string $title Title of the meta box.
2764 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2765 * @param string $page The type of edit page on which to show the box (post, page, link).
2766 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2767 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2769 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2770 global $wp_meta_boxes;
2772 if ( !isset($wp_meta_boxes) )
2773 $wp_meta_boxes = array();
2774 if ( !isset($wp_meta_boxes[$page]) )
2775 $wp_meta_boxes[$page] = array();
2776 if ( !isset($wp_meta_boxes[$page][$context]) )
2777 $wp_meta_boxes[$page][$context] = array();
2779 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2780 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2781 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2784 // If a core box was previously added or removed by a plugin, don't add.
2785 if ( 'core' == $priority ) {
2786 // If core box previously deleted, don't add
2787 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2789 // If box was added with default priority, give it core priority to maintain sort order
2790 if ( 'default' == $a_priority ) {
2791 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2792 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2796 // If no priority given and id already present, use existing priority
2797 if ( empty($priority) ) {
2798 $priority = $a_priority;
2799 // else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
2800 } elseif ( 'sorted' == $priority ) {
2801 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2802 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2803 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2805 // An id can be in only one priority and one context
2806 if ( $priority != $a_priority || $context != $a_context )
2807 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2811 if ( empty($priority) )
2814 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2815 $wp_meta_boxes[$page][$context][$priority] = array();
2817 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2821 * Meta-Box template function
2825 * @param string $page page identifier, also known as screen identifier
2826 * @param string $context box context
2827 * @param mixed $object gets passed to the box callback function as first parameter
2828 * @return int number of meta_boxes
2830 function do_meta_boxes($page, $context, $object) {
2831 global $wp_meta_boxes;
2832 static $already_sorted = false;
2834 $hidden = get_hidden_meta_boxes($page);
2836 printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
2840 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2841 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
2842 foreach ( $sorted as $box_context => $ids )
2843 foreach ( explode(',', $ids) as $id )
2845 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2847 $already_sorted = true;
2849 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2852 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2853 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2854 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2855 if ( false == $box || ! $box['title'] )
2859 $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
2860 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
2861 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
2862 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
2863 echo '<div class="inside">' . "\n";
2864 call_user_func($box['callback'], $object, $box);
2879 * Remove a meta box from an edit form.
2883 * @param string $id String for use in the 'id' attribute of tags.
2884 * @param string $page The type of edit page on which to show the box (post, page, link).
2885 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2887 function remove_meta_box($id, $page, $context) {
2888 global $wp_meta_boxes;
2890 if ( !isset($wp_meta_boxes) )
2891 $wp_meta_boxes = array();
2892 if ( !isset($wp_meta_boxes[$page]) )
2893 $wp_meta_boxes[$page] = array();
2894 if ( !isset($wp_meta_boxes[$page][$context]) )
2895 $wp_meta_boxes[$page][$context] = array();
2897 foreach ( array('high', 'core', 'default', 'low') as $priority )
2898 $wp_meta_boxes[$page][$context][$priority][$id] = false;
2902 * {@internal Missing Short Description}}
2906 * @param unknown_type $screen
2908 function meta_box_prefs($screen) {
2909 global $wp_meta_boxes;
2911 if ( is_string($screen) )
2912 $screen = convert_to_screen($screen);
2914 if ( empty($wp_meta_boxes[$screen->id]) )
2917 $hidden = get_hidden_meta_boxes($screen);
2919 foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
2920 foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
2921 foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
2922 if ( false == $box || ! $box['title'] )
2924 // Submit box cannot be hidden
2925 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
2927 $box_id = $box['id'];
2928 echo '<label for="' . $box_id . '-hide">';
2929 echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
2930 echo "{$box['title']}</label>\n";
2937 * Get Hidden Meta Boxes
2941 * @param string|object $screen Screen identifier
2942 * @return array Hidden Meta Boxes
2944 function get_hidden_meta_boxes( $screen ) {
2945 if ( is_string( $screen ) )
2946 $screen = convert_to_screen( $screen );
2948 $hidden = get_user_option( "metaboxhidden_{$screen->id}" );
2950 // Hide slug boxes by default
2951 if ( !is_array( $hidden ) )
2952 $hidden = array('slugdiv');
2958 * Add a new section to a settings page.
2960 * Part of the Settings API. Use this to define new settings sections for an admin page.
2961 * Show settings sections in your admin page callback function with do_settings_sections().
2962 * Add settings fields to your section with add_settings_field()
2964 * The $callback argument should be the name of a function that echoes out any
2965 * content you want to show at the top of the settings section before the actual
2966 * fields. It can output nothing if you want.
2970 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
2972 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
2973 * @param string $title Formatted title of the section. Shown as the heading for the section.
2974 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
2975 * @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
2977 function add_settings_section($id, $title, $callback, $page) {
2978 global $wp_settings_sections;
2980 if ( 'misc' == $page ) {
2981 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
2985 if ( !isset($wp_settings_sections) )
2986 $wp_settings_sections = array();
2987 if ( !isset($wp_settings_sections[$page]) )
2988 $wp_settings_sections[$page] = array();
2989 if ( !isset($wp_settings_sections[$page][$id]) )
2990 $wp_settings_sections[$page][$id] = array();
2992 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
2996 * Add a new field to a section of a settings page
2998 * Part of the Settings API. Use this to define a settings field that will show
2999 * as part of a settings section inside a settings page. The fields are shown using
3000 * do_settings_fields() in do_settings-sections()
3002 * The $callback argument should be the name of a function that echoes out the
3003 * html input tags for this setting field. Use get_option() to retrive existing
3008 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
3010 * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
3011 * @param string $title Formatted title of the field. Shown as the label for the field during output.
3012 * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
3013 * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
3014 * @param string $section The slug-name of the section of the settingss page in which to show the box (default, ...).
3015 * @param array $args Additional arguments
3017 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3018 global $wp_settings_fields;
3020 if ( 'misc' == $page ) {
3021 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
3025 if ( !isset($wp_settings_fields) )
3026 $wp_settings_fields = array();
3027 if ( !isset($wp_settings_fields[$page]) )
3028 $wp_settings_fields[$page] = array();
3029 if ( !isset($wp_settings_fields[$page][$section]) )
3030 $wp_settings_fields[$page][$section] = array();
3032 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3036 * Prints out all settings sections added to a particular settings page
3038 * Part of the Settings API. Use this in a settings page callback function
3039 * to output all the sections and fields that were added to that $page with
3040 * add_settings_section() and add_settings_field()
3042 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
3043 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
3046 * @param string $page The slug name of the page whos settings sections you want to output
3048 function do_settings_sections($page) {
3049 global $wp_settings_sections, $wp_settings_fields;
3051 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3054 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3055 echo "<h3>{$section['title']}</h3>\n";
3056 call_user_func($section['callback'], $section);
3057 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3059 echo '<table class="form-table">';
3060 do_settings_fields($page, $section['id']);
3066 * Print out the settings fields for a particular settings section
3068 * Part of the Settings API. Use this in a settings page to output
3069 * a specific section. Should normally be called by do_settings_sections()
3070 * rather than directly.
3072 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
3076 * @param string $page Slug title of the admin page who's settings fields you want to show.
3077 * @param section $section Slug title of the settings section who's fields you want to show.
3079 function do_settings_fields($page, $section) {
3080 global $wp_settings_fields;
3082 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3085 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3086 echo '<tr valign="top">';
3087 if ( !empty($field['args']['label_for']) )
3088 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3090 echo '<th scope="row">' . $field['title'] . '</th>';
3092 call_user_func($field['callback'], $field['args']);
3099 * Register a settings error to be displayed to the user
3101 * Part of the Settings API. Use this to show messages to users about settings validation
3102 * problems, missing settings or anything else.
3104 * Settings errors should be added inside the $sanitize_callback function defined in
3105 * register_setting() for a given setting to give feedback about the submission.
3107 * By default messages will show immediately after the submission that generated the error.
3108 * Additional calls to settings_errors() can be used to show errors even when the settings
3109 * page is first accessed.
3111 * @global array $wp_settings_errors Storage array of errors registered during this pageload
3113 * @param string $setting Slug title of the setting to which this error applies
3114 * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
3115 * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
3116 * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
3118 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
3119 global $wp_settings_errors;
3121 if ( !isset($wp_settings_errors) )
3122 $wp_settings_errors = array();
3125 'setting' => $setting,
3127 'message' => $message,
3130 $wp_settings_errors[] = $new_error;
3134 * Fetch settings errors registered by add_settings_error()
3136 * Checks the $wp_settings_errors array for any errors declared during the current
3137 * pageload and returns them.
3139 * If changes were just submitted ($_GET['updated']) and settings errors were saved
3140 * to the 'settings_errors' transient then those errors will be returned instead. This
3141 * is used to pass errors back across pageloads.
3143 * Use the $sanitize argument to manually re-sanitize the option before returning errors.
3144 * This is useful if you have errors or notices you want to show even when the user
3145 * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
3147 * @global array $wp_settings_errors Storage array of errors registered during this pageload
3149 * @param string $setting Optional slug title of a specific setting who's errors you want.
3150 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
3151 * @return array Array of settings errors
3153 function get_settings_errors( $setting = '', $sanitize = FALSE ) {
3154 global $wp_settings_errors;
3156 // If $sanitize is true, manually re-run the sanitizisation for this option
3157 // This allows the $sanitize_callback from register_setting() to run, adding
3158 // any settings errors you want to show by default.
3160 sanitize_option( $setting, get_option($setting));
3162 // If settings were passed back from options.php then use them
3163 // Ignore transients if $sanitize is true, we dont' want the old values anyway
3164 if ( isset($_GET['updated']) && $_GET['updated'] && get_transient('settings_errors') ) {
3165 $settings_errors = get_transient('settings_errors');
3166 delete_transient('settings_errors');
3167 // Otherwise check global in case validation has been run on this pageload
3168 } elseif ( count( $wp_settings_errors ) ) {
3169 $settings_errors = $wp_settings_errors;
3174 // Filter the results to those of a specific setting if one was set
3176 foreach ( (array) $settings_errors as $key => $details )
3177 if ( $setting != $details['setting'] )
3178 unset( $settings_errors[$key] );
3180 return $settings_errors;
3184 * Display settings errors registered by add_settings_error()
3186 * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
3188 * This is called automatically after a settings page based on the Settings API is submitted.
3189 * Errors should be added during the validation callback function for a setting defined in register_setting()
3191 * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
3192 * on its current value.
3194 * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
3195 * if the user has already saved new values it will be hidden to avoid repeating messages already
3196 * shown in the default error reporting after submission. This is useful to show general errors like missing
3197 * settings when the user arrives at the settings page.
3199 * @param string $setting Optional slug title of a specific setting who's errors you want.
3200 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
3201 * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
3204 function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
3206 if ($hide_on_update AND $_GET['updated']) return;
3208 $settings_errors = get_settings_errors( $setting, $sanitize );
3210 if ( !is_array($settings_errors) ) return;
3213 foreach ( $settings_errors as $key => $details ) {
3214 $css_id = 'setting-error-' . $details['code'];
3215 $css_class = $details['type'] . ' settings-error';
3216 $output .= "<div id='$css_id' class='$css_class'> \n";
3217 $output .= "<p><strong>{$details['message']}</strong></p>";
3218 $output .= "</div> \n";
3224 * {@internal Missing Short Description}}
3228 * @param unknown_type $page
3230 function manage_columns_prefs( $page ) {
3231 $columns = get_column_headers( $page );
3232 $hidden = get_hidden_columns( $page );
3233 $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
3235 foreach ( $columns as $column => $title ) {
3236 // Can't hide these or they are special
3237 if ( in_array( $column, $special ) )
3239 if ( empty( $title ) )
3242 if ( 'comments' == $column )
3243 $title = __( 'Comments' );
3244 $id = "$column-hide";
3245 echo '<label for="' . $id . '">';
3246 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3247 echo "$title</label>\n";
3252 * {@internal Missing Short Description}}
3256 * @param unknown_type $found_action
3258 function find_posts_div($found_action = '') {
3260 <div id="find-posts" class="find-box" style="display:none;">
3261 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3262 <div class="find-box-inside">
3263 <div class="find-box-search">
3264 <?php if ( $found_action ) { ?>
3265 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3268 <input type="hidden" name="affected" id="affected" value="" />
3269 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3270 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3271 <input type="text" id="find-posts-input" name="ps" value="" />
3272 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3275 $post_types = get_post_types( array('public' => true), 'objects' );
3276 foreach ( $post_types as $post ) {
3277 if ( 'attachment' == $post->name )
3280 <input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name, 'post'); ?> />
3281 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
3285 <div id="find-posts-response"></div>
3287 <div class="find-box-buttons">
3288 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3289 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3296 * Display the post password.
3298 * The password is passed through {@link esc_attr()} to ensure that it
3299 * is safe for placing in an html attribute.
3304 function the_post_password() {
3306 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3310 * {@internal Missing Short Description}}
3314 function favorite_actions( $screen = null ) {
3315 $default_action = false;
3317 if ( is_string($screen) )
3318 $screen = convert_to_screen($screen);
3320 if ( isset($screen->post_type) ) {
3321 $post_type_object = get_post_type_object($screen->post_type);
3322 if ( 'add' != $screen->action )
3323 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
3325 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
3328 if ( !$default_action ) {
3329 switch ( $screen->id ) {
3331 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3334 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3336 case 'link-manager':
3338 if ( 'add' != $screen->action )
3339 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3341 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3344 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3347 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3350 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3352 case 'plugin-install':
3353 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3356 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3358 case 'theme-install':
3359 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3362 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3368 'post-new.php' => array(__('New Post'), 'edit_posts'),
3369 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3370 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
3371 'media-new.php' => array(__('Upload'), 'upload_files'),
3372 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3375 $default_key = array_keys($default_action);
3376 $default_key = $default_key[0];
3377 if ( isset($actions[$default_key]) )
3378 unset($actions[$default_key]);
3379 $actions = array_merge($default_action, $actions);
3380 $actions = apply_filters('favorite_actions', $actions);
3382 $allowed_actions = array();
3383 foreach ( $actions as $action => $data ) {
3384 if ( current_user_can($data[1]) )
3385 $allowed_actions[$action] = $data[0];
3388 if ( empty($allowed_actions) )
3391 $first = array_keys($allowed_actions);
3393 echo '<div id="favorite-actions">';
3394 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3395 echo '<div id="favorite-inside">';
3397 array_shift($allowed_actions);
3399 foreach ( $allowed_actions as $action => $label) {
3400 echo "<div class='favorite-action'><a href='$action'>";
3402 echo "</a></div>\n";
3404 echo "</div></div>\n";
3408 * Get the post title.
3410 * The post title is fetched and if it is blank then a default string is
3414 * @param int $id The post id. If not supplied the global $post is used.
3417 function _draft_or_post_title($post_id = 0) {
3418 $title = get_the_title($post_id);
3419 if ( empty($title) )
3420 $title = __('(no title)');
3425 * Display the search query.
3427 * A simple wrapper to display the "s" parameter in a GET URI. This function
3428 * should only be used when {@link the_search_query()} cannot.
3434 function _admin_search_query() {
3435 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
3439 * Generic Iframe header for use with Thickbox
3442 * @param string $title Title of the Iframe page.
3443 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3446 function iframe_header( $title = '', $limit_styles = false ) {
3447 global $hook_suffix;
3448 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3449 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3451 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3452 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
3454 wp_enqueue_style( 'global' );
3455 if ( ! $limit_styles )
3456 wp_enqueue_style( 'wp-admin' );
3457 wp_enqueue_style( 'colors' );
3459 <script type="text/javascript">
3461 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
3462 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
3466 do_action('admin_print_styles');
3467 do_action('admin_print_scripts');
3468 do_action('admin_head');
3470 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
3473 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="no-js <?php echo $admin_body_class; ?>">
3474 <script type="text/javascript">
3477 var c = document.body.className;
3478 c = c.replace(/no-js/, 'js');
3479 document.body.className = c;
3487 * Generic Iframe footer for use with Thickbox
3492 function iframe_footer() {
3493 //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
3494 <div class="hidden">
3496 do_action('admin_footer', '');
3497 do_action('admin_print_footer_scripts'); ?>
3499 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
3505 function _post_states($post) {
3506 $post_states = array();
3507 if ( isset($_GET['post_status']) )
3508 $post_status = $_GET['post_status'];
3512 if ( !empty($post->post_password) )
3513 $post_states[] = __('Password protected');
3514 if ( 'private' == $post->post_status && 'private' != $post_status )
3515 $post_states[] = __('Private');
3516 if ( 'draft' == $post->post_status && 'draft' != $post_status )
3517 $post_states[] = __('Draft');
3518 if ( 'pending' == $post->post_status && 'pending' != $post_status )
3519 /* translators: post state */
3520 $post_states[] = _x('Pending', 'post state');
3521 if ( is_sticky($post->ID) )
3522 $post_states[] = __('Sticky');
3524 $post_states = apply_filters( 'display_post_states', $post_states );
3526 if ( ! empty($post_states) ) {
3527 $state_count = count($post_states);
3530 foreach ( $post_states as $state ) {
3532 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
3533 echo "<span class='post-state'>$state$sep</span>";
3539 * Convert a screen string to a screen object
3543 * @param string $screen The name of the screen
3544 * @return object An object containing the safe screen name and id
3546 function convert_to_screen( $screen ) {
3547 $screen = str_replace( array('.php', '-new', '-add' ), '', $screen);
3548 $screen = (string) apply_filters( 'screen_meta_screen', $screen );
3549 $screen = (object) array('id' => $screen, 'base' => $screen);
3553 function screen_meta($screen) {
3554 global $wp_meta_boxes, $_wp_contextual_help, $title;
3556 if ( is_string($screen) )
3557 $screen = convert_to_screen($screen);
3559 $column_screens = get_column_headers($screen);
3560 $meta_screens = array('index' => 'dashboard');
3562 if ( isset($meta_screens[$screen->id]) ) {
3563 $screen->id = $meta_screens[$screen->id];
3564 $screen->base = $screen->id;
3567 $show_screen = false;
3568 if ( !empty($wp_meta_boxes[$screen->id]) || !empty($column_screens) )
3569 $show_screen = true;
3571 $screen_options = screen_options($screen);
3572 if ( $screen_options )
3573 $show_screen = true;
3575 if ( !isset($_wp_contextual_help) )
3576 $_wp_contextual_help = array();
3578 $settings = apply_filters('screen_settings', '', $screen);
3580 switch ( $screen->id ) {
3582 $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
3583 $show_screen = true;
3586 if( ! empty( $settings ) )
3587 $show_screen = true;
3589 <div id="screen-meta">
3590 <?php if ( $show_screen ) : ?>
3591 <div id="screen-options-wrap" class="hidden">
3592 <form id="adv-settings" action="" method="post">
3593 <?php if ( isset($wp_meta_boxes[$screen->id]) ) : ?>
3594 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
3595 <div class="metabox-prefs">
3596 <?php meta_box_prefs($screen); ?>
3597 <br class="clear" />
3600 if ( ! empty($column_screens) ) : ?>
3601 <h5><?php echo ( isset( $column_screens['_title'] ) ? $column_screens['_title'] : _x('Show on screen', 'Columns') ) ?></h5>
3602 <div class="metabox-prefs">
3603 <?php manage_columns_prefs($screen); ?>
3604 <br class="clear" />
3607 echo screen_layout($screen);
3609 if ( !empty( $screen_options ) ) {
3611 <h5><?php _ex('Show on screen', 'Screen Options') ?></h5>
3615 echo $screen_options;
3617 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
3621 <?php endif; // $show_screen
3623 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
3625 <div id="contextual-help-wrap" class="hidden">
3627 $contextual_help = '';
3628 if ( isset($_wp_contextual_help[$screen->id]) ) {
3629 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
3631 $contextual_help .= '<div class="metabox-prefs">';
3632 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
3633 $default_help .= '<br />';
3634 $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
3635 $contextual_help .= apply_filters('default_contextual_help', $default_help);
3636 $contextual_help .= "</div>\n";
3639 echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen);
3643 <div id="screen-meta-links">
3644 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
3645 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
3647 <?php if ( $show_screen ) { ?>
3648 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
3649 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
3658 * Add contextual help text for a page
3662 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
3663 * @param string $help Arbitrary help text
3665 function add_contextual_help($screen, $help) {
3666 global $_wp_contextual_help;
3668 if ( is_string($screen) )
3669 $screen = convert_to_screen($screen);
3671 if ( !isset($_wp_contextual_help) )
3672 $_wp_contextual_help = array();
3674 $_wp_contextual_help[$screen->id] = $help;
3677 function drag_drop_help() {
3679 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p>
3680 <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p>
3684 function plugins_search_help() {
3686 <p><strong>' . __('Search help') . '</strong></p>' .
3687 '<p>' . __('You may search based on 3 criteria:') . '<br />' .
3688 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .
3689 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .
3690 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>
3694 function screen_layout($screen) {
3695 global $screen_layout_columns;
3697 if ( is_string($screen) )
3698 $screen = convert_to_screen($screen);
3700 $columns = array('dashboard' => 4, 'link' => 2);
3702 // Add custom post types
3703 foreach ( get_post_types( array('show_ui' => true) ) as $post_type )
3704 $columns[$post_type] = 2;
3706 $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen);
3708 if ( !isset($columns[$screen->id]) ) {
3709 $screen_layout_columns = 0;
3713 $screen_layout_columns = get_user_option("screen_layout_$screen->id");
3714 $num = $columns[$screen->id];
3716 if ( ! $screen_layout_columns )
3717 $screen_layout_columns = 2;
3720 $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
3721 while ( $i <= $num ) {
3722 $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
3725 $return .= "</div>\n";
3729 function screen_options($screen) {
3730 if ( is_string($screen) )
3731 $screen = convert_to_screen($screen);
3733 switch ( $screen->base ) {
3736 $post_type = 'post';
3737 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
3738 $post_type = $_GET['post_type'];
3739 $post_type_object = get_post_type_object($post_type);
3740 $per_page_label = $post_type_object->labels->name;
3743 $per_page_label = _x( 'Sites', 'sites per page (screen options)' );
3746 $per_page_label = _x( 'Users', 'users per page (screen options)' );
3748 case 'edit-comments':
3749 $per_page_label = _x( 'Comments', 'comments per page (screen options)' );
3752 $per_page_label = _x( 'Media items', 'items per page (screen options)' );
3756 $per_page_label = $tax->labels->name;
3759 $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' );
3765 $option = str_replace( '-', '_', "{$screen->id}_per_page" );
3766 if ( 'edit_tags_per_page' == $option ) {
3767 if ( 'category' == $tax->name )
3768 $option = 'categories_per_page';
3769 elseif ( 'post_tag' != $tax->name )
3770 $option = 'edit_' . $tax->name . '_per_page';
3773 $per_page = (int) get_user_option( $option );
3774 if ( empty( $per_page ) || $per_page < 1 ) {
3775 if ( 'plugins' == $screen->id )
3781 if ( 'edit_comments_per_page' == $option )
3782 $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
3783 elseif ( 'categories_per_page' == $option )
3784 $per_page = apply_filters( 'edit_categories_per_page', $per_page );
3786 $per_page = apply_filters( $option, $per_page );
3788 $return = "<div class='screen-options'>\n";
3789 if ( !empty($per_page_label) )
3790 $return .= "<input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' /> <label for='$option'>$per_page_label</label>\n";
3791 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";
3792 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
3793 $return .= "</div>\n";
3797 function screen_icon($screen = '') {
3798 global $current_screen;
3800 if ( empty($screen) )
3801 $screen = $current_screen;
3802 elseif ( is_string($screen) )
3805 if ( empty($name) ) {
3806 if ( !empty($screen->parent_base) )
3807 $name = $screen->parent_base;
3809 $name = $screen->base;
3811 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )
3812 $name = 'edit-pages';
3816 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
3821 * Test support for compressing JavaScript from PHP
3823 * Outputs JavaScript that tests if compression from PHP works as expected
3824 * and sets an option with the result. Has no effect when the current user
3825 * is not an administrator. To run the test again the option 'can_compress_scripts'
3826 * has to be deleted.
3830 function compression_test() {
3832 <script type="text/javascript">
3834 var testCompression = {
3835 get : function(test) {
3837 if ( window.XMLHttpRequest ) {
3838 x = new XMLHttpRequest();
3840 try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
3844 x.onreadystatechange = function() {
3846 if ( x.readyState == 4 ) {
3847 r = x.responseText.substr(0, 18);
3848 h = x.getResponseHeader('Content-Encoding');
3849 testCompression.check(r, h, test);
3853 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
3858 check : function(r, h, test) {
3859 if ( ! r && ! test )
3863 if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
3872 if ( '"wpCompressionTest' == r )
3879 testCompression.check();
3886 * Set the current screen object
3890 * @uses $current_screen
3892 * @param string $id Screen id, optional.
3894 function set_current_screen( $id = '' ) {
3895 global $current_screen, $hook_suffix, $typenow, $taxnow;
3900 $current_screen = $hook_suffix;
3901 $current_screen = str_replace('.php', '', $current_screen);
3902 if ( preg_match('/-add|-new$/', $current_screen) )
3904 $current_screen = str_replace('-new', '', $current_screen);
3905 $current_screen = str_replace('-add', '', $current_screen);
3906 $current_screen = array('id' => $current_screen, 'base' => $current_screen);
3908 $id = sanitize_key($id);
3909 if ( false !== strpos($id, '-') ) {
3910 list( $id, $typenow ) = explode('-', $id, 2);
3911 if ( taxonomy_exists( $typenow ) ) {
3917 $current_screen = array('id' => $id, 'base' => $id);
3920 $current_screen = (object) $current_screen;
3922 $current_screen->action = $action;
3924 // Map index to dashboard
3925 if ( 'index' == $current_screen->base )
3926 $current_screen->base = 'dashboard';
3927 if ( 'index' == $current_screen->id )
3928 $current_screen->id = 'dashboard';
3930 if ( 'edit' == $current_screen->id ) {
3931 if ( empty($typenow) )
3933 $current_screen->id .= '-' . $typenow;
3934 $current_screen->post_type = $typenow;
3935 } elseif ( 'post' == $current_screen->id ) {
3936 if ( empty($typenow) )
3938 $current_screen->id = $typenow;
3939 $current_screen->post_type = $typenow;
3940 } elseif ( 'edit-tags' == $current_screen->id ) {
3941 if ( empty($taxnow) )
3942 $taxnow = 'post_tag';
3943 $current_screen->id = 'edit-' . $taxnow;
3944 $current_screen->taxonomy = $taxnow;
3947 $current_screen = apply_filters('current_screen', $current_screen);