@@ -1,5 +1,5 @@ discard block |
||
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 Settings Class |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | * @access public |
19 | 19 | * @since 1.0.0 |
20 | 20 | */ |
21 | - public function __construct () { |
|
21 | + public function __construct() { |
|
22 | 22 | parent::__construct(); // Required in extended classes. |
23 | 23 | |
24 | 24 | $this->token = 'woothemes-sensei-settings'; |
25 | - add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
25 | + add_action('init', array(__CLASS__, 'flush_rewrite_rules')); |
|
26 | 26 | |
27 | 27 | // Setup Admin Settings data |
28 | - if ( is_admin() ) { |
|
28 | + if (is_admin()) { |
|
29 | 29 | |
30 | 30 | $this->has_tabs = true; |
31 | - $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
|
32 | - $this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
|
31 | + $this->name = __('Sensei Settings', 'woothemes-sensei'); |
|
32 | + $this->menu_label = __('Settings', 'woothemes-sensei'); |
|
33 | 33 | $this->page_slug = 'woothemes-sensei-settings'; |
34 | 34 | |
35 | 35 | } // End If Statement |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | * @param string $setting_name |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function get( $setting_name ){ |
|
49 | + public function get($setting_name) { |
|
50 | 50 | |
51 | - if( isset( $this->settings[ $setting_name ] ) ){ |
|
51 | + if (isset($this->settings[$setting_name])) { |
|
52 | 52 | |
53 | - return $this->settings[ $setting_name ]; |
|
53 | + return $this->settings[$setting_name]; |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | * @param $setting |
64 | 64 | * @param $new_value |
65 | 65 | */ |
66 | - public function set( $setting, $new_value ){ |
|
66 | + public function set($setting, $new_value) { |
|
67 | 67 | |
68 | - $settings = get_option( $this->token, array() ); |
|
68 | + $settings = get_option($this->token, array()); |
|
69 | 69 | |
70 | - if( isset( $settings[ $setting ] ) ){ |
|
70 | + if (isset($settings[$setting])) { |
|
71 | 71 | |
72 | - $settings[ $setting ] = $new_value; |
|
73 | - return update_option( $this->token,$settings ); |
|
72 | + $settings[$setting] = $new_value; |
|
73 | + return update_option($this->token, $settings); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | return false; |
@@ -83,17 +83,17 @@ discard block |
||
83 | 83 | * @since 1.0.0 |
84 | 84 | * @return void |
85 | 85 | */ |
86 | - public function register_settings_screen () { |
|
86 | + public function register_settings_screen() { |
|
87 | 87 | |
88 | 88 | $this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. |
89 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
89 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
90 | 90 | $this->hook = $hook; |
91 | 91 | |
92 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
93 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
94 | - add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); |
|
95 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
96 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
92 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
93 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
94 | + add_action('admin_notices', array($this, 'language_pack_notices')); |
|
95 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
96 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
97 | 97 | } |
98 | 98 | } // End register_settings_screen() |
99 | 99 | |
@@ -103,49 +103,49 @@ discard block |
||
103 | 103 | * @since 1.0.0 |
104 | 104 | * @return void |
105 | 105 | */ |
106 | - public function init_sections () { |
|
106 | + public function init_sections() { |
|
107 | 107 | $sections = array(); |
108 | 108 | |
109 | 109 | $sections['default-settings'] = array( |
110 | - 'name' => __( 'General', 'woothemes-sensei' ), |
|
111 | - 'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) |
|
110 | + 'name' => __('General', 'woothemes-sensei'), |
|
111 | + 'description' => __('Settings that apply to the entire plugin.', 'woothemes-sensei') |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | $sections['course-settings'] = array( |
115 | - 'name' => __( 'Courses', 'woothemes-sensei' ), |
|
116 | - 'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) |
|
115 | + 'name' => __('Courses', 'woothemes-sensei'), |
|
116 | + 'description' => __('Settings that apply to all Courses.', 'woothemes-sensei') |
|
117 | 117 | ); |
118 | 118 | |
119 | 119 | $sections['lesson-settings'] = array( |
120 | - 'name' => __( 'Lessons', 'woothemes-sensei' ), |
|
121 | - 'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) |
|
120 | + 'name' => __('Lessons', 'woothemes-sensei'), |
|
121 | + 'description' => __('Settings that apply to all Lessons.', 'woothemes-sensei') |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | $sections['email-notification-settings'] = array( |
125 | - 'name' => __( 'Email Notifications', 'woothemes-sensei' ), |
|
126 | - 'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) |
|
125 | + 'name' => __('Email Notifications', 'woothemes-sensei'), |
|
126 | + 'description' => __('Settings for email notifications sent from your site.', 'woothemes-sensei') |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $sections['learner-profile-settings'] = array( |
130 | - 'name' => __( 'Learner Profiles', 'woothemes-sensei' ), |
|
131 | - 'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) |
|
130 | + 'name' => __('Learner Profiles', 'woothemes-sensei'), |
|
131 | + 'description' => __('Settings for public Learner Profiles.', 'woothemes-sensei') |
|
132 | 132 | ); |
133 | 133 | |
134 | - if ( Sensei_WC::is_woocommerce_present() ) { |
|
134 | + if (Sensei_WC::is_woocommerce_present()) { |
|
135 | 135 | $sections['woocommerce-settings'] = array( |
136 | - 'name' => __( 'WooCommerce', 'woothemes-sensei' ), |
|
137 | - 'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) |
|
136 | + 'name' => __('WooCommerce', 'woothemes-sensei'), |
|
137 | + 'description' => __('Optional settings for WooCommerce functions.', 'woothemes-sensei') |
|
138 | 138 | ); |
139 | 139 | } // End If Statement |
140 | 140 | |
141 | - if ( 'en_US' !== get_locale() ) { |
|
141 | + if ('en_US' !== get_locale()) { |
|
142 | 142 | $sections['language-settings'] = array( |
143 | - 'name' => __( 'Language', 'woothemes-sensei' ), |
|
144 | - 'description' => __( 'Language options.', 'woothemes-sensei' ) |
|
143 | + 'name' => __('Language', 'woothemes-sensei'), |
|
144 | + 'description' => __('Language options.', 'woothemes-sensei') |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
148 | - $this->sections = apply_filters( 'sensei_settings_tabs', $sections ); |
|
148 | + $this->sections = apply_filters('sensei_settings_tabs', $sections); |
|
149 | 149 | } // End init_sections() |
150 | 150 | |
151 | 151 | /** |
@@ -155,71 +155,71 @@ discard block |
||
155 | 155 | * @uses Sensei_Utils::get_slider_types() |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public function init_fields () { |
|
158 | + public function init_fields() { |
|
159 | 159 | global $pagenow; |
160 | 160 | |
161 | 161 | $pages_array = $this->pages_array(); |
162 | - $posts_per_page_array = array( '0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20' ); |
|
163 | - $complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); |
|
164 | - $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
|
162 | + $posts_per_page_array = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20'); |
|
163 | + $complete_settings = array('passed' => __('Once all the course lessons have been completed', 'woothemes-sensei'), 'complete' => __('At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei')); |
|
164 | + $course_display_settings = array('excerpt' => __('Course Excerpt', 'woothemes-sensei'), 'full' => __('Full Course Content', 'woothemes-sensei')); |
|
165 | 165 | |
166 | 166 | $fields = array(); |
167 | 167 | |
168 | 168 | $fields['access_permission'] = array( |
169 | - 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
|
170 | - 'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), |
|
169 | + 'name' => __('Access Permissions', 'woothemes-sensei'), |
|
170 | + 'description' => __('Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei'), |
|
171 | 171 | 'type' => 'checkbox', |
172 | 172 | 'default' => true, |
173 | 173 | 'section' => 'default-settings' |
174 | 174 | ); |
175 | 175 | |
176 | 176 | $fields['messages_disable'] = array( |
177 | - 'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), |
|
178 | - 'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), |
|
177 | + 'name' => __('Disable Private Messages', 'woothemes-sensei'), |
|
178 | + 'description' => __('Disable the private message functions between learners and teachers.', 'woothemes-sensei'), |
|
179 | 179 | 'type' => 'checkbox', |
180 | 180 | 'default' => false, |
181 | 181 | 'section' => 'default-settings' |
182 | 182 | ); |
183 | 183 | |
184 | 184 | $fields['course_page'] = array( |
185 | - 'name' => __( 'Course Archive Page', 'woothemes-sensei' ), |
|
186 | - 'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), |
|
185 | + 'name' => __('Course Archive Page', 'woothemes-sensei'), |
|
186 | + 'description' => __('The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei'), |
|
187 | 187 | 'type' => 'select', |
188 | - 'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), |
|
188 | + 'default' => get_option('woothemes-sensei_courses_page_id', 0), |
|
189 | 189 | 'section' => 'default-settings', |
190 | 190 | 'required' => 0, |
191 | 191 | 'options' => $pages_array |
192 | 192 | ); |
193 | 193 | |
194 | 194 | $fields['my_course_page'] = array( |
195 | - 'name' => __( 'My Courses Page', 'woothemes-sensei' ), |
|
196 | - 'description' => __( 'The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei' ), |
|
195 | + 'name' => __('My Courses Page', 'woothemes-sensei'), |
|
196 | + 'description' => __('The page to use to display the courses that a user is currently taking as well as the courses a user has complete.', 'woothemes-sensei'), |
|
197 | 197 | 'type' => 'select', |
198 | - 'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), |
|
198 | + 'default' => get_option('woothemes-sensei_user_dashboard_page_id', 0), |
|
199 | 199 | 'section' => 'default-settings', |
200 | 200 | 'required' => 0, |
201 | 201 | 'options' => $pages_array |
202 | 202 | ); |
203 | 203 | |
204 | 204 | $fields['placeholder_images_enable'] = array( |
205 | - 'name' => __( 'Use placeholder images', 'woothemes-sensei' ), |
|
206 | - 'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), |
|
205 | + 'name' => __('Use placeholder images', 'woothemes-sensei'), |
|
206 | + 'description' => __('Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei'), |
|
207 | 207 | 'type' => 'checkbox', |
208 | 208 | 'default' => false, |
209 | 209 | 'section' => 'default-settings' |
210 | 210 | ); |
211 | 211 | |
212 | 212 | $fields['styles_disable'] = array( |
213 | - 'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), |
|
214 | - 'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), |
|
213 | + 'name' => __('Disable Sensei Styles', 'woothemes-sensei'), |
|
214 | + 'description' => __('Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei'), |
|
215 | 215 | 'type' => 'checkbox', |
216 | 216 | 'default' => false, |
217 | 217 | 'section' => 'default-settings' |
218 | 218 | ); |
219 | 219 | |
220 | 220 | $fields['js_disable'] = array( |
221 | - 'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), |
|
222 | - 'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), |
|
221 | + 'name' => __('Disable Sensei Javascript', 'woothemes-sensei'), |
|
222 | + 'description' => __('Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei'), |
|
223 | 223 | 'type' => 'checkbox', |
224 | 224 | 'default' => false, |
225 | 225 | 'section' => 'default-settings' |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | // Course Settings |
229 | 229 | |
230 | 230 | $fields['course_completion'] = array( |
231 | - 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
|
232 | - 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
|
231 | + 'name' => __('Courses are complete:', 'woothemes-sensei'), |
|
232 | + 'description' => __('This will determine when courses are marked as complete.', 'woothemes-sensei'), |
|
233 | 233 | 'type' => 'select', |
234 | 234 | 'default' => 'passed', |
235 | 235 | 'section' => 'course-settings', |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | ); |
239 | 239 | |
240 | 240 | $fields['course_author'] = array( |
241 | - 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
|
242 | - 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
|
241 | + 'name' => __('Display Course Author', 'woothemes-sensei'), |
|
242 | + 'description' => __('Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei'), |
|
243 | 243 | 'type' => 'checkbox', |
244 | 244 | 'default' => true, |
245 | 245 | 'section' => 'course-settings' |
246 | 246 | ); |
247 | 247 | |
248 | 248 | $fields['my_course_amount'] = array( |
249 | - 'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), |
|
250 | - 'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), |
|
249 | + 'name' => __('My Courses Pagination', 'woothemes-sensei'), |
|
250 | + 'description' => __('The number of courses to output for the my courses page.', 'woothemes-sensei'), |
|
251 | 251 | 'type' => 'range', |
252 | 252 | 'default' => '0', |
253 | 253 | 'section' => 'course-settings', |
@@ -256,16 +256,16 @@ discard block |
||
256 | 256 | ); |
257 | 257 | |
258 | 258 | $fields['course_archive_image_enable'] = array( |
259 | - 'name' => __( 'Course Archive Image', 'woothemes-sensei' ), |
|
260 | - 'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), |
|
259 | + 'name' => __('Course Archive Image', 'woothemes-sensei'), |
|
260 | + 'description' => __('Output the Course Image on the Course Archive Page.', 'woothemes-sensei'), |
|
261 | 261 | 'type' => 'checkbox', |
262 | 262 | 'default' => true, |
263 | 263 | 'section' => 'course-settings' |
264 | 264 | ); |
265 | 265 | |
266 | 266 | $fields['course_archive_image_width'] = array( |
267 | - 'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), |
|
268 | - 'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
267 | + 'name' => __('Image Width - Archive', 'woothemes-sensei'), |
|
268 | + 'description' => __('The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
269 | 269 | 'type' => 'text', |
270 | 270 | 'default' => '100', |
271 | 271 | 'section' => 'course-settings', |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | ); |
274 | 274 | |
275 | 275 | $fields['course_archive_image_height'] = array( |
276 | - 'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), |
|
277 | - 'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
|
276 | + 'name' => __('Image Height - Archive', 'woothemes-sensei'), |
|
277 | + 'description' => __('The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei'), |
|
278 | 278 | 'type' => 'text', |
279 | 279 | 'default' => '100', |
280 | 280 | 'section' => 'course-settings', |
@@ -282,24 +282,24 @@ discard block |
||
282 | 282 | ); |
283 | 283 | |
284 | 284 | $fields['course_archive_image_hard_crop'] = array( |
285 | - 'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), |
|
286 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
285 | + 'name' => __('Image Hard Crop - Archive', 'woothemes-sensei'), |
|
286 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
287 | 287 | 'type' => 'checkbox', |
288 | 288 | 'default' => false, |
289 | 289 | 'section' => 'course-settings' |
290 | 290 | ); |
291 | 291 | |
292 | 292 | $fields['course_single_image_enable'] = array( |
293 | - 'name' => __( 'Single Course Image', 'woothemes-sensei' ), |
|
294 | - 'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), |
|
293 | + 'name' => __('Single Course Image', 'woothemes-sensei'), |
|
294 | + 'description' => __('Output the Course Image on the Single Course Page.', 'woothemes-sensei'), |
|
295 | 295 | 'type' => 'checkbox', |
296 | 296 | 'default' => false, |
297 | 297 | 'section' => 'course-settings' |
298 | 298 | ); |
299 | 299 | |
300 | 300 | $fields['course_single_image_width'] = array( |
301 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
302 | - 'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
301 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
302 | + 'description' => __('The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
303 | 303 | 'type' => 'text', |
304 | 304 | 'default' => '100', |
305 | 305 | 'section' => 'course-settings', |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | ); |
308 | 308 | |
309 | 309 | $fields['course_single_image_height'] = array( |
310 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
311 | - 'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
|
310 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
311 | + 'description' => __('The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei'), |
|
312 | 312 | 'type' => 'text', |
313 | 313 | 'default' => '100', |
314 | 314 | 'section' => 'course-settings', |
@@ -316,16 +316,16 @@ discard block |
||
316 | 316 | ); |
317 | 317 | |
318 | 318 | $fields['course_single_image_hard_crop'] = array( |
319 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
320 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
319 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
320 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
321 | 321 | 'type' => 'checkbox', |
322 | 322 | 'default' => false, |
323 | 323 | 'section' => 'course-settings' |
324 | 324 | ); |
325 | 325 | |
326 | 326 | $fields['course_single_content_display'] = array( |
327 | - 'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), |
|
328 | - 'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), |
|
327 | + 'name' => __('Single Course page displays:', 'woothemes-sensei'), |
|
328 | + 'description' => __('Determines what content to display on the single course page.', 'woothemes-sensei'), |
|
329 | 329 | 'type' => 'select', |
330 | 330 | 'default' => 'excerpt', |
331 | 331 | 'section' => 'course-settings', |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | ); |
335 | 335 | |
336 | 336 | $fields['course_archive_featured_enable'] = array( |
337 | - 'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), |
|
338 | - 'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
337 | + 'name' => __('Featured Courses Panel', 'woothemes-sensei'), |
|
338 | + 'description' => __('Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
339 | 339 | 'type' => 'checkbox', |
340 | 340 | 'default' => true, |
341 | 341 | 'section' => 'course-settings' |
342 | 342 | ); |
343 | 343 | |
344 | 344 | $fields['course_archive_more_link_text'] = array( |
345 | - 'name' => __( 'More link text', 'woothemes-sensei' ), |
|
346 | - 'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), |
|
345 | + 'name' => __('More link text', 'woothemes-sensei'), |
|
346 | + 'description' => __('The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei'), |
|
347 | 347 | 'type' => 'text', |
348 | - 'default' => __ ( 'More', 'woothemes-sensei' ), |
|
348 | + 'default' => __('More', 'woothemes-sensei'), |
|
349 | 349 | 'section' => 'course-settings', |
350 | 350 | 'required' => 0 |
351 | 351 | ); |
@@ -353,32 +353,32 @@ discard block |
||
353 | 353 | // Lesson Settings |
354 | 354 | |
355 | 355 | $fields['lesson_comments'] = array( |
356 | - 'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), |
|
357 | - 'description' => __( 'This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei' ), |
|
356 | + 'name' => __('Allow Comments for Lessons', 'woothemes-sensei'), |
|
357 | + 'description' => __('This will allow learners to post comments on the single Lesson page, only learner who have access to the Lesson will be allowed to comment.', 'woothemes-sensei'), |
|
358 | 358 | 'type' => 'checkbox', |
359 | 359 | 'default' => true, |
360 | 360 | 'section' => 'lesson-settings' |
361 | 361 | ); |
362 | 362 | |
363 | 363 | $fields['lesson_author'] = array( |
364 | - 'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), |
|
365 | - 'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), |
|
364 | + 'name' => __('Display Lesson Author', 'woothemes-sensei'), |
|
365 | + 'description' => __('Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei'), |
|
366 | 366 | 'type' => 'checkbox', |
367 | 367 | 'default' => true, |
368 | 368 | 'section' => 'lesson-settings' |
369 | 369 | ); |
370 | 370 | |
371 | 371 | $fields['course_lesson_image_enable'] = array( |
372 | - 'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), |
|
373 | - 'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), |
|
372 | + 'name' => __('Course Lesson Images', 'woothemes-sensei'), |
|
373 | + 'description' => __('Output the Lesson Image on the Single Course Page.', 'woothemes-sensei'), |
|
374 | 374 | 'type' => 'checkbox', |
375 | 375 | 'default' => false, |
376 | 376 | 'section' => 'lesson-settings' |
377 | 377 | ); |
378 | 378 | |
379 | 379 | $fields['lesson_archive_image_width'] = array( |
380 | - 'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), |
|
381 | - 'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
380 | + 'name' => __('Image Width - Course Lessons', 'woothemes-sensei'), |
|
381 | + 'description' => __('The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
382 | 382 | 'type' => 'text', |
383 | 383 | 'default' => '100', |
384 | 384 | 'section' => 'lesson-settings', |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | ); |
387 | 387 | |
388 | 388 | $fields['lesson_archive_image_height'] = array( |
389 | - 'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), |
|
390 | - 'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
|
389 | + 'name' => __('Image Height - Course Lessons', 'woothemes-sensei'), |
|
390 | + 'description' => __('The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei'), |
|
391 | 391 | 'type' => 'text', |
392 | 392 | 'default' => '100', |
393 | 393 | 'section' => 'lesson-settings', |
@@ -395,24 +395,24 @@ discard block |
||
395 | 395 | ); |
396 | 396 | |
397 | 397 | $fields['lesson_archive_image_hard_crop'] = array( |
398 | - 'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), |
|
399 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
398 | + 'name' => __('Image Hard Crop - Course Lessons', 'woothemes-sensei'), |
|
399 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
400 | 400 | 'type' => 'checkbox', |
401 | 401 | 'default' => false, |
402 | 402 | 'section' => 'lesson-settings' |
403 | 403 | ); |
404 | 404 | |
405 | 405 | $fields['lesson_single_image_enable'] = array( |
406 | - 'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), |
|
407 | - 'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), |
|
406 | + 'name' => __('Single Lesson Images', 'woothemes-sensei'), |
|
407 | + 'description' => __('Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei'), |
|
408 | 408 | 'type' => 'checkbox', |
409 | 409 | 'default' => false, |
410 | 410 | 'section' => 'lesson-settings' |
411 | 411 | ); |
412 | 412 | |
413 | 413 | $fields['lesson_single_image_width'] = array( |
414 | - 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
|
415 | - 'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
414 | + 'name' => __('Image Width - Single', 'woothemes-sensei'), |
|
415 | + 'description' => __('The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
416 | 416 | 'type' => 'text', |
417 | 417 | 'default' => '100', |
418 | 418 | 'section' => 'lesson-settings', |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | ); |
421 | 421 | |
422 | 422 | $fields['lesson_single_image_height'] = array( |
423 | - 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
|
424 | - 'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
|
423 | + 'name' => __('Image Height - Single', 'woothemes-sensei'), |
|
424 | + 'description' => __('The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei'), |
|
425 | 425 | 'type' => 'text', |
426 | 426 | 'default' => '100', |
427 | 427 | 'section' => 'lesson-settings', |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | ); |
430 | 430 | |
431 | 431 | $fields['lesson_single_image_hard_crop'] = array( |
432 | - 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
|
433 | - 'description' => sprintf( __( 'After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei' ), '<a href="' . esc_url( 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ) . '">', '</a>' ), |
|
432 | + 'name' => __('Image Hard Crop - Single', 'woothemes-sensei'), |
|
433 | + 'description' => sprintf(__('After changing this setting, you may need to %1$sregenerate your thumbnails%2$s.', 'woothemes-sensei'), '<a href="'.esc_url('http://wordpress.org/extend/plugins/regenerate-thumbnails/').'">', '</a>'), |
|
434 | 434 | 'type' => 'checkbox', |
435 | 435 | 'default' => false, |
436 | 436 | 'section' => 'lesson-settings' |
@@ -438,20 +438,20 @@ discard block |
||
438 | 438 | |
439 | 439 | // Learner Profile settings |
440 | 440 | |
441 | - $profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
|
442 | - $profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; |
|
441 | + $profile_url_base = apply_filters('sensei_learner_profiles_url_base', __('learner', 'woothemes-sensei')); |
|
442 | + $profile_url_example = trailingslashit(get_site_url()).$profile_url_base.'/%username%'; |
|
443 | 443 | |
444 | 444 | $fields['learner_profile_enable'] = array( |
445 | - 'name' => __( 'Public learner profiles', 'woothemes-sensei' ), |
|
446 | - 'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), |
|
445 | + 'name' => __('Public learner profiles', 'woothemes-sensei'), |
|
446 | + 'description' => sprintf(__('Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei'), $profile_url_example), |
|
447 | 447 | 'type' => 'checkbox', |
448 | 448 | 'default' => true, |
449 | 449 | 'section' => 'learner-profile-settings' |
450 | 450 | ); |
451 | 451 | |
452 | 452 | $fields['learner_profile_show_courses'] = array( |
453 | - 'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), |
|
454 | - 'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), |
|
453 | + 'name' => __('Show learner\'s courses', 'woothemes-sensei'), |
|
454 | + 'description' => __('Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei'), |
|
455 | 455 | 'type' => 'checkbox', |
456 | 456 | 'default' => true, |
457 | 457 | 'section' => 'learner-profile-settings' |
@@ -460,70 +460,70 @@ discard block |
||
460 | 460 | // Email notifications |
461 | 461 | |
462 | 462 | $learner_email_options = array( |
463 | - 'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), |
|
464 | - 'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), |
|
463 | + 'learner-graded-quiz' => __('Their quiz is graded (auto and manual grading)', 'woothemes-sensei'), |
|
464 | + 'learner-completed-course' => __('They complete a course', 'woothemes-sensei'), |
|
465 | 465 | ); |
466 | 466 | |
467 | 467 | $teacher_email_options = array( |
468 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
469 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
470 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
471 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
472 | - 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
|
468 | + 'teacher-started-course' => __('A learner starts their course', 'woothemes-sensei'), |
|
469 | + 'teacher-completed-course' => __('A learner completes their course', 'woothemes-sensei'), |
|
470 | + 'teacher-completed-lesson' => __('A learner completes a lesson', 'woothemes-sensei'), |
|
471 | + 'teacher-quiz-submitted' => __('A learner submits a quiz for grading', 'woothemes-sensei'), |
|
472 | + 'teacher-new-message' => __('A learner sends a private message to a teacher', 'woothemes-sensei'), |
|
473 | 473 | ); |
474 | 474 | |
475 | 475 | $global_email_options = array( |
476 | - 'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), |
|
476 | + 'new-message-reply' => __('They receive a reply to their private message', 'woothemes-sensei'), |
|
477 | 477 | ); |
478 | 478 | |
479 | 479 | $fields['email_learners'] = array( |
480 | - 'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), |
|
481 | - 'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), |
|
480 | + 'name' => __('Emails Sent to Learners', 'woothemes-sensei'), |
|
481 | + 'description' => __('Select the notifications that will be sent to learners.', 'woothemes-sensei'), |
|
482 | 482 | 'type' => 'multicheck', |
483 | 483 | 'options' => $learner_email_options, |
484 | - 'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), |
|
484 | + 'defaults' => array('learner-graded-quiz', 'learner-completed-course'), |
|
485 | 485 | 'section' => 'email-notification-settings' |
486 | 486 | ); |
487 | 487 | |
488 | 488 | $fields['email_teachers'] = array( |
489 | - 'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), |
|
490 | - 'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), |
|
489 | + 'name' => __('Emails Sent to Teachers', 'woothemes-sensei'), |
|
490 | + 'description' => __('Select the notifications that will be sent to teachers.', 'woothemes-sensei'), |
|
491 | 491 | 'type' => 'multicheck', |
492 | 492 | 'options' => $teacher_email_options, |
493 | - 'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), |
|
493 | + 'defaults' => array('teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message'), |
|
494 | 494 | 'section' => 'email-notification-settings' |
495 | 495 | ); |
496 | 496 | |
497 | 497 | $fields['email_global'] = array( |
498 | - 'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), |
|
499 | - 'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), |
|
498 | + 'name' => __('Emails Sent to All Users', 'woothemes-sensei'), |
|
499 | + 'description' => __('Select the notifications that will be sent to all users.', 'woothemes-sensei'), |
|
500 | 500 | 'type' => 'multicheck', |
501 | 501 | 'options' => $global_email_options, |
502 | - 'defaults' => array( 'new-message-reply' ), |
|
502 | + 'defaults' => array('new-message-reply'), |
|
503 | 503 | 'section' => 'email-notification-settings' |
504 | 504 | ); |
505 | 505 | |
506 | 506 | $fields['email_from_name'] = array( |
507 | - 'name' => __( '"From" Name', 'woothemes-sensei' ), |
|
508 | - 'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), |
|
507 | + 'name' => __('"From" Name', 'woothemes-sensei'), |
|
508 | + 'description' => __('The name from which all emails will be sent.', 'woothemes-sensei'), |
|
509 | 509 | 'type' => 'text', |
510 | - 'default' => get_bloginfo( 'name' ), |
|
510 | + 'default' => get_bloginfo('name'), |
|
511 | 511 | 'section' => 'email-notification-settings', |
512 | 512 | 'required' => 1 |
513 | 513 | ); |
514 | 514 | |
515 | 515 | $fields['email_from_address'] = array( |
516 | - 'name' => __( '"From" Address', 'woothemes-sensei' ), |
|
517 | - 'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), |
|
516 | + 'name' => __('"From" Address', 'woothemes-sensei'), |
|
517 | + 'description' => __('The address from which all emails will be sent.', 'woothemes-sensei'), |
|
518 | 518 | 'type' => 'text', |
519 | - 'default' => get_bloginfo( 'admin_email' ), |
|
519 | + 'default' => get_bloginfo('admin_email'), |
|
520 | 520 | 'section' => 'email-notification-settings', |
521 | 521 | 'required' => 1 |
522 | 522 | ); |
523 | 523 | |
524 | 524 | $fields['email_header_image'] = array( |
525 | - 'name' => __( 'Header Image', 'woothemes-sensei' ), |
|
526 | - 'description' => sprintf( __( 'Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'media-new.php' ) . '">', '</a>' ), |
|
525 | + 'name' => __('Header Image', 'woothemes-sensei'), |
|
526 | + 'description' => sprintf(__('Enter a URL to an image you want to show in the email\'s header. Upload your image using the %1$smedia uploader%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('media-new.php').'">', '</a>'), |
|
527 | 527 | 'type' => 'text', |
528 | 528 | 'default' => '', |
529 | 529 | 'section' => 'email-notification-settings', |
@@ -531,17 +531,17 @@ discard block |
||
531 | 531 | ); |
532 | 532 | |
533 | 533 | $fields['email_footer_text'] = array( |
534 | - 'name' => __( 'Email Footer Text', 'woothemes-sensei' ), |
|
535 | - 'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), |
|
534 | + 'name' => __('Email Footer Text', 'woothemes-sensei'), |
|
535 | + 'description' => __('The text to appear in the footer of Sensei emails.', 'woothemes-sensei'), |
|
536 | 536 | 'type' => 'textarea', |
537 | - 'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), |
|
537 | + 'default' => sprintf(__('%1$s - Powered by Sensei', 'woothemes-sensei'), get_bloginfo('name')), |
|
538 | 538 | 'section' => 'email-notification-settings', |
539 | 539 | 'required' => 0 |
540 | 540 | ); |
541 | 541 | |
542 | 542 | $fields['email_base_color'] = array( |
543 | - 'name' => __( 'Base Colour', 'woothemes-sensei' ), |
|
544 | - 'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
543 | + 'name' => __('Base Colour', 'woothemes-sensei'), |
|
544 | + 'description' => sprintf(__('The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
545 | 545 | 'type' => 'color', |
546 | 546 | 'default' => '#557da1', |
547 | 547 | 'section' => 'email-notification-settings', |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | ); |
550 | 550 | |
551 | 551 | $fields['email_background_color'] = array( |
552 | - 'name' => __( 'Background Colour', 'woothemes-sensei' ), |
|
553 | - 'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
552 | + 'name' => __('Background Colour', 'woothemes-sensei'), |
|
553 | + 'description' => sprintf(__('The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
554 | 554 | 'type' => 'color', |
555 | 555 | 'default' => '#f5f5f5', |
556 | 556 | 'section' => 'email-notification-settings', |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | ); |
559 | 559 | |
560 | 560 | $fields['email_body_background_color'] = array( |
561 | - 'name' => __( 'Body Background Colour', 'woothemes-sensei' ), |
|
562 | - 'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
561 | + 'name' => __('Body Background Colour', 'woothemes-sensei'), |
|
562 | + 'description' => sprintf(__('The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
563 | 563 | 'type' => 'color', |
564 | 564 | 'default' => '#fdfdfd', |
565 | 565 | 'section' => 'email-notification-settings', |
@@ -567,35 +567,35 @@ discard block |
||
567 | 567 | ); |
568 | 568 | |
569 | 569 | $fields['email_text_color'] = array( |
570 | - 'name' => __( 'Body Text Colour', 'woothemes-sensei' ), |
|
571 | - 'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
|
570 | + 'name' => __('Body Text Colour', 'woothemes-sensei'), |
|
571 | + 'description' => sprintf(__('The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei'), '<code>', '</code>'), |
|
572 | 572 | 'type' => 'color', |
573 | 573 | 'default' => '#505050', |
574 | 574 | 'section' => 'email-notification-settings', |
575 | 575 | 'required' => 1 |
576 | 576 | ); |
577 | 577 | |
578 | - if ( Sensei_WC::is_woocommerce_present() ) { |
|
578 | + if (Sensei_WC::is_woocommerce_present()) { |
|
579 | 579 | // WooCommerce Settings |
580 | 580 | $fields['woocommerce_enabled'] = array( |
581 | - 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
|
582 | - 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
|
581 | + 'name' => __('Enable WooCommerce Courses', 'woothemes-sensei'), |
|
582 | + 'description' => __('Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei'), |
|
583 | 583 | 'type' => 'checkbox', |
584 | 584 | 'default' => true, |
585 | 585 | 'section' => 'woocommerce-settings' |
586 | 586 | ); |
587 | 587 | |
588 | 588 | $fields['course_archive_free_enable'] = array( |
589 | - 'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), |
|
590 | - 'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
589 | + 'name' => __('Free Courses Panel', 'woothemes-sensei'), |
|
590 | + 'description' => __('Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
591 | 591 | 'type' => 'checkbox', |
592 | 592 | 'default' => true, |
593 | 593 | 'section' => 'woocommerce-settings' |
594 | 594 | ); |
595 | 595 | |
596 | 596 | $fields['course_archive_paid_enable'] = array( |
597 | - 'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), |
|
598 | - 'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
|
597 | + 'name' => __('Paid Courses Panel', 'woothemes-sensei'), |
|
598 | + 'description' => __('Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei'), |
|
599 | 599 | 'type' => 'checkbox', |
600 | 600 | 'default' => true, |
601 | 601 | 'section' => 'woocommerce-settings' |
@@ -603,18 +603,18 @@ discard block |
||
603 | 603 | |
604 | 604 | } // End If Statement |
605 | 605 | |
606 | - if ( 'en_US' !== get_locale() ) { |
|
606 | + if ('en_US' !== get_locale()) { |
|
607 | 607 | $fields['install_language_pack'] = array( |
608 | - 'name' => __( 'Install Language Pack', 'woothemes-sensei' ), |
|
609 | - 'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), |
|
608 | + 'name' => __('Install Language Pack', 'woothemes-sensei'), |
|
609 | + 'description' => __('Use this action to install or re-install translation for your language if available.', 'woothemes-sensei'), |
|
610 | 610 | 'type' => 'button', |
611 | 611 | 'section' => 'language-settings', |
612 | 612 | 'target' => Sensei_Language_Pack_Manager::get_install_uri(), |
613 | - 'label' => __( 'Install', 'woothemes-sensei' ) |
|
613 | + 'label' => __('Install', 'woothemes-sensei') |
|
614 | 614 | ); |
615 | 615 | } |
616 | 616 | |
617 | - $this->fields = apply_filters( 'sensei_settings_fields', $fields ); |
|
617 | + $this->fields = apply_filters('sensei_settings_fields', $fields); |
|
618 | 618 | |
619 | 619 | } // End init_fields() |
620 | 620 | |
@@ -624,20 +624,20 @@ discard block |
||
624 | 624 | * @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. |
625 | 625 | * @return array Options between 0.1 and 10 seconds. |
626 | 626 | */ |
627 | - private function get_duration_options ( $include_milliseconds = true ) { |
|
628 | - $numbers = array( '1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0' ); |
|
627 | + private function get_duration_options($include_milliseconds = true) { |
|
628 | + $numbers = array('1.0', '1.5', '2.0', '2.5', '3.0', '3.5', '4.0', '4.5', '5.0', '5.5', '6.0', '6.5', '7.0', '7.5', '8.0', '8.5', '9.0', '9.5', '10.0'); |
|
629 | 629 | $options = array(); |
630 | 630 | |
631 | - if ( true == (bool)$include_milliseconds ) { |
|
632 | - $milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); |
|
633 | - foreach ( $milliseconds as $k => $v ) { |
|
631 | + if (true == (bool) $include_milliseconds) { |
|
632 | + $milliseconds = array('0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9'); |
|
633 | + foreach ($milliseconds as $k => $v) { |
|
634 | 634 | $options[$v] = $v; |
635 | 635 | } |
636 | 636 | } else { |
637 | 637 | $options['0.5'] = '0.5'; |
638 | 638 | } |
639 | 639 | |
640 | - foreach ( $numbers as $k => $v ) { |
|
640 | + foreach ($numbers as $k => $v) { |
|
641 | 641 | $options[$v] = $v; |
642 | 642 | } |
643 | 643 | |
@@ -653,25 +653,25 @@ discard block |
||
653 | 653 | private function pages_array() { |
654 | 654 | // REFACTOR - Transform this into a field type instead. |
655 | 655 | // Setup an array of portfolio gallery terms for a dropdown. |
656 | - $args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); |
|
657 | - $pages_dropdown = wp_dropdown_pages( $args ); |
|
656 | + $args = array('echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC'); |
|
657 | + $pages_dropdown = wp_dropdown_pages($args); |
|
658 | 658 | $page_items = array(); |
659 | 659 | |
660 | 660 | // Quick string hack to make sure we get the pages with the indents. |
661 | - $pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); |
|
662 | - $pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); |
|
663 | - $pages_split = explode( '</option>', $pages_dropdown ); |
|
661 | + $pages_dropdown = str_replace("<select class='' name='page_id' id='page_id'>", '', $pages_dropdown); |
|
662 | + $pages_dropdown = str_replace('</select>', '', $pages_dropdown); |
|
663 | + $pages_split = explode('</option>', $pages_dropdown); |
|
664 | 664 | |
665 | - $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
|
665 | + $page_items[] = __('Select a Page:', 'woothemes-sensei'); |
|
666 | 666 | |
667 | - foreach ( $pages_split as $k => $v ) { |
|
667 | + foreach ($pages_split as $k => $v) { |
|
668 | 668 | $id = ''; |
669 | 669 | // Get the ID value. |
670 | - preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
670 | + preg_match('/value="(.*?)"/i', $v, $matches); |
|
671 | 671 | |
672 | - if ( isset( $matches[1] ) ) { |
|
672 | + if (isset($matches[1])) { |
|
673 | 673 | $id = $matches[1]; |
674 | - $page_items[$id] = trim( strip_tags( $v ) ); |
|
674 | + $page_items[$id] = trim(strip_tags($v)); |
|
675 | 675 | } // End If Statement |
676 | 676 | } // End For Loop |
677 | 677 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | * |
696 | 696 | * @since 1.9.0 |
697 | 697 | */ |
698 | - public static function flush_rewrite_rules(){ |
|
698 | + public static function flush_rewrite_rules() { |
|
699 | 699 | |
700 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
701 | - && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
700 | + if (isset($_POST['option_page']) && 'woothemes-sensei-settings' == $_POST['option_page'] |
|
701 | + && isset($_POST['action']) && 'update' == $_POST['action']) { |
|
702 | 702 | |
703 | 703 | Sensei()->initiate_rewrite_rules_flush(); |
704 | 704 | |
@@ -712,4 +712,4 @@ discard block |
||
712 | 712 | * @ignore only for backward compatibility |
713 | 713 | * @since 1.9.0 |
714 | 714 | */ |
715 | -class WooThemes_Sensei_Settings extends Sensei_Settings{} |
|
715 | +class WooThemes_Sensei_Settings extends Sensei_Settings {} |
@@ -1,5 +1,5 @@ discard block |
||
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 Utilities Class |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | * @since 1.0.0 |
19 | 19 | * @return string The URL to the placeholder thumbnail image. |
20 | 20 | */ |
21 | - public static function get_placeholder_image () { |
|
21 | + public static function get_placeholder_image() { |
|
22 | 22 | |
23 | - return esc_url( apply_filters( 'sensei_placeholder_thumbnail', Sensei()->plugin_url . 'assets/images/placeholder.png' ) ); |
|
23 | + return esc_url(apply_filters('sensei_placeholder_thumbnail', Sensei()->plugin_url.'assets/images/placeholder.png')); |
|
24 | 24 | } // End get_placeholder_image() |
25 | 25 | |
26 | 26 | /** |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @static |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public static function sensei_is_woocommerce_present () { |
|
35 | + public static function sensei_is_woocommerce_present() { |
|
36 | 36 | |
37 | 37 | return Sensei_WC::is_woocommerce_present(); |
38 | 38 | |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @static |
48 | 48 | * @return boolean |
49 | 49 | */ |
50 | - public static function sensei_is_woocommerce_activated () { |
|
50 | + public static function sensei_is_woocommerce_activated() { |
|
51 | 51 | |
52 | 52 | return Sensei_WC::is_woocommerce_active(); |
53 | 53 | |
@@ -60,70 +60,70 @@ discard block |
||
60 | 60 | * @param array $args (default: array()) |
61 | 61 | * @return bool | int |
62 | 62 | */ |
63 | - public static function sensei_log_activity ( $args = array() ) { |
|
63 | + public static function sensei_log_activity($args = array()) { |
|
64 | 64 | global $wpdb; |
65 | 65 | |
66 | 66 | // Args, minimum data required for WP |
67 | 67 | $data = array( |
68 | - 'comment_post_ID' => intval( $args['post_id'] ), |
|
68 | + 'comment_post_ID' => intval($args['post_id']), |
|
69 | 69 | 'comment_author' => '', // Not needed |
70 | 70 | 'comment_author_email' => '', // Not needed |
71 | 71 | 'comment_author_url' => '', // Not needed |
72 | - 'comment_content' => !empty($args['data']) ? esc_html( $args['data'] ) : '', |
|
73 | - 'comment_type' => esc_attr( $args['type'] ), |
|
74 | - 'user_id' => intval( $args['user_id'] ), |
|
75 | - 'comment_approved' => !empty($args['status']) ? esc_html( $args['status'] ) : 'log', // 'log' == 'sensei_user_answer' |
|
72 | + 'comment_content' => ! empty($args['data']) ? esc_html($args['data']) : '', |
|
73 | + 'comment_type' => esc_attr($args['type']), |
|
74 | + 'user_id' => intval($args['user_id']), |
|
75 | + 'comment_approved' => ! empty($args['status']) ? esc_html($args['status']) : 'log', // 'log' == 'sensei_user_answer' |
|
76 | 76 | ); |
77 | 77 | // Allow extra data |
78 | - if ( !empty($args['username']) ) { |
|
79 | - $data['comment_author'] = sanitize_user( $args['username'] ); |
|
78 | + if ( ! empty($args['username'])) { |
|
79 | + $data['comment_author'] = sanitize_user($args['username']); |
|
80 | 80 | } |
81 | - if ( !empty($args['user_email']) ) { |
|
82 | - $data['comment_author_email'] = sanitize_email( $args['user_email'] ); |
|
81 | + if ( ! empty($args['user_email'])) { |
|
82 | + $data['comment_author_email'] = sanitize_email($args['user_email']); |
|
83 | 83 | } |
84 | - if ( !empty($args['user_url']) ) { |
|
85 | - $data['comment_author_url'] = esc_url( $args['user_url'] ); |
|
84 | + if ( ! empty($args['user_url'])) { |
|
85 | + $data['comment_author_url'] = esc_url($args['user_url']); |
|
86 | 86 | } |
87 | - if ( !empty($args['parent']) ) { |
|
87 | + if ( ! empty($args['parent'])) { |
|
88 | 88 | $data['comment_parent'] = $args['parent']; |
89 | 89 | } |
90 | 90 | // Sanity check |
91 | - if ( empty($args['user_id']) ) { |
|
92 | - _deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') ); |
|
91 | + if (empty($args['user_id'])) { |
|
92 | + _deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei')); |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
96 | - do_action( 'sensei_log_activity_before', $args, $data ); |
|
96 | + do_action('sensei_log_activity_before', $args, $data); |
|
97 | 97 | |
98 | 98 | $flush_cache = false; |
99 | 99 | |
100 | 100 | // Custom Logic |
101 | 101 | // Check if comment exists first |
102 | - $comment_id = $wpdb->get_var( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'] ) ); |
|
103 | - if ( ! $comment_id ) { |
|
102 | + $comment_id = $wpdb->get_var($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = %s ", $args['post_id'], $args['user_id'], $args['type'])); |
|
103 | + if ( ! $comment_id) { |
|
104 | 104 | // Add the comment |
105 | - $comment_id = wp_insert_comment( $data ); |
|
105 | + $comment_id = wp_insert_comment($data); |
|
106 | 106 | |
107 | 107 | $flush_cache = true; |
108 | - } elseif ( isset( $args['action'] ) && 'update' == $args['action'] ) { |
|
108 | + } elseif (isset($args['action']) && 'update' == $args['action']) { |
|
109 | 109 | // Update the comment if an update was requested |
110 | 110 | $data['comment_ID'] = $comment_id; |
111 | 111 | // By default update the timestamp of the comment |
112 | - if ( empty($args['keep_time']) ) { |
|
112 | + if (empty($args['keep_time'])) { |
|
113 | 113 | $data['comment_date'] = current_time('mysql'); |
114 | 114 | } |
115 | - wp_update_comment( $data ); |
|
115 | + wp_update_comment($data); |
|
116 | 116 | $flush_cache = true; |
117 | 117 | } // End If Statement |
118 | 118 | |
119 | 119 | // Manually Flush the Cache |
120 | - if ( $flush_cache ) { |
|
120 | + if ($flush_cache) { |
|
121 | 121 | wp_cache_flush(); |
122 | 122 | } |
123 | 123 | |
124 | - do_action( 'sensei_log_activity_after', $args, $data, $comment_id ); |
|
124 | + do_action('sensei_log_activity_after', $args, $data, $comment_id); |
|
125 | 125 | |
126 | - if ( 0 < $comment_id ) { |
|
126 | + if (0 < $comment_id) { |
|
127 | 127 | // Return the ID so that it can be used for meta data storage |
128 | 128 | return $comment_id; |
129 | 129 | } else { |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | * @param bool $return_comments (default: false) |
141 | 141 | * @return mixed | int |
142 | 142 | */ |
143 | - public static function sensei_check_for_activity ( $args = array(), $return_comments = false ) { |
|
143 | + public static function sensei_check_for_activity($args = array(), $return_comments = false) { |
|
144 | 144 | |
145 | 145 | global $wp_version; |
146 | - if ( !$return_comments ) { |
|
146 | + if ( ! $return_comments) { |
|
147 | 147 | $args['count'] = true; |
148 | 148 | } |
149 | 149 | |
150 | 150 | // Are we only retrieving a single entry, or not care about the order... |
151 | - if ( isset( $args['count'] ) || isset( $args['post_id'] ) ){ |
|
151 | + if (isset($args['count']) || isset($args['post_id'])) { |
|
152 | 152 | |
153 | 153 | // ...then we don't need to ask the db to order the results, this overrides WP default behaviour |
154 | - if ( version_compare( $wp_version, '4.1', '>=' ) ) { |
|
154 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
155 | 155 | $args['order'] = false; |
156 | 156 | $args['orderby'] = false; |
157 | 157 | } |
158 | 158 | } |
159 | 159 | |
160 | 160 | // A user ID of 0 is in valid, so shortcut this |
161 | - if ( isset( $args['user_id'] ) && 0 == intval ( $args['user_id'] ) ) { |
|
162 | - _deprecated_argument( __FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei') ); |
|
161 | + if (isset($args['user_id']) && 0 == intval($args['user_id'])) { |
|
162 | + _deprecated_argument(__FUNCTION__, '1.0', __('At no point should user_id be equal to 0.', 'woothemes-sensei')); |
|
163 | 163 | return false; |
164 | 164 | } |
165 | 165 | // Check for legacy code |
166 | - if ( isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes') ) ) { |
|
167 | - _deprecated_argument( __FUNCTION__, '1.7', sprintf( __('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'] ) ); |
|
166 | + if (isset($args['type']) && in_array($args['type'], array('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_quiz_grade', 'sense_answer_notes'))) { |
|
167 | + _deprecated_argument(__FUNCTION__, '1.7', sprintf(__('Sensei activity type %s is no longer used.', 'woothemes-sensei'), $args['type'])); |
|
168 | 168 | return false; |
169 | 169 | } |
170 | 170 | // Are we checking for specific comment_approved statuses? |
171 | - if ( isset($args['status']) ) { |
|
171 | + if (isset($args['status'])) { |
|
172 | 172 | // Temporarily store as a custom status if requesting an array... |
173 | - if ( is_array( $args['status'] ) && version_compare($wp_version, '4.1', '<') ) { |
|
173 | + if (is_array($args['status']) && version_compare($wp_version, '4.1', '<')) { |
|
174 | 174 | // Encode now, decode later |
175 | - $args['status'] = implode( ",", $args['status'] ); |
|
175 | + $args['status'] = implode(",", $args['status']); |
|
176 | 176 | // ...use a filter to switch the encoding back |
177 | - add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
|
177 | + add_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter')); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | else { |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | // Take into account WP < 4.1 will automatically add ' comment_approved = 1 OR comment_approved = 0 ' |
185 | - if ( ( is_array( $args['status'] ) || 'any' == $args['status'] ) && version_compare($wp_version, '4.1', '<') ) { |
|
186 | - add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); |
|
185 | + if ((is_array($args['status']) || 'any' == $args['status']) && version_compare($wp_version, '4.1', '<')) { |
|
186 | + add_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter')); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | //Get the comments |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param int|array $comments |
196 | 196 | */ |
197 | - $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); |
|
197 | + $comments = apply_filters('sensei_check_for_activity', get_comments($args)); |
|
198 | 198 | |
199 | - remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
|
200 | - remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); |
|
199 | + remove_filter('comments_clauses', array(__CLASS__, 'comment_multiple_status_filter')); |
|
200 | + remove_filter('comments_clauses', array(__CLASS__, 'comment_any_status_filter')); |
|
201 | 201 | // Return comments |
202 | - if ( $return_comments ) { |
|
202 | + if ($return_comments) { |
|
203 | 203 | // Could check for array of 1 and just return the 1 item? |
204 | - if ( is_array($comments) && 1 == count($comments) ) { |
|
204 | + if (is_array($comments) && 1 == count($comments)) { |
|
205 | 205 | $comments = array_shift($comments); |
206 | 206 | } |
207 | 207 | |
@@ -219,31 +219,31 @@ discard block |
||
219 | 219 | * @param array $args (default: array()) |
220 | 220 | * @return array |
221 | 221 | */ |
222 | - public static function sensei_activity_ids ( $args = array() ) { |
|
222 | + public static function sensei_activity_ids($args = array()) { |
|
223 | 223 | |
224 | 224 | |
225 | - $comments = Sensei_Utils::sensei_check_for_activity( $args, true ); |
|
225 | + $comments = Sensei_Utils::sensei_check_for_activity($args, true); |
|
226 | 226 | // Need to always use an array, even with only 1 item |
227 | - if ( !is_array($comments) ) { |
|
228 | - $comments = array( $comments ); |
|
227 | + if ( ! is_array($comments)) { |
|
228 | + $comments = array($comments); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | $post_ids = array(); |
232 | 232 | // Count comments |
233 | - if ( is_array( $comments ) && ( 0 < intval( count( $comments ) ) ) ) { |
|
234 | - foreach ( $comments as $key => $value ) { |
|
233 | + if (is_array($comments) && (0 < intval(count($comments)))) { |
|
234 | + foreach ($comments as $key => $value) { |
|
235 | 235 | // Add matches to id array |
236 | - if ( isset( $args['field'] ) && 'comment' == $args['field'] ) { |
|
237 | - array_push( $post_ids, $value->comment_ID ); |
|
238 | - } elseif( isset( $args['field'] ) && 'user_id' == $args['field'] ) { |
|
239 | - array_push( $post_ids, $value->user_id ); |
|
236 | + if (isset($args['field']) && 'comment' == $args['field']) { |
|
237 | + array_push($post_ids, $value->comment_ID); |
|
238 | + } elseif (isset($args['field']) && 'user_id' == $args['field']) { |
|
239 | + array_push($post_ids, $value->user_id); |
|
240 | 240 | } else { |
241 | - array_push( $post_ids, $value->comment_post_ID ); |
|
241 | + array_push($post_ids, $value->comment_post_ID); |
|
242 | 242 | } // End If Statement |
243 | 243 | } // End For Loop |
244 | 244 | // Reset array indexes |
245 | - $post_ids = array_unique( $post_ids ); |
|
246 | - $post_ids = array_values( $post_ids ); |
|
245 | + $post_ids = array_unique($post_ids); |
|
246 | + $post_ids = array_values($post_ids); |
|
247 | 247 | } // End If Statement |
248 | 248 | |
249 | 249 | return $post_ids; |
@@ -257,20 +257,20 @@ discard block |
||
257 | 257 | * @param array $args (default: array()) |
258 | 258 | * @return boolean |
259 | 259 | */ |
260 | - public static function sensei_delete_activities ( $args = array() ) { |
|
260 | + public static function sensei_delete_activities($args = array()) { |
|
261 | 261 | |
262 | 262 | $dataset_changes = false; |
263 | 263 | |
264 | 264 | // If activity exists remove activity from log |
265 | - $comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => intval( $args['post_id'] ), 'user_id' => intval( $args['user_id'] ), 'type' => esc_attr( $args['type'] ) ), true ); |
|
266 | - if( $comments ) { |
|
265 | + $comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => intval($args['post_id']), 'user_id' => intval($args['user_id']), 'type' => esc_attr($args['type'])), true); |
|
266 | + if ($comments) { |
|
267 | 267 | // Need to always return an array, even with only 1 item |
268 | - if ( !is_array( $comments ) ) { |
|
269 | - $comments = array( $comments ); |
|
268 | + if ( ! is_array($comments)) { |
|
269 | + $comments = array($comments); |
|
270 | 270 | } |
271 | - foreach ( $comments as $key => $value ) { |
|
272 | - if ( isset( $value->comment_ID ) && 0 < $value->comment_ID ) { |
|
273 | - $dataset_changes = wp_delete_comment( intval( $value->comment_ID ), true ); |
|
271 | + foreach ($comments as $key => $value) { |
|
272 | + if (isset($value->comment_ID) && 0 < $value->comment_ID) { |
|
273 | + $dataset_changes = wp_delete_comment(intval($value->comment_ID), true); |
|
274 | 274 | } // End If Statement |
275 | 275 | } // End For Loop |
276 | 276 | // Manually flush the cache |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | * @param integer $user_id User ID |
287 | 287 | * @return boolean |
288 | 288 | */ |
289 | - public static function delete_all_user_activity( $user_id = 0 ) { |
|
289 | + public static function delete_all_user_activity($user_id = 0) { |
|
290 | 290 | |
291 | 291 | $dataset_changes = false; |
292 | 292 | |
293 | - if( $user_id ) { |
|
293 | + if ($user_id) { |
|
294 | 294 | |
295 | - $activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true ); |
|
295 | + $activities = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user_id), true); |
|
296 | 296 | |
297 | - if( $activities ) { |
|
297 | + if ($activities) { |
|
298 | 298 | |
299 | 299 | // Need to always return an array, even with only 1 item |
300 | - if ( ! is_array( $activities ) ) { |
|
301 | - $activities = array( $activities ); |
|
300 | + if ( ! is_array($activities)) { |
|
301 | + $activities = array($activities); |
|
302 | 302 | } |
303 | 303 | |
304 | - foreach( $activities as $activity ) { |
|
305 | - if( '' == $activity->comment_type ) continue; |
|
306 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
307 | - $dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true ); |
|
304 | + foreach ($activities as $activity) { |
|
305 | + if ('' == $activity->comment_type) continue; |
|
306 | + if (strpos('sensei_', $activity->comment_type) != 0) continue; |
|
307 | + $dataset_changes = wp_delete_comment(intval($activity->comment_ID), true); |
|
308 | 308 | wp_cache_flush(); |
309 | 309 | } |
310 | 310 | } |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | * @param array $args (default: array()) |
322 | 322 | * @return string |
323 | 323 | */ |
324 | - public static function sensei_get_activity_value ( $args = array() ) { |
|
324 | + public static function sensei_get_activity_value($args = array()) { |
|
325 | 325 | |
326 | 326 | |
327 | 327 | $activity_value = false; |
328 | - if ( !empty($args['field']) ) { |
|
329 | - $comment = Sensei_Utils::sensei_check_for_activity( $args, true ); |
|
328 | + if ( ! empty($args['field'])) { |
|
329 | + $comment = Sensei_Utils::sensei_check_for_activity($args, true); |
|
330 | 330 | |
331 | - if ( isset( $comment->{$args['field']} ) && '' != $comment->{$args['field']} ) { |
|
331 | + if (isset($comment->{$args['field']} ) && '' != $comment->{$args['field']} ) { |
|
332 | 332 | $activity_value = $comment->{$args['field']}; |
333 | 333 | } // End If Statement |
334 | 334 | } |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | * @param int $product_id |
347 | 347 | * @return bool |
348 | 348 | */ |
349 | - public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { |
|
349 | + public static function sensei_customer_bought_product($customer_email, $user_id, $product_id) { |
|
350 | 350 | |
351 | 351 | $emails = array(); |
352 | 352 | |
353 | - if ( $user_id ) { |
|
354 | - $user = get_user_by( 'id', intval( $user_id ) ); |
|
353 | + if ($user_id) { |
|
354 | + $user = get_user_by('id', intval($user_id)); |
|
355 | 355 | $emails[] = $user->user_email; |
356 | 356 | } |
357 | 357 | |
358 | - if ( is_email( $customer_email ) ) |
|
358 | + if (is_email($customer_email)) |
|
359 | 359 | $emails[] = $customer_email; |
360 | 360 | |
361 | - if ( sizeof( $emails ) == 0 ) |
|
361 | + if (sizeof($emails) == 0) |
|
362 | 362 | return false; |
363 | 363 | |
364 | - return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
|
364 | + return Sensei_WC::has_customer_bought_product($user_id, $product_id); |
|
365 | 365 | |
366 | 366 | } // End sensei_customer_bought_product() |
367 | 367 | |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | * @param string $input_name Name for text area form element |
373 | 373 | * @return void |
374 | 374 | */ |
375 | - public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) { |
|
375 | + public static function sensei_text_editor($content = '', $editor_id = 'senseitexteditor', $input_name = '') { |
|
376 | 376 | |
377 | - if( ! $input_name ) $input_name = $editor_id; |
|
377 | + if ( ! $input_name) $input_name = $editor_id; |
|
378 | 378 | |
379 | 379 | $buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext'; |
380 | 380 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | 'quicktags' => false |
393 | 393 | ); |
394 | 394 | |
395 | - wp_editor( $content, $editor_id, $settings ); |
|
395 | + wp_editor($content, $editor_id, $settings); |
|
396 | 396 | |
397 | 397 | } // End sensei_text_editor() |
398 | 398 | |
@@ -402,57 +402,57 @@ discard block |
||
402 | 402 | * @param int $user_id |
403 | 403 | * @return boolean Whether the answers were saved or not |
404 | 404 | */ |
405 | - public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) { |
|
405 | + public static function sensei_save_quiz_answers($submitted = array(), $user_id = 0) { |
|
406 | 406 | |
407 | - if( intval( $user_id ) == 0 ) { |
|
407 | + if (intval($user_id) == 0) { |
|
408 | 408 | $user_id = get_current_user_id(); |
409 | 409 | } |
410 | 410 | |
411 | 411 | $answers_saved = false; |
412 | 412 | |
413 | - if( $submitted && intval( $user_id ) > 0 ) { |
|
413 | + if ($submitted && intval($user_id) > 0) { |
|
414 | 414 | |
415 | - foreach( $submitted as $question_id => $answer ) { |
|
415 | + foreach ($submitted as $question_id => $answer) { |
|
416 | 416 | |
417 | 417 | // Get question type |
418 | - $question_type = Sensei()->question->get_question_type( $question_id ); |
|
418 | + $question_type = Sensei()->question->get_question_type($question_id); |
|
419 | 419 | |
420 | 420 | // Sanitise answer |
421 | - if( 0 == get_magic_quotes_gpc() ) { |
|
422 | - $answer = wp_unslash( $answer ); |
|
421 | + if (0 == get_magic_quotes_gpc()) { |
|
422 | + $answer = wp_unslash($answer); |
|
423 | 423 | } |
424 | - switch( $question_type ) { |
|
425 | - case 'multi-line': $answer = nl2br( $answer ); break; |
|
424 | + switch ($question_type) { |
|
425 | + case 'multi-line': $answer = nl2br($answer); break; |
|
426 | 426 | case 'single-line': break; |
427 | 427 | case 'gap-fill': break; |
428 | - default: $answer = maybe_serialize( $answer ); break; |
|
428 | + default: $answer = maybe_serialize($answer); break; |
|
429 | 429 | } |
430 | 430 | $args = array( |
431 | 431 | 'post_id' => $question_id, |
432 | - 'data' => base64_encode( $answer ), |
|
432 | + 'data' => base64_encode($answer), |
|
433 | 433 | 'type' => 'sensei_user_answer', /* FIELD SIZE 20 */ |
434 | 434 | 'user_id' => $user_id, |
435 | 435 | 'action' => 'update' |
436 | 436 | ); |
437 | - $answers_saved = Sensei_Utils::sensei_log_activity( $args ); |
|
437 | + $answers_saved = Sensei_Utils::sensei_log_activity($args); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | // Handle file upload questions |
441 | - if( isset( $_FILES ) ) { |
|
442 | - foreach( $_FILES as $field => $file ) { |
|
443 | - if( strpos( $field, 'file_upload_' ) !== false ) { |
|
444 | - $question_id = str_replace( 'file_upload_', '', $field ); |
|
445 | - if( $file && $question_id ) { |
|
446 | - $attachment_id = self::upload_file( $file ); |
|
447 | - if( $attachment_id ) { |
|
441 | + if (isset($_FILES)) { |
|
442 | + foreach ($_FILES as $field => $file) { |
|
443 | + if (strpos($field, 'file_upload_') !== false) { |
|
444 | + $question_id = str_replace('file_upload_', '', $field); |
|
445 | + if ($file && $question_id) { |
|
446 | + $attachment_id = self::upload_file($file); |
|
447 | + if ($attachment_id) { |
|
448 | 448 | $args = array( |
449 | 449 | 'post_id' => $question_id, |
450 | - 'data' => base64_encode( $attachment_id ), |
|
450 | + 'data' => base64_encode($attachment_id), |
|
451 | 451 | 'type' => 'sensei_user_answer', /* FIELD SIZE 20 */ |
452 | 452 | 'user_id' => $user_id, |
453 | 453 | 'action' => 'update' |
454 | 454 | ); |
455 | - $answers_saved = Sensei_Utils::sensei_log_activity( $args ); |
|
455 | + $answers_saved = Sensei_Utils::sensei_log_activity($args); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
@@ -464,9 +464,9 @@ discard block |
||
464 | 464 | |
465 | 465 | } // End sensei_save_quiz_answers() |
466 | 466 | |
467 | - public static function upload_file( $file = array() ) { |
|
467 | + public static function upload_file($file = array()) { |
|
468 | 468 | |
469 | - require_once( ABSPATH . 'wp-admin/includes/admin.php' ); |
|
469 | + require_once(ABSPATH.'wp-admin/includes/admin.php'); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Filter the data array for the Sensei wp_handle_upload function call |
@@ -481,11 +481,11 @@ discard block |
||
481 | 481 | * @type string test_form set to false by default |
482 | 482 | * } |
483 | 483 | */ |
484 | - $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); |
|
484 | + $file_upload_args = apply_filters('sensei_file_upload_args', array('test_form' => false)); |
|
485 | 485 | |
486 | - $file_return = wp_handle_upload( $file, $file_upload_args ); |
|
486 | + $file_return = wp_handle_upload($file, $file_upload_args); |
|
487 | 487 | |
488 | - if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { |
|
488 | + if (isset($file_return['error']) || isset($file_return['upload_error_handler'])) { |
|
489 | 489 | return false; |
490 | 490 | } else { |
491 | 491 | |
@@ -493,19 +493,19 @@ discard block |
||
493 | 493 | |
494 | 494 | $attachment = array( |
495 | 495 | 'post_mime_type' => $file_return['type'], |
496 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), |
|
496 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), |
|
497 | 497 | 'post_content' => '', |
498 | 498 | 'post_status' => 'inherit', |
499 | 499 | 'guid' => $file_return['url'] |
500 | 500 | ); |
501 | 501 | |
502 | - $attachment_id = wp_insert_attachment( $attachment, $filename ); |
|
502 | + $attachment_id = wp_insert_attachment($attachment, $filename); |
|
503 | 503 | |
504 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
505 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
506 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
504 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
505 | + $attachment_data = wp_generate_attachment_metadata($attachment_id, $filename); |
|
506 | + wp_update_attachment_metadata($attachment_id, $attachment_data); |
|
507 | 507 | |
508 | - if( 0 < intval( $attachment_id ) ) { |
|
508 | + if (0 < intval($attachment_id)) { |
|
509 | 509 | return $attachment_id; |
510 | 510 | } |
511 | 511 | } |
@@ -531,9 +531,9 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return int $quiz_grade total sum of all question grades |
533 | 533 | */ |
534 | - public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { |
|
534 | + public static function sensei_grade_quiz_auto($quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto') { |
|
535 | 535 | |
536 | - return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); |
|
536 | + return Sensei_Grading::grade_quiz_auto($quiz_id, $submitted, $total_questions, $quiz_grade_type); |
|
537 | 537 | |
538 | 538 | } // End sensei_grade_quiz_auto() |
539 | 539 | |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | * @param string $quiz_grade_type default 'auto' |
546 | 546 | * @return boolean |
547 | 547 | */ |
548 | - public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) { |
|
549 | - if( intval( $user_id ) == 0 ) { |
|
548 | + public static function sensei_grade_quiz($quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto') { |
|
549 | + if (intval($user_id) == 0) { |
|
550 | 550 | $user_id = get_current_user_id(); |
551 | 551 | } |
552 | 552 | |
553 | 553 | $activity_logged = false; |
554 | - if( intval( $quiz_id ) > 0 && intval( $user_id ) > 0 ) { |
|
555 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
556 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
557 | - $activity_logged = update_comment_meta( $user_lesson_status->comment_ID, 'grade', $grade ); |
|
554 | + if (intval($quiz_id) > 0 && intval($user_id) > 0) { |
|
555 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
556 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
557 | + $activity_logged = update_comment_meta($user_lesson_status->comment_ID, 'grade', $grade); |
|
558 | 558 | |
559 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); |
|
559 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); |
|
560 | 560 | |
561 | - do_action( 'sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type ); |
|
561 | + do_action('sensei_user_quiz_grade', $user_id, $quiz_id, $grade, $quiz_passmark, $quiz_grade_type); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | return $activity_logged; |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return int $question_grade |
580 | 580 | */ |
581 | - public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { |
|
581 | + public static function sensei_grade_question_auto($question_id = 0, $question_type = '', $answer = '', $user_id = 0) { |
|
582 | 582 | |
583 | - return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); |
|
583 | + return WooThemes_Sensei_Grading::grade_question_auto($question_id, $question_type, $answer, $user_id); |
|
584 | 584 | |
585 | 585 | } // end sensei_grade_question_auto |
586 | 586 | |
@@ -591,20 +591,20 @@ discard block |
||
591 | 591 | * @param int $user_id |
592 | 592 | * @return boolean |
593 | 593 | */ |
594 | - public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) { |
|
595 | - if( intval( $user_id ) == 0 ) { |
|
594 | + public static function sensei_grade_question($question_id = 0, $grade = 0, $user_id = 0) { |
|
595 | + if (intval($user_id) == 0) { |
|
596 | 596 | $user_id = get_current_user_id(); |
597 | 597 | } |
598 | 598 | |
599 | 599 | $activity_logged = false; |
600 | - if( intval( $question_id ) > 0 && intval( $user_id ) > 0 ) { |
|
600 | + if (intval($question_id) > 0 && intval($user_id) > 0) { |
|
601 | 601 | |
602 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
|
603 | - $activity_logged = update_comment_meta( $user_answer_id, 'user_grade', $grade ); |
|
602 | + $user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); |
|
603 | + $activity_logged = update_comment_meta($user_answer_id, 'user_grade', $grade); |
|
604 | 604 | |
605 | - $answer_notes = get_post_meta( $question_id, '_answer_feedback', true ); |
|
606 | - if ( !empty($answer_notes) ) { |
|
607 | - update_comment_meta( $user_answer_id, 'answer_note', base64_encode( $answer_notes ) ); |
|
605 | + $answer_notes = get_post_meta($question_id, '_answer_feedback', true); |
|
606 | + if ( ! empty($answer_notes)) { |
|
607 | + update_comment_meta($user_answer_id, 'answer_note', base64_encode($answer_notes)); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | } |
@@ -612,15 +612,15 @@ discard block |
||
612 | 612 | return $activity_logged; |
613 | 613 | } |
614 | 614 | |
615 | - public static function sensei_delete_question_grade( $question_id = 0, $user_id = 0 ) { |
|
616 | - if( intval( $user_id ) == 0 ) { |
|
615 | + public static function sensei_delete_question_grade($question_id = 0, $user_id = 0) { |
|
616 | + if (intval($user_id) == 0) { |
|
617 | 617 | $user_id = get_current_user_id(); |
618 | 618 | } |
619 | 619 | |
620 | 620 | $activity_logged = false; |
621 | - if( intval( $question_id ) > 0 ) { |
|
622 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
|
623 | - $activity_logged = delete_comment_meta( $user_answer_id, 'user_grade' ); |
|
621 | + if (intval($question_id) > 0) { |
|
622 | + $user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); |
|
623 | + $activity_logged = delete_comment_meta($user_answer_id, 'user_grade'); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | return $activity_logged; |
@@ -638,9 +638,9 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @return mixed boolean or comment_ID |
640 | 640 | */ |
641 | - public static function user_start_lesson( $user_id = 0, $lesson_id = 0, $complete = false ) { |
|
641 | + public static function user_start_lesson($user_id = 0, $lesson_id = 0, $complete = false) { |
|
642 | 642 | |
643 | - return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); |
|
643 | + return self::sensei_start_lesson($lesson_id, $user_id, $complete); |
|
644 | 644 | |
645 | 645 | }// end user_start_lesson() |
646 | 646 | |
@@ -657,22 +657,22 @@ discard block |
||
657 | 657 | * |
658 | 658 | * @return mixed boolean or comment_ID |
659 | 659 | */ |
660 | - public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) { |
|
660 | + public static function sensei_start_lesson($lesson_id = 0, $user_id = 0, $complete = false) { |
|
661 | 661 | |
662 | 662 | |
663 | - if( intval( $user_id ) == 0 ) { |
|
663 | + if (intval($user_id) == 0) { |
|
664 | 664 | $user_id = get_current_user_id(); |
665 | 665 | } |
666 | 666 | |
667 | 667 | $activity_logged = false; |
668 | 668 | |
669 | - if( intval( $lesson_id ) > 0 ) { |
|
669 | + if (intval($lesson_id) > 0) { |
|
670 | 670 | |
671 | - $course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
672 | - if( $course_id ) { |
|
673 | - $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, $user_id ); |
|
674 | - if( ! $is_user_taking_course ) { |
|
675 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
671 | + $course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
672 | + if ($course_id) { |
|
673 | + $is_user_taking_course = Sensei_Utils::user_started_course($course_id, $user_id); |
|
674 | + if ( ! $is_user_taking_course) { |
|
675 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
@@ -680,12 +680,12 @@ discard block |
||
680 | 680 | $status = 'in-progress'; |
681 | 681 | |
682 | 682 | // Note: When this action runs the lesson status may not yet exist |
683 | - do_action( 'sensei_user_lesson_start', $user_id, $lesson_id ); |
|
683 | + do_action('sensei_user_lesson_start', $user_id, $lesson_id); |
|
684 | 684 | |
685 | - if( $complete ) { |
|
685 | + if ($complete) { |
|
686 | 686 | |
687 | - $has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
688 | - if ( $has_questions ) { |
|
687 | + $has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
688 | + if ($has_questions) { |
|
689 | 689 | $status = 'passed'; // Force a pass |
690 | 690 | $metadata['grade'] = 0; |
691 | 691 | } |
@@ -695,31 +695,31 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | // Check if user is already taking the lesson |
698 | - $activity_logged = Sensei_Utils::user_started_lesson( $lesson_id, $user_id ); |
|
699 | - if( ! $activity_logged ) { |
|
698 | + $activity_logged = Sensei_Utils::user_started_lesson($lesson_id, $user_id); |
|
699 | + if ( ! $activity_logged) { |
|
700 | 700 | |
701 | 701 | $metadata['start'] = current_time('mysql'); |
702 | - $activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata ); |
|
702 | + $activity_logged = Sensei_Utils::update_lesson_status($user_id, $lesson_id, $status, $metadata); |
|
703 | 703 | |
704 | 704 | } else { |
705 | 705 | |
706 | 706 | // if users is already taking the lesson and the status changes to complete update it |
707 | 707 | $current_user_activity = get_comment($activity_logged); |
708 | - if( $status=='complete' && |
|
709 | - $status != $current_user_activity->comment_approved ){ |
|
708 | + if ($status == 'complete' && |
|
709 | + $status != $current_user_activity->comment_approved) { |
|
710 | 710 | |
711 | 711 | $comment = array(); |
712 | 712 | $comment['comment_ID'] = $activity_logged; |
713 | 713 | $comment['comment_approved'] = $status; |
714 | - wp_update_comment( $comment ); |
|
714 | + wp_update_comment($comment); |
|
715 | 715 | |
716 | 716 | } |
717 | 717 | |
718 | 718 | } |
719 | 719 | |
720 | - if ( $complete ) { |
|
720 | + if ($complete) { |
|
721 | 721 | // Run this *after* the lesson status has been created/updated |
722 | - do_action( 'sensei_user_lesson_end', $user_id, $lesson_id ); |
|
722 | + do_action('sensei_user_lesson_end', $user_id, $lesson_id); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | } |
@@ -734,20 +734,20 @@ discard block |
||
734 | 734 | * @param int $user_id |
735 | 735 | * @return boolean |
736 | 736 | */ |
737 | - public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) { |
|
737 | + public static function sensei_remove_user_from_lesson($lesson_id = 0, $user_id = 0, $from_course = false) { |
|
738 | 738 | |
739 | 739 | |
740 | - if( ! $lesson_id ) return false; |
|
740 | + if ( ! $lesson_id) return false; |
|
741 | 741 | |
742 | - if( intval( $user_id ) == 0 ) { |
|
742 | + if (intval($user_id) == 0) { |
|
743 | 743 | $user_id = get_current_user_id(); |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Process quiz |
747 | - $lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
747 | + $lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
748 | 748 | |
749 | 749 | // Delete quiz answers, this auto deletes the corresponding meta data, such as the question/answer grade |
750 | - Sensei_Utils::sensei_delete_quiz_answers( $lesson_quiz_id, $user_id ); |
|
750 | + Sensei_Utils::sensei_delete_quiz_answers($lesson_quiz_id, $user_id); |
|
751 | 751 | |
752 | 752 | // Delete lesson status |
753 | 753 | $args = array( |
@@ -756,10 +756,10 @@ discard block |
||
756 | 756 | 'user_id' => $user_id, |
757 | 757 | ); |
758 | 758 | // This auto deletes the corresponding meta data, such as the quiz grade, and questions asked |
759 | - Sensei_Utils::sensei_delete_activities( $args ); |
|
759 | + Sensei_Utils::sensei_delete_activities($args); |
|
760 | 760 | |
761 | - if( ! $from_course ) { |
|
762 | - do_action( 'sensei_user_lesson_reset', $user_id, $lesson_id ); |
|
761 | + if ( ! $from_course) { |
|
762 | + do_action('sensei_user_lesson_reset', $user_id, $lesson_id); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | return true; |
@@ -772,19 +772,19 @@ discard block |
||
772 | 772 | * @param int $user_id |
773 | 773 | * @return boolean |
774 | 774 | */ |
775 | - public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) { |
|
775 | + public static function sensei_remove_user_from_course($course_id = 0, $user_id = 0) { |
|
776 | 776 | |
777 | 777 | |
778 | - if( ! $course_id ) return false; |
|
778 | + if ( ! $course_id) return false; |
|
779 | 779 | |
780 | - if( intval( $user_id ) == 0 ) { |
|
780 | + if (intval($user_id) == 0) { |
|
781 | 781 | $user_id = get_current_user_id(); |
782 | 782 | } |
783 | 783 | |
784 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
784 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
785 | 785 | |
786 | - foreach( $lesson_ids as $lesson_id ) { |
|
787 | - Sensei_Utils::sensei_remove_user_from_lesson( $lesson_id, $user_id, true ); |
|
786 | + foreach ($lesson_ids as $lesson_id) { |
|
787 | + Sensei_Utils::sensei_remove_user_from_lesson($lesson_id, $user_id, true); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | // Delete course status |
@@ -794,36 +794,36 @@ discard block |
||
794 | 794 | 'user_id' => $user_id, |
795 | 795 | ); |
796 | 796 | |
797 | - Sensei_Utils::sensei_delete_activities( $args ); |
|
797 | + Sensei_Utils::sensei_delete_activities($args); |
|
798 | 798 | |
799 | - do_action( 'sensei_user_course_reset', $user_id, $course_id ); |
|
799 | + do_action('sensei_user_course_reset', $user_id, $course_id); |
|
800 | 800 | |
801 | 801 | return true; |
802 | 802 | } |
803 | 803 | |
804 | - public static function sensei_get_quiz_questions( $quiz_id = 0 ) { |
|
804 | + public static function sensei_get_quiz_questions($quiz_id = 0) { |
|
805 | 805 | |
806 | 806 | |
807 | 807 | $questions = array(); |
808 | 808 | |
809 | - if( intval( $quiz_id ) > 0 ) { |
|
810 | - $questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
|
811 | - $questions = Sensei_Utils::array_sort_reorder( $questions ); |
|
809 | + if (intval($quiz_id) > 0) { |
|
810 | + $questions = Sensei()->lesson->lesson_quiz_questions($quiz_id); |
|
811 | + $questions = Sensei_Utils::array_sort_reorder($questions); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | return $questions; |
815 | 815 | } |
816 | 816 | |
817 | - public static function sensei_get_quiz_total( $quiz_id = 0 ) { |
|
817 | + public static function sensei_get_quiz_total($quiz_id = 0) { |
|
818 | 818 | |
819 | 819 | |
820 | 820 | $quiz_total = 0; |
821 | 821 | |
822 | - if( $quiz_id > 0 ) { |
|
823 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
822 | + if ($quiz_id > 0) { |
|
823 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
824 | 824 | $question_grade = 0; |
825 | - foreach( $questions as $question ) { |
|
826 | - $question_grade = Sensei()->question->get_question_grade( $question->ID ); |
|
825 | + foreach ($questions as $question) { |
|
826 | + $question_grade = Sensei()->question->get_question_grade($question->ID); |
|
827 | 827 | $quiz_total += $question_grade; |
828 | 828 | } |
829 | 829 | } |
@@ -838,20 +838,20 @@ discard block |
||
838 | 838 | * @param int $user_id |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - public static function sensei_get_user_question_grade( $question = 0, $user_id = 0 ) { |
|
841 | + public static function sensei_get_user_question_grade($question = 0, $user_id = 0) { |
|
842 | 842 | $question_grade = false; |
843 | - if( $question ) { |
|
844 | - if ( is_object( $question ) ) { |
|
843 | + if ($question) { |
|
844 | + if (is_object($question)) { |
|
845 | 845 | $user_answer_id = $question->comment_ID; |
846 | 846 | } |
847 | 847 | else { |
848 | - if( intval( $user_id ) == 0 ) { |
|
848 | + if (intval($user_id) == 0) { |
|
849 | 849 | $user_id = get_current_user_id(); |
850 | 850 | } |
851 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
|
851 | + $user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); |
|
852 | 852 | } |
853 | - if ( $user_answer_id ) { |
|
854 | - $question_grade = get_comment_meta( $user_answer_id, 'user_grade', true ); |
|
853 | + if ($user_answer_id) { |
|
854 | + $question_grade = get_comment_meta($user_answer_id, 'user_grade', true); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
@@ -866,52 +866,52 @@ discard block |
||
866 | 866 | * @param int $user_id |
867 | 867 | * @return string |
868 | 868 | */ |
869 | - public static function sensei_get_user_question_answer_notes( $question = 0, $user_id = 0 ) { |
|
869 | + public static function sensei_get_user_question_answer_notes($question = 0, $user_id = 0) { |
|
870 | 870 | $answer_notes = false; |
871 | - if( $question ) { |
|
872 | - if ( is_object( $question ) ) { |
|
871 | + if ($question) { |
|
872 | + if (is_object($question)) { |
|
873 | 873 | $user_answer_id = $question->comment_ID; |
874 | 874 | } |
875 | 875 | else { |
876 | - if( intval( $user_id ) == 0 ) { |
|
876 | + if (intval($user_id) == 0) { |
|
877 | 877 | $user_id = get_current_user_id(); |
878 | 878 | } |
879 | - $user_answer_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
|
879 | + $user_answer_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => intval($question), 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); |
|
880 | 880 | } |
881 | - if ( $user_answer_id ) { |
|
882 | - $answer_notes = base64_decode( get_comment_meta( $user_answer_id, 'answer_note', true ) ); |
|
881 | + if ($user_answer_id) { |
|
882 | + $answer_notes = base64_decode(get_comment_meta($user_answer_id, 'answer_note', true)); |
|
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | 886 | return $answer_notes; |
887 | 887 | } |
888 | 888 | |
889 | - public static function sensei_delete_quiz_answers( $quiz_id = 0, $user_id = 0 ) { |
|
890 | - if( intval( $user_id ) == 0 ) { |
|
889 | + public static function sensei_delete_quiz_answers($quiz_id = 0, $user_id = 0) { |
|
890 | + if (intval($user_id) == 0) { |
|
891 | 891 | $user_id = get_current_user_id(); |
892 | 892 | } |
893 | 893 | |
894 | 894 | $delete_answers = false; |
895 | - if( intval( $quiz_id ) > 0 ) { |
|
896 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
897 | - foreach( $questions as $question ) { |
|
898 | - $delete_answers = Sensei_Utils::sensei_delete_activities( array( 'post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer' ) ); |
|
895 | + if (intval($quiz_id) > 0) { |
|
896 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
897 | + foreach ($questions as $question) { |
|
898 | + $delete_answers = Sensei_Utils::sensei_delete_activities(array('post_id' => $question->ID, 'user_id' => $user_id, 'type' => 'sensei_user_answer')); |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | |
902 | 902 | return $delete_answers; |
903 | 903 | } |
904 | 904 | |
905 | - public static function sensei_delete_quiz_grade( $quiz_id = 0, $user_id = 0 ) { |
|
906 | - if( intval( $user_id ) == 0 ) { |
|
905 | + public static function sensei_delete_quiz_grade($quiz_id = 0, $user_id = 0) { |
|
906 | + if (intval($user_id) == 0) { |
|
907 | 907 | $user_id = get_current_user_id(); |
908 | 908 | } |
909 | 909 | |
910 | 910 | $delete_grade = false; |
911 | - if( intval( $quiz_id ) > 0 ) { |
|
912 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
913 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
914 | - $delete_grade = delete_comment_meta( $user_lesson_status->comment_ID, 'grade' ); |
|
911 | + if (intval($quiz_id) > 0) { |
|
912 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
913 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
914 | + $delete_grade = delete_comment_meta($user_lesson_status->comment_ID, 'grade'); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | return $delete_grade; |
@@ -924,20 +924,20 @@ discard block |
||
924 | 924 | * @param string $notes |
925 | 925 | * @return boolean |
926 | 926 | */ |
927 | - public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) { |
|
928 | - if( intval( $user_id ) == 0 ) { |
|
927 | + public static function sensei_add_answer_notes($question_id = 0, $user_id = 0, $notes = '') { |
|
928 | + if (intval($user_id) == 0) { |
|
929 | 929 | $user_id = get_current_user_id(); |
930 | 930 | } |
931 | 931 | |
932 | 932 | $activity_logged = false; |
933 | 933 | |
934 | - if( intval( $question_id ) > 0 ) { |
|
935 | - $notes = base64_encode( $notes ); |
|
934 | + if (intval($question_id) > 0) { |
|
935 | + $notes = base64_encode($notes); |
|
936 | 936 | |
937 | 937 | // Don't store empty values, no point |
938 | - if ( !empty($notes) ) { |
|
939 | - $user_lesson_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
|
940 | - $activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes ); |
|
938 | + if ( ! empty($notes)) { |
|
939 | + $user_lesson_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID')); |
|
940 | + $activity_logged = update_comment_meta($user_lesson_id, 'answer_note', $notes); |
|
941 | 941 | } |
942 | 942 | else { |
943 | 943 | $activity_logged = true; |
@@ -953,16 +953,16 @@ discard block |
||
953 | 953 | * @param array $return_array data to be ordered |
954 | 954 | * @return array $return_array ordered data |
955 | 955 | */ |
956 | - public static function array_sort_reorder( $return_array ) { |
|
957 | - if ( isset( $_GET['orderby'] ) && '' != esc_html( $_GET['orderby'] ) ) { |
|
956 | + public static function array_sort_reorder($return_array) { |
|
957 | + if (isset($_GET['orderby']) && '' != esc_html($_GET['orderby'])) { |
|
958 | 958 | $sort_key = ''; |
959 | 959 | // if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->sortable_columns ) ) { |
960 | 960 | // $sort_key = esc_html( $_GET['orderby'] ); |
961 | 961 | // } // End If Statement |
962 | - if ( '' != $sort_key ) { |
|
963 | - Sensei_Utils::sort_array_by_key($return_array,$sort_key); |
|
964 | - if ( isset( $_GET['order'] ) && 'desc' == esc_html( $_GET['order'] ) ) { |
|
965 | - $return_array = array_reverse( $return_array, true ); |
|
962 | + if ('' != $sort_key) { |
|
963 | + Sensei_Utils::sort_array_by_key($return_array, $sort_key); |
|
964 | + if (isset($_GET['order']) && 'desc' == esc_html($_GET['order'])) { |
|
965 | + $return_array = array_reverse($return_array, true); |
|
966 | 966 | } // End If Statement |
967 | 967 | } // End If Statement |
968 | 968 | return $return_array; |
@@ -978,15 +978,15 @@ discard block |
||
978 | 978 | * @param $key string column name in array |
979 | 979 | * @return void |
980 | 980 | */ |
981 | - public static function sort_array_by_key( $array, $key ) { |
|
981 | + public static function sort_array_by_key($array, $key) { |
|
982 | 982 | $sorter = array(); |
983 | 983 | $ret = array(); |
984 | - reset( $array ); |
|
985 | - foreach ( $array as $ii => $va ) { |
|
984 | + reset($array); |
|
985 | + foreach ($array as $ii => $va) { |
|
986 | 986 | $sorter[$ii] = $va[$key]; |
987 | 987 | } // End For Loop |
988 | - asort( $sorter ); |
|
989 | - foreach ( $sorter as $ii => $va ) { |
|
988 | + asort($sorter); |
|
989 | + foreach ($sorter as $ii => $va) { |
|
990 | 990 | $ret[$ii] = $array[$ii]; |
991 | 991 | } // End For Loop |
992 | 992 | $array = $ret; |
@@ -998,10 +998,10 @@ discard block |
||
998 | 998 | * @param integer $quiz_id |
999 | 999 | * @return array of quiz questions |
1000 | 1000 | */ |
1001 | - public static function lesson_quiz_questions( $quiz_id = 0 ) { |
|
1001 | + public static function lesson_quiz_questions($quiz_id = 0) { |
|
1002 | 1002 | $questions_array = array(); |
1003 | - if ( 0 < $quiz_id ) { |
|
1004 | - $question_args = array( 'post_type' => 'question', |
|
1003 | + if (0 < $quiz_id) { |
|
1004 | + $question_args = array('post_type' => 'question', |
|
1005 | 1005 | 'posts_per_page' => -1, |
1006 | 1006 | 'orderby' => 'ID', |
1007 | 1007 | 'order' => 'ASC', |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | 'post_status' => 'any', |
1015 | 1015 | 'suppress_filters' => 0 |
1016 | 1016 | ); |
1017 | - $questions_array = get_posts( $question_args ); |
|
1017 | + $questions_array = get_posts($question_args); |
|
1018 | 1018 | } // End If Statement |
1019 | 1019 | return $questions_array; |
1020 | 1020 | } // End lesson_quiz_questions() |
@@ -1024,25 +1024,25 @@ discard block |
||
1024 | 1024 | * @param integer $course_id ID of course |
1025 | 1025 | * @return integer Pass mark for course |
1026 | 1026 | */ |
1027 | - public static function sensei_course_pass_grade( $course_id = 0 ) { |
|
1027 | + public static function sensei_course_pass_grade($course_id = 0) { |
|
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | $course_passmark = 0; |
1031 | 1031 | |
1032 | - if( $course_id > 0 ) { |
|
1033 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
1032 | + if ($course_id > 0) { |
|
1033 | + $lessons = Sensei()->course->course_lessons($course_id); |
|
1034 | 1034 | $lesson_count = 0; |
1035 | 1035 | $total_passmark = 0; |
1036 | - foreach( $lessons as $lesson ) { |
|
1036 | + foreach ($lessons as $lesson) { |
|
1037 | 1037 | |
1038 | 1038 | // Get Quiz ID |
1039 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson->ID ); |
|
1039 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson->ID); |
|
1040 | 1040 | |
1041 | 1041 | // Check for a pass being required |
1042 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
1043 | - if ( $pass_required ) { |
|
1042 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
1043 | + if ($pass_required) { |
|
1044 | 1044 | // Get quiz passmark |
1045 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); |
|
1045 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); |
|
1046 | 1046 | |
1047 | 1047 | // Add up total passmark |
1048 | 1048 | $total_passmark += $quiz_passmark; |
@@ -1051,12 +1051,12 @@ discard block |
||
1051 | 1051 | } |
1052 | 1052 | } |
1053 | 1053 | // Might be a case of no required lessons |
1054 | - if ( $lesson_count ) { |
|
1055 | - $course_passmark = ( $total_passmark / $lesson_count ); |
|
1054 | + if ($lesson_count) { |
|
1055 | + $course_passmark = ($total_passmark / $lesson_count); |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | |
1059 | - return Sensei_Utils::round( $course_passmark ); |
|
1059 | + return Sensei_Utils::round($course_passmark); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
@@ -1065,27 +1065,27 @@ discard block |
||
1065 | 1065 | * @param integer $user_id ID of user |
1066 | 1066 | * @return integer User's total grade |
1067 | 1067 | */ |
1068 | - public static function sensei_course_user_grade( $course_id = 0, $user_id = 0 ) { |
|
1068 | + public static function sensei_course_user_grade($course_id = 0, $user_id = 0) { |
|
1069 | 1069 | |
1070 | 1070 | |
1071 | - if( intval( $user_id ) == 0 ) { |
|
1071 | + if (intval($user_id) == 0) { |
|
1072 | 1072 | $user_id = get_current_user_id(); |
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | $total_grade = 0; |
1076 | 1076 | |
1077 | - if( $course_id > 0 && $user_id > 0 ) { |
|
1078 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
1077 | + if ($course_id > 0 && $user_id > 0) { |
|
1078 | + $lessons = Sensei()->course->course_lessons($course_id); |
|
1079 | 1079 | $lesson_count = 0; |
1080 | 1080 | $total_grade = 0; |
1081 | - foreach( $lessons as $lesson ) { |
|
1081 | + foreach ($lessons as $lesson) { |
|
1082 | 1082 | |
1083 | 1083 | // Check for lesson having questions, thus a quiz, thus having a grade |
1084 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
1085 | - if ( $has_questions ) { |
|
1086 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, $user_id ); |
|
1084 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); |
|
1085 | + if ($has_questions) { |
|
1086 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, $user_id); |
|
1087 | 1087 | // Get user quiz grade |
1088 | - $quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); |
|
1088 | + $quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); |
|
1089 | 1089 | |
1090 | 1090 | // Add up total grade |
1091 | 1091 | $total_grade += $quiz_grade; |
@@ -1095,13 +1095,13 @@ discard block |
||
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | // Might be a case of no lessons with quizzes |
1098 | - if ( $lesson_count ) { |
|
1099 | - $total_grade = ( $total_grade / $lesson_count ); |
|
1098 | + if ($lesson_count) { |
|
1099 | + $total_grade = ($total_grade / $lesson_count); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - return Sensei_Utils::round( $total_grade ); |
|
1104 | + return Sensei_Utils::round($total_grade); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | /** |
@@ -1110,18 +1110,18 @@ discard block |
||
1110 | 1110 | * @param integer $user_id ID of user |
1111 | 1111 | * @return boolean |
1112 | 1112 | */ |
1113 | - public static function sensei_user_passed_course( $course_id = 0, $user_id = 0 ) { |
|
1114 | - if( intval( $user_id ) == 0 ) { |
|
1113 | + public static function sensei_user_passed_course($course_id = 0, $user_id = 0) { |
|
1114 | + if (intval($user_id) == 0) { |
|
1115 | 1115 | $user_id = get_current_user_id(); |
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | $pass = false; |
1119 | 1119 | |
1120 | - if( $course_id > 0 && $user_id > 0 ) { |
|
1121 | - $passmark = Sensei_Utils::sensei_course_pass_grade( $course_id ); |
|
1122 | - $user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); |
|
1120 | + if ($course_id > 0 && $user_id > 0) { |
|
1121 | + $passmark = Sensei_Utils::sensei_course_pass_grade($course_id); |
|
1122 | + $user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id); |
|
1123 | 1123 | |
1124 | - if( $user_grade >= $passmark ) { |
|
1124 | + if ($user_grade >= $passmark) { |
|
1125 | 1125 | $pass = true; |
1126 | 1126 | } |
1127 | 1127 | } |
@@ -1136,38 +1136,38 @@ discard block |
||
1136 | 1136 | * @param integer $user_id ID of user |
1137 | 1137 | * @return array Status code and message |
1138 | 1138 | */ |
1139 | - public static function sensei_user_course_status_message( $course_id = 0, $user_id = 0 ) { |
|
1140 | - if( intval( $user_id ) == 0 ) { |
|
1139 | + public static function sensei_user_course_status_message($course_id = 0, $user_id = 0) { |
|
1140 | + if (intval($user_id) == 0) { |
|
1141 | 1141 | $user_id = get_current_user_id(); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | $status = 'not_started'; |
1145 | 1145 | $box_class = 'info'; |
1146 | - $message = __( 'You have not started this course yet.', 'woothemes-sensei' ); |
|
1146 | + $message = __('You have not started this course yet.', 'woothemes-sensei'); |
|
1147 | 1147 | |
1148 | - if( $course_id > 0 && $user_id > 0 ) { |
|
1148 | + if ($course_id > 0 && $user_id > 0) { |
|
1149 | 1149 | |
1150 | - $started_course = Sensei_Utils::user_started_course( $course_id, $user_id ); |
|
1150 | + $started_course = Sensei_Utils::user_started_course($course_id, $user_id); |
|
1151 | 1151 | |
1152 | - if( $started_course ) { |
|
1153 | - $passmark = Sensei_Utils::sensei_course_pass_grade( $course_id ); // This happens inside sensei_user_passed_course()! |
|
1154 | - $user_grade = Sensei_Utils::sensei_course_user_grade( $course_id, $user_id ); // This happens inside sensei_user_passed_course()! |
|
1155 | - if( $user_grade >= $passmark ) { |
|
1152 | + if ($started_course) { |
|
1153 | + $passmark = Sensei_Utils::sensei_course_pass_grade($course_id); // This happens inside sensei_user_passed_course()! |
|
1154 | + $user_grade = Sensei_Utils::sensei_course_user_grade($course_id, $user_id); // This happens inside sensei_user_passed_course()! |
|
1155 | + if ($user_grade >= $passmark) { |
|
1156 | 1156 | $status = 'passed'; |
1157 | 1157 | $box_class = 'tick'; |
1158 | - $message = sprintf( __( 'You have passed this course with a grade of %1$d%%.', 'woothemes-sensei' ), $user_grade ); |
|
1158 | + $message = sprintf(__('You have passed this course with a grade of %1$d%%.', 'woothemes-sensei'), $user_grade); |
|
1159 | 1159 | } else { |
1160 | 1160 | $status = 'failed'; |
1161 | 1161 | $box_class = 'alert'; |
1162 | - $message = sprintf( __( 'You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei' ), $passmark, $user_grade ); |
|
1162 | + $message = sprintf(__('You require %1$d%% to pass this course. Your grade is %2$s%%.', 'woothemes-sensei'), $passmark, $user_grade); |
|
1163 | 1163 | } |
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | } |
1167 | 1167 | |
1168 | - $message = apply_filters( 'sensei_user_course_status_' . $status, $message ); |
|
1168 | + $message = apply_filters('sensei_user_course_status_'.$status, $message); |
|
1169 | 1169 | |
1170 | - return array( 'status' => $status, 'box_class' => $box_class, 'message' => $message ); |
|
1170 | + return array('status' => $status, 'box_class' => $box_class, 'message' => $message); |
|
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | /** |
@@ -1177,94 +1177,94 @@ discard block |
||
1177 | 1177 | * @param bool $is_lesson |
1178 | 1178 | * @return array Status code and message |
1179 | 1179 | */ |
1180 | - public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) { |
|
1180 | + public static function sensei_user_quiz_status_message($lesson_id = 0, $user_id = 0, $is_lesson = false) { |
|
1181 | 1181 | global $current_user; |
1182 | - if( intval( $user_id ) == 0 ) { |
|
1182 | + if (intval($user_id) == 0) { |
|
1183 | 1183 | $user_id = $current_user->ID; |
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | $status = 'not_started'; |
1187 | 1187 | $box_class = 'info'; |
1188 | - $message = __( "You have not taken this lesson's quiz yet", 'woothemes-sensei' ); |
|
1188 | + $message = __("You have not taken this lesson's quiz yet", 'woothemes-sensei'); |
|
1189 | 1189 | $extra = ''; |
1190 | 1190 | |
1191 | - if( $lesson_id > 0 && $user_id > 0 ) { |
|
1191 | + if ($lesson_id > 0 && $user_id > 0) { |
|
1192 | 1192 | |
1193 | 1193 | // Prerequisite lesson |
1194 | - $prerequisite = get_post_meta( $lesson_id, '_lesson_prerequisite', true ); |
|
1194 | + $prerequisite = get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
1195 | 1195 | |
1196 | 1196 | // Course ID |
1197 | - $course_id = absint( get_post_meta( $lesson_id, '_lesson_course', true ) ); |
|
1197 | + $course_id = absint(get_post_meta($lesson_id, '_lesson_course', true)); |
|
1198 | 1198 | |
1199 | 1199 | // Has user started course |
1200 | - $started_course = Sensei_Utils::user_started_course( $course_id, $user_id ); |
|
1200 | + $started_course = Sensei_Utils::user_started_course($course_id, $user_id); |
|
1201 | 1201 | |
1202 | 1202 | // Has user completed lesson |
1203 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
1204 | - $lesson_complete = Sensei_Utils::user_completed_lesson( $user_lesson_status ); |
|
1203 | + $user_lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
1204 | + $lesson_complete = Sensei_Utils::user_completed_lesson($user_lesson_status); |
|
1205 | 1205 | |
1206 | 1206 | // Quiz ID |
1207 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
1207 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
1208 | 1208 | |
1209 | 1209 | // Quiz grade |
1210 | 1210 | $quiz_grade = 0; |
1211 | - if ( $user_lesson_status ) { |
|
1212 | - $quiz_grade = get_comment_meta( $user_lesson_status->comment_ID, 'grade', true ); |
|
1211 | + if ($user_lesson_status) { |
|
1212 | + $quiz_grade = get_comment_meta($user_lesson_status->comment_ID, 'grade', true); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | // Quiz passmark |
1216 | - $quiz_passmark = absint( get_post_meta( $quiz_id, '_quiz_passmark', true ) ); |
|
1216 | + $quiz_passmark = absint(get_post_meta($quiz_id, '_quiz_passmark', true)); |
|
1217 | 1217 | $quiz_passmark_float = (float) $quiz_passmark; |
1218 | 1218 | |
1219 | 1219 | // Pass required |
1220 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
1220 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
1221 | 1221 | |
1222 | 1222 | // Quiz questions |
1223 | - $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
1223 | + $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true); |
|
1224 | 1224 | |
1225 | - if ( ! $started_course ) { |
|
1225 | + if ( ! $started_course) { |
|
1226 | 1226 | |
1227 | 1227 | $status = 'not_started_course'; |
1228 | 1228 | $box_class = 'info'; |
1229 | - $message = sprintf( __( 'Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . esc_attr( __( 'Sign Up', 'woothemes-sensei' ) ) . '">', '</a>' ); |
|
1229 | + $message = sprintf(__('Please sign up for %1$sthe course%2$s before taking this quiz', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.esc_attr(__('Sign Up', 'woothemes-sensei')).'">', '</a>'); |
|
1230 | 1230 | |
1231 | - } elseif ( ! is_user_logged_in() ) { |
|
1231 | + } elseif ( ! is_user_logged_in()) { |
|
1232 | 1232 | |
1233 | 1233 | $status = 'login_required'; |
1234 | 1234 | $box_class = 'info'; |
1235 | - $message = __( 'You must be logged in to take this quiz', 'woothemes-sensei' ); |
|
1235 | + $message = __('You must be logged in to take this quiz', 'woothemes-sensei'); |
|
1236 | 1236 | |
1237 | 1237 | } |
1238 | 1238 | // Lesson/Quiz is marked as complete thus passing any quiz restrictions |
1239 | - elseif ( $lesson_complete ) { |
|
1239 | + elseif ($lesson_complete) { |
|
1240 | 1240 | |
1241 | 1241 | $status = 'passed'; |
1242 | 1242 | $box_class = 'tick'; |
1243 | 1243 | // Lesson status will be "complete" (has no Quiz) |
1244 | - if ( ! $has_quiz_questions ) { |
|
1245 | - $message = sprintf( __( 'Congratulations! You have passed this lesson.', 'woothemes-sensei' ) ); |
|
1244 | + if ( ! $has_quiz_questions) { |
|
1245 | + $message = sprintf(__('Congratulations! You have passed this lesson.', 'woothemes-sensei')); |
|
1246 | 1246 | } |
1247 | 1247 | // Lesson status will be "graded" (no passmark required so might have failed all the questions) |
1248 | - elseif ( empty( $quiz_grade ) ) { |
|
1249 | - $message = sprintf( __( 'Congratulations! You have completed this lesson.', 'woothemes-sensei' ) ); |
|
1248 | + elseif (empty($quiz_grade)) { |
|
1249 | + $message = sprintf(__('Congratulations! You have completed this lesson.', 'woothemes-sensei')); |
|
1250 | 1250 | } |
1251 | 1251 | // Lesson status will be "passed" (passmark reached) |
1252 | - elseif ( ! empty( $quiz_grade ) && abs( $quiz_grade ) >= 0 ) { |
|
1253 | - if( $is_lesson ) { |
|
1254 | - $message = sprintf( __( 'Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_grade ) ); |
|
1252 | + elseif ( ! empty($quiz_grade) && abs($quiz_grade) >= 0) { |
|
1253 | + if ($is_lesson) { |
|
1254 | + $message = sprintf(__('Congratulations! You have passed this lesson\'s quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade)); |
|
1255 | 1255 | } else { |
1256 | - $message = sprintf( __( 'Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_grade ) ); |
|
1256 | + $message = sprintf(__('Congratulations! You have passed this quiz achieving %s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_grade)); |
|
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | // add next lesson button |
1261 | - $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); |
|
1262 | - $next_lesson_id = absint( $nav_id_array['next_lesson'] ); |
|
1261 | + $nav_id_array = sensei_get_prev_next_lessons($lesson_id); |
|
1262 | + $next_lesson_id = absint($nav_id_array['next_lesson']); |
|
1263 | 1263 | |
1264 | 1264 | // Output HTML |
1265 | - if ( ( 0 < $next_lesson_id ) ) { |
|
1266 | - $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) |
|
1267 | - . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') |
|
1265 | + if ((0 < $next_lesson_id)) { |
|
1266 | + $message .= ' '.'<a class="next-lesson" href="'.esc_url(get_permalink($next_lesson_id)) |
|
1267 | + . '" rel="next"><span class="meta-nav"></span>'.__('Next Lesson', 'woothemes-sensei') |
|
1268 | 1268 | .'</a>'; |
1269 | 1269 | |
1270 | 1270 | } |
@@ -1273,33 +1273,33 @@ discard block |
||
1273 | 1273 | // Lesson/Quiz not complete |
1274 | 1274 | else { |
1275 | 1275 | // Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete) |
1276 | - if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) { |
|
1276 | + if (isset($user_lesson_status->comment_approved) && 'ungraded' == $user_lesson_status->comment_approved) { |
|
1277 | 1277 | $status = 'complete'; |
1278 | 1278 | $box_class = 'info'; |
1279 | - if( $is_lesson ) { |
|
1280 | - $message = sprintf( __( 'You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . esc_attr( get_the_title( $quiz_id ) ) . '">', '</a>' ); |
|
1279 | + if ($is_lesson) { |
|
1280 | + $message = sprintf(__('You have completed this lesson\'s quiz and it will be graded soon. %1$sView the lesson quiz%2$s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($quiz_id)).'" title="'.esc_attr(get_the_title($quiz_id)).'">', '</a>'); |
|
1281 | 1281 | } else { |
1282 | - $message = sprintf( __( 'You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); |
|
1282 | + $message = sprintf(__('You have completed this quiz and it will be graded soon. You require %1$s%% to pass.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); |
|
1283 | 1283 | } |
1284 | 1284 | } |
1285 | 1285 | // Lesson status must be "failed" |
1286 | - elseif ( isset( $user_lesson_status->comment_approved ) && 'failed' == $user_lesson_status->comment_approved ) { |
|
1286 | + elseif (isset($user_lesson_status->comment_approved) && 'failed' == $user_lesson_status->comment_approved) { |
|
1287 | 1287 | $status = 'failed'; |
1288 | 1288 | $box_class = 'alert'; |
1289 | - if( $is_lesson ) { |
|
1290 | - $message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ), Sensei_Utils::round( $quiz_grade ) ); |
|
1289 | + if ($is_lesson) { |
|
1290 | + $message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade)); |
|
1291 | 1291 | } else { |
1292 | - $message = sprintf( __( 'You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ), Sensei_Utils::round( $quiz_grade ) ); |
|
1292 | + $message = sprintf(__('You require %1$d%% to pass this quiz. Your grade is %2$s%%', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark), Sensei_Utils::round($quiz_grade)); |
|
1293 | 1293 | } |
1294 | 1294 | } |
1295 | 1295 | // Lesson/Quiz requires a pass |
1296 | - elseif( $pass_required ) { |
|
1296 | + elseif ($pass_required) { |
|
1297 | 1297 | $status = 'not_started'; |
1298 | 1298 | $box_class = 'info'; |
1299 | - if( $is_lesson ) { |
|
1300 | - $message = sprintf( __( 'You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); |
|
1299 | + if ($is_lesson) { |
|
1300 | + $message = sprintf(__('You require %1$d%% to pass this lesson\'s quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); |
|
1301 | 1301 | } else { |
1302 | - $message = sprintf( __( 'You require %1$d%% to pass this quiz.', 'woothemes-sensei' ), Sensei_Utils::round( $quiz_passmark ) ); |
|
1302 | + $message = sprintf(__('You require %1$d%% to pass this quiz.', 'woothemes-sensei'), Sensei_Utils::round($quiz_passmark)); |
|
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | } |
@@ -1307,15 +1307,15 @@ discard block |
||
1307 | 1307 | } |
1308 | 1308 | |
1309 | 1309 | // Legacy filter |
1310 | - $message = apply_filters( 'sensei_user_quiz_status_' . $status, $message ); |
|
1310 | + $message = apply_filters('sensei_user_quiz_status_'.$status, $message); |
|
1311 | 1311 | |
1312 | - if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) { |
|
1313 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
1314 | - $extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '</a></p>'; |
|
1312 | + if ($is_lesson && ! in_array($status, array('login_required', 'not_started_course'))) { |
|
1313 | + $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
1314 | + $extra = '<p><a class="button" href="'.esc_url(get_permalink($quiz_id)).'" title="'.__('View the lesson quiz', 'woothemes-sensei').'">'.__('View the lesson quiz', 'woothemes-sensei').'</a></p>'; |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | // Filter of all messages |
1318 | - return apply_filters( 'sensei_user_quiz_status', array( 'status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra ), $lesson_id, $user_id, $is_lesson ); |
|
1318 | + return apply_filters('sensei_user_quiz_status', array('status' => $status, 'box_class' => $box_class, 'message' => $message, 'extra' => $extra), $lesson_id, $user_id, $is_lesson); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | /** |
@@ -1325,14 +1325,14 @@ discard block |
||
1325 | 1325 | * @param integer $course_id Course ID |
1326 | 1326 | * @return mixed boolean or comment_ID |
1327 | 1327 | */ |
1328 | - public static function user_start_course( $user_id = 0, $course_id = 0 ) { |
|
1328 | + public static function user_start_course($user_id = 0, $course_id = 0) { |
|
1329 | 1329 | |
1330 | 1330 | $activity_logged = false; |
1331 | 1331 | |
1332 | - if( $user_id && $course_id ) { |
|
1332 | + if ($user_id && $course_id) { |
|
1333 | 1333 | // Check if user is already on the Course |
1334 | - $activity_logged = Sensei_Utils::user_started_course( $course_id, $user_id ); |
|
1335 | - if ( ! $activity_logged ) { |
|
1334 | + $activity_logged = Sensei_Utils::user_started_course($course_id, $user_id); |
|
1335 | + if ( ! $activity_logged) { |
|
1336 | 1336 | |
1337 | 1337 | // Add user to course |
1338 | 1338 | $course_metadata = array( |
@@ -1341,11 +1341,11 @@ discard block |
||
1341 | 1341 | 'complete' => 0, |
1342 | 1342 | ); |
1343 | 1343 | |
1344 | - $activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status = 'in-progress', $course_metadata ); |
|
1344 | + $activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status = 'in-progress', $course_metadata); |
|
1345 | 1345 | |
1346 | 1346 | // Allow further actions |
1347 | - if ( $activity_logged ) { |
|
1348 | - do_action( 'sensei_user_course_start', $user_id, $course_id ); |
|
1347 | + if ($activity_logged) { |
|
1348 | + do_action('sensei_user_course_start', $user_id, $course_id); |
|
1349 | 1349 | } |
1350 | 1350 | } |
1351 | 1351 | } |
@@ -1361,19 +1361,19 @@ discard block |
||
1361 | 1361 | * @param int $user_id |
1362 | 1362 | * @return mixed false or comment_ID |
1363 | 1363 | */ |
1364 | - public static function user_started_course( $course_id = 0, $user_id = 0 ) { |
|
1364 | + public static function user_started_course($course_id = 0, $user_id = 0) { |
|
1365 | 1365 | |
1366 | - if( $course_id ) { |
|
1367 | - if( ! $user_id ) { |
|
1366 | + if ($course_id) { |
|
1367 | + if ( ! $user_id) { |
|
1368 | 1368 | $user_id = get_current_user_id(); |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - if( ! $user_id > 0 ){ |
|
1371 | + if ( ! $user_id > 0) { |
|
1372 | 1372 | return false; |
1373 | 1373 | } |
1374 | 1374 | |
1375 | - $user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) ); |
|
1376 | - if( $user_course_status_id ) { |
|
1375 | + $user_course_status_id = Sensei_Utils::sensei_get_activity_value(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID')); |
|
1376 | + if ($user_course_status_id) { |
|
1377 | 1377 | return $user_course_status_id; |
1378 | 1378 | } |
1379 | 1379 | } |
@@ -1388,17 +1388,17 @@ discard block |
||
1388 | 1388 | * @param integer $user_id User ID |
1389 | 1389 | * @return int |
1390 | 1390 | */ |
1391 | - public static function user_complete_course( $course_id = 0, $user_id = 0 ) { |
|
1391 | + public static function user_complete_course($course_id = 0, $user_id = 0) { |
|
1392 | 1392 | global $wp_version; |
1393 | 1393 | |
1394 | - if( $course_id ) { |
|
1395 | - if( ! $user_id ) { |
|
1394 | + if ($course_id) { |
|
1395 | + if ( ! $user_id) { |
|
1396 | 1396 | $user_id = get_current_user_id(); |
1397 | 1397 | } |
1398 | 1398 | |
1399 | 1399 | $course_status = 'in-progress'; |
1400 | 1400 | $course_metadata = array(); |
1401 | - $course_completion = Sensei()->settings->settings[ 'course_completion' ]; |
|
1401 | + $course_completion = Sensei()->settings->settings['course_completion']; |
|
1402 | 1402 | $lessons_completed = $total_lessons = 0; |
1403 | 1403 | $lesson_status_args = array( |
1404 | 1404 | 'user_id' => $user_id, |
@@ -1407,8 +1407,8 @@ discard block |
||
1407 | 1407 | ); |
1408 | 1408 | |
1409 | 1409 | // Grab all of this Courses' lessons, looping through each... |
1410 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
1411 | - $total_lessons = count( $lesson_ids ); |
|
1410 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
1411 | + $total_lessons = count($lesson_ids); |
|
1412 | 1412 | // ...if course completion not set to 'passed', and all lessons are complete or graded, |
1413 | 1413 | // ......then all lessons are 'passed' |
1414 | 1414 | // ...else if course completion is set to 'passed', check if each lesson has questions... |
@@ -1421,29 +1421,29 @@ discard block |
||
1421 | 1421 | // The below checks if a lesson is fully completed, though maybe should be Utils::user_completed_lesson() |
1422 | 1422 | $all_lesson_statuses = array(); |
1423 | 1423 | // In WordPress 4.1 get_comments() allows a single query to cover multiple comment_post_IDs |
1424 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
1424 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
1425 | 1425 | $lesson_status_args['post__in'] = $lesson_ids; |
1426 | - $all_lesson_statuses = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true ); |
|
1426 | + $all_lesson_statuses = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true); |
|
1427 | 1427 | // Need to always return an array, even with only 1 item |
1428 | - if ( !is_array($all_lesson_statuses) ) { |
|
1429 | - $all_lesson_statuses = array( $all_lesson_statuses ); |
|
1428 | + if ( ! is_array($all_lesson_statuses)) { |
|
1429 | + $all_lesson_statuses = array($all_lesson_statuses); |
|
1430 | 1430 | } |
1431 | 1431 | } |
1432 | 1432 | // ...otherwise check each one |
1433 | 1433 | else { |
1434 | - foreach( $lesson_ids as $lesson_id ) { |
|
1434 | + foreach ($lesson_ids as $lesson_id) { |
|
1435 | 1435 | $lesson_status_args['post_id'] = $lesson_id; |
1436 | - $each_lesson_status = Sensei_Utils::sensei_check_for_activity( $lesson_status_args, true ); |
|
1436 | + $each_lesson_status = Sensei_Utils::sensei_check_for_activity($lesson_status_args, true); |
|
1437 | 1437 | // Check for valid return before using |
1438 | - if ( !empty($each_lesson_status->comment_approved) ) { |
|
1438 | + if ( ! empty($each_lesson_status->comment_approved)) { |
|
1439 | 1439 | $all_lesson_statuses[] = $each_lesson_status; |
1440 | 1440 | } |
1441 | 1441 | } |
1442 | 1442 | } |
1443 | - foreach( $all_lesson_statuses as $lesson_status ) { |
|
1443 | + foreach ($all_lesson_statuses as $lesson_status) { |
|
1444 | 1444 | // If lessons are complete without needing quizzes to be passed |
1445 | - if ( 'passed' != $course_completion ) { |
|
1446 | - switch ( $lesson_status->comment_approved ) { |
|
1445 | + if ('passed' != $course_completion) { |
|
1446 | + switch ($lesson_status->comment_approved) { |
|
1447 | 1447 | // A user cannot 'complete' a course if a lesson... |
1448 | 1448 | case 'in-progress': // ...is still in progress |
1449 | 1449 | case 'ungraded': // ...hasn't yet been graded |
@@ -1455,7 +1455,7 @@ discard block |
||
1455 | 1455 | } |
1456 | 1456 | } |
1457 | 1457 | else { |
1458 | - switch ( $lesson_status->comment_approved ) { |
|
1458 | + switch ($lesson_status->comment_approved) { |
|
1459 | 1459 | case 'complete': // Lesson has no quiz/questions |
1460 | 1460 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
1461 | 1461 | case 'passed': // Lesson has quiz and the user passed |
@@ -1469,20 +1469,20 @@ discard block |
||
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | } // Each lesson |
1472 | - if ( $lessons_completed == $total_lessons ) { |
|
1472 | + if ($lessons_completed == $total_lessons) { |
|
1473 | 1473 | $course_status = 'complete'; |
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | // Update meta data on how many lessons have been completed |
1477 | 1477 | $course_metadata['complete'] = $lessons_completed; |
1478 | 1478 | // update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above |
1479 | - $course_metadata['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ); |
|
1479 | + $course_metadata['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)); |
|
1480 | 1480 | |
1481 | - $activity_logged = Sensei_Utils::update_course_status( $user_id, $course_id, $course_status, $course_metadata ); |
|
1481 | + $activity_logged = Sensei_Utils::update_course_status($user_id, $course_id, $course_status, $course_metadata); |
|
1482 | 1482 | |
1483 | 1483 | // Allow further actions |
1484 | - if ( 'complete' == $course_status ) { |
|
1485 | - do_action( 'sensei_user_course_end', $user_id, $course_id ); |
|
1484 | + if ('complete' == $course_status) { |
|
1485 | + do_action('sensei_user_course_end', $user_id, $course_id); |
|
1486 | 1486 | } |
1487 | 1487 | return $activity_logged; |
1488 | 1488 | } |
@@ -1498,31 +1498,31 @@ discard block |
||
1498 | 1498 | * @param int $user_id |
1499 | 1499 | * @return boolean |
1500 | 1500 | */ |
1501 | - public static function user_completed_course( $course , $user_id = 0 ) { |
|
1501 | + public static function user_completed_course($course, $user_id = 0) { |
|
1502 | 1502 | |
1503 | - if( $course ) { |
|
1504 | - if ( is_object( $course ) && is_a( $course,'WP_Comment') ) { |
|
1503 | + if ($course) { |
|
1504 | + if (is_object($course) && is_a($course, 'WP_Comment')) { |
|
1505 | 1505 | $user_course_status = $course->comment_approved; |
1506 | 1506 | } |
1507 | - elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
1507 | + elseif ( ! is_numeric($course) && ! is_a($course, 'WP_Post')) { |
|
1508 | 1508 | $user_course_status = $course; |
1509 | 1509 | } |
1510 | 1510 | else { |
1511 | - if( ! $user_id ) { |
|
1511 | + if ( ! $user_id) { |
|
1512 | 1512 | $user_id = get_current_user_id(); |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - if( is_a( $course, 'WP_Post' ) ){ |
|
1516 | - $course = $course->ID; |
|
1515 | + if (is_a($course, 'WP_Post')) { |
|
1516 | + $course = $course->ID; |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | - $user_course_status = Sensei_Utils::user_course_status( $course , $user_id ); |
|
1520 | - if( isset( $user_course_status->comment_approved ) ){ |
|
1519 | + $user_course_status = Sensei_Utils::user_course_status($course, $user_id); |
|
1520 | + if (isset($user_course_status->comment_approved)) { |
|
1521 | 1521 | $user_course_status = $user_course_status->comment_approved; |
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | } |
1525 | - if( $user_course_status && 'complete' == $user_course_status ) { |
|
1525 | + if ($user_course_status && 'complete' == $user_course_status) { |
|
1526 | 1526 | return true; |
1527 | 1527 | } |
1528 | 1528 | } |
@@ -1537,10 +1537,10 @@ discard block |
||
1537 | 1537 | * @param int $user_id |
1538 | 1538 | * @return mixed false or comment_ID |
1539 | 1539 | */ |
1540 | - public static function user_started_lesson( $lesson_id = 0, $user_id = 0 ) { |
|
1540 | + public static function user_started_lesson($lesson_id = 0, $user_id = 0) { |
|
1541 | 1541 | |
1542 | - if( $lesson_id ) { |
|
1543 | - if( ! $user_id ) { |
|
1542 | + if ($lesson_id) { |
|
1543 | + if ( ! $user_id) { |
|
1544 | 1544 | $user_id = get_current_user_id(); |
1545 | 1545 | } |
1546 | 1546 | |
@@ -1550,8 +1550,8 @@ discard block |
||
1550 | 1550 | 'type' => 'sensei_lesson_status', |
1551 | 1551 | 'field' => 'comment_ID' ); |
1552 | 1552 | |
1553 | - $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args ); |
|
1554 | - if( $user_lesson_status_id ) { |
|
1553 | + $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value($activity_args); |
|
1554 | + if ($user_lesson_status_id) { |
|
1555 | 1555 | return $user_lesson_status_id; |
1556 | 1556 | } |
1557 | 1557 | } |
@@ -1566,29 +1566,29 @@ discard block |
||
1566 | 1566 | * @param int $user_id |
1567 | 1567 | * @return boolean |
1568 | 1568 | */ |
1569 | - public static function user_completed_lesson( $lesson = 0, $user_id = 0 ) { |
|
1569 | + public static function user_completed_lesson($lesson = 0, $user_id = 0) { |
|
1570 | 1570 | |
1571 | - if( $lesson ) { |
|
1571 | + if ($lesson) { |
|
1572 | 1572 | $lesson_id = 0; |
1573 | - if ( is_object( $lesson ) ) { |
|
1573 | + if (is_object($lesson)) { |
|
1574 | 1574 | $user_lesson_status = $lesson->comment_approved; |
1575 | 1575 | $lesson_id = $lesson->comment_post_ID; |
1576 | 1576 | } |
1577 | - elseif ( ! is_numeric( $lesson ) ) { |
|
1577 | + elseif ( ! is_numeric($lesson)) { |
|
1578 | 1578 | $user_lesson_status = $lesson; |
1579 | 1579 | } |
1580 | 1580 | else { |
1581 | - if( ! $user_id ) { |
|
1581 | + if ( ! $user_id) { |
|
1582 | 1582 | $user_id = get_current_user_id(); |
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | // the user is not logged in |
1586 | - if( ! $user_id > 0 ){ |
|
1586 | + if ( ! $user_id > 0) { |
|
1587 | 1587 | return false; |
1588 | 1588 | } |
1589 | - $_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id ); |
|
1589 | + $_user_lesson_status = Sensei_Utils::user_lesson_status($lesson, $user_id); |
|
1590 | 1590 | |
1591 | - if ( $_user_lesson_status ) { |
|
1591 | + if ($_user_lesson_status) { |
|
1592 | 1592 | $user_lesson_status = $_user_lesson_status->comment_approved; |
1593 | 1593 | } |
1594 | 1594 | else { |
@@ -1596,12 +1596,12 @@ discard block |
||
1596 | 1596 | } |
1597 | 1597 | $lesson_id = $lesson; |
1598 | 1598 | } |
1599 | - if ( 'in-progress' != $user_lesson_status ) { |
|
1599 | + if ('in-progress' != $user_lesson_status) { |
|
1600 | 1600 | // Check for Passed or Completed Setting |
1601 | 1601 | // Should we be checking for the Course completion setting? Surely that should only affect the Course completion, not bypass each Lesson setting |
1602 | 1602 | // $course_completion = Sensei()->settings->settings[ 'course_completion' ]; |
1603 | 1603 | // if ( 'passed' == $course_completion ) { |
1604 | - switch( $user_lesson_status ) { |
|
1604 | + switch ($user_lesson_status) { |
|
1605 | 1605 | case 'complete': |
1606 | 1606 | case 'graded': |
1607 | 1607 | case 'passed': |
@@ -1610,13 +1610,13 @@ discard block |
||
1610 | 1610 | |
1611 | 1611 | case 'failed': |
1612 | 1612 | // This may be 'completed' depending on... |
1613 | - if ( $lesson_id ) { |
|
1613 | + if ($lesson_id) { |
|
1614 | 1614 | // Get Quiz ID, this won't be needed once all Quiz meta fields are stored on the Lesson |
1615 | - $lesson_quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
1616 | - if ( $lesson_quiz_id ) { |
|
1615 | + $lesson_quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id); |
|
1616 | + if ($lesson_quiz_id) { |
|
1617 | 1617 | // ...the quiz pass setting |
1618 | - $pass_required = get_post_meta( $lesson_quiz_id, '_pass_required', true ); |
|
1619 | - if ( empty($pass_required) ) { |
|
1618 | + $pass_required = get_post_meta($lesson_quiz_id, '_pass_required', true); |
|
1619 | + if (empty($pass_required)) { |
|
1620 | 1620 | // We just require the user to have done the quiz, not to have passed |
1621 | 1621 | return true; |
1622 | 1622 | } |
@@ -1639,15 +1639,15 @@ discard block |
||
1639 | 1639 | * @param int $user_id |
1640 | 1640 | * @return object |
1641 | 1641 | */ |
1642 | - public static function user_course_status( $course_id = 0, $user_id = 0 ) { |
|
1642 | + public static function user_course_status($course_id = 0, $user_id = 0) { |
|
1643 | 1643 | |
1644 | 1644 | |
1645 | - if( $course_id ) { |
|
1646 | - if( ! $user_id ) { |
|
1645 | + if ($course_id) { |
|
1646 | + if ( ! $user_id) { |
|
1647 | 1647 | $user_id = get_current_user_id(); |
1648 | 1648 | } |
1649 | 1649 | |
1650 | - $user_course_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status' ), true ); |
|
1650 | + $user_course_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status'), true); |
|
1651 | 1651 | return $user_course_status; |
1652 | 1652 | } |
1653 | 1653 | |
@@ -1662,27 +1662,27 @@ discard block |
||
1662 | 1662 | * @param int $user_id |
1663 | 1663 | * @return object | bool |
1664 | 1664 | */ |
1665 | - public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) { |
|
1665 | + public static function user_lesson_status($lesson_id = 0, $user_id = 0) { |
|
1666 | 1666 | |
1667 | - if( ! $user_id ) { |
|
1667 | + if ( ! $user_id) { |
|
1668 | 1668 | $user_id = get_current_user_id(); |
1669 | 1669 | } |
1670 | 1670 | |
1671 | - if( $lesson_id > 0 && $user_id > 0 ) { |
|
1671 | + if ($lesson_id > 0 && $user_id > 0) { |
|
1672 | 1672 | |
1673 | - $user_lesson_status = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status' ), true ); |
|
1673 | + $user_lesson_status = Sensei_Utils::sensei_check_for_activity(array('post_id' => $lesson_id, 'user_id' => $user_id, 'type' => 'sensei_lesson_status'), true); |
|
1674 | 1674 | return $user_lesson_status; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | return false; |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - public static function is_preview_lesson( $lesson_id ) { |
|
1680 | + public static function is_preview_lesson($lesson_id) { |
|
1681 | 1681 | $is_preview = false; |
1682 | 1682 | |
1683 | - if( 'lesson' == get_post_type( $lesson_id ) ) { |
|
1684 | - $lesson_preview = get_post_meta( $lesson_id, '_lesson_preview', true ); |
|
1685 | - if ( isset( $lesson_preview ) && '' != $lesson_preview ) { |
|
1683 | + if ('lesson' == get_post_type($lesson_id)) { |
|
1684 | + $lesson_preview = get_post_meta($lesson_id, '_lesson_preview', true); |
|
1685 | + if (isset($lesson_preview) && '' != $lesson_preview) { |
|
1686 | 1686 | $is_preview = true; |
1687 | 1687 | } |
1688 | 1688 | } |
@@ -1690,22 +1690,22 @@ discard block |
||
1690 | 1690 | return $is_preview; |
1691 | 1691 | } |
1692 | 1692 | |
1693 | - public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) { |
|
1693 | + public static function user_passed_quiz($quiz_id = 0, $user_id = 0) { |
|
1694 | 1694 | |
1695 | - if( ! $quiz_id ) return false; |
|
1695 | + if ( ! $quiz_id) return false; |
|
1696 | 1696 | |
1697 | - if( ! $user_id ) { |
|
1697 | + if ( ! $user_id) { |
|
1698 | 1698 | $user_id = get_current_user_id(); |
1699 | 1699 | } |
1700 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
1700 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
1701 | 1701 | |
1702 | 1702 | // Quiz Grade |
1703 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, $user_id ); |
|
1704 | - $quiz_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
1703 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson_id, $user_id); |
|
1704 | + $quiz_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
1705 | 1705 | |
1706 | 1706 | // Check if Grade is greater than or equal to pass percentage |
1707 | - $quiz_passmark = abs( round( doubleval( get_post_meta( $quiz_id, '_quiz_passmark', true ) ), 2 ) ); |
|
1708 | - if ( $quiz_passmark <= intval( $quiz_grade ) ) { |
|
1707 | + $quiz_passmark = abs(round(doubleval(get_post_meta($quiz_id, '_quiz_passmark', true)), 2)); |
|
1708 | + if ($quiz_passmark <= intval($quiz_grade)) { |
|
1709 | 1709 | return true; |
1710 | 1710 | } |
1711 | 1711 | |
@@ -1725,9 +1725,9 @@ discard block |
||
1725 | 1725 | * |
1726 | 1726 | * @return mixed false or comment_ID |
1727 | 1727 | */ |
1728 | - public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) { |
|
1728 | + public static function update_lesson_status($user_id, $lesson_id, $status = 'in-progress', $metadata = array()) { |
|
1729 | 1729 | $comment_id = false; |
1730 | - if ( !empty($status) ) { |
|
1730 | + if ( ! empty($status)) { |
|
1731 | 1731 | $args = array( |
1732 | 1732 | 'user_id' => $user_id, |
1733 | 1733 | 'post_id' => $lesson_id, |
@@ -1736,18 +1736,18 @@ discard block |
||
1736 | 1736 | 'action' => 'update', // Update the existing status... |
1737 | 1737 | 'keep_time' => true, // ...but don't change the existing timestamp |
1738 | 1738 | ); |
1739 | - if( 'in-progress' == $status ) { |
|
1740 | - unset( $args['keep_time'] ); // Keep updating what's happened |
|
1739 | + if ('in-progress' == $status) { |
|
1740 | + unset($args['keep_time']); // Keep updating what's happened |
|
1741 | 1741 | } |
1742 | 1742 | |
1743 | - $comment_id = Sensei_Utils::sensei_log_activity( $args ); |
|
1744 | - if ( $comment_id && !empty($metadata) ) { |
|
1745 | - foreach( $metadata as $key => $value ) { |
|
1746 | - update_comment_meta( $comment_id, $key, $value ); |
|
1743 | + $comment_id = Sensei_Utils::sensei_log_activity($args); |
|
1744 | + if ($comment_id && ! empty($metadata)) { |
|
1745 | + foreach ($metadata as $key => $value) { |
|
1746 | + update_comment_meta($comment_id, $key, $value); |
|
1747 | 1747 | } |
1748 | 1748 | } |
1749 | 1749 | |
1750 | - do_action( 'sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id ); |
|
1750 | + do_action('sensei_lesson_status_updated', $status, $user_id, $lesson_id, $comment_id); |
|
1751 | 1751 | } |
1752 | 1752 | return $comment_id; |
1753 | 1753 | } |
@@ -1763,9 +1763,9 @@ discard block |
||
1763 | 1763 | * @param array $metadata |
1764 | 1764 | * @return mixed false or comment_ID |
1765 | 1765 | */ |
1766 | - public static function update_course_status( $user_id, $course_id, $status = 'in-progress', $metadata = array() ) { |
|
1766 | + public static function update_course_status($user_id, $course_id, $status = 'in-progress', $metadata = array()) { |
|
1767 | 1767 | $comment_id = false; |
1768 | - if ( !empty($status) ) { |
|
1768 | + if ( ! empty($status)) { |
|
1769 | 1769 | $args = array( |
1770 | 1770 | 'user_id' => $user_id, |
1771 | 1771 | 'post_id' => $course_id, |
@@ -1774,17 +1774,17 @@ discard block |
||
1774 | 1774 | 'action' => 'update', // Update the existing status... |
1775 | 1775 | 'keep_time' => true, // ...but don't change the existing timestamp |
1776 | 1776 | ); |
1777 | - if( 'in-progress' == $status ) { |
|
1778 | - unset( $args['keep_time'] ); // Keep updating what's happened |
|
1777 | + if ('in-progress' == $status) { |
|
1778 | + unset($args['keep_time']); // Keep updating what's happened |
|
1779 | 1779 | } |
1780 | 1780 | |
1781 | - $comment_id = Sensei_Utils::sensei_log_activity( $args ); |
|
1782 | - if ( $comment_id && !empty($metadata) ) { |
|
1783 | - foreach( $metadata as $key => $value ) { |
|
1784 | - update_comment_meta( $comment_id, $key, $value ); |
|
1781 | + $comment_id = Sensei_Utils::sensei_log_activity($args); |
|
1782 | + if ($comment_id && ! empty($metadata)) { |
|
1783 | + foreach ($metadata as $key => $value) { |
|
1784 | + update_comment_meta($comment_id, $key, $value); |
|
1785 | 1785 | } |
1786 | 1786 | } |
1787 | - do_action( 'sensei_course_status_updated', $status, $user_id, $course_id, $comment_id ); |
|
1787 | + do_action('sensei_course_status_updated', $status, $user_id, $course_id, $comment_id); |
|
1788 | 1788 | } |
1789 | 1789 | return $comment_id; |
1790 | 1790 | } |
@@ -1796,9 +1796,9 @@ discard block |
||
1796 | 1796 | * @param array $pieces (default: array()) |
1797 | 1797 | * @return array |
1798 | 1798 | */ |
1799 | - public static function single_comment_filter( $pieces ) { |
|
1800 | - unset( $pieces['orderby'] ); |
|
1801 | - unset( $pieces['order'] ); |
|
1799 | + public static function single_comment_filter($pieces) { |
|
1800 | + unset($pieces['orderby']); |
|
1801 | + unset($pieces['order']); |
|
1802 | 1802 | |
1803 | 1803 | return $pieces; |
1804 | 1804 | } |
@@ -1810,9 +1810,9 @@ discard block |
||
1810 | 1810 | * @param array $pieces (default: array()) |
1811 | 1811 | * @return array |
1812 | 1812 | */ |
1813 | - public static function comment_any_status_filter( $pieces ) { |
|
1813 | + public static function comment_any_status_filter($pieces) { |
|
1814 | 1814 | |
1815 | - $pieces['where'] = str_replace( array( "( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND" ), '', $pieces['where'] ); |
|
1815 | + $pieces['where'] = str_replace(array("( comment_approved = '0' OR comment_approved = '1' ) AND", "comment_approved = 'any' AND"), '', $pieces['where']); |
|
1816 | 1816 | |
1817 | 1817 | return $pieces; |
1818 | 1818 | } |
@@ -1824,12 +1824,12 @@ discard block |
||
1824 | 1824 | * @param array $pieces (default: array()) |
1825 | 1825 | * @return array |
1826 | 1826 | */ |
1827 | - public static function comment_multiple_status_filter( $pieces ) { |
|
1827 | + public static function comment_multiple_status_filter($pieces) { |
|
1828 | 1828 | |
1829 | - preg_match( "/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder ); |
|
1830 | - if ( !empty($placeholder[1]) ) { |
|
1831 | - $statuses = explode( ',', $placeholder[1] ); |
|
1832 | - $pieces['where'] = str_replace( "comment_approved = '" . $placeholder[1] . "'", "comment_approved IN ('". implode( "', '", $statuses ) . "')", $pieces['where'] ); |
|
1829 | + preg_match("/^comment_approved = '([a-z\-\,]+)'/", $pieces['where'], $placeholder); |
|
1830 | + if ( ! empty($placeholder[1])) { |
|
1831 | + $statuses = explode(',', $placeholder[1]); |
|
1832 | + $pieces['where'] = str_replace("comment_approved = '".$placeholder[1]."'", "comment_approved IN ('".implode("', '", $statuses)."')", $pieces['where']); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | 1835 | return $pieces; |
@@ -1841,12 +1841,12 @@ discard block |
||
1841 | 1841 | * @param array $pieces |
1842 | 1842 | * @return array $pieces |
1843 | 1843 | */ |
1844 | - public static function comment_total_sum_meta_value_filter( $pieces ) { |
|
1844 | + public static function comment_total_sum_meta_value_filter($pieces) { |
|
1845 | 1845 | global $wpdb, $wp_version; |
1846 | 1846 | |
1847 | 1847 | $pieces['fields'] = " COUNT(*) AS total, SUM($wpdb->commentmeta.meta_value) AS meta_sum "; |
1848 | - unset( $pieces['groupby'] ); |
|
1849 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
1848 | + unset($pieces['groupby']); |
|
1849 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
1850 | 1850 | $args['order'] = false; |
1851 | 1851 | $args['orderby'] = false; |
1852 | 1852 | } |
@@ -1861,12 +1861,12 @@ discard block |
||
1861 | 1861 | * @param array $pieces (default: array()) |
1862 | 1862 | * @return array |
1863 | 1863 | */ |
1864 | - public static function get_posts_count_only_filter( $pieces ) { |
|
1864 | + public static function get_posts_count_only_filter($pieces) { |
|
1865 | 1865 | global $wp_version; |
1866 | 1866 | |
1867 | 1867 | $pieces['fields'] = " COUNT(*) AS total "; |
1868 | - unset( $pieces['groupby'] ); |
|
1869 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
1868 | + unset($pieces['groupby']); |
|
1869 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
1870 | 1870 | $args['order'] = false; |
1871 | 1871 | $args['orderby'] = false; |
1872 | 1872 | } |
@@ -1885,9 +1885,9 @@ discard block |
||
1885 | 1885 | * |
1886 | 1886 | * @return bool $success |
1887 | 1887 | */ |
1888 | - public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0 ){ |
|
1888 | + public static function add_user_data($data_key, $post_id, $value = '', $user_id = 0) { |
|
1889 | 1889 | |
1890 | - return self::update_user_data( $data_key, $post_id, $value , $user_id ); |
|
1890 | + return self::update_user_data($data_key, $post_id, $value, $user_id); |
|
1891 | 1891 | |
1892 | 1892 | }// end add_user_data |
1893 | 1893 | |
@@ -1906,18 +1906,18 @@ discard block |
||
1906 | 1906 | * |
1907 | 1907 | * @return bool $success |
1908 | 1908 | */ |
1909 | - public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0 ){ |
|
1909 | + public static function update_user_data($data_key, $post_id, $value = '', $user_id = 0) { |
|
1910 | 1910 | |
1911 | - if( ! ( $user_id > 0 ) ){ |
|
1911 | + if ( ! ($user_id > 0)) { |
|
1912 | 1912 | $user_id = get_current_user_id(); |
1913 | 1913 | } |
1914 | 1914 | |
1915 | - $supported_post_types = array( 'course', 'lesson' ); |
|
1916 | - $post_type = get_post_type( $post_id ); |
|
1917 | - if( empty( $post_id ) || empty( $data_key ) |
|
1918 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1919 | - || !get_userdata( $user_id ) |
|
1920 | - || ! in_array( $post_type, $supported_post_types ) ){ |
|
1915 | + $supported_post_types = array('course', 'lesson'); |
|
1916 | + $post_type = get_post_type($post_id); |
|
1917 | + if (empty($post_id) || empty($data_key) |
|
1918 | + || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) |
|
1919 | + || ! get_userdata($user_id) |
|
1920 | + || ! in_array($post_type, $supported_post_types)) { |
|
1921 | 1921 | |
1922 | 1922 | return false; |
1923 | 1923 | } |
@@ -1925,20 +1925,20 @@ discard block |
||
1925 | 1925 | // check if there and existing Sensei status on this post type if not create it |
1926 | 1926 | // and get the activity ID |
1927 | 1927 | $status_function = 'user_'.$post_type.'_status'; |
1928 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1929 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1928 | + $sensei_user_status = self::$status_function($post_id, $user_id); |
|
1929 | + if ( ! isset($sensei_user_status->comment_ID)) { |
|
1930 | 1930 | |
1931 | 1931 | $start_function = 'user_start_'.$post_type; |
1932 | - $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
|
1932 | + $sensei_user_activity_id = self::$start_function($user_id, $post_id); |
|
1933 | 1933 | |
1934 | - }else{ |
|
1934 | + } else { |
|
1935 | 1935 | |
1936 | 1936 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
1937 | 1937 | |
1938 | 1938 | } |
1939 | 1939 | |
1940 | 1940 | // store the data |
1941 | - $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); |
|
1941 | + $success = update_comment_meta($sensei_user_activity_id, $data_key, $value); |
|
1942 | 1942 | |
1943 | 1943 | return $success; |
1944 | 1944 | |
@@ -1957,20 +1957,20 @@ discard block |
||
1957 | 1957 | * |
1958 | 1958 | * @return mixed $user_data_value |
1959 | 1959 | */ |
1960 | - public static function get_user_data( $data_key, $post_id, $user_id = 0 ){ |
|
1960 | + public static function get_user_data($data_key, $post_id, $user_id = 0) { |
|
1961 | 1961 | |
1962 | 1962 | $user_data_value = true; |
1963 | 1963 | |
1964 | - if( ! ( $user_id > 0 ) ){ |
|
1964 | + if ( ! ($user_id > 0)) { |
|
1965 | 1965 | $user_id = get_current_user_id(); |
1966 | 1966 | } |
1967 | 1967 | |
1968 | - $supported_post_types = array( 'course', 'lesson' ); |
|
1969 | - $post_type = get_post_type( $post_id ); |
|
1970 | - if( empty( $post_id ) || empty( $data_key ) |
|
1971 | - || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1972 | - || ! get_userdata( $user_id ) |
|
1973 | - || !in_array( $post_type, $supported_post_types ) ){ |
|
1968 | + $supported_post_types = array('course', 'lesson'); |
|
1969 | + $post_type = get_post_type($post_id); |
|
1970 | + if (empty($post_id) || empty($data_key) |
|
1971 | + || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) |
|
1972 | + || ! get_userdata($user_id) |
|
1973 | + || ! in_array($post_type, $supported_post_types)) { |
|
1974 | 1974 | |
1975 | 1975 | return false; |
1976 | 1976 | } |
@@ -1978,13 +1978,13 @@ discard block |
||
1978 | 1978 | // check if there and existing Sensei status on this post type if not create it |
1979 | 1979 | // and get the activity ID |
1980 | 1980 | $status_function = 'user_'.$post_type.'_status'; |
1981 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1982 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1981 | + $sensei_user_status = self::$status_function($post_id, $user_id); |
|
1982 | + if ( ! isset($sensei_user_status->comment_ID)) { |
|
1983 | 1983 | return false; |
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
1987 | - $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); |
|
1987 | + $user_data_value = get_comment_meta($sensei_user_activity_id, $data_key, true); |
|
1988 | 1988 | |
1989 | 1989 | return $user_data_value; |
1990 | 1990 | |
@@ -1999,19 +1999,19 @@ discard block |
||
1999 | 1999 | * |
2000 | 2000 | * @return bool $deleted |
2001 | 2001 | */ |
2002 | - public static function delete_user_data( $data_key, $post_id , $user_id ){ |
|
2002 | + public static function delete_user_data($data_key, $post_id, $user_id) { |
|
2003 | 2003 | $deleted = true; |
2004 | 2004 | |
2005 | - if( ! ( $user_id > 0 ) ){ |
|
2005 | + if ( ! ($user_id > 0)) { |
|
2006 | 2006 | $user_id = get_current_user_id(); |
2007 | 2007 | } |
2008 | 2008 | |
2009 | - $supported_post_types = array( 'course', 'lesson' ); |
|
2010 | - $post_type = get_post_type( $post_id ); |
|
2011 | - if( empty( $post_id ) || empty( $data_key ) |
|
2012 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
2013 | - || ! get_userdata( $user_id ) |
|
2014 | - || !in_array( $post_type, $supported_post_types ) ){ |
|
2009 | + $supported_post_types = array('course', 'lesson'); |
|
2010 | + $post_type = get_post_type($post_id); |
|
2011 | + if (empty($post_id) || empty($data_key) |
|
2012 | + || ! is_int($post_id) || ! (intval($post_id) > 0) || ! (intval($user_id) > 0) |
|
2013 | + || ! get_userdata($user_id) |
|
2014 | + || ! in_array($post_type, $supported_post_types)) { |
|
2015 | 2015 | |
2016 | 2016 | return false; |
2017 | 2017 | } |
@@ -2019,13 +2019,13 @@ discard block |
||
2019 | 2019 | // check if there and existing Sensei status on this post type if not create it |
2020 | 2020 | // and get the activity ID |
2021 | 2021 | $status_function = 'user_'.$post_type.'_status'; |
2022 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
2023 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
2022 | + $sensei_user_status = self::$status_function($post_id, $user_id); |
|
2023 | + if ( ! isset($sensei_user_status->comment_ID)) { |
|
2024 | 2024 | return false; |
2025 | 2025 | } |
2026 | 2026 | |
2027 | 2027 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
2028 | - $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); |
|
2028 | + $deleted = delete_comment_meta($sensei_user_activity_id, $data_key); |
|
2029 | 2029 | |
2030 | 2030 | return $deleted; |
2031 | 2031 | |
@@ -2050,62 +2050,62 @@ discard block |
||
2050 | 2050 | * |
2051 | 2051 | * @return string $drop_down_element |
2052 | 2052 | */ |
2053 | - public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { |
|
2053 | + public static function generate_drop_down($selected_value, $options = array(), $attributes = array(), $enable_none_option = true) { |
|
2054 | 2054 | |
2055 | 2055 | $drop_down_element = ''; |
2056 | 2056 | |
2057 | 2057 | // setup the basic attributes |
2058 | - if( !isset( $attributes['name'] ) || empty( $attributes['name'] ) ) { |
|
2058 | + if ( ! isset($attributes['name']) || empty($attributes['name'])) { |
|
2059 | 2059 | |
2060 | 2060 | $attributes['name'] = 'sensei-options'; |
2061 | 2061 | |
2062 | 2062 | } |
2063 | 2063 | |
2064 | - if( !isset( $attributes['id'] ) || empty( $attributes['id'] ) ) { |
|
2064 | + if ( ! isset($attributes['id']) || empty($attributes['id'])) { |
|
2065 | 2065 | |
2066 | 2066 | $attributes['id'] = 'sensei-options'; |
2067 | 2067 | |
2068 | 2068 | } |
2069 | 2069 | |
2070 | - if( !isset( $attributes['class'] ) || empty( $attributes['class'] ) ) { |
|
2070 | + if ( ! isset($attributes['class']) || empty($attributes['class'])) { |
|
2071 | 2071 | |
2072 | - $attributes['class'] ='chosen_select widefat'; |
|
2072 | + $attributes['class'] = 'chosen_select widefat'; |
|
2073 | 2073 | |
2074 | 2074 | } |
2075 | 2075 | |
2076 | 2076 | // create element attributes |
2077 | 2077 | $combined_attributes = ''; |
2078 | - foreach( $attributes as $attribute => $value ){ |
|
2078 | + foreach ($attributes as $attribute => $value) { |
|
2079 | 2079 | |
2080 | - $combined_attributes .= $attribute . '="'.$value.'"' . ' '; |
|
2080 | + $combined_attributes .= $attribute.'="'.$value.'"'.' '; |
|
2081 | 2081 | |
2082 | 2082 | }// end for each |
2083 | 2083 | |
2084 | 2084 | |
2085 | 2085 | // create the select element |
2086 | - $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; |
|
2086 | + $drop_down_element .= '<select '.$combined_attributes.' >'."\n"; |
|
2087 | 2087 | |
2088 | 2088 | // show the none option if the client requested |
2089 | - if( $enable_none_option ) { |
|
2090 | - $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; |
|
2089 | + if ($enable_none_option) { |
|
2090 | + $drop_down_element .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
2091 | 2091 | } |
2092 | 2092 | |
2093 | - if ( count( $options ) > 0 ) { |
|
2093 | + if (count($options) > 0) { |
|
2094 | 2094 | |
2095 | - foreach ($options as $value => $option ){ |
|
2095 | + foreach ($options as $value => $option) { |
|
2096 | 2096 | |
2097 | 2097 | $element = ''; |
2098 | - $element.= '<option value="' . esc_attr( $value ) . '"'; |
|
2099 | - $element .= selected( $value, $selected_value, false ) . '>'; |
|
2100 | - $element .= esc_html( $option ) . '</option>' . "\n"; |
|
2098 | + $element .= '<option value="'.esc_attr($value).'"'; |
|
2099 | + $element .= selected($value, $selected_value, false).'>'; |
|
2100 | + $element .= esc_html($option).'</option>'."\n"; |
|
2101 | 2101 | |
2102 | 2102 | // add the element to the select html |
2103 | - $drop_down_element.= $element; |
|
2103 | + $drop_down_element .= $element; |
|
2104 | 2104 | } // End For Loop |
2105 | 2105 | |
2106 | 2106 | } // End If Statement |
2107 | 2107 | |
2108 | - $drop_down_element .= '</select>' . "\n"; |
|
2108 | + $drop_down_element .= '</select>'."\n"; |
|
2109 | 2109 | |
2110 | 2110 | return $drop_down_element; |
2111 | 2111 | |
@@ -2125,14 +2125,14 @@ discard block |
||
2125 | 2125 | * |
2126 | 2126 | * @return double $val |
2127 | 2127 | */ |
2128 | - public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '' ){ |
|
2128 | + public static function round($val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '') { |
|
2129 | 2129 | |
2130 | 2130 | /**å |
2131 | 2131 | * Change the precision for the Sensei_Utils::round function. |
2132 | 2132 | * the precision given will be passed into the php round function |
2133 | 2133 | * @since 1.8.5 |
2134 | 2134 | */ |
2135 | - $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); |
|
2135 | + $precision = apply_filters('sensei_round_precision', $precision, $val, $context, $mode); |
|
2136 | 2136 | |
2137 | 2137 | /** |
2138 | 2138 | * Change the mode for the Sensei_Utils::round function. |
@@ -2142,15 +2142,15 @@ discard block |
||
2142 | 2142 | * |
2143 | 2143 | * @since 1.8.5 |
2144 | 2144 | */ |
2145 | - $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); |
|
2145 | + $mode = apply_filters('sensei_round_mode', $mode, $val, $context, $precision); |
|
2146 | 2146 | |
2147 | - if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { |
|
2147 | + if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
|
2148 | 2148 | |
2149 | - return round( $val, $precision, $mode ); |
|
2149 | + return round($val, $precision, $mode); |
|
2150 | 2150 | |
2151 | - }else{ |
|
2151 | + } else { |
|
2152 | 2152 | |
2153 | - return round( $val, $precision ); |
|
2153 | + return round($val, $precision); |
|
2154 | 2154 | |
2155 | 2155 | } |
2156 | 2156 | |
@@ -2162,15 +2162,15 @@ discard block |
||
2162 | 2162 | * @since 1.9.0 |
2163 | 2163 | * @return string $url |
2164 | 2164 | */ |
2165 | - public static function get_current_url(){ |
|
2165 | + public static function get_current_url() { |
|
2166 | 2166 | |
2167 | 2167 | global $wp; |
2168 | - $current_url = trailingslashit( home_url( $wp->request ) ); |
|
2169 | - if ( isset( $_GET ) ) { |
|
2168 | + $current_url = trailingslashit(home_url($wp->request)); |
|
2169 | + if (isset($_GET)) { |
|
2170 | 2170 | |
2171 | - foreach ($_GET as $param => $val ) { |
|
2171 | + foreach ($_GET as $param => $val) { |
|
2172 | 2172 | |
2173 | - $current_url = add_query_arg( $param, $val , $current_url ); |
|
2173 | + $current_url = add_query_arg($param, $val, $current_url); |
|
2174 | 2174 | |
2175 | 2175 | } |
2176 | 2176 | } |
@@ -2200,27 +2200,27 @@ discard block |
||
2200 | 2200 | * @param array $array_b |
2201 | 2201 | * @return array $merged_array |
2202 | 2202 | */ |
2203 | - public static function array_zip_merge( $array_a, $array_b ){ |
|
2203 | + public static function array_zip_merge($array_a, $array_b) { |
|
2204 | 2204 | |
2205 | - if( ! is_array( $array_a ) || ! is_array( $array_b ) ){ |
|
2205 | + if ( ! is_array($array_a) || ! is_array($array_b)) { |
|
2206 | 2206 | trigger_error('array_zip_merge requires both arrays to be indexed arrays '); |
2207 | 2207 | } |
2208 | 2208 | |
2209 | 2209 | $merged_array = array(); |
2210 | - $total_elements = count( $array_a ) + count( $array_b ); |
|
2210 | + $total_elements = count($array_a) + count($array_b); |
|
2211 | 2211 | |
2212 | 2212 | // Zip arrays |
2213 | - for ( $i = 0; $i < $total_elements; $i++) { |
|
2213 | + for ($i = 0; $i < $total_elements; $i++) { |
|
2214 | 2214 | |
2215 | 2215 | // if has an element at current index push a on top |
2216 | - if( isset( $array_a[ $i ] ) ){ |
|
2217 | - $merged_array[] = $array_a[ $i ] ; |
|
2216 | + if (isset($array_a[$i])) { |
|
2217 | + $merged_array[] = $array_a[$i]; |
|
2218 | 2218 | } |
2219 | 2219 | |
2220 | 2220 | // next if $array_b has an element at current index push a on top of the element |
2221 | 2221 | // from a if there was one, if not the element before that. |
2222 | - if( isset( $array_b[ $i ] ) ){ |
|
2223 | - $merged_array[] = $array_b[ $i ] ; |
|
2222 | + if (isset($array_b[$i])) { |
|
2223 | + $merged_array[] = $array_b[$i]; |
|
2224 | 2224 | } |
2225 | 2225 | |
2226 | 2226 | } |
@@ -2235,4 +2235,4 @@ discard block |
||
2235 | 2235 | * @ignore only for backward compatibility |
2236 | 2236 | * @since 1.9.0 |
2237 | 2237 | */ |
2238 | -class WooThemes_Sensei_Utils extends Sensei_Utils{} |
|
2239 | 2238 | \ No newline at end of file |
2239 | +class WooThemes_Sensei_Utils extends Sensei_Utils {} |
|
2240 | 2240 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
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 | * Output tags. |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @param string $type (default: 'newcourses') |
13 | 13 | * @return void |
14 | 14 | */ |
15 | - function sensei_course_archive_next_link( $type = 'newcourses' ) { |
|
15 | + function sensei_course_archive_next_link($type = 'newcourses') { |
|
16 | 16 | |
17 | - _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); |
|
17 | + _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.'); |
|
18 | 18 | |
19 | 19 | } // End sensei_course_archive_next_link() |
20 | 20 | |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | function course_single_lessons() { |
28 | 28 | |
29 | 29 | // load backwards compatible template name if it exists in the users theme |
30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); |
|
31 | - if( $located_template ){ |
|
30 | + $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php'); |
|
31 | + if ($located_template) { |
|
32 | 32 | |
33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); |
|
33 | + Sensei_Templates::get_template('single-course/course-lessons.php'); |
|
34 | 34 | return; |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - Sensei_Templates::get_template( 'single-course/lessons.php' ); |
|
38 | + Sensei_Templates::get_template('single-course/lessons.php'); |
|
39 | 39 | |
40 | 40 | } // End course_single_lessons() |
41 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function lesson_single_meta() { |
50 | 50 | |
51 | - _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); |
|
51 | + _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta'); |
|
52 | 52 | sensei_the_single_lesson_meta(); |
53 | 53 | |
54 | 54 | } // End lesson_single_meta() |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * @return void |
63 | 63 | * @deprecated since 1.9.0 |
64 | 64 | */ |
65 | - function quiz_questions( $return = false ) { |
|
65 | + function quiz_questions($return = false) { |
|
66 | 66 | |
67 | - Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' ); |
|
67 | + Sensei_Templates::get_template('single-quiz/quiz-questions.php'); |
|
68 | 68 | |
69 | 69 | } // End quiz_questions() |
70 | 70 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @return void |
77 | 77 | * @deprecated |
78 | 78 | */ |
79 | - function quiz_question_type( $question_type = 'multiple-choice' ) { |
|
79 | + function quiz_question_type($question_type = 'multiple-choice') { |
|
80 | 80 | |
81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
81 | + Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php'); |
|
82 | 82 | |
83 | 83 | } // End lesson_single_meta() |
84 | 84 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param mixed $course_id |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - function sensei_check_prerequisite_course( $course_id ) { |
|
97 | + function sensei_check_prerequisite_course($course_id) { |
|
98 | 98 | |
99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); |
|
99 | + return Sensei_Course::is_prerequisite_complete($course_id); |
|
100 | 100 | |
101 | 101 | } // End sensei_check_prerequisite_course() |
102 | 102 | |
@@ -108,16 +108,16 @@ discard block |
||
108 | 108 | * @param mixed $course_id |
109 | 109 | * @return void |
110 | 110 | */ |
111 | - function sensei_start_course_form( $course_id ) { |
|
111 | + function sensei_start_course_form($course_id) { |
|
112 | 112 | |
113 | - $prerequisite_complete = sensei_check_prerequisite_course( $course_id ); |
|
113 | + $prerequisite_complete = sensei_check_prerequisite_course($course_id); |
|
114 | 114 | |
115 | - if ( $prerequisite_complete ) { |
|
116 | - ?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
115 | + if ($prerequisite_complete) { |
|
116 | + ?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
117 | 117 | |
118 | - <input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" /> |
|
118 | + <input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" /> |
|
119 | 119 | |
120 | - <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> |
|
120 | + <span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span> |
|
121 | 121 | |
122 | 122 | </form><?php |
123 | 123 | } // End If Statement |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @param mixed $course_id |
133 | 133 | * @return void |
134 | 134 | */ |
135 | - function sensei_wc_add_to_cart( $course_id ) { |
|
135 | + function sensei_wc_add_to_cart($course_id) { |
|
136 | 136 | |
137 | - Sensei_WC::the_add_to_cart_button_html( $course_id ); |
|
137 | + Sensei_WC::the_add_to_cart_button_html($course_id); |
|
138 | 138 | |
139 | 139 | } // End sensei_wc_add_to_cart() |
140 | 140 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param int $wc_post_id (default: 0) |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { |
|
150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); |
|
149 | + function sensei_check_if_product_is_in_cart($wc_product_id = 0) { |
|
150 | + return Sensei_WC::is_product_in_cart($wc_product_id); |
|
151 | 151 | } // End sensei_check_if_product_is_in_cart() |
152 | 152 | |
153 | 153 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | * @param mixed $post_id |
158 | 158 | * @return void |
159 | 159 | */ |
160 | - function sensei_simple_course_price( $post_id ) { |
|
160 | + function sensei_simple_course_price($post_id) { |
|
161 | 161 | |
162 | 162 | //WooCommerce Pricing |
163 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); |
|
165 | - if ( 0 < $wc_post_id ) { |
|
163 | + if (Sensei_WC::is_woocommerce_active()) { |
|
164 | + $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true); |
|
165 | + if (0 < $wc_post_id) { |
|
166 | 166 | // Get the product |
167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
167 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
168 | 168 | |
169 | - if ( isset( $product ) && !empty( $product ) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> |
|
169 | + if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?> |
|
170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> |
171 | 171 | <?php } // End If Statement |
172 | 172 | } // End If Statement |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param array $widget_args (default: array()) |
181 | 181 | * @return array |
182 | 182 | */ |
183 | - function sensei_recent_comments_widget_filter( $widget_args = array() ) { |
|
184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); |
|
183 | + function sensei_recent_comments_widget_filter($widget_args = array()) { |
|
184 | + if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page'); |
|
185 | 185 | return $widget_args; |
186 | 186 | } // End sensei_recent_comments_widget_filter() |
187 | - add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); |
|
187 | + add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * sensei_course_archive_filter function. |
@@ -193,26 +193,26 @@ discard block |
||
193 | 193 | * @param WP_Query $query ( default: array ( ) ) |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - function sensei_course_archive_filter( $query ) { |
|
196 | + function sensei_course_archive_filter($query) { |
|
197 | 197 | |
198 | 198 | |
199 | - if ( ! $query->is_main_query() ) |
|
199 | + if ( ! $query->is_main_query()) |
|
200 | 200 | return; |
201 | 201 | |
202 | 202 | // Apply Filter only if on frontend and when course archive is running |
203 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
203 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
204 | 204 | |
205 | - if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { |
|
205 | + if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) { |
|
206 | 206 | // Check for pagination settings |
207 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
207 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
208 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
209 | 209 | } else { |
210 | - $amount = $query->get( 'posts_per_page' ); |
|
210 | + $amount = $query->get('posts_per_page'); |
|
211 | 211 | } // End If Statement |
212 | - $query->set( 'posts_per_page', $amount ); |
|
212 | + $query->set('posts_per_page', $amount); |
|
213 | 213 | } // End If Statement |
214 | 214 | } // End sensei_course_archive_filter() |
215 | - add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); |
|
215 | + add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * sensei_complete_lesson_button description |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return html |
221 | 221 | */ |
222 | 222 | function sensei_complete_lesson_button() { |
223 | - do_action( 'sensei_complete_lesson_button' ); |
|
223 | + do_action('sensei_complete_lesson_button'); |
|
224 | 224 | } // End sensei_complete_lesson_button() |
225 | 225 | |
226 | 226 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return html |
230 | 230 | */ |
231 | 231 | function sensei_reset_lesson_button() { |
232 | - do_action( 'sensei_reset_lesson_button' ); |
|
232 | + do_action('sensei_reset_lesson_button'); |
|
233 | 233 | } // End sensei_reset_lesson_button() |
234 | 234 | |
235 | 235 | /** |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * @param integer $lesson_id |
239 | 239 | * @return array $return_values |
240 | 240 | */ |
241 | - function sensei_get_prev_next_lessons( $lesson_id = 0 ) { |
|
241 | + function sensei_get_prev_next_lessons($lesson_id = 0) { |
|
242 | 242 | |
243 | 243 | $return_values = array(); |
244 | 244 | $return_values['prev_lesson'] = 0; |
245 | 245 | $return_values['next_lesson'] = 0; |
246 | - if ( 0 < $lesson_id ) { |
|
246 | + if (0 < $lesson_id) { |
|
247 | 247 | // Get the List of Lessons in the Course |
248 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
248 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
249 | 249 | $all_lessons = array(); |
250 | 250 | |
251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); |
|
251 | + $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id)); |
|
252 | 252 | |
253 | - foreach( (array) $modules as $module ) { |
|
253 | + foreach ((array) $modules as $module) { |
|
254 | 254 | |
255 | 255 | $args = array( |
256 | 256 | 'post_type' => 'lesson', |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'meta_query' => array( |
260 | 260 | array( |
261 | 261 | 'key' => '_lesson_course', |
262 | - 'value' => intval( $lesson_course_id ), |
|
262 | + 'value' => intval($lesson_course_id), |
|
263 | 263 | 'compare' => '=' |
264 | 264 | ) |
265 | 265 | ), |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | array( |
268 | 268 | 'taxonomy' => Sensei()->modules->taxonomy, |
269 | 269 | 'field' => 'id', |
270 | - 'terms' => intval( $module->term_id ) |
|
270 | + 'terms' => intval($module->term_id) |
|
271 | 271 | ) |
272 | 272 | ), |
273 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
273 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
274 | 274 | 'orderby' => 'meta_value_num date', |
275 | 275 | 'order' => 'ASC', |
276 | 276 | 'suppress_filters' => 0 |
277 | 277 | ); |
278 | 278 | |
279 | - $lessons = get_posts( $args ); |
|
280 | - if ( 0 < count( $lessons ) ) { |
|
281 | - foreach ($lessons as $lesson_item){ |
|
279 | + $lessons = get_posts($args); |
|
280 | + if (0 < count($lessons)) { |
|
281 | + foreach ($lessons as $lesson_item) { |
|
282 | 282 | $all_lessons[] = $lesson_item->ID; |
283 | 283 | } // End For Loop |
284 | 284 | } // End If Statement |
@@ -288,36 +288,36 @@ discard block |
||
288 | 288 | 'post_type' => 'lesson', |
289 | 289 | 'posts_per_page' => -1, |
290 | 290 | 'suppress_filters' => 0, |
291 | - 'meta_key' => '_order_' . $lesson_course_id, |
|
291 | + 'meta_key' => '_order_'.$lesson_course_id, |
|
292 | 292 | 'orderby' => 'meta_value_num date', |
293 | 293 | 'order' => 'ASC', |
294 | 294 | 'meta_query' => array( |
295 | 295 | array( |
296 | 296 | 'key' => '_lesson_course', |
297 | - 'value' => intval( $lesson_course_id ), |
|
297 | + 'value' => intval($lesson_course_id), |
|
298 | 298 | ), |
299 | 299 | ), |
300 | 300 | 'post__not_in' => $all_lessons, |
301 | 301 | ); |
302 | 302 | |
303 | - $other_lessons = get_posts( $args ); |
|
304 | - if ( 0 < count( $other_lessons ) ) { |
|
305 | - foreach ($other_lessons as $lesson_item){ |
|
303 | + $other_lessons = get_posts($args); |
|
304 | + if (0 < count($other_lessons)) { |
|
305 | + foreach ($other_lessons as $lesson_item) { |
|
306 | 306 | $all_lessons[] = $lesson_item->ID; |
307 | 307 | } // End For Loop |
308 | 308 | } // End If Statement |
309 | 309 | |
310 | - if ( 0 < count( $all_lessons ) ) { |
|
310 | + if (0 < count($all_lessons)) { |
|
311 | 311 | $found_index = false; |
312 | - foreach ( $all_lessons as $lesson ){ |
|
313 | - if ( $found_index && $return_values['next_lesson'] == 0 ) { |
|
312 | + foreach ($all_lessons as $lesson) { |
|
313 | + if ($found_index && $return_values['next_lesson'] == 0) { |
|
314 | 314 | $return_values['next_lesson'] = $lesson; |
315 | 315 | } // End If Statement |
316 | - if ( $lesson == $lesson_id ) { |
|
316 | + if ($lesson == $lesson_id) { |
|
317 | 317 | // Is the current post |
318 | 318 | $found_index = true; |
319 | 319 | } // End If Statement |
320 | - if ( !$found_index ) { |
|
320 | + if ( ! $found_index) { |
|
321 | 321 | $return_values['prev_lesson'] = $lesson; |
322 | 322 | } // End If Statement |
323 | 323 | } // End For Loop |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param int|WP_Post $post_id Optional. Defaults to current post |
337 | 337 | * @return string $excerpt |
338 | 338 | */ |
339 | - function sensei_get_excerpt( $post_id = '' ) { |
|
339 | + function sensei_get_excerpt($post_id = '') { |
|
340 | 340 | |
341 | 341 | global $post; |
342 | 342 | _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) { |
|
348 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" ); |
|
349 | - return Sensei_Utils::user_started_course( $post_id, $user_id ); |
|
347 | + function sensei_has_user_started_course($post_id = 0, $user_id = 0) { |
|
348 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()"); |
|
349 | + return Sensei_Utils::user_started_course($post_id, $user_id); |
|
350 | 350 | } // End sensei_has_user_started_course() |
351 | 351 | |
352 | - function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
353 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
354 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
352 | + function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
353 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
354 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
355 | 355 | } // End sensei_has_user_completed_lesson() |
356 | 356 | |
357 | 357 | /** |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | * @param int $user_id |
364 | 364 | * @return bool |
365 | 365 | */ |
366 | -function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { |
|
366 | +function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) { |
|
367 | 367 | |
368 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); |
|
368 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id); |
|
369 | 369 | |
370 | 370 | } // End sensei_has_user_completed_prerequisite_lesson() |
371 | 371 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | * |
390 | 390 | */ |
391 | -function sensei_have_modules( $course_post_id = '' ){ |
|
391 | +function sensei_have_modules($course_post_id = '') { |
|
392 | 392 | |
393 | 393 | global $post, $wp_query, $sensei_modules_loop; |
394 | 394 | |
@@ -396,23 +396,23 @@ discard block |
||
396 | 396 | wp_reset_query(); |
397 | 397 | $post = $wp_query->post; |
398 | 398 | |
399 | - if( empty( $course_post_id ) ){ |
|
399 | + if (empty($course_post_id)) { |
|
400 | 400 | |
401 | 401 | $course_id = $post->ID; |
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | 405 | // doesn't apply to none course post types |
406 | - if( ! sensei_is_a_course( $course_id ) ){ |
|
406 | + if ( ! sensei_is_a_course($course_id)) { |
|
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | 410 | // check the current item compared to the total number of modules |
411 | - if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ] ){ |
|
411 | + if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) { |
|
412 | 412 | |
413 | 413 | return false; |
414 | 414 | |
415 | - }else{ |
|
415 | + } else { |
|
416 | 416 | |
417 | 417 | return true; |
418 | 418 | |
@@ -426,27 +426,27 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @since 1.9.0 |
428 | 428 | */ |
429 | -function sensei_setup_module(){ |
|
429 | +function sensei_setup_module() { |
|
430 | 430 | |
431 | 431 | global $sensei_modules_loop, $wp_query; |
432 | 432 | |
433 | 433 | // increment the index |
434 | - $sensei_modules_loop[ 'current' ]++; |
|
435 | - $index = $sensei_modules_loop[ 'current' ]; |
|
436 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
434 | + $sensei_modules_loop['current']++; |
|
435 | + $index = $sensei_modules_loop['current']; |
|
436 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
437 | 437 | |
438 | 438 | $sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index]; |
439 | 439 | // setup the query for the module lessons |
440 | 440 | $course_id = $sensei_modules_loop['course_id']; |
441 | 441 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
442 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
442 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
443 | 443 | |
444 | 444 | // setup the global wp-query only if the lessons |
445 | - if( $modules_query->have_posts() ){ |
|
445 | + if ($modules_query->have_posts()) { |
|
446 | 446 | |
447 | 447 | $wp_query = $modules_query; |
448 | 448 | |
449 | - }else{ |
|
449 | + } else { |
|
450 | 450 | |
451 | 451 | wp_reset_query(); |
452 | 452 | |
@@ -470,30 +470,30 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return bool |
472 | 472 | */ |
473 | -function sensei_module_has_lessons(){ |
|
473 | +function sensei_module_has_lessons() { |
|
474 | 474 | |
475 | 475 | global $wp_query, $sensei_modules_loop; |
476 | 476 | |
477 | - if( 'lesson' == $wp_query->get('post_type') ){ |
|
477 | + if ('lesson' == $wp_query->get('post_type')) { |
|
478 | 478 | |
479 | 479 | return have_posts(); |
480 | 480 | |
481 | - }else{ |
|
481 | + } else { |
|
482 | 482 | |
483 | 483 | // if the loop has not been initiated check the first module has lessons |
484 | - if( -1 == $sensei_modules_loop[ 'current' ] ){ |
|
484 | + if ( -1 == $sensei_modules_loop['current'] ) { |
|
485 | 485 | |
486 | 486 | $index = 0; |
487 | 487 | |
488 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
488 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
489 | 489 | // setup the query for the module lessons |
490 | 490 | $course_id = $sensei_modules_loop['course_id']; |
491 | 491 | |
492 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; |
|
493 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
492 | + $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id; |
|
493 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
494 | 494 | |
495 | 495 | // setup the global wp-query only if the lessons |
496 | - if( $modules_query->have_posts() ){ |
|
496 | + if ($modules_query->have_posts()) { |
|
497 | 497 | |
498 | 498 | return true; |
499 | 499 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | * @uses sensei_the_module_title |
518 | 518 | * @return string |
519 | 519 | */ |
520 | -function sensei_the_module_title_attribute(){ |
|
520 | +function sensei_the_module_title_attribute() { |
|
521 | 521 | |
522 | - esc_attr_e( sensei_get_the_module_title() ); |
|
522 | + esc_attr_e(sensei_get_the_module_title()); |
|
523 | 523 | |
524 | 524 | } |
525 | 525 | |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | -function sensei_the_module_permalink(){ |
|
533 | +function sensei_the_module_permalink() { |
|
534 | 534 | |
535 | 535 | global $sensei_modules_loop; |
536 | 536 | $course_id = $sensei_modules_loop['course_id']; |
537 | - $module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) ); |
|
537 | + $module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module')); |
|
538 | 538 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
539 | 539 | |
540 | 540 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param int $module_term_id |
547 | 547 | * @param string $course_id |
548 | 548 | */ |
549 | - echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id ,$course_id ) ); |
|
549 | + echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id)); |
|
550 | 550 | |
551 | 551 | }// end sensei_the_module_permalink |
552 | 552 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string |
560 | 560 | */ |
561 | -function sensei_get_the_module_title(){ |
|
561 | +function sensei_get_the_module_title() { |
|
562 | 562 | |
563 | 563 | global $sensei_modules_loop; |
564 | 564 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param $module_term_id |
578 | 578 | * @param $course_id |
579 | 579 | */ |
580 | - return apply_filters( 'sensei_the_module_title', $module_title , $module_term_id, $course_id ); |
|
580 | + return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id); |
|
581 | 581 | |
582 | 582 | } |
583 | 583 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @uses sensei_get_the_module_title |
590 | 590 | * @return string |
591 | 591 | */ |
592 | -function sensei_the_module_title(){ |
|
592 | +function sensei_the_module_title() { |
|
593 | 593 | |
594 | 594 | echo sensei_get_the_module_title(); |
595 | 595 | |
@@ -602,16 +602,16 @@ discard block |
||
602 | 602 | * @since 1.9.0 |
603 | 603 | * @return string |
604 | 604 | */ |
605 | -function sensei_get_the_module_status(){ |
|
605 | +function sensei_get_the_module_status() { |
|
606 | 606 | |
607 | 607 | global $sensei_modules_loop; |
608 | 608 | $module_title = $sensei_modules_loop['current_module']->name; |
609 | 609 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
610 | 610 | $course_id = $sensei_modules_loop['course_id']; |
611 | - $module_progress = Sensei()->modules->get_user_module_progress( $module_term_id, $course_id, get_current_user_id() ); |
|
611 | + $module_progress = Sensei()->modules->get_user_module_progress($module_term_id, $course_id, get_current_user_id()); |
|
612 | 612 | |
613 | - $module_status = ''; |
|
614 | - if ( $module_progress && $module_progress > 0) { |
|
613 | + $module_status = ''; |
|
614 | + if ($module_progress && $module_progress > 0) { |
|
615 | 615 | |
616 | 616 | $module_status = __('Completed', 'woothemes-sensei'); |
617 | 617 | |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } |
625 | 625 | |
626 | 626 | $module_status_html = '<p class="status module-status completed">' |
627 | - . strtolower( str_replace( ' ', '-', $module_status ) ) |
|
627 | + . strtolower(str_replace(' ', '-', $module_status)) |
|
628 | 628 | . '</p>'; |
629 | 629 | |
630 | 630 | /** |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * @param $module_term_id |
639 | 639 | * @param $course_id |
640 | 640 | */ |
641 | - return apply_filters( 'sensei_the_module_status_html', $module_status_html , $module_term_id, $course_id ); |
|
641 | + return apply_filters('sensei_the_module_status_html', $module_status_html, $module_term_id, $course_id); |
|
642 | 642 | |
643 | 643 | } |
644 | 644 | |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * Print out the current module status |
647 | 647 | * @since 1.9.0 |
648 | 648 | */ |
649 | -function sensei_the_module_status(){ |
|
649 | +function sensei_the_module_status() { |
|
650 | 650 | |
651 | 651 | echo sensei_get_the_module_status(); |
652 | 652 | |
@@ -667,19 +667,19 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @return bool |
669 | 669 | */ |
670 | -function sensei_quiz_has_questions(){ |
|
670 | +function sensei_quiz_has_questions() { |
|
671 | 671 | |
672 | 672 | global $sensei_question_loop; |
673 | 673 | |
674 | - if( !isset( $sensei_question_loop['total'] ) ){ |
|
674 | + if ( ! isset($sensei_question_loop['total'])) { |
|
675 | 675 | return false; |
676 | 676 | } |
677 | 677 | |
678 | - if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total'] ){ |
|
678 | + if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) { |
|
679 | 679 | |
680 | 680 | return true; |
681 | 681 | |
682 | - }else{ |
|
682 | + } else { |
|
683 | 683 | |
684 | 684 | return false; |
685 | 685 | |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | * @since 1.9.0 |
697 | 697 | |
698 | 698 | */ |
699 | -function sensei_setup_the_question(){ |
|
699 | +function sensei_setup_the_question() { |
|
700 | 700 | |
701 | 701 | global $sensei_question_loop; |
702 | 702 | |
703 | 703 | $sensei_question_loop['current']++; |
704 | 704 | $index = $sensei_question_loop['current']; |
705 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; |
|
705 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index]; |
|
706 | 706 | |
707 | 707 | |
708 | 708 | }// end sensei_setup_the_question |
@@ -713,14 +713,14 @@ discard block |
||
713 | 713 | * This function gets the type and loads the template that will handle it. |
714 | 714 | * |
715 | 715 | */ |
716 | -function sensei_the_question_content(){ |
|
716 | +function sensei_the_question_content() { |
|
717 | 717 | |
718 | 718 | global $sensei_question_loop; |
719 | 719 | |
720 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
720 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
721 | 721 | |
722 | 722 | // load the template that displays the question information. |
723 | - WooThemes_Sensei_Question::load_question_template( $question_type ); |
|
723 | + WooThemes_Sensei_Question::load_question_template($question_type); |
|
724 | 724 | |
725 | 725 | }// end sensei_the_question_content |
726 | 726 | |
@@ -729,11 +729,11 @@ discard block |
||
729 | 729 | * |
730 | 730 | * @since 1.9.0 |
731 | 731 | */ |
732 | -function sensei_the_question_class(){ |
|
732 | +function sensei_the_question_class() { |
|
733 | 733 | |
734 | 734 | global $sensei_question_loop; |
735 | 735 | |
736 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
736 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
737 | 737 | |
738 | 738 | /** |
739 | 739 | * filter the sensei question class within |
@@ -741,16 +741,16 @@ discard block |
||
741 | 741 | * |
742 | 742 | * @since 1.9.0 |
743 | 743 | */ |
744 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); |
|
744 | + $classes = apply_filters('sensei_question_classes', array($question_type)); |
|
745 | 745 | |
746 | 746 | $html_classes = ''; |
747 | - foreach( $classes as $class ){ |
|
747 | + foreach ($classes as $class) { |
|
748 | 748 | |
749 | - $html_classes .= $class . ' '; |
|
749 | + $html_classes .= $class.' '; |
|
750 | 750 | |
751 | 751 | }// end foreach |
752 | 752 | |
753 | - esc_attr_e( trim( $html_classes ) ); |
|
753 | + esc_attr_e(trim($html_classes)); |
|
754 | 754 | |
755 | 755 | } |
756 | 756 | |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @since 1.9.0 |
761 | 761 | */ |
762 | -function sensei_get_the_question_id( ){ |
|
762 | +function sensei_get_the_question_id( ) { |
|
763 | 763 | |
764 | 764 | global $sensei_question_loop; |
765 | - if( isset( $sensei_question_loop['current_question']->ID ) ){ |
|
765 | + if (isset($sensei_question_loop['current_question']->ID)) { |
|
766 | 766 | |
767 | 767 | return $sensei_question_loop['current_question']->ID; |
768 | 768 | |
@@ -791,27 +791,27 @@ discard block |
||
791 | 791 | * @param string $lesson_id |
792 | 792 | * @return bool |
793 | 793 | */ |
794 | -function sensei_can_user_view_lesson( $lesson_id = '', $user_id = '' ){ |
|
794 | +function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') { |
|
795 | 795 | |
796 | - if( empty( $lesson_id ) ){ |
|
796 | + if (empty($lesson_id)) { |
|
797 | 797 | |
798 | 798 | $lesson_id = get_the_ID(); |
799 | 799 | |
800 | 800 | } |
801 | 801 | |
802 | - if( empty( $user_id ) ){ |
|
802 | + if (empty($user_id)) { |
|
803 | 803 | |
804 | 804 | $user_id = get_current_user_id(); |
805 | 805 | |
806 | 806 | } |
807 | 807 | |
808 | 808 | // Check for prerequisite lesson completions |
809 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); |
|
810 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
811 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); |
|
809 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id); |
|
810 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
811 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, $user_id); |
|
812 | 812 | |
813 | 813 | $is_preview = false; |
814 | - if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { |
|
814 | + if (Sensei_Utils::is_preview_lesson($lesson_id)) { |
|
815 | 815 | |
816 | 816 | $is_preview = true; |
817 | 817 | $pre_requisite_complete = true; |
@@ -819,24 +819,24 @@ discard block |
||
819 | 819 | }; |
820 | 820 | |
821 | 821 | |
822 | - $user_can_access_lesson = false; |
|
822 | + $user_can_access_lesson = false; |
|
823 | 823 | |
824 | - if( is_user_logged_in() && $user_taking_course ){ |
|
824 | + if (is_user_logged_in() && $user_taking_course) { |
|
825 | 825 | |
826 | - $user_can_access_lesson = true; |
|
826 | + $user_can_access_lesson = true; |
|
827 | 827 | |
828 | 828 | } |
829 | 829 | |
830 | 830 | |
831 | 831 | $access_permission = false; |
832 | 832 | |
833 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
833 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { |
|
834 | 834 | |
835 | 835 | $access_permission = true; |
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; |
|
839 | + $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview; |
|
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Filter the can user view lesson function |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @param string $lesson_id |
850 | 850 | * @param string $user_id |
851 | 851 | */ |
852 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); |
|
852 | + return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id); |
|
853 | 853 | |
854 | 854 | } // end sensei_can_current_user_view_lesson |
855 | 855 | |
@@ -859,51 +859,51 @@ discard block |
||
859 | 859 | * The function should only be called on the single lesson |
860 | 860 | * |
861 | 861 | */ |
862 | -function sensei_the_single_lesson_meta(){ |
|
862 | +function sensei_the_single_lesson_meta() { |
|
863 | 863 | |
864 | 864 | // if the lesson meta is included within theme load that instead of the function content |
865 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); |
|
866 | - if( ! empty( $template ) ){ |
|
865 | + $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php'); |
|
866 | + if ( ! empty($template)) { |
|
867 | 867 | |
868 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); |
|
868 | + Sensei_Templates::get_template('single-lesson/lesson-meta.php'); |
|
869 | 869 | return; |
870 | 870 | |
871 | 871 | } |
872 | 872 | |
873 | 873 | // Get the meta info |
874 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); |
|
875 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); |
|
874 | + $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true)); |
|
875 | + $is_preview = Sensei_Utils::is_preview_lesson(get_the_ID()); |
|
876 | 876 | |
877 | 877 | // Complete Lesson Logic |
878 | - do_action( 'sensei_complete_lesson' ); |
|
878 | + do_action('sensei_complete_lesson'); |
|
879 | 879 | // Check that the course has been started |
880 | - if ( Sensei()->access_settings() |
|
881 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) |
|
882 | - || $is_preview ) { |
|
880 | + if (Sensei()->access_settings() |
|
881 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()) |
|
882 | + || $is_preview) { |
|
883 | 883 | ?> |
884 | 884 | <section class="lesson-meta"> |
885 | 885 | <?php |
886 | - if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { |
|
886 | + if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') { |
|
887 | 887 | |
888 | - do_action( 'sensei_lesson_video', get_the_ID() ); |
|
888 | + do_action('sensei_lesson_video', get_the_ID()); |
|
889 | 889 | |
890 | 890 | } |
891 | 891 | ?> |
892 | - <?php do_action( 'sensei_frontend_messages' ); ?> |
|
892 | + <?php do_action('sensei_frontend_messages'); ?> |
|
893 | 893 | |
894 | 894 | <?php if ( ! $is_preview |
895 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { |
|
895 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) { |
|
896 | 896 | |
897 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); |
|
897 | + sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id())); |
|
898 | 898 | |
899 | 899 | } ?> |
900 | 900 | </section> |
901 | 901 | |
902 | - <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> |
|
902 | + <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?> |
|
903 | 903 | |
904 | 904 | <?php } |
905 | 905 | |
906 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); |
|
906 | + do_action('sensei_lesson_meta_extra', get_the_ID()); |
|
907 | 907 | |
908 | 908 | } // end the_single_lesson_meta |
909 | 909 | |
@@ -917,9 +917,9 @@ discard block |
||
917 | 917 | * |
918 | 918 | * @since 1.9.0 |
919 | 919 | */ |
920 | -function get_sensei_header(){ |
|
920 | +function get_sensei_header() { |
|
921 | 921 | |
922 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
922 | + if ( ! defined('ABSPATH')) exit; |
|
923 | 923 | |
924 | 924 | get_header(); |
925 | 925 | |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * |
929 | 929 | * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) |
930 | 930 | */ |
931 | - do_action( 'sensei_before_main_content' ); |
|
931 | + do_action('sensei_before_main_content'); |
|
932 | 932 | |
933 | 933 | }// end get_sensei_header |
934 | 934 | |
@@ -942,28 +942,28 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @since 1.9.0 |
944 | 944 | */ |
945 | -function get_sensei_footer(){ |
|
945 | +function get_sensei_footer() { |
|
946 | 946 | |
947 | 947 | /** |
948 | 948 | * sensei_pagination hook |
949 | 949 | * |
950 | 950 | * @hooked sensei_pagination - 10 (outputs pagination) |
951 | 951 | */ |
952 | - do_action( 'sensei_pagination' ); |
|
952 | + do_action('sensei_pagination'); |
|
953 | 953 | |
954 | 954 | /** |
955 | 955 | * sensei_after_main_content hook |
956 | 956 | * |
957 | 957 | * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) |
958 | 958 | */ |
959 | - do_action( 'sensei_after_main_content' ); |
|
959 | + do_action('sensei_after_main_content'); |
|
960 | 960 | |
961 | 961 | /** |
962 | 962 | * sensei_sidebar hook |
963 | 963 | * |
964 | 964 | * @hooked sensei_get_sidebar - 10 |
965 | 965 | */ |
966 | - do_action( 'sensei_sidebar' ); |
|
966 | + do_action('sensei_sidebar'); |
|
967 | 967 | |
968 | 968 | get_footer(); |
969 | 969 | |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | * |
976 | 976 | * @since 1.9.0 |
977 | 977 | */ |
978 | -function the_no_permissions_title(){ |
|
978 | +function the_no_permissions_title() { |
|
979 | 979 | |
980 | 980 | /** |
981 | 981 | * Filter the no permissions title just before it is echo'd on the |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @since 1.9.0 |
985 | 985 | * @param $no_permissions_title |
986 | 986 | */ |
987 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); |
|
987 | + echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']); |
|
988 | 988 | |
989 | 989 | } |
990 | 990 | |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | * |
994 | 994 | * @since 1.9.0 |
995 | 995 | */ |
996 | -function the_no_permissions_message( $post_id ){ |
|
996 | +function the_no_permissions_message($post_id) { |
|
997 | 997 | |
998 | 998 | /** |
999 | 999 | * Filter the no permissions message just before it is echo'd on the |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | * @since 1.9.0 |
1003 | 1003 | * @param $no_permissions_message |
1004 | 1004 | */ |
1005 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); |
|
1005 | + echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id); |
|
1006 | 1006 | |
1007 | 1007 | } |
1008 | 1008 | |
@@ -1011,10 +1011,10 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @since 1.9.0 |
1013 | 1013 | */ |
1014 | -function sensei_the_excerpt( $post_id ){ |
|
1014 | +function sensei_the_excerpt($post_id) { |
|
1015 | 1015 | |
1016 | 1016 | global $post; |
1017 | - the_excerpt( $post ); |
|
1017 | + the_excerpt($post); |
|
1018 | 1018 | |
1019 | 1019 | } |
1020 | 1020 | |
@@ -1026,10 +1026,10 @@ discard block |
||
1026 | 1026 | * @global WP $wp |
1027 | 1027 | * @return string $current_page_url |
1028 | 1028 | */ |
1029 | - function sensei_get_current_page_url(){ |
|
1029 | + function sensei_get_current_page_url() { |
|
1030 | 1030 | |
1031 | 1031 | global $wp; |
1032 | - $current_page_url = home_url( $wp->request ); |
|
1032 | + $current_page_url = home_url($wp->request); |
|
1033 | 1033 | return $current_page_url; |
1034 | 1034 | |
1035 | 1035 | } |
@@ -1040,9 +1040,9 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @since 1.9.0 |
1042 | 1042 | */ |
1043 | -function sensei_the_my_courses_content(){ |
|
1043 | +function sensei_the_my_courses_content() { |
|
1044 | 1044 | |
1045 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); |
|
1045 | + echo Sensei()->course->load_user_courses_content(wp_get_current_user()); |
|
1046 | 1046 | |
1047 | 1047 | } // sensei_the_my_courses_content |
1048 | 1048 | |
@@ -1055,9 +1055,9 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @since 1.9.0 |
1057 | 1057 | */ |
1058 | -function sensei_load_template( $template_name ){ |
|
1058 | +function sensei_load_template($template_name) { |
|
1059 | 1059 | |
1060 | - Sensei_Templates::get_template( $template_name ); |
|
1060 | + Sensei_Templates::get_template($template_name); |
|
1061 | 1061 | |
1062 | 1062 | } |
1063 | 1063 | |
@@ -1069,9 +1069,9 @@ discard block |
||
1069 | 1069 | * @param string $name the name of the template. |
1070 | 1070 | * @since 1.9.0 |
1071 | 1071 | */ |
1072 | -function sensei_load_template_part( $slug, $name ){ |
|
1072 | +function sensei_load_template_part($slug, $name) { |
|
1073 | 1073 | |
1074 | - Sensei_Templates::get_part( $slug, $name ); |
|
1074 | + Sensei_Templates::get_part($slug, $name); |
|
1075 | 1075 | |
1076 | 1076 | } |
1077 | 1077 | |
@@ -1088,19 +1088,19 @@ discard block |
||
1088 | 1088 | * @access public |
1089 | 1089 | * @param string $lesson_id |
1090 | 1090 | */ |
1091 | -function sensei_the_lesson_excerpt( $lesson_id = '' ) { |
|
1091 | +function sensei_the_lesson_excerpt($lesson_id = '') { |
|
1092 | 1092 | |
1093 | - if( empty( $lesson_id )){ |
|
1093 | + if (empty($lesson_id)) { |
|
1094 | 1094 | |
1095 | 1095 | $lesson_id = get_the_ID(); |
1096 | 1096 | |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
1099 | + if ('lesson' != get_post_type($lesson_id)) { |
|
1100 | 1100 | return; |
1101 | 1101 | } |
1102 | 1102 | |
1103 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); |
|
1103 | + echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false); |
|
1104 | 1104 | |
1105 | 1105 | }// End lesson_excerpt() |
1106 | 1106 | |
@@ -1109,17 +1109,17 @@ discard block |
||
1109 | 1109 | * |
1110 | 1110 | * @since 1.9.0 |
1111 | 1111 | */ |
1112 | -function sensei_the_course_results_lessons(){ |
|
1112 | +function sensei_the_course_results_lessons() { |
|
1113 | 1113 | // load backwards compatible template name if it exists in the users theme |
1114 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); |
|
1115 | - if( $located_template ){ |
|
1114 | + $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php'); |
|
1115 | + if ($located_template) { |
|
1116 | 1116 | |
1117 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); |
|
1117 | + Sensei_Templates::get_template('course-results/course-lessons.php'); |
|
1118 | 1118 | return; |
1119 | 1119 | |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); |
|
1122 | + Sensei_Templates::get_template('course-results/lessons.php'); |
|
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | /** |
@@ -1129,7 +1129,7 @@ discard block |
||
1129 | 1129 | * @uses Sensei_Course::get_loop_number_of_columns |
1130 | 1130 | * @since 1.9.0 |
1131 | 1131 | */ |
1132 | -function sensei_courses_per_row(){ |
|
1132 | +function sensei_courses_per_row() { |
|
1133 | 1133 | |
1134 | 1134 | echo Sensei_Course::get_loop_number_of_columns(); |
1135 | 1135 | |
@@ -1143,9 +1143,9 @@ discard block |
||
1143 | 1143 | * @param $args |
1144 | 1144 | * @param $path |
1145 | 1145 | */ |
1146 | -function sensei_get_template( $template_name, $args, $path ){ |
|
1146 | +function sensei_get_template($template_name, $args, $path) { |
|
1147 | 1147 | |
1148 | - Sensei_Templates::get_template( $template_name, $args, $path ); |
|
1148 | + Sensei_Templates::get_template($template_name, $args, $path); |
|
1149 | 1149 | |
1150 | 1150 | } |
1151 | 1151 | |
@@ -1157,12 +1157,12 @@ discard block |
||
1157 | 1157 | * |
1158 | 1158 | * @return string $status_class |
1159 | 1159 | */ |
1160 | -function get_the_lesson_status_class(){ |
|
1160 | +function get_the_lesson_status_class() { |
|
1161 | 1161 | |
1162 | 1162 | $status_class = ''; |
1163 | - $lesson_completed = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() ); |
|
1163 | + $lesson_completed = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id()); |
|
1164 | 1164 | |
1165 | - if ( $lesson_completed ) { |
|
1165 | + if ($lesson_completed) { |
|
1166 | 1166 | $status_class = 'completed'; |
1167 | 1167 | } |
1168 | 1168 | |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | * |
1177 | 1177 | * @since 1.9.0 |
1178 | 1178 | */ |
1179 | -function sensei_the_lesson_status_class(){ |
|
1179 | +function sensei_the_lesson_status_class() { |
|
1180 | 1180 | |
1181 | 1181 | echo get_the_lesson_status_class(); |
1182 | 1182 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 | * Handles all admin views, assets and navigation. |
@@ -14,51 +14,51 @@ discard block |
||
14 | 14 | * Constructor. |
15 | 15 | * @since 1.0.0 |
16 | 16 | */ |
17 | - public function __construct () { |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | //register admin styles |
20 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) ); |
|
20 | + add_action('admin_enqueue_scripts', array($this, 'admin_styles_global')); |
|
21 | 21 | |
22 | 22 | //register admin scripts |
23 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
23 | + add_action('admin_enqueue_scripts', array($this, 'register_scripts')); |
|
24 | 24 | |
25 | - add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) ); |
|
26 | - add_action( 'settings_before_form', array( $this, 'install_pages_output' ) ); |
|
27 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
28 | - add_action( 'menu_order', array( $this, 'admin_menu_order' ) ); |
|
29 | - add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) ); |
|
30 | - add_action( 'admin_init', array( $this, 'page_redirect' ) ); |
|
31 | - add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) ); |
|
32 | - add_action( 'admin_init', array( __CLASS__, 'install_pages' )); |
|
25 | + add_action('admin_print_styles', array($this, 'admin_notices_styles')); |
|
26 | + add_action('settings_before_form', array($this, 'install_pages_output')); |
|
27 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
28 | + add_action('menu_order', array($this, 'admin_menu_order')); |
|
29 | + add_action('admin_head', array($this, 'admin_menu_highlight')); |
|
30 | + add_action('admin_init', array($this, 'page_redirect')); |
|
31 | + add_action('admin_init', array($this, 'sensei_add_custom_menu_items')); |
|
32 | + add_action('admin_init', array(__CLASS__, 'install_pages')); |
|
33 | 33 | |
34 | 34 | // Duplicate lesson & courses |
35 | - add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 ); |
|
36 | - add_action( 'admin_action_duplicate_lesson', array( $this, 'duplicate_lesson_action' ) ); |
|
37 | - add_action( 'admin_action_duplicate_course', array( $this, 'duplicate_course_action' ) ); |
|
38 | - add_action( 'admin_action_duplicate_course_with_lessons', array( $this, 'duplicate_course_with_lessons_action' ) ); |
|
35 | + add_filter('post_row_actions', array($this, 'duplicate_action_link'), 10, 2); |
|
36 | + add_action('admin_action_duplicate_lesson', array($this, 'duplicate_lesson_action')); |
|
37 | + add_action('admin_action_duplicate_course', array($this, 'duplicate_course_action')); |
|
38 | + add_action('admin_action_duplicate_course_with_lessons', array($this, 'duplicate_course_with_lessons_action')); |
|
39 | 39 | |
40 | 40 | // Handle lessons list table filtering |
41 | - add_action( 'restrict_manage_posts', array( $this, 'lesson_filter_options' ) ); |
|
42 | - add_filter( 'request', array( $this, 'lesson_filter_actions' ) ); |
|
41 | + add_action('restrict_manage_posts', array($this, 'lesson_filter_options')); |
|
42 | + add_filter('request', array($this, 'lesson_filter_actions')); |
|
43 | 43 | |
44 | 44 | // Add Sensei items to 'at a glance' widget |
45 | - add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), 10, 1 ); |
|
45 | + add_filter('dashboard_glance_items', array($this, 'glance_items'), 10, 1); |
|
46 | 46 | |
47 | 47 | // Handle course and lesson deletions |
48 | - add_action( 'trash_course', array( $this, 'delete_content' ), 10, 2 ); |
|
49 | - add_action( 'trash_lesson', array( $this, 'delete_content' ), 10, 2 ); |
|
48 | + add_action('trash_course', array($this, 'delete_content'), 10, 2); |
|
49 | + add_action('trash_lesson', array($this, 'delete_content'), 10, 2); |
|
50 | 50 | |
51 | 51 | // Delete user activity when user is deleted |
52 | - add_action( 'deleted_user', array( $this, 'delete_user_activity' ), 10, 1 ); |
|
52 | + add_action('deleted_user', array($this, 'delete_user_activity'), 10, 1); |
|
53 | 53 | |
54 | 54 | // Add notices to WP dashboard |
55 | - add_action( 'admin_notices', array( $this, 'theme_compatibility_notices' ) ); |
|
55 | + add_action('admin_notices', array($this, 'theme_compatibility_notices')); |
|
56 | 56 | |
57 | 57 | // Reset theme notices when switching themes |
58 | - add_action( 'switch_theme', array( $this, 'reset_theme_check_notices' ) ); |
|
58 | + add_action('switch_theme', array($this, 'reset_theme_check_notices')); |
|
59 | 59 | |
60 | 60 | // Allow Teacher access the admin area |
61 | - add_filter( 'woocommerce_prevent_admin_access', array( $this, 'admin_access' ) ); |
|
61 | + add_filter('woocommerce_prevent_admin_access', array($this, 'admin_access')); |
|
62 | 62 | |
63 | 63 | } // End __construct() |
64 | 64 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | public function admin_menu() { |
71 | 71 | global $menu; |
72 | 72 | $menu_cap = ''; |
73 | - if( current_user_can( 'manage_sensei' ) ) { |
|
73 | + if (current_user_can('manage_sensei')) { |
|
74 | 74 | $menu_cap = 'manage_sensei'; |
75 | 75 | } else { |
76 | - if( current_user_can( 'manage_sensei_grades' ) ) { |
|
76 | + if (current_user_can('manage_sensei_grades')) { |
|
77 | 77 | $menu_cap = 'manage_sensei_grades'; |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | - if( $menu_cap ) { |
|
82 | - $menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' ); |
|
83 | - add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' ); |
|
81 | + if ($menu_cap) { |
|
82 | + $menu[] = array('', 'read', 'separator-sensei', '', 'wp-menu-separator sensei'); |
|
83 | + add_menu_page('Sensei', 'Sensei', $menu_cap, 'sensei', array(Sensei()->analysis, 'analysis_page'), '', '50'); |
|
84 | 84 | } |
85 | 85 | |
86 | - add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) ); |
|
87 | - add_submenu_page( 'edit.php?post_type=lesson', __( 'Order Lessons', 'woothemes-sensei' ), __( 'Order Lessons', 'woothemes-sensei' ), 'edit_lessons', 'lesson-order', array( $this, 'lesson_order_screen' ) ); |
|
86 | + add_submenu_page('edit.php?post_type=course', __('Order Courses', 'woothemes-sensei'), __('Order Courses', 'woothemes-sensei'), 'manage_sensei', 'course-order', array($this, 'course_order_screen')); |
|
87 | + add_submenu_page('edit.php?post_type=lesson', __('Order Lessons', 'woothemes-sensei'), __('Order Lessons', 'woothemes-sensei'), 'edit_lessons', 'lesson-order', array($this, 'lesson_order_screen')); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -93,22 +93,22 @@ discard block |
||
93 | 93 | * @param array $menu_order Existing menu order |
94 | 94 | * @return array Modified menu order for Sensei |
95 | 95 | */ |
96 | - public function admin_menu_order( $menu_order ) { |
|
96 | + public function admin_menu_order($menu_order) { |
|
97 | 97 | |
98 | 98 | // Initialize our custom order array |
99 | 99 | $sensei_menu_order = array(); |
100 | 100 | |
101 | 101 | // Get the index of our custom separator |
102 | - $sensei_separator = array_search( 'separator-sensei', $menu_order ); |
|
102 | + $sensei_separator = array_search('separator-sensei', $menu_order); |
|
103 | 103 | |
104 | 104 | // Loop through menu order and do some rearranging |
105 | - foreach ( $menu_order as $index => $item ) : |
|
105 | + foreach ($menu_order as $index => $item) : |
|
106 | 106 | |
107 | - if ( ( ( 'sensei' ) == $item ) ) : |
|
107 | + if ((('sensei') == $item)) : |
|
108 | 108 | $sensei_menu_order[] = 'separator-sensei'; |
109 | 109 | $sensei_menu_order[] = $item; |
110 | - unset( $menu_order[$sensei_separator] ); |
|
111 | - elseif ( !in_array( $item, array( 'separator-sensei' ) ) ) : |
|
110 | + unset($menu_order[$sensei_separator]); |
|
111 | + elseif ( ! in_array($item, array('separator-sensei'))) : |
|
112 | 112 | $sensei_menu_order[] = $item; |
113 | 113 | endif; |
114 | 114 | |
@@ -128,24 +128,24 @@ discard block |
||
128 | 128 | |
129 | 129 | $screen = get_current_screen(); |
130 | 130 | |
131 | - if ( $screen->base == 'post' && $post_type == 'course' ) { |
|
131 | + if ($screen->base == 'post' && $post_type == 'course') { |
|
132 | 132 | |
133 | - $parent_file = 'edit.php?post_type=course'; |
|
133 | + $parent_file = 'edit.php?post_type=course'; |
|
134 | 134 | |
135 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) { |
|
135 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') { |
|
136 | 136 | |
137 | 137 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; |
138 | 138 | $parent_file = 'edit.php?post_type=course'; |
139 | 139 | |
140 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
140 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') { |
|
141 | 141 | |
142 | 142 | $submenu_file = 'edit-tags.php?taxonomy=module'; |
143 | 143 | $parent_file = 'edit.php?post_type=course'; |
144 | 144 | |
145 | - } elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { |
|
145 | + } elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) { |
|
146 | 146 | |
147 | 147 | $submenu_file = 'edit.php?post_type=sensei_message'; |
148 | - $parent_file = 'sensei'; |
|
148 | + $parent_file = 'sensei'; |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | } |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @return void |
157 | 157 | */ |
158 | 158 | public function page_redirect() { |
159 | - if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) { |
|
160 | - wp_safe_redirect( 'admin.php?page=sensei_analysis' ); |
|
159 | + if (isset($_GET['page']) && $_GET['page'] == 'sensei') { |
|
160 | + wp_safe_redirect('admin.php?page=sensei_analysis'); |
|
161 | 161 | exit; |
162 | 162 | } |
163 | 163 | } |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | */ |
173 | 173 | function install_pages_output() { |
174 | 174 | |
175 | - if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
175 | + if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
176 | 176 | |
177 | 177 | ?> |
178 | 178 | <div id="message" class="updated sensei-message sensei-connect"> |
179 | - <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> |
|
179 | + <p><?php _e('<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei'); ?></p> |
|
180 | 180 | <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a> |
181 | 181 | <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p> |
182 | 182 | </div> |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | * @param int $post_parent (default: 0) |
199 | 199 | * @return integer $page_id |
200 | 200 | */ |
201 | - function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
201 | + function create_page($slug, $page_title = '', $page_content = '', $post_parent = 0) { |
|
202 | 202 | global $wpdb; |
203 | 203 | |
204 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); |
|
205 | - if ( $page_id ) : |
|
204 | + $page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug)); |
|
205 | + if ($page_id) : |
|
206 | 206 | return $page_id; |
207 | 207 | endif; |
208 | 208 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | 'comment_status' => 'closed' |
218 | 218 | ); |
219 | 219 | |
220 | - $page_id = wp_insert_post( $page_data ); |
|
220 | + $page_id = wp_insert_post($page_data); |
|
221 | 221 | |
222 | 222 | return $page_id; |
223 | 223 | |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | function create_pages() { |
234 | 234 | |
235 | 235 | // Courses page |
236 | - $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), __('Courses', 'woothemes-sensei'), '' ); |
|
237 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); |
|
236 | + $new_course_page_id = $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), __('Courses', 'woothemes-sensei'), ''); |
|
237 | + Sensei()->settings->set('course_page', $new_course_page_id); |
|
238 | 238 | |
239 | 239 | // User Dashboard page |
240 | - $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); |
|
241 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); |
|
240 | + $new_my_course_page_id = $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]'); |
|
241 | + Sensei()->settings->set('my_course_page', $new_my_course_page_id); |
|
242 | 242 | |
243 | 243 | } // End create_pages() |
244 | 244 | |
@@ -248,25 +248,25 @@ discard block |
||
248 | 248 | * @since 1.0.0 |
249 | 249 | * @return void |
250 | 250 | */ |
251 | - public function admin_styles_global ( $hook ) { |
|
251 | + public function admin_styles_global($hook) { |
|
252 | 252 | global $post_type; |
253 | 253 | |
254 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) ); |
|
255 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); |
|
256 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) ); |
|
254 | + $allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question')); |
|
255 | + $allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); |
|
256 | + $allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order')); |
|
257 | 257 | |
258 | 258 | // Global Styles for icons and menu items |
259 | - wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); |
|
260 | - wp_enqueue_style( 'woothemes-sensei-global' ); |
|
259 | + wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen'); |
|
260 | + wp_enqueue_style('woothemes-sensei-global'); |
|
261 | 261 | |
262 | 262 | // Select 2 styles |
263 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
263 | + wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen'); |
|
264 | 264 | |
265 | 265 | // Test for Write Panel Pages |
266 | - if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
|
266 | + if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) { |
|
267 | 267 | |
268 | - wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' ); |
|
269 | - wp_enqueue_style( 'woothemes-sensei-admin-custom' ); |
|
268 | + wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen'); |
|
269 | + wp_enqueue_style('woothemes-sensei-admin-custom'); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
@@ -281,20 +281,20 @@ discard block |
||
281 | 281 | * @since 1.8.2 |
282 | 282 | * @access public |
283 | 283 | */ |
284 | - public function register_scripts( $hook ){ |
|
284 | + public function register_scripts($hook) { |
|
285 | 285 | |
286 | 286 | $screen = get_current_screen(); |
287 | 287 | |
288 | 288 | // Allow developers to load non-minified versions of scripts |
289 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
289 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
290 | 290 | |
291 | 291 | // Select2 script used to enhance all select boxes |
292 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
292 | + wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version); |
|
293 | 293 | |
294 | 294 | // load edit module scripts |
295 | - if( 'edit-module' == $screen->id ){ |
|
295 | + if ('edit-module' == $screen->id) { |
|
296 | 296 | |
297 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
297 | + wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true); |
|
298 | 298 | |
299 | 299 | } |
300 | 300 | |
@@ -312,19 +312,19 @@ discard block |
||
312 | 312 | <div id="message" class="updated sensei-message sensei-connect"> |
313 | 313 | |
314 | 314 | <p> |
315 | - <?php _e( '<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?> |
|
315 | + <?php _e('<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei'); ?> |
|
316 | 316 | </p> |
317 | 317 | |
318 | 318 | <p class="submit"> |
319 | 319 | |
320 | - <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>" |
|
320 | + <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>" |
|
321 | 321 | class="button-primary"> |
322 | 322 | |
323 | - <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?> |
|
323 | + <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?> |
|
324 | 324 | |
325 | 325 | </a> |
326 | 326 | |
327 | - <a class="skip button" href="<?php echo esc_url( add_query_arg( 'skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings' ) ) ); ?>"> |
|
327 | + <a class="skip button" href="<?php echo esc_url(add_query_arg('skip_install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>"> |
|
328 | 328 | |
329 | 329 | <?php _e('Skip setup', 'woothemes-sensei'); ?> |
330 | 330 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | <div id="message" class="updated sensei-message sensei-connect"> |
348 | 348 | |
349 | 349 | <p> |
350 | - <?php _e( '<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei' ); ?> |
|
350 | + <?php _e('<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei'); ?> |
|
351 | 351 | </p> |
352 | 352 | |
353 | 353 | <p class="submit"> |
354 | - <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e( 'Settings', 'woothemes-sensei' ); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/"> |
|
354 | + <a href="<?php echo admin_url('admin.php?page=woothemes-sensei-settings'); ?>" class="button-primary"><?php _e('Settings', 'woothemes-sensei'); ?></a> <a class="docs button" href="http://www.woothemes.com/sensei-docs/"> |
|
355 | 355 | <?php _e('Documentation', 'woothemes-sensei'); ?> |
356 | 356 | </a> |
357 | 357 | </p> |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | public function language_pack_install_notice() { |
385 | 385 | ?> |
386 | 386 | <div id="message" class="updated sensei-message sensei-connect"> |
387 | - <p><?php _e( '<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei' ); ?><p> |
|
387 | + <p><?php _e('<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei'); ?><p> |
|
388 | 388 | |
389 | 389 | <p class="submit"> |
390 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a> |
|
391 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a> |
|
390 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a> |
|
391 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a> |
|
392 | 392 | </p> |
393 | 393 | </div> |
394 | 394 | <?php |
@@ -404,20 +404,20 @@ discard block |
||
404 | 404 | function admin_notices_styles() { |
405 | 405 | |
406 | 406 | // Installed notices |
407 | - if ( 1 == get_option( 'sensei_installed' ) ) { |
|
407 | + if (1 == get_option('sensei_installed')) { |
|
408 | 408 | |
409 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
409 | + wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version); |
|
410 | 410 | |
411 | - if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
412 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
413 | - } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
414 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
411 | + if (get_option('skip_install_sensei_pages') != 1 && Sensei()->get_page_id('course') < 1 && ! isset($_GET['install_sensei_pages']) && ! isset($_GET['skip_install_sensei_pages'])) { |
|
412 | + add_action('admin_notices', array($this, 'admin_install_notice')); |
|
413 | + } elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') { |
|
414 | + add_action('admin_notices', array($this, 'admin_installed_notice')); |
|
415 | 415 | } // End If Statement |
416 | 416 | |
417 | 417 | } // End If Statement |
418 | 418 | |
419 | - if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
420 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
419 | + if (Sensei_Language_Pack_Manager::has_language_pack_available()) { |
|
420 | + add_action('admin_notices', array($this, 'language_pack_install_notice')); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | } // End admin_notices_styles() |
@@ -428,17 +428,17 @@ discard block |
||
428 | 428 | * @param object $post Current post |
429 | 429 | * @return array Modified actions |
430 | 430 | */ |
431 | - public function duplicate_action_link( $actions, $post ) { |
|
432 | - switch( $post->post_type ) { |
|
431 | + public function duplicate_action_link($actions, $post) { |
|
432 | + switch ($post->post_type) { |
|
433 | 433 | case 'lesson': |
434 | - $confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' ); |
|
435 | - $actions['duplicate'] = "<a onclick='return confirm(\"" . $confirm . "\");' href='" . $this->get_duplicate_link( $post->ID ) . "' title='" . esc_attr(__( 'Duplicate this lesson', 'woothemes-sensei' ) ) . "'>" . __('Duplicate', 'woothemes-sensei' ) . "</a>"; |
|
434 | + $confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei'); |
|
435 | + $actions['duplicate'] = "<a onclick='return confirm(\"".$confirm."\");' href='".$this->get_duplicate_link($post->ID)."' title='".esc_attr(__('Duplicate this lesson', 'woothemes-sensei'))."'>".__('Duplicate', 'woothemes-sensei')."</a>"; |
|
436 | 436 | break; |
437 | 437 | |
438 | 438 | case 'course': |
439 | - $confirm = __( 'This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei' ); |
|
440 | - $actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' . __('Duplicate', 'woothemes-sensei' ) . '</a>'; |
|
441 | - $actions['duplicate_with_lessons'] = '<a onclick="return confirm(\'' . $confirm . '\');" href="' . $this->get_duplicate_link( $post->ID, true ) . '" title="' . esc_attr(__( 'Duplicate this course with its lessons', 'woothemes-sensei' ) ) . '">' . __('Duplicate (with lessons)', 'woothemes-sensei' ) . '</a>'; |
|
439 | + $confirm = __('This will duplicate the course lessons along with all of their quizzes and questions. Are you sure you want to do this?', 'woothemes-sensei'); |
|
440 | + $actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>'; |
|
441 | + $actions['duplicate_with_lessons'] = '<a onclick="return confirm(\''.$confirm.'\');" href="'.$this->get_duplicate_link($post->ID, true).'" title="'.esc_attr(__('Duplicate this course with its lessons', 'woothemes-sensei')).'">'.__('Duplicate (with lessons)', 'woothemes-sensei').'</a>'; |
|
442 | 442 | break; |
443 | 443 | } |
444 | 444 | |
@@ -451,17 +451,17 @@ discard block |
||
451 | 451 | * @param boolean $with_lessons Include lessons or not |
452 | 452 | * @return string Duplication link |
453 | 453 | */ |
454 | - private function get_duplicate_link( $post_id = 0, $with_lessons = false ) { |
|
454 | + private function get_duplicate_link($post_id = 0, $with_lessons = false) { |
|
455 | 455 | |
456 | - $post = get_post( $post_id ); |
|
456 | + $post = get_post($post_id); |
|
457 | 457 | |
458 | - $action = 'duplicate_' . $post->post_type; |
|
458 | + $action = 'duplicate_'.$post->post_type; |
|
459 | 459 | |
460 | - if( 'course' == $post->post_type && $with_lessons ) { |
|
460 | + if ('course' == $post->post_type && $with_lessons) { |
|
461 | 461 | $action .= '_with_lessons'; |
462 | 462 | } |
463 | 463 | |
464 | - return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id ); |
|
464 | + return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | * @return void |
470 | 470 | */ |
471 | 471 | public function duplicate_lesson_action() { |
472 | - $this->duplicate_content( 'lesson' ); |
|
472 | + $this->duplicate_content('lesson'); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @return void |
478 | 478 | */ |
479 | 479 | public function duplicate_course_action() { |
480 | - $this->duplicate_content( 'course' ); |
|
480 | + $this->duplicate_content('course'); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * @return void |
486 | 486 | */ |
487 | 487 | public function duplicate_course_with_lessons_action() { |
488 | - $this->duplicate_content( 'course', true ); |
|
488 | + $this->duplicate_content('course', true); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -494,34 +494,34 @@ discard block |
||
494 | 494 | * @param boolean $with_lessons Include lessons or not |
495 | 495 | * @return void |
496 | 496 | */ |
497 | - private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) { |
|
498 | - if ( ! isset( $_GET['post'] ) ) { |
|
499 | - wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type ); |
|
497 | + private function duplicate_content($post_type = 'lesson', $with_lessons = false) { |
|
498 | + if ( ! isset($_GET['post'])) { |
|
499 | + wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | $post_id = $_GET['post']; |
503 | - $post = get_post( $post_id ); |
|
503 | + $post = get_post($post_id); |
|
504 | 504 | |
505 | - if( ! is_wp_error( $post ) ) { |
|
505 | + if ( ! is_wp_error($post)) { |
|
506 | 506 | |
507 | - $new_post = $this->duplicate_post( $post ); |
|
507 | + $new_post = $this->duplicate_post($post); |
|
508 | 508 | |
509 | - if( $new_post && ! is_wp_error( $new_post ) ) { |
|
509 | + if ($new_post && ! is_wp_error($new_post)) { |
|
510 | 510 | |
511 | - if( 'lesson' == $new_post->post_type ) { |
|
512 | - $this->duplicate_lesson_quizzes( $post_id, $new_post->ID ); |
|
511 | + if ('lesson' == $new_post->post_type) { |
|
512 | + $this->duplicate_lesson_quizzes($post_id, $new_post->ID); |
|
513 | 513 | } |
514 | 514 | |
515 | - if( 'course' == $new_post->post_type && $with_lessons ) { |
|
516 | - $this->duplicate_course_lessons( $post_id, $new_post->ID ); |
|
515 | + if ('course' == $new_post->post_type && $with_lessons) { |
|
516 | + $this->duplicate_course_lessons($post_id, $new_post->ID); |
|
517 | 517 | } |
518 | 518 | |
519 | - $redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' ); |
|
519 | + $redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit'); |
|
520 | 520 | } else { |
521 | - $redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' ); |
|
521 | + $redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed'); |
|
522 | 522 | } |
523 | 523 | |
524 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); |
|
524 | + wp_safe_redirect(esc_url_raw($redirect_url)); |
|
525 | 525 | exit; |
526 | 526 | } |
527 | 527 | } |
@@ -532,19 +532,19 @@ discard block |
||
532 | 532 | * @param integer $new_lesson_id ID of duplicate lesson |
533 | 533 | * @return void |
534 | 534 | */ |
535 | - private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { |
|
535 | + private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) { |
|
536 | 536 | |
537 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
538 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
537 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id); |
|
538 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id); |
|
539 | 539 | |
540 | 540 | // duplicate the generic wp post information |
541 | - $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); |
|
541 | + $new_quiz = $this->duplicate_post(get_post($old_quiz_id), ''); |
|
542 | 542 | |
543 | 543 | //update the new lesson data |
544 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
544 | + add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID); |
|
545 | 545 | |
546 | 546 | //update the new quiz data |
547 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
547 | + add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id); |
|
548 | 548 | wp_update_post( |
549 | 549 | array( |
550 | 550 | 'ID' => $new_quiz->ID, |
@@ -552,15 +552,15 @@ discard block |
||
552 | 552 | ) |
553 | 553 | ); |
554 | 554 | |
555 | - foreach( $old_quiz_questions as $question ) { |
|
555 | + foreach ($old_quiz_questions as $question) { |
|
556 | 556 | |
557 | 557 | // copy the question order over to the new quiz |
558 | - $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); |
|
559 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
560 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
558 | + $old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true); |
|
559 | + $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order); |
|
560 | + add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order); |
|
561 | 561 | |
562 | 562 | // Add question to quiz |
563 | - add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); |
|
563 | + add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false); |
|
564 | 564 | |
565 | 565 | } |
566 | 566 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | * @param integer $new_course_id ID of duplicated course |
572 | 572 | * @return void |
573 | 573 | */ |
574 | - private function duplicate_course_lessons( $old_course_id, $new_course_id ) { |
|
574 | + private function duplicate_course_lessons($old_course_id, $new_course_id) { |
|
575 | 575 | $lesson_args = array( |
576 | 576 | 'post_type' => 'lesson', |
577 | 577 | 'posts_per_page' => -1, |
@@ -579,13 +579,13 @@ discard block |
||
579 | 579 | 'meta_value' => $old_course_id, |
580 | 580 | 'suppress_filters' => 0 |
581 | 581 | ); |
582 | - $lessons = get_posts( $lesson_args ); |
|
582 | + $lessons = get_posts($lesson_args); |
|
583 | 583 | |
584 | - foreach( $lessons as $lesson ) { |
|
585 | - $new_lesson = $this->duplicate_post( $lesson, '', true ); |
|
586 | - add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id ); |
|
584 | + foreach ($lessons as $lesson) { |
|
585 | + $new_lesson = $this->duplicate_post($lesson, '', true); |
|
586 | + add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id); |
|
587 | 587 | |
588 | - $this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID ); |
|
588 | + $this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
@@ -596,24 +596,24 @@ discard block |
||
596 | 596 | * @param boolean $ignore_course Ignore lesson course when dulicating |
597 | 597 | * @return object Duplicate post object |
598 | 598 | */ |
599 | - private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) { |
|
599 | + private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) { |
|
600 | 600 | |
601 | 601 | $new_post = array(); |
602 | 602 | |
603 | - foreach( $post as $k => $v ) { |
|
604 | - if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) { |
|
605 | - $new_post[ $k ] = $v; |
|
603 | + foreach ($post as $k => $v) { |
|
604 | + if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) { |
|
605 | + $new_post[$k] = $v; |
|
606 | 606 | } |
607 | 607 | } |
608 | 608 | |
609 | - $new_post['post_title'] .= __( $suffix, 'woothemes-sensei' ); |
|
609 | + $new_post['post_title'] .= __($suffix, 'woothemes-sensei'); |
|
610 | 610 | |
611 | - $new_post['post_date'] = current_time( 'mysql' ); |
|
612 | - $new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] ); |
|
611 | + $new_post['post_date'] = current_time('mysql'); |
|
612 | + $new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']); |
|
613 | 613 | $new_post['post_modified'] = $new_post['post_date']; |
614 | 614 | $new_post['post_modified_gmt'] = $new_post['post_date_gmt']; |
615 | 615 | |
616 | - switch( $post->post_type ) { |
|
616 | + switch ($post->post_type) { |
|
617 | 617 | case 'course': $new_post['post_status'] = 'draft'; break; |
618 | 618 | case 'lesson': $new_post['post_status'] = 'draft'; break; |
619 | 619 | case 'quiz': $new_post['post_status'] = 'publish'; break; |
@@ -621,45 +621,45 @@ discard block |
||
621 | 621 | } |
622 | 622 | |
623 | 623 | // As per wp_update_post() we need to escape the data from the db. |
624 | - $new_post = wp_slash( $new_post ); |
|
624 | + $new_post = wp_slash($new_post); |
|
625 | 625 | |
626 | - $new_post_id = wp_insert_post( $new_post ); |
|
626 | + $new_post_id = wp_insert_post($new_post); |
|
627 | 627 | |
628 | - if( ! is_wp_error( $new_post_id ) ) { |
|
628 | + if ( ! is_wp_error($new_post_id)) { |
|
629 | 629 | |
630 | - $post_meta = get_post_custom( $post->ID ); |
|
631 | - if( $post_meta && count( $post_meta ) > 0 ) { |
|
630 | + $post_meta = get_post_custom($post->ID); |
|
631 | + if ($post_meta && count($post_meta) > 0) { |
|
632 | 632 | |
633 | - $ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' ); |
|
633 | + $ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz'); |
|
634 | 634 | |
635 | - if( $ignore_course ) { |
|
635 | + if ($ignore_course) { |
|
636 | 636 | $ignore_meta[] = '_lesson_course'; |
637 | 637 | } |
638 | 638 | |
639 | - foreach( $post_meta as $key => $meta ) { |
|
640 | - foreach( $meta as $value ) { |
|
641 | - $value = maybe_unserialize( $value ); |
|
642 | - if( ! in_array( $key, $ignore_meta ) ) { |
|
643 | - add_post_meta( $new_post_id, $key, $value ); |
|
639 | + foreach ($post_meta as $key => $meta) { |
|
640 | + foreach ($meta as $value) { |
|
641 | + $value = maybe_unserialize($value); |
|
642 | + if ( ! in_array($key, $ignore_meta)) { |
|
643 | + add_post_meta($new_post_id, $key, $value); |
|
644 | 644 | } |
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
649 | - add_post_meta( $new_post_id, '_duplicate', $post->ID ); |
|
649 | + add_post_meta($new_post_id, '_duplicate', $post->ID); |
|
650 | 650 | |
651 | - $taxonomies = get_object_taxonomies( $post->post_type, 'objects' ); |
|
651 | + $taxonomies = get_object_taxonomies($post->post_type, 'objects'); |
|
652 | 652 | |
653 | - foreach ( $taxonomies as $slug => $tax ) { |
|
654 | - $terms = get_the_terms( $post->ID, $slug ); |
|
655 | - if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) { |
|
656 | - foreach( $terms as $term ) { |
|
657 | - wp_set_object_terms( $new_post_id, $term->term_id, $slug, true ); |
|
653 | + foreach ($taxonomies as $slug => $tax) { |
|
654 | + $terms = get_the_terms($post->ID, $slug); |
|
655 | + if (isset($terms) && is_array($terms) && 0 < count($terms)) { |
|
656 | + foreach ($terms as $term) { |
|
657 | + wp_set_object_terms($new_post_id, $term->term_id, $slug, true); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | - $new_post = get_post( $new_post_id ); |
|
662 | + $new_post = get_post($new_post_id); |
|
663 | 663 | |
664 | 664 | return $new_post; |
665 | 665 | } |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | public function lesson_filter_options() { |
675 | 675 | global $typenow; |
676 | 676 | |
677 | - if( is_admin() && 'lesson' == $typenow ) { |
|
677 | + if (is_admin() && 'lesson' == $typenow) { |
|
678 | 678 | |
679 | 679 | $args = array( |
680 | 680 | 'post_type' => 'course', |
@@ -684,16 +684,16 @@ discard block |
||
684 | 684 | 'orderby' => 'menu_order date', |
685 | 685 | 'order' => 'ASC', |
686 | 686 | ); |
687 | - $courses = get_posts( $args ); |
|
687 | + $courses = get_posts($args); |
|
688 | 688 | |
689 | - $selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
689 | + $selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
690 | 690 | $course_options = ''; |
691 | - foreach( $courses as $course ) { |
|
692 | - $course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>'; |
|
691 | + foreach ($courses as $course) { |
|
692 | + $course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>'; |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | $output = '<select name="lesson_course" id="dropdown_lesson_course">'; |
696 | - $output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>'; |
|
696 | + $output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>'; |
|
697 | 697 | $output .= $course_options; |
698 | 698 | $output .= '</select>'; |
699 | 699 | |
@@ -706,13 +706,13 @@ discard block |
||
706 | 706 | * @param array $request Current request |
707 | 707 | * @return array Modified request |
708 | 708 | */ |
709 | - public function lesson_filter_actions( $request ) { |
|
709 | + public function lesson_filter_actions($request) { |
|
710 | 710 | global $typenow; |
711 | 711 | |
712 | - if( is_admin() && 'lesson' == $typenow ) { |
|
713 | - $lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
712 | + if (is_admin() && 'lesson' == $typenow) { |
|
713 | + $lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
714 | 714 | |
715 | - if( $lesson_course ) { |
|
715 | + if ($lesson_course) { |
|
716 | 716 | $request['meta_key'] = '_lesson_course'; |
717 | 717 | $request['meta_value'] = $lesson_course; |
718 | 718 | $request['meta_compare'] = '='; |
@@ -727,27 +727,27 @@ discard block |
||
727 | 727 | * @param array $items Existing items |
728 | 728 | * @return array Updated items |
729 | 729 | */ |
730 | - public function glance_items( $items = array() ) { |
|
730 | + public function glance_items($items = array()) { |
|
731 | 731 | |
732 | - $types = array( 'course', 'lesson', 'question' ); |
|
732 | + $types = array('course', 'lesson', 'question'); |
|
733 | 733 | |
734 | - foreach( $types as $type ) { |
|
735 | - if( ! post_type_exists( $type ) ) continue; |
|
734 | + foreach ($types as $type) { |
|
735 | + if ( ! post_type_exists($type)) continue; |
|
736 | 736 | |
737 | - $num_posts = wp_count_posts( $type ); |
|
737 | + $num_posts = wp_count_posts($type); |
|
738 | 738 | |
739 | - if( $num_posts ) { |
|
739 | + if ($num_posts) { |
|
740 | 740 | |
741 | - $published = intval( $num_posts->publish ); |
|
742 | - $post_type = get_post_type_object( $type ); |
|
741 | + $published = intval($num_posts->publish); |
|
742 | + $post_type = get_post_type_object($type); |
|
743 | 743 | |
744 | - $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' ); |
|
745 | - $text = sprintf( $text, number_format_i18n( $published ) ); |
|
744 | + $text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei'); |
|
745 | + $text = sprintf($text, number_format_i18n($published)); |
|
746 | 746 | |
747 | - if ( current_user_can( $post_type->cap->edit_posts ) ) { |
|
748 | - $items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n"; |
|
747 | + if (current_user_can($post_type->cap->edit_posts)) { |
|
748 | + $items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n"; |
|
749 | 749 | } else { |
750 | - $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n"; |
|
750 | + $items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n"; |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | } |
@@ -761,13 +761,13 @@ discard block |
||
761 | 761 | * @param object $post Post object |
762 | 762 | * @return void |
763 | 763 | */ |
764 | - public function delete_content( $post_id, $post ) { |
|
764 | + public function delete_content($post_id, $post) { |
|
765 | 765 | |
766 | 766 | $type = $post->post_type; |
767 | 767 | |
768 | - if( in_array( $type, array( 'lesson', 'course' ) ) ) { |
|
768 | + if (in_array($type, array('lesson', 'course'))) { |
|
769 | 769 | |
770 | - $meta_key = '_' . $type . '_prerequisite'; |
|
770 | + $meta_key = '_'.$type.'_prerequisite'; |
|
771 | 771 | |
772 | 772 | $args = array( |
773 | 773 | 'post_type' => $type, |
@@ -777,10 +777,10 @@ discard block |
||
777 | 777 | 'meta_value' => $post_id |
778 | 778 | ); |
779 | 779 | |
780 | - $posts = get_posts( $args ); |
|
780 | + $posts = get_posts($args); |
|
781 | 781 | |
782 | - foreach( $posts as $post ) { |
|
783 | - delete_post_meta( $post->ID, $meta_key ); |
|
782 | + foreach ($posts as $post) { |
|
783 | + delete_post_meta($post->ID, $meta_key); |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | } |
@@ -790,181 +790,181 @@ discard block |
||
790 | 790 | * @param integer $user_id User ID |
791 | 791 | * @return void |
792 | 792 | */ |
793 | - public function delete_user_activity( $user_id = 0 ) { |
|
794 | - if( $user_id ) { |
|
795 | - Sensei_Utils::delete_all_user_activity( $user_id ); |
|
793 | + public function delete_user_activity($user_id = 0) { |
|
794 | + if ($user_id) { |
|
795 | + Sensei_Utils::delete_all_user_activity($user_id); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | |
799 | - public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) { |
|
799 | + public function render_settings($settings = array(), $post_id = 0, $group_id = '') { |
|
800 | 800 | |
801 | 801 | $html = ''; |
802 | 802 | |
803 | - if( 0 == count( $settings ) ) return $html; |
|
803 | + if (0 == count($settings)) return $html; |
|
804 | 804 | |
805 | - $html .= '<div class="sensei-options-panel">' . "\n"; |
|
805 | + $html .= '<div class="sensei-options-panel">'."\n"; |
|
806 | 806 | |
807 | - $html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n"; |
|
807 | + $html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n"; |
|
808 | 808 | |
809 | - foreach( $settings as $field ) { |
|
809 | + foreach ($settings as $field) { |
|
810 | 810 | |
811 | 811 | $data = ''; |
812 | 812 | |
813 | - if( $post_id ) { |
|
814 | - $data = get_post_meta( $post_id, '_' . $field['id'], true ); |
|
815 | - if( ! $data && isset( $field['default'] ) ) { |
|
813 | + if ($post_id) { |
|
814 | + $data = get_post_meta($post_id, '_'.$field['id'], true); |
|
815 | + if ( ! $data && isset($field['default'])) { |
|
816 | 816 | $data = $field['default']; |
817 | 817 | } |
818 | 818 | } else { |
819 | - $option = get_option( $field['id'] ); |
|
820 | - if( isset( $field['default'] ) ) { |
|
819 | + $option = get_option($field['id']); |
|
820 | + if (isset($field['default'])) { |
|
821 | 821 | $data = $field['default']; |
822 | - if( $option ) { |
|
822 | + if ($option) { |
|
823 | 823 | $data = $option; |
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
827 | 827 | |
828 | 828 | $disabled = ''; |
829 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
830 | - $disabled = disabled( $field['disabled'], true, false ); |
|
829 | + if (isset($field['disabled']) && $field['disabled']) { |
|
830 | + $disabled = disabled($field['disabled'], true, false); |
|
831 | 831 | } |
832 | 832 | |
833 | - if( 'hidden' != $field['type'] ) { |
|
833 | + if ('hidden' != $field['type']) { |
|
834 | 834 | |
835 | 835 | $class_tail = ''; |
836 | 836 | |
837 | - if( isset( $field['class'] ) ) { |
|
837 | + if (isset($field['class'])) { |
|
838 | 838 | $class_tail .= $field['class']; |
839 | 839 | } |
840 | 840 | |
841 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
841 | + if (isset($field['disabled']) && $field['disabled']) { |
|
842 | 842 | $class_tail .= ' disabled'; |
843 | 843 | } |
844 | 844 | |
845 | - $html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n"; |
|
845 | + $html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n"; |
|
846 | 846 | } |
847 | 847 | |
848 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
849 | - $html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n"; |
|
848 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
849 | + $html .= '<label for="'.esc_attr($field['id']).'">'."\n"; |
|
850 | 850 | } |
851 | 851 | |
852 | - if( $field['label'] ) { |
|
853 | - $html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>'; |
|
852 | + if ($field['label']) { |
|
853 | + $html .= '<span class="label">'.esc_html($field['label']).'</span>'; |
|
854 | 854 | } |
855 | 855 | |
856 | - switch( $field['type'] ) { |
|
856 | + switch ($field['type']) { |
|
857 | 857 | case 'text': |
858 | 858 | case 'password': |
859 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n"; |
|
859 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n"; |
|
860 | 860 | break; |
861 | 861 | |
862 | 862 | case 'number': |
863 | 863 | |
864 | 864 | $min = ''; |
865 | - if( isset( $field['min'] ) ) { |
|
866 | - $min = 'min="' . esc_attr( $field['min'] ) . '"'; |
|
865 | + if (isset($field['min'])) { |
|
866 | + $min = 'min="'.esc_attr($field['min']).'"'; |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | $max = ''; |
870 | - if( isset( $field['max'] ) ) { |
|
871 | - $max = 'max="' . esc_attr( $field['max'] ) . '"'; |
|
870 | + if (isset($field['max'])) { |
|
871 | + $max = 'max="'.esc_attr($field['max']).'"'; |
|
872 | 872 | } |
873 | 873 | |
874 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $min . ' ' . $max . ' class="small-text" ' . $disabled . ' />' . "\n"; |
|
874 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$min.' '.$max.' class="small-text" '.$disabled.' />'."\n"; |
|
875 | 875 | break; |
876 | 876 | |
877 | 877 | case 'textarea': |
878 | - $html .= '<textarea id="' . esc_attr( $field['id'] ) . '" rows="5" cols="50" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" ' . $disabled . '>' . $data . '</textarea><br/>'. "\n"; |
|
878 | + $html .= '<textarea id="'.esc_attr($field['id']).'" rows="5" cols="50" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" '.$disabled.'>'.$data.'</textarea><br/>'."\n"; |
|
879 | 879 | break; |
880 | 880 | |
881 | 881 | case 'checkbox': |
882 | 882 | //backwards compatibility |
883 | - if( empty( $data ) || 'on' == $data ){ |
|
883 | + if (empty($data) || 'on' == $data) { |
|
884 | 884 | $checked_value = 'on'; |
885 | - }elseif( 'yes' == $data ) { |
|
885 | + }elseif ('yes' == $data) { |
|
886 | 886 | |
887 | 887 | $checked_value = 'yes'; |
888 | 888 | |
889 | - }elseif( 'auto' == $data ) { |
|
889 | + }elseif ('auto' == $data) { |
|
890 | 890 | |
891 | 891 | $checked_value = 'auto'; |
892 | 892 | |
893 | 893 | } else { |
894 | 894 | $checked_value = 1; |
895 | - $data = intval( $data ); |
|
895 | + $data = intval($data); |
|
896 | 896 | } |
897 | - $checked = checked( $checked_value, $data, false ); |
|
898 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; |
|
897 | + $checked = checked($checked_value, $data, false); |
|
898 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n"; |
|
899 | 899 | break; |
900 | 900 | |
901 | 901 | case 'checkbox_multi': |
902 | - foreach( $field['options'] as $k => $v ) { |
|
902 | + foreach ($field['options'] as $k => $v) { |
|
903 | 903 | $checked = false; |
904 | - if( in_array( $k, $data ) ) { |
|
904 | + if (in_array($k, $data)) { |
|
905 | 905 | $checked = true; |
906 | 906 | } |
907 | - $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="checkbox" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '[]" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n"; |
|
907 | + $html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="checkbox" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'[]" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n"; |
|
908 | 908 | } |
909 | 909 | break; |
910 | 910 | |
911 | 911 | case 'radio': |
912 | - foreach( $field['options'] as $k => $v ) { |
|
912 | + foreach ($field['options'] as $k => $v) { |
|
913 | 913 | $checked = false; |
914 | - if( $k == $data ) { |
|
914 | + if ($k == $data) { |
|
915 | 915 | $checked = true; |
916 | 916 | } |
917 | - $html .= '<label for="' . esc_attr( $field['id'] . '_' . $k ) . '"><input type="radio" ' . checked( $checked, true, false ) . ' name="' . esc_attr( $field['id'] ) . '" value="' . esc_attr( $k ) . '" id="' . esc_attr( $field['id'] . '_' . $k ) . '" ' . $disabled . ' /> ' . $v . '</label> ' . "\n"; |
|
917 | + $html .= '<label for="'.esc_attr($field['id'].'_'.$k).'"><input type="radio" '.checked($checked, true, false).' name="'.esc_attr($field['id']).'" value="'.esc_attr($k).'" id="'.esc_attr($field['id'].'_'.$k).'" '.$disabled.' /> '.$v.'</label> '."\n"; |
|
918 | 918 | } |
919 | 919 | break; |
920 | 920 | |
921 | 921 | case 'select': |
922 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n"; |
|
923 | - foreach( $field['options'] as $k => $v ) { |
|
922 | + $html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n"; |
|
923 | + foreach ($field['options'] as $k => $v) { |
|
924 | 924 | $selected = false; |
925 | - if( $k == $data ) { |
|
925 | + if ($k == $data) { |
|
926 | 926 | $selected = true; |
927 | 927 | } |
928 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n"; |
|
928 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n"; |
|
929 | 929 | } |
930 | - $html .= '</select><br/>' . "\n"; |
|
930 | + $html .= '</select><br/>'."\n"; |
|
931 | 931 | break; |
932 | 932 | |
933 | 933 | case 'select_multi': |
934 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n"; |
|
935 | - foreach( $field['options'] as $k => $v ) { |
|
934 | + $html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n"; |
|
935 | + foreach ($field['options'] as $k => $v) { |
|
936 | 936 | $selected = false; |
937 | - if( in_array( $k, $data ) ) { |
|
937 | + if (in_array($k, $data)) { |
|
938 | 938 | $selected = true; |
939 | 939 | } |
940 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n"; |
|
940 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n"; |
|
941 | 941 | } |
942 | 942 | $html .= '</select> . "\n"'; |
943 | 943 | break; |
944 | 944 | |
945 | 945 | case 'hidden': |
946 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n"; |
|
946 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n"; |
|
947 | 947 | break; |
948 | 948 | |
949 | 949 | } |
950 | 950 | |
951 | - if( $field['description'] ) { |
|
952 | - $html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n"; |
|
951 | + if ($field['description']) { |
|
952 | + $html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n"; |
|
953 | 953 | } |
954 | 954 | |
955 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
956 | - $html .= '</label>' . "\n"; |
|
955 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
956 | + $html .= '</label>'."\n"; |
|
957 | 957 | } |
958 | 958 | |
959 | - if( 'hidden' != $field['type'] ) { |
|
960 | - $html .= '</p>' . "\n"; |
|
959 | + if ('hidden' != $field['type']) { |
|
960 | + $html .= '</p>'."\n"; |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | } |
964 | 964 | |
965 | - $html .= '</div>' . "\n"; |
|
965 | + $html .= '</div>'."\n"; |
|
966 | 966 | |
967 | - $html .= '</div>' . "\n"; |
|
967 | + $html .= '</div>'."\n"; |
|
968 | 968 | |
969 | 969 | return $html; |
970 | 970 | } |
@@ -975,61 +975,61 @@ discard block |
||
975 | 975 | */ |
976 | 976 | public function course_order_screen() { |
977 | 977 | |
978 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
979 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
978 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
979 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
980 | 980 | |
981 | 981 | ?><div id="course-order" class="wrap course-order"> |
982 | - <h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php |
|
982 | + <h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php |
|
983 | 983 | |
984 | 984 | $html = ''; |
985 | 985 | |
986 | - if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) { |
|
987 | - $ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) ); |
|
986 | + if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) { |
|
987 | + $ordered = $this->save_course_order(esc_attr($_POST['course-order'])); |
|
988 | 988 | |
989 | - if( $ordered ) { |
|
990 | - $html .= '<div class="updated fade">' . "\n"; |
|
991 | - $html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
992 | - $html .= '</div>' . "\n"; |
|
989 | + if ($ordered) { |
|
990 | + $html .= '<div class="updated fade">'."\n"; |
|
991 | + $html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
992 | + $html .= '</div>'."\n"; |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | |
996 | 996 | $courses = Sensei()->course->get_all_courses(); |
997 | 997 | |
998 | - if( 0 < count( $courses ) ) { |
|
998 | + if (0 < count($courses)) { |
|
999 | 999 | |
1000 | 1000 | // order the courses as set by the users |
1001 | 1001 | $all_course_ids = array(); |
1002 | - foreach( $courses as $course ){ |
|
1002 | + foreach ($courses as $course) { |
|
1003 | 1003 | |
1004 | - $all_course_ids[] = (string)$course->ID; |
|
1004 | + $all_course_ids[] = (string) $course->ID; |
|
1005 | 1005 | |
1006 | 1006 | } |
1007 | 1007 | $order_string = $this->get_course_order(); |
1008 | 1008 | |
1009 | - if( !empty( $order_string ) ){ |
|
1010 | - $ordered_course_ids = explode(',' , $order_string ); |
|
1011 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
1009 | + if ( ! empty($order_string)) { |
|
1010 | + $ordered_course_ids = explode(',', $order_string); |
|
1011 | + $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids)); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | |
1015 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
1016 | - $html .= '<ul class="sortable-course-list">' . "\n"; |
|
1015 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
1016 | + $html .= '<ul class="sortable-course-list">'."\n"; |
|
1017 | 1017 | $count = 0; |
1018 | - foreach ( $all_course_ids as $course_id ) { |
|
1019 | - $course = get_post( $course_id ); |
|
1018 | + foreach ($all_course_ids as $course_id) { |
|
1019 | + $course = get_post($course_id); |
|
1020 | 1020 | $count++; |
1021 | 1021 | $class = 'course'; |
1022 | - if ( $count == 1 ) { $class .= ' first'; } |
|
1023 | - if ( $count == count( $course ) ) { $class .= ' last'; } |
|
1024 | - if ( $count % 2 != 0 ) { |
|
1022 | + if ($count == 1) { $class .= ' first'; } |
|
1023 | + if ($count == count($course)) { $class .= ' last'; } |
|
1024 | + if ($count % 2 != 0) { |
|
1025 | 1025 | $class .= ' alternate'; |
1026 | 1026 | } |
1027 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n"; |
|
1027 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n"; |
|
1028 | 1028 | } |
1029 | - $html .= '</ul>' . "\n"; |
|
1029 | + $html .= '</ul>'."\n"; |
|
1030 | 1030 | |
1031 | - $html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
1032 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
1031 | + $html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
1032 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n"; |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | echo $html; |
@@ -1038,25 +1038,25 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | public function get_course_order() { |
1041 | - return get_option( 'sensei_course_order', '' ); |
|
1041 | + return get_option('sensei_course_order', ''); |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | - public function save_course_order( $order_string = '' ) { |
|
1045 | - $order = explode( ',', $order_string ); |
|
1044 | + public function save_course_order($order_string = '') { |
|
1045 | + $order = explode(',', $order_string); |
|
1046 | 1046 | |
1047 | - update_option( 'sensei_course_order', $order_string ); |
|
1047 | + update_option('sensei_course_order', $order_string); |
|
1048 | 1048 | |
1049 | 1049 | $i = 1; |
1050 | - foreach( $order as $course_id ) { |
|
1050 | + foreach ($order as $course_id) { |
|
1051 | 1051 | |
1052 | - if( $course_id ) { |
|
1052 | + if ($course_id) { |
|
1053 | 1053 | |
1054 | 1054 | $update_args = array( |
1055 | 1055 | 'ID' => $course_id, |
1056 | 1056 | 'menu_order' => $i, |
1057 | 1057 | ); |
1058 | 1058 | |
1059 | - wp_update_post( $update_args ); |
|
1059 | + wp_update_post($update_args); |
|
1060 | 1060 | |
1061 | 1061 | ++$i; |
1062 | 1062 | } |
@@ -1071,22 +1071,22 @@ discard block |
||
1071 | 1071 | */ |
1072 | 1072 | public function lesson_order_screen() { |
1073 | 1073 | |
1074 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
1075 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
1074 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
1075 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
1076 | 1076 | |
1077 | 1077 | ?><div id="lesson-order" class="wrap lesson-order"> |
1078 | - <h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php |
|
1078 | + <h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php |
|
1079 | 1079 | |
1080 | 1080 | $html = ''; |
1081 | 1081 | |
1082 | - if( isset( $_POST['lesson-order'] ) ) { |
|
1082 | + if (isset($_POST['lesson-order'])) { |
|
1083 | 1083 | |
1084 | - $ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) ); |
|
1084 | + $ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id'])); |
|
1085 | 1085 | |
1086 | - if( $ordered ) { |
|
1087 | - $html .= '<div class="updated fade">' . "\n"; |
|
1088 | - $html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
1089 | - $html .= '</div>' . "\n"; |
|
1086 | + if ($ordered) { |
|
1087 | + $html .= '<div class="updated fade">'."\n"; |
|
1088 | + $html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
1089 | + $html .= '</div>'."\n"; |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1097,43 +1097,43 @@ discard block |
||
1097 | 1097 | 'orderby' => 'name', |
1098 | 1098 | 'order' => 'ASC', |
1099 | 1099 | ); |
1100 | - $courses = get_posts( $args ); |
|
1100 | + $courses = get_posts($args); |
|
1101 | 1101 | |
1102 | - $html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n"; |
|
1103 | - $html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n"; |
|
1104 | - $html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n"; |
|
1105 | - $html .= '<select id="lesson-order-course" name="course_id">' . "\n"; |
|
1106 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
1102 | + $html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n"; |
|
1103 | + $html .= '<input type="hidden" name="post_type" value="lesson" />'."\n"; |
|
1104 | + $html .= '<input type="hidden" name="page" value="lesson-order" />'."\n"; |
|
1105 | + $html .= '<select id="lesson-order-course" name="course_id">'."\n"; |
|
1106 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n"; |
|
1107 | 1107 | |
1108 | - foreach( $courses as $course ) { |
|
1108 | + foreach ($courses as $course) { |
|
1109 | 1109 | $course_id = ''; |
1110 | - if( isset( $_GET['course_id'] ) ) { |
|
1111 | - $course_id = intval( $_GET['course_id'] ); |
|
1110 | + if (isset($_GET['course_id'])) { |
|
1111 | + $course_id = intval($_GET['course_id']); |
|
1112 | 1112 | } |
1113 | - $html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n"; |
|
1113 | + $html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n"; |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | - $html .= '</select>' . "\n"; |
|
1117 | - $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n"; |
|
1118 | - $html .= '</form>' . "\n"; |
|
1116 | + $html .= '</select>'."\n"; |
|
1117 | + $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n"; |
|
1118 | + $html .= '</form>'."\n"; |
|
1119 | 1119 | |
1120 | - $html .= '<script type="text/javascript">' . "\n"; |
|
1121 | - $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n"; |
|
1122 | - $html .= '</script>' . "\n"; |
|
1120 | + $html .= '<script type="text/javascript">'."\n"; |
|
1121 | + $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n"; |
|
1122 | + $html .= '</script>'."\n"; |
|
1123 | 1123 | |
1124 | - if( isset( $_GET['course_id'] ) ) { |
|
1125 | - $course_id = intval( $_GET['course_id'] ); |
|
1126 | - if( $course_id > 0 ) { |
|
1124 | + if (isset($_GET['course_id'])) { |
|
1125 | + $course_id = intval($_GET['course_id']); |
|
1126 | + if ($course_id > 0) { |
|
1127 | 1127 | |
1128 | - $order_string = $this->get_lesson_order( $course_id ); |
|
1128 | + $order_string = $this->get_lesson_order($course_id); |
|
1129 | 1129 | |
1130 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
1130 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
1131 | 1131 | |
1132 | 1132 | $displayed_lessons = array(); |
1133 | 1133 | |
1134 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1134 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
1135 | 1135 | |
1136 | - foreach( $modules as $module ) { |
|
1136 | + foreach ($modules as $module) { |
|
1137 | 1137 | |
1138 | 1138 | $args = array( |
1139 | 1139 | 'post_type' => 'lesson', |
@@ -1142,7 +1142,7 @@ discard block |
||
1142 | 1142 | 'meta_query' => array( |
1143 | 1143 | array( |
1144 | 1144 | 'key' => '_lesson_course', |
1145 | - 'value' => intval( $course_id ), |
|
1145 | + 'value' => intval($course_id), |
|
1146 | 1146 | 'compare' => '=' |
1147 | 1147 | ) |
1148 | 1148 | ), |
@@ -1150,66 +1150,66 @@ discard block |
||
1150 | 1150 | array( |
1151 | 1151 | 'taxonomy' => Sensei()->modules->taxonomy, |
1152 | 1152 | 'field' => 'id', |
1153 | - 'terms' => intval( $module->term_id ) |
|
1153 | + 'terms' => intval($module->term_id) |
|
1154 | 1154 | ) |
1155 | 1155 | ), |
1156 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
1156 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
1157 | 1157 | 'orderby' => 'meta_value_num date', |
1158 | 1158 | 'order' => 'ASC', |
1159 | 1159 | 'suppress_filters' => 0 |
1160 | 1160 | ); |
1161 | 1161 | |
1162 | - $lessons = get_posts( $args ); |
|
1162 | + $lessons = get_posts($args); |
|
1163 | 1163 | |
1164 | - if( count( $lessons ) > 0 ) { |
|
1165 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
1166 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
1164 | + if (count($lessons) > 0) { |
|
1165 | + $html .= '<h3>'.$module->name.'</h3>'."\n"; |
|
1166 | + $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n"; |
|
1167 | 1167 | |
1168 | 1168 | $count = 0; |
1169 | - foreach( $lessons as $lesson ) { |
|
1169 | + foreach ($lessons as $lesson) { |
|
1170 | 1170 | $count++; |
1171 | 1171 | $class = 'lesson'; |
1172 | - if ( $count == 1 ) { $class .= ' first'; } |
|
1173 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
1174 | - if ( $count % 2 != 0 ) { |
|
1172 | + if ($count == 1) { $class .= ' first'; } |
|
1173 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
1174 | + if ($count % 2 != 0) { |
|
1175 | 1175 | $class .= ' alternate'; |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
1178 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
1179 | 1179 | |
1180 | 1180 | $displayed_lessons[] = $lesson->ID; |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $html .= '</ul>' . "\n"; |
|
1183 | + $html .= '</ul>'."\n"; |
|
1184 | 1184 | |
1185 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
1185 | + $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n"; |
|
1186 | 1186 | } |
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
1190 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
1190 | + $lessons = Sensei()->course->course_lessons($course_id); |
|
1191 | 1191 | |
1192 | - if( 0 < count( $lessons ) ) { |
|
1192 | + if (0 < count($lessons)) { |
|
1193 | 1193 | |
1194 | 1194 | //get module term ids, will be used to exclude lessons |
1195 | 1195 | $module_items_ids = array(); |
1196 | - if( ! empty( $modules ) ) { |
|
1196 | + if ( ! empty($modules)) { |
|
1197 | 1197 | foreach ($modules as $module) { |
1198 | 1198 | $module_items_ids[] = $module->term_id; |
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - if( 0 < count( $displayed_lessons ) ) { |
|
1203 | - $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; |
|
1202 | + if (0 < count($displayed_lessons)) { |
|
1203 | + $html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n"; |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | - $html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n"; |
|
1206 | + $html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n"; |
|
1207 | 1207 | $count = 0; |
1208 | - foreach ( $lessons as $lesson ) { |
|
1208 | + foreach ($lessons as $lesson) { |
|
1209 | 1209 | |
1210 | 1210 | // if lesson belongs to one fo the course modules then exclude it here |
1211 | 1211 | // as it is listed above |
1212 | - if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
1212 | + if (has_term($module_items_ids, 'module', $lesson->ID)) { |
|
1213 | 1213 | |
1214 | 1214 | continue; |
1215 | 1215 | |
@@ -1217,28 +1217,28 @@ discard block |
||
1217 | 1217 | |
1218 | 1218 | $count++; |
1219 | 1219 | $class = 'lesson'; |
1220 | - if ( $count == 1 ) { $class .= ' first'; } |
|
1221 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
1222 | - if ( $count % 2 != 0 ) { |
|
1220 | + if ($count == 1) { $class .= ' first'; } |
|
1221 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
1222 | + if ($count % 2 != 0) { |
|
1223 | 1223 | |
1224 | 1224 | $class .= ' alternate'; |
1225 | 1225 | |
1226 | 1226 | } |
1227 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
1227 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
1228 | 1228 | |
1229 | 1229 | $displayed_lessons[] = $lesson->ID; |
1230 | 1230 | } |
1231 | - $html .= '</ul>' . "\n"; |
|
1231 | + $html .= '</ul>'."\n"; |
|
1232 | 1232 | } else { |
1233 | - if( 0 == count( $displayed_lessons ) ) { |
|
1234 | - $html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>'; |
|
1233 | + if (0 == count($displayed_lessons)) { |
|
1234 | + $html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>'; |
|
1235 | 1235 | } |
1236 | 1236 | } |
1237 | 1237 | |
1238 | - if( 0 < count( $displayed_lessons ) ) { |
|
1239 | - $html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
1240 | - $html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n"; |
|
1241 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
1238 | + if (0 < count($displayed_lessons)) { |
|
1239 | + $html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
1240 | + $html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n"; |
|
1241 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n"; |
|
1242 | 1242 | } |
1243 | 1243 | } |
1244 | 1244 | } |
@@ -1248,29 +1248,29 @@ discard block |
||
1248 | 1248 | ?></div><?php |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - public function get_lesson_order( $course_id = 0 ) { |
|
1252 | - $order_string = get_post_meta( $course_id, '_lesson_order', true ); |
|
1251 | + public function get_lesson_order($course_id = 0) { |
|
1252 | + $order_string = get_post_meta($course_id, '_lesson_order', true); |
|
1253 | 1253 | return $order_string; |
1254 | 1254 | } |
1255 | 1255 | |
1256 | - public function save_lesson_order( $order_string = '', $course_id = 0 ) { |
|
1256 | + public function save_lesson_order($order_string = '', $course_id = 0) { |
|
1257 | 1257 | |
1258 | - if( $course_id ) { |
|
1258 | + if ($course_id) { |
|
1259 | 1259 | |
1260 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1260 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
1261 | 1261 | |
1262 | - foreach( $modules as $module ) { |
|
1262 | + foreach ($modules as $module) { |
|
1263 | 1263 | |
1264 | 1264 | |
1265 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) |
|
1266 | - && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { |
|
1265 | + if (isset($_POST['lesson-order-module-'.$module->term_id]) |
|
1266 | + && $_POST['lesson-order-module-'.$module->term_id]) { |
|
1267 | 1267 | |
1268 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); |
|
1268 | + $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]); |
|
1269 | 1269 | $i = 1; |
1270 | - foreach( $order as $lesson_id ) { |
|
1270 | + foreach ($order as $lesson_id) { |
|
1271 | 1271 | |
1272 | - if( $lesson_id ) { |
|
1273 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
1272 | + if ($lesson_id) { |
|
1273 | + update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i); |
|
1274 | 1274 | ++$i; |
1275 | 1275 | } |
1276 | 1276 | |
@@ -1281,15 +1281,15 @@ discard block |
||
1281 | 1281 | } // end for each modules |
1282 | 1282 | |
1283 | 1283 | |
1284 | - if( $order_string ) { |
|
1285 | - update_post_meta( $course_id, '_lesson_order', $order_string ); |
|
1284 | + if ($order_string) { |
|
1285 | + update_post_meta($course_id, '_lesson_order', $order_string); |
|
1286 | 1286 | |
1287 | - $order = explode( ',', $order_string ); |
|
1287 | + $order = explode(',', $order_string); |
|
1288 | 1288 | |
1289 | 1289 | $i = 1; |
1290 | - foreach( $order as $lesson_id ) { |
|
1291 | - if( $lesson_id ) { |
|
1292 | - update_post_meta( $lesson_id, '_order_' . $course_id, $i ); |
|
1290 | + foreach ($order as $lesson_id) { |
|
1291 | + if ($lesson_id) { |
|
1292 | + update_post_meta($lesson_id, '_order_'.$course_id, $i); |
|
1293 | 1293 | ++$i; |
1294 | 1294 | } |
1295 | 1295 | } |
@@ -1304,54 +1304,54 @@ discard block |
||
1304 | 1304 | function sensei_add_custom_menu_items() { |
1305 | 1305 | global $pagenow; |
1306 | 1306 | |
1307 | - if( 'nav-menus.php' == $pagenow ) { |
|
1308 | - add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' ); |
|
1307 | + if ('nav-menus.php' == $pagenow) { |
|
1308 | + add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low'); |
|
1309 | 1309 | } |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - function wp_nav_menu_item_sensei_links_meta_box( $object ) { |
|
1312 | + function wp_nav_menu_item_sensei_links_meta_box($object) { |
|
1313 | 1313 | global $nav_menu_selected_id; |
1314 | 1314 | |
1315 | 1315 | $menu_items = array( |
1316 | - '#senseicourses' => __( 'Courses', 'woothemes-sensei' ), |
|
1317 | - '#senseilessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
1318 | - '#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ), |
|
1319 | - '#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ), |
|
1320 | - '#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ), |
|
1321 | - '#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' ) |
|
1316 | + '#senseicourses' => __('Courses', 'woothemes-sensei'), |
|
1317 | + '#senseilessons' => __('Lessons', 'woothemes-sensei'), |
|
1318 | + '#senseimycourses' => __('My Courses', 'woothemes-sensei'), |
|
1319 | + '#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'), |
|
1320 | + '#senseimymessages' => __('My Messages', 'woothemes-sensei'), |
|
1321 | + '#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei') |
|
1322 | 1322 | ); |
1323 | 1323 | |
1324 | 1324 | $menu_items_obj = array(); |
1325 | - foreach ( $menu_items as $value => $title ) { |
|
1325 | + foreach ($menu_items as $value => $title) { |
|
1326 | 1326 | $menu_items_obj[$title] = new stdClass; |
1327 | - $menu_items_obj[$title]->object_id = esc_attr( $value ); |
|
1328 | - $menu_items_obj[$title]->title = esc_attr( $title ); |
|
1329 | - $menu_items_obj[$title]->url = esc_attr( $value ); |
|
1330 | - $menu_items_obj[$title]->description = 'description'; |
|
1327 | + $menu_items_obj[$title]->object_id = esc_attr($value); |
|
1328 | + $menu_items_obj[$title]->title = esc_attr($title); |
|
1329 | + $menu_items_obj[$title]->url = esc_attr($value); |
|
1330 | + $menu_items_obj[$title]->description = 'description'; |
|
1331 | 1331 | $menu_items_obj[$title]->db_id = 0; |
1332 | 1332 | $menu_items_obj[$title]->object = 'sensei'; |
1333 | - $menu_items_obj[$title]->menu_item_parent = 0; |
|
1334 | - $menu_items_obj[$title]->type = 'custom'; |
|
1333 | + $menu_items_obj[$title]->menu_item_parent = 0; |
|
1334 | + $menu_items_obj[$title]->type = 'custom'; |
|
1335 | 1335 | $menu_items_obj[$title]->target = ''; |
1336 | - $menu_items_obj[$title]->attr_title = ''; |
|
1337 | - $menu_items_obj[$title]->classes = array(); |
|
1338 | - $menu_items_obj[$title]->xfn = ''; |
|
1336 | + $menu_items_obj[$title]->attr_title = ''; |
|
1337 | + $menu_items_obj[$title]->classes = array(); |
|
1338 | + $menu_items_obj[$title]->xfn = ''; |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
1341 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
1342 | 1342 | ?> |
1343 | 1343 | |
1344 | 1344 | <div id="sensei-links" class="senseidiv taxonomydiv"> |
1345 | 1345 | <div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active"> |
1346 | 1346 | |
1347 | 1347 | <ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear"> |
1348 | - <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?> |
|
1348 | + <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?> |
|
1349 | 1349 | </ul> |
1350 | 1350 | |
1351 | 1351 | </div> |
1352 | 1352 | <p class="button-controls"> |
1353 | 1353 | <span class="add-to-menu"> |
1354 | - <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'woothemes-sensei' ); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" /> |
|
1354 | + <input type="submit"<?php disabled($nav_menu_selected_id, 0); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'woothemes-sensei'); ?>" name="add-sensei-links-menu-item" id="submit-sensei-links" /> |
|
1355 | 1355 | <span class="spinner"></span> |
1356 | 1356 | </span> |
1357 | 1357 | </p> |
@@ -1367,17 +1367,17 @@ discard block |
||
1367 | 1367 | */ |
1368 | 1368 | public function theme_compatibility_notices() { |
1369 | 1369 | |
1370 | - if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
1371 | - switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
1372 | - case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; |
|
1373 | - case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; |
|
1370 | + if (isset($_GET['sensei_hide_notice'])) { |
|
1371 | + switch (esc_attr($_GET['sensei_hide_notice'])) { |
|
1372 | + case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break; |
|
1373 | + case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break; |
|
1374 | 1374 | } |
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | // white list templates that are already support by default and do not show notice for them |
1378 | - $template = get_option( 'template' ); |
|
1378 | + $template = get_option('template'); |
|
1379 | 1379 | |
1380 | - $white_list = array( 'twentyeleven', |
|
1380 | + $white_list = array('twentyeleven', |
|
1381 | 1381 | 'twentytwelve', |
1382 | 1382 | 'twentyfourteen', |
1383 | 1383 | 'twentyfifteen', |
@@ -1385,43 +1385,43 @@ discard block |
||
1385 | 1385 | 'storefront', |
1386 | 1386 | ); |
1387 | 1387 | |
1388 | - if ( in_array( $template, $white_list ) ) { |
|
1388 | + if (in_array($template, $white_list)) { |
|
1389 | 1389 | |
1390 | 1390 | return; |
1391 | 1391 | |
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | // don't show the notice if the user chose to hide it |
1395 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
1396 | - if( $hide_theme_check_notice ) { |
|
1395 | + $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); |
|
1396 | + if ($hide_theme_check_notice) { |
|
1397 | 1397 | |
1398 | 1398 | return; |
1399 | 1399 | |
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | // show the notice for themes not supporting sensei |
1403 | - if ( ! current_theme_supports( 'sensei' ) ) { |
|
1403 | + if ( ! current_theme_supports('sensei')) { |
|
1404 | 1404 | ?> |
1405 | 1405 | |
1406 | 1406 | <div id="message" class="error sensei-message sensei-connect"> |
1407 | 1407 | <p> |
1408 | 1408 | <strong> |
1409 | 1409 | |
1410 | - <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?> |
|
1410 | + <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?> |
|
1411 | 1411 | |
1412 | 1412 | </strong> – |
1413 | 1413 | |
1414 | - <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?> |
|
1414 | + <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?> |
|
1415 | 1415 | |
1416 | - <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a> |
|
1416 | + <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e('Sensei theme', 'woothemes-sensei') ?> </a> |
|
1417 | 1417 | |
1418 | 1418 | :) |
1419 | 1419 | |
1420 | 1420 | </p> |
1421 | 1421 | <p class="submit"> |
1422 | - <a href="<?php echo esc_url( apply_filters( 'sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility' ) ); ?>" class="button-primary"> |
|
1422 | + <a href="<?php echo esc_url(apply_filters('sensei_docs_url', 'http://docs.woothemes.com/document/sensei-and-theme-compatibility/', 'theme-compatibility')); ?>" class="button-primary"> |
|
1423 | 1423 | |
1424 | - <?php _e( 'Theme Integration Guide', 'woothemes-sensei' ); ?></a> <a class="skip button" href="<?php echo esc_url( add_query_arg( 'sensei_hide_notice', 'theme_check' ) ); ?>"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?> |
|
1424 | + <?php _e('Theme Integration Guide', 'woothemes-sensei'); ?></a> <a class="skip button" href="<?php echo esc_url(add_query_arg('sensei_hide_notice', 'theme_check')); ?>"><?php _e('Hide this notice', 'woothemes-sensei'); ?> |
|
1425 | 1425 | |
1426 | 1426 | </a> |
1427 | 1427 | </p> |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | wp_get_current_user(); |
1440 | 1440 | $user_id = $current_user->ID; |
1441 | 1441 | |
1442 | - delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); |
|
1442 | + delete_user_meta($user_id, 'sensei_hide_theme_check_notice'); |
|
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | /** |
@@ -1449,8 +1449,8 @@ discard block |
||
1449 | 1449 | * @param bool $prevent_access |
1450 | 1450 | * @return bool |
1451 | 1451 | */ |
1452 | - public function admin_access( $prevent_access ) { |
|
1453 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
1452 | + public function admin_access($prevent_access) { |
|
1453 | + if (current_user_can('manage_sensei_grades')) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | |
@@ -1465,12 +1465,12 @@ discard block |
||
1465 | 1465 | * |
1466 | 1466 | * @since 1.8.7 |
1467 | 1467 | */ |
1468 | - public static function install_pages(){ |
|
1468 | + public static function install_pages() { |
|
1469 | 1469 | |
1470 | 1470 | // only fire on the settings page |
1471 | - if( ! isset( $_GET['page'] ) |
|
1471 | + if ( ! isset($_GET['page']) |
|
1472 | 1472 | || 'woothemes-sensei-settings' != $_GET['page'] |
1473 | - || 1 == get_option('skip_install_sensei_pages') ){ |
|
1473 | + || 1 == get_option('skip_install_sensei_pages')) { |
|
1474 | 1474 | |
1475 | 1475 | return; |
1476 | 1476 | |
@@ -1507,8 +1507,8 @@ discard block |
||
1507 | 1507 | // Set installed option |
1508 | 1508 | update_option('sensei_installed', 0); |
1509 | 1509 | |
1510 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
1511 | - wp_redirect( $complete_url ); |
|
1510 | + $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url); |
|
1511 | + wp_redirect($complete_url); |
|
1512 | 1512 | |
1513 | 1513 | } |
1514 | 1514 | |
@@ -1522,4 +1522,4 @@ discard block |
||
1522 | 1522 | * @since 1.9.0 |
1523 | 1523 | * @ignore |
1524 | 1524 | */ |
1525 | -class WooThemes_Sensei_Admin extends Sensei_Admin{ } |
|
1525 | +class WooThemes_Sensei_Admin extends Sensei_Admin { } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * List the Course Modules and Lesson in these modules |
5 | 5 | * |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | ?> |
32 | 32 | |
33 | -<?php if( sensei_have_modules() ): ?> |
|
33 | +<?php if (sensei_have_modules()): ?> |
|
34 | 34 | |
35 | - <?php while ( sensei_have_modules() ): sensei_setup_module(); ?> |
|
36 | - <?php if( sensei_module_has_lessons() ): ?> |
|
35 | + <?php while (sensei_have_modules()): sensei_setup_module(); ?> |
|
36 | + <?php if (sensei_module_has_lessons()): ?> |
|
37 | 37 | |
38 | 38 | <article class="module"> |
39 | 39 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | <h2> |
59 | 59 | |
60 | - <a href="<?php sensei_the_module_permalink(); ?>" title="<?php sensei_the_module_title_attribute();?>"> |
|
60 | + <a href="<?php sensei_the_module_permalink(); ?>" title="<?php sensei_the_module_title_attribute(); ?>"> |
|
61 | 61 | |
62 | 62 | <?php sensei_the_module_title(); ?> |
63 | 63 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | <ul class="lessons-list" > |
83 | 83 | |
84 | - <?php while( sensei_module_has_lessons() ): the_post(); ?> |
|
84 | + <?php while (sensei_module_has_lessons()): the_post(); ?> |
|
85 | 85 | |
86 | - <li class="<?php sensei_the_lesson_status_class();?>"> |
|
86 | + <li class="<?php sensei_the_lesson_status_class(); ?>"> |
|
87 | 87 | |
88 | 88 | <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute() ?>" > |
89 | 89 |