1 | <?php |
||
15 | class Assets { |
||
16 | /** |
||
17 | * Holds all the scripts handles that should be loaded in a deferred fashion. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | private $defer_script_handles = array(); |
||
22 | /** |
||
23 | * The singleton instance of this class. |
||
24 | * |
||
25 | * @var Assets |
||
26 | */ |
||
27 | protected static $instance; |
||
28 | |||
29 | /** |
||
30 | * Constructor. |
||
31 | * |
||
32 | * Static-only class, so nothing here. |
||
33 | */ |
||
34 | private function __construct() {} |
||
35 | |||
36 | /** |
||
37 | * Get the singleton instance of the class. |
||
38 | * |
||
39 | * @return Assets |
||
40 | */ |
||
41 | public static function instance() { |
||
49 | |||
50 | /** |
||
51 | * Initalize the hooks as needed. |
||
52 | */ |
||
53 | private function init_hooks() { |
||
59 | |||
60 | /** |
||
61 | * A public method for adding the async script. |
||
62 | * |
||
63 | * @param string $script_handle Script handle. |
||
64 | */ |
||
65 | public function add_async_script( $script_handle ) { |
||
68 | |||
69 | /** |
||
70 | * Add an async attribute to scripts that can be loaded deferred. |
||
71 | * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script |
||
72 | * |
||
73 | * @param string $tag The <script> tag for the enqueued script. |
||
74 | * @param string $handle The script's registered handle. |
||
75 | */ |
||
76 | public function script_add_async( $tag, $handle ) { |
||
87 | |||
88 | /** |
||
89 | * Given a minified path, and a non-minified path, will return |
||
90 | * a minified or non-minified file URL based on whether SCRIPT_DEBUG is set and truthy. |
||
91 | * |
||
92 | * If $package_path is provided, then the minified or non-minified file URL will be generated |
||
93 | * relative to the root package directory. |
||
94 | * |
||
95 | * Both `$min_base` and `$non_min_base` can be either full URLs, or are expected to be relative to the |
||
96 | * root Jetpack directory. |
||
97 | * |
||
98 | * @param string $min_path minified path. |
||
99 | * @param string $non_min_path non-minified path. |
||
100 | * @param string $package_path Optional. A full path to a file inside a package directory |
||
101 | * The URL will be relative to its directory. Default empty. |
||
102 | * Typically this is done by passing __FILE__ as the argument. |
||
103 | * |
||
104 | * @return string The URL to the file |
||
105 | * @since 5.6.0 |
||
106 | */ |
||
107 | public static function get_file_url_for_environment( $min_path, $non_min_path, $package_path = '' ) { |
||
138 | |||
139 | /** |
||
140 | * A helper function that lets you enqueue scripts in an async fashion. |
||
141 | * |
||
142 | * @param string $handle Name of the script. Should be unique. |
||
143 | * @param string $min_path Minimized script path. |
||
144 | * @param string $non_min_path Full Script path. |
||
145 | * @param array $deps Array of script dependencies. |
||
146 | * @param bool $ver The script version. |
||
147 | * @param bool $in_footer Should the script be included in the footer. |
||
148 | */ |
||
149 | public static function enqueue_async_script( $handle, $min_path, $non_min_path, $deps = array(), $ver = false, $in_footer = true ) { |
||
154 | |||
155 | /** |
||
156 | * Passes an array of URLs to wp_resource_hints. |
||
157 | * |
||
158 | * @since 8.8.0 |
||
159 | * |
||
160 | * @param string|array $urls URLs to hint. |
||
161 | * @param string $type One of the supported resource types: dns-prefetch (default), preconnect, prefetch, or prerender. |
||
162 | */ |
||
163 | public static function add_resource_hint( $urls, $type = 'dns-prefetch' ) { |
||
179 | |||
180 | /** |
||
181 | * Serve a WordPress.com static resource via a randomized wp.com subdomain. |
||
182 | * |
||
183 | * @since 9.3.0 |
||
184 | * |
||
185 | * @param string $url WordPress.com static resource URL. |
||
186 | * |
||
187 | * @return string $url |
||
188 | */ |
||
189 | public static function staticize_subdomain( $url ) { |
||
225 | } |
||
226 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.