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">' . apply_filters('editable_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>" . apply_filters('editable_slug', $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">' . apply_filters('editable_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>" . apply_filters('editable_slug', $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 ( (string) $helper === (string) $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, $checked_ontop = true ) {
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 if ( $checked_ontop ) {
519 // 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)
520 $checked_categories = array();
521 $keys = array_keys( $categories );
523 foreach( $keys as $k ) {
524 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
525 $checked_categories[] = $categories[$k];
526 unset( $categories[$k] );
530 // Put checked cats on top
531 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
533 // Then the rest of them
534 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
538 * {@internal Missing Short Description}}
542 * @param unknown_type $taxonomy
543 * @param unknown_type $default
544 * @param unknown_type $number
545 * @param unknown_type $echo
548 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
552 $checked_categories = wp_get_post_categories($post_ID);
554 $checked_categories = array();
556 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
558 $popular_ids = array();
559 foreach ( (array) $categories as $category ) {
560 $popular_ids[] = $category->term_id;
561 if ( !$echo ) // hack for AJAX use
563 $id = "popular-category-$category->term_id";
564 $checked = in_array( $category->term_id, $checked_categories ) ? 'checked="checked"' : '';
567 <li id="<?php echo $id; ?>" class="popular-category">
568 <label class="selectit">
569 <input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $category->term_id; ?>" />
570 <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?>
580 * {@internal Missing Short Description}}
583 * @deprecated Use {@link wp_link_category_checklist()}
584 * @see wp_link_category_checklist()
586 * @param unknown_type $default
588 function dropdown_link_categories( $default = 0 ) {
591 wp_link_category_checklist($link_id);
595 * {@internal Missing Short Description}}
599 * @param unknown_type $link_id
601 function wp_link_category_checklist( $link_id = 0 ) {
605 $checked_categories = wp_get_link_cats($link_id);
607 if ( count( $checked_categories ) == 0 ) {
608 // No selected categories, strange
609 $checked_categories[] = $default;
612 $checked_categories[] = $default;
615 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
617 if ( empty($categories) )
620 foreach ( $categories as $category ) {
621 $cat_id = $category->term_id;
622 $name = esc_html( apply_filters('the_category', $category->name));
623 $checked = in_array( $cat_id, $checked_categories );
624 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>";
630 // Returns a single tag row (see tag_rows below)
631 // Note: this is also used in admin-ajax.php!
633 * {@internal Missing Short Description}}
637 * @param unknown_type $tag
638 * @param unknown_type $class
641 function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
642 $count = number_format_i18n( $tag->count );
643 $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy);
644 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count;
646 $name = apply_filters( 'term_name', $tag->name );
647 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
648 $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id";
650 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
651 $columns = get_column_headers('edit-tags');
652 $hidden = get_hidden_columns('edit-tags');
653 foreach ( $columns as $column_name => $column_display_name ) {
654 $class = "class=\"$column_name column-$column_name\"";
657 if ( in_array($column_name, $hidden) )
658 $style = ' style="display:none;"';
660 $attributes = "$class$style";
662 switch ($column_name) {
664 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
667 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit “%s”'), $name)) . '">' . $name . '</a></strong><br />';
669 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
670 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
671 $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
672 $actions = apply_filters('tag_row_actions', $actions, $tag);
673 $action_count = count($actions);
675 $out .= '<div class="row-actions">';
676 foreach ( $actions as $action => $link ) {
678 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
679 $out .= "<span class='$action'>$link$sep</span>";
682 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
683 $out .= '<div class="name">' . $qe_data->name . '</div>';
684 $out .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div></div></td>';
687 $out .= "<td $attributes>$tag->description</td>";
690 $out .= "<td $attributes>" . apply_filters('editable_slug', $tag->slug) . "</td>";
693 $attributes = 'class="posts column-posts num"' . $style;
694 $out .= "<td $attributes>$count</td>";
697 $out .= "<td $attributes>";
698 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
708 // Outputs appropriate rows for the Nth page of the Tag Management screen,
709 // assuming M tags displayed at a time on the page
710 // Returns the number of tags displayed
712 * {@internal Missing Short Description}}
716 * @param unknown_type $page
717 * @param unknown_type $pagesize
718 * @param unknown_type $searchterms
721 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
723 // Get a page worth of tags
724 $start = ($page - 1) * $pagesize;
726 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
728 if ( !empty( $searchterms ) ) {
729 $args['search'] = $searchterms;
732 $tags = get_terms( $taxonomy, $args );
734 // convert it to table rows
737 foreach( $tags as $tag )
738 $out .= _tag_row( $tag, ++$count % 2 ? ' class="alternate"' : '', $taxonomy );
740 // filter and send to screen
745 // define the columns to display, the syntax is 'internal name' => 'display name'
747 * {@internal Missing Short Description}}
753 function wp_manage_posts_columns() {
754 $posts_columns = array();
755 $posts_columns['cb'] = '<input type="checkbox" />';
756 /* translators: manage posts column name */
757 $posts_columns['title'] = _x('Post', 'column name');
758 $posts_columns['author'] = __('Author');
759 $posts_columns['categories'] = __('Categories');
760 $posts_columns['tags'] = __('Tags');
761 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
762 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) )
763 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
764 $posts_columns['date'] = __('Date');
765 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
767 return $posts_columns;
770 // define the columns to display, the syntax is 'internal name' => 'display name'
772 * {@internal Missing Short Description}}
778 function wp_manage_media_columns() {
779 $posts_columns = array();
780 $posts_columns['cb'] = '<input type="checkbox" />';
781 $posts_columns['icon'] = '';
782 /* translators: column name */
783 $posts_columns['media'] = _x('File', 'column name');
784 $posts_columns['author'] = __('Author');
785 //$posts_columns['tags'] = _x('Tags', 'column name');
786 /* translators: column name */
787 $posts_columns['parent'] = _x('Attached to', 'column name');
788 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
789 //$posts_columns['comments'] = __('Comments');
790 /* translators: column name */
791 $posts_columns['date'] = _x('Date', 'column name');
792 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
794 return $posts_columns;
798 * {@internal Missing Short Description}}
804 function wp_manage_pages_columns() {
805 $posts_columns = array();
806 $posts_columns['cb'] = '<input type="checkbox" />';
807 $posts_columns['title'] = __('Title');
808 $posts_columns['author'] = __('Author');
809 $post_status = !empty($_REQUEST['post_status']) ? $_REQUEST['post_status'] : 'all';
810 if ( !in_array( $post_status, array('pending', 'draft', 'future') ) )
811 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
812 $posts_columns['date'] = __('Date');
813 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
815 return $posts_columns;
819 * {@internal Missing Short Description}}
823 * @param unknown_type $page
826 function get_column_headers($page) {
827 global $_wp_column_headers;
829 if ( !isset($_wp_column_headers) )
830 $_wp_column_headers = array();
832 // Store in static to avoid running filters on each call
833 if ( isset($_wp_column_headers[$page]) )
834 return $_wp_column_headers[$page];
838 $_wp_column_headers[$page] = wp_manage_posts_columns();
841 $_wp_column_headers[$page] = wp_manage_pages_columns();
843 case 'edit-comments':
844 $_wp_column_headers[$page] = array(
845 'cb' => '<input type="checkbox" />',
846 'author' => __('Author'),
847 /* translators: column name */
848 'comment' => _x('Comment', 'column name'),
849 //'date' => __('Submitted'),
850 'response' => __('In Response To')
855 $_wp_column_headers[$page] = array(
856 'cb' => '<input type="checkbox" />',
857 'name' => __('Name'),
859 'categories' => __('Categories'),
860 'rel' => __('Relationship'),
861 'visible' => __('Visible'),
862 'rating' => __('Rating')
867 $_wp_column_headers[$page] = wp_manage_media_columns();
870 $_wp_column_headers[$page] = array(
871 'cb' => '<input type="checkbox" />',
872 'name' => __('Name'),
873 'description' => __('Description'),
874 'slug' => __('Slug'),
875 'posts' => __('Posts')
879 case 'edit-link-categories':
880 $_wp_column_headers[$page] = array(
881 'cb' => '<input type="checkbox" />',
882 'name' => __('Name'),
883 'description' => __('Description'),
884 'slug' => __('Slug'),
885 'links' => __('Links')
890 $_wp_column_headers[$page] = array(
891 'cb' => '<input type="checkbox" />',
892 'name' => __('Name'),
893 'description' => __('Description'),
894 'slug' => __('Slug'),
895 'posts' => __('Posts')
900 $_wp_column_headers[$page] = array(
901 'cb' => '<input type="checkbox" />',
902 'username' => __('Username'),
903 'name' => __('Name'),
904 'email' => __('E-mail'),
905 'role' => __('Role'),
906 'posts' => __('Posts')
910 $_wp_column_headers[$page] = array();
913 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
914 return $_wp_column_headers[$page];
918 * {@internal Missing Short Description}}
922 * @param unknown_type $type
923 * @param unknown_type $id
925 function print_column_headers( $type, $id = true ) {
926 $type = str_replace('.php', '', $type);
927 $columns = get_column_headers( $type );
928 $hidden = get_hidden_columns($type);
930 // $styles['tag']['posts'] = 'width: 90px;';
931 // $styles['link-category']['links'] = 'width: 90px;';
932 // $styles['category']['posts'] = 'width: 90px;';
933 // $styles['link']['visible'] = 'text-align: center;';
935 foreach ( $columns as $column_key => $column_display_name ) {
936 $class = ' class="manage-column';
938 $class .= " column-$column_key";
940 if ( 'cb' == $column_key )
941 $class .= ' check-column';
942 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
948 if ( in_array($column_key, $hidden) )
949 $style = 'display:none;';
951 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
952 $style .= ' ' . $styles[$type][$column_key];
953 $style = ' style="' . $style . '"';
955 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
960 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
964 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
965 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
966 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
968 function register_column_headers($screen, $columns) {
969 global $_wp_column_headers;
971 if ( !isset($_wp_column_headers) )
972 $_wp_column_headers = array();
974 $_wp_column_headers[$screen] = $columns;
978 * {@internal Missing Short Description}}
982 * @param unknown_type $page
984 function get_hidden_columns($page) {
985 $page = str_replace('.php', '', $page);
986 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
990 * {@internal Missing Short Description}}
992 * Outputs the quick edit and bulk edit table rows for posts and pages
996 * @param string $type 'post' or 'page'
998 function inline_edit_row( $type ) {
999 global $current_user, $mode;
1001 $is_page = 'page' == $type;
1003 $screen = 'edit-pages';
1004 $post = get_default_page_to_edit();
1007 $post = get_default_post_to_edit();
1010 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
1011 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
1012 $col_count = count($columns) - count($hidden);
1013 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
1014 $can_publish = current_user_can("publish_{$type}s");
1015 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1019 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
1022 while ( $bulk < 2 ) { ?>
1024 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
1025 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
1026 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
1028 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
1029 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
1032 <?php if ( $bulk ) : ?>
1033 <div id="bulk-title-div">
1034 <div id="bulk-titles"></div>
1037 <?php else : // $bulk ?>
1040 <span class="title"><?php _e( 'Title' ); ?></span>
1041 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1044 <?php endif; // $bulk ?>
1047 <?php if ( !$bulk ) : ?>
1050 <span class="title"><?php _e( 'Slug' ); ?></span>
1051 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1054 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
1055 <div class="inline-edit-date">
1056 <?php touch_time(1, 1, 4, 1); ?>
1058 <br class="clear" />
1060 <?php endif; // $bulk
1062 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
1063 $authors_dropdown = '';
1064 if ( $authors && count( $authors ) > 1 ) :
1065 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1, 'echo' => 0);
1067 $users_opt['show_option_none'] = __('- No Change -');
1068 $authors_dropdown = '<label>';
1069 $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
1070 $authors_dropdown .= wp_dropdown_users( $users_opt );
1071 $authors_dropdown .= '</label>';
1076 <?php if ( !$bulk ) : echo $authors_dropdown; ?>
1078 <div class="inline-edit-group">
1079 <label class="alignleft">
1080 <span class="title"><?php _e( 'Password' ); ?></span>
1081 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1084 <em style="margin:5px 10px 0 0" class="alignleft">
1086 /* translators: Between password field and private checkbox on post quick edit interface */
1087 echo __( '–OR–' );
1090 <label class="alignleft inline-edit-private">
1091 <input type="checkbox" name="keep_private" value="private" />
1092 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
1100 <?php if ( !$is_page && !$bulk ) : ?>
1102 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1103 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
1104 <span class="catshow"><?php _e('[more]'); ?></span>
1105 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
1107 <ul class="cat-checklist">
1108 <?php wp_category_checklist(); ?>
1112 <?php endif; // !$is_page && !$bulk ?>
1114 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1118 echo $authors_dropdown;
1121 <?php if ( $is_page ) : ?>
1124 <span class="title"><?php _e( 'Parent' ); ?></span>
1126 $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');
1128 $dropdown_args['show_option_no_change'] = __('- No Change -');
1129 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1130 wp_dropdown_pages($dropdown_args);
1134 <?php if ( !$bulk ) : ?>
1137 <span class="title"><?php _e( 'Order' ); ?></span>
1138 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1141 <?php endif; // !$bulk ?>
1144 <span class="title"><?php _e( 'Template' ); ?></span>
1145 <select name="page_template">
1146 <?php if ( $bulk ) : ?>
1147 <option value="-1"><?php _e('- No Change -'); ?></option>
1148 <?php endif; // $bulk ?>
1149 <option value="default"><?php _e( 'Default Template' ); ?></option>
1150 <?php page_template_dropdown() ?>
1154 <?php elseif ( !$bulk ) : // $is_page ?>
1156 <label class="inline-edit-tags">
1157 <span class="title"><?php _e( 'Tags' ); ?></span>
1158 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
1161 <?php endif; // $is_page ?>
1163 <?php if ( $bulk ) : ?>
1165 <div class="inline-edit-group">
1166 <label class="alignleft">
1167 <span class="title"><?php _e( 'Comments' ); ?></span>
1168 <select name="comment_status">
1169 <option value=""><?php _e('- No Change -'); ?></option>
1170 <option value="open"><?php _e('Allow'); ?></option>
1171 <option value="closed"><?php _e('Do not allow'); ?></option>
1175 <label class="alignright">
1176 <span class="title"><?php _e( 'Pings' ); ?></span>
1177 <select name="ping_status">
1178 <option value=""><?php _e('- No Change -'); ?></option>
1179 <option value="open"><?php _e('Allow'); ?></option>
1180 <option value="closed"><?php _e('Do not allow'); ?></option>
1185 <?php else : // $bulk ?>
1187 <div class="inline-edit-group">
1188 <label class="alignleft">
1189 <input type="checkbox" name="comment_status" value="open" />
1190 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1193 <label class="alignleft">
1194 <input type="checkbox" name="ping_status" value="open" />
1195 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1199 <?php endif; // $bulk ?>
1202 <div class="inline-edit-group">
1203 <label class="inline-edit-status alignleft">
1204 <span class="title"><?php _e( 'Status' ); ?></span>
1205 <select name="_status">
1206 <?php if ( $bulk ) : ?>
1207 <option value="-1"><?php _e('- No Change -'); ?></option>
1208 <?php endif; // $bulk ?>
1209 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1210 <option value="publish"><?php _e( 'Published' ); ?></option>
1211 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1212 <?php if ( $bulk ) : ?>
1213 <option value="private"><?php _e('Private') ?></option>
1214 <?php endif; // $bulk ?>
1216 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1217 <option value="draft"><?php _e( 'Draft' ); ?></option>
1221 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
1223 <?php if ( $bulk ) : ?>
1225 <label class="alignright">
1226 <span class="title"><?php _e( 'Sticky' ); ?></span>
1227 <select name="sticky">
1228 <option value="-1"><?php _e( '- No Change -' ); ?></option>
1229 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1230 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1234 <?php else : // $bulk ?>
1236 <label class="alignleft">
1237 <input type="checkbox" name="sticky" value="sticky" />
1238 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1241 <?php endif; // $bulk ?>
1243 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
1250 foreach ( $columns as $column_name => $column_display_name ) {
1251 if ( isset( $core_columns[$column_name] ) )
1253 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
1256 <p class="submit inline-edit-save">
1257 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
1258 <?php if ( ! $bulk ) {
1259 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1260 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
1262 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
1263 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
1265 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
1267 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
1269 <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
1270 <br class="clear" />
1276 </tbody></table></form>
1280 // adds hidden fields with the data for use in the inline editor for posts and pages
1282 * {@internal Missing Short Description}}
1286 * @param unknown_type $post
1288 function get_inline_data($post) {
1290 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
1293 $title = esc_attr($post->post_title);
1296 <div class="hidden" id="inline_' . $post->ID . '">
1297 <div class="post_title">' . $title . '</div>
1298 <div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
1299 <div class="post_author">' . $post->post_author . '</div>
1300 <div class="comment_status">' . $post->comment_status . '</div>
1301 <div class="ping_status">' . $post->ping_status . '</div>
1302 <div class="_status">' . $post->post_status . '</div>
1303 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
1304 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
1305 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
1306 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
1307 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
1308 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
1309 <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
1311 if( $post->post_type == 'page' )
1313 <div class="post_parent">' . $post->post_parent . '</div>
1314 <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>
1315 <div class="menu_order">' . $post->menu_order . '</div>';
1317 if( $post->post_type == 'post' )
1319 <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>
1320 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
1321 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
1327 * {@internal Missing Short Description}}
1331 * @param unknown_type $posts
1333 function post_rows( $posts = array() ) {
1334 global $wp_query, $post, $mode;
1336 add_filter('the_title','esc_html');
1338 // Create array of post IDs.
1339 $post_ids = array();
1341 if ( empty($posts) )
1342 $posts = &$wp_query->posts;
1344 foreach ( $posts as $a_post )
1345 $post_ids[] = $a_post->ID;
1347 $comment_pending_count = get_pending_comments_num($post_ids);
1348 if ( empty($comment_pending_count) )
1349 $comment_pending_count = array();
1351 foreach ( $posts as $post ) {
1352 if ( empty($comment_pending_count[$post->ID]) )
1353 $comment_pending_count[$post->ID] = 0;
1355 _post_row($post, $comment_pending_count[$post->ID], $mode);
1360 * {@internal Missing Short Description}}
1364 * @param unknown_type $a_post
1365 * @param unknown_type $pending_comments
1366 * @param unknown_type $mode
1368 function _post_row($a_post, $pending_comments, $mode) {
1369 global $post, $current_user;
1372 $global_post = $post;
1374 setup_postdata($post);
1376 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
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) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
1443 if ( 'excerpt' == $mode )
1447 if ( current_user_can('edit_post', $post->ID) && 'trash' != $post->post_status ) {
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 if ( 'trash' == $post->post_status )
1453 $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
1454 elseif ( EMPTY_TRASH_DAYS )
1455 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
1456 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
1457 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
1459 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1460 if ( current_user_can('edit_post', $post->ID) )
1461 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1462 } elseif ( 'trash' != $post->post_status ) {
1463 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1465 $actions = apply_filters('post_row_actions', $actions, $post);
1466 $action_count = count($actions);
1468 echo '<div class="row-actions">';
1469 foreach ( $actions as $action => $link ) {
1471 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1472 echo "<span class='$action'>$link$sep</span>";
1476 get_inline_data($post);
1484 <td <?php echo $attributes ?>><?php
1485 $categories = get_the_category();
1486 if ( !empty( $categories ) ) {
1488 foreach ( $categories as $c )
1489 $out[] = "<a href='edit.php?category_name=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
1490 echo join( ', ', $out );
1492 _e('Uncategorized');
1500 <td <?php echo $attributes ?>><?php
1501 $tags = get_the_tags($post->ID);
1502 if ( !empty( $tags ) ) {
1504 foreach ( $tags as $c )
1505 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
1506 echo join( ', ', $out );
1516 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1518 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
1519 if ( $pending_comments )
1521 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>');
1522 if ( $pending_comments )
1531 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1535 case 'control_view':
1537 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
1541 case 'control_edit':
1543 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
1547 case 'control_delete':
1549 <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>
1555 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
1563 $post = $global_post;
1567 * display one row if the page doesn't have any children
1568 * otherwise, display the row and its children in subsequent rows
1571 * {@internal Missing Short Description}}
1575 * @param unknown_type $page
1576 * @param unknown_type $level
1578 function display_page_row( $page, $level = 0 ) {
1583 setup_postdata($page);
1585 if ( 0 == $level && (int)$page->post_parent > 0 ) {
1586 //sent level 0 by accident, by default, or because we don't know the actual level
1587 $find_main_page = (int)$page->post_parent;
1588 while ( $find_main_page > 0 ) {
1589 $parent = get_page($find_main_page);
1591 if ( is_null($parent) )
1595 $find_main_page = (int)$parent->post_parent;
1597 if ( !isset($parent_name) )
1598 $parent_name = $parent->post_title;
1602 $page->post_title = esc_html( $page->post_title );
1603 $pad = str_repeat( '— ', $level );
1604 $id = (int) $page->ID;
1605 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1606 $posts_columns = get_column_headers('edit-pages');
1607 $hidden = get_hidden_columns('edit-pages');
1608 $title = _draft_or_post_title();
1610 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
1613 foreach ($posts_columns as $column_name=>$column_display_name) {
1614 $class = "class=\"$column_name column-$column_name\"";
1617 if ( in_array($column_name, $hidden) )
1618 $style = ' style="display:none;"';
1620 $attributes = "$class$style";
1622 switch ($column_name) {
1626 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
1630 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
1631 $t_time = $h_time = __('Unpublished');
1634 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1635 $m_time = $page->post_date;
1636 $time = get_post_time('G', true);
1638 $time_diff = time() - $time;
1640 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1641 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1643 $h_time = mysql2date(__('Y/m/d'), $m_time);
1645 echo '<td ' . $attributes . '>';
1646 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
1648 if ( 'publish' == $page->post_status ) {
1650 } elseif ( 'future' == $page->post_status ) {
1651 if ( $time_diff > 0 )
1652 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1656 _e('Last Modified');
1661 $attributes = 'class="post-title page-title column-title"' . $style;
1662 $edit_link = get_edit_post_link( $page->ID );
1664 <td <?php echo $attributes ?>><strong><?php if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>
1667 if ( current_user_can('edit_page', $page->ID) && $post->post_status != 'trash' ) {
1668 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
1669 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
1671 if ( current_user_can('delete_page', $page->ID) ) {
1672 if ( $post->post_status == 'trash' )
1673 $actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("page.php?action=untrash&post=$page->ID", 'untrash-page_' . $page->ID) . "'>" . __('Restore') . "</a>";
1674 elseif ( EMPTY_TRASH_DAYS )
1675 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this page to the Trash')) . "' href='" . get_delete_post_link($page->ID) . "'>" . __('Trash') . "</a>";
1676 if ( $post->post_status == 'trash' || !EMPTY_TRASH_DAYS )
1677 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
1679 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1680 if ( current_user_can('edit_page', $page->ID) )
1681 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1682 } elseif ( $post->post_status != 'trash' ) {
1683 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1685 $actions = apply_filters('page_row_actions', $actions, $page);
1686 $action_count = count($actions);
1689 echo '<div class="row-actions">';
1690 foreach ( $actions as $action => $link ) {
1692 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1693 echo "<span class='$action'>$link$sep</span>";
1697 get_inline_data($post);
1703 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1705 $left = get_pending_comments_num( $page->ID );
1706 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
1709 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>');
1719 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1725 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
1738 * displays pages in hierarchical order with paging support
1741 * {@internal Missing Short Description}}
1745 * @param unknown_type $pages
1746 * @param unknown_type $pagenum
1747 * @param unknown_type $per_page
1750 function page_rows($pages, $pagenum = 1, $per_page = 20) {
1756 $pages = get_pages( array('sort_column' => 'menu_order') );
1763 * arrange pages into two parts: top level pages and children_pages
1764 * children_pages is two dimensional array, eg.
1765 * children_pages[10][] contains all sub-pages whose parent is 10.
1766 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
1767 * If searching, ignore hierarchy and treat everything as top level
1769 if ( empty($_GET['s']) ) {
1771 $top_level_pages = array();
1772 $children_pages = array();
1774 foreach ( $pages as $page ) {
1776 // catch and repair bad pages
1777 if ( $page->post_parent == $page->ID ) {
1778 $page->post_parent = 0;
1779 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
1780 clean_page_cache( $page->ID );
1783 if ( 0 == $page->post_parent )
1784 $top_level_pages[] = $page;
1786 $children_pages[ $page->post_parent ][] = $page;
1789 $pages = &$top_level_pages;
1793 $start = ($pagenum - 1) * $per_page;
1794 $end = $start + $per_page;
1796 foreach ( $pages as $page ) {
1797 if ( $count >= $end )
1800 if ( $count >= $start )
1801 echo "\t" . display_page_row( $page, $level );
1805 if ( isset($children_pages) )
1806 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1809 // if it is the last pagenum and there are orphaned pages, display them with paging as well
1810 if ( isset($children_pages) && $count < $end ){
1811 foreach( $children_pages as $orphans ){
1812 foreach ( $orphans as $op ) {
1813 if ( $count >= $end )
1815 if ( $count >= $start )
1816 echo "\t" . display_page_row( $op, 0 );
1824 * Given a top level page ID, display the nested hierarchy of sub-pages
1825 * together with paging support
1828 * {@internal Missing Short Description}}
1832 * @param unknown_type $children_pages
1833 * @param unknown_type $count
1834 * @param unknown_type $parent
1835 * @param unknown_type $level
1836 * @param unknown_type $pagenum
1837 * @param unknown_type $per_page
1839 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
1841 if ( ! isset( $children_pages[$parent] ) )
1844 $start = ($pagenum - 1) * $per_page;
1845 $end = $start + $per_page;
1847 foreach ( $children_pages[$parent] as $page ) {
1849 if ( $count >= $end )
1852 // If the page starts in a subtree, print the parents.
1853 if ( $count == $start && $page->post_parent > 0 ) {
1854 $my_parents = array();
1855 $my_parent = $page->post_parent;
1856 while ( $my_parent) {
1857 $my_parent = get_post($my_parent);
1858 $my_parents[] = $my_parent;
1859 if ( !$my_parent->post_parent )
1861 $my_parent = $my_parent->post_parent;
1863 $num_parents = count($my_parents);
1864 while( $my_parent = array_pop($my_parents) ) {
1865 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
1870 if ( $count >= $start )
1871 echo "\t" . display_page_row( $page, $level );
1875 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1878 unset( $children_pages[$parent] ); //required in order to keep track of orphans
1882 * {@internal Missing Short Description}}
1886 * @param unknown_type $user_object
1887 * @param unknown_type $style
1888 * @param unknown_type $role
1891 function user_row( $user_object, $style = '', $role = '' ) {
1894 $current_user = wp_get_current_user();
1896 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1897 $user_object = new WP_User( (int) $user_object );
1898 $user_object = sanitize_user_object($user_object, 'display');
1899 $email = $user_object->user_email;
1900 $url = $user_object->user_url;
1901 $short_url = str_replace( 'http://', '', $url );
1902 $short_url = str_replace( 'www.', '', $short_url );
1903 if ('/' == substr( $short_url, -1 ))
1904 $short_url = substr( $short_url, 0, -1 );
1905 if ( strlen( $short_url ) > 35 )
1906 $short_url = substr( $short_url, 0, 32 ).'...';
1907 $numposts = get_usernumposts( $user_object->ID );
1909 // Check if the user for this row is editable
1910 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
1911 // Set up the user editing link
1912 // TODO: make profile/user-edit determination a seperate function
1913 if ($current_user->ID == $user_object->ID) {
1914 $edit_link = 'profile.php';
1916 $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" ) );
1918 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1920 // Set up the hover actions for this user
1922 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1923 if ( $current_user->ID != $user_object->ID )
1924 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1925 $actions = apply_filters('user_row_actions', $actions, $user_object);
1926 $action_count = count($actions);
1928 $edit .= '<div class="row-actions">';
1929 foreach ( $actions as $action => $link ) {
1931 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1932 $edit .= "<span class='$action'>$link$sep</span>";
1936 // Set up the checkbox (because the user is editable, otherwise its empty)
1937 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
1940 $edit = '<strong>' . $user_object->user_login . '</strong>';
1942 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
1943 $r = "<tr id='user-$user_object->ID'$style>";
1944 $columns = get_column_headers('users');
1945 $hidden = get_hidden_columns('users');
1946 $avatar = get_avatar( $user_object->ID, 32 );
1947 foreach ( $columns as $column_name => $column_display_name ) {
1948 $class = "class=\"$column_name column-$column_name\"";
1951 if ( in_array($column_name, $hidden) )
1952 $style = ' style="display:none;"';
1954 $attributes = "$class$style";
1956 switch ($column_name) {
1958 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
1961 $r .= "<td $attributes>$avatar $edit</td>";
1964 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1967 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
1970 $r .= "<td $attributes>$role_name</td>";
1973 $attributes = 'class="posts column-posts num"' . $style;
1974 $r .= "<td $attributes>";
1975 if ( $numposts > 0 ) {
1976 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1985 $r .= "<td $attributes>";
1986 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
1996 * {@internal Missing Short Description}}
2000 * @param string $status Comment status (approved, spam, trash, etc)
2001 * @param string $s Term to search for
2002 * @param int $start Offset to start at for pagination
2003 * @param int $num Maximum number of comments to return
2004 * @param int $post Post ID or 0 to return all comments
2005 * @param string $type Comment type (comment, trackback, pingback, etc)
2006 * @return array [0] contains the comments and [1] contains the total number of comments that match (ignoring $start and $num)
2008 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
2011 $start = abs( (int) $start );
2013 $post = (int) $post;
2014 $count = wp_count_comments();
2017 if ( 'moderated' == $status ) {
2018 $approved = "c.comment_approved = '0'";
2019 $total = $count->moderated;
2020 } elseif ( 'approved' == $status ) {
2021 $approved = "c.comment_approved = '1'";
2022 $total = $count->approved;
2023 } elseif ( 'spam' == $status ) {
2024 $approved = "c.comment_approved = 'spam'";
2025 $total = $count->spam;
2026 } elseif ( 'trash' == $status ) {
2027 $approved = "c.comment_approved = 'trash'";
2028 $total = $count->trash;
2030 $approved = "( c.comment_approved = '0' OR c.comment_approved = '1' )";
2031 $total = $count->moderated + $count->approved;
2032 $index = 'USE INDEX (c.comment_date_gmt)';
2037 $post = " AND c.comment_post_ID = '$post'";
2042 $orderby = "ORDER BY c.comment_date_gmt DESC LIMIT $start, $num";
2044 if ( 'comment' == $type )
2045 $typesql = "AND c.comment_type = ''";
2046 elseif ( 'pings' == $type )
2047 $typesql = "AND ( c.comment_type = 'pingback' OR c.comment_type = 'trackback' )";
2048 elseif ( 'all' == $type )
2050 elseif ( !empty($type) )
2051 $typesql = $wpdb->prepare("AND c.comment_type = %s", $type);
2055 if ( !empty($type) )
2058 $query = "FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ";
2061 $s = $wpdb->escape($s);
2063 (c.comment_author LIKE '%$s%' OR
2064 c.comment_author_email LIKE '%$s%' OR
2065 c.comment_author_url LIKE ('%$s%') OR
2066 c.comment_author_IP LIKE ('%$s%') OR
2067 c.comment_content LIKE ('%$s%') ) AND
2071 $query .= "AND $approved $post $typesql";
2074 $comments = $wpdb->get_results("SELECT * $query $orderby");
2075 if ( '' === $total )
2076 $total = $wpdb->get_var("SELECT COUNT(c.comment_ID) $query");
2078 update_comment_cache($comments);
2080 return array($comments, $total);
2084 * {@internal Missing Short Description}}
2088 * @param unknown_type $comment_id
2089 * @param unknown_type $mode
2090 * @param unknown_type $comment_status
2091 * @param unknown_type $checkbox
2093 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
2094 global $comment, $post, $_comment_pending_count;
2095 $comment = get_comment( $comment_id );
2096 $post = get_post($comment->comment_post_ID);
2097 $the_comment_status = wp_get_comment_status($comment->comment_ID);
2098 $user_can = current_user_can('edit_post', $post->ID);
2100 $author_url = get_comment_author_url();
2101 if ( 'http://' == $author_url )
2103 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);
2104 if ( strlen($author_url_display) > 50 )
2105 $author_url_display = substr($author_url_display, 0, 49) . '...';
2107 $ptime = date('G', strtotime( $comment->comment_date ) );
2108 if ( ( abs(time() - $ptime) ) < 86400 )
2109 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
2111 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
2114 $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
2115 $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
2117 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2118 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2119 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2120 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2121 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2122 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2123 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2126 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2127 $columns = get_column_headers('edit-comments');
2128 $hidden = get_hidden_columns('edit-comments');
2129 foreach ( $columns as $column_name => $column_display_name ) {
2130 $class = "class=\"$column_name column-$column_name\"";
2133 if ( in_array($column_name, $hidden) )
2134 $style = ' style="display:none;"';
2136 $attributes = "$class$style";
2138 switch ($column_name) {
2140 if ( !$checkbox ) break;
2141 echo '<th scope="row" class="check-column">';
2142 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2146 echo "<td $attributes>";
2147 echo '<div id="submitted-on">';
2148 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')));
2151 if ( $user_can ) { ?>
2152 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2153 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>
2154 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
2155 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
2156 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2157 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2163 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
2165 'approve' => '', 'unapprove' => '',
2169 'spam' => '', 'unspam' => '',
2170 'trash' => '', 'untrash' => '', 'delete' => ''
2173 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2174 if ( 'approved' == $the_comment_status )
2175 $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>';
2176 else if ( 'unapproved' == $the_comment_status )
2177 $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>';
2179 $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>';
2180 $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>';
2183 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
2184 $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>';
2185 } elseif ( 'spam' == $the_comment_status ) {
2186 $actions['unspam'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . __( 'Not Spam' ) . '</a>';
2187 } elseif ( 'trash' == $the_comment_status ) {
2188 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
2191 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
2192 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
2194 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
2197 if ( 'trash' != $the_comment_status ) {
2198 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
2199 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
2200 if ( 'spam' != $the_comment_status )
2201 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2204 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
2207 echo '<div class="row-actions">';
2208 foreach ( $actions as $action => $link ) {
2210 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2212 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2213 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2214 $action .= ' hide-if-no-js';
2215 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {
2216 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
2217 $action .= ' approve';
2219 $action .= ' unapprove';
2222 echo "<span class='$action'>$sep$link</span>";
2230 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2231 if ( !empty($author_url) )
2232 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2234 if ( !empty($comment->comment_author_email) ) {
2235 comment_author_email_link();
2238 echo '<a href="edit-comments.php?s=';
2239 comment_author_IP();
2240 echo '&mode=detail';
2241 if ( 'spam' == $comment_status )
2242 echo '&comment_status=spam';
2244 comment_author_IP();
2246 } //current_user_can
2250 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2253 if ( 'single' !== $mode ) {
2254 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2255 $pending_comments = absint( $_comment_pending_count[$post->ID] );
2257 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
2258 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2261 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2262 $post_link .= get_the_title($post->ID) . '</a>';
2264 $post_link = get_the_title($post->ID);
2266 echo "<td $attributes>\n";
2267 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2268 echo $post_link . '<br />';
2269 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
2270 if ( $pending_comments )
2272 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>');
2273 if ( $pending_comments )
2276 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2278 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2284 echo "<td $attributes>\n";
2285 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2294 * {@internal Missing Short Description}}
2298 * @param unknown_type $position
2299 * @param unknown_type $checkbox
2300 * @param unknown_type $mode
2302 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2303 global $current_user;
2305 // allow plugin to replace the popup content
2306 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2308 if ( ! empty($content) ) {
2313 $columns = get_column_headers('edit-comments');
2314 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2315 $col_count = count($columns) - count($hidden);
2318 <form method="get" action="">
2319 <?php if ( $table_row ) : ?>
2320 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>">
2322 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
2324 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2326 <div id="edithead" style="display:none;">
2327 <div class="inside">
2328 <label for="author"><?php _e('Name') ?></label>
2329 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2332 <div class="inside">
2333 <label for="author-email"><?php _e('E-mail') ?></label>
2334 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2337 <div class="inside">
2338 <label for="author-url"><?php _e('URL') ?></label>
2339 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2341 <div style="clear:both;"></div>
2344 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2346 <p id="replysubmit" class="submit">
2347 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2348 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2349 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2350 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2351 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
2352 <span class="error" style="display:none;"></span>
2353 <br class="clear" />
2356 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2357 <input type="hidden" name="action" id="action" value="" />
2358 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2359 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2360 <input type="hidden" name="status" id="status" value="" />
2361 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2362 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2363 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2364 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
2365 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2366 <?php if ( $table_row ) : ?>
2367 </td></tr></tbody></table>
2376 * Output 'undo move to trash' text for comments
2380 function wp_comment_trashnotice() {
2382 <div class="hidden" id="trash-undo-holder">
2383 <div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
2385 <div class="hidden" id="spam-undo-holder">
2386 <div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
2392 * {@internal Missing Short Description}}
2396 * @param unknown_type $currentcat
2397 * @param unknown_type $currentparent
2398 * @param unknown_type $parent
2399 * @param unknown_type $level
2400 * @param unknown_type $categories
2403 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
2405 $categories = get_categories( array('hide_empty' => 0) );
2407 if ( $categories ) {
2408 foreach ( $categories as $category ) {
2409 if ( $currentcat != $category->term_id && $parent == $category->parent) {
2410 $pad = str_repeat( '– ', $level );
2411 $category->name = esc_html( $category->name );
2412 echo "\n\t<option value='$category->term_id'";
2413 if ( $currentparent == $category->term_id )
2414 echo " selected='selected'";
2415 echo ">$pad$category->name</option>";
2416 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
2425 * {@internal Missing Short Description}}
2429 * @param unknown_type $meta
2431 function list_meta( $meta ) {
2435 <table id="list-table" style="display: none;">
2438 <th class="left">' . __( 'Name' ) . '</th>
2439 <th>' . __( 'Value' ) . '</th>
2442 <tbody id="the-list" class="list:meta">
2445 </table>'; //TBODY needed for list-manipulation JS
2450 <table id="list-table">
2453 <th class="left"><?php _e( 'Name' ) ?></th>
2454 <th><?php _e( 'Value' ) ?></th>
2457 <tbody id='the-list' class='list:meta'>
2459 foreach ( $meta as $entry )
2460 echo _list_meta_row( $entry, $count );
2468 * {@internal Missing Short Description}}
2472 * @param unknown_type $entry
2473 * @param unknown_type $count
2476 function _list_meta_row( $entry, &$count ) {
2477 static $update_nonce = false;
2478 if ( !$update_nonce )
2479 $update_nonce = wp_create_nonce( 'add-meta' );
2484 $style = 'alternate';
2487 if ('_' == $entry['meta_key'] { 0 } )
2488 $style .= ' hidden';
2490 if ( is_serialized( $entry['meta_value'] ) ) {
2491 if ( is_serialized_string( $entry['meta_value'] ) ) {
2492 // this is a serialized string, so we should display it
2493 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2495 // this is a serialized array/object so we should NOT display it
2501 $entry['meta_key'] = esc_attr($entry['meta_key']);
2502 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2503 $entry['meta_id'] = (int) $entry['meta_id'];
2505 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2507 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2508 $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']}' />";
2510 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2511 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2512 $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>";
2513 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2516 $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>";
2521 * {@internal Missing Short Description}}
2525 function meta_form() {
2527 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2528 $keys = $wpdb->get_col( "
2530 FROM $wpdb->postmeta
2532 HAVING meta_key NOT LIKE '\_%'
2533 ORDER BY LOWER(meta_key)
2538 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
2539 <table id="newmeta">
2542 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2543 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2549 <td id="newmetaleft" class="left">
2550 <?php if ( $keys ) { ?>
2551 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2552 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
2555 foreach ( $keys as $key ) {
2556 $key = esc_attr( $key );
2557 echo "\n<option value='" . esc_attr($key) . "'>$key</option>";
2561 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2562 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2563 <span id="enternew"><?php _e('Enter new'); ?></span>
2564 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2566 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2569 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2572 <tr><td colspan="2" class="submit">
2573 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2574 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
2583 * {@internal Missing Short Description}}
2587 * @param unknown_type $edit
2588 * @param unknown_type $for_post
2589 * @param unknown_type $tab_index
2590 * @param unknown_type $multi
2592 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2593 global $wp_locale, $post, $comment;
2596 $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;
2598 $tab_index_attribute = '';
2599 if ( (int) $tab_index > 0 )
2600 $tab_index_attribute = " tabindex=\"$tab_index\"";
2602 // 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 />';
2604 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
2605 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2606 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2607 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2608 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2609 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2610 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2611 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2613 $cur_jj = gmdate( 'd', $time_adj );
2614 $cur_mm = gmdate( 'm', $time_adj );
2615 $cur_aa = gmdate( 'Y', $time_adj );
2616 $cur_hh = gmdate( 'H', $time_adj );
2617 $cur_mn = gmdate( 'i', $time_adj );
2619 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2620 for ( $i = 1; $i < 13; $i = $i +1 ) {
2621 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2623 $month .= ' selected="selected"';
2624 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2626 $month .= '</select>';
2628 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2629 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2630 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2631 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2633 echo '<div class="timestamp-wrap">';
2634 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2635 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2637 echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2639 if ( $multi ) return;
2642 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2643 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2644 $cur_timeunit = 'cur_' . $timeunit;
2645 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2650 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2651 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2657 * {@internal Missing Short Description}}
2661 * @param unknown_type $default
2663 function page_template_dropdown( $default = '' ) {
2664 $templates = get_page_templates();
2665 ksort( $templates );
2666 foreach (array_keys( $templates ) as $template )
2667 : if ( $default == $templates[$template] )
2668 $selected = " selected='selected'";
2671 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2676 * {@internal Missing Short Description}}
2680 * @param unknown_type $default
2681 * @param unknown_type $parent
2682 * @param unknown_type $level
2685 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2686 global $wpdb, $post_ID;
2687 $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) );
2690 foreach ( $items as $item ) {
2691 // A page cannot be its own parent.
2692 if (!empty ( $post_ID ) ) {
2693 if ( $item->ID == $post_ID ) {
2697 $pad = str_repeat( ' ', $level * 3 );
2698 if ( $item->ID == $default)
2699 $current = ' selected="selected"';
2703 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2704 parent_dropdown( $default, $item->ID, $level +1 );
2712 * {@internal Missing Short Description}}
2716 function browse_happy() {
2717 $getit = __( 'WordPress recommends a better browser' );
2719 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
2724 * {@internal Missing Short Description}}
2728 * @param unknown_type $id
2731 function the_attachment_links( $id = false ) {
2733 $post = & get_post( $id );
2735 if ( $post->post_type != 'attachment' )
2738 $icon = get_attachment_icon( $post->ID );
2739 $attachment_data = wp_get_attachment_metadata( $id );
2740 $thumb = isset( $attachment_data['thumb'] );
2742 <form id="the-attachment-links">
2745 <col class="widefat" />
2747 <th scope="row"><?php _e( 'URL' ) ?></th>
2748 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2750 <?php if ( $icon ) : ?>
2752 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2753 <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>
2756 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2757 <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>
2761 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2762 <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>
2765 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2766 <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>
2776 * Print out <option> html elements for role selectors based on $wp_roles
2778 * @package WordPress
2779 * @subpackage Administration
2783 * @param string $default slug for the role that should be already selected
2785 function wp_dropdown_roles( $selected = false ) {
2790 $editable_roles = get_editable_roles();
2792 foreach( $editable_roles as $role => $details ) {
2793 $name = translate_user_role($details['name'] );
2794 if ( $selected == $role ) // Make default first in list
2795 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2797 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2803 * {@internal Missing Short Description}}
2807 * @param unknown_type $size
2810 function wp_convert_hr_to_bytes( $size ) {
2811 $size = strtolower($size);
2812 $bytes = (int) $size;
2813 if ( strpos($size, 'k') !== false )
2814 $bytes = intval($size) * 1024;
2815 elseif ( strpos($size, 'm') !== false )
2816 $bytes = intval($size) * 1024 * 1024;
2817 elseif ( strpos($size, 'g') !== false )
2818 $bytes = intval($size) * 1024 * 1024 * 1024;
2823 * {@internal Missing Short Description}}
2827 * @param unknown_type $bytes
2830 function wp_convert_bytes_to_hr( $bytes ) {
2831 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2832 $log = log( $bytes, 1024 );
2833 $power = (int) $log;
2834 $size = pow(1024, $log - $power);
2835 return $size . $units[$power];
2839 * {@internal Missing Short Description}}
2845 function wp_max_upload_size() {
2846 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2847 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2848 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2853 * Outputs the form used by the importers to accept the data to be imported
2857 * @param string $action The action attribute for the form.
2859 function wp_import_upload_form( $action ) {
2860 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2861 $size = wp_convert_bytes_to_hr( $bytes );
2862 $upload_dir = wp_upload_dir();
2863 if ( ! empty( $upload_dir['error'] ) ) :
2864 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2865 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2868 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
2870 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2871 <input type="file" id="upload" name="import" size="25" />
2872 <input type="hidden" name="action" value="save" />
2873 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2876 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2884 * {@internal Missing Short Description}}
2888 function wp_remember_old_slug() {
2890 $name = esc_attr($post->post_name); // just in case
2891 if ( strlen($name) )
2892 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
2896 * Add a meta box to an edit form.
2900 * @param string $id String for use in the 'id' attribute of tags.
2901 * @param string $title Title of the meta box.
2902 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2903 * @param string $page The type of edit page on which to show the box (post, page, link).
2904 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2905 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2907 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2908 global $wp_meta_boxes;
2910 if ( !isset($wp_meta_boxes) )
2911 $wp_meta_boxes = array();
2912 if ( !isset($wp_meta_boxes[$page]) )
2913 $wp_meta_boxes[$page] = array();
2914 if ( !isset($wp_meta_boxes[$page][$context]) )
2915 $wp_meta_boxes[$page][$context] = array();
2917 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2918 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2919 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2922 // If a core box was previously added or removed by a plugin, don't add.
2923 if ( 'core' == $priority ) {
2924 // If core box previously deleted, don't add
2925 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2927 // If box was added with default priority, give it core priority to maintain sort order
2928 if ( 'default' == $a_priority ) {
2929 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2930 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2934 // If no priority given and id already present, use existing priority
2935 if ( empty($priority) ) {
2936 $priority = $a_priority;
2937 // 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.
2938 } elseif ( 'sorted' == $priority ) {
2939 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2940 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2941 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2943 // An id can be in only one priority and one context
2944 if ( $priority != $a_priority || $context != $a_context )
2945 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2949 if ( empty($priority) )
2952 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2953 $wp_meta_boxes[$page][$context][$priority] = array();
2955 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2959 * {@internal Missing Short Description}}
2963 * @param unknown_type $page
2964 * @param unknown_type $context
2965 * @param unknown_type $object
2966 * @return int number of meta_boxes
2968 function do_meta_boxes($page, $context, $object) {
2969 global $wp_meta_boxes;
2970 static $already_sorted = false;
2972 //do_action('do_meta_boxes', $page, $context, $object);
2974 $hidden = get_hidden_meta_boxes($page);
2976 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
2980 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2981 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
2982 foreach ( $sorted as $box_context => $ids )
2983 foreach ( explode(',', $ids) as $id )
2985 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2987 $already_sorted = true;
2989 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2992 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2993 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2994 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2995 if ( false == $box || ! $box['title'] )
2999 if ( in_array($box['id'], $hidden) )
3000 $style = 'style="display:none;"';
3001 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
3002 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
3003 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
3004 echo '<div class="inside">' . "\n";
3005 call_user_func($box['callback'], $object, $box);
3020 * Remove a meta box from an edit form.
3024 * @param string $id String for use in the 'id' attribute of tags.
3025 * @param string $page The type of edit page on which to show the box (post, page, link).
3026 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
3028 function remove_meta_box($id, $page, $context) {
3029 global $wp_meta_boxes;
3031 if ( !isset($wp_meta_boxes) )
3032 $wp_meta_boxes = array();
3033 if ( !isset($wp_meta_boxes[$page]) )
3034 $wp_meta_boxes[$page] = array();
3035 if ( !isset($wp_meta_boxes[$page][$context]) )
3036 $wp_meta_boxes[$page][$context] = array();
3038 foreach ( array('high', 'core', 'default', 'low') as $priority )
3039 $wp_meta_boxes[$page][$context][$priority][$id] = false;
3043 * {@internal Missing Short Description}}
3047 * @param unknown_type $page
3049 function meta_box_prefs($page) {
3050 global $wp_meta_boxes;
3052 if ( empty($wp_meta_boxes[$page]) )
3055 $hidden = get_hidden_meta_boxes($page);
3057 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
3058 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
3059 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
3060 if ( false == $box || ! $box['title'] )
3062 // Submit box cannot be hidden
3063 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
3065 $box_id = $box['id'];
3066 echo '<label for="' . $box_id . '-hide">';
3067 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"' : '') . ' />';
3068 echo "{$box['title']}</label>\n";
3074 function get_hidden_meta_boxes($page) {
3075 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
3077 // Hide slug boxes by default
3078 if ( empty($hidden[0]) ) {
3079 $hidden = array('slugdiv');
3086 * Add a new section to a settings page.
3090 * @param string $id String for use in the 'id' attribute of tags.
3091 * @param string $title Title of the section.
3092 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
3093 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
3095 function add_settings_section($id, $title, $callback, $page) {
3096 global $wp_settings_sections;
3098 if ( !isset($wp_settings_sections) )
3099 $wp_settings_sections = array();
3100 if ( !isset($wp_settings_sections[$page]) )
3101 $wp_settings_sections[$page] = array();
3102 if ( !isset($wp_settings_sections[$page][$id]) )
3103 $wp_settings_sections[$page][$id] = array();
3105 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
3109 * Add a new field to a settings page.
3113 * @param string $id String for use in the 'id' attribute of tags.
3114 * @param string $title Title of the field.
3115 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
3116 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
3117 * @param string $section The section of the settingss page in which to show the box (default, ...).
3118 * @param array $args Additional arguments
3120 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3121 global $wp_settings_fields;
3123 if ( !isset($wp_settings_fields) )
3124 $wp_settings_fields = array();
3125 if ( !isset($wp_settings_fields[$page]) )
3126 $wp_settings_fields[$page] = array();
3127 if ( !isset($wp_settings_fields[$page][$section]) )
3128 $wp_settings_fields[$page][$section] = array();
3130 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3134 * {@internal Missing Short Description}}
3138 * @param unknown_type $page
3140 function do_settings_sections($page) {
3141 global $wp_settings_sections, $wp_settings_fields;
3143 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3146 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3147 echo "<h3>{$section['title']}</h3>\n";
3148 call_user_func($section['callback'], $section);
3149 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3151 echo '<table class="form-table">';
3152 do_settings_fields($page, $section['id']);
3158 * {@internal Missing Short Description}}
3162 * @param unknown_type $page
3163 * @param unknown_type $section
3165 function do_settings_fields($page, $section) {
3166 global $wp_settings_fields;
3168 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3171 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3172 echo '<tr valign="top">';
3173 if ( !empty($field['args']['label_for']) )
3174 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3176 echo '<th scope="row">' . $field['title'] . '</th>';
3178 call_user_func($field['callback'], $field['args']);
3185 * {@internal Missing Short Description}}
3189 * @param unknown_type $page
3191 function manage_columns_prefs($page) {
3192 $columns = get_column_headers($page);
3194 $hidden = get_hidden_columns($page);
3196 foreach ( $columns as $column => $title ) {
3198 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
3200 if ( empty($title) )
3203 if ( 'comments' == $column )
3204 $title = __('Comments');
3205 $id = "$column-hide";
3206 echo '<label for="' . $id . '">';
3207 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3208 echo "$title</label>\n";
3213 * {@internal Missing Short Description}}
3217 * @param unknown_type $found_action
3219 function find_posts_div($found_action = '') {
3221 <div id="find-posts" class="find-box" style="display:none;">
3222 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3223 <div class="find-box-inside">
3224 <div class="find-box-search">
3225 <?php if ( $found_action ) { ?>
3226 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3229 <input type="hidden" name="affected" id="affected" value="" />
3230 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3231 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3232 <input type="text" id="find-posts-input" name="ps" value="" />
3233 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3235 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
3236 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
3237 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
3238 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
3240 <div id="find-posts-response"></div>
3242 <div class="find-box-buttons">
3243 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3244 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3251 * Display the post password.
3253 * The password is passed through {@link esc_attr()} to ensure that it
3254 * is safe for placing in an html attribute.
3259 function the_post_password() {
3261 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3265 * {@internal Missing Short Description}}
3269 function favorite_actions( $screen = null ) {
3270 switch ( $screen ) {
3271 case 'post-new.php':
3272 $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
3274 case 'edit-pages.php':
3275 $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
3277 case 'page-new.php':
3278 $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
3281 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3283 case 'media-new.php':
3284 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3286 case 'link-manager.php':
3287 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3289 case 'link-add.php':
3290 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3293 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3295 case 'user-new.php':
3296 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3299 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3301 case 'plugin-install.php':
3302 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3305 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3307 case 'theme-install.php':
3308 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3311 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3316 'post-new.php' => array(__('New Post'), 'edit_posts'),
3317 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3318 'page-new.php' => array(__('New Page'), 'edit_pages'),
3319 'media-new.php' => array(__('Upload'), 'upload_files'),
3320 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3323 $default_key = array_keys($default_action);
3324 $default_key = $default_key[0];
3325 if ( isset($actions[$default_key]) )
3326 unset($actions[$default_key]);
3327 $actions = array_merge($default_action, $actions);