PluginProbe
Code Engine – PHP Snippets, AI Functions & Automation for WordPress / 0.4.8
Code Engine – PHP Snippets, AI Functions & Automation for WordPress v0.4.8
0.5.7 0.5.6 0.5.5 0.5.4 0.5.3 0.5.2 0.5.1 0.5.0 0.4.9 0.4.8 0.4.7 0.4.6 trunk 0.0.1 0.0.2 0.2.8 0.2.9 0.3.0 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 All 33 releases
← All changes | classes/api.php +5 -13 0.5.70.4.8 View file →
@@ -287,9 +287,9 @@
287 287 * Create a new snippet.
288 288 *
289 289 * @param string $name Name of the snippet.
290 290 * @param string $code Code of the snippet.
291 - * @param string $scope Scope of the snippet: 'function', 'backend', 'frontend', 'scheduled', 'persistent', 'content_php', 'content_js'.
291 + * @param string $scope Scope of the snippet: 'function', 'backend', 'frontend', 'scheduled', 'persistent'.
292 292 * @param array $options Additional options:
293 293 * - target: 'php' or 'js' (for function snippets)
294 294 * - description: Description of the snippet
295 295 * - args: Arguments for function snippets
@@ -294,9 +294,8 @@
294 294 * - description: Description of the snippet
295 295 * - args: Arguments for function snippets
296 296 * - argsData: Argument data for function snippets (use 'description' for each argument's description)
297 297 * - behavior: 'dynamic' or 'static' (for function snippets)
298 - * - mcp: Expose this function as its own MCP tool in AI Engine (for function snippets)
299 298 * - tags: Array of tags
300 299 * - priority: Execution priority
301 300 * - active: Active status (true/false)
302 301 * - endpoint: REST endpoint
@@ -317,13 +316,13 @@
317 316 if ( empty( $code ) ) {
318 317 throw new Exception( 'The snippet code is required.' );
319 318 }
320 319
321 - $validScopes = ['function', 'backend', 'frontend', 'scheduled', 'persistent', 'content_php', 'content_js'];
320 + $validScopes = ['function', 'backend', 'frontend', 'scheduled', 'persistent'];
322 321 if ( !in_array( $scope, $validScopes ) ) {
323 322 throw new Exception( sprintf( 'Invalid scope. Must be one of: %s', implode( ', ', $validScopes ) ) );
324 323 }
325 -
324 +
326 325 // Extract options with defaults
327 326 $target = $options['target'] ?? 'php';
328 327 $description = $options['description'] ?? '';
329 328 $args = $options['args'] ?? [];
@@ -328,9 +327,8 @@
328 327 $description = $options['description'] ?? '';
329 328 $args = $options['args'] ?? [];
330 329 $argsData = $options['argsData'] ?? [];
331 330 $behavior = $options['behavior'] ?? 'dynamic';
332 - $mcp = $options['mcp'] ?? false;
333 331 $tags = $options['tags'] ?? ['api'];
334 332 $priority = $options['priority'] ?? 10;
335 333 $active = $options['active'] ?? true;
336 334 $endpoint = $options['endpoint'] ?? '';
@@ -374,9 +372,8 @@
374 372 $params['functionTarget'] = $target;
375 373 $params['functionArgs'] = $args;
376 374 $params['functionArgsDict'] = $argsData;
377 375 $params['functionBehavior'] = $behavior;
378 - $params['functionMcp'] = $mcp;
379 376 }
380 377
381 378 // Add scheduled-specific params
382 379 if ( $scope === 'scheduled' ) {
@@ -418,9 +415,8 @@
418 415 * - target: 'php' or 'js' (for function snippets)
419 416 * - args: Arguments (for function snippets)
420 417 * - argsData: Argument data (for function snippets)
421 418 * - behavior: 'dynamic' or 'static' (for function snippets)
422 - * - mcp: Expose this function as its own MCP tool in AI Engine (for function snippets)
423 419 * - intervalHours: Hours (for scheduled snippets)
424 420 * - intervalMinutes: Minutes (for scheduled snippets)
425 421 *
426 422 * @return array The updated snippet data.
@@ -443,9 +439,9 @@
443 439 }
444 440
445 441 // Validate scope if provided
446 442 if ( isset( $params['scope'] ) ) {
447 - $validScopes = ['function', 'backend', 'frontend', 'scheduled', 'persistent', 'content_php', 'content_js'];
443 + $validScopes = ['function', 'backend', 'frontend', 'scheduled', 'persistent'];
448 444 if ( !in_array( $params['scope'], $validScopes ) ) {
449 445 throw new Exception( sprintf( 'Invalid scope. Must be one of: %s', implode( ', ', $validScopes ) ) );
450 446 }
451 447 }
@@ -481,12 +477,8 @@
481 477 $updateParams['functionTarget'] = $params['target'] ?? $snippet['functionTarget'] ?? 'php';
482 478 $updateParams['functionArgs'] = $params['args'] ?? $snippet['functionArgs'] ?? [];
483 479 $updateParams['functionArgsDict'] = $params['argsData'] ?? $snippet['functionArgsDict'] ?? [];
484 480 $updateParams['functionBehavior'] = $params['behavior'] ?? $snippet['functionBehavior'] ?? 'dynamic';
485 - // select_one() doesn't carry function metadata, so read the current MCP flag
486 - // from the stored function to preserve it when the caller doesn't set it.
487 - $existingFn = $this->snippet_module->get_function( $id );
488 - $updateParams['functionMcp'] = $params['mcp'] ?? ( $existingFn['mcp'] ?? false );
489 481 }
490 482
491 483 // Add scheduled-specific params if it's a scheduled snippet
492 484 if ( $scope === 'scheduled' ) {
@@ -775,9 +767,9 @@
775 767
776 768 /**
777 769 * Get snippets by scope.
778 770 *
779 - * @param string $scope The scope to filter by: 'backend', 'frontend', 'function', 'scheduled', 'persistent', 'content_php', 'content_js'.
771 + * @param string $scope The scope to filter by: 'backend', 'frontend', 'function', 'scheduled', 'persistent'.
780 772 * @param array $filters Additional filters: 'active' (bool), 'tags' (array).
781 773 * @return array The list of snippets matching the criteria.
782 774 * @throws Exception If the scope is invalid.
783 775 */