1 | <?php |
||
2 | /** |
||
3 | * Assets. |
||
4 | * |
||
5 | * @package App |
||
6 | */ |
||
7 | |||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace App\Providers; |
||
11 | |||
12 | use WPSteak\Providers\AbstractHookProvider; |
||
0 ignored issues
–
show
|
|||
13 | use WPSteak\Services; |
||
0 ignored issues
–
show
The type
WPSteak\Services was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
14 | |||
15 | /** |
||
16 | * Assets class. |
||
17 | */ |
||
18 | class Assets extends AbstractHookProvider { |
||
19 | |||
20 | use Services\Assets; |
||
0 ignored issues
–
show
The type
WPSteak\Services\Assets was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
21 | |||
22 | /** |
||
23 | * Register hooks. |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | public function register_hooks() { |
||
28 | $this->add_action( 'wp_enqueue_scripts', 'register_theme_assets' ); |
||
29 | $this->add_action( 'admin_enqueue_scripts', 'register_admin_assets' ); |
||
30 | $this->add_action( 'login_enqueue_scripts', 'register_login_assets' ); |
||
31 | $this->add_action( 'enqueue_block_editor_assets', 'register_editor_assets' ); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Register theme assets |
||
36 | * |
||
37 | * @return void |
||
38 | */ |
||
39 | protected function register_theme_assets() { |
||
40 | $this->enqueue_script( |
||
41 | 'app-theme-js', |
||
42 | $this->plugin->get_url( 'dist/theme.js' ), |
||
43 | $this->plugin->get_path( 'dist/theme.js' ), |
||
44 | [ 'jquery', 'wp-i18n' ], |
||
45 | true |
||
46 | ); |
||
47 | |||
48 | $this->enqueue_style( |
||
49 | 'app-theme-css', |
||
50 | $this->plugin->get_url( 'dist/styles/theme.css' ), |
||
51 | $this->plugin->get_path( 'dist/styles/theme.css' ) |
||
52 | ); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Register admin assets. |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | protected function register_admin_assets() { |
||
61 | $this->enqueue_script( |
||
62 | 'app-admin-js', |
||
63 | $this->plugin->get_url( 'dist/admin.js' ), |
||
64 | $this->plugin->get_path( 'dist/admin.js' ), |
||
65 | [ 'jquery', 'wp-i18n' ], |
||
66 | true |
||
67 | ); |
||
68 | |||
69 | $this->enqueue_style( |
||
70 | 'app-admin-css', |
||
71 | $this->plugin->get_url( 'dist/styles/admin.css' ), |
||
72 | $this->plugin->get_path( 'dist/styles/admin.css' ) |
||
73 | ); |
||
74 | |||
75 | $this->script_translation(); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Register login assets. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | protected function register_login_assets() { |
||
84 | $this->enqueue_script( |
||
85 | 'app-login-js', |
||
86 | $this->plugin->get_url( 'dist/login.js' ), |
||
87 | $this->plugin->get_path( 'dist/login.js' ), |
||
88 | [ 'jquery' ], |
||
89 | true |
||
90 | ); |
||
91 | |||
92 | $this->enqueue_style( |
||
93 | 'app-login-css', |
||
94 | $this->plugin->get_url( 'dist/styles/login.css' ), |
||
95 | $this->plugin->get_path( 'dist/styles/login.css' ) |
||
96 | ); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Register editor assets. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | protected function register_editor_assets() { |
||
105 | $this->enqueue_script( |
||
106 | 'app-editor-js', |
||
107 | $this->plugin->get_url( 'dist/editor.js' ), |
||
108 | $this->plugin->get_path( 'dist/editor.js' ), |
||
109 | [ 'wp-blocks', 'wp-element', 'wp-i18n' ], |
||
110 | true |
||
111 | ); |
||
112 | |||
113 | $this->enqueue_style( |
||
114 | 'app-editor-css', |
||
115 | $this->plugin->get_url( 'dist/styles/editor.css' ), |
||
116 | $this->plugin->get_path( 'dist/styles/editor.css' ) |
||
117 | ); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Script translation. |
||
122 | * |
||
123 | * @return void |
||
124 | */ |
||
125 | protected function script_translation() { |
||
126 | if ( ! function_exists( 'wp_set_script_translations' ) ) { |
||
127 | return; |
||
128 | } |
||
129 | |||
130 | wp_set_script_translations( 'app-admin-js-bundle', $this->plugin->get_slug(), $this->plugin->get_path( 'languages' ) ); |
||
131 | } |
||
132 | } |
||
133 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths