__('Webhook', 'wp-multisite-waas'), // singular name of the listed records 'plural' => __('Webhooks', 'wp-multisite-waas'), // plural name of the listed records 'ajax' => true, // does this table support ajax? 'add_new' => [ 'url' => wu_get_form_url('add_new_webhook_modal'), 'classes' => 'wubox', ], ] ); } /** * Displays the content of the name column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. */ public function column_name($item): string { $url_atts = [ 'id' => $item->get_id(), 'model' => 'webhook', ]; $title = sprintf( '%s ', wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts), $item->get_name(), $item->get_id(), __('Sending Test..', 'wp-multisite-waas') ); $actions = [ 'edit' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts), __('Edit', 'wp-multisite-waas')), 'test' => sprintf('%s', $item->get_webhook_url(), __('Send Test', 'wp-multisite-waas')), 'delete' => sprintf( '%s', __('Delete', 'wp-multisite-waas'), wu_get_form_url( 'delete_modal', $url_atts ), __('Delete', 'wp-multisite-waas') ), ]; return $title . $this->row_actions($actions); } /** * Displays the content of the webhook url column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. * @return string */ public function column_webhook_url($item) { $trimmed_url = mb_strimwidth((string) $item->get_webhook_url(), 0, 50, '...'); return "{$trimmed_url}"; } /** * Displays the content of the event column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. * @return string */ public function column_event($item) { $event = $item->get_event(); return "{$event}"; } /** * Displays the content of the count column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. */ public function column_count($item): string { $count = $item->get_count(); $actions = [ 'edit' => sprintf('%s', '', __('See Events', 'wp-multisite-waas')), ]; return $count . $this->row_actions($actions); } /** * Displays the content of the integration column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. */ public function column_integration($item): string { return ucwords(str_replace(['_', '-'], ' ', (string) $item->get_integration())); } /** * Displays the content of the active column. * * @since 2.0.0 * * @param WP_Ultimo\Models\Webhook $item Webhook object. * @return string */ public function column_active($item) { return $item->is_active() ? __('Yes', 'wp-multisite-waas') : __('No', 'wp-multisite-waas'); } /** * Returns the list of columns for this particular List Table. * * @since 2.0.0 * @return array */ public function get_columns() { $columns = [ 'cb' => '', 'name' => __('Name', 'wp-multisite-waas'), 'webhook_url' => __('Target URL', 'wp-multisite-waas'), 'event' => __('Trigger Event', 'wp-multisite-waas'), 'event_count' => __('Count', 'wp-multisite-waas'), 'integration' => __('Integration', 'wp-multisite-waas'), 'active' => __('Active', 'wp-multisite-waas'), 'id' => __('ID', 'wp-multisite-waas'), ]; return $columns; } /** * Returns the filters for this page. * * @since 2.0.0 */ public function get_filters(): array { return [ 'filters' => [], 'date_filters' => [], ]; } }