@@ -17,270 +17,270 @@ |
||
17 | 17 | */ |
18 | 18 | class Sensei_Shortcode_Teachers implements Sensei_Shortcode_Interface { |
19 | 19 | |
20 | - /** |
|
21 | - * @var WP_User_Query keeps a reference to the user query created |
|
22 | - */ |
|
23 | - protected $user_query; |
|
20 | + /** |
|
21 | + * @var WP_User_Query keeps a reference to the user query created |
|
22 | + */ |
|
23 | + protected $user_query; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var which user id's to include |
|
27 | - */ |
|
28 | - protected $include; |
|
25 | + /** |
|
26 | + * @var which user id's to include |
|
27 | + */ |
|
28 | + protected $include; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var which user id's to exclude |
|
32 | - */ |
|
33 | - protected $exclude; |
|
30 | + /** |
|
31 | + * @var which user id's to exclude |
|
32 | + */ |
|
33 | + protected $exclude; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Setup the shortcode object |
|
37 | - * |
|
38 | - * @since 1.9.0 |
|
39 | - * @param array $attributes |
|
40 | - * @param string $content |
|
41 | - * @param string $shortcode the shortcode that was called for this instance |
|
42 | - */ |
|
43 | - public function __construct( $attributes, $content, $shortcode ){ |
|
35 | + /** |
|
36 | + * Setup the shortcode object |
|
37 | + * |
|
38 | + * @since 1.9.0 |
|
39 | + * @param array $attributes |
|
40 | + * @param string $content |
|
41 | + * @param string $shortcode the shortcode that was called for this instance |
|
42 | + */ |
|
43 | + public function __construct( $attributes, $content, $shortcode ){ |
|
44 | 44 | |
45 | - $include = isset( $attributes['include'] ) ? explode( ',', $attributes['include'] ) : ''; |
|
46 | - $exclude = isset( $attributes['exclude'] ) ? explode( ',', $attributes['exclude'] ) : ''; |
|
45 | + $include = isset( $attributes['include'] ) ? explode( ',', $attributes['include'] ) : ''; |
|
46 | + $exclude = isset( $attributes['exclude'] ) ? explode( ',', $attributes['exclude'] ) : ''; |
|
47 | 47 | |
48 | - // convert teacher usernames given to the id |
|
49 | - $this->include = $this->convert_usernames_to_ids( $include ); |
|
50 | - $this->exclude = $this->convert_usernames_to_ids( $exclude ); |
|
48 | + // convert teacher usernames given to the id |
|
49 | + $this->include = $this->convert_usernames_to_ids( $include ); |
|
50 | + $this->exclude = $this->convert_usernames_to_ids( $exclude ); |
|
51 | 51 | |
52 | - $this->setup_teacher_query(); |
|
52 | + $this->setup_teacher_query(); |
|
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * |
|
58 | - * Setup the user query that will be used in the render method |
|
59 | - * |
|
60 | - * @since 1.9.0 |
|
61 | - */ |
|
62 | - protected function setup_teacher_query(){ |
|
56 | + /** |
|
57 | + * |
|
58 | + * Setup the user query that will be used in the render method |
|
59 | + * |
|
60 | + * @since 1.9.0 |
|
61 | + */ |
|
62 | + protected function setup_teacher_query(){ |
|
63 | 63 | |
64 | - $user_query_args = array( |
|
65 | - 'role' => 'teacher', |
|
66 | - ); |
|
64 | + $user_query_args = array( |
|
65 | + 'role' => 'teacher', |
|
66 | + ); |
|
67 | 67 | |
68 | - $this->user_query = new WP_User_Query( $user_query_args ); |
|
68 | + $this->user_query = new WP_User_Query( $user_query_args ); |
|
69 | 69 | |
70 | - }// end setup _course_query |
|
70 | + }// end setup _course_query |
|
71 | 71 | |
72 | - /** |
|
73 | - * Rendering the shortcode this class is responsible for. |
|
74 | - * |
|
75 | - * @return string $content |
|
76 | - */ |
|
77 | - public function render(){ |
|
72 | + /** |
|
73 | + * Rendering the shortcode this class is responsible for. |
|
74 | + * |
|
75 | + * @return string $content |
|
76 | + */ |
|
77 | + public function render(){ |
|
78 | 78 | |
79 | - $all_users = $this->user_query->get_results(); |
|
80 | - // if the user has specified more users add them as well. |
|
81 | - if( ! empty( $this->include ) ){ |
|
79 | + $all_users = $this->user_query->get_results(); |
|
80 | + // if the user has specified more users add them as well. |
|
81 | + if( ! empty( $this->include ) ){ |
|
82 | 82 | |
83 | - $included_users_query = new WP_User_Query( array( 'include' => $this->include ) ); |
|
84 | - $included_users = $included_users_query->get_results(); |
|
85 | - if( ! empty( $included_users ) ){ |
|
83 | + $included_users_query = new WP_User_Query( array( 'include' => $this->include ) ); |
|
84 | + $included_users = $included_users_query->get_results(); |
|
85 | + if( ! empty( $included_users ) ){ |
|
86 | 86 | |
87 | - $merged_users = array_merge( $all_users, $included_users ); |
|
88 | - $all_users = $this->users_unique( $merged_users ); |
|
89 | - $all_users = $this->users_sort( $all_users ); |
|
87 | + $merged_users = array_merge( $all_users, $included_users ); |
|
88 | + $all_users = $this->users_unique( $merged_users ); |
|
89 | + $all_users = $this->users_sort( $all_users ); |
|
90 | 90 | |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - } |
|
93 | + } |
|
94 | 94 | |
95 | - // exclude the users not wanted |
|
96 | - if( ! empty( $this->exclude ) ){ |
|
95 | + // exclude the users not wanted |
|
96 | + if( ! empty( $this->exclude ) ){ |
|
97 | 97 | |
98 | - $all_users = $this->exclude_users( $all_users, $this->exclude ); |
|
98 | + $all_users = $this->exclude_users( $all_users, $this->exclude ); |
|
99 | 99 | |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - if( ! count( $all_users )> 0 ){ |
|
103 | - return ''; |
|
104 | - } |
|
102 | + if( ! count( $all_users )> 0 ){ |
|
103 | + return ''; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - $users_output = ''; |
|
107 | + $users_output = ''; |
|
108 | 108 | |
109 | - foreach ( $all_users as $user ) { |
|
109 | + foreach ( $all_users as $user ) { |
|
110 | 110 | |
111 | - $user_display_name = $this->get_user_public_name( $user ); |
|
111 | + $user_display_name = $this->get_user_public_name( $user ); |
|
112 | 112 | |
113 | - /** |
|
114 | - * Sensei teachers shortcode list item filter |
|
115 | - * |
|
116 | - * @since 1.9.0 |
|
117 | - * |
|
118 | - * @param string $teacher_li the html for the teacher li |
|
119 | - * @param WP_User $user |
|
120 | - */ |
|
121 | - $users_output .= apply_filters( 'sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'. get_author_posts_url( $user->ID ) . '">'. $user_display_name . '<a/></li>', $user ); |
|
113 | + /** |
|
114 | + * Sensei teachers shortcode list item filter |
|
115 | + * |
|
116 | + * @since 1.9.0 |
|
117 | + * |
|
118 | + * @param string $teacher_li the html for the teacher li |
|
119 | + * @param WP_User $user |
|
120 | + */ |
|
121 | + $users_output .= apply_filters( 'sensei_teachers_shortcode_list_item', '<li class="teacher"><a href="'. get_author_posts_url( $user->ID ) . '">'. $user_display_name . '<a/></li>', $user ); |
|
122 | 122 | |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | - return '<ul class="sensei-teachers">' . $users_output . '</ul>'; |
|
125 | + return '<ul class="sensei-teachers">' . $users_output . '</ul>'; |
|
126 | 126 | |
127 | - }// end render |
|
127 | + }// end render |
|
128 | 128 | |
129 | - /** |
|
130 | - * remove duplicate user objects from and array of users |
|
131 | - * |
|
132 | - * @since 1.9.0 |
|
133 | - * |
|
134 | - * @param array $users{ |
|
135 | - * @type WP_User |
|
136 | - * } |
|
137 | - * |
|
138 | - * @return array $unique_users { |
|
139 | - * @type WP_User |
|
140 | - * } |
|
141 | - */ |
|
142 | - public function users_unique( $users ){ |
|
129 | + /** |
|
130 | + * remove duplicate user objects from and array of users |
|
131 | + * |
|
132 | + * @since 1.9.0 |
|
133 | + * |
|
134 | + * @param array $users{ |
|
135 | + * @type WP_User |
|
136 | + * } |
|
137 | + * |
|
138 | + * @return array $unique_users { |
|
139 | + * @type WP_User |
|
140 | + * } |
|
141 | + */ |
|
142 | + public function users_unique( $users ){ |
|
143 | 143 | |
144 | - $array_unique_users_ids = array(); |
|
145 | - foreach( $users as $index => $user ){ |
|
144 | + $array_unique_users_ids = array(); |
|
145 | + foreach( $users as $index => $user ){ |
|
146 | 146 | |
147 | - if( in_array( $user->ID, $array_unique_users_ids) ){ |
|
147 | + if( in_array( $user->ID, $array_unique_users_ids) ){ |
|
148 | 148 | |
149 | - // exclude this user as it is already in the list |
|
150 | - unset( $users[ $index ] ); |
|
149 | + // exclude this user as it is already in the list |
|
150 | + unset( $users[ $index ] ); |
|
151 | 151 | |
152 | - }else{ |
|
152 | + }else{ |
|
153 | 153 | |
154 | - // add teh user to the list of users |
|
155 | - $array_unique_users_ids[] = $user->ID; |
|
154 | + // add teh user to the list of users |
|
155 | + $array_unique_users_ids[] = $user->ID; |
|
156 | 156 | |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - return $users; |
|
161 | + return $users; |
|
162 | 162 | |
163 | - }// end users_unique |
|
163 | + }// end users_unique |
|
164 | 164 | |
165 | - /** |
|
166 | - * Exclude users based ont he ids given. |
|
167 | - * |
|
168 | - * @since 1.9.0 |
|
169 | - * |
|
170 | - * @param array $users |
|
171 | - * @param array $exclude_ids |
|
172 | - * @return array |
|
173 | - */ |
|
174 | - public function exclude_users( $users, $exclude_ids ){ |
|
165 | + /** |
|
166 | + * Exclude users based ont he ids given. |
|
167 | + * |
|
168 | + * @since 1.9.0 |
|
169 | + * |
|
170 | + * @param array $users |
|
171 | + * @param array $exclude_ids |
|
172 | + * @return array |
|
173 | + */ |
|
174 | + public function exclude_users( $users, $exclude_ids ){ |
|
175 | 175 | |
176 | - foreach( $users as $index => $user ){ |
|
176 | + foreach( $users as $index => $user ){ |
|
177 | 177 | |
178 | - if( in_array( $user->ID, $exclude_ids ) ){ |
|
178 | + if( in_array( $user->ID, $exclude_ids ) ){ |
|
179 | 179 | |
180 | - // remove the user from the list |
|
181 | - unset( $users[ $index ] ); |
|
180 | + // remove the user from the list |
|
181 | + unset( $users[ $index ] ); |
|
182 | 182 | |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | - } |
|
185 | + } |
|
186 | 186 | |
187 | - return $users; |
|
187 | + return $users; |
|
188 | 188 | |
189 | - }// end exclude_users |
|
189 | + }// end exclude_users |
|
190 | 190 | |
191 | - /** |
|
192 | - * Convert mixed array of user id and user names to only be an array of user_ids |
|
193 | - * |
|
194 | - * @param array $users |
|
195 | - * @return array $users_ids |
|
196 | - */ |
|
197 | - public function convert_usernames_to_ids( $users ){ |
|
191 | + /** |
|
192 | + * Convert mixed array of user id and user names to only be an array of user_ids |
|
193 | + * |
|
194 | + * @param array $users |
|
195 | + * @return array $users_ids |
|
196 | + */ |
|
197 | + public function convert_usernames_to_ids( $users ){ |
|
198 | 198 | |
199 | - // backup |
|
200 | - $users_ids = array(); |
|
199 | + // backup |
|
200 | + $users_ids = array(); |
|
201 | 201 | |
202 | - if ( is_array($users) ) { |
|
202 | + if ( is_array($users) ) { |
|
203 | 203 | |
204 | - foreach ($users as $user_id_or_username) { |
|
204 | + foreach ($users as $user_id_or_username) { |
|
205 | 205 | |
206 | - if (!is_numeric($user_id_or_username)) { |
|
206 | + if (!is_numeric($user_id_or_username)) { |
|
207 | 207 | |
208 | - $user_name = $user_id_or_username; |
|
209 | - $user = get_user_by('login', $user_name); |
|
208 | + $user_name = $user_id_or_username; |
|
209 | + $user = get_user_by('login', $user_name); |
|
210 | 210 | |
211 | - if (is_a($user, 'WP_User')) { |
|
212 | - $users_ids[] = $user->ID; |
|
213 | - } |
|
211 | + if (is_a($user, 'WP_User')) { |
|
212 | + $users_ids[] = $user->ID; |
|
213 | + } |
|
214 | 214 | |
215 | - } else { |
|
215 | + } else { |
|
216 | 216 | |
217 | - $user_id = $user_id_or_username; |
|
218 | - $users_ids[] = $user_id; |
|
217 | + $user_id = $user_id_or_username; |
|
218 | + $users_ids[] = $user_id; |
|
219 | 219 | |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - } |
|
223 | - } |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - return $users_ids; |
|
226 | - } |
|
225 | + return $users_ids; |
|
226 | + } |
|
227 | 227 | |
228 | - /** |
|
229 | - * Returns the first name and last name or the display name of a user. |
|
230 | - * |
|
231 | - * @since 1.9.0 |
|
232 | - * |
|
233 | - * @param $user |
|
234 | - * @return string $user_public_name |
|
235 | - */ |
|
236 | - public function get_user_public_name( $user ){ |
|
228 | + /** |
|
229 | + * Returns the first name and last name or the display name of a user. |
|
230 | + * |
|
231 | + * @since 1.9.0 |
|
232 | + * |
|
233 | + * @param $user |
|
234 | + * @return string $user_public_name |
|
235 | + */ |
|
236 | + public function get_user_public_name( $user ){ |
|
237 | 237 | |
238 | - if (!empty($user->first_name) && !empty($user->last_name)) { |
|
238 | + if (!empty($user->first_name) && !empty($user->last_name)) { |
|
239 | 239 | |
240 | - $user_public_name = $user->first_name . ' ' . $user->last_name; |
|
240 | + $user_public_name = $user->first_name . ' ' . $user->last_name; |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - else { |
|
244 | + else { |
|
245 | 245 | |
246 | - $user_public_name = $user->display_name; |
|
246 | + $user_public_name = $user->display_name; |
|
247 | 247 | |
248 | - } |
|
248 | + } |
|
249 | 249 | |
250 | - return $user_public_name; |
|
251 | - } |
|
250 | + return $user_public_name; |
|
251 | + } |
|
252 | 252 | |
253 | - /** |
|
254 | - * |
|
255 | - * Sort user objects by user display |
|
256 | - * |
|
257 | - * @since 1.9.0 |
|
258 | - * |
|
259 | - * @param $users |
|
260 | - * @return array $sorted_users |
|
261 | - */ |
|
262 | - public function users_sort( $users ){ |
|
253 | + /** |
|
254 | + * |
|
255 | + * Sort user objects by user display |
|
256 | + * |
|
257 | + * @since 1.9.0 |
|
258 | + * |
|
259 | + * @param $users |
|
260 | + * @return array $sorted_users |
|
261 | + */ |
|
262 | + public function users_sort( $users ){ |
|
263 | 263 | |
264 | - $sorted_users = $users; |
|
264 | + $sorted_users = $users; |
|
265 | 265 | |
266 | - uasort( $sorted_users, array( $this, 'custom_user_sort' ) ); |
|
266 | + uasort( $sorted_users, array( $this, 'custom_user_sort' ) ); |
|
267 | 267 | |
268 | - return $sorted_users; |
|
269 | - } |
|
268 | + return $sorted_users; |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * Used in the uasort function to sort users by title |
|
273 | - * |
|
274 | - * @since 1.9.0 |
|
275 | - * |
|
276 | - * @param $user_1 |
|
277 | - * @param $user_2 |
|
278 | - * @return int |
|
279 | - */ |
|
280 | - public function custom_user_sort($user_1, $user_2){ |
|
271 | + /** |
|
272 | + * Used in the uasort function to sort users by title |
|
273 | + * |
|
274 | + * @since 1.9.0 |
|
275 | + * |
|
276 | + * @param $user_1 |
|
277 | + * @param $user_2 |
|
278 | + * @return int |
|
279 | + */ |
|
280 | + public function custom_user_sort($user_1, $user_2){ |
|
281 | 281 | |
282 | - return strcasecmp( $this->get_user_public_name( $user_1 ), $this->get_user_public_name( $user_2 ) ); |
|
282 | + return strcasecmp( $this->get_user_public_name( $user_1 ), $this->get_user_public_name( $user_2 ) ); |
|
283 | 283 | |
284 | - }// end custom_user_sort |
|
284 | + }// end custom_user_sort |
|
285 | 285 | |
286 | 286 | }// end class |
287 | 287 | \ No newline at end of file |
@@ -24,135 +24,135 @@ |
||
24 | 24 | */ |
25 | 25 | class Sensei_Shortcode_Course_Categories implements Sensei_Shortcode_Interface { |
26 | 26 | |
27 | - /** |
|
28 | - * @var array list of taxonomy terms. |
|
29 | - */ |
|
30 | - protected $sensei_course_taxonomy_terms; |
|
27 | + /** |
|
28 | + * @var array list of taxonomy terms. |
|
29 | + */ |
|
30 | + protected $sensei_course_taxonomy_terms; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Setup the shortcode object |
|
34 | - * |
|
35 | - * @since 1.9.0 |
|
36 | - * @param array $attributes |
|
37 | - * @param string $content |
|
38 | - * @param string $shortcode the shortcode that was called for this instance |
|
39 | - */ |
|
40 | - public function __construct( $attributes, $content, $shortcode ){ |
|
32 | + /** |
|
33 | + * Setup the shortcode object |
|
34 | + * |
|
35 | + * @since 1.9.0 |
|
36 | + * @param array $attributes |
|
37 | + * @param string $content |
|
38 | + * @param string $shortcode the shortcode that was called for this instance |
|
39 | + */ |
|
40 | + public function __construct( $attributes, $content, $shortcode ){ |
|
41 | 41 | |
42 | - $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'name'; |
|
43 | - $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
|
44 | - $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '100'; |
|
45 | - $this->parent = isset( $attributes['parent'] ) ? $attributes['parent'] : ''; |
|
42 | + $this->orderby = isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'name'; |
|
43 | + $this->order = isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'; |
|
44 | + $this->number = isset( $attributes['number'] ) ? $attributes['number'] : '100'; |
|
45 | + $this->parent = isset( $attributes['parent'] ) ? $attributes['parent'] : ''; |
|
46 | 46 | |
47 | - $include = isset( $attributes['include'] ) ? explode( ',' , $attributes['include'] ) : ''; |
|
48 | - $this->include = $this->generate_term_ids( $include ); |
|
47 | + $include = isset( $attributes['include'] ) ? explode( ',' , $attributes['include'] ) : ''; |
|
48 | + $this->include = $this->generate_term_ids( $include ); |
|
49 | 49 | |
50 | - $exclude = isset( $attributes['exclude'] ) ? explode( ',' , $attributes['exclude'] ) : ''; |
|
51 | - $this->exclude = $this->generate_term_ids( $exclude ); |
|
50 | + $exclude = isset( $attributes['exclude'] ) ? explode( ',' , $attributes['exclude'] ) : ''; |
|
51 | + $this->exclude = $this->generate_term_ids( $exclude ); |
|
52 | 52 | |
53 | - // make sure we handle string true/false values correctly with respective defaults |
|
54 | - $hide_empty = isset( $attributes['hide_empty'] ) ? $attributes['hide_empty'] : 'false'; |
|
55 | - $this->hide_empty = 'true' == $hide_empty ? true: false; |
|
53 | + // make sure we handle string true/false values correctly with respective defaults |
|
54 | + $hide_empty = isset( $attributes['hide_empty'] ) ? $attributes['hide_empty'] : 'false'; |
|
55 | + $this->hide_empty = 'true' == $hide_empty ? true: false; |
|
56 | 56 | |
57 | - $this->setup_course_categories(); |
|
57 | + $this->setup_course_categories(); |
|
58 | 58 | |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * create the messages query . |
|
63 | - * |
|
64 | - * @return mixed |
|
65 | - */ |
|
66 | - public function setup_course_categories(){ |
|
61 | + /** |
|
62 | + * create the messages query . |
|
63 | + * |
|
64 | + * @return mixed |
|
65 | + */ |
|
66 | + public function setup_course_categories(){ |
|
67 | 67 | |
68 | - $args = array( |
|
69 | - 'orderby' => $this->orderby, |
|
70 | - 'order' => $this->order, |
|
71 | - 'exclude' => $this->exclude, |
|
72 | - 'include' => $this->include, |
|
73 | - 'number' => $this->number, |
|
74 | - 'parent' => $this->parent, |
|
75 | - 'hide_empty' => $this->hide_empty, |
|
76 | - 'fields' => 'all', |
|
77 | - ); |
|
68 | + $args = array( |
|
69 | + 'orderby' => $this->orderby, |
|
70 | + 'order' => $this->order, |
|
71 | + 'exclude' => $this->exclude, |
|
72 | + 'include' => $this->include, |
|
73 | + 'number' => $this->number, |
|
74 | + 'parent' => $this->parent, |
|
75 | + 'hide_empty' => $this->hide_empty, |
|
76 | + 'fields' => 'all', |
|
77 | + ); |
|
78 | 78 | |
79 | - $this->sensei_course_taxonomy_terms = get_terms('course-category', $args); |
|
79 | + $this->sensei_course_taxonomy_terms = get_terms('course-category', $args); |
|
80 | 80 | |
81 | - } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Rendering the shortcode this class is responsible for. |
|
85 | - * |
|
86 | - * @return string $content |
|
87 | - */ |
|
88 | - public function render(){ |
|
83 | + /** |
|
84 | + * Rendering the shortcode this class is responsible for. |
|
85 | + * |
|
86 | + * @return string $content |
|
87 | + */ |
|
88 | + public function render(){ |
|
89 | 89 | |
90 | - if( empty( $this->sensei_course_taxonomy_terms ) ){ |
|
90 | + if( empty( $this->sensei_course_taxonomy_terms ) ){ |
|
91 | 91 | |
92 | - return __( 'No course categories found.', 'woothemes-sensei' ); |
|
92 | + return __( 'No course categories found.', 'woothemes-sensei' ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | - $terms_html = ''; |
|
96 | + $terms_html = ''; |
|
97 | 97 | |
98 | - //set the wp_query to the current messages query |
|
99 | - $terms_html .= '<ul class="sensei course-categories">'; |
|
100 | - foreach( $this->sensei_course_taxonomy_terms as $category ){ |
|
98 | + //set the wp_query to the current messages query |
|
99 | + $terms_html .= '<ul class="sensei course-categories">'; |
|
100 | + foreach( $this->sensei_course_taxonomy_terms as $category ){ |
|
101 | 101 | |
102 | - $category_link = '<a href="'. get_term_link( $category ) . '">' . $category->name . '</a>'; |
|
103 | - $terms_html .= '<li class="sensei course-category" >' . $category_link . '</li>'; |
|
102 | + $category_link = '<a href="'. get_term_link( $category ) . '">' . $category->name . '</a>'; |
|
103 | + $terms_html .= '<li class="sensei course-category" >' . $category_link . '</li>'; |
|
104 | 104 | |
105 | - } |
|
106 | - $terms_html .= '<ul>'; |
|
105 | + } |
|
106 | + $terms_html .= '<ul>'; |
|
107 | 107 | |
108 | - return $terms_html; |
|
108 | + return $terms_html; |
|
109 | 109 | |
110 | - }// end render |
|
110 | + }// end render |
|
111 | 111 | |
112 | - /** |
|
113 | - * Convert an array of mixed ids, slugs or names to only the id's of those terms |
|
114 | - * |
|
115 | - * @since 1.9.0 |
|
116 | - * |
|
117 | - * @param array $category_ids |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public function generate_term_ids( $categories = array() ){ |
|
112 | + /** |
|
113 | + * Convert an array of mixed ids, slugs or names to only the id's of those terms |
|
114 | + * |
|
115 | + * @since 1.9.0 |
|
116 | + * |
|
117 | + * @param array $category_ids |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public function generate_term_ids( $categories = array() ){ |
|
121 | 121 | |
122 | - $cat_ids = array(); |
|
122 | + $cat_ids = array(); |
|
123 | 123 | |
124 | - if ( is_array($categories) ) { |
|
125 | - foreach ($categories as $cat) { |
|
124 | + if ( is_array($categories) ) { |
|
125 | + foreach ($categories as $cat) { |
|
126 | 126 | |
127 | - if (!is_numeric($cat)) { |
|
127 | + if (!is_numeric($cat)) { |
|
128 | 128 | |
129 | - // try the slug |
|
130 | - $term = get_term_by('slug', $cat, 'course-category'); |
|
129 | + // try the slug |
|
130 | + $term = get_term_by('slug', $cat, 'course-category'); |
|
131 | 131 | |
132 | - // if the slug didn't work try the name |
|
133 | - if (!$term) { |
|
132 | + // if the slug didn't work try the name |
|
133 | + if (!$term) { |
|
134 | 134 | |
135 | - $term = get_term_by('name', $cat, 'course-category'); |
|
135 | + $term = get_term_by('name', $cat, 'course-category'); |
|
136 | 136 | |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | - if ($term) { |
|
140 | - $cat_ids[] = $term->term_id; |
|
141 | - } |
|
139 | + if ($term) { |
|
140 | + $cat_ids[] = $term->term_id; |
|
141 | + } |
|
142 | 142 | |
143 | - } else { |
|
143 | + } else { |
|
144 | 144 | |
145 | - $cat_ids[] = $cat; |
|
145 | + $cat_ids[] = $cat; |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | - } |
|
151 | + } |
|
152 | 152 | |
153 | - return $cat_ids; |
|
153 | + return $cat_ids; |
|
154 | 154 | |
155 | - }// end generate_term_ids |
|
155 | + }// end generate_term_ids |
|
156 | 156 | |
157 | 157 | }// end class |
158 | 158 |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Display output to the admin view |
44 | - * |
|
45 | - * This view is shown when grading a quiz for a single user in admin under grading |
|
46 | - * |
|
44 | + * |
|
45 | + * This view is shown when grading a quiz for a single user in admin under grading |
|
46 | + * |
|
47 | 47 | * @since 1.3.0 |
48 | 48 | * @return html |
49 | 49 | */ |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | $user_quiz_grade_total = 0; |
58 | 58 | $quiz_grade_total = 0; |
59 | 59 | $quiz_grade = 0; |
60 | - $lesson_id = $this->lesson_id; |
|
61 | - $user_id = $this->user_id; |
|
60 | + $lesson_id = $this->lesson_id; |
|
61 | + $user_id = $this->user_id; |
|
62 | 62 | |
63 | 63 | ?><form name="<?php esc_attr_e( 'quiz_' . $this->quiz_id ); ?>" action="" method="post"> |
64 | 64 | <?php wp_nonce_field( 'sensei_manual_grading', '_wp_sensei_manual_grading_nonce' ); ?> |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | <p class="user-answer"><?php |
207 | 207 | foreach ( $user_answer_content as $_user_answer ) { |
208 | 208 | |
209 | - if( 'multi-line' == Sensei()->question->get_question_type( $question->ID ) ){ |
|
209 | + if( 'multi-line' == Sensei()->question->get_question_type( $question->ID ) ){ |
|
210 | 210 | |
211 | - $_user_answer = htmlspecialchars_decode( nl2br( esc_html($_user_answer) ) ); |
|
211 | + $_user_answer = htmlspecialchars_decode( nl2br( esc_html($_user_answer) ) ); |
|
212 | 212 | |
213 | - } |
|
213 | + } |
|
214 | 214 | |
215 | 215 | echo apply_filters( 'sensei_answer_text', $_user_answer ) . "<br>"; |
216 | 216 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | add_action( 'sensei_course_status_updated', array( $this, 'learner_completed_course' ), 10, 4 ); |
52 | 52 | add_action( 'sensei_course_status_updated', array( $this, 'teacher_completed_course' ), 10, 4 ); |
53 | 53 | add_action( 'sensei_user_course_start', array( $this, 'teacher_started_course' ), 10, 2 ); |
54 | - add_action( 'sensei_user_lesson_end', array( $this, 'teacher_completed_lesson' ), 10, 2 ); |
|
54 | + add_action( 'sensei_user_lesson_end', array( $this, 'teacher_completed_lesson' ), 10, 2 ); |
|
55 | 55 | add_action( 'sensei_user_quiz_submitted', array( $this, 'teacher_quiz_submitted' ), 10, 5 ); |
56 | 56 | add_action( 'sensei_new_private_message', array( $this, 'teacher_new_message' ), 10, 1 ); |
57 | 57 | add_action( 'sensei_private_message_reply', array( $this, 'new_message_reply' ), 10, 2 ); |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | $this->emails['learner-graded-quiz'] = include( 'emails/class-woothemes-sensei-email-learner-graded-quiz.php' ); |
69 | 69 | $this->emails['learner-completed-course'] = include( 'emails/class-woothemes-sensei-email-learner-completed-course.php' ); |
70 | 70 | $this->emails['teacher-completed-course'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-course.php' ); |
71 | - $this->emails['teacher-started-course'] = include( 'emails/class-woothemes-sensei-email-teacher-started-course.php' ); |
|
72 | - $this->emails['teacher-completed-lesson'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-lesson.php' ); |
|
73 | - $this->emails['teacher-quiz-submitted'] = include( 'emails/class-woothemes-sensei-email-teacher-quiz-submitted.php' ); |
|
71 | + $this->emails['teacher-started-course'] = include( 'emails/class-woothemes-sensei-email-teacher-started-course.php' ); |
|
72 | + $this->emails['teacher-completed-lesson'] = include( 'emails/class-woothemes-sensei-email-teacher-completed-lesson.php' ); |
|
73 | + $this->emails['teacher-quiz-submitted'] = include( 'emails/class-woothemes-sensei-email-teacher-quiz-submitted.php' ); |
|
74 | 74 | $this->emails['teacher-new-message'] = include( 'emails/class-woothemes-sensei-email-teacher-new-message.php' ); |
75 | 75 | $this->emails['new-message-reply'] = include( 'emails/class-woothemes-sensei-email-new-message-reply.php' ); |
76 | 76 | $this->emails = apply_filters( 'sensei_email_classes', $this->emails ); |
@@ -177,20 +177,20 @@ discard block |
||
177 | 177 | add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) ); |
178 | 178 | add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) ); |
179 | 179 | |
180 | - // Send |
|
181 | - $send_email = true; |
|
180 | + // Send |
|
181 | + $send_email = true; |
|
182 | 182 | |
183 | - /** |
|
184 | - * Filter Sensei's ability to send out emails. |
|
185 | - * |
|
186 | - * @since 1.8.0 |
|
187 | - * @param bool $send_email default true |
|
188 | - */ |
|
189 | - if( apply_filters('sensei_send_emails', $send_email,$to, $subject, $message ) ){ |
|
183 | + /** |
|
184 | + * Filter Sensei's ability to send out emails. |
|
185 | + * |
|
186 | + * @since 1.8.0 |
|
187 | + * @param bool $send_email default true |
|
188 | + */ |
|
189 | + if( apply_filters('sensei_send_emails', $send_email,$to, $subject, $message ) ){ |
|
190 | 190 | |
191 | - wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
191 | + wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
192 | 192 | |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | 195 | // Unhook filters |
196 | 196 | remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) ); |
@@ -332,33 +332,33 @@ discard block |
||
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
335 | - /** |
|
336 | - * teacher_completed_lesson() |
|
337 | - * |
|
338 | - * Send email to teacher on student completing lesson |
|
339 | - * |
|
340 | - * @access public |
|
341 | - * @return void |
|
342 | - * @since 1.9.0 |
|
343 | - */ |
|
344 | - function teacher_completed_lesson( $learner_id = 0, $lesson_id = 0 ) { |
|
345 | - |
|
346 | - |
|
347 | - $send = false; |
|
348 | - |
|
349 | - if( isset( Sensei()->settings->settings[ 'email_teachers' ] ) ) { |
|
350 | - if( in_array( 'teacher-completed-lesson', (array) Sensei()->settings->settings[ 'email_teachers' ]) ) { |
|
351 | - $send = true; |
|
352 | - } |
|
353 | - } else { |
|
354 | - $send = true; |
|
355 | - } |
|
356 | - |
|
357 | - if( $send ) { |
|
358 | - $email = $this->emails['teacher-completed-lesson']; |
|
359 | - $email->trigger( $learner_id, $lesson_id ); |
|
360 | - } |
|
361 | - } |
|
335 | + /** |
|
336 | + * teacher_completed_lesson() |
|
337 | + * |
|
338 | + * Send email to teacher on student completing lesson |
|
339 | + * |
|
340 | + * @access public |
|
341 | + * @return void |
|
342 | + * @since 1.9.0 |
|
343 | + */ |
|
344 | + function teacher_completed_lesson( $learner_id = 0, $lesson_id = 0 ) { |
|
345 | + |
|
346 | + |
|
347 | + $send = false; |
|
348 | + |
|
349 | + if( isset( Sensei()->settings->settings[ 'email_teachers' ] ) ) { |
|
350 | + if( in_array( 'teacher-completed-lesson', (array) Sensei()->settings->settings[ 'email_teachers' ]) ) { |
|
351 | + $send = true; |
|
352 | + } |
|
353 | + } else { |
|
354 | + $send = true; |
|
355 | + } |
|
356 | + |
|
357 | + if( $send ) { |
|
358 | + $email = $this->emails['teacher-completed-lesson']; |
|
359 | + $email->trigger( $learner_id, $lesson_id ); |
|
360 | + } |
|
361 | + } |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Send email to teacher on quiz submission |
@@ -16,28 +16,28 @@ discard block |
||
16 | 16 | class Sensei_Notices{ |
17 | 17 | |
18 | 18 | /** |
19 | - * @var $notices |
|
20 | - */ |
|
19 | + * @var $notices |
|
20 | + */ |
|
21 | 21 | protected $notices; |
22 | 22 | |
23 | 23 | /** |
24 | - * constructor |
|
25 | - */ |
|
24 | + * constructor |
|
25 | + */ |
|
26 | 26 | public function __construct(){ |
27 | 27 | //initialize the notices variable |
28 | 28 | $this->notices = array(); |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | - * Add a notice to the array of notices for display at a later stage. |
|
33 | - * |
|
34 | - * |
|
35 | - * |
|
36 | - * @param string $message |
|
37 | - * @param string $type defaults to alert options( alert, tick , download , note ) |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
32 | + * Add a notice to the array of notices for display at a later stage. |
|
33 | + * |
|
34 | + * |
|
35 | + * |
|
36 | + * @param string $message |
|
37 | + * @param string $type defaults to alert options( alert, tick , download , note ) |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | 41 | |
42 | 42 | public function add_notice( $content , $type = 'alert' ){ |
43 | 43 | // append the new notice |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | } // end add_notice() |
46 | 46 | |
47 | 47 | /** |
48 | - * Output all notices added |
|
49 | - * |
|
50 | - * @param string $message |
|
51 | - * @param string $type |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
48 | + * Output all notices added |
|
49 | + * |
|
50 | + * @param string $message |
|
51 | + * @param string $type |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | 55 | |
56 | 56 | public function print_notices(){ |
57 | 57 | if( count( $this->notices ) > 0 ){ |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | } // end print_notice() |
69 | 69 | |
70 | 70 | /** |
71 | - * Clear all notices |
|
72 | - * |
|
73 | - * @return void |
|
74 | - */ |
|
71 | + * Clear all notices |
|
72 | + * |
|
73 | + * @return void |
|
74 | + */ |
|
75 | 75 | |
76 | 76 | public function clear_notices(){ |
77 | 77 | // assign an empty array to clear all existing notices |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
7 | 7 | |
8 | 8 | if ( class_exists( 'Teacher_New_Course_Assignment' ) ){ |
9 | - return; |
|
9 | + return; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -40,40 +40,40 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function __construct() { |
42 | 42 | |
43 | - $this->template = 'teacher-new-course-assignment'; |
|
43 | + $this->template = 'teacher-new-course-assignment'; |
|
44 | 44 | $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have been assigned to a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
45 | 45 | $this->heading = apply_filters( 'sensei_email_heading', __( 'Course assigned to you', 'woothemes-sensei' ), $this->template ); |
46 | - return; |
|
46 | + return; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * trigger function. |
51 | 51 | * |
52 | 52 | * @access public |
53 | - * @param $teacher_id |
|
54 | - * @param $course_id |
|
53 | + * @param $teacher_id |
|
54 | + * @param $course_id |
|
55 | 55 | * @return void |
56 | 56 | */ |
57 | 57 | function trigger( $teacher_id = 0, $course_id = 0 ) { |
58 | 58 | global $sensei_email_data; |
59 | 59 | |
60 | 60 | $this->teacher = new WP_User( $teacher_id ); |
61 | - $this->recipient = stripslashes( $this->teacher->user_email ); |
|
62 | - $this->subject = __( 'New course assigned to you', 'woothemes-sensei' ); |
|
61 | + $this->recipient = stripslashes( $this->teacher->user_email ); |
|
62 | + $this->subject = __( 'New course assigned to you', 'woothemes-sensei' ); |
|
63 | 63 | |
64 | - //course edit link |
|
65 | - $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
|
64 | + //course edit link |
|
65 | + $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
|
66 | 66 | |
67 | - // Course name |
|
68 | - $course = get_post( $course_id); |
|
67 | + // Course name |
|
68 | + $course = get_post( $course_id); |
|
69 | 69 | // Construct data array |
70 | 70 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
71 | 71 | 'template' => $this->template, |
72 | 72 | 'heading' => $this->heading, |
73 | 73 | 'teacher_id' => $teacher_id, |
74 | 74 | 'course_id' => $course_id, |
75 | - 'course_name' => $course->post_title, |
|
76 | - 'course_edit_link' => $course_edit_link, |
|
75 | + 'course_name' => $course->post_title, |
|
76 | + 'course_edit_link' => $course_edit_link, |
|
77 | 77 | ), $this->template ); |
78 | 78 | |
79 | 79 | // Send mail |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $teacher_id = get_post_field( 'post_author', $lesson_id, 'raw' ); |
52 | 52 | $this->teacher = new WP_User( $teacher_id ); |
53 | 53 | |
54 | - // Construct data array |
|
54 | + // Construct data array |
|
55 | 55 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
56 | 56 | 'template' => $this->template, |
57 | 57 | 'heading' => $this->heading, |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->recipient = stripslashes( $this->teacher->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 |
@@ -48,8 +48,8 @@ |
||
48 | 48 | $this->learner = new WP_User( $learner_id ); |
49 | 49 | |
50 | 50 | // Get teacher ID and user object |
51 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
52 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
51 | + $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
52 | + $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
53 | 53 | $teacher_id = get_post_field( 'post_author', $course_id, 'raw' ); |
54 | 54 | $this->teacher = new WP_User( $teacher_id ); |
55 | 55 |
@@ -57,16 +57,16 @@ |
||
57 | 57 | $content_id = get_post_meta( $message_id, '_post', true ); |
58 | 58 | $content_title = get_the_title( $content_id ); |
59 | 59 | |
60 | - // setup the post type parameter |
|
61 | - $content_type = get_post_type( $content_id ); |
|
62 | - if( !$content_type ){ |
|
63 | - $content_type =''; |
|
64 | - } |
|
60 | + // setup the post type parameter |
|
61 | + $content_type = get_post_type( $content_id ); |
|
62 | + if( !$content_type ){ |
|
63 | + $content_type =''; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | // Construct data array |
67 | 67 | $sensei_email_data = apply_filters( 'sensei_email_data', array( |
68 | 68 | 'template' => $this->template, |
69 | - $content_type.'_id' => $content_id, |
|
69 | + $content_type.'_id' => $content_id, |
|
70 | 70 | 'heading' => $this->heading, |
71 | 71 | 'teacher_id' => $this->teacher->ID, |
72 | 72 | 'learner_id' => $this->learner->ID, |