Skip to content

Instantly share code, notes, and snippets.

@tobiasschutter
Last active July 26, 2019 14:57
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/ab2643a55baa9df4000be2f2ee564759 to your computer and use it in GitHub Desktop.
Save tobiasschutter/ab2643a55baa9df4000be2f2ee564759 to your computer and use it in GitHub Desktop.
Admin Columns Pro API method for fetching layouts by post type
<?php
/**
* @param string $post_type
*
* @return \ACP\Layout[]
*/
function acp_get_layouts_by_post_type( string $post_type ) : array {
$list_screen = new \ACP\ListScreen\Post( $post_type );
$layouts = new \ACP\Layouts( $list_screen );
return $layouts->get_layouts();
}
/**
* Example Usage
*/
add_action( 'admin_init', function() {
$layouts = acp_get_layouts_by_post_type( 'post' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment