Skip to content

Commit

Permalink
applying Tmeister#25
Browse files Browse the repository at this point in the history
  • Loading branch information
fharper committed Dec 5, 2023
1 parent 0492d8e commit ad004f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions includes/class.process-vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ function process_vote_up(){

$userid = get_current_user_ID();

} elseif ( !is_user_logged_in() && $public_can_vote ) {
} elseif ( !is_user_logged_in() && $public_can_vote == 'on' ) {

$userid = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : 0;
}

// if the public can vote and the user has already voted or they are logged in and have already voted then bail out
if ( $public_can_vote && $has_public_voted || $has_private_voted ) {
if ( $public_can_vote == 'on' && $has_public_voted || $has_private_voted ) {
echo 'already-voted';
die();
}
Expand All @@ -59,7 +59,7 @@ function process_vote_up(){
update_post_meta( $postid, '_idea_votes', intval( $votes ) + 1 );
update_post_meta( $postid, '_idea_total_votes', intval( $total_votes ) + 1 );

if ( !is_user_logged_in() && $public_can_vote ) {
if ( !is_user_logged_in() && $public_can_vote == 'on' ) {

$args = array( 'postid' => $postid );
idea_factory_add_public_vote( $args );
Expand Down Expand Up @@ -107,14 +107,14 @@ function process_vote_down(){

$userid = get_current_user_ID();

} elseif ( !is_user_logged_in() && $public_can_vote ) {
} elseif ( !is_user_logged_in() && $public_can_vote == 'on' ) {

$userid = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : 0;
}


// if the public can vote and the user has already voted or they are logged in and have already voted then bail out
if ( $public_can_vote && $has_public_voted || $has_private_voted ) {
if ( $public_can_vote == 'on' && $has_public_voted || $has_private_voted ) {
echo 'already-voted';
die();
}
Expand All @@ -124,7 +124,7 @@ function process_vote_down(){
update_post_meta( $postid, '_idea_total_votes', intval( $total_votes ) + 1 );

// update user meta so they can't vote on this again
if ( !is_user_logged_in() && $public_can_vote ) {
if ( !is_user_logged_in() && $public_can_vote == 'on' ) {

$args = array( 'postid' => $postid );
idea_factory_add_public_vote( $args );
Expand Down
4 changes: 2 additions & 2 deletions public/includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function idea_factory_is_voting_active( $postid = '' ) {

//if ( ( !idea_factory_has_private_voted( $postid ) && is_user_logged_in() || !idea_factory_has_public_voted( $postid ) && $public_can_vote ) && 'approved' !== $status ){

if ( ( ( false == idea_factory_has_private_voted( $postid ) && is_user_logged_in()) || false == idea_factory_has_public_voted( $postid ) && $public_can_vote && !is_user_logged_in() ) && 'approved' !== $status ){
if ( ( ( false == idea_factory_has_private_voted( $postid ) && is_user_logged_in()) || false == idea_factory_has_public_voted( $postid ) && $public_can_vote == 'on' && !is_user_logged_in() ) && 'approved' !== $status ){

return true;

Expand Down Expand Up @@ -407,7 +407,7 @@ function idea_factory_submit_header(){
$intro_message = idea_factory_get_option('if_welcome','if_settings_main',apply_filters('idea_factory_default_message', __('Submit and vote for new features!','idea-factory')));
$public_can_vote = idea_factory_get_option('if_public_voting','if_settings_main');

if ( is_user_logged_in() || $public_can_vote ): ?>
if ( is_user_logged_in() || $public_can_vote == 'on' ): ?>

<aside class="idea-factory--layout-submit">

Expand Down
2 changes: 1 addition & 1 deletion templates/template-ideas.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

$has_voted = get_user_meta( get_current_user_ID(), '_idea'.$id.'_has_voted', true);

} elseif( $public_can_vote ) {
} elseif( $public_can_vote == 'on' ) {

$has_voted = idea_factory_has_public_voted( $id );

Expand Down

0 comments on commit ad004f8

Please sign in to comment.