Last active
July 26, 2019 14:56
-
-
Save tobiasschutter/a5f798dd3c267717658b4296a4b0d6b8 to your computer and use it in GitHub Desktop.
Admin Colums Pro API method for fetching columns by post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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