79 */ |
79 */ |
80 function __construct( $args = array() ) { |
80 function __construct( $args = array() ) { |
81 $args = wp_parse_args( $args, array( |
81 $args = wp_parse_args( $args, array( |
82 'plural' => '', |
82 'plural' => '', |
83 'singular' => '', |
83 'singular' => '', |
84 'ajax' => false |
84 'ajax' => false, |
|
85 'screen' => null, |
85 ) ); |
86 ) ); |
86 |
87 |
87 $screen = get_current_screen(); |
88 $this->screen = convert_to_screen( $args['screen'] ); |
88 |
89 |
89 add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 ); |
90 add_filter( "manage_{$this->screen->id}_columns", array( &$this, 'get_columns' ), 0 ); |
90 |
91 |
91 if ( !$args['plural'] ) |
92 if ( !$args['plural'] ) |
92 $args['plural'] = $screen->base; |
93 $args['plural'] = $this->screen->base; |
93 |
94 |
94 $args['plural'] = sanitize_key( $args['plural'] ); |
95 $args['plural'] = sanitize_key( $args['plural'] ); |
95 $args['singular'] = sanitize_key( $args['singular'] ); |
96 $args['singular'] = sanitize_key( $args['singular'] ); |
96 |
97 |
97 $this->_args = $args; |
98 $this->_args = $args; |
207 |
208 |
208 if ( ! empty( $_REQUEST['orderby'] ) ) |
209 if ( ! empty( $_REQUEST['orderby'] ) ) |
209 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
210 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
210 if ( ! empty( $_REQUEST['order'] ) ) |
211 if ( ! empty( $_REQUEST['order'] ) ) |
211 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
212 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
213 if ( ! empty( $_REQUEST['post_mime_type'] ) ) |
|
214 echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
|
215 if ( ! empty( $_REQUEST['detached'] ) ) |
|
216 echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
212 ?> |
217 ?> |
213 <p class="search-box"> |
218 <p class="search-box"> |
214 <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
219 <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
215 <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
220 <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
216 <?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?> |
221 <?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?> |
236 * |
241 * |
237 * @since 3.1.0 |
242 * @since 3.1.0 |
238 * @access public |
243 * @access public |
239 */ |
244 */ |
240 function views() { |
245 function views() { |
241 $screen = get_current_screen(); |
|
242 |
|
243 $views = $this->get_views(); |
246 $views = $this->get_views(); |
244 $views = apply_filters( 'views_' . $screen->id, $views ); |
247 $views = apply_filters( 'views_' . $this->screen->id, $views ); |
245 |
248 |
246 if ( empty( $views ) ) |
249 if ( empty( $views ) ) |
247 return; |
250 return; |
248 |
251 |
249 echo "<ul class='subsubsub'>\n"; |
252 echo "<ul class='subsubsub'>\n"; |
272 * |
275 * |
273 * @since 3.1.0 |
276 * @since 3.1.0 |
274 * @access public |
277 * @access public |
275 */ |
278 */ |
276 function bulk_actions() { |
279 function bulk_actions() { |
277 $screen = get_current_screen(); |
|
278 |
|
279 if ( is_null( $this->_actions ) ) { |
280 if ( is_null( $this->_actions ) ) { |
280 $no_new_actions = $this->_actions = $this->get_bulk_actions(); |
281 $no_new_actions = $this->_actions = $this->get_bulk_actions(); |
281 // This filter can currently only be used to remove actions. |
282 // This filter can currently only be used to remove actions. |
282 $this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions ); |
283 $this->_actions = apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions ); |
283 $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); |
284 $this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions ); |
284 $two = ''; |
285 $two = ''; |
285 } else { |
286 } else { |
286 $two = '2'; |
287 $two = '2'; |
287 } |
288 } |
298 echo "\t<option value='$name'$class>$title</option>\n"; |
299 echo "\t<option value='$name'$class>$title</option>\n"; |
299 } |
300 } |
300 |
301 |
301 echo "</select>\n"; |
302 echo "</select>\n"; |
302 |
303 |
303 submit_button( __( 'Apply' ), 'button-secondary action', false, false, array( 'id' => "doaction$two" ) ); |
304 submit_button( __( 'Apply' ), 'action', false, false, array( 'id' => "doaction$two" ) ); |
304 echo "\n"; |
305 echo "\n"; |
305 } |
306 } |
306 |
307 |
307 /** |
308 /** |
308 * Get the current action selected from the bulk actions dropdown. |
309 * Get the current action selected from the bulk actions dropdown. |
488 |
489 |
489 $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
490 $output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; |
490 |
491 |
491 $current = $this->get_pagenum(); |
492 $current = $this->get_pagenum(); |
492 |
493 |
493 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
494 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
494 |
495 |
495 $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); |
496 $current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); |
496 |
497 |
497 $page_links = array(); |
498 $page_links = array(); |
498 |
499 |
598 */ |
599 */ |
599 function get_column_info() { |
600 function get_column_info() { |
600 if ( isset( $this->_column_headers ) ) |
601 if ( isset( $this->_column_headers ) ) |
601 return $this->_column_headers; |
602 return $this->_column_headers; |
602 |
603 |
603 $screen = get_current_screen(); |
604 $columns = get_column_headers( $this->screen ); |
604 |
605 $hidden = get_hidden_columns( $this->screen ); |
605 $columns = get_column_headers( $screen ); |
606 |
606 $hidden = get_hidden_columns( $screen ); |
607 $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() ); |
607 |
|
608 $_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() ); |
|
609 |
608 |
610 $sortable = array(); |
609 $sortable = array(); |
611 foreach ( $_sortable as $id => $data ) { |
610 foreach ( $_sortable as $id => $data ) { |
612 if ( empty( $data ) ) |
611 if ( empty( $data ) ) |
613 continue; |
612 continue; |
645 * @access protected |
644 * @access protected |
646 * |
645 * |
647 * @param bool $with_id Whether to set the id attribute or not |
646 * @param bool $with_id Whether to set the id attribute or not |
648 */ |
647 */ |
649 function print_column_headers( $with_id = true ) { |
648 function print_column_headers( $with_id = true ) { |
650 $screen = get_current_screen(); |
|
651 |
|
652 list( $columns, $hidden, $sortable ) = $this->get_column_info(); |
649 list( $columns, $hidden, $sortable ) = $this->get_column_info(); |
653 |
650 |
654 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
651 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
655 $current_url = remove_query_arg( 'paged', $current_url ); |
652 $current_url = remove_query_arg( 'paged', $current_url ); |
656 |
653 |
657 if ( isset( $_GET['orderby'] ) ) |
654 if ( isset( $_GET['orderby'] ) ) |
658 $current_orderby = $_GET['orderby']; |
655 $current_orderby = $_GET['orderby']; |
659 else |
656 else |
661 |
658 |
662 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
659 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) |
663 $current_order = 'desc'; |
660 $current_order = 'desc'; |
664 else |
661 else |
665 $current_order = 'asc'; |
662 $current_order = 'asc'; |
|
663 |
|
664 if ( ! empty( $columns['cb'] ) ) { |
|
665 static $cb_counter = 1; |
|
666 $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' |
|
667 . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; |
|
668 $cb_counter++; |
|
669 } |
666 |
670 |
667 foreach ( $columns as $column_key => $column_display_name ) { |
671 foreach ( $columns as $column_key => $column_display_name ) { |
668 $class = array( 'manage-column', "column-$column_key" ); |
672 $class = array( 'manage-column', "column-$column_key" ); |
669 |
673 |
670 $style = ''; |
674 $style = ''; |
759 wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
763 wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
760 ?> |
764 ?> |
761 <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
765 <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
762 |
766 |
763 <div class="alignleft actions"> |
767 <div class="alignleft actions"> |
764 <?php $this->bulk_actions( $which ); ?> |
768 <?php $this->bulk_actions(); ?> |
765 </div> |
769 </div> |
766 <?php |
770 <?php |
767 $this->extra_tablenav( $which ); |
771 $this->extra_tablenav( $which ); |
768 $this->pagination( $which ); |
772 $this->pagination( $which ); |
769 ?> |
773 ?> |
901 * Send required variables to JavaScript land |
905 * Send required variables to JavaScript land |
902 * |
906 * |
903 * @access private |
907 * @access private |
904 */ |
908 */ |
905 function _js_vars() { |
909 function _js_vars() { |
906 $current_screen = get_current_screen(); |
|
907 |
|
908 $args = array( |
910 $args = array( |
909 'class' => get_class( $this ), |
911 'class' => get_class( $this ), |
910 'screen' => array( |
912 'screen' => array( |
911 'id' => $current_screen->id, |
913 'id' => $this->screen->id, |
912 'base' => $current_screen->base, |
914 'base' => $this->screen->base, |
913 ) |
915 ) |
914 ); |
916 ); |
915 |
917 |
916 printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) ); |
918 printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) ); |
917 } |
919 } |