Make WordPress Core


Ignore:
Timestamp:
01/03/2015 03:53:30 AM (9 years ago)
Author:
wonderboymusic
Message:

Allow the 3rd argument to wp_localize_script()/WP_Scripts->localize() to be a callable, allowing data to be lazy-loaded when the script is actually enqueued.

Props jtsternberg.
Fixes #26111.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class.wp-scripts.php

    r30753 r31030  
    143143        $tag = "<script type='text/javascript' src='$src'></script>\n";
    144144
    145         /** 
     145        /**
    146146         * Filter the HTML script tag of an enqueued script.
    147147         *
     
    172172            $handle = 'jquery-core';
    173173
     174        if ( is_callable( $l10n ) ) {
     175            $l10n = call_user_func( $l10n );
     176        }
     177
    174178        if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
    175179            $after = $l10n['l10n_print_after'];
Note: See TracChangeset for help on using the changeset viewer.