Created
May 19, 2018 15:51
-
-
Save celticwebdesign/7d6644ccca55870c16b03d2a2d7796b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codex.wordpress.org/Plugin_API/Action_Reference/admin_footer | |
function my_admin_add_js() { | |
echo ' | |
<script type="text/javascript"> | |
var ajaxurl = "'.admin_url("admin-ajax.php").'"; | |
var user_id = '.get_current_user_id().'; | |
</script> | |
<!-- This script should be enqueued properly in the footer --> | |
<script> | |
(function ($) { | |
$("a.thickbox1, a.thickbox2").click(function(e) { | |
e.preventDefault(); | |
console.log( ajaxurl ); | |
$.ajax({ | |
url : ajaxurl, | |
type : "post", | |
data : { | |
action : "post_love_add_love", | |
user_id : user_id | |
}, | |
success : function( response ) { | |
alert(response) | |
}, | |
error : function( error ) { | |
alert(error) | |
} | |
}); | |
alert("open"); | |
}); | |
})(jQuery); | |
</script> | |
'; | |
} | |
add_action('admin_footer', 'my_admin_add_js'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment