用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/wp-media/wp-rocket --skill wordpress-ability命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | wordpress-ability |
| description | Use this skill when adding or modifying WordPress abilities |
Always check if the function exists before calling it, to ensure compatibility with WordPress versions prior to 6.9:
if ( ! function_exists( 'wp_register_ability' ) ) {
return;
}
To add a new ability, follow these steps:
AbilitiesInterfaceServiceProviderwp_abilities_api_init hookAn ability name must be unique and follow the format wp-rocket/ability-name, where wp-rocket is the vendor name and ability-name is a descriptive name for the ability. Use hyphens to separate words in the ability name.
The check_permissions()method should always verify against the current user capabilities, using current_user_can( 'rocket_manage_options ) by default, to ensure that only authorized users can execute the ability, except explicitly required otherwise.
An ability must be associated to an ability category. If the category doesn't exist yet, register a new one in the related subscriber using the wp_abilities_api_categories_init hook.
Make the ability available to the REST API and the MCP by adding meta.show_in_rest=true and meta.mcp.public=true when registering the ability, unless explicitly required otherwise.
Annotations should be added to the meta field when registering the ability, as an array of key-value pairs:
An example of an ability class can be found in the /inc/Engine/Abilities/Options/GetOptions.php file.
If an ability requires input parameters, the parameters of the execute() method should always match the input schema defined when registering the ability.
The return value of the execute() method of an ability should always match the output schema defined when registering the ability.
Test only the execute() method of the ability class, which contains the logic to perform the action associated with the ability. Mock any dependencies and assert that the method behaves as expected under different conditions.
An example of unit tests for an ability class can be found in the /tests/Unit/inc/Engine/Abilities/Options/GetOptions/ExecuteTest.php file.
Check for WordPress version compatibility, abilities are available starting WordPress 6.9. Mark skip test if version under test is lower than 6.9.
Set up user to ensure ability permissions are correctly applied. Add scenario where user has the ability and another where they don't, and assert that the expected outcomes occur in both cases.
Test ability execution output by getting the ability WP_Ability object using wp_get_ability( $ability_name ) and calling the execute() method. Assert that the output is correct based on the input parameters and the expected behavior of the ability.
An example of integration tests for an ability class can be found in the /tests/Integration/inc/Engine/Abilities/Options/GetOptions/RegisterGetOptionsAbilityTest.php file.