Save jQuery UI Sortable on WordPress

if you use the stop function when you intialise .sortable() you can ajax send the new order to a script, which (when you write it!) would save the new order to the database. jQuery(function(){ jQuery(“#sortable”).sortable({ stop: function (event, ui) { var new_order = jQuery(this).sortable(‘serialize’); jQuery.post( “http://www.thissite.com/wp-admin/ajax.php”, { action: my_custom_ajax_save, order: new_order }, function( data ) … Read more

Set cookie for visitor

If you are looking for user only comments then you could try this one ( http://codex.wordpress.org/Function_Reference/wp_set_auth_cookie). This function can be replaced via plugins. If plugins do not redefine these functions, then this will be used instead. Sets the authentication cookies based User ID. The $remember parameter increases the time that the cookie will be kept. … Read more

Unexpected token ILLEGAL, even on clean install – jquery-issue?

It looks to me like you’re trying to utilize jQuery in custom code, but haven’t actually enqueue’d the jQuery script – This line gives it away (I think?): ReferenceError: jQuery is not defined if you are using wp_enqueue_script to bring in a custom .js file, make sure you set jquery as a dependancy wp_enqueue_script( ‘my-script’, … Read more

Using WP functions inside javascript

I found out about wp_localize_scripts here and it solves my issue: functions.php $var=get_current_user_id(); $params = array( ‘max’ => $var ); wp_localize_script( ‘myscript’, ‘MyScriptParams’, $params ); wp_enqueue_script(‘myscript’); and in the .js file I can retrieve this variable with MyScriptParams.max.

WP_ENQUEUE not working with Foundation 5

EDIT: I’m coming back to correct this post, having successfully wp_enqueue’d Foundation 5.3 for Sites to WordPress 3.9. This code below is for anyone who has struggled to WP_ENQUEUE Foundation. The code below works perfectly. UPDATES: I will continue to update this post with the newest version of WordPress and Foundation to give you all … Read more

Ajax +wordpress onClick link redirect to new page and create html content

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 html so all you need to do is output it; your alert() should contain all the html … Read more

Manipulate retrieved ajax data in php

Yes you should use die(); in ajax function call, but because you’re not returning data and don’t care what is returned it’s not necessary You should be using nonce, it’s good practice to get used to always using it regardless of the situation. http://codex.wordpress.org/WordPress_Nonces http://codex.wordpress.org/AJAX_in_Plugins You should not be using a function called func, name … Read more

Removed jQuery script from header.php , any problems?

Here is the correct way to include jQuery in your theme. Open functions.php in your theme folder and add this to it: // Proper way to enqueue scripts and styles function royal_insert_jquery(){ wp_enqueue_script(‘jquery’, false, array(), false, false); } add_filter(‘wp_enqueue_scripts’,’royal_insert_jquery’,1); This will load the WordPress bundled version of jQuery and will make sure that it is … Read more