Plugin Directory

Changeset 1681345


Ignore:
Timestamp:
06/19/2017 04:46:07 PM (9 years ago)
Author:
n7studios
Message:

Adding version 2.2.0

Location:
comment-rating-field-plugin/trunk
Files:
7 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • comment-rating-field-plugin/trunk/assets/css/rating.css

    r1599967 r1681345  
    11/* Form */
    22span.star-rating-control { display: inline-block; margin: 0 0 10px 0; }
    3 div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
    4 div.rating-cancel,div.rating-cancel a{background:url(../images/delete.gif) no-repeat 0 -16px}
    5 div.star-rating,div.star-rating a{background:url(../images/star.gif) no-repeat 0 0px}
     3div.rating-cancel,div.star-rating{float:left;width:17px;height:16px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}
     4div.rating-cancel,div.rating-cancel a{background:url(../images/delete.png) no-repeat 0 -16px; background-size: 16px;}
     5div.star-rating,div.star-rating a{background:url(../images/star.png) no-repeat 0 0px; background-size: 16px;}
    66div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}
    77div.star-rating-on a{background-position:0 -16px!important}
     
    1212/* Rating */
    1313div.rating { width: 80px; height: 16px; margin: 5px 0 10px 0; }
    14 div.crfp-rating { width: 80px; height: 16px; background: url(../images/star.gif) 0 -32px repeat-x; text-indent: -9999px; overflow: hidden; }
     14div.crfp-rating { width: 80px; height: 16px; background: url(../images/star.png) 0 -32px repeat-x; background-size: 16px; text-indent: -9999px; overflow: hidden; }
    1515div.crfp-rating-5 { width: 80px !important; }
    1616div.crfp-rating-4 { width: 64px !important; }
  • comment-rating-field-plugin/trunk/comment-rating-field-plugin.php

    r1607373 r1681345  
    33* Plugin Name: Comment Rating Field Plugin
    44* Plugin URI: https://www.wpzinc.com/plugins/comment-rating-field-pro-plugin
    5 * Version: 2.1.3
     5* Version: 2.2.0
    66* Author: WP Zinc
    77* Author URI: https://www.wpzinc.com
     
    5757        $this->plugin->name             = 'comment-rating-field-plugin';
    5858        $this->plugin->displayName      = 'Comment Rating Field';
    59         $this->plugin->version          = '2.1.3';
    60         $this->plugin->buildDate        = '2017-03-03 18:00:00';
     59        $this->plugin->version          = '2.2.0';
     60        $this->plugin->buildDate        = '2017-03-27 18:00:00';
    6161        $this->plugin->requires         = 3.6;
    62         $this->plugin->tested           = '4.7.2';
     62        $this->plugin->tested           = '4.7.3';
    6363        $this->plugin->folder           = plugin_dir_path( __FILE__ );
    6464        $this->plugin->url              = plugin_dir_url( __FILE__ );
     
    100100            ),
    101101            array(
    102                 __( 'Manage Reviews', $this->plugin->name),
    103                 __( 'View and edit ratings in the WordPress Admin when editing a Comment.', $this->plugin->name ),
    104             ),
    105             array(
    106102                __( 'Jetpack, WooCommerce and Simple Comment Editing Support', $this->plugin->name),
    107103                __( 'Pro is compatible with Jetpack, WooCommerce and SCE.', $this->plugin->name ),
     
    120116            ),
    121117            array(
    122                 __( 'Shortcodes', $this->plugin->name),
    123                 __( 'Use a shortcode to display the rating output anywhere within your content, for any Post ID.', $this->plugin->name ),
     118                __( 'Advanced Shortcodes', $this->plugin->name),
     119                __( 'Use advanced shortcode to display the rating output anywhere within your content, for any Post ID.', $this->plugin->name ),
    124120            ),
    125121            array(
    126122                __( 'Widgets', $this->plugin->name),
    127                 __( 'Use a shortcode to display the rating output anywhere within your content, for any Post ID.', $this->plugin->name ),
    128             ),
    129             array(
    130                 __( 'Functions', $this->plugin->name),
    131                 __( 'For developers not using comment_form() and wp_list_comments(), PHP functions are supplied to easily output average ratings, ratings on comments and rating fields within your custom implementation.', $this->plugin->name ),
     123                __( 'Display the Top Rated Posts as a Widget in your WordPress Sidebars.', $this->plugin->name ),
    132124            ),
    133125        );             
     
    143135            // Required class
    144136            require_once( $this->plugin->folder . 'includes/admin/admin.php' );
     137            require_once( $this->plugin->folder . 'includes/admin/comments.php' );
     138            require_once( $this->plugin->folder . 'includes/admin/editor.php' );
    145139        }
    146140
     
    149143        require_once( $this->plugin->folder . 'includes/global/rating-output.php' );
    150144        require_once( $this->plugin->folder . 'includes/global/settings.php' );
     145        require_once( $this->plugin->folder . 'includes/global/shortcode.php' );
    151146
    152147    }
  • comment-rating-field-plugin/trunk/includes/admin/admin.php

    r1605202 r1681345  
    4747
    4848        // Admin CSS, JS, Menu and Meta Boxes
     49        add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_css' ) );
    4950        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
     51       
     52    }
     53
     54    /**
     55     * Enqueues CSS and JS
     56     *
     57     * @since   2.2.0
     58     */
     59    public function admin_scripts_css() {
     60
     61        // Get base instance
     62        $this->base = CommentRatingFieldPlugin::get_instance();
     63
     64        // CSS
     65        wp_enqueue_style( $this->base->plugin->name . '-admin', $this->base->plugin->url . 'assets/css/admin.css', false, $this->base->plugin->version );
    5066       
    5167    }
  • comment-rating-field-plugin/trunk/includes/global/rating-input.php

    r1599967 r1681345  
    4343    public function __construct() {
    4444
    45         if ( is_admin() ) {
    46             add_action( 'wp_set_comment_status', array( $this, 'update_post_rating_by_comment_id' ) ); // Recalculate average rating on comment approval / hold / spam
    47             add_action( 'deleted_comment', array( $this, 'update_post_rating_by_comment_id' ) ); // Recalculate average rating on comment delete
    48         }
    49 
    5045        add_action( 'comment_form_logged_in_after', array( $this, 'display_rating_field' ) ); // Logged in
    5146        add_action( 'comment_form_after_fields', array( $this, 'display_rating_field' ) ); // Guest
    5247        add_action( 'comment_post', array( $this, 'save_rating' ) ); // Save Rating Field on Comment Post
     48        add_action( 'edit_comment', array( $this, 'save_rating' ) ); // Save Rating Field on editing existing comment
    5349       
    5450    }
     
    10399
    104100        // Save rating against comment
    105         add_comment_meta( $comment_id, 'crfp-rating', $_POST['crfp-rating'], true );
     101        $result = update_comment_meta( $comment_id, 'crfp-rating', $_POST['crfp-rating'] );
    106102
    107103        // Request that the user review the plugin. Notification displayed later,
     
    120116     * @since   2.1.1
    121117     *
    122      * @return  bool    Post can have rating
    123      */
    124     public function post_can_have_rating() {
     118     * @param   int     $post_id    Post ID (optional)
     119     * @return  bool                Post can have rating
     120     */
     121    public function post_can_have_rating( $post_id = '' ) {
    125122
    126123        global $post;
    127124
    128         // Reset to default loop query so we can test if a single Page or Post
    129         wp_reset_query();
     125        // Fetch Post, if an ID is specified
     126        if ( ! empty( $post_id ) ) {
     127            $post = get_post( $post_id );
     128        } else {
     129            // Reset to default loop query so we can test if a single Page or Post
     130            wp_reset_query();
     131
     132            // Bail if not a singular Post
     133            if ( ! is_singular() ) {
     134                return false;
     135            }
     136        }
    130137
    131138        // Bail if comments aren't open
    132139        if ( $post->comment_status != 'open' ) {
    133             return false;
    134         }
    135 
    136         // Bail if not a singular Post
    137         if ( ! is_singular() ) {
    138140            return false;
    139141        }
  • comment-rating-field-plugin/trunk/includes/global/rating-output.php

    r1599967 r1681345  
    4343    public function __construct() {
    4444
    45         // Don't load any actions if we're in the admin interface.
    46         if ( is_admin() ) {
    47             return;
    48         }
    49 
    50         add_action( 'wp_enqueue_scripts', array( $this, 'scripts_css' ), 10 );
    51         add_filter( 'the_content', array( $this, 'display_average_rating' ) ); // Displays Average Rating below Content
     45        add_action( 'wp_enqueue_scripts', array( $this, 'scripts_css' ), 10 );
     46        add_filter( 'the_content', array( $this, 'display_average_rating_content' ) ); // Displays Average Rating below Content
    5247        add_action( 'comment_text', array( $this, 'display_comment_rating' ) ); // Displays Rating on Comments
    5348
     
    8176     * @return  string              Post Content w/ Ratings HTML
    8277     */
    83     public function display_average_rating( $content ) {
     78    public function display_average_rating_content( $content ) {
    8479
    8580        global $post;
     
    10196        }
    10297
     98        // Build rating HTML
     99        $rating_html = $this->display_average_rating( $this->settings, $post->ID );
     100
     101        // Return rating HTML with content
     102        return $content . $rating_html;   
     103
     104    }
     105
     106    /**
     107     * Returns the HTML for the average rating
     108     *
     109     * @since   2.2.0
     110     *
     111     * @param   array   $settings   Settings
     112     * @param   int     $post_id    Post ID
     113     * @return  string              Rating Output
     114     */
     115    public function display_average_rating( $settings, $post_id ) {
     116
    103117        // Get average rating
    104         $average_rating = get_post_meta( $post->ID, 'crfp-average-rating', true );
     118        $average_rating = get_post_meta( $post_id, 'crfp-average-rating', true );
    105119
    106120        // Calculate average rating now, if one doesn't exist, and fetch the average rating again
    107121        if ( empty( $average_rating ) ) {
    108             Comment_Rating_Field_Plugin_Rating_Input::get_instance()->update_post_rating_by_post_id( $post->ID );
    109             $average_rating = get_post_meta( $post->ID, 'crfp-average-rating', true );
     122            Comment_Rating_Field_Plugin_Rating_Input::get_instance()->update_post_rating_by_post_id( $post_id );
     123            $average_rating = get_post_meta( $post_id, 'crfp-average-rating', true );
    110124        }
    111125
    112126        // If the average is still zero or empty, bail
    113127        if ( empty( $average_rating ) || $average_rating == 0 ) {
    114             return $content;
     128            return '';
    115129        }
    116130
     
    118132        $rating_html = '<div class="crfp-average-rating">' . $this->settings['averageRatingText'] . '<div class="crfp-rating crfp-rating-' . $average_rating . '"></div></div>';
    119133       
    120         // Return rating HTML with content
    121         return $content . $rating_html;   
     134        // Return rating HTML
     135        return $rating_html;   
    122136
    123     }
     137    }
    124138
    125139    /**
  • comment-rating-field-plugin/trunk/readme.txt

    r1607373 r1681345  
    6565
    6666== Changelog ==
     67
     68= 2.2.0 =
     69* Added: Edit Ratings in WordPress Admin when editing a Comment
     70* Added: Improved graphics for star rating and cancel buttons, with Retina support
     71* Added: Shortcode to output average rating for a Post
    6772
    6873= 2.1.3 =
  • comment-rating-field-plugin/trunk/views/admin/settings.php

    r1599967 r1681345  
    8686                            <div class="option">
    8787                                <div class="left">
    88                                     <strong><?php _e( 'Display Average', $this->base->plugin->name ); ?></strong>
     88                                    <strong><?php _e( 'Display Average after Content', $this->base->plugin->name ); ?></strong>
    8989                                </div>
    9090                                <div class="right">
     
    9292                               
    9393                                    <p class="description">
    94                                         <?php _e('Displays the average rating based on the average of all ratings for the given Page or Post.'); ?>
     94                                        <?php _e( 'Displays the average rating based on the average of all ratings for the given Page or Post at the end of the Page/Post content.', 'comment-rating-field-plugin' ); ?>
     95                                    </p>
     96                                    <p class="description">
     97                                        <?php _e( 'Want to control where the rating is displayed? Disable this option and use the [crfp] shortcode in your content instead.', 'comment-rating-field-plugin' ); ?>
    9598                                    </p>
    9699                                </div>
     
    105108                               
    106109                                    <p class="description">
    107                                         <?php _e('If Display Average Rating above is selected, optionally define text to appear before the average rating stars are displayed.'); ?>
     110                                        <?php _e( 'Optionally define text to appear before the average rating stars are displayed.', 'comment-rating-field-plugin' ); ?>
    108111                                    </p>
    109112                                </div>
Note: See TracChangeset for help on using the changeset viewer.