Skip to content

Instantly share code, notes, and snippets.

@emre-edu-tech
Last active October 13, 2024 06:08
Show Gist options
  • Save emre-edu-tech/555ecb65923279750281c15a0f1bf220 to your computer and use it in GitHub Desktop.
Save emre-edu-tech/555ecb65923279750281c15a0f1bf220 to your computer and use it in GitHub Desktop.
Checking the custom post type mapped capabilities while in development stage.
<?php
// FOR DEVELOPMENT PURPOSES, create a submenu page that displays the capabilities of
// Custom Post Type which is called Topic and this page is only available to ADMINS
add_action('admin_menu', 'mpons_forum_submenu');
function mpons_forum_submenu() {
add_submenu_page(
'tools.php',
__('Media Pons Topic CPT', 'media-pons-forum'),
__('Media Pons Topic CPT', 'media-pons-forum'),
'manage_options',
'media-pons-topic-cpt',
'media_pons_render_topic_cpt'
);
}
function media_pons_render_topic_cpt() {
$topic = $GLOBALS['wp_post_types']['topic'];
?>
<div class="wrap" id="media-pons-cpt-admin">
<h1>Topic</h1>
<pre><?php print_r(['capability_type' => $topic->capability_type]) ?></pre>
<pre><?php print_r(['map_meta_cap' => $topic->map_meta_cap]) ?></pre>
<pre><?php print_r(['cap' => $topic->cap]) ?></pre>
<pre><?php print_r($topic) ?></pre>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment