Tag Info

Hot answers tagged

3

I was curious about this and checked the Codex on keyboard shortcuts, but didn't find it mentioned there. I searched and found out that this seems to be already solved, e.g. here and here. I haven't tested out these other plugins so I'm not sure how they solve it, but I decided to take on the challenge and see how this could be solved ;-) So here's my ...


2

I'm not really sure why you'd want to do this...but the only thing I can think of that might work is something like this: function prefix_block_resources(){ if(is_admin())return; //I can't imagine any scenario where blocking scripts in the admin area would be wise. global $wp_scripts; global $wp_styles; ...


2

The script_loader_tag filter, added in version 4.1, addresses this issue. To add an async attribute to an enqueued script you can do: /** * Add an aysnc attribute to an enqueued script * * @param string $tag Tag for the enqueued script. * @param string $handle The script's registered handle. * @return string Script tag for the enqueued script */ ...


1

You are calling jQuery wrong by the shorthand $. If you will look in your console you will see an error that $ is not a function / undeclared etc (this is due to jQuery's conflict mode if I am not wrong). Your code should look something like this: <script type="text/javascript"> jQuery(function($) { $( "a.toggle").click(function() { ...


1

The "Failed to load resource" is probably a red herring and isn't related to your issue. The fact that it is throwing an error about the $ shortcut means your js file is being loaded correctly. The likely issue is that jQuery in WordPress loads in "noConflict" mode. As such the $ shortcut will not work by default. Try replacing your script with this: ...


1

Building on the accepted answer and filling in some details... You need to call wp_localize script right after wp_enqueue_script. So, something like this: function my_enqueue_scripts() { wp_enqueue_script( 'myjs', plugins_url( 'js/my.js', __FILE__) ); $options = get_option( 'my_settings' ); $scriptData = array( ...


1

I actually ran into a similar issue yesterday. A theme I was working with was adding 500+ lines of internal styles to the header which absolutely drives me nuts! I ended up finding a clever solution online to work around this which you could use for CSS. The JavaScript side I'll explain toward the bottom. --- :: CSS :: --- There's a few key points in how ...


1

So, you're using wp_localize_script to inject the ajax url. But you didn't use the localized var handle to access that value. Try this: /* ... */ $.ajax({ url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object /* ... */


1

obviously the answer is no. wordpress do not load JS and CSS on the admin side if it is not needed. In addition your method will probably trigger all kinds of plugins which assume that wp_head and wp_footer are triggered only at the frontend which might create "interesting" side effects. If you want to customize the admin you will have to actually write ...



Only top voted, non community-wiki answers of a minimum length are eligible