class-scf-abilities-integration.php
6 months ago
class-scf-field-abilities.php
1 week ago
class-scf-field-group-abilities.php
6 months ago
class-scf-internal-post-type-abilities.php
1 week 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-abilities-integration.php
64 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WordPress Abilities API integration for Secure Custom Fields. |
| 4 | * |
| 5 | * @package SCF |
| 6 | * @since 6.6.0 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | if ( ! class_exists( 'SCF_Abilities_Integration' ) ) { |
| 14 | |
| 15 | /** |
| 16 | * Handles integration with WordPress Abilities API. |
| 17 | * |
| 18 | * @since 6.6.0 |
| 19 | * @codeCoverageIgnore Glue code tested implicitly via E2E tests. |
| 20 | */ |
| 21 | class SCF_Abilities_Integration { |
| 22 | |
| 23 | /** |
| 24 | * Constructor. |
| 25 | * |
| 26 | * @since 6.6.0 |
| 27 | */ |
| 28 | public function __construct() { |
| 29 | add_action( 'plugins_loaded', array( $this, 'init' ), 20 ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Initialize abilities integration if dependencies are available. |
| 34 | * |
| 35 | * @since 6.6.0 |
| 36 | */ |
| 37 | public function init() { |
| 38 | if ( ! $this->dependencies_available() ) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | acf_include( 'includes/abilities/class-scf-internal-post-type-abilities.php' ); |
| 43 | acf_include( 'includes/abilities/class-scf-post-type-abilities.php' ); |
| 44 | acf_include( 'includes/abilities/class-scf-taxonomy-abilities.php' ); |
| 45 | acf_include( 'includes/abilities/class-scf-ui-options-page-abilities.php' ); |
| 46 | acf_include( 'includes/abilities/class-scf-field-group-abilities.php' ); |
| 47 | acf_include( 'includes/abilities/class-scf-field-abilities.php' ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Check if required dependencies are available. |
| 52 | * |
| 53 | * @since 6.6.0 |
| 54 | * @return bool True if dependencies are available. |
| 55 | */ |
| 56 | private function dependencies_available() { |
| 57 | return function_exists( 'wp_register_ability' ) |
| 58 | && function_exists( 'wp_register_ability_category' ); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | acf_new_instance( 'SCF_Abilities_Integration' ); |
| 63 | } |
| 64 |