| @@ -137,15 +137,13 @@ | ||
| 137 | 137 | $snippet['functionArgs'] = []; |
| 138 | 138 | $snippet['functionArgsDict'] = []; |
| 139 | 139 | $snippet['functionBehavior'] = ''; |
| 140 | 140 | $snippet['functionTarget'] = 'PHP'; |
| 141 | - $snippet['functionMcp'] = false; | |
| 142 | 141 | |
| 143 | 142 | foreach ( $functions_snippet as $function_snippet ) { |
| 144 | 143 | if ( $function_snippet['snippetId'] == $snippetId ) { |
| 145 | 144 | |
| 146 | 145 | $snippet['functionName'] = $function_snippet['name']; |
| 147 | - $snippet['functionMcp'] = !empty( $function_snippet['mcp'] ); | |
| 148 | 146 | if ( !isset( $function_snippet['behavior'] ) || empty( $function_snippet['behavior'] ) ) { |
| 149 | 147 | $snippet['functionBehavior'] = 'dynamic'; |
| 150 | 148 | } |
| 151 | 149 | else { |
| @@ -217,9 +215,8 @@ | ||
| 217 | 215 | 'name' => $params['functionName'], |
| 218 | 216 | 'behavior' => $params['functionBehavior'], |
| 219 | 217 | 'desc' => $params['description'] ?? '', |
| 220 | 218 | 'target' => $params['functionTarget'] ?? 'PHP', |
| 221 | - 'mcp' => !empty( $params['functionMcp'] ), | |
| 222 | 219 | 'args' => [], |
| 223 | 220 | ]; |
| 224 | 221 | |
| 225 | 222 | foreach ( $params['functionArgs'] as $argName ) { |
| @@ -356,27 +353,8 @@ | ||
| 356 | 353 | |
| 357 | 354 | return null; |
| 358 | 355 | } |
| 359 | 356 | |
| 360 | - /** | |
| 361 | - * Return the snippet IDs of every function that opted in to MCP exposure. | |
| 362 | - * Used by the "MCP" list filter and its count (functionMcp lives in the | |
| 363 | - * functions option, not a snippets table column, so it can't be queried in SQL). | |
| 364 | - * | |
| 365 | - * @return int[] | |
| 366 | - */ | |
| 367 | - public function get_mcp_function_ids() | |
| 368 | - { | |
| 369 | - $functions = get_option( $this->option_functions, [] ); | |
| 370 | - $ids = []; | |
| 371 | - foreach ( $functions as $fn ) { | |
| 372 | - if ( !empty( $fn['mcp'] ) && !empty( $fn['snippetId'] ) ) { | |
| 373 | - $ids[] = (int) $fn['snippetId']; | |
| 374 | - } | |
| 375 | - } | |
| 376 | - return $ids; | |
| 377 | - } | |
| 378 | - | |
| 379 | 357 | #endregion |
| 380 | 358 | |
| 381 | 359 | #region Utilities |
| 382 | 360 | |
| @@ -412,9 +390,8 @@ | ||
| 412 | 390 | $scopes = [ |
| 413 | 391 | "global" => "persistent", |
| 414 | 392 | "front-end" => "frontend", |
| 415 | 393 | "admin" => "backend", |
| 416 | - "content" => "content_php", | |
| 417 | 394 | ]; |
| 418 | 395 | |
| 419 | 396 | if ( array_key_exists( $params['scope'], $scopes ) ) { |
| 420 | 397 | $params['scope'] = $scopes[$params['scope']]; |
| @@ -608,15 +585,9 @@ | ||
| 608 | 585 | $stats[$scope] = $this->wpdb->get_var( $this->wpdb->prepare( "SELECT COUNT( * ) FROM $this->table_name WHERE scope = %s", $scope ) ); |
| 609 | 586 | } |
| 610 | 587 | $stats['all'] += $stats[$scope]; |
| 611 | 588 | } |
| 612 | - | |
| 613 | - // Combined count for the "Content" filter (PHP + JS). Not added to 'all', already counted above. | |
| 614 | - $stats['content'] = (int) $stats['content_php'] + (int) $stats['content_js']; | |
| 615 | - | |
| 616 | - // Functions exposed via MCP. A subset of 'function', so not added to 'all'. | |
| 617 | - $stats['mcp'] = count( $this->get_mcp_function_ids() ); | |
| 618 | - | |
| 589 | + | |
| 619 | 590 | return $stats; |
| 620 | 591 | } |
| 621 | 592 | |
| 622 | 593 | public function import( ) |
| @@ -652,21 +623,8 @@ | ||
| 652 | 623 | |
| 653 | 624 | return $code; |
| 654 | 625 | } |
| 655 | 626 | |
| 656 | - public function delete_duplicates() { | |
| 657 | - // Delete snippets that have the same code and scope, keeping only the most recent one ( based on the updated column ) | |
| 658 | - $query = "DELETE t1 FROM $this->table_name t1 | |
| 659 | - INNER JOIN $this->table_name t2 | |
| 660 | - WHERE t1.id < t2.id | |
| 661 | - AND t1.code = t2.code | |
| 662 | - AND t1.scope = t2.scope"; | |
| 663 | - | |
| 664 | - $this->wpdb->query( $query ); | |
| 665 | - | |
| 666 | - return $this->wpdb->rows_affected; | |
| 667 | - } | |
| 668 | - | |
| 669 | 627 | #endregion |
| 670 | 628 | |
| 671 | 629 | #region Snippet CRUD |
| 672 | 630 | |
| @@ -697,11 +655,8 @@ | ||
| 697 | 655 | } |
| 698 | 656 | else if ( $filter['accessor'] === 'scope' && $filter['value'] === 'global' ) { |
| 699 | 657 | $freshFilters[] = [ 'accessor' => 'scope', 'value' => ['backend', 'frontend', 'persistent'] ]; |
| 700 | 658 | } |
| 701 | - else if ( $filter['accessor'] === 'scope' && $filter['value'] === 'content' ) { | |
| 702 | - $freshFilters[] = [ 'accessor' => 'scope', 'value' => ['content_php', 'content_js'] ]; | |
| 703 | - } | |
| 704 | 659 | else { |
| 705 | 660 | $freshFilters[] = $filter; |
| 706 | 661 | } |
| 707 | 662 | } |
| @@ -733,17 +688,9 @@ | ||
| 733 | 688 | $where[] = $this->wpdb->prepare( "active = %d", $value ); |
| 734 | 689 | } elseif ( $filter['accessor'] === 'endpoint' ) { |
| 735 | 690 | $where[] = boolval( $filter['value'] ) ? "endpoint <> ''" : "endpoint = ''"; |
| 736 | 691 | } elseif ( $filter['accessor'] === 'scope' ) { |
| 737 | - if ( $filter['value'] === 'mcp' ) { | |
| 738 | - // Not a scope: constrain to the functions opted in to MCP exposure. | |
| 739 | - $ids = $this->get_mcp_function_ids(); | |
| 740 | - if ( empty( $ids ) ) { | |
| 741 | - $where[] = '1 = 0'; | |
| 742 | - } else { | |
| 743 | - $where[] = 'id IN (' . implode( ',', array_map( 'intval', $ids ) ) . ')'; | |
| 744 | - } | |
| 745 | - } else if ( is_array( $filter['value'] ) ) { | |
| 692 | + if ( is_array( $filter['value'] ) ) { | |
| 746 | 693 | $scopes = array_map( function( $scope ) { |
| 747 | 694 | return esc_sql( $scope ); |
| 748 | 695 | }, $filter['value'] ); |
| 749 | 696 | $where[] = "scope IN ('" . implode( "', '", $scopes ) . "')"; |