LearnPress – Course Review - Version 0.9.1

Version Description

  • Updated languages file
  • Fixed PHP5 version 5.3.x error
Download this release

Release Info

Developer tunnhn
Plugin Icon 128x128 LearnPress – Course Review
Version 0.9.1
Comparing to
See all releases

Version 0.9.1

assets/course-review.css ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ #review-overlay {
3
+ background-color: rgba(0,0,0,.25);
4
+ bottom: 0;
5
+ display: flex;
6
+ justify-content: center;
7
+ left: 0;
8
+ position: fixed;
9
+ top: 0;
10
+ width: 100%;
11
+ }
12
+
13
+ #review-overlay > .review-wrapper {
14
+ align-self: center;
15
+ background-color: rgba(0,0,0,.25);
16
+ border-radius: 2px;
17
+ padding: 6px;
18
+ width: 450px;
19
+ }
20
+
21
+ #review-overlay .review-content {
22
+ background-color: rgb(255,255,255);
23
+ border-radius: 2px;
24
+ padding: 24px;
25
+ position: relative;
26
+ }
27
+
28
+ #review{
29
+ position: fixed;
30
+ z-index: 99999;
31
+ display: none;
32
+ align-self: center;
33
+ background-color: rgba(0,0,0,.25);
34
+ border-radius: 2px;
35
+ padding: 6px;
36
+ width: 500px;
37
+ top: 50px;
38
+ left: 50%;
39
+ margin-left: -250px;
40
+ }
41
+ #review .review-content {
42
+ background-color: rgb(255,255,255);
43
+ border-radius: 2px;
44
+ padding: 24px;
45
+ position: relative;
46
+ }
47
+ #review h3{
48
+ font-size: 16px;
49
+ margin: 0 0 20px;
50
+ }
51
+ #review h3 .close{
52
+ float: right;
53
+ border: none;
54
+ text-decoration: none;
55
+ width: auto;
56
+ height: auto;
57
+ margin-right: -9px;
58
+ margin-top: -7px;
59
+ }
60
+ #review h3 .close:before{font-size: 32px;}
61
+ #review .review-fields{
62
+ margin: 0 0 -20px;
63
+ list-style: none;
64
+ }
65
+ #review .review-fields > li{
66
+ margin: 0 0 20px 0;
67
+ }
68
+ #review .review-fields > li > label{
69
+ display: block;
70
+ margin: 0 0 7px;
71
+ font-size: 15px;
72
+ }
73
+ #review .review-fields > li > label .required{
74
+ margin-left: 5px;
75
+ display: inline-block;
76
+ vertical-align: middle;
77
+ font-size: 24px;
78
+ line-height: 1;
79
+ height: 15px;
80
+ margin-top: -3px;
81
+ }
82
+ .review-stars{
83
+ margin: 0 0;
84
+ list-style: none;
85
+ }
86
+ .review-stars:after{
87
+ clear: both;
88
+ content: '';
89
+ display: block;
90
+ }
91
+ .review-stars > li{
92
+ width: 40px;
93
+ height: 40px;
94
+ float: left;
95
+ }
96
+ .review-stars > li span{
97
+ text-decoration: none;
98
+ font-size: 40px;
99
+ border-bottom: none;
100
+ width: auto;
101
+ height: auto;
102
+ }
103
+ .review-stars > li a:visited,
104
+ .review-stars > li a:focus{
105
+ border: none;
106
+ }
107
+ .review-stars > li span:before{
108
+ width: 40px;
109
+ height: 40px;
110
+ }
111
+ .review-stars > li span.hover:before{
112
+ content: "\f155";
113
+ color: #F05A19;
114
+ cursor: pointer;
115
+ }
116
+ #review .review-actions{
117
+ text-align: right;
118
+ padding-top: 20px;
119
+ border-top: 1px solid #F0F0F0;
120
+ }
121
+
122
+ #review .submitting{
123
+ display: none;
124
+ }
125
+ #review .review-stars{
126
+ cursor: pointer;
127
+ }
128
+
129
+ .review-stars-rated{
130
+ display: inline-block;
131
+ position: relative;
132
+ }
133
+ .review-stars-rated .review-stars{
134
+ display: inline-block;
135
+ }
136
+ .review-stars-rated .review-stars.filled{
137
+ position: absolute;
138
+ top: 0;
139
+ left: 0;
140
+ z-index: 10;
141
+ white-space: nowrap;
142
+ overflow: hidden;
143
+ color: #F05A19;
144
+ height: 40px;
145
+ }
146
+ .review-stars.filled > li{
147
+ position: absolute;
148
+ }
149
+ .review-stars.filled > li:nth-child(2){
150
+ left: 40px;
151
+ }
152
+ .review-stars.filled > li:nth-child(3){
153
+ left: 80px;
154
+ }
155
+ .review-stars.filled > li:nth-child(4){
156
+ left: 120px;
157
+ }
158
+ .review-stars.filled > li:nth-child(5){
159
+ left: 160px;
160
+ }
161
+ #course-reviews .loading{
162
+ display: none;
163
+ }
assets/course-review.js ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Created by foobla on 4/10/2015.
3
+ */
4
+
5
+ jQuery(document).ready(function ($){
6
+ var $review = $('#review');
7
+ function close_form(){
8
+ $(document.body).unblock_ui();
9
+ $review.fadeOut('fast');
10
+ $(document.body).unbind('click.close_review_form')
11
+ $(window).unbind('scroll.review-position');
12
+ }
13
+ $(".write-a-review").click(function( event ){
14
+ event.preventDefault();
15
+ $(document.body).block_ui({
16
+ backgroundColor: '#000',
17
+ opacity: 0.5,
18
+ position: 'fixed'
19
+ });
20
+ $('input, textarea', $review).val('');
21
+ stars.removeClass('hover')
22
+ $review
23
+ .removeData('selected')
24
+ .css({
25
+ top: $(window).scrollTop() + 50,
26
+ marginTop: -$(window).scrollTop()
27
+ })
28
+ .fadeIn("fast", function(){
29
+ $('input:first', $review).focus();
30
+ });
31
+ $(window).on('scroll.review-position', function(){
32
+ $review.css({
33
+ marginTop: -$(window).scrollTop()
34
+ })
35
+ });
36
+ $(document.body).on('click.close_review_form', ">.block-ui", close_form)
37
+ });
38
+
39
+ $(".close", $review).click(function(evt){
40
+ evt.preventDefault();
41
+ close_form();
42
+ });
43
+
44
+ $('.cancel', $review).click(close_form);
45
+
46
+ $(document).keyup(function(e) {
47
+ if( e.keyCode == 27 && $review.is(':visible') ) {
48
+ event.preventDefault();
49
+ close_form();
50
+ }
51
+ });
52
+
53
+ $('.review-title', $review).tipsy({gravity: 's'});
54
+ var stars = $('.review-fields ul > li span', $review).each(function(i){
55
+ $(this).hover(function(){
56
+ stars.map(function(j){ j <= i ? $(this).addClass('hover') : $(this).removeClass('hover');})
57
+ }, function(){
58
+ var selected = $review.data('selected');
59
+ stars.map(function(j){ j <= selected ? $(this).addClass('hover') : $(this).removeClass('hover');})
60
+ }).click(function(e){
61
+ e.preventDefault();
62
+ $review.data('selected', i)
63
+ });
64
+ })
65
+
66
+ $(document).on('click', '#course-review-load-more', function(){
67
+ var $button = $(this);
68
+ if( ! $button.is(':visible') ) return;
69
+ $button.hide();
70
+ var paged = parseInt($(this).attr('data-paged')) + 1;
71
+ $('#course-reviews .loading').show();
72
+ $.ajax({
73
+ type: "POST",
74
+ dataType: 'html',
75
+ url: window.location.href,
76
+ data: {
77
+ action: 'learn_press_load_course_review',
78
+ paged: paged
79
+ },
80
+ success: function (response) {
81
+ var $content = $(response),
82
+ $loading = $('#course-reviews .loading').hide();
83
+ $content.find( '.course-reviews-list > li:not(.loading)').insertBefore( $loading );
84
+ if( $content.find( '#course-review-load-more').length ) {
85
+ $button.show().attr('data-paged', paged);
86
+ }else{
87
+ $button.remove();
88
+ }
89
+ }
90
+ });
91
+ });
92
+ $('.submit-review').click(function (event){
93
+ event.preventDefault();
94
+
95
+ var $review_title = $('input[name="review-title"]');
96
+ var $review_content = $('textarea[name="review-content"]');
97
+ var review_rate = $review.data('selected');
98
+ var course_id = $(this).attr('data-id');
99
+
100
+ if( 0 == $review_title.val().length ){
101
+ alert('Please enter the review title')
102
+ $review_title.focus();
103
+ return;
104
+ }
105
+
106
+ if( 0 == $review_content.val().length ){
107
+ alert('Please enter the review content')
108
+ $review_content.focus();
109
+ return;
110
+ }
111
+
112
+ if( review_rate == undefined ){
113
+ alert('Please select your rating')
114
+ return;
115
+ }
116
+ $review.block_ui();
117
+ $('.submitting', $review).show();
118
+ $.ajax({
119
+ type : "POST",
120
+ dataType: 'html',
121
+ url : ajaxurl,
122
+ data : {
123
+ action : 'learn_press_add_course_review',
124
+ review_rate : parseInt( review_rate ) + 1,
125
+ review_title : $review_title.val(),
126
+ review_content : $review_content.val(),
127
+ course_id : course_id
128
+ },
129
+ success: function (html) {
130
+ $('.course-rate').replaceWith($(html))
131
+ $('.submitting', $review).hide();
132
+ $(".close", $review).trigger('click');
133
+ $('button.write-a-review').remove();
134
+ }
135
+ })
136
+ })
137
+ })
assets/images/star-rating-sprite.png ADDED
Binary file
init.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: foobla
5
+ * Date: 4/7/2015
6
+ * Time: 4:38 PM
7
+ */
8
+
9
+ if ( !defined( 'ABSPATH' ) ) {
10
+ exit; // Exit if accessed directly
11
+ }
12
+ define( 'COURSE_REVIEWS_PER_PAGE', 5 );
13
+ define( 'COURSE_REVIEW_TMPL', LPR_COURSE_REVIEW_PATH . '/template/' );
14
+ define( 'COURSE_REVIEW_THEME_TMPL', learn_press_template_path() . '/addons/course-review/' );
15
+ /**
16
+ * @param int $course_id
17
+ * @param int $paged
18
+ * @param int $per_page
19
+ * @return mixed|void
20
+ */
21
+ function learn_press_get_course_review( $course_id, $paged = 1, $per_page = COURSE_REVIEWS_PER_PAGE ) {
22
+
23
+ if( empty( $GLOBALS['course_reviews'] ) ) $GLOBALS['course_reviews'] = array();
24
+
25
+ if( ! empty( $GLOBALS['course_reviews'][ $course_id ] ) ) return $GLOBALS['course_reviews'][ $course_id ];
26
+ global $wpdb;
27
+ $per_page = apply_filters( 'learn_press_course_reviews_per_page', $per_page );
28
+ $start = ( $paged - 1 ) * $per_page;
29
+ $start = max( $start, 0 );
30
+ $per_page = max( $per_page, 1 );
31
+
32
+ $results = array(
33
+ 'reviews' => array(),
34
+ 'paged' => $paged,
35
+ 'total' => 0,
36
+ 'per_page' => $per_page
37
+ );
38
+
39
+ $query = $wpdb->prepare("
40
+ SELECT SQL_CALC_FOUND_ROWS u.*, cm1.meta_value as title, c.comment_content as content, cm2.meta_value as rate
41
+ FROM {$wpdb->posts} p
42
+ INNER JOIN {$wpdb->comments} c ON p.ID = c.comment_post_ID
43
+ INNER JOIN {$wpdb->users} u ON u.ID = c.user_id
44
+ INNER JOIN {$wpdb->commentmeta} cm1 ON cm1.comment_id = c.comment_ID AND cm1.meta_key=%s
45
+ INNER JOIN {$wpdb->commentmeta} cm2 ON cm2.comment_id = c.comment_ID AND cm2.meta_key=%s
46
+ WHERE p.ID=%d AND c.comment_type=%s
47
+ ORDER BY c.comment_date DESC
48
+ LIMIT %d, %d
49
+ ", '_lpr_review_title', '_lpr_rating', $course_id, 'review', $start, $per_page );
50
+ $course_review = $wpdb->get_results( $query );
51
+ if( $course_review ) {
52
+ $results['reviews'] = $course_review;
53
+ $results['total'] = $wpdb->get_var( "SELECT FOUND_ROWS();");
54
+ if( $results['total'] <= $start + $per_page ){
55
+ $results['finish'] = true;
56
+ }
57
+ }
58
+ $GLOBALS['course_reviews'][ $course_id ] = apply_filters( 'learn_press_get_course_review', $results );
59
+ return $GLOBALS['course_reviews'][ $course_id ];
60
+ }
61
+
62
+ /**
63
+ * @param $course_id
64
+ *
65
+ * @return mixed|void
66
+ */
67
+ function learn_press_get_course_rate( $course_id ) {
68
+ global $wpdb;
69
+ $query = $wpdb->prepare("
70
+ SELECT avg( cm1.meta_value ) as rated
71
+ FROM {$wpdb->posts} p
72
+ INNER JOIN {$wpdb->comments} c ON p.ID = c.comment_post_ID
73
+ INNER JOIN {$wpdb->commentmeta} cm1 ON cm1.comment_id = c.comment_ID AND cm1.meta_key='_lpr_rating'
74
+ WHERE p.ID=%d
75
+ AND c.comment_type=%s
76
+ ", $course_id, 'review');
77
+
78
+ $rated = $wpdb->get_var( $query );
79
+ return apply_filters( 'learn_press_get_course_rate', $rated );
80
+ }
81
+
82
+ function learn_press_get_course_rate_total( $course_id ) {
83
+
84
+ $course_review = learn_press_get_course_review( $course_id );
85
+
86
+ return $course_review['total'];
87
+
88
+ $course_review = get_post_meta( $course_id, '_lpr_course_review', true );
89
+ $total = 0;
90
+ $rate = 0;
91
+ if( $course_review ) {
92
+ for( $i = 1; $i<6; $i++ ) {
93
+ $total += $course_review['rate_value'][$i];
94
+ }
95
+ }
96
+ return apply_filters( 'learn_press_get_course_rate', $total );
97
+ }
98
+
99
+ /**
100
+ * @param $course_id
101
+ * @param $user_id
102
+ *
103
+ * @return mixed|void
104
+ */
105
+ function learn_press_get_user_review_title( $course_id, $user_id ) {
106
+ $course_review = get_post_meta( $course_id, '_lpr_course_review', true );
107
+ if( $course_review && array_key_exists($user_id, $course_review['review_title'])) {
108
+ return apply_filters( 'learn_press_get_user_review', $course_review['review_title'][$user_id] );
109
+ }
110
+ return false;
111
+ }
112
+
113
+ /**
114
+ * @param $course_id
115
+ * @param $user_id
116
+ *
117
+ * @return mixed|void
118
+ */
119
+ function learn_press_get_user_rate( $course_id = null, $user_id = null ){
120
+ $course_id = learn_press_get_course_id( $course_id );
121
+ if( ! $user_id ) $user_id = get_current_user_id();
122
+ if( ! $course_id || ! $user_id ) return false;
123
+
124
+ $comment = false;
125
+ global $wpdb;
126
+ $query = $wpdb->prepare("
127
+ SELECT *
128
+ FROM {$wpdb->posts} p
129
+ INNER JOIN {$wpdb->comments} c ON c.comment_post_ID = p.ID
130
+ WHERE c.comment_post_ID = %d AND user_id = %d
131
+ ", $course_id, $user_id);
132
+ $comments = $wpdb->get_results( $query );
133
+ if( $comments ){
134
+ $comment = $comments[0];
135
+ $comment->comment_title = get_comment_meta( $comment->comment_ID, '_lpr_review_title', true );
136
+ $comment->rating = get_comment_meta( $comment->comment_ID, '_lpr_rating', true );
137
+ }
138
+ return $comment;
139
+ }
140
+
141
+ /**
142
+ * @param int $course_id
143
+ * @param int $review_rate
144
+ * @param string $review_title
145
+ * @param string $review_content
146
+ */
147
+ function learn_press_save_course_review( $course_id, $review_rate, $review_title, $review_content) {
148
+ $user = wp_get_current_user();
149
+ $course_review = get_post_meta( $course_id, '_lpr_course_review', true );
150
+ if( !isset($course_review) || !is_array($course_review) ) {
151
+ $course_review = array();
152
+ $course_review['rate_value'] = array( 0, 0, 0, 0, 0, 0, 0 );
153
+
154
+ $course_review['user'] = array();
155
+ $course_review['rate'] = array();
156
+ $course_review['review_title'] = array();
157
+ $course_review['review_content'] = array();
158
+ }
159
+ $comment_id = wp_new_comment(
160
+ array(
161
+ 'comment_post_ID' => $course_id,
162
+ 'comment_author' => 'LearnPress',
163
+ 'comment_author_email' => $user->user_email,
164
+ 'comment_author_url' => '',
165
+ 'comment_content' => $review_content,
166
+ 'comment_type' => '',
167
+ 'comment_parent' => 0,
168
+ 'user_id' => $user->ID,
169
+ 'comment_approved' => 1,
170
+ 'comment_type' => 'review' // let filter to not display it as comments
171
+ )
172
+ );
173
+ if( $comment_id ){
174
+ add_comment_meta( $comment_id, '_lpr_rating', $review_rate );
175
+ add_comment_meta( $comment_id, '_lpr_review_title', $review_title );
176
+ }
177
+
178
+ return $comment_id;
179
+ $course_review['rate_value'][$review_rate]++;
180
+ array_push($course_review['user'], $user_id);
181
+ $course_review['rate'][$user_id] = $review_rate;
182
+ $course_review['review_title'][$user_id] = $review_title;
183
+ $course_review['review_content'][$user_id] = $review_content;
184
+ update_post_meta( $course_id, '_lpr_course_review', $course_review );
185
+ }
186
+
187
+ function learn_press_course_review_template( $name, $args = null ){
188
+ learn_press_get_template( $name, $args, COURSE_REVIEW_THEME_TMPL, COURSE_REVIEW_TMPL );
189
+ }
190
+ function learn_press_add_course_review() {
191
+ $user_id = get_current_user_id();
192
+ $course_id = $_POST['course_id'];
193
+ $user_review = learn_press_get_user_rate( $course_id, $user_id );//learn_press_get_user_review_title( $course_id, $user_id );
194
+ if( ! $user_review ) {
195
+ $review_title = $_POST['review_title'];
196
+ $review_content = $_POST['review_content'];
197
+ $review_rate = $_POST['review_rate'];
198
+ learn_press_save_course_review( $course_id, $review_rate, $review_title, $review_content );
199
+ }
200
+ global $post;
201
+ $post = get_post( $course_id );
202
+ setup_postdata($post);
203
+ //learn_press_get_template('course-rate.php', null, LPR_COURSE_REVIEW_PATH . '/template' );
204
+ learn_press_course_review_template( 'course-rate.php' );
205
+ die();
206
+ }
207
+ add_action( 'wp_ajax_learn_press_add_course_review', 'learn_press_add_course_review' );
208
+
209
+ /**
210
+ * Print rate for course
211
+ */
212
+ function learn_press_print_rate( ) {
213
+ learn_press_course_review_template( 'course-rate.php' );
214
+ }
215
+ add_action('learn_press_after_the_title', 'learn_press_print_rate', 10 , 1);
216
+
217
+
218
+ function learn_press_print_review() {
219
+ //learn_press_get_template('addons/course-review/course-review.php');
220
+ learn_press_course_review_template( 'course-review.php' );
221
+ }
222
+ add_action( 'learn_press_course_landing_content', 'learn_press_print_review', 80 );
223
+
224
+ function learn_press_add_review_button( ) {
225
+ if( ! learn_press_get_user_rate() ) {
226
+ ///learn_press_get_template('addons/course-review/add-review.php');
227
+ learn_press_course_review_template( 'add-review.php' );
228
+ }
229
+ }
230
+ add_action('learn_press_course_learning_content', 'learn_press_add_review_button', 5);
231
+
232
+ function learn_press_review_assets(){
233
+ wp_enqueue_script( 'block-ui', LPR_PLUGIN_URL . '/assets/js/jquery.block-ui.js', array('jquery'), '', true );
234
+ wp_enqueue_script( 'lpr-print-rate-js', untrailingslashit(plugins_url('/', __FILE__)) . '/assets/course-review.js', array('jquery'), '', true );
235
+ wp_enqueue_style( 'lpr-print-rate-css', untrailingslashit(plugins_url('/', __FILE__)) . '/assets/course-review.css' );
236
+ wp_enqueue_style( 'dashicons' );
237
+ }
238
+ add_action( 'wp_enqueue_scripts', 'learn_press_review_assets' );
239
+
240
+ function learn_press_course_review_init(){
241
+ $paged = ! empty( $_REQUEST['paged'] ) ? intval( $_REQUEST['paged'] ) : 1;
242
+ learn_press_get_course_review( get_the_ID(), $paged );
243
+ }
244
+ add_action( 'wp', 'learn_press_course_review_init' );
245
+
246
+ function learn_press_exclude_rating( $query ){
247
+ $query->query_vars['type__not_in'] = 'review';
248
+ }
249
+ add_action( 'parse_comment_query', 'learn_press_exclude_rating' );
lang/default.pot ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2015-08-01 16:04+0700\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: template/add-review.php:2
21
+ msgid "Write a Review"
22
+ msgstr ""
23
+
24
+ #: template/add-review.php:6
25
+ msgid "Write a review"
26
+ msgstr ""
27
+
28
+ #: template/add-review.php:12
29
+ msgid "Title"
30
+ msgstr ""
31
+
32
+ #: template/add-review.php:16
33
+ msgid "Content"
34
+ msgstr ""
35
+
36
+ #: template/add-review.php:20
37
+ msgid "Rating"
38
+ msgstr ""
39
+
40
+ #: template/add-review.php:29
41
+ msgid "Please wait..."
42
+ msgstr ""
43
+
44
+ #: template/add-review.php:30
45
+ msgid "Add review"
46
+ msgstr ""
47
+
48
+ #: template/add-review.php:31
49
+ msgid "Cancel"
50
+ msgstr ""
51
+
52
+ #: template/course-review.php:13
53
+ msgid "Reviews"
54
+ msgstr ""
55
+
56
+ #: template/course-review.php:14
57
+ #, php-format
58
+ msgid "Average rate: <span>%.1f</span>"
59
+ msgstr ""
60
+
61
+ #: template/course-review.php:22
62
+ msgid "Loading..."
63
+ msgstr ""
64
+
65
+ #: template/course-review.php:25
66
+ msgid "No review to load"
67
+ msgstr ""
68
+
69
+ #: template/course-review.php:28
70
+ msgid "Load More"
71
+ msgstr ""
lang/default.temp ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2015-07-25 11:42+0700\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: template/add-review.php:2
21
+ msgid "Write a Review"
22
+ msgstr ""
23
+
24
+ #: template/add-review.php:6
25
+ msgid "Write a review"
26
+ msgstr ""
27
+
28
+ #: template/add-review.php:12
29
+ msgid "Title"
30
+ msgstr ""
31
+
32
+ #: template/add-review.php:16
33
+ msgid "Content"
34
+ msgstr ""
35
+
36
+ #: template/add-review.php:20
37
+ msgid "Rating"
38
+ msgstr ""
39
+
40
+ #: template/add-review.php:29
41
+ msgid "Please wait..."
42
+ msgstr ""
43
+
44
+ #: template/add-review.php:30
45
+ msgid "Add review"
46
+ msgstr ""
47
+
48
+ #: template/add-review.php:31
49
+ msgid "Cancel"
50
+ msgstr ""
51
+
52
+ #: template/course-review.php:13
53
+ msgid "Reviews"
54
+ msgstr ""
55
+
56
+ #: template/course-review.php:14
57
+ #, php-format
58
+ msgid "Average rate: <span>%.1f</span>"
59
+ msgstr ""
60
+
61
+ #: template/course-review.php:22
62
+ msgid "Loading..."
63
+ msgstr ""
64
+
65
+ #: template/course-review.php:25
66
+ msgid "No review to load"
67
+ msgstr ""
68
+
69
+ #: template/course-review.php:28
70
+ msgid "Load More"
71
+ msgstr ""
learnpress-course-review.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: LearnPress Course Review
4
+ Plugin URI: http://thimpress.com/learnpress
5
+ Description: Adding review for course
6
+ Author: thimpress
7
+ Version: 0.9.1
8
+ Author URI: http://thimpress.com
9
+ Tags: learnpress
10
+ */
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
+
15
+ define( 'LPR_COURSE_REVIEW_PATH', dirname( __FILE__ ) );
16
+
17
+ /**
18
+ * Register course-review course addon
19
+ */
20
+ function learn_press_register_course_review() {
21
+ require_once( LPR_COURSE_REVIEW_PATH . '/init.php' );
22
+ }
23
+ add_action( 'learn_press_register_add_ons', 'learn_press_register_course_review' );
24
+
25
+ add_action('plugins_loaded','learnpress_course_review_translations');
26
+ function learnpress_course_review_translations(){
27
+ $textdomain = 'learnpress_course_review';
28
+ $locale = apply_filters("plugin_locale", get_locale(), $textdomain);
29
+ $lang_dir = dirname( __FILE__ ) . '/lang/';
30
+ $mofile = sprintf( '%s.mo', $locale );
31
+ $mofile_local = $lang_dir . $mofile;
32
+ $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
33
+ if ( file_exists( $mofile_global ) ) {
34
+ load_textdomain( $textdomain, $mofile_global );
35
+ } else {
36
+ load_textdomain( $textdomain, $mofile_local );
37
+ }
38
+ }
readme.txt ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === LearnPress Course Review - WordPress extension for LearnPress===
2
+ Contributors: thimpress, halink0803, tunnhn
3
+ Donate link:
4
+ Tags: lms, elearning, e-learning, learning management system, education, course, courses, quiz, quizzes, questions, training, guru, sell courses
5
+ Requires at least: 3.8
6
+ Tested up to: 4.2.2
7
+ Stable tag: 0.9.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ LearnPress Course Review - An extension plugin for LearnPress.
12
+
13
+ == Description ==
14
+
15
+ **LearnPress** is a <a href="http://thimpress.com/learnpress">WordPress LMS Plugin</a> by ThimPress.
16
+
17
+ LearnPress Course Review bring review feature to your course. Now, student can rate and give review for the course they take on a LearnPress site.
18
+
19
+ Review add-on for LearnPress is using on some WordPress Themes: [Education WordPress Theme](http://themeforest.net/item/education-wordpress-theme-education-wp/14058034?utm_source=wporg&utm_medium=course-review&ref=thimpress&utm_campaign=learnpress "Education WordPress Theme") and [LMS WordPress Theme](http://themeforest.net/item/lms-wordpress-theme-elearning-wp/11797847??utm_source=wporg&utm_medium=course-review&ref=thimpress&utm_campaign=learnpress "LMS WordPress Theme"), more is coming.
20
+
21
+ **Other free add-ons for LearnPress are available in WordPress:**
22
+
23
+ - <a href="https://wordpress.org/plugins/learnpress-wishlist/" target="_blank">LearnPress Wishlist</a> - add courses to a wishlist for students.
24
+ - <a href="https://wordpress.org/plugins/learnpress-course-review/" target="_blank">LearnPress Course Review</a> - review course for enrolled students.
25
+ - <a href="https://wordpress.org/plugins/learnpress-import-export/" target="_blank">LearnPress Import Export</a> - export or import course or courses out-of-box.
26
+ - <a href="https://wordpress.org/plugins/learnpress-prerequisites-courses/" target="_blank">LearnPress Prerequisites Courses</a> - require student to pass some courses in order to enroll other course.
27
+ - <a href="https://wordpress.org/plugins/learnpress-bbpress" target="_blank">LearnPress bbPress</a> - add bbPress Forum support for LearnPress.
28
+ - <a href="https://wordpress.org/plugins/learnpress-buddypress" target="_blank">LearnPress BuddyPress</a> - add BuddyPress support for LearnPress.
29
+
30
+ **Premium Plugins (add-ons) for LearnPress WordPress LMS Plugin**
31
+
32
+ - <a href="http://thimpress.com/shop/certificates-add-on-for-learnpress/" target="_blank">Certificates add-on for LearnPress</a> - adding drag & drop certificates builder as well as selecting designed certificate for each LMS course, your student will get particular certificate when they finished a course.
33
+ - <a href="http://thimpress.com/shop/co-instructors-add-on-for-learnpress/" target="_blank">Co-instructors add-on for LearnPress</a> - multiple instructors support for each LMS course.
34
+ - <a href="http://thimpress.com/shop/collections-add-on-for-learnpress/" target="_blank">Collections add-on for LearnPress</a> - making LMS courses collection by selecting number of courses, this is helpful if you want to combine multiple LMS courses into a collection for a group of skills.
35
+ - <a href="http://thimpress.com/shop/stripe-add-on-for-learnpress/" target="_blank">Stripe Payment method for LearnPress</a> - Stripe payment method for LearnPress WordPress LMS Plugin.
36
+ - <a href="http://thimpress.com/shop/woocommerce-add-on-for-learnpress/" target="_blank">WooCommerce add-on for LearnPress</a> - using WooCommerce as payment gateway for LearnPrss WordPress LMS Plugin.
37
+
38
+ == Installation ==
39
+
40
+ **From your WordPress dashboard**
41
+ 1. Visit 'Plugin > Add new'.
42
+ 2. Search for 'LearnPress Course Review'.
43
+ 3. Activate LearnPress from your Plugins page.
44
+
45
+ **From WordPress.org**
46
+ 1. Search, select and download LearnPress Course Review.
47
+ 2. Activate the plugin through the 'Plugins' menu in WordPress Dashboard.
48
+
49
+ == Frequently Asked Questions ==
50
+
51
+ Check out <a href="http://docs.thimpress.com/learnpress" target="_blank">LearnPress</a> sites.
52
+
53
+ == Screenshots ==
54
+
55
+ 1. LearnPress Course Review screenshot.
56
+
57
+ == Changelog ==
58
+
59
+ = 0.9.1 =
60
+ - Updated languages file
61
+ - Fixed PHP5 version 5.3.x error
62
+
63
+ = 0.9.0 =
64
+ - The first beta release.
65
+
66
+ == Upgrade Notice ==
67
+ Later :)
68
+
69
+ == Other note ==
70
+ <a href="http://docs.thimpress.com/learnpress" target="_blank">Documentation</a> is available in ThimPress site.
71
+ <a href="https://github.com/LearnPress/LearnPress/" target="_blank">LearnPress github repo.</a>
template/add-review.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php learn_press_prevent_access_directly(); ?>
2
+ <button class="write-a-review"><?php _e( 'Write a Review', 'learnpress_course_review' );?></button>
3
+ <div class="review-wrapper" id="review">
4
+ <div class="review-content" id="reviewTarget">
5
+ <h3>
6
+ <?php _e( 'Write a review', 'learnpress_course_review' );?>
7
+ <a href="" class="close dashicons dashicons-no-alt"></a>
8
+ </h3>
9
+ <ul class="review-fields">
10
+ <?php do_action( 'learn_press_before_review_fields' );?>
11
+ <li>
12
+ <label><?php _e( 'Title', 'learnpress_course_review' );?> <span class="required">*</span></label>
13
+ <input type="text" name="review-title" />
14
+ </li>
15
+ <li>
16
+ <label><?php _e( 'Content', 'learnpress_course_review' );?><span class="required">*</span></label>
17
+ <textarea name="review-content"></textarea>
18
+ </li>
19
+ <li>
20
+ <label><?php _e( 'Rating', 'learnpress_course_review' );?><span class="required">*</span></label>
21
+ <ul class="review-stars">
22
+ <?php for( $i = 1; $i <= 5; $i ++ ){?>
23
+ <li class="review-title" title="<?php echo $i;?>"><span class="dashicons dashicons-star-empty"></span> </li>
24
+ <?php }?>
25
+ </ul>
26
+ </li>
27
+ <?php do_action( 'learn_press_after_review_fields' );?>
28
+ <li class="review-actions">
29
+ <span class="submitting"><?php _e( 'Please wait...', 'learnpress_course_review' );?></span>
30
+ <button type="button" class="submit-review" data-id="<?php the_ID();?>"><?php _e( 'Add review', 'learnpress_course_review' );?></button>
31
+ <button type="button" class="cancel"><?php _e( 'Cancel', 'learnpress_course_review' );?></button>
32
+ </li>
33
+ </ul>
34
+ </div>
35
+ </div>
template/course-rate.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ $course_id = get_the_ID();
7
+ $course_rate = learn_press_get_course_rate( $course_id );
8
+ $total = learn_press_get_course_rate_total( $course_id );
9
+ ?>
10
+ <div class="course-rate">
11
+ <?php
12
+ learn_press_course_review_template( 'rating-stars.php', array( 'rated' => $course_rate ) );
13
+ $text=' ratings';
14
+ if( $total <= 1 ) $text = ' rating';
15
+ ?>
16
+ <p class="review-number">
17
+ <?php do_action( 'learn_press_before_total_review_number' );?>
18
+ <?php echo $total . $text ; ?>
19
+ <?php do_action( 'learn_press_after_total_review_number' );?>
20
+ </p>
21
+ </div>
template/course-review.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+ $course_id = get_the_ID();
7
+ $course_review = learn_press_get_course_review( $course_id );
8
+ if( $course_review['total'] ) {
9
+ $course_rate = learn_press_get_course_rate( $course_id );
10
+ $reviews = $course_review['reviews'];
11
+ ?>
12
+ <div id="course-reviews">
13
+ <h3 class="course-review-head"><?php _e( 'Reviews', 'learnpress_course_review' );?></h3>
14
+ <p class="course-average-rate"><?php printf( __( 'Average rate: <span>%.1f</span>', 'learnpress_course_review' ), $course_rate );?></p>
15
+ <ul class="course-reviews-list">
16
+ <?php foreach( $reviews as $review ) {?>
17
+ <?php
18
+ learn_press_course_review_template( 'loop-review.php', array( 'review' => $review ) );
19
+ ?>
20
+ <?php } ?>
21
+ <?php if( empty( $course_review['finish'] ) ){?>
22
+ <li class="loading"><?php _e( 'Loading...', 'learnpress_course_review' );?></li>
23
+ <?php }
24
+ //else?>
25
+ <!-- <li><?php _e( 'No review to load', 'learnpress_course_review' );?></li> -->
26
+ </ul>
27
+ <?php if( empty( $course_review['finish'] ) ){?>
28
+ <button class="button" id="course-review-load-more" data-paged="<?php echo $course_review['paged'];?>"><?php _e( 'Load More', 'learnpress_course_review' );?></button>
29
+ <?php }?>
30
+ </div>
31
+ <?php
32
+ }
template/loop-review.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <li>
2
+ <h4 class="user-name">
3
+ <?php do_action( 'learn_press_before_review_username' );?>
4
+ <?php echo $review->user_login; ?>
5
+ <?php do_action( 'learn_press_after_review_username' );?>
6
+ </h4>
7
+ <?php learn_press_course_review_template( 'rating-stars.php', array( 'rated' => $review->rate ) );?>
8
+ <p class="review-title">
9
+ <?php do_action( 'learn_press_before_review_title' );?>
10
+ <?php echo $review->title ?>
11
+ <?php do_action( 'learn_press_after_review_title' );?>
12
+ </p>
13
+ <div class="review-content">
14
+ <?php do_action( 'learn_press_before_review_content' );?>
15
+ <?php echo $review->content ?>
16
+ <?php do_action( 'learn_press_after_review_content' );?>
17
+ </div>
18
+ </li>
template/rating-stars.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="review-stars-rated">
2
+ <ul class="review-stars">
3
+ <li><span class="dashicons dashicons-star-empty"></span> </li>
4
+ <li><span class="dashicons dashicons-star-empty"></span> </li>
5
+ <li><span class="dashicons dashicons-star-empty"></span> </li>
6
+ <li><span class="dashicons dashicons-star-empty"></span> </li>
7
+ <li><span class="dashicons dashicons-star-empty"></span> </li>
8
+ </ul>
9
+ <ul class="review-stars filled" style="width:<?php echo $rated*20; ?>%;">
10
+ <li><span class="dashicons dashicons-star-filled"></span> </li>
11
+ <li><span class="dashicons dashicons-star-filled"></span> </li>
12
+ <li><span class="dashicons dashicons-star-filled"></span> </li>
13
+ <li><span class="dashicons dashicons-star-filled"></span> </li>
14
+ <li><span class="dashicons dashicons-star-filled"></span> </li>
15
+ </ul>
16
+ </div>