'subscriber',
				'plural'   => 'subscribers',
				'ajax'     => false,
			)
		);
		$this->date_format = get_option( 'date_format' );
		$this->time_format = get_option( 'time_format' );
	}
	public function column_default( $item, $column_name ) {
		global $current_tab;
		switch ( $column_name ) {
			case 'email':
			case 'date':
				return $item[ $column_name ];
		}
	}
	public function column_email( $item ) {
		global $current_tab;
		if ( 'registered' === $current_tab ) {
			$actions = array(
				'edit' => sprintf( '%s', 's2', rawurlencode( $item['id'] ), __( 'Edit', 'subscribe2' ) ),
			);
			return sprintf( '%1$s %2$s', $item['email'], $this->row_actions( $actions ) );
		} else {
			global $mysubscribe2;
			if ( '0' === $mysubscribe2->is_public( $item['email'] ) ) {
				return sprintf( '%1$s', $item['email'], $item['ip'] );
			} else {
				return sprintf( '%1$s', $item['email'], $item['ip'] );
			}
		}
	}
	public function column_date( $item ) {
		global $current_tab;
		if ( 'registered' === $current_tab ) {
			$timestamp = strtotime( $item['date'] );
			return sprintf( '%1$s', date_i18n( $this->date_format, $timestamp ), date_i18n( $this->time_format, $timestamp ) );
		} else {
			$timestamp = strtotime( $item['date'] . ' ' . $item['time'] );
			return sprintf( '%1$s', date_i18n( $this->date_format, $timestamp ), date_i18n( $this->time_format, $timestamp ) );
		}
	}
	public function column_cb( $item ) {
		return sprintf( '', $this->_args['singular'], $item['email'] );
	}
	public function get_columns() {
		global $current_tab;
		$columns = array(
			'cb'    => '',
			'email' => _x( 'Email', 'column name', 'subscribe2' ),
			'date'  => _x( 'Date', 'column name', 'subscribe2' ),
		);
		return $columns;
	}
	public function get_sortable_columns() {
		global $current_tab;
		$sortable_columns = array(
			'email' => array( 'email', true ),
			'date'  => array( 'date', false ),
		);
		return $sortable_columns;
	}
	public function print_column_headers( $with_id = true ) {
		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
		$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
		$current_url = remove_query_arg( 'paged', $current_url );
		if ( isset( $_REQUEST['what'] ) ) {
			$current_url = add_query_arg(
				array(
					'what' => $_REQUEST['what'],
				),
				$current_url
			);
		}
		if ( isset( $_GET['orderby'] ) ) {
			$current_orderby = $_GET['orderby'];
		} else {
			$current_orderby = '';
		}
		if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
			$current_order = 'desc';
		} else {
			$current_order = 'asc';
		}
		if ( ! empty( $columns['cb'] ) ) {
			static $cb_counter = 1;
			$columns['cb']     = ''
				. '';
			$cb_counter++;
		}
		foreach ( $columns as $column_key => $column_display_name ) {
			$class = array( 'manage-column', "column-$column_key" );
			if ( in_array( $column_key, $hidden, true ) ) {
				$class[] = 'hidden';
			}
			if ( 'cb' === $column_key ) {
				$class[] = 'check-column';
			}
			if ( $column_key === $primary ) {
				$class[] = 'column-primary';
			}
			if ( isset( $sortable[ $column_key ] ) ) {
				list( $orderby, $desc_first ) = $sortable[ $column_key ];
				if ( $current_orderby === $orderby ) {
					$order   = 'asc' === $current_order ? 'desc' : 'asc';
					$class[] = 'sorted';
					$class[] = $current_order;
				} else {
					$order   = $desc_first ? 'desc' : 'asc';
					$class[] = 'sortable';
					$class[] = $desc_first ? 'asc' : 'desc';
				}
				$column_display_name = '' . $column_display_name . '';
			}
			$tag   = ( 'cb' === $column_key ) ? 'td' : 'th';
			$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
			$id    = $with_id ? "id='$column_key'" : '';
			if ( ! empty( $class ) ) {
				$class = "class='" . join( ' ', $class ) . "'";
			}
			echo "<$tag $scope $id $class>$column_display_name$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput
		}
	}
	public function get_bulk_actions() {
		global $current_tab;
		if ( 'registered' === $current_tab ) {
			if ( is_multisite() ) {
				return array();
			} else {
				return array(
					'delete' => __( 'Delete', 'subscribe2' ),
				);
			}
		} else {
			$actions = array(
				'delete' => __( 'Delete', 'subscribe2' ),
				'toggle' => __( 'Toggle', 'subscribe2' ),
			);
			return $actions;
		}
	}
	public function process_bulk_action() {
		if ( in_array( $this->current_action(), array( 'delete', 'toggle' ), true ) ) {
			if ( ! isset( $_REQUEST['subscriber'] ) ) {
				echo '
' . esc_html__( 'No users were selected.', 'subscribe2' ) . '
', array_filter( $message ) );
			echo '' . esc_html( $final_message ) . '
' . esc_html__( 'Status changed!', 'subscribe2' ) . '
$output
";
		echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput
	}
	public function prepare_items() {
		global $mysubscribe2, $subscribers, $current_tab;
		$user          = get_current_user_id();
		$screen        = get_current_screen();
		$screen_option = $screen->get_option( 'per_page', 'option' );
		$per_page      = get_user_meta( $user, $screen_option, true );
		if ( empty( $per_page ) || $per_page < 1 ) {
			$per_page = $screen->get_option( 'per_page', 'default' );
		}
		$columns  = $this->get_columns();
		$hidden   = array();
		$sortable = $this->get_sortable_columns();
		$this->_column_headers = array( $columns, $hidden, $sortable );
		$this->process_bulk_action();
		$data = array();
		if ( 'public' === $current_tab ) {
			foreach ( (array) $subscribers as $email ) {
				$data[] = array(
					'email' => $email,
					'date'  => $mysubscribe2->signup_date( $email ),
					'time'  => $mysubscribe2->signup_time( $email ),
					'ip'    => $mysubscribe2->signup_ip( $email ),
				);
			}
		} else {
			foreach ( (array) $subscribers as $subscriber ) {
				$data[] = array(
					'email' => $subscriber['user_email'],
					'id'    => $subscriber['ID'],
					'date'  => get_userdata( $subscriber['ID'] )->user_registered,
				);
			}
		}
		function usort_reorder( $a, $b ) {
			$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'email';
			$order   = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
			$result  = strcasecmp( $a[ $orderby ], $b[ $orderby ] );
			return ( 'asc' === $order ) ? $result : -$result;
		}
		usort( $data, 'usort_reorder' );
		if ( isset( $_POST['what'] ) ) {
			$current_page = 1;
		} else {
			$current_page = $this->get_pagenum();
		}
		$total_items = count( $data );
		$data        = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
		$this->items = $data;
		$this->set_pagination_args(
			array(
				'total_items' => $total_items,
				'per_page'    => $per_page,
				'total_pages' => ceil( $total_items / $per_page ),
			)
		);
	}
}