Last active
May 6, 2022 17:55
-
-
Save max-kk/2d773bc181ad5cb5268d7f8155988662 to your computer and use it in GitHub Desktop.
FV :: unvote
This file contains 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
+(function($) { | |
// action before voting | |
FvLib.addFilter('fv/vote/get_data', function(data) { | |
if ( data.res !== 10 ) { | |
return data; | |
} | |
data.no_process = "yes"; | |
if ( FvVote.is_voted_for(data.contestant_id) ) { | |
localStorage.removeItem( "voted_" + data.contestant_id ); | |
jQuery(".contest-block[data-id='" + data.contestant_id + "']").removeClass("is-voted"); | |
FvModal.goVoted("success", "Unvoted!", "The vote was removed!", "", data.contestant_id); | |
fv_set_votes_count(data.contestant_id, data.new_votes); | |
} | |
return data; | |
}, 9, 1); | |
})(jQuery); |
This file contains 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
<?php | |
// COPY AFTER | |
add_action('fv/vote/fail', function($code, $contest, $competitor, $add_subscription, $used_votes, $check_ip_query, $check_ip) { | |
$vote = array_pop($check_ip); | |
ModelVotes::q()->delete( $vote->id ); | |
$competitor->votes_count = $competitor->votes_count - 1; | |
$competitor->save(); | |
FV_Public_Vote::echoVoteRes(10, false, $add_subscription, 0, $competitor->votes_count); // echo response | |
}, 10, 7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment