120 * screen. If left null, the current screen will be automatically set. |
134 * screen. If left null, the current screen will be automatically set. |
121 * Default null. |
135 * Default null. |
122 * } |
136 * } |
123 */ |
137 */ |
124 public function __construct( $args = array() ) { |
138 public function __construct( $args = array() ) { |
125 $args = wp_parse_args( $args, array( |
139 $args = wp_parse_args( |
126 'plural' => '', |
140 $args, |
127 'singular' => '', |
141 array( |
128 'ajax' => false, |
142 'plural' => '', |
129 'screen' => null, |
143 'singular' => '', |
130 ) ); |
144 'ajax' => false, |
|
145 'screen' => null, |
|
146 ) |
|
147 ); |
131 |
148 |
132 $this->screen = convert_to_screen( $args['screen'] ); |
149 $this->screen = convert_to_screen( $args['screen'] ); |
133 |
150 |
134 add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
151 add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
135 |
152 |
136 if ( !$args['plural'] ) |
153 if ( ! $args['plural'] ) { |
137 $args['plural'] = $this->screen->base; |
154 $args['plural'] = $this->screen->base; |
138 |
155 } |
139 $args['plural'] = sanitize_key( $args['plural'] ); |
156 |
|
157 $args['plural'] = sanitize_key( $args['plural'] ); |
140 $args['singular'] = sanitize_key( $args['singular'] ); |
158 $args['singular'] = sanitize_key( $args['singular'] ); |
141 |
159 |
142 $this->_args = $args; |
160 $this->_args = $args; |
143 |
161 |
144 if ( $args['ajax'] ) { |
162 if ( $args['ajax'] ) { |
319 * |
342 * |
320 * @param string $text The 'submit' button label. |
343 * @param string $text The 'submit' button label. |
321 * @param string $input_id ID attribute value for the search input field. |
344 * @param string $input_id ID attribute value for the search input field. |
322 */ |
345 */ |
323 public function search_box( $text, $input_id ) { |
346 public function search_box( $text, $input_id ) { |
324 if ( empty( $_REQUEST['s'] ) && !$this->has_items() ) |
347 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
325 return; |
348 return; |
|
349 } |
326 |
350 |
327 $input_id = $input_id . '-search-input'; |
351 $input_id = $input_id . '-search-input'; |
328 |
352 |
329 if ( ! empty( $_REQUEST['orderby'] ) ) |
353 if ( ! empty( $_REQUEST['orderby'] ) ) { |
330 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
354 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
331 if ( ! empty( $_REQUEST['order'] ) ) |
355 } |
|
356 if ( ! empty( $_REQUEST['order'] ) ) { |
332 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
357 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
333 if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
358 } |
|
359 if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
334 echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
360 echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
335 if ( ! empty( $_REQUEST['detached'] ) ) |
361 } |
|
362 if ( ! empty( $_REQUEST['detached'] ) ) { |
336 echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
363 echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
337 ?> |
364 } |
|
365 ?> |
338 <p class="search-box"> |
366 <p class="search-box"> |
339 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
367 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
340 <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
368 <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
341 <?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
369 <?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
342 </p> |
370 </p> |
343 <?php |
371 <?php |
344 } |
372 } |
345 |
373 |
346 /** |
374 /** |
347 * Get an associative array ( id => link ) with the list |
375 * Get an associative array ( id => link ) with the list |
348 * of views available on this table. |
376 * of views available on this table. |
368 * The dynamic portion of the hook name, `$this->screen->id`, refers |
396 * The dynamic portion of the hook name, `$this->screen->id`, refers |
369 * to the ID of the current screen, usually a string. |
397 * to the ID of the current screen, usually a string. |
370 * |
398 * |
371 * @since 3.5.0 |
399 * @since 3.5.0 |
372 * |
400 * |
373 * @param array $views An array of available list table views. |
401 * @param string[] $views An array of available list table views. |
374 */ |
402 */ |
375 $views = apply_filters( "views_{$this->screen->id}", $views ); |
403 $views = apply_filters( "views_{$this->screen->id}", $views ); |
376 |
404 |
377 if ( empty( $views ) ) |
405 if ( empty( $views ) ) { |
378 return; |
406 return; |
|
407 } |
379 |
408 |
380 $this->screen->render_screen_reader_content( 'heading_views' ); |
409 $this->screen->render_screen_reader_content( 'heading_views' ); |
381 |
410 |
382 echo "<ul class='subsubsub'>\n"; |
411 echo "<ul class='subsubsub'>\n"; |
383 foreach ( $views as $class => $view ) { |
412 foreach ( $views as $class => $view ) { |
384 $views[ $class ] = "\t<li class='$class'>$view"; |
413 $views[ $class ] = "\t<li class='$class'>$view"; |
385 } |
414 } |
386 echo implode( " |</li>\n", $views ) . "</li>\n"; |
415 echo implode( " |</li>\n", $views ) . "</li>\n"; |
387 echo "</ul>"; |
416 echo '</ul>'; |
388 } |
417 } |
389 |
418 |
390 /** |
419 /** |
391 * Get an associative array ( option_name => option_title ) with the list |
420 * Get an associative array ( option_name => option_title ) with the list |
392 * of bulk actions available on this table. |
421 * of bulk actions available on this table. |
453 * @since 3.1.0 |
483 * @since 3.1.0 |
454 * |
484 * |
455 * @return string|false The action name or False if no action was selected |
485 * @return string|false The action name or False if no action was selected |
456 */ |
486 */ |
457 public function current_action() { |
487 public function current_action() { |
458 if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) |
488 if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
459 return false; |
489 return false; |
460 |
490 } |
461 if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) |
491 |
|
492 if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { |
462 return $_REQUEST['action']; |
493 return $_REQUEST['action']; |
463 |
494 } |
464 if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) |
495 |
|
496 if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { |
465 return $_REQUEST['action2']; |
497 return $_REQUEST['action2']; |
|
498 } |
466 |
499 |
467 return false; |
500 return false; |
468 } |
501 } |
469 |
502 |
470 /** |
503 /** |
471 * Generate row actions div |
504 * Generate row actions div |
472 * |
505 * |
473 * @since 3.1.0 |
506 * @since 3.1.0 |
474 * |
507 * |
475 * @param array $actions The list of actions |
508 * @param string[] $actions An array of action links. |
476 * @param bool $always_visible Whether the actions should be always visible |
509 * @param bool $always_visible Whether the actions should be always visible. |
477 * @return string |
510 * @return string |
478 */ |
511 */ |
479 protected function row_actions( $actions, $always_visible = false ) { |
512 protected function row_actions( $actions, $always_visible = false ) { |
480 $action_count = count( $actions ); |
513 $action_count = count( $actions ); |
481 $i = 0; |
514 $i = 0; |
482 |
515 |
483 if ( !$action_count ) |
516 if ( ! $action_count ) { |
484 return ''; |
517 return ''; |
|
518 } |
485 |
519 |
486 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
520 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
487 foreach ( $actions as $action => $link ) { |
521 foreach ( $actions as $action => $link ) { |
488 ++$i; |
522 ++$i; |
489 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
523 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; |
490 $out .= "<span class='$action'>$link$sep</span>"; |
524 $out .= "<span class='$action'>$link$sep</span>"; |
491 } |
525 } |
492 $out .= '</div>'; |
526 $out .= '</div>'; |
493 |
527 |
494 $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; |
528 $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>'; |
495 |
529 |
546 */ |
585 */ |
547 $months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
586 $months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
548 |
587 |
549 $month_count = count( $months ); |
588 $month_count = count( $months ); |
550 |
589 |
551 if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) |
590 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
552 return; |
591 return; |
|
592 } |
553 |
593 |
554 $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
594 $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
555 ?> |
595 ?> |
556 <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> |
596 <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> |
557 <select name="m" id="filter-by-date"> |
597 <select name="m" id="filter-by-date"> |
558 <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
598 <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
559 <?php |
599 <?php |
560 foreach ( $months as $arc_row ) { |
600 foreach ( $months as $arc_row ) { |
561 if ( 0 == $arc_row->year ) |
601 if ( 0 == $arc_row->year ) { |
562 continue; |
602 continue; |
|
603 } |
563 |
604 |
564 $month = zeroise( $arc_row->month, 2 ); |
605 $month = zeroise( $arc_row->month, 2 ); |
565 $year = $arc_row->year; |
606 $year = $arc_row->year; |
566 |
607 |
567 printf( "<option %s value='%s'>%s</option>\n", |
608 printf( |
|
609 "<option %s value='%s'>%s</option>\n", |
568 selected( $m, $year . $month, false ), |
610 selected( $m, $year . $month, false ), |
569 esc_attr( $arc_row->year . $month ), |
611 esc_attr( $arc_row->year . $month ), |
570 /* translators: 1: month name, 2: 4-digit year */ |
612 /* translators: 1: month name, 2: 4-digit year */ |
571 sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) |
613 sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) |
572 ); |
614 ); |
573 } |
615 } |
574 ?> |
616 ?> |
575 </select> |
617 </select> |
576 <?php |
618 <?php |
577 } |
619 } |
578 |
620 |
579 /** |
621 /** |
580 * Display a view switcher |
622 * Display a view switcher |
581 * |
623 * |
582 * @since 3.1.0 |
624 * @since 3.1.0 |
583 * |
625 * |
584 * @param string $current_mode |
626 * @param string $current_mode |
585 */ |
627 */ |
586 protected function view_switcher( $current_mode ) { |
628 protected function view_switcher( $current_mode ) { |
587 ?> |
629 ?> |
588 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
630 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
589 <div class="view-switch"> |
631 <div class="view-switch"> |
590 <?php |
632 <?php |
591 foreach ( $this->modes as $mode => $title ) { |
633 foreach ( $this->modes as $mode => $title ) { |
592 $classes = array( 'view-' . $mode ); |
634 $classes = array( 'view-' . $mode ); |
593 if ( $current_mode === $mode ) |
635 if ( $current_mode === $mode ) { |
594 $classes[] = 'current'; |
636 $classes[] = 'current'; |
595 printf( |
|
596 "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
|
597 esc_url( add_query_arg( 'mode', $mode ) ), |
|
598 implode( ' ', $classes ), |
|
599 $title |
|
600 ); |
|
601 } |
637 } |
|
638 printf( |
|
639 "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", |
|
640 esc_url( add_query_arg( 'mode', $mode ) ), |
|
641 implode( ' ', $classes ), |
|
642 $title |
|
643 ); |
|
644 } |
602 ?> |
645 ?> |
603 </div> |
646 </div> |
604 <?php |
647 <?php |
605 } |
648 } |
606 |
649 |
607 /** |
650 /** |
608 * Display a comment count bubble |
651 * Display a comment count bubble |
609 * |
652 * |
614 */ |
657 */ |
615 protected function comments_bubble( $post_id, $pending_comments ) { |
658 protected function comments_bubble( $post_id, $pending_comments ) { |
616 $approved_comments = get_comments_number(); |
659 $approved_comments = get_comments_number(); |
617 |
660 |
618 $approved_comments_number = number_format_i18n( $approved_comments ); |
661 $approved_comments_number = number_format_i18n( $approved_comments ); |
619 $pending_comments_number = number_format_i18n( $pending_comments ); |
662 $pending_comments_number = number_format_i18n( $pending_comments ); |
620 |
663 |
621 $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number ); |
664 $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number ); |
622 $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number ); |
665 $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number ); |
623 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); |
666 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); |
624 |
667 |
625 // No comments at all. |
668 // No comments at all. |
626 if ( ! $approved_comments && ! $pending_comments ) { |
669 if ( ! $approved_comments && ! $pending_comments ) { |
627 printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
670 printf( |
|
671 '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', |
628 __( 'No comments' ) |
672 __( 'No comments' ) |
629 ); |
673 ); |
630 // Approved comments have different display depending on some conditions. |
674 // Approved comments have different display depending on some conditions. |
631 } elseif ( $approved_comments ) { |
675 } elseif ( $approved_comments ) { |
632 printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
676 printf( |
633 esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ), |
677 '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
678 esc_url( |
|
679 add_query_arg( |
|
680 array( |
|
681 'p' => $post_id, |
|
682 'comment_status' => 'approved', |
|
683 ), |
|
684 admin_url( 'edit-comments.php' ) |
|
685 ) |
|
686 ), |
634 $approved_comments_number, |
687 $approved_comments_number, |
635 $pending_comments ? $approved_phrase : $approved_only_phrase |
688 $pending_comments ? $approved_phrase : $approved_only_phrase |
636 ); |
689 ); |
637 } else { |
690 } else { |
638 printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
691 printf( |
|
692 '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
639 $approved_comments_number, |
693 $approved_comments_number, |
640 $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) |
694 $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) |
641 ); |
695 ); |
642 } |
696 } |
643 |
697 |
644 if ( $pending_comments ) { |
698 if ( $pending_comments ) { |
645 printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
699 printf( |
646 esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ), |
700 '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
|
701 esc_url( |
|
702 add_query_arg( |
|
703 array( |
|
704 'p' => $post_id, |
|
705 'comment_status' => 'moderated', |
|
706 ), |
|
707 admin_url( 'edit-comments.php' ) |
|
708 ) |
|
709 ), |
647 $pending_comments_number, |
710 $pending_comments_number, |
648 $pending_phrase |
711 $pending_phrase |
649 ); |
712 ); |
650 } else { |
713 } else { |
651 printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
714 printf( |
|
715 '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', |
652 $pending_comments_number, |
716 $pending_comments_number, |
653 $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) |
717 $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) |
654 ); |
718 ); |
655 } |
719 } |
656 } |
720 } |
738 $total_pages_before = '<span class="paging-input">'; |
804 $total_pages_before = '<span class="paging-input">'; |
739 $total_pages_after = '</span></span>'; |
805 $total_pages_after = '</span></span>'; |
740 |
806 |
741 $disable_first = $disable_last = $disable_prev = $disable_next = false; |
807 $disable_first = $disable_last = $disable_prev = $disable_next = false; |
742 |
808 |
743 if ( $current == 1 ) { |
809 if ( $current == 1 ) { |
744 $disable_first = true; |
810 $disable_first = true; |
745 $disable_prev = true; |
811 $disable_prev = true; |
746 } |
812 } |
747 if ( $current == 2 ) { |
813 if ( $current == 2 ) { |
748 $disable_first = true; |
814 $disable_first = true; |
749 } |
815 } |
750 if ( $current == $total_pages ) { |
816 if ( $current == $total_pages ) { |
751 $disable_last = true; |
817 $disable_last = true; |
752 $disable_next = true; |
818 $disable_next = true; |
753 } |
819 } |
754 if ( $current == $total_pages - 1 ) { |
820 if ( $current == $total_pages - 1 ) { |
755 $disable_last = true; |
821 $disable_last = true; |
756 } |
822 } |
757 |
823 |
758 if ( $disable_first ) { |
824 if ( $disable_first ) { |
759 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>'; |
825 $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">«</span>'; |
760 } else { |
826 } else { |
761 $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
827 $page_links[] = sprintf( |
|
828 "<a class='first-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
762 esc_url( remove_query_arg( 'paged', $current_url ) ), |
829 esc_url( remove_query_arg( 'paged', $current_url ) ), |
763 __( 'First page' ), |
830 __( 'First page' ), |
764 '«' |
831 '«' |
765 ); |
832 ); |
766 } |
833 } |
767 |
834 |
768 if ( $disable_prev ) { |
835 if ( $disable_prev ) { |
769 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; |
836 $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</span>'; |
770 } else { |
837 } else { |
771 $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
838 $page_links[] = sprintf( |
772 esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), |
839 "<a class='prev-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
840 esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), |
773 __( 'Previous page' ), |
841 __( 'Previous page' ), |
774 '‹' |
842 '‹' |
775 ); |
843 ); |
776 } |
844 } |
777 |
845 |
778 if ( 'bottom' === $which ) { |
846 if ( 'bottom' === $which ) { |
779 $html_current_page = $current; |
847 $html_current_page = $current; |
780 $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
848 $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; |
781 } else { |
849 } else { |
782 $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", |
850 $html_current_page = sprintf( |
|
851 "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", |
783 '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', |
852 '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', |
784 $current, |
853 $current, |
785 strlen( $total_pages ) |
854 strlen( $total_pages ) |
786 ); |
855 ); |
787 } |
856 } |
788 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
857 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
789 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; |
858 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; |
790 |
859 |
791 if ( $disable_next ) { |
860 if ( $disable_next ) { |
792 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; |
861 $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">›</span>'; |
793 } else { |
862 } else { |
794 $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
863 $page_links[] = sprintf( |
795 esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), |
864 "<a class='next-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
|
865 esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), |
796 __( 'Next page' ), |
866 __( 'Next page' ), |
797 '›' |
867 '›' |
798 ); |
868 ); |
799 } |
869 } |
800 |
870 |
801 if ( $disable_last ) { |
871 if ( $disable_last ) { |
802 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>'; |
872 $page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">»</span>'; |
803 } else { |
873 } else { |
804 $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
874 $page_links[] = sprintf( |
|
875 "<a class='last-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", |
805 esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
876 esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
806 __( 'Last page' ), |
877 __( 'Last page' ), |
807 '»' |
878 '»' |
808 ); |
879 ); |
809 } |
880 } |
1033 |
1106 |
1034 if ( in_array( $column_key, $hidden ) ) { |
1107 if ( in_array( $column_key, $hidden ) ) { |
1035 $class[] = 'hidden'; |
1108 $class[] = 'hidden'; |
1036 } |
1109 } |
1037 |
1110 |
1038 if ( 'cb' === $column_key ) |
1111 if ( 'cb' === $column_key ) { |
1039 $class[] = 'check-column'; |
1112 $class[] = 'check-column'; |
1040 elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) |
1113 } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { |
1041 $class[] = 'num'; |
1114 $class[] = 'num'; |
|
1115 } |
1042 |
1116 |
1043 if ( $column_key === $primary ) { |
1117 if ( $column_key === $primary ) { |
1044 $class[] = 'column-primary'; |
1118 $class[] = 'column-primary'; |
1045 } |
1119 } |
1046 |
1120 |
1047 if ( isset( $sortable[$column_key] ) ) { |
1121 if ( isset( $sortable[ $column_key ] ) ) { |
1048 list( $orderby, $desc_first ) = $sortable[$column_key]; |
1122 list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
1049 |
1123 |
1050 if ( $current_orderby === $orderby ) { |
1124 if ( $current_orderby === $orderby ) { |
1051 $order = 'asc' === $current_order ? 'desc' : 'asc'; |
1125 $order = 'asc' === $current_order ? 'desc' : 'asc'; |
1052 $class[] = 'sorted'; |
1126 $class[] = 'sorted'; |
1053 $class[] = $current_order; |
1127 $class[] = $current_order; |
1054 } else { |
1128 } else { |
1055 $order = $desc_first ? 'desc' : 'asc'; |
1129 $order = $desc_first ? 'desc' : 'asc'; |
1056 $class[] = 'sortable'; |
1130 $class[] = 'sortable'; |
1057 $class[] = $desc_first ? 'asc' : 'desc'; |
1131 $class[] = $desc_first ? 'asc' : 'desc'; |
1058 } |
1132 } |
1059 |
1133 |
1060 $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
1134 $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; |
1061 } |
1135 } |
1062 |
1136 |
1063 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
1137 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
1064 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1138 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
1065 $id = $with_id ? "id='$column_key'" : ''; |
1139 $id = $with_id ? "id='$column_key'" : ''; |
1066 |
1140 |
1067 if ( !empty( $class ) ) |
1141 if ( ! empty( $class ) ) { |
1068 $class = "class='" . join( ' ', $class ) . "'"; |
1142 $class = "class='" . join( ' ', $class ) . "'"; |
|
1143 } |
1069 |
1144 |
1070 echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
1145 echo "<$tag $scope $id $class>$column_display_name</$tag>"; |
1071 } |
1146 } |
1072 } |
1147 } |
1073 |
1148 |
1296 _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
1374 _n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
1297 number_format_i18n( $this->_pagination_args['total_items'] ) |
1375 number_format_i18n( $this->_pagination_args['total_items'] ) |
1298 ); |
1376 ); |
1299 } |
1377 } |
1300 if ( isset( $this->_pagination_args['total_pages'] ) ) { |
1378 if ( isset( $this->_pagination_args['total_pages'] ) ) { |
1301 $response['total_pages'] = $this->_pagination_args['total_pages']; |
1379 $response['total_pages'] = $this->_pagination_args['total_pages']; |
1302 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
1380 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
1303 } |
1381 } |
1304 |
1382 |
1305 die( wp_json_encode( $response ) ); |
1383 die( wp_json_encode( $response ) ); |
1306 } |
1384 } |
1307 |
1385 |
1308 /** |
1386 /** |
1309 * Send required variables to JavaScript land |
1387 * Send required variables to JavaScript land |
1310 * |
|
1311 */ |
1388 */ |
1312 public function _js_vars() { |
1389 public function _js_vars() { |
1313 $args = array( |
1390 $args = array( |
1314 'class' => get_class( $this ), |
1391 'class' => get_class( $this ), |
1315 'screen' => array( |
1392 'screen' => array( |
1316 'id' => $this->screen->id, |
1393 'id' => $this->screen->id, |
1317 'base' => $this->screen->base, |
1394 'base' => $this->screen->base, |
1318 ) |
1395 ), |
1319 ); |
1396 ); |
1320 |
1397 |
1321 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
1398 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
1322 } |
1399 } |
1323 } |
1400 } |