Exemplo n.º 1
0
function pado_docs_vote()
{
    global $post;
    global $pado_options;
    if (is_user_logged_in()) {
        $vote_count = (array) get_user_meta(get_current_user_id(), 'vote_count', true);
        if (isset($_GET['vote_like']) && $_GET['vote_like'] > 0) {
            $post_id = (int) $_GET['vote_like'];
            $the_post = get_post($post_id);
            if ($the_post && !in_array($post_id, $vote_count)) {
                $vote_count[] = $post_id;
                update_user_meta(get_current_user_id(), 'vote_count', $vote_count);
                $post_votes = (int) get_post_meta($post_id, '_votes_likes', true);
                $post_votes++;
                update_post_meta($post_id, '_votes_likes', $post_votes);
                $post = get_post($post_id);
                pado_docs_votes(true);
                die('');
            }
        } elseif (isset($_GET['vote_dislike']) && $_GET['vote_dislike'] > 0) {
            $post_id = (int) $_GET['vote_dislike'];
            $the_post = get_post($post_id);
            if ($the_post && !in_array($post_id, $vote_count)) {
                $vote_count[] = $post_id;
                update_user_meta(get_current_user_id(), 'vote_count', $vote_count);
                $post_votes = (int) get_post_meta($post_id, '_votes_dislikes', true);
                $post_votes++;
                update_post_meta($post_id, '_votes_dislikes', $post_votes);
                $post = get_post($post_id);
                pado_docs_votes(true);
                die('');
            }
        }
    } elseif (!is_user_logged_in() && $pado_options['voting'] == 1) {
        // ADD VOTING FOR NON LOGGED IN USERS USING COOKIE TO STOP REPEAT VOTING ON AN ARTICLE
        $vote_count = '';
        if (isset($_COOKIE['vote_count'])) {
            $vote_count = @unserialize(base64_decode($_COOKIE['vote_count']));
        }
        if (!is_array($vote_count) && isset($vote_count)) {
            $vote_count = array();
        }
        if (isset($_GET['vote_like']) && $_GET['vote_like'] > 0) {
            $post_id = (int) $_GET['vote_like'];
            $the_post = get_post($post_id);
            if ($the_post && !in_array($post_id, $vote_count)) {
                $vote_count[] = $post_id;
                $_COOKIE['vote_count'] = base64_encode(serialize($vote_count));
                setcookie('vote_count', $_COOKIE['vote_count'], time() + 10 * 365 * 24 * 60 * 60, '/');
                $post_votes = (int) get_post_meta($post_id, '_votes_likes', true);
                $post_votes++;
                update_post_meta($post_id, '_votes_likes', $post_votes);
                $post = get_post($post_id);
                pado_docs_votes(true);
                die('');
            }
        } elseif (isset($_GET['vote_dislike']) && $_GET['vote_dislike'] > 0) {
            $post_id = (int) $_GET['vote_dislike'];
            $the_post = get_post($post_id);
            if ($the_post && !in_array($post_id, $vote_count)) {
                $vote_count[] = $post_id;
                $_COOKIE['vote_count'] = base64_encode(serialize($vote_count));
                setcookie('vote_count', $_COOKIE['vote_count'], time() + 10 * 365 * 24 * 60 * 60, '/');
                $post_votes = (int) get_post_meta($post_id, '_votes_dislikes', true);
                $post_votes++;
                update_post_meta($post_id, '_votes_dislikes', $post_votes);
                $post = get_post($post_id);
                pado_docs_votes(true);
                die('');
            }
        }
    } elseif (!is_user_logged_in() && $pado_options['voting'] == 2) {
        return;
    }
}
Exemplo n.º 2
0
                            <?php 
            the_post_thumbnail();
            ?>
                        </div>
                    <?php 
        }
        ?>
                                
                    <div class="document-content">
                        <?php 
        the_content();
        ?>
                    </div>
                    <?php 
        if ($pado_options['voting'] != 0) {
            pado_docs_votes();
        }
        ?>
                    <p class="pado-back-top"><a href="#top"><i class="pado-icon-angle-up"></i> <?php 
        _e('Back To Top', 'pressapps');
        ?>
</a></p>
                </article>
                <?php 
    }
}
?>
    </div>
    
</div>