Skip to content

Commit 3b17059

Browse files
committed
chore: add cpt capabilities
1 parent 8c89c37 commit 3b17059

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

plugins/wp-graphql-headless-webhooks/src/Plugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public static function instance(): self {
7777
*/
7878
private function setup(): void {
7979
Helper::set_hook_prefix( 'graphql_webhooks' );
80-
8180
WebhookPostType::init();
8281

8382
$this->repository = new WebhookRepository();

plugins/wp-graphql-headless-webhooks/src/PostTypes/WebhookPostType.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function init(): void {
2323
* Register the webhook CPT
2424
*/
2525
public static function register_webhook_cpt(): void {
26-
$labels = [
26+
$labels = [
2727
'name' => __( 'Webhooks', 'wp-graphql-headless-webhooks' ),
2828
'singular_name' => __( 'Webhook', 'wp-graphql-headless-webhooks' ),
2929
'add_new' => __( 'Add New', 'wp-graphql-headless-webhooks' ),
@@ -37,8 +37,7 @@ public static function register_webhook_cpt(): void {
3737
'parent_item_colon' => __( 'Parent Webhook:', 'wp-graphql-headless-webhooks' ),
3838
'menu_name' => __( 'Webhooks', 'wp-graphql-headless-webhooks' ),
3939
];
40-
41-
$args = [
40+
$args = [
4241
'labels' => $labels,
4342
'publicly_queryable' => false,
4443
'hierarchical' => false,
@@ -55,8 +54,18 @@ public static function register_webhook_cpt(): void {
5554
'query_var' => true,
5655
'can_export' => true,
5756
'rewrite' => false,
58-
'capability_type' => 'post',
57+
'capability_type' => 'webhook',
5958
'supports' => [ 'title' ],
59+
'capabilities' => [
60+
'create_posts' => 'manage_options',
61+
'edit_posts' => 'manage_options',
62+
'edit_post' => 'manage_options',
63+
'delete_posts' => 'manage_options',
64+
'delete_post' => 'manage_options',
65+
'read_post' => 'manage_options',
66+
'read_private_posts' => 'manage_options',
67+
],
68+
'map_meta_cap' => false,
6069
];
6170

6271
register_post_type( 'graphql_webhook', $args );

0 commit comments

Comments
 (0)