From 64255a1550f46c7b9ac6f3d6f512a498a9c6657c Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:54:49 +0100 Subject: [PATCH 1/8] Add schema for SCF identifiers --- schemas/scf-identifier.schema.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 schemas/scf-identifier.schema.json diff --git a/schemas/scf-identifier.schema.json b/schemas/scf-identifier.schema.json new file mode 100644 index 00000000..ecbdc5be --- /dev/null +++ b/schemas/scf-identifier.schema.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "scf-identifier.schema.json", + "title": "SCF Identifier", + "description": "Schema for SCF entity identifiers (post types, field groups, fields, taxonomies, etc.)", + "type": ["string", "integer"], + "examples": [ + 123, + "post_type_products", + "post_type_testimonials" + ] +} From de23e25467baf780f05ef948ce3b66af1a481520 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:24:08 +0100 Subject: [PATCH 2/8] Add global function to check for SCF capability --- includes/api/api-helpers.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/api/api-helpers.php b/includes/api/api-helpers.php index 4b2b25d1..21880478 100644 --- a/includes/api/api-helpers.php +++ b/includes/api/api-helpers.php @@ -2732,6 +2732,16 @@ function acf_current_user_can_admin() { return false; } +/** + * Checks if the current user has the SCF capability for programmatic access, without considering show_admin setting. + * + * @since 6.6.0 + * @return bool True if the user has the ACF capability. + */ +function scf_current_user_has_capability() { + return current_user_can( acf_get_setting( 'capability' ) ); +} + /** * Wrapper function for current_user_can( 'edit_post', $post_id ). * From cb540d27f8c8e2a32780a476bf46d3f8d63239f2 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Thu, 6 Nov 2025 17:00:36 +0100 Subject: [PATCH 3/8] Add ability regsitration functions and callbacks --- .../class-scf-post-type-abilities.php | 583 ++++++++++++++++++ 1 file changed, 583 insertions(+) create mode 100644 includes/abilities/class-scf-post-type-abilities.php diff --git a/includes/abilities/class-scf-post-type-abilities.php b/includes/abilities/class-scf-post-type-abilities.php new file mode 100644 index 00000000..9a90a50b --- /dev/null +++ b/includes/abilities/class-scf-post-type-abilities.php @@ -0,0 +1,583 @@ +post_type_schema ) { + $validator = new SCF_JSON_Schema_Validator(); + $schema = $validator->load_schema( 'post-type' ); + + $this->post_type_schema = $schema->definitions->postType; + } + + return $this->post_type_schema; + } + + /** + * Get the SCF identifier schema, loading it once and caching for reuse. + * + * @since 6.6.0 + * + * @return array The SCF identifier schema definition. + */ + private function get_scf_identifier_schema() { + if ( null === $this->scf_identifier_schema ) { + $validator = new SCF_JSON_Schema_Validator(); + + $this->scf_identifier_schema = $validator->load_schema( 'scf-identifier' ); + } + + return $this->scf_identifier_schema; + } + + /** + * Get the post type schema extended with internal fields for GET/LIST operations. + * + * @since 6.6.0 + * + * @return object The extended post type schema with internal fields. + */ + private function get_post_type_with_internal_fields_schema() { + $schema = clone $this->get_post_type_schema(); + $properties = clone $schema->properties; + $schema->properties = $properties; + + // Add internal WordPress/SCF fields that appear in GET/LIST but not EXPORT. + $schema->properties->ID = (object) array( + 'type' => 'integer', + 'description' => __( 'WordPress post ID (internal field, present in GET/LIST operations only).', 'secure-custom-fields' ), + ); + + $schema->properties->_valid = (object) array( + 'type' => 'boolean', + 'description' => __( 'SCF validation cache flag (internal field, present in GET/LIST operations only).', 'secure-custom-fields' ), + ); + + return $schema; + } + + /** + * Register all post type abilities. + * + * @since 6.6.0 + */ + public function register() { + $this->register_list_post_types_ability(); + $this->register_get_post_type_ability(); + $this->register_create_post_type_ability(); + $this->register_update_post_type_ability(); + $this->register_delete_post_type_ability(); + $this->register_duplicate_post_type_ability(); + $this->register_export_post_type_ability(); + $this->register_import_post_type_ability(); + } + + /** + * Register the list post types ability. + * + * @since 6.6.0 + */ + private function register_list_post_types_ability() { + wp_register_ability( + 'scf/list-post-types', + array( + 'label' => __( 'List Post Types', 'secure-custom-fields' ), + 'description' => __( 'Retrieves a list of all SCF post types with optional filtering.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'list_post_types_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => true, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => array( + 'type' => 'object', + 'properties' => array( + 'filter' => array( + 'type' => 'object', + 'description' => __( 'Optional filters to apply to the post type list.', 'secure-custom-fields' ), + 'properties' => array( + 'active' => array( + 'type' => 'boolean', + 'description' => __( 'Filter by active status.', 'secure-custom-fields' ), + ), + 'search' => array( + 'type' => 'string', + 'description' => __( 'Search term to filter post types.', 'secure-custom-fields' ), + ), + ), + ), + ), + ), + 'output_schema' => array( + 'type' => 'array', + 'items' => $this->get_post_type_with_internal_fields_schema(), + ), + ) + ); + } + + /** + * Register the get post type ability. + * + * @since 6.6.0 + */ + private function register_get_post_type_ability() { + wp_register_ability( + 'scf/get-post-type', + array( + 'label' => __( 'Get Post Type', 'secure-custom-fields' ), + 'description' => __( 'Retrieves a specific SCF post type configuration by ID or key.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'get_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => true, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => array( + 'type' => 'object', + 'properties' => array( + 'identifier' => $this->get_scf_identifier_schema(), + ), + 'required' => array( 'identifier' ), + ), + 'output_schema' => $this->get_post_type_with_internal_fields_schema(), + ) + ); + } + + /** + * Register the create post type ability. + * + * @since 6.6.0 + */ + private function register_create_post_type_ability() { + $input_schema = $this->get_post_type_schema(); + + wp_register_ability( + 'scf/create-post-type', + array( + 'label' => __( 'Create Post Type', 'secure-custom-fields' ), + 'description' => __( 'Creates a new custom post type in SCF with the provided configuration.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'create_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => false, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => $input_schema, + 'output_schema' => $this->get_post_type_schema(), + ) + ); + } + + /** + * Register the update post type ability. + * + * @since 6.6.0 + */ + private function register_update_post_type_ability() { + wp_register_ability( + 'scf/update-post-type', + array( + 'label' => __( 'Update Post Type', 'secure-custom-fields' ), + 'description' => __( 'Updates an existing SCF post type with new configuration.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'update_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => true, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => $this->get_post_type_schema(), + 'output_schema' => $this->get_post_type_schema(), + ) + ); + } + + /** + * Register the delete post type ability. + * + * @since 6.6.0 + */ + private function register_delete_post_type_ability() { + wp_register_ability( + 'scf/delete-post-type', + array( + 'label' => __( 'Delete Post Type', 'secure-custom-fields' ), + 'description' => __( 'Permanently deletes an SCF post type. This action cannot be undone.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'delete_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => true, + 'idempotent' => true, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => array( + 'type' => 'object', + 'properties' => array( + 'identifier' => $this->get_scf_identifier_schema(), + ), + 'required' => array( 'identifier' ), + ), + 'output_schema' => array( + 'type' => 'boolean', + 'description' => __( 'True if post type was successfully deleted.', 'secure-custom-fields' ), + ), + ) + ); + } + + /** + * Register the duplicate post type ability. + * + * @since 6.6.0 + */ + private function register_duplicate_post_type_ability() { + wp_register_ability( + 'scf/duplicate-post-type', + array( + 'label' => __( 'Duplicate Post Type', 'secure-custom-fields' ), + 'description' => __( 'Creates a copy of an existing SCF post type with optional modifications.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'duplicate_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => false, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => array( + 'type' => 'object', + 'properties' => array( + 'identifier' => $this->get_scf_identifier_schema(), + 'new_post_id' => array( + 'type' => 'integer', + 'description' => __( 'Optional new post ID for the duplicated post type.', 'secure-custom-fields' ), + ), + ), + 'required' => array( 'identifier' ), + ), + 'output_schema' => $this->get_post_type_schema(), + ) + ); + } + + /** + * Register the export post type ability. + * + * @since 6.6.0 + */ + private function register_export_post_type_ability() { + wp_register_ability( + 'scf/export-post-type', + array( + 'label' => __( 'Export Post Type', 'secure-custom-fields' ), + 'description' => __( 'Exports an SCF post type configuration as JSON for backup or transfer.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'export_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => true, + 'destructive' => false, + 'idempotent' => true, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => array( + 'type' => 'object', + 'properties' => array( + 'identifier' => $this->get_scf_identifier_schema(), + ), + 'required' => array( 'identifier' ), + ), + 'output_schema' => $this->get_post_type_schema(), + ) + ); + } + + /** + * Register the import post type ability. + * + * @since 6.6.0 + */ + private function register_import_post_type_ability() { + $post_type_schema = $this->get_post_type_schema(); + + wp_register_ability( + 'scf/import-post-type', + array( + 'label' => __( 'Import Post Type', 'secure-custom-fields' ), + 'description' => __( 'Imports an SCF post type from JSON configuration data.', 'secure-custom-fields' ), + 'category' => 'scf-post-types', + 'execute_callback' => array( $this, 'import_post_type_callback' ), + 'meta' => array( + 'show_in_rest' => false, + 'mcp' => array( + 'public' => true, + ), + 'annotations' => array( + 'readonly' => false, + 'destructive' => false, + 'idempotent' => false, + ), + ), + 'permission_callback' => 'scf_current_user_has_capability', + 'input_schema' => $this->get_post_type_schema(), + 'output_schema' => $this->get_post_type_schema(), + ) + ); + } + + /** + * Callback for the list post types ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array The response data. + */ + public function list_post_types_callback( $input ) { + $filter = isset( $input['filter'] ) ? $input['filter'] : array(); + + $post_types = acf_get_acf_post_types( $filter ); + return is_array( $post_types ) ? $post_types : array(); + } + + /** + * Callback for the get post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array The response data. + */ + public function get_post_type_callback( $input ) { + $post_type = acf_get_post_type( $input['identifier'] ); + + if ( ! $post_type ) { + return new WP_Error( 'post_type_not_found', __( 'Post type not found.', 'secure-custom-fields' ) ); + } + + return $post_type; + } + + /** + * Callback for the create post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array The response data. + */ + public function create_post_type_callback( $input ) { + // Check if post type already exists. + if ( acf_get_post_type( $input['key'] ) ) { + return new WP_Error( 'post_type_exists', __( 'A post type with this key already exists.', 'secure-custom-fields' ) ); + } + + $post_type = acf_update_post_type( $input ); + + if ( ! $post_type ) { + return new WP_Error( 'create_post_type_failed', __( 'Failed to create post type.', 'secure-custom-fields' ) ); + } + + return $post_type; + } + + /** + * Callback for the update post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array|WP_Error The post type data on success, WP_Error on failure. + */ + public function update_post_type_callback( $input ) { + // Check if post type exists. + if ( ! acf_get_post_type( $input['key'] ) ) { + return new WP_Error( 'post_type_not_found', __( 'Post type not found.', 'secure-custom-fields' ) ); + } + + $post_type = acf_update_post_type( $input ); + + if ( ! $post_type ) { + return new WP_Error( 'update_post_type_failed', __( 'Failed to update post type.', 'secure-custom-fields' ) ); + } + + return $post_type; + } + + /** + * Callback for the delete post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return bool|WP_Error True on success, WP_Error on failure. + */ + public function delete_post_type_callback( $input ) { + $result = acf_delete_post_type( $input['identifier'] ); + + if ( ! $result ) { + return new WP_Error( 'delete_post_type_failed', __( 'Failed to delete post type.', 'secure-custom-fields' ) ); + } + + return true; + } + + /** + * Callback for the duplicate post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array|WP_Error The duplicated post type data on success, WP_Error on failure. + */ + public function duplicate_post_type_callback( $input ) { + $new_post_id = isset( $input['new_post_id'] ) ? $input['new_post_id'] : 0; + $duplicated_post_type = acf_duplicate_post_type( $input['identifier'], $new_post_id ); + + if ( ! $duplicated_post_type ) { + return new WP_Error( 'duplicate_post_type_failed', __( 'Failed to duplicate post type.', 'secure-custom-fields' ) ); + } + + return $duplicated_post_type; + } + + /** + * Callback for the export post type ability. + * + * @since 6.6.0 + * + * @param array $input The input parameters. + * @return array|WP_Error The export data on success, WP_Error on failure. + */ + public function export_post_type_callback( $input ) { + $post_type = acf_get_post_type( $input['identifier'] ); + if ( ! $post_type ) { + return new WP_Error( 'post_type_not_found', __( 'Post type not found.', 'secure-custom-fields' ) ); + } + + $export_data = acf_prepare_internal_post_type_for_export( $post_type, 'acf-post-type' ); + + if ( ! $export_data ) { + return new WP_Error( 'export_post_type_failed', __( 'Failed to prepare post type for export.', 'secure-custom-fields' ) ); + } + + return $export_data; + } + + /** + * Callback for the import post type ability. + * + * @since 6.6.0 + * + * @param array|object $input The input parameters. + * @return array|WP_Error The imported post type data on success, WP_Error on failure. + */ + public function import_post_type_callback( $input ) { + // Import the post type (handles both create and update based on presence of ID). + $imported_post_type = acf_import_internal_post_type( $input, 'acf-post-type' ); + + if ( ! $imported_post_type ) { + return new WP_Error( 'import_post_type_failed', __( 'Failed to import post type.', 'secure-custom-fields' ) ); + } + + return $imported_post_type; + } +} From f6922fe379e5fa4a3fe4e338963eafc75fe93050 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Fri, 7 Nov 2025 00:59:58 +0100 Subject: [PATCH 4/8] Move category registration to post type class --- .../class-scf-post-type-abilities.php | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/includes/abilities/class-scf-post-type-abilities.php b/includes/abilities/class-scf-post-type-abilities.php index 9a90a50b..77447630 100644 --- a/includes/abilities/class-scf-post-type-abilities.php +++ b/includes/abilities/class-scf-post-type-abilities.php @@ -43,6 +43,16 @@ class SCF_Post_Type_Abilities { */ private $scf_identifier_schema = null; + /** + * Constructor. + * + * @since 6.6.0 + */ + public function __construct() { + add_action( 'wp_abilities_api_categories_init', array( $this, 'register_categories' ) ); + add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) ); + } + /** * Get the SCF post type schema, loading it once and caching for reuse. * @@ -103,12 +113,27 @@ private function get_post_type_with_internal_fields_schema() { return $schema; } + /** + * Register SCF ability categories. + * + * @since 6.6.0 + */ + public function register_categories() { + wp_register_ability_category( + 'scf-post-types', + array( + 'label' => __( 'SCF Post Types', 'secure-custom-fields' ), + 'description' => __( 'Abilities for managing Secure Custom Fields post types.', 'secure-custom-fields' ), + ) + ); + } + /** * Register all post type abilities. * * @since 6.6.0 */ - public function register() { + public function register_abilities() { $this->register_list_post_types_ability(); $this->register_get_post_type_ability(); $this->register_create_post_type_ability(); @@ -581,3 +606,5 @@ public function import_post_type_callback( $input ) { return $imported_post_type; } } + +acf_new_instance( 'SCF_Post_Type_Abilities' ); From af892837a8c6dad4c412be2bf9c18c7f60abc655 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Fri, 7 Nov 2025 01:00:49 +0100 Subject: [PATCH 5/8] Create ability integrator class that loads the entity-specific classes if dependencies are available --- includes/abilities/abilities-integration.php | 57 ++++++++++++++++++++ secure-custom-fields.php | 1 + 2 files changed, 58 insertions(+) create mode 100644 includes/abilities/abilities-integration.php diff --git a/includes/abilities/abilities-integration.php b/includes/abilities/abilities-integration.php new file mode 100644 index 00000000..ba56f3e9 --- /dev/null +++ b/includes/abilities/abilities-integration.php @@ -0,0 +1,57 @@ +dependencies_available() ) { + return; + } + + acf_include( 'includes/abilities/class-scf-post-type-abilities.php' ); + } + + /** + * Check if required dependencies are available. + * + * @since 6.6.0 + * @return bool True if dependencies are available. + */ + private function dependencies_available() { + return function_exists( 'wp_register_ability' ) + && function_exists( 'wp_register_ability_category' ); + } + } + + acf_new_instance( 'SCF_Abilities_Integration' ); +} diff --git a/secure-custom-fields.php b/secure-custom-fields.php index 1ffb3557..3325b857 100644 --- a/secure-custom-fields.php +++ b/secure-custom-fields.php @@ -190,6 +190,7 @@ public function initialize() { acf_include( 'includes/class-acf-options-page.php' ); acf_include( 'includes/class-acf-site-health.php' ); acf_include( 'includes/class-scf-json-schema-validator.php' ); + acf_include( 'includes/abilities/abilities-integration.php' ); acf_include( 'includes/fields/class-acf-field.php' ); acf_include( 'includes/locations/abstract-acf-legacy-location.php' ); acf_include( 'includes/locations/abstract-acf-location.php' ); From 3952bed8ef9df6d10cb27357b6cdaed0dab51223 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Fri, 7 Nov 2025 01:02:29 +0100 Subject: [PATCH 6/8] Ignore Abilities API functions not found in PHPStan --- phpstan.neon | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon b/phpstan.neon index 99807a00..877beff3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,6 +5,7 @@ parameters: reportUnmatchedIgnoredErrors: false ignoreErrors: - '#^Path in (include_once|require_once|require)\(\) ".*wp-admin/includes/.*" is not a file#' + - '#Function wp_(register_ability|register_ability_category|execute_ability) not found#' paths: - . excludePaths: From 8df611decf6013da8373d9d70cd70c5172adfbe2 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Fri, 7 Nov 2025 13:05:21 +0100 Subject: [PATCH 7/8] Convert schema object to array --- .../abilities/class-scf-post-type-abilities.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/includes/abilities/class-scf-post-type-abilities.php b/includes/abilities/class-scf-post-type-abilities.php index 77447630..8676affc 100644 --- a/includes/abilities/class-scf-post-type-abilities.php +++ b/includes/abilities/class-scf-post-type-abilities.php @@ -64,7 +64,7 @@ private function get_post_type_schema() { $validator = new SCF_JSON_Schema_Validator(); $schema = $validator->load_schema( 'post-type' ); - $this->post_type_schema = $schema->definitions->postType; + $this->post_type_schema = json_decode( wp_json_encode( $schema->definitions->postType ), true ); } return $this->post_type_schema; @@ -81,7 +81,7 @@ private function get_scf_identifier_schema() { if ( null === $this->scf_identifier_schema ) { $validator = new SCF_JSON_Schema_Validator(); - $this->scf_identifier_schema = $validator->load_schema( 'scf-identifier' ); + $this->scf_identifier_schema = json_decode( wp_json_encode( $validator->load_schema( 'scf-identifier' ) ), true ); } return $this->scf_identifier_schema; @@ -92,20 +92,18 @@ private function get_scf_identifier_schema() { * * @since 6.6.0 * - * @return object The extended post type schema with internal fields. + * @return array The extended post type schema with internal fields. */ private function get_post_type_with_internal_fields_schema() { - $schema = clone $this->get_post_type_schema(); - $properties = clone $schema->properties; - $schema->properties = $properties; + $schema = $this->get_post_type_schema(); // Add internal WordPress/SCF fields that appear in GET/LIST but not EXPORT. - $schema->properties->ID = (object) array( + $schema['properties']['ID'] = array( 'type' => 'integer', 'description' => __( 'WordPress post ID (internal field, present in GET/LIST operations only).', 'secure-custom-fields' ), ); - $schema->properties->_valid = (object) array( + $schema['properties']['_valid'] = array( 'type' => 'boolean', 'description' => __( 'SCF validation cache flag (internal field, present in GET/LIST operations only).', 'secure-custom-fields' ), ); From 35b5f4bd5d554988fdfd1e19053af22502cb18a4 Mon Sep 17 00:00:00 2001 From: priethor <27339341+priethor@users.noreply.github.com> Date: Sat, 8 Nov 2025 16:44:12 +0100 Subject: [PATCH 8/8] Expose the abilities in the REST API --- .../abilities/class-scf-post-type-abilities.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/abilities/class-scf-post-type-abilities.php b/includes/abilities/class-scf-post-type-abilities.php index 8676affc..058f3804 100644 --- a/includes/abilities/class-scf-post-type-abilities.php +++ b/includes/abilities/class-scf-post-type-abilities.php @@ -156,7 +156,7 @@ private function register_list_post_types_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'list_post_types_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -208,7 +208,7 @@ private function register_get_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'get_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -247,7 +247,7 @@ private function register_create_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'create_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -278,7 +278,7 @@ private function register_update_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'update_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -309,7 +309,7 @@ private function register_delete_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'delete_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -349,7 +349,7 @@ private function register_duplicate_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'duplicate_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -390,7 +390,7 @@ private function register_export_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'export_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ), @@ -429,7 +429,7 @@ private function register_import_post_type_ability() { 'category' => 'scf-post-types', 'execute_callback' => array( $this, 'import_post_type_callback' ), 'meta' => array( - 'show_in_rest' => false, + 'show_in_rest' => true, 'mcp' => array( 'public' => true, ),