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rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / class-wc-admin-webhooks-table-list.php
woocommerce / includes / admin Last commit date
helper 2 months ago importers 1 year ago list-tables 1 month ago marketplace-suggestions 11 months ago meta-boxes 1 month ago notes 2 months ago plugin-updates 2 years ago reports 3 months ago settings 6 days ago views 1 month ago class-wc-admin-addons.php 9 months ago class-wc-admin-api-keys-table-list.php 2 years ago class-wc-admin-api-keys.php 11 months ago class-wc-admin-assets.php 1 month ago class-wc-admin-attributes.php 1 month ago class-wc-admin-brands.php 4 months ago class-wc-admin-customize.php 5 years ago class-wc-admin-dashboard-setup.php 1 month ago class-wc-admin-dashboard.php 4 months ago class-wc-admin-duplicate-product.php 5 months ago class-wc-admin-exporters.php 1 year ago class-wc-admin-help.php 2 years ago class-wc-admin-importers.php 11 months ago class-wc-admin-log-table-list.php 4 months ago class-wc-admin-marketplace-promotions.php 4 months ago class-wc-admin-menus.php 1 month ago class-wc-admin-meta-boxes.php 1 month ago class-wc-admin-notices.php 1 month ago class-wc-admin-permalink-settings.php 5 years ago class-wc-admin-pointers.php 3 years ago class-wc-admin-post-types.php 1 year ago class-wc-admin-profile.php 1 year ago class-wc-admin-reports.php 4 months ago class-wc-admin-settings.php 3 months ago class-wc-admin-setup-wizard.php 1 month ago class-wc-admin-status.php 1 year ago class-wc-admin-taxonomies.php 1 month ago class-wc-admin-upload-downloadable-product.php 2 years ago class-wc-admin-webhooks-table-list.php 1 month ago class-wc-admin-webhooks.php 1 month ago class-wc-admin.php 3 months ago wc-admin-functions.php 7 months ago wc-meta-box-functions.php 1 year ago woocommerce-legacy-reports.php 1 year ago
class-wc-admin-webhooks-table-list.php
338 lines
1 <?php
2 /**
3 * WooCommerce Webhooks Table List
4 *
5 * @package WooCommerce\Admin
6 * @version 3.3.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 if ( ! class_exists( 'WP_List_Table' ) ) {
12 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 }
14
15 /**
16 * Webhooks table list class.
17 */
18 class WC_Admin_Webhooks_Table_List extends WP_List_Table {
19
20 /**
21 * Initialize the webhook table list.
22 */
23 public function __construct() {
24 parent::__construct(
25 array(
26 'singular' => 'webhook',
27 'plural' => 'webhooks',
28 'ajax' => false,
29 )
30 );
31 }
32
33 /**
34 * No items found text.
35 */
36 public function no_items() {
37 esc_html_e( 'No webhooks found.', 'woocommerce' );
38 }
39
40 /**
41 * Get list columns.
42 *
43 * @return array
44 */
45 public function get_columns() {
46 return array(
47 'cb' => '<input type="checkbox" />',
48 'title' => __( 'Name', 'woocommerce' ),
49 'status' => __( 'Status', 'woocommerce' ),
50 'topic' => __( 'Topic', 'woocommerce' ),
51 'delivery_url' => __( 'Delivery URL', 'woocommerce' ),
52 );
53 }
54
55 /**
56 * Column cb.
57 *
58 * @param WC_Webhook $webhook Webhook instance.
59 * @return string
60 */
61 public function column_cb( $webhook ) {
62 return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_args['singular'], $webhook->get_id() );
63 }
64
65 /**
66 * Return title column.
67 *
68 * @param WC_Webhook $webhook Webhook instance.
69 * @return string
70 */
71 public function column_title( $webhook ) {
72 $edit_link = admin_url( 'admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;edit-webhook=' . $webhook->get_id() );
73 $output = '<strong><a href="' . esc_url( $edit_link ) . '" class="row-title">' . esc_html( $webhook->get_name() ) . '</a></strong>';
74
75 // Get actions.
76 $actions = array(
77 /* translators: %s: webhook ID. */
78 'id' => sprintf( __( 'ID: %d', 'woocommerce' ), $webhook->get_id() ),
79 'edit' => '<a href="' . esc_url( $edit_link ) . '">' . esc_html__( 'Edit', 'woocommerce' ) . '</a>',
80 /* translators: %s: webhook name */
81 'delete' => '<a class="submitdelete" aria-label="' . esc_attr( sprintf( __( 'Delete "%s" permanently', 'woocommerce' ), $webhook->get_name() ) ) . '" href="' . esc_url(
82 wp_nonce_url(
83 add_query_arg(
84 array(
85 'delete' => $webhook->get_id(),
86 ),
87 admin_url( 'admin.php?page=wc-settings&tab=advanced&section=webhooks' )
88 ),
89 'delete-webhook'
90 )
91 ) . '">' . esc_html__( 'Delete permanently', 'woocommerce' ) . '</a>',
92 );
93
94 $actions = apply_filters( 'webhook_row_actions', $actions, $webhook );
95 $row_actions = array();
96
97 foreach ( $actions as $action => $link ) {
98 $row_actions[] = '<span class="' . esc_attr( $action ) . '">' . $link . '</span>';
99 }
100
101 $output .= '<div class="row-actions">' . implode( ' | ', $row_actions ) . '</div>';
102
103 return $output;
104 }
105
106 /**
107 * Return status column.
108 *
109 * @param WC_Webhook $webhook Webhook instance.
110 * @return string
111 */
112 public function column_status( $webhook ) {
113 return $webhook->get_i18n_status();
114 }
115
116 /**
117 * Return topic column.
118 *
119 * @param WC_Webhook $webhook Webhook instance.
120 * @return string
121 */
122 public function column_topic( $webhook ) {
123 return $webhook->get_topic();
124 }
125
126 /**
127 * Return delivery URL column.
128 *
129 * @param WC_Webhook $webhook Webhook instance.
130 * @return string
131 */
132 public function column_delivery_url( $webhook ) {
133 return $webhook->get_delivery_url();
134 }
135
136 /**
137 * Get the status label for webhooks.
138 *
139 * @param string $status_name Status name.
140 * @param int $amount Amount of webhooks.
141 * @return array
142 */
143 private function get_status_label( $status_name, $amount ) {
144 $statuses = wc_get_webhook_statuses();
145
146 if ( isset( $statuses[ $status_name ] ) ) {
147 return array(
148 'singular' => sprintf( '%s <span class="count">(%s)</span>', esc_html( $statuses[ $status_name ] ), $amount ),
149 'plural' => sprintf( '%s <span class="count">(%s)</span>', esc_html( $statuses[ $status_name ] ), $amount ),
150 'context' => '',
151 'domain' => 'woocommerce',
152 );
153 }
154
155 return array(
156 'singular' => sprintf( '%s <span class="count">(%s)</span>', esc_html( $status_name ), $amount ),
157 'plural' => sprintf( '%s <span class="count">(%s)</span>', esc_html( $status_name ), $amount ),
158 'context' => '',
159 'domain' => 'woocommerce',
160 );
161 }
162
163 /**
164 * Table list views.
165 *
166 * @return array
167 */
168 protected function get_views() {
169 $status_links = array();
170 $data_store = WC_Data_Store::load( 'webhook' );
171 $num_webhooks = $data_store->get_count_webhooks_by_status();
172 $total_webhooks = array_sum( (array) $num_webhooks );
173 $statuses = array_keys( wc_get_webhook_statuses() );
174 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
175 $class = empty( $_REQUEST['status'] ) && empty( $_REQUEST['legacy'] ) ? ' class="current"' : '';
176
177 /* translators: %s: count */
178 $status_links['all'] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_webhooks, 'posts', 'woocommerce' ), number_format_i18n( $total_webhooks ) ) . '</a>';
179
180 foreach ( $statuses as $status_name ) {
181 $class = '';
182
183 if ( empty( $num_webhooks[ $status_name ] ) ) {
184 continue;
185 }
186
187 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
188 if ( isset( $_REQUEST['status'] ) && sanitize_key( wp_unslash( $_REQUEST['status'] ) ) === $status_name ) {
189 $class = ' class="current"';
190 }
191
192 $label = $this->get_status_label( $status_name, $num_webhooks[ $status_name ] );
193
194 $status_links[ $status_name ] = "<a href='admin.php?page=wc-settings&amp;tab=advanced&amp;section=webhooks&amp;status=$status_name'$class>" . sprintf( translate_nooped_plural( $label, $num_webhooks[ $status_name ] ), number_format_i18n( $num_webhooks[ $status_name ] ) ) . '</a>';
195 }
196
197 return $status_links;
198 }
199
200 /**
201 * Get bulk actions.
202 *
203 * @return array
204 */
205 protected function get_bulk_actions() {
206 return array(
207 'delete' => __( 'Delete permanently', 'woocommerce' ),
208 );
209 }
210
211 /**
212 * Process bulk actions.
213 */
214 public function process_bulk_action() {
215 $action = $this->current_action();
216 $webhooks = isset( $_REQUEST['webhook'] ) ? array_map( 'absint', (array) $_REQUEST['webhook'] ) : array(); // WPCS: input var okay, CSRF ok.
217
218 if ( false !== $action ) {
219 check_admin_referer( 'woocommerce-settings' );
220
221 if ( ! current_user_can( 'manage_woocommerce' ) ) {
222 wp_die( esc_html__( 'You do not have permission to edit Webhooks', 'woocommerce' ) );
223 }
224
225 if ( 'delete' === $action ) {
226 WC_Admin_Webhooks::bulk_delete( $webhooks );
227 }
228 }
229 }
230
231 /**
232 * Generate the table navigation above or below the table.
233 * Included to remove extra nonce input.
234 *
235 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
236 */
237 protected function display_tablenav( $which ) {
238 echo '<div class="tablenav ' . esc_attr( $which ) . '">';
239
240 if ( $this->has_items() ) {
241 echo '<div class="alignleft actions bulkactions">';
242 $this->bulk_actions( $which );
243 echo '</div>';
244 }
245
246 $this->extra_tablenav( $which );
247 $this->pagination( $which );
248 echo '<br class="clear" />';
249 echo '</div>';
250 }
251
252 /**
253 * Search box.
254 *
255 * @param string $text Button text.
256 * @param string $input_id Input ID.
257 */
258 public function search_box( $text, $input_id ) {
259 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { // WPCS: input var okay, CSRF ok.
260 return;
261 }
262
263 $input_id = $input_id . '-search-input';
264 $search_query = isset( $_REQUEST['s'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ) : ''; // WPCS: input var okay, CSRF ok.
265
266 echo '<p class="search-box">';
267 echo '<label class="screen-reader-text" for="' . esc_attr( $input_id ) . '">' . esc_html( $text ) . ':</label>';
268 echo '<input type="search" id="' . esc_attr( $input_id ) . '" name="s" value="' . esc_attr( $search_query ) . '" />';
269 submit_button(
270 $text,
271 '',
272 '',
273 false,
274 array(
275 'id' => 'search-submit',
276 )
277 );
278 echo '</p>';
279 }
280
281 /**
282 * Prepare table list items.
283 */
284 public function prepare_items() {
285 $per_page = $this->get_items_per_page( 'woocommerce_webhooks_per_page' );
286 $current_page = $this->get_pagenum();
287
288 // Query args.
289 $args = array(
290 'limit' => $per_page,
291 'offset' => $per_page * ( $current_page - 1 ),
292 );
293
294 // Handle the status query.
295 if ( ! empty( $_REQUEST['status'] ) ) { // WPCS: input var okay, CSRF ok.
296 $args['status'] = sanitize_key( wp_unslash( $_REQUEST['status'] ) ); // WPCS: input var okay, CSRF ok.
297 }
298
299 if ( ! empty( $_REQUEST['s'] ) ) { // WPCS: input var okay, CSRF ok.
300 $args['search'] = sanitize_text_field( wp_unslash( $_REQUEST['s'] ) ); // WPCS: input var okay, CSRF ok.
301 }
302
303 $args['paginate'] = true;
304
305 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
306 if ( 'true' === sanitize_key( wp_unslash( $_REQUEST['legacy'] ?? null ) ) ) {
307 $args['api_version'] = -1;
308 }
309
310 // Get the webhooks.
311 $data_store = WC_Data_Store::load( 'webhook' );
312 $webhooks = $data_store->search_webhooks( $args );
313 $this->items = array_map( 'wc_get_webhook', $webhooks->webhooks );
314
315 // Set the pagination.
316 $this->set_pagination_args(
317 array(
318 'total_items' => $webhooks->total,
319 'per_page' => $per_page,
320 'total_pages' => $webhooks->max_num_pages,
321 )
322 );
323 }
324
325 /**
326 * Get how many of the existing webhooks are configured to use the legacy payload format.
327 *
328 * @since 9.0.0
329 * @deprecated 10.8.0 The Legacy REST API has been removed from WooCommerce core. This always returns 0.
330 *
331 * @return int Always 0.
332 */
333 public function get_legacy_api_webhooks_count() {
334 wc_deprecated_function( __METHOD__, '10.8.0' );
335 return 0;
336 }
337 }
338