Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created April 22, 2014 12:13
Show Gist options
  • Select an option

  • Save gicolek/11176527 to your computer and use it in GitHub Desktop.

Select an option

Save gicolek/11176527 to your computer and use it in GitHub Desktop.
Trigger View
<script>
function trigger_view(id) {
jQuery.post(
<?php echo json_encode( 'some_url' ) ?>,
{
// a post id, fetched before
"cp_post_id": id,
// wordpress nonce for safety reason
"nonce": '<?php echo wp_create_nonce( 'view' ); ?>'
}
).done(function() {
// log some data
console.log('Post ' + id + ' viewed.');
});
}
;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment