7 * @since 3.1.0 |
7 * @since 3.1.0 |
8 * @access private |
8 * @access private |
9 */ |
9 */ |
10 class WP_Links_List_Table extends WP_List_Table { |
10 class WP_Links_List_Table extends WP_List_Table { |
11 |
11 |
12 function __construct( $args = array() ) { |
12 /** |
|
13 * Constructor. |
|
14 * |
|
15 * @since 3.1.0 |
|
16 * @access public |
|
17 * |
|
18 * @see WP_List_Table::__construct() for more information on default arguments. |
|
19 * |
|
20 * @param array $args An associative array of arguments. |
|
21 */ |
|
22 public function __construct( $args = array() ) { |
13 parent::__construct( array( |
23 parent::__construct( array( |
14 'plural' => 'bookmarks', |
24 'plural' => 'bookmarks', |
15 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
25 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
16 ) ); |
26 ) ); |
17 } |
27 } |
18 |
28 |
19 function ajax_user_can() { |
29 public function ajax_user_can() { |
20 return current_user_can( 'manage_links' ); |
30 return current_user_can( 'manage_links' ); |
21 } |
31 } |
22 |
32 |
23 function prepare_items() { |
33 public function prepare_items() { |
24 global $cat_id, $s, $orderby, $order; |
34 global $cat_id, $s, $orderby, $order; |
25 |
35 |
26 wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
36 wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
27 |
37 |
28 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
38 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
37 $args['order'] = $order; |
47 $args['order'] = $order; |
38 |
48 |
39 $this->items = get_bookmarks( $args ); |
49 $this->items = get_bookmarks( $args ); |
40 } |
50 } |
41 |
51 |
42 function no_items() { |
52 public function no_items() { |
43 _e( 'No links found.' ); |
53 _e( 'No links found.' ); |
44 } |
54 } |
45 |
55 |
46 function get_bulk_actions() { |
56 protected function get_bulk_actions() { |
47 $actions = array(); |
57 $actions = array(); |
48 $actions['delete'] = __( 'Delete' ); |
58 $actions['delete'] = __( 'Delete' ); |
49 |
59 |
50 return $actions; |
60 return $actions; |
51 } |
61 } |
52 |
62 |
53 function extra_tablenav( $which ) { |
63 protected function extra_tablenav( $which ) { |
54 global $cat_id; |
64 global $cat_id; |
55 |
65 |
56 if ( 'top' != $which ) |
66 if ( 'top' != $which ) |
57 return; |
67 return; |
58 ?> |
68 ?> |
60 <?php |
70 <?php |
61 $dropdown_options = array( |
71 $dropdown_options = array( |
62 'selected' => $cat_id, |
72 'selected' => $cat_id, |
63 'name' => 'cat_id', |
73 'name' => 'cat_id', |
64 'taxonomy' => 'link_category', |
74 'taxonomy' => 'link_category', |
65 'show_option_all' => __( 'View all categories' ), |
75 'show_option_all' => __( 'All categories' ), |
66 'hide_empty' => true, |
76 'hide_empty' => true, |
67 'hierarchical' => 1, |
77 'hierarchical' => 1, |
68 'show_count' => 0, |
78 'show_count' => 0, |
69 'orderby' => 'name', |
79 'orderby' => 'name', |
70 ); |
80 ); |
|
81 |
|
82 echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; |
71 wp_dropdown_categories( $dropdown_options ); |
83 wp_dropdown_categories( $dropdown_options ); |
72 submit_button( __( 'Filter' ), 'button', false, false, array( 'id' => 'post-query-submit' ) ); |
84 submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
73 ?> |
85 ?> |
74 </div> |
86 </div> |
75 <?php |
87 <?php |
76 } |
88 } |
77 |
89 |
78 function get_columns() { |
90 public function get_columns() { |
79 return array( |
91 return array( |
80 'cb' => '<input type="checkbox" />', |
92 'cb' => '<input type="checkbox" />', |
81 'name' => _x( 'Name', 'link name' ), |
93 'name' => _x( 'Name', 'link name' ), |
82 'url' => __( 'URL' ), |
94 'url' => __( 'URL' ), |
83 'categories' => __( 'Categories' ), |
95 'categories' => __( 'Categories' ), |
85 'visible' => __( 'Visible' ), |
97 'visible' => __( 'Visible' ), |
86 'rating' => __( 'Rating' ) |
98 'rating' => __( 'Rating' ) |
87 ); |
99 ); |
88 } |
100 } |
89 |
101 |
90 function get_sortable_columns() { |
102 protected function get_sortable_columns() { |
91 return array( |
103 return array( |
92 'name' => 'name', |
104 'name' => 'name', |
93 'url' => 'url', |
105 'url' => 'url', |
94 'visible' => 'visible', |
106 'visible' => 'visible', |
95 'rating' => 'rating' |
107 'rating' => 'rating' |
96 ); |
108 ); |
97 } |
109 } |
98 |
110 |
99 function display_rows() { |
111 public function display_rows() { |
100 global $cat_id; |
112 global $cat_id; |
101 |
|
102 $alt = 0; |
|
103 |
113 |
104 foreach ( $this->items as $link ) { |
114 foreach ( $this->items as $link ) { |
105 $link = sanitize_bookmark( $link ); |
115 $link = sanitize_bookmark( $link ); |
106 $link->link_name = esc_attr( $link->link_name ); |
116 $link->link_name = esc_attr( $link->link_name ); |
107 $link->link_category = wp_get_link_cats( $link->link_id ); |
117 $link->link_category = wp_get_link_cats( $link->link_id ); |
108 |
118 |
109 $short_url = url_shorten( $link->link_url ); |
119 $short_url = url_shorten( $link->link_url ); |
110 |
120 |
111 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); |
121 $visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' ); |
112 $rating = $link->link_rating; |
122 $rating = $link->link_rating; |
113 $style = ( $alt++ % 2 ) ? '' : ' class="alternate"'; |
|
114 |
123 |
115 $edit_link = get_edit_bookmark_link( $link ); |
124 $edit_link = get_edit_bookmark_link( $link ); |
116 ?> |
125 ?> |
117 <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> |
126 <tr id="link-<?php echo $link->link_id; ?>"> |
118 <?php |
127 <?php |
119 |
128 |
120 list( $columns, $hidden ) = $this->get_column_info(); |
129 list( $columns, $hidden ) = $this->get_column_info(); |
121 |
130 |
122 foreach ( $columns as $column_name => $column_display_name ) { |
131 foreach ( $columns as $column_name => $column_display_name ) { |
174 case 'rating': |
183 case 'rating': |
175 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php |
184 ?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php |
176 break; |
185 break; |
177 default: |
186 default: |
178 ?> |
187 ?> |
179 <td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td> |
188 <td <?php echo $attributes ?>><?php |
|
189 /** |
|
190 * Fires for each registered custom link column. |
|
191 * |
|
192 * @since 2.1.0 |
|
193 * |
|
194 * @param string $column_name Name of the custom column. |
|
195 * @param int $link_id Link ID. |
|
196 */ |
|
197 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
|
198 ?></td> |
180 <?php |
199 <?php |
181 break; |
200 break; |
182 } |
201 } |
183 } |
202 } |
184 ?> |
203 ?> |