class-abilities.php
1 week ago
class-ability-create-gallery.php
1 week ago
class-ability-get-gallery-layout-schema.php
1 week ago
class-ability-get-gallery.php
1 week ago
class-ability-list-galleries.php
1 week ago
class-ability-list-gallery-layouts.php
1 week ago
class-ability-media-search.php
1 week ago
class-ability-update-gallery-attachments.php
1 week ago
class-ability-update-gallery.php
1 week ago
functions.php
1 week ago
index.php
1 week ago
class-abilities.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * FooGallery abilities bootstrap. |
| 9 | */ |
| 10 | |
| 11 | if ( ! class_exists( 'FooGallery_Abilities' ) ) { |
| 12 | |
| 13 | class FooGallery_Abilities { |
| 14 | |
| 15 | /** |
| 16 | * Main FooGallery ability category slug. |
| 17 | * |
| 18 | * @var string |
| 19 | */ |
| 20 | const CATEGORY = 'foogallery-management'; |
| 21 | |
| 22 | /** |
| 23 | * Wire up the WordPress core abilities hooks. |
| 24 | */ |
| 25 | public function __construct() { |
| 26 | if ( ! foogallery_abilities_wp_api_available() ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | add_action( 'wp_abilities_api_categories_init', array( $this, 'register_main_category' ) ); |
| 31 | add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) ); |
| 32 | |
| 33 | new FooGallery_Ability_List_Galleries(); |
| 34 | new FooGallery_Ability_Get_Gallery(); |
| 35 | new FooGallery_Ability_Get_Gallery_Layout_Schema(); |
| 36 | new FooGallery_Ability_List_Gallery_Layouts(); |
| 37 | new FooGallery_Ability_Media_Search(); |
| 38 | new FooGallery_Ability_Create_Gallery(); |
| 39 | new FooGallery_Ability_Update_Gallery(); |
| 40 | new FooGallery_Ability_Update_Gallery_Attachments(); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Register the main FooGallery ability category. |
| 45 | * |
| 46 | * @return void |
| 47 | */ |
| 48 | public function register_main_category() { |
| 49 | // phpcs:ignore -- This callback is registered only when the WordPress Abilities API is available. |
| 50 | wp_register_ability_category( |
| 51 | self::CATEGORY, |
| 52 | array( |
| 53 | 'label' => __( 'FooGallery Management', 'foogallery' ), |
| 54 | 'description' => __( 'Create, inspect, and update FooGallery galleries using the existing gallery, layout, and attachment APIs.', 'foogallery' ), |
| 55 | ) |
| 56 | ); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Allow FooGallery code to register abilities. |
| 61 | * |
| 62 | * @return void |
| 63 | */ |
| 64 | public function register_abilities() { |
| 65 | do_action( 'foogallery_register_abilities' ); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 |