Skip to content

Instantly share code, notes, and snippets.

@tobiasschutter
Last active July 26, 2019 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiasschutter/a5f798dd3c267717658b4296a4b0d6b8 to your computer and use it in GitHub Desktop.
Save tobiasschutter/a5f798dd3c267717658b4296a4b0d6b8 to your computer and use it in GitHub Desktop.
Admin Colums Pro API method for fetching columns by post type
<?php
/**
* @param string $post_type
* @param string|null $layout
*
* @return \AC\Column[]
*/
function acp_get_columns_by_post_type( string $post_type, string $layout = null ): array {
$list_screen = new \ACP\ListScreen\Post( $post_type );
if ( $layout ) {
$list_screen->set_layout_id( $layout );
}
return $list_screen->get_columns();
}
/**
* Example Usage
*/
add_action( 'admin_init', function() {
$columns = acp_get_columns_by_post_type( 'post' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment