Completed
Push — master ( e3266d...1e8c99 )
by Dwain
06:18
created
includes/class-sensei-messages.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Messages Class
@@ -21,61 +21,61 @@  discard block
 block discarded – undo
21 21
 	 * Constructor.
22 22
 	 * @since  1.6.0
23 23
 	 */
24
-	public function __construct () {
24
+	public function __construct() {
25 25
 		$this->post_type = 'sensei_message';
26
-		$this->meta_fields = array( 'sender', 'receiver' );
26
+		$this->meta_fields = array('sender', 'receiver');
27 27
 
28 28
 		// Add Messages page to admin menu
29
-		add_action( 'admin_menu', array( $this, 'add_menu_item' ), 40 );
30
-		add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10, 2 );
31
-		add_action( 'admin_menu', array( $this, 'remove_meta_box' ) );
29
+		add_action('admin_menu', array($this, 'add_menu_item'), 40);
30
+		add_action('add_meta_boxes', array($this, 'add_meta_box'), 10, 2);
31
+		add_action('admin_menu', array($this, 'remove_meta_box'));
32 32
 
33 33
 		// Save new private message
34
-		add_action( 'init', array( $this, 'save_new_message' ), 1 );
34
+		add_action('init', array($this, 'save_new_message'), 1);
35 35
 
36 36
 		// Monitor when new reply is posted
37
-		add_action( 'comment_post', array( $this, 'message_reply_received' ), 10, 1 );
37
+		add_action('comment_post', array($this, 'message_reply_received'), 10, 1);
38 38
 
39 39
         // Block WordPress from sending comment update emails for the messages post type
40
-        add_filter('comment_notification_recipients', array( $this, 'stop_wp_comment_emails' ),  20, 2  );
40
+        add_filter('comment_notification_recipients', array($this, 'stop_wp_comment_emails'), 20, 2);
41 41
 
42 42
         // Block WordPress from sending comment moderator emails on the sensei messages post types
43
-        add_filter('comment_moderation_recipients', array( $this, 'stop_wp_comment_emails' ),  20, 2  );
43
+        add_filter('comment_moderation_recipients', array($this, 'stop_wp_comment_emails'), 20, 2);
44 44
 
45 45
 		// Process saving of message posts
46
-		add_action( 'save_post', array( $this, 'save_message' ) );
46
+		add_action('save_post', array($this, 'save_message'));
47 47
 
48 48
 		// Add message links to courses & lessons
49
-		add_action( 'sensei_single_course_content_inside_before', array( $this, 'send_message_link' ), 35 );
49
+		add_action('sensei_single_course_content_inside_before', array($this, 'send_message_link'), 35);
50 50
 
51 51
         // add message link to lesson
52
-        add_action( 'sensei_single_lesson_content_inside_before', array( $this, 'send_message_link' ), 30, 2 );
52
+        add_action('sensei_single_lesson_content_inside_before', array($this, 'send_message_link'), 30, 2);
53 53
 
54 54
         // add message link to lesson
55
-        add_action( 'sensei_single_quiz_questions_before', array( $this, 'send_message_link' ), 10, 2 );
55
+        add_action('sensei_single_quiz_questions_before', array($this, 'send_message_link'), 10, 2);
56 56
 
57 57
 		// Hide messages and replies from users who do not have access
58
-        add_action( 'template_redirect', array( $this, 'message_login' ), 10, 1 );
59
-        add_action( 'pre_get_posts', array( $this, 'message_list' ), 10, 1 );
60
-        add_filter( 'the_title', array( $this, 'message_title' ), 10, 2 );
61
-        add_filter( 'the_content', array( $this, 'message_content' ), 10, 1 );
62
-        add_filter( 'comments_array', array( $this, 'message_replies' ), 100, 1 );
63
-        add_filter( 'get_comments_number', array( $this, 'message_reply_count' ), 100, 2 );
64
-        add_filter( 'comments_open', array( $this, 'message_replies_open' ), 100, 2 );
58
+        add_action('template_redirect', array($this, 'message_login'), 10, 1);
59
+        add_action('pre_get_posts', array($this, 'message_list'), 10, 1);
60
+        add_filter('the_title', array($this, 'message_title'), 10, 2);
61
+        add_filter('the_content', array($this, 'message_content'), 10, 1);
62
+        add_filter('comments_array', array($this, 'message_replies'), 100, 1);
63
+        add_filter('get_comments_number', array($this, 'message_reply_count'), 100, 2);
64
+        add_filter('comments_open', array($this, 'message_replies_open'), 100, 2);
65 65
 	} // End __construct()
66 66
 
67 67
 	public function add_menu_item() {
68 68
 
69
-		if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) {
70
-			add_submenu_page( 'sensei', __( 'Messages', 'woothemes-sensei'),  __( 'Messages', 'woothemes-sensei') , 'edit_courses', 'edit.php?post_type=sensei_message' );
69
+		if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) {
70
+			add_submenu_page('sensei', __('Messages', 'woothemes-sensei'), __('Messages', 'woothemes-sensei'), 'edit_courses', 'edit.php?post_type=sensei_message');
71 71
 		}
72 72
 	}
73 73
 
74
-	public function add_meta_box( $post_type, $post ) {
74
+	public function add_meta_box($post_type, $post) {
75 75
 
76
-		if( ! $post_type == $this->post_type ) return;
76
+		if ( ! $post_type == $this->post_type) return;
77 77
 
78
-		add_meta_box( $this->post_type . '-data', __( 'Message Information', 'woothemes-sensei' ), array( $this, 'meta_box_content' ), $this->post_type, 'normal', 'default' );
78
+		add_meta_box($this->post_type.'-data', __('Message Information', 'woothemes-sensei'), array($this, 'meta_box_content'), $this->post_type, 'normal', 'default');
79 79
 
80 80
 	}
81 81
 
@@ -85,25 +85,25 @@  discard block
 block discarded – undo
85 85
 		$settings = array(
86 86
 			array(
87 87
 				'id' 			=> 'sender',
88
-				'label'			=> __( 'Message sent by:', 'woothemes-sensei' ),
89
-				'description'	=> __( 'The username of the learner who sent this message.', 'woothemes-sensei' ),
88
+				'label'			=> __('Message sent by:', 'woothemes-sensei'),
89
+				'description'	=> __('The username of the learner who sent this message.', 'woothemes-sensei'),
90 90
 				'type'			=> 'text',
91 91
 				'default'		=> '',
92
-				'placeholder'	=> __( 'Learner username', 'woothemes-sensei' ),
92
+				'placeholder'	=> __('Learner username', 'woothemes-sensei'),
93 93
 			),
94 94
 			array(
95 95
 				'id' 			=> 'receiver',
96
-				'label'			=> __( 'Message received by:', 'woothemes-sensei' ),
97
-				'description'	=> __( 'The username of the teacher who received this message.', 'woothemes-sensei' ),
96
+				'label'			=> __('Message received by:', 'woothemes-sensei'),
97
+				'description'	=> __('The username of the teacher who received this message.', 'woothemes-sensei'),
98 98
 				'type'			=> 'text',
99 99
 				'default'		=> '',
100
-				'placeholder'	=> __( 'Teacher username', 'woothemes-sensei' ),
100
+				'placeholder'	=> __('Teacher username', 'woothemes-sensei'),
101 101
 			),
102 102
 		);
103 103
 
104
-		$message_posttype = get_post_meta( $post->ID, '_posttype', true );
104
+		$message_posttype = get_post_meta($post->ID, '_posttype', true);
105 105
 
106
-		if( isset( $message_posttype ) && $message_posttype ) {
106
+		if (isset($message_posttype) && $message_posttype) {
107 107
 
108 108
 			$args = array(
109 109
 				'post_type' => $message_posttype,
@@ -113,58 +113,58 @@  discard block
 block discarded – undo
113 113
 				'post_status' => 'publish',
114 114
 			);
115 115
 
116
-			$posts = get_posts( $args );
116
+			$posts = get_posts($args);
117 117
 
118
-			$post_options[0] = sprintf( __( 'Select %1$s', 'woothemes-sensei' ), $message_posttype );
119
-			foreach( $posts as $post_item ) {
120
-				$post_options[ $post_item->ID ] = $post_item->post_title;
118
+			$post_options[0] = sprintf(__('Select %1$s', 'woothemes-sensei'), $message_posttype);
119
+			foreach ($posts as $post_item) {
120
+				$post_options[$post_item->ID] = $post_item->post_title;
121 121
 			}
122 122
 
123 123
 			$settings[] = array(
124 124
 				'id' 			=> 'post',
125
-				'label'			=> sprintf( __( 'Message from %1$s:', 'woothemes-sensei' ), $message_posttype ),
126
-				'description'	=> sprintf( __( 'The %1$s to which this message relates.', 'woothemes-sensei' ), $message_posttype ),
125
+				'label'			=> sprintf(__('Message from %1$s:', 'woothemes-sensei'), $message_posttype),
126
+				'description'	=> sprintf(__('The %1$s to which this message relates.', 'woothemes-sensei'), $message_posttype),
127 127
 				'type'			=> 'select',
128 128
 				'default'		=> 0,
129 129
 				'options'		=> $post_options,
130 130
 			);
131 131
 		}
132 132
 
133
-		$html = Sensei()->admin->render_settings( $settings, $post->ID, 'message-info' );
133
+		$html = Sensei()->admin->render_settings($settings, $post->ID, 'message-info');
134 134
 
135 135
 		echo $html;
136 136
 	}
137 137
 
138
-	public function save_message( $post_id = 0 ) {
138
+	public function save_message($post_id = 0) {
139 139
 		global $post;
140 140
 
141
-		if( $this->post_type != get_post_type() ) return;
141
+		if ($this->post_type != get_post_type()) return;
142 142
 
143
-		if( isset( $_POST['sender'] ) && $_POST['sender'] ) {
144
-			update_post_meta( $post_id, '_sender', $_POST['sender'] );
143
+		if (isset($_POST['sender']) && $_POST['sender']) {
144
+			update_post_meta($post_id, '_sender', $_POST['sender']);
145 145
 		}
146 146
 
147
-		if( isset( $_POST['receiver'] ) && $_POST['receiver'] ) {
148
-			update_post_meta( $post_id, '_receiver', $_POST['receiver'] );
147
+		if (isset($_POST['receiver']) && $_POST['receiver']) {
148
+			update_post_meta($post_id, '_receiver', $_POST['receiver']);
149 149
 		}
150 150
 
151
-		if( isset( $_POST['post'] ) && $_POST['post'] ) {
152
-			update_post_meta( $post_id, '_post', $_POST['post'] );
151
+		if (isset($_POST['post']) && $_POST['post']) {
152
+			update_post_meta($post_id, '_post', $_POST['post']);
153 153
 		}
154 154
 
155
-		remove_action( 'save_post', array( $this, 'save_message' ) );
155
+		remove_action('save_post', array($this, 'save_message'));
156 156
 
157
-		wp_update_post( array( 'ID' => $post_id, 'comment_status' => 'open' ) );
157
+		wp_update_post(array('ID' => $post_id, 'comment_status' => 'open'));
158 158
 
159
-		add_action( 'save_post', array( $this, 'save_message' ) );
159
+		add_action('save_post', array($this, 'save_message'));
160 160
 	}
161 161
 
162
-	public function send_message_link( $post_id = 0, $user_id = 0 ) {
162
+	public function send_message_link($post_id = 0, $user_id = 0) {
163 163
 		global  $post;
164 164
 
165 165
         // only show the link for the allowed post types:
166 166
         $allowed_post_types = array('lesson', 'course', 'quiz');
167
-		if ( ! in_array( get_post_type() , $allowed_post_types ) ) {
167
+		if ( ! in_array(get_post_type(), $allowed_post_types)) {
168 168
 
169 169
 			return;
170 170
 
@@ -172,28 +172,28 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$html = '';
174 174
 
175
-		if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) {
175
+		if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) {
176 176
 
177
-			if( ! is_user_logged_in() ) return;
177
+			if ( ! is_user_logged_in()) return;
178 178
 
179
-			if( isset( $_GET['contact'] ) ) {
180
-				$html .= $this->teacher_contact_form( $post );
179
+			if (isset($_GET['contact'])) {
180
+				$html .= $this->teacher_contact_form($post);
181 181
 			} else {
182
-				$href = add_query_arg( array( 'contact' => $post->post_type ) );
183
-
184
-				if( 'lesson' == $post->post_type ) {
185
-					$contact_button_text = __( 'Contact Lesson Teacher', 'woothemes-sensei' );
186
-				} elseif( 'course' == $post->post_type ) {
187
-					$contact_button_text = __( 'Contact Course Teacher', 'woothemes-sensei' );
188
-				}else{
189
-                    $contact_button_text = __( 'Contact Teacher', 'woothemes-sensei' );
182
+				$href = add_query_arg(array('contact' => $post->post_type));
183
+
184
+				if ('lesson' == $post->post_type) {
185
+					$contact_button_text = __('Contact Lesson Teacher', 'woothemes-sensei');
186
+				} elseif ('course' == $post->post_type) {
187
+					$contact_button_text = __('Contact Course Teacher', 'woothemes-sensei');
188
+				} else {
189
+                    $contact_button_text = __('Contact Teacher', 'woothemes-sensei');
190 190
                 }
191 191
 
192
-				$html .= '<p><a class="button send-message-button" href="' . esc_url($href) . '#private_message">' . $contact_button_text . '</a></p>';
192
+				$html .= '<p><a class="button send-message-button" href="'.esc_url($href).'#private_message">'.$contact_button_text.'</a></p>';
193 193
 			}
194 194
 
195
-			if( isset( $this->message_notice ) && isset( $this->message_notice['type'] ) && isset( $this->message_notice['notice'] ) ) {
196
-				$html .= '<div class="sensei-message ' . $this->message_notice['type'] . '">' . $this->message_notice['notice'] . '</div>';
195
+			if (isset($this->message_notice) && isset($this->message_notice['type']) && isset($this->message_notice['notice'])) {
196
+				$html .= '<div class="sensei-message '.$this->message_notice['type'].'">'.$this->message_notice['notice'].'</div>';
197 197
 			}
198 198
 
199 199
 		}
@@ -201,40 +201,40 @@  discard block
 block discarded – undo
201 201
 		echo $html;
202 202
 	}
203 203
 
204
-	public function teacher_contact_form( $post ) {
204
+	public function teacher_contact_form($post) {
205 205
 
206
-		if( ! is_user_logged_in() ) return;
206
+		if ( ! is_user_logged_in()) return;
207 207
 
208 208
 		global $current_user;
209 209
 		wp_get_current_user();
210 210
 
211 211
 		$html = '';
212 212
 
213
-		if( ! isset( $post->ID ) ) return $html;
213
+		if ( ! isset($post->ID)) return $html;
214 214
 
215 215
         //confirm private message
216 216
         $confirmation = '';
217
-        if( isset( $_GET[ 'send' ] ) && 'complete' == $_GET[ 'send' ] ) {
217
+        if (isset($_GET['send']) && 'complete' == $_GET['send']) {
218 218
 
219 219
             $confirmation_message = __('Your private message has been sent.', 'woothemes-sensei');
220
-            $confirmation = '<div class="sensei-message tick">' . $confirmation_message . '</div>';
220
+            $confirmation = '<div class="sensei-message tick">'.$confirmation_message.'</div>';
221 221
 
222 222
         }
223 223
 
224
-		$html .= '<h3 id="private_message">' . __( 'Send Private Message', 'woothemes-sensei' ) . '</h3>';
224
+		$html .= '<h3 id="private_message">'.__('Send Private Message', 'woothemes-sensei').'</h3>';
225 225
         $html .= '<p>';
226
-        $html .=  $confirmation;
226
+        $html .= $confirmation;
227 227
         $html .= '</p>';
228 228
 		$html .= '<form name="contact-teacher" action="" method="post" class="contact-teacher">';
229 229
 			$html .= '<p class="form-row form-row-wide">';
230
-				$html .= '<textarea name="contact_message" placeholder="' . __( 'Enter your private message.', 'woothemes-sensei' ) . '"></textarea>';
230
+				$html .= '<textarea name="contact_message" placeholder="'.__('Enter your private message.', 'woothemes-sensei').'"></textarea>';
231 231
 			$html .= '</p>';
232 232
 			$html .= '<p class="form-row">';
233
-				$html .= '<input type="hidden" name="post_id" value="' . $post->ID . '" />';
234
-				$html .= '<input type="hidden" name="sender_id" value="' . $current_user->ID . '" />';
235
-				$html .= '<input type="hidden" name="receiver_id" value="' . $post->post_author . '" />';
236
-				$html .= wp_nonce_field( 'message_teacher', 'sensei_message_teacher_nonce', true, false );
237
-				$html .= '<input type="submit" class="send_message" value="' . __( 'Send Message', 'woothemes-sensei' ) . '" />';
233
+				$html .= '<input type="hidden" name="post_id" value="'.$post->ID.'" />';
234
+				$html .= '<input type="hidden" name="sender_id" value="'.$current_user->ID.'" />';
235
+				$html .= '<input type="hidden" name="receiver_id" value="'.$post->post_author.'" />';
236
+				$html .= wp_nonce_field('message_teacher', 'sensei_message_teacher_nonce', true, false);
237
+				$html .= '<input type="submit" class="send_message" value="'.__('Send Message', 'woothemes-sensei').'" />';
238 238
 			$html .= '</p>';
239 239
 			$html .= '<div class="fix"></div>';
240 240
 		$html .= '</form>';
@@ -244,30 +244,30 @@  discard block
 block discarded – undo
244 244
 
245 245
 	public function save_new_message() {
246 246
 
247
-		if( ! isset( $_POST['sensei_message_teacher_nonce'] ) ) return;
247
+		if ( ! isset($_POST['sensei_message_teacher_nonce'])) return;
248 248
 
249
-		if( ! wp_verify_nonce( $_POST['sensei_message_teacher_nonce'], 'message_teacher' ) ) return;
249
+		if ( ! wp_verify_nonce($_POST['sensei_message_teacher_nonce'], 'message_teacher')) return;
250 250
 
251
-		$message_id = $this->save_new_message_post( $_POST['sender_id'], $_POST['receiver_id'], $_POST['contact_message'], $_POST['post_id'] );
251
+		$message_id = $this->save_new_message_post($_POST['sender_id'], $_POST['receiver_id'], $_POST['contact_message'], $_POST['post_id']);
252 252
 
253 253
 	}
254 254
 
255
-	public function message_reply_received( $comment_id = 0 ) {
255
+	public function message_reply_received($comment_id = 0) {
256 256
 
257 257
 		// Get comment object
258
-    	$comment = get_comment( $comment_id );
258
+    	$comment = get_comment($comment_id);
259 259
 
260
-		if( is_null( $comment ) ) return;
260
+		if (is_null($comment)) return;
261 261
 
262 262
 		// Get message post object
263
-		$message = get_post( $comment->comment_post_ID );
263
+		$message = get_post($comment->comment_post_ID);
264 264
 
265
-		if( $message->post_type != $this->post_type ) return;
265
+		if ($message->post_type != $this->post_type) return;
266 266
 
267 267
 		// Force comment to be approved
268
-		wp_set_comment_status( $comment_id, 'approve' );
268
+		wp_set_comment_status($comment_id, 'approve');
269 269
 
270
-		do_action( 'sensei_private_message_reply', $comment, $message );
270
+		do_action('sensei_private_message_reply', $comment, $message);
271 271
 	}
272 272
 
273 273
     /**
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
      * @param int $comment_id
281 281
      * @return array;
282 282
      */
283
-    public function stop_wp_comment_emails( $emails , $comment_id ){
283
+    public function stop_wp_comment_emails($emails, $comment_id) {
284 284
 
285
-        $comment = get_comment( $comment_id );
286
-        if( isset( $comment->comment_post_ID ) &&
287
-            'sensei_message' == get_post_type( $comment->comment_post_ID )  ){
285
+        $comment = get_comment($comment_id);
286
+        if (isset($comment->comment_post_ID) &&
287
+            'sensei_message' == get_post_type($comment->comment_post_ID)) {
288 288
 
289 289
             // empty the emails array to ensure no emails are sent for this comment
290 290
             $emails = array();
@@ -302,45 +302,45 @@  discard block
 block discarded – undo
302 302
      * @param  string  $post_id     ID of post related to message
303 303
      * @return mixed                Message ID on success, boolean false on failure
304 304
      */
305
-    private function save_new_message_post( $sender_id = 0, $receiver_id = 0, $message = '', $post_id = 0 ) {
305
+    private function save_new_message_post($sender_id = 0, $receiver_id = 0, $message = '', $post_id = 0) {
306 306
 
307 307
     	$message_id = false;
308 308
 
309
-    	if( $sender_id && $receiver_id && $message && $post_id ) {
309
+    	if ($sender_id && $receiver_id && $message && $post_id) {
310 310
 
311
-    		$title = wp_trim_words( $message, 8, '...' );
311
+    		$title = wp_trim_words($message, 8, '...');
312 312
 
313 313
     		// Set up post data for message
314 314
 	    	$message_data = array(
315 315
 	            'post_type'      => $this->post_type,
316
-	            'post_title'     => esc_html( $title ),
317
-	            'post_content'   => esc_html( $message ),
316
+	            'post_title'     => esc_html($title),
317
+	            'post_content'   => esc_html($message),
318 318
 	            'post_status'    => 'publish',
319 319
 	            'ping_status'    => 'closed',
320 320
 	            'comment_status' => 'open',
321 321
 	            'post_excerpt'   => '',
322
-	            'post_author'	 => intval( $sender_id )
322
+	            'post_author'	 => intval($sender_id)
323 323
 	        );
324 324
 
325 325
 	    	// Insert post
326
-	        $message_id = wp_insert_post( $message_data );
326
+	        $message_id = wp_insert_post($message_data);
327 327
 
328
-	        if( ! is_wp_error( $message_id ) ) {
328
+	        if ( ! is_wp_error($message_id)) {
329 329
 
330 330
 	        	// Add sender to message meta
331
-	        	$sender = get_userdata( $sender_id );
332
-	        	add_post_meta( $message_id, '_sender', $sender->user_login );
331
+	        	$sender = get_userdata($sender_id);
332
+	        	add_post_meta($message_id, '_sender', $sender->user_login);
333 333
 
334 334
 	        	// Add receiver to message meta
335
-	        	$receiver = get_userdata( $receiver_id );
336
-		        add_post_meta( $message_id, '_receiver', $receiver->user_login );
335
+	        	$receiver = get_userdata($receiver_id);
336
+		        add_post_meta($message_id, '_receiver', $receiver->user_login);
337 337
 
338 338
 		        // Add lesson/course ID to message meta
339
-		        $post = get_post( $post_id );
340
-		        add_post_meta( $message_id, '_posttype', $post->post_type );
341
-		        add_post_meta( $message_id, '_post', $post->ID );
339
+		        $post = get_post($post_id);
340
+		        add_post_meta($message_id, '_posttype', $post->post_type);
341
+		        add_post_meta($message_id, '_post', $post->ID);
342 342
 
343
-		        do_action( 'sensei_new_private_message', $message_id );
343
+		        do_action('sensei_new_private_message', $message_id);
344 344
 
345 345
 		    } else {
346 346
 
@@ -358,22 +358,22 @@  discard block
 block discarded – undo
358 358
 	 * @param  integer $user_id    ID of user
359 359
 	 * @return boolean             True if user has access to this message
360 360
 	 */
361
-	private function view_message( $message_id, $user_id = 0) {
361
+	private function view_message($message_id, $user_id = 0) {
362 362
 
363
-		if( ! is_user_logged_in() ) return false;
363
+		if ( ! is_user_logged_in()) return false;
364 364
 
365
-		if( $user_id == 0 ) {
365
+		if ($user_id == 0) {
366 366
 			global $current_user;
367 367
 			wp_get_current_user();
368 368
 			$user_login = $current_user->user_login;
369 369
 		}
370 370
 
371 371
 		// Get allowed users
372
-		$receiver = get_post_meta( $message_id, '_receiver', true );
373
-		$sender = get_post_meta( $message_id, '_sender', true );
372
+		$receiver = get_post_meta($message_id, '_receiver', true);
373
+		$sender = get_post_meta($message_id, '_sender', true);
374 374
 
375 375
 		// Check if user is allowed to view the message
376
-		if( in_array( $user_login, array( $receiver, $sender ) ) ) {
376
+		if (in_array($user_login, array($receiver, $sender))) {
377 377
 			return true;
378 378
 		}
379 379
 
@@ -400,27 +400,27 @@  discard block
 block discarded – undo
400 400
      * @return void
401 401
      */
402 402
 
403
-    public function message_login () {
403
+    public function message_login() {
404 404
 
405
-        if ( is_user_logged_in() ) {
405
+        if (is_user_logged_in()) {
406 406
 
407 407
             return;
408 408
         }
409 409
 
410 410
         $settings = Sensei()->settings->get_settings();
411
-        if( isset( $settings[ 'my_course_page' ] )
412
-            && 0 < intval( $settings[ 'my_course_page' ] ) ){
411
+        if (isset($settings['my_course_page'])
412
+            && 0 < intval($settings['my_course_page'])) {
413 413
 
414
-            $my_courses_page_id = $settings[ 'my_course_page' ];
414
+            $my_courses_page_id = $settings['my_course_page'];
415 415
 
416 416
             $my_courses_url = get_permalink($my_courses_page_id);
417 417
 
418 418
         }
419 419
 
420
-        if ( is_single() && is_singular( $this->post_type )
421
-            || is_post_type_archive( $this->post_type ) ) {
420
+        if (is_single() && is_singular($this->post_type)
421
+            || is_post_type_archive($this->post_type)) {
422 422
 
423
-            if ( isset($my_courses_url) ) {
423
+            if (isset($my_courses_url)) {
424 424
 
425 425
                 wp_redirect($my_courses_url, 303);
426 426
                 exit;
@@ -439,12 +439,12 @@  discard block
 block discarded – undo
439 439
      * @param  array $query Original query
440 440
      * @return void
441 441
      */
442
-	public function message_list( $query ) {
442
+	public function message_list($query) {
443 443
 		global $current_user;
444 444
 
445
-		if( is_admin() ) return;
445
+		if (is_admin()) return;
446 446
 
447
-		if( is_post_type_archive( $this->post_type ) && $query->is_main_query() ) {
447
+		if (is_post_type_archive($this->post_type) && $query->is_main_query()) {
448 448
 			wp_get_current_user();
449 449
 			$username = $current_user->user_login;
450 450
 
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 				'compare' => '='
463 463
 			);
464 464
 
465
-			$query->set( 'meta_query', $meta_query );
465
+			$query->set('meta_query', $meta_query);
466 466
 
467 467
 			return;
468 468
 		}
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @param  integer $post_id ID of post
475 475
 	 * @return string           Modified string if user does not have access to this message
476 476
 	 */
477
-	public function message_title( $title = '', $post_id = null ) {
477
+	public function message_title($title = '', $post_id = null) {
478 478
 
479
-		if( is_single() && is_singular( $this->post_type ) && in_the_loop() && get_post_type( $post_id ) == $this->post_type ) {
480
-			if( ! is_user_logged_in() || ! $this->view_message( $post_id ) ) {
481
-				$title = __( 'You are not allowed to view this message.', 'woothemes-sensei' );
479
+		if (is_single() && is_singular($this->post_type) && in_the_loop() && get_post_type($post_id) == $this->post_type) {
480
+			if ( ! is_user_logged_in() || ! $this->view_message($post_id)) {
481
+				$title = __('You are not allowed to view this message.', 'woothemes-sensei');
482 482
 			}
483 483
 		}
484 484
 
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $content Original message content
491 491
 	 * @return string          Empty string if user does not have access to this message
492 492
 	 */
493
-	public function message_content( $content ) {
493
+	public function message_content($content) {
494 494
 		global $post;
495 495
 
496
-		if( is_single() && is_singular( $this->post_type ) && in_the_loop() ) {
497
-			if( ! is_user_logged_in() || ! $this->view_message( $post->ID ) ) {
498
-				$content = __( 'Please log in to view your messages.', 'woothemes-sensei' );
496
+		if (is_single() && is_singular($this->post_type) && in_the_loop()) {
497
+			if ( ! is_user_logged_in() || ! $this->view_message($post->ID)) {
498
+				$content = __('Please log in to view your messages.', 'woothemes-sensei');
499 499
 			}
500 500
 		}
501 501
 
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	 * @param  array $comments Array of replies
508 508
 	 * @return array           Empty array if user does not have access to this message
509 509
 	 */
510
-	public function message_replies( $comments ) {
510
+	public function message_replies($comments) {
511 511
 		global $post;
512 512
 
513
-		if( is_single() && is_singular( $this->post_type ) && in_the_loop() ) {
514
-			if( ! is_user_logged_in() || ! $this->view_message( $post->ID ) ) {
513
+		if (is_single() && is_singular($this->post_type) && in_the_loop()) {
514
+			if ( ! is_user_logged_in() || ! $this->view_message($post->ID)) {
515 515
 				$comments = array();
516 516
 			}
517 517
 		}
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
 	 * @param  integer $post_id ID of post
526 526
 	 * @return integer          0 if user does not have access to this message
527 527
 	 */
528
-	public function message_reply_count( $count, $post_id ) {
528
+	public function message_reply_count($count, $post_id) {
529 529
 		global $post;
530 530
 
531
-		if( is_single() && is_singular( $this->post_type ) && in_the_loop() ) {
532
-			if( ! is_user_logged_in() || ! $this->view_message( $post->ID ) ) {
531
+		if (is_single() && is_singular($this->post_type) && in_the_loop()) {
532
+			if ( ! is_user_logged_in() || ! $this->view_message($post->ID)) {
533 533
 				$count = 0;
534 534
 			}
535 535
 		}
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 	 * @param  integer $post_id ID of post
544 544
 	 * @return boolean          False if user does not have access to this message
545 545
 	 */
546
-	public function message_replies_open( $open, $post_id ) {
546
+	public function message_replies_open($open, $post_id) {
547 547
 		global $post;
548 548
 
549
-		if( is_single() && is_singular( $this->post_type ) && in_the_loop() ) {
550
-			if( ! is_user_logged_in() || ! $this->view_message( $post->ID ) ) {
549
+		if (is_single() && is_singular($this->post_type) && in_the_loop()) {
550
+			if ( ! is_user_logged_in() || ! $this->view_message($post->ID)) {
551 551
 				$open = false;
552 552
 			}
553 553
 		}
@@ -560,17 +560,17 @@  discard block
 block discarded – undo
560 560
      *
561 561
      * @since 1.9.0
562 562
      */
563
-    public static function the_message_sent_by_title(){
563
+    public static function the_message_sent_by_title() {
564 564
 
565
-        $sender_username = get_post_meta( get_the_ID() , '_sender', true );
566
-        if( $sender_username ) {
565
+        $sender_username = get_post_meta(get_the_ID(), '_sender', true);
566
+        if ($sender_username) {
567 567
 
568
-            $sender = get_user_by( 'login', $sender_username ); ?>
568
+            $sender = get_user_by('login', $sender_username); ?>
569 569
 
570 570
             <p class="message-meta">
571 571
                 <small>
572 572
                     <em>
573
-                        <?php printf( __( 'Sent by %1$s on %2$s.', 'woothemes-sensei' ), $sender->display_name, get_the_date() ); ?>
573
+                        <?php printf(__('Sent by %1$s on %2$s.', 'woothemes-sensei'), $sender->display_name, get_the_date()); ?>
574 574
                     </em>
575 575
                 </small>
576 576
             </p>
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
 
590 590
         global $post;
591 591
 
592
-        $content_post_id = get_post_meta( $post->ID, '_post', true );
593
-        if( $content_post_id ) {
594
-            $title = sprintf( __( 'Re: %1$s', 'woothemes-sensei' ), '<a href="' . get_permalink( $content_post_id ) . '">' . get_the_title( $content_post_id ) . '</a>' );
592
+        $content_post_id = get_post_meta($post->ID, '_post', true);
593
+        if ($content_post_id) {
594
+            $title = sprintf(__('Re: %1$s', 'woothemes-sensei'), '<a href="'.get_permalink($content_post_id).'">'.get_the_title($content_post_id).'</a>');
595 595
         } else {
596
-            $title = get_the_title( $post->ID );
596
+            $title = get_the_title($post->ID);
597 597
         }
598 598
 
599 599
         ?>
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
                  * @param string $template
611 611
                  * @param string $post_type
612 612
                  */
613
-                echo apply_filters( 'sensei_single_title', $title, $post->post_type );
613
+                echo apply_filters('sensei_single_title', $title, $post->post_type);
614 614
                 ?>
615 615
 
616 616
             </h1>
@@ -629,18 +629,18 @@  discard block
 block discarded – undo
629 629
      *
630 630
      * @return string
631 631
      */
632
-    public static function the_archive_header( ){
632
+    public static function the_archive_header( ) {
633 633
 
634 634
         $html = '';
635 635
         $html .= '<header class="archive-header"><h1>';
636
-        $html .= __( 'My Messages', 'woothemes-sensei' );
636
+        $html .= __('My Messages', 'woothemes-sensei');
637 637
         $html .= '</h1></header>';
638 638
 
639 639
         /**
640 640
          * Filter the sensei messages archive title.
641 641
          * @since 1.0.0
642 642
          */
643
-        echo apply_filters( 'sensei_message_archive_title', $html );
643
+        echo apply_filters('sensei_message_archive_title', $html);
644 644
 
645 645
     } // get_archive_header()
646 646
 
@@ -650,23 +650,23 @@  discard block
 block discarded – undo
650 650
      * @since 1.9.0
651 651
      * @param $post_id
652 652
      */
653
-    public static function the_message_title( $message_post_id ){
653
+    public static function the_message_title($message_post_id) {
654 654
 
655
-        $content_post_id = get_post_meta( $message_post_id, '_post', true );
655
+        $content_post_id = get_post_meta($message_post_id, '_post', true);
656 656
 
657
-        if( $content_post_id ) {
657
+        if ($content_post_id) {
658 658
 
659
-            $title = sprintf( __( 'Re: %1$s', 'woothemes-sensei' ), get_the_title( $content_post_id ) );
659
+            $title = sprintf(__('Re: %1$s', 'woothemes-sensei'), get_the_title($content_post_id));
660 660
 
661 661
         } else {
662 662
 
663
-            $title = get_the_title( $message_post_id );
663
+            $title = get_the_title($message_post_id);
664 664
 
665 665
         }
666 666
 
667 667
         ?>
668 668
         <h2>
669
-            <a href="<?php esc_url( get_permalink( $message_post_id ) );?>">
669
+            <a href="<?php esc_url(get_permalink($message_post_id)); ?>">
670 670
                 <?php echo  $title; ?>
671 671
             </a>
672 672
 
@@ -680,13 +680,13 @@  discard block
 block discarded – undo
680 680
      *
681 681
      * @param $message_post_id
682 682
      */
683
-    public  static function the_message_sender( $message_post_id ){
683
+    public  static function the_message_sender($message_post_id) {
684 684
 
685
-        $sender_username = get_post_meta( $message_post_id, '_sender', true );
686
-        $sender = get_user_by( 'login', $sender_username );
685
+        $sender_username = get_post_meta($message_post_id, '_sender', true);
686
+        $sender = get_user_by('login', $sender_username);
687 687
 
688
-        if( $sender_username && $sender instanceof WP_User ) {
689
-            $sender_display_name = sprintf( __( 'Sent by %1$s on %2$s.', 'woothemes-sensei' ), $sender->display_name, get_the_date() );
688
+        if ($sender_username && $sender instanceof WP_User) {
689
+            $sender_display_name = sprintf(__('Sent by %1$s on %2$s.', 'woothemes-sensei'), $sender->display_name, get_the_date());
690 690
             ?>
691 691
             <p class="message-meta">
692 692
                 <small>
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
      *
705 705
      * @since 1.9.0
706 706
      */
707
-    public static function the_my_messages_link(){
708
-        if( ! Sensei()->settings->get('messages_disable')  ) {
707
+    public static function the_my_messages_link() {
708
+        if ( ! Sensei()->settings->get('messages_disable')) {
709 709
             ?>
710 710
             <p class="my-messages-link-container">
711
-                <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>"
712
-                   title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>">
713
-                    <?php _e( 'My Messages', 'woothemes-sensei' ); ?>
711
+                <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>"
712
+                   title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>">
713
+                    <?php _e('My Messages', 'woothemes-sensei'); ?>
714 714
                 </a>
715 715
             </p>
716 716
             <?php
@@ -724,4 +724,4 @@  discard block
 block discarded – undo
724 724
  * for backward compatibility
725 725
  * @since 1.9.0
726 726
  */
727
-class WooThemes_Sensei_Messages extends Sensei_Messages{}
727
+class WooThemes_Sensei_Messages extends Sensei_Messages {}
Please login to merge, or discard this patch.
includes/hooks/woocommerce.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@  discard block
 block discarded – undo
7 7
  * show the WooCommerce course filter links above the courses
8 8
  * @since 1.9.0
9 9
  */
10
-add_filter( 'sensei_archive_course_filter_by_options', array( 'Sensei_WC', 'add_course_archive_wc_filter_links' ) );
10
+add_filter('sensei_archive_course_filter_by_options', array('Sensei_WC', 'add_course_archive_wc_filter_links'));
11 11
 
12 12
 /**
13 13
  * filter the queries for paid and free course based on the users selection.
14 14
  * @since 1.9.0
15 15
  */
16
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_free'));
17
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_paid'));
16
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_free'));
17
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_paid'));
18 18
 
19 19
 /**
20 20
  * Add woocommerce action above single course the action
21 21
  * @since 1.9.0
22 22
  */
23
-add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action') ,50) ;
23
+add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action'), 50);
24 24
 
25 25
 /******************************
26 26
  *
27 27
  * Single Lesson Hooks
28 28
  *
29 29
  ******************************/
30
-add_filter( 'sensei_can_user_view_lesson', array( 'Sensei_WC','alter_can_user_view_lesson' ), 20, 3 );
30
+add_filter('sensei_can_user_view_lesson', array('Sensei_WC', 'alter_can_user_view_lesson'), 20, 3);
31 31
 
32 32
 /******************************
33 33
  *
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  *
36 36
  ******************************/
37 37
 // add a notice on the checkout page to tell users about the course they've purchase
38
-add_action( 'template_redirect', array( 'Sensei_WC','course_link_from_order' ) );
38
+add_action('template_redirect', array('Sensei_WC', 'course_link_from_order'));
39 39
 
40 40
 /******************************
41 41
  *
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  ******************************/
45 45
 //@since 1.9.0
46 46
 //show a notice if the user has already added the current course to their cart
47
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_WC', 'course_in_cart_message' ), 20 );
47
+add_action('sensei_single_course_content_inside_before', array('Sensei_WC', 'course_in_cart_message'), 20);
48 48
 
49 49
 /******************************
50 50
  *
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
  ******************************/
54 54
 //@since 1.9.0
55 55
 // alter the no permissions message to show the woocommerce message instead
56
-add_filter( 'sensei_the_no_permissions_message', array( 'Sensei_WC', 'alter_no_permissions_message' ), 20, 2 );
56
+add_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2);
57 57
 
58 58
 //@since 1.9.0
59 59
 // add the add to cart button for a valid purchasable course
60
-add_action( 'sensei_no_permissions_inside_before_content', array( 'Sensei_WC', 'the_add_to_cart_button_html' ), 20, 1);
60
+add_action('sensei_no_permissions_inside_before_content', array('Sensei_WC', 'the_add_to_cart_button_html'), 20, 1);
61 61
 
62 62
 // @since 1.9.0
63 63
 // add  woocommerce class to the the no permission body class to ensure WooCommerce elements are styled
64
-add_filter( 'body_class', array( 'Sensei_WC', 'add_woocommerce_body_class' ), 20, 1);
64
+add_filter('body_class', array('Sensei_WC', 'add_woocommerce_body_class'), 20, 1);
Please login to merge, or discard this patch.
templates/no-permissions.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 ?>
13 13
 
14
-<?php  get_sensei_header();  ?>
14
+<?php  get_sensei_header(); ?>
15 15
 
16 16
 <?php
17 17
 /**
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
  * @since 1.9.0
22 22
  * @param $post_id
23 23
  */
24
-do_action('sensei_no_permissions_before_content', get_the_ID() );
24
+do_action('sensei_no_permissions_before_content', get_the_ID());
25 25
 ?>
26 26
 
27
-<article <?php post_class( 'no-permission' ) ?> >
27
+<article <?php post_class('no-permission') ?> >
28 28
 
29 29
     <header>
30 30
 
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
      * @since 1.9.0
41 41
      * @param $post_id
42 42
      */
43
-    do_action('sensei_no_permissions_inside_before_content', get_the_ID() );
43
+    do_action('sensei_no_permissions_inside_before_content', get_the_ID());
44 44
     ?>
45 45
 
46 46
     <section class="entry fix">
47 47
 
48 48
         <div class="sensei-message alert">
49 49
 
50
-            <?php the_no_permissions_message( get_the_ID() ); ?>
50
+            <?php the_no_permissions_message(get_the_ID()); ?>
51 51
 
52 52
         </div>
53 53
 
54 54
         <p class="excerpt">
55 55
 
56
-            <?php sensei_the_excerpt( get_the_ID() ); ?>
56
+            <?php sensei_the_excerpt(get_the_ID()); ?>
57 57
 
58 58
         </p>
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @since 1.9.0
68 68
      * @param $post_id
69 69
      */
70
-    do_action('sensei_no_permissions_inside_after_content', get_the_ID() );
70
+    do_action('sensei_no_permissions_inside_after_content', get_the_ID());
71 71
     ?>
72 72
 
73 73
 </article><!-- .no-permissions -->
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @since 1.9.0
81 81
  * @param $post_id
82 82
  */
83
-do_action('sensei_no_permissions_after_content', get_the_ID() );
83
+do_action('sensei_no_permissions_after_content', get_the_ID());
84 84
 ?>
85 85
 
86 86
 <?php get_sensei_footer(); ?>
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
templates/course-results/lessons.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying all course lessons on the course results page.
5 5
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 global $course;
15 15
 ?>
16 16
 
17
-<?php if ( is_user_logged_in() ): ?>
17
+<?php if (is_user_logged_in()): ?>
18 18
 
19 19
     <?php
20 20
     /**
@@ -22,53 +22,53 @@  discard block
 block discarded – undo
22 22
      * is uer logged check, just above the lessons header.
23 23
      * @since 1.4.0
24 24
      */
25
-    do_action( 'sensei_course_results_before_lessons', $course->ID );
25
+    do_action('sensei_course_results_before_lessons', $course->ID);
26 26
     ?>
27 27
 
28 28
     <header>
29 29
 
30
-        <h2>  <?php _e( 'Lessons', 'woothemes-sensei' );  ?> </h2>
30
+        <h2>  <?php _e('Lessons', 'woothemes-sensei'); ?> </h2>
31 31
 
32 32
     </header>
33 33
 
34
-    <article class="<?php  esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ), $course->ID ) ) ); ?> ">
34
+    <article class="<?php  esc_attr_e(join(' ', get_post_class(array('course', 'post'), $course->ID))); ?> ">
35 35
 
36 36
         <?php
37 37
 
38 38
 		$displayed_lessons = array();
39
-        $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) );
39
+        $modules = Sensei()->modules->get_course_modules(intval($course->ID));
40 40
 
41 41
         // List modules with lessons
42
-        foreach( $modules as $module ) {
42
+        foreach ($modules as $module) {
43 43
 
44
-            $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id );
44
+            $lessons_query = Sensei()->modules->get_lessons_query($course->ID, $module->term_id);
45 45
             $lessons = $lessons_query->get_posts();
46 46
 
47
-            if( count( $lessons ) > 0 ) { ?>
47
+            if (count($lessons) > 0) { ?>
48 48
 
49 49
                 <h3> <?php echo $module->name; ?></h3>
50 50
 
51 51
                 <?php
52 52
                 $count = 0;
53
-                foreach( $lessons as $lesson ) {
53
+                foreach ($lessons as $lesson) {
54 54
 
55 55
                     $lesson_grade = 'n/a';
56
-                    $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
57
-                    if ( $has_questions ) {
58
-                        $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() );
56
+                    $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
57
+                    if ($has_questions) {
58
+                        $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id());
59 59
                         // Get user quiz grade
60
-                        $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
61
-                        if ( $lesson_grade ) {
60
+                        $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
61
+                        if ($lesson_grade) {
62 62
                             $lesson_grade .= '%';
63 63
                         }
64 64
                     }
65 65
                     ?>
66 66
                     <h2>
67 67
 
68
-                        <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>"
69
-                           title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>">
68
+                        <a href="<?php esc_url_raw(get_permalink($lesson->ID)); ?>"
69
+                           title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)); ?>">
70 70
 
71
-                            <?php esc_html_e( $lesson->post_title ); ?>
71
+                            <?php esc_html_e($lesson->post_title); ?>
72 72
 
73 73
                         </a>
74 74
 
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 
90 90
         <?php
91 91
 
92
-        $lessons = Sensei()->modules->get_none_module_lessons( $course->ID );
93
-        if( 0 < count( $lessons ) ): ?>
92
+        $lessons = Sensei()->modules->get_none_module_lessons($course->ID);
93
+        if (0 < count($lessons)): ?>
94 94
 
95 95
 			<h3>
96 96
 
97
-                <?php _e( 'Other Lessons', 'woothemes-sensei' ); ?>
97
+                <?php _e('Other Lessons', 'woothemes-sensei'); ?>
98 98
 
99 99
             </h3>
100 100
 
101
-            <?php foreach ( $lessons as $lesson ): ?>
101
+            <?php foreach ($lessons as $lesson): ?>
102 102
 
103 103
                 <?php
104 104
                 $lesson_grade = 'n/a';
105
-                $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true );
106
-                if ( $has_questions ) {
107
-                    $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id());
105
+                $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true);
106
+                if ($has_questions) {
107
+                    $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id());
108 108
                     // Get user quiz grade
109
-                    $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true );
110
-                    if ( $lesson_grade ) {
109
+                    $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
110
+                    if ($lesson_grade) {
111 111
                         $lesson_grade .= '%';
112 112
                     }
113 113
                 }
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 
116 116
                 <h2>
117 117
 
118
-                    <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ) ?>" title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ) ?>" >
118
+                    <a href="<?php esc_url_raw(get_permalink($lesson->ID)) ?>" title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)) ?>" >
119 119
 
120
-                        <?php esc_html_e( sprintf( __( '%s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>
120
+                        <?php esc_html_e(sprintf(__('%s', 'woothemes-sensei'), $lesson->post_title)); ?>
121 121
 
122 122
                     </a>
123 123
 
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 
133 133
         <h2 class="total-grade">
134 134
 
135
-            <?php _e( 'Total Grade', 'woothemes-sensei' ); ?>
135
+            <?php _e('Total Grade', 'woothemes-sensei'); ?>
136 136
             <span class="lesson-grade">
137 137
 
138 138
                 <?php
139 139
 
140
-                    $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() );
141
-                    echo $course_user_grade . '%';
140
+                    $course_user_grade = Sensei_Utils::sensei_course_user_grade($course->ID, get_current_user_id());
141
+                    echo $course_user_grade.'%';
142 142
 
143 143
                 ?>
144 144
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      *
156 156
      * @since 1.4.0
157 157
      */
158
-	do_action( 'sensei_course_results_after_lessons', $course->ID );
158
+	do_action('sensei_course_results_after_lessons', $course->ID);
159 159
     ?>
160 160
 
161 161
 <?php endif; //user logged in ?>
162 162
\ No newline at end of file
Please login to merge, or discard this patch.
templates/single-quiz/question_type-multi-line.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying Multi Line Questions.
5 5
  *
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
      * Get the question data with the current quiz id
19 19
      * All data is loaded in this array to keep the template clean.
20 20
      */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
21
+    $question_data = WooThemes_Sensei_Question::get_template_data(sensei_get_the_question_id(), get_the_ID());
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+    Sensei_Utils::sensei_text_editor($question_data['user_answer_entry'],
28
+                                                'textquestion'.$question_data['ID'],
29
+                                                'sensei_question['.$question_data['ID'].']');
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-teacher-completed-course.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Teacher_Completed_Course' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Teacher_Completed_Course')) :
6 6
 
7 7
 /**
8 8
  * Teacher Completed Course
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	function __construct() {
33 33
 		$this->template = 'teacher-completed-course';
34
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your student has completed a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
35
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'Your student has completed a course', 'woothemes-sensei' ), $this->template );
34
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your student has completed a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
35
+		$this->heading = apply_filters('sensei_email_heading', __('Your student has completed a course', 'woothemes-sensei'), $this->template);
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
 	 * @access public
42 42
 	 * @return void
43 43
 	 */
44
-	function trigger( $learner_id = 0, $course_id = 0 ) {
44
+	function trigger($learner_id = 0, $course_id = 0) {
45 45
 		global  $sensei_email_data;
46 46
 
47 47
 		// Get learner user object
48
-		$this->learner = new WP_User( $learner_id );
48
+		$this->learner = new WP_User($learner_id);
49 49
 
50 50
 		// Get teacher ID and user object
51
-		$teacher_id = get_post_field( 'post_author', $course_id, 'raw' );
52
-		$this->teacher = new WP_User( $teacher_id );
51
+		$teacher_id = get_post_field('post_author', $course_id, 'raw');
52
+		$this->teacher = new WP_User($teacher_id);
53 53
 
54 54
 		// Get passed status
55
-		$passed = __( 'passed', 'woothemes-sensei' );
56
-		if( ! Sensei_Utils::sensei_user_passed_course( $course_id, $learner_id ) ) {
57
-			$passed = __( 'failed', 'woothemes-sensei' );
55
+		$passed = __('passed', 'woothemes-sensei');
56
+		if ( ! Sensei_Utils::sensei_user_passed_course($course_id, $learner_id)) {
57
+			$passed = __('failed', 'woothemes-sensei');
58 58
 		}
59 59
 
60 60
 		// Construct data array
61
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
61
+		$sensei_email_data = apply_filters('sensei_email_data', array(
62 62
 			'template'			=> $this->template,
63 63
 			'heading'			=> $this->heading,
64 64
 			'teacher_id'		=> $teacher_id,
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 			'learner_name'		=> $this->learner->display_name,
67 67
 			'course_id'			=> $course_id,
68 68
 			'passed'			=> $passed,
69
-		), $this->template );
69
+		), $this->template);
70 70
 
71 71
 		// Set recipient (learner)
72
-		$this->recipient = stripslashes( $this->teacher->user_email );
72
+		$this->recipient = stripslashes($this->teacher->user_email);
73 73
 
74 74
 		// Send mail
75
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
75
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
76 76
 	}
77 77
 }
78 78
 
Please login to merge, or discard this patch.
includes/emails/class-woothemes-sensei-email-learner-completed-course.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
4 4
 
5
-if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Completed_Course' ) ) :
5
+if ( ! class_exists('WooThemes_Sensei_Email_Learner_Completed_Course')) :
6 6
 
7 7
 /**
8 8
  * Learner Completed Course
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	function __construct() {
32 32
 		$this->template = 'learner-completed-course';
33
-		$this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have completed a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template );
34
-		$this->heading = apply_filters( 'sensei_email_heading', __( 'You have completed a course', 'woothemes-sensei' ), $this->template );
33
+		$this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have completed a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template);
34
+		$this->heading = apply_filters('sensei_email_heading', __('You have completed a course', 'woothemes-sensei'), $this->template);
35 35
 	}
36 36
 
37 37
 	/**
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
 	 * @access public
41 41
 	 * @return void
42 42
 	 */
43
-	function trigger( $user_id = 0, $course_id = 0 ) {
43
+	function trigger($user_id = 0, $course_id = 0) {
44 44
 		global  $sensei_email_data;
45 45
 
46 46
 		// Get learner user object
47
-		$this->user = new WP_User( $user_id );
47
+		$this->user = new WP_User($user_id);
48 48
 
49 49
 		// Get passed status
50
-		$passed = __( 'passed', 'woothemes-sensei' );
51
-		if( ! Sensei_Utils::sensei_user_passed_course( $course_id, $user_id ) ) {
52
-			$passed = __( 'failed', 'woothemes-sensei' );
50
+		$passed = __('passed', 'woothemes-sensei');
51
+		if ( ! Sensei_Utils::sensei_user_passed_course($course_id, $user_id)) {
52
+			$passed = __('failed', 'woothemes-sensei');
53 53
 		}
54 54
 
55 55
 		// Construct data array
56
-		$sensei_email_data = apply_filters( 'sensei_email_data', array(
56
+		$sensei_email_data = apply_filters('sensei_email_data', array(
57 57
 			'template'			=> $this->template,
58 58
 			'heading'			=> $this->heading,
59 59
 			'user_id'			=> $user_id,
60 60
 			'course_id'			=> $course_id,
61 61
 			'passed'			=> $passed,
62
-		), $this->template );
62
+		), $this->template);
63 63
 
64 64
 		// Set recipient (learner)
65
-		$this->recipient = stripslashes( $this->user->user_email );
65
+		$this->recipient = stripslashes($this->user->user_email);
66 66
 
67 67
 		// Send mail
68
-		Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) );
68
+		Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template));
69 69
 	}
70 70
 }
71 71
 
Please login to merge, or discard this patch.
includes/lib/woo-functions.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Queue updates for the WooUpdater
5 5
  */
6
-if ( ! function_exists( 'woothemes_queue_update' ) ) {
7
-	function woothemes_queue_update( $file, $file_id, $product_id ) {
6
+if ( ! function_exists('woothemes_queue_update')) {
7
+	function woothemes_queue_update($file, $file_id, $product_id) {
8 8
 		global $woothemes_queued_updates;
9 9
 
10
-		if ( ! isset( $woothemes_queued_updates ) )
10
+		if ( ! isset($woothemes_queued_updates))
11 11
 			$woothemes_queued_updates = array();
12 12
 
13 13
 		$plugin             = new stdClass();
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
  * Load installer for the WooThemes Updater.
24 24
  * @return $api Object
25 25
  */
26
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_install' ) ) {
27
-	function woothemes_updater_install( $api, $action, $args ) {
26
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_install')) {
27
+	function woothemes_updater_install($api, $action, $args) {
28 28
 		$download_url = 'http://woodojo.s3.amazonaws.com/downloads/woothemes-updater/woothemes-updater.zip';
29 29
 
30
-		if ( 'plugin_information' != $action ||
30
+		if ('plugin_information' != $action ||
31 31
 			false !== $api ||
32
-			! isset( $args->slug ) ||
32
+			! isset($args->slug) ||
33 33
 			'woothemes-updater' != $args->slug
34 34
 		) return $api;
35 35
 
36 36
 		$api = new stdClass();
37 37
 		$api->name = 'WooThemes Updater';
38 38
 		$api->version = '';
39
-		$api->download_link = esc_url( $download_url );
39
+		$api->download_link = esc_url($download_url);
40 40
 		return $api;
41 41
 	}
42 42
 
43
-	add_filter( 'plugins_api', 'woothemes_updater_install', 10, 3 );
43
+	add_filter('plugins_api', 'woothemes_updater_install', 10, 3);
44 44
 }
45 45
 
46 46
 /**
47 47
  * WooUpdater Installation Prompts
48 48
  */
49
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_notice' ) ) {
49
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_notice')) {
50 50
 
51 51
 	/**
52 52
 	 * Display a notice if the "WooThemes Updater" plugin hasn't been installed.
53 53
 	 * @return void
54 54
 	 */
55 55
 	function woothemes_updater_notice() {
56
-		$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
57
-		if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) return;
56
+		$active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
57
+		if (in_array('woothemes-updater/woothemes-updater.php', $active_plugins)) return;
58 58
 
59 59
 		$slug = 'woothemes-updater';
60
-		$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
61
-		$activate_url = 'plugins.php?action=activate&plugin=' . urlencode( 'woothemes-updater/woothemes-updater.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( 'activate-plugin_woothemes-updater/woothemes-updater.php' ) );
60
+		$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$slug), 'install-plugin_'.$slug);
61
+		$activate_url = 'plugins.php?action=activate&plugin='.urlencode('woothemes-updater/woothemes-updater.php').'&plugin_status=all&paged=1&s&_wpnonce='.urlencode(wp_create_nonce('activate-plugin_woothemes-updater/woothemes-updater.php'));
62 62
 
63
-		$message = '<a href="' . esc_url( $install_url ) . '">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
63
+		$message = '<a href="'.esc_url($install_url).'">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
64 64
 		$is_downloaded = false;
65
-		$plugins = array_keys( get_plugins() );
66
-		foreach ( $plugins as $plugin ) {
67
-			if ( strpos( $plugin, 'woothemes-updater.php' ) !== false ) {
65
+		$plugins = array_keys(get_plugins());
66
+		foreach ($plugins as $plugin) {
67
+			if (strpos($plugin, 'woothemes-updater.php') !== false) {
68 68
 				$is_downloaded = true;
69
-				$message = '<a href="' . esc_url( admin_url( $activate_url ) ) . '">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
69
+				$message = '<a href="'.esc_url(admin_url($activate_url)).'">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
70 70
 			}
71 71
 		}
72
-		echo '<div class="updated fade"><p>' . $message . '</p></div>' . "\n";
72
+		echo '<div class="updated fade"><p>'.$message.'</p></div>'."\n";
73 73
 	}
74 74
 
75
-	add_action( 'admin_notices', 'woothemes_updater_notice' );
75
+	add_action('admin_notices', 'woothemes_updater_notice');
76 76
 }
77 77
 
78 78
 /**
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
  * @param  $version Version to check against
82 82
  * @return @boolean
83 83
  */
84
-if( ! function_exists( 'sensei_check_woocommerce_version' ) ) {
85
-	function sensei_check_woocommerce_version( $version = '2.1' ) {
86
-		if ( Sensei_WC::is_woocommerce_active() ) {
84
+if ( ! function_exists('sensei_check_woocommerce_version')) {
85
+	function sensei_check_woocommerce_version($version = '2.1') {
86
+		if (Sensei_WC::is_woocommerce_active()) {
87 87
 			global $woocommerce;
88
-			if( version_compare( $woocommerce->version, $version, ">=" ) ) {
88
+			if (version_compare($woocommerce->version, $version, ">=")) {
89 89
 			    return true;
90 90
 			}
91 91
 		}
Please login to merge, or discard this patch.
includes/shortcodes/class-sensei-legacy-shortcodes.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
      *
16 16
      * @since 1.9.0
17 17
      */
18
-    public static function init(){
18
+    public static function init() {
19 19
 
20
-        add_shortcode( 'allcourses',      array( __CLASS__, 'all_courses' ) );
21
-        add_shortcode( 'newcourses',      array( __CLASS__,'new_courses' ) );
22
-        add_shortcode( 'featuredcourses', array( __CLASS__,'featured_courses') );
23
-        add_shortcode( 'freecourses',     array( __CLASS__,'free_courses') );
24
-        add_shortcode( 'paidcourses',     array( __CLASS__,'paid_courses') );
25
-        add_shortcode( 'usercourses',     array( __CLASS__,'user_courses' ) );
20
+        add_shortcode('allcourses', array(__CLASS__, 'all_courses'));
21
+        add_shortcode('newcourses', array(__CLASS__, 'new_courses'));
22
+        add_shortcode('featuredcourses', array(__CLASS__, 'featured_courses'));
23
+        add_shortcode('freecourses', array(__CLASS__, 'free_courses'));
24
+        add_shortcode('paidcourses', array(__CLASS__, 'paid_courses'));
25
+        add_shortcode('usercourses', array(__CLASS__, 'user_courses'));
26 26
 
27 27
     }
28 28
     /**
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
      * @param mixed $content (default: null)
36 36
      * @return string
37 37
      */
38
-    public static function all_courses( $atts, $content = null ) {
38
+    public static function all_courses($atts, $content = null) {
39 39
 
40
-        return self::generate_shortcode_courses( '', 'allcourses' ); // all courses but no title
40
+        return self::generate_shortcode_courses('', 'allcourses'); // all courses but no title
41 41
 
42 42
     } // all_courses()
43 43
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
      * @param mixed $content (default: null)
50 50
      * @return string
51 51
      */
52
-    public static function paid_courses( $atts, $content = null ) {
52
+    public static function paid_courses($atts, $content = null) {
53 53
 
54
-        return self::generate_shortcode_courses( 'Paid Courses', 'paidcourses' );
54
+        return self::generate_shortcode_courses('Paid Courses', 'paidcourses');
55 55
 
56 56
     } // End paid_courses()
57 57
 
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
      * @param mixed $content (default: null)
65 65
      * @return string
66 66
      */
67
-    public static function featured_courses( $atts, $content = null ) {
67
+    public static function featured_courses($atts, $content = null) {
68 68
 
69
-        return self::generate_shortcode_courses( 'Featured Courses', 'featuredcourses' );
69
+        return self::generate_shortcode_courses('Featured Courses', 'featuredcourses');
70 70
 
71 71
     } // End featured_courses()
72 72
 
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
      * @param mixed $content (default: null)
79 79
      * @return string
80 80
      */
81
-    public static function free_courses( $atts, $content = null ) {
81
+    public static function free_courses($atts, $content = null) {
82 82
 
83
-        return self::generate_shortcode_courses( 'Free Courses', 'freecourses' );
83
+        return self::generate_shortcode_courses('Free Courses', 'freecourses');
84 84
 
85 85
     } // End free_courses()
86 86
 
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
      * @param mixed $content (default: null)
93 93
      * @return string
94 94
      */
95
-    public static function new_courses( $atts, $content = null ) {
95
+    public static function new_courses($atts, $content = null) {
96 96
 
97
-        return self::generate_shortcode_courses( 'New Courses', 'newcourses' );
97
+        return self::generate_shortcode_courses('New Courses', 'newcourses');
98 98
 
99 99
     } // End new_courses()
100 100
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      * @param $shortcode_specific_override
108 108
      * @return string
109 109
      */
110
-    public static function generate_shortcode_courses( $title , $shortcode_specific_override  ){
110
+    public static function generate_shortcode_courses($title, $shortcode_specific_override) {
111 111
 
112 112
         global  $shortcode_override, $posts_array;
113 113
 
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 
116 116
         // do not show this short code if there is a shortcode int he url and
117 117
         // this specific shortcode is not the one requested in the ur.
118
-        $specific_shortcode_requested = isset( $_GET['action'] ) ?  sanitize_text_field(  $_GET['action']  ) : '';
119
-        if( ! empty( $specific_shortcode_requested) &&
120
-            $specific_shortcode_requested != $shortcode_override ){
118
+        $specific_shortcode_requested = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
119
+        if ( ! empty($specific_shortcode_requested) &&
120
+            $specific_shortcode_requested != $shortcode_override) {
121 121
 
122 122
             return '';
123 123
 
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
         $courses = ob_get_clean();
130 130
 
131 131
         $content = '';
132
-        if( count( $posts_array ) > 0 ){
132
+        if (count($posts_array) > 0) {
133 133
 
134
-            $before = empty($title)? '' : '<header class="archive-header"><h2>'. $title .'</h2></header>';
134
+            $before = empty($title) ? '' : '<header class="archive-header"><h2>'.$title.'</h2></header>';
135 135
             $before .= '<section id="main-course" class="course-container">';
136 136
 
137 137
             $after = '</section>';
138 138
 
139 139
             //assemble
140
-            $content = $before . $courses . $after;
140
+            $content = $before.$courses.$after;
141 141
 
142 142
         }
143 143
 
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
      * @param mixed $content (default: null)
155 155
      * @return string
156 156
      */
157
-    public static function user_courses( $atts, $content = null ) {
157
+    public static function user_courses($atts, $content = null) {
158 158
         global $shortcode_override;
159
-        extract( shortcode_atts( array(	'amount' => 0 ), $atts ) );
159
+        extract(shortcode_atts(array('amount' => 0), $atts));
160 160
 
161 161
         $shortcode_override = 'usercourses';
162 162
 
163 163
         ob_start();
164 164
 
165
-        if( is_user_logged_in() ){
165
+        if (is_user_logged_in()) {
166 166
 
167
-            Sensei_Templates::get_template( 'user/my-courses.php' );
167
+            Sensei_Templates::get_template('user/my-courses.php');
168 168
 
169
-        }else{
169
+        } else {
170 170
 
171 171
             Sensei()->frontend->sensei_login_form();
172 172
 
@@ -182,54 +182,54 @@  discard block
 block discarded – undo
182 182
      * loop-course.php for the old shortcodes.
183 183
      * @since 1.9.0
184 184
      */
185
-    public static function initialise_legacy_course_loop(){
185
+    public static function initialise_legacy_course_loop() {
186 186
 
187 187
         global  $post, $wp_query, $shortcode_override, $course_excludes;
188 188
 
189 189
         // Handle Query Type
190 190
         $query_type = '';
191 191
 
192
-        if ( isset( $_GET[ 'action' ] ) && ( '' != esc_html( $_GET[ 'action' ] ) ) ) {
193
-            $query_type = esc_html( $_GET[ 'action' ] );
192
+        if (isset($_GET['action']) && ('' != esc_html($_GET['action']))) {
193
+            $query_type = esc_html($_GET['action']);
194 194
         } // End If Statement
195 195
 
196
-        if ( '' != $shortcode_override ) {
196
+        if ('' != $shortcode_override) {
197 197
             $query_type = $shortcode_override;
198 198
         } // End If Statement
199 199
 
200
-        if ( !is_array( $course_excludes ) ) { $course_excludes = array(); }
200
+        if ( ! is_array($course_excludes)) { $course_excludes = array(); }
201 201
 
202 202
         // Check that query returns results
203 203
         // Handle Pagination
204
-        $paged = $wp_query->get( 'paged' );
205
-        $paged = empty( $paged ) ? 1 : $paged;
204
+        $paged = $wp_query->get('paged');
205
+        $paged = empty($paged) ? 1 : $paged;
206 206
 
207 207
 
208 208
         // Check for pagination settings
209
-        if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) {
209
+        if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) {
210 210
 
211
-            $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
211
+            $amount = absint(Sensei()->settings->settings['course_archive_amount']);
212 212
 
213 213
         } else {
214 214
 
215
-            $amount = $wp_query->get( 'posts_per_page' );
215
+            $amount = $wp_query->get('posts_per_page');
216 216
 
217 217
         } // End If Statement
218 218
 
219 219
         // This is not a paginated page (or it's simply the first page of a paginated page/post)
220 220
 
221 221
         global $posts_array;
222
-        $course_includes   = array();
222
+        $course_includes = array();
223 223
 
224
-        $query_args = Sensei()->course->get_archive_query_args( $shortcode_override, $amount, $course_includes, $course_excludes );
225
-        $course_query = new WP_Query( $query_args );
224
+        $query_args = Sensei()->course->get_archive_query_args($shortcode_override, $amount, $course_includes, $course_excludes);
225
+        $course_query = new WP_Query($query_args);
226 226
         $posts_array = $course_query->get_posts();
227 227
 
228 228
         // output the courses
229
-        if( ! empty( $posts_array ) ) {
229
+        if ( ! empty($posts_array)) {
230 230
 
231 231
             //output all courses for current query
232
-            self::loop_courses( $course_query, $amount );
232
+            self::loop_courses($course_query, $amount);
233 233
 
234 234
         }
235 235
 
@@ -242,31 +242,31 @@  discard block
 block discarded – undo
242 242
      *
243 243
      * @param WP_Query $course_query
244 244
      */
245
-    public static function loop_courses( $course_query, $amount ){
245
+    public static function loop_courses($course_query, $amount) {
246 246
 
247 247
         global $shortcode_override, $posts_array, $post, $wp_query, $shortcode_override, $course_excludes, $course_includes;
248 248
 
249
-        if ( count( $course_query->get_posts() ) > 0 ) {
249
+        if (count($course_query->get_posts()) > 0) {
250 250
 
251
-            do_action( 'sensei_course_archive_header', $shortcode_override );
251
+            do_action('sensei_course_archive_header', $shortcode_override);
252 252
 
253
-            foreach ( $course_query->get_posts() as $course){
253
+            foreach ($course_query->get_posts() as $course) {
254 254
 
255 255
                 // Make sure the other loops dont include the same post twice!
256
-                array_push( $course_excludes, $course->ID );
256
+                array_push($course_excludes, $course->ID);
257 257
 
258 258
                 // output the course markup
259
-                self::the_course( $course->ID );
259
+                self::the_course($course->ID);
260 260
 
261 261
             } // End For Loop
262 262
 
263 263
             // More and Prev links
264
-            $posts_array_query = new WP_Query(Sensei()->course->course_query( $shortcode_override, $amount, $course_includes, $course_excludes ) );
264
+            $posts_array_query = new WP_Query(Sensei()->course->course_query($shortcode_override, $amount, $course_includes, $course_excludes));
265 265
             $posts_array       = $posts_array_query->get_posts();
266 266
             $max_pages = $course_query->found_posts / $amount;
267
-            if ( '' != $shortcode_override && ( $max_pages > $course_query->get( 'paged' ) ) ) {
267
+            if ('' != $shortcode_override && ($max_pages > $course_query->get('paged'))) {
268 268
 
269
-                switch( $shortcode_override ){
269
+                switch ($shortcode_override) {
270 270
                     case 'paidcourses':
271 271
                         $filter = 'paid';
272 272
                         break;
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
                 }
283 283
 
284 284
                 $quer_args = array();
285
-                $quer_args[ 'paged' ] = '2';
286
-                if( !empty( $filter ) ){
287
-                    $quer_args[ 'course_filter' ] = $filter;
285
+                $quer_args['paged'] = '2';
286
+                if ( ! empty($filter)) {
287
+                    $quer_args['course_filter'] = $filter;
288 288
                 }
289 289
 
290
-                $course_pagination_link = get_post_type_archive_link( 'course' );
291
-                $more_link_text = esc_html( Sensei()->settings->settings[ 'course_archive_more_link_text' ] );
292
-                $more_link_url =  esc_url( add_query_arg( $quer_args, $course_pagination_link ) );
290
+                $course_pagination_link = get_post_type_archive_link('course');
291
+                $more_link_text = esc_html(Sensei()->settings->settings['course_archive_more_link_text']);
292
+                $more_link_url = esc_url(add_query_arg($quer_args, $course_pagination_link));
293 293
 
294 294
                 // next/more
295 295
                 $html  = '<div class="navigation"><div class="nav-next">';
296
-                $html .= '<a href="' . $more_link_url . '">';
296
+                $html .= '<a href="'.$more_link_url.'">';
297 297
                 $html .= $more_link_text;
298 298
                 $html .= '<span class="meta-nav"></span></a></div>';
299 299
 
300
-                echo apply_filters( 'course_archive_next_link', $html );
300
+                echo apply_filters('course_archive_next_link', $html);
301 301
 
302 302
             } // End If Statement
303 303
 
@@ -309,23 +309,23 @@  discard block
 block discarded – undo
309 309
      *
310 310
      * @param $course_id
311 311
      */
312
-    public static function the_course( $course_id ){
312
+    public static function the_course($course_id) {
313 313
 
314 314
         // Get meta data
315
-        $course =  get_post( $course_id );
316
-        $user_info = get_userdata( absint( $course->post_author ) );
317
-        $author_link = get_author_posts_url( absint( $course->post_author ) );
315
+        $course = get_post($course_id);
316
+        $user_info = get_userdata(absint($course->post_author));
317
+        $author_link = get_author_posts_url(absint($course->post_author));
318 318
         $author_display_name = $user_info->display_name;
319 319
         $author_id = $course->post_author;
320
-        $category_output = get_the_term_list( $course_id, 'course-category', '', ', ', '' );
321
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course_id ) );
322
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
320
+        $category_output = get_the_term_list($course_id, 'course-category', '', ', ', '');
321
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course_id));
322
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
323 323
         ?>
324 324
 
325
-        <article class="<?php echo esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_id ) ) ); ?>">
325
+        <article class="<?php echo esc_attr(join(' ', get_post_class(array('course', 'post'), $course_id))); ?>">
326 326
             <?php
327 327
             // so that legacy shortcodes work with thir party plugins that wants to hook in
328
-            do_action('sensei_course_content_before',$course );
328
+            do_action('sensei_course_content_before', $course);
329 329
             ?>
330 330
             <div class="course-content">
331 331
 
@@ -341,19 +341,19 @@  discard block
 block discarded – undo
341 341
 
342 342
                     <p class="sensei-course-meta">
343 343
 
344
-                        <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
345
-                            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name   ); ?></a></span>
344
+                        <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
345
+                            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo $author_link; ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span>
346 346
                         <?php } // End If Statement ?>
347 347
 
348 348
                         <span class="course-lesson-count">
349
-                                    <?php echo Sensei()->course->course_lesson_count( $course_id ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?>
349
+                                    <?php echo Sensei()->course->course_lesson_count($course_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?>
350 350
                                 </span>
351 351
 
352
-                        <?php if ( '' != $category_output ) { ?>
353
-                            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
352
+                        <?php if ('' != $category_output) { ?>
353
+                            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
354 354
                         <?php } // End If Statement ?>
355 355
 
356
-                        <?php sensei_simple_course_price( $course_id ); ?>
356
+                        <?php sensei_simple_course_price($course_id); ?>
357 357
 
358 358
                     </p>
359 359
 
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 
362 362
                     </p>
363 363
 
364
-                    <?php if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
365
-                        $preview_lessons = sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ); ?>
364
+                    <?php if (0 < $preview_lesson_count && ! $is_user_taking_course) {
365
+                        $preview_lessons = sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
366 366
                         <p class="sensei-free-lessons">
367
-                            <a href="<?php echo get_permalink( $course_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
367
+                            <a href="<?php echo get_permalink($course_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?>
368 368
                             </a> - <?php echo $preview_lessons; ?>
369 369
                         </p>
370 370
                     <?php } ?>
Please login to merge, or discard this patch.