Plugin Directory

Changeset 1397774


Ignore:
Timestamp:
04/17/2016 01:52:16 PM (10 years ago)
Author:
bykaVBS
Message:

Version 1.03 - add support function outside the post

Location:
cs-likes-counter/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cs-likes-counter/trunk/cs-likes-counter.php

    r1397762 r1397774  
    44  Plugin URI: http://codesweet.ru/cs-likes-counter/
    55  Description: Likes Dislikes post counter
    6   Version: 1.0.2
     6  Version: 1.0.3
    77  Author: EdCreater
    88  Author URI: http://codesweet.ru
     
    287287   * @return string $form html form
    288288   */
    289     public static function show_buttons_like(){
     289    public static function show_buttons_like($post_id = NULL){
    290290        global $post, $current_user;
    291291
    292292        get_currentuserinfo();
    293293
    294         $post_likes = get_post_meta($post->ID, 'cs_post_likes', true);
     294        if (!$post_id){
     295            $post_id = $post->ID;
     296        }
     297        $post_likes = get_post_meta($post_id, 'cs_post_likes', true);
    295298        if (empty($post_likes)){
    296299            $post_likes = 0;
    297300        }
    298         $post_dislikes = get_post_meta($post->ID, 'cs_post_dislikes', true);
     301        $post_dislikes = get_post_meta($post_id, 'cs_post_dislikes', true);
    299302        if (empty($post_dislikes)){
    300303            $post_dislikes= 0;
    301304        }
    302305
    303         $form = '<div id="cs-likes-dislikes-'.$post->ID.'" class="cs-likes-dislikes">';
     306        $form = '<div id="cs-likes-dislikes-'.$post_id.'" class="cs-likes-dislikes">';
    304307        $form .='<form action="" method="post" class="cs-likes-dislikes-form">';
    305308
    306         $form .= '<a href="#" class="cs-like-post" data-post="' . $post->ID . '"><span class="like-ico"></span>';
     309        $form .= '<a href="#" class="cs-like-post" data-post="' . $post_id . '"><span class="like-ico"></span>';
    307310        $form .= '<span class="like-count">'.$post_likes.'</span></a>';
    308         $form .= '<a href="#" class="cs-dislike-post" data-post="' . $post->ID . '"><span class="dislike-ico"></span>';
     311        $form .= '<a href="#" class="cs-dislike-post" data-post="' . $post_id . '"><span class="dislike-ico"></span>';
    309312        $form .= '<span class="dislike-count">'.$post_dislikes.'</span></a>';
    310313
  • cs-likes-counter/trunk/readme.txt

    r1397765 r1397774  
    55Requires at least: 3.9
    66Tested up to: 4.4.2
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88License: GPLv2
    99
     
    2222Simply place the template single.php function call inside the loop
    2323
    24     <?php echo CS_Likes::show_buttons_like(); ?>
     24    <?php while(have_post()) : the_post(); ?>
     25        <?php echo CS_Likes::show_buttons_like(); ?>
     26    <?php endwhile; ?>
     27
     28Or use ID of post, if function call outside the loop
     29
     30    <?php echo CS_Likes::show_buttons_like($post_id); ?>
    2531
    2632
     
    5157= I\'m having issues getting the plugin to work what should I do? =
    5258
    53 See the [FAQs](http://codesweet.dev/nashi-razrabotki/cs-likes-counter) page for a detailed rundown of common issues
     59See the [FAQs](http://codesweet.dev/nashi-razrabotki/cs-likes-counter/) page for a detailed rundown of common issues
    5460
    5561
     
    6470* Add Russian Language support
    6571* Add likes metabox to page
     72
     73= 1.0.2 =
     74
     75* Add support function outside the loop
Note: See TracChangeset for help on using the changeset viewer.