__('Webhook', 'wp-ultimo'), // singular name of the listed records
'plural' => __('Webhooks', 'wp-ultimo'), // 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
%s',
wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts),
$item->get_name(),
$item->get_id(),
__('Sending Test..', 'wp-ultimo')
);
$actions = [
'edit' => sprintf('%s', wu_network_admin_url('wp-ultimo-edit-webhook', $url_atts), __('Edit', 'wp-ultimo')),
'test' => sprintf('%s', $item->get_webhook_url(), __('Send Test', 'wp-ultimo')),
'delete' => sprintf(
'%s',
__('Delete', 'wp-ultimo'),
wu_get_form_url(
'delete_modal',
$url_atts
),
__('Delete', 'wp-ultimo')
),
];
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-ultimo')),
];
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-ultimo') : __('No', 'wp-ultimo');
}
/**
* 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-ultimo'),
'webhook_url' => __('Target URL', 'wp-ultimo'),
'event' => __('Trigger Event', 'wp-ultimo'),
'event_count' => __('Count', 'wp-ultimo'),
'integration' => __('Integration', 'wp-ultimo'),
'active' => __('Active', 'wp-ultimo'),
'id' => __('ID', 'wp-ultimo'),
];
return $columns;
}
/**
* Returns the filters for this page.
*
* @since 2.0.0
*/
public function get_filters(): array {
return [
'filters' => [],
'date_filters' => [],
];
}
}