Tag Info

New answers tagged

1

This is being caused by core bug #33106 which was unfortunately introduced with the security fixes in 4.1.6 (and 4.2.3). New lines are erroneously being stripped from CDATA blocks in this situation. From the bug ticket: As of 4.2.3, depending on how a CDATA block is used, the stripping of new lines in this content may break when displayed on the front ...


0

You can't hook it directly as wp.Uploader doesn't expose it but you can use its init() to hook its internal pluploader instance: add_action( 'admin_print_footer_scripts', function () { ?> <script type="text/javascript"> (function ($) { if (typeof wp.Uploader === 'function') { $.extend( wp.Uploader.prototype, { ...


2

So, far the problem was with the initial loading of the JS file. As i couldn't find any solution using the JS. The problem was not about the script loading rather then the execution timing. Anyways, The theme customizer looks into the global variable for which Panel/Section/Control it will show as active when it loads. How to Make ...


0

Although not a pretty solution, maybe you can sample it using window.setInterval() and once visible stop the interval and do whatever you want to do.


0

Rather than trying to divine the mysteries of the customizer javascript initialization, which as you say is far from clear, you could use a custom control to inject your javascript, by overriding the render_content(), eg add_action( 'customize_register', function ( $wp_customize ) { // Custom control. class PPL_Ninja_Skin_Select_Customize_Control ...


0

Sounds like a dependency problem. You're only checking for jQuery, so your script could be getting preempted. You can ensure your script loads after all the other customizer scripts with 'customize-preview-widgets'. Try this… add_action('customize_preview_init', 'ppl_customize_controls_scripts'); function ppl_customize_controls_scripts(){ ...


6

First of all this is what I use and for me and it works. I'm not saying that my code is 100% correct but Pingdom as well GTmetrix show a positive effect and WP is satisfied also, so it can't be that wrong as I do. The versions showing (?ver=x.x.x) can be debet when those files need to be cached so stripping(filter) that is already a first step. The code ...


0

Seems like a timing problem to me, maybe/probably I'm oversimplifying this, but what about making use of the $debs parameter wp_register_script and wp_enqueue_script are offering to control load order, where one of those - in the order they are added at script-loader.php - customize-base, customize-loader, customize-preview, customize-models, ...


0

To load the css/js on just one page, please see my earlier answer, and use a WordPress Conditional Tag, just as I showed you in the code example, except replace "Home" in the example with the conditional tag for the page you want this code on. You can find the conditional tag for any specific page by looking it up as indicated in the CODEX link in my ...


0

You want to add CSS OR SCRIPT in wordpress theme .. so. wordpress provide a functions.php in copy and past YOUR CSS LINK OR JS SCRIPT LINK. /** * Enqueue scripts and styles. */ function function_name() { // ADD STYLE wp_enqueue_style( 'CSS-ID', get_template_directory_uri() .'/css/style.css','', '3.3.1' ); // ADD SCRIPT ...


0

Toodarday, For the code you want to put in your <head> section, you should do this in the header.php file. To do this, go to your WordPress dashboard, hover your cursor over APPEARANCE in the left-side menu bar, and click on EDITOR. When the editor screen appears, in the right column, you should see the listing "Header" with (header.php) below it. ...


0

Here is my own solution. In my html I've assign id to all the item and inside the form I've added an input option where I pass the value through the script and it was saved later. Simple... script jQuery(document).ready(function($){ $(".sortable").sortable({ connectWith: '.sortable', receive: function (event, ui) { ...


0

You need type: 'POST' in your jQuery.ajax call. The default is GET, and this requires POST. Because someone below requested an example: jQuery.ajax({ url: dgxDonateAjax.ajaxurl, data: data, type: 'POST', success: function() { console.log("-- SeamlessDonationsCheckout: jQuery.ajax success"); //response(data); } });


1

You should run updatepage() function after loading the google jsapi script. try jquery ready inside updatepage like this: function updatepage(){ // this line added by me jQuery(document).ready(function ($) { // Load the Visualization API and the piechart package. .... .... chart.draw(data, options); } } ...


1

Well after a bit of better searching i found the answer, function my_enqueue($hook) { if ( 'settings_page_data-layer-management' != $hook ) { return; } wp_enqueue_script( 'my_custom_script', plugins_url( 'js/dlm-window.js', __FILE__ )); } add_action( 'admin_enqueue_scripts', 'my_enqueue' ); to explain just incase anyone has this ...


0

This was very frustrating to figure out. I spent hours on this issue and discovered your problem is in this input: <input type="text" name="name" id="name" size="30" value=""/> Try changing the input field name to anything but "name", for example: <input type="text" name="user_name" id="name" size="30" value=""/>


0

Short Answer: Yes, but... Just make sure your call to wp enqueue script is before the call to get_header(). The problem is that when you're in a later part of your template the header including the script is already sent to the browser so you can't change it any more. While this is possible I'd still encourage you to reconsider and put this in the ...


-3

You can check whether this plugin helps you to achieve your purpose or You can write your own code in your custom plugin with the following approach: Check if the user is logged in. Check if the current user has the any roles from the specified list of roles which you want the notice to be shown. If the above conditions are true just add a Notice to the ...


0

addMenuItem() adds to tinymce's toolbar, which isn't used by WP by default, and uses context to add to the particular (sub)menu. You're adding a MenuButton, and you can access the button through the editor's buttons array, keyed by the button name: add_action( 'admin_print_footer_scripts', function () { ?> <script type="text/javascript"> ...


0

One option would be to create a shortcode exclusively for that script. Even thought it's not an elegant solution, it works. In your functions file (functions.php) of your theme add: function custom_script_shortcode(){ $code = '<script>'; $code .= 'var foo = "bar";' $code .= '</script>'; return $code; } ...


0

If you go in and edit the post, and click the "Text" tab, and enter your code in <script> tags: <script type="text/javascript"> console.log("gosh"); </script> and update the post, the content should save as <script type="text/javascript">// <![CDATA[ console.log("gosh"); // ]]></script> which should execute when the ...


0

If it is for all the posts, an external script is always a better idea, linked with wp_enqueue_script() (see this article for more information). If you only want to add a code to a single post, simply write it in the editor (into a script tag, in the "Text" tab).


0

You can add your script on header or footer normally with . Or you can hooked your script on function.php like this way: function theme_name_scripts() { wp_enqueue_style( 'style-name', get_stylesheet_uri() ); wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', ...


0

wp_ajax_{my-action} action hook is only for admin side. For frontend you must use wp_ajax_nopriv_{my-action}. You can combina both if the ajax action is for both sides. For example: add_action('wp_ajax_filter_search', 'filter_search_result'); add_action('wp_ajax_nopriv_filter_search', 'filter_search_result'); Also, don't forget, never, to die or exit at ...


-1

put this code at the end of functions.php add_action('customize_register', 'customizer'); function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return "$url' defer "; } add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );


0

So, after hours of searching, I finally found where was my problem : another method in my class interfered with my ajax authentication system.



Top 50 recent answers are included