WPSEO_Bulk_List_Table::populate_editable_post_types()protectedYoast 1.0

Used in the constructor to build a reference list of post types the current user can edit.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

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

Код WPSEO_Bulk_List_Table::populate_editable_post_types() Yoast 22.4

protected function populate_editable_post_types() {
	$post_types = get_post_types(
		[
			'public'              => true,
			'exclude_from_search' => false,
		],
		'object'
	);

	$this->all_posts = [];
	$this->own_posts = [];

	if ( is_array( $post_types ) && $post_types !== [] ) {
		foreach ( $post_types as $post_type ) {
			if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
				continue;
			}

			if ( current_user_can( $post_type->cap->edit_others_posts ) ) {
				$this->all_posts[] = esc_sql( $post_type->name );
			}
			else {
				$this->own_posts[] = esc_sql( $post_type->name );
			}
		}
	}
}