container = $container;
parent::__construct( $args );
}
/**
* Current sanitized page number.
*
* @since 1.0.0
* @return int
*/
protected function current_page() {
return max( 1, $this->get_pagenum() );
}
/**
* Sanitized GET filter value.
*
* @since 1.0.0
* @param string $key GET key.
* @return string
*/
protected function get_filter( $key ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read only list filter.
return isset( $_GET[ $key ] ) ? sanitize_text_field( wp_unslash( $_GET[ $key ] ) ) : '';
}
/**
* Affiliate display label with a link to the detail screen.
*
* @since 1.0.0
* @param int $affiliate_id Affiliate id.
* @return string HTML.
*/
protected function affiliate_label( $affiliate_id ) {
$affiliate = $this->container->get( 'affiliates.repository' )->find( (int) $affiliate_id );
if ( ! $affiliate ) {
return '#' . (int) $affiliate_id;
}
$user = get_userdata( (int) $affiliate->user_id );
$name = $user ? $user->display_name : '#' . $affiliate->user_id;
$url = admin_url( 'admin.php?page=ppl-afw-affiliates&view=' . (int) $affiliate->id );
return '' . esc_html( $name ) . ' ' . esc_html( $affiliate->slug ) . '';
}
/**
* HPOS-safe order edit link.
*
* @since 1.0.0
* @param int $order_id Order id.
* @return string HTML.
*/
protected function order_link( $order_id ) {
if ( ! $order_id ) {
return '-';
}
return '#' . (int) $order_id . '';
}
/**
* Status badge markup.
*
* @since 1.0.0
* @param string $status Status key.
* @return string HTML.
*/
protected function badge( $status ) {
return '' . esc_html( $status ) . '';
}
/**
* Lets an extension add columns to this list.
*
* @since 1.3.0
* @param array $columns Column key => label.
* @return array
*/
protected function extend_columns( array $columns ) {
/**
* Filters the columns of an Affiliates admin list.
*
* @since 1.3.0
* @param array $columns Column key => label.
* @param string $list List name: referrals or visits.
*/
return (array) apply_filters( 'ppl_afw_admin_columns', $columns, $this->_args['plural'] );
}
/**
* Cell of a column added through ppl_afw_admin_columns.
*
* @since 1.3.0
* @param object $item Row.
* @param string $column Column key.
* @return string Escaped HTML.
*/
protected function extra_column( $item, $column ) {
/**
* Filters the cell of an added column. Return escaped HTML.
*
* @since 1.3.0
* @param string $html Cell HTML.
* @param string $column Column key.
* @param object $item Row.
* @param string $list List name: referrals or visits.
*/
return wp_kses_post( (string) apply_filters( 'ppl_afw_admin_column', '', $column, $item, $this->_args['plural'] ) );
}
/**
* Verifies the bulk action nonce when a bulk action was submitted.
*
* @since 1.0.0
* @return bool Whether a valid bulk request is in flight.
*/
protected function verify_bulk() {
if ( ! $this->current_action() ) {
return false;
}
check_admin_referer( 'bulk-' . $this->_args['plural'] );
return true;
}
}