PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / trunk
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages vtrunk
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / includes / mcp / class-convertkit-mcp-ability.php

class-convertkit-mcp-ability.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages trunk, at includes/mcp/class-convertkit-mcp-ability.php

166 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Kit MCP Ability base class.
4 *
5 * @package ConvertKit
6 * @author ConvertKit
7 */
8
9 /**
10 * Abstract base for all Kit Plugin abilities exposed via the WordPress Abilities
11 * API and MCP Adapter.
12 *
13 * @package ConvertKit
14 * @author ConvertKit
15 */
16 abstract class ConvertKit_MCP_Ability {
17
18 /**
19 * Sets whether the ability is readonly.
20 *
21 * @since 3.4.0
22 *
23 * @var bool
24 */
25 private $readonly = false;
26
27 /**
28 * Sets whether the ability is destructive.
29 *
30 * @since 3.4.0
31 *
32 * @var bool
33 */
34 private $destructive = false;
35
36 /**
37 * Sets whether the ability is idempotent.
38 *
39 * @since 3.4.0
40 *
41 * @var bool
42 */
43 private $idempotent = false;
44
45 /**
46 * Returns the ability name, prefixed with `kit/` (e.g. `kit/form-insert`).
47 *
48 * @since 3.4.0
49 *
50 * @return string
51 */
52 abstract public function get_name();
53
54 /**
55 * Returns the arguments array passed to wp_register_ability().
56 *
57 * @since 3.4.0
58 *
59 * @return array
60 */
61 public function get_ability_args() {
62
63 return array(
64 'label' => $this->get_label(),
65 'description' => $this->get_description(),
66 'category' => $this->get_category(),
67 'input_schema' => $this->get_input_schema(),
68 'output_schema' => $this->get_output_schema(),
69 'permission_callback' => array( $this, 'permission_callback' ),
70 'execute_callback' => array( $this, 'execute_callback' ),
71 'meta' => array(
72 'annotations' => $this->get_annotations(),
73 ),
74 );
75
76 }
77
78 /**
79 * Returns the ability's human-readable label.
80 *
81 * @since 3.4.0
82 *
83 * @return string
84 */
85 abstract public function get_label();
86
87 /**
88 * Returns the ability's human-readable description.
89 *
90 * @since 3.4.0
91 *
92 * @return string
93 */
94 abstract public function get_description();
95
96 /**
97 * Returns the ability's category.
98 *
99 * @since 3.4.0
100 *
101 * @return string
102 */
103 public function get_category() {
104
105 return 'kit';
106
107 }
108
109 /**
110 * Returns the ability's input JSON Schema.
111 *
112 * @since 3.4.0
113 *
114 * @return array
115 */
116 abstract public function get_input_schema();
117
118 /**
119 * Returns the ability's output JSON Schema.
120 *
121 * @since 3.4.0
122 *
123 * @return array
124 */
125 abstract public function get_output_schema();
126
127 /**
128 * Define the annotations for the ability.
129 *
130 * @since 3.4.0
131 *
132 * @return array
133 */
134 public function get_annotations() {
135
136 return array(
137 'title' => $this->get_label(),
138 'readonly' => $this->readonly,
139 'destructive' => $this->destructive,
140 'idempotent' => $this->idempotent,
141 );
142
143 }
144
145 /**
146 * Permission callback for this ability.
147 *
148 * @since 3.4.0
149 *
150 * @param array $input Ability input.
151 * @return bool|WP_Error
152 */
153 abstract public function permission_callback( $input );
154
155 /**
156 * Execute callback for this ability.
157 *
158 * @since 3.4.0
159 *
160 * @param array $input Ability input.
161 * @return array|WP_Error
162 */
163 abstract public function execute_callback( $input );
164
165 }
166