Make WordPress Core


Ignore:
Timestamp:
01/03/2015 03:53:30 AM (10 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/functions.wp-scripts.php

    r31028 r31030  
    107107 * @todo Documentation cleanup
    108108 *
    109  * @param string $handle      Script handle the data will be attached to.
    110  * @param string $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
    111  *                            Example: '/[a-zA-Z0-9_]+/'.
    112  * @param array $l10n         The data itself. The data can be either a single or multi-dimensional array.
     109 * @param string         $handle       Script handle the data will be attached to.
     110 * @param string         $object_name  Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
     111 *                                     Example: '/[a-zA-Z0-9_]+/'.
     112 * @param array|callable $l10n         The data itself. The data can be either a single or multi-dimensional array. If a callable
     113 *                                     is passed, it will be invoked at runtime.
    113114 * @return bool True if the script was successfully localized, false otherwise.
    114115 */
Note: See TracChangeset for help on using the changeset viewer.