← All changes
|
includes/abilities/code-snippets/wdesignkit-save-snippet.php
+9
-2
2.6.2
→
2.7.0
View file →
| @@ -69,8 +69,9 @@ | ||
| 69 | 69 | ], |
| 70 | 70 | 'execute_callback' => 'wdesignkit_mcp_save_snippet', |
| 71 | 71 | 'permission_callback' => 'wdesignkit_mcp_permission_callback', |
| 72 | 72 | 'meta' => [ |
| 73 | + 'public' => true, | |
| 73 | 74 | 'show_in_rest' => true, |
| 74 | 75 | 'mcp' => ['public' => true], |
| 75 | 76 | 'annotations' => [ |
| 76 | 77 | 'instructions' => implode("\n", [ |
| @@ -128,8 +129,9 @@ | ||
| 128 | 129 | ], |
| 129 | 130 | 'execute_callback' => 'wdesignkit_mcp_update_snippet_details', |
| 130 | 131 | 'permission_callback' => 'wdesignkit_mcp_permission_callback', |
| 131 | 132 | 'meta' => [ |
| 133 | + 'public' => true, | |
| 132 | 134 | 'show_in_rest' => true, |
| 133 | 135 | 'mcp' => ['public' => true], |
| 134 | 136 | 'annotations' => [ |
| 135 | 137 | 'instructions' => implode("\n", [ |
| @@ -186,9 +188,14 @@ | ||
| 186 | 188 | } |
| 187 | 189 | } |
| 188 | 190 | |
| 189 | 191 | if (!empty($file_code_list) && is_array($file_code_list)) { |
| 190 | - $type = $file_code_list['type'] ?? ''; | |
| 192 | + $type = strtolower((string) ($file_code_list['type'] ?? '')); | |
| 193 | + $lang_code = (string) ($file_code_list['langCode'] ?? ''); | |
| 194 | + if ($type === 'php' && $lang_code !== '' && !preg_match('/^\s*<\?php/i', $lang_code)) { | |
| 195 | + $lang_code = "<?php\n" . $lang_code; | |
| 196 | + } | |
| 197 | + | |
| 191 | 198 | $get_data = [ |
| 192 | 199 | 'id' => $post_id, |
| 193 | 200 | 'name' => $file_code_list['name'] ?? '', |
| 194 | 201 | 'description' => ($description !== '') ? $description : ($file_code_list['description'] ?? ''), |
| @@ -196,9 +203,9 @@ | ||
| 196 | 203 | 'post_type' => $file_code_list['post_type'] ?? '', |
| 197 | 204 | 'tags' => $file_code_list['tags'] ?? '', |
| 198 | 205 | 'codeExecute' => $file_code_list['codeExecute'] ?? '', |
| 199 | 206 | 'status' => $file_code_list['status'] ?? '', |
| 200 | - 'langCode' => $file_code_list['langCode'] ?? '', | |
| 207 | + 'langCode' => $lang_code, | |
| 201 | 208 | 'htmlHooks' => $file_code_list['htmlHooks'] ?? '', |
| 202 | 209 | 'hooksPriority' => $file_code_list['hooksPriority'] ?? '', |
| 203 | 210 | 'include_data' => $file_code_list['include_data'] ?? '', |
| 204 | 211 | 'exclude_data' => $file_code_list['exclude_data'] ?? '', |