Plugin retrieving results even after uninstallation
WordPress v4.7 has added the REST API into core, so this might explain why your REST functionality is still available even after uninstalling the REST API plugin.
WordPress v4.7 has added the REST API into core, so this might explain why your REST functionality is still available even after uninstalling the REST API plugin.
You can internally route REST API requests using rest_do_request and a WP_REST_Request object. $request = new WP_REST_Request( ‘GET’, ‘/fb_connect’ ); $request->set_param( ‘x’, true ); // You can also use it this way: $request[‘y’] = true; $request[‘z’] = true; $response = rest_do_request( $request );
Adding this line to my $.ajax call fixed the problem for me. $.ajax({ xhrFields: { withCredentials: true }, // the rest… Sidenote: this requires the following header to be set on the server-side, which is enabled by default with the REST API (it seems). Access-Control-Allow-Credentials:true
As stated in the documentation page you linked, It is important to keep in mind that this authentication method relies on WordPress cookies. As a result this method is only applicable when the REST API is used inside of WordPress and the current user is logged in. In addition, the current user must have the … Read more
Step 1: Learn how to use AJAX in WordPress Plugins/Themes. The trick is that your Javascript doesn’t get the Stuff from Beta Site, your Javascript calls a PHP-Function you coded that itself gets the Stuff. Step 2: Keep using the Transients. Check within your Ajax Callback, if there is a transient. If there is, return … Read more
If your requests take 3-5 sec to finish, then there is most likely something else going on. The admin Ajax itself won’t take that much to load. You might be having some heavy plugin, or having some hooks running expensive meta queries on load. You can try the REST-API, which is slightly faster than Admin-Ajax. … Read more
the URL is not good in the AJAX call to correct that, modify the function theme_sniffer_admin_scripts in inc/admin.php to add the home URL to wp_localize_script : “homeURL” => home_url(), and then use this URL in the 2 AJAX calls in js/admin.js : url: localizationObject[“homeURL”] + ‘/wp-json/theme-sniffer/v1/sniff-run’,
Look at the URL in the error: http://solucase.com/wp-json/wp/v2/posts?categories=%27cat_id%27 %27 is the URL encoded character for ‘, so you can see what’s happening is that in the URL you are requesting with AJAX cat_id is not being replaced with the variable value. This is because the way you have used quotes when defining the URL is … Read more
My REST URL was wrong – I didn’t add the userid to the url. Proper REST URL should be: /wp-json/wp/v2/users/30/ where 30 should be changed with user’s id.
You can use the WP_REST_Server::get_namespaces() method. For instance. $exists = in_array( ‘ns/v1’, rest_get_server()->get_namespaces() );