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 $comment_url = esc_url(get_comment_link($comment->comment_ID));
2118 $approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2119 $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
2120 $spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2121 $unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2122 $trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2123 $untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2124 $delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
2127 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2128 $columns = get_column_headers('edit-comments');
2129 $hidden = get_hidden_columns('edit-comments');
2130 foreach ( $columns as $column_name => $column_display_name ) {
2131 $class = "class=\"$column_name column-$column_name\"";
2134 if ( in_array($column_name, $hidden) )
2135 $style = ' style="display:none;"';
2137 $attributes = "$class$style";
2139 switch ($column_name) {
2141 if ( !$checkbox ) break;
2142 echo '<th scope="row" class="check-column">';
2143 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2147 echo "<td $attributes>";
2148 echo '<div id="submitted-on">';
2149 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), $comment_url, get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
2152 if ( $user_can ) { ?>
2153 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2154 <textarea class="comment" rows="1" cols="1"><?php echo htmlspecialchars( apply_filters('comment_edit_pre', $comment->comment_content), ENT_QUOTES ); ?></textarea>
2155 <div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
2156 <div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
2157 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2158 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2164 // preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
2166 'approve' => '', 'unapprove' => '',
2170 'spam' => '', 'unspam' => '',
2171 'trash' => '', 'untrash' => '', 'delete' => ''
2174 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2175 if ( 'approved' == $the_comment_status )
2176 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2177 else if ( 'unapproved' == $the_comment_status )
2178 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2180 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2181 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2184 if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
2185 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
2186 } elseif ( 'spam' == $the_comment_status ) {
2187 $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>';
2188 } elseif ( 'trash' == $the_comment_status ) {
2189 $actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
2192 if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
2193 $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>';
2195 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
2198 if ( 'trash' != $the_comment_status ) {
2199 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
2200 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.esc_attr__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
2201 if ( 'spam' != $the_comment_status )
2202 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2205 $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
2208 echo '<div class="row-actions">';
2209 foreach ( $actions as $action => $link ) {
2211 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2213 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2214 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2215 $action .= ' hide-if-no-js';
2216 elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {
2217 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
2218 $action .= ' approve';
2220 $action .= ' unapprove';
2223 echo "<span class='$action'>$sep$link</span>";
2231 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2232 if ( !empty($author_url) )
2233 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2235 if ( !empty($comment->comment_author_email) ) {
2236 comment_author_email_link();
2239 echo '<a href="edit-comments.php?s=';
2240 comment_author_IP();
2241 echo '&mode=detail';
2242 if ( 'spam' == $comment_status )
2243 echo '&comment_status=spam';
2245 comment_author_IP();
2247 } //current_user_can
2251 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2254 if ( 'single' !== $mode ) {
2255 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2256 $pending_comments = absint( $_comment_pending_count[$post->ID] );
2258 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
2259 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2262 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2263 $post_link .= get_the_title($post->ID) . '</a>';
2265 $post_link = get_the_title($post->ID);
2267 echo "<td $attributes>\n";
2268 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2269 echo $post_link . '<br />';
2270 $pending_phrase = esc_attr(sprintf( __('%s pending'), number_format( $pending_comments ) ));
2271 if ( $pending_comments )
2273 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>');
2274 if ( $pending_comments )
2277 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2279 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2285 echo "<td $attributes>\n";
2286 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2295 * {@internal Missing Short Description}}
2299 * @param unknown_type $position
2300 * @param unknown_type $checkbox
2301 * @param unknown_type $mode
2303 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2304 global $current_user;
2306 // allow plugin to replace the popup content
2307 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2309 if ( ! empty($content) ) {
2314 $columns = get_column_headers('edit-comments');
2315 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2316 $col_count = count($columns) - count($hidden);
2319 <form method="get" action="">
2320 <?php if ( $table_row ) : ?>
2321 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $col_count; ?>">
2323 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
2325 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2327 <div id="edithead" style="display:none;">
2328 <div class="inside">
2329 <label for="author"><?php _e('Name') ?></label>
2330 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2333 <div class="inside">
2334 <label for="author-email"><?php _e('E-mail') ?></label>
2335 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2338 <div class="inside">
2339 <label for="author-url"><?php _e('URL') ?></label>
2340 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2342 <div style="clear:both;"></div>
2345 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2347 <p id="replysubmit" class="submit">
2348 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2349 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2350 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2351 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2352 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
2353 <span class="error" style="display:none;"></span>
2354 <br class="clear" />
2357 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2358 <input type="hidden" name="action" id="action" value="" />
2359 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2360 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2361 <input type="hidden" name="status" id="status" value="" />
2362 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2363 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2364 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2365 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
2366 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2367 <?php if ( $table_row ) : ?>
2368 </td></tr></tbody></table>
2377 * Output 'undo move to trash' text for comments
2381 function wp_comment_trashnotice() {
2383 <div class="hidden" id="trash-undo-holder">
2384 <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>
2386 <div class="hidden" id="spam-undo-holder">
2387 <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>
2393 * {@internal Missing Short Description}}
2397 * @param unknown_type $currentcat
2398 * @param unknown_type $currentparent
2399 * @param unknown_type $parent
2400 * @param unknown_type $level
2401 * @param unknown_type $categories
2404 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
2406 $categories = get_categories( array('hide_empty' => 0) );
2408 if ( $categories ) {
2409 foreach ( $categories as $category ) {
2410 if ( $currentcat != $category->term_id && $parent == $category->parent) {
2411 $pad = str_repeat( '– ', $level );
2412 $category->name = esc_html( $category->name );
2413 echo "\n\t<option value='$category->term_id'";
2414 if ( $currentparent == $category->term_id )
2415 echo " selected='selected'";
2416 echo ">$pad$category->name</option>";
2417 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
2426 * {@internal Missing Short Description}}
2430 * @param unknown_type $meta
2432 function list_meta( $meta ) {
2436 <table id="list-table" style="display: none;">
2439 <th class="left">' . __( 'Name' ) . '</th>
2440 <th>' . __( 'Value' ) . '</th>
2443 <tbody id="the-list" class="list:meta">
2446 </table>'; //TBODY needed for list-manipulation JS
2451 <table id="list-table">
2454 <th class="left"><?php _e( 'Name' ) ?></th>
2455 <th><?php _e( 'Value' ) ?></th>
2458 <tbody id='the-list' class='list:meta'>
2460 foreach ( $meta as $entry )
2461 echo _list_meta_row( $entry, $count );
2469 * {@internal Missing Short Description}}
2473 * @param unknown_type $entry
2474 * @param unknown_type $count
2477 function _list_meta_row( $entry, &$count ) {
2478 static $update_nonce = false;
2479 if ( !$update_nonce )
2480 $update_nonce = wp_create_nonce( 'add-meta' );
2485 $style = 'alternate';
2488 if ('_' == $entry['meta_key'] { 0 } )
2489 $style .= ' hidden';
2491 if ( is_serialized( $entry['meta_value'] ) ) {
2492 if ( is_serialized_string( $entry['meta_value'] ) ) {
2493 // this is a serialized string, so we should display it
2494 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2496 // this is a serialized array/object so we should NOT display it
2502 $entry['meta_key'] = esc_attr($entry['meta_key']);
2503 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2504 $entry['meta_id'] = (int) $entry['meta_id'];
2506 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2508 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2509 $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']}' />";
2511 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2512 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2513 $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>";
2514 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2517 $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>";
2522 * {@internal Missing Short Description}}
2526 function meta_form() {
2528 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2529 $keys = $wpdb->get_col( "
2531 FROM $wpdb->postmeta
2533 HAVING meta_key NOT LIKE '\_%'
2534 ORDER BY LOWER(meta_key)
2539 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
2540 <table id="newmeta">
2543 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2544 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2550 <td id="newmetaleft" class="left">
2551 <?php if ( $keys ) { ?>
2552 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2553 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
2556 foreach ( $keys as $key ) {
2557 $key = esc_attr( $key );
2558 echo "\n<option value='" . esc_attr($key) . "'>$key</option>";
2562 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2563 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2564 <span id="enternew"><?php _e('Enter new'); ?></span>
2565 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2567 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2570 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2573 <tr><td colspan="2" class="submit">
2574 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2575 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
2584 * {@internal Missing Short Description}}
2588 * @param unknown_type $edit
2589 * @param unknown_type $for_post
2590 * @param unknown_type $tab_index
2591 * @param unknown_type $multi
2593 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2594 global $wp_locale, $post, $comment;
2597 $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;
2599 $tab_index_attribute = '';
2600 if ( (int) $tab_index > 0 )
2601 $tab_index_attribute = " tabindex=\"$tab_index\"";
2603 // 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 />';
2605 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
2606 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2607 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2608 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2609 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2610 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2611 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2612 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2614 $cur_jj = gmdate( 'd', $time_adj );
2615 $cur_mm = gmdate( 'm', $time_adj );
2616 $cur_aa = gmdate( 'Y', $time_adj );
2617 $cur_hh = gmdate( 'H', $time_adj );
2618 $cur_mn = gmdate( 'i', $time_adj );
2620 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2621 for ( $i = 1; $i < 13; $i = $i +1 ) {
2622 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2624 $month .= ' selected="selected"';
2625 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2627 $month .= '</select>';
2629 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2630 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2631 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2632 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2634 echo '<div class="timestamp-wrap">';
2635 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2636 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2638 echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2640 if ( $multi ) return;
2643 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2644 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2645 $cur_timeunit = 'cur_' . $timeunit;
2646 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2651 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2652 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2658 * {@internal Missing Short Description}}
2662 * @param unknown_type $default
2664 function page_template_dropdown( $default = '' ) {
2665 $templates = get_page_templates();
2666 ksort( $templates );
2667 foreach (array_keys( $templates ) as $template )
2668 : if ( $default == $templates[$template] )
2669 $selected = " selected='selected'";
2672 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2677 * {@internal Missing Short Description}}
2681 * @param unknown_type $default
2682 * @param unknown_type $parent
2683 * @param unknown_type $level
2686 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2687 global $wpdb, $post_ID;
2688 $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) );
2691 foreach ( $items as $item ) {
2692 // A page cannot be its own parent.
2693 if (!empty ( $post_ID ) ) {
2694 if ( $item->ID == $post_ID ) {
2698 $pad = str_repeat( ' ', $level * 3 );
2699 if ( $item->ID == $default)
2700 $current = ' selected="selected"';
2704 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2705 parent_dropdown( $default, $item->ID, $level +1 );
2713 * {@internal Missing Short Description}}
2717 function browse_happy() {
2718 $getit = __( 'WordPress recommends a better browser' );
2720 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
2725 * {@internal Missing Short Description}}
2729 * @param unknown_type $id
2732 function the_attachment_links( $id = false ) {
2734 $post = & get_post( $id );
2736 if ( $post->post_type != 'attachment' )
2739 $icon = get_attachment_icon( $post->ID );
2740 $attachment_data = wp_get_attachment_metadata( $id );
2741 $thumb = isset( $attachment_data['thumb'] );
2743 <form id="the-attachment-links">
2746 <col class="widefat" />
2748 <th scope="row"><?php _e( 'URL' ) ?></th>
2749 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2751 <?php if ( $icon ) : ?>
2753 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2754 <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>
2757 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2758 <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>
2762 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2763 <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>
2766 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2767 <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>
2777 * Print out <option> html elements for role selectors based on $wp_roles
2779 * @package WordPress
2780 * @subpackage Administration
2784 * @param string $default slug for the role that should be already selected
2786 function wp_dropdown_roles( $selected = false ) {
2791 $editable_roles = get_editable_roles();
2793 foreach( $editable_roles as $role => $details ) {
2794 $name = translate_user_role($details['name'] );
2795 if ( $selected == $role ) // Make default first in list
2796 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2798 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2804 * {@internal Missing Short Description}}
2808 * @param unknown_type $size
2811 function wp_convert_hr_to_bytes( $size ) {
2812 $size = strtolower($size);
2813 $bytes = (int) $size;
2814 if ( strpos($size, 'k') !== false )
2815 $bytes = intval($size) * 1024;
2816 elseif ( strpos($size, 'm') !== false )
2817 $bytes = intval($size) * 1024 * 1024;
2818 elseif ( strpos($size, 'g') !== false )
2819 $bytes = intval($size) * 1024 * 1024 * 1024;
2824 * {@internal Missing Short Description}}
2828 * @param unknown_type $bytes
2831 function wp_convert_bytes_to_hr( $bytes ) {
2832 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2833 $log = log( $bytes, 1024 );
2834 $power = (int) $log;
2835 $size = pow(1024, $log - $power);
2836 return $size . $units[$power];
2840 * {@internal Missing Short Description}}
2846 function wp_max_upload_size() {
2847 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2848 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2849 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2854 * Outputs the form used by the importers to accept the data to be imported
2858 * @param string $action The action attribute for the form.
2860 function wp_import_upload_form( $action ) {
2861 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2862 $size = wp_convert_bytes_to_hr( $bytes );
2863 $upload_dir = wp_upload_dir();
2864 if ( ! empty( $upload_dir['error'] ) ) :
2865 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2866 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2869 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
2871 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2872 <input type="file" id="upload" name="import" size="25" />
2873 <input type="hidden" name="action" value="save" />
2874 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2877 <input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2885 * {@internal Missing Short Description}}
2889 function wp_remember_old_slug() {
2891 $name = esc_attr($post->post_name); // just in case
2892 if ( strlen($name) )
2893 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
2897 * Add a meta box to an edit form.
2901 * @param string $id String for use in the 'id' attribute of tags.
2902 * @param string $title Title of the meta box.
2903 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2904 * @param string $page The type of edit page on which to show the box (post, page, link).
2905 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2906 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2908 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2909 global $wp_meta_boxes;
2911 if ( !isset($wp_meta_boxes) )
2912 $wp_meta_boxes = array();
2913 if ( !isset($wp_meta_boxes[$page]) )
2914 $wp_meta_boxes[$page] = array();
2915 if ( !isset($wp_meta_boxes[$page][$context]) )
2916 $wp_meta_boxes[$page][$context] = array();
2918 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2919 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2920 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2923 // If a core box was previously added or removed by a plugin, don't add.
2924 if ( 'core' == $priority ) {
2925 // If core box previously deleted, don't add
2926 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2928 // If box was added with default priority, give it core priority to maintain sort order
2929 if ( 'default' == $a_priority ) {
2930 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2931 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2935 // If no priority given and id already present, use existing priority
2936 if ( empty($priority) ) {
2937 $priority = $a_priority;
2938 // 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.
2939 } elseif ( 'sorted' == $priority ) {
2940 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2941 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2942 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2944 // An id can be in only one priority and one context
2945 if ( $priority != $a_priority || $context != $a_context )
2946 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2950 if ( empty($priority) )
2953 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2954 $wp_meta_boxes[$page][$context][$priority] = array();
2956 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2960 * {@internal Missing Short Description}}
2964 * @param unknown_type $page
2965 * @param unknown_type $context
2966 * @param unknown_type $object
2967 * @return int number of meta_boxes
2969 function do_meta_boxes($page, $context, $object) {
2970 global $wp_meta_boxes;
2971 static $already_sorted = false;
2973 //do_action('do_meta_boxes', $page, $context, $object);
2975 $hidden = get_hidden_meta_boxes($page);
2977 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
2981 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2982 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
2983 foreach ( $sorted as $box_context => $ids )
2984 foreach ( explode(',', $ids) as $id )
2986 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2988 $already_sorted = true;
2990 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2993 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2994 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2995 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2996 if ( false == $box || ! $box['title'] )
3000 if ( in_array($box['id'], $hidden) )
3001 $style = 'style="display:none;"';
3002 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
3003 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
3004 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
3005 echo '<div class="inside">' . "\n";
3006 call_user_func($box['callback'], $object, $box);
3021 * Remove a meta box from an edit form.
3025 * @param string $id String for use in the 'id' attribute of tags.
3026 * @param string $page The type of edit page on which to show the box (post, page, link).
3027 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
3029 function remove_meta_box($id, $page, $context) {
3030 global $wp_meta_boxes;
3032 if ( !isset($wp_meta_boxes) )
3033 $wp_meta_boxes = array();
3034 if ( !isset($wp_meta_boxes[$page]) )
3035 $wp_meta_boxes[$page] = array();
3036 if ( !isset($wp_meta_boxes[$page][$context]) )
3037 $wp_meta_boxes[$page][$context] = array();
3039 foreach ( array('high', 'core', 'default', 'low') as $priority )
3040 $wp_meta_boxes[$page][$context][$priority][$id] = false;
3044 * {@internal Missing Short Description}}
3048 * @param unknown_type $page
3050 function meta_box_prefs($page) {
3051 global $wp_meta_boxes;
3053 if ( empty($wp_meta_boxes[$page]) )
3056 $hidden = get_hidden_meta_boxes($page);
3058 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
3059 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
3060 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
3061 if ( false == $box || ! $box['title'] )
3063 // Submit box cannot be hidden
3064 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
3066 $box_id = $box['id'];
3067 echo '<label for="' . $box_id . '-hide">';
3068 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"' : '') . ' />';
3069 echo "{$box['title']}</label>\n";
3075 function get_hidden_meta_boxes($page) {
3076 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
3078 // Hide slug boxes by default
3079 if ( empty($hidden[0]) ) {
3080 $hidden = array('slugdiv');
3087 * Add a new section to a settings page.
3091 * @param string $id String for use in the 'id' attribute of tags.
3092 * @param string $title Title of the section.
3093 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
3094 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
3096 function add_settings_section($id, $title, $callback, $page) {
3097 global $wp_settings_sections;
3099 if ( !isset($wp_settings_sections) )
3100 $wp_settings_sections = array();
3101 if ( !isset($wp_settings_sections[$page]) )
3102 $wp_settings_sections[$page] = array();
3103 if ( !isset($wp_settings_sections[$page][$id]) )
3104 $wp_settings_sections[$page][$id] = array();
3106 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
3110 * Add a new field to a settings page.
3114 * @param string $id String for use in the 'id' attribute of tags.
3115 * @param string $title Title of the field.
3116 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
3117 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
3118 * @param string $section The section of the settingss page in which to show the box (default, ...).
3119 * @param array $args Additional arguments
3121 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3122 global $wp_settings_fields;
3124 if ( !isset($wp_settings_fields) )
3125 $wp_settings_fields = array();
3126 if ( !isset($wp_settings_fields[$page]) )
3127 $wp_settings_fields[$page] = array();
3128 if ( !isset($wp_settings_fields[$page][$section]) )
3129 $wp_settings_fields[$page][$section] = array();
3131 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3135 * {@internal Missing Short Description}}
3139 * @param unknown_type $page
3141 function do_settings_sections($page) {
3142 global $wp_settings_sections, $wp_settings_fields;
3144 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3147 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3148 echo "<h3>{$section['title']}</h3>\n";
3149 call_user_func($section['callback'], $section);
3150 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3152 echo '<table class="form-table">';
3153 do_settings_fields($page, $section['id']);
3159 * {@internal Missing Short Description}}
3163 * @param unknown_type $page
3164 * @param unknown_type $section
3166 function do_settings_fields($page, $section) {
3167 global $wp_settings_fields;
3169 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3172 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3173 echo '<tr valign="top">';
3174 if ( !empty($field['args']['label_for']) )
3175 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3177 echo '<th scope="row">' . $field['title'] . '</th>';
3179 call_user_func($field['callback'], $field['args']);
3186 * {@internal Missing Short Description}}
3190 * @param unknown_type $page
3192 function manage_columns_prefs($page) {
3193 $columns = get_column_headers($page);
3195 $hidden = get_hidden_columns($page);
3197 foreach ( $columns as $column => $title ) {
3199 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
3201 if ( empty($title) )
3204 if ( 'comments' == $column )
3205 $title = __('Comments');
3206 $id = "$column-hide";
3207 echo '<label for="' . $id . '">';
3208 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3209 echo "$title</label>\n";
3214 * {@internal Missing Short Description}}
3218 * @param unknown_type $found_action
3220 function find_posts_div($found_action = '') {
3222 <div id="find-posts" class="find-box" style="display:none;">
3223 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3224 <div class="find-box-inside">
3225 <div class="find-box-search">
3226 <?php if ( $found_action ) { ?>
3227 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3230 <input type="hidden" name="affected" id="affected" value="" />
3231 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3232 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3233 <input type="text" id="find-posts-input" name="ps" value="" />
3234 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3236 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
3237 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
3238 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
3239 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
3241 <div id="find-posts-response"></div>
3243 <div class="find-box-buttons">
3244 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3245 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3252 * Display the post password.
3254 * The password is passed through {@link esc_attr()} to ensure that it
3255 * is safe for placing in an html attribute.
3260 function the_post_password() {
3262 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3266 * {@internal Missing Short Description}}
3270 function favorite_actions( $screen = null ) {
3271 switch ( $screen ) {
3272 case 'post-new.php':
3273 $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
3275 case 'edit-pages.php':
3276 $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
3278 case 'page-new.php':
3279 $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
3282 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3284 case 'media-new.php':
3285 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3287 case 'link-manager.php':
3288 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3290 case 'link-add.php':
3291 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3294 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3296 case 'user-new.php':
3297 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3300 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3302 case 'plugin-install.php':
3303 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3306 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3308 case 'theme-install.php':
3309 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3312 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3317 'post-new.php' => array(__('New Post'), 'edit_posts'),
3318 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3319 'page-new.php' => array(__('New Page'), 'edit_pages'),
3320 'media-new.php' => array(__('Upload'), 'upload_files'),
3321 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3324 $default_key = array_keys($default_action);
3325 $default_key = $default_key[0];
3326 if ( isset($actions[$default_key]) )
3327 unset($actions[$default_key]);
3328 $actions = array_merge($default_action, $actions);
3329 $actions = apply_filters('favorite_actions', $actions);
3331 $allowed_actions = array();
3332 foreach ( $actions as $action => $data ) {
3333 if ( current_user_can($data[1]) )
3334 $allowed_actions[$action] = $data[0];
3337 if ( empty($allowed_actions) )
3340 $first = array_keys($allowed_actions);
3342 echo '<div id="favorite-actions">';
3343 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3344 echo '<div id="favorite-inside">';
3346 array_shift($allowed_actions);
3348 foreach ( $allowed_actions as $action => $label) {
3349 echo "<div class='favorite-action'><a href='$action'>";
3351 echo "</a></div>\n";
3353 echo "</div></div>\n";
3357 * Get the post title.
3359 * The post title is fetched and if it is blank then a default string is
3363 * @param int $id The post id. If not supplied the global $post is used.
3366 function _draft_or_post_title($post_id = 0)
3368 $title = get_the_title($post_id);
3369 if ( empty($title) )
3370 $title = __('(no title)');
3375 * Display the search query.
3377 * A simple wrapper to display the "s" parameter in a GET URI. This function
3378 * should only be used when {@link the_search_query()} cannot.
3384 function _admin_search_query() {
3385 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
3389 * Generic Iframe header for use with Thickbox
3392 * @param string $title Title of the Iframe page.
3393 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3396 function iframe_header( $title = '', $limit_styles = false ) {
3397 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3398 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3400 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3401 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
3403 wp_enqueue_style( 'global' );
3404 if ( ! $limit_styles )
3405 wp_enqueue_style( 'wp-admin' );
3406 wp_enqueue_style( 'colors' );
3408 <script type="text/javascript">
3410 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
3411 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
3415 do_action('admin_print_styles');
3416 do_action('admin_print_scripts');
3417 do_action('admin_head');
3420 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
3425 * Generic Iframe footer for use with Thickbox
3430 function iframe_footer() {
3431 //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
3432 <div class="hidden">
3434 do_action('admin_footer', '');
3435 do_action('admin_print_footer_scripts'); ?>
3437 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
3443 function _post_states($post) {
3444 $post_states = array();
3445 if ( isset($_GET['post_status']) )
3446 $post_status = $_GET['post_status'];
3450 if ( !empty($post->post_password) )
3451 $post_states[] = __('Password protected');
3452 if ( 'private' == $post->post_status && 'private' != $post_status )
3453 $post_states[] = __('Private');
3454 if ( 'draft' == $post->post_status && 'draft' != $post_status )
3455 $post_states[] = __('Draft');
3456 if ( 'pending' == $post->post_status && 'pending' != $post_status )
3457 /* translators: post state */
3458 $post_states[] = _x('Pending', 'post state');
3459 if ( is_sticky($post->ID) )
3460 $post_states[] = __('Sticky');
3462 $post_states = apply_filters( 'display_post_states', $post_states );
3464 if ( ! empty($post_states) ) {
3465 $state_count = count($post_states);
3468 foreach ( $post_states as $state ) {
3470 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
3471 echo "<span class='post-state'>$state$sep</span>";
3476 function screen_meta($screen) {
3477 global $wp_meta_boxes, $_wp_contextual_help;
3479 $screen = str_replace('.php', '', $screen);
3480 $screen = str_replace('-new', '', $screen);
3481 $screen = str_replace('-add', '', $screen);
3482 $screen = apply_filters('screen_meta_screen', $screen);
3484 $column_screens = get_column_headers($screen);
3485 $meta_screens = array('index' => 'dashboard');
3487 if ( isset($meta_screens[$screen]) )
3488 $screen = $meta_screens[$screen];
3489 $show_screen = false;
3490 $show_on_screen = false;
3491 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) {
3492 $show_screen = true;
3493 $show_on_screen = true;
3496 $screen_options = screen_options($screen);
3497 if ( $screen_options )
3498 $show_screen = true;
3500 if ( !isset($_wp_contextual_help) )
3501 $_wp_contextual_help = array();
3505 switch ( $screen ) {
3507 if ( !isset($_wp_contextual_help['post']) ) {
3508 $help = drag_drop_help();
3509 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
3510 $_wp_contextual_help['post'] = $help;
3514 if ( !isset($_wp_contextual_help['page']) ) {
3515 $help = drag_drop_help();
3516 $_wp_contextual_help['page'] = $help;
3520 if ( !isset($_wp_contextual_help['dashboard']) ) {
3521 $help = '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n";
3522 $help .= drag_drop_help();
3523 $_wp_contextual_help['dashboard'] = $help;
3527 if ( !isset($_wp_contextual_help['link']) ) {
3528 $help = drag_drop_help();
3529 $_wp_contextual_help['link'] = $help;
3532 case 'options-general':
3533 if ( !isset($_wp_contextual_help['options-general']) )
3534 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
3536 case 'theme-install':
3537 case 'plugin-install':
3538 if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) {
3539 $help = plugins_search_help();
3540 $_wp_contextual_help[$screen] = $help;
3544 if ( !isset($_wp_contextual_help['widgets']) ) {
3545 $help = widgets_help();
3546 $_wp_contextual_help['widgets'] = $help;
3548 $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
3549 $show_screen = true;
3553 <div id="screen-meta">
3555 if ( $show_screen ) :
3557 <div id="screen-options-wrap" class="hidden">
3558 <form id="adv-settings" action="" method="post">
3559 <?php if ( $show_on_screen ) : ?>
3560 <h5><?php _e('Show on screen') ?></h5>
3561 <div class="metabox-prefs">
3563 if ( !meta_box_prefs($screen) && isset($column_screens) ) {
3564 manage_columns_prefs($screen);
3567 <br class="clear" />
3570 <?php echo screen_layout($screen); ?>
3571 <?php echo $screen_options; ?>
3572 <?php echo $settings; ?>
3573 <div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
3582 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
3584 <div id="contextual-help-wrap" class="hidden">
3586 $contextual_help = '';
3587 if ( isset($_wp_contextual_help[$screen]) ) {
3588 if ( !empty($title) )
3589 $contextual_help .= '<h5>' . sprintf(__('Get help with “%s”'), $title) . '</h5>';
3591 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
3592 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
3594 $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
3596 $contextual_help .= '<h5>' . __('Help') . '</h5>';
3599 $contextual_help .= '<div class="metabox-prefs">';
3600 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
3601 $default_help .= '<br />';
3602 $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
3603 $contextual_help .= apply_filters('default_contextual_help', $default_help);
3604 $contextual_help .= "</div>\n";
3605 echo apply_filters('contextual_help', $contextual_help, $screen);
3609 <div id="screen-meta-links">
3610 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
3611 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
3613 <?php if ( $show_screen ) { ?>
3614 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
3615 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
3624 * Add contextual help text for a page
3628 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
3629 * @param string $help Arbitrary help text
3631 function add_contextual_help($screen, $help) {
3632 global $_wp_contextual_help;
3634 if ( !isset($_wp_contextual_help) )
3635 $_wp_contextual_help = array();
3637 $_wp_contextual_help[$screen] = $help;
3640 function drag_drop_help() {
3642 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you’ll notice the 4 arrow cursor appears to let you know it is movable. Click on it, hold down the mouse button and start dragging the module to a new location. As you drag the module, notice the dotted gray box that also moves. This box indicates where the module will be placed when you release the mouse button.') . '</p>
3643 <p>' . __('The same modules can be expanded and collapsed by clicking once on their title bar and also completely hidden from the Screen Options tab.') . '</p>
3647 function plugins_search_help() {
3649 <p><strong>' . __('Search help') . '</strong></p>' .
3650 '<p>' . __('You may search based on 3 criteria:') . '<br />' .
3651 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .
3652 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .
3653 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>
3657 function widgets_help() {
3659 <p>' . __('Widgets are added and arranged by simple drag ’n’ drop. If you hover your mouse over the titlebar of a widget, you’ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you’ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
3660 <p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
3661 <p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
3662 <p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
3666 function screen_layout($screen) {
3667 global $screen_layout_columns;
3669 $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
3670 $columns = apply_filters('screen_layout_columns', $columns, $screen);
3672 if ( !isset($columns[$screen]) ) {
3673 $screen_layout_columns = 0;
3677 $screen_layout_columns = get_user_option("screen_layout_$screen");
3678 $num = $columns[$screen];
3680 if ( ! $screen_layout_columns )
3681 $screen_layout_columns = 2;
3684 $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
3685 while ( $i <= $num ) {
3686 $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
3689 $return .= "</div>\n";
3693 function screen_options($screen) {
3694 switch ( $screen ) {
3696 $per_page_label = __('Posts per page:');
3699 $per_page_label = __('Pages per page:');
3701 case 'edit-comments':
3702 $per_page_label = __('Comments per page:');
3705 $per_page_label = __('Media items per page:');
3708 $per_page_label = __('Categories per page:');
3711 $per_page_label = __('Tags per page:');
3714 $per_page_label = __('Plugins per page:');
3720 $option = str_replace( '-', '_', "${screen}_per_page" );
3721 $per_page = (int) get_user_option( $option, 0, false );
3722 if ( empty( $per_page ) || $per_page < 1 ) {
3723 if ( 'plugins' == $screen )
3728 if ( 'edit_comments_per_page' == $option )
3729 $per_page = apply_filters( 'comments_per_page', $per_page, isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all' );
3730 elseif ( 'categories' == $option )
3731 $per_page = apply_filters( 'edit_categories_per_page', $per_page );
3733 $per_page = apply_filters( $option, $per_page );
3735 $return = '<h5>' . __('Options') . "</h5>\n";
3736 $return .= "<div class='screen-options'>\n";
3737 if ( !empty($per_page_label) )
3738 $return .= "<label for='$option'>$per_page_label</label> <input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' />\n";
3739 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";
3740 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
3741 $return .= "</div>\n";
3745 function screen_icon($name = '') {
3746 global $parent_file, $hook_suffix;
3748 if ( empty($name) ) {
3749 if ( isset($parent_file) && !empty($parent_file) )
3750 $name = substr($parent_file, 0, -4);
3752 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
3755 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
3760 * Test support for compressing JavaScript from PHP
3762 * Outputs JavaScript that tests if compression from PHP works as expected
3763 * and sets an option with the result. Has no effect when the current user
3764 * is not an administrator. To run the test again the option 'can_compress_scripts'
3765 * has to be deleted.
3769 function compression_test() {
3771 <script type="text/javascript">
3773 var testCompression = {
3774 get : function(test) {
3776 if ( window.XMLHttpRequest ) {
3777 x = new XMLHttpRequest();
3779 try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
3783 x.onreadystatechange = function() {
3785 if ( x.readyState == 4 ) {
3786 r = x.responseText.substr(0, 18);
3787 h = x.getResponseHeader('Content-Encoding');
3788 testCompression.check(r, h, test);
3792 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
3797 check : function(r, h, test) {
3798 if ( ! r && ! test )
3802 if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
3811 if ( '"wpCompressionTest' == r )
3818 testCompression.check();