Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function script_js() {
- $data= [
- 'ajax_url'=> admin_url('admin-ajax.php')
- ];
- wp_localize_script('my_script','ajax_obj', $data);
- wp_enqueue_script('my_script', get_theme_file_uri('src/script.js'),'jquery',time(),true);
- }
- add_action('wp_enqueu_scripts', 'script_js');
- $post_id = isset($_POST['post_id']);
- echo wp_json_encode($post_id);
- wp_die();
- function ajax_post_status_change(){
- }
- add_action('wp_ajax_post_status_change', 'ajax_post_status_change');
- (function ($) {
- $(document).ready(function () {
- $(".post_option a").on("click", function (e) {
- let post_id = $(this).data("post-id");
- $.ajax({
- type: "POST",
- url: ajax_obj.ajax_url,
- data: { action: "post_status_change", post_id:post_id },
- success: function (response) {
- alert(response);
- },
- });
- e.preventDefault();
- });
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement