Priority File Manager
📁 public_html
Base Directory:
/home/toolrmtm/crazyespresso.com
/home/toolrmtm/crazyespresso.com/wp-content/plugins
/home/toolrmtm/crazyespresso.com/wp-content
/home/toolrmtm
/home
/home/toolrmtm/public_html
/var/www
/var/www/cgi-bin
/var/www/html
crazyespresso.com
/
wp-includes
/home/toolrmtm/crazyespresso.com/wp-includes
Name
Type
Size
Actions
📁
..
Folder
-
Delete
Rename
📁
ID3
Folder
-
Delete
Rename
📁
IXR
Folder
-
Delete
Rename
📁
PHPMailer
Folder
-
Delete
Rename
📁
Requests
Folder
-
Delete
Rename
📁
SimplePie
Folder
-
Delete
Rename
📁
Text
Folder
-
Delete
Rename
📁
abilities-api
Folder
-
Delete
Rename
📄
abilities-api.php
File
24369
Delete
Rename
Edit
Download
📄
abilities.php
File
7983
Delete
Rename
Edit
Download
📄
admin-bar.php
File
36966
Delete
Rename
Edit
Download
📁
assets
Folder
-
Delete
Rename
📄
atomlib.php
File
12181
Delete
Rename
Edit
Download
📄
author-template.php
File
19391
Delete
Rename
Edit
Download
📁
block-bindings
Folder
-
Delete
Rename
📄
block-bindings.php
File
7526
Delete
Rename
Edit
Download
📄
block-editor.php
File
29282
Delete
Rename
Edit
Download
📄
block-i18n.json
File
316
Delete
Rename
Edit
Download
📁
block-patterns
Folder
-
Delete
Rename
📄
block-patterns.php
File
13213
Delete
Rename
Edit
Download
📁
block-supports
Folder
-
Delete
Rename
📄
block-template-utils.php
File
62484
Delete
Rename
Edit
Download
📄
block-template.php
File
15359
Delete
Rename
Edit
Download
📁
blocks
Folder
-
Delete
Rename
📄
blocks.php
File
114739
Delete
Rename
Edit
Download
📄
bookmark-template.php
File
12768
Delete
Rename
Edit
Download
📄
bookmark.php
File
15427
Delete
Rename
Edit
Download
📄
cache-compat.php
File
10078
Delete
Rename
Edit
Download
📄
cache.php
File
13486
Delete
Rename
Edit
Download
📄
canonical.php
File
34645
Delete
Rename
Edit
Download
📄
capabilities.php
File
43652
Delete
Rename
Edit
Download
📄
category-template.php
File
57045
Delete
Rename
Edit
Download
📄
category.php
File
12829
Delete
Rename
Edit
Download
📁
certificates
Folder
-
Delete
Rename
📄
class-IXR.php
File
2616
Delete
Rename
Edit
Download
📄
class-avif-info.php
File
29615
Delete
Rename
Edit
Download
📄
class-feed.php
File
539
Delete
Rename
Edit
Download
📄
class-http.php
File
367
Delete
Rename
Edit
Download
📄
class-json.php
File
43676
Delete
Rename
Edit
Download
📄
class-oembed.php
File
401
Delete
Rename
Edit
Download
📄
class-phpass.php
File
6771
Delete
Rename
Edit
Download
📄
class-phpmailer.php
File
664
Delete
Rename
Edit
Download
📄
class-pop3.php
File
21121
Delete
Rename
Edit
Download
📄
class-requests.php
File
2237
Delete
Rename
Edit
Download
📄
class-simplepie.php
File
453
Delete
Rename
Edit
Download
📄
class-smtp.php
File
457
Delete
Rename
Edit
Download
📄
class-snoopy.php
File
37715
Delete
Rename
Edit
Download
📄
class-walker-category-dropdown.php
File
2469
Delete
Rename
Edit
Download
📄
class-walker-category.php
File
8477
Delete
Rename
Edit
Download
📄
class-walker-comment.php
File
14221
Delete
Rename
Edit
Download
📄
class-walker-nav-menu.php
File
12044
Delete
Rename
Edit
Download
📄
class-walker-page-dropdown.php
File
2710
Delete
Rename
Edit
Download
📄
class-walker-page.php
File
7612
Delete
Rename
Edit
Download
📄
class-wp-admin-bar.php
File
17874
Delete
Rename
Edit
Download
📄
class-wp-ajax-response.php
File
5266
Delete
Rename
Edit
Download
📄
class-wp-application-passwords.php
File
17099
Delete
Rename
Edit
Download
📄
class-wp-block-bindings-registry.php
File
8482
Delete
Rename
Edit
Download
📄
class-wp-block-bindings-source.php
File
2992
Delete
Rename
Edit
Download
📄
class-wp-block-editor-context.php
File
1350
Delete
Rename
Edit
Download
📄
class-wp-block-list.php
File
4713
Delete
Rename
Edit
Download
📄
class-wp-block-metadata-registry.php
File
11895
Delete
Rename
Edit
Download
📄
class-wp-block-parser-block.php
File
2555
Delete
Rename
Edit
Download
📄
class-wp-block-parser-frame.php
File
2017
Delete
Rename
Edit
Download
📄
class-wp-block-parser.php
File
11516
Delete
Rename
Edit
Download
📄
class-wp-block-pattern-categories-registry.php
File
5450
Delete
Rename
Edit
Download
📄
class-wp-block-patterns-registry.php
File
10851
Delete
Rename
Edit
Download
📄
class-wp-block-processor.php
File
69469
Delete
Rename
Edit
Download
📄
class-wp-block-styles-registry.php
File
6497
Delete
Rename
Edit
Download
📄
class-wp-block-supports.php
File
5626
Delete
Rename
Edit
Download
📄
class-wp-block-template.php
File
2033
Delete
Rename
Edit
Download
📄
class-wp-block-templates-registry.php
File
7193
Delete
Rename
Edit
Download
📄
class-wp-block-type-registry.php
File
5030
Delete
Rename
Edit
Download
📄
class-wp-block-type.php
File
17265
Delete
Rename
Edit
Download
📄
class-wp-block.php
File
24812
Delete
Rename
Edit
Download
📄
class-wp-classic-to-block-menu-converter.php
File
4070
Delete
Rename
Edit
Download
📄
class-wp-comment-query.php
File
48804
Delete
Rename
Edit
Download
📄
class-wp-comment.php
File
9437
Delete
Rename
Edit
Download
📄
class-wp-customize-control.php
File
26119
Delete
Rename
Edit
Download
📄
class-wp-customize-manager.php
File
203139
Delete
Rename
Edit
Download
📄
class-wp-customize-nav-menus.php
File
58013
Delete
Rename
Edit
Download
📄
class-wp-customize-panel.php
File
10710
Delete
Rename
Edit
Download
📄
class-wp-customize-section.php
File
11209
Delete
Rename
Edit
Download
📄
class-wp-customize-setting.php
File
29962
Delete
Rename
Edit
Download
📄
class-wp-customize-widgets.php
File
72607
Delete
Rename
Edit
Download
📄
class-wp-date-query.php
File
36147
Delete
Rename
Edit
Download
📄
class-wp-dependencies.php
File
15381
Delete
Rename
Edit
Download
📄
class-wp-dependency.php
File
2633
Delete
Rename
Edit
Download
📄
class-wp-duotone.php
File
40783
Delete
Rename
Edit
Download
📄
class-wp-editor.php
File
72335
Delete
Rename
Edit
Download
📄
class-wp-embed.php
File
15931
Delete
Rename
Edit
Download
📄
class-wp-error.php
File
7502
Delete
Rename
Edit
Download
📄
class-wp-exception.php
File
253
Delete
Rename
Edit
Download
📄
class-wp-fatal-error-handler.php
File
8150
Delete
Rename
Edit
Download
📄
class-wp-feed-cache-transient.php
File
3304
Delete
Rename
Edit
Download
📄
class-wp-feed-cache.php
File
969
Delete
Rename
Edit
Download
📄
class-wp-hook.php
File
16674
Delete
Rename
Edit
Download
📄
class-wp-http-cookie.php
File
7389
Delete
Rename
Edit
Download
📄
class-wp-http-curl.php
File
13261
Delete
Rename
Edit
Download
📄
class-wp-http-encoding.php
File
6689
Delete
Rename
Edit
Download
📄
class-wp-http-ixr-client.php
File
3501
Delete
Rename
Edit
Download
📄
class-wp-http-proxy.php
File
5980
Delete
Rename
Edit
Download
📄
class-wp-http-requests-hooks.php
File
2022
Delete
Rename
Edit
Download
📄
class-wp-http-requests-response.php
File
4400
Delete
Rename
Edit
Download
📄
class-wp-http-response.php
File
2977
Delete
Rename
Edit
Download
📄
class-wp-http-streams.php
File
16859
Delete
Rename
Edit
Download
📄
class-wp-http.php
File
41570
Delete
Rename
Edit
Download
📄
class-wp-image-editor-gd.php
File
20705
Delete
Rename
Edit
Download
📄
class-wp-image-editor-imagick.php
File
36977
Delete
Rename
Edit
Download
📄
class-wp-image-editor.php
File
17415
Delete
Rename
Edit
Download
📄
class-wp-list-util.php
File
7443
Delete
Rename
Edit
Download
📄
class-wp-locale-switcher.php
File
6776
Delete
Rename
Edit
Download
📄
class-wp-locale.php
File
16883
Delete
Rename
Edit
Download
📄
class-wp-matchesmapregex.php
File
1828
Delete
Rename
Edit
Download
📄
class-wp-meta-query.php
File
30533
Delete
Rename
Edit
Download
📄
class-wp-metadata-lazyloader.php
File
6833
Delete
Rename
Edit
Download
📄
class-wp-navigation-fallback.php
File
9193
Delete
Rename
Edit
Download
📄
class-wp-network-query.php
File
19887
Delete
Rename
Edit
Download
📄
class-wp-network.php
File
12296
Delete
Rename
Edit
Download
📄
class-wp-object-cache.php
File
17524
Delete
Rename
Edit
Download
📄
class-wp-oembed-controller.php
File
6905
Delete
Rename
Edit
Download
📄
class-wp-oembed.php
File
31670
Delete
Rename
Edit
Download
📄
class-wp-paused-extensions-storage.php
File
5111
Delete
Rename
Edit
Download
📄
class-wp-phpmailer.php
File
4348
Delete
Rename
Edit
Download
📄
class-wp-plugin-dependencies.php
File
25315
Delete
Rename
Edit
Download
📄
class-wp-post-type.php
File
30680
Delete
Rename
Edit
Download
📄
class-wp-post.php
File
6491
Delete
Rename
Edit
Download
📄
class-wp-query.php
File
163744
Delete
Rename
Edit
Download
📄
class-wp-recovery-mode-cookie-service.php
File
6877
Delete
Rename
Edit
Download
📄
class-wp-recovery-mode-email-service.php
File
11183
Delete
Rename
Edit
Download
📄
class-wp-recovery-mode-key-service.php
File
4884
Delete
Rename
Edit
Download
📄
class-wp-recovery-mode-link-service.php
File
3463
Delete
Rename
Edit
Download
📄
class-wp-recovery-mode.php
File
11453
Delete
Rename
Edit
Download
📄
class-wp-rewrite.php
File
63687
Delete
Rename
Edit
Download
📄
class-wp-role.php
File
2523
Delete
Rename
Edit
Download
📄
class-wp-roles.php
File
9394
Delete
Rename
Edit
Download
📄
class-wp-script-modules.php
File
31882
Delete
Rename
Edit
Download
📄
class-wp-scripts.php
File
34177
Delete
Rename
Edit
Download
📄
class-wp-session-tokens.php
File
7319
Delete
Rename
Edit
Download
📄
class-wp-simplepie-file.php
File
3552
Delete
Rename
Edit
Download
📄
class-wp-simplepie-sanitize-kses.php
File
1910
Delete
Rename
Edit
Download
📄
class-wp-site-query.php
File
31655
Delete
Rename
Edit
Download
📄
class-wp-site.php
File
7467
Delete
Rename
Edit
Download
📄
class-wp-speculation-rules.php
File
7527
Delete
Rename
Edit
Download
📄
class-wp-styles.php
File
12144
Delete
Rename
Edit
Download
📄
class-wp-tax-query.php
File
19577
Delete
Rename
Edit
Download
📄
class-wp-taxonomy.php
File
18559
Delete
Rename
Edit
Download
📄
class-wp-term-query.php
File
40953
Delete
Rename
Edit
Download
📄
class-wp-term.php
File
5298
Delete
Rename
Edit
Download
📄
class-wp-text-diff-renderer-inline.php
File
979
Delete
Rename
Edit
Download
📄
class-wp-text-diff-renderer-table.php
File
18880
Delete
Rename
Edit
Download
📄
class-wp-textdomain-registry.php
File
10481
Delete
Rename
Edit
Download
📄
class-wp-theme-json-data.php
File
1809
Delete
Rename
Edit
Download
📄
class-wp-theme-json-resolver.php
File
35738
Delete
Rename
Edit
Download
📄
class-wp-theme-json-schema.php
File
7367
Delete
Rename
Edit
Download
📄
class-wp-theme-json.php
File
164347
Delete
Rename
Edit
Download
📄
class-wp-theme.php
File
65810
Delete
Rename
Edit
Download
📄
class-wp-token-map.php
File
28618
Delete
Rename
Edit
Download
📄
class-wp-url-pattern-prefixer.php
File
4802
Delete
Rename
Edit
Download
📄
class-wp-user-meta-session-tokens.php
File
3011
Delete
Rename
Edit
Download
📄
class-wp-user-query.php
File
44166
Delete
Rename
Edit
Download
📄
class-wp-user-request.php
File
2305
Delete
Rename
Edit
Download
📄
class-wp-user.php
File
23044
Delete
Rename
Edit
Download
📄
class-wp-walker.php
File
13322
Delete
Rename
Edit
Download
📄
class-wp-widget-factory.php
File
3347
Delete
Rename
Edit
Download
📄
class-wp-widget.php
File
18429
Delete
Rename
Edit
Download
📄
class-wp-xmlrpc-server.php
File
215447
Delete
Rename
Edit
Download
📄
class-wp.php
File
26481
Delete
Rename
Edit
Download
📄
class-wpdb.php
File
118627
Delete
Rename
Edit
Download
📄
class.wp-dependencies.php
File
373
Delete
Rename
Edit
Download
📄
class.wp-scripts.php
File
343
Delete
Rename
Edit
Download
📄
class.wp-styles.php
File
338
Delete
Rename
Edit
Download
📄
comment-template.php
File
103145
Delete
Rename
Edit
Download
📄
comment.php
File
134069
Delete
Rename
Edit
Download
📄
compat-utf8.php
File
19554
Delete
Rename
Edit
Download
📄
compat.php
File
17830
Delete
Rename
Edit
Download
📄
cron.php
File
42988
Delete
Rename
Edit
Download
📁
css
Folder
-
Delete
Rename
📁
customize
Folder
-
Delete
Rename
📄
date.php
File
400
Delete
Rename
Edit
Download
📄
default-constants.php
File
11365
Delete
Rename
Edit
Download
📄
default-filters.php
File
37910
Delete
Rename
Edit
Download
📄
default-widgets.php
File
2295
Delete
Rename
Edit
Download
📄
deprecated.php
File
192644
Delete
Rename
Edit
Download
📄
embed-template.php
File
338
Delete
Rename
Edit
Download
📄
embed.php
File
38911
Delete
Rename
Edit
Download
📄
error-protection.php
File
4121
Delete
Rename
Edit
Download
📄
feed-atom-comments.php
File
5504
Delete
Rename
Edit
Download
📄
feed-atom.php
File
3121
Delete
Rename
Edit
Download
📄
feed-rdf.php
File
2668
Delete
Rename
Edit
Download
📄
feed-rss.php
File
1189
Delete
Rename
Edit
Download
📄
feed-rss2-comments.php
File
4136
Delete
Rename
Edit
Download
📄
feed-rss2.php
File
3799
Delete
Rename
Edit
Download
📄
feed.php
File
23579
Delete
Rename
Edit
Download
📁
fonts
Folder
-
Delete
Rename
📄
fonts.php
File
9790
Delete
Rename
Edit
Download
📄
formatting.php
File
354741
Delete
Rename
Edit
Download
📄
functions.php
File
288600
Delete
Rename
Edit
Download
📄
functions.wp-scripts.php
File
15311
Delete
Rename
Edit
Download
📄
functions.wp-styles.php
File
8641
Delete
Rename
Edit
Download
📄
general-template.php
File
173004
Delete
Rename
Edit
Download
📄
global-styles-and-settings.php
File
21204
Delete
Rename
Edit
Download
📁
html-api
Folder
-
Delete
Rename
📄
http.php
File
25878
Delete
Rename
Edit
Download
📄
https-detection.php
File
5857
Delete
Rename
Edit
Download
📄
https-migration.php
File
4741
Delete
Rename
Edit
Download
📁
images
Folder
-
Delete
Rename
📁
interactivity-api
Folder
-
Delete
Rename
📁
js
Folder
-
Delete
Rename
📄
kses.php
File
83677
Delete
Rename
Edit
Download
📁
l10n
Folder
-
Delete
Rename
📄
l10n.php
File
68797
Delete
Rename
Edit
Download
📄
link-template.php
File
160117
Delete
Rename
Edit
Download
📄
load.php
File
56510
Delete
Rename
Edit
Download
📄
locale.php
File
162
Delete
Rename
Edit
Download
📄
media-template.php
File
63197
Delete
Rename
Edit
Download
📄
media.php
File
221186
Delete
Rename
Edit
Download
📄
meta.php
File
66556
Delete
Rename
Edit
Download
📄
ms-blogs.php
File
25845
Delete
Rename
Edit
Download
📄
ms-default-constants.php
File
4921
Delete
Rename
Edit
Download
📄
ms-default-filters.php
File
6636
Delete
Rename
Edit
Download
📄
ms-deprecated.php
File
21759
Delete
Rename
Edit
Download
📄
ms-files.php
File
2857
Delete
Rename
Edit
Download
📄
ms-functions.php
File
91842
Delete
Rename
Edit
Download
📄
ms-load.php
File
19887
Delete
Rename
Edit
Download
📄
ms-network.php
File
3782
Delete
Rename
Edit
Download
📄
ms-settings.php
File
4204
Delete
Rename
Edit
Download
📄
ms-site.php
File
41717
Delete
Rename
Edit
Download
📄
nav-menu-template.php
File
25990
Delete
Rename
Edit
Download
📄
nav-menu.php
File
44373
Delete
Rename
Edit
Download
📄
option.php
File
105035
Delete
Rename
Edit
Download
📁
php-compat
Folder
-
Delete
Rename
📄
pluggable-deprecated.php
File
6324
Delete
Rename
Edit
Download
📄
pluggable.php
File
127440
Delete
Rename
Edit
Download
📄
plugin.php
File
36501
Delete
Rename
Edit
Download
📁
pomo
Folder
-
Delete
Rename
📄
post-formats.php
File
7102
Delete
Rename
Edit
Download
📄
post-template.php
File
68648
Delete
Rename
Edit
Download
📄
post-thumbnail-template.php
File
10879
Delete
Rename
Edit
Download
📄
post.php
File
296072
Delete
Rename
Edit
Download
📄
query.php
File
37095
Delete
Rename
Edit
Download
📄
registration-functions.php
File
200
Delete
Rename
Edit
Download
📄
registration.php
File
200
Delete
Rename
Edit
Download
📁
rest-api
Folder
-
Delete
Rename
📄
rest-api.php
File
100654
Delete
Rename
Edit
Download
📄
revision.php
File
30741
Delete
Rename
Edit
Download
📄
rewrite.php
File
19490
Delete
Rename
Edit
Download
📄
robots-template.php
File
5185
Delete
Rename
Edit
Download
📄
rss-functions.php
File
255
Delete
Rename
Edit
Download
📄
rss.php
File
23203
Delete
Rename
Edit
Download
📄
script-loader.php
File
153993
Delete
Rename
Edit
Download
📄
script-modules.php
File
9911
Delete
Rename
Edit
Download
📄
session.php
File
258
Delete
Rename
Edit
Download
📄
shortcodes.php
File
24050
Delete
Rename
Edit
Download
📁
sitemaps
Folder
-
Delete
Rename
📄
sitemaps.php
File
3238
Delete
Rename
Edit
Download
📁
sodium_compat
Folder
-
Delete
Rename
📄
speculative-loading.php
File
8600
Delete
Rename
Edit
Download
📄
spl-autoload-compat.php
File
441
Delete
Rename
Edit
Download
📁
style-engine
Folder
-
Delete
Rename
📄
style-engine.php
File
7563
Delete
Rename
Edit
Download
📄
taxonomy.php
File
177058
Delete
Rename
Edit
Download
📄
template-canvas.php
File
544
Delete
Rename
Edit
Download
📄
template-loader.php
File
3929
Delete
Rename
Edit
Download
📄
template.php
File
36834
Delete
Rename
Edit
Download
📁
theme-compat
Folder
-
Delete
Rename
📄
theme-i18n.json
File
1526
Delete
Rename
Edit
Download
📄
theme-previews.php
File
2910
Delete
Rename
Edit
Download
📄
theme-templates.php
File
6238
Delete
Rename
Edit
Download
📄
theme.json
File
8921
Delete
Rename
Edit
Download
📄
theme.php
File
135008
Delete
Rename
Edit
Download
📄
update.php
File
38353
Delete
Rename
Edit
Download
📄
user.php
File
178062
Delete
Rename
Edit
Download
📄
utf8.php
File
7260
Delete
Rename
Edit
Download
📄
vars.php
File
6562
Delete
Rename
Edit
Download
📄
version.php
File
1104
Delete
Rename
Edit
Download
📁
widgets
Folder
-
Delete
Rename
📄
widgets.php
File
71129
Delete
Rename
Edit
Download
📄
wp-db.php
File
445
Delete
Rename
Edit
Download
📄
wp-diff.php
File
799
Delete
Rename
Edit
Download
Upload
Create Folder
📝 Editing:
abilities-api.php
Size: 24,369 bytes
Lines: 615
Type: .php
💾 Save
Cancel
✕
<?php /** * Abilities API: core functions for registering and managing abilities. * * The Abilities API provides a unified, extensible framework for registering * and executing discrete capabilities within WordPress. An "ability" is a * self-contained unit of functionality with defined inputs, outputs, permissions, * and execution logic. * * ## Overview * * The Abilities API enables developers to: * * - Register custom abilities with standardized interfaces. * - Define permission checks and execution callbacks. * - Organize abilities into logical categories. * - Validate inputs and outputs using JSON Schema. * - Expose abilities through the REST API. * * ## Working with Abilities * * Abilities must be registered on the `wp_abilities_api_init` action hook. * Attempting to register an ability outside of this hook will fail and * trigger a `_doing_it_wrong()` notice. * Example: * * function my_plugin_register_abilities(): void { * wp_register_ability( * 'my-plugin/export-users', * array( * 'label' => __( 'Export Users', 'my-plugin' ), * 'description' => __( 'Exports user data to CSV format.', 'my-plugin' ), * 'category' => 'data-export', * 'execute_callback' => 'my_plugin_export_users', * 'permission_callback' => function(): bool { * return current_user_can( 'export' ); * }, * 'input_schema' => array( * 'type' => 'string', * 'enum' => array( 'subscriber', 'contributor', 'author', 'editor', 'administrator' ), * 'description' => __( 'Limits the export to users with this role.', 'my-plugin' ), * 'required' => false, * ), * 'output_schema' => array( * 'type' => 'string', * 'description' => __( 'User data in CSV format.', 'my-plugin' ), * 'required' => true, * ), * 'meta' => array( * 'show_in_rest' => true, * ), * ) * ); * } * add_action( 'wp_abilities_api_init', 'my_plugin_register_abilities' ); * * Once registered, abilities can be checked, retrieved, and managed: * * // Checks if an ability is registered, and prints its label. * if ( wp_has_ability( 'my-plugin/export-users' ) ) { * $ability = wp_get_ability( 'my-plugin/export-users' ); * * echo $ability->get_label(); * } * * // Gets all registered abilities. * $all_abilities = wp_get_abilities(); * * // Unregisters when no longer needed. * wp_unregister_ability( 'my-plugin/export-users' ); * * ## Best Practices * * - Always register abilities on the `wp_abilities_api_init` hook. * - Use namespaced ability names to prevent conflicts. * - Implement robust permission checks in permission callbacks. * - Provide an `input_schema` to ensure data integrity and document expected inputs. * - Define an `output_schema` to describe return values and validate responses. * - Return `WP_Error` objects for failures rather than throwing exceptions. * - Use internationalization functions for all user-facing strings. * * @package WordPress * @subpackage Abilities_API * @since 6.9.0 */ declare( strict_types = 1 ); /** * Registers a new ability using the Abilities API. It requires three steps: * * 1. Hook into the `wp_abilities_api_init` action. * 2. Call `wp_register_ability()` with a namespaced name and configuration. * 3. Provide execute and permission callbacks. * * Example: * * function my_plugin_register_abilities(): void { * wp_register_ability( * 'my-plugin/analyze-text', * array( * 'label' => __( 'Analyze Text', 'my-plugin' ), * 'description' => __( 'Performs sentiment analysis on provided text.', 'my-plugin' ), * 'category' => 'text-processing', * 'input_schema' => array( * 'type' => 'string', * 'description' => __( 'The text to be analyzed.', 'my-plugin' ), * 'minLength' => 10, * 'required' => true, * ), * 'output_schema' => array( * 'type' => 'string', * 'enum' => array( 'positive', 'negative', 'neutral' ), * 'description' => __( 'The sentiment result: positive, negative, or neutral.', 'my-plugin' ), * 'required' => true, * ), * 'execute_callback' => 'my_plugin_analyze_text', * 'permission_callback' => 'my_plugin_can_analyze_text', * 'meta' => array( * 'annotations' => array( * 'readonly' => true, * ), * 'show_in_rest' => true, * ), * ) * ); * } * add_action( 'wp_abilities_api_init', 'my_plugin_register_abilities' ); * * ### Naming Conventions * * Ability names must follow these rules: * * - Include a namespace prefix (e.g., `my-plugin/my-ability`). * - Use only lowercase alphanumeric characters, dashes, and forward slashes. * - Use descriptive, action-oriented names (e.g., `process-payment`, `generate-report`). * * ### Categories * * Abilities must be organized into categories. Ability categories provide better * discoverability and must be registered before the abilities that reference them: * * function my_plugin_register_categories(): void { * wp_register_ability_category( * 'text-processing', * array( * 'label' => __( 'Text Processing', 'my-plugin' ), * 'description' => __( 'Abilities for analyzing and transforming text.', 'my-plugin' ), * ) * ); * } * add_action( 'wp_abilities_api_categories_init', 'my_plugin_register_categories' ); * * ### Input and Output Schemas * * Schemas define the expected structure, type, and constraints for ability inputs * and outputs using JSON Schema syntax. They serve two critical purposes: automatic * validation of data passed to and returned from abilities, and self-documenting * API contracts for developers. * * WordPress implements a validator based on a subset of the JSON Schema Version 4 * specification (https://json-schema.org/specification-links.html#draft-4). * For details on supported JSON Schema properties and syntax, see the * related WordPress REST API Schema documentation: * https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#json-schema-basics * * Defining schemas is mandatory when there is a value to pass or return. * They ensure data integrity, improve developer experience, and enable * better documentation: * * 'input_schema' => array( * 'type' => 'string', * 'description' => __( 'The text to be analyzed.', 'my-plugin' ), * 'minLength' => 10, * 'required' => true, * ), * 'output_schema' => array( * 'type' => 'string', * 'enum' => array( 'positive', 'negative', 'neutral' ), * 'description' => __( 'The sentiment result: positive, negative, or neutral.', 'my-plugin' ), * 'required' => true, * ), * * ### Callbacks * * #### Execute Callback * * The execute callback performs the ability's core functionality. It receives * optional input data and returns either a result or `WP_Error` on failure. * * function my_plugin_analyze_text( string $input ): string|WP_Error { * $score = My_Plugin::perform_sentiment_analysis( $input ); * if ( is_wp_error( $score ) ) { * return $score; * } * return My_Plugin::interpret_sentiment_score( $score ); * } * * #### Permission Callback * * The permission callback determines whether the ability can be executed. * It receives the same input as the execute callback and must return a * boolean or `WP_Error`. Common use cases include checking user capabilities, * validating API keys, or verifying system state: * * function my_plugin_can_analyze_text( string $input ): bool|WP_Error { * return current_user_can( 'edit_posts' ); * } * * ### REST API Integration * * Abilities can be exposed through the REST API by setting `show_in_rest` * to `true` in the meta configuration: * * 'meta' => array( * 'show_in_rest' => true, * ), * * This allows abilities to be invoked via HTTP requests to the WordPress REST API. * * @since 6.9.0 * * @see WP_Abilities_Registry::register() * @see wp_register_ability_category() * @see wp_unregister_ability() * * @param string $name The name of the ability. Must be a namespaced string containing * a prefix, e.g., `my-plugin/my-ability`. Can only contain lowercase * alphanumeric characters, dashes, and forward slashes. * @param array<string, mixed> $args { * An associative array of arguments for configuring the ability. * * @type string $label Required. The human-readable label for the ability. * @type string $description Required. A detailed description of what the ability does * and when it should be used. * @type string $category Required. The ability category slug this ability belongs to. * The ability category must be registered via `wp_register_ability_category()` * before registering the ability. * @type callable $execute_callback Required. A callback function to execute when the ability is invoked. * Receives optional mixed input data and must return either a result * value (any type) or a `WP_Error` object on failure. * @type callable $permission_callback Required. A callback function to check permissions before execution. * Receives optional mixed input data (same as `execute_callback`) and * must return `true`/`false` for simple checks, or `WP_Error` for * detailed error responses. * @type array<string, mixed> $input_schema Optional. JSON Schema definition for validating the ability's input. * Must be a valid JSON Schema object defining the structure and * constraints for input data. Used for automatic validation and * API documentation. * @type array<string, mixed> $output_schema Optional. JSON Schema definition for the ability's output. * Describes the structure of successful return values from * `execute_callback`. Used for documentation and validation. * @type array<string, mixed> $meta { * Optional. Additional metadata for the ability. * * @type array<string, bool|null> $annotations { * Optional. Semantic annotations describing the ability's behavioral characteristics. * These annotations are hints for tooling and documentation. * * @type bool|null $readonly Optional. If true, the ability does not modify its environment. * @type bool|null $destructive Optional. If true, the ability may perform destructive updates to its environment. * If false, the ability performs only additive updates. * @type bool|null $idempotent Optional. If true, calling the ability repeatedly with the same arguments * will have no additional effect on its environment. * } * @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. * When true, the ability can be invoked via HTTP requests. * Default false. * } * @type string $ability_class Optional. Fully-qualified custom class name to instantiate * instead of the default `WP_Ability` class. The custom class * must extend `WP_Ability`. Useful for advanced customization * of ability behavior. * } * @return WP_Ability|null The registered ability instance on success, `null` on failure. */ function wp_register_ability( string $name, array $args ): ?WP_Ability { if ( ! doing_action( 'wp_abilities_api_init' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( /* translators: 1: wp_abilities_api_init, 2: string value of the ability name. */ __( 'Abilities must be registered on the %1$s action. The ability %2$s was not registered.' ), '<code>wp_abilities_api_init</code>', '<code>' . esc_html( $name ) . '</code>' ), '6.9.0' ); return null; } $registry = WP_Abilities_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->register( $name, $args ); } /** * Unregisters an ability from the Abilities API. * * Removes a previously registered ability from the global registry. Use this to * disable abilities provided by other plugins or when an ability is no longer needed. * * Can be called at any time after the ability has been registered. * * Example: * * if ( wp_has_ability( 'other-plugin/some-ability' ) ) { * wp_unregister_ability( 'other-plugin/some-ability' ); * } * * @since 6.9.0 * * @see WP_Abilities_Registry::unregister() * @see wp_register_ability() * * @param string $name The name of the ability to unregister, including namespace prefix * (e.g., 'my-plugin/my-ability'). * @return WP_Ability|null The unregistered ability instance on success, `null` on failure. */ function wp_unregister_ability( string $name ): ?WP_Ability { $registry = WP_Abilities_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->unregister( $name ); } /** * Checks if an ability is registered. * * Use this for conditional logic and feature detection before attempting to * retrieve or use an ability. * * Example: * * // Displays different UI based on available abilities. * if ( wp_has_ability( 'premium-plugin/advanced-export' ) ) { * echo 'Export with Premium Features'; * } else { * echo 'Basic Export'; * } * * @since 6.9.0 * * @see WP_Abilities_Registry::is_registered() * @see wp_get_ability() * * @param string $name The name of the ability to check, including namespace prefix * (e.g., 'my-plugin/my-ability'). * @return bool `true` if the ability is registered, `false` otherwise. */ function wp_has_ability( string $name ): bool { $registry = WP_Abilities_Registry::get_instance(); if ( null === $registry ) { return false; } return $registry->is_registered( $name ); } /** * Retrieves a registered ability. * * Returns the ability instance for inspection or use. The instance provides access * to the ability's configuration, metadata, and execution methods. * * Example: * * // Prints information about a registered ability. * $ability = wp_get_ability( 'my-plugin/export-data' ); * if ( $ability ) { * echo $ability->get_label() . ': ' . $ability->get_description(); * } * * @since 6.9.0 * * @see WP_Abilities_Registry::get_registered() * @see wp_has_ability() * * @param string $name The name of the ability, including namespace prefix * (e.g., 'my-plugin/my-ability'). * @return WP_Ability|null The registered ability instance, or `null` if not registered. */ function wp_get_ability( string $name ): ?WP_Ability { $registry = WP_Abilities_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->get_registered( $name ); } /** * Retrieves all registered abilities. * * Returns an array of all ability instances currently registered in the system. * Use this for discovery, debugging, or building administrative interfaces. * * Example: * * // Prints information about all available abilities. * $abilities = wp_get_abilities(); * foreach ( $abilities as $ability ) { * echo $ability->get_label() . ': ' . $ability->get_description() . "\n"; * } * * @since 6.9.0 * * @see WP_Abilities_Registry::get_all_registered() * * @return WP_Ability[] An array of registered WP_Ability instances. Returns an empty * array if no abilities are registered or if the registry is unavailable. */ function wp_get_abilities(): array { $registry = WP_Abilities_Registry::get_instance(); if ( null === $registry ) { return array(); } return $registry->get_all_registered(); } /** * Registers a new ability category. * * Ability categories provide a way to organize and group related abilities for better * discoverability and management. Ability categories must be registered before abilities * that reference them. * * Ability categories must be registered on the `wp_abilities_api_categories_init` action hook. * * Example: * * function my_plugin_register_categories() { * wp_register_ability_category( * 'content-management', * array( * 'label' => __( 'Content Management', 'my-plugin' ), * 'description' => __( 'Abilities for managing and organizing content.', 'my-plugin' ), * ) * ); * } * add_action( 'wp_abilities_api_categories_init', 'my_plugin_register_categories' ); * * @since 6.9.0 * * @see WP_Ability_Categories_Registry::register() * @see wp_register_ability() * @see wp_unregister_ability_category() * * @param string $slug The unique slug for the ability category. Must contain only lowercase * alphanumeric characters and dashes (e.g., 'data-export'). * @param array<string, mixed> $args { * An associative array of arguments for the ability category. * * @type string $label Required. The human-readable label for the ability category. * @type string $description Required. A description of what abilities in this category do. * @type array<string, mixed> $meta Optional. Additional metadata for the ability category. * } * @return WP_Ability_Category|null The registered ability category instance on success, `null` on failure. */ function wp_register_ability_category( string $slug, array $args ): ?WP_Ability_Category { if ( ! doing_action( 'wp_abilities_api_categories_init' ) ) { _doing_it_wrong( __FUNCTION__, sprintf( /* translators: 1: wp_abilities_api_categories_init, 2: ability category slug. */ __( 'Ability categories must be registered on the %1$s action. The ability category %2$s was not registered.' ), '<code>wp_abilities_api_categories_init</code>', '<code>' . esc_html( $slug ) . '</code>' ), '6.9.0' ); return null; } $registry = WP_Ability_Categories_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->register( $slug, $args ); } /** * Unregisters an ability category. * * Removes a previously registered ability category from the global registry. Use this to * disable ability categories that are no longer needed. * * Can be called at any time after the ability category has been registered. * * Example: * * if ( wp_has_ability_category( 'deprecated-category' ) ) { * wp_unregister_ability_category( 'deprecated-category' ); * } * * @since 6.9.0 * * @see WP_Ability_Categories_Registry::unregister() * @see wp_register_ability_category() * * @param string $slug The slug of the ability category to unregister. * @return WP_Ability_Category|null The unregistered ability category instance on success, `null` on failure. */ function wp_unregister_ability_category( string $slug ): ?WP_Ability_Category { $registry = WP_Ability_Categories_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->unregister( $slug ); } /** * Checks if an ability category is registered. * * Use this for conditional logic and feature detection before attempting to * retrieve or use an ability category. * * Example: * * // Displays different UI based on available ability categories. * if ( wp_has_ability_category( 'premium-features' ) ) { * echo 'Premium Features Available'; * } else { * echo 'Standard Features'; * } * * @since 6.9.0 * * @see WP_Ability_Categories_Registry::is_registered() * @see wp_get_ability_category() * * @param string $slug The slug of the ability category to check. * @return bool `true` if the ability category is registered, `false` otherwise. */ function wp_has_ability_category( string $slug ): bool { $registry = WP_Ability_Categories_Registry::get_instance(); if ( null === $registry ) { return false; } return $registry->is_registered( $slug ); } /** * Retrieves a registered ability category. * * Returns the ability category instance for inspection or use. The instance provides access * to the ability category's configuration and metadata. * * Example: * * // Prints information about a registered ability category. * $ability_category = wp_get_ability_category( 'content-management' ); * if ( $ability_category ) { * echo $ability_category->get_label() . ': ' . $ability_category->get_description(); * } * * @since 6.9.0 * * @see WP_Ability_Categories_Registry::get_registered() * @see wp_has_ability_category() * @see wp_get_ability_categories() * * @param string $slug The slug of the ability category. * @return WP_Ability_Category|null The ability category instance, or `null` if not registered. */ function wp_get_ability_category( string $slug ): ?WP_Ability_Category { $registry = WP_Ability_Categories_Registry::get_instance(); if ( null === $registry ) { return null; } return $registry->get_registered( $slug ); } /** * Retrieves all registered ability categories. * * Returns an array of all ability category instances currently registered in the system. * Use this for discovery, debugging, or building administrative interfaces. * * Example: * * // Prints information about all available ability categories. * $ability_categories = wp_get_ability_categories(); * foreach ( $ability_categories as $ability_category ) { * echo $ability_category->get_label() . ': ' . $ability_category->get_description() . "\n"; * } * * @since 6.9.0 * * @see WP_Ability_Categories_Registry::get_all_registered() * @see wp_get_ability_category() * * @return WP_Ability_Category[] An array of registered ability category instances. Returns an empty array * if no ability categories are registered or if the registry is unavailable. */ function wp_get_ability_categories(): array { $registry = WP_Ability_Categories_Registry::get_instance(); if ( null === $registry ) { return array(); } return $registry->get_all_registered(); }
✅ File saved successfully!