| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | namespace Yatra\Blocks; |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | - * Resolves the Gutenberg editor script URL for yatra/tour, yatra/activity, yatra/destination. | |
| 8 | + * Resolves the Gutenberg editor script URL for yatra/tour, yatra/activity, yatra/destination, yatra/trip-category. | |
| 9 | 9 | * |
| 10 | 10 | * Prefer Vite output under assets/dist/blocks/ (present after npm run build). Fall back to |
| 11 | 11 | * legacy IIFE scripts under resources/js/blocks/{slug}/block.js (dev or when dist is missing). |
| 12 | 12 | */ |
| @@ -75,8 +75,9 @@ | ||
| 75 | 75 | 'wp-element', |
| 76 | 76 | 'wp-block-editor', |
| 77 | 77 | 'wp-components', |
| 78 | 78 | 'wp-i18n', |
| 79 | + 'wp-api-fetch', | |
| 79 | 80 | 'wp-data', |
| 80 | 81 | 'wp-hooks', |
| 81 | 82 | 'wp-server-side-render', |
| 82 | 83 | ]; |
| @@ -83,9 +84,12 @@ | ||
| 83 | 84 | } |
| 84 | 85 | |
| 85 | 86 | public static function blockJsonPath(string $slug): string |
| 86 | 87 | { |
| 87 | - $slug = preg_replace('/[^a-z]/', '', strtolower($slug)); | |
| 88 | + // Keep hyphens for on-disk paths (e.g. trip-category/block.json). Editor bundles still use | |
| 89 | + // letters-only slugs in resolveEditorBundle() (e.g. tripcategory.js). | |
| 90 | + $slug = strtolower((string) $slug); | |
| 91 | + $slug = preg_replace('/[^a-z0-9_-]/', '', $slug); | |
| 88 | 92 | |
| 89 | 93 | return YATRA_PLUGIN_PATH . 'resources/js/blocks/' . $slug . '/block.json'; |
| 90 | 94 | } |
| 91 | 95 | |
| @@ -128,18 +132,9 @@ | ||
| 128 | 132 | } |
| 129 | 133 | } |
| 130 | 134 | } |
| 131 | 135 | if ($bundle === null) { |
| 132 | - if (defined('WP_DEBUG') && WP_DEBUG) { | |
| 133 | - // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | |
| 134 | - error_log( | |
| 135 | - sprintf( | |
| 136 | - '[Yatra] Block editor script not found for slug "%s" (handle "%s"). Run npm run build in the plugin directory.', | |
| 137 | - $slug, | |
| 138 | - $handle | |
| 139 | - ) | |
| 140 | - ); | |
| 141 | - } | |
| 136 | + | |
| 142 | 137 | |
| 143 | 138 | return false; |
| 144 | 139 | } |
| 145 | 140 | |