esc_html__( 'Spam Reason', 'antispam-bee' ),
)
);
}
/**
* Display plugin column values on comments screen
*
* @since 2.6.0
* @change 2.6.0
*
* @param string $column Currently selected column.
* @param integer $comment_id Comment ID.
*/
public static function print_plugin_column( $column, $comment_id ) {
if ( 'antispam_bee_reason' !== $column ) {
return;
}
$spam_reason = get_comment_meta( $comment_id, $column, true );
$spam_reasons = Antispam_Bee::$defaults['reasons'];
if ( empty( $spam_reason ) || empty( $spam_reasons[ $spam_reason ] ) ) {
return;
}
echo esc_html( $spam_reasons[ $spam_reason ] );
}
/**
* Register plugin sortable columns on comments screen
*
* @since 2.6.3
* @change 2.6.3
*
* @param array $columns Registered columns.
* @return array $columns Columns with AB field.
*/
public static function register_sortable_columns( $columns ) {
$columns['antispam_bee_reason'] = 'antispam_bee_reason';
return $columns;
}
// phpcs:disable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
// phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
/**
* Adjust orderby query
*
* @since 2.6.3
* @change 2.6.3
*
* @param \WP_Comment_Query $query Current WordPress query.
*/
public static function set_orderby_query( $query ) {
$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : '';
if ( empty( $orderby ) || 'antispam_bee_reason' !== $orderby ) {
return;
}
$query->query_vars['meta_key'] = 'antispam_bee_reason';
$query->query_vars['orderby'] = 'meta_value';
}
// phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
// phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification
//phpcs:disable WordPress.CSRF.NonceVerification.NoNonceVerification
/**
* Filter comments by the spam reason
*
* @global \wpdb $wpdb
*/
public static function filter_columns() {
global $wpdb;
?>
query_vars['meta_key'] = 'antispam_bee_reason';
$query->query_vars['meta_value'] = $spam_reason;
}
//phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_key
//phpcs:enable WordPress.VIP.SlowDBQuery.slow_db_query_meta_value
//phpcs:enable WordPress.CSRF.NonceVerification.NoNonceVerification
/**
* Print CSS for the plugin column
*
* @since 2.6.1
* @change 2.6.1
*/
public static function print_column_styles() {
?>