Extending wp JavaScript base class to make a post request to a custom REST endpoint
Extending wp JavaScript base class to make a post request to a custom REST endpoint
Extending wp JavaScript base class to make a post request to a custom REST endpoint
Nonces, AJAX, script variables & security in WordPress
You can mount a react or a vue app partially into a page, so what you ask is theoretically possible but probably not the best solution. You may consider expanding the react application a bit and go fully headless. In this case, next.js (based on react) might be a better solution as it will allow … Read more
You need to is is_front_page() instead of is_home(). is_home() actually refers to the blog page (or the home page if you have it set to show latest posts). is_front_page() refers to the page (regardless of whether it is a static page or a latest posts feed) that sits on the front of your site.
The problem is with your jQuery selector: var usr = $(“#site-addres-input”).attr(‘value’); Will get the default value of the input element. Typically this will be blank, because you’re not setting it ahead of time. You need to use: var usr = $(“#site-addres-input”).val(); I’m also noticing that you’re using #site-addres-input, but “address” has two s at the … Read more
First You can get rid of nasty globals in your AJAX call. I’m not sure what the $st variable that you were output is all about so I’ve excluded, but you can include as you wish – add_action(‘wp_ajax_change_subscription’, ‘change_subscription’); function change_subscription(){ if(!empty($_POST[‘term_id’]) && !empty($_POST[‘type’])) : $user_id = get_current_user_id(); update_user_meta( $user_id, ‘hannit_meta’, ‘My Value’ ); endif; … Read more
That’s not the right way to specify data. When you’re using jQuery AJAX, you specify data as an array or an object when passing it in to the method. In your question, it seems like ‘filters_get’ === ‘?actor=x&’ Instead, you should do the following: filters_get = { ‘actor’: ‘x’ }; $.ajax({ url: templatePath + “getmovies.php”, … Read more
The dynamic wp_ajax_ hooks serve mostly organizational convenience on PHP side. You could choose not to use it, then you would probably have to: hook into admin_init check that DOING_AJAX is true check that request ($_REQUEST[‘action’] and rest of it) is your special kind of request Then either process your request and die() or let … Read more
Switch to full SSL for everything. Seriously, it’s way easier than dealing with mixed content.
I’ve met the same issue. …the recommended Basic Auth… I found that the problem is in the Basic Auth plugin. WP-API guys recommend using their own plugin and this solution works for me. Deactivate all activated basic auth plugins in your WordPress dashboard On the machine your WordPress is running go to the plugin folder … Read more