1 | <?php # -*- coding: utf-8 -*- |
||
2 | declare(strict_types=1); |
||
3 | |||
4 | namespace MultisiteGlobalMedia; |
||
5 | |||
6 | /** |
||
7 | * Class Assets |
||
8 | */ |
||
9 | class Assets |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var PluginProperties |
||
14 | */ |
||
15 | private $pluginProperties; |
||
16 | |||
17 | /** |
||
18 | * Assets constructor |
||
19 | * |
||
20 | * @param PluginProperties $pluginProperties |
||
21 | */ |
||
22 | public function __construct(PluginProperties $pluginProperties) |
||
23 | { |
||
24 | $this->pluginProperties = $pluginProperties; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Enqueue script for media modal |
||
29 | * |
||
30 | * @since 2015-01-26 |
||
31 | */ |
||
32 | public function enqueueScripts() |
||
33 | { |
||
34 | if ('post' !== get_current_screen()->base) { |
||
0 ignored issues
–
show
|
|||
35 | return; |
||
36 | } |
||
37 | |||
38 | $scriptFile = '/assets/js/global-media.js'; |
||
39 | wp_register_script( |
||
40 | 'global_media', |
||
41 | $this->pluginProperties->dirUrl() . $scriptFile, |
||
42 | ['media-views'], |
||
43 | filemtime($this->pluginProperties->dirPath() . $scriptFile), |
||
44 | true |
||
45 | ); |
||
46 | wp_enqueue_script('global_media'); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Enqueue script for media modal |
||
51 | * |
||
52 | * @since 2015-02-27 |
||
53 | */ |
||
54 | public function enqueueStyles() |
||
55 | { |
||
56 | if ('post' !== get_current_screen()->base) { |
||
0 ignored issues
–
show
Are you sure the usage of
get_current_screen() is correct as it seems to always return null .
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
57 | return; |
||
58 | } |
||
59 | |||
60 | $styleFile = '/assets/css/global-media.css'; |
||
61 | wp_register_style( |
||
62 | 'global_media', |
||
63 | $this->pluginProperties->dirUrl() . $styleFile, |
||
64 | [], |
||
65 | filemtime($this->pluginProperties->dirPath() . $styleFile) |
||
66 | ); |
||
67 | wp_enqueue_style('global_media'); |
||
68 | } |
||
69 | } |
||
70 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.