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 ) {
25 _cat_rows($categories, $count, $parent, $level, $page, $per_page);
29 * {@internal Missing Short Description}}
33 * @param unknown_type $categories
34 * @param unknown_type $count
35 * @param unknown_type $parent
36 * @param unknown_type $level
37 * @param unknown_type $page
38 * @param unknown_type $per_page
41 function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
42 if ( empty($categories) ) {
43 $args = array('hide_empty' => 0);
44 if ( !empty($_GET['s']) )
45 $args['search'] = $_GET['s'];
46 $categories = get_categories( $args );
52 $children = _get_term_hierarchy('category');
54 $start = ($page - 1) * $per_page;
55 $end = $start + $per_page;
58 foreach ( $categories as $category ) {
64 if ( $category->parent != $parent )
67 // If the page starts in a subtree, print the parents.
68 if ( $count == $start && $category->parent > 0 ) {
69 $my_parents = array();
71 $my_parent = get_category($my_parent);
72 $my_parents[] = $my_parent;
73 if ( !$my_parent->parent )
75 $my_parent = $my_parent->parent;
77 $num_parents = count($my_parents);
78 while( $my_parent = array_pop($my_parents) ) {
79 echo "\t" . _cat_row( $my_parent, $level - $num_parents );
84 if ( $count >= $start )
85 echo "\t" . _cat_row( $category, $level );
87 unset($categories[$i]); // Prune the working set
90 if ( isset($children[$category->term_id]) )
91 _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
95 $output = ob_get_contents();
102 * {@internal Missing Short Description}}
106 * @param unknown_type $category
107 * @param unknown_type $level
108 * @param unknown_type $name_override
111 function _cat_row( $category, $level, $name_override = false ) {
112 static $row_class = '';
114 $category = get_category( $category, OBJECT, 'display' );
116 $default_cat_id = (int) get_option( 'default_category' );
117 $pad = str_repeat( '— ', $level );
118 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
119 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id";
120 if ( current_user_can( 'manage_categories' ) ) {
121 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
123 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
124 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
125 if ( $default_cat_id != $category->term_id )
126 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
127 $action_count = count($actions);
129 $edit .= '<div class="row-actions">';
130 foreach ( $actions as $action => $link ) {
132 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
133 $edit .= "<span class='$action'>$link$sep</span>";
140 $row_class = 'alternate' == $row_class ? '' : 'alternate';
141 $qe_data = get_category_to_edit($category->term_id);
143 $category->count = number_format_i18n( $category->count );
144 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
145 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
147 $columns = get_column_headers('categories');
148 $hidden = get_hidden_columns('categories');
149 foreach ( $columns as $column_name => $column_display_name ) {
150 $class = "class=\"$column_name column-$column_name\"";
153 if ( in_array($column_name, $hidden) )
154 $style = ' style="display:none;"';
156 $attributes = "$class$style";
158 switch ($column_name) {
160 $output .= "<th scope='row' class='check-column'>";
161 if ( $default_cat_id != $category->term_id ) {
162 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
169 $output .= "<td $attributes>$edit";
170 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
171 $output .= '<div class="name">' . $qe_data->name . '</div>';
172 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
173 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
176 $output .= "<td $attributes>$category->description</td>";
179 $output .= "<td $attributes>$category->slug</td>";
182 $attributes = 'class="posts column-posts num"' . $style;
183 $output .= "<td $attributes>$posts_count</td>\n";
192 * {@internal Missing Short Description}}
196 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
198 * @param string $type "tag", "category" or "link-category"
201 function inline_edit_term_row($type) {
203 if ( ! current_user_can( 'manage_categories' ) )
206 $is_tag = $type == 'edit-tags';
207 $columns = get_column_headers($type);
208 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
209 $col_count = count($columns) - count($hidden);
212 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
213 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
215 <fieldset><div class="inline-edit-col">
216 <h4><?php _e( 'Quick Edit' ); ?></h4>
219 <span class="title"><?php _e( 'Name' ); ?></span>
220 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
224 <span class="title"><?php _e( 'Slug' ); ?></span>
225 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
228 <?php if ( 'category' == $type ) : ?>
231 <span class="title"><?php _e( 'Parent' ); ?></span>
232 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
235 <?php endif; // $type ?>
241 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
243 foreach ( $columns as $column_name => $column_display_name ) {
244 if ( isset( $core_columns[$column_name] ) )
246 do_action( 'quick_edit_custom_box', $column_name, $type );
251 <p class="inline-edit-save submit">
252 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
253 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
254 <a accesskey="s" href="#inline-edit" title="<?php echo attribute_escape( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
255 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
256 <span class="error" style="display:none;"></span>
257 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
261 </tbody></table></form>
266 * {@internal Missing Short Description}}
270 * @param unknown_type $category
271 * @param unknown_type $name_override
274 function link_cat_row( $category, $name_override = false ) {
275 static $row_class = '';
277 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
279 if ( is_wp_error( $category ) )
282 $default_cat_id = (int) get_option( 'default_link_category' );
283 $name = ( $name_override ? $name_override : $category->name );
284 $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
285 if ( current_user_can( 'manage_categories' ) ) {
286 $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
288 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
289 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
290 if ( $default_cat_id != $category->term_id )
291 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
292 $action_count = count($actions);
294 $edit .= '<div class="row-actions">';
295 foreach ( $actions as $action => $link ) {
297 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
298 $edit .= "<span class='$action'>$link$sep</span>";
305 $row_class = 'alternate' == $row_class ? '' : 'alternate';
306 $qe_data = get_term_to_edit($category->term_id, 'link_category');
308 $category->count = number_format_i18n( $category->count );
309 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
310 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
311 $columns = get_column_headers('edit-link-categories');
312 $hidden = get_hidden_columns('edit-link-categories');
313 foreach ( $columns as $column_name => $column_display_name ) {
314 $class = "class=\"$column_name column-$column_name\"";
317 if ( in_array($column_name, $hidden) )
318 $style = ' style="display:none;"';
320 $attributes = "$class$style";
322 switch ($column_name) {
324 $output .= "<th scope='row' class='check-column'>";
325 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
326 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
333 $output .= "<td $attributes>$edit";
334 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
335 $output .= '<div class="name">' . $qe_data->name . '</div>';
336 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
337 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
340 $output .= "<td $attributes>$category->description</td>";
343 $output .= "<td $attributes>$category->slug</td>";
346 $attributes = 'class="links column-links num"' . $style;
347 $output .= "<td $attributes>$count</td>";
356 * {@internal Missing Short Description}}
360 * @param unknown_type $checked
361 * @param unknown_type $current
363 function checked( $checked, $current) {
364 if ( $checked == $current)
365 echo ' checked="checked"';
369 * {@internal Missing Short Description}}
373 * @param unknown_type $selected
374 * @param unknown_type $current
376 function selected( $selected, $current) {
377 if ( $selected == $current)
378 echo ' selected="selected"';
382 // Category Checklists
386 * {@internal Missing Short Description}}
389 * @deprecated Use {@link wp_link_category_checklist()}
390 * @see wp_link_category_checklist()
392 * @param unknown_type $default
393 * @param unknown_type $parent
394 * @param unknown_type $popular_ids
396 function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
398 wp_category_checklist($post_ID);
402 * {@internal Missing Short Description}}
406 class Walker_Category_Checklist extends Walker {
407 var $tree_type = 'category';
408 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
410 function start_lvl(&$output, $depth, $args) {
411 $indent = str_repeat("\t", $depth);
412 $output .= "$indent<ul class='children'>\n";
415 function end_lvl(&$output, $depth, $args) {
416 $indent = str_repeat("\t", $depth);
417 $output .= "$indent</ul>\n";
420 function start_el(&$output, $category, $depth, $args) {
423 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
424 $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"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
427 function end_el(&$output, $category, $depth, $args) {
428 $output .= "</li>\n";
433 * {@internal Missing Short Description}}
437 * @param unknown_type $post_id
438 * @param unknown_type $descendants_and_self
439 * @param unknown_type $selected_cats
440 * @param unknown_type $popular_cats
442 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {
443 if ( empty($walker) || !is_a($walker, 'Walker') )
444 $walker = new Walker_Category_Checklist;
446 $descendants_and_self = (int) $descendants_and_self;
450 if ( is_array( $selected_cats ) )
451 $args['selected_cats'] = $selected_cats;
453 $args['selected_cats'] = wp_get_post_categories($post_id);
455 $args['selected_cats'] = array();
457 if ( is_array( $popular_cats ) )
458 $args['popular_cats'] = $popular_cats;
460 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
462 if ( $descendants_and_self ) {
463 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
464 $self = get_category( $descendants_and_self );
465 array_unshift( $categories, $self );
467 $categories = get_categories('get=all');
470 // 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)
471 $checked_categories = array();
472 for ( $i = 0; isset($categories[$i]); $i++ ) {
473 if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
474 $checked_categories[] = $categories[$i];
475 unset($categories[$i]);
479 // Put checked cats on top
480 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
481 // Then the rest of them
482 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
486 * {@internal Missing Short Description}}
490 * @param unknown_type $taxonomy
491 * @param unknown_type $default
492 * @param unknown_type $number
493 * @param unknown_type $echo
496 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
499 $checked_categories = wp_get_post_categories($post_ID);
501 $checked_categories = array();
502 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
504 $popular_ids = array();
505 foreach ( (array) $categories as $category ) {
506 $popular_ids[] = $category->term_id;
507 if ( !$echo ) // hack for AJAX use
509 $id = "popular-category-$category->term_id";
512 <li id="<?php echo $id; ?>" class="popular-category">
513 <label class="selectit">
514 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
515 <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
525 * {@internal Missing Short Description}}
528 * @deprecated Use {@link wp_link_category_checklist()}
529 * @see wp_link_category_checklist()
531 * @param unknown_type $default
533 function dropdown_link_categories( $default = 0 ) {
536 wp_link_category_checklist($link_id);
540 * {@internal Missing Short Description}}
544 * @param unknown_type $link_id
546 function wp_link_category_checklist( $link_id = 0 ) {
550 $checked_categories = wp_get_link_cats($link_id);
552 if ( count( $checked_categories ) == 0 ) {
553 // No selected categories, strange
554 $checked_categories[] = $default;
557 $checked_categories[] = $default;
560 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
562 if ( empty($categories) )
565 foreach ( $categories as $category ) {
566 $cat_id = $category->term_id;
567 $name = wp_specialchars( apply_filters('the_category', $category->name));
568 $checked = in_array( $cat_id, $checked_categories );
569 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>";
575 // Returns a single tag row (see tag_rows below)
576 // Note: this is also used in admin-ajax.php!
578 * {@internal Missing Short Description}}
582 * @param unknown_type $tag
583 * @param unknown_type $class
586 function _tag_row( $tag, $class = '' ) {
587 $count = number_format_i18n( $tag->count );
588 $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
590 $name = apply_filters( 'term_name', $tag->name );
591 $qe_data = get_term($tag->term_id, 'post_tag', object, 'edit');
592 $edit_link = "edit-tags.php?action=edit&tag_ID=$tag->term_id";
594 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
595 $columns = get_column_headers('edit-tags');
596 $hidden = get_hidden_columns('edit-tags');
597 foreach ( $columns as $column_name => $column_display_name ) {
598 $class = "class=\"$column_name column-$column_name\"";
601 if ( in_array($column_name, $hidden) )
602 $style = ' style="display:none;"';
604 $attributes = "$class$style";
606 switch ($column_name) {
608 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
611 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
613 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
614 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
615 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this tag '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
616 $action_count = count($actions);
618 $out .= '<div class="row-actions">';
619 foreach ( $actions as $action => $link ) {
621 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
622 $out .= "<span class='$action'>$link$sep</span>";
625 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
626 $out .= '<div class="name">' . $qe_data->name . '</div>';
627 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
630 $out .= "<td $attributes>$tag->slug</td>";
633 $attributes = 'class="posts column-posts num"' . $style;
634 $out .= "<td $attributes>$count</td>";
644 // Outputs appropriate rows for the Nth page of the Tag Management screen,
645 // assuming M tags displayed at a time on the page
646 // Returns the number of tags displayed
648 * {@internal Missing Short Description}}
652 * @param unknown_type $page
653 * @param unknown_type $pagesize
654 * @param unknown_type $searchterms
657 function tag_rows( $page = 1, $pagesize = 20, $searchterms = '' ) {
659 // Get a page worth of tags
660 $start = ($page - 1) * $pagesize;
662 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
664 if ( !empty( $searchterms ) ) {
665 $args['search'] = $searchterms;
668 $tags = get_terms( 'post_tag', $args );
670 // convert it to table rows
673 foreach( $tags as $tag )
674 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"' );
676 // filter and send to screen
681 // define the columns to display, the syntax is 'internal name' => 'display name'
683 * {@internal Missing Short Description}}
689 function wp_manage_posts_columns() {
690 $posts_columns = array();
691 $posts_columns['cb'] = '<input type="checkbox" />';
692 $posts_columns['title'] = _c('Post|noun');
693 $posts_columns['author'] = __('Author');
694 $posts_columns['categories'] = __('Categories');
695 $posts_columns['tags'] = __('Tags');
696 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
697 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
698 $posts_columns['date'] = __('Date');
699 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
701 return $posts_columns;
704 // define the columns to display, the syntax is 'internal name' => 'display name'
706 * {@internal Missing Short Description}}
712 function wp_manage_media_columns() {
713 $posts_columns = array();
714 $posts_columns['cb'] = '<input type="checkbox" />';
715 $posts_columns['icon'] = '';
716 $posts_columns['media'] = _c('File|media column header');
717 $posts_columns['author'] = __('Author');
718 //$posts_columns['tags'] = _c('Tags|media column header');
719 $posts_columns['parent'] = _c('Attached to|media column header');
720 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
721 //$posts_columns['comments'] = __('Comments');
722 $posts_columns['date'] = _c('Date|media column header');
723 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
725 return $posts_columns;
729 * {@internal Missing Short Description}}
735 function wp_manage_pages_columns() {
736 $posts_columns = array();
737 $posts_columns['cb'] = '<input type="checkbox" />';
738 $posts_columns['title'] = __('Title');
739 $posts_columns['author'] = __('Author');
740 $post_status = 'all';
741 if ( !empty($_GET['post_status']) )
742 $post_status = $_GET['post_status'];
743 if ( !in_array($post_status, array('pending', 'draft', 'future')) )
744 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
745 $posts_columns['date'] = __('Date');
746 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
748 return $posts_columns;
752 * {@internal Missing Short Description}}
756 * @param unknown_type $page
759 function get_column_headers($page) {
760 global $_wp_column_headers;
762 if ( !isset($_wp_column_headers) )
763 $_wp_column_headers = array();
765 // Store in static to avoid running filters on each call
766 if ( isset($_wp_column_headers[$page]) )
767 return $_wp_column_headers[$page];
771 $_wp_column_headers[$page] = wp_manage_posts_columns();
774 $_wp_column_headers[$page] = wp_manage_pages_columns();
776 case 'edit-comments':
777 $_wp_column_headers[$page] = array(
778 'cb' => '<input type="checkbox" />',
779 'author' => __('Author'),
780 'comment' => _c('Comment|noun'),
781 //'date' => __('Submitted'),
782 'response' => __('In Response To')
787 $_wp_column_headers[$page] = array(
788 'cb' => '<input type="checkbox" />',
789 'name' => __('Name'),
791 'categories' => __('Categories'),
793 'visible' => __('Visible')
798 $_wp_column_headers[$page] = wp_manage_media_columns();
801 $_wp_column_headers[$page] = array(
802 'cb' => '<input type="checkbox" />',
803 'name' => __('Name'),
804 'description' => __('Description'),
805 'slug' => __('Slug'),
806 'posts' => __('Posts')
810 case 'edit-link-categories':
811 $_wp_column_headers[$page] = array(
812 'cb' => '<input type="checkbox" />',
813 'name' => __('Name'),
814 'description' => __('Description'),
815 'slug' => __('Slug'),
816 'links' => __('Links')
821 $_wp_column_headers[$page] = array(
822 'cb' => '<input type="checkbox" />',
823 'name' => __('Name'),
824 'slug' => __('Slug'),
825 'posts' => __('Posts')
830 $_wp_column_headers[$page] = array(
831 'cb' => '<input type="checkbox" />',
832 'username' => __('Username'),
833 'name' => __('Name'),
834 'email' => __('E-mail'),
835 'role' => __('Role'),
836 'posts' => __('Posts')
840 $_wp_column_headers[$page] = array();
843 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
844 return $_wp_column_headers[$page];
848 * {@internal Missing Short Description}}
852 * @param unknown_type $type
853 * @param unknown_type $id
855 function print_column_headers( $type, $id = true ) {
856 $type = str_replace('.php', '', $type);
857 $columns = get_column_headers( $type );
858 $hidden = get_hidden_columns($type);
860 // $styles['tag']['posts'] = 'width: 90px;';
861 // $styles['link-category']['links'] = 'width: 90px;';
862 // $styles['category']['posts'] = 'width: 90px;';
863 // $styles['link']['visible'] = 'text-align: center;';
865 foreach ( $columns as $column_key => $column_display_name ) {
866 $class = ' class="manage-column';
868 $class .= " column-$column_key";
870 if ( 'cb' == $column_key )
871 $class .= ' check-column';
872 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
878 if ( in_array($column_key, $hidden) )
879 $style = 'display:none;';
881 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
882 $style .= ' ' . $styles[$type][$column_key];
883 $style = ' style="' . $style . '"';
885 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
890 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
894 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
895 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
896 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
898 function register_column_headers($screen, $columns) {
899 global $_wp_column_headers;
901 if ( !isset($_wp_column_headers) )
902 $_wp_column_headers = array();
904 $_wp_column_headers[$screen] = $columns;
908 * {@internal Missing Short Description}}
912 * @param unknown_type $page
914 function get_hidden_columns($page) {
915 $page = str_replace('.php', '', $page);
916 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
920 * {@internal Missing Short Description}}
922 * Outputs the quick edit and bulk edit table rows for posts and pages
926 * @param string $type 'post' or 'page'
928 function inline_edit_row( $type ) {
929 global $current_user, $mode;
931 $is_page = 'page' == $type;
933 $screen = 'edit-pages';
934 $post = get_default_page_to_edit();
937 $post = get_default_post_to_edit();
940 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
941 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
942 $col_count = count($columns) - count($hidden);
943 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
944 $can_publish = current_user_can("publish_{$type}s");
945 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
949 <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
952 while ( $bulk < 2 ) { ?>
954 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
955 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
956 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
958 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
959 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
962 <?php if ( $bulk ) : ?>
963 <div id="bulk-title-div">
964 <div id="bulk-titles"></div>
967 <?php else : // $bulk ?>
970 <span class="title"><?php _e( 'Title' ); ?></span>
971 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
974 <?php endif; // $bulk ?>
977 <?php if ( !$bulk ) : ?>
980 <span class="title"><?php _e( 'Slug' ); ?></span>
981 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
984 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
985 <div class="inline-edit-date">
986 <?php touch_time(1, 1, 4, 1); ?>
990 <?php endif; // $bulk
993 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
994 if ( $authors && count( $authors ) > 1 ) :
995 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
997 $users_opt['show_option_none'] = __('- No Change -');
1000 <span class="title"><?php _e( 'Author' ); ?></span>
1001 <?php wp_dropdown_users( $users_opt ); ?>
1006 $authors_dropdown = ob_get_clean();
1009 <?php if ( !$bulk ) : echo $authors_dropdown; ?>
1011 <div class="inline-edit-group">
1012 <label class="alignleft">
1013 <span class="title"><?php _e( 'Password' ); ?></span>
1014 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1017 <em style="margin:5px 10px 0 0" class="alignleft"><?php echo _c( '–OR–|Between password field and private checkbox on post quick edit interface' ); ?></em>
1019 <label class="alignleft inline-edit-private">
1020 <input type="checkbox" name="keep_private" value="private" />
1021 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
1029 <?php if ( !$is_page && !$bulk ) : ?>
1031 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1032 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
1033 <span class="catshow"><?php _e('[more]'); ?></span>
1034 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
1036 <ul class="cat-checklist">
1037 <?php wp_category_checklist(); ?>
1041 <?php endif; // !$is_page && !$bulk ?>
1043 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1047 echo $authors_dropdown;
1050 <?php if ( $is_page ) : ?>
1053 <span class="title"><?php _e( 'Parent' ); ?></span>
1055 $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');
1057 $dropdown_args['show_option_no_change'] = __('- No Change -');
1058 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1059 wp_dropdown_pages($dropdown_args);
1063 <?php if ( !$bulk ) : ?>
1066 <span class="title"><?php _e( 'Order' ); ?></span>
1067 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1070 <?php endif; // !$bulk ?>
1073 <span class="title"><?php _e( 'Template' ); ?></span>
1074 <select name="page_template">
1075 <?php if ( $bulk ) : ?>
1076 <option value="-1"><?php _e('- No Change -'); ?></option>
1077 <?php endif; // $bulk ?>
1078 <option value="default"><?php _e( 'Default Template' ); ?></option>
1079 <?php page_template_dropdown() ?>
1083 <?php elseif ( !$bulk ) : // $is_page ?>
1085 <label class="inline-edit-tags">
1086 <span class="title"><?php _e( 'Tags' ); ?></span>
1087 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
1090 <?php endif; // $is_page ?>
1092 <?php if ( $bulk ) : ?>
1094 <div class="inline-edit-group">
1095 <label class="alignleft">
1096 <span class="title"><?php _e( 'Comments' ); ?></span>
1097 <select name="comment_status">
1098 <option value=""><?php _e('- No Change -'); ?></option>
1099 <option value="open"><?php _e('Allow'); ?></option>
1100 <option value="closed"><?php _e('Do not allow'); ?></option>
1104 <label class="alignright">
1105 <span class="title"><?php _e( 'Pings' ); ?></span>
1106 <select name="ping_status">
1107 <option value=""><?php _e('- No Change -'); ?></option>
1108 <option value="open"><?php _e('Allow'); ?></option>
1109 <option value="closed"><?php _e('Do not allow'); ?></option>
1114 <?php else : // $bulk ?>
1116 <div class="inline-edit-group">
1117 <label class="alignleft">
1118 <input type="checkbox" name="comment_status" value="open" />
1119 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1122 <label class="alignleft">
1123 <input type="checkbox" name="ping_status" value="open" />
1124 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1128 <?php endif; // $bulk ?>
1131 <div class="inline-edit-group">
1132 <label class="inline-edit-status alignleft">
1133 <span class="title"><?php _e( 'Status' ); ?></span>
1134 <select name="_status">
1135 <?php if ( $bulk ) : ?>
1136 <option value="-1"><?php _e('- No Change -'); ?></option>
1137 <?php endif; // $bulk ?>
1138 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1139 <option value="publish"><?php _e( 'Published' ); ?></option>
1140 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1141 <?php if ( $bulk ) : ?>
1142 <option value="private"><?php _e('Private') ?></option>
1143 <?php endif; // $bulk ?>
1145 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1146 <option value="draft"><?php _e( 'Unpublished' ); ?></option>
1150 <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
1152 <?php if ( $bulk ) : ?>
1154 <label class="alignright">
1155 <span class="title"><?php _e( 'Sticky' ); ?></span>
1156 <select name="sticky">
1157 <option value="-1"><?php _e( '- No Change -' ); ?></option>
1158 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1159 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1163 <?php else : // $bulk ?>
1165 <label class="alignleft">
1166 <input type="checkbox" name="sticky" value="sticky" />
1167 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1170 <?php endif; // $bulk ?>
1172 <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
1179 foreach ( $columns as $column_name => $column_display_name ) {
1180 if ( isset( $core_columns[$column_name] ) )
1182 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
1185 <p class="submit inline-edit-save">
1186 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
1187 <?php if ( ! $bulk ) {
1188 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1189 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
1191 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a>
1192 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
1194 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
1196 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" />
1198 <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
1199 <br class="clear" />
1205 </tbody></table></form>
1209 // adds hidden fields with the data for use in the inline editor for posts and pages
1211 * {@internal Missing Short Description}}
1215 * @param unknown_type $post
1217 function get_inline_data($post) {
1219 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
1222 $title = attribute_escape($post->post_title);
1225 <div class="hidden" id="inline_' . $post->ID . '">
1226 <div class="post_title">' . $title . '</div>
1227 <div class="post_name">' . $post->post_name . '</div>
1228 <div class="post_author">' . $post->post_author . '</div>
1229 <div class="comment_status">' . $post->comment_status . '</div>
1230 <div class="ping_status">' . $post->ping_status . '</div>
1231 <div class="_status">' . $post->post_status . '</div>
1232 <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
1233 <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
1234 <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
1235 <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
1236 <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
1237 <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
1238 <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
1240 if( $post->post_type == 'page' )
1242 <div class="post_parent">' . $post->post_parent . '</div>
1243 <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
1244 <div class="menu_order">' . $post->menu_order . '</div>';
1246 if( $post->post_type == 'post' )
1248 <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
1249 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
1250 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
1256 * {@internal Missing Short Description}}
1260 * @param unknown_type $posts
1262 function post_rows( $posts = array() ) {
1263 global $wp_query, $post, $mode;
1265 add_filter('the_title','wp_specialchars');
1267 // Create array of post IDs.
1268 $post_ids = array();
1270 if ( empty($posts) )
1271 $posts = &$wp_query->posts;
1273 foreach ( $posts as $a_post )
1274 $post_ids[] = $a_post->ID;
1276 $comment_pending_count = get_pending_comments_num($post_ids);
1277 if ( empty($comment_pending_count) )
1278 $comment_pending_count = array();
1280 foreach ( $posts as $post ) {
1281 if ( empty($comment_pending_count[$post->ID]) )
1282 $comment_pending_count[$post->ID] = 0;
1284 _post_row($post, $comment_pending_count[$post->ID], $mode);
1289 * {@internal Missing Short Description}}
1293 * @param unknown_type $a_post
1294 * @param unknown_type $pending_comments
1295 * @param unknown_type $mode
1297 function _post_row($a_post, $pending_comments, $mode) {
1301 $global_post = $post;
1303 setup_postdata($post);
1305 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1306 global $current_user;
1307 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
1308 $edit_link = get_edit_post_link( $post->ID );
1309 $title = _draft_or_post_title();
1311 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
1313 $posts_columns = get_column_headers('edit');
1314 $hidden = get_hidden_columns('edit');
1315 foreach ( $posts_columns as $column_name=>$column_display_name ) {
1316 $class = "class=\"$column_name column-$column_name\"";
1319 if ( in_array($column_name, $hidden) )
1320 $style = ' style="display:none;"';
1322 $attributes = "$class$style";
1324 switch ($column_name) {
1328 <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>
1333 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
1334 $t_time = $h_time = __('Unpublished');
1336 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1337 $m_time = $post->post_date;
1338 $time = get_post_time('G', true, $post);
1340 $time_diff = time() - $time;
1342 if ( ( 'future' == $post->post_status) ) {
1343 if ( $time_diff <= 0 ) {
1344 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
1351 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1352 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1354 $h_time = mysql2date(__('Y/m/d'), $m_time);
1358 echo '<td ' . $attributes . '>';
1359 if ( 'excerpt' == $mode )
1360 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
1362 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
1364 if ( 'publish' == $post->post_status ) {
1366 } elseif ( 'future' == $post->post_status ) {
1367 if ( isset($missed) )
1368 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1372 _e('Last Modified');
1378 $attributes = 'class="post-title column-title"' . $style;
1380 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
1382 if ( 'excerpt' == $mode )
1386 if ( current_user_can('edit_post', $post->ID) ) {
1387 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
1388 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
1389 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1391 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1392 if ( current_user_can('edit_post', $post->ID) )
1393 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1395 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1397 $action_count = count($actions);
1399 echo '<div class="row-actions">';
1400 foreach ( $actions as $action => $link ) {
1402 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1403 echo "<span class='$action'>$link$sep</span>";
1407 get_inline_data($post);
1415 <td <?php echo $attributes ?>><?php
1416 $categories = get_the_category();
1417 if ( !empty( $categories ) ) {
1419 foreach ( $categories as $c )
1420 $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
1421 echo join( ', ', $out );
1423 _e('Uncategorized');
1431 <td <?php echo $attributes ?>><?php
1432 $tags = get_the_tags($post->ID);
1433 if ( !empty( $tags ) ) {
1435 foreach ( $tags as $c )
1436 $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
1437 echo join( ', ', $out );
1447 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1449 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
1450 if ( $pending_comments )
1452 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
1453 if ( $pending_comments )
1462 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
1466 case 'control_view':
1468 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
1472 case 'control_edit':
1474 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
1478 case 'control_delete':
1480 <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>
1486 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
1494 $post = $global_post;
1498 * display one row if the page doesn't have any children
1499 * otherwise, display the row and its children in subsequent rows
1502 * {@internal Missing Short Description}}
1506 * @param unknown_type $page
1507 * @param unknown_type $level
1509 function display_page_row( $page, $level = 0 ) {
1514 setup_postdata($page);
1516 $page->post_title = wp_specialchars( $page->post_title );
1517 $pad = str_repeat( '— ', $level );
1518 $id = (int) $page->ID;
1519 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1520 $posts_columns = get_column_headers('edit-pages');
1521 $hidden = get_hidden_columns('edit-pages');
1522 $title = _draft_or_post_title();
1524 <tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
1527 foreach ($posts_columns as $column_name=>$column_display_name) {
1528 $class = "class=\"$column_name column-$column_name\"";
1531 if ( in_array($column_name, $hidden) )
1532 $style = ' style="display:none;"';
1534 $attributes = "$class$style";
1536 switch ($column_name) {
1540 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
1544 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
1545 $t_time = $h_time = __('Unpublished');
1547 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1548 $m_time = $page->post_date;
1549 $time = get_post_time('G', true);
1551 if ( ( abs(time() - $time) ) < 86400 ) {
1552 if ( ( 'future' == $page->post_status) )
1553 $h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
1555 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1557 $h_time = mysql2date(__('Y/m/d'), $m_time);
1560 echo '<td ' . $attributes . '>';
1561 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
1563 if ( 'publish' == $page->post_status || 'future' == $page->post_status )
1566 _e('Last Modified');
1570 $attributes = 'class="post-title page-title column-title"' . $style;
1571 $edit_link = get_edit_post_link( $page->ID );
1573 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); ?></strong>
1576 if ( current_user_can('edit_page', $page->ID) ) {
1577 $actions['edit'] = '<a href="' . $edit_link . '" title="' . attribute_escape(__('Edit this page')) . '">' . __('Edit') . '</a>';
1578 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
1579 $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1581 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1582 if ( current_user_can('edit_page', $page->ID) )
1583 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1585 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1587 $action_count = count($actions);
1590 echo '<div class="row-actions">';
1591 foreach ( $actions as $action => $link ) {
1593 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1594 echo "<span class='$action'>$link$sep</span>";
1598 get_inline_data($post);
1604 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1606 $left = get_pending_comments_num( $page->ID );
1607 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
1610 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
1620 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
1626 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
1639 * displays pages in hierarchical order with paging support
1642 * {@internal Missing Short Description}}
1646 * @param unknown_type $pages
1647 * @param unknown_type $pagenum
1648 * @param unknown_type $per_page
1651 function page_rows($pages, $pagenum = 1, $per_page = 20) {
1657 $pages = get_pages( array('sort_column' => 'menu_order') );
1664 * arrange pages into two parts: top level pages and children_pages
1665 * children_pages is two dimensional array, eg.
1666 * children_pages[10][] contains all sub-pages whose parent is 10.
1667 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
1668 * If searching, ignore hierarchy and treat everything as top level
1670 if ( empty($_GET['s']) ) {
1672 $top_level_pages = array();
1673 $children_pages = array();
1675 foreach ( $pages as $page ) {
1677 // catch and repair bad pages
1678 if ( $page->post_parent == $page->ID ) {
1679 $page->post_parent = 0;
1680 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
1681 clean_page_cache( $page->ID );
1684 if ( 0 == $page->post_parent )
1685 $top_level_pages[] = $page;
1687 $children_pages[ $page->post_parent ][] = $page;
1690 $pages = &$top_level_pages;
1694 $start = ($pagenum - 1) * $per_page;
1695 $end = $start + $per_page;
1697 foreach ( $pages as $page ) {
1698 if ( $count >= $end )
1701 if ( $count >= $start )
1702 echo "\t" . display_page_row( $page, $level );
1706 if ( isset($children_pages) )
1707 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1710 // if it is the last pagenum and there are orphaned pages, display them with paging as well
1711 if ( isset($children_pages) && $count < $end ){
1712 foreach( $children_pages as $orphans ){
1713 foreach ( $orphans as $op ) {
1714 if ( $count >= $end )
1716 if ( $count >= $start )
1717 echo "\t" . display_page_row( $op, 0 );
1725 * Given a top level page ID, display the nested hierarchy of sub-pages
1726 * together with paging support
1729 * {@internal Missing Short Description}}
1733 * @param unknown_type $children_pages
1734 * @param unknown_type $count
1735 * @param unknown_type $parent
1736 * @param unknown_type $level
1737 * @param unknown_type $pagenum
1738 * @param unknown_type $per_page
1740 function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
1742 if ( ! isset( $children_pages[$parent] ) )
1745 $start = ($pagenum - 1) * $per_page;
1746 $end = $start + $per_page;
1748 foreach ( $children_pages[$parent] as $page ) {
1750 if ( $count >= $end )
1753 // If the page starts in a subtree, print the parents.
1754 if ( $count == $start && $page->post_parent > 0 ) {
1755 $my_parents = array();
1756 $my_parent = $page->post_parent;
1757 while ( $my_parent) {
1758 $my_parent = get_post($my_parent);
1759 $my_parents[] = $my_parent;
1760 if ( !$my_parent->post_parent )
1762 $my_parent = $my_parent->post_parent;
1764 $num_parents = count($my_parents);
1765 while( $my_parent = array_pop($my_parents) ) {
1766 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
1771 if ( $count >= $start )
1772 echo "\t" . display_page_row( $page, $level );
1776 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1779 unset( $children_pages[$parent] ); //required in order to keep track of orphans
1783 * {@internal Missing Short Description}}
1787 * @param unknown_type $user_object
1788 * @param unknown_type $style
1789 * @param unknown_type $role
1792 function user_row( $user_object, $style = '', $role = '' ) {
1795 $current_user = wp_get_current_user();
1797 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1798 $user_object = new WP_User( (int) $user_object );
1799 $email = $user_object->user_email;
1800 $url = $user_object->user_url;
1801 $short_url = str_replace( 'http://', '', $url );
1802 $short_url = str_replace( 'www.', '', $short_url );
1803 if ('/' == substr( $short_url, -1 ))
1804 $short_url = substr( $short_url, 0, -1 );
1805 if ( strlen( $short_url ) > 35 )
1806 $short_url = substr( $short_url, 0, 32 ).'...';
1807 $numposts = get_usernumposts( $user_object->ID );
1808 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
1809 if ($current_user->ID == $user_object->ID) {
1810 $edit_link = 'profile.php';
1812 $edit_link = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
1814 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1816 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1817 if ( $current_user->ID != $user_object->ID )
1818 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1819 $action_count = count($actions);
1821 $edit .= '<div class="row-actions">';
1822 foreach ( $actions as $action => $link ) {
1824 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1825 $edit .= "<span class='$action'>$link$sep</span>";
1829 $edit = '<strong>' . $user_object->user_login . '</strong>';
1831 $role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
1832 $r = "<tr id='user-$user_object->ID'$style>";
1833 $columns = get_column_headers('users');
1834 $hidden = get_hidden_columns('users');
1835 $avatar = get_avatar( $user_object->user_email, 32 );
1836 foreach ( $columns as $column_name => $column_display_name ) {
1837 $class = "class=\"$column_name column-$column_name\"";
1840 if ( in_array($column_name, $hidden) )
1841 $style = ' style="display:none;"';
1843 $attributes = "$class$style";
1845 switch ($column_name) {
1847 $r .= "<th scope='row' class='check-column'><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></th>";
1850 $r .= "<td $attributes>$avatar $edit</td>";
1853 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1856 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
1859 $r .= "<td $attributes>$role_name</td>";
1862 $attributes = 'class="posts column-posts num"' . $style;
1863 $r .= "<td $attributes>";
1864 if ( $numposts > 0 ) {
1865 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1880 * {@internal Missing Short Description}}
1884 * @param unknown_type $status
1885 * @param unknown_type $s
1886 * @param unknown_type $start
1887 * @param unknown_type $num
1888 * @param unknown_type $post
1889 * @param unknown_type $type
1892 function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
1895 $start = abs( (int) $start );
1897 $post = (int) $post;
1899 if ( 'moderated' == $status )
1900 $approved = "comment_approved = '0'";
1901 elseif ( 'approved' == $status )
1902 $approved = "comment_approved = '1'";
1903 elseif ( 'spam' == $status )
1904 $approved = "comment_approved = 'spam'";
1906 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
1909 $post = " AND comment_post_ID = '$post'";
1910 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
1913 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
1916 if ( 'comment' == $type )
1917 $typesql = "AND comment_type = ''";
1918 elseif ( 'pingback' == $type )
1919 $typesql = "AND comment_type = 'pingback'";
1920 elseif ( 'trackback' == $type )
1921 $typesql = "AND comment_type = 'trackback'";
1922 elseif ( 'pings' == $type )
1923 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
1928 $s = $wpdb->escape($s);
1929 $comments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE
1930 (comment_author LIKE '%$s%' OR
1931 comment_author_email LIKE '%$s%' OR
1932 comment_author_url LIKE ('%$s%') OR
1933 comment_author_IP LIKE ('%$s%') OR
1934 comment_content LIKE ('%$s%') ) AND
1939 $comments = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->comments WHERE $approved $post $typesql $orderby" );
1942 update_comment_cache($comments);
1944 $total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
1946 return array($comments, $total);
1950 * {@internal Missing Short Description}}
1954 * @param unknown_type $comment_id
1955 * @param unknown_type $mode
1956 * @param unknown_type $comment_status
1957 * @param unknown_type $checkbox
1959 function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
1960 global $comment, $post, $_comment_pending_count;
1961 $comment = get_comment( $comment_id );
1962 $post = get_post($comment->comment_post_ID);
1963 $the_comment_status = wp_get_comment_status($comment->comment_ID);
1965 $author_url = get_comment_author_url();
1966 if ( 'http://' == $author_url )
1968 $author_url_display = $author_url;
1969 $author_url_display = str_replace('http://www.', '', $author_url_display);
1970 $author_url_display = str_replace('http://', '', $author_url_display);
1971 if ( strlen($author_url_display) > 50 )
1972 $author_url_display = substr($author_url_display, 0, 49) . '...';
1974 $ptime = date('G', strtotime( $comment->comment_date ) );
1975 if ( ( abs(time() - $ptime) ) < 86400 )
1976 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
1978 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
1980 $delete_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
1981 $approve_url = clean_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
1982 $unapprove_url = clean_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
1983 $spam_url = clean_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
1985 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
1986 $columns = get_column_headers('edit-comments');
1987 $hidden = get_hidden_columns('edit-comments');
1988 foreach ( $columns as $column_name => $column_display_name ) {
1989 $class = "class=\"$column_name column-$column_name\"";
1992 if ( in_array($column_name, $hidden) )
1993 $style = ' style="display:none;"';
1995 $attributes = "$class$style";
1997 switch ($column_name) {
1999 if ( !$checkbox ) break;
2000 echo '<th scope="row" class="check-column">';
2001 if ( current_user_can('edit_post', $post->ID) ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2005 echo "<td $attributes>";
2006 echo '<div id="submitted-on">';
2007 printf(__('Submitted on <a href="%1$s">%2$s at %3$s</a>'), get_comment_link($comment->comment_ID), get_comment_date(__('Y/m/d')), get_comment_date(__('g:ia')));
2010 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2011 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
2012 <div class="author-email"><?php echo attribute_escape( $comment->comment_author_email ); ?></div>
2013 <div class="author"><?php echo attribute_escape( $comment->comment_author ); ?></div>
2014 <div class="author-url"><?php echo attribute_escape( $comment->comment_author_url ); ?></div>
2015 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2020 if ( current_user_can('edit_post', $post->ID) ) {
2021 $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2022 $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2023 if ( $comment_status ) { // not looking at all comments
2024 if ( 'approved' == $the_comment_status ) {
2025 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2026 unset($actions['approve']);
2028 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2029 unset($actions['unapprove']);
2032 if ( 'spam' != $the_comment_status )
2033 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . _c( 'Spam|verb' ) . '</a>';
2034 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
2035 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
2036 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
2037 if ( 'spam' != $the_comment_status )
2038 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2040 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
2043 echo '<div class="row-actions">';
2044 foreach ( $actions as $action => $link ) {
2046 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2048 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2049 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2050 $action .= ' hide-if-no-js';
2052 echo "<span class='$action'>$sep$link</span>";
2060 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2061 if ( !empty($author_url) )
2062 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2063 if ( current_user_can( 'edit_post', $post->ID ) ) {
2064 if ( !empty($comment->comment_author_email) ) {
2065 comment_author_email_link();
2068 echo '<a href="edit-comments.php?s=';
2069 comment_author_IP();
2070 echo '&mode=detail';
2071 if ( 'spam' == $comment_status )
2072 echo '&comment_status=spam';
2074 comment_author_IP();
2076 } //current_user_can
2080 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2083 if ( 'single' !== $mode ) {
2084 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2085 $pending_comments = absint( $_comment_pending_count[$post->ID] );
2087 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
2088 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2090 if ( current_user_can( 'edit_post', $post->ID ) ) {
2091 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2092 $post_link .= get_the_title($post->ID) . '</a>';
2094 $post_link = get_the_title($post->ID);
2096 echo "<td $attributes>\n";
2099 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2100 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
2101 if ( $pending_comments )
2103 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
2104 if ( $pending_comments )
2107 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2116 * {@internal Missing Short Description}}
2120 * @param unknown_type $position
2121 * @param unknown_type $checkbox
2122 * @param unknown_type $mode
2124 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2125 global $current_user;
2127 // allow plugin to replace the popup content
2128 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2130 if ( ! empty($content) ) {
2135 $columns = get_column_headers('edit-comments');
2136 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2137 $col_count = count($columns) - count($hidden);
2140 <form method="get" action="">
2141 <?php if ( $table_row ) : ?>
2142 <table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
2144 <div id="com-reply" style="display:none;"><div id="replyrow">
2146 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2148 <div id="edithead" style="display:none;">
2149 <div class="inside">
2150 <label for="author"><?php _e('Name') ?></label>
2151 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2154 <div class="inside">
2155 <label for="author-email"><?php _e('E-mail') ?></label>
2156 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2159 <div class="inside">
2160 <label for="author-url"><?php _e('URL') ?></label>
2161 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2163 <div style="clear:both;"></div>
2166 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2168 <p id="replysubmit" class="submit">
2169 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2170 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2171 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2172 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2173 <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
2174 <span class="error" style="display:none;"></span>
2175 <br class="clear" />
2178 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2179 <input type="hidden" name="action" id="action" value="" />
2180 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2181 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2182 <input type="hidden" name="status" id="status" value="" />
2183 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2184 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2185 <input type="hidden" name="mode" id="mode" value="<?php echo $mode; ?>" />
2186 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
2187 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2188 <?php if ( $table_row ) : ?>
2189 </td></tr></tbody></table>
2198 * {@internal Missing Short Description}}
2202 * @param unknown_type $currentcat
2203 * @param unknown_type $currentparent
2204 * @param unknown_type $parent
2205 * @param unknown_type $level
2206 * @param unknown_type $categories
2209 function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
2211 $categories = get_categories( array('hide_empty' => 0) );
2213 if ( $categories ) {
2214 foreach ( $categories as $category ) {
2215 if ( $currentcat != $category->term_id && $parent == $category->parent) {
2216 $pad = str_repeat( '– ', $level );
2217 $category->name = wp_specialchars( $category->name );
2218 echo "\n\t<option value='$category->term_id'";
2219 if ( $currentparent == $category->term_id )
2220 echo " selected='selected'";
2221 echo ">$pad$category->name</option>";
2222 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
2231 * {@internal Missing Short Description}}
2235 * @param unknown_type $meta
2237 function list_meta( $meta ) {
2241 <table id="list-table" style="display: none;">
2244 <th class="left">' . __( 'Name' ) . '</th>
2245 <th>' . __( 'Value' ) . '</th>
2248 <tbody id="the-list" class="list:meta">
2251 </table>'; //TBODY needed for list-manipulation JS
2256 <table id="list-table">
2259 <th class="left"><?php _e( 'Name' ) ?></th>
2260 <th><?php _e( 'Value' ) ?></th>
2263 <tbody id='the-list' class='list:meta'>
2265 foreach ( $meta as $entry )
2266 echo _list_meta_row( $entry, $count );
2274 * {@internal Missing Short Description}}
2278 * @param unknown_type $entry
2279 * @param unknown_type $count
2282 function _list_meta_row( $entry, &$count ) {
2283 static $update_nonce = false;
2284 if ( !$update_nonce )
2285 $update_nonce = wp_create_nonce( 'add-meta' );
2290 $style = 'alternate';
2293 if ('_' == $entry['meta_key'] { 0 } )
2294 $style .= ' hidden';
2296 if ( is_serialized( $entry['meta_value'] ) ) {
2297 if ( is_serialized_string( $entry['meta_value'] ) ) {
2298 // this is a serialized string, so we should display it
2299 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2301 // this is a serialized array/object so we should NOT display it
2307 $entry['meta_key'] = attribute_escape($entry['meta_key']);
2308 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2309 $entry['meta_id'] = (int) $entry['meta_id'];
2311 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2313 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2314 $r .= "\n\t\t<td class='left'><label class='hidden' 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']}' />";
2316 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2317 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='".attribute_escape(__( 'Delete' ))."' />";
2318 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='".attribute_escape(__( 'Update' ))."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
2319 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2322 $r .= "\n\t\t<td><label class='hidden' 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>";
2327 * {@internal Missing Short Description}}
2331 function meta_form() {
2333 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2334 $keys = $wpdb->get_col( "
2336 FROM $wpdb->postmeta
2337 WHERE meta_key NOT LIKE '\_%'
2339 ORDER BY meta_id DESC
2344 <p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
2345 <table id="newmeta">
2348 <th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2349 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2355 <td id="newmetaleft" class="left">
2356 <?php if ( $keys ) { ?>
2357 <select id="metakeyselect" name="metakeyselect" tabindex="7">
2358 <option value="#NONE#"><?php _e( '- Select -' ); ?></option>
2361 foreach ( $keys as $key ) {
2362 $key = attribute_escape( $key );
2363 echo "\n<option value='$key'>$key</option>";
2367 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2368 <a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2369 <span id="enternew"><?php _e('Enter new'); ?></span>
2370 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2372 <input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2375 <td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2378 <tr><td colspan="2" class="submit">
2379 <input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php _e( 'Add Custom Field' ) ?>" />
2380 <?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
2389 * {@internal Missing Short Description}}
2393 * @param unknown_type $edit
2394 * @param unknown_type $for_post
2395 * @param unknown_type $tab_index
2396 * @param unknown_type $multi
2398 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2399 global $wp_locale, $post, $comment;
2402 $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;
2404 $tab_index_attribute = '';
2405 if ( (int) $tab_index > 0 )
2406 $tab_index_attribute = " tabindex=\"$tab_index\"";
2408 // 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 />';
2410 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
2411 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2412 $jj = ($edit) ? mysql2date( 'd', $post_date ) : gmdate( 'd', $time_adj );
2413 $mm = ($edit) ? mysql2date( 'm', $post_date ) : gmdate( 'm', $time_adj );
2414 $aa = ($edit) ? mysql2date( 'Y', $post_date ) : gmdate( 'Y', $time_adj );
2415 $hh = ($edit) ? mysql2date( 'H', $post_date ) : gmdate( 'H', $time_adj );
2416 $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
2417 $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
2419 $cur_jj = gmdate( 'd', $time_adj );
2420 $cur_mm = gmdate( 'm', $time_adj );
2421 $cur_aa = gmdate( 'Y', $time_adj );
2422 $cur_hh = gmdate( 'H', $time_adj );
2423 $cur_mn = gmdate( 'i', $time_adj );
2425 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2426 for ( $i = 1; $i < 13; $i = $i +1 ) {
2427 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2429 $month .= ' selected="selected"';
2430 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2432 $month .= '</select>';
2434 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2435 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off" />';
2436 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2437 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2438 printf(_c('%1$s%2$s, %3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
2440 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2442 if ( $multi ) return;
2445 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2446 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2447 $cur_timeunit = 'cur_' . $timeunit;
2448 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2452 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
2455 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2456 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2462 * {@internal Missing Short Description}}
2466 * @param unknown_type $default
2468 function page_template_dropdown( $default = '' ) {
2469 $templates = get_page_templates();
2470 ksort( $templates );
2471 foreach (array_keys( $templates ) as $template )
2472 : if ( $default == $templates[$template] )
2473 $selected = " selected='selected'";
2476 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2481 * {@internal Missing Short Description}}
2485 * @param unknown_type $default
2486 * @param unknown_type $parent
2487 * @param unknown_type $level
2490 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2491 global $wpdb, $post_ID;
2492 $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) );
2495 foreach ( $items as $item ) {
2496 // A page cannot be its own parent.
2497 if (!empty ( $post_ID ) ) {
2498 if ( $item->ID == $post_ID ) {
2502 $pad = str_repeat( ' ', $level * 3 );
2503 if ( $item->ID == $default)
2504 $current = ' selected="selected"';
2508 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . wp_specialchars($item->post_title) . "</option>";
2509 parent_dropdown( $default, $item->ID, $level +1 );
2517 * {@internal Missing Short Description}}
2521 function browse_happy() {
2522 $getit = __( 'WordPress recommends a better browser' );
2524 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
2529 * {@internal Missing Short Description}}
2533 * @param unknown_type $id
2536 function the_attachment_links( $id = false ) {
2538 $post = & get_post( $id );
2540 if ( $post->post_type != 'attachment' )
2543 $icon = get_attachment_icon( $post->ID );
2544 $attachment_data = wp_get_attachment_metadata( $id );
2545 $thumb = isset( $attachment_data['thumb'] );
2547 <form id="the-attachment-links">
2550 <col class="widefat" />
2552 <th scope="row"><?php _e( 'URL' ) ?></th>
2553 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2555 <?php if ( $icon ) : ?>
2557 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2558 <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>
2561 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2562 <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>
2566 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2567 <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>
2570 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2571 <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>
2580 * {@internal Missing Short Description}}
2584 * @param unknown_type $default
2586 function wp_dropdown_roles( $default = false ) {
2590 foreach( $wp_roles->role_names as $role => $name ) {
2591 $name = translate_with_context($name);
2592 if ( $default == $role ) // Make default first in list
2593 $p = "\n\t<option selected='selected' value='$role'>$name</option>";
2595 $r .= "\n\t<option value='$role'>$name</option>";
2601 * {@internal Missing Short Description}}
2605 * @param unknown_type $size
2608 function wp_convert_hr_to_bytes( $size ) {
2609 $size = strtolower($size);
2610 $bytes = (int) $size;
2611 if ( strpos($size, 'k') !== false )
2612 $bytes = intval($size) * 1024;
2613 elseif ( strpos($size, 'm') !== false )
2614 $bytes = intval($size) * 1024 * 1024;
2615 elseif ( strpos($size, 'g') !== false )
2616 $bytes = intval($size) * 1024 * 1024 * 1024;
2621 * {@internal Missing Short Description}}
2625 * @param unknown_type $bytes
2628 function wp_convert_bytes_to_hr( $bytes ) {
2629 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2630 $log = log( $bytes, 1024 );
2631 $power = (int) $log;
2632 $size = pow(1024, $log - $power);
2633 return $size . $units[$power];
2637 * {@internal Missing Short Description}}
2643 function wp_max_upload_size() {
2644 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2645 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2646 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2651 * {@internal Missing Short Description}}
2655 * @param unknown_type $action
2657 function wp_import_upload_form( $action ) {
2658 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2659 $size = wp_convert_bytes_to_hr( $bytes );
2661 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>">
2663 <?php wp_nonce_field('import-upload'); ?>
2664 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2665 <input type="file" id="upload" name="import" size="25" />
2666 <input type="hidden" name="action" value="save" />
2667 <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2670 <input type="submit" class="button" value="<?php _e( 'Upload file and import' ); ?>" />
2677 * {@internal Missing Short Description}}
2681 function wp_remember_old_slug() {
2683 $name = attribute_escape($post->post_name); // just in case
2684 if ( strlen($name) )
2685 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
2689 * Add a meta box to an edit form.
2693 * @param string $id String for use in the 'id' attribute of tags.
2694 * @param string $title Title of the meta box.
2695 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2696 * @param string $page The type of edit page on which to show the box (post, page, link).
2697 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2698 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2700 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default') {
2701 global $wp_meta_boxes;
2703 if ( !isset($wp_meta_boxes) )
2704 $wp_meta_boxes = array();
2705 if ( !isset($wp_meta_boxes[$page]) )
2706 $wp_meta_boxes[$page] = array();
2707 if ( !isset($wp_meta_boxes[$page][$context]) )
2708 $wp_meta_boxes[$page][$context] = array();
2710 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2711 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2712 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2715 // If a core box was previously added or removed by a plugin, don't add.
2716 if ( 'core' == $priority ) {
2717 // If core box previously deleted, don't add
2718 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2720 // If box was added with default priority, give it core priority to maintain sort order
2721 if ( 'default' == $a_priority ) {
2722 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2723 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2727 // If no priority given and id already present, use existing priority
2728 if ( empty($priority) ) {
2729 $priority = $a_priority;
2730 // 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.
2731 } elseif ( 'sorted' == $priority ) {
2732 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2733 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2735 // An id can be in only one priority and one context
2736 if ( $priority != $a_priority || $context != $a_context )
2737 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2741 if ( empty($priority) )
2744 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2745 $wp_meta_boxes[$page][$context][$priority] = array();
2747 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
2751 * {@internal Missing Short Description}}
2755 * @param unknown_type $page
2756 * @param unknown_type $context
2757 * @param unknown_type $object
2758 * @return int number of meta_boxes
2760 function do_meta_boxes($page, $context, $object) {
2761 global $wp_meta_boxes;
2762 static $already_sorted = false;
2764 //do_action('do_meta_boxes', $page, $context, $object);
2766 $hidden = get_hidden_meta_boxes($page);
2768 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
2772 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2773 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
2774 foreach ( $sorted as $box_context => $ids )
2775 foreach ( explode(',', $ids) as $id )
2777 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2779 $already_sorted = true;
2781 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2784 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2785 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2786 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2787 if ( false == $box || ! $box['title'] )
2791 if ( in_array($box['id'], $hidden) )
2792 $style = 'style="display:none;"';
2793 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
2794 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
2795 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
2796 echo '<div class="inside">' . "\n";
2797 call_user_func($box['callback'], $object, $box);
2812 * Remove a meta box from an edit form.
2816 * @param string $id String for use in the 'id' attribute of tags.
2817 * @param string $page The type of edit page on which to show the box (post, page, link).
2818 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2820 function remove_meta_box($id, $page, $context) {
2821 global $wp_meta_boxes;
2823 if ( !isset($wp_meta_boxes) )
2824 $wp_meta_boxes = array();
2825 if ( !isset($wp_meta_boxes[$page]) )
2826 $wp_meta_boxes[$page] = array();
2827 if ( !isset($wp_meta_boxes[$page][$context]) )
2828 $wp_meta_boxes[$page][$context] = array();
2830 foreach ( array('high', 'core', 'default', 'low') as $priority )
2831 $wp_meta_boxes[$page][$context][$priority][$id] = false;
2835 * {@internal Missing Short Description}}
2839 * @param unknown_type $page
2841 function meta_box_prefs($page) {
2842 global $wp_meta_boxes;
2844 if ( empty($wp_meta_boxes[$page]) )
2847 $hidden = get_hidden_meta_boxes($page);
2849 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
2850 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
2851 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
2852 if ( false == $box || ! $box['title'] )
2854 // Submit box cannot be hidden
2855 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
2857 $box_id = $box['id'];
2858 echo '<label for="' . $box_id . '-hide">';
2859 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"' : '') . ' />';
2860 echo "{$box['title']}</label>\n";
2866 function get_hidden_meta_boxes($page) {
2867 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
2869 // Hide slug boxes by default
2870 if ( empty($hidden[0]) ) {
2871 if ( 'page' == $page )
2872 $hidden = array('pageslugdiv');
2873 elseif ( 'post' == $page )
2874 $hidden = array('slugdiv');
2881 * Add a new section to a settings page.
2885 * @param string $id String for use in the 'id' attribute of tags.
2886 * @param string $title Title of the section.
2887 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
2888 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
2890 function add_settings_section($id, $title, $callback, $page) {
2891 global $wp_settings_sections;
2893 if ( !isset($wp_settings_sections) )
2894 $wp_settings_sections = array();
2895 if ( !isset($wp_settings_sections[$page]) )
2896 $wp_settings_sections[$page] = array();
2897 if ( !isset($wp_settings_sections[$page][$id]) )
2898 $wp_settings_sections[$page][$id] = array();
2900 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
2904 * Add a new field to a settings page.
2908 * @param string $id String for use in the 'id' attribute of tags.
2909 * @param string $title Title of the field.
2910 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
2911 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
2912 * @param string $section The section of the settingss page in which to show the box (default, ...).
2913 * @param array $args Additional arguments
2915 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
2916 global $wp_settings_fields;
2918 if ( !isset($wp_settings_fields) )
2919 $wp_settings_fields = array();
2920 if ( !isset($wp_settings_fields[$page]) )
2921 $wp_settings_fields[$page] = array();
2922 if ( !isset($wp_settings_fields[$page][$section]) )
2923 $wp_settings_fields[$page][$section] = array();
2925 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
2929 * {@internal Missing Short Description}}
2933 * @param unknown_type $page
2935 function do_settings_sections($page) {
2936 global $wp_settings_sections, $wp_settings_fields;
2938 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
2941 foreach ( (array) $wp_settings_sections[$page] as $section ) {
2942 echo "<h3>{$section['title']}</h3>\n";
2943 call_user_func($section['callback'], $section);
2944 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
2946 echo '<table class="form-table">';
2947 do_settings_fields($page, $section['id']);
2953 * {@internal Missing Short Description}}
2957 * @param unknown_type $page
2958 * @param unknown_type $section
2960 function do_settings_fields($page, $section) {
2961 global $wp_settings_fields;
2963 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
2966 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
2967 echo '<tr valign="top">';
2968 if ( !empty($field['args']['label_for']) )
2969 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
2971 echo '<th scope="row">' . $field['title'] . '</th>';
2973 call_user_func($field['callback']);
2980 * {@internal Missing Short Description}}
2984 * @param unknown_type $page
2986 function manage_columns_prefs($page) {
2987 $columns = get_column_headers($page);
2989 $hidden = get_hidden_columns($page);
2991 foreach ( $columns as $column => $title ) {
2993 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
2995 if ( empty($title) )
2998 if ( 'comments' == $column )
2999 $title = __('Comments');
3000 $id = "$column-hide";
3001 echo '<label for="' . $id . '">';
3002 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3003 echo "$title</label>\n";
3008 * {@internal Missing Short Description}}
3012 * @param unknown_type $found_action
3014 function find_posts_div($found_action = '') {
3016 <div id="find-posts" class="find-box" style="display:none;">
3017 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3018 <div class="find-box-inside">
3019 <div class="find-box-search">
3020 <?php if ( $found_action ) { ?>
3021 <input type="hidden" name="found_action" value="<?php echo $found_action; ?>" />
3024 <input type="hidden" name="affected" id="affected" value="" />
3025 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3026 <label class="hidden" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3027 <input type="text" id="find-posts-input" class="search-input" name="ps" value="" />
3028 <input type="button" onclick="findPosts.send();" value="<?php _e( 'Search' ); ?>" class="button" /><br />
3030 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
3031 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
3032 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
3033 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
3035 <div id="find-posts-response"></div>
3037 <div class="find-box-buttons">
3038 <input type="button" class="button" onclick="findPosts.close();" value="<?php _e('Close'); ?>" />
3039 <input id="find-posts-submit" type="submit" class="button" value="<?php _e('Select'); ?>" />
3042 <script type="text/javascript">
3046 open : function(af_name, af_val) {
3047 var st = document.documentElement.scrollTop || $(document).scrollTop();
3049 if ( af_name && af_val )
3050 $('#affected').attr('name', af_name).val(af_val);
3052 $('#find-posts').show().draggable({
3053 handle: '#find-posts-head'
3058 }).css({'top':st+'px','left':'50%','marginLeft':'-200px'});
3060 $('.ui-resizable-handle').css({
3061 'backgroundColor': '#e5e5e5'
3064 $('.ui-resizable-se').css({
3068 'background': 'transparent url(images/se.png) no-repeat scroll 0 0'
3071 $('#find-posts-input').focus().keyup(function(e){
3072 if (e.which == 27) findPosts.close(); // close on Escape
3078 close : function() {
3079 $('#find-posts-response').html('');
3080 $('#find-posts').draggable('destroy').resizable('destroy').hide();
3086 post['ps'] = $('#find-posts-input').val();
3087 post['action'] = 'find_posts';
3088 post['_ajax_nonce'] = $('#_ajax_nonce').val();
3090 if ( $('#find-posts-pages:checked').val() )
3097 url : '<?php echo admin_url('admin-ajax.php'); ?>',
3099 success : function(x) { findPosts.show(x); },
3100 error : function(r) { findPosts.error(r); }
3104 show : function(x) {
3106 if ( typeof(x) == 'string' ) {
3107 this.error({'responseText': x});
3111 var r = wpAjax.parseAjaxResponse(x);
3114 this.error({'responseText': wpAjax.broken});
3117 $('#find-posts-response').html(r.data);
3120 error : function(r) {
3121 var er = r.statusText;
3123 if ( r.responseText )
3124 er = r.responseText.replace( /<.[^<>]*?>/g, '' );
3127 $('#find-posts-response').html(er);
3131 $(document).ready(function(){
3132 $('#find-posts-submit').click(function(e) {
3133 if ( '' == $('#find-posts-response').html() )
3144 * Display the post password.
3146 * The password is passed through {@link attribute_escape()} to ensure that it
3147 * is safe for placing in an html attribute.
3149 * @uses attribute_escape
3152 function the_post_password() {
3154 if ( isset( $post->post_password ) ) echo attribute_escape( $post->post_password );
3158 * {@internal Missing Short Description}}
3162 function favorite_actions() {
3164 'post-new.php' => array(__('New Post'), 'edit_posts'),
3165 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3166 'page-new.php' => array(__('New Page'), 'edit_pages'),
3167 'media-new.php' => array(__('Upload'), 'upload_files'),
3168 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3171 $actions = apply_filters('favorite_actions', $actions);
3173 $allowed_actions = array();
3174 foreach ( $actions as $action => $data ) {
3175 if ( current_user_can($data[1]) )
3176 $allowed_actions[$action] = $data[0];
3179 if ( empty($allowed_actions) )
3182 $first = array_keys($allowed_actions);
3184 echo '<div id="favorite-actions">';
3185 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3186 echo '<div id="favorite-inside">';
3188 array_shift($allowed_actions);
3190 foreach ( $allowed_actions as $action => $label) {
3191 echo "<div class='favorite-action'><a href='$action'>";
3193 echo "</a></div>\n";
3195 echo "</div></div>\n";
3199 * Get the post title.
3201 * The post title is fetched and if it is blank then a default string is
3205 * @param int $id The post id. If not supplied the global $post is used.
3208 function _draft_or_post_title($post_id = 0)
3210 $title = get_the_title($post_id);
3211 if ( empty($title) )
3212 $title = __('(no title)');
3217 * Display the search query.
3219 * A simple wrapper to display the "s" parameter in a GET URI. This function
3220 * should only be used when {@link the_search_query()} cannot.
3222 * @uses attribute_escape
3226 function _admin_search_query() {
3227 echo isset($_GET['s']) ? attribute_escape( stripslashes( $_GET['s'] ) ) : '';
3231 * Generic Iframe header for use with Thickbox
3234 * @param string $title Title of the Iframe page.
3235 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3238 function iframe_header( $title = '', $limit_styles = false) {
3239 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3240 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3242 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3243 <title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
3245 wp_enqueue_style( 'global' );
3246 wp_enqueue_style( 'colors' );
3247 if ( ! $limit_styles )
3248 wp_enqueue_style( 'wp-admin' );
3250 <script type="text/javascript">
3252 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
3256 do_action('admin_print_styles');
3257 do_action('admin_print_scripts');
3258 do_action('admin_head');
3261 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
3266 * Generic Iframe footer for use with Thickbox
3271 function iframe_footer() {
3277 function _post_states($post) {
3278 $post_states = array();
3279 if ( isset($_GET['post_status']) )
3280 $post_status = $_GET['post_status'];
3284 if ( !empty($post->post_password) )
3285 $post_states[] = __('Password protected');
3286 if ( 'private' == $post->post_status && 'private' != $post_status )
3287 $post_states[] = __('Private');
3288 if ( 'draft' == $post->post_status && 'draft' != $post_status )
3289 $post_states[] = __('Draft');
3290 if ( 'pending' == $post->post_status && 'pending' != $post_status )
3291 $post_states[] = __('Pending');
3293 if ( ! empty($post_states) ) {
3294 $state_count = count($post_states);
3297 foreach ( $post_states as $state ) {
3299 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
3300 echo "<span class='post-state'>$state$sep</span>";
3305 function screen_meta($screen) {
3306 global $wp_meta_boxes, $_wp_contextual_help;
3308 $screen = str_replace('.php', '', $screen);
3309 $screen = str_replace('-new', '', $screen);
3310 $screen = str_replace('-add', '', $screen);
3311 $screen = apply_filters('screen_meta_screen', $screen);
3313 $column_screens = get_column_headers($screen);
3314 $meta_screens = array('index' => 'dashboard');
3316 if ( isset($meta_screens[$screen]) )
3317 $screen = $meta_screens[$screen];
3318 $show_screen = false;
3319 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) )
3320 $show_screen = true;
3322 <div id="screen-meta">
3324 if ( $show_screen ) :
3326 <div id="screen-options-wrap" class="hidden">
3327 <h5><?php _e('Show on screen') ?></h5>
3328 <form id="adv-settings" action="" method="get">
3329 <div class="metabox-prefs">
3331 if ( !meta_box_prefs($screen) && isset($column_screens) ) {
3332 manage_columns_prefs($screen);
3333 wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false );
3336 <br class="clear" />
3345 if ( !isset($_wp_contextual_help) )
3346 $_wp_contextual_help = array();
3348 if ( !isset($_wp_contextual_help['post']) ) {
3349 $help = drag_drop_help();
3350 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
3351 $_wp_contextual_help['post'] = $help;
3354 if ( !isset($_wp_contextual_help['page']) ) {
3355 $help = drag_drop_help();
3356 $_wp_contextual_help['page'] = $help;
3359 if ( !isset($_wp_contextual_help['dashboard']) ) {
3360 $help = drag_drop_help();
3361 $_wp_contextual_help['dashboard'] = $help;
3364 if ( !isset($_wp_contextual_help['link']) ) {
3365 $help = drag_drop_help();
3366 $_wp_contextual_help['link'] = $help;
3369 if ( !isset($_wp_contextual_help['options-general']) )
3370 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
3372 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
3374 <div id="contextual-help-wrap" class="hidden">
3376 $contextual_help = '';
3377 if ( isset($_wp_contextual_help[$screen]) ) {
3378 if ( !empty($title) )
3379 $contextual_help .= '<h5>' . sprintf(__('Get help with "%s"'), $title) . '</h5>';
3381 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
3382 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
3384 $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
3386 $contextual_help .= '<h5>' . __('Help') . '</h5>';
3389 $contextual_help .= '<div class="metabox-prefs">';
3390 $contextual_help .= __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
3391 $contextual_help .= '<br />';
3392 $contextual_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
3393 $contextual_help .= "</div>\n";
3394 echo apply_filters('contextual_help', $contextual_help, $screen);
3398 <div id="screen-meta-links">
3399 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
3400 <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
3402 <?php if ( $show_screen ) { ?>
3403 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
3404 <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
3413 * Add contextual help text for a page
3417 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
3418 * @param string $help Arbitrary help text
3420 function add_contextual_help($screen, $help) {
3421 global $_wp_contextual_help;
3423 if ( !isset($_wp_contextual_help) )
3424 $_wp_contextual_help = array();
3426 $_wp_contextual_help[$screen] = $help;
3429 function drag_drop_help() {
3431 <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>
3432 <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>
3436 function screen_icon($name = '') {
3437 global $parent_file, $hook_suffix;
3439 if ( empty($name) ) {
3440 if ( isset($parent_file) && !empty($parent_file) )
3441 $name = substr($parent_file, 0, -4);
3443 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
3445 unset($hook_suffix);
3447 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>