25 * @see WP_List_Table::__construct() for more information on default arguments. |
25 * @see WP_List_Table::__construct() for more information on default arguments. |
26 * |
26 * |
27 * @param array $args An associative array of arguments. |
27 * @param array $args An associative array of arguments. |
28 */ |
28 */ |
29 public function __construct( $args = array() ) { |
29 public function __construct( $args = array() ) { |
30 parent::__construct( array( |
30 parent::__construct( |
31 'plural' => 'bookmarks', |
31 array( |
32 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
32 'plural' => 'bookmarks', |
33 ) ); |
33 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
34 } |
34 ) |
35 |
35 ); |
36 /** |
36 } |
37 * |
37 |
|
38 /** |
38 * @return bool |
39 * @return bool |
39 */ |
40 */ |
40 public function ajax_user_can() { |
41 public function ajax_user_can() { |
41 return current_user_can( 'manage_links' ); |
42 return current_user_can( 'manage_links' ); |
42 } |
43 } |
43 |
44 |
44 /** |
45 /** |
45 * |
|
46 * @global int $cat_id |
46 * @global int $cat_id |
47 * @global string $s |
47 * @global string $s |
48 * @global string $orderby |
48 * @global string $orderby |
49 * @global string $order |
49 * @global string $order |
50 */ |
50 */ |
51 public function prepare_items() { |
51 public function prepare_items() { |
52 global $cat_id, $s, $orderby, $order; |
52 global $cat_id, $s, $orderby, $order; |
53 |
53 |
54 wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
54 wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
55 |
55 |
56 $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
56 $args = array( |
57 |
57 'hide_invisible' => 0, |
58 if ( 'all' != $cat_id ) |
58 'hide_empty' => 0, |
|
59 ); |
|
60 |
|
61 if ( 'all' != $cat_id ) { |
59 $args['category'] = $cat_id; |
62 $args['category'] = $cat_id; |
60 if ( !empty( $s ) ) |
63 } |
|
64 if ( ! empty( $s ) ) { |
61 $args['search'] = $s; |
65 $args['search'] = $s; |
62 if ( !empty( $orderby ) ) |
66 } |
|
67 if ( ! empty( $orderby ) ) { |
63 $args['orderby'] = $orderby; |
68 $args['orderby'] = $orderby; |
64 if ( !empty( $order ) ) |
69 } |
|
70 if ( ! empty( $order ) ) { |
65 $args['order'] = $order; |
71 $args['order'] = $order; |
|
72 } |
66 |
73 |
67 $this->items = get_bookmarks( $args ); |
74 $this->items = get_bookmarks( $args ); |
68 } |
75 } |
69 |
76 |
70 /** |
77 /** |
72 public function no_items() { |
79 public function no_items() { |
73 _e( 'No links found.' ); |
80 _e( 'No links found.' ); |
74 } |
81 } |
75 |
82 |
76 /** |
83 /** |
77 * |
|
78 * @return array |
84 * @return array |
79 */ |
85 */ |
80 protected function get_bulk_actions() { |
86 protected function get_bulk_actions() { |
81 $actions = array(); |
87 $actions = array(); |
82 $actions['delete'] = __( 'Delete' ); |
88 $actions['delete'] = __( 'Delete' ); |
83 |
89 |
84 return $actions; |
90 return $actions; |
85 } |
91 } |
86 |
92 |
87 /** |
93 /** |
88 * |
|
89 * @global int $cat_id |
94 * @global int $cat_id |
90 * @param string $which |
95 * @param string $which |
91 */ |
96 */ |
92 protected function extra_tablenav( $which ) { |
97 protected function extra_tablenav( $which ) { |
93 global $cat_id; |
98 global $cat_id; |
94 |
99 |
95 if ( 'top' != $which ) |
100 if ( 'top' != $which ) { |
96 return; |
101 return; |
97 ?> |
102 } |
|
103 ?> |
98 <div class="alignleft actions"> |
104 <div class="alignleft actions"> |
99 <?php |
105 <?php |
100 $dropdown_options = array( |
106 $dropdown_options = array( |
101 'selected' => $cat_id, |
107 'selected' => $cat_id, |
102 'name' => 'cat_id', |
108 'name' => 'cat_id', |
103 'taxonomy' => 'link_category', |
109 'taxonomy' => 'link_category', |
104 'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items, |
110 'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items, |
105 'hide_empty' => true, |
111 'hide_empty' => true, |
106 'hierarchical' => 1, |
112 'hierarchical' => 1, |
107 'show_count' => 0, |
113 'show_count' => 0, |
108 'orderby' => 'name', |
114 'orderby' => 'name', |
109 ); |
115 ); |
110 |
116 |
111 echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; |
117 echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; |
112 wp_dropdown_categories( $dropdown_options ); |
118 wp_dropdown_categories( $dropdown_options ); |
113 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
119 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
114 ?> |
120 ?> |
115 </div> |
121 </div> |
116 <?php |
122 <?php |
117 } |
123 } |
118 |
124 |
119 /** |
125 /** |
120 * |
|
121 * @return array |
126 * @return array |
122 */ |
127 */ |
123 public function get_columns() { |
128 public function get_columns() { |
124 return array( |
129 return array( |
125 'cb' => '<input type="checkbox" />', |
130 'cb' => '<input type="checkbox" />', |
126 'name' => _x( 'Name', 'link name' ), |
131 'name' => _x( 'Name', 'link name' ), |
127 'url' => __( 'URL' ), |
132 'url' => __( 'URL' ), |
128 'categories' => __( 'Categories' ), |
133 'categories' => __( 'Categories' ), |
129 'rel' => __( 'Relationship' ), |
134 'rel' => __( 'Relationship' ), |
130 'visible' => __( 'Visible' ), |
135 'visible' => __( 'Visible' ), |
131 'rating' => __( 'Rating' ) |
136 'rating' => __( 'Rating' ), |
132 ); |
137 ); |
133 } |
138 } |
134 |
139 |
135 /** |
140 /** |
136 * |
|
137 * @return array |
141 * @return array |
138 */ |
142 */ |
139 protected function get_sortable_columns() { |
143 protected function get_sortable_columns() { |
140 return array( |
144 return array( |
141 'name' => 'name', |
145 'name' => 'name', |
142 'url' => 'url', |
146 'url' => 'url', |
143 'visible' => 'visible', |
147 'visible' => 'visible', |
144 'rating' => 'rating' |
148 'rating' => 'rating', |
145 ); |
149 ); |
146 } |
150 } |
147 |
151 |
148 /** |
152 /** |
149 * Get the name of the default primary column. |
153 * Get the name of the default primary column. |
177 * |
181 * |
178 * @param object $link The current link object. |
182 * @param object $link The current link object. |
179 */ |
183 */ |
180 public function column_name( $link ) { |
184 public function column_name( $link ) { |
181 $edit_link = get_edit_bookmark_link( $link ); |
185 $edit_link = get_edit_bookmark_link( $link ); |
182 printf( '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>', |
186 printf( |
|
187 '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>', |
183 $edit_link, |
188 $edit_link, |
184 /* translators: %s: link name */ |
189 /* translators: %s: link name */ |
185 esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ), |
190 esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ), |
186 $link->link_name |
191 $link->link_name |
187 ); |
192 ); |
283 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
288 do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
284 } |
289 } |
285 |
290 |
286 public function display_rows() { |
291 public function display_rows() { |
287 foreach ( $this->items as $link ) { |
292 foreach ( $this->items as $link ) { |
288 $link = sanitize_bookmark( $link ); |
293 $link = sanitize_bookmark( $link ); |
289 $link->link_name = esc_attr( $link->link_name ); |
294 $link->link_name = esc_attr( $link->link_name ); |
290 $link->link_category = wp_get_link_cats( $link->link_id ); |
295 $link->link_category = wp_get_link_cats( $link->link_id ); |
291 ?> |
296 ?> |
292 <tr id="link-<?php echo $link->link_id; ?>"> |
297 <tr id="link-<?php echo $link->link_id; ?>"> |
293 <?php $this->single_row_columns( $link ) ?> |
298 <?php $this->single_row_columns( $link ); ?> |
294 </tr> |
299 </tr> |
295 <?php |
300 <?php |
296 } |
301 } |
297 } |
302 } |
298 |
303 |
299 /** |
304 /** |
300 * Generates and displays row action links. |
305 * Generates and displays row action links. |
311 return ''; |
316 return ''; |
312 } |
317 } |
313 |
318 |
314 $edit_link = get_edit_bookmark_link( $link ); |
319 $edit_link = get_edit_bookmark_link( $link ); |
315 |
320 |
316 $actions = array(); |
321 $actions = array(); |
317 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
322 $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
318 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>"; |
323 $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . '</a>'; |
319 return $this->row_actions( $actions ); |
324 return $this->row_actions( $actions ); |
320 } |
325 } |
321 } |
326 } |