Issues (57)

src/Providers/Assets/Admin.php (5 issues)

1
<?php declare(strict_types = 1);
0 ignored issues
show
Expected 1 line before declare statement, found 0.
Loading history...
2
3
namespace App\Providers\Assets;
4
5
use WPSteak\Providers\AbstractHookProvider;
6
use WPSteak\Services\Assets;
7
8
class Admin extends AbstractHookProvider {
9
10
	use Assets;
11
12
	/**
13
	 * {@inheritDoc}
14
	 */
15
	public function register_hooks(): void {
16
		$this->add_action( 'admin_enqueue_scripts', 'enqueue' );
17
	}
18
19
	protected function enqueue(): void {
0 ignored issues
show
Your function is too long. Currently using 29 lines. Can be up to 20 lines.
Loading history...
20
		$handle = "{$this->plugin->get_slug()}-admin";
21
22
		$this->enqueue_script(
23
			$handle,
24
			$this->plugin->get_url( 'dist/admin.js' ),
25
			$this->plugin->get_path( 'dist/admin.js' ),
26
			['jquery', 'wp-i18n'],
27
			true,
0 ignored issues
show
Trailing comma after the last parameter in function call is disallowed.
Loading history...
28
		);
29
30
		$this->enqueue_style(
31
			$handle,
32
			$this->plugin->get_url( 'dist/styles/admin.css' ),
33
			$this->plugin->get_path( 'dist/styles/admin.css' ),
0 ignored issues
show
Trailing comma after the last parameter in function call is disallowed.
Loading history...
34
		);
35
36
		if ( ! function_exists( 'wp_set_script_translations' ) ) {
37
			return;
38
		}
39
40
		/**
41
		 * The `.json` file must be on following format: domain-locale-handler.json
42
		 * You can generate this file with `po2json`
43
		 */
44
		wp_set_script_translations(
45
			$handle,
46
			$this->plugin->get_slug(),
47
			$this->plugin->get_path( 'languages' ),
0 ignored issues
show
Trailing comma after the last parameter in function call is disallowed.
Loading history...
48
		);
49
	}
50
51
}
52