__('Event', 'wp-ultimo'), // singular name of the listed records 'plural' => __('Events', 'wp-ultimo'), // plural name of the listed records 'ajax' => true, // does this table support ajax? ) ); } /** * Returns the markup for the object_type column. * * @since 2.0.0 * * @param \WP_Ultimo\Models\Event $item The event being displayed. * @return string */ public function column_object_type($item) { $object_type = $item->get_object_type(); return "{$object_type}"; } /** * Returns the markup for the initiator column. * * @since 2.0.0 * * @param \WP_Ultimo\Models\Event $item The event being displayed. * @return string */ public function column_initiator($item) { $object_initiator = $item->get_initiator(); $object_severity_label = $item->get_severity_label(); $object_severity_class = $item->get_severity_class(); $object_label_tooltip = substr($object_severity_label, 0, 1); if ($object_initiator === 'system') { $avatar = ''; $system_text = ucfirst($object_initiator); // phpcs:disable $html = "
{$avatar} {$object_label_tooltip}
{$system_text} " . __('Automatically started', 'wp-ultimo') . "
"; // phpcs:enable } elseif ($object_initiator === 'manual') { $avatar = get_avatar( $item->get_author_id(), 32, 'identicon', '', array( 'force_display' => true, 'class' => 'wu-rounded-full', ) ); $display_name = $item->get_author_display_name(); $id = $item->get_author_id(); $url_atts = array( 'id' => $item->get_author_id(), ); $initiator_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts); $email = $item->get_author_email_address(); $html = "
{$avatar} {$object_label_tooltip}
{$display_name} (#{$id}) {$email}
"; } else { $not_found = __('No initiator found', 'wp-ultimo'); $html = "
 
{$not_found}
"; } return $html; } /** * Returns the markup for the initiator column. * * @since 2.0.0 * * @param \WP_Ultimo\Models\Event $item The event being displayed. * @return string */ public function column_slug($item) { $object_slug = $item->get_slug(); return "{$object_slug}"; } /** * Returns the markup for the message column. * * @since 2.0.0 * * @param \WP_Ultimo\Models\Event $item The event being displayed. */ public function column_message($item): string { $message = wp_trim_words($item->get_message(), 13); $url_atts = array( 'id' => $item->get_id(), 'model' => 'event', ); $actions = array( 'view' => sprintf('%s', wu_network_admin_url('wp-ultimo-view-event', $url_atts), __('View', 'wp-ultimo')), 'delete' => sprintf( '%s', __('Delete', 'wp-ultimo'), wu_get_form_url( 'delete_modal', $url_atts ), __('Delete', 'wp-ultimo') ), ); return $message . $this->row_actions($actions); } /** * Returns the list of columns for this particular List Table. * * @since 2.0.0 * @return array */ public function get_columns() { $columns = array( 'cb' => '', 'initiator' => __('Initiator', 'wp-ultimo'), 'message' => __('Event Message', 'wp-ultimo'), 'slug' => __('SLug', 'wp-ultimo'), 'object_type' => __('Type', 'wp-ultimo'), 'date_created' => __('Created at', 'wp-ultimo'), 'id' => __('ID', 'wp-ultimo'), ); return apply_filters('wu_events_list_table_get_columns', $columns, $this); } /** * Returns the filters for this page. * * @since 2.0.0 */ public function get_filters(): array { return array( 'filters' => array( 'severity' => array( 'label' => __('Severity', 'wp-ultimo'), 'options' => array( Event::SEVERITY_SUCCESS => __('Success', 'wp-ultimo'), Event::SEVERITY_NEUTRAL => __('Neutral', 'wp-ultimo'), Event::SEVERITY_INFO => __('Info', 'wp-ultimo'), Event::SEVERITY_WARNING => __('Warning', 'wp-ultimo'), Event::SEVERITY_FATAL => __('Fatal', 'wp-ultimo'), ), ), ), 'date_filters' => array( 'date_created' => array( 'label' => __('Created At', 'wp-ultimo'), 'options' => $this->get_default_date_filter_options(), ), ), ); } }