Advertisement
designbymerovingi

myCRED Link Script adjusted for post id

Nov 22nd, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /**
  2. * myCRED Points for Link Clicks jQuery Scripts
  3. * @since 0.1
  4. * @version 1.3.2
  5. */
  6. jQuery(function($) {
  7. var mycred_click = function( href, title, target, skey, post ) {
  8. $.ajax({
  9. type : "POST",
  10. data : {
  11. action : 'mycred-click-points',
  12. url : href,
  13. token : myCREDgive.token,
  14. etitle : title,
  15. key : skey,
  16. post_id : post
  17. },
  18. dataType : "JSON",
  19. url : myCREDgive.ajaxurl,
  20. success : function( data ) {
  21. //console.log( data );
  22. if ( target == 'self' )
  23. window.location.href = href;
  24. },
  25. error : function( jqXHR, textStatus, errorThrown ) {
  26. // Debug
  27. //console.log( jqXHR );
  28. //console.log( 'textStatus: ' + textStatus + ' | errorThrown: ' + errorThrown );
  29. }
  30. });
  31. };
  32.  
  33. $('.mycred-points-link').click(function(){
  34. var target = $(this).attr( 'target' );
  35. //console.log( target );
  36. if ( typeof target === 'undefined' ) {
  37. target = 'self';
  38. }
  39.  
  40. mycred_click( $(this).attr( 'href' ), $(this).text(), target, $(this).attr( 'data-key' ), $(this).attr( 'data-post' ) );
  41.  
  42. if ( target == 'self' ) return false;
  43. });
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement