Plugin Directory

Changeset 2019500


Ignore:
Timestamp:
01/26/2019 11:01:19 AM (7 years ago)
Author:
deller21
Message:

fix bugs

Location:
recobox/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • recobox/trunk/README.txt

    r2015231 r2019500  
    55Requires at least: 3.0
    66Tested up to: 4.9.5
    7 Stable tag: 1.0.4
     7Stable tag: 1.0.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • recobox/trunk/admin/class-rcb-comments-admin.php

    r2015231 r2019500  
    209209                    [
    210210                        'post_id' => $channel->name,
    211                         'recobox_id' => $channel->id
     211                        'recobox_id' => $channel->id,
     212                        'rating' => json_encode($channel->rating)
    212213                    ],
    213214                    ['%s', '%s']
  • recobox/trunk/includes/class-rcb-comments-activator.php

    r2014437 r2019500  
    5252                    post_id text NOT NULL default '',
    5353                    recobox_id text NOT NULL default '',
     54                    rating text NOT NULL default '',
    5455                    PRIMARY KEY  (id)
    5556                ) {$charset_collate};";
  • recobox/trunk/public/class-rcb-comments-public.php

    r2014437 r2019500  
    9393    public function get_data_from_recobox_func($request)
    9494    {
    95         $test_wr = fopen('testlog.txt', 'a+');
    96         fwrite($test_wr, print_r($request, true));
    97         fclose($test_wr);
     95        //$test_wr = fopen('testlog.txt', 'a+');
     96        //fwrite($test_wr, print_r($request, true));
     97        //fclose($test_wr);
    9898
    9999        $type = $request->get_param('type');
     
    262262                        FROM $channesTableName
    263263                          WHERE recobox_id = %d
    264                           ", $comment['channel']['name']));
     264                          ", $comment['channel']['id']));
    265265
    266266            if (empty($recoboxChannel)) {
     
    270270                    [
    271271                        'post_id' => $comment['channel']['name'],
    272                         'recobox_id' => $comment['channel']['id']
     272                        'recobox_id' => $comment['channel']['id'],
     273                        'rating' => json_encode($comment['channel']['rating'])
    273274                    ],
     275                    ['%s', '%s', '%s']
     276                );
     277
     278            } else {
     279
     280                $wpdb->update(
     281                    $wpdb->get_blog_prefix() . 'recobox_channels',
     282                    [
     283                        'rating' => json_encode($comment['channel']['rating'])
     284                    ],
     285                    [
     286                        'post_id' => $comment['channel']['name'],
     287                        'recobox_id' => $comment['channel']['id'],
     288                    ],
     289                    ['%s'],
    274290                    ['%s', '%s']
    275291                );
  • recobox/trunk/public/partials/rcb-comment-template.php

    r2015231 r2019500  
    2121        $sync = $settings['sync'];
    2222    }
     23
     24    $host = $_SERVER['HTTP_HOST'];
     25    $host = str_replace('www.', '', $host);
     26    $hosts = explode('.', $host);
     27    if(count($hosts) > 2) {
     28        $prefix = [];
     29        for($i = 0; $i < (count($hosts) - 2); $i++) {
     30            $prefix[] = $hosts[$i];
     31        }
     32        $postId = implode('_', $prefix) . '_' . $post->ID;
     33    } else {
     34        $postId = $post->ID;
     35    }
     36
     37    $channesTableName = $wpdb->get_blog_prefix() . 'recobox_channels';
     38    $recoboxChannel = $wpdb->get_row($wpdb->prepare(
     39        "
     40                        SELECT *
     41                        FROM $channesTableName
     42                          WHERE post_id = %d
     43                          ", $postId));
     44    $htmlRating = '';
     45    if (!empty($recoboxChannel)) {
     46
     47        if(!empty($recoboxChannel->rating)) {
     48            $rating = (array)json_decode($recoboxChannel->rating);
     49            switch ($rating['type']) {
     50                case 'stars':
     51                    $ratingValue = $rating['rating_avg'];
     52                    $ratingCount = $rating['rating_count'];
     53                    break;
     54                case 'like_dislike':
     55                    $ratingValue = $rating['likes'] - $rating['dislikes'];
     56                    if($ratingValue < 0)
     57                        $ratingValue = 0;
     58                    else
     59                        $ratingValue = 5;
     60                    $ratingCount = $rating['likes'] + $rating['dislikes'];
     61                    break;
     62            }
     63
     64            $htmlRating = '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
     65                    Рейтинг <span itemprop="ratingValue">' . $ratingValue . '</span> из <span itemprop="bestRating">5</span>.
     66                    Проголосовало: <span itemprop="ratingCount">' . $ratingCount . '</span></div>';
     67        }
     68
     69    }
     70
     71
    2372    do_action('comment_form_before');
    2473   
    2574    if(comments_open()) {
    2675    ?>
    27     <div class="entry">
    28 <div class="entry-footer">
    2976    <div id="rcb-comments-area">
    3077        <div id="rcb-comments">
    3178            <?php
     79            echo $htmlRating;
    3280            if ($sync) { ?>
    3381                <ul id="recobox-comments">
     
    4088        </div>
    4189    </div>
    42     </div>
    43     </div>
    4490    <?php do_action('comment_form_after'); ?>
    4591
    4692    <script type="text/javascript">
    47     <?php
    48     $host = $_SERVER['HTTP_HOST'];
    49     $host = str_replace('www.', '', $host);
    50     $hosts = explode('.', $host);
    51     if(count($hosts) > 2) {
    52         $prefix = [];
    53         for($i = 0; $i < (count($hosts) - 2); $i++) {
    54             $prefix[] = $hosts[$i];
    55         }
    56         $postId = implode('_', $prefix) . '_' . $post->ID;
    57     } else {
    58         $postId = $post->ID;
    59     }
    60     ?>
    6193        (function () {
    6294            RCB = window.RCB || [];
  • recobox/trunk/rcb-comments.php

    r2015231 r2019500  
    33/**
    44 * @link              https://recobox.ru
    5  * @since             1.0.4
     5 * @since             1.0.5
    66 * @package           Rcb_Comments
    77 *
     
    1010 * Plugin URI:        https://recobox.ru
    1111 * Description:       Система комментирования с различными вариантами социальной аутентификации(ВКонтакте, Одноклассники, FaceBook, Google+ и т.д.).
    12  * Version:           1.0.4
     12 * Version:           1.0.5
    1313 * Author:            Recobox
    1414 * Author URI:        https://profiles.wordpress.org/deller21
     
    6565 * not affect the page life cycle.
    6666 *
    67  * @since    1.0.4
     67 * @since    1.0.5
    6868 */
    6969function rcb_comments_run() {
Note: See TracChangeset for help on using the changeset viewer.