views(); } } /** * Define which columns are hidden * * @return Array */ public function get_hidden_columns() { return array(); } /** * Sanitised `?page` query arg. * * @return string */ protected function getCurrentPage(): string { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return ! empty( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; } /** * Override the parent columns method. Defines the columns to use in your listing table * * @return Array */ public function get_columns() { $current_page = $this->getCurrentPage(); /** * Filters the columns displayed in the Coupons list table. * * @param string[] $coupon_columns An associative array of column headings. */ return (array) apply_filters( "manage_{$current_page}_columns", array() ); } /** * Handles the default column output. * * @param WP_Post $item The current WP_Post object. * @param string $column_name The current column name. */ public function column_default( $item, $column_name ) { $current_page = $this->getCurrentPage(); /** * Fires for each custom column of any SureCart List Table. * * The dynamic portion of the hook name, `$current_page`, refers to the page name. * * Possible hook names include: * * - `manage_orders_custom_column` * - `manage_products_custom_column` * * @param string $column_name The name of the column to display. * @param mixed $item The current item's data object. */ do_action( "manage_{$current_page}_custom_column", $column_name, $item ); } /** * Get the archive query status. * * @return boolean|null */ public function getArchiveStatus( $default = 'active' ) { $status = sanitize_text_field( wp_unslash( $_GET['status'] ?? $default ) ); $archived = false; if ( 'archived' === $status ) { $archived = true; } if ( 'all' === $status ) { $archived = null; } return $archived; } /** * Handle the date * * @param \SureCart\Models\Model $model Model. * * @return string */ public function column_date( $model ) { $created = sprintf( '', esc_attr( $model->created_at ), esc_html( $model->created_at_date_time ), esc_html( TimeDate::humanTimeDiff( $model->created_at ) ) ); $updated = sprintf( '%1$s ', __( 'Updated', 'surecart' ), esc_attr( $model->updated_at_date_time ), esc_html( $model->updated_at_date_time ), esc_html( TimeDate::humanTimeDiff( $model->updated_at ) ) ); return $created . '
' . $updated . ''; } /** * Handle the created column * * @param \SureCart\Models\Model $model Model. * * @return string */ public function column_created( $model ) { return esc_attr( $model->created_at_date_time ); } /** * The mode for the model. * * @param \SureCart\Models\Model $model Model. * * @return string */ public function column_mode( $model ) { return empty( $model->live_mode ) ? '' . __( 'Test', 'surecart' ) . '' : ''; } /** * Show an integrations list based on a product id. * * @param string $args The args. * * @return string */ public function productIntegrationsList( $args ) { // parse the args. $args = wp_parse_args( $args, [ 'product_id' => '', 'price_id' => '', 'variant_id' => '', ] ); // get the integration first by product id. $integrations = Integration::where( 'model_id', $args['product_id'] ); $output = ''; $integrations = $integrations->group_by( 'integration_id' )->get(); if ( empty( $integrations ) || is_wp_error( $integrations ) ) { return $output; } foreach ( $integrations as $integration ) { $provider = (object) apply_filters( "surecart/integrations/providers/find/{$integration->provider}", [] ); $item = (object) apply_filters( "surecart/integrations/providers/{$integration->provider}/item", $integration->integration_id ); if ( $integration->price_id && $args['price_id'] && $integration->price_id !== $args['price_id'] ) { continue; } if ( $integration->variant_id && $args['variant_id'] && $integration->variant_id !== $args['variant_id'] ) { continue; } if ( ! empty( $item->label ) ) { // Tooltip surfaces both the provider ("Zapier") and the item ("New order → Slack") // so keyboard + screen-reader users aren't limited to the native `title` hover. $tooltip_text = trim( sprintf( '%s%s%s', ! empty( $provider->label ) ? $provider->label : '', ! empty( $provider->label ) && ! empty( $item->label ) ? ' — ' : '', $item->label ?? '' ) ); ob_start(); ?> logo ) ) : ?> <?php echo esc_attr( $tooltip_text ); ?> label ); ?>
search_box( $text, $input_id ); ?>
'created_at', 'updated_at' => 'updated_at', ); } }