[wp-trac] [WordPress Trac] #24197: wp_localize_script() doesn't work on admin_enqueue_scripts action
WordPress Trac
noreply at wordpress.org
Sat Apr 27 10:06:16 UTC 2013
#24197: wp_localize_script() doesn't work on admin_enqueue_scripts action
-------------------------------+------------------------------
Reporter: IcyPixels | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: major | Resolution:
Keywords: reporter-feedback |
-------------------------------+------------------------------
Comment (by t31os_):
There seems to be some specific issue with calling localize with the
jquery handle, switching the call to use jquery-ui-core also works, it's
definitely specific to trying to create vars for the jquery enqueue.
{{{
wp_localize_script( 'jquery', 'myvars', array( 'foo' => 'bar' ) );
}}}
No vars output in the page.
{{{
wp_localize_script( 'jquery-ui-core', 'myvars', array( 'foo' => 'bar' ) );
}}}
Vars are successfully output in the page(assuming you have jquery ui on
the given page of course).
{{{
wp_localize_script( 'my-enqueued-script', 'myvars', array( 'foo' => 'bar'
) );
}}}
Again vars are output to the page.
I also tried calling the localize method directly, and can see they appear
in the registered scripts data array.
{{{
$wp_scripts->localize( 'jquery', 'myvars', array( 'foo' => 'bar' ) );
echo $wp_scripts->registered['jquery']['extra']['data']; // Prints var
myvars = {"foo":"bar"};
}}}
However, again the vars are not output in the page, specifically when they
are created for the jquery handle. Not sure why any of this occurs, just
wanted to confirm i can replicate the issue being described in trunk.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24197#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list