Make WordPress Core

Ticket #10629: template.php

File template.php, 127.7 KB (added by novasource, 17 years ago)
Line 
1<?php
2/**
3 * Template WordPress Administration API.
4 *
5 * A Big Mess. Also some neat functions that are nicely written.
6 *
7 * @package WordPress
8 * @subpackage Administration
9 */
10
11// Ugly recursive category stuff.
12/**
13 * {@internal Missing Short Description}}
14 *
15 * @since unknown
16 *
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
22 */
23function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
24
25 $count = 0;
26
27 if ( empty($categories) ) {
28
29 $args = array('hide_empty' => 0);
30 if ( !empty($_GET['s']) )
31 $args['search'] = $_GET['s'];
32
33 $categories = get_categories( $args );
34
35 if ( empty($categories) )
36 return false;
37 }
38
39 $children = _get_term_hierarchy('category');
40
41 _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );
42
43}
44
45/**
46 * {@internal Missing Short Description}}
47 *
48 * @since unknown
49 *
50 * @param unknown_type $categories
51 * @param unknown_type $count
52 * @param unknown_type $parent
53 * @param unknown_type $level
54 * @param unknown_type $page
55 * @param unknown_type $per_page
56 * @return unknown
57 */
58function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) {
59
60 $start = ($page - 1) * $per_page;
61 $end = $start + $per_page;
62 ob_start();
63
64 foreach ( $categories as $key => $category ) {
65 if ( $count >= $end )
66 break;
67
68 if ( $category->parent != $parent && empty($_GET['s']) )
69 continue;
70
71 // If the page starts in a subtree, print the parents.
72 if ( $count == $start && $category->parent > 0 ) {
73
74 $my_parents = array();
75 $p = $category->parent;
76 while ( $p ) {
77 $my_parent = get_category( $p );
78 $my_parents[] = $my_parent;
79 if ( $my_parent->parent == 0 )
80 break;
81 $p = $my_parent->parent;
82 }
83
84 $num_parents = count($my_parents);
85 while( $my_parent = array_pop($my_parents) ) {
86 echo "\t" . _cat_row( $my_parent, $level - $num_parents );
87 $num_parents--;
88 }
89 }
90
91 if ( $count >= $start )
92 echo "\t" . _cat_row( $category, $level );
93
94 unset( $categories[ $key ] );
95
96 $count++;
97
98 if ( isset($children[$category->term_id]) )
99 _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );
100 }
101
102 $output = ob_get_contents();
103 ob_end_clean();
104
105 echo $output;
106}
107
108/**
109 * {@internal Missing Short Description}}
110 *
111 * @since unknown
112 *
113 * @param unknown_type $category
114 * @param unknown_type $level
115 * @param unknown_type $name_override
116 * @return unknown
117 */
118function _cat_row( $category, $level, $name_override = false ) {
119 static $row_class = '';
120
121 $category = get_category( $category, OBJECT, 'display' );
122
123 $default_cat_id = (int) get_option( 'default_category' );
124 $pad = str_repeat( '&#8212; ', max(0, $level) );
125 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
126 $edit_link = "categories.php?action=edit&amp;cat_ID=$category->term_id";
127 if ( current_user_can( 'manage_categories' ) ) {
128 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $category->name)) . "'>" . esc_attr( $name ) . '</a><br />';
129 $actions = array();
130 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
131 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
132 if ( $default_cat_id != $category->term_id )
133 $actions['delete'] = "<a class='delete:the-list:cat-$category->term_id submitdelete' href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
134 $actions = apply_filters('cat_row_actions', $actions, $category);
135 $action_count = count($actions);
136 $i = 0;
137 $edit .= '<div class="row-actions">';
138 foreach ( $actions as $action => $link ) {
139 ++$i;
140 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
141 $edit .= "<span class='$action'>$link$sep</span>";
142 }
143 $edit .= '</div>';
144 } else {
145 $edit = $name;
146 }
147
148 $row_class = 'alternate' == $row_class ? '' : 'alternate';
149 $qe_data = get_category_to_edit($category->term_id);
150
151 $category->count = number_format_i18n( $category->count );
152 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
153 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
154
155 $columns = get_column_headers('categories');
156 $hidden = get_hidden_columns('categories');
157 foreach ( $columns as $column_name => $column_display_name ) {
158 $class = "class=\"$column_name column-$column_name\"";
159
160 $style = '';
161 if ( in_array($column_name, $hidden) )
162 $style = ' style="display:none;"';
163
164 $attributes = "$class$style";
165
166 switch ($column_name) {
167 case 'cb':
168 $output .= "<th scope='row' class='check-column'>";
169 if ( $default_cat_id != $category->term_id ) {
170 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
171 } else {
172 $output .= "&nbsp;";
173 }
174 $output .= '</th>';
175 break;
176 case 'name':
177 $output .= "<td $attributes>$edit";
178 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
179 $output .= '<div class="name">' . $qe_data->name . '</div>';
180 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
181 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
182 break;
183 case 'description':
184 $output .= "<td $attributes>$category->description</td>";
185 break;
186 case 'slug':
187 $output .= "<td $attributes>$category->slug</td>";
188 break;
189 case 'posts':
190 $attributes = 'class="posts column-posts num"' . $style;
191 $output .= "<td $attributes>$posts_count</td>\n";
192 break;
193 default:
194 $output .= "<td $attributes>";
195 $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id);
196 $output .= "</td>";
197 }
198 }
199 $output .= '</tr>';
200
201 return $output;
202}
203
204/**
205 * {@internal Missing Short Description}}
206 *
207 * @since 2.7
208 *
209 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
210 *
211 * @param string $type "tag", "category" or "link-category"
212 * @return
213 */
214function inline_edit_term_row($type) {
215
216 if ( ! current_user_can( 'manage_categories' ) )
217 return;
218
219 $is_tag = $type == 'edit-tags';
220 $columns = get_column_headers($type);
221 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
222 $col_count = count($columns) - count($hidden);
223 ?>
224
225<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
226 <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
227
228 <fieldset><div class="inline-edit-col">
229 <h4><?php _e( 'Quick Edit' ); ?></h4>
230
231 <label>
232 <span class="title"><?php _e( 'Name' ); ?></span>
233 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
234 </label>
235
236 <label>
237 <span class="title"><?php _e( 'Slug' ); ?></span>
238 <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
239 </label>
240
241<?php if ( 'category' == $type ) : ?>
242
243 <label>
244 <span class="title"><?php _e( 'Parent' ); ?></span>
245 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
246 </label>
247
248<?php endif; // $type ?>
249
250 </div></fieldset>
251
252<?php
253
254 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
255
256 foreach ( $columns as $column_name => $column_display_name ) {
257 if ( isset( $core_columns[$column_name] ) )
258 continue;
259 do_action( 'quick_edit_custom_box', $column_name, $type );
260 }
261
262?>
263
264 <p class="inline-edit-save submit">
265 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
266 <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
267 <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
268 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
269 <span class="error" style="display:none;"></span>
270 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
271 <br class="clear" />
272 </p>
273 </td></tr>
274 </tbody></table></form>
275<?php
276}
277
278/**
279 * {@internal Missing Short Description}}
280 *
281 * @since unknown
282 *
283 * @param unknown_type $category
284 * @param unknown_type $name_override
285 * @return unknown
286 */
287function link_cat_row( $category, $name_override = false ) {
288 static $row_class = '';
289
290 if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
291 return false;
292 if ( is_wp_error( $category ) )
293 return $category;
294
295 $default_cat_id = (int) get_option( 'default_link_category' );
296 $name = ( $name_override ? $name_override : $category->name );
297 $edit_link = "link-category.php?action=edit&amp;cat_ID=$category->term_id";
298 if ( current_user_can( 'manage_categories' ) ) {
299 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $category->name)) . "'>$name</a><br />";
300 $actions = array();
301 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
302 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
303 if ( $default_cat_id != $category->term_id )
304 $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&amp;cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
305 $actions = apply_filters('link_cat_row_actions', $actions, $category);
306 $action_count = count($actions);
307 $i = 0;
308 $edit .= '<div class="row-actions">';
309 foreach ( $actions as $action => $link ) {
310 ++$i;
311 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
312 $edit .= "<span class='$action'>$link$sep</span>";
313 }
314 $edit .= '</div>';
315 } else {
316 $edit = $name;
317 }
318
319 $row_class = 'alternate' == $row_class ? '' : 'alternate';
320 $qe_data = get_term_to_edit($category->term_id, 'link_category');
321
322 $category->count = number_format_i18n( $category->count );
323 $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
324 $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
325 $columns = get_column_headers('edit-link-categories');
326 $hidden = get_hidden_columns('edit-link-categories');
327 foreach ( $columns as $column_name => $column_display_name ) {
328 $class = "class=\"$column_name column-$column_name\"";
329
330 $style = '';
331 if ( in_array($column_name, $hidden) )
332 $style = ' style="display:none;"';
333
334 $attributes = "$class$style";
335
336 switch ($column_name) {
337 case 'cb':
338 $output .= "<th scope='row' class='check-column'>";
339 if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
340 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
341 } else {
342 $output .= "&nbsp;";
343 }
344 $output .= "</th>";
345 break;
346 case 'name':
347 $output .= "<td $attributes>$edit";
348 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
349 $output .= '<div class="name">' . $qe_data->name . '</div>';
350 $output .= '<div class="slug">' . $qe_data->slug . '</div>';
351 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
352 break;
353 case 'description':
354 $output .= "<td $attributes>$category->description</td>";
355 break;
356 case 'slug':
357 $output .= "<td $attributes>$category->slug</td>";
358 break;
359 case 'links':
360 $attributes = 'class="links column-links num"' . $style;
361 $output .= "<td $attributes>$count</td>";
362 break;
363 default:
364 $output .= "<td $attributes>";
365 $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);
366 $output .= "</td>";
367 }
368 }
369 $output .= '</tr>';
370
371 return $output;
372}
373
374/**
375 * Outputs the html checked attribute.
376 *
377 * Compares the first two arguments and if identical marks as checked
378 *
379 * @since 2.8
380 *
381 * @param any $checked One of the values to compare
382 * @param any $current (true) The other value to compare if not just true
383 * @param bool $echo Whether or not to echo or just return the string
384 */
385function checked( $checked, $current = true, $echo = true) {
386 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
387}
388
389/**
390 * Outputs the html selected attribute.
391 *
392 * Compares the first two arguments and if identical marks as selected
393 *
394 * @since 2.8
395 *
396 * @param any selected One of the values to compare
397 * @param any $current (true) The other value to compare if not just true
398 * @param bool $echo Whether or not to echo or just return the string
399 */
400function selected( $selected, $current = true, $echo = true) {
401 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
402}
403
404/**
405 * Private helper function for checked and selected.
406 *
407 * Compares the first two arguments and if identical marks as $type
408 *
409 * @since 2.8
410 * @access private
411 *
412 * @param any $helper One of the values to compare
413 * @param any $current (true) The other value to compare if not just true
414 * @param bool $echo Whether or not to echo or just return the string
415 * @param string $type The type of checked|selected we are doing.
416 */
417function __checked_selected_helper( $helper, $current, $echo, $type) {
418 if ( $helper == $current)
419 $result = " $type='$type'";
420 else
421 $result = '';
422
423 if ($echo)
424 echo $result;
425
426 return $result;
427}
428
429//
430// Category Checklists
431//
432
433/**
434 * {@internal Missing Short Description}}
435 *
436 * @since unknown
437 * @deprecated Use {@link wp_link_category_checklist()}
438 * @see wp_link_category_checklist()
439 *
440 * @param unknown_type $default
441 * @param unknown_type $parent
442 * @param unknown_type $popular_ids
443 */
444function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
445 global $post_ID;
446 wp_category_checklist($post_ID);
447}
448
449/**
450 * {@internal Missing Short Description}}
451 *
452 * @since unknown
453 */
454class Walker_Category_Checklist extends Walker {
455 var $tree_type = 'category';
456 var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
457
458 function start_lvl(&$output, $depth, $args) {
459 $indent = str_repeat("\t", $depth);
460 $output .= "$indent<ul class='children'>\n";
461 }
462
463 function end_lvl(&$output, $depth, $args) {
464 $indent = str_repeat("\t", $depth);
465 $output .= "$indent</ul>\n";
466 }
467
468 function start_el(&$output, $category, $depth, $args) {
469 extract($args);
470
471 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
472 $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
473 }
474
475 function end_el(&$output, $category, $depth, $args) {
476 $output .= "</li>\n";
477 }
478}
479
480/**
481 * {@internal Missing Short Description}}
482 *
483 * @since unknown
484 *
485 * @param unknown_type $post_id
486 * @param unknown_type $descendants_and_self
487 * @param unknown_type $selected_cats
488 * @param unknown_type $popular_cats
489 */
490function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {
491 if ( empty($walker) || !is_a($walker, 'Walker') )
492 $walker = new Walker_Category_Checklist;
493
494 $descendants_and_self = (int) $descendants_and_self;
495
496 $args = array();
497
498 if ( is_array( $selected_cats ) )
499 $args['selected_cats'] = $selected_cats;
500 elseif ( $post_id )
501 $args['selected_cats'] = wp_get_post_categories($post_id);
502 else
503 $args['selected_cats'] = array();
504
505 if ( is_array( $popular_cats ) )
506 $args['popular_cats'] = $popular_cats;
507 else
508 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
509
510 if ( $descendants_and_self ) {
511 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
512 $self = get_category( $descendants_and_self );
513 array_unshift( $categories, $self );
514 } else {
515 $categories = get_categories('get=all');
516 }
517
518 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
519 $checked_categories = array();
520 $keys = array_keys( $categories );
521
522 foreach( $keys as $k ) {
523 if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
524 $checked_categories[] = $categories[$k];
525 unset( $categories[$k] );
526 }
527 }
528
529 // Put checked cats on top
530 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
531 // Then the rest of them
532 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
533}
534
535/**
536 * {@internal Missing Short Description}}
537 *
538 * @since unknown
539 *
540 * @param unknown_type $taxonomy
541 * @param unknown_type $default
542 * @param unknown_type $number
543 * @param unknown_type $echo
544 * @return unknown
545 */
546function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
547 global $post_ID;
548 if ( $post_ID )
549 $checked_categories = wp_get_post_categories($post_ID);
550 else
551 $checked_categories = array();
552 $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
553
554 $popular_ids = array();
555 foreach ( (array) $categories as $category ) {
556 $popular_ids[] = $category->term_id;
557 if ( !$echo ) // hack for AJAX use
558 continue;
559 $id = "popular-category-$category->term_id";
560 ?>
561
562 <li id="<?php echo $id; ?>" class="popular-category">
563 <label class="selectit">
564 <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
565 <?php echo esc_html( apply_filters( 'the_category', $category->name ) ); ?>
566 </label>
567 </li>
568
569 <?php
570 }
571 return $popular_ids;
572}
573
574/**
575 * {@internal Missing Short Description}}
576 *
577 * @since unknown
578 * @deprecated Use {@link wp_link_category_checklist()}
579 * @see wp_link_category_checklist()
580 *
581 * @param unknown_type $default
582 */
583function dropdown_link_categories( $default = 0 ) {
584 global $link_id;
585
586 wp_link_category_checklist($link_id);
587}
588
589/**
590 * {@internal Missing Short Description}}
591 *
592 * @since unknown
593 *
594 * @param unknown_type $link_id
595 */
596function wp_link_category_checklist( $link_id = 0 ) {
597 $default = 1;
598
599 if ( $link_id ) {
600 $checked_categories = wp_get_link_cats($link_id);
601
602 if ( count( $checked_categories ) == 0 ) {
603 // No selected categories, strange
604 $checked_categories[] = $default;
605 }
606 } else {
607 $checked_categories[] = $default;
608 }
609
610 $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
611
612 if ( empty($categories) )
613 return;
614
615 foreach ( $categories as $category ) {
616 $cat_id = $category->term_id;
617 $name = esc_html( apply_filters('the_category', $category->name));
618 $checked = in_array( $cat_id, $checked_categories );
619 echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
620 }
621}
622
623// Tag stuff
624
625// Returns a single tag row (see tag_rows below)
626// Note: this is also used in admin-ajax.php!
627/**
628 * {@internal Missing Short Description}}
629 *
630 * @since unknown
631 *
632 * @param unknown_type $tag
633 * @param unknown_type $class
634 * @return unknown
635 */
636function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
637 $count = number_format_i18n( $tag->count );
638 $tagsel = ($taxonomy == 'post_tag' ? 'tag' : $taxonomy);
639 $count = ( $count > 0 ) ? "<a href='edit.php?$tagsel=$tag->slug'>$count</a>" : $count;
640
641 $name = apply_filters( 'term_name', $tag->name );
642 $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
643 $edit_link = "edit-tags.php?action=edit&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id";
644 $out = '';
645 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
646 $columns = get_column_headers('edit-tags');
647 $hidden = get_hidden_columns('edit-tags');
648 foreach ( $columns as $column_name => $column_display_name ) {
649 $class = "class=\"$column_name column-$column_name\"";
650
651 $style = '';
652 if ( in_array($column_name, $hidden) )
653 $style = ' style="display:none;"';
654
655 $attributes = "$class$style";
656
657 switch ($column_name) {
658 case 'cb':
659 $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
660 break;
661 case 'name':
662 $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $name)) . '">' . $name . '</a></strong><br />';
663 $actions = array();
664 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
665 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
666 $actions['delete'] = "<a class='delete:the-list:tag-$tag->term_id submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
667 $actions = apply_filters('tag_row_actions', $actions, $tag);
668 $action_count = count($actions);
669 $i = 0;
670 $out .= '<div class="row-actions">';
671 foreach ( $actions as $action => $link ) {
672 ++$i;
673 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
674 $out .= "<span class='$action'>$link$sep</span>";
675 }
676 $out .= '</div>';
677 $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
678 $out .= '<div class="name">' . $qe_data->name . '</div>';
679 $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
680 break;
681 case 'description':
682 $out .= "<td $attributes>$tag->description</td>";
683 break;
684 case 'slug':
685 $out .= "<td $attributes>$tag->slug</td>";
686 break;
687 case 'posts':
688 $attributes = 'class="posts column-posts num"' . $style;
689 $out .= "<td $attributes>$count</td>";
690 break;
691 default:
692 $out .= "<td $attributes>";
693 $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
694 $out .= "</td>";
695 }
696 }
697
698 $out .= '</tr>';
699
700 return $out;
701}
702
703// Outputs appropriate rows for the Nth page of the Tag Management screen,
704// assuming M tags displayed at a time on the page
705// Returns the number of tags displayed
706/**
707 * {@internal Missing Short Description}}
708 *
709 * @since unknown
710 *
711 * @param unknown_type $page
712 * @param unknown_type $pagesize
713 * @param unknown_type $searchterms
714 * @return unknown
715 */
716function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
717
718 // Get a page worth of tags
719 $start = ($page - 1) * $pagesize;
720
721 $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
722
723 if ( !empty( $searchterms ) ) {
724 $args['search'] = $searchterms;
725 }
726
727 $tags = get_terms( $taxonomy, $args );
728
729 // convert it to table rows
730 $out = '';
731 $count = 0;
732 foreach( $tags as $tag )
733 $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy );
734
735 // filter and send to screen
736 echo $out;
737 return $count;
738}
739
740// define the columns to display, the syntax is 'internal name' => 'display name'
741/**
742 * {@internal Missing Short Description}}
743 *
744 * @since unknown
745 *
746 * @return unknown
747 */
748function wp_manage_posts_columns() {
749 $posts_columns = array();
750 $posts_columns['cb'] = '<input type="checkbox" />';
751 /* translators: manage posts column name */
752 $posts_columns['title'] = _x('Post', 'column name');
753 $posts_columns['author'] = __('Author');
754 $posts_columns['categories'] = __('Categories');
755 $posts_columns['tags'] = __('Tags');
756 if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
757 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
758 $posts_columns['date'] = __('Date');
759 $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
760
761 return $posts_columns;
762}
763
764// define the columns to display, the syntax is 'internal name' => 'display name'
765/**
766 * {@internal Missing Short Description}}
767 *
768 * @since unknown
769 *
770 * @return unknown
771 */
772function wp_manage_media_columns() {
773 $posts_columns = array();
774 $posts_columns['cb'] = '<input type="checkbox" />';
775 $posts_columns['icon'] = '';
776 /* translators: column name */
777 $posts_columns['media'] = _x('File', 'column name');
778 $posts_columns['author'] = __('Author');
779 //$posts_columns['tags'] = _x('Tags', 'column name');
780 /* translators: column name */
781 $posts_columns['parent'] = _x('Attached to', 'column name');
782 $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
783 //$posts_columns['comments'] = __('Comments');
784 /* translators: column name */
785 $posts_columns['date'] = _x('Date', 'column name');
786 $posts_columns = apply_filters('manage_media_columns', $posts_columns);
787
788 return $posts_columns;
789}
790
791/**
792 * {@internal Missing Short Description}}
793 *
794 * @since unknown
795 *
796 * @return unknown
797 */
798function wp_manage_pages_columns() {
799 $posts_columns = array();
800 $posts_columns['cb'] = '<input type="checkbox" />';
801 $posts_columns['title'] = __('Title');
802 $posts_columns['author'] = __('Author');
803 $post_status = 'all';
804 if ( !empty($_GET['post_status']) )
805 $post_status = $_GET['post_status'];
806 if ( !in_array($post_status, array('pending', 'draft', 'future')) )
807 $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
808 $posts_columns['date'] = __('Date');
809 $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
810
811 return $posts_columns;
812}
813
814/**
815 * {@internal Missing Short Description}}
816 *
817 * @since unknown
818 *
819 * @param unknown_type $page
820 * @return unknown
821 */
822function get_column_headers($page) {
823 global $_wp_column_headers;
824
825 if ( !isset($_wp_column_headers) )
826 $_wp_column_headers = array();
827
828 // Store in static to avoid running filters on each call
829 if ( isset($_wp_column_headers[$page]) )
830 return $_wp_column_headers[$page];
831
832 switch ($page) {
833 case 'edit':
834 $_wp_column_headers[$page] = wp_manage_posts_columns();
835 break;
836 case 'edit-pages':
837 $_wp_column_headers[$page] = wp_manage_pages_columns();
838 break;
839 case 'edit-comments':
840 $_wp_column_headers[$page] = array(
841 'cb' => '<input type="checkbox" />',
842 'author' => __('Author'),
843 /* translators: column name */
844 'comment' => _x('Comment', 'column name'),
845 //'date' => __('Submitted'),
846 'response' => __('In Response To')
847 );
848
849 break;
850 case 'link-manager':
851 $_wp_column_headers[$page] = array(
852 'cb' => '<input type="checkbox" />',
853 'name' => __('Name'),
854 'url' => __('URL'),
855 'categories' => __('Categories'),
856 'rel' => __('Relationship'),
857 'visible' => __('Visible'),
858 'rating' => __('Rating')
859 );
860
861 break;
862 case 'upload':
863 $_wp_column_headers[$page] = wp_manage_media_columns();
864 break;
865 case 'categories':
866 $_wp_column_headers[$page] = array(
867 'cb' => '<input type="checkbox" />',
868 'name' => __('Name'),
869 'description' => __('Description'),
870 'slug' => __('Slug'),
871 'posts' => __('Posts')
872 );
873
874 break;
875 case 'edit-link-categories':
876 $_wp_column_headers[$page] = array(
877 'cb' => '<input type="checkbox" />',
878 'name' => __('Name'),
879 'description' => __('Description'),
880 'slug' => __('Slug'),
881 'links' => __('Links')
882 );
883
884 break;
885 case 'edit-tags':
886 $_wp_column_headers[$page] = array(
887 'cb' => '<input type="checkbox" />',
888 'name' => __('Name'),
889 'description' => __('Description'),
890 'slug' => __('Slug'),
891 'posts' => __('Posts')
892 );
893
894 break;
895 case 'users':
896 $_wp_column_headers[$page] = array(
897 'cb' => '<input type="checkbox" />',
898 'username' => __('Username'),
899 'name' => __('Name'),
900 'email' => __('E-mail'),
901 'role' => __('Role'),
902 'posts' => __('Posts'),
903 'comments' => __('Comments')
904 );
905 break;
906 default :
907 $_wp_column_headers[$page] = array();
908 }
909
910 $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
911 return $_wp_column_headers[$page];
912}
913
914/**
915 * {@internal Missing Short Description}}
916 *
917 * @since unknown
918 *
919 * @param unknown_type $type
920 * @param unknown_type $id
921 */
922function print_column_headers( $type, $id = true ) {
923 $type = str_replace('.php', '', $type);
924 $columns = get_column_headers( $type );
925 $hidden = get_hidden_columns($type);
926 $styles = array();
927// $styles['tag']['posts'] = 'width: 90px;';
928// $styles['link-category']['links'] = 'width: 90px;';
929// $styles['category']['posts'] = 'width: 90px;';
930// $styles['link']['visible'] = 'text-align: center;';
931
932 foreach ( $columns as $column_key => $column_display_name ) {
933 $class = ' class="manage-column';
934
935 $class .= " column-$column_key";
936
937 if ( 'cb' == $column_key )
938 $class .= ' check-column';
939 elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
940 $class .= ' num';
941
942 $class .= '"';
943
944 $style = '';
945 if ( in_array($column_key, $hidden) )
946 $style = 'display:none;';
947
948 if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
949 $style .= ' ' . $styles[$type][$column_key];
950 $style = ' style="' . $style . '"';
951?>
952 <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
953<?php }
954}
955
956/**
957 * Register column headers for a particular screen. The header names will be listed in the Screen Options.
958 *
959 * @since 2.7.0
960 *
961 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
962 * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
963 * @see get_column_headers(), print_column_headers(), get_hidden_columns()
964 */
965function register_column_headers($screen, $columns) {
966 global $_wp_column_headers;
967
968 if ( !isset($_wp_column_headers) )
969 $_wp_column_headers = array();
970
971 $_wp_column_headers[$screen] = $columns;
972}
973
974/**
975 * {@internal Missing Short Description}}
976 *
977 * @since unknown
978 *
979 * @param unknown_type $page
980 */
981function get_hidden_columns($page) {
982 $page = str_replace('.php', '', $page);
983 return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
984}
985
986/**
987 * {@internal Missing Short Description}}
988 *
989 * Outputs the quick edit and bulk edit table rows for posts and pages
990 *
991 * @since 2.7
992 *
993 * @param string $type 'post' or 'page'
994 */
995function inline_edit_row( $type ) {
996 global $current_user, $mode;
997
998 $is_page = 'page' == $type;
999 if ( $is_page ) {
1000 $screen = 'edit-pages';
1001 $post = get_default_page_to_edit();
1002 } else {
1003 $screen = 'edit';
1004 $post = get_default_post_to_edit();
1005 }
1006
1007 $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
1008 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
1009 $col_count = count($columns) - count($hidden);
1010 $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
1011 $can_publish = current_user_can("publish_{$type}s");
1012 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
1013
1014?>
1015
1016<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
1017 <?php
1018 $bulk = 0;
1019 while ( $bulk < 2 ) { ?>
1020
1021 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
1022 echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
1023 ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
1024
1025 <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
1026 <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
1027
1028
1029<?php if ( $bulk ) : ?>
1030 <div id="bulk-title-div">
1031 <div id="bulk-titles"></div>
1032 </div>
1033
1034<?php else : // $bulk ?>
1035
1036 <label>
1037 <span class="title"><?php _e( 'Title' ); ?></span>
1038 <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
1039 </label>
1040
1041<?php endif; // $bulk ?>
1042
1043
1044<?php if ( !$bulk ) : ?>
1045
1046 <label>
1047 <span class="title"><?php _e( 'Slug' ); ?></span>
1048 <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
1049 </label>
1050
1051 <label><span class="title"><?php _e( 'Date' ); ?></span></label>
1052 <div class="inline-edit-date">
1053 <?php touch_time(1, 1, 4, 1); ?>
1054 </div>
1055 <br class="clear" />
1056
1057<?php endif; // $bulk
1058
1059 ob_start();
1060 $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
1061 if ( $authors && count( $authors ) > 1 ) :
1062 $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
1063 if ( $bulk )
1064 $users_opt['show_option_none'] = __('- No Change -');
1065?>
1066 <label>
1067 <span class="title"><?php _e( 'Author' ); ?></span>
1068 <?php wp_dropdown_users( $users_opt ); ?>
1069 </label>
1070
1071<?php
1072 endif; // authors
1073 $authors_dropdown = ob_get_clean();
1074?>
1075
1076<?php if ( !$bulk ) : echo $authors_dropdown; ?>
1077
1078 <div class="inline-edit-group">
1079 <label class="alignleft">
1080 <span class="title"><?php _e( 'Password' ); ?></span>
1081 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
1082 </label>
1083
1084 <em style="margin:5px 10px 0 0" class="alignleft">
1085 <?php
1086 /* translators: Between password field and private checkbox on post quick edit interface */
1087 echo __( '&ndash;OR&ndash;' );
1088 ?>
1089 </em>
1090 <label class="alignleft inline-edit-private">
1091 <input type="checkbox" name="keep_private" value="private" />
1092 <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
1093 </label>
1094 </div>
1095
1096<?php endif; ?>
1097
1098 </div></fieldset>
1099
1100<?php if ( !$is_page && !$bulk ) : ?>
1101
1102 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
1103 <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
1104 <span class="catshow"><?php _e('[more]'); ?></span>
1105 <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
1106 </span>
1107 <ul class="cat-checklist">
1108 <?php wp_category_checklist(); ?>
1109 </ul>
1110 </div></fieldset>
1111
1112<?php endif; // !$is_page && !$bulk ?>
1113
1114 <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
1115
1116<?php
1117 if ( $bulk )
1118 echo $authors_dropdown;
1119?>
1120
1121<?php if ( $is_page ) : ?>
1122
1123 <label>
1124 <span class="title"><?php _e( 'Parent' ); ?></span>
1125<?php
1126 $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
1127 if ( $bulk )
1128 $dropdown_args['show_option_no_change'] = __('- No Change -');
1129 $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
1130 wp_dropdown_pages($dropdown_args);
1131?>
1132 </label>
1133
1134<?php if ( !$bulk ) : ?>
1135
1136 <label>
1137 <span class="title"><?php _e( 'Order' ); ?></span>
1138 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
1139 </label>
1140
1141<?php endif; // !$bulk ?>
1142
1143 <label>
1144 <span class="title"><?php _e( 'Template' ); ?></span>
1145 <select name="page_template">
1146<?php if ( $bulk ) : ?>
1147 <option value="-1"><?php _e('- No Change -'); ?></option>
1148<?php endif; // $bulk ?>
1149 <option value="default"><?php _e( 'Default Template' ); ?></option>
1150 <?php page_template_dropdown() ?>
1151 </select>
1152 </label>
1153
1154<?php elseif ( !$bulk ) : // $is_page ?>
1155
1156 <label class="inline-edit-tags">
1157 <span class="title"><?php _e( 'Tags' ); ?></span>
1158 <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
1159 </label>
1160
1161<?php endif; // $is_page ?>
1162
1163<?php if ( $bulk ) : ?>
1164
1165 <div class="inline-edit-group">
1166 <label class="alignleft">
1167 <span class="title"><?php _e( 'Comments' ); ?></span>
1168 <select name="comment_status">
1169 <option value=""><?php _e('- No Change -'); ?></option>
1170 <option value="open"><?php _e('Allow'); ?></option>
1171 <option value="closed"><?php _e('Do not allow'); ?></option>
1172 </select>
1173 </label>
1174
1175 <label class="alignright">
1176 <span class="title"><?php _e( 'Pings' ); ?></span>
1177 <select name="ping_status">
1178 <option value=""><?php _e('- No Change -'); ?></option>
1179 <option value="open"><?php _e('Allow'); ?></option>
1180 <option value="closed"><?php _e('Do not allow'); ?></option>
1181 </select>
1182 </label>
1183 </div>
1184
1185<?php else : // $bulk ?>
1186
1187 <div class="inline-edit-group">
1188 <label class="alignleft">
1189 <input type="checkbox" name="comment_status" value="open" />
1190 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
1191 </label>
1192
1193 <label class="alignleft">
1194 <input type="checkbox" name="ping_status" value="open" />
1195 <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
1196 </label>
1197 </div>
1198
1199<?php endif; // $bulk ?>
1200
1201
1202 <div class="inline-edit-group">
1203 <label class="inline-edit-status alignleft">
1204 <span class="title"><?php _e( 'Status' ); ?></span>
1205 <select name="_status">
1206<?php if ( $bulk ) : ?>
1207 <option value="-1"><?php _e('- No Change -'); ?></option>
1208<?php endif; // $bulk ?>
1209 <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
1210 <option value="publish"><?php _e( 'Published' ); ?></option>
1211 <option value="future"><?php _e( 'Scheduled' ); ?></option>
1212<?php if ( $bulk ) : ?>
1213 <option value="private"><?php _e('Private') ?></option>
1214<?php endif; // $bulk ?>
1215 <?php endif; ?>
1216 <option value="pending"><?php _e( 'Pending Review' ); ?></option>
1217 <option value="draft"><?php _e( 'Draft' ); ?></option>
1218 </select>
1219 </label>
1220
1221<?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
1222
1223<?php if ( $bulk ) : ?>
1224
1225 <label class="alignright">
1226 <span class="title"><?php _e( 'Sticky' ); ?></span>
1227 <select name="sticky">
1228 <option value="-1"><?php _e( '- No Change -' ); ?></option>
1229 <option value="sticky"><?php _e( 'Sticky' ); ?></option>
1230 <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
1231 </select>
1232 </label>
1233
1234<?php else : // $bulk ?>
1235
1236 <label class="alignleft">
1237 <input type="checkbox" name="sticky" value="sticky" />
1238 <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
1239 </label>
1240
1241<?php endif; // $bulk ?>
1242
1243<?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
1244
1245 </div>
1246
1247 </div></fieldset>
1248
1249<?php
1250 foreach ( $columns as $column_name => $column_display_name ) {
1251 if ( isset( $core_columns[$column_name] ) )
1252 continue;
1253 do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
1254 }
1255?>
1256 <p class="submit inline-edit-save">
1257 <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
1258 <?php if ( ! $bulk ) {
1259 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
1260 $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
1261 ?>
1262 <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
1263 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
1264 <?php } else {
1265 $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
1266 ?>
1267 <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
1268 <?php } ?>
1269 <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
1270 <br class="clear" />
1271 </p>
1272 </td></tr>
1273<?php
1274 $bulk++;
1275 } ?>
1276 </tbody></table></form>
1277<?php
1278}
1279
1280// adds hidden fields with the data for use in the inline editor for posts and pages
1281/**
1282 * {@internal Missing Short Description}}
1283 *
1284 * @since unknown
1285 *
1286 * @param unknown_type $post
1287 */
1288function get_inline_data($post) {
1289
1290 if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
1291 return;
1292
1293 $title = esc_attr($post->post_title);
1294
1295 echo '
1296<div class="hidden" id="inline_' . $post->ID . '">
1297 <div class="post_title">' . $title . '</div>
1298 <div class="post_name">' . $post->post_name . '</div>
1299 <div class="post_author">' . $post->post_author . '</div>
1300 <div class="comment_status">' . $post->comment_status . '</div>
1301 <div class="ping_status">' . $post->ping_status . '</div>
1302 <div class="_status">' . $post->post_status . '</div>
1303 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
1304 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
1305 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
1306 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
1307 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
1308 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
1309 <div class="post_password">' . esc_html( $post->post_password ) . '</div>';
1310
1311 if( $post->post_type == 'page' )
1312 echo '
1313 <div class="post_parent">' . $post->post_parent . '</div>
1314 <div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>
1315 <div class="menu_order">' . $post->menu_order . '</div>';
1316
1317 if( $post->post_type == 'post' )
1318 echo '
1319 <div class="tags_input">' . esc_html( str_replace( ',', ', ', get_tags_to_edit($post->ID) ) ) . '</div>
1320 <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
1321 <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
1322
1323 echo '</div>';
1324}
1325
1326/**
1327 * {@internal Missing Short Description}}
1328 *
1329 * @since unknown
1330 *
1331 * @param unknown_type $posts
1332 */
1333function post_rows( $posts = array() ) {
1334 global $wp_query, $post, $mode;
1335
1336 add_filter('the_title','esc_html');
1337
1338 // Create array of post IDs.
1339 $post_ids = array();
1340
1341 if ( empty($posts) )
1342 $posts = &$wp_query->posts;
1343
1344 foreach ( $posts as $a_post )
1345 $post_ids[] = $a_post->ID;
1346
1347 $comment_pending_count = get_pending_comments_num($post_ids);
1348 if ( empty($comment_pending_count) )
1349 $comment_pending_count = array();
1350
1351 foreach ( $posts as $post ) {
1352 if ( empty($comment_pending_count[$post->ID]) )
1353 $comment_pending_count[$post->ID] = 0;
1354
1355 _post_row($post, $comment_pending_count[$post->ID], $mode);
1356 }
1357}
1358
1359/**
1360 * {@internal Missing Short Description}}
1361 *
1362 * @since unknown
1363 *
1364 * @param unknown_type $a_post
1365 * @param unknown_type $pending_comments
1366 * @param unknown_type $mode
1367 */
1368function _post_row($a_post, $pending_comments, $mode) {
1369 global $post;
1370 static $rowclass;
1371
1372 $global_post = $post;
1373 $post = $a_post;
1374 setup_postdata($post);
1375
1376 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1377 global $current_user;
1378 $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
1379 $edit_link = get_edit_post_link( $post->ID );
1380 $title = _draft_or_post_title();
1381?>
1382 <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
1383<?php
1384 $posts_columns = get_column_headers('edit');
1385 $hidden = get_hidden_columns('edit');
1386 foreach ( $posts_columns as $column_name=>$column_display_name ) {
1387 $class = "class=\"$column_name column-$column_name\"";
1388
1389 $style = '';
1390 if ( in_array($column_name, $hidden) )
1391 $style = ' style="display:none;"';
1392
1393 $attributes = "$class$style";
1394
1395 switch ($column_name) {
1396
1397 case 'cb':
1398 ?>
1399 <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>
1400 <?php
1401 break;
1402
1403 case 'date':
1404 if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
1405 $t_time = $h_time = __('Unpublished');
1406 $time_diff = 0;
1407 } else {
1408 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1409 $m_time = $post->post_date;
1410 $time = get_post_time('G', true, $post);
1411
1412 $time_diff = time() - $time;
1413
1414 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1415 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1416 else
1417 $h_time = mysql2date(__('Y/m/d'), $m_time);
1418 }
1419
1420 echo '<td ' . $attributes . '>';
1421 if ( 'excerpt' == $mode )
1422 echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
1423 else
1424 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
1425 echo '<br />';
1426 if ( 'publish' == $post->post_status ) {
1427 _e('Published');
1428 } elseif ( 'future' == $post->post_status ) {
1429 if ( $time_diff > 0 )
1430 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1431 else
1432 _e('Scheduled');
1433 } else {
1434 _e('Last Modified');
1435 }
1436 echo '</td>';
1437 break;
1438
1439 case 'title':
1440 $attributes = 'class="post-title column-title"' . $style;
1441 ?>
1442 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
1443 <?php
1444 if ( 'excerpt' == $mode )
1445 the_excerpt();
1446
1447 $actions = array();
1448 if ( current_user_can('edit_post', $post->ID) ) {
1449 $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
1450 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
1451 }
1452 if ( current_user_can('delete_post', $post->ID) ) {
1453 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1454 }
1455 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1456 if ( current_user_can('edit_post', $post->ID) )
1457 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1458 } else {
1459 $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1460 }
1461 $actions = apply_filters('post_row_actions', $actions, $post);
1462 $action_count = count($actions);
1463 $i = 0;
1464 echo '<div class="row-actions">';
1465 foreach ( $actions as $action => $link ) {
1466 ++$i;
1467 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1468 echo "<span class='$action'>$link$sep</span>";
1469 }
1470 echo '</div>';
1471
1472 get_inline_data($post);
1473 ?>
1474 </td>
1475 <?php
1476 break;
1477
1478 case 'categories':
1479 ?>
1480 <td <?php echo $attributes ?>><?php
1481 $categories = get_the_category();
1482 if ( !empty( $categories ) ) {
1483 $out = array();
1484 foreach ( $categories as $c )
1485 $out[] = "<a href='edit.php?category_name=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
1486 echo join( ', ', $out );
1487 } else {
1488 _e('Uncategorized');
1489 }
1490 ?></td>
1491 <?php
1492 break;
1493
1494 case 'tags':
1495 ?>
1496 <td <?php echo $attributes ?>><?php
1497 $tags = get_the_tags($post->ID);
1498 if ( !empty( $tags ) ) {
1499 $out = array();
1500 foreach ( $tags as $c )
1501 $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
1502 echo join( ', ', $out );
1503 } else {
1504 _e('No Tags');
1505 }
1506 ?></td>
1507 <?php
1508 break;
1509
1510 case 'comments':
1511 ?>
1512 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1513 <?php
1514 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
1515 if ( $pending_comments )
1516 echo '<strong>';
1517 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
1518 if ( $pending_comments )
1519 echo '</strong>';
1520 ?>
1521 </div></td>
1522 <?php
1523 break;
1524
1525 case 'author':
1526 ?>
1527 <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1528 <?php
1529 break;
1530
1531 case 'control_view':
1532 ?>
1533 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
1534 <?php
1535 break;
1536
1537 case 'control_edit':
1538 ?>
1539 <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
1540 <?php
1541 break;
1542
1543 case 'control_delete':
1544 ?>
1545 <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
1546 <?php
1547 break;
1548
1549 default:
1550 ?>
1551 <td <?php echo $attributes ?>><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?></td>
1552 <?php
1553 break;
1554 }
1555}
1556?>
1557 </tr>
1558<?php
1559 $post = $global_post;
1560}
1561
1562/*
1563 * display one row if the page doesn't have any children
1564 * otherwise, display the row and its children in subsequent rows
1565 */
1566/**
1567 * {@internal Missing Short Description}}
1568 *
1569 * @since unknown
1570 *
1571 * @param unknown_type $page
1572 * @param unknown_type $level
1573 */
1574function display_page_row( $page, $level = 0 ) {
1575 global $post;
1576 static $rowclass;
1577
1578 $post = $page;
1579 setup_postdata($page);
1580
1581 if ( 0 == $level && (int)$page->post_parent > 0 ) {
1582 //sent level 0 by accident, by default, or because we don't know the actual level
1583 $find_main_page = (int)$page->post_parent;
1584 while ( $find_main_page > 0 ) {
1585 $parent = get_page($find_main_page);
1586
1587 if ( is_null($parent) )
1588 break;
1589
1590 $level++;
1591 $find_main_page = (int)$parent->post_parent;
1592
1593 if ( !isset($parent_name) )
1594 $parent_name = $parent->post_title;
1595 }
1596 }
1597
1598 $page->post_title = esc_html( $page->post_title );
1599 $pad = str_repeat( '&#8212; ', $level );
1600 $id = (int) $page->ID;
1601 $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
1602 $posts_columns = get_column_headers('edit-pages');
1603 $hidden = get_hidden_columns('edit-pages');
1604 $title = _draft_or_post_title();
1605?>
1606<tr id="page-<?php echo $id; ?>" class="<?php echo $rowclass; ?> iedit">
1607<?php
1608
1609foreach ($posts_columns as $column_name=>$column_display_name) {
1610 $class = "class=\"$column_name column-$column_name\"";
1611
1612 $style = '';
1613 if ( in_array($column_name, $hidden) )
1614 $style = ' style="display:none;"';
1615
1616 $attributes = "$class$style";
1617
1618 switch ($column_name) {
1619
1620 case 'cb':
1621 ?>
1622 <th scope="row" class="check-column"><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /></th>
1623 <?php
1624 break;
1625 case 'date':
1626 if ( '0000-00-00 00:00:00' == $page->post_date && 'date' == $column_name ) {
1627 $t_time = $h_time = __('Unpublished');
1628 $time_diff = 0;
1629 } else {
1630 $t_time = get_the_time(__('Y/m/d g:i:s A'));
1631 $m_time = $page->post_date;
1632 $time = get_post_time('G', true);
1633
1634 $time_diff = time() - $time;
1635
1636 if ( $time_diff > 0 && $time_diff < 24*60*60 )
1637 $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
1638 else
1639 $h_time = mysql2date(__('Y/m/d'), $m_time);
1640 }
1641 echo '<td ' . $attributes . '>';
1642 echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $page, $column_name, '') . '</abbr>';
1643 echo '<br />';
1644 if ( 'publish' == $page->post_status ) {
1645 _e('Published');
1646 } elseif ( 'future' == $page->post_status ) {
1647 if ( $time_diff > 0 )
1648 echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
1649 else
1650 _e('Scheduled');
1651 } else {
1652 _e('Last Modified');
1653 }
1654 echo '</td>';
1655 break;
1656 case 'title':
1657 $attributes = 'class="post-title page-title column-title"' . $style;
1658 $edit_link = get_edit_post_link( $page->ID );
1659 ?>
1660 <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_page', $page->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: ') . esc_html($parent_name) : ''; ?></strong>
1661 <?php
1662 $actions = array();
1663 if ( current_user_can('edit_page', $page->ID) ) {
1664 $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
1665 $actions['inline'] = '<a href="#" class="editinline">' . __('Quick&nbsp;Edit') . '</a>';
1666 }
1667 if ( current_user_can('delete_page', $page->ID) ) {
1668 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page')) . "' href='" . wp_nonce_url("page.php?action=delete&amp;post=$page->ID", 'delete-page_' . $page->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $page->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this page '%s'\n 'Cancel' to stop, 'OK' to delete."), $page->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
1669 }
1670 if ( in_array($post->post_status, array('pending', 'draft')) ) {
1671 if ( current_user_can('edit_page', $page->ID) )
1672 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
1673 } else {
1674 $actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
1675 }
1676 $actions = apply_filters('page_row_actions', $actions, $page);
1677 $action_count = count($actions);
1678
1679 $i = 0;
1680 echo '<div class="row-actions">';
1681 foreach ( $actions as $action => $link ) {
1682 ++$i;
1683 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1684 echo "<span class='$action'>$link$sep</span>";
1685 }
1686 echo '</div>';
1687
1688 get_inline_data($post);
1689 echo '</td>';
1690 break;
1691
1692 case 'comments':
1693 ?>
1694 <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
1695 <?php
1696 $left = get_pending_comments_num( $page->ID );
1697 $pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
1698 if ( $left )
1699 echo '<strong>';
1700 comments_number("<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$id' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
1701 if ( $left )
1702 echo '</strong>';
1703 ?>
1704 </div></td>
1705 <?php
1706 break;
1707
1708 case 'author':
1709 ?>
1710 <td <?php echo $attributes ?>><a href="edit-pages.php?author=<?php the_author_meta('ID'); ?>"><?php the_author() ?></a></td>
1711 <?php
1712 break;
1713
1714 default:
1715 ?>
1716 <td <?php echo $attributes ?>><?php do_action('manage_pages_custom_column', $column_name, $id); ?></td>
1717 <?php
1718 break;
1719 }
1720}
1721?>
1722
1723</tr>
1724
1725<?php
1726}
1727
1728/*
1729 * displays pages in hierarchical order with paging support
1730 */
1731/**
1732 * {@internal Missing Short Description}}
1733 *
1734 * @since unknown
1735 *
1736 * @param unknown_type $pages
1737 * @param unknown_type $pagenum
1738 * @param unknown_type $per_page
1739 * @return unknown
1740 */
1741function page_rows($pages, $pagenum = 1, $per_page = 20) {
1742 global $wpdb;
1743
1744 $level = 0;
1745
1746 if ( ! $pages ) {
1747 $pages = get_pages( array('sort_column' => 'menu_order') );
1748
1749 if ( ! $pages )
1750 return false;
1751 }
1752
1753 /*
1754 * arrange pages into two parts: top level pages and children_pages
1755 * children_pages is two dimensional array, eg.
1756 * children_pages[10][] contains all sub-pages whose parent is 10.
1757 * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
1758 * If searching, ignore hierarchy and treat everything as top level
1759 */
1760 if ( empty($_GET['s']) ) {
1761
1762 $top_level_pages = array();
1763 $children_pages = array();
1764
1765 foreach ( $pages as $page ) {
1766
1767 // catch and repair bad pages
1768 if ( $page->post_parent == $page->ID ) {
1769 $page->post_parent = 0;
1770 $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
1771 clean_page_cache( $page->ID );
1772 }
1773
1774 if ( 0 == $page->post_parent )
1775 $top_level_pages[] = $page;
1776 else
1777 $children_pages[ $page->post_parent ][] = $page;
1778 }
1779
1780 $pages = &$top_level_pages;
1781 }
1782
1783 $count = 0;
1784 $start = ($pagenum - 1) * $per_page;
1785 $end = $start + $per_page;
1786
1787 foreach ( $pages as $page ) {
1788 if ( $count >= $end )
1789 break;
1790
1791 if ( $count >= $start )
1792 echo "\t" . display_page_row( $page, $level );
1793
1794 $count++;
1795
1796 if ( isset($children_pages) )
1797 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1798 }
1799
1800 // if it is the last pagenum and there are orphaned pages, display them with paging as well
1801 if ( isset($children_pages) && $count < $end ){
1802 foreach( $children_pages as $orphans ){
1803 foreach ( $orphans as $op ) {
1804 if ( $count >= $end )
1805 break;
1806 if ( $count >= $start )
1807 echo "\t" . display_page_row( $op, 0 );
1808 $count++;
1809 }
1810 }
1811 }
1812}
1813
1814/*
1815 * Given a top level page ID, display the nested hierarchy of sub-pages
1816 * together with paging support
1817 */
1818/**
1819 * {@internal Missing Short Description}}
1820 *
1821 * @since unknown
1822 *
1823 * @param unknown_type $children_pages
1824 * @param unknown_type $count
1825 * @param unknown_type $parent
1826 * @param unknown_type $level
1827 * @param unknown_type $pagenum
1828 * @param unknown_type $per_page
1829 */
1830function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
1831
1832 if ( ! isset( $children_pages[$parent] ) )
1833 return;
1834
1835 $start = ($pagenum - 1) * $per_page;
1836 $end = $start + $per_page;
1837
1838 foreach ( $children_pages[$parent] as $page ) {
1839
1840 if ( $count >= $end )
1841 break;
1842
1843 // If the page starts in a subtree, print the parents.
1844 if ( $count == $start && $page->post_parent > 0 ) {
1845 $my_parents = array();
1846 $my_parent = $page->post_parent;
1847 while ( $my_parent) {
1848 $my_parent = get_post($my_parent);
1849 $my_parents[] = $my_parent;
1850 if ( !$my_parent->post_parent )
1851 break;
1852 $my_parent = $my_parent->post_parent;
1853 }
1854 $num_parents = count($my_parents);
1855 while( $my_parent = array_pop($my_parents) ) {
1856 echo "\t" . display_page_row( $my_parent, $level - $num_parents );
1857 $num_parents--;
1858 }
1859 }
1860
1861 if ( $count >= $start )
1862 echo "\t" . display_page_row( $page, $level );
1863
1864 $count++;
1865
1866 _page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
1867 }
1868
1869 unset( $children_pages[$parent] ); //required in order to keep track of orphans
1870}
1871
1872/**
1873 * {@internal Missing Short Description}}
1874 *
1875 * @since unknown
1876 *
1877 * @param unknown_type $user_object
1878 * @param unknown_type $style
1879 * @param unknown_type $role
1880 * @return unknown
1881 */
1882function user_row( $user_object, $style = '', $role = '' ) {
1883 global $wp_roles;
1884
1885 $current_user = wp_get_current_user();
1886
1887 if ( !( is_object( $user_object) && is_a( $user_object, 'WP_User' ) ) )
1888 $user_object = new WP_User( (int) $user_object );
1889 $email = $user_object->user_email;
1890 $url = $user_object->user_url;
1891 $short_url = str_replace( 'http://', '', $url );
1892 $short_url = str_replace( 'www.', '', $short_url );
1893 if ('/' == substr( $short_url, -1 ))
1894 $short_url = substr( $short_url, 0, -1 );
1895 if ( strlen( $short_url ) > 35 )
1896 $short_url = substr( $short_url, 0, 32 ).'...';
1897 $numposts = get_usernumposts( $user_object->ID );
1898 $numcomments = get_usernumcomments( $user_object->ID );
1899 $checkbox = '';
1900 // Check if the user for this row is editable
1901 if ( current_user_can( 'edit_user', $user_object->ID ) ) {
1902 // Set up the user editing link
1903 // TODO: make profile/user-edit determination a seperate function
1904 if ($current_user->ID == $user_object->ID) {
1905 $edit_link = 'profile.php';
1906 } else {
1907 $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( esc_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" ) );
1908 }
1909 $edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
1910
1911 // Set up the hover actions for this user
1912 $actions = array();
1913 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
1914 if ( $current_user->ID != $user_object->ID )
1915 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&amp;user=$user_object->ID", 'bulk-users') . "'>" . __('Delete') . "</a>";
1916 $actions = apply_filters('user_row_actions', $actions, $user_object);
1917 $action_count = count($actions);
1918 $i = 0;
1919 $edit .= '<div class="row-actions">';
1920 foreach ( $actions as $action => $link ) {
1921 ++$i;
1922 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
1923 $edit .= "<span class='$action'>$link$sep</span>";
1924 }
1925 $edit .= '</div>';
1926
1927 // Set up the checkbox (because the user is editable, otherwise its empty)
1928 $checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
1929
1930 } else {
1931 $edit = '<strong>' . $user_object->user_login . '</strong>';
1932 }
1933 $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
1934 $r = "<tr id='user-$user_object->ID'$style>";
1935 $columns = get_column_headers('users');
1936 $hidden = get_hidden_columns('users');
1937 $avatar = get_avatar( $user_object->ID, 32 );
1938 foreach ( $columns as $column_name => $column_display_name ) {
1939 $class = "class=\"$column_name column-$column_name\"";
1940
1941 $style = '';
1942 if ( in_array($column_name, $hidden) )
1943 $style = ' style="display:none;"';
1944
1945 $attributes = "$class$style";
1946
1947 switch ($column_name) {
1948 case 'cb':
1949 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
1950 break;
1951 case 'username':
1952 $r .= "<td $attributes>$avatar $edit</td>";
1953 break;
1954 case 'name':
1955 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
1956 break;
1957 case 'email':
1958 $r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
1959 break;
1960 case 'role':
1961 $r .= "<td $attributes>$role_name</td>";
1962 break;
1963 case 'posts':
1964 $attributes = 'class="posts column-posts num"' . $style;
1965 $r .= "<td $attributes>";
1966 if ( $numposts > 0 ) {
1967 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
1968 $r .= $numposts;
1969 $r .= '</a>';
1970 }
1971 $r .= "</td>";
1972 break;
1973 case 'comments':
1974 $attributes = 'class="num"' . $style;
1975 $r .= "<td $attributes>";
1976 if ( $numcomments > 0 ) {
1977 $r .= $numcomments;
1978 }
1979 $r .= "</td>";
1980 break;
1981 default:
1982 $r .= "<td $attributes>";
1983 $r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
1984 $r .= "</td>";
1985 }
1986 }
1987 $r .= '</tr>';
1988
1989 return $r;
1990}
1991
1992/**
1993 * {@internal Missing Short Description}}
1994 *
1995 * @since unknown
1996 *
1997 * @param unknown_type $status
1998 * @param unknown_type $s
1999 * @param unknown_type $start
2000 * @param unknown_type $num
2001 * @param unknown_type $post
2002 * @param unknown_type $type
2003 * @return unknown
2004 */
2005function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0, $type = '' ) {
2006 global $wpdb;
2007
2008 $start = abs( (int) $start );
2009 $num = (int) $num;
2010 $post = (int) $post;
2011 $count = wp_count_comments();
2012 $index = '';
2013
2014 if ( 'moderated' == $status ) {
2015 $approved = "comment_approved = '0'";
2016 $total = $count->moderated;
2017 } elseif ( 'approved' == $status ) {
2018 $approved = "comment_approved = '1'";
2019 $total = $count->approved;
2020 } elseif ( 'spam' == $status ) {
2021 $approved = "comment_approved = 'spam'";
2022 $total = $count->spam;
2023 } else {
2024 $approved = "( comment_approved = '0' OR comment_approved = '1' )";
2025 $total = $count->moderated + $count->approved;
2026 $index = 'USE INDEX (comment_date_gmt)';
2027 }
2028
2029 if ( $post ) {
2030 $total = '';
2031 $post = " AND comment_post_ID = '$post'";
2032 $orderby = "ORDER BY comment_date_gmt ASC LIMIT $start, $num";
2033 } else {
2034 $post = '';
2035 $orderby = "ORDER BY comment_date_gmt DESC LIMIT $start, $num";
2036 }
2037
2038 if ( 'comment' == $type )
2039 $typesql = "AND comment_type = ''";
2040 elseif ( 'pingback' == $type )
2041 $typesql = "AND comment_type = 'pingback'";
2042 elseif ( 'trackback' == $type )
2043 $typesql = "AND comment_type = 'trackback'";
2044 elseif ( 'pings' == $type )
2045 $typesql = "AND ( comment_type = 'pingback' OR comment_type = 'trackback' )";
2046 else
2047 $typesql = '';
2048
2049 if ( !empty($type) )
2050 $total = '';
2051
2052 if ( $s ) {
2053 $total = '';
2054 $s = $wpdb->escape($s);
2055 $query = "FROM $wpdb->comments WHERE
2056 (comment_author LIKE '%$s%' OR
2057 comment_author_email LIKE '%$s%' OR
2058 comment_author_url LIKE ('%$s%') OR
2059 comment_author_IP LIKE ('%$s%') OR
2060 comment_content LIKE ('%$s%') ) AND
2061 $approved
2062 $typesql";
2063 } else {
2064 $query = "FROM $wpdb->comments $index WHERE $approved $post $typesql";
2065 }
2066
2067 $comments = $wpdb->get_results("SELECT * $query $orderby");
2068 if ( '' === $total )
2069 $total = $wpdb->get_var("SELECT COUNT(comment_ID) $query");
2070
2071 update_comment_cache($comments);
2072
2073 return array($comments, $total);
2074}
2075
2076/**
2077 * {@internal Missing Short Description}}
2078 *
2079 * @since unknown
2080 *
2081 * @param unknown_type $comment_id
2082 * @param unknown_type $mode
2083 * @param unknown_type $comment_status
2084 * @param unknown_type $checkbox
2085 */
2086function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true, $from_ajax = false ) {
2087 global $comment, $post, $_comment_pending_count;
2088 $comment = get_comment( $comment_id );
2089 $post = get_post($comment->comment_post_ID);
2090 $the_comment_status = wp_get_comment_status($comment->comment_ID);
2091 $user_can = current_user_can('edit_post', $post->ID);
2092
2093 $author_url = get_comment_author_url();
2094 if ( 'http://' == $author_url )
2095 $author_url = '';
2096 $author_url_display = preg_replace('|http://(www\.)?|i', '', $author_url);
2097 if ( strlen($author_url_display) > 50 )
2098 $author_url_display = substr($author_url_display, 0, 49) . '...';
2099
2100 $ptime = date('G', strtotime( $comment->comment_date ) );
2101 if ( ( abs(time() - $ptime) ) < 86400 )
2102 $ptime = sprintf( __('%s ago'), human_time_diff( $ptime ) );
2103 else
2104 $ptime = mysql2date(__('Y/m/d \a\t g:i A'), $comment->comment_date );
2105
2106 $delete_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
2107 $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) );
2108 $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) );
2109 $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );
2110
2111 echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
2112 $columns = get_column_headers('edit-comments');
2113 $hidden = get_hidden_columns('edit-comments');
2114 foreach ( $columns as $column_name => $column_display_name ) {
2115 $class = "class=\"$column_name column-$column_name\"";
2116
2117 $style = '';
2118 if ( in_array($column_name, $hidden) )
2119 $style = ' style="display:none;"';
2120
2121 $attributes = "$class$style";
2122
2123 switch ($column_name) {
2124 case 'cb':
2125 if ( !$checkbox ) break;
2126 echo '<th scope="row" class="check-column">';
2127 if ( $user_can ) echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
2128 echo '</th>';
2129 break;
2130 case 'comment':
2131 echo "<td $attributes>";
2132 echo '<div id="submitted-on">';
2133 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')));
2134 echo '</div>';
2135 comment_text(); ?>
2136 <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
2137 <textarea class="comment" rows="3" cols="10"><?php echo $comment->comment_content; ?></textarea>
2138 <div class="author-email"><?php if ( $user_can ) echo esc_attr( $comment->comment_author_email ); ?></div>
2139 <div class="author"><?php if ( $user_can ) echo esc_attr( $comment->comment_author ); ?></div>
2140 <div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
2141 <div class="comment_status"><?php echo $comment->comment_approved; ?></div>
2142 </div>
2143 <?php
2144 $actions = array();
2145
2146 if ( $user_can ) {
2147 $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>';
2148 $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>';
2149 if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
2150 if ( 'approved' == $the_comment_status ) {
2151 $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
2152 unset($actions['approve']);
2153 } else {
2154 $actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
2155 unset($actions['unapprove']);
2156 }
2157 }
2158 if ( 'spam' != $the_comment_status )
2159 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
2160 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
2161 $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
2162 $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';
2163 if ( 'spam' != $the_comment_status )
2164 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
2165
2166 $actions = apply_filters( 'comment_row_actions', $actions, $comment );
2167
2168 $i = 0;
2169 echo '<div class="row-actions">';
2170 foreach ( $actions as $action => $link ) {
2171 ++$i;
2172 ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
2173
2174 // Reply and quickedit need a hide-if-no-js span when not added with ajax
2175 if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
2176 $action .= ' hide-if-no-js';
2177
2178 echo "<span class='$action'>$sep$link</span>";
2179 }
2180 echo '</div>';
2181 }
2182
2183 echo '</td>';
2184 break;
2185 case 'author':
2186 echo "<td $attributes><strong>"; comment_author(); echo '</strong><br />';
2187 if ( !empty($author_url) )
2188 echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
2189 if ( $user_can ) {
2190 if ( !empty($comment->comment_author_email) ) {
2191 comment_author_email_link();
2192 echo '<br />';
2193 }
2194 echo '<a href="edit-comments.php?s=';
2195 comment_author_IP();
2196 echo '&amp;mode=detail';
2197 if ( 'spam' == $comment_status )
2198 echo '&amp;comment_status=spam';
2199 echo '">';
2200 comment_author_IP();
2201 echo '</a>';
2202 } //current_user_can
2203 echo '</td>';
2204 break;
2205 case 'date':
2206 echo "<td $attributes>" . get_comment_date(__('Y/m/d \a\t g:ia')) . '</td>';
2207 break;
2208 case 'response':
2209 if ( 'single' !== $mode ) {
2210 if ( isset( $_comment_pending_count[$post->ID] ) ) {
2211 $pending_comments = absint( $_comment_pending_count[$post->ID] );
2212 } else {
2213 $_comment_pending_count_temp = (array) get_pending_comments_num( array( $post->ID ) );
2214 $pending_comments = $_comment_pending_count[$post->ID] = $_comment_pending_count_temp[$post->ID];
2215 }
2216 if ( $user_can ) {
2217 $post_link = "<a href='" . get_edit_post_link($post->ID) . "'>";
2218 $post_link .= get_the_title($post->ID) . '</a>';
2219 } else {
2220 $post_link = get_the_title($post->ID);
2221 }
2222 echo "<td $attributes>\n";
2223 echo '<div class="response-links"><span class="post-com-count-wrapper">';
2224 echo $post_link . '<br />';
2225 $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
2226 if ( $pending_comments )
2227 echo '<strong>';
2228 comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link */ _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . /* translators: comment count link: % will be substituted by comment count */ _x('%', 'comment count') . '</span></a>');
2229 if ( $pending_comments )
2230 echo '</strong>';
2231 echo '</span> ';
2232 echo "<a href='" . get_permalink( $post->ID ) . "'>#</a>";
2233 echo '</div>';
2234 if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array(80, 60), true ) ) )
2235 echo $thumb;
2236 echo '</td>';
2237 }
2238 break;
2239 default:
2240 echo "<td $attributes>\n";
2241 do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
2242 echo "</td>\n";
2243 break;
2244 }
2245 }
2246 echo "</tr>\n";
2247}
2248
2249/**
2250 * {@internal Missing Short Description}}
2251 *
2252 * @since unknown
2253 *
2254 * @param unknown_type $position
2255 * @param unknown_type $checkbox
2256 * @param unknown_type $mode
2257 */
2258function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
2259 global $current_user;
2260
2261 // allow plugin to replace the popup content
2262 $content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
2263
2264 if ( ! empty($content) ) {
2265 echo $content;
2266 return;
2267 }
2268
2269 $columns = get_column_headers('edit-comments');
2270 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) );
2271 $col_count = count($columns) - count($hidden);
2272
2273?>
2274<form method="get" action="">
2275<?php if ( $table_row ) : ?>
2276<table style="display:none;"><tbody id="com-reply"><tr id="replyrow"><td colspan="<?php echo $col_count; ?>">
2277<?php else : ?>
2278<div id="com-reply" style="display:none;"><div id="replyrow">
2279<?php endif; ?>
2280 <div id="replyhead" style="display:none;"><?php _e('Reply to Comment'); ?></div>
2281
2282 <div id="edithead" style="display:none;">
2283 <div class="inside">
2284 <label for="author"><?php _e('Name') ?></label>
2285 <input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
2286 </div>
2287
2288 <div class="inside">
2289 <label for="author-email"><?php _e('E-mail') ?></label>
2290 <input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
2291 </div>
2292
2293 <div class="inside">
2294 <label for="author-url"><?php _e('URL') ?></label>
2295 <input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
2296 </div>
2297 <div style="clear:both;"></div>
2298 </div>
2299
2300 <div id="replycontainer"><textarea rows="8" cols="40" name="replycontent" tabindex="104" id="replycontent"></textarea></div>
2301
2302 <p id="replysubmit" class="submit">
2303 <a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
2304 <a href="#comments-form" class="save button-primary alignright" tabindex="104">
2305 <span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
2306 <span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
2307 <img class="waiting" style="display:none;" src="images/wpspin_light.gif" alt="" />
2308 <span class="error" style="display:none;"></span>
2309 <br class="clear" />
2310 </p>
2311
2312 <input type="hidden" name="user_ID" id="user_ID" value="<?php echo $current_user->ID; ?>" />
2313 <input type="hidden" name="action" id="action" value="" />
2314 <input type="hidden" name="comment_ID" id="comment_ID" value="" />
2315 <input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
2316 <input type="hidden" name="status" id="status" value="" />
2317 <input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
2318 <input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
2319 <input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
2320 <?php wp_nonce_field( 'replyto-comment', '_ajax_nonce', false ); ?>
2321 <?php wp_comment_form_unfiltered_html_nonce(); ?>
2322<?php if ( $table_row ) : ?>
2323</td></tr></tbody></table>
2324<?php else : ?>
2325</div></div>
2326<?php endif; ?>
2327</form>
2328<?php
2329}
2330
2331/**
2332 * {@internal Missing Short Description}}
2333 *
2334 * @since unknown
2335 *
2336 * @param unknown_type $currentcat
2337 * @param unknown_type $currentparent
2338 * @param unknown_type $parent
2339 * @param unknown_type $level
2340 * @param unknown_type $categories
2341 * @return unknown
2342 */
2343function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
2344 if (!$categories )
2345 $categories = get_categories( array('hide_empty' => 0) );
2346
2347 if ( $categories ) {
2348 foreach ( $categories as $category ) {
2349 if ( $currentcat != $category->term_id && $parent == $category->parent) {
2350 $pad = str_repeat( '&#8211; ', $level );
2351 $category->name = esc_html( $category->name );
2352 echo "\n\t<option value='$category->term_id'";
2353 if ( $currentparent == $category->term_id )
2354 echo " selected='selected'";
2355 echo ">$pad$category->name</option>";
2356 wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
2357 }
2358 }
2359 } else {
2360 return false;
2361 }
2362}
2363
2364/**
2365 * {@internal Missing Short Description}}
2366 *
2367 * @since unknown
2368 *
2369 * @param unknown_type $meta
2370 */
2371function list_meta( $meta ) {
2372 // Exit if no meta
2373 if ( ! $meta ) {
2374 echo '
2375<table id="list-table" style="display: none;">
2376 <thead>
2377 <tr>
2378 <th class="left">' . __( 'Name' ) . '</th>
2379 <th>' . __( 'Value' ) . '</th>
2380 </tr>
2381 </thead>
2382 <tbody id="the-list" class="list:meta">
2383 <tr><td></td></tr>
2384 </tbody>
2385</table>'; //TBODY needed for list-manipulation JS
2386 return;
2387 }
2388 $count = 0;
2389?>
2390<table id="list-table">
2391 <thead>
2392 <tr>
2393 <th class="left"><?php _e( 'Name' ) ?></th>
2394 <th><?php _e( 'Value' ) ?></th>
2395 </tr>
2396 </thead>
2397 <tbody id='the-list' class='list:meta'>
2398<?php
2399 foreach ( $meta as $entry )
2400 echo _list_meta_row( $entry, $count );
2401?>
2402 </tbody>
2403</table>
2404<?php
2405}
2406
2407/**
2408 * {@internal Missing Short Description}}
2409 *
2410 * @since unknown
2411 *
2412 * @param unknown_type $entry
2413 * @param unknown_type $count
2414 * @return unknown
2415 */
2416function _list_meta_row( $entry, &$count ) {
2417 static $update_nonce = false;
2418 if ( !$update_nonce )
2419 $update_nonce = wp_create_nonce( 'add-meta' );
2420
2421 $r = '';
2422 ++ $count;
2423 if ( $count % 2 )
2424 $style = 'alternate';
2425 else
2426 $style = '';
2427 if ('_' == $entry['meta_key'] { 0 } )
2428 $style .= ' hidden';
2429
2430 if ( is_serialized( $entry['meta_value'] ) ) {
2431 if ( is_serialized_string( $entry['meta_value'] ) ) {
2432 // this is a serialized string, so we should display it
2433 $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
2434 } else {
2435 // this is a serialized array/object so we should NOT display it
2436 --$count;
2437 return;
2438 }
2439 }
2440
2441 $entry['meta_key'] = esc_attr($entry['meta_key']);
2442 $entry['meta_value'] = htmlspecialchars($entry['meta_value']); // using a <textarea />
2443 $entry['meta_id'] = (int) $entry['meta_id'];
2444
2445 $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
2446
2447 $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
2448 $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
2449
2450 $r .= "\n\t\t<div class='submit'><input name='deletemeta[{$entry['meta_id']}]' type='submit' ";
2451 $r .= "class='delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta' tabindex='6' value='". esc_attr__( 'Delete' ) ."' />";
2452 $r .= "\n\t\t<input name='updatemeta' type='submit' tabindex='6' value='". esc_attr__( 'Update' ) ."' class='add:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$update_nonce updatemeta' /></div>";
2453 $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
2454 $r .= "</td>";
2455
2456 $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
2457 return $r;
2458}
2459
2460/**
2461 * {@internal Missing Short Description}}
2462 *
2463 * @since unknown
2464 */
2465function meta_form() {
2466 global $wpdb;
2467 $limit = (int) apply_filters( 'postmeta_form_limit', 30 );
2468 $keys = $wpdb->get_col( "
2469 SELECT meta_key
2470 FROM $wpdb->postmeta
2471 GROUP BY meta_key
2472 HAVING meta_key NOT LIKE '\_%'
2473 ORDER BY LOWER(meta_key)
2474 LIMIT $limit" );
2475 if ( $keys )
2476 natcasesort($keys);
2477?>
2478<p><strong><?php _e( 'Add new custom field:' ) ?></strong></p>
2479<table id="newmeta">
2480<thead>
2481<tr>
2482<th class="left"><label for="metakeyselect"><?php _e( 'Name' ) ?></label></th>
2483<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
2484</tr>
2485</thead>
2486
2487<tbody>
2488<tr>
2489<td id="newmetaleft" class="left">
2490<?php if ( $keys ) { ?>
2491<select id="metakeyselect" name="metakeyselect" tabindex="7">
2492<option value="#NONE#"><?php _e( '- Select -' ); ?></option>
2493<?php
2494
2495 foreach ( $keys as $key ) {
2496 $key = esc_attr( $key );
2497 echo "\n<option value='" . esc_attr($key) . "'>$key</option>";
2498 }
2499?>
2500</select>
2501<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2502<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
2503<span id="enternew"><?php _e('Enter new'); ?></span>
2504<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
2505<?php } else { ?>
2506<input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
2507<?php } ?>
2508</td>
2509<td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
2510</tr>
2511
2512<tr><td colspan="2" class="submit">
2513<input type="submit" id="addmetasub" name="addmeta" class="add:the-list:newmeta" tabindex="9" value="<?php esc_attr_e( 'Add Custom Field' ) ?>" />
2514<?php wp_nonce_field( 'add-meta', '_ajax_nonce', false ); ?>
2515</td></tr>
2516</tbody>
2517</table>
2518<?php
2519
2520}
2521
2522/**
2523 * {@internal Missing Short Description}}
2524 *
2525 * @since unknown
2526 *
2527 * @param unknown_type $edit
2528 * @param unknown_type $for_post
2529 * @param unknown_type $tab_index
2530 * @param unknown_type $multi
2531 */
2532function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
2533 global $wp_locale, $post, $comment;
2534
2535 if ( $for_post )
2536 $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;
2537
2538 $tab_index_attribute = '';
2539 if ( (int) $tab_index > 0 )
2540 $tab_index_attribute = " tabindex=\"$tab_index\"";
2541
2542 // 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 />';
2543
2544 $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
2545 $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
2546 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
2547 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
2548 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
2549 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
2550 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
2551 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
2552
2553 $cur_jj = gmdate( 'd', $time_adj );
2554 $cur_mm = gmdate( 'm', $time_adj );
2555 $cur_aa = gmdate( 'Y', $time_adj );
2556 $cur_hh = gmdate( 'H', $time_adj );
2557 $cur_mn = gmdate( 'i', $time_adj );
2558
2559 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
2560 for ( $i = 1; $i < 13; $i = $i +1 ) {
2561 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
2562 if ( $i == $mm )
2563 $month .= ' selected="selected"';
2564 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
2565 }
2566 $month .= '</select>';
2567
2568 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2569 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
2570 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2571 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
2572 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
2573 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
2574
2575 echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
2576
2577 if ( $multi ) return;
2578
2579 echo "\n\n";
2580 foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
2581 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
2582 $cur_timeunit = 'cur_' . $timeunit;
2583 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
2584 }
2585?>
2586
2587<p>
2588<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
2589<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
2590</p>
2591<?php
2592}
2593
2594/**
2595 * {@internal Missing Short Description}}
2596 *
2597 * @since unknown
2598 *
2599 * @param unknown_type $default
2600 */
2601function page_template_dropdown( $default = '' ) {
2602 $templates = get_page_templates();
2603 ksort( $templates );
2604 foreach (array_keys( $templates ) as $template )
2605 : if ( $default == $templates[$template] )
2606 $selected = " selected='selected'";
2607 else
2608 $selected = '';
2609 echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
2610 endforeach;
2611}
2612
2613/**
2614 * {@internal Missing Short Description}}
2615 *
2616 * @since unknown
2617 *
2618 * @param unknown_type $default
2619 * @param unknown_type $parent
2620 * @param unknown_type $level
2621 * @return unknown
2622 */
2623function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
2624 global $wpdb, $post_ID;
2625 $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) );
2626
2627 if ( $items ) {
2628 foreach ( $items as $item ) {
2629 // A page cannot be its own parent.
2630 if (!empty ( $post_ID ) ) {
2631 if ( $item->ID == $post_ID ) {
2632 continue;
2633 }
2634 }
2635 $pad = str_repeat( '&nbsp;', $level * 3 );
2636 if ( $item->ID == $default)
2637 $current = ' selected="selected"';
2638 else
2639 $current = '';
2640
2641 echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
2642 parent_dropdown( $default, $item->ID, $level +1 );
2643 }
2644 } else {
2645 return false;
2646 }
2647}
2648
2649/**
2650 * {@internal Missing Short Description}}
2651 *
2652 * @since unknown
2653 */
2654function browse_happy() {
2655 $getit = __( 'WordPress recommends a better browser' );
2656 echo '
2657 <div id="bh"><a href="http://browsehappy.com/" title="'.$getit.'"><img src="images/browse-happy.gif" alt="Browse Happy" /></a></div>
2658';
2659}
2660
2661/**
2662 * {@internal Missing Short Description}}
2663 *
2664 * @since unknown
2665 *
2666 * @param unknown_type $id
2667 * @return unknown
2668 */
2669function the_attachment_links( $id = false ) {
2670 $id = (int) $id;
2671 $post = & get_post( $id );
2672
2673 if ( $post->post_type != 'attachment' )
2674 return false;
2675
2676 $icon = get_attachment_icon( $post->ID );
2677 $attachment_data = wp_get_attachment_metadata( $id );
2678 $thumb = isset( $attachment_data['thumb'] );
2679?>
2680<form id="the-attachment-links">
2681<table>
2682 <col />
2683 <col class="widefat" />
2684 <tr>
2685 <th scope="row"><?php _e( 'URL' ) ?></th>
2686 <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo wp_get_attachment_url(); ?></textarea></td>
2687 </tr>
2688<?php if ( $icon ) : ?>
2689 <tr>
2690 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
2691 <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>
2692 </tr>
2693 <tr>
2694 <th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
2695 <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>
2696 </tr>
2697<?php else : ?>
2698 <tr>
2699 <th scope="row"><?php _e( 'Link to file' ) ?></th>
2700 <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>
2701 </tr>
2702 <tr>
2703 <th scope="row"><?php _e( 'Link to page' ) ?></th>
2704 <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>
2705 </tr>
2706<?php endif; ?>
2707</table>
2708</form>
2709<?php
2710}
2711
2712
2713/**
2714 * Print out <option> html elements for role selectors based on $wp_roles
2715 *
2716 * @package WordPress
2717 * @subpackage Administration
2718 * @since 2.1
2719 *
2720 * @uses $wp_roles
2721 * @param string $default slug for the role that should be already selected
2722 */
2723function wp_dropdown_roles( $selected = false ) {
2724 global $wp_roles;
2725 $p = '';
2726 $r = '';
2727
2728 $editable_roles = get_editable_roles();
2729
2730 foreach( $editable_roles as $role => $details ) {
2731 $name = translate_user_role($details['name'] );
2732 if ( $selected == $role ) // Make default first in list
2733 $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
2734 else
2735 $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
2736 }
2737 echo $p . $r;
2738}
2739
2740/**
2741 * {@internal Missing Short Description}}
2742 *
2743 * @since unknown
2744 *
2745 * @param unknown_type $size
2746 * @return unknown
2747 */
2748function wp_convert_hr_to_bytes( $size ) {
2749 $size = strtolower($size);
2750 $bytes = (int) $size;
2751 if ( strpos($size, 'k') !== false )
2752 $bytes = intval($size) * 1024;
2753 elseif ( strpos($size, 'm') !== false )
2754 $bytes = intval($size) * 1024 * 1024;
2755 elseif ( strpos($size, 'g') !== false )
2756 $bytes = intval($size) * 1024 * 1024 * 1024;
2757 return $bytes;
2758}
2759
2760/**
2761 * {@internal Missing Short Description}}
2762 *
2763 * @since unknown
2764 *
2765 * @param unknown_type $bytes
2766 * @return unknown
2767 */
2768function wp_convert_bytes_to_hr( $bytes ) {
2769 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
2770 $log = log( $bytes, 1024 );
2771 $power = (int) $log;
2772 $size = pow(1024, $log - $power);
2773 return $size . $units[$power];
2774}
2775
2776/**
2777 * {@internal Missing Short Description}}
2778 *
2779 * @since unknown
2780 *
2781 * @return unknown
2782 */
2783function wp_max_upload_size() {
2784 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
2785 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
2786 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
2787 return $bytes;
2788}
2789
2790/**
2791 * {@internal Missing Short Description}}
2792 *
2793 * @since unknown
2794 *
2795 * @param unknown_type $action
2796 */
2797function wp_import_upload_form( $action ) {
2798 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
2799 $size = wp_convert_bytes_to_hr( $bytes );
2800 $upload_dir = wp_upload_dir();
2801 if ( ! empty( $upload_dir['error'] ) ) :
2802 ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
2803 <p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
2804 else :
2805?>
2806<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr($action) ?>">
2807<p>
2808<?php wp_nonce_field('import-upload'); ?>
2809<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
2810<input type="file" id="upload" name="import" size="25" />
2811<input type="hidden" name="action" value="save" />
2812<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
2813</p>
2814<p class="submit">
2815<input type="submit" class="button" value="<?php esc_attr_e( 'Upload file and import' ); ?>" />
2816</p>
2817</form>
2818<?php
2819 endif;
2820}
2821
2822/**
2823 * {@internal Missing Short Description}}
2824 *
2825 * @since unknown
2826 */
2827function wp_remember_old_slug() {
2828 global $post;
2829 $name = esc_attr($post->post_name); // just in case
2830 if ( strlen($name) )
2831 echo '<input type="hidden" id="wp-old-slug" name="wp-old-slug" value="' . $name . '" />';
2832}
2833
2834/**
2835 * Add a meta box to an edit form.
2836 *
2837 * @since 2.5.0
2838 *
2839 * @param string $id String for use in the 'id' attribute of tags.
2840 * @param string $title Title of the meta box.
2841 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
2842 * @param string $page The type of edit page on which to show the box (post, page, link).
2843 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2844 * @param string $priority The priority within the context where the boxes should show ('high', 'low').
2845 */
2846function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) {
2847 global $wp_meta_boxes;
2848
2849 if ( !isset($wp_meta_boxes) )
2850 $wp_meta_boxes = array();
2851 if ( !isset($wp_meta_boxes[$page]) )
2852 $wp_meta_boxes[$page] = array();
2853 if ( !isset($wp_meta_boxes[$page][$context]) )
2854 $wp_meta_boxes[$page][$context] = array();
2855
2856 foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
2857 foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
2858 if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
2859 continue;
2860
2861 // If a core box was previously added or removed by a plugin, don't add.
2862 if ( 'core' == $priority ) {
2863 // If core box previously deleted, don't add
2864 if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
2865 return;
2866 // If box was added with default priority, give it core priority to maintain sort order
2867 if ( 'default' == $a_priority ) {
2868 $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
2869 unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
2870 }
2871 return;
2872 }
2873 // If no priority given and id already present, use existing priority
2874 if ( empty($priority) ) {
2875 $priority = $a_priority;
2876 // 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.
2877 } elseif ( 'sorted' == $priority ) {
2878 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
2879 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
2880 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
2881 }
2882 // An id can be in only one priority and one context
2883 if ( $priority != $a_priority || $context != $a_context )
2884 unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
2885 }
2886 }
2887
2888 if ( empty($priority) )
2889 $priority = 'low';
2890
2891 if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
2892 $wp_meta_boxes[$page][$context][$priority] = array();
2893
2894 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
2895}
2896
2897/**
2898 * {@internal Missing Short Description}}
2899 *
2900 * @since unknown
2901 *
2902 * @param unknown_type $page
2903 * @param unknown_type $context
2904 * @param unknown_type $object
2905 * @return int number of meta_boxes
2906 */
2907function do_meta_boxes($page, $context, $object) {
2908 global $wp_meta_boxes;
2909 static $already_sorted = false;
2910
2911 //do_action('do_meta_boxes', $page, $context, $object);
2912
2913 $hidden = get_hidden_meta_boxes($page);
2914
2915 echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
2916
2917 $i = 0;
2918 do {
2919 // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
2920 if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page", 0, false ) ) {
2921 foreach ( $sorted as $box_context => $ids )
2922 foreach ( explode(',', $ids) as $id )
2923 if ( $id )
2924 add_meta_box( $id, null, null, $page, $box_context, 'sorted' );
2925 }
2926 $already_sorted = true;
2927
2928 if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
2929 break;
2930
2931 foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
2932 if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
2933 foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
2934 if ( false == $box || ! $box['title'] )
2935 continue;
2936 $i++;
2937 $style = '';
2938 if ( in_array($box['id'], $hidden) )
2939 $style = 'style="display:none;"';
2940 echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . '" ' . $style . '>' . "\n";
2941 echo '<div class="handlediv" title="' . __('Click to toggle') . '"><br /></div>';
2942 echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
2943 echo '<div class="inside">' . "\n";
2944 call_user_func($box['callback'], $object, $box);
2945 echo "</div>\n";
2946 echo "</div>\n";
2947 }
2948 }
2949 }
2950 } while(0);
2951
2952 echo "</div>";
2953
2954 return $i;
2955
2956}
2957
2958/**
2959 * Remove a meta box from an edit form.
2960 *
2961 * @since 2.6.0
2962 *
2963 * @param string $id String for use in the 'id' attribute of tags.
2964 * @param string $page The type of edit page on which to show the box (post, page, link).
2965 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
2966 */
2967function remove_meta_box($id, $page, $context) {
2968 global $wp_meta_boxes;
2969
2970 if ( !isset($wp_meta_boxes) )
2971 $wp_meta_boxes = array();
2972 if ( !isset($wp_meta_boxes[$page]) )
2973 $wp_meta_boxes[$page] = array();
2974 if ( !isset($wp_meta_boxes[$page][$context]) )
2975 $wp_meta_boxes[$page][$context] = array();
2976
2977 foreach ( array('high', 'core', 'default', 'low') as $priority )
2978 $wp_meta_boxes[$page][$context][$priority][$id] = false;
2979}
2980
2981/**
2982 * {@internal Missing Short Description}}
2983 *
2984 * @since unknown
2985 *
2986 * @param unknown_type $page
2987 */
2988function meta_box_prefs($page) {
2989 global $wp_meta_boxes;
2990
2991 if ( empty($wp_meta_boxes[$page]) )
2992 return;
2993
2994 $hidden = get_hidden_meta_boxes($page);
2995
2996 foreach ( array_keys($wp_meta_boxes[$page]) as $context ) {
2997 foreach ( array_keys($wp_meta_boxes[$page][$context]) as $priority ) {
2998 foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
2999 if ( false == $box || ! $box['title'] )
3000 continue;
3001 // Submit box cannot be hidden
3002 if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
3003 continue;
3004 $box_id = $box['id'];
3005 echo '<label for="' . $box_id . '-hide">';
3006 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"' : '') . ' />';
3007 echo "{$box['title']}</label>\n";
3008 }
3009 }
3010 }
3011}
3012
3013function get_hidden_meta_boxes($page) {
3014 $hidden = (array) get_user_option( "meta-box-hidden_$page", 0, false );
3015
3016 // Hide slug boxes by default
3017 if ( empty($hidden[0]) ) {
3018 if ( 'page' == $page )
3019 $hidden = array('pageslugdiv');
3020 elseif ( 'post' == $page )
3021 $hidden = array('slugdiv');
3022 }
3023
3024 return $hidden;
3025}
3026
3027/**
3028 * Add a new section to a settings page.
3029 *
3030 * @since 2.7.0
3031 *
3032 * @param string $id String for use in the 'id' attribute of tags.
3033 * @param string $title Title of the section.
3034 * @param string $callback Function that fills the section with the desired content. The function should echo its output.
3035 * @param string $page The type of settings page on which to show the section (general, reading, writing, ...).
3036 */
3037function add_settings_section($id, $title, $callback, $page) {
3038 global $wp_settings_sections;
3039
3040 if ( !isset($wp_settings_sections) )
3041 $wp_settings_sections = array();
3042 if ( !isset($wp_settings_sections[$page]) )
3043 $wp_settings_sections[$page] = array();
3044 if ( !isset($wp_settings_sections[$page][$id]) )
3045 $wp_settings_sections[$page][$id] = array();
3046
3047 $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
3048}
3049
3050/**
3051 * Add a new field to a settings page.
3052 *
3053 * @since 2.7.0
3054 *
3055 * @param string $id String for use in the 'id' attribute of tags.
3056 * @param string $title Title of the field.
3057 * @param string $callback Function that fills the field with the desired content. The function should echo its output.
3058 * @param string $page The type of settings page on which to show the field (general, reading, writing, ...).
3059 * @param string $section The section of the settingss page in which to show the box (default, ...).
3060 * @param array $args Additional arguments
3061 */
3062function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
3063 global $wp_settings_fields;
3064
3065 if ( !isset($wp_settings_fields) )
3066 $wp_settings_fields = array();
3067 if ( !isset($wp_settings_fields[$page]) )
3068 $wp_settings_fields[$page] = array();
3069 if ( !isset($wp_settings_fields[$page][$section]) )
3070 $wp_settings_fields[$page][$section] = array();
3071
3072 $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
3073}
3074
3075/**
3076 * {@internal Missing Short Description}}
3077 *
3078 * @since unknown
3079 *
3080 * @param unknown_type $page
3081 */
3082function do_settings_sections($page) {
3083 global $wp_settings_sections, $wp_settings_fields;
3084
3085 if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
3086 return;
3087
3088 foreach ( (array) $wp_settings_sections[$page] as $section ) {
3089 echo "<h3>{$section['title']}</h3>\n";
3090 call_user_func($section['callback'], $section);
3091 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
3092 continue;
3093 echo '<table class="form-table">';
3094 do_settings_fields($page, $section['id']);
3095 echo '</table>';
3096 }
3097}
3098
3099/**
3100 * {@internal Missing Short Description}}
3101 *
3102 * @since unknown
3103 *
3104 * @param unknown_type $page
3105 * @param unknown_type $section
3106 */
3107function do_settings_fields($page, $section) {
3108 global $wp_settings_fields;
3109
3110 if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
3111 return;
3112
3113 foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
3114 echo '<tr valign="top">';
3115 if ( !empty($field['args']['label_for']) )
3116 echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
3117 else
3118 echo '<th scope="row">' . $field['title'] . '</th>';
3119 echo '<td>';
3120 call_user_func($field['callback']);
3121 echo '</td>';
3122 echo '</tr>';
3123 }
3124}
3125
3126/**
3127 * {@internal Missing Short Description}}
3128 *
3129 * @since unknown
3130 *
3131 * @param unknown_type $page
3132 */
3133function manage_columns_prefs($page) {
3134 $columns = get_column_headers($page);
3135
3136 $hidden = get_hidden_columns($page);
3137
3138 foreach ( $columns as $column => $title ) {
3139 // Can't hide these
3140 if ( 'cb' == $column || 'title' == $column || 'name' == $column || 'username' == $column || 'media' == $column || 'comment' == $column )
3141 continue;
3142 if ( empty($title) )
3143 continue;
3144
3145 if ( 'comments' == $column )
3146 $title = __('Comments');
3147 $id = "$column-hide";
3148 echo '<label for="' . $id . '">';
3149 echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . (! in_array($column, $hidden) ? ' checked="checked"' : '') . ' />';
3150 echo "$title</label>\n";
3151 }
3152}
3153
3154/**
3155 * {@internal Missing Short Description}}
3156 *
3157 * @since unknown
3158 *
3159 * @param unknown_type $found_action
3160 */
3161function find_posts_div($found_action = '') {
3162?>
3163 <div id="find-posts" class="find-box" style="display:none;">
3164 <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
3165 <div class="find-box-inside">
3166 <div class="find-box-search">
3167 <?php if ( $found_action ) { ?>
3168 <input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
3169 <?php } ?>
3170
3171 <input type="hidden" name="affected" id="affected" value="" />
3172 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
3173 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
3174 <input type="text" id="find-posts-input" name="ps" value="" />
3175 <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
3176
3177 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
3178 <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label>
3179 <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" />
3180 <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label>
3181 </div>
3182 <div id="find-posts-response"></div>
3183 </div>
3184 <div class="find-box-buttons">
3185 <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
3186 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
3187 </div>
3188 </div>
3189<?php
3190}
3191
3192/**
3193 * Display the post password.
3194 *
3195 * The password is passed through {@link esc_attr()} to ensure that it
3196 * is safe for placing in an html attribute.
3197 *
3198 * @uses attr
3199 * @since 2.7.0
3200 */
3201function the_post_password() {
3202 global $post;
3203 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
3204}
3205
3206/**
3207 * {@internal Missing Short Description}}
3208 *
3209 * @since unknown
3210 */
3211function favorite_actions( $screen = null ) {
3212 switch ( $screen ) {
3213 case 'post-new.php':
3214 $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
3215 break;
3216 case 'edit-pages.php':
3217 $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages'));
3218 break;
3219 case 'page-new.php':
3220 $default_action = array('edit-pages.php' => array(__('Edit Pages'), 'edit_pages'));
3221 break;
3222 case 'upload.php':
3223 $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
3224 break;
3225 case 'media-new.php':
3226 $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
3227 break;
3228 case 'link-manager.php':
3229 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
3230 break;
3231 case 'link-add.php':
3232 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
3233 break;
3234 case 'users.php':
3235 $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
3236 break;
3237 case 'user-new.php':
3238 $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
3239 break;
3240 case 'plugins.php':
3241 $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
3242 break;
3243 case 'plugin-install.php':
3244 $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
3245 break;
3246 case 'themes.php':
3247 $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
3248 break;
3249 case 'theme-install.php':
3250 $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
3251 break;
3252 default:
3253 $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
3254 break;
3255 }
3256
3257 $actions = array(
3258 'post-new.php' => array(__('New Post'), 'edit_posts'),
3259 'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
3260 'page-new.php' => array(__('New Page'), 'edit_pages'),
3261 'media-new.php' => array(__('Upload'), 'upload_files'),
3262 'edit-comments.php' => array(__('Comments'), 'moderate_comments')
3263 );
3264
3265 $default_key = array_keys($default_action);
3266 $default_key = $default_key[0];
3267 if ( isset($actions[$default_key]) )
3268 unset($actions[$default_key]);
3269 $actions = array_merge($default_action, $actions);
3270 $actions = apply_filters('favorite_actions', $actions);
3271
3272 $allowed_actions = array();
3273 foreach ( $actions as $action => $data ) {
3274 if ( current_user_can($data[1]) )
3275 $allowed_actions[$action] = $data[0];
3276 }
3277
3278 if ( empty($allowed_actions) )
3279 return;
3280
3281 $first = array_keys($allowed_actions);
3282 $first = $first[0];
3283 echo '<div id="favorite-actions">';
3284 echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
3285 echo '<div id="favorite-inside">';
3286
3287 array_shift($allowed_actions);
3288
3289 foreach ( $allowed_actions as $action => $label) {
3290 echo "<div class='favorite-action'><a href='$action'>";
3291 echo $label;
3292 echo "</a></div>\n";
3293 }
3294 echo "</div></div>\n";
3295}
3296
3297/**
3298 * Get the post title.
3299 *
3300 * The post title is fetched and if it is blank then a default string is
3301 * returned.
3302 *
3303 * @since 2.7.0
3304 * @param int $id The post id. If not supplied the global $post is used.
3305 *
3306 */
3307function _draft_or_post_title($post_id = 0)
3308{
3309 $title = get_the_title($post_id);
3310 if ( empty($title) )
3311 $title = __('(no title)');
3312 return $title;
3313}
3314
3315/**
3316 * Display the search query.
3317 *
3318 * A simple wrapper to display the "s" parameter in a GET URI. This function
3319 * should only be used when {@link the_search_query()} cannot.
3320 *
3321 * @uses attr
3322 * @since 2.7.0
3323 *
3324 */
3325function _admin_search_query() {
3326 echo isset($_GET['s']) ? esc_attr( stripslashes( $_GET['s'] ) ) : '';
3327}
3328
3329/**
3330 * Generic Iframe header for use with Thickbox
3331 *
3332 * @since 2.7.0
3333 * @param string $title Title of the Iframe page.
3334 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
3335 *
3336 */
3337function iframe_header( $title = '', $limit_styles = false ) {
3338?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3339<html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
3340<head>
3341<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
3342<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
3343<?php
3344wp_enqueue_style( 'global' );
3345if ( ! $limit_styles )
3346 wp_enqueue_style( 'wp-admin' );
3347wp_enqueue_style( 'colors' );
3348?>
3349<script type="text/javascript">
3350//<![CDATA[
3351addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
3352function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
3353//]]>
3354</script>
3355<?php
3356do_action('admin_print_styles');
3357do_action('admin_print_scripts');
3358do_action('admin_head');
3359?>
3360</head>
3361<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
3362<?php
3363}
3364
3365/**
3366 * Generic Iframe footer for use with Thickbox
3367 *
3368 * @since 2.7.0
3369 *
3370 */
3371function iframe_footer() {
3372 //We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
3373 <div class="hidden">
3374<?php
3375 do_action('admin_footer', '');
3376 do_action('admin_print_footer_scripts'); ?>
3377 </div>
3378<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
3379</body>
3380</html>
3381<?php
3382}
3383
3384function _post_states($post) {
3385 $post_states = array();
3386 if ( isset($_GET['post_status']) )
3387 $post_status = $_GET['post_status'];
3388 else
3389 $post_status = '';
3390
3391 if ( !empty($post->post_password) )
3392 $post_states[] = __('Password protected');
3393 if ( 'private' == $post->post_status && 'private' != $post_status )
3394 $post_states[] = __('Private');
3395 if ( 'draft' == $post->post_status && 'draft' != $post_status )
3396 $post_states[] = __('Draft');
3397 if ( 'pending' == $post->post_status && 'pending' != $post_status )
3398 /* translators: post state */
3399 $post_states[] = _x('Pending', 'post state');
3400 if ( is_sticky($post->ID) )
3401 $post_states[] = __('Sticky');
3402
3403 $post_states = apply_filters( 'display_post_states', $post_states );
3404
3405 if ( ! empty($post_states) ) {
3406 $state_count = count($post_states);
3407 $i = 0;
3408 echo ' - ';
3409 foreach ( $post_states as $state ) {
3410 ++$i;
3411 ( $i == $state_count ) ? $sep = '' : $sep = ', ';
3412 echo "<span class='post-state'>$state$sep</span>";
3413 }
3414 }
3415}
3416
3417function screen_meta($screen) {
3418 global $wp_meta_boxes, $_wp_contextual_help;
3419
3420 $screen = str_replace('.php', '', $screen);
3421 $screen = str_replace('-new', '', $screen);
3422 $screen = str_replace('-add', '', $screen);
3423 $screen = apply_filters('screen_meta_screen', $screen);
3424
3425 $column_screens = get_column_headers($screen);
3426 $meta_screens = array('index' => 'dashboard');
3427
3428 if ( isset($meta_screens[$screen]) )
3429 $screen = $meta_screens[$screen];
3430 $show_screen = false;
3431 $show_on_screen = false;
3432 if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) {
3433 $show_screen = true;
3434 $show_on_screen = true;
3435 }
3436
3437 $screen_options = screen_options($screen);
3438 if ( $screen_options )
3439 $show_screen = true;
3440
3441 if ( !isset($_wp_contextual_help) )
3442 $_wp_contextual_help = array();
3443
3444 $settings = '';
3445
3446 switch ( $screen ) {
3447 case 'post':
3448 if ( !isset($_wp_contextual_help['post']) ) {
3449 $help = drag_drop_help();
3450 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>';
3451 $_wp_contextual_help['post'] = $help;
3452 }
3453 break;
3454 case 'page':
3455 if ( !isset($_wp_contextual_help['page']) ) {
3456 $help = drag_drop_help();
3457 $_wp_contextual_help['page'] = $help;
3458 }
3459 break;
3460 case 'dashboard':
3461 if ( !isset($_wp_contextual_help['dashboard']) ) {
3462 $help = '<p>' . __('The modules on this screen can be arranged in several columns. You can select the number of columns from the Screen Options tab.') . "</p>\n";
3463 $help .= drag_drop_help();
3464 $_wp_contextual_help['dashboard'] = $help;
3465 }
3466 break;
3467 case 'link':
3468 if ( !isset($_wp_contextual_help['link']) ) {
3469 $help = drag_drop_help();
3470 $_wp_contextual_help['link'] = $help;
3471 }
3472 break;
3473 case 'options-general':
3474 if ( !isset($_wp_contextual_help['options-general']) )
3475 $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>');
3476 break;
3477 case 'theme-install':
3478 case 'plugin-install':
3479 if ( ( !isset($_GET['tab']) || 'dashboard' == $_GET['tab'] ) && !isset($_wp_contextual_help[$screen]) ) {
3480 $help = plugins_search_help();
3481 $_wp_contextual_help[$screen] = $help;
3482 }
3483 break;
3484 case 'widgets':
3485 if ( !isset($_wp_contextual_help['widgets']) ) {
3486 $help = widgets_help();
3487 $_wp_contextual_help['widgets'] = $help;
3488 }
3489 $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
3490 $show_screen = true;
3491 break;
3492 }
3493?>
3494<div id="screen-meta">
3495<?php
3496 if ( $show_screen ) :
3497?>
3498<div id="screen-options-wrap" class="hidden">
3499 <form id="adv-settings" action="" method="post">
3500<?php if ( $show_on_screen ) : ?>
3501 <h5><?php _e('Show on screen') ?></h5>
3502 <div class="metabox-prefs">
3503<?php
3504 if ( !meta_box_prefs($screen) && isset($column_screens) ) {
3505 manage_columns_prefs($screen);
3506 }
3507?>
3508 <br class="clear" />
3509 </div>
3510<?php endif; ?>
3511<?php echo screen_layout($screen); ?>
3512<?php echo $screen_options; ?>
3513<?php echo $settings; ?>
3514<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
3515</form>
3516</div>
3517
3518<?php
3519 endif;
3520
3521 global $title;
3522
3523 $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen);
3524 ?>
3525 <div id="contextual-help-wrap" class="hidden">
3526 <?php
3527 $contextual_help = '';
3528 if ( isset($_wp_contextual_help[$screen]) ) {
3529 if ( !empty($title) )
3530 $contextual_help .= '<h5>' . sprintf(__('Get help with &#8220;%s&#8221;'), $title) . '</h5>';
3531 else
3532 $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>';
3533 $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n";
3534
3535 $contextual_help .= '<h5>' . __('Other Help') . '</h5>';
3536 } else {
3537 $contextual_help .= '<h5>' . __('Help') . '</h5>';
3538 }
3539
3540 $contextual_help .= '<div class="metabox-prefs">';
3541 $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>');
3542 $default_help .= '<br />';
3543 $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>');
3544 $contextual_help .= apply_filters('default_contextual_help', $default_help);
3545 $contextual_help .= "</div>\n";
3546 echo apply_filters('contextual_help', $contextual_help, $screen);
3547 ?>
3548 </div>
3549
3550<div id="screen-meta-links">
3551<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
3552<a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a>
3553</div>
3554<?php if ( $show_screen ) { ?>
3555<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
3556<a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a>
3557</div>
3558<?php } ?>
3559</div>
3560</div>
3561<?php
3562}
3563
3564/**
3565 * Add contextual help text for a page
3566 *
3567 * @since 2.7.0
3568 *
3569 * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
3570 * @param string $help Arbitrary help text
3571 */
3572function add_contextual_help($screen, $help) {
3573 global $_wp_contextual_help;
3574
3575 if ( !isset($_wp_contextual_help) )
3576 $_wp_contextual_help = array();
3577
3578 $_wp_contextual_help[$screen] = $help;
3579}
3580
3581function drag_drop_help() {
3582 return '
3583 <p>' . __('Most of the modules on this screen can be moved. If you hover your mouse over the title bar of a module you&rsquo;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>
3584 <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>
3585';
3586}
3587
3588function plugins_search_help() {
3589 return '
3590 <p><strong>' . __('Search help') . '</strong></p>' .
3591 '<p>' . __('You may search based on 3 criteria:') . '<br />' .
3592 __('<strong>Term:</strong> Searches theme names and descriptions for the specified term.') . '<br />' .
3593 __('<strong>Tag:</strong> Searches for themes tagged as such.') . '<br />' .
3594 __('<strong>Author:</strong> Searches for themes created by the Author, or which the Author contributed to.') . '</p>
3595';
3596}
3597
3598function widgets_help() {
3599 return '
3600 <p>' . __('Widgets are added and arranged by simple drag &#8217;n&#8217; drop. If you hover your mouse over the titlebar of a widget, you&#8217;ll see a 4-arrow cursor which indicates that the widget is movable. Click on the titlebar, hold down the mouse button and drag the widget to a sidebar. As you drag, you&#8217;ll see a dotted box that also moves. This box shows where the widget will go once you drop it.') . '</p>
3601 <p>' . __('To remove a widget from a sidebar, drag it back to Available Widgets or click on the arrow on its titlebar to reveal its settings, and then click Remove.') . '</p>
3602 <p>' . __('To remove a widget from a sidebar <em>and keep its configuration</em>, drag it to Inactive Widgets.') . '</p>
3603 <p>' . __('The Inactive Widgets area stores widgets that are configured but not curently used. If you change themes and the new theme has fewer sidebars than the old, all extra widgets will be stored to Inactive Widgets automatically.') . '</p>
3604';
3605}
3606
3607function screen_layout($screen) {
3608 global $screen_layout_columns;
3609
3610 $columns = array('dashboard' => 4, 'post' => 2, 'page' => 2, 'link' => 2);
3611 $columns = apply_filters('screen_layout_columns', $columns, $screen);
3612
3613 if ( !isset($columns[$screen]) ) {
3614 $screen_layout_columns = 0;
3615 return '';
3616 }
3617
3618 $screen_layout_columns = get_user_option("screen_layout_$screen");
3619 $num = $columns[$screen];
3620
3621 if ( ! $screen_layout_columns )
3622 $screen_layout_columns = 2;
3623
3624 $i = 1;
3625 $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
3626 while ( $i <= $num ) {
3627 $return .= "<label><input type='radio' name='screen_columns' value='$i'" . ( ($screen_layout_columns == $i) ? " checked='checked'" : "" ) . " /> $i</label>\n";
3628 ++$i;
3629 }
3630 $return .= "</div>\n";
3631 return $return;
3632}
3633
3634function screen_options($screen) {
3635 switch ( $screen ) {
3636 case 'edit':
3637 $per_page_label = __('Posts per page:');
3638 break;
3639 case 'edit-pages':
3640 $per_page_label = __('Pages per page:');
3641 break;
3642 case 'edit-comments':
3643 $per_page_label = __('Comments per page:');
3644 break;
3645 case 'upload':
3646 $per_page_label = __('Media items per page:');
3647 break;
3648 case 'categories':
3649 $per_page_label = __('Categories per page:');
3650 break;
3651 case 'edit-tags':
3652 $per_page_label = __('Tags per page:');
3653 break;
3654 case 'plugins':
3655 $per_page_label = __('Plugins per page:');
3656 break;
3657 default:
3658 return '';
3659 }
3660
3661 $option = str_replace('-', '_', "${screen}_per_page");
3662 $per_page = get_user_option($option);
3663 if ( empty($per_page) ) {
3664 if ( 'plugins' == $screen )
3665 $per_page = 999;
3666 else
3667 $per_page = 20;
3668 }
3669
3670 $return = '<h5>' . __('Options') . "</h5>\n";
3671 $return .= "<div class='screen-options'>\n";
3672 if ( !empty($per_page_label) )
3673 $return .= "<label for='$option'>$per_page_label</label> <input type='text' class='screen-per-page' name='wp_screen_options[value]' id='$option' maxlength='3' value='$per_page' />\n";
3674 $return .= "<input type='submit' class='button' value='" . esc_attr__('Apply') . "' />";
3675 $return .= "<input type='hidden' name='wp_screen_options[option]' value='" . esc_attr($option) . "' />";
3676 $return .= "</div>\n";
3677 return $return;
3678}
3679
3680function screen_icon($name = '') {
3681 global $parent_file, $hook_suffix;
3682
3683 if ( empty($name) ) {
3684 if ( isset($parent_file) && !empty($parent_file) )
3685 $name = substr($parent_file, 0, -4);
3686 else
3687 $name = str_replace(array('.php', '-new', '-add'), '', $hook_suffix);
3688 }
3689?>
3690 <div id="icon-<?php echo $name; ?>" class="icon32"><br /></div>
3691<?php
3692}
3693
3694/**
3695 * Test support for compressing JavaScript from PHP
3696 *
3697 * Outputs JavaScript that tests if compression from PHP works as expected
3698 * and sets an option with the result. Has no effect when the current user
3699 * is not an administrator. To run the test again the option 'can_compress_scripts'
3700 * has to be deleted.
3701 *
3702 * @since 2.8.0
3703 */
3704function compression_test() {
3705?>
3706 <script type="text/javascript">
3707 /* <![CDATA[ */
3708 var testCompression = {
3709 get : function(test) {
3710 var x;
3711 if ( window.XMLHttpRequest ) {
3712 x = new XMLHttpRequest();
3713 } else {
3714 try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
3715 }
3716
3717 if (x) {
3718 x.onreadystatechange = function() {
3719 var r, h;
3720 if ( x.readyState == 4 ) {
3721 r = x.responseText.substr(0, 18);
3722 h = x.getResponseHeader('Content-Encoding');
3723 testCompression.check(r, h, test);
3724 }
3725 }
3726
3727 x.open('GET', 'admin-ajax.php?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
3728 x.send('');
3729 }
3730 },
3731
3732 check : function(r, h, test) {
3733 if ( ! r && ! test )
3734 this.get(1);
3735
3736 if ( 1 == test ) {
3737 if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
3738 this.get('no');
3739 else
3740 this.get(2);
3741
3742 return;
3743 }
3744
3745 if ( 2 == test ) {
3746 if ( '"wpCompressionTest' == r )
3747 this.get('yes');
3748 else
3749 this.get('no');
3750 }
3751 }
3752 };
3753 testCompression.check();
3754 /* ]]> */
3755 </script>
3756<?php
3757}
3758
3759?>