Hot answers tagged

4

I had this problem with a multisite setup. On my secondary site load-scripts.php returned a 404 error. the following line in wp-config.php fixed it for me: define( 'CONCATENATE_SCRIPTS', false ); # worked for me my .htaccess file: # BEGIN manual WordPress Multisite # The directives (lines) between `BEGIN WordPress` and `END WordPress` are # dynamically ...


2

There's only one reason you get a 400 error with admin-ajax.php: The wp_ajax_{$action} or wp_ajax_nopriv_{$action} action has not been hooked with an {$action} that matches the action data parameter sent with your request. So either your callback is not hooked, or you're not sending the action correctly. Your code is making both errors. You are encoding the ...


2

Here is your problem: blogcontent.php When WP is contacted to handle the Admin AJAX request, it doesn't load a page template. Remember, every request to WP loads WP from a blank slate. It doesn't know anything about the previous requests, only what it's told. So because you aren't requesting that page, the template never loads, the filters never run, so ...


2

I'm answering this in case anyone should stumble upon this having the same issue. I just removed the jQuery(function ($) { }); wrapping from my TinyMCE plugin code and it works perfectly on any browser now. I realised there was no reason to call jQuery since it's not used in the code as Rup correctly pointed out above. I had copy-pasted a code snippet ...


2

You no longer need to use create_function you can instead just use an anonymous function: add_action( 'gform_preview_footer', create_function( '', 'GFFormDisplay::footer_init_scripts(' . $form['id'] . ');' ) ); Should be: add_action( 'gform_preview_footer', function() use ($form){ GFFormDisplay::footer_init_scripts($form['id']); }); https://www.php.net/...


2

First of all, in your jquery event handler the action parameter's value should be the string after wp_ajax_ and wp_ajax_nopriv_. So in your example the action should be update_records. So display_func is wrong. Then in line 3 of your php code here the echo keyword should be removed. So your php code should be like this: function update_records(){ global $...


1

I want the URLs of the nav-items to be replaced with # You can use the nav_menu_link_attributes hook to set the custom href value like so: add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) { if ( 'menu-categorias' === $args->theme_location && 'category' === $item->object ) { $atts['href'] = '#' . ...


1

/* Show/Hide my div*/ jQuery(document).on('click','.my-button',function() { //jQuery('.div-wordpress').slideToggle('230','swing','hide'); this.remove();//supposed to be #my-button ? }); Note that I have swapped ids for classes and just made a small JS update - this is the clicked element inside a jQuery event - not jQuery(this) Here is a CodePen: ...


1

Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written. jQuery(document).ready(function() { // Some Code Goes Here... }) Just take a look at the complete segment: public function doSomethingSpecific() { ?> <script type="text/javascript" > ...


1

In PHP, it's not necessary to post to a PHP file, it is only required to include ( or require ) files and then use checks and validations to ensure that code is only processed when required. You simply need to include the PHP file as part of your application - it will process the PHP is the conditions are met.


1

This was resolved by discountasp.net. Their note: The other issue is because the older IIS 7 server did not support TLS 1.2 protocol which your application required for SSL to work. I resolved it by migrating your site to our newer IIS 10 web server where TLS 1.2 is supported.


1

GREAT... thank you very much. It opens my mind. I've tried to translate this eventListener in bind jQuery version, but I can't. So I modified the FancyBox Jquery to read directly wp block < a href > $("li.blocks-gallery-item figure a").fancybox({ /* wp block version */ }); $('.fancybox').fancybox({ /* fancybox default standard */ });


1

In jQuery focus by default scroll the page to the element. If we use focus({preventScroll: true}) our copy function will not work as you mension. So I have use some css hack. See the following jQuery code. function copyToClipboard(selector, event){ event.preventDefault(); var $temp = jQuery("<div>"); jQuery("body")....


1

@Rup's comment above led me to the answer; my wp-ajax request was functioning fine, but my incomplete understanding of jquery's $(this) selector meant that I was targeting the last item clicked with the success response each time. This question can now be closed.


1

I think there is a small correction in your code, you just passing page number but you have pass category ID also. I've added data-category attribute in load more button. So your archive.twig should like: <section class="archive"> <p class="archive__title h-headline text-size-l">In the same thematic</p> <div ...


1

This is Trac ticket 51223: commonL10n and other JS globals removed without backwards compatibility In WordPress 5.5, the localized translations under commonL10n were replaced by wp.i18n.__ without deprecation notice or backwards compatibility. Plugins using commonL10n now have JavaScript errors introduced by updating WordPress which can break site ...


1

Here, the code operates on anything that matches the #searchButton element: jQuery("#searchButton") If there is a searchButton on other pages, it will match it, soo you need to be more specific. For example, on the homepage, the <body> tag will have the home class, here is my sites homepage body tag: <body class="home blog logged-in ...


1

I got here debugging the same error on my WP installation. The previous answer was for developer of plugin/theme, so being an admin, I needed a little different approach. I had to find the source of the problem myself. As I learned here I used following line in my config.php to get unminified version of Javascript sources. define('SCRIPT_DEBUG', true); TL;...


1

In the method check_ajax_referer(), the second parameter is not the nonce value, is the key of the post request param. check_ajax_referer( 'login_nonce', 'security', false );


1

Check your handles! The script can fail to load if you pick a handle that has been used elsewhere. If all looks correct with no errors but no script load, check the installation for something else using the same handle. In my case, as I'm extending a parent via a child theme, I (stupidly in hindsight!) stuck with the same naming convention of the parent. ...


1

https://developer.wordpress.org/reference/functions/wp_add_inline_script/ should be a preferred option nowadays EDIT: From the docs above: function mytheme_enqueue_typekit() { wp_enqueue_script( 'mytheme-typekit', 'https://use.typekit.net/.js', array(), '1.0' ); wp_add_inline_script( 'mytheme-typekit', 'try{Typekit.load({ async: true });}catch(e){}' ); ...


1

You can call your functions on 'widget-added widget-updated'. Example - $( document ).on( 'widget-added widget-updated', onSaveWidget ); function onSaveWidget( event, widget ) { initColorPicker( widget ); } So your custom JS functions will also work after your widget is saved.


1

Heres a nice article describing how to do this, but a very different approach to yours : https://aceplugins.com/ajax-add-to-cart-button-on-the-product-page-woocommerce/ Since you know how many items are being added to the cart (1 based on your link) you could just fake some addition and upate the cart icon value Assuming the cart icon number has an id 'cart-...


1

Issues I noticed in your code I don't see where/how you're calling that custom datepicker() function and you should use the same admin_enqueue_scripts hook for registering/enqueueing a stylesheet (.css) file. You should only load the CSS and JS files on the pages where the styles and scripts are being used, e.g. in your case, the post editing screen for ...


1

If you want to remove Effect Core the you have to remove depended scripts too. Follow this to remove them: add_action( 'wp_enqueue_scripts', 'remove_jquery_effects', 100 ); function remove_jquery_effects() { wp_dequeue_script( 'jquery-effects-core' ); wp_dequeue_script( 'jquery-effects-blind' ); wp_dequeue_script( 'jquery-effects-bounce' ); ...


1

You can achieve this using wp_footer action. Add bellow code to functions.php file. It will load the script at the footer of page. add_action('wp_footer', 'load_count_down'); function load_count_down(){ if ($year = get_option('of_year') && $month = get_option('of_month') && $day = get_option('of_day') ) { $date = $year.'/'.$...


1

You could use PluginPrePublishPanel to check for the title and lock publishing if it's empty. Have a look at the accepted answer here for an example of locking the post - Add pre-publish conditions to the block editor For your example you could modify the checking portion as follows: const { registerPlugin } = wp.plugins; const { PluginPrePublishPanel } = ...


1

I used this: function wpb_countx() { wp_enqueue_script('jquery'); ?> <script> jQuery(function($) { // configure var comment_input = $( '#commentform textarea' ); var submit_button = $( '#commentform .form-submit' ); var comment_limit_chars = 1400; // stop editing here // display how many characters are ...


1

I fixed it with some IDs add in function.php add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_loop_ajax_add_to_cart', 10, 2 ); function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() ...


1

jQuery is loaded by WordPress with wp_enqueue_script. The problem is Wordpress also use the below code to change the handle public function localize( $handle, $object_name, $l10n ) { if ( 'jquery' === $handle ) { $handle = 'jquery-core'; } The solution is to use the function function wpse_script_loader_tag( $tag, $handle ) { if ( 'jquery-...


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