class-scf-abilities-integration.php
6 months ago
class-scf-field-abilities.php
3 weeks ago
class-scf-field-group-abilities.php
6 months ago
class-scf-internal-post-type-abilities.php
3 weeks ago
class-scf-post-type-abilities.php
7 months ago
class-scf-taxonomy-abilities.php
7 months ago
class-scf-ui-options-page-abilities.php
6 months ago
class-scf-field-group-abilities.php
68 lines
| 1 | <?php |
| 2 | /** |
| 3 | * SCF Field Group Abilities |
| 4 | * |
| 5 | * Handles WordPress Abilities API registration for SCF field group management. |
| 6 | * |
| 7 | * @package wordpress/secure-custom-fields |
| 8 | * @since 6.8.0 |
| 9 | */ |
| 10 | |
| 11 | // Exit if accessed directly. |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | if ( ! class_exists( 'SCF_Field_Group_Abilities' ) ) : |
| 17 | |
| 18 | /** |
| 19 | * SCF Field Group Abilities class. |
| 20 | * |
| 21 | * Registers and handles all field group management abilities for the |
| 22 | * WordPress Abilities API integration. Provides programmatic access |
| 23 | * to SCF field group operations. |
| 24 | * |
| 25 | * @since 6.8.0 |
| 26 | */ |
| 27 | class SCF_Field_Group_Abilities extends SCF_Internal_Post_Type_Abilities { |
| 28 | |
| 29 | /** |
| 30 | * The internal post type identifier. |
| 31 | * |
| 32 | * @var string |
| 33 | */ |
| 34 | protected $internal_post_type = 'acf-field-group'; |
| 35 | |
| 36 | /** |
| 37 | * Handles the list ability callback. |
| 38 | * |
| 39 | * Overrides parent to ignore location rules. Field groups use location rules |
| 40 | * to determine which edit screens they appear on - this is a UX feature for |
| 41 | * showing contextually relevant field groups, not access control. |
| 42 | * |
| 43 | * The abilities API should return all field groups regardless of location |
| 44 | * rules, so we bypass that filtering while preserving other filters like |
| 45 | * active status. |
| 46 | * |
| 47 | * @since 6.8.0 |
| 48 | * |
| 49 | * @param array $input The input parameters. |
| 50 | * @return array List of field groups. |
| 51 | */ |
| 52 | public function list_callback( $input ) { |
| 53 | // Ensure filter is an array (REST API may pass empty string for empty filter). |
| 54 | $filter = isset( $input['filter'] ) && is_array( $input['filter'] ) ? $input['filter'] : array(); |
| 55 | |
| 56 | // Location rules are a UX feature for edit screens, not access control. |
| 57 | $filter['ignore_location_rules'] = true; |
| 58 | |
| 59 | $instance = acf_get_internal_post_type_instance( $this->internal_post_type ); |
| 60 | return $instance->filter_posts( $instance->get_posts(), $filter ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Initialize abilities instance. |
| 65 | acf_new_instance( 'SCF_Field_Group_Abilities' ); |
| 66 | |
| 67 | endif; // class_exists check. |
| 68 |