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 ) {
850 global $current_user, $mode;
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( $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_user, $current_screen;
1275 $global_post = $post;
1277 setup_postdata($post);
1279 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1280 $post_owner = ( $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?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?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 $current_user = wp_get_current_user();
1800 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1801 $user_object = new WP_User( (int) $user_object );
1802 $user_object = sanitize_user_object($user_object, 'display');
1803 $email = $user_object->user_email;
1804 $url = $user_object->user_url;
1805 $short_url = str_replace( 'http://', '', $url );
1806 $short_url = str_replace( 'www.', '', $short_url );
1807 if ('/' == substr( $short_url, -1 ))
1808 $short_url = substr( $short_url, 0, -1 );
1809 if ( strlen( $short_url ) > 35 )
1810 $short_url = substr( $short_url, 0, 32 ).'...';
1812 // Check if the user for this row is editable
1813 if ( current_user_can( 'list_users' ) ) {
1814 // Set up the user editing link
1815 // TODO: make profile/user-edit determination a separate function
1816 if ($current_user->ID == $user_object->ID) {
1817 $edit_link = 'profile.php';
1819 $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" ) );
1821 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1823 // Set up the hover actions for this user
1826 if ( current_user_can('edit_user', $user_object->ID) ) {
1827 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1828 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1830 $edit = "<strong>$user_object->user_login</strong><br />";
1833 if ( !is_multisite() && $current_user->ID != $user_object->ID && current_user_can('delete_user', $user_object->ID) )
1834 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1835 if ( is_multisite() && $current_user->ID != $user_object->ID && current_user_can('remove_user', $user_object->ID) )
1836 $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=remove&user=$user_object->ID", 'bulk-users') . "'>" . __('Remove') . "</a>";
1837 $actions = apply_filters('user_row_actions', $actions, $user_object);
1838 $action_count = count($actions);
1840 $edit .= '<div class="row-actions">';
1841 foreach ( $actions as $action => $link ) {
1843 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1844 $edit .= "<span class='$action'>$link$sep</span>";
1848 // Set up the checkbox (because the user is editable, otherwise its empty)
1849 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
1852 $edit = '<strong>' . $user_object->user_login . '</strong>';
1854 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
1855 $r = "<tr id='user-$user_object->ID'$style>";
1856 $columns = get_column_headers('users');
1857 $hidden = get_hidden_columns('users');
1858 $avatar = get_avatar( $user_object->ID, 32 );
1859 foreach ( $columns as $column_name => $column_display_name ) {
1860 $class = "class=\"$column_name column-$column_name\"";
1863 if ( in_array($column_name, $hidden) )
1864 $style = ' style="display:none;"';
1866 $attributes = "$class$style";
1868 switch ($column_name) {
1870 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
1873 $r .= "<td $attributes>$avatar $edit</td>";
1876 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1879 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('E-mail: %s' ), $email ) . "'>$email</a></td>";
1882 $r .= "<td $attributes>$role_name</td>";
1885 $attributes = 'class="posts column-posts num"' . $style;
1886 $r .= "<td $attributes>";
1887 if ( $numposts > 0 ) {
1888 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1897 $r .= "<td $attributes>";
1898 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
1908 * {@internal Missing Short Description}}
1912 * @param string $status Comment status (approved, spam, trash, etc)
1913 * @param string $s Term to search for
1914 * @param int $start Offset to start at for pagination
1915 * @param int $num Maximum number of comments to return
1916 * @param int $post Post ID or 0 to return all comments
1917 * @param string $type Comment type (comment, trackback, pingback, etc)
1918 * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num)
1920 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
1923 $start = abs( (int) $start );
1925 $post = (int) $post;
1926 $count = wp_count_comments();
1929 if ( 'moderated' == $status ) {
1930 $approved = "c.comment_approved = '0'";
1931 $total = $count->moderated;
1932 } elseif ( 'approved' == $status ) {
1933 $approved = "c.comment_approved = '1'";
1934 $total = $count->approved;
1935 } elseif ( 'spam' == $status ) {
1936 $approved = "c.comment_approved = 'spam'";
1937 $total = $count->spam;
1938 } elseif ( 'trash' == $status ) {
1939 $approved = "c.comment_approved = 'trash'";
1940 $total = $count->trash;
1942 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
1943 $total = $count->moderated + $count->approved;
1944 $index = 'USE INDEX (c.comment_date_gmt)';
1949 $post = " AND c.comment_post_ID = '$post'";
1954 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
1956 if ( 'comment' == $type )
1957 $typesql = "AND c.comment_type = ''";
1958 elseif ( 'pings' == $type )
1959 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
1960 elseif ( 'all' == $type )
1962 elseif ( !empty($type) )
1963 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
1967 if ( !empty($type) )
1970 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
1973 $s = $wpdb->escape($s);
1975 (c.comment_author LIKE '%$s%' OR
1976 c.comment_author_email LIKE '%$s%' OR
1977 c.comment_author_url LIKE ('%$s%') OR
1978 c.comment_author_IP LIKE ('%$s%') OR
1979 c.comment_content LIKE ('%$s%') ) AND
1983 $query .= "AND $approved $post $typesql";
1986 $comments = $wpdb->get_results("SELECT * $query $orderby");
1987 if ( '' === $total )
1988 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
1990 update_comment_cache($comments);
1992 return array($comments, $total);
1996 * {@internal Missing Short Description}}
2000 * @param unknown_type $comment_id
2001 * @param unknown_type $mode
2002 * @param unknown_type $comment_status
2003 * @param unknown_type $checkbox
2005 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
2006 global $comment, $post, $_comment_pending_count;
2007 $comment = get_comment( $comment_id );
2008 $post = get_post($comment->comment_post_ID);
2009 $the_comment_status = wp_get_comment_status($comment->comment_ID);
2010 $post_type_object = get_post_type_object($post->post_type);
2011 $user_can = current_user_can($post_type_object->cap->edit_post, $post->ID);
2013 $comment_url = esc_url(get_comment_link($comment->comment_ID));
2014 $author_url = get_comment_author_url();
2015 if ( 'http://' == $author_url )
2017 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);
2018 if ( strlen($author_url_display) > 50 )
2019 $author_url_display = substr($author_url_display, 0, 49) . '...';
2021 $ptime = date('G', strtotime( $comment->comment_date ) );
2022 if ( ( abs(time() - $ptime) ) < 86400 )
2023 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
2025 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
2028 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
2029 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
2031 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2032 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2033 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2034 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2035 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2036 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2037 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2040 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2041 $columns = get_column_headers('edit-comments');
2042 $hidden = get_hidden_columns('edit-comments');
2043 foreach ( $columns as $column_name => $column_display_name ) {
2044 $class = "class=\"$column_name column-$column_name\"";
2047 if ( in_array($column_name, $hidden) )
2048 $style = ' style="display:none;"';
2050 $attributes = "$class$style";
2052 switch ($column_name) {
2054 if ( !$checkbox ) break;
2055 echo '<th scope="row" class="check-column">';
2056 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2060 echo "<td $attributes>";
2061 echo '<div id="submitted-on">';
2062 /* translators: 2: comment date, 3: comment time */
2063 printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
2064 /* translators: comment date format. See http://php.net/date */ get_comment_date( __('Y/m/d') ),
2065 /* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
2067 if ( $comment->comment_parent ) {
2068 $parent = get_comment( $comment->comment_parent );
2069 $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
2070 $name = apply_filters( 'get_comment_author', $parent->comment_author ); // there's no API function for this
2071 printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
2076 if ( $user_can ) { ?>
2077 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2078 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>
2079 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
2080 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
2081 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2082 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2088 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
2090 'approve' => '', 'unapprove' => '',
2094 'spam' => '', 'unspam' => '',
2095 'trash' => '', 'untrash' => '', 'delete' => ''
2098 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2099 if ( 'approved' == $the_comment_status )
2100 $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>';
2101 else if ( 'unapproved' == $the_comment_status )
2102 $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>';
2104 $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>';
2105 $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>';
2108 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
2109 $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>';
2110 } elseif ( 'spam' == $the_comment_status ) {
2111 $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>';
2112 } elseif ( 'trash' == $the_comment_status ) {
2113 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
2116 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
2117 $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>';
2119 $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>';
2122 if ( 'trash' != $the_comment_status ) {
2123 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
2124 $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>';
2125 if ( 'spam' != $the_comment_status )
2126 $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>';
2129 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
2132 echo '<div class="row-actions">';
2133 foreach ( $actions as $action => $link ) {
2135 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2137 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2138 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2139 $action .= ' hide-if-no-js';
2140 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {
2141 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
2142 $action .= ' approve';
2144 $action .= ' unapprove';
2147 echo "<span class='$action'>$sep$link</span>";
2155 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2156 if ( !empty($author_url) )
2157 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2159 if ( !empty($comment->comment_author_email) ) {
2160 comment_author_email_link();
2163 echo '<a href="edit-comments.php?s=';
2164 comment_author_IP();
2165 echo '&mode=detail';
2166 if ( 'spam' == $comment_status )
2167 echo '&comment_status=spam';
2169 comment_author_IP();
2171 } //current_user_can
2175 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2178 if ( 'single' !== $mode ) {
2179 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2180 $pending_comments = $_comment_pending_count[$post->ID];
2182 $_comment_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
2183 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2186 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2187 $post_link .= get_the_title($post->ID) . '</a>';
2189 $post_link = get_the_title($post->ID);
2191 echo "<td $attributes>\n";
2192 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2193 echo $post_link . '<br />';
2194 $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) ));
2195 if ( $pending_comments )
2197 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>');
2198 if ( $pending_comments )
2201 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2203 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2209 echo "<td $attributes>\n";
2210 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2219 * {@internal Missing Short Description}}
2223 * @param unknown_type $position
2224 * @param unknown_type $checkbox
2225 * @param unknown_type $mode
2227 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2228 global $current_user;
2230 // allow plugin to replace the popup content
2231 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2233 if ( ! empty($content) ) {
2238 $columns = get_column_headers('edit-comments');
2239 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2240 $col_count = count($columns) - count($hidden);
2243 <form method="get" action="">
2244 <?php if ( $table_row ) : ?>
2245 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>">
2247 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
2249 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2251 <div id="edithead" style="display:none;">
2252 <div class="inside">
2253 <label for="author"><?php _e('Name') ?></label>
2254 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2257 <div class="inside">
2258 <label for="author-email"><?php _e('E-mail') ?></label>
2259 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2262 <div class="inside">
2263 <label for="author-url"><?php _e('URL') ?></label>
2264 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2266 <div style="clear:both;"></div>
2269 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2271 <p id="replysubmit" class="submit">
2272 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2273 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2274 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2275 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2276 <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
2277 <span class="error" style="display:none;"></span>
2278 <br class="clear" />
2281 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2282 <input type="hidden" name="action" id="action" value="" />
2283 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2284 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2285 <input type="hidden" name="status" id="status" value="" />
2286 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2287 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2288 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2289 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false ); ?>
2290 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2291 <?php if ( $table_row ) : ?>
2292 </td></tr></tbody></table>
2301 * Output 'undo move to trash' text for comments
2305 function wp_comment_trashnotice() {
2307 <div class="hidden" id="trash-undo-holder">
2308 <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>
2310 <div class="hidden" id="spam-undo-holder">
2311 <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>
2317 * {@internal Missing Short Description}}
2321 * @param unknown_type $meta
2323 function list_meta( $meta ) {
2327 <table id="list-table" style="display: none;">
2330 <th class="left">' . __( 'Name' ) . '</th>
2331 <th>' . __( 'Value' ) . '</th>
2334 <tbody id="the-list" class="list:meta">
2337 </table>'; //TBODY needed for list-manipulation JS
2342 <table id="list-table">
2345 <th class="left"><?php _e( 'Name' ) ?></th>
2346 <th><?php _e( 'Value' ) ?></th>
2349 <tbody id='the-list' class='list:meta'>
2351 foreach ( $meta as $entry )
2352 echo _list_meta_row( $entry, $count );
2360 * {@internal Missing Short Description}}
2364 * @param unknown_type $entry
2365 * @param unknown_type $count
2368 function _list_meta_row( $entry, &$count ) {
2369 static $update_nonce = false;
2370 if ( !$update_nonce )
2371 $update_nonce = wp_create_nonce( 'add-meta' );
2376 $style = 'alternate';
2379 if ('_' == $entry['meta_key'] { 0 } )
2380 $style .= ' hidden';
2382 if ( is_serialized( $entry['meta_value'] ) ) {
2383 if ( is_serialized_string( $entry['meta_value'] ) ) {
2384 // this is a serialized string, so we should display it
2385 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2387 // this is a serialized array/object so we should NOT display it
2393 $entry['meta_key'] = esc_attr($entry['meta_key']);
2394 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2395 $entry['meta_id'] = (int) $entry['meta_id'];
2397 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2399 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2400 $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']}' />";
2402 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2403 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2404 $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>";
2405 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2408 $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>";
2413 * {@internal Missing Short Description}}
2417 function meta_form() {
2419 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2420 $keys = $wpdb->get_col( "
2422 FROM $wpdb->postmeta
2424 HAVING meta_key NOT LIKE '\_%'
2430 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
2431 <table id="newmeta">
2434 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2435 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2441 <td id="newmetaleft" class="left">
2442 <?php if ( $keys ) { ?>
2443 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2444 <option value="#NONE#"><?php _e( '— Select —' ); ?></option>
2447 foreach ( $keys as $key ) {
2448 echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
2452 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2453 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2454 <span id="enternew"><?php _e('Enter new'); ?></span>
2455 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2457 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2460 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2463 <tr><td colspan="2" class="submit">
2464 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2465 <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
2474 * {@internal Missing Short Description}}
2478 * @param unknown_type $edit
2479 * @param unknown_type $for_post
2480 * @param unknown_type $tab_index
2481 * @param unknown_type $multi
2483 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2484 global $wp_locale, $post, $comment;
2487 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
2489 $tab_index_attribute = '';
2490 if ( (int) $tab_index > 0 )
2491 $tab_index_attribute = " tabindex=\"$tab_index\"";
2493 // 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 />';
2495 $time_adj = current_time('timestamp');
2496 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2497 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2498 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2499 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2500 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2501 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2502 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2504 $cur_jj = gmdate( 'd', $time_adj );
2505 $cur_mm = gmdate( 'm', $time_adj );
2506 $cur_aa = gmdate( 'Y', $time_adj );
2507 $cur_hh = gmdate( 'H', $time_adj );
2508 $cur_mn = gmdate( 'i', $time_adj );
2510 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2511 for ( $i = 1; $i < 13; $i = $i +1 ) {
2512 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2514 $month .= ' selected="selected"';
2515 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2517 $month .= '</select>';
2519 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2520 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2521 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2522 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2524 echo '<div class="timestamp-wrap">';
2525 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2526 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2528 echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2530 if ( $multi ) return;
2533 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2534 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2535 $cur_timeunit = 'cur_' . $timeunit;
2536 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2541 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2542 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2548 * {@internal Missing Short Description}}
2552 * @param unknown_type $default
2554 function page_template_dropdown( $default = '' ) {
2555 $templates = get_page_templates();
2556 ksort( $templates );
2557 foreach (array_keys( $templates ) as $template )
2558 : if ( $default == $templates[$template] )
2559 $selected = " selected='selected'";
2562 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2567 * {@internal Missing Short Description}}
2571 * @param unknown_type $default
2572 * @param unknown_type $parent
2573 * @param unknown_type $level
2576 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2577 global $wpdb, $post_ID;
2578 $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) );
2581 foreach ( $items as $item ) {
2582 // A page cannot be its own parent.
2583 if (!empty ( $post_ID ) ) {
2584 if ( $item->ID == $post_ID ) {
2588 $pad = str_repeat( ' ', $level * 3 );
2589 if ( $item->ID == $default)
2590 $current = ' selected="selected"';
2594 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2595 parent_dropdown( $default, $item->ID, $level +1 );
2603 * {@internal Missing Short Description}}
2607 * @param unknown_type $id
2610 function the_attachment_links( $id = false ) {
2612 $post = & get_post( $id );
2614 if ( $post->post_type != 'attachment' )
2617 $icon = wp_get_attachment_image( $post->ID, 'thumbnail', true );
2618 $attachment_data = wp_get_attachment_metadata( $id );
2619 $thumb = isset( $attachment_data['thumb'] );
2621 <form id="the-attachment-links">
2624 <col class="widefat" />
2626 <th scope="row"><?php _e( 'URL' ) ?></th>
2627 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2629 <?php if ( $icon ) : ?>
2631 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2632 <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>
2635 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2636 <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>
2640 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2641 <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>
2644 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2645 <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>
2655 * Print out <option> html elements for role selectors based on $wp_roles
2657 * @package WordPress
2658 * @subpackage Administration
2662 * @param string $default slug for the role that should be already selected
2664 function wp_dropdown_roles( $selected = false ) {
2668 $editable_roles = get_editable_roles();
2670 foreach ( $editable_roles as $role => $details ) {
2671 $name = translate_user_role($details['name'] );
2672 if ( $selected == $role ) // Make default first in list
2673 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2675 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2681 * {@internal Missing Short Description}}
2685 * @param unknown_type $size
2688 function wp_convert_hr_to_bytes( $size ) {
2689 $size = strtolower($size);
2690 $bytes = (int) $size;
2691 if ( strpos($size, 'k') !== false )
2692 $bytes = intval($size) * 1024;
2693 elseif ( strpos($size, 'm') !== false )
2694 $bytes = intval($size) * 1024 * 1024;
2695 elseif ( strpos($size, 'g') !== false )
2696 $bytes = intval($size) * 1024 * 1024 * 1024;
2701 * {@internal Missing Short Description}}
2705 * @param unknown_type $bytes
2708 function wp_convert_bytes_to_hr( $bytes ) {
2709 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2710 $log = log( $bytes, 1024 );
2711 $power = (int) $log;
2712 $size = pow(1024, $log - $power);
2713 return $size . $units[$power];
2717 * {@internal Missing Short Description}}
2723 function wp_max_upload_size() {
2724 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2725 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2726 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2731 * Outputs the form used by the importers to accept the data to be imported
2735 * @param string $action The action attribute for the form.
2737 function wp_import_upload_form( $action ) {
2738 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2739 $size = wp_convert_bytes_to_hr( $bytes );
2740 $upload_dir = wp_upload_dir();
2741 if ( ! empty( $upload_dir['error'] ) ) :
2742 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2743 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2746 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
2748 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2749 <input type="file" id="upload" name="import" size="25" />
2750 <input type="hidden" name="action" value="save" />
2751 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2754 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2762 * Add a meta box to an edit form.
2766 * @param string $id String for use in the 'id' attribute of tags.
2767 * @param string $title Title of the meta box.
2768 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2769 * @param string $page The type of edit page on which to show the box (post, page, link).
2770 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2771 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2773 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2774 global $wp_meta_boxes;
2776 if ( !isset($wp_meta_boxes) )
2777 $wp_meta_boxes = array();
2778 if ( !isset($wp_meta_boxes[$page]) )
2779 $wp_meta_boxes[$page] = array();
2780 if ( !isset($wp_meta_boxes[$page][$context]) )
2781 $wp_meta_boxes[$page][$context] = array();
2783 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2784 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2785 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2788 // If a core box was previously added or removed by a plugin, don't add.
2789 if ( 'core' == $priority ) {
2790 // If core box previously deleted, don't add
2791 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2793 // If box was added with default priority, give it core priority to maintain sort order
2794 if ( 'default' == $a_priority ) {
2795 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2796 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2800 // If no priority given and id already present, use existing priority
2801 if ( empty($priority) ) {
2802 $priority = $a_priority;
2803 // 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.
2804 } elseif ( 'sorted' == $priority ) {
2805 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2806 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2807 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2809 // An id can be in only one priority and one context
2810 if ( $priority != $a_priority || $context != $a_context )
2811 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2815 if ( empty($priority) )
2818 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2819 $wp_meta_boxes[$page][$context][$priority] = array();
2821 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2825 * Meta-Box template function
2829 * @param string $page page identifier, also known as screen identifier
2830 * @param string $context box context
2831 * @param mixed $object gets passed to the box callback function as first parameter
2832 * @return int number of meta_boxes
2834 function do_meta_boxes($page, $context, $object) {
2835 global $wp_meta_boxes;
2836 static $already_sorted = false;
2838 $hidden = get_hidden_meta_boxes($page);
2840 printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
2844 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2845 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
2846 foreach ( $sorted as $box_context => $ids )
2847 foreach ( explode(',', $ids) as $id )
2849 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2851 $already_sorted = true;
2853 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2856 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2857 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2858 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2859 if ( false == $box || ! $box['title'] )
2863 $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
2864 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
2865 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
2866 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
2867 echo '<div class="inside">' . "\n";
2868 call_user_func($box['callback'], $object, $box);
2883 * Remove a meta box from an edit form.
2887 * @param string $id String for use in the 'id' attribute of tags.
2888 * @param string $page The type of edit page on which to show the box (post, page, link).
2889 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2891 function remove_meta_box($id, $page, $context) {
2892 global $wp_meta_boxes;
2894 if ( !isset($wp_meta_boxes) )
2895 $wp_meta_boxes = array();
2896 if ( !isset($wp_meta_boxes[$page]) )
2897 $wp_meta_boxes[$page] = array();
2898 if ( !isset($wp_meta_boxes[$page][$context]) )
2899 $wp_meta_boxes[$page][$context] = array();
2901 foreach ( array('high', 'core', 'default', 'low') as $priority )
2902 $wp_meta_boxes[$page][$context][$priority][$id] = false;
2906 * {@internal Missing Short Description}}
2910 * @param unknown_type $screen
2912 function meta_box_prefs($screen) {
2913 global $wp_meta_boxes;
2915 if ( is_string($screen) )
2916 $screen = convert_to_screen($screen);
2918 if ( empty($wp_meta_boxes[$screen->id]) )
2921 $hidden = get_hidden_meta_boxes($screen);
2923 foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
2924 foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
2925 foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
2926 if ( false == $box || ! $box['title'] )
2928 // Submit box cannot be hidden
2929 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
2931 $box_id = $box['id'];
2932 echo '<label for="' . $box_id . '-hide">';
2933 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"' : '') . ' />';
2934 echo "{$box['title']}</label>\n";
2941 * Get Hidden Meta Boxes
2945 * @param string|object $screen Screen identifier
2946 * @return array Hidden Meta Boxes
2948 function get_hidden_meta_boxes( $screen ) {
2949 if ( is_string( $screen ) )
2950 $screen = convert_to_screen( $screen );
2952 $hidden = get_user_option( "metaboxhidden_{$screen->id}" );
2954 // Hide slug boxes by default
2955 if ( !is_array( $hidden ) )
2956 $hidden = array('slugdiv');
2962 * Add a new section to a settings page.
2964 * Part of the Settings API. Use this to define new settings sections for an admin page.
2965 * Show settings sections in your admin page callback function with do_settings_sections().
2966 * Add settings fields to your section with add_settings_field()
2968 * The $callback argument should be the name of a function that echoes out any
2969 * content you want to show at the top of the settings section before the actual
2970 * fields. It can output nothing if you want.
2974 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
2976 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
2977 * @param string $title Formatted title of the section. Shown as the heading for the section.
2978 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
2979 * @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();
2981 function add_settings_section($id, $title, $callback, $page) {
2982 global $wp_settings_sections;
2984 if ( 'misc' == $page ) {
2985 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
2989 if ( !isset($wp_settings_sections) )
2990 $wp_settings_sections = array();
2991 if ( !isset($wp_settings_sections[$page]) )
2992 $wp_settings_sections[$page] = array();
2993 if ( !isset($wp_settings_sections[$page][$id]) )
2994 $wp_settings_sections[$page][$id] = array();
2996 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
3000 * Add a new field to a section of a settings page
3002 * Part of the Settings API. Use this to define a settings field that will show
3003 * as part of a settings section inside a settings page. The fields are shown using
3004 * do_settings_fields() in do_settings-sections()
3006 * The $callback argument should be the name of a function that echoes out the
3007 * html input tags for this setting field. Use get_option() to retrive existing
3012 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
3014 * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
3015 * @param string $title Formatted title of the field. Shown as the label for the field during output.
3016 * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
3017 * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
3018 * @param string $section The slug-name of the section of the settingss page in which to show the box (default, ...).
3019 * @param array $args Additional arguments
3021 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3022 global $wp_settings_fields;
3024 if ( 'misc' == $page ) {
3025 _deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
3029 if ( !isset($wp_settings_fields) )
3030 $wp_settings_fields = array();
3031 if ( !isset($wp_settings_fields[$page]) )
3032 $wp_settings_fields[$page] = array();
3033 if ( !isset($wp_settings_fields[$page][$section]) )
3034 $wp_settings_fields[$page][$section] = array();
3036 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3040 * Prints out all settings sections added to a particular settings page
3042 * Part of the Settings API. Use this in a settings page callback function
3043 * to output all the sections and fields that were added to that $page with
3044 * add_settings_section() and add_settings_field()
3046 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
3047 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
3050 * @param string $page The slug name of the page whos settings sections you want to output
3052 function do_settings_sections($page) {
3053 global $wp_settings_sections, $wp_settings_fields;
3055 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3058 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3059 echo "<h3>{$section['title']}</h3>\n";
3060 call_user_func($section['callback'], $section);
3061 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3063 echo '<table class="form-table">';
3064 do_settings_fields($page, $section['id']);
3070 * Print out the settings fields for a particular settings section
3072 * Part of the Settings API. Use this in a settings page to output
3073 * a specific section. Should normally be called by do_settings_sections()
3074 * rather than directly.
3076 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
3080 * @param string $page Slug title of the admin page who's settings fields you want to show.
3081 * @param section $section Slug title of the settings section who's fields you want to show.
3083 function do_settings_fields($page, $section) {
3084 global $wp_settings_fields;
3086 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3089 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3090 echo '<tr valign="top">';
3091 if ( !empty($field['args']['label_for']) )
3092 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3094 echo '<th scope="row">' . $field['title'] . '</th>';
3096 call_user_func($field['callback'], $field['args']);
3103 * Register a settings error to be displayed to the user
3105 * Part of the Settings API. Use this to show messages to users about settings validation
3106 * problems, missing settings or anything else.
3108 * Settings errors should be added inside the $sanitize_callback function defined in
3109 * register_setting() for a given setting to give feedback about the submission.
3111 * By default messages will show immediately after the submission that generated the error.
3112 * Additional calls to settings_errors() can be used to show errors even when the settings
3113 * page is first accessed.
3115 * @global array $wp_settings_errors Storage array of errors registered during this pageload
3117 * @param string $setting Slug title of the setting to which this error applies
3118 * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
3119 * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
3120 * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
3122 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
3123 global $wp_settings_errors;
3125 if ( !isset($wp_settings_errors) )
3126 $wp_settings_errors = array();
3129 'setting' => $setting,
3131 'message' => $message,
3134 $wp_settings_errors[] = $new_error;
3138 * Fetch settings errors registered by add_settings_error()
3140 * Checks the $wp_settings_errors array for any errors declared during the current
3141 * pageload and returns them.
3143 * If changes were just submitted ($_GET['updated']) and settings errors were saved
3144 * to the 'settings_errors' transient then those errors will be returned instead. This
3145 * is used to pass errors back across pageloads.
3147 * Use the $sanitize argument to manually re-sanitize the option before returning errors.
3148 * This is useful if you have errors or notices you want to show even when the user
3149 * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
3151 * @global array $wp_settings_errors Storage array of errors registered during this pageload
3153 * @param string $setting Optional slug title of a specific setting who's errors you want.
3154 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
3155 * @return array Array of settings errors
3157 function get_settings_errors( $setting = '', $sanitize = FALSE ) {
3158 global $wp_settings_errors;
3160 // If $sanitize is true, manually re-run the sanitizisation for this option
3161 // This allows the $sanitize_callback from register_setting() to run, adding
3162 // any settings errors you want to show by default.
3164 sanitize_option( $setting, get_option($setting));
3166 // If settings were passed back from options.php then use them
3167 // Ignore transients if $sanitize is true, we dont' want the old values anyway
3168 if ( isset($_GET['updated']) && $_GET['updated'] && get_transient('settings_errors') ) {
3169 $settings_errors = get_transient('settings_errors');
3170 delete_transient('settings_errors');
3171 // Otherwise check global in case validation has been run on this pageload
3172 } elseif ( count( $wp_settings_errors ) ) {
3173 $settings_errors = $wp_settings_errors;
3178 // Filter the results to those of a specific setting if one was set
3180 foreach ( (array) $settings_errors as $key => $details )
3181 if ( $setting != $details['setting'] )
3182 unset( $settings_errors[$key] );
3184 return $settings_errors;
3188 * Display settings errors registered by add_settings_error()
3190 * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
3192 * This is called automatically after a settings page based on the Settings API is submitted.
3193 * Errors should be added during the validation callback function for a setting defined in register_setting()
3195 * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
3196 * on its current value.
3198 * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
3199 * if the user has already saved new values it will be hidden to avoid repeating messages already
3200 * shown in the default error reporting after submission. This is useful to show general errors like missing
3201 * settings when the user arrives at the settings page.
3203 * @param string $setting Optional slug title of a specific setting who's errors you want.
3204 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
3205 * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
3208 function settings_errors ( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {
3210 if ($hide_on_update AND $_GET['updated']) return;
3212 $settings_errors = get_settings_errors( $setting, $sanitize );
3214 if ( !is_array($settings_errors) ) return;
3217 foreach ( $settings_errors as $key => $details ) {
3218 $css_id = 'setting-error-' . $details['code'];
3219 $css_class = $details['type'] . ' settings-error';
3220 $output .= "<div id='$css_id' class='$css_class'> \n";
3221 $output .= "<p><strong>{$details['message']}</strong></p>";
3222 $output .= "</div> \n";
3228 * {@internal Missing Short Description}}
3232 * @param unknown_type $page
3234 function manage_columns_prefs( $page ) {
3235 $columns = get_column_headers( $page );
3236 $hidden = get_hidden_columns( $page );
3237 $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username');
3239 foreach ( $columns as $column => $title ) {
3240 // Can't hide these or they are special
3241 if ( in_array( $column, $special ) )
3243 if ( empty( $title ) )
3246 if ( 'comments' == $column )
3247 $title = __( 'Comments' );
3248 $id = "$column-hide";
3249 echo '<label for="' . $id . '">';
3250 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3251 echo "$title</label>\n";
3256 * {@internal Missing Short Description}}
3260 * @param unknown_type $found_action
3262 function find_posts_div($found_action = '') {
3264 <div id="find-posts" class="find-box" style="display:none;">
3265 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3266 <div class="find-box-inside">
3267 <div class="find-box-search">
3268 <?php if ( $found_action ) { ?>
3269 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3272 <input type="hidden" name="affected" id="affected" value="" />
3273 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3274 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3275 <input type="text" id="find-posts-input" name="ps" value="" />
3276 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3279 $post_types = get_post_types( array('public' => true), 'objects' );
3280 foreach ( $post_types as $post ) {
3281 if ( 'attachment' == $post->name )
3284 <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'); ?> />
3285 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
3289 <div id="find-posts-response"></div>
3291 <div class="find-box-buttons">
3292 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3293 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3300 * Display the post password.
3302 * The password is passed through {@link esc_attr()} to ensure that it
3303 * is safe for placing in an html attribute.
3308 function the_post_password() {
3310 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3314 * {@internal Missing Short Description}}
3318 function favorite_actions( $screen = null ) {
3319 $default_action = false;
3321 if ( is_string($screen) )
3322 $screen = convert_to_screen($screen);
3324 if ( isset($screen->post_type) ) {
3325 $post_type_object = get_post_type_object($screen->post_type);
3326 if ( 'add' != $screen->action )
3327 $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));
3329 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
3332 if ( !$default_action ) {
3333 switch ( $screen->id ) {
3335 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3338 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3340 case 'link-manager':
3342 if ( 'add' != $screen->action )
3343 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3345 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3348 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3351 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3354 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3356 case 'plugin-install':
3357 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3360 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3362 case 'theme-install':
3363 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3366 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3372 'post-new.php' => array(__('New Post'), 'edit_posts'),
3373 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3374 'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
3375 'media-new.php' => array(__('Upload'), 'upload_files'),
3376 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3379 $default_key = array_keys($default_action);
3380 $default_key = $default_key[0];
3381 if ( isset($actions[$default_key]) )
3382 unset($actions[$default_key]);
3383 $actions = array_merge($default_action, $actions);
3384 $actions = apply_filters('favorite_actions', $actions);
3386 $allowed_actions = array();
3387 foreach ( $actions as $action => $data ) {
3388 if ( current_user_can($data[1]) )
3389 $allowed_actions[$action] = $data[0];
3392 if ( empty($allowed_actions) )
3395 $first = array_keys($allowed_actions);
3397 echo '<div id="favorite-actions">';
3398 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3399 echo '<div id="favorite-inside">';
3401 array_shift($allowed_actions);
3403 foreach ( $allowed_actions as $action => $label) {
3404 echo "<div class='favorite-action'><a href='$action'>";
3406 echo "</a></div>\n";
3408 echo "</div></div>\n";
3412 * Get the post title.
3414 * The post title is fetched and if it is blank then a default string is
3418 * @param int $id The post id. If not supplied the global $post is used.
3421 function _draft_or_post_title($post_id = 0) {
3422 $title = get_the_title($post_id);
3423 if ( empty($title) )
3424 $title = __('(no title)');
3429 * Display the search query.
3431 * A simple wrapper to display the "s" parameter in a GET URI. This function
3432 * should only be used when {@link the_search_query()} cannot.
3438 function _admin_search_query() {
3439 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
3443 * Generic Iframe header for use with Thickbox
3446 * @param string $title Title of the Iframe page.
3447 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3450 function iframe_header( $title = '', $limit_styles = false ) {
3451 global $hook_suffix;
3452 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3453 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3455 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3456 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
3458 wp_enqueue_style( 'global' );
3459 if ( ! $limit_styles )
3460 wp_enqueue_style( 'wp-admin' );
3461 wp_enqueue_style( 'colors' );
3463 <script type="text/javascript">
3465 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();}}};
3466 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
3470 do_action('admin_print_styles');
3471 do_action('admin_print_scripts');
3472 do_action('admin_head');
3474 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
3477 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="no-js <?php echo $admin_body_class; ?>">
3478 <script type="text/javascript">
3481 var c = document.body.className;
3482 c = c.replace(/no-js/, 'js');
3483 document.body.className = c;
3491 * Generic Iframe footer for use with Thickbox
3496 function iframe_footer() {
3497 //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
3498 <div class="hidden">
3500 do_action('admin_footer', '');
3501 do_action('admin_print_footer_scripts'); ?>
3503 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
3509 function _post_states($post) {
3510 $post_states = array();
3511 if ( isset($_GET['post_status']) )
3512 $post_status = $_GET['post_status'];
3516 if ( !empty($post->post_password) )
3517 $post_states[] = __('Password protected');
3518 if ( 'private' == $post->post_status && 'private' != $post_status )
3519 $post_states[] = __('Private');
3520 if ( 'draft' == $post->post_status && 'draft' != $post_status )
3521 $post_states[] = __('Draft');
3522 if ( 'pending' == $post->post_status && 'pending' != $post_status )
3523 /* translators: post state */
3524 $post_states[] = _x('Pending', 'post state');
3525 if ( is_sticky($post->ID) )
3526 $post_states[] = __('Sticky');
3528 $post_states = apply_filters( 'display_post_states', $post_states );
3530 if ( ! empty($post_states) ) {
3531 $state_count = count($post_states);
3534 foreach ( $post_states as $state ) {
3536 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
3537 echo "<span class='post-state'>$state$sep</span>";
3543 * Convert a screen string to a screen object
3547 * @param string $screen The name of the screen
3548 * @return object An object containing the safe screen name and id
3550 function convert_to_screen( $screen ) {
3551 $screen = str_replace( array('.php', '-new', '-add' ), '', $screen);
3552 $screen = (string) apply_filters( 'screen_meta_screen', $screen );
3553 $screen = (object) array('id' => $screen, 'base' => $screen);
3557 function screen_meta($screen) {
3558 global $wp_meta_boxes, $_wp_contextual_help, $title;
3560 if ( is_string($screen) )
3561 $screen = convert_to_screen($screen);
3563 $column_screens = get_column_headers($screen);
3564 $meta_screens = array('index' => 'dashboard');
3566 if ( isset($meta_screens[$screen->id]) ) {
3567 $screen->id = $meta_screens[$screen->id];
3568 $screen->base = $screen->id;
3571 $show_screen = false;
3572 if ( !empty($wp_meta_boxes[$screen->id]) || !empty($column_screens) )
3573 $show_screen = true;
3575 $screen_options = screen_options($screen);
3576 if ( $screen_options )
3577 $show_screen = true;
3579 if ( !isset($_wp_contextual_help) )
3580 $_wp_contextual_help = array();
3582 $settings = apply_filters('screen_settings', '', $screen);
3584 switch ( $screen->id ) {
3586 $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";
3587 $show_screen = true;
3590 if( ! empty( $settings ) )
3591 $show_screen = true;
3593 <div id="screen-meta">
3594 <?php if ( $show_screen ) : ?>
3595 <div id="screen-options-wrap" class="hidden">
3596 <form id="adv-settings" action="" method="post">
3597 <?php if ( isset($wp_meta_boxes[$screen->id]) ) : ?>
3598 <h5><?php _ex('Show on screen', 'Metaboxes') ?></h5>
3599 <div class="metabox-prefs">
3600 <?php meta_box_prefs($screen); ?>
3601 <br class="clear" />
3604 if ( ! empty($column_screens) ) : ?>
3605 <h5><?php echo ( isset( $column_screens['_title'] ) ? $column_screens['_title'] : _x('Show on screen', 'Columns') ) ?></h5>
3606 <div class="metabox-prefs">
3607 <?php manage_columns_prefs($screen); ?>
3608 <br class="clear" />
3611 echo screen_layout($screen);
3613 if ( !empty( $screen_options ) ) {
3615 <h5><?php _ex('Show on screen', 'Screen Options') ?></h5>
3619 echo $screen_options;
3621 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
3625 <?php endif; // $show_screen
3627 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
3629 <div id="contextual-help-wrap" class="hidden">
3631 $contextual_help = '';
3632 if ( isset($_wp_contextual_help[$screen->id]) ) {
3633 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n";
3635 $contextual_help .= '<div class="metabox-prefs">';
3636 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
3637 $default_help .= '<br />';
3638 $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
3639 $contextual_help .= apply_filters('default_contextual_help', $default_help);
3640 $contextual_help .= "</div>\n";
3643 echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen);
3647 <div id="screen-meta-links">
3648 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
3649 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
3651 <?php if ( $show_screen ) { ?>
3652 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
3653 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
3662 * Add contextual help text for a page
3666 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
3667 * @param string $help Arbitrary help text
3669 function add_contextual_help($screen, $help) {
3670 global $_wp_contextual_help;
3672 if ( is_string($screen) )
3673 $screen = convert_to_screen($screen);
3675 if ( !isset($_wp_contextual_help) )
3676 $_wp_contextual_help = array();
3678 $_wp_contextual_help[$screen->id] = $help;
3681 function drag_drop_help() {
3683 <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>
3684 <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>
3688 function plugins_search_help() {
3690 <p><strong>' . __('Search help') . '</strong></p>' .
3691 '<p>' . __('You may search based on 3 criteria:') . '<br />' .
3692 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .
3693 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .
3694 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>
3698 function screen_layout($screen) {
3699 global $screen_layout_columns;
3701 if ( is_string($screen) )
3702 $screen = convert_to_screen($screen);
3704 $columns = array('dashboard' => 4, 'link' => 2);
3706 // Add custom post types
3707 foreach ( get_post_types( array('show_ui' => true) ) as $post_type )
3708 $columns[$post_type] = 2;
3710 $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen);
3712 if ( !isset($columns[$screen->id]) ) {
3713 $screen_layout_columns = 0;
3717 $screen_layout_columns = get_user_option("screen_layout_$screen->id");
3718 $num = $columns[$screen->id];
3720 if ( ! $screen_layout_columns )
3721 $screen_layout_columns = 2;
3724 $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
3725 while ( $i <= $num ) {
3726 $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
3729 $return .= "</div>\n";
3733 function screen_options($screen) {
3734 if ( is_string($screen) )
3735 $screen = convert_to_screen($screen);
3737 switch ( $screen->base ) {
3740 $post_type = 'post';
3741 if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
3742 $post_type = $_GET['post_type'];
3743 $post_type_object = get_post_type_object($post_type);
3744 $per_page_label = $post_type_object->labels->name;
3747 $per_page_label = _x( 'Sites', 'sites per page (screen options)' );
3750 $per_page_label = _x( 'Users', 'users per page (screen options)' );
3752 case 'edit-comments':
3753 $per_page_label = _x( 'Comments', 'comments per page (screen options)' );
3756 $per_page_label = _x( 'Media items', 'items per page (screen options)' );
3760 $per_page_label = $tax->labels->name;
3763 $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' );
3769 $option = str_replace( '-', '_', "{$screen->id}_per_page" );
3770 if ( 'edit_tags_per_page' == $option ) {
3771 if ( 'category' == $tax->name )
3772 $option = 'categories_per_page';
3773 elseif ( 'post_tag' != $tax->name )
3774 $option = 'edit_' . $tax->name . '_per_page';
3777 $per_page = (int) get_user_option( $option );
3778 if ( empty( $per_page ) || $per_page < 1 ) {
3779 if ( 'plugins' == $screen->id )
3785 if ( 'edit_comments_per_page' == $option )
3786 $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
3787 elseif ( 'categories_per_page' == $option )
3788 $per_page = apply_filters( 'edit_categories_per_page', $per_page );
3790 $per_page = apply_filters( $option, $per_page );
3792 $return = "<div class='screen-options'>\n";
3793 if ( !empty($per_page_label) )
3794 $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";
3795 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";
3796 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
3797 $return .= "</div>\n";
3801 function screen_icon($screen = '') {
3802 global $current_screen;
3804 if ( empty($screen) )
3805 $screen = $current_screen;
3806 elseif ( is_string($screen) )
3809 if ( empty($name) ) {
3810 if ( !empty($screen->parent_base) )
3811 $name = $screen->parent_base;
3813 $name = $screen->base;
3815 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )
3816 $name = 'edit-pages';
3820 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
3825 * Test support for compressing JavaScript from PHP
3827 * Outputs JavaScript that tests if compression from PHP works as expected
3828 * and sets an option with the result. Has no effect when the current user
3829 * is not an administrator. To run the test again the option 'can_compress_scripts'
3830 * has to be deleted.
3834 function compression_test() {
3836 <script type="text/javascript">
3838 var testCompression = {
3839 get : function(test) {
3841 if ( window.XMLHttpRequest ) {
3842 x = new XMLHttpRequest();
3844 try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
3848 x.onreadystatechange = function() {
3850 if ( x.readyState == 4 ) {
3851 r = x.responseText.substr(0, 18);
3852 h = x.getResponseHeader('Content-Encoding');
3853 testCompression.check(r, h, test);
3857 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
3862 check : function(r, h, test) {
3863 if ( ! r && ! test )
3867 if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
3876 if ( '"wpCompressionTest' == r )
3883 testCompression.check();
3890 * Set the current screen object
3894 * @uses $current_screen
3896 * @param string $id Screen id, optional.
3898 function set_current_screen( $id = '' ) {
3899 global $current_screen, $hook_suffix, $typenow, $taxnow;
3904 $current_screen = $hook_suffix;
3905 $current_screen = str_replace('.php', '', $current_screen);
3906 if ( preg_match('/-add|-new$/', $current_screen) )
3908 $current_screen = str_replace('-new', '', $current_screen);
3909 $current_screen = str_replace('-add', '', $current_screen);
3910 $current_screen = array('id' => $current_screen, 'base' => $current_screen);
3912 $id = sanitize_key($id);
3913 if ( false !== strpos($id, '-') ) {
3914 list( $id, $typenow ) = explode('-', $id, 2);
3915 if ( taxonomy_exists( $typenow ) ) {
3921 $current_screen = array('id' => $id, 'base' => $id);
3924 $current_screen = (object) $current_screen;
3926 $current_screen->action = $action;
3928 // Map index to dashboard
3929 if ( 'index' == $current_screen->base )
3930 $current_screen->base = 'dashboard';
3931 if ( 'index' == $current_screen->id )
3932 $current_screen->id = 'dashboard';
3934 if ( 'edit' == $current_screen->id ) {
3935 if ( empty($typenow) )
3937 $current_screen->id .= '-' . $typenow;
3938 $current_screen->post_type = $typenow;
3939 } elseif ( 'post' == $current_screen->id ) {
3940 if ( empty($typenow) )
3942 $current_screen->id = $typenow;
3943 $current_screen->post_type = $typenow;
3944 } elseif ( 'edit-tags' == $current_screen->id ) {
3945 if ( empty($taxnow) )
3946 $taxnow = 'post_tag';
3947 $current_screen->id = 'edit-' . $taxnow;
3948 $current_screen->taxonomy = $taxnow;
3951 $current_screen = apply_filters('current_screen', $current_screen);