equal
deleted
inserted
replaced
9 |
9 |
10 /** |
10 /** |
11 * Core class used to implement displaying links in a list table. |
11 * Core class used to implement displaying links in a list table. |
12 * |
12 * |
13 * @since 3.1.0 |
13 * @since 3.1.0 |
14 * @access private |
|
15 * |
14 * |
16 * @see WP_List_Table |
15 * @see WP_List_Table |
17 */ |
16 */ |
18 class WP_Links_List_Table extends WP_List_Table { |
17 class WP_Links_List_Table extends WP_List_Table { |
19 |
18 |
49 * @global string $order |
48 * @global string $order |
50 */ |
49 */ |
51 public function prepare_items() { |
50 public function prepare_items() { |
52 global $cat_id, $s, $orderby, $order; |
51 global $cat_id, $s, $orderby, $order; |
53 |
52 |
54 wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
53 $cat_id = ! empty( $_REQUEST['cat_id'] ) ? absint( $_REQUEST['cat_id'] ) : 0; |
|
54 $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
|
55 $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
|
56 $s = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
55 |
57 |
56 $args = array( |
58 $args = array( |
57 'hide_invisible' => 0, |
59 'hide_invisible' => 0, |
58 'hide_empty' => 0, |
60 'hide_empty' => 0, |
59 ); |
61 ); |
123 </div> |
125 </div> |
124 <?php |
126 <?php |
125 } |
127 } |
126 |
128 |
127 /** |
129 /** |
128 * @return array |
130 * @return string[] Array of column titles keyed by their column name. |
129 */ |
131 */ |
130 public function get_columns() { |
132 public function get_columns() { |
131 return array( |
133 return array( |
132 'cb' => '<input type="checkbox" />', |
134 'cb' => '<input type="checkbox" />', |
133 'name' => _x( 'Name', 'link name' ), |
135 'name' => _x( 'Name', 'link name' ), |
142 /** |
144 /** |
143 * @return array |
145 * @return array |
144 */ |
146 */ |
145 protected function get_sortable_columns() { |
147 protected function get_sortable_columns() { |
146 return array( |
148 return array( |
147 'name' => 'name', |
149 'name' => array( 'name', false, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ), |
148 'url' => 'url', |
150 'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ), |
149 'visible' => 'visible', |
151 'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ), |
150 'rating' => 'rating', |
152 'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ), |
151 ); |
153 ); |
152 } |
154 } |
153 |
155 |
154 /** |
156 /** |
155 * Get the name of the default primary column. |
157 * Gets the name of the default primary column. |
156 * |
158 * |
157 * @since 4.3.0 |
159 * @since 4.3.0 |
158 * |
160 * |
159 * @return string Name of the default primary column, in this case, 'name'. |
161 * @return string Name of the default primary column, in this case, 'name'. |
160 */ |
162 */ |
173 public function column_cb( $item ) { |
175 public function column_cb( $item ) { |
174 // Restores the more descriptive, specific name for use within this method. |
176 // Restores the more descriptive, specific name for use within this method. |
175 $link = $item; |
177 $link = $item; |
176 |
178 |
177 ?> |
179 ?> |
178 <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"> |
180 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> |
|
181 <label for="cb-select-<?php echo $link->link_id; ?>"> |
|
182 <span class="screen-reader-text"> |
179 <?php |
183 <?php |
180 /* translators: %s: Link name. */ |
184 /* translators: Hidden accessibility text. %s: Link name. */ |
181 printf( __( 'Select %s' ), $link->link_name ); |
185 printf( __( 'Select %s' ), $link->link_name ); |
182 ?> |
186 ?> |
|
187 </span> |
183 </label> |
188 </label> |
184 <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> |
|
185 <?php |
189 <?php |
186 } |
190 } |
187 |
191 |
188 /** |
192 /** |
189 * Handles the link name column output. |
193 * Handles the link name column output. |
287 * |
291 * |
288 * @param object $item Link object. |
292 * @param object $item Link object. |
289 * @param string $column_name Current column name. |
293 * @param string $column_name Current column name. |
290 */ |
294 */ |
291 public function column_default( $item, $column_name ) { |
295 public function column_default( $item, $column_name ) { |
|
296 // Restores the more descriptive, specific name for use within this method. |
|
297 $link = $item; |
|
298 |
292 /** |
299 /** |
293 * Fires for each registered custom link column. |
300 * Fires for each registered custom link column. |
294 * |
301 * |
295 * @since 2.1.0 |
302 * @since 2.1.0 |
296 * |
303 * |
297 * @param string $column_name Name of the custom column. |
304 * @param string $column_name Name of the custom column. |
298 * @param int $link_id Link ID. |
305 * @param int $link_id Link ID. |
299 */ |
306 */ |
300 do_action( 'manage_link_custom_column', $column_name, $item->link_id ); |
307 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
301 } |
308 } |
302 |
309 |
303 public function display_rows() { |
310 public function display_rows() { |
304 foreach ( $this->items as $link ) { |
311 foreach ( $this->items as $link ) { |
305 $link = sanitize_bookmark( $link ); |
312 $link = sanitize_bookmark( $link ); |
329 if ( $primary !== $column_name ) { |
336 if ( $primary !== $column_name ) { |
330 return ''; |
337 return ''; |
331 } |
338 } |
332 |
339 |
333 // Restores the more descriptive, specific name for use within this method. |
340 // Restores the more descriptive, specific name for use within this method. |
334 $link = $item; |
341 $link = $item; |
|
342 |
335 $edit_link = get_edit_bookmark_link( $link ); |
343 $edit_link = get_edit_bookmark_link( $link ); |
336 |
344 |
337 $actions = array(); |
345 $actions = array(); |
338 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
346 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
339 $actions['delete'] = sprintf( |
347 $actions['delete'] = sprintf( |