~canonical-sysadmins/wordpress/4.7

« back to all changes in this revision

Viewing changes to wp-includes/functions.wp-scripts.php

  • Committer: Haw Loeung
  • Date: 2016-12-13 06:56:21 UTC
  • mfrom: (1.1.20 upstream)
  • Revision ID: haw.loeung@canonical.com-20161213065621-8tcu7u7vlxgs2s81
Merge WP4.7 from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 * @param string $function Function name.
35
35
 */
36
36
function _wp_scripts_maybe_doing_it_wrong( $function ) {
37
 
        if ( did_action( 'init' ) ) {
 
37
        if ( did_action( 'init' ) || did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' ) || did_action( 'login_enqueue_scripts' ) ) {
38
38
                return;
39
39
        }
40
40
 
41
41
        _doing_it_wrong( $function, sprintf(
 
42
                /* translators: 1: wp_enqueue_scripts, 2: admin_enqueue_scripts, 3: login_enqueue_scripts */
42
43
                __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
43
44
                '<code>wp_enqueue_scripts</code>',
44
45
                '<code>admin_enqueue_scripts</code>',
224
225
                );
225
226
 
226
227
                if ( in_array( $handle, $no ) ) {
227
 
                        $message = sprintf( __( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),
228
 
                                "<code>$handle</code>", '<code>wp_enqueue_scripts</code>' );
 
228
                        $message = sprintf(
 
229
                                /* translators: 1: script name, 2: wp_enqueue_scripts */
 
230
                                __( 'Do not deregister the %1$s script in the administration area. To target the front-end theme, use the %2$s hook.' ),
 
231
                                "<code>$handle</code>",
 
232
                                '<code>wp_enqueue_scripts</code>'
 
233
                        );
229
234
                        _doing_it_wrong( __FUNCTION__, $message, '3.6.0' );
230
235
                        return;
231
236
                }
247
252
 *
248
253
 * @param string           $handle    Name of the script. Should be unique.
249
254
 * @param string           $src       Full URL of the script, or path of the script relative to the WordPress root directory.
 
255
 *                                    Default empty.
250
256
 * @param array            $deps      Optional. An array of registered script handles this script depends on. Default empty array.
251
257
 * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
252
258
 *                                    as a query string for cache busting purposes. If version is set to false, a version
255
261
 * @param bool             $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
256
262
 *                                    Default 'false'.
257
263
 */
258
 
function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
 
264
function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false ) {
259
265
        $wp_scripts = wp_scripts();
260
266
 
261
267
        _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );