3 * Template WordPress Administration API.
5 * A Big Mess. Also some neat functions that are nicely written.
8 * @subpackage Administration
11 // Ugly recursive category stuff.
13 * {@internal Missing Short Description}}
17 * @param unknown_type $parent
18 * @param unknown_type $level
19 * @param unknown_type $categories
20 * @param unknown_type $page
21 * @param unknown_type $per_page
23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
27 if ( empty($categories) ) {
29 $args = array('hide_empty' => 0);
30 if ( !empty($_GET['s']) )
31 $args['search'] = $_GET['s'];
33 $categories = get_categories( $args );
35 if ( empty($categories) )
39 $children = _get_term_hierarchy('category');
41 _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );
46 * {@internal Missing Short Description}}
50 * @param unknown_type $categories
51 * @param unknown_type $count
52 * @param unknown_type $parent
53 * @param unknown_type $level
54 * @param unknown_type $page
55 * @param unknown_type $per_page
58 function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) {
60 $start = ($page - 1) * $per_page;
61 $end = $start + $per_page;
64 foreach ( $categories as $key => $category ) {
68 if ( $category->parent != $parent && empty($_GET['s']) )
71 // If the page starts in a subtree, print the parents.
72 if ( $count == $start && $category->parent > 0 ) {
74 $my_parents = array();
75 $p = $category->parent;
77 $my_parent = get_category( $p );
78 $my_parents[] = $my_parent;
79 if ( $my_parent->parent == 0 )
81 $p = $my_parent->parent;
84 $num_parents = count($my_parents);
85 while( $my_parent = array_pop($my_parents) ) {
86 echo "\t" . _cat_row( $my_parent, $level - $num_parents );
91 if ( $count >= $start )
92 echo "\t" . _cat_row( $category, $level );
94 unset( $categories[ $key ] );
98 if ( isset($children[$category->term_id]) )
99 _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );
102 $output = ob_get_contents();
109 * {@internal Missing Short Description}}
113 * @param unknown_type $category
114 * @param unknown_type $level
115 * @param unknown_type $name_override
118 function _cat_row( $category, $level, $name_override = false ) {
119 static $row_class = '';
121 $category = get_category( $category, OBJECT, 'display' );
123 $default_cat_id = (int) get_option( 'default_category' );
124 $pad = str_repeat( '— ', max(0, $level) );
125 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
126 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id";
127 if ( current_user_can( 'manage_categories' ) ) {
128 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>" . esc_attr( $name ) . '</a><br />';
130 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
131 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
132 if ( $default_cat_id != $category->term_id )
133 $actions['delete'] = "<a class='delete:the-list:cat-$category->term_id submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
134 $actions = apply_filters('cat_row_actions', $actions, $category);
135 $action_count = count($actions);
137 $edit .= '<div class="row-actions">';
138 foreach ( $actions as $action => $link ) {
140 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
141 $edit .= "<span class='$action'>$link$sep</span>";
148 $row_class = 'alternate' == $row_class ? '' : 'alternate';
149 $qe_data = get_category_to_edit($category->term_id);
151 $category->count = number_format_i18n( $category->count );
152 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
153 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
155 $columns = get_column_headers('categories');
156 $hidden = get_hidden_columns('categories');
157 foreach ( $columns as $column_name => $column_display_name ) {
158 $class = "class=\"$column_name column-$column_name\"";
161 if ( in_array($column_name, $hidden) )
162 $style = ' style="display:none;"';
164 $attributes = "$class$style";
166 switch ($column_name) {
168 $output .= "<th scope='row' class='check-column'>";
169 if ( $default_cat_id != $category->term_id ) {
170 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
177 $output .= "<td $attributes>$edit";
178 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
179 $output .= '<div class="name">' . $qe_data->name . '</div>';
180 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
181 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
184 $output .= "<td $attributes>$category->description</td>";
187 $output .= "<td $attributes>$category->slug</td>";
190 $attributes = 'class="posts column-posts num"' . $style;
191 $output .= "<td $attributes>$posts_count</td>\n";
194 $output .= "<td $attributes>";
195 $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id);
205 * {@internal Missing Short Description}}
209 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
211 * @param string $type "tag", "category" or "link-category"
214 function inline_edit_term_row($type) {
216 if ( ! current_user_can( 'manage_categories' ) )
219 $is_tag = $type == 'edit-tags';
220 $columns = get_column_headers($type);
221 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
222 $col_count = count($columns) - count($hidden);
225 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
226 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
228 <fieldset><div class="inline-edit-col">
229 <h4><?php _e( 'Quick Edit' ); ?></h4>
232 <span class="title"><?php _e( 'Name' ); ?></span>
233 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
237 <span class="title"><?php _e( 'Slug' ); ?></span>
238 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
241 <?php if ( 'category' == $type ) : ?>
244 <span class="title"><?php _e( 'Parent' ); ?></span>
245 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
248 <?php endif; // $type ?>
254 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
256 foreach ( $columns as $column_name => $column_display_name ) {
257 if ( isset( $core_columns[$column_name] ) )
259 do_action( 'quick_edit_custom_box', $column_name, $type );
264 <p class="inline-edit-save submit">
265 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
266 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
267 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
268 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
269 <span class="error" style="display:none;"></span>
270 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
274 </tbody></table></form>
279 * {@internal Missing Short Description}}
283 * @param unknown_type $category
284 * @param unknown_type $name_override
287 function link_cat_row( $category, $name_override = false ) {
288 static $row_class = '';
290 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
292 if ( is_wp_error( $category ) )
295 $default_cat_id = (int) get_option( 'default_link_category' );
296 $name = ( $name_override ? $name_override : $category->name );
297 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
298 if ( current_user_can( 'manage_categories' ) ) {
299 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>$name</a><br />";
301 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
302 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
303 if ( $default_cat_id != $category->term_id )
304 $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>";
305 $actions = apply_filters('link_cat_row_actions', $actions, $category);
306 $action_count = count($actions);
308 $edit .= '<div class="row-actions">';
309 foreach ( $actions as $action => $link ) {
311 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
312 $edit .= "<span class='$action'>$link$sep</span>";
319 $row_class = 'alternate' == $row_class ? '' : 'alternate';
320 $qe_data = get_term_to_edit($category->term_id, 'link_category');
322 $category->count = number_format_i18n( $category->count );
323 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
324 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
325 $columns = get_column_headers('edit-link-categories');
326 $hidden = get_hidden_columns('edit-link-categories');
327 foreach ( $columns as $column_name => $column_display_name ) {
328 $class = "class=\"$column_name column-$column_name\"";
331 if ( in_array($column_name, $hidden) )
332 $style = ' style="display:none;"';
334 $attributes = "$class$style";
336 switch ($column_name) {
338 $output .= "<th scope='row' class='check-column'>";
339 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
340 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
347 $output .= "<td $attributes>$edit";
348 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
349 $output .= '<div class="name">' . $qe_data->name . '</div>';
350 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
351 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
354 $output .= "<td $attributes>$category->description</td>";
357 $output .= "<td $attributes>$category->slug</td>";
360 $attributes = 'class="links column-links num"' . $style;
361 $output .= "<td $attributes>$count</td>";
364 $output .= "<td $attributes>";
365 $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);
375 * Outputs the html checked attribute.
377 * Compares the first two arguments and if identical marks as checked
381 * @param any $checked One of the values to compare
382 * @param any $current (true) The other value to compare if not just true
383 * @param bool $echo Whether or not to echo or just return the string
385 function checked( $checked, $current = true, $echo = true) {
386 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
390 * Outputs the html selected attribute.
392 * Compares the first two arguments and if identical marks as selected
396 * @param any selected One of the values to compare
397 * @param any $current (true) The other value to compare if not just true
398 * @param bool $echo Whether or not to echo or just return the string
400 function selected( $selected, $current = true, $echo = true) {
401 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
405 * Private helper function for checked and selected.
407 * Compares the first two arguments and if identical marks as $type
412 * @param any $helper One of the values to compare
413 * @param any $current (true) The other value to compare if not just true
414 * @param bool $echo Whether or not to echo or just return the string
415 * @param string $type The type of checked|selected we are doing.
417 function __checked_selected_helper( $helper, $current, $echo, $type) {
418 if ( $helper == $current)
419 $result = " $type='$type'";
430 // Category Checklists
434 * {@internal Missing Short Description}}
437 * @deprecated Use {@link wp_link_category_checklist()}
438 * @see wp_link_category_checklist()
440 * @param unknown_type $default
441 * @param unknown_type $parent
442 * @param unknown_type $popular_ids
444 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
446 wp_category_checklist($post_ID);
450 * {@internal Missing Short Description}}
454 class Walker_Category_Checklist extends Walker {
455 var $tree_type = 'category';
456 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
458 function start_lvl(&$output, $depth, $args) {
459 $indent = str_repeat("\t", $depth);
460 $output .= "$indent<ul class='children'>\n";
463 function end_lvl(&$output, $depth, $args) {
464 $indent = str_repeat("\t", $depth);
465 $output .= "$indent</ul>\n";
468 function start_el(&$output, $category, $depth, $args) {
471 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
472 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
475 function end_el(&$output, $category, $depth, $args) {
476 $output .= "</li>\n";
481 * {@internal Missing Short Description}}
485 * @param unknown_type $post_id
486 * @param unknown_type $descendants_and_self
487 * @param unknown_type $selected_cats
488 * @param unknown_type $popular_cats
490 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {
491 if ( empty($walker) || !is_a($walker, 'Walker') )
492 $walker = new Walker_Category_Checklist;
494 $descendants_and_self = (int) $descendants_and_self;
498 if ( is_array( $selected_cats ) )
499 $args['selected_cats'] = $selected_cats;
501 $args['selected_cats'] = wp_get_post_categories($post_id);
503 $args['selected_cats'] = array();
505 if ( is_array( $popular_cats ) )
506 $args['popular_cats'] = $popular_cats;
508 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
510 if ( $descendants_and_self ) {
511 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
512 $self = get_category( $descendants_and_self );
513 array_unshift( $categories, $self );
515 $categories = get_categories('get=all');
518 // 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)
519 $checked_categories = array();
520 $keys = array_keys( $categories );
522 foreach( $keys as $k ) {
523 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
524 $checked_categories[] = $categories[$k];
525 unset( $categories[$k] );
529 // Put checked cats on top
530 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
531 // Then the rest of them
532 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
536 * {@internal Missing Short Description}}
540 * @param unknown_type $taxonomy
541 * @param unknown_type $default
542 * @param unknown_type $number
543 * @param unknown_type $echo
546 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
549 $checked_categories = wp_get_post_categories($post_ID);
551 $checked_categories = array();
552 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
554 $popular_ids = array();
555 foreach ( (array) $categories as $category ) {
556 $popular_ids[] = $category->term_id;
557 if ( !$echo ) // hack for AJAX use
559 $id = "popular-category-$category->term_id";
562 <li id="<?php echo $id; ?>" class="popular-category">
563 <label class="selectit">
564 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
565 <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?>
575 * {@internal Missing Short Description}}
578 * @deprecated Use {@link wp_link_category_checklist()}
579 * @see wp_link_category_checklist()
581 * @param unknown_type $default
583 function dropdown_link_categories( $default = 0 ) {
586 wp_link_category_checklist($link_id);
590 * {@internal Missing Short Description}}
594 * @param unknown_type $link_id
596 function wp_link_category_checklist( $link_id = 0 ) {
600 $checked_categories = wp_get_link_cats($link_id);
602 if ( count( $checked_categories ) == 0 ) {
603 // No selected categories, strange
604 $checked_categories[] = $default;
607 $checked_categories[] = $default;
610 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
612 if ( empty($categories) )
615 foreach ( $categories as $category ) {
616 $cat_id = $category->term_id;
617 $name = esc_html( apply_filters('the_category', $category->name));
618 $checked = in_array( $cat_id, $checked_categories );
619 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
625 // Returns a single tag row (see tag_rows below)
626 // Note: this is also used in admin-ajax.php!
628 * {@internal Missing Short Description}}
632 * @param unknown_type $tag
633 * @param unknown_type $class
636 function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
637 $count = number_format_i18n( $tag->count );
638 $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy);
639 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count;
641 $name = apply_filters( 'term_name', $tag->name );
642 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
643 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id";
645 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
646 $columns = get_column_headers('edit-tags');
647 $hidden = get_hidden_columns('edit-tags');
648 foreach ( $columns as $column_name => $column_display_name ) {
649 $class = "class=\"$column_name column-$column_name\"";
652 if ( in_array($column_name, $hidden) )
653 $style = ' style="display:none;"';
655 $attributes = "$class$style";
657 switch ($column_name) {
659 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
662 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />';
664 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
665 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
666 $actions['delete'] = "<a class='delete:the-list:tag-$tag->term_id submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
667 $actions = apply_filters('tag_row_actions', $actions, $tag);
668 $action_count = count($actions);
670 $out .= '<div class="row-actions">';
671 foreach ( $actions as $action => $link ) {
673 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
674 $out .= "<span class='$action'>$link$sep</span>";
677 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
678 $out .= '<div class="name">' . $qe_data->name . '</div>';
679 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
682 $out .= "<td $attributes>$tag->description</td>";
685 $out .= "<td $attributes>$tag->slug</td>";
688 $attributes = 'class="posts column-posts num"' . $style;
689 $out .= "<td $attributes>$count</td>";
692 $out .= "<td $attributes>";
693 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
703 // Outputs appropriate rows for the Nth page of the Tag Management screen,
704 // assuming M tags displayed at a time on the page
705 // Returns the number of tags displayed
707 * {@internal Missing Short Description}}
711 * @param unknown_type $page
712 * @param unknown_type $pagesize
713 * @param unknown_type $searchterms
716 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
718 // Get a page worth of tags
719 $start = ($page - 1) * $pagesize;
721 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
723 if ( !empty( $searchterms ) ) {
724 $args['search'] = $searchterms;
727 $tags = get_terms( $taxonomy, $args );
729 // convert it to table rows
732 foreach( $tags as $tag )
733 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy );
735 // filter and send to screen
740 // define the columns to display, the syntax is 'internal name' => 'display name'
742 * {@internal Missing Short Description}}
748 function wp_manage_posts_columns() {
749 $posts_columns = array();
750 $posts_columns['cb'] = '<input type="checkbox" />';
751 /* translators: manage posts column name */
752 $posts_columns['title'] = _x('Post', 'column name');
753 $posts_columns['author'] = __('Author');
754 $posts_columns['categories'] = __('Categories');
755 $posts_columns['tags'] = __('Tags');
756 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
757 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
758 $posts_columns['date'] = __('Date');
759 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
761 return $posts_columns;
764 // define the columns to display, the syntax is 'internal name' => 'display name'
766 * {@internal Missing Short Description}}
772 function wp_manage_media_columns() {
773 $posts_columns = array();
774 $posts_columns['cb'] = '<input type="checkbox" />';
775 $posts_columns['icon'] = '';
776 /* translators: column name */
777 $posts_columns['media'] = _x('File', 'column name');
778 $posts_columns['author'] = __('Author');
779 //$posts_columns['tags'] = _x('Tags', 'column name');
780 /* translators: column name */
781 $posts_columns['parent'] = _x('Attached to', 'column name');
782 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
783 //$posts_columns['comments'] = __('Comments');
784 /* translators: column name */
785 $posts_columns['date'] = _x('Date', 'column name');
786 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
788 return $posts_columns;
792 * {@internal Missing Short Description}}
798 function wp_manage_pages_columns() {
799 $posts_columns = array();
800 $posts_columns['cb'] = '<input type="checkbox" />';
801 $posts_columns['title'] = __('Title');
802 $posts_columns['author'] = __('Author');
803 $post_status = 'all';
804 if ( !empty($_GET['post_status']) )
805 $post_status = $_GET['post_status'];
806 if ( !in_array($post_status, array('pending', 'draft', 'future')) )
807 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
808 $posts_columns['date'] = __('Date');
809 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
811 return $posts_columns;
815 * {@internal Missing Short Description}}
819 * @param unknown_type $page
822 function get_column_headers($page) {
823 global $_wp_column_headers;
825 if ( !isset($_wp_column_headers) )
826 $_wp_column_headers = array();
828 // Store in static to avoid running filters on each call
829 if ( isset($_wp_column_headers[$page]) )
830 return $_wp_column_headers[$page];
834 $_wp_column_headers[$page] = wp_manage_posts_columns();
837 $_wp_column_headers[$page] = wp_manage_pages_columns();
839 case 'edit-comments':
840 $_wp_column_headers[$page] = array(
841 'cb' => '<input type="checkbox" />',
842 'author' => __('Author'),
843 /* translators: column name */
844 'comment' => _x('Comment', 'column name'),
845 //'date' => __('Submitted'),
846 'response' => __('In Response To')
851 $_wp_column_headers[$page] = array(
852 'cb' => '<input type="checkbox" />',
853 'name' => __('Name'),
855 'categories' => __('Categories'),
856 'rel' => __('Relationship'),
857 'visible' => __('Visible'),
858 'rating' => __('Rating')
863 $_wp_column_headers[$page] = wp_manage_media_columns();
866 $_wp_column_headers[$page] = array(
867 'cb' => '<input type="checkbox" />',
868 'name' => __('Name'),
869 'description' => __('Description'),
870 'slug' => __('Slug'),
871 'posts' => __('Posts')
875 case 'edit-link-categories':
876 $_wp_column_headers[$page] = array(
877 'cb' => '<input type="checkbox" />',
878 'name' => __('Name'),
879 'description' => __('Description'),
880 'slug' => __('Slug'),
881 'links' => __('Links')
886 $_wp_column_headers[$page] = array(
887 'cb' => '<input type="checkbox" />',
888 'name' => __('Name'),
889 'description' => __('Description'),
890 'slug' => __('Slug'),
891 'posts' => __('Posts')
896 $_wp_column_headers[$page] = array(
897 'cb' => '<input type="checkbox" />',
898 'username' => __('Username'),
899 'name' => __('Name'),
900 'email' => __('E-mail'),
901 'role' => __('Role'),
902 'posts' => __('Posts')
906 $_wp_column_headers[$page] = array();
909 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
910 return $_wp_column_headers[$page];
914 * {@internal Missing Short Description}}
918 * @param unknown_type $type
919 * @param unknown_type $id
921 function print_column_headers( $type, $id = true ) {
922 $type = str_replace('.php', '', $type);
923 $columns = get_column_headers( $type );
924 $hidden = get_hidden_columns($type);
926 // $styles['tag']['posts'] = 'width: 90px;';
927 // $styles['link-category']['links'] = 'width: 90px;';
928 // $styles['category']['posts'] = 'width: 90px;';
929 // $styles['link']['visible'] = 'text-align: center;';
931 foreach ( $columns as $column_key => $column_display_name ) {
932 $class = ' class="manage-column';
934 $class .= " column-$column_key";
936 if ( 'cb' == $column_key )
937 $class .= ' check-column';
938 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
944 if ( in_array($column_key, $hidden) )
945 $style = 'display:none;';
947 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
948 $style .= ' ' . $styles[$type][$column_key];
949 $style = ' style="' . $style . '"';
951 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
956 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
960 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
961 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
962 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
964 function register_column_headers($screen, $columns) {
965 global $_wp_column_headers;
967 if ( !isset($_wp_column_headers) )
968 $_wp_column_headers = array();
970 $_wp_column_headers[$screen] = $columns;
974 * {@internal Missing Short Description}}
978 * @param unknown_type $page
980 function get_hidden_columns($page) {
981 $page = str_replace('.php', '', $page);
982 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
986 * {@internal Missing Short Description}}
988 * Outputs the quick edit and bulk edit table rows for posts and pages
992 * @param string $type 'post' or 'page'
994 function inline_edit_row( $type ) {
995 global $current_user, $mode;
997 $is_page = 'page' == $type;
999 $screen = 'edit-pages';
1000 $post = get_default_page_to_edit();
1003 $post = get_default_post_to_edit();
1006 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
1007 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
1008 $col_count = count($columns) - count($hidden);
1009 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
1010 $can_publish = current_user_can("publish_{$type}s");
1011 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1015 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
1018 while ( $bulk < 2 ) { ?>
1020 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
1021 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
1022 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
1024 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
1025 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
1028 <?php if ( $bulk ) : ?>
1029 <div id="bulk-title-div">
1030 <div id="bulk-titles"></div>
1033 <?php else : // $bulk ?>
1036 <span class="title"><?php _e( 'Title' ); ?></span>
1037 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1040 <?php endif; // $bulk ?>
1043 <?php if ( !$bulk ) : ?>
1046 <span class="title"><?php _e( 'Slug' ); ?></span>
1047 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1050 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
1051 <div class="inline-edit-date">
1052 <?php touch_time(1, 1, 4, 1); ?>
1054 <br class="clear" />
1056 <?php endif; // $bulk
1059 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
1060 if ( $authors && count( $authors ) > 1 ) :
1061 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
1063 $users_opt['show_option_none'] = __('- No Change -');
1066 <span class="title"><?php _e( 'Author' ); ?></span>
1067 <?php wp_dropdown_users( $users_opt ); ?>
1072 $authors_dropdown = ob_get_clean();
1075 <?php if ( !$bulk ) : echo $authors_dropdown; ?>
1077 <div class="inline-edit-group">
1078 <label class="alignleft">
1079 <span class="title"><?php _e( 'Password' ); ?></span>
1080 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1083 <em style="margin:5px 10px 0 0" class="alignleft">
1085 /* translators: Between password field and private checkbox on post quick edit interface */
1086 echo __( '–OR–' );
1089 <label class="alignleft inline-edit-private">
1090 <input type="checkbox" name="keep_private" value="private" />
1091 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
1099 <?php if ( !$is_page && !$bulk ) : ?>
1101 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1102 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
1103 <span class="catshow"><?php _e('[more]'); ?></span>
1104 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
1106 <ul class="cat-checklist">
1107 <?php wp_category_checklist(); ?>
1111 <?php endif; // !$is_page && !$bulk ?>
1113 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1117 echo $authors_dropdown;
1120 <?php if ( $is_page ) : ?>
1123 <span class="title"><?php _e( 'Parent' ); ?></span>
1125 $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
1127 $dropdown_args['show_option_no_change'] = __('- No Change -');
1128 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1129 wp_dropdown_pages($dropdown_args);
1133 <?php if ( !$bulk ) : ?>
1136 <span class="title"><?php _e( 'Order' ); ?></span>
1137 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1140 <?php endif; // !$bulk ?>
1143 <span class="title"><?php _e( 'Template' ); ?></span>
1144 <select name="page_template">
1145 <?php if ( $bulk ) : ?>
1146 <option value="-1"><?php _e('- No Change -'); ?></option>
1147 <?php endif; // $bulk ?>
1148 <option value="default"><?php _e( 'Default Template' ); ?></option>
1149 <?php page_template_dropdown() ?>
1153 <?php elseif ( !$bulk ) : // $is_page ?>
1155 <label class="inline-edit-tags">
1156 <span class="title"><?php _e( 'Tags' ); ?></span>
1157 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
1160 <?php endif; // $is_page ?>
1162 <?php if ( $bulk ) : ?>
1164 <div class="inline-edit-group">
1165 <label class="alignleft">
1166 <span class="title"><?php _e( 'Comments' ); ?></span>
1167 <select name="comment_status">
1168 <option value=""><?php _e('- No Change -'); ?></option>
1169 <option value="open"><?php _e('Allow'); ?></option>
1170 <option value="closed"><?php _e('Do not allow'); ?></option>
1174 <label class="alignright">
1175 <span class="title"><?php _e( 'Pings' ); ?></span>
1176 <select name="ping_status">
1177 <option value=""><?php _e('- No Change -'); ?></option>
1178 <option value="open"><?php _e('Allow'); ?></option>
1179 <option value="closed"><?php _e('Do not allow'); ?></option>
1184 <?php else : // $bulk ?>
1186 <div class="inline-edit-group">
1187 <label class="alignleft">
1188 <input type="checkbox" name="comment_status" value="open" />
1189 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1192 <label class="alignleft">
1193 <input type="checkbox" name="ping_status" value="open" />
1194 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1198 <?php endif; // $bulk ?>
1201 <div class="inline-edit-group">
1202 <label class="inline-edit-status alignleft">
1203 <span class="title"><?php _e( 'Status' ); ?></span>
1204 <select name="_status">
1205 <?php if ( $bulk ) : ?>
1206 <option value="-1"><?php _e('- No Change -'); ?></option>
1207 <?php endif; // $bulk ?>
1208 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1209 <option value="publish"><?php _e( 'Published' ); ?></option>
1210 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1211 <?php if ( $bulk ) : ?>
1212 <option value="private"><?php _e('Private') ?></option>
1213 <?php endif; // $bulk ?>
1215 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1216 <option value="draft"><?php _e( 'Draft' ); ?></option>
1220 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
1222 <?php if ( $bulk ) : ?>
1224 <label class="alignright">
1225 <span class="title"><?php _e( 'Sticky' ); ?></span>
1226 <select name="sticky">
1227 <option value="-1"><?php _e( '- No Change -' ); ?></option>
1228 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1229 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1233 <?php else : // $bulk ?>
1235 <label class="alignleft">
1236 <input type="checkbox" name="sticky" value="sticky" />
1237 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1240 <?php endif; // $bulk ?>
1242 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
1249 foreach ( $columns as $column_name => $column_display_name ) {
1250 if ( isset( $core_columns[$column_name] ) )
1252 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
1255 <p class="submit inline-edit-save">
1256 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
1257 <?php if ( ! $bulk ) {
1258 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1259 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
1261 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
1262 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
1264 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
1266 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
1268 <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
1269 <br class="clear" />
1275 </tbody></table></form>
1279 // adds hidden fields with the data for use in the inline editor for posts and pages
1281 * {@internal Missing Short Description}}
1285 * @param unknown_type $post
1287 function get_inline_data($post) {
1289 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
1292 $title = esc_attr($post->post_title);
1295 <div class="hidden" id="inline_' . $post->ID . '">
1296 <div class="post_title">' . $title . '</div>
1297 <div class="post_name">' . $post->post_name . '</div>
1298 <div class="post_author">' . $post->post_author . '</div>
1299 <div class="comment_status">' . $post->comment_status . '</div>
1300 <div class="ping_status">' . $post->ping_status . '</div>
1301 <div class="_status">' . $post->post_status . '</div>
1302 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
1303 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
1304 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
1305 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
1306 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
1307 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
1308 <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
1310 if( $post->post_type == 'page' )
1312 <div class="post_parent">' . $post->post_parent . '</div>
1313 <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>
1314 <div class="menu_order">' . $post->menu_order . '</div>';
1316 if( $post->post_type == 'post' )
1318 <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>
1319 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
1320 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
1326 * {@internal Missing Short Description}}
1330 * @param unknown_type $posts
1332 function post_rows( $posts = array() ) {
1333 global $wp_query, $post, $mode;
1335 add_filter('the_title','esc_html');
1337 // Create array of post IDs.
1338 $post_ids = array();
1340 if ( empty($posts) )
1341 $posts = &$wp_query->posts;
1343 foreach ( $posts as $a_post )
1344 $post_ids[] = $a_post->ID;
1346 $comment_pending_count = get_pending_comments_num($post_ids);
1347 if ( empty($comment_pending_count) )
1348 $comment_pending_count = array();
1350 foreach ( $posts as $post ) {
1351 if ( empty($comment_pending_count[$post->ID]) )
1352 $comment_pending_count[$post->ID] = 0;
1354 _post_row($post, $comment_pending_count[$post->ID], $mode);
1359 * {@internal Missing Short Description}}
1363 * @param unknown_type $a_post
1364 * @param unknown_type $pending_comments
1365 * @param unknown_type $mode
1367 function _post_row($a_post, $pending_comments, $mode) {
1371 $global_post = $post;
1373 setup_postdata($post);
1375 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1376 global $current_user;
1377 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
1378 $edit_link = get_edit_post_link( $post->ID );
1379 $title = _draft_or_post_title();
1381 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
1383 $posts_columns = get_column_headers('edit');
1384 $hidden = get_hidden_columns('edit');
1385 foreach ( $posts_columns as $column_name=>$column_display_name ) {
1386 $class = "class=\"$column_name column-$column_name\"";
1389 if ( in_array($column_name, $hidden) )
1390 $style = ' style="display:none;"';
1392 $attributes = "$class$style";
1394 switch ($column_name) {
1398 <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
1403 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
1404 $t_time = $h_time = __('Unpublished');
1407 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1408 $m_time = $post->post_date;
1409 $time = get_post_time('G', true, $post);
1411 $time_diff = time() - $time;
1413 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1414 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1416 $h_time = mysql2date(__('Y/m/d'), $m_time);
1419 echo '<td ' . $attributes . '>';
1420 if ( 'excerpt' == $mode )
1421 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
1423 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
1425 if ( 'publish' == $post->post_status ) {
1427 } elseif ( 'future' == $post->post_status ) {
1428 if ( $time_diff > 0 )
1429 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1433 _e('Last Modified');
1439 $attributes = 'class="post-title column-title"' . $style;
1441 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><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>
1443 if ( 'excerpt' == $mode )
1447 if ( current_user_can('edit_post', $post->ID) ) {
1448 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
1449 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
1451 if ( current_user_can('delete_post', $post->ID) ) {
1452 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1454 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1455 if ( current_user_can('edit_post', $post->ID) )
1456 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1458 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1460 $actions = apply_filters('post_row_actions', $actions, $post);
1461 $action_count = count($actions);
1463 echo '<div class="row-actions">';
1464 foreach ( $actions as $action => $link ) {
1466 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1467 echo "<span class='$action'>$link$sep</span>";
1471 get_inline_data($post);
1479 <td <?php echo $attributes ?>><?php
1480 $categories = get_the_category();
1481 if ( !empty( $categories ) ) {
1483 foreach ( $categories as $c )
1484 $out[] = "<a href='edit.php?category_name=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
1485 echo join( ', ', $out );
1487 _e('Uncategorized');
1495 <td <?php echo $attributes ?>><?php
1496 $tags = get_the_tags($post->ID);
1497 if ( !empty( $tags ) ) {
1499 foreach ( $tags as $c )
1500 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
1501 echo join( ', ', $out );
1511 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1513 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
1514 if ( $pending_comments )
1516 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>');
1517 if ( $pending_comments )
1526 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1530 case 'control_view':
1532 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
1536 case 'control_edit':
1538 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
1542 case 'control_delete':
1544 <td><?php if ( current_user_can('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>
1550 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
1558 $post = $global_post;
1562 * display one row if the page doesn't have any children
1563 * otherwise, display the row and its children in subsequent rows
1566 * {@internal Missing Short Description}}
1570 * @param unknown_type $page
1571 * @param unknown_type $level
1573 function display_page_row( $page, $level = 0 ) {
1578 setup_postdata($page);
1580 if ( 0 == $level && (int)$page->post_parent > 0 ) {
1581 //sent level 0 by accident, by default, or because we don't know the actual level
1582 $find_main_page = (int)$page->post_parent;
1583 while ( $find_main_page > 0 ) {
1584 $parent = get_page($find_main_page);
1586 if ( is_null($parent) )
1590 $find_main_page = (int)$parent->post_parent;
1592 if ( !isset($parent_name) )
1593 $parent_name = $parent->post_title;
1597 $page->post_title = esc_html( $page->post_title );
1598 $pad = str_repeat( '— ', $level );
1599 $id = (int) $page->ID;
1600 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1601 $posts_columns = get_column_headers('edit-pages');
1602 $hidden = get_hidden_columns('edit-pages');
1603 $title = _draft_or_post_title();
1605 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
1608 foreach ($posts_columns as $column_name=>$column_display_name) {
1609 $class = "class=\"$column_name column-$column_name\"";
1612 if ( in_array($column_name, $hidden) )
1613 $style = ' style="display:none;"';
1615 $attributes = "$class$style";
1617 switch ($column_name) {
1621 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
1625 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
1626 $t_time = $h_time = __('Unpublished');
1629 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1630 $m_time = $page->post_date;
1631 $time = get_post_time('G', true);
1633 $time_diff = time() - $time;
1635 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1636 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1638 $h_time = mysql2date(__('Y/m/d'), $m_time);
1640 echo '<td ' . $attributes . '>';
1641 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
1643 if ( 'publish' == $page->post_status ) {
1645 } elseif ( 'future' == $page->post_status ) {
1646 if ( $time_diff > 0 )
1647 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1651 _e('Last Modified');
1656 $attributes = 'class="post-title page-title column-title"' . $style;
1657 $edit_link = get_edit_post_link( $page->ID );
1659 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_page', $page->ID ) ) { ?><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) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>
1662 if ( current_user_can('edit_page', $page->ID) ) {
1663 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
1664 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
1666 if ( current_user_can('delete_page', $page->ID) ) {
1667 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1669 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1670 if ( current_user_can('edit_page', $page->ID) )
1671 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1673 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1675 $actions = apply_filters('page_row_actions', $actions, $page);
1676 $action_count = count($actions);
1679 echo '<div class="row-actions">';
1680 foreach ( $actions as $action => $link ) {
1682 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1683 echo "<span class='$action'>$link$sep</span>";
1687 get_inline_data($post);
1693 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1695 $left = get_pending_comments_num( $page->ID );
1696 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
1699 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>');
1709 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1715 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
1728 * displays pages in hierarchical order with paging support
1731 * {@internal Missing Short Description}}
1735 * @param unknown_type $pages
1736 * @param unknown_type $pagenum
1737 * @param unknown_type $per_page
1740 function page_rows($pages, $pagenum = 1, $per_page = 20) {
1746 $pages = get_pages( array('sort_column' => 'menu_order') );
1753 * arrange pages into two parts: top level pages and children_pages
1754 * children_pages is two dimensional array, eg.
1755 * children_pages[10][] contains all sub-pages whose parent is 10.
1756 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
1757 * If searching, ignore hierarchy and treat everything as top level
1759 if ( empty($_GET['s']) ) {
1761 $top_level_pages = array();
1762 $children_pages = array();
1764 foreach ( $pages as $page ) {
1766 // catch and repair bad pages
1767 if ( $page->post_parent == $page->ID ) {
1768 $page->post_parent = 0;
1769 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
1770 clean_page_cache( $page->ID );
1773 if ( 0 == $page->post_parent )
1774 $top_level_pages[] = $page;
1776 $children_pages[ $page->post_parent ][] = $page;
1779 $pages = &$top_level_pages;
1783 $start = ($pagenum - 1) * $per_page;
1784 $end = $start + $per_page;
1786 foreach ( $pages as $page ) {
1787 if ( $count >= $end )
1790 if ( $count >= $start )
1791 echo "\t" . display_page_row( $page, $level );
1795 if ( isset($children_pages) )
1796 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1799 // if it is the last pagenum and there are orphaned pages, display them with paging as well
1800 if ( isset($children_pages) && $count < $end ){
1801 foreach( $children_pages as $orphans ){
1802 foreach ( $orphans as $op ) {
1803 if ( $count >= $end )
1805 if ( $count >= $start )
1806 echo "\t" . display_page_row( $op, 0 );
1814 * Given a top level page ID, display the nested hierarchy of sub-pages
1815 * together with paging support
1818 * {@internal Missing Short Description}}
1822 * @param unknown_type $children_pages
1823 * @param unknown_type $count
1824 * @param unknown_type $parent
1825 * @param unknown_type $level
1826 * @param unknown_type $pagenum
1827 * @param unknown_type $per_page
1829 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
1831 if ( ! isset( $children_pages[$parent] ) )
1834 $start = ($pagenum - 1) * $per_page;
1835 $end = $start + $per_page;
1837 foreach ( $children_pages[$parent] as $page ) {
1839 if ( $count >= $end )
1842 // If the page starts in a subtree, print the parents.
1843 if ( $count == $start && $page->post_parent > 0 ) {
1844 $my_parents = array();
1845 $my_parent = $page->post_parent;
1846 while ( $my_parent) {
1847 $my_parent = get_post($my_parent);
1848 $my_parents[] = $my_parent;
1849 if ( !$my_parent->post_parent )
1851 $my_parent = $my_parent->post_parent;
1853 $num_parents = count($my_parents);
1854 while( $my_parent = array_pop($my_parents) ) {
1855 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
1860 if ( $count >= $start )
1861 echo "\t" . display_page_row( $page, $level );
1865 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1868 unset( $children_pages[$parent] ); //required in order to keep track of orphans
1872 * {@internal Missing Short Description}}
1876 * @param unknown_type $user_object
1877 * @param unknown_type $style
1878 * @param unknown_type $role
1881 function user_row( $user_object, $style = '', $role = '' ) {
1884 $current_user = wp_get_current_user();
1886 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1887 $user_object = new WP_User( (int) $user_object );
1888 $email = $user_object->user_email;
1889 $url = $user_object->user_url;
1890 $short_url = str_replace( 'http://', '', $url );
1891 $short_url = str_replace( 'www.', '', $short_url );
1892 if ('/' == substr( $short_url, -1 ))
1893 $short_url = substr( $short_url, 0, -1 );
1894 if ( strlen( $short_url ) > 35 )
1895 $short_url = substr( $short_url, 0, 32 ).'...';
1896 $numposts = get_usernumposts( $user_object->ID );
1898 // Check if the user for this row is editable
1899 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
1900 // Set up the user editing link
1901 // TODO: make profile/user-edit determination a seperate function
1902 if ($current_user->ID == $user_object->ID) {
1903 $edit_link = 'profile.php';
1905 $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" ) );
1907 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1909 // Set up the hover actions for this user
1911 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1912 if ( $current_user->ID != $user_object->ID )
1913 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1914 $actions = apply_filters('user_row_actions', $actions, $user_object);
1915 $action_count = count($actions);
1917 $edit .= '<div class="row-actions">';
1918 foreach ( $actions as $action => $link ) {
1920 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1921 $edit .= "<span class='$action'>$link$sep</span>";
1925 // Set up the checkbox (because the user is editable, otherwise its empty)
1926 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
1929 $edit = '<strong>' . $user_object->user_login . '</strong>';
1931 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
1932 $r = "<tr id='user-$user_object->ID'$style>";
1933 $columns = get_column_headers('users');
1934 $hidden = get_hidden_columns('users');
1935 $avatar = get_avatar( $user_object->ID, 32 );
1936 foreach ( $columns as $column_name => $column_display_name ) {
1937 $class = "class=\"$column_name column-$column_name\"";
1940 if ( in_array($column_name, $hidden) )
1941 $style = ' style="display:none;"';
1943 $attributes = "$class$style";
1945 switch ($column_name) {
1947 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
1950 $r .= "<td $attributes>$avatar $edit</td>";
1953 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1956 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
1959 $r .= "<td $attributes>$role_name</td>";
1962 $attributes = 'class="posts column-posts num"' . $style;
1963 $r .= "<td $attributes>";
1964 if ( $numposts > 0 ) {
1965 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1974 $r .= "<td $attributes>";
1975 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
1985 * {@internal Missing Short Description}}
1989 * @param unknown_type $status
1990 * @param unknown_type $s
1991 * @param unknown_type $start
1992 * @param unknown_type $num
1993 * @param unknown_type $post
1994 * @param unknown_type $type
1997 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
2000 $start = abs( (int) $start );
2002 $post = (int) $post;
2003 $count = wp_count_comments();
2006 if ( 'moderated' == $status ) {
2007 $approved = "comment_approved = '0'";
2008 $total = $count->moderated;
2009 } elseif ( 'approved' == $status ) {
2010 $approved = "comment_approved = '1'";
2011 $total = $count->approved;
2012 } elseif ( 'spam' == $status ) {
2013 $approved = "comment_approved = 'spam'";
2014 $total = $count->spam;
2016 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
2017 $total = $count->moderated + $count->approved;
2018 $index = 'USE INDEX (comment_date_gmt)';
2023 $post = " AND comment_post_ID = '$post'";
2024 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
2027 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
2030 if ( 'comment' == $type )
2031 $typesql = "AND comment_type = ''";
2032 elseif ( 'pingback' == $type )
2033 $typesql = "AND comment_type = 'pingback'";
2034 elseif ( 'trackback' == $type )
2035 $typesql = "AND comment_type = 'trackback'";
2036 elseif ( 'pings' == $type )
2037 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
2041 if ( !empty($type) )
2046 $s = $wpdb->escape($s);
2047 $query = "FROM $wpdb->comments WHERE
2048 (comment_author LIKE '%$s%' OR
2049 comment_author_email LIKE '%$s%' OR
2050 comment_author_url LIKE ('%$s%') OR
2051 comment_author_IP LIKE ('%$s%') OR
2052 comment_content LIKE ('%$s%') ) AND
2056 $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
2059 $comments = $wpdb->get_results("SELECT * $query $orderby");
2060 if ( '' === $total )
2061 $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
2063 update_comment_cache($comments);
2065 return array($comments, $total);
2069 * {@internal Missing Short Description}}
2073 * @param unknown_type $comment_id
2074 * @param unknown_type $mode
2075 * @param unknown_type $comment_status
2076 * @param unknown_type $checkbox
2078 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
2079 global $comment, $post, $_comment_pending_count;
2080 $comment = get_comment( $comment_id );
2081 $post = get_post($comment->comment_post_ID);
2082 $the_comment_status = wp_get_comment_status($comment->comment_ID);
2083 $user_can = current_user_can('edit_post', $post->ID);
2085 $author_url = get_comment_author_url();
2086 if ( 'http://' == $author_url )
2088 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);
2089 if ( strlen($author_url_display) > 50 )
2090 $author_url_display = substr($author_url_display, 0, 49) . '...';
2092 $ptime = date('G', strtotime( $comment->comment_date ) );
2093 if ( ( abs(time() - $ptime) ) < 86400 )
2094 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
2096 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
2098 $delete_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
2099 $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
2100 $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
2101 $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
2103 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2104 $columns = get_column_headers('edit-comments');
2105 $hidden = get_hidden_columns('edit-comments');
2106 foreach ( $columns as $column_name => $column_display_name ) {
2107 $class = "class=\"$column_name column-$column_name\"";
2110 if ( in_array($column_name, $hidden) )
2111 $style = ' style="display:none;"';
2113 $attributes = "$class$style";
2115 switch ($column_name) {
2117 if ( !$checkbox ) break;
2118 echo '<th scope="row" class="check-column">';
2119 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2123 echo "<td $attributes>";
2124 echo '<div id="submitted-on">';
2125 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
2128 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2129 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
2130 <div class="author-email"><?php if ( $user_can ) echo esc_attr( $comment->comment_author_email ); ?></div>
2131 <div class="author"><?php if ( $user_can ) echo esc_attr( $comment->comment_author ); ?></div>
2132 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2133 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2139 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2140 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2141 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2142 if ( 'approved' == $the_comment_status ) {
2143 $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='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2144 unset($actions['approve']);
2146 $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='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2147 unset($actions['unapprove']);
2150 if ( 'spam' != $the_comment_status )
2151 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
2152 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
2153 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
2154 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
2155 if ( 'spam' != $the_comment_status )
2156 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2158 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
2161 echo '<div class="row-actions">';
2162 foreach ( $actions as $action => $link ) {
2164 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2166 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2167 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2168 $action .= ' hide-if-no-js';
2170 echo "<span class='$action'>$sep$link</span>";
2178 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2179 if ( !empty($author_url) )
2180 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2182 if ( !empty($comment->comment_author_email) ) {
2183 comment_author_email_link();
2186 echo '<a href="edit-comments.php?s=';
2187 comment_author_IP();
2188 echo '&mode=detail';
2189 if ( 'spam' == $comment_status )
2190 echo '&comment_status=spam';
2192 comment_author_IP();
2194 } //current_user_can
2198 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2201 if ( 'single' !== $mode ) {
2202 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2203 $pending_comments = absint( $_comment_pending_count[$post->ID] );
2205 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
2206 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2209 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2210 $post_link .= get_the_title($post->ID) . '</a>';
2212 $post_link = get_the_title($post->ID);
2214 echo "<td $attributes>\n";
2215 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2216 echo $post_link . '<br />';
2217 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
2218 if ( $pending_comments )
2220 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>');
2221 if ( $pending_comments )
2224 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2226 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2232 echo "<td $attributes>\n";
2233 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2242 * {@internal Missing Short Description}}
2246 * @param unknown_type $position
2247 * @param unknown_type $checkbox
2248 * @param unknown_type $mode
2250 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2251 global $current_user;
2253 // allow plugin to replace the popup content
2254 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2256 if ( ! empty($content) ) {
2261 $columns = get_column_headers('edit-comments');
2262 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2263 $col_count = count($columns) - count($hidden);
2266 <form method="get" action="">
2267 <?php if ( $table_row ) : ?>
2268 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
2270 <div id="com-reply" style="display:none;"><div id="replyrow">
2272 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2274 <div id="edithead" style="display:none;">
2275 <div class="inside">
2276 <label for="author"><?php _e('Name') ?></label>
2277 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2280 <div class="inside">
2281 <label for="author-email"><?php _e('E-mail') ?></label>
2282 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2285 <div class="inside">
2286 <label for="author-url"><?php _e('URL') ?></label>
2287 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2289 <div style="clear:both;"></div>
2292 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2294 <p id="replysubmit" class="submit">
2295 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2296 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2297 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2298 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2299 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
2300 <span class="error" style="display:none;"></span>
2301 <br class="clear" />
2304 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2305 <input type="hidden" name="action" id="action" value="" />
2306 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2307 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2308 <input type="hidden" name="status" id="status" value="" />
2309 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2310 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2311 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2312 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
2313 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2314 <?php if ( $table_row ) : ?>
2315 </td></tr></tbody></table>
2324 * {@internal Missing Short Description}}
2328 * @param unknown_type $currentcat
2329 * @param unknown_type $currentparent
2330 * @param unknown_type $parent
2331 * @param unknown_type $level
2332 * @param unknown_type $categories
2335 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
2337 $categories = get_categories( array('hide_empty' => 0) );
2339 if ( $categories ) {
2340 foreach ( $categories as $category ) {
2341 if ( $currentcat != $category->term_id && $parent == $category->parent) {
2342 $pad = str_repeat( '– ', $level );
2343 $category->name = esc_html( $category->name );
2344 echo "\n\t<option value='$category->term_id'";
2345 if ( $currentparent == $category->term_id )
2346 echo " selected='selected'";
2347 echo ">$pad$category->name</option>";
2348 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
2357 * {@internal Missing Short Description}}
2361 * @param unknown_type $meta
2363 function list_meta( $meta ) {
2367 <table id="list-table" style="display: none;">
2370 <th class="left">' . __( 'Name' ) . '</th>
2371 <th>' . __( 'Value' ) . '</th>
2374 <tbody id="the-list" class="list:meta">
2377 </table>'; //TBODY needed for list-manipulation JS
2382 <table id="list-table">
2385 <th class="left"><?php _e( 'Name' ) ?></th>
2386 <th><?php _e( 'Value' ) ?></th>
2389 <tbody id='the-list' class='list:meta'>
2391 foreach ( $meta as $entry )
2392 echo _list_meta_row( $entry, $count );
2400 * {@internal Missing Short Description}}
2404 * @param unknown_type $entry
2405 * @param unknown_type $count
2408 function _list_meta_row( $entry, &$count ) {
2409 static $update_nonce = false;
2410 if ( !$update_nonce )
2411 $update_nonce = wp_create_nonce( 'add-meta' );
2416 $style = 'alternate';
2419 if ('_' == $entry['meta_key'] { 0 } )
2420 $style .= ' hidden';
2422 if ( is_serialized( $entry['meta_value'] ) ) {
2423 if ( is_serialized_string( $entry['meta_value'] ) ) {
2424 // this is a serialized string, so we should display it
2425 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2427 // this is a serialized array/object so we should NOT display it
2433 $entry['meta_key'] = esc_attr($entry['meta_key']);
2434 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2435 $entry['meta_id'] = (int) $entry['meta_id'];
2437 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2439 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2440 $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']}' />";
2442 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2443 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2444 $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=$update_nonce updatemeta' /></div>";
2445 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2448 $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>";
2453 * {@internal Missing Short Description}}
2457 function meta_form() {
2459 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2460 $keys = $wpdb->get_col( "
2462 FROM $wpdb->postmeta
2464 HAVING meta_key NOT LIKE '\_%'
2465 ORDER BY LOWER(meta_key)
2470 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
2471 <table id="newmeta">
2474 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2475 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2481 <td id="newmetaleft" class="left">
2482 <?php if ( $keys ) { ?>
2483 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2484 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
2487 foreach ( $keys as $key ) {
2488 $key = esc_attr( $key );
2489 echo "\n<option value='" . esc_attr($key) . "'>$key</option>";
2493 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2494 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2495 <span id="enternew"><?php _e('Enter new'); ?></span>
2496 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2498 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2501 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2504 <tr><td colspan="2" class="submit">
2505 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2506 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
2515 * {@internal Missing Short Description}}
2519 * @param unknown_type $edit
2520 * @param unknown_type $for_post
2521 * @param unknown_type $tab_index
2522 * @param unknown_type $multi
2524 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2525 global $wp_locale, $post, $comment;
2528 $edit = ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ) ? false : true;
2530 $tab_index_attribute = '';
2531 if ( (int) $tab_index > 0 )
2532 $tab_index_attribute = " tabindex=\"$tab_index\"";
2534 // 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 />';
2536 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
2537 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2538 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2539 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2540 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2541 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2542 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2543 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2545 $cur_jj = gmdate( 'd', $time_adj );
2546 $cur_mm = gmdate( 'm', $time_adj );
2547 $cur_aa = gmdate( 'Y', $time_adj );
2548 $cur_hh = gmdate( 'H', $time_adj );
2549 $cur_mn = gmdate( 'i', $time_adj );
2551 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2552 for ( $i = 1; $i < 13; $i = $i +1 ) {
2553 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2555 $month .= ' selected="selected"';
2556 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2558 $month .= '</select>';
2560 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2561 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2562 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2563 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2564 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2565 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2567 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2569 if ( $multi ) return;
2572 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2573 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2574 $cur_timeunit = 'cur_' . $timeunit;
2575 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2580 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2581 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2587 * {@internal Missing Short Description}}
2591 * @param unknown_type $default
2593 function page_template_dropdown( $default = '' ) {
2594 $templates = get_page_templates();
2595 ksort( $templates );
2596 foreach (array_keys( $templates ) as $template )
2597 : if ( $default == $templates[$template] )
2598 $selected = " selected='selected'";
2601 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2606 * {@internal Missing Short Description}}
2610 * @param unknown_type $default
2611 * @param unknown_type $parent
2612 * @param unknown_type $level
2615 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2616 global $wpdb, $post_ID;
2617 $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) );
2620 foreach ( $items as $item ) {
2621 // A page cannot be its own parent.
2622 if (!empty ( $post_ID ) ) {
2623 if ( $item->ID == $post_ID ) {
2627 $pad = str_repeat( ' ', $level * 3 );
2628 if ( $item->ID == $default)
2629 $current = ' selected="selected"';
2633 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2634 parent_dropdown( $default, $item->ID, $level +1 );
2642 * {@internal Missing Short Description}}
2646 function browse_happy() {
2647 $getit = __( 'WordPress recommends a better browser' );
2649 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
2654 * {@internal Missing Short Description}}
2658 * @param unknown_type $id
2661 function the_attachment_links( $id = false ) {
2663 $post = & get_post( $id );
2665 if ( $post->post_type != 'attachment' )
2668 $icon = get_attachment_icon( $post->ID );
2669 $attachment_data = wp_get_attachment_metadata( $id );
2670 $thumb = isset( $attachment_data['thumb'] );
2672 <form id="the-attachment-links">
2675 <col class="widefat" />
2677 <th scope="row"><?php _e( 'URL' ) ?></th>
2678 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2680 <?php if ( $icon ) : ?>
2682 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2683 <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>
2686 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2687 <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>
2691 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2692 <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>
2695 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2696 <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>
2706 * Print out <option> html elements for role selectors based on $wp_roles
2708 * @package WordPress
2709 * @subpackage Administration
2713 * @param string $default slug for the role that should be already selected
2715 function wp_dropdown_roles( $selected = false ) {
2720 $editable_roles = get_editable_roles();
2722 foreach( $editable_roles as $role => $details ) {
2723 $name = translate_user_role($details['name'] );
2724 if ( $selected == $role ) // Make default first in list
2725 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2727 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2733 * {@internal Missing Short Description}}
2737 * @param unknown_type $size
2740 function wp_convert_hr_to_bytes( $size ) {
2741 $size = strtolower($size);
2742 $bytes = (int) $size;
2743 if ( strpos($size, 'k') !== false )
2744 $bytes = intval($size) * 1024;
2745 elseif ( strpos($size, 'm') !== false )
2746 $bytes = intval($size) * 1024 * 1024;
2747 elseif ( strpos($size, 'g') !== false )
2748 $bytes = intval($size) * 1024 * 1024 * 1024;
2753 * {@internal Missing Short Description}}
2757 * @param unknown_type $bytes
2760 function wp_convert_bytes_to_hr( $bytes ) {
2761 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2762 $log = log( $bytes, 1024 );
2763 $power = (int) $log;
2764 $size = pow(1024, $log - $power);
2765 return $size . $units[$power];
2769 * {@internal Missing Short Description}}
2775 function wp_max_upload_size() {
2776 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2777 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2778 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2783 * {@internal Missing Short Description}}
2787 * @param unknown_type $action
2789 function wp_import_upload_form( $action ) {
2790 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2791 $size = wp_convert_bytes_to_hr( $bytes );
2792 $upload_dir = wp_upload_dir();
2793 if ( ! empty( $upload_dir['error'] ) ) :
2794 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2795 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2798 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr($action) ?>">
2800 <?php wp_nonce_field('import-upload'); ?>
2801 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2802 <input type="file" id="upload" name="import" size="25" />
2803 <input type="hidden" name="action" value="save" />
2804 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2807 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2815 * {@internal Missing Short Description}}
2819 function wp_remember_old_slug() {
2821 $name = esc_attr($post->post_name); // just in case
2822 if ( strlen($name) )
2823 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
2827 * Add a meta box to an edit form.
2831 * @param string $id String for use in the 'id' attribute of tags.
2832 * @param string $title Title of the meta box.
2833 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2834 * @param string $page The type of edit page on which to show the box (post, page, link).
2835 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2836 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2838 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2839 global $wp_meta_boxes;
2841 if ( !isset($wp_meta_boxes) )
2842 $wp_meta_boxes = array();
2843 if ( !isset($wp_meta_boxes[$page]) )
2844 $wp_meta_boxes[$page] = array();
2845 if ( !isset($wp_meta_boxes[$page][$context]) )
2846 $wp_meta_boxes[$page][$context] = array();
2848 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2849 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2850 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2853 // If a core box was previously added or removed by a plugin, don't add.
2854 if ( 'core' == $priority ) {
2855 // If core box previously deleted, don't add
2856 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2858 // If box was added with default priority, give it core priority to maintain sort order
2859 if ( 'default' == $a_priority ) {
2860 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2861 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2865 // If no priority given and id already present, use existing priority
2866 if ( empty($priority) ) {
2867 $priority = $a_priority;
2868 // 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.
2869 } elseif ( 'sorted' == $priority ) {
2870 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2871 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2872 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2874 // An id can be in only one priority and one context
2875 if ( $priority != $a_priority || $context != $a_context )
2876 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2880 if ( empty($priority) )
2883 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2884 $wp_meta_boxes[$page][$context][$priority] = array();
2886 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2890 * {@internal Missing Short Description}}
2894 * @param unknown_type $page
2895 * @param unknown_type $context
2896 * @param unknown_type $object
2897 * @return int number of meta_boxes
2899 function do_meta_boxes($page, $context, $object) {
2900 global $wp_meta_boxes;
2901 static $already_sorted = false;
2903 //do_action('do_meta_boxes', $page, $context, $object);
2905 $hidden = get_hidden_meta_boxes($page);
2907 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
2911 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2912 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
2913 foreach ( $sorted as $box_context => $ids )
2914 foreach ( explode(',', $ids) as $id )
2916 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2918 $already_sorted = true;
2920 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2923 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2924 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2925 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2926 if ( false == $box || ! $box['title'] )
2930 if ( in_array($box['id'], $hidden) )
2931 $style = 'style="display:none;"';
2932 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
2933 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
2934 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
2935 echo '<div class="inside">' . "\n";
2936 call_user_func($box['callback'], $object, $box);
2951 * Remove a meta box from an edit form.
2955 * @param string $id String for use in the 'id' attribute of tags.
2956 * @param string $page The type of edit page on which to show the box (post, page, link).
2957 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2959 function remove_meta_box($id, $page, $context) {
2960 global $wp_meta_boxes;
2962 if ( !isset($wp_meta_boxes) )
2963 $wp_meta_boxes = array();
2964 if ( !isset($wp_meta_boxes[$page]) )
2965 $wp_meta_boxes[$page] = array();
2966 if ( !isset($wp_meta_boxes[$page][$context]) )
2967 $wp_meta_boxes[$page][$context] = array();
2969 foreach ( array('high', 'core', 'default', 'low') as $priority )
2970 $wp_meta_boxes[$page][$context][$priority][$id] = false;
2974 * {@internal Missing Short Description}}
2978 * @param unknown_type $page
2980 function meta_box_prefs($page) {
2981 global $wp_meta_boxes;
2983 if ( empty($wp_meta_boxes[$page]) )
2986 $hidden = get_hidden_meta_boxes($page);
2988 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
2989 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
2990 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
2991 if ( false == $box || ! $box['title'] )
2993 // Submit box cannot be hidden
2994 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
2996 $box_id = $box['id'];
2997 echo '<label for="' . $box_id . '-hide">';
2998 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"' : '') . ' />';
2999 echo "{$box['title']}</label>\n";
3005 function get_hidden_meta_boxes($page) {
3006 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
3008 // Hide slug boxes by default
3009 if ( empty($hidden[0]) ) {
3010 if ( 'page' == $page )
3011 $hidden = array('pageslugdiv');
3012 elseif ( 'post' == $page )
3013 $hidden = array('slugdiv');
3020 * Add a new section to a settings page.
3024 * @param string $id String for use in the 'id' attribute of tags.
3025 * @param string $title Title of the section.
3026 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
3027 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
3029 function add_settings_section($id, $title, $callback, $page) {
3030 global $wp_settings_sections;
3032 if ( !isset($wp_settings_sections) )
3033 $wp_settings_sections = array();
3034 if ( !isset($wp_settings_sections[$page]) )
3035 $wp_settings_sections[$page] = array();
3036 if ( !isset($wp_settings_sections[$page][$id]) )
3037 $wp_settings_sections[$page][$id] = array();
3039 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
3043 * Add a new field to a settings page.
3047 * @param string $id String for use in the 'id' attribute of tags.
3048 * @param string $title Title of the field.
3049 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
3050 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
3051 * @param string $section The section of the settingss page in which to show the box (default, ...).
3052 * @param array $args Additional arguments
3054 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3055 global $wp_settings_fields;
3057 if ( !isset($wp_settings_fields) )
3058 $wp_settings_fields = array();
3059 if ( !isset($wp_settings_fields[$page]) )
3060 $wp_settings_fields[$page] = array();
3061 if ( !isset($wp_settings_fields[$page][$section]) )
3062 $wp_settings_fields[$page][$section] = array();
3064 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3068 * {@internal Missing Short Description}}
3072 * @param unknown_type $page
3074 function do_settings_sections($page) {
3075 global $wp_settings_sections, $wp_settings_fields;
3077 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3080 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3081 echo "<h3>{$section['title']}</h3>\n";
3082 call_user_func($section['callback'], $section);
3083 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3085 echo '<table class="form-table">';
3086 do_settings_fields($page, $section['id']);
3092 * {@internal Missing Short Description}}
3096 * @param unknown_type $page
3097 * @param unknown_type $section
3099 function do_settings_fields($page, $section) {
3100 global $wp_settings_fields;
3102 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3105 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3106 echo '<tr valign="top">';
3107 if ( !empty($field['args']['label_for']) )
3108 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3110 echo '<th scope="row">' . $field['title'] . '</th>';
3112 call_user_func($field['callback']);
3119 * {@internal Missing Short Description}}
3123 * @param unknown_type $page
3125 function manage_columns_prefs($page) {
3126 $columns = get_column_headers($page);
3128 $hidden = get_hidden_columns($page);
3130 foreach ( $columns as $column => $title ) {
3132 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
3134 if ( empty($title) )
3137 if ( 'comments' == $column )
3138 $title = __('Comments');
3139 $id = "$column-hide";
3140 echo '<label for="' . $id . '">';
3141 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3142 echo "$title</label>\n";
3147 * {@internal Missing Short Description}}
3151 * @param unknown_type $found_action
3153 function find_posts_div($found_action = '') {
3155 <div id="find-posts" class="find-box" style="display:none;">
3156 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3157 <div class="find-box-inside">
3158 <div class="find-box-search">
3159 <?php if ( $found_action ) { ?>
3160 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3163 <input type="hidden" name="affected" id="affected" value="" />
3164 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3165 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3166 <input type="text" id="find-posts-input" name="ps" value="" />
3167 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3169 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
3170 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
3171 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
3172 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
3174 <div id="find-posts-response"></div>
3176 <div class="find-box-buttons">
3177 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3178 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3185 * Display the post password.
3187 * The password is passed through {@link esc_attr()} to ensure that it
3188 * is safe for placing in an html attribute.
3193 function the_post_password() {
3195 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3199 * {@internal Missing Short Description}}
3203 function favorite_actions( $screen = null ) {
3204 switch ( $screen ) {
3205 case 'post-new.php':
3206 $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
3208 case 'edit-pages.php':
3209 $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
3211 case 'page-new.php':
3212 $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
3215 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3217 case 'media-new.php':
3218 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3220 case 'link-manager.php':
3221 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3223 case 'link-add.php':
3224 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3227 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3229 case 'user-new.php':
3230 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3233 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3235 case 'plugin-install.php':
3236 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3239 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3241 case 'theme-install.php':
3242 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3245 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3250 'post-new.php' => array(__('New Post'), 'edit_posts'),
3251 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3252 'page-new.php' => array(__('New Page'), 'edit_pages'),
3253 'media-new.php' => array(__('Upload'), 'upload_files'),
3254 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3257 $default_key = array_keys($default_action);
3258 $default_key = $default_key[0];
3259 if ( isset($actions[$default_key]) )
3260 unset($actions[$default_key]);
3261 $actions = array_merge($default_action, $actions);
3262 $actions = apply_filters('favorite_actions', $actions);
3264 $allowed_actions = array();
3265 foreach ( $actions as $action => $data ) {
3266 if ( current_user_can($data[1]) )
3267 $allowed_actions[$action] = $data[0];
3270 if ( empty($allowed_actions) )
3273 $first = array_keys($allowed_actions);
3275 echo '<div id="favorite-actions">';
3276 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3277 echo '<div id="favorite-inside">';
3279 array_shift($allowed_actions);
3281 foreach ( $allowed_actions as $action => $label) {
3282 echo "<div class='favorite-action'><a href='$action'>";
3284 echo "</a></div>\n";
3286 echo "</div></div>\n";
3290 * Get the post title.
3292 * The post title is fetched and if it is blank then a default string is
3296 * @param int $id The post id. If not supplied the global $post is used.
3299 function _draft_or_post_title($post_id = 0)
3301 $title = get_the_title($post_id);
3302 if ( empty($title) )
3303 $title = __('(no title)');
3308 * Display the search query.
3310 * A simple wrapper to display the "s" parameter in a GET URI. This function
3311 * should only be used when {@link the_search_query()} cannot.
3317 function _admin_search_query() {
3318 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
3322 * Generic Iframe header for use with Thickbox
3325 * @param string $title Title of the Iframe page.
3326 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3329 function iframe_header( $title = '', $limit_styles = false ) {
3330 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3331 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3333 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3334 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
3336 wp_enqueue_style( 'global' );
3337 if ( ! $limit_styles )
3338 wp_enqueue_style( 'wp-admin' );
3339 wp_enqueue_style( 'colors' );
3341 <script type="text/javascript">
3343 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();}}};
3344 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
3348 do_action('admin_print_styles');
3349 do_action('admin_print_scripts');
3350 do_action('admin_head');
3353 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
3358 * Generic Iframe footer for use with Thickbox
3363 function iframe_footer() {
3364 //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
3365 <div class="hidden">
3367 do_action('admin_footer', '');
3368 do_action('admin_print_footer_scripts'); ?>
3370 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
3376 function _post_states($post) {
3377 $post_states = array();
3378 if ( isset($_GET['post_status']) )