Hot answers tagged

8

WordPress uses the jQuery migrate script to ensure backwards compatibility for any plugins or themes you might be using which use functionality removed from newer versions of jQuery. With the release of WordPress 4.5, it appears they have upgraded the version of jQuery migrate from v1.2.1 to v1.4.0 - Having a quick scan through the code reveals that v1.4.0 ...


5

Problem "Serialization" is the act of turning a data-object into a string-representation. jQuery automatically serializes the data property before sending an AJAX request. The server then deserializes the GET querystring from the URL, and the request body for POST requests before populating PHP's request variables. Your code functioned as expected when ...


3

You could change the log message text to blank in jquery-migrate.min.js but this will not be preserved on core update. The alternative is to add passthrough/filter function copy of console.log to just before the migrate script is loaded, and tell it to ignore logging messages that contain 'Migrate is installed'. Doing it this way will preserve other Migrate ...


2

You forgot to set dependencies at third parameter put it with array() or array('jquery') if you want to depend on jQuery wp_register_script( 'navbar-scroll', 'http://www.classyclutter.net/wp-content/themes/foodiepro/assets/js/scrolling-navbar.js', array(), '1.0.0', true);


2

WP loads jQuery in no conflict mode so shortcut $ is not available for jQuery to use .You should not use the $ variable for jQuery within WordPress. jQuery(function ($) { //code here }) or (function($){ //code here })(jQuery); There are so many Q&A which refers to the same conflict issue.Check this and this.


2

From your site i can say that script is not being loaded because of wrong opening quote for script tag.Use " instead of ” So <script src=”http://lookbook.nu/widget/profile.js?id=2303472&width=standard&align=left&stats_fans=1&fanbox=yes&hash=14575a9cd02fd36d2758e5db3cb92b5a”></script> Should be this <script ...


2

Note that the action should be inside the data key. In your post request there is no key named as action therefore, the callback function is never being called. Consider this example:- jQuery.ajax({ type:"POST", url: "/wp-admin/admin-ajax.php", data: { action: "my_test_action", form_data : newFormChange }, success: ...


1

Found a solution. Turns out the activate, deactivate functions are not persistent, meaning the controls' state are reset if the page is refreshed! Therefore I used 'active_callback' => 'fname' in my customizer.php in order to make changes persistent where fname is the function name as seen below. function fname() { if ( !strcmp ( ...


1

Never let anyone add any jQuery scripts via any text editor. How are you going to know if the script is malicious or not, how are you going to handle jQuery errors, how are you going to know if the jQuery is even proper and allowed jQuery. eval() brings an added extra security risk and should be avoided where user submitted strings are to be evaluated. ...


1

Not allow. Your user is not a software developer, pretending that he is can only end bad. This is even before speaking about security etc. If you think that there are callbacks that make sense, just provide them yourself.


1

Just a little test here. I peeked into jquery-migrate.js and noticed this part: // Set to true to prevent console output; migrateWarnings still maintained // jQuery.migrateMute = false; so I tested the following with the newly wp_add_inline_script(), introduced in version 4.5: add_action( 'wp_enqueue_scripts', function() { wp_add_inline_script( ...


1

I see two things. You're missing an action call - you need add_action( 'wp_ajax_render_admin_charts_page', 'render_admin_charts_page' ); add_action('wp_ajax_nopriv_render_admin_charts_page', 'render_admin_charts_page'); Plus, from looking at your render_admin_charts_page() you need to change your json dataType to html. Your charts function is outputting ...


1

You are trying to load your inline js script after jQuery just by calling add_action( 'wp_footer', 'myscript' ); after wp_enqueue_script( 'jquery' ); But this will not load your myscript after jQuery. It is not how wp_footer and wp_enqueue_script works. wp_footer has a third argument named "priority". add_action( 'wp_footer', 'your_function', 100 ); ...


1

Seems like you'd be better off saving your script in a .js file and then enqueuing your script using wp_enqueue_script() instead of wp_footer. That way you can designate jquery as a dependency for your script. wp_enqueue_script( 'myscript', 'path/to/myscript.js', array( 'jquery' ), false, true ); This also separates your js out of your php into a proper ...



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