Changeset 1681345
- Timestamp:
- 06/19/2017 04:46:07 PM (9 years ago)
- Location:
- comment-rating-field-plugin/trunk
- Files:
-
- 7 added
- 2 deleted
- 7 edited
-
assets/css/admin.css (added)
-
assets/css/rating.css (modified) (2 diffs)
-
assets/images/delete.gif (deleted)
-
assets/images/delete.png (added)
-
assets/images/star.gif (deleted)
-
assets/images/star.png (added)
-
assets/js/editor_plugin.js (added)
-
comment-rating-field-plugin.php (modified) (6 diffs)
-
includes/admin/admin.php (modified) (1 diff)
-
includes/admin/comments.php (added)
-
includes/admin/editor.php (added)
-
includes/global/rating-input.php (modified) (3 diffs)
-
includes/global/rating-output.php (modified) (4 diffs)
-
includes/global/shortcode.php (added)
-
readme.txt (modified) (1 diff)
-
views/admin/settings.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
comment-rating-field-plugin/trunk/assets/css/rating.css
r1599967 r1681345 1 1 /* Form */ 2 2 span.star-rating-control { display: inline-block; margin: 0 0 10px 0; } 3 div.rating-cancel,div.star-rating{float:left;width:17px;height:1 5px;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}3 div.rating-cancel,div.star-rating{float:left;width:17px;height:16px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden} 4 div.rating-cancel,div.rating-cancel a{background:url(../images/delete.png) no-repeat 0 -16px; background-size: 16px;} 5 div.star-rating,div.star-rating a{background:url(../images/star.png) no-repeat 0 0px; background-size: 16px;} 6 6 div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0} 7 7 div.star-rating-on a{background-position:0 -16px!important} … … 12 12 /* Rating */ 13 13 div.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; }14 div.crfp-rating { width: 80px; height: 16px; background: url(../images/star.png) 0 -32px repeat-x; background-size: 16px; text-indent: -9999px; overflow: hidden; } 15 15 div.crfp-rating-5 { width: 80px !important; } 16 16 div.crfp-rating-4 { width: 64px !important; } -
comment-rating-field-plugin/trunk/comment-rating-field-plugin.php
r1607373 r1681345 3 3 * Plugin Name: Comment Rating Field Plugin 4 4 * Plugin URI: https://www.wpzinc.com/plugins/comment-rating-field-pro-plugin 5 * Version: 2. 1.35 * Version: 2.2.0 6 6 * Author: WP Zinc 7 7 * Author URI: https://www.wpzinc.com … … 57 57 $this->plugin->name = 'comment-rating-field-plugin'; 58 58 $this->plugin->displayName = 'Comment Rating Field'; 59 $this->plugin->version = '2. 1.3';60 $this->plugin->buildDate = '2017-03- 0318:00:00';59 $this->plugin->version = '2.2.0'; 60 $this->plugin->buildDate = '2017-03-27 18:00:00'; 61 61 $this->plugin->requires = 3.6; 62 $this->plugin->tested = '4.7. 2';62 $this->plugin->tested = '4.7.3'; 63 63 $this->plugin->folder = plugin_dir_path( __FILE__ ); 64 64 $this->plugin->url = plugin_dir_url( __FILE__ ); … … 100 100 ), 101 101 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(106 102 __( 'Jetpack, WooCommerce and Simple Comment Editing Support', $this->plugin->name), 107 103 __( 'Pro is compatible with Jetpack, WooCommerce and SCE.', $this->plugin->name ), … … 120 116 ), 121 117 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 ), 124 120 ), 125 121 array( 126 122 __( '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 ), 132 124 ), 133 125 ); … … 143 135 // Required class 144 136 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' ); 145 139 } 146 140 … … 149 143 require_once( $this->plugin->folder . 'includes/global/rating-output.php' ); 150 144 require_once( $this->plugin->folder . 'includes/global/settings.php' ); 145 require_once( $this->plugin->folder . 'includes/global/shortcode.php' ); 151 146 152 147 } -
comment-rating-field-plugin/trunk/includes/admin/admin.php
r1605202 r1681345 47 47 48 48 // Admin CSS, JS, Menu and Meta Boxes 49 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts_css' ) ); 49 50 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 ); 50 66 51 67 } -
comment-rating-field-plugin/trunk/includes/global/rating-input.php
r1599967 r1681345 43 43 public function __construct() { 44 44 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 / spam47 add_action( 'deleted_comment', array( $this, 'update_post_rating_by_comment_id' ) ); // Recalculate average rating on comment delete48 }49 50 45 add_action( 'comment_form_logged_in_after', array( $this, 'display_rating_field' ) ); // Logged in 51 46 add_action( 'comment_form_after_fields', array( $this, 'display_rating_field' ) ); // Guest 52 47 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 53 49 54 50 } … … 103 99 104 100 // 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'] ); 106 102 107 103 // Request that the user review the plugin. Notification displayed later, … … 120 116 * @since 2.1.1 121 117 * 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 = '' ) { 125 122 126 123 global $post; 127 124 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 } 130 137 131 138 // Bail if comments aren't open 132 139 if ( $post->comment_status != 'open' ) { 133 return false;134 }135 136 // Bail if not a singular Post137 if ( ! is_singular() ) {138 140 return false; 139 141 } -
comment-rating-field-plugin/trunk/includes/global/rating-output.php
r1599967 r1681345 43 43 public function __construct() { 44 44 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 52 47 add_action( 'comment_text', array( $this, 'display_comment_rating' ) ); // Displays Rating on Comments 53 48 … … 81 76 * @return string Post Content w/ Ratings HTML 82 77 */ 83 public function display_average_rating ( $content ) {78 public function display_average_rating_content( $content ) { 84 79 85 80 global $post; … … 101 96 } 102 97 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 103 117 // 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 ); 105 119 106 120 // Calculate average rating now, if one doesn't exist, and fetch the average rating again 107 121 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 ); 110 124 } 111 125 112 126 // If the average is still zero or empty, bail 113 127 if ( empty( $average_rating ) || $average_rating == 0 ) { 114 return $content;128 return ''; 115 129 } 116 130 … … 118 132 $rating_html = '<div class="crfp-average-rating">' . $this->settings['averageRatingText'] . '<div class="crfp-rating crfp-rating-' . $average_rating . '"></div></div>'; 119 133 120 // Return rating HTML with content121 return $ content . $rating_html;134 // Return rating HTML 135 return $rating_html; 122 136 123 }137 } 124 138 125 139 /** -
comment-rating-field-plugin/trunk/readme.txt
r1607373 r1681345 65 65 66 66 == 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 67 72 68 73 = 2.1.3 = -
comment-rating-field-plugin/trunk/views/admin/settings.php
r1599967 r1681345 86 86 <div class="option"> 87 87 <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> 89 89 </div> 90 90 <div class="right"> … … 92 92 93 93 <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' ); ?> 95 98 </p> 96 99 </div> … … 105 108 106 109 <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' ); ?> 108 111 </p> 109 112 </div>
Note: See TracChangeset
for help on using the changeset viewer.