WP_Posts_List_Table::get_sortable_columns()protectedWP 1.0

Метод класса: WP_Posts_List_Table{}

Хуков нет.

Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_sortable_columns();

Код WP_Posts_List_Table::get_sortable_columns() WP 6.6.2

protected function get_sortable_columns() {

	$post_type = $this->screen->post_type;

	if ( 'page' === $post_type ) {
		if ( isset( $_GET['orderby'] ) ) {
			$title_orderby_text = __( 'Table ordered by Title.' );
		} else {
			$title_orderby_text = __( 'Table ordered by Hierarchical Menu Order and Title.' );
		}

		$sortables = array(
			'title'    => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ),
			'parent'   => array( 'parent', false ),
			'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
			'date'     => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ),
		);
	} else {
		$sortables = array(
			'title'    => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ),
			'parent'   => array( 'parent', false ),
			'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
			'date'     => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
		);
	}
	// Custom Post Types: there's a filter for that, see get_column_info().

	return $sortables;
}