PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | app/Agent/AbilitiesDiscovery.php +105 -3 3.1.23.2.1 View file →
@@ -44,12 +44,14 @@
44 44 *
45 45 * @param array $abilities WP_Ability objects from wp_get_abilities().
46 46 * @param array $categories WP_Ability_Category objects from wp_get_ability_categories().
47 47 * @param array|null $allowlist Namespace prefixes to keep; null keeps every namespace.
48 + * @param array|null $glossary English label => our translation; null uses the shipped map.
48 49 * @return array
49 50 */
50 - public static function shape(array $abilities, array $categories = [], $allowlist = null)
51 + public static function shape(array $abilities, array $categories = [], $allowlist = null, $glossary = null)
51 52 {
53 + $glossary = $glossary ?? self::labelGlossary();
52 54 $allowed = array_filter($abilities, function ($ability) use ($allowlist) {
53 55 if (!$ability->get_meta_item('show_in_rest')) {
54 56 return false;
55 57 }
@@ -64,13 +66,19 @@
64 66 $byCategory = [];
65 67 foreach ($allowed as $ability) {
66 68 $meta = $ability->get_meta();
67 69 $name = $ability->get_name();
70 + $label = $ability->get_label();
71 + $schema = $ability->get_input_schema();
72 + // Filters out unnecessary context
73 + if (function_exists('wp_prepare_json_schema_for_client')) {
74 + $schema = wp_prepare_json_schema_for_client($schema);
75 + }
68 76 $byCategory[$ability->get_category()][] = [
69 77 'name' => $name,
70 - 'label' => $ability->get_label(),
78 + 'label' => $glossary[$label] ?? $label,
71 79 'description' => $ability->get_description(),
72 - 'inputSchema' => $ability->get_input_schema(),
80 + 'inputSchema' => $schema,
73 81 'annotations' => $meta['annotations'] ?? null,
74 82 'runHref' => \rest_url('wp-abilities/v1/abilities/' . $name . '/run'),
75 83 ];
76 84 }
@@ -93,6 +101,100 @@
93 101 ];
94 102 }
95 103
96 104 return $result;
105 + }
106 +
107 + /**
108 + * Our own translations for third-party ability labels, keyed by the exact
109 + * English string the plugin registers. A polyfill: once the plugin ships its
110 + * own translation, get_label() returns the localized string, which no longer
111 + * matches the English key, so upstream wins and this map goes dormant.
112 + *
113 + * @return array
114 + */
115 + private static function labelGlossary()
116 + {
117 + return [
118 + // translators: WooCommerce AI Agent ability — searches the store's products.
119 + 'Query products' => __('Query products', 'extendify-local'),
120 + // translators: WooCommerce AI Agent ability — searches the store's orders.
121 + 'Query orders' => __('Query orders', 'extendify-local'),
122 + // translators: WooCommerce AI Agent ability — creates a product.
123 + 'Create product' => __('Create product', 'extendify-local'),
124 + // translators: WooCommerce AI Agent ability — updates a product.
125 + 'Update product' => __('Update product', 'extendify-local'),
126 + // translators: WooCommerce AI Agent ability — deletes a product.
127 + 'Delete product' => __('Delete product', 'extendify-local'),
128 + // translators: WooCommerce AI Agent ability — adds a note to an order.
129 + 'Add order note' => __('Add order note', 'extendify-local'),
130 + // translators: WooCommerce AI Agent ability — changes an order's status.
131 + 'Update order status' => __('Update order status', 'extendify-local'),
132 + // translators: TranslatePress AI Agent ability — adds a translation language.
133 + 'Add a translation language' => __('Add a translation language', 'extendify-local'),
134 + // translators: TranslatePress AI Agent ability — sets the license key.
135 + 'Set TranslatePress license key' => __('Set TranslatePress license key', 'extendify-local'),
136 + // translators: TranslatePress AI Agent ability — turns on automatic translation.
137 + 'Enable Automatic Translation' => __('Enable Automatic Translation', 'extendify-local'),
138 + // translators: TranslatePress AI Agent ability — lists the site's configured languages.
139 + 'List configured languages' => __('List configured languages', 'extendify-local'),
140 + // translators: TranslatePress AI Agent ability — lists selectable language codes.
141 + 'List available language codes' => __('List available language codes', 'extendify-local'),
142 + // translators: TranslatePress AI Agent ability — removes a translation language.
143 + 'Remove a translation language' => __('Remove a translation language', 'extendify-local'),
144 + // translators: TranslatePress AI Agent ability — updates a translation language.
145 + 'Update a translation language' => __('Update a translation language', 'extendify-local'),
146 + // translators: TranslatePress AI Agent ability — sets the site's default language.
147 + 'Set the default language' => __('Set the default language', 'extendify-local'),
148 + // translators: WPForms AI Agent ability — lists the site's forms.
149 + 'List Forms' => __('List Forms', 'extendify-local'),
150 + // translators: WPForms AI Agent ability — fetches a form's details.
151 + 'Get Form' => __('Get Form', 'extendify-local'),
152 + // translators: WPForms AI Agent ability — describes which form fields and settings can be edited.
153 + 'Describe Editing Schema' => __('Describe Editing Schema', 'extendify-local'),
154 + // translators: WPForms AI Agent ability — creates a form.
155 + 'Create Form' => __('Create Form', 'extendify-local'),
156 + // translators: WPForms AI Agent ability — updates a form's settings.
157 + 'Update Form Settings' => __('Update Form Settings', 'extendify-local'),
158 + // translators: WPForms AI Agent ability — adds a field to a form.
159 + 'Add Field' => __('Add Field', 'extendify-local'),
160 + // translators: WPForms AI Agent ability — updates a form field.
161 + 'Update Field' => __('Update Field', 'extendify-local'),
162 + // translators: WPForms AI Agent ability — gets a form's entry statistics.
163 + 'Get Form Stats' => __('Get Form Stats', 'extendify-local'),
164 + // translators: SimplyBook AI Agent ability — gets booking statistics.
165 + 'Get Statistics' => __('Get Statistics', 'extendify-local'),
166 + // translators: SimplyBook AI Agent ability — counts bookings from the last 30 days.
167 + 'Count Recent Bookings' => __('Count Recent Bookings', 'extendify-local'),
168 + // translators: SimplyBook AI Agent ability — updates the booking widget's design settings.
169 + 'Update Design Settings' => __('Update Design Settings', 'extendify-local'),
170 + // translators: SimplyBook AI Agent ability — lists the booking widget's design settings.
171 + 'List Design Settings' => __('List Design Settings', 'extendify-local'),
172 + // translators: SimplyBook AI Agent ability — lists the plugin's setup tasks.
173 + 'List Tasks' => __('List Tasks', 'extendify-local'),
174 + // translators: SimplyBook AI Agent ability — updates a setup task's status.
175 + 'Update Task Status' => __('Update Task Status', 'extendify-local'),
176 + // translators: SimplyBook AI Agent ability — lists service providers (staff).
177 + 'List Providers' => __('List Providers', 'extendify-local'),
178 + // translators: SimplyBook AI Agent ability — updates a service provider (staff member).
179 + 'Update Service Provider' => __('Update Service Provider', 'extendify-local'),
180 + // translators: SimplyBook AI Agent ability — updates a bookable service.
181 + 'Update Service' => __('Update Service', 'extendify-local'),
182 + // translators: SimplyBook AI Agent ability — lists the bookable services.
183 + 'List Services' => __('List Services', 'extendify-local'),
184 + // translators: Imagify AI Agent ability — optimizes an image in the media library.
185 + 'Optimize media' => __('Optimize media', 'extendify-local'),
186 + // translators: Imagify AI Agent ability — gets an image's optimization status.
187 + 'Get Media Status' => __('Get Media Status', 'extendify-local'),
188 + // translators: Imagify AI Agent ability — gets the site's image optimization statistics.
189 + 'Get Imagify optimization stats' => __('Get Imagify optimization stats', 'extendify-local'),
190 + // translators: Imagify AI Agent ability — reports how many images have next-gen formats (WebP/AVIF).
191 + 'Get next-gen coverage' => __('Get next-gen coverage', 'extendify-local'),
192 + // translators: Imagify AI Agent ability — gets the plugin's settings.
193 + 'Get Imagify settings' => __('Get Imagify settings', 'extendify-local'),
194 + // translators: Imagify AI Agent ability — updates the plugin's settings.
195 + 'Update Imagify settings' => __('Update Imagify settings', 'extendify-local'),
196 + // translators: Imagify AI Agent ability — gets the Imagify account status and quota.
197 + 'Get Imagify account status' => __('Get Imagify account status', 'extendify-local'),
198 + ];
97 199 }
98 200 }