Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:25:36 +08:00
commit cfadf66888
24 changed files with 4160 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
/**
* Client-Side Ability: {{LABEL}}
*
* {{DESCRIPTION}}
*/
import { registerAbility } from '@wordpress/abilities';
/**
* Register the {{ABILITY_NAME}} ability.
*/
registerAbility( {
name: '{{ABILITY_NAME}}',
label: '{{LABEL}}',
description: '{{DESCRIPTION}}',
category: '{{CATEGORY}}',
// Define expected input structure using JSON Schema
inputSchema: {
type: 'object',
properties: {
// TODO: Define input parameters
// param1: {
// type: 'string',
// description: 'Description of parameter',
// },
},
required: [], // TODO: List required parameters
additionalProperties: false,
},
// Define output structure using JSON Schema
outputSchema: {
type: 'object',
properties: {
result: {
type: 'string',
description: 'The result of the operation',
},
},
},
// The async callback function to execute
callback: async ( input ) => {
// TODO: Implement your ability logic here
// Example error handling:
// if ( ! someValidation( input ) ) {
// throw new Error( 'The provided input is invalid.' );
// }
return {
result: 'TODO: Implement logic',
};
},
// Permission check callback
permissionCallback: ( input ) => {
// TODO: Implement appropriate permission checks
// Examples:
// return window.wp?.data?.select('core')?.getCurrentUser() !== null;
return true; // Everyone can access (use with caution!)
},
// Metadata
meta: {
annotations: {
readonly: {{READONLY}},
destructive: {{DESTRUCTIVE}},
idempotent: {{IDEMPOTENT}},
},
},
} );