|
13 | 13 |
|
14 | 14 | // Enqueue scripts and styles conditionally |
15 | 15 | function yunus_admin_view_enqueue_scripts($hook_suffix) { |
16 | | - // Load only on the custom admin page |
17 | 16 | if ($hook_suffix === 'toplevel_page_yunus-admin-view-app') { |
18 | 17 | wp_enqueue_script( |
19 | 18 | 'yunus_vue_app', |
20 | 19 | plugins_url('/dist/main.js', __FILE__), |
21 | | - [], // Add script dependencies here if any, like 'jquery' |
22 | | - filemtime(plugin_dir_path(__FILE__) . '/dist/main.js'), // Cache-busting |
23 | | - true // Load in footer |
| 20 | + [], |
| 21 | + filemtime(plugin_dir_path(__FILE__) . 'dist/main.js'), |
| 22 | + true |
24 | 23 | ); |
25 | | - |
| 24 | + |
26 | 25 | wp_localize_script('yunus_vue_app', 'yunusPluginData', [ |
27 | 26 | 'root_url' => esc_url_raw(rest_url()), |
28 | 27 | 'nonce' => wp_create_nonce('wp_rest') |
29 | 28 | ]); |
30 | | - |
31 | | - wp_enqueue_style( |
32 | | - 'yunus_vue_styles', |
33 | | - plugins_url('/dist/style.css', __FILE__), |
34 | | - [], |
35 | | - filemtime(plugin_dir_path(__FILE__) . '/dist/style.css') // Cache-busting |
36 | | - ); |
| 29 | + |
| 30 | + // Check for style.css before enqueueing |
| 31 | + $style_path = plugin_dir_path(__FILE__) . 'dist/style.css'; |
| 32 | + if (file_exists($style_path)) { |
| 33 | + wp_enqueue_style( |
| 34 | + 'yunus_vue_styles', |
| 35 | + plugins_url('/dist/style.css', __FILE__), |
| 36 | + [], |
| 37 | + filemtime($style_path) |
| 38 | + ); |
| 39 | + } else { |
| 40 | + error_log('Style.css file not found at ' . $style_path); |
| 41 | + } |
37 | 42 | } |
38 | 43 | } |
39 | 44 | add_action('admin_enqueue_scripts', 'yunus_admin_view_enqueue_scripts'); |
|
0 commit comments