• Resolved wouterstg

    (@wouterstg)


    I was wondering if this is possible? For our site this would be very nice.

    Except this nothing but love for this great plugin!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Technically yes, however it’s not recommended for the following reasons.

    1. Site Reviews uses the WordPress wp_star_rating function which expects a maximum of 5 stars. It will not show empty stars for numbers above 5.
    2. Changing to 10 stars when you have existing 1-5 star reviews will mess up your rating counts. You would need to apply the change before you have any reviews.
    3. Once you have set it to 10 stars, you will not easily be able to revert to 5 stars.
    4. Changing the maximum rating number is not officially supported. So if you experience problems after changing to 10 stars you may have to figure it out yourself if the problem is related to the rating.

    If you would like to go ahead with this change in spite of the warnings above, you may do so like this:

    /**
     * Changes the maximum rating to 10 stars
     * @return int
     */
    add_filter('site-reviews/const/MAX_RATING', function () {
        return 10;
    });
    
    /**
     * Changes the rating validation to allow 10 stars
     * @param array $rules
     * @return array
     */
    add_filter('site-reviews/validation/rules', function ($rules) {
        if (array_key_exists('rating', $rules)) {
            $rules['rating'] = 'required|number|between:1,10';
        }
        return $rules;
    });
    
    /**
     * Changes the summary bars labels for each of the 10 stars
     * @param array $atts
     * @param string $type
     * @param string $partial
     * @return array
     */
    add_filter('site-reviews/shortcode/atts', function($atts, $type, $partial) {
        if ('site-reviews-summary' === $partial) {
            $atts['labels'] = '10 stars,9 stars,8 stars,7 stars,6 stars,5 stars,4 stars,3 stars,2 stars,1 star';
        }
        return $atts;
    }, 10, 3);
    Thread Starter wouterstg

    (@wouterstg)

    Hi Thanks for the quick reply. I only want to change the number from max 5 to 10 so it’ll show 9.4 out of 10 instead of 4.3 or something like that. The stars wil stay at max 5.

    Is that possible to do?

    Plugin Author Gemini Labs

    (@geminilabs)

    The only way that it is possible to change the number of stars is shown above.

    Thread Starter wouterstg

    (@wouterstg)

    Hi (sorry for the late reply, Christmas time and stuff.) I’ve tried your script and it does work. However, like you said, this causes troubles ??

    I’m going for a different approach now. Can I hook into the rating number and multiply it by 2. So when ever the review count is 4.2 it multiply’s the count to 8.4. Maybe thats a simpeler way of doing this. Is this possible?

    Plugin Author Gemini Labs

    (@geminilabs)

    Not really.

    The next update will remove the wp_star_rating usage in order to allow max ratings higher than 5 without throwing a PHP warning.

    Thread Starter wouterstg

    (@wouterstg)

    Hi,
    Today i’ve updated the plugin and was surprised to see this option Fixed stars when MAX_RATING is greater than 5.

    Is this only when you use the code above? Or is there an option to change this?

    I still would like the review rating to go to 10 instead of 5. But this is not that is it ??

    • This reply was modified 5 years, 1 month ago by wouterstg.
    Plugin Author Gemini Labs

    (@geminilabs)

    The update fixes the PHP warning that is thrown when changing the max rating to a number higher than 5 (when using the code above).

    Fixes this: https://www.ads-software.com/support/topic/score-count-up-to-10-instead-of-5/#post-12290425

    And #1 of this: https://www.ads-software.com/support/topic/score-count-up-to-10-instead-of-5/#post-12266247

    • This reply was modified 5 years, 1 month ago by Gemini Labs.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Score count up to 10 instead of 5’ is closed to new replies.