Abilities.php
2 months ago
AbstractAbilityGroup.php
2 months ago
FieldGroup.php
1 month ago
PostType.php
2 months ago
SCF_REST_Ability.php
2 months ago
Taxonomy.php
1 month ago
SCF_REST_Ability.php
41 lines
| 1 | <?php |
| 2 | /** |
| 3 | * ACF 6.8.0 feature port. |
| 4 | * |
| 5 | * @package wordpress/secure-custom-fields |
| 6 | */ |
| 7 | |
| 8 | // phpcs:disable -- Upstream ACF 6.8.0 feature-port files are kept close to source. |
| 9 | |
| 10 | namespace SCF\AI\Abilities; |
| 11 | |
| 12 | use WP_Ability; |
| 13 | |
| 14 | // Exit if accessed directly. |
| 15 | defined( 'ABSPATH' ) || exit; |
| 16 | |
| 17 | /** |
| 18 | * SCF REST Ability |
| 19 | * |
| 20 | * Custom ability class that extends WP_Ability to skip output validation. |
| 21 | * This is needed because REST API schemas don't always match Abilities API schemas exactly, |
| 22 | * but we want to proxy directly to REST API endpoints. |
| 23 | */ |
| 24 | class SCF_REST_Ability extends WP_Ability { |
| 25 | |
| 26 | /** |
| 27 | * Override validate_output to always return true. |
| 28 | * |
| 29 | * Since we're proxying to WordPress REST API endpoints that have their own |
| 30 | * validation, we trust their output and skip Abilities API output validation. |
| 31 | * |
| 32 | * @since 6.8.0 |
| 33 | * |
| 34 | * @param mixed $output The output to validate. |
| 35 | * @return true Always returns true to skip validation. |
| 36 | */ |
| 37 | protected function validate_output( $output ) { |
| 38 | return true; |
| 39 | } |
| 40 | } |
| 41 |