WordPress Ajax URL for function in functions.php

//ajax call var data = { action: ‘folder_contents’, path: datafolder }; var ajaxurl = baseurl + ”; //WHAT IS THIS?!?! jQuery.post(ajaxurl, data, function(response) { alert(‘Got this from the server: ‘ + response); console.log(response); }); And your PHP in functions.php //Called by Ajax from App – list the contents of the folder so they can be … Read more

How to get the path to current theme, but from a JS file?

You can use wp_localize_script to pass an object with the url to load before the file. and then in the file you can use it like testpage_obj.json_data wp_register_script(‘testpage’, get_stylesheet_directory_uri() . ‘/js/testscript.js’, array(‘jquery’), ”, true); wp_localize_script( ‘testpage’, ‘testpage_obj’, array( ‘json_data’ => get_stylesheet_directory_uri() . ‘/js/mydata.json’ ) ); wp_enqueue_script(‘testpage’); In the JS file jQuery.getJSON(testpage_obj.json_data)

How to prevent wordpress from loading old versions of jquery in wp_head();?

add_action(‘wp_enqueue_scripts’, ‘no_more_jquery’); function no_more_jquery(){ wp_deregister_script(‘jquery’); } That will deregister jquery. But why wouldn’t you want jQuery at all? If you mean to simply use your own, you should do it in that function, like this: add_action(‘wp_enqueue_scripts’, ‘no_more_jquery’); function no_more_jquery(){ wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, “http” . ($_SERVER[‘SERVER_PORT’] == 443 ? “s” : “”) . “://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”, false, null); wp_enqueue_script(‘jquery’); … Read more

How to control what jQuery version to include, with wp_enqueue_script

That’s the size of the minified jQuery nowadays 🙂 You can load the latest from Google: wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js”), false, ‘1.8.2’); Please keep in mind that this can cause issues moving forward, as you are forcing WordPress to load a certain version of jQuery instead of the version bundled with it. There are plugins out … Read more

AJAX nonce with check_ajax_referer()

Difficult to say for sure where the mistake is as you have not mentioned about your add_action(‘wp_ajax_my_function’,’whatever_callback’);which I think you missed out on that. But your question is missing info in this respect. This is how I would get on about this: In your functions.php file or similar: add_action(wp_ajax_handle_login, ‘handle_login_ajax’); add_action(wp_ajax_nopriv_handle_login, ‘handle_login_ajax’); Make sure your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)