@@ -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; |
|
| 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 | |
@@ -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,28 +128,28 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $screen = get_current_screen(); |
| 130 | 130 | |
| 131 | - if( empty( $screen ) ){ |
|
| 131 | + if (empty($screen)) { |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if ( $screen->base == 'post' && $post_type == 'course' ) { |
|
| 135 | + if ($screen->base == 'post' && $post_type == 'course') { |
|
| 136 | 136 | |
| 137 | - $parent_file = 'edit.php?post_type=course'; |
|
| 137 | + $parent_file = 'edit.php?post_type=course'; |
|
| 138 | 138 | |
| 139 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'course-category' ) { |
|
| 139 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'course-category') { |
|
| 140 | 140 | |
| 141 | 141 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; |
| 142 | 142 | $parent_file = 'edit.php?post_type=course'; |
| 143 | 143 | |
| 144 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
| 144 | + } elseif ($screen->base == 'edit-tags' && $taxonomy == 'module') { |
|
| 145 | 145 | |
| 146 | 146 | $submenu_file = 'edit-tags.php?taxonomy=module'; |
| 147 | 147 | $parent_file = 'edit.php?post_type=course'; |
| 148 | 148 | |
| 149 | - } elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { |
|
| 149 | + } elseif (in_array($screen->id, array('sensei_message', 'edit-sensei_message'))) { |
|
| 150 | 150 | |
| 151 | 151 | $submenu_file = 'edit.php?post_type=sensei_message'; |
| 152 | - $parent_file = 'sensei'; |
|
| 152 | + $parent_file = 'sensei'; |
|
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @return void |
| 161 | 161 | */ |
| 162 | 162 | public function page_redirect() { |
| 163 | - if( isset( $_GET['page'] ) && $_GET['page'] == 'sensei' ) { |
|
| 164 | - wp_safe_redirect( 'admin.php?page=sensei_analysis' ); |
|
| 163 | + if (isset($_GET['page']) && $_GET['page'] == 'sensei') { |
|
| 164 | + wp_safe_redirect('admin.php?page=sensei_analysis'); |
|
| 165 | 165 | exit; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | function install_pages_output() { |
| 178 | 178 | |
| 179 | - if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 179 | + if (isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
| 180 | 180 | |
| 181 | 181 | ?> |
| 182 | 182 | <div id="message" class="updated sensei-message sensei-connect"> |
| 183 | - <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> |
|
| 183 | + <p><?php _e('<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei'); ?></p> |
|
| 184 | 184 | <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> |
| 185 | 185 | <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> |
| 186 | 186 | </div> |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | * @param int $post_parent (default: 0) |
| 203 | 203 | * @return integer $page_id |
| 204 | 204 | */ |
| 205 | - function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) { |
|
| 205 | + function create_page($slug, $page_title = '', $page_content = '', $post_parent = 0) { |
|
| 206 | 206 | global $wpdb; |
| 207 | 207 | |
| 208 | - $page_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) ); |
|
| 209 | - if ( $page_id ) : |
|
| 208 | + $page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", $slug)); |
|
| 209 | + if ($page_id) : |
|
| 210 | 210 | return $page_id; |
| 211 | 211 | endif; |
| 212 | 212 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | 'comment_status' => 'closed' |
| 222 | 222 | ); |
| 223 | 223 | |
| 224 | - $page_id = wp_insert_post( $page_data ); |
|
| 224 | + $page_id = wp_insert_post($page_data); |
|
| 225 | 225 | |
| 226 | 226 | return $page_id; |
| 227 | 227 | |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | function create_pages() { |
| 238 | 238 | |
| 239 | 239 | // Courses page |
| 240 | - $new_course_page_id = $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), __('Courses', 'woothemes-sensei'), '' ); |
|
| 241 | - Sensei()->settings->set( 'course_page', $new_course_page_id ); |
|
| 240 | + $new_course_page_id = $this->create_page(esc_sql(_x('courses-overview', 'page_slug', 'woothemes-sensei')), __('Courses', 'woothemes-sensei'), ''); |
|
| 241 | + Sensei()->settings->set('course_page', $new_course_page_id); |
|
| 242 | 242 | |
| 243 | 243 | // User Dashboard page |
| 244 | - $new_my_course_page_id = $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]' ); |
|
| 245 | - Sensei()->settings->set( 'my_course_page',$new_my_course_page_id ); |
|
| 244 | + $new_my_course_page_id = $this->create_page(esc_sql(_x('my-courses', 'page_slug', 'woothemes-sensei')), __('My Courses', 'woothemes-sensei'), '[sensei_user_courses]'); |
|
| 245 | + Sensei()->settings->set('my_course_page', $new_my_course_page_id); |
|
| 246 | 246 | |
| 247 | 247 | } // End create_pages() |
| 248 | 248 | |
@@ -252,25 +252,25 @@ discard block |
||
| 252 | 252 | * @since 1.0.0 |
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | - public function admin_styles_global ( $hook ) { |
|
| 255 | + public function admin_styles_global($hook) { |
|
| 256 | 256 | global $post_type; |
| 257 | 257 | |
| 258 | - $allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) ); |
|
| 259 | - $allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) ); |
|
| 260 | - $allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order' ) ); |
|
| 258 | + $allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question')); |
|
| 259 | + $allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php')); |
|
| 260 | + $allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order', 'course-order')); |
|
| 261 | 261 | |
| 262 | 262 | // Global Styles for icons and menu items |
| 263 | - wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); |
|
| 264 | - wp_enqueue_style( 'woothemes-sensei-global' ); |
|
| 263 | + wp_register_style('woothemes-sensei-global', Sensei()->plugin_url.'assets/css/global.css', '', Sensei()->version, 'screen'); |
|
| 264 | + wp_enqueue_style('woothemes-sensei-global'); |
|
| 265 | 265 | |
| 266 | 266 | // Select 2 styles |
| 267 | - wp_enqueue_style( 'sensei-core-select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
| 267 | + wp_enqueue_style('sensei-core-select2', Sensei()->plugin_url.'assets/css/select2/select2.css', '', Sensei()->version, 'screen'); |
|
| 268 | 268 | |
| 269 | 269 | // Test for Write Panel Pages |
| 270 | - 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 ) ) ) { |
|
| 270 | + 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))) { |
|
| 271 | 271 | |
| 272 | - wp_register_style( 'woothemes-sensei-admin-custom', Sensei()->plugin_url . 'assets/css/admin-custom.css', '', Sensei()->version, 'screen' ); |
|
| 273 | - wp_enqueue_style( 'woothemes-sensei-admin-custom' ); |
|
| 272 | + wp_register_style('woothemes-sensei-admin-custom', Sensei()->plugin_url.'assets/css/admin-custom.css', '', Sensei()->version, 'screen'); |
|
| 273 | + wp_enqueue_style('woothemes-sensei-admin-custom'); |
|
| 274 | 274 | |
| 275 | 275 | } |
| 276 | 276 | |
@@ -285,20 +285,20 @@ discard block |
||
| 285 | 285 | * @since 1.8.2 |
| 286 | 286 | * @access public |
| 287 | 287 | */ |
| 288 | - public function register_scripts( $hook ){ |
|
| 288 | + public function register_scripts($hook) { |
|
| 289 | 289 | |
| 290 | 290 | $screen = get_current_screen(); |
| 291 | 291 | |
| 292 | 292 | // Allow developers to load non-minified versions of scripts |
| 293 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 293 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 294 | 294 | |
| 295 | 295 | // Select2 script used to enhance all select boxes |
| 296 | - wp_register_script( 'sensei-core-select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
| 296 | + wp_register_script('sensei-core-select2', Sensei()->plugin_url.'/assets/js/select2/select2'.$suffix.'.js', array('jquery'), Sensei()->version); |
|
| 297 | 297 | |
| 298 | 298 | // load edit module scripts |
| 299 | - if( 'edit-module' == $screen->id ){ |
|
| 299 | + if ('edit-module' == $screen->id) { |
|
| 300 | 300 | |
| 301 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
| 301 | + wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery.min.js', array('jquery', 'sensei-chosen'), Sensei()->version, true); |
|
| 302 | 302 | |
| 303 | 303 | } |
| 304 | 304 | |
@@ -316,19 +316,19 @@ discard block |
||
| 316 | 316 | <div id="message" class="updated sensei-message sensei-connect"> |
| 317 | 317 | |
| 318 | 318 | <p> |
| 319 | - <?php _e( '<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei' ); ?> |
|
| 319 | + <?php _e('<strong>Welcome to Sensei</strong> – You\'re almost ready to create some courses!', 'woothemes-sensei'); ?> |
|
| 320 | 320 | </p> |
| 321 | 321 | |
| 322 | 322 | <p class="submit"> |
| 323 | 323 | |
| 324 | - <a href="<?php echo esc_url( add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings') ) ); ?>" |
|
| 324 | + <a href="<?php echo esc_url(add_query_arg('install_sensei_pages', 'true', admin_url('admin.php?page=woothemes-sensei-settings'))); ?>" |
|
| 325 | 325 | class="button-primary"> |
| 326 | 326 | |
| 327 | - <?php _e( 'Install Sensei Pages', 'woothemes-sensei' ); ?> |
|
| 327 | + <?php _e('Install Sensei Pages', 'woothemes-sensei'); ?> |
|
| 328 | 328 | |
| 329 | 329 | </a> |
| 330 | 330 | |
| 331 | - <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' ) ) ); ?>"> |
|
| 331 | + <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'))); ?>"> |
|
| 332 | 332 | |
| 333 | 333 | <?php _e('Skip setup', 'woothemes-sensei'); ?> |
| 334 | 334 | |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | <div id="message" class="updated sensei-message sensei-connect"> |
| 352 | 352 | |
| 353 | 353 | <p> |
| 354 | - <?php _e( '<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei' ); ?> |
|
| 354 | + <?php _e('<strong>Sensei has been installed</strong> – You\'re ready to start creating courses!', 'woothemes-sensei'); ?> |
|
| 355 | 355 | </p> |
| 356 | 356 | |
| 357 | 357 | <p class="submit"> |
| 358 | - <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/"> |
|
| 358 | + <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/"> |
|
| 359 | 359 | <?php _e('Documentation', 'woothemes-sensei'); ?> |
| 360 | 360 | </a> |
| 361 | 361 | </p> |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | public function language_pack_install_notice() { |
| 389 | 389 | ?> |
| 390 | 390 | <div id="message" class="updated sensei-message sensei-connect"> |
| 391 | - <p><?php _e( '<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei' ); ?><p> |
|
| 391 | + <p><?php _e('<strong>Sensei in your language</strong> – There is a translation available for your language.', 'woothemes-sensei'); ?><p> |
|
| 392 | 392 | |
| 393 | 393 | <p class="submit"> |
| 394 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_install_uri() ); ?>" class="button-primary"><?php _e( 'Install', 'woothemes-sensei' ); ?></a> |
|
| 395 | - <a href="<?php echo esc_url( Sensei_Language_Pack_Manager::get_dismiss_uri() ) ?>" class="docs button"><?php _e( 'Hide this notice', 'woothemes-sensei' ); ?></a> |
|
| 394 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_install_uri()); ?>" class="button-primary"><?php _e('Install', 'woothemes-sensei'); ?></a> |
|
| 395 | + <a href="<?php echo esc_url(Sensei_Language_Pack_Manager::get_dismiss_uri()) ?>" class="docs button"><?php _e('Hide this notice', 'woothemes-sensei'); ?></a> |
|
| 396 | 396 | </p> |
| 397 | 397 | </div> |
| 398 | 398 | <?php |
@@ -408,20 +408,20 @@ discard block |
||
| 408 | 408 | function admin_notices_styles() { |
| 409 | 409 | |
| 410 | 410 | // Installed notices |
| 411 | - if ( 1 == get_option( 'sensei_installed' ) ) { |
|
| 411 | + if (1 == get_option('sensei_installed')) { |
|
| 412 | 412 | |
| 413 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
| 413 | + wp_enqueue_style('sensei-activation', plugins_url('/assets/css/activation.css', dirname(__FILE__)), '', Sensei()->version); |
|
| 414 | 414 | |
| 415 | - 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'])) { |
|
| 416 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
| 417 | - } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
| 418 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
| 415 | + 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'])) { |
|
| 416 | + add_action('admin_notices', array($this, 'admin_install_notice')); |
|
| 417 | + } elseif ( ! isset($_GET['page']) || $_GET['page'] != 'woothemes-sensei-settings') { |
|
| 418 | + add_action('admin_notices', array($this, 'admin_installed_notice')); |
|
| 419 | 419 | } // End If Statement |
| 420 | 420 | |
| 421 | 421 | } // End If Statement |
| 422 | 422 | |
| 423 | - if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
| 424 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
| 423 | + if (Sensei_Language_Pack_Manager::has_language_pack_available()) { |
|
| 424 | + add_action('admin_notices', array($this, 'language_pack_install_notice')); |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | } // End admin_notices_styles() |
@@ -432,17 +432,17 @@ discard block |
||
| 432 | 432 | * @param object $post Current post |
| 433 | 433 | * @return array Modified actions |
| 434 | 434 | */ |
| 435 | - public function duplicate_action_link( $actions, $post ) { |
|
| 436 | - switch( $post->post_type ) { |
|
| 435 | + public function duplicate_action_link($actions, $post) { |
|
| 436 | + switch ($post->post_type) { |
|
| 437 | 437 | case 'lesson': |
| 438 | - $confirm = __( 'This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei' ); |
|
| 439 | - $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>"; |
|
| 438 | + $confirm = __('This will duplicate the lesson quiz and all of its questions. Are you sure you want to do this?', 'woothemes-sensei'); |
|
| 439 | + $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>"; |
|
| 440 | 440 | break; |
| 441 | 441 | |
| 442 | 442 | case 'course': |
| 443 | - $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' ); |
|
| 444 | - $actions['duplicate'] = '<a href="' . $this->get_duplicate_link( $post->ID ) . '" title="' . esc_attr(__( 'Duplicate this course', 'woothemes-sensei' ) ) . '">' . __('Duplicate', 'woothemes-sensei' ) . '</a>'; |
|
| 445 | - $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>'; |
|
| 443 | + $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'); |
|
| 444 | + $actions['duplicate'] = '<a href="'.$this->get_duplicate_link($post->ID).'" title="'.esc_attr(__('Duplicate this course', 'woothemes-sensei')).'">'.__('Duplicate', 'woothemes-sensei').'</a>'; |
|
| 445 | + $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>'; |
|
| 446 | 446 | break; |
| 447 | 447 | } |
| 448 | 448 | |
@@ -455,17 +455,17 @@ discard block |
||
| 455 | 455 | * @param boolean $with_lessons Include lessons or not |
| 456 | 456 | * @return string Duplication link |
| 457 | 457 | */ |
| 458 | - private function get_duplicate_link( $post_id = 0, $with_lessons = false ) { |
|
| 458 | + private function get_duplicate_link($post_id = 0, $with_lessons = false) { |
|
| 459 | 459 | |
| 460 | - $post = get_post( $post_id ); |
|
| 460 | + $post = get_post($post_id); |
|
| 461 | 461 | |
| 462 | - $action = 'duplicate_' . $post->post_type; |
|
| 462 | + $action = 'duplicate_'.$post->post_type; |
|
| 463 | 463 | |
| 464 | - if( 'course' == $post->post_type && $with_lessons ) { |
|
| 464 | + if ('course' == $post->post_type && $with_lessons) { |
|
| 465 | 465 | $action .= '_with_lessons'; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - return apply_filters( $action . '_link', admin_url( 'admin.php?action=' . $action . '&post=' . $post_id ), $post_id ); |
|
| 468 | + return apply_filters($action.'_link', admin_url('admin.php?action='.$action.'&post='.$post_id), $post_id); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | 475 | public function duplicate_lesson_action() { |
| 476 | - $this->duplicate_content( 'lesson' ); |
|
| 476 | + $this->duplicate_content('lesson'); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | /** |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | * @return void |
| 482 | 482 | */ |
| 483 | 483 | public function duplicate_course_action() { |
| 484 | - $this->duplicate_content( 'course' ); |
|
| 484 | + $this->duplicate_content('course'); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | * @return void |
| 490 | 490 | */ |
| 491 | 491 | public function duplicate_course_with_lessons_action() { |
| 492 | - $this->duplicate_content( 'course', true ); |
|
| 492 | + $this->duplicate_content('course', true); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -498,34 +498,34 @@ discard block |
||
| 498 | 498 | * @param boolean $with_lessons Include lessons or not |
| 499 | 499 | * @return void |
| 500 | 500 | */ |
| 501 | - private function duplicate_content( $post_type = 'lesson', $with_lessons = false ) { |
|
| 502 | - if ( ! isset( $_GET['post'] ) ) { |
|
| 503 | - wp_die( sprintf( __( 'Please supply a %1$s ID.', 'woothemes-sensei' ) ), $post_type ); |
|
| 501 | + private function duplicate_content($post_type = 'lesson', $with_lessons = false) { |
|
| 502 | + if ( ! isset($_GET['post'])) { |
|
| 503 | + wp_die(sprintf(__('Please supply a %1$s ID.', 'woothemes-sensei')), $post_type); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $post_id = $_GET['post']; |
| 507 | - $post = get_post( $post_id ); |
|
| 507 | + $post = get_post($post_id); |
|
| 508 | 508 | |
| 509 | - if( ! is_wp_error( $post ) ) { |
|
| 509 | + if ( ! is_wp_error($post)) { |
|
| 510 | 510 | |
| 511 | - $new_post = $this->duplicate_post( $post ); |
|
| 511 | + $new_post = $this->duplicate_post($post); |
|
| 512 | 512 | |
| 513 | - if( $new_post && ! is_wp_error( $new_post ) ) { |
|
| 513 | + if ($new_post && ! is_wp_error($new_post)) { |
|
| 514 | 514 | |
| 515 | - if( 'lesson' == $new_post->post_type ) { |
|
| 516 | - $this->duplicate_lesson_quizzes( $post_id, $new_post->ID ); |
|
| 515 | + if ('lesson' == $new_post->post_type) { |
|
| 516 | + $this->duplicate_lesson_quizzes($post_id, $new_post->ID); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - if( 'course' == $new_post->post_type && $with_lessons ) { |
|
| 520 | - $this->duplicate_course_lessons( $post_id, $new_post->ID ); |
|
| 519 | + if ('course' == $new_post->post_type && $with_lessons) { |
|
| 520 | + $this->duplicate_course_lessons($post_id, $new_post->ID); |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - $redirect_url = admin_url( 'post.php?post=' . $new_post->ID . '&action=edit' ); |
|
| 523 | + $redirect_url = admin_url('post.php?post='.$new_post->ID.'&action=edit'); |
|
| 524 | 524 | } else { |
| 525 | - $redirect_url = admin_url( 'edit.php?post_type=' . $post->post_type . '&message=duplicate_failed' ); |
|
| 525 | + $redirect_url = admin_url('edit.php?post_type='.$post->post_type.'&message=duplicate_failed'); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); |
|
| 528 | + wp_safe_redirect(esc_url_raw($redirect_url)); |
|
| 529 | 529 | exit; |
| 530 | 530 | } |
| 531 | 531 | } |
@@ -536,19 +536,19 @@ discard block |
||
| 536 | 536 | * @param integer $new_lesson_id ID of duplicate lesson |
| 537 | 537 | * @return void |
| 538 | 538 | */ |
| 539 | - private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { |
|
| 539 | + private function duplicate_lesson_quizzes($old_lesson_id, $new_lesson_id) { |
|
| 540 | 540 | |
| 541 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
| 542 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
| 541 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes($old_lesson_id); |
|
| 542 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions($old_quiz_id); |
|
| 543 | 543 | |
| 544 | 544 | // duplicate the generic wp post information |
| 545 | - $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); |
|
| 545 | + $new_quiz = $this->duplicate_post(get_post($old_quiz_id), ''); |
|
| 546 | 546 | |
| 547 | 547 | //update the new lesson data |
| 548 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
| 548 | + add_post_meta($new_lesson_id, '_lesson_quiz', $new_quiz->ID); |
|
| 549 | 549 | |
| 550 | 550 | //update the new quiz data |
| 551 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
| 551 | + add_post_meta($new_quiz->ID, '_quiz_lesson', $new_lesson_id); |
|
| 552 | 552 | wp_update_post( |
| 553 | 553 | array( |
| 554 | 554 | 'ID' => $new_quiz->ID, |
@@ -556,15 +556,15 @@ discard block |
||
| 556 | 556 | ) |
| 557 | 557 | ); |
| 558 | 558 | |
| 559 | - foreach( $old_quiz_questions as $question ) { |
|
| 559 | + foreach ($old_quiz_questions as $question) { |
|
| 560 | 560 | |
| 561 | 561 | // copy the question order over to the new quiz |
| 562 | - $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); |
|
| 563 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
| 564 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
| 562 | + $old_question_order = get_post_meta($question->ID, '_quiz_question_order'.$old_quiz_id, true); |
|
| 563 | + $new_question_order = str_ireplace($old_quiz_id, $new_quiz->ID, $old_question_order); |
|
| 564 | + add_post_meta($question->ID, '_quiz_question_order'.$new_quiz->ID, $new_question_order); |
|
| 565 | 565 | |
| 566 | 566 | // Add question to quiz |
| 567 | - add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); |
|
| 567 | + add_post_meta($question->ID, '_quiz_id', $new_quiz->ID, false); |
|
| 568 | 568 | |
| 569 | 569 | } |
| 570 | 570 | } |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | * @param integer $new_course_id ID of duplicated course |
| 576 | 576 | * @return void |
| 577 | 577 | */ |
| 578 | - private function duplicate_course_lessons( $old_course_id, $new_course_id ) { |
|
| 578 | + private function duplicate_course_lessons($old_course_id, $new_course_id) { |
|
| 579 | 579 | $lesson_args = array( |
| 580 | 580 | 'post_type' => 'lesson', |
| 581 | 581 | 'posts_per_page' => -1, |
@@ -583,13 +583,13 @@ discard block |
||
| 583 | 583 | 'meta_value' => $old_course_id, |
| 584 | 584 | 'suppress_filters' => 0 |
| 585 | 585 | ); |
| 586 | - $lessons = get_posts( $lesson_args ); |
|
| 586 | + $lessons = get_posts($lesson_args); |
|
| 587 | 587 | |
| 588 | - foreach( $lessons as $lesson ) { |
|
| 589 | - $new_lesson = $this->duplicate_post( $lesson, '', true ); |
|
| 590 | - add_post_meta( $new_lesson->ID, '_lesson_course', $new_course_id ); |
|
| 588 | + foreach ($lessons as $lesson) { |
|
| 589 | + $new_lesson = $this->duplicate_post($lesson, '', true); |
|
| 590 | + add_post_meta($new_lesson->ID, '_lesson_course', $new_course_id); |
|
| 591 | 591 | |
| 592 | - $this->duplicate_lesson_quizzes( $lesson->ID, $new_lesson->ID ); |
|
| 592 | + $this->duplicate_lesson_quizzes($lesson->ID, $new_lesson->ID); |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | |
@@ -600,24 +600,24 @@ discard block |
||
| 600 | 600 | * @param boolean $ignore_course Ignore lesson course when dulicating |
| 601 | 601 | * @return object Duplicate post object |
| 602 | 602 | */ |
| 603 | - private function duplicate_post( $post, $suffix = ' (Duplicate)', $ignore_course = false ) { |
|
| 603 | + private function duplicate_post($post, $suffix = ' (Duplicate)', $ignore_course = false) { |
|
| 604 | 604 | |
| 605 | 605 | $new_post = array(); |
| 606 | 606 | |
| 607 | - foreach( $post as $k => $v ) { |
|
| 608 | - if( ! in_array( $k, array( 'ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count' ) ) ) { |
|
| 609 | - $new_post[ $k ] = $v; |
|
| 607 | + foreach ($post as $k => $v) { |
|
| 608 | + if ( ! in_array($k, array('ID', 'post_status', 'post_date', 'post_date_gmt', 'post_name', 'post_modified', 'post_modified_gmt', 'guid', 'comment_count'))) { |
|
| 609 | + $new_post[$k] = $v; |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | |
| 613 | - $new_post['post_title'] .= __( $suffix, 'woothemes-sensei' ); |
|
| 613 | + $new_post['post_title'] .= __($suffix, 'woothemes-sensei'); |
|
| 614 | 614 | |
| 615 | - $new_post['post_date'] = current_time( 'mysql' ); |
|
| 616 | - $new_post['post_date_gmt'] = get_gmt_from_date( $new_post['post_date'] ); |
|
| 615 | + $new_post['post_date'] = current_time('mysql'); |
|
| 616 | + $new_post['post_date_gmt'] = get_gmt_from_date($new_post['post_date']); |
|
| 617 | 617 | $new_post['post_modified'] = $new_post['post_date']; |
| 618 | 618 | $new_post['post_modified_gmt'] = $new_post['post_date_gmt']; |
| 619 | 619 | |
| 620 | - switch( $post->post_type ) { |
|
| 620 | + switch ($post->post_type) { |
|
| 621 | 621 | case 'course': $new_post['post_status'] = 'draft'; break; |
| 622 | 622 | case 'lesson': $new_post['post_status'] = 'draft'; break; |
| 623 | 623 | case 'quiz': $new_post['post_status'] = 'publish'; break; |
@@ -625,45 +625,45 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // As per wp_update_post() we need to escape the data from the db. |
| 628 | - $new_post = wp_slash( $new_post ); |
|
| 628 | + $new_post = wp_slash($new_post); |
|
| 629 | 629 | |
| 630 | - $new_post_id = wp_insert_post( $new_post ); |
|
| 630 | + $new_post_id = wp_insert_post($new_post); |
|
| 631 | 631 | |
| 632 | - if( ! is_wp_error( $new_post_id ) ) { |
|
| 632 | + if ( ! is_wp_error($new_post_id)) { |
|
| 633 | 633 | |
| 634 | - $post_meta = get_post_custom( $post->ID ); |
|
| 635 | - if( $post_meta && count( $post_meta ) > 0 ) { |
|
| 634 | + $post_meta = get_post_custom($post->ID); |
|
| 635 | + if ($post_meta && count($post_meta) > 0) { |
|
| 636 | 636 | |
| 637 | - $ignore_meta = array( '_quiz_lesson', '_quiz_id', '_lesson_quiz' ); |
|
| 637 | + $ignore_meta = array('_quiz_lesson', '_quiz_id', '_lesson_quiz'); |
|
| 638 | 638 | |
| 639 | - if( $ignore_course ) { |
|
| 639 | + if ($ignore_course) { |
|
| 640 | 640 | $ignore_meta[] = '_lesson_course'; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - foreach( $post_meta as $key => $meta ) { |
|
| 644 | - foreach( $meta as $value ) { |
|
| 645 | - $value = maybe_unserialize( $value ); |
|
| 646 | - if( ! in_array( $key, $ignore_meta ) ) { |
|
| 647 | - add_post_meta( $new_post_id, $key, $value ); |
|
| 643 | + foreach ($post_meta as $key => $meta) { |
|
| 644 | + foreach ($meta as $value) { |
|
| 645 | + $value = maybe_unserialize($value); |
|
| 646 | + if ( ! in_array($key, $ignore_meta)) { |
|
| 647 | + add_post_meta($new_post_id, $key, $value); |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - add_post_meta( $new_post_id, '_duplicate', $post->ID ); |
|
| 653 | + add_post_meta($new_post_id, '_duplicate', $post->ID); |
|
| 654 | 654 | |
| 655 | - $taxonomies = get_object_taxonomies( $post->post_type, 'objects' ); |
|
| 655 | + $taxonomies = get_object_taxonomies($post->post_type, 'objects'); |
|
| 656 | 656 | |
| 657 | - foreach ( $taxonomies as $slug => $tax ) { |
|
| 658 | - $terms = get_the_terms( $post->ID, $slug ); |
|
| 659 | - if( isset( $terms ) && is_array( $terms ) && 0 < count( $terms ) ) { |
|
| 660 | - foreach( $terms as $term ) { |
|
| 661 | - wp_set_object_terms( $new_post_id, $term->term_id, $slug, true ); |
|
| 657 | + foreach ($taxonomies as $slug => $tax) { |
|
| 658 | + $terms = get_the_terms($post->ID, $slug); |
|
| 659 | + if (isset($terms) && is_array($terms) && 0 < count($terms)) { |
|
| 660 | + foreach ($terms as $term) { |
|
| 661 | + wp_set_object_terms($new_post_id, $term->term_id, $slug, true); |
|
| 662 | 662 | } |
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - $new_post = get_post( $new_post_id ); |
|
| 666 | + $new_post = get_post($new_post_id); |
|
| 667 | 667 | |
| 668 | 668 | return $new_post; |
| 669 | 669 | } |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | public function lesson_filter_options() { |
| 679 | 679 | global $typenow; |
| 680 | 680 | |
| 681 | - if( is_admin() && 'lesson' == $typenow ) { |
|
| 681 | + if (is_admin() && 'lesson' == $typenow) { |
|
| 682 | 682 | |
| 683 | 683 | $args = array( |
| 684 | 684 | 'post_type' => 'course', |
@@ -688,16 +688,16 @@ discard block |
||
| 688 | 688 | 'orderby' => 'menu_order date', |
| 689 | 689 | 'order' => 'ASC', |
| 690 | 690 | ); |
| 691 | - $courses = get_posts( $args ); |
|
| 691 | + $courses = get_posts($args); |
|
| 692 | 692 | |
| 693 | - $selected = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
| 693 | + $selected = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
| 694 | 694 | $course_options = ''; |
| 695 | - foreach( $courses as $course ) { |
|
| 696 | - $course_options .= '<option value="' . esc_attr( $course->ID ) . '" ' . selected( $selected, $course->ID, false ) . '>' . get_the_title( $course->ID ) . '</option>'; |
|
| 695 | + foreach ($courses as $course) { |
|
| 696 | + $course_options .= '<option value="'.esc_attr($course->ID).'" '.selected($selected, $course->ID, false).'>'.get_the_title($course->ID).'</option>'; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | $output = '<select name="lesson_course" id="dropdown_lesson_course">'; |
| 700 | - $output .= '<option value="">'.__( 'Show all courses', 'woothemes-sensei' ).'</option>'; |
|
| 700 | + $output .= '<option value="">'.__('Show all courses', 'woothemes-sensei').'</option>'; |
|
| 701 | 701 | $output .= $course_options; |
| 702 | 702 | $output .= '</select>'; |
| 703 | 703 | |
@@ -710,13 +710,13 @@ discard block |
||
| 710 | 710 | * @param array $request Current request |
| 711 | 711 | * @return array Modified request |
| 712 | 712 | */ |
| 713 | - public function lesson_filter_actions( $request ) { |
|
| 713 | + public function lesson_filter_actions($request) { |
|
| 714 | 714 | global $typenow; |
| 715 | 715 | |
| 716 | - if( is_admin() && 'lesson' == $typenow ) { |
|
| 717 | - $lesson_course = isset( $_GET['lesson_course'] ) ? $_GET['lesson_course'] : ''; |
|
| 716 | + if (is_admin() && 'lesson' == $typenow) { |
|
| 717 | + $lesson_course = isset($_GET['lesson_course']) ? $_GET['lesson_course'] : ''; |
|
| 718 | 718 | |
| 719 | - if( $lesson_course ) { |
|
| 719 | + if ($lesson_course) { |
|
| 720 | 720 | $request['meta_key'] = '_lesson_course'; |
| 721 | 721 | $request['meta_value'] = $lesson_course; |
| 722 | 722 | $request['meta_compare'] = '='; |
@@ -731,27 +731,27 @@ discard block |
||
| 731 | 731 | * @param array $items Existing items |
| 732 | 732 | * @return array Updated items |
| 733 | 733 | */ |
| 734 | - public function glance_items( $items = array() ) { |
|
| 734 | + public function glance_items($items = array()) { |
|
| 735 | 735 | |
| 736 | - $types = array( 'course', 'lesson', 'question' ); |
|
| 736 | + $types = array('course', 'lesson', 'question'); |
|
| 737 | 737 | |
| 738 | - foreach( $types as $type ) { |
|
| 739 | - if( ! post_type_exists( $type ) ) continue; |
|
| 738 | + foreach ($types as $type) { |
|
| 739 | + if ( ! post_type_exists($type)) continue; |
|
| 740 | 740 | |
| 741 | - $num_posts = wp_count_posts( $type ); |
|
| 741 | + $num_posts = wp_count_posts($type); |
|
| 742 | 742 | |
| 743 | - if( $num_posts ) { |
|
| 743 | + if ($num_posts) { |
|
| 744 | 744 | |
| 745 | - $published = intval( $num_posts->publish ); |
|
| 746 | - $post_type = get_post_type_object( $type ); |
|
| 745 | + $published = intval($num_posts->publish); |
|
| 746 | + $post_type = get_post_type_object($type); |
|
| 747 | 747 | |
| 748 | - $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $published, 'woothemes-sensei' ); |
|
| 749 | - $text = sprintf( $text, number_format_i18n( $published ) ); |
|
| 748 | + $text = _n('%s '.$post_type->labels->singular_name, '%s '.$post_type->labels->name, $published, 'woothemes-sensei'); |
|
| 749 | + $text = sprintf($text, number_format_i18n($published)); |
|
| 750 | 750 | |
| 751 | - if ( current_user_can( $post_type->cap->edit_posts ) ) { |
|
| 752 | - $items[] = sprintf( '<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text ) . "\n"; |
|
| 751 | + if (current_user_can($post_type->cap->edit_posts)) { |
|
| 752 | + $items[] = sprintf('<a class="%1$s-count" href="edit.php?post_type=%1$s">%2$s</a>', $type, $text)."\n"; |
|
| 753 | 753 | } else { |
| 754 | - $items[] = sprintf( '<span class="%1$s-count">%2$s</span>', $type, $text ) . "\n"; |
|
| 754 | + $items[] = sprintf('<span class="%1$s-count">%2$s</span>', $type, $text)."\n"; |
|
| 755 | 755 | } |
| 756 | 756 | } |
| 757 | 757 | } |
@@ -765,13 +765,13 @@ discard block |
||
| 765 | 765 | * @param object $post Post object |
| 766 | 766 | * @return void |
| 767 | 767 | */ |
| 768 | - public function delete_content( $post_id, $post ) { |
|
| 768 | + public function delete_content($post_id, $post) { |
|
| 769 | 769 | |
| 770 | 770 | $type = $post->post_type; |
| 771 | 771 | |
| 772 | - if( in_array( $type, array( 'lesson', 'course' ) ) ) { |
|
| 772 | + if (in_array($type, array('lesson', 'course'))) { |
|
| 773 | 773 | |
| 774 | - $meta_key = '_' . $type . '_prerequisite'; |
|
| 774 | + $meta_key = '_'.$type.'_prerequisite'; |
|
| 775 | 775 | |
| 776 | 776 | $args = array( |
| 777 | 777 | 'post_type' => $type, |
@@ -781,10 +781,10 @@ discard block |
||
| 781 | 781 | 'meta_value' => $post_id |
| 782 | 782 | ); |
| 783 | 783 | |
| 784 | - $posts = get_posts( $args ); |
|
| 784 | + $posts = get_posts($args); |
|
| 785 | 785 | |
| 786 | - foreach( $posts as $post ) { |
|
| 787 | - delete_post_meta( $post->ID, $meta_key ); |
|
| 786 | + foreach ($posts as $post) { |
|
| 787 | + delete_post_meta($post->ID, $meta_key); |
|
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | } |
@@ -794,181 +794,181 @@ discard block |
||
| 794 | 794 | * @param integer $user_id User ID |
| 795 | 795 | * @return void |
| 796 | 796 | */ |
| 797 | - public function delete_user_activity( $user_id = 0 ) { |
|
| 798 | - if( $user_id ) { |
|
| 799 | - Sensei_Utils::delete_all_user_activity( $user_id ); |
|
| 797 | + public function delete_user_activity($user_id = 0) { |
|
| 798 | + if ($user_id) { |
|
| 799 | + Sensei_Utils::delete_all_user_activity($user_id); |
|
| 800 | 800 | } |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | - public function render_settings( $settings = array(), $post_id = 0, $group_id = '' ) { |
|
| 803 | + public function render_settings($settings = array(), $post_id = 0, $group_id = '') { |
|
| 804 | 804 | |
| 805 | 805 | $html = ''; |
| 806 | 806 | |
| 807 | - if( 0 == count( $settings ) ) return $html; |
|
| 807 | + if (0 == count($settings)) return $html; |
|
| 808 | 808 | |
| 809 | - $html .= '<div class="sensei-options-panel">' . "\n"; |
|
| 809 | + $html .= '<div class="sensei-options-panel">'."\n"; |
|
| 810 | 810 | |
| 811 | - $html .= '<div class="options_group" id="' . esc_attr( $group_id ) . '">' . "\n"; |
|
| 811 | + $html .= '<div class="options_group" id="'.esc_attr($group_id).'">'."\n"; |
|
| 812 | 812 | |
| 813 | - foreach( $settings as $field ) { |
|
| 813 | + foreach ($settings as $field) { |
|
| 814 | 814 | |
| 815 | 815 | $data = ''; |
| 816 | 816 | |
| 817 | - if( $post_id ) { |
|
| 818 | - $data = get_post_meta( $post_id, '_' . $field['id'], true ); |
|
| 819 | - if( ! $data && isset( $field['default'] ) ) { |
|
| 817 | + if ($post_id) { |
|
| 818 | + $data = get_post_meta($post_id, '_'.$field['id'], true); |
|
| 819 | + if ( ! $data && isset($field['default'])) { |
|
| 820 | 820 | $data = $field['default']; |
| 821 | 821 | } |
| 822 | 822 | } else { |
| 823 | - $option = get_option( $field['id'] ); |
|
| 824 | - if( isset( $field['default'] ) ) { |
|
| 823 | + $option = get_option($field['id']); |
|
| 824 | + if (isset($field['default'])) { |
|
| 825 | 825 | $data = $field['default']; |
| 826 | - if( $option ) { |
|
| 826 | + if ($option) { |
|
| 827 | 827 | $data = $option; |
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $disabled = ''; |
| 833 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 834 | - $disabled = disabled( $field['disabled'], true, false ); |
|
| 833 | + if (isset($field['disabled']) && $field['disabled']) { |
|
| 834 | + $disabled = disabled($field['disabled'], true, false); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if( 'hidden' != $field['type'] ) { |
|
| 837 | + if ('hidden' != $field['type']) { |
|
| 838 | 838 | |
| 839 | 839 | $class_tail = ''; |
| 840 | 840 | |
| 841 | - if( isset( $field['class'] ) ) { |
|
| 841 | + if (isset($field['class'])) { |
|
| 842 | 842 | $class_tail .= $field['class']; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if( isset( $field['disabled'] ) && $field['disabled'] ) { |
|
| 845 | + if (isset($field['disabled']) && $field['disabled']) { |
|
| 846 | 846 | $class_tail .= ' disabled'; |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | - $html .= '<p class="form-field ' . esc_attr( $field['id'] ) . ' ' . esc_attr( $class_tail ) . '">' . "\n"; |
|
| 849 | + $html .= '<p class="form-field '.esc_attr($field['id']).' '.esc_attr($class_tail).'">'."\n"; |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
| 853 | - $html .= '<label for="' . esc_attr( $field['id'] ) . '">' . "\n"; |
|
| 852 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
| 853 | + $html .= '<label for="'.esc_attr($field['id']).'">'."\n"; |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | - if( $field['label'] ) { |
|
| 857 | - $html .= '<span class="label">' . esc_html( $field['label'] ) . '</span>'; |
|
| 856 | + if ($field['label']) { |
|
| 857 | + $html .= '<span class="label">'.esc_html($field['label']).'</span>'; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - switch( $field['type'] ) { |
|
| 860 | + switch ($field['type']) { |
|
| 861 | 861 | case 'text': |
| 862 | 862 | case 'password': |
| 863 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" placeholder="' . esc_attr( $field['placeholder'] ) . '" value="' . $data . '" ' . $disabled . ' />' . "\n"; |
|
| 863 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" placeholder="'.esc_attr($field['placeholder']).'" value="'.$data.'" '.$disabled.' />'."\n"; |
|
| 864 | 864 | break; |
| 865 | 865 | |
| 866 | 866 | case 'number': |
| 867 | 867 | |
| 868 | 868 | $min = ''; |
| 869 | - if( isset( $field['min'] ) ) { |
|
| 870 | - $min = 'min="' . esc_attr( $field['min'] ) . '"'; |
|
| 869 | + if (isset($field['min'])) { |
|
| 870 | + $min = 'min="'.esc_attr($field['min']).'"'; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | $max = ''; |
| 874 | - if( isset( $field['max'] ) ) { |
|
| 875 | - $max = 'max="' . esc_attr( $field['max'] ) . '"'; |
|
| 874 | + if (isset($field['max'])) { |
|
| 875 | + $max = 'max="'.esc_attr($field['max']).'"'; |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $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"; |
|
| 878 | + $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"; |
|
| 879 | 879 | break; |
| 880 | 880 | |
| 881 | 881 | case 'textarea': |
| 882 | - $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"; |
|
| 882 | + $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"; |
|
| 883 | 883 | break; |
| 884 | 884 | |
| 885 | 885 | case 'checkbox': |
| 886 | 886 | //backwards compatibility |
| 887 | - if( empty( $data ) || 'on' == $data ){ |
|
| 887 | + if (empty($data) || 'on' == $data) { |
|
| 888 | 888 | $checked_value = 'on'; |
| 889 | - }elseif( 'yes' == $data ) { |
|
| 889 | + }elseif ('yes' == $data) { |
|
| 890 | 890 | |
| 891 | 891 | $checked_value = 'yes'; |
| 892 | 892 | |
| 893 | - }elseif( 'auto' == $data ) { |
|
| 893 | + }elseif ('auto' == $data) { |
|
| 894 | 894 | |
| 895 | 895 | $checked_value = 'auto'; |
| 896 | 896 | |
| 897 | 897 | } else { |
| 898 | 898 | $checked_value = 1; |
| 899 | - $data = intval( $data ); |
|
| 899 | + $data = intval($data); |
|
| 900 | 900 | } |
| 901 | - $checked = checked( $checked_value, $data, false ); |
|
| 902 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; |
|
| 901 | + $checked = checked($checked_value, $data, false); |
|
| 902 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" '.$checked.' '.$disabled.'/>'."\n"; |
|
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | 905 | case 'checkbox_multi': |
| 906 | - foreach( $field['options'] as $k => $v ) { |
|
| 906 | + foreach ($field['options'] as $k => $v) { |
|
| 907 | 907 | $checked = false; |
| 908 | - if( in_array( $k, $data ) ) { |
|
| 908 | + if (in_array($k, $data)) { |
|
| 909 | 909 | $checked = true; |
| 910 | 910 | } |
| 911 | - $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"; |
|
| 911 | + $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"; |
|
| 912 | 912 | } |
| 913 | 913 | break; |
| 914 | 914 | |
| 915 | 915 | case 'radio': |
| 916 | - foreach( $field['options'] as $k => $v ) { |
|
| 916 | + foreach ($field['options'] as $k => $v) { |
|
| 917 | 917 | $checked = false; |
| 918 | - if( $k == $data ) { |
|
| 918 | + if ($k == $data) { |
|
| 919 | 919 | $checked = true; |
| 920 | 920 | } |
| 921 | - $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"; |
|
| 921 | + $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"; |
|
| 922 | 922 | } |
| 923 | 923 | break; |
| 924 | 924 | |
| 925 | 925 | case 'select': |
| 926 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '" id="' . esc_attr( $field['id'] ) . '" ' . $disabled . '>' . "\n"; |
|
| 927 | - foreach( $field['options'] as $k => $v ) { |
|
| 926 | + $html .= '<select name="'.esc_attr($field['id']).'" id="'.esc_attr($field['id']).'" '.$disabled.'>'."\n"; |
|
| 927 | + foreach ($field['options'] as $k => $v) { |
|
| 928 | 928 | $selected = false; |
| 929 | - if( $k == $data ) { |
|
| 929 | + if ($k == $data) { |
|
| 930 | 930 | $selected = true; |
| 931 | 931 | } |
| 932 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>' . "\n"; |
|
| 932 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'">'.$v.'</option>'."\n"; |
|
| 933 | 933 | } |
| 934 | - $html .= '</select><br/>' . "\n"; |
|
| 934 | + $html .= '</select><br/>'."\n"; |
|
| 935 | 935 | break; |
| 936 | 936 | |
| 937 | 937 | case 'select_multi': |
| 938 | - $html .= '<select name="' . esc_attr( $field['id'] ) . '[]" id="' . esc_attr( $field['id'] ) . '" multiple="multiple" ' . $disabled . '>' . "\n"; |
|
| 939 | - foreach( $field['options'] as $k => $v ) { |
|
| 938 | + $html .= '<select name="'.esc_attr($field['id']).'[]" id="'.esc_attr($field['id']).'" multiple="multiple" '.$disabled.'>'."\n"; |
|
| 939 | + foreach ($field['options'] as $k => $v) { |
|
| 940 | 940 | $selected = false; |
| 941 | - if( in_array( $k, $data ) ) { |
|
| 941 | + if (in_array($k, $data)) { |
|
| 942 | 942 | $selected = true; |
| 943 | 943 | } |
| 944 | - $html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '" />' . $v . '</option>' . "\n"; |
|
| 944 | + $html .= '<option '.selected($selected, true, false).' value="'.esc_attr($k).'" />'.$v.'</option>'."\n"; |
|
| 945 | 945 | } |
| 946 | 946 | $html .= '</select> . "\n"'; |
| 947 | 947 | break; |
| 948 | 948 | |
| 949 | 949 | case 'hidden': |
| 950 | - $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" value="' . $data . '" ' . $disabled . '/>' . "\n"; |
|
| 950 | + $html .= '<input id="'.esc_attr($field['id']).'" type="'.$field['type'].'" name="'.esc_attr($field['id']).'" value="'.$data.'" '.$disabled.'/>'."\n"; |
|
| 951 | 951 | break; |
| 952 | 952 | |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - if( $field['description'] ) { |
|
| 956 | - $html .= ' <span class="description">' . esc_html( $field['description'] ) . '</span>' . "\n"; |
|
| 955 | + if ($field['description']) { |
|
| 956 | + $html .= ' <span class="description">'.esc_html($field['description']).'</span>'."\n"; |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | - if( ! in_array( $field['type'], array( 'hidden', 'checkbox_multi', 'radio' ) ) ) { |
|
| 960 | - $html .= '</label>' . "\n"; |
|
| 959 | + if ( ! in_array($field['type'], array('hidden', 'checkbox_multi', 'radio'))) { |
|
| 960 | + $html .= '</label>'."\n"; |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if( 'hidden' != $field['type'] ) { |
|
| 964 | - $html .= '</p>' . "\n"; |
|
| 963 | + if ('hidden' != $field['type']) { |
|
| 964 | + $html .= '</p>'."\n"; |
|
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - $html .= '</div>' . "\n"; |
|
| 969 | + $html .= '</div>'."\n"; |
|
| 970 | 970 | |
| 971 | - $html .= '</div>' . "\n"; |
|
| 971 | + $html .= '</div>'."\n"; |
|
| 972 | 972 | |
| 973 | 973 | return $html; |
| 974 | 974 | } |
@@ -979,61 +979,61 @@ discard block |
||
| 979 | 979 | */ |
| 980 | 980 | public function course_order_screen() { |
| 981 | 981 | |
| 982 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 983 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
| 982 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 983 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
| 984 | 984 | |
| 985 | 985 | ?><div id="course-order" class="wrap course-order"> |
| 986 | - <h2><?php _e( 'Order Courses', 'woothemes-sensei' ); ?></h2><?php |
|
| 986 | + <h2><?php _e('Order Courses', 'woothemes-sensei'); ?></h2><?php |
|
| 987 | 987 | |
| 988 | 988 | $html = ''; |
| 989 | 989 | |
| 990 | - if( isset( $_POST['course-order'] ) && 0 < strlen( $_POST['course-order'] ) ) { |
|
| 991 | - $ordered = $this->save_course_order( esc_attr( $_POST['course-order'] ) ); |
|
| 990 | + if (isset($_POST['course-order']) && 0 < strlen($_POST['course-order'])) { |
|
| 991 | + $ordered = $this->save_course_order(esc_attr($_POST['course-order'])); |
|
| 992 | 992 | |
| 993 | - if( $ordered ) { |
|
| 994 | - $html .= '<div class="updated fade">' . "\n"; |
|
| 995 | - $html .= '<p>' . __( 'The course order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 996 | - $html .= '</div>' . "\n"; |
|
| 993 | + if ($ordered) { |
|
| 994 | + $html .= '<div class="updated fade">'."\n"; |
|
| 995 | + $html .= '<p>'.__('The course order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
| 996 | + $html .= '</div>'."\n"; |
|
| 997 | 997 | } |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | $courses = Sensei()->course->get_all_courses(); |
| 1001 | 1001 | |
| 1002 | - if( 0 < count( $courses ) ) { |
|
| 1002 | + if (0 < count($courses)) { |
|
| 1003 | 1003 | |
| 1004 | 1004 | // order the courses as set by the users |
| 1005 | 1005 | $all_course_ids = array(); |
| 1006 | - foreach( $courses as $course ){ |
|
| 1006 | + foreach ($courses as $course) { |
|
| 1007 | 1007 | |
| 1008 | - $all_course_ids[] = (string)$course->ID; |
|
| 1008 | + $all_course_ids[] = (string) $course->ID; |
|
| 1009 | 1009 | |
| 1010 | 1010 | } |
| 1011 | 1011 | $order_string = $this->get_course_order(); |
| 1012 | 1012 | |
| 1013 | - if( !empty( $order_string ) ){ |
|
| 1014 | - $ordered_course_ids = explode(',' , $order_string ); |
|
| 1015 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
| 1013 | + if ( ! empty($order_string)) { |
|
| 1014 | + $ordered_course_ids = explode(',', $order_string); |
|
| 1015 | + $all_course_ids = array_unique(array_merge($ordered_course_ids, $all_course_ids)); |
|
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | 1018 | |
| 1019 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
| 1020 | - $html .= '<ul class="sortable-course-list">' . "\n"; |
|
| 1019 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
| 1020 | + $html .= '<ul class="sortable-course-list">'."\n"; |
|
| 1021 | 1021 | $count = 0; |
| 1022 | - foreach ( $all_course_ids as $course_id ) { |
|
| 1023 | - $course = get_post( $course_id ); |
|
| 1022 | + foreach ($all_course_ids as $course_id) { |
|
| 1023 | + $course = get_post($course_id); |
|
| 1024 | 1024 | $count++; |
| 1025 | 1025 | $class = 'course'; |
| 1026 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1027 | - if ( $count == count( $course ) ) { $class .= ' last'; } |
|
| 1028 | - if ( $count % 2 != 0 ) { |
|
| 1026 | + if ($count == 1) { $class .= ' first'; } |
|
| 1027 | + if ($count == count($course)) { $class .= ' last'; } |
|
| 1028 | + if ($count % 2 != 0) { |
|
| 1029 | 1029 | $class .= ' alternate'; |
| 1030 | 1030 | } |
| 1031 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $course->ID ) . '" style="width: 100%;"> ' . $course->post_title . '</span></li>' . "\n"; |
|
| 1031 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($course->ID).'" style="width: 100%;"> '.$course->post_title.'</span></li>'."\n"; |
|
| 1032 | 1032 | } |
| 1033 | - $html .= '</ul>' . "\n"; |
|
| 1033 | + $html .= '</ul>'."\n"; |
|
| 1034 | 1034 | |
| 1035 | - $html .= '<input type="hidden" name="course-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
| 1036 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save course order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1035 | + $html .= '<input type="hidden" name="course-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
| 1036 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save course order', 'woothemes-sensei').'" />'."\n"; |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | echo $html; |
@@ -1042,25 +1042,25 @@ discard block |
||
| 1042 | 1042 | } |
| 1043 | 1043 | |
| 1044 | 1044 | public function get_course_order() { |
| 1045 | - return get_option( 'sensei_course_order', '' ); |
|
| 1045 | + return get_option('sensei_course_order', ''); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | - public function save_course_order( $order_string = '' ) { |
|
| 1049 | - $order = explode( ',', $order_string ); |
|
| 1048 | + public function save_course_order($order_string = '') { |
|
| 1049 | + $order = explode(',', $order_string); |
|
| 1050 | 1050 | |
| 1051 | - update_option( 'sensei_course_order', $order_string ); |
|
| 1051 | + update_option('sensei_course_order', $order_string); |
|
| 1052 | 1052 | |
| 1053 | 1053 | $i = 1; |
| 1054 | - foreach( $order as $course_id ) { |
|
| 1054 | + foreach ($order as $course_id) { |
|
| 1055 | 1055 | |
| 1056 | - if( $course_id ) { |
|
| 1056 | + if ($course_id) { |
|
| 1057 | 1057 | |
| 1058 | 1058 | $update_args = array( |
| 1059 | 1059 | 'ID' => $course_id, |
| 1060 | 1060 | 'menu_order' => $i, |
| 1061 | 1061 | ); |
| 1062 | 1062 | |
| 1063 | - wp_update_post( $update_args ); |
|
| 1063 | + wp_update_post($update_args); |
|
| 1064 | 1064 | |
| 1065 | 1065 | ++$i; |
| 1066 | 1066 | } |
@@ -1075,22 +1075,22 @@ discard block |
||
| 1075 | 1075 | */ |
| 1076 | 1076 | public function lesson_order_screen() { |
| 1077 | 1077 | |
| 1078 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1079 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'jquery-ui-sortable' ), Sensei()->version ); |
|
| 1078 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1079 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'jquery-ui-sortable'), Sensei()->version); |
|
| 1080 | 1080 | |
| 1081 | 1081 | ?><div id="lesson-order" class="wrap lesson-order"> |
| 1082 | - <h2><?php _e( 'Order Lessons', 'woothemes-sensei' ); ?></h2><?php |
|
| 1082 | + <h2><?php _e('Order Lessons', 'woothemes-sensei'); ?></h2><?php |
|
| 1083 | 1083 | |
| 1084 | 1084 | $html = ''; |
| 1085 | 1085 | |
| 1086 | - if( isset( $_POST['lesson-order'] ) ) { |
|
| 1086 | + if (isset($_POST['lesson-order'])) { |
|
| 1087 | 1087 | |
| 1088 | - $ordered = $this->save_lesson_order( esc_attr( $_POST['lesson-order'] ), esc_attr( $_POST['course_id'] ) ); |
|
| 1088 | + $ordered = $this->save_lesson_order(esc_attr($_POST['lesson-order']), esc_attr($_POST['course_id'])); |
|
| 1089 | 1089 | |
| 1090 | - if( $ordered ) { |
|
| 1091 | - $html .= '<div class="updated fade">' . "\n"; |
|
| 1092 | - $html .= '<p>' . __( 'The lesson order has been saved.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
| 1093 | - $html .= '</div>' . "\n"; |
|
| 1090 | + if ($ordered) { |
|
| 1091 | + $html .= '<div class="updated fade">'."\n"; |
|
| 1092 | + $html .= '<p>'.__('The lesson order has been saved.', 'woothemes-sensei').'</p>'."\n"; |
|
| 1093 | + $html .= '</div>'."\n"; |
|
| 1094 | 1094 | } |
| 1095 | 1095 | } |
| 1096 | 1096 | |
@@ -1101,43 +1101,43 @@ discard block |
||
| 1101 | 1101 | 'orderby' => 'name', |
| 1102 | 1102 | 'order' => 'ASC', |
| 1103 | 1103 | ); |
| 1104 | - $courses = get_posts( $args ); |
|
| 1104 | + $courses = get_posts($args); |
|
| 1105 | 1105 | |
| 1106 | - $html .= '<form action="' . admin_url( 'edit.php' ) . '" method="get">' . "\n"; |
|
| 1107 | - $html .= '<input type="hidden" name="post_type" value="lesson" />' . "\n"; |
|
| 1108 | - $html .= '<input type="hidden" name="page" value="lesson-order" />' . "\n"; |
|
| 1109 | - $html .= '<select id="lesson-order-course" name="course_id">' . "\n"; |
|
| 1110 | - $html .= '<option value="">' . __( 'Select a course', 'woothemes-sensei' ) . '</option>' . "\n"; |
|
| 1106 | + $html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n"; |
|
| 1107 | + $html .= '<input type="hidden" name="post_type" value="lesson" />'."\n"; |
|
| 1108 | + $html .= '<input type="hidden" name="page" value="lesson-order" />'."\n"; |
|
| 1109 | + $html .= '<select id="lesson-order-course" name="course_id">'."\n"; |
|
| 1110 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n"; |
|
| 1111 | 1111 | |
| 1112 | - foreach( $courses as $course ) { |
|
| 1112 | + foreach ($courses as $course) { |
|
| 1113 | 1113 | $course_id = ''; |
| 1114 | - if( isset( $_GET['course_id'] ) ) { |
|
| 1115 | - $course_id = intval( $_GET['course_id'] ); |
|
| 1114 | + if (isset($_GET['course_id'])) { |
|
| 1115 | + $course_id = intval($_GET['course_id']); |
|
| 1116 | 1116 | } |
| 1117 | - $html .= '<option value="' . esc_attr( intval( $course->ID ) ) . '" ' . selected( $course->ID, $course_id, false ) .'>' . get_the_title( $course->ID ) . '</option>' . "\n"; |
|
| 1117 | + $html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n"; |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - $html .= '</select>' . "\n"; |
|
| 1121 | - $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="' . __( 'Select', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1122 | - $html .= '</form>' . "\n"; |
|
| 1120 | + $html .= '</select>'."\n"; |
|
| 1121 | + $html .= '<input type="submit" class="button-primary lesson-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n"; |
|
| 1122 | + $html .= '</form>'."\n"; |
|
| 1123 | 1123 | |
| 1124 | - $html .= '<script type="text/javascript">' . "\n"; |
|
| 1125 | - $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});' . "\n"; |
|
| 1126 | - $html .= '</script>' . "\n"; |
|
| 1124 | + $html .= '<script type="text/javascript">'."\n"; |
|
| 1125 | + $html .= 'jQuery( \'#lesson-order-course\' ).select2({width:"resolve"});'."\n"; |
|
| 1126 | + $html .= '</script>'."\n"; |
|
| 1127 | 1127 | |
| 1128 | - if( isset( $_GET['course_id'] ) ) { |
|
| 1129 | - $course_id = intval( $_GET['course_id'] ); |
|
| 1130 | - if( $course_id > 0 ) { |
|
| 1128 | + if (isset($_GET['course_id'])) { |
|
| 1129 | + $course_id = intval($_GET['course_id']); |
|
| 1130 | + if ($course_id > 0) { |
|
| 1131 | 1131 | |
| 1132 | - $order_string = $this->get_lesson_order( $course_id ); |
|
| 1132 | + $order_string = $this->get_lesson_order($course_id); |
|
| 1133 | 1133 | |
| 1134 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
| 1134 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
| 1135 | 1135 | |
| 1136 | 1136 | $displayed_lessons = array(); |
| 1137 | 1137 | |
| 1138 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1138 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
| 1139 | 1139 | |
| 1140 | - foreach( $modules as $module ) { |
|
| 1140 | + foreach ($modules as $module) { |
|
| 1141 | 1141 | |
| 1142 | 1142 | $args = array( |
| 1143 | 1143 | 'post_type' => 'lesson', |
@@ -1146,7 +1146,7 @@ discard block |
||
| 1146 | 1146 | 'meta_query' => array( |
| 1147 | 1147 | array( |
| 1148 | 1148 | 'key' => '_lesson_course', |
| 1149 | - 'value' => intval( $course_id ), |
|
| 1149 | + 'value' => intval($course_id), |
|
| 1150 | 1150 | 'compare' => '=' |
| 1151 | 1151 | ) |
| 1152 | 1152 | ), |
@@ -1154,66 +1154,66 @@ discard block |
||
| 1154 | 1154 | array( |
| 1155 | 1155 | 'taxonomy' => Sensei()->modules->taxonomy, |
| 1156 | 1156 | 'field' => 'id', |
| 1157 | - 'terms' => intval( $module->term_id ) |
|
| 1157 | + 'terms' => intval($module->term_id) |
|
| 1158 | 1158 | ) |
| 1159 | 1159 | ), |
| 1160 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
| 1160 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
| 1161 | 1161 | 'orderby' => 'meta_value_num date', |
| 1162 | 1162 | 'order' => 'ASC', |
| 1163 | 1163 | 'suppress_filters' => 0 |
| 1164 | 1164 | ); |
| 1165 | 1165 | |
| 1166 | - $lessons = get_posts( $args ); |
|
| 1166 | + $lessons = get_posts($args); |
|
| 1167 | 1167 | |
| 1168 | - if( count( $lessons ) > 0 ) { |
|
| 1169 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
| 1170 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
| 1168 | + if (count($lessons) > 0) { |
|
| 1169 | + $html .= '<h3>'.$module->name.'</h3>'."\n"; |
|
| 1170 | + $html .= '<ul class="sortable-lesson-list" data-module_id="'.$module->term_id.'">'."\n"; |
|
| 1171 | 1171 | |
| 1172 | 1172 | $count = 0; |
| 1173 | - foreach( $lessons as $lesson ) { |
|
| 1173 | + foreach ($lessons as $lesson) { |
|
| 1174 | 1174 | $count++; |
| 1175 | 1175 | $class = 'lesson'; |
| 1176 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1177 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1178 | - if ( $count % 2 != 0 ) { |
|
| 1176 | + if ($count == 1) { $class .= ' first'; } |
|
| 1177 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
| 1178 | + if ($count % 2 != 0) { |
|
| 1179 | 1179 | $class .= ' alternate'; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1182 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
| 1183 | 1183 | |
| 1184 | 1184 | $displayed_lessons[] = $lesson->ID; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - $html .= '</ul>' . "\n"; |
|
| 1187 | + $html .= '</ul>'."\n"; |
|
| 1188 | 1188 | |
| 1189 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
| 1189 | + $html .= '<input type="hidden" name="lesson-order-module-'.$module->term_id.'" value="" />'."\n"; |
|
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | |
| 1194 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
| 1194 | + $lessons = Sensei()->course->course_lessons($course_id); |
|
| 1195 | 1195 | |
| 1196 | - if( 0 < count( $lessons ) ) { |
|
| 1196 | + if (0 < count($lessons)) { |
|
| 1197 | 1197 | |
| 1198 | 1198 | //get module term ids, will be used to exclude lessons |
| 1199 | 1199 | $module_items_ids = array(); |
| 1200 | - if( ! empty( $modules ) ) { |
|
| 1200 | + if ( ! empty($modules)) { |
|
| 1201 | 1201 | foreach ($modules as $module) { |
| 1202 | 1202 | $module_items_ids[] = $module->term_id; |
| 1203 | 1203 | } |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | - if( 0 < count( $displayed_lessons ) ) { |
|
| 1207 | - $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; |
|
| 1206 | + if (0 < count($displayed_lessons)) { |
|
| 1207 | + $html .= '<h3>'.__('Other Lessons', 'woothemes-sensei').'</h3>'."\n"; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | |
| 1210 | - $html .= '<ul class="sortable-lesson-list" data-module_id="0">' . "\n"; |
|
| 1210 | + $html .= '<ul class="sortable-lesson-list" data-module_id="0">'."\n"; |
|
| 1211 | 1211 | $count = 0; |
| 1212 | - foreach ( $lessons as $lesson ) { |
|
| 1212 | + foreach ($lessons as $lesson) { |
|
| 1213 | 1213 | |
| 1214 | 1214 | // if lesson belongs to one fo the course modules then exclude it here |
| 1215 | 1215 | // as it is listed above |
| 1216 | - if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
| 1216 | + if (has_term($module_items_ids, 'module', $lesson->ID)) { |
|
| 1217 | 1217 | |
| 1218 | 1218 | continue; |
| 1219 | 1219 | |
@@ -1221,28 +1221,28 @@ discard block |
||
| 1221 | 1221 | |
| 1222 | 1222 | $count++; |
| 1223 | 1223 | $class = 'lesson'; |
| 1224 | - if ( $count == 1 ) { $class .= ' first'; } |
|
| 1225 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
| 1226 | - if ( $count % 2 != 0 ) { |
|
| 1224 | + if ($count == 1) { $class .= ' first'; } |
|
| 1225 | + if ($count == count($lesson)) { $class .= ' last'; } |
|
| 1226 | + if ($count % 2 != 0) { |
|
| 1227 | 1227 | |
| 1228 | 1228 | $class .= ' alternate'; |
| 1229 | 1229 | |
| 1230 | 1230 | } |
| 1231 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
| 1231 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($lesson->ID).'" style="width: 100%;"> '.$lesson->post_title.'</span></li>'."\n"; |
|
| 1232 | 1232 | |
| 1233 | 1233 | $displayed_lessons[] = $lesson->ID; |
| 1234 | 1234 | } |
| 1235 | - $html .= '</ul>' . "\n"; |
|
| 1235 | + $html .= '</ul>'."\n"; |
|
| 1236 | 1236 | } else { |
| 1237 | - if( 0 == count( $displayed_lessons ) ) { |
|
| 1238 | - $html .= '<p><em>' . __( 'There are no lessons in this course.', 'woothemes-sensei' ) . '</em></p>'; |
|
| 1237 | + if (0 == count($displayed_lessons)) { |
|
| 1238 | + $html .= '<p><em>'.__('There are no lessons in this course.', 'woothemes-sensei').'</em></p>'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - if( 0 < count( $displayed_lessons ) ) { |
|
| 1243 | - $html .= '<input type="hidden" name="lesson-order" value="' . esc_attr( $order_string ) . '" />' . "\n"; |
|
| 1244 | - $html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n"; |
|
| 1245 | - $html .= '<input type="submit" class="button-primary" value="' . __( 'Save lesson order', 'woothemes-sensei' ) . '" />' . "\n"; |
|
| 1242 | + if (0 < count($displayed_lessons)) { |
|
| 1243 | + $html .= '<input type="hidden" name="lesson-order" value="'.esc_attr($order_string).'" />'."\n"; |
|
| 1244 | + $html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n"; |
|
| 1245 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save lesson order', 'woothemes-sensei').'" />'."\n"; |
|
| 1246 | 1246 | } |
| 1247 | 1247 | } |
| 1248 | 1248 | } |
@@ -1252,29 +1252,29 @@ discard block |
||
| 1252 | 1252 | ?></div><?php |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | - public function get_lesson_order( $course_id = 0 ) { |
|
| 1256 | - $order_string = get_post_meta( $course_id, '_lesson_order', true ); |
|
| 1255 | + public function get_lesson_order($course_id = 0) { |
|
| 1256 | + $order_string = get_post_meta($course_id, '_lesson_order', true); |
|
| 1257 | 1257 | return $order_string; |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - public function save_lesson_order( $order_string = '', $course_id = 0 ) { |
|
| 1260 | + public function save_lesson_order($order_string = '', $course_id = 0) { |
|
| 1261 | 1261 | |
| 1262 | - if( $course_id ) { |
|
| 1262 | + if ($course_id) { |
|
| 1263 | 1263 | |
| 1264 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
| 1264 | + $modules = Sensei()->modules->get_course_modules(intval($course_id)); |
|
| 1265 | 1265 | |
| 1266 | - foreach( $modules as $module ) { |
|
| 1266 | + foreach ($modules as $module) { |
|
| 1267 | 1267 | |
| 1268 | 1268 | |
| 1269 | - if( isset( $_POST[ 'lesson-order-module-' . $module->term_id ] ) |
|
| 1270 | - && $_POST[ 'lesson-order-module-' . $module->term_id ] ) { |
|
| 1269 | + if (isset($_POST['lesson-order-module-'.$module->term_id]) |
|
| 1270 | + && $_POST['lesson-order-module-'.$module->term_id]) { |
|
| 1271 | 1271 | |
| 1272 | - $order = explode( ',', $_POST[ 'lesson-order-module-' . $module->term_id ] ); |
|
| 1272 | + $order = explode(',', $_POST['lesson-order-module-'.$module->term_id]); |
|
| 1273 | 1273 | $i = 1; |
| 1274 | - foreach( $order as $lesson_id ) { |
|
| 1274 | + foreach ($order as $lesson_id) { |
|
| 1275 | 1275 | |
| 1276 | - if( $lesson_id ) { |
|
| 1277 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
| 1276 | + if ($lesson_id) { |
|
| 1277 | + update_post_meta($lesson_id, '_order_module_'.$module->term_id, $i); |
|
| 1278 | 1278 | ++$i; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
@@ -1285,15 +1285,15 @@ discard block |
||
| 1285 | 1285 | } // end for each modules |
| 1286 | 1286 | |
| 1287 | 1287 | |
| 1288 | - if( $order_string ) { |
|
| 1289 | - update_post_meta( $course_id, '_lesson_order', $order_string ); |
|
| 1288 | + if ($order_string) { |
|
| 1289 | + update_post_meta($course_id, '_lesson_order', $order_string); |
|
| 1290 | 1290 | |
| 1291 | - $order = explode( ',', $order_string ); |
|
| 1291 | + $order = explode(',', $order_string); |
|
| 1292 | 1292 | |
| 1293 | 1293 | $i = 1; |
| 1294 | - foreach( $order as $lesson_id ) { |
|
| 1295 | - if( $lesson_id ) { |
|
| 1296 | - update_post_meta( $lesson_id, '_order_' . $course_id, $i ); |
|
| 1294 | + foreach ($order as $lesson_id) { |
|
| 1295 | + if ($lesson_id) { |
|
| 1296 | + update_post_meta($lesson_id, '_order_'.$course_id, $i); |
|
| 1297 | 1297 | ++$i; |
| 1298 | 1298 | } |
| 1299 | 1299 | } |
@@ -1308,54 +1308,54 @@ discard block |
||
| 1308 | 1308 | function sensei_add_custom_menu_items() { |
| 1309 | 1309 | global $pagenow; |
| 1310 | 1310 | |
| 1311 | - if( 'nav-menus.php' == $pagenow ) { |
|
| 1312 | - add_meta_box( 'add-sensei-links', 'Sensei', array( $this, 'wp_nav_menu_item_sensei_links_meta_box' ), 'nav-menus', 'side', 'low' ); |
|
| 1311 | + if ('nav-menus.php' == $pagenow) { |
|
| 1312 | + add_meta_box('add-sensei-links', 'Sensei', array($this, 'wp_nav_menu_item_sensei_links_meta_box'), 'nav-menus', 'side', 'low'); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | - function wp_nav_menu_item_sensei_links_meta_box( $object ) { |
|
| 1316 | + function wp_nav_menu_item_sensei_links_meta_box($object) { |
|
| 1317 | 1317 | global $nav_menu_selected_id; |
| 1318 | 1318 | |
| 1319 | 1319 | $menu_items = array( |
| 1320 | - '#senseicourses' => __( 'Courses', 'woothemes-sensei' ), |
|
| 1321 | - '#senseilessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 1322 | - '#senseimycourses' => __( 'My Courses', 'woothemes-sensei' ), |
|
| 1323 | - '#senseilearnerprofile' => __( 'My Profile', 'woothemes-sensei' ), |
|
| 1324 | - '#senseimymessages' => __( 'My Messages', 'woothemes-sensei' ), |
|
| 1325 | - '#senseiloginlogout' => __( 'Login', 'woothemes-sensei' ) . '|' . __( 'Logout', 'woothemes-sensei' ) |
|
| 1320 | + '#senseicourses' => __('Courses', 'woothemes-sensei'), |
|
| 1321 | + '#senseilessons' => __('Lessons', 'woothemes-sensei'), |
|
| 1322 | + '#senseimycourses' => __('My Courses', 'woothemes-sensei'), |
|
| 1323 | + '#senseilearnerprofile' => __('My Profile', 'woothemes-sensei'), |
|
| 1324 | + '#senseimymessages' => __('My Messages', 'woothemes-sensei'), |
|
| 1325 | + '#senseiloginlogout' => __('Login', 'woothemes-sensei').'|'.__('Logout', 'woothemes-sensei') |
|
| 1326 | 1326 | ); |
| 1327 | 1327 | |
| 1328 | 1328 | $menu_items_obj = array(); |
| 1329 | - foreach ( $menu_items as $value => $title ) { |
|
| 1329 | + foreach ($menu_items as $value => $title) { |
|
| 1330 | 1330 | $menu_items_obj[$title] = new stdClass; |
| 1331 | - $menu_items_obj[$title]->object_id = esc_attr( $value ); |
|
| 1332 | - $menu_items_obj[$title]->title = esc_attr( $title ); |
|
| 1333 | - $menu_items_obj[$title]->url = esc_attr( $value ); |
|
| 1334 | - $menu_items_obj[$title]->description = 'description'; |
|
| 1331 | + $menu_items_obj[$title]->object_id = esc_attr($value); |
|
| 1332 | + $menu_items_obj[$title]->title = esc_attr($title); |
|
| 1333 | + $menu_items_obj[$title]->url = esc_attr($value); |
|
| 1334 | + $menu_items_obj[$title]->description = 'description'; |
|
| 1335 | 1335 | $menu_items_obj[$title]->db_id = 0; |
| 1336 | 1336 | $menu_items_obj[$title]->object = 'sensei'; |
| 1337 | - $menu_items_obj[$title]->menu_item_parent = 0; |
|
| 1338 | - $menu_items_obj[$title]->type = 'custom'; |
|
| 1337 | + $menu_items_obj[$title]->menu_item_parent = 0; |
|
| 1338 | + $menu_items_obj[$title]->type = 'custom'; |
|
| 1339 | 1339 | $menu_items_obj[$title]->target = ''; |
| 1340 | - $menu_items_obj[$title]->attr_title = ''; |
|
| 1341 | - $menu_items_obj[$title]->classes = array(); |
|
| 1342 | - $menu_items_obj[$title]->xfn = ''; |
|
| 1340 | + $menu_items_obj[$title]->attr_title = ''; |
|
| 1341 | + $menu_items_obj[$title]->classes = array(); |
|
| 1342 | + $menu_items_obj[$title]->xfn = ''; |
|
| 1343 | 1343 | } |
| 1344 | 1344 | |
| 1345 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
| 1345 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
| 1346 | 1346 | ?> |
| 1347 | 1347 | |
| 1348 | 1348 | <div id="sensei-links" class="senseidiv taxonomydiv"> |
| 1349 | 1349 | <div id="tabs-panel-sensei-links-all" class="tabs-panel tabs-panel-view-all tabs-panel-active"> |
| 1350 | 1350 | |
| 1351 | 1351 | <ul id="sensei-linkschecklist" class="list:sensei-links categorychecklist form-no-clear"> |
| 1352 | - <?php echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items_obj ), 0, (object)array( 'walker' => $walker ) ); ?> |
|
| 1352 | + <?php echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items_obj), 0, (object) array('walker' => $walker)); ?> |
|
| 1353 | 1353 | </ul> |
| 1354 | 1354 | |
| 1355 | 1355 | </div> |
| 1356 | 1356 | <p class="button-controls"> |
| 1357 | 1357 | <span class="add-to-menu"> |
| 1358 | - <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" /> |
|
| 1358 | + <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" /> |
|
| 1359 | 1359 | <span class="spinner"></span> |
| 1360 | 1360 | </span> |
| 1361 | 1361 | </p> |
@@ -1371,17 +1371,17 @@ discard block |
||
| 1371 | 1371 | */ |
| 1372 | 1372 | public function theme_compatibility_notices() { |
| 1373 | 1373 | |
| 1374 | - if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
| 1375 | - switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
| 1376 | - case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; |
|
| 1377 | - case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; |
|
| 1374 | + if (isset($_GET['sensei_hide_notice'])) { |
|
| 1375 | + switch (esc_attr($_GET['sensei_hide_notice'])) { |
|
| 1376 | + case 'menu_settings': add_user_meta(get_current_user_id(), 'sensei_hide_menu_settings_notice', true); break; |
|
| 1377 | + case 'theme_check': add_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); break; |
|
| 1378 | 1378 | } |
| 1379 | 1379 | } |
| 1380 | 1380 | |
| 1381 | 1381 | // white list templates that are already support by default and do not show notice for them |
| 1382 | - $template = get_option( 'template' ); |
|
| 1382 | + $template = get_option('template'); |
|
| 1383 | 1383 | |
| 1384 | - $white_list = array( 'twentyeleven', |
|
| 1384 | + $white_list = array('twentyeleven', |
|
| 1385 | 1385 | 'twentytwelve', |
| 1386 | 1386 | 'twentyfourteen', |
| 1387 | 1387 | 'twentyfifteen', |
@@ -1389,43 +1389,43 @@ discard block |
||
| 1389 | 1389 | 'storefront', |
| 1390 | 1390 | ); |
| 1391 | 1391 | |
| 1392 | - if ( in_array( $template, $white_list ) ) { |
|
| 1392 | + if (in_array($template, $white_list)) { |
|
| 1393 | 1393 | |
| 1394 | 1394 | return; |
| 1395 | 1395 | |
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | // don't show the notice if the user chose to hide it |
| 1399 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
| 1400 | - if( $hide_theme_check_notice ) { |
|
| 1399 | + $hide_theme_check_notice = get_user_meta(get_current_user_id(), 'sensei_hide_theme_check_notice', true); |
|
| 1400 | + if ($hide_theme_check_notice) { |
|
| 1401 | 1401 | |
| 1402 | 1402 | return; |
| 1403 | 1403 | |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | // show the notice for themes not supporting sensei |
| 1407 | - if ( ! current_theme_supports( 'sensei' ) ) { |
|
| 1407 | + if ( ! current_theme_supports('sensei')) { |
|
| 1408 | 1408 | ?> |
| 1409 | 1409 | |
| 1410 | 1410 | <div id="message" class="error sensei-message sensei-connect"> |
| 1411 | 1411 | <p> |
| 1412 | 1412 | <strong> |
| 1413 | 1413 | |
| 1414 | - <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei' ); ?> |
|
| 1414 | + <?php _e('Your theme does not declare Sensei support', 'woothemes-sensei'); ?> |
|
| 1415 | 1415 | |
| 1416 | 1416 | </strong> – |
| 1417 | 1417 | |
| 1418 | - <?php _e( 'if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei' ); ?> |
|
| 1418 | + <?php _e('if you encounter layout issues please read our integration guide or choose a ', 'woothemes-sensei'); ?> |
|
| 1419 | 1419 | |
| 1420 | - <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e( 'Sensei theme', 'woothemes-sensei' ) ?> </a> |
|
| 1420 | + <a href="http://www.woothemes.com/product-category/themes/sensei-themes/"> <?php _e('Sensei theme', 'woothemes-sensei') ?> </a> |
|
| 1421 | 1421 | |
| 1422 | 1422 | :) |
| 1423 | 1423 | |
| 1424 | 1424 | </p> |
| 1425 | 1425 | <p class="submit"> |
| 1426 | - <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"> |
|
| 1426 | + <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"> |
|
| 1427 | 1427 | |
| 1428 | - <?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' ); ?> |
|
| 1428 | + <?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'); ?> |
|
| 1429 | 1429 | |
| 1430 | 1430 | </a> |
| 1431 | 1431 | </p> |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | wp_get_current_user(); |
| 1444 | 1444 | $user_id = $current_user->ID; |
| 1445 | 1445 | |
| 1446 | - delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); |
|
| 1446 | + delete_user_meta($user_id, 'sensei_hide_theme_check_notice'); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1453,8 +1453,8 @@ discard block |
||
| 1453 | 1453 | * @param bool $prevent_access |
| 1454 | 1454 | * @return bool |
| 1455 | 1455 | */ |
| 1456 | - public function admin_access( $prevent_access ) { |
|
| 1457 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
| 1456 | + public function admin_access($prevent_access) { |
|
| 1457 | + if (current_user_can('manage_sensei_grades')) { |
|
| 1458 | 1458 | return false; |
| 1459 | 1459 | } |
| 1460 | 1460 | |
@@ -1469,12 +1469,12 @@ discard block |
||
| 1469 | 1469 | * |
| 1470 | 1470 | * @since 1.8.7 |
| 1471 | 1471 | */ |
| 1472 | - public static function install_pages(){ |
|
| 1472 | + public static function install_pages() { |
|
| 1473 | 1473 | |
| 1474 | 1474 | // only fire on the settings page |
| 1475 | - if( ! isset( $_GET['page'] ) |
|
| 1475 | + if ( ! isset($_GET['page']) |
|
| 1476 | 1476 | || 'woothemes-sensei-settings' != $_GET['page'] |
| 1477 | - || 1 == get_option('skip_install_sensei_pages') ){ |
|
| 1477 | + || 1 == get_option('skip_install_sensei_pages')) { |
|
| 1478 | 1478 | |
| 1479 | 1479 | return; |
| 1480 | 1480 | |
@@ -1511,8 +1511,8 @@ discard block |
||
| 1511 | 1511 | // Set installed option |
| 1512 | 1512 | update_option('sensei_installed', 0); |
| 1513 | 1513 | |
| 1514 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
| 1515 | - wp_redirect( $complete_url ); |
|
| 1514 | + $complete_url = add_query_arg('sensei_install_complete', 'true', $settings_url); |
|
| 1515 | + wp_redirect($complete_url); |
|
| 1516 | 1516 | |
| 1517 | 1517 | } |
| 1518 | 1518 | |
@@ -1526,4 +1526,4 @@ discard block |
||
| 1526 | 1526 | * @since 1.9.0 |
| 1527 | 1527 | * @ignore |
| 1528 | 1528 | */ |
| 1529 | -class WooThemes_Sensei_Admin extends Sensei_Admin{ } |
|
| 1529 | +class WooThemes_Sensei_Admin extends Sensei_Admin { } |
|
@@ -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 | * A settings API (wrapping the WordPress Settings API). |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @access public |
| 32 | 32 | * @since 1.0.0 |
| 33 | 33 | */ |
| 34 | - public function __construct () { |
|
| 34 | + public function __construct() { |
|
| 35 | 35 | |
| 36 | 36 | $this->token = 'woothemes-sensei-settings'; |
| 37 | 37 | $this->page_slug = 'woothemes-sensei-settings-api'; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function register_hook_listener() { |
| 59 | 59 | |
| 60 | - add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 61 | - add_action( 'admin_init', array( $this, 'settings_fields' ) ); |
|
| 62 | - add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 60 | + add_action('admin_menu', array($this, 'register_settings_screen'), 60); |
|
| 61 | + add_action('admin_init', array($this, 'settings_fields')); |
|
| 62 | + add_action('init', array($this, 'general_init'), 5); |
|
| 63 | 63 | |
| 64 | 64 | } // End setup_settings() |
| 65 | 65 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $this->init_sections(); |
| 74 | 74 | $this->init_fields(); |
| 75 | 75 | $this->get_settings(); |
| 76 | - if ( $this->has_tabs == true ) { |
|
| 76 | + if ($this->has_tabs == true) { |
|
| 77 | 77 | $this->create_tabs(); |
| 78 | 78 | } // End If Statement |
| 79 | 79 | } // End general_init() |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | * @since 1.0.0 |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function init_sections () { |
|
| 87 | + public function init_sections() { |
|
| 88 | 88 | // Override this function in your class and assign the array of sections to $this->sections. |
| 89 | - _e( 'Override init_sections() in your class.', 'woothemes-sensei' ); |
|
| 89 | + _e('Override init_sections() in your class.', 'woothemes-sensei'); |
|
| 90 | 90 | } // End init_sections() |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @since 1.0.0 |
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | - public function init_fields () { |
|
| 98 | + public function init_fields() { |
|
| 99 | 99 | // Override this function in your class and assign the array of sections to $this->fields. |
| 100 | - _e( 'Override init_fields() in your class.', 'woothemes-sensei' ); |
|
| 100 | + _e('Override init_fields() in your class.', 'woothemes-sensei'); |
|
| 101 | 101 | } // End init_fields() |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -106,34 +106,34 @@ discard block |
||
| 106 | 106 | * @since 1.1.0 |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function settings_tabs () { |
|
| 109 | + public function settings_tabs() { |
|
| 110 | 110 | |
| 111 | - if ( ! $this->has_tabs ) { return; } |
|
| 111 | + if ( ! $this->has_tabs) { return; } |
|
| 112 | 112 | |
| 113 | - if ( count( $this->tabs ) > 0 ) { |
|
| 113 | + if (count($this->tabs) > 0) { |
|
| 114 | 114 | $html = ''; |
| 115 | 115 | |
| 116 | - $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n"; |
|
| 116 | + $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">'."\n"; |
|
| 117 | 117 | |
| 118 | 118 | $sections = array( |
| 119 | - 'all' => array( 'href' => '#all', 'name' => __( 'All', 'woothemes-sensei' ), 'class' => 'current all tab' ) |
|
| 119 | + 'all' => array('href' => '#all', 'name' => __('All', 'woothemes-sensei'), 'class' => 'current all tab') |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - foreach ( $this->tabs as $k => $v ) { |
|
| 123 | - $sections[$k] = array( 'href' => '#' . esc_attr( $k ), 'name' => esc_attr( $v['name'] ), 'class' => 'tab' ); |
|
| 122 | + foreach ($this->tabs as $k => $v) { |
|
| 123 | + $sections[$k] = array('href' => '#'.esc_attr($k), 'name' => esc_attr($v['name']), 'class' => 'tab'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $count = 1; |
| 127 | - foreach ( $sections as $k => $v ) { |
|
| 127 | + foreach ($sections as $k => $v) { |
|
| 128 | 128 | $count++; |
| 129 | - $html .= '<li><a href="' . $v['href'] . '"'; |
|
| 130 | - if ( isset( $v['class'] ) && ( $v['class'] != '' ) ) { $html .= ' class="' . esc_attr( $v['class'] ) . '"'; } |
|
| 131 | - $html .= '>' . esc_attr( $v['name'] ) . '</a>'; |
|
| 132 | - if ( $count <= count( $sections ) ) { $html .= ' | '; } |
|
| 133 | - $html .= '</li>' . "\n"; |
|
| 129 | + $html .= '<li><a href="'.$v['href'].'"'; |
|
| 130 | + if (isset($v['class']) && ($v['class'] != '')) { $html .= ' class="'.esc_attr($v['class']).'"'; } |
|
| 131 | + $html .= '>'.esc_attr($v['name']).'</a>'; |
|
| 132 | + if ($count <= count($sections)) { $html .= ' | '; } |
|
| 133 | + $html .= '</li>'."\n"; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $html .= '</ul><div class="clear"></div>' . "\n"; |
|
| 136 | + $html .= '</ul><div class="clear"></div>'."\n"; |
|
| 137 | 137 | |
| 138 | 138 | echo $html; |
| 139 | 139 | } |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | * @since 1.1.0 |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | - private function create_tabs () { |
|
| 149 | - if ( count( $this->sections ) > 0 ) { |
|
| 148 | + private function create_tabs() { |
|
| 149 | + if (count($this->sections) > 0) { |
|
| 150 | 150 | $tabs = array(); |
| 151 | - foreach ( $this->sections as $k => $v ) { |
|
| 151 | + foreach ($this->sections as $k => $v) { |
|
| 152 | 152 | $tabs[$k] = $v; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @since 1.0.0 |
| 163 | 163 | * @return void |
| 164 | 164 | */ |
| 165 | - public function create_sections () { |
|
| 166 | - if ( count( $this->sections ) > 0 ) { |
|
| 167 | - foreach ( $this->sections as $k => $v ) { |
|
| 168 | - add_settings_section( $k, $v['name'], array( $this, 'section_description' ), $this->token ); |
|
| 165 | + public function create_sections() { |
|
| 166 | + if (count($this->sections) > 0) { |
|
| 167 | + foreach ($this->sections as $k => $v) { |
|
| 168 | + add_settings_section($k, $v['name'], array($this, 'section_description'), $this->token); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } // End create_sections() |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | * @since 1.0.0 |
| 177 | 177 | * @return void |
| 178 | 178 | */ |
| 179 | - public function create_fields () { |
|
| 180 | - if ( count( $this->sections ) > 0 ) { |
|
| 179 | + public function create_fields() { |
|
| 180 | + if (count($this->sections) > 0) { |
|
| 181 | 181 | // $this->parse_fields( $this->fields ); |
| 182 | 182 | |
| 183 | - foreach ( $this->fields as $k => $v ) { |
|
| 184 | - $method = $this->determine_method( $v, 'form' ); |
|
| 183 | + foreach ($this->fields as $k => $v) { |
|
| 184 | + $method = $this->determine_method($v, 'form'); |
|
| 185 | 185 | $name = $v['name']; |
| 186 | - if ( $v['type'] == 'info' ) { $name = ''; } |
|
| 187 | - add_settings_field( $k, $name, $method, $this->token, $v['section'], array( 'key' => $k, 'data' => $v ) ); |
|
| 186 | + if ($v['type'] == 'info') { $name = ''; } |
|
| 187 | + add_settings_field($k, $name, $method, $this->token, $v['section'], array('key' => $k, 'data' => $v)); |
|
| 188 | 188 | |
| 189 | 189 | // Let the API know that we have a colourpicker field. |
| 190 | - if ( $v['type'] == 'range' && $this->has_range == false ) { $this->has_range = true; } |
|
| 190 | + if ($v['type'] == 'range' && $this->has_range == false) { $this->has_range = true; } |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } // End create_fields() |
@@ -199,43 +199,43 @@ discard block |
||
| 199 | 199 | * @param array $data |
| 200 | 200 | * @return callable, array or string |
| 201 | 201 | */ |
| 202 | - protected function determine_method ( $data, $type = 'form' ) { |
|
| 202 | + protected function determine_method($data, $type = 'form') { |
|
| 203 | 203 | $method = ''; |
| 204 | 204 | |
| 205 | - if ( ! in_array( $type, array( 'form', 'validate', 'check' ) ) ) { return; } |
|
| 205 | + if ( ! in_array($type, array('form', 'validate', 'check'))) { return; } |
|
| 206 | 206 | |
| 207 | 207 | // Check for custom functions. |
| 208 | - if ( isset( $data[$type] ) ) { |
|
| 209 | - if ( function_exists( $data[$type] ) ) { |
|
| 208 | + if (isset($data[$type])) { |
|
| 209 | + if (function_exists($data[$type])) { |
|
| 210 | 210 | $method = $data[$type]; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( $method == '' && method_exists( $this, $data[$type] ) ) { |
|
| 214 | - if ( $type == 'form' ) { |
|
| 215 | - $method = array( $this, $data[$type] ); |
|
| 213 | + if ($method == '' && method_exists($this, $data[$type])) { |
|
| 214 | + if ($type == 'form') { |
|
| 215 | + $method = array($this, $data[$type]); |
|
| 216 | 216 | } else { |
| 217 | 217 | $method = $data[$type]; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( $method == '' && method_exists ( $this, $type . '_field_' . $data['type'] ) ) { |
|
| 223 | - if ( $type == 'form' ) { |
|
| 224 | - $method = array( $this, $type . '_field_' . $data['type'] ); |
|
| 222 | + if ($method == '' && method_exists($this, $type.'_field_'.$data['type'])) { |
|
| 223 | + if ($type == 'form') { |
|
| 224 | + $method = array($this, $type.'_field_'.$data['type']); |
|
| 225 | 225 | } else { |
| 226 | - $method = $type . '_field_' . $data['type']; |
|
| 226 | + $method = $type.'_field_'.$data['type']; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( $method == '' && function_exists ( $this->token . '_' . $type . '_field_' . $data['type'] ) ) { |
|
| 231 | - $method = $this->token . '_' . $type . '_field_' . $data['type']; |
|
| 230 | + if ($method == '' && function_exists($this->token.'_'.$type.'_field_'.$data['type'])) { |
|
| 231 | + $method = $this->token.'_'.$type.'_field_'.$data['type']; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( $method == '' ) { |
|
| 235 | - if ( $type == 'form' ) { |
|
| 236 | - $method = array( $this, $type . '_field_text' ); |
|
| 234 | + if ($method == '') { |
|
| 235 | + if ($type == 'form') { |
|
| 236 | + $method = array($this, $type.'_field_text'); |
|
| 237 | 237 | } else { |
| 238 | - $method = $type . '_field_text'; |
|
| 238 | + $method = $type.'_field_text'; |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * @param array $fields |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function parse_fields ( $fields ) { |
|
| 253 | - foreach ( $fields as $k => $v ) { |
|
| 254 | - if ( isset( $v['section'] ) && ( $v['section'] != '' ) && ( isset( $this->sections[$v['section']] ) ) ) { |
|
| 255 | - if ( ! isset( $this->sections[$v['section']]['fields'] ) ) { |
|
| 252 | + public function parse_fields($fields) { |
|
| 253 | + foreach ($fields as $k => $v) { |
|
| 254 | + if (isset($v['section']) && ($v['section'] != '') && (isset($this->sections[$v['section']]))) { |
|
| 255 | + if ( ! isset($this->sections[$v['section']]['fields'])) { |
|
| 256 | 256 | $this->sections[$v['section']]['fields'] = array(); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -269,19 +269,19 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @return void |
| 271 | 271 | */ |
| 272 | - public function register_settings_screen () { |
|
| 272 | + public function register_settings_screen() { |
|
| 273 | 273 | |
| 274 | - if ( current_user_can( 'manage_sensei' ) ) { |
|
| 275 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
| 274 | + if (current_user_can('manage_sensei')) { |
|
| 275 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
| 276 | 276 | |
| 277 | 277 | $this->hook = $hook; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 280 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 281 | 281 | |
| 282 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
| 283 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 284 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 282 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
| 283 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 284 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | } // End register_settings_screen() |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * @since 1.0.0 |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | - public function settings_screen () |
|
| 295 | + public function settings_screen() |
|
| 296 | 296 | { |
| 297 | 297 | |
| 298 | 298 | ?> |
| 299 | 299 | <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>"> |
| 300 | 300 | <?php screen_icon('woothemes-sensei'); ?> |
| 301 | 301 | <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { |
| 302 | - echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 302 | + echo ' <span class="version">'.$this->settings_version.'</span>'; |
|
| 303 | 303 | } ?></h2> |
| 304 | 304 | <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" |
| 305 | 305 | title="WooThemes"><img |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | $page = 'woothemes-sensei-settings'; |
| 314 | 314 | foreach ($this->sections as $section_id => $section) { |
| 315 | 315 | |
| 316 | - echo '<section id="' . $section_id . '">'; |
|
| 316 | + echo '<section id="'.$section_id.'">'; |
|
| 317 | 317 | |
| 318 | 318 | if ($section['name']) |
| 319 | 319 | echo "<h2>{$section['name']}</h2>\n"; |
| 320 | 320 | |
| 321 | 321 | echo '<table class="form-table">'; |
| 322 | - do_settings_fields($page, $section_id ); |
|
| 322 | + do_settings_fields($page, $section_id); |
|
| 323 | 323 | echo '</table>'; |
| 324 | 324 | |
| 325 | 325 | echo '</section>'; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | submit_button(); |
| 330 | 330 | ?> |
| 331 | 331 | </form> |
| 332 | - <?php do_action( 'settings_after_form' ); ?> |
|
| 332 | + <?php do_action('settings_after_form'); ?> |
|
| 333 | 333 | </div><!--/#woothemes-sensei--> |
| 334 | 334 | <?php |
| 335 | 335 | } // End settings_screen() |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | * @since 1.0.0 |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
| 343 | - public function get_settings () { |
|
| 343 | + public function get_settings() { |
|
| 344 | 344 | |
| 345 | - $this->settings = get_option( $this->token, array() ); |
|
| 345 | + $this->settings = get_option($this->token, array()); |
|
| 346 | 346 | |
| 347 | - foreach ( $this->fields as $k => $v ) { |
|
| 348 | - if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) { |
|
| 347 | + foreach ($this->fields as $k => $v) { |
|
| 348 | + if ( ! isset($this->settings[$k]) && isset($v['default'])) { |
|
| 349 | 349 | $this->settings[$k] = $v['default']; |
| 350 | 350 | } |
| 351 | - if ( $v['type'] == 'checkbox' && $this->settings[$k] != true ) { |
|
| 351 | + if ($v['type'] == 'checkbox' && $this->settings[$k] != true) { |
|
| 352 | 352 | $this->settings[$k] = 0; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | * @since 1.0.0 |
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | - public function settings_fields () { |
|
| 366 | - register_setting( $this->token, $this->token, array( $this, 'validate_fields' ) ); |
|
| 365 | + public function settings_fields() { |
|
| 366 | + register_setting($this->token, $this->token, array($this, 'validate_fields')); |
|
| 367 | 367 | $this->create_sections(); |
| 368 | 368 | $this->create_fields(); |
| 369 | 369 | } // End settings_fields() |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | * @since 1.0.0 |
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | - public function settings_errors () { |
|
| 378 | - settings_errors( $this->token . '-errors' ); |
|
| 377 | + public function settings_errors() { |
|
| 378 | + settings_errors($this->token.'-errors'); |
|
| 379 | 379 | } // End settings_errors() |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -384,9 +384,9 @@ discard block |
||
| 384 | 384 | * @since 1.0.0 |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | - public function section_description ( $section ) { |
|
| 388 | - if ( isset( $this->sections[$section['id']]['description'] ) ) { |
|
| 389 | - echo wpautop( $this->sections[$section['id']]['description'] ); |
|
| 387 | + public function section_description($section) { |
|
| 388 | + if (isset($this->sections[$section['id']]['description'])) { |
|
| 389 | + echo wpautop($this->sections[$section['id']]['description']); |
|
| 390 | 390 | } |
| 391 | 391 | } // End section_description_main() |
| 392 | 392 | |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | * @param array $args |
| 398 | 398 | * @return void |
| 399 | 399 | */ |
| 400 | - public function form_field_text ( $args ) { |
|
| 400 | + public function form_field_text($args) { |
|
| 401 | 401 | $options = $this->get_settings(); |
| 402 | 402 | |
| 403 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 404 | - if ( isset( $args['data']['description'] ) ) { |
|
| 405 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 403 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 404 | + if (isset($args['data']['description'])) { |
|
| 405 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 406 | 406 | } |
| 407 | 407 | } // End form_field_text() |
| 408 | 408 | |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | * @param array $args |
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | - public function form_field_color ( $args ) { |
|
| 416 | + public function form_field_color($args) { |
|
| 417 | 417 | $options = $this->get_settings(); |
| 418 | 418 | |
| 419 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" class="color" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 419 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" class="color" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 420 | 420 | echo '<div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div>'; |
| 421 | - if ( isset( $args['data']['description'] ) ) { |
|
| 422 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 421 | + if (isset($args['data']['description'])) { |
|
| 422 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 423 | 423 | } |
| 424 | 424 | } // End form_field_text() |
| 425 | 425 | |
@@ -430,22 +430,22 @@ discard block |
||
| 430 | 430 | * @param array $args |
| 431 | 431 | * @return void |
| 432 | 432 | */ |
| 433 | - public function form_field_checkbox ( $args ) { |
|
| 433 | + public function form_field_checkbox($args) { |
|
| 434 | 434 | $options = $this->get_settings(); |
| 435 | 435 | |
| 436 | 436 | $has_description = false; |
| 437 | - if ( isset( $args['data']['description'] ) ) { |
|
| 437 | + if (isset($args['data']['description'])) { |
|
| 438 | 438 | $has_description = true; |
| 439 | - echo '<label for="' . esc_attr( $args['key'] ) . '">' . "\n"; |
|
| 439 | + echo '<label for="'.esc_attr($args['key']).'">'."\n"; |
|
| 440 | 440 | } |
| 441 | - echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n"; |
|
| 442 | - if ( $has_description ) { |
|
| 443 | - echo wp_kses( $args['data']['description'], array( 'a' => array( |
|
| 441 | + echo '<input id="'.$args['key'].'" name="'.$this->token.'['.esc_attr($args['key']).']" type="checkbox" value="1"'.checked(esc_attr($options[$args['key']]), '1', false).' />'."\n"; |
|
| 442 | + if ($has_description) { |
|
| 443 | + echo wp_kses($args['data']['description'], array('a' => array( |
|
| 444 | 444 | 'href' => array(), |
| 445 | 445 | 'title' => array() |
| 446 | 446 | ) |
| 447 | 447 | ) |
| 448 | - ) . '</label>' . "\n"; |
|
| 448 | + ).'</label>'."\n"; |
|
| 449 | 449 | } |
| 450 | 450 | } // End form_field_checkbox() |
| 451 | 451 | |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | * @param array $args |
| 457 | 457 | * @return void |
| 458 | 458 | */ |
| 459 | - public function form_field_textarea ( $args ) { |
|
| 459 | + public function form_field_textarea($args) { |
|
| 460 | 460 | $options = $this->get_settings(); |
| 461 | 461 | |
| 462 | - echo '<textarea id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" cols="42" rows="5">' . esc_html( $options[$args['key']] ) . '</textarea>' . "\n"; |
|
| 463 | - if ( isset( $args['data']['description'] ) ) { |
|
| 464 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 462 | + echo '<textarea id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" cols="42" rows="5">'.esc_html($options[$args['key']]).'</textarea>'."\n"; |
|
| 463 | + if (isset($args['data']['description'])) { |
|
| 464 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 465 | 465 | } |
| 466 | 466 | } // End form_field_textarea() |
| 467 | 467 | |
@@ -472,20 +472,20 @@ discard block |
||
| 472 | 472 | * @param array $args |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function form_field_select ( $args ) { |
|
| 475 | + public function form_field_select($args) { |
|
| 476 | 476 | $options = $this->get_settings(); |
| 477 | 477 | |
| 478 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 478 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 479 | 479 | $html = ''; |
| 480 | - $html .= '<select class="" id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']">' . "\n"; |
|
| 481 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 482 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 480 | + $html .= '<select class="" id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']">'."\n"; |
|
| 481 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 482 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 483 | 483 | } |
| 484 | - $html .= '</select>' . "\n"; |
|
| 484 | + $html .= '</select>'."\n"; |
|
| 485 | 485 | echo $html; |
| 486 | 486 | |
| 487 | - if ( isset( $args['data']['description'] ) ) { |
|
| 488 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 487 | + if (isset($args['data']['description'])) { |
|
| 488 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | } // End form_field_select() |
@@ -497,18 +497,18 @@ discard block |
||
| 497 | 497 | * @param array $args |
| 498 | 498 | * @return void |
| 499 | 499 | */ |
| 500 | - public function form_field_radio ( $args ) { |
|
| 500 | + public function form_field_radio($args) { |
|
| 501 | 501 | $options = $this->get_settings(); |
| 502 | 502 | |
| 503 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 503 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 504 | 504 | $html = ''; |
| 505 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 506 | - $html .= '<input type="radio" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 505 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 506 | + $html .= '<input type="radio" name="'.$this->token.'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 507 | 507 | } |
| 508 | 508 | echo $html; |
| 509 | 509 | |
| 510 | - if ( isset( $args['data']['description'] ) ) { |
|
| 511 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 510 | + if (isset($args['data']['description'])) { |
|
| 511 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | } // End form_field_radio() |
@@ -520,28 +520,28 @@ discard block |
||
| 520 | 520 | * @param array $args |
| 521 | 521 | * @return void |
| 522 | 522 | */ |
| 523 | - public function form_field_multicheck ( $args ) { |
|
| 523 | + public function form_field_multicheck($args) { |
|
| 524 | 524 | $options = $this->get_settings(); |
| 525 | 525 | |
| 526 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 527 | - $html = '<div class="multicheck-container" style="margin-bottom:10px;">' . "\n"; |
|
| 528 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 526 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 527 | + $html = '<div class="multicheck-container" style="margin-bottom:10px;">'."\n"; |
|
| 528 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 529 | 529 | $checked = ''; |
| 530 | 530 | |
| 531 | - if( isset( $options[ $args['key'] ] ) ) { |
|
| 532 | - if ( in_array( $k, (array)$options[ $args['key'] ] ) ) { $checked = ' checked="checked"'; } |
|
| 531 | + if (isset($options[$args['key']])) { |
|
| 532 | + if (in_array($k, (array) $options[$args['key']])) { $checked = ' checked="checked"'; } |
|
| 533 | 533 | } else { |
| 534 | - if ( in_array( $k, $args['data']['defaults'] ) ) { $checked = ' checked="checked"'; } |
|
| 534 | + if (in_array($k, $args['data']['defaults'])) { $checked = ' checked="checked"'; } |
|
| 535 | 535 | } |
| 536 | - $html .= '<label for="checkbox-' . esc_attr( $k ) . '">' . "\n"; |
|
| 537 | - $html .= '<input type="checkbox" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . '][]" class="multicheck multicheck-' . esc_attr( $args['key'] ) . '" value="' . esc_attr( $k ) . '" id="checkbox-' . esc_attr( $k ) . '" ' . $checked . ' /> ' . $v . "\n"; |
|
| 538 | - $html .= '</label><br />' . "\n"; |
|
| 536 | + $html .= '<label for="checkbox-'.esc_attr($k).'">'."\n"; |
|
| 537 | + $html .= '<input type="checkbox" name="'.esc_attr($this->token).'['.esc_attr($args['key']).'][]" class="multicheck multicheck-'.esc_attr($args['key']).'" value="'.esc_attr($k).'" id="checkbox-'.esc_attr($k).'" '.$checked.' /> '.$v."\n"; |
|
| 538 | + $html .= '</label><br />'."\n"; |
|
| 539 | 539 | } |
| 540 | - $html .= '</div>' . "\n"; |
|
| 540 | + $html .= '</div>'."\n"; |
|
| 541 | 541 | echo $html; |
| 542 | 542 | |
| 543 | - if ( isset( $args['data']['description'] ) ) { |
|
| 544 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 543 | + if (isset($args['data']['description'])) { |
|
| 544 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } // End form_field_multicheck() |
@@ -553,20 +553,20 @@ discard block |
||
| 553 | 553 | * @param array $args |
| 554 | 554 | * @return void |
| 555 | 555 | */ |
| 556 | - public function form_field_range ( $args ) { |
|
| 556 | + public function form_field_range($args) { |
|
| 557 | 557 | $options = $this->get_settings(); |
| 558 | 558 | |
| 559 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 559 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 560 | 560 | $html = ''; |
| 561 | - $html .= '<select id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" class="range-input">' . "\n"; |
|
| 562 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 563 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 561 | + $html .= '<select id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" class="range-input">'."\n"; |
|
| 562 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 563 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 564 | 564 | } |
| 565 | - $html .= '</select>' . "\n"; |
|
| 565 | + $html .= '</select>'."\n"; |
|
| 566 | 566 | echo $html; |
| 567 | 567 | |
| 568 | - if ( isset( $args['data']['description'] ) ) { |
|
| 569 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 568 | + if (isset($args['data']['description'])) { |
|
| 569 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | } // End form_field_range() |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | * @param array $args |
| 579 | 579 | * @return void |
| 580 | 580 | */ |
| 581 | - public function form_field_images ( $args ) { |
|
| 581 | + public function form_field_images($args) { |
|
| 582 | 582 | $options = $this->get_settings(); |
| 583 | 583 | |
| 584 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 584 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 585 | 585 | $html = ''; |
| 586 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 587 | - $html .= '<input type="radio" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 586 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 587 | + $html .= '<input type="radio" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 588 | 588 | } |
| 589 | 589 | echo $html; |
| 590 | 590 | |
| 591 | - if ( isset( $args['data']['description'] ) ) { |
|
| 592 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 591 | + if (isset($args['data']['description'])) { |
|
| 592 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | } // End form_field_images() |
@@ -601,19 +601,19 @@ discard block |
||
| 601 | 601 | * @param array $args |
| 602 | 602 | * @return void |
| 603 | 603 | */ |
| 604 | - public function form_field_info ( $args ) { |
|
| 604 | + public function form_field_info($args) { |
|
| 605 | 605 | $class = ''; |
| 606 | - if ( isset( $args['data']['class'] ) ) { |
|
| 607 | - $class = ' ' . esc_attr( $args['data']['class'] ); |
|
| 606 | + if (isset($args['data']['class'])) { |
|
| 607 | + $class = ' '.esc_attr($args['data']['class']); |
|
| 608 | 608 | } |
| 609 | - $html = '<div id="' . $args['key'] . '" class="info-box' . $class . '">' . "\n"; |
|
| 610 | - if ( isset( $args['data']['name'] ) && ( $args['data']['name'] != '' ) ) { |
|
| 611 | - $html .= '<h3 class="title">' . esc_html( $args['data']['name'] ) . '</h3>' . "\n"; |
|
| 609 | + $html = '<div id="'.$args['key'].'" class="info-box'.$class.'">'."\n"; |
|
| 610 | + if (isset($args['data']['name']) && ($args['data']['name'] != '')) { |
|
| 611 | + $html .= '<h3 class="title">'.esc_html($args['data']['name']).'</h3>'."\n"; |
|
| 612 | 612 | } |
| 613 | - if ( isset( $args['data']['description'] ) && ( $args['data']['description'] != '' ) ) { |
|
| 614 | - $html .= '<p>' . esc_html( $args['data']['description'] ) . '</p>' . "\n"; |
|
| 613 | + if (isset($args['data']['description']) && ($args['data']['description'] != '')) { |
|
| 614 | + $html .= '<p>'.esc_html($args['data']['description']).'</p>'."\n"; |
|
| 615 | 615 | } |
| 616 | - $html .= '</div>' . "\n"; |
|
| 616 | + $html .= '</div>'."\n"; |
|
| 617 | 617 | |
| 618 | 618 | echo $html; |
| 619 | 619 | } // End form_field_info() |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | * @since 1.9.0 |
| 626 | 626 | * @param array $args |
| 627 | 627 | */ |
| 628 | - public function form_field_button( $args ) { |
|
| 628 | + public function form_field_button($args) { |
|
| 629 | 629 | $options = $this->get_settings(); |
| 630 | 630 | |
| 631 | - if ( isset( $args['data']['target'] ) && isset( $args['data']['label'] ) ) { |
|
| 632 | - printf( '<a href="%s" class="button button-secondary">%s</a> ', esc_url( $args['data']['target'] ), esc_html( $args['data']['label'] ) ); |
|
| 631 | + if (isset($args['data']['target']) && isset($args['data']['label'])) { |
|
| 632 | + printf('<a href="%s" class="button button-secondary">%s</a> ', esc_url($args['data']['target']), esc_html($args['data']['label'])); |
|
| 633 | 633 | |
| 634 | - if ( isset( $args['data']['description'] ) ) { |
|
| 635 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 634 | + if (isset($args['data']['description'])) { |
|
| 635 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } // End form_field_button() |
@@ -646,23 +646,23 @@ discard block |
||
| 646 | 646 | * @uses $this->parse_errors() |
| 647 | 647 | * @return array $options |
| 648 | 648 | */ |
| 649 | - public function validate_fields ( $input ) { |
|
| 649 | + public function validate_fields($input) { |
|
| 650 | 650 | $options = $this->get_settings(); |
| 651 | 651 | |
| 652 | - foreach ( $this->fields as $k => $v ) { |
|
| 652 | + foreach ($this->fields as $k => $v) { |
|
| 653 | 653 | // Make sure checkboxes are present even when false. |
| 654 | - if ( $v['type'] == 'checkbox' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 655 | - if ( $v['type'] == 'multicheck' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 654 | + if ($v['type'] == 'checkbox' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 655 | + if ($v['type'] == 'multicheck' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 656 | 656 | |
| 657 | - if ( isset( $input[$k] ) ) { |
|
| 657 | + if (isset($input[$k])) { |
|
| 658 | 658 | // Perform checks on required fields. |
| 659 | - if ( isset( $v['required'] ) && ( $v['required'] == true ) ) { |
|
| 660 | - if ( in_array( $v['type'], $this->get_array_field_types() ) && ( count( (array) $input[$k] ) <= 0 ) ) { |
|
| 661 | - $this->add_error( $k, $v ); |
|
| 659 | + if (isset($v['required']) && ($v['required'] == true)) { |
|
| 660 | + if (in_array($v['type'], $this->get_array_field_types()) && (count((array) $input[$k]) <= 0)) { |
|
| 661 | + $this->add_error($k, $v); |
|
| 662 | 662 | continue; |
| 663 | 663 | } else { |
| 664 | - if ( $input[$k] == '' ) { |
|
| 665 | - $this->add_error( $k, $v ); |
|
| 664 | + if ($input[$k] == '') { |
|
| 665 | + $this->add_error($k, $v); |
|
| 666 | 666 | continue; |
| 667 | 667 | } |
| 668 | 668 | } |
@@ -671,28 +671,28 @@ discard block |
||
| 671 | 671 | $value = $input[$k]; |
| 672 | 672 | |
| 673 | 673 | // Check if the field is valid. |
| 674 | - $method = $this->determine_method( $v, 'check' ); |
|
| 674 | + $method = $this->determine_method($v, 'check'); |
|
| 675 | 675 | |
| 676 | - if ( function_exists ( $method ) ) { |
|
| 677 | - $is_valid = $method( $value ); |
|
| 676 | + if (function_exists($method)) { |
|
| 677 | + $is_valid = $method($value); |
|
| 678 | 678 | } else { |
| 679 | - if ( method_exists( $this, $method ) ) { |
|
| 680 | - $is_valid = $this->$method( $value ); |
|
| 679 | + if (method_exists($this, $method)) { |
|
| 680 | + $is_valid = $this->$method($value); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ( ! $is_valid ) { |
|
| 685 | - $this->add_error( $k, $v ); |
|
| 684 | + if ( ! $is_valid) { |
|
| 685 | + $this->add_error($k, $v); |
|
| 686 | 686 | continue; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - $method = $this->determine_method( $v, 'validate' ); |
|
| 689 | + $method = $this->determine_method($v, 'validate'); |
|
| 690 | 690 | |
| 691 | - if ( function_exists ( $method ) ) { |
|
| 692 | - $options[$k] = $method( $value ); |
|
| 691 | + if (function_exists($method)) { |
|
| 692 | + $options[$k] = $method($value); |
|
| 693 | 693 | } else { |
| 694 | - if ( method_exists( $this, $method ) ) { |
|
| 695 | - $options[$k] = $this->$method( $value ); |
|
| 694 | + if (method_exists($this, $method)) { |
|
| 695 | + $options[$k] = $this->$method($value); |
|
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | * @param string $input |
| 711 | 711 | * @return string |
| 712 | 712 | */ |
| 713 | - public function validate_field_text ( $input ) { |
|
| 714 | - return trim( esc_attr( $input ) ); |
|
| 713 | + public function validate_field_text($input) { |
|
| 714 | + return trim(esc_attr($input)); |
|
| 715 | 715 | } // End validate_field_text() |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -721,11 +721,11 @@ discard block |
||
| 721 | 721 | * @param string $input |
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | - public function validate_field_checkbox ( $input ) { |
|
| 725 | - if ( ! isset( $input ) ) { |
|
| 724 | + public function validate_field_checkbox($input) { |
|
| 725 | + if ( ! isset($input)) { |
|
| 726 | 726 | return 0; |
| 727 | 727 | } else { |
| 728 | - return (bool)$input; |
|
| 728 | + return (bool) $input; |
|
| 729 | 729 | } |
| 730 | 730 | } // End validate_field_checkbox() |
| 731 | 731 | |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | * @param string $input |
| 737 | 737 | * @return string |
| 738 | 738 | */ |
| 739 | - public function validate_field_multicheck ( $input ) { |
|
| 739 | + public function validate_field_multicheck($input) { |
|
| 740 | 740 | $input = (array) $input; |
| 741 | 741 | |
| 742 | - $input = array_map( 'esc_attr', $input ); |
|
| 742 | + $input = array_map('esc_attr', $input); |
|
| 743 | 743 | |
| 744 | 744 | return $input; |
| 745 | 745 | } // End validate_field_multicheck() |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | * @param string $input |
| 752 | 752 | * @return string |
| 753 | 753 | */ |
| 754 | - public function validate_field_range ( $input ) { |
|
| 755 | - $input = number_format( floatval( $input ), 0 ); |
|
| 754 | + public function validate_field_range($input) { |
|
| 755 | + $input = number_format(floatval($input), 0); |
|
| 756 | 756 | |
| 757 | 757 | return $input; |
| 758 | 758 | } // End validate_field_range() |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $input |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function validate_field_url ( $input ) { |
|
| 768 | - return trim( esc_url( $input ) ); |
|
| 767 | + public function validate_field_url($input) { |
|
| 768 | + return trim(esc_url($input)); |
|
| 769 | 769 | } // End validate_field_url() |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @since 1.1.0 |
| 775 | 775 | * @return boolean Is the value valid? |
| 776 | 776 | */ |
| 777 | - public function check_field_text ( $input ) { |
|
| 777 | + public function check_field_text($input) { |
|
| 778 | 778 | $is_valid = true; |
| 779 | 779 | |
| 780 | 780 | return $is_valid; |
@@ -788,11 +788,11 @@ discard block |
||
| 788 | 788 | * @param array $data |
| 789 | 789 | * @return void |
| 790 | 790 | */ |
| 791 | - protected function add_error ( $key, $data ) { |
|
| 792 | - if ( isset( $data['error_message'] ) ) { |
|
| 791 | + protected function add_error($key, $data) { |
|
| 792 | + if (isset($data['error_message'])) { |
|
| 793 | 793 | $message = $data['error_message']; |
| 794 | 794 | } else { |
| 795 | - $message = sprintf( __( '%s is a required field', 'woothemes-sensei' ), $data['name'] ); |
|
| 795 | + $message = sprintf(__('%s is a required field', 'woothemes-sensei'), $data['name']); |
|
| 796 | 796 | } |
| 797 | 797 | $this->errors[$key] = $message; |
| 798 | 798 | } // End add_error() |
@@ -803,14 +803,14 @@ discard block |
||
| 803 | 803 | * @since 1.0.0 |
| 804 | 804 | * @return void |
| 805 | 805 | */ |
| 806 | - protected function parse_errors () { |
|
| 807 | - if ( count ( $this->errors ) > 0 ) { |
|
| 808 | - foreach ( $this->errors as $k => $v ) { |
|
| 809 | - add_settings_error( $this->token . '-errors', $k, $v, 'error' ); |
|
| 806 | + protected function parse_errors() { |
|
| 807 | + if (count($this->errors) > 0) { |
|
| 808 | + foreach ($this->errors as $k => $v) { |
|
| 809 | + add_settings_error($this->token.'-errors', $k, $v, 'error'); |
|
| 810 | 810 | } |
| 811 | 811 | } else { |
| 812 | - $message = sprintf( __( '%s updated', 'woothemes-sensei' ), $this->name ); |
|
| 813 | - add_settings_error( $this->token . '-errors', $this->token, $message, 'updated' ); |
|
| 812 | + $message = sprintf(__('%s updated', 'woothemes-sensei'), $this->name); |
|
| 813 | + add_settings_error($this->token.'-errors', $this->token, $message, 'updated'); |
|
| 814 | 814 | } |
| 815 | 815 | } // End parse_errors() |
| 816 | 816 | |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | * @since 1.0.0 |
| 821 | 821 | * @return array |
| 822 | 822 | */ |
| 823 | - protected function get_array_field_types () { |
|
| 824 | - return array( 'multicheck' ); |
|
| 823 | + protected function get_array_field_types() { |
|
| 824 | + return array('multicheck'); |
|
| 825 | 825 | } // End get_array_field_types() |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -830,21 +830,21 @@ discard block |
||
| 830 | 830 | * @since 1.0.0 |
| 831 | 831 | * @return void |
| 832 | 832 | */ |
| 833 | - public function enqueue_scripts () { |
|
| 833 | + public function enqueue_scripts() { |
|
| 834 | 834 | |
| 835 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 835 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 836 | 836 | |
| 837 | - wp_enqueue_script( 'farbtastic' ); |
|
| 838 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version ); |
|
| 837 | + wp_enqueue_script('farbtastic'); |
|
| 838 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'farbtastic'), Sensei()->version); |
|
| 839 | 839 | |
| 840 | - if ( $this->has_range ) { |
|
| 841 | - wp_enqueue_script( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/js/ranges' . $suffix . '.js' ), array( 'jquery-ui-slider' ), Sensei()->version ); |
|
| 840 | + if ($this->has_range) { |
|
| 841 | + wp_enqueue_script('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/js/ranges'.$suffix.'.js'), array('jquery-ui-slider'), Sensei()->version); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - wp_register_script( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/js/image-selectors' . $suffix . '.js' ), array( 'jquery' ), Sensei()->version ); |
|
| 844 | + wp_register_script('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/js/image-selectors'.$suffix.'.js'), array('jquery'), Sensei()->version); |
|
| 845 | 845 | |
| 846 | - if ( $this->has_imageselector ) { |
|
| 847 | - wp_enqueue_script( 'woothemes-sensei-settings-imageselectors' ); |
|
| 846 | + if ($this->has_imageselector) { |
|
| 847 | + wp_enqueue_script('woothemes-sensei-settings-imageselectors'); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | } // End enqueue_scripts() |
@@ -855,12 +855,12 @@ discard block |
||
| 855 | 855 | * @since 1.0.0 |
| 856 | 856 | * @return void |
| 857 | 857 | */ |
| 858 | - public function enqueue_styles () { |
|
| 858 | + public function enqueue_styles() { |
|
| 859 | 859 | |
| 860 | - wp_enqueue_style( $this->token . '-admin' ); |
|
| 860 | + wp_enqueue_style($this->token.'-admin'); |
|
| 861 | 861 | |
| 862 | - wp_enqueue_style( 'farbtastic' ); |
|
| 863 | - wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), array( 'farbtastic' ), Sensei()->version ); |
|
| 862 | + wp_enqueue_style('farbtastic'); |
|
| 863 | + wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), array('farbtastic'), Sensei()->version); |
|
| 864 | 864 | |
| 865 | 865 | $this->enqueue_field_styles(); |
| 866 | 866 | } // End enqueue_styles() |
@@ -871,16 +871,16 @@ discard block |
||
| 871 | 871 | * @since 1.0.0 |
| 872 | 872 | * @return void |
| 873 | 873 | */ |
| 874 | - public function enqueue_field_styles () { |
|
| 874 | + public function enqueue_field_styles() { |
|
| 875 | 875 | |
| 876 | - if ( $this->has_range ) { |
|
| 877 | - wp_enqueue_style( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/css/ranges.css' ), '', Sensei()->version ); |
|
| 876 | + if ($this->has_range) { |
|
| 877 | + wp_enqueue_style('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/css/ranges.css'), '', Sensei()->version); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - wp_register_style( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/css/image-selectors.css' ), '', Sensei()->version ); |
|
| 880 | + wp_register_style('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/css/image-selectors.css'), '', Sensei()->version); |
|
| 881 | 881 | |
| 882 | - if ( $this->has_imageselector ) { |
|
| 883 | - wp_enqueue_style( 'woothemes-sensei-settings-imageselectors' ); |
|
| 882 | + if ($this->has_imageselector) { |
|
| 883 | + wp_enqueue_style('woothemes-sensei-settings-imageselectors'); |
|
| 884 | 884 | } |
| 885 | 885 | } // End enqueue_field_styles() |
| 886 | 886 | } // End Class |
@@ -890,4 +890,4 @@ discard block |
||
| 890 | 890 | * @ignore only for backward compatibility |
| 891 | 891 | * @since 1.9.0 |
| 892 | 892 | */ |
| 893 | -class WooThemes_Sensei_Settings_API extends Sensei_Settings_API{} |
|
| 893 | +class WooThemes_Sensei_Settings_API extends Sensei_Settings_API {} |
|
@@ -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 | * Analysis Overview Data Table. |
@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | * @since 1.2.0 |
| 19 | 19 | * @return void |
| 20 | 20 | */ |
| 21 | - public function __construct ( $type = 'users' ) { |
|
| 22 | - $this->type = in_array( $type, array( 'courses', 'lessons', 'users' ) ) ? $type : 'users'; |
|
| 21 | + public function __construct($type = 'users') { |
|
| 22 | + $this->type = in_array($type, array('courses', 'lessons', 'users')) ? $type : 'users'; |
|
| 23 | 23 | |
| 24 | 24 | // Load Parent token into constructor |
| 25 | - parent::__construct( 'analysis_overview' ); |
|
| 25 | + parent::__construct('analysis_overview'); |
|
| 26 | 26 | |
| 27 | 27 | // Actions |
| 28 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
| 29 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
| 28 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
| 29 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
| 30 | 30 | |
| 31 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
| 31 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
| 32 | 32 | } // End __construct() |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -38,41 +38,41 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | function get_columns() { |
| 40 | 40 | |
| 41 | - switch( $this->type ) { |
|
| 41 | + switch ($this->type) { |
|
| 42 | 42 | case 'courses': |
| 43 | 43 | $columns = array( |
| 44 | - 'title' => __( 'Course', 'woothemes-sensei' ), |
|
| 45 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
| 46 | - 'lessons' => __( 'Lessons', 'woothemes-sensei' ), |
|
| 47 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 48 | - 'average_percent' => __( 'Average Percentage', 'woothemes-sensei' ), |
|
| 44 | + 'title' => __('Course', 'woothemes-sensei'), |
|
| 45 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
| 46 | + 'lessons' => __('Lessons', 'woothemes-sensei'), |
|
| 47 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 48 | + 'average_percent' => __('Average Percentage', 'woothemes-sensei'), |
|
| 49 | 49 | ); |
| 50 | 50 | break; |
| 51 | 51 | |
| 52 | 52 | case 'lessons': |
| 53 | 53 | $columns = array( |
| 54 | - 'title' => __( 'Lesson', 'woothemes-sensei' ), |
|
| 55 | - 'course' => __( 'Course', 'woothemes-sensei' ), |
|
| 56 | - 'students' => __( 'Learners', 'woothemes-sensei' ), |
|
| 57 | - 'completions' => __( 'Completed', 'woothemes-sensei' ), |
|
| 58 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 54 | + 'title' => __('Lesson', 'woothemes-sensei'), |
|
| 55 | + 'course' => __('Course', 'woothemes-sensei'), |
|
| 56 | + 'students' => __('Learners', 'woothemes-sensei'), |
|
| 57 | + 'completions' => __('Completed', 'woothemes-sensei'), |
|
| 58 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 59 | 59 | ); |
| 60 | 60 | break; |
| 61 | 61 | |
| 62 | 62 | case 'users': |
| 63 | 63 | default: |
| 64 | 64 | $columns = array( |
| 65 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
| 66 | - 'registered' => __( 'Date Registered', 'woothemes-sensei' ), |
|
| 67 | - 'active_courses' => __( 'Active Courses', 'woothemes-sensei' ), |
|
| 68 | - 'completed_courses' => __( 'Completed Courses', 'woothemes-sensei' ), |
|
| 69 | - 'average_grade' => __( 'Average Grade', 'woothemes-sensei' ), |
|
| 65 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
| 66 | + 'registered' => __('Date Registered', 'woothemes-sensei'), |
|
| 67 | + 'active_courses' => __('Active Courses', 'woothemes-sensei'), |
|
| 68 | + 'completed_courses' => __('Completed Courses', 'woothemes-sensei'), |
|
| 69 | + 'average_grade' => __('Average Grade', 'woothemes-sensei'), |
|
| 70 | 70 | ); |
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | 73 | // Backwards compatible filter name, moving forward should have single filter name |
| 74 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns', $columns, $this ); |
|
| 75 | - $columns = apply_filters( 'sensei_analysis_overview_columns', $columns, $this ); |
|
| 74 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns', $columns, $this); |
|
| 75 | + $columns = apply_filters('sensei_analysis_overview_columns', $columns, $this); |
|
| 76 | 76 | return $columns; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -83,41 +83,41 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function get_sortable_columns() { |
| 85 | 85 | |
| 86 | - switch( $this->type ) { |
|
| 86 | + switch ($this->type) { |
|
| 87 | 87 | case 'courses': |
| 88 | 88 | $columns = array( |
| 89 | - 'title' => array( 'title', false ), |
|
| 90 | - 'students' => array( 'students', false ), |
|
| 91 | - 'lessons' => array( 'lessons', false ), |
|
| 92 | - 'completions' => array( 'completions', false ), |
|
| 93 | - 'average_percent' => array( 'average_percent', false ), |
|
| 89 | + 'title' => array('title', false), |
|
| 90 | + 'students' => array('students', false), |
|
| 91 | + 'lessons' => array('lessons', false), |
|
| 92 | + 'completions' => array('completions', false), |
|
| 93 | + 'average_percent' => array('average_percent', false), |
|
| 94 | 94 | ); |
| 95 | 95 | break; |
| 96 | 96 | |
| 97 | 97 | case 'lessons': |
| 98 | 98 | $columns = array( |
| 99 | - 'title' => array( 'title', false ), |
|
| 100 | - 'course' => array( 'course', false ), |
|
| 101 | - 'students' => array( 'students', false ), |
|
| 102 | - 'completions' => array( 'completions', false ), |
|
| 103 | - 'average_grade' => array( 'average_grade', false ), |
|
| 99 | + 'title' => array('title', false), |
|
| 100 | + 'course' => array('course', false), |
|
| 101 | + 'students' => array('students', false), |
|
| 102 | + 'completions' => array('completions', false), |
|
| 103 | + 'average_grade' => array('average_grade', false), |
|
| 104 | 104 | ); |
| 105 | 105 | break; |
| 106 | 106 | |
| 107 | 107 | case 'users': |
| 108 | 108 | default: |
| 109 | 109 | $columns = array( |
| 110 | - 'title' => array( 'user_login', false ), |
|
| 111 | - 'registered' => array( 'registered', false ), |
|
| 112 | - 'active_courses' => array( 'active_courses', false ), |
|
| 113 | - 'completed_courses' => array( 'completed_courses', false ), |
|
| 114 | - 'average_grade' => array( 'average_grade', false ) |
|
| 110 | + 'title' => array('user_login', false), |
|
| 111 | + 'registered' => array('registered', false), |
|
| 112 | + 'active_courses' => array('active_courses', false), |
|
| 113 | + 'completed_courses' => array('completed_courses', false), |
|
| 114 | + 'average_grade' => array('average_grade', false) |
|
| 115 | 115 | ); |
| 116 | 116 | break; |
| 117 | 117 | } |
| 118 | 118 | // Backwards compatible filter name, moving forward should have single filter name |
| 119 | - $columns = apply_filters( 'sensei_analysis_overview_' . $this->type . '_columns_sortable', $columns, $this ); |
|
| 120 | - $columns = apply_filters( 'sensei_analysis_overview_columns_sortable', $columns, $this ); |
|
| 119 | + $columns = apply_filters('sensei_analysis_overview_'.$this->type.'_columns_sortable', $columns, $this); |
|
| 120 | + $columns = apply_filters('sensei_analysis_overview_columns_sortable', $columns, $this); |
|
| 121 | 121 | return $columns; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -131,25 +131,25 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Handle orderby |
| 133 | 133 | $orderby = ''; |
| 134 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 135 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 136 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 134 | + if ( ! empty($_GET['orderby'])) { |
|
| 135 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 136 | + $orderby = esc_html($_GET['orderby']); |
|
| 137 | 137 | } // End If Statement |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Handle order |
| 141 | 141 | $order = 'ASC'; |
| 142 | - if ( !empty( $_GET['order'] ) ) { |
|
| 143 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 142 | + if ( ! empty($_GET['order'])) { |
|
| 143 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
| 147 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
| 146 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
| 147 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
| 148 | 148 | |
| 149 | 149 | $paged = $this->get_pagenum(); |
| 150 | 150 | $offset = 0; |
| 151 | - if ( !empty($paged) ) { |
|
| 152 | - $offset = $per_page * ( $paged - 1 ); |
|
| 151 | + if ( ! empty($paged)) { |
|
| 152 | + $offset = $per_page * ($paged - 1); |
|
| 153 | 153 | } // End If Statement |
| 154 | 154 | |
| 155 | 155 | $args = array( |
@@ -160,32 +160,32 @@ discard block |
||
| 160 | 160 | ); |
| 161 | 161 | |
| 162 | 162 | // Handle search |
| 163 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 164 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 163 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
| 164 | + $args['search'] = esc_html($_GET['s']); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - switch ( $this->type ) { |
|
| 167 | + switch ($this->type) { |
|
| 168 | 168 | case 'courses': |
| 169 | - $this->items = $this->get_courses( $args ); |
|
| 169 | + $this->items = $this->get_courses($args); |
|
| 170 | 170 | break; |
| 171 | 171 | |
| 172 | 172 | case 'lessons': |
| 173 | - $this->items = $this->get_lessons( $args ); |
|
| 173 | + $this->items = $this->get_lessons($args); |
|
| 174 | 174 | break; |
| 175 | 175 | |
| 176 | 176 | case 'users': |
| 177 | 177 | default : |
| 178 | - $this->items = $this->get_learners( $args ); |
|
| 178 | + $this->items = $this->get_learners($args); |
|
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $total_items = $this->total_items; |
| 183 | - $total_pages = ceil( $total_items / $per_page ); |
|
| 184 | - $this->set_pagination_args( array( |
|
| 183 | + $total_pages = ceil($total_items / $per_page); |
|
| 184 | + $this->set_pagination_args(array( |
|
| 185 | 185 | 'total_items' => $total_items, |
| 186 | 186 | 'total_pages' => $total_pages, |
| 187 | 187 | 'per_page' => $per_page |
| 188 | - ) ); |
|
| 188 | + )); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @since 1.7.0 |
| 194 | 194 | * @return data |
| 195 | 195 | */ |
| 196 | - public function generate_report( $report ) { |
|
| 196 | + public function generate_report($report) { |
|
| 197 | 197 | |
| 198 | 198 | $data = array(); |
| 199 | 199 | |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | // Handle orderby |
| 203 | 203 | $orderby = ''; |
| 204 | - if ( !empty( $_GET['orderby'] ) ) { |
|
| 205 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
| 206 | - $orderby = esc_html( $_GET['orderby'] ); |
|
| 204 | + if ( ! empty($_GET['orderby'])) { |
|
| 205 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
| 206 | + $orderby = esc_html($_GET['orderby']); |
|
| 207 | 207 | } // End If Statement |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Handle order |
| 211 | 211 | $order = 'ASC'; |
| 212 | - if ( !empty( $_GET['order'] ) ) { |
|
| 213 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
| 212 | + if ( ! empty($_GET['order'])) { |
|
| 213 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | $args = array( |
@@ -220,37 +220,37 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | |
| 222 | 222 | // Handle search |
| 223 | - if ( isset( $_GET['s'] ) && !empty( $_GET['s'] ) ) { |
|
| 224 | - $args['search'] = esc_html( $_GET['s'] ); |
|
| 223 | + if (isset($_GET['s']) && ! empty($_GET['s'])) { |
|
| 224 | + $args['search'] = esc_html($_GET['s']); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
| 228 | 228 | // Start the csv with the column headings |
| 229 | 229 | $column_headers = array(); |
| 230 | 230 | $columns = $this->get_columns(); |
| 231 | - foreach( $columns AS $key => $title ) { |
|
| 231 | + foreach ($columns AS $key => $title) { |
|
| 232 | 232 | $column_headers[] = $title; |
| 233 | 233 | } |
| 234 | 234 | $data[] = $column_headers; |
| 235 | 235 | |
| 236 | - switch ( $this->type ) { |
|
| 236 | + switch ($this->type) { |
|
| 237 | 237 | case 'courses': |
| 238 | - $this->items = $this->get_courses( $args ); |
|
| 238 | + $this->items = $this->get_courses($args); |
|
| 239 | 239 | break; |
| 240 | 240 | |
| 241 | 241 | case 'lessons': |
| 242 | - $this->items = $this->get_lessons( $args ); |
|
| 242 | + $this->items = $this->get_lessons($args); |
|
| 243 | 243 | break; |
| 244 | 244 | |
| 245 | 245 | case 'users': |
| 246 | 246 | default : |
| 247 | - $this->items = $this->get_learners( $args ); |
|
| 247 | + $this->items = $this->get_learners($args); |
|
| 248 | 248 | break; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // Process each row |
| 252 | - foreach( $this->items AS $item) { |
|
| 253 | - $data[] = $this->get_row_data( $item ); |
|
| 252 | + foreach ($this->items AS $item) { |
|
| 253 | + $data[] = $this->get_row_data($item); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | return $data; |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * @param object $item The current item |
| 263 | 263 | * @return array $column_data; |
| 264 | 264 | */ |
| 265 | - protected function get_row_data( $item ) { |
|
| 265 | + protected function get_row_data($item) { |
|
| 266 | 266 | |
| 267 | - switch( $this->type ) { |
|
| 267 | + switch ($this->type) { |
|
| 268 | 268 | case 'courses' : |
| 269 | 269 | // Get Learners (i.e. those who have started) |
| 270 | 270 | $course_args = array( |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | 'type' => 'sensei_course_status', |
| 273 | 273 | 'status' => 'any', |
| 274 | 274 | ); |
| 275 | - $course_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_learners', $course_args, $item ) ); |
|
| 275 | + $course_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_learners', $course_args, $item)); |
|
| 276 | 276 | |
| 277 | 277 | // Get Course Completions |
| 278 | 278 | $course_args = array( |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | 'type' => 'sensei_course_status', |
| 281 | 281 | 'status' => 'complete', |
| 282 | 282 | ); |
| 283 | - $course_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_completions', $course_args, $item ) ); |
|
| 283 | + $course_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_completions', $course_args, $item)); |
|
| 284 | 284 | |
| 285 | 285 | // Course Lessons |
| 286 | - $course_lessons = Sensei()->lesson->lesson_count( array('publish', 'private'), $item->ID ); |
|
| 286 | + $course_lessons = Sensei()->lesson->lesson_count(array('publish', 'private'), $item->ID); |
|
| 287 | 287 | |
| 288 | 288 | // Get Percent Complete |
| 289 | 289 | $grade_args = array( |
@@ -293,31 +293,31 @@ discard block |
||
| 293 | 293 | 'meta_key' => 'percent', |
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | - $percent_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_percentage', $grade_args, $item ), true ) ); |
|
| 297 | - $percent_total = Sensei_Grading::get_course_users_grades_sum( $item->ID ); |
|
| 296 | + $percent_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_percentage', $grade_args, $item), true)); |
|
| 297 | + $percent_total = Sensei_Grading::get_course_users_grades_sum($item->ID); |
|
| 298 | 298 | |
| 299 | 299 | $course_average_percent = 0; |
| 300 | - if( $percent_count > 0 && $percent_total > 0 ){ |
|
| 301 | - $course_average_percent = abs( round( doubleval( $percent_total / $percent_count ), 2 ) ); |
|
| 300 | + if ($percent_count > 0 && $percent_total > 0) { |
|
| 301 | + $course_average_percent = abs(round(doubleval($percent_total / $percent_count), 2)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
| 305 | 305 | // Output course data |
| 306 | - if ( $this->csv_output ) { |
|
| 307 | - $course_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 306 | + if ($this->csv_output) { |
|
| 307 | + $course_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 308 | 308 | } |
| 309 | 309 | else { |
| 310 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 310 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID), admin_url('admin.php')); |
|
| 311 | 311 | |
| 312 | - $course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 312 | + $course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 313 | 313 | $course_average_percent .= '%'; |
| 314 | 314 | } // End If Statement |
| 315 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $course_title, |
|
| 315 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $course_title, |
|
| 316 | 316 | 'students' => $course_students, |
| 317 | 317 | 'lessons' => $course_lessons, |
| 318 | 318 | 'completions' => $course_completions, |
| 319 | 319 | 'average_percent' => $course_average_percent, |
| 320 | - ), $item, $this ); |
|
| 320 | + ), $item, $this); |
|
| 321 | 321 | break; |
| 322 | 322 | |
| 323 | 323 | case 'lessons' : |
@@ -327,65 +327,65 @@ discard block |
||
| 327 | 327 | 'type' => 'sensei_lesson_status', |
| 328 | 328 | 'status' => 'any', |
| 329 | 329 | ); |
| 330 | - $lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) ); |
|
| 330 | + $lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item)); |
|
| 331 | 331 | |
| 332 | 332 | // Get Course Completions |
| 333 | 333 | $lesson_args = array( |
| 334 | 334 | 'post_id' => $item->ID, |
| 335 | 335 | 'type' => 'sensei_lesson_status', |
| 336 | - 'status' => array( 'complete', 'graded', 'passed', 'failed' ), |
|
| 336 | + 'status' => array('complete', 'graded', 'passed', 'failed'), |
|
| 337 | 337 | 'count' => true, |
| 338 | 338 | ); |
| 339 | - $lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) ); |
|
| 339 | + $lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item)); |
|
| 340 | 340 | |
| 341 | 341 | // Course |
| 342 | - $course_id = get_post_meta( $item->ID, '_lesson_course', true ); |
|
| 343 | - $course_title = $course_id ? get_the_title( $course_id ) : ''; |
|
| 342 | + $course_id = get_post_meta($item->ID, '_lesson_course', true); |
|
| 343 | + $course_title = $course_id ? get_the_title($course_id) : ''; |
|
| 344 | 344 | |
| 345 | 345 | $lesson_average_grade = __('n/a', 'woothemes-sensei'); |
| 346 | - if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) { |
|
| 346 | + if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) { |
|
| 347 | 347 | // Get Percent Complete |
| 348 | 348 | $grade_args = array( |
| 349 | 349 | 'post_id' => $item->ID, |
| 350 | 350 | 'type' => 'sensei_lesson_status', |
| 351 | - 'status' => array( 'graded', 'passed', 'failed' ), |
|
| 351 | + 'status' => array('graded', 'passed', 'failed'), |
|
| 352 | 352 | 'meta_key' => 'grade', |
| 353 | 353 | ); |
| 354 | 354 | |
| 355 | - $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true )); |
|
| 356 | - $grade_total = Sensei_Grading::get_lessons_users_grades_sum( $item->ID ); |
|
| 355 | + $grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true)); |
|
| 356 | + $grade_total = Sensei_Grading::get_lessons_users_grades_sum($item->ID); |
|
| 357 | 357 | |
| 358 | 358 | $lesson_average_grade = 0; |
| 359 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 360 | - $lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 359 | + if ($grade_total > 0 && $grade_count > 0) { |
|
| 360 | + $lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | // Output lesson data |
| 365 | - if ( $this->csv_output ) { |
|
| 366 | - $lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID ); |
|
| 365 | + if ($this->csv_output) { |
|
| 366 | + $lesson_title = apply_filters('the_title', $item->post_title, $item->ID); |
|
| 367 | 367 | } |
| 368 | 368 | else { |
| 369 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 370 | - $lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>'; |
|
| 369 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php')); |
|
| 370 | + $lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>'; |
|
| 371 | 371 | |
| 372 | - if ( $course_id ) { |
|
| 373 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ); |
|
| 374 | - $course_title = '<a href="' . esc_url( $url ) . '">' . $course_title . '</a>'; |
|
| 372 | + if ($course_id) { |
|
| 373 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php')); |
|
| 374 | + $course_title = '<a href="'.esc_url($url).'">'.$course_title.'</a>'; |
|
| 375 | 375 | } |
| 376 | 376 | else { |
| 377 | 377 | $course_title = __('n/a', 'woothemes-sensei'); |
| 378 | 378 | } |
| 379 | - if ( is_numeric( $lesson_average_grade ) ) { |
|
| 379 | + if (is_numeric($lesson_average_grade)) { |
|
| 380 | 380 | $lesson_average_grade .= '%'; |
| 381 | 381 | } |
| 382 | 382 | } // End If Statement |
| 383 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $lesson_title, |
|
| 383 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $lesson_title, |
|
| 384 | 384 | 'course' => $course_title, |
| 385 | 385 | 'students' => $lesson_students, |
| 386 | 386 | 'completions' => $lesson_completions, |
| 387 | 387 | 'average_grade' => $lesson_average_grade, |
| 388 | - ), $item, $this ); |
|
| 388 | + ), $item, $this); |
|
| 389 | 389 | break; |
| 390 | 390 | |
| 391 | 391 | case 'users' : |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | 'type' => 'sensei_course_status', |
| 397 | 397 | 'status' => 'any', |
| 398 | 398 | ); |
| 399 | - $user_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_started', $course_args, $item ) ); |
|
| 399 | + $user_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_started', $course_args, $item)); |
|
| 400 | 400 | |
| 401 | 401 | // Get Completed Courses |
| 402 | 402 | $course_args = array( |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | 'type' => 'sensei_course_status', |
| 405 | 405 | 'status' => 'complete', |
| 406 | 406 | ); |
| 407 | - $user_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_courses_ended', $course_args, $item ) ); |
|
| 407 | + $user_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_courses_ended', $course_args, $item)); |
|
| 408 | 408 | |
| 409 | 409 | // Get Quiz Grades |
| 410 | 410 | $grade_args = array( |
@@ -414,29 +414,29 @@ discard block |
||
| 414 | 414 | 'meta_key' => 'grade', |
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | - $grade_count = count( Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_user_lesson_grades', $grade_args, $item ), true )); |
|
| 418 | - $grade_total = Sensei_Grading::get_user_graded_lessons_sum( $item->ID ); |
|
| 417 | + $grade_count = count(Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_user_lesson_grades', $grade_args, $item), true)); |
|
| 418 | + $grade_total = Sensei_Grading::get_user_graded_lessons_sum($item->ID); |
|
| 419 | 419 | |
| 420 | 420 | $user_average_grade = 0; |
| 421 | - if( $grade_total > 0 && $grade_count > 0 ){ |
|
| 422 | - $user_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) ); |
|
| 421 | + if ($grade_total > 0 && $grade_count > 0) { |
|
| 422 | + $user_average_grade = abs(round(doubleval($grade_total / $grade_count), 2)); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Output the users data |
| 426 | - if ( $this->csv_output ) { |
|
| 427 | - $user_name = Sensei_Learner::get_full_name( $item->ID ); |
|
| 426 | + if ($this->csv_output) { |
|
| 427 | + $user_name = Sensei_Learner::get_full_name($item->ID); |
|
| 428 | 428 | } |
| 429 | 429 | else { |
| 430 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->ID ), admin_url( 'admin.php' ) ); |
|
| 431 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $item->display_name . '</a></strong>'; |
|
| 430 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->ID), admin_url('admin.php')); |
|
| 431 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$item->display_name.'</a></strong>'; |
|
| 432 | 432 | $user_average_grade .= '%'; |
| 433 | 433 | } // End If Statement |
| 434 | - $column_data = apply_filters( 'sensei_analysis_overview_column_data', array( 'title' => $user_name, |
|
| 434 | + $column_data = apply_filters('sensei_analysis_overview_column_data', array('title' => $user_name, |
|
| 435 | 435 | 'registered' => $item->user_registered, |
| 436 | - 'active_courses' => ( $user_courses_started - $user_courses_ended ), |
|
| 436 | + 'active_courses' => ($user_courses_started - $user_courses_ended), |
|
| 437 | 437 | 'completed_courses' => $user_courses_ended, |
| 438 | 438 | 'average_grade' => $user_average_grade, |
| 439 | - ), $item, $this ); |
|
| 439 | + ), $item, $this); |
|
| 440 | 440 | break; |
| 441 | 441 | } // end switch |
| 442 | 442 | return $column_data; |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * @since 1.7.0 |
| 448 | 448 | * @return array courses |
| 449 | 449 | */ |
| 450 | - private function get_courses( $args ) { |
|
| 450 | + private function get_courses($args) { |
|
| 451 | 451 | $course_args = array( |
| 452 | 452 | 'post_type' => 'course', |
| 453 | 453 | 'post_status' => array('publish', 'private'), |
@@ -458,16 +458,16 @@ discard block |
||
| 458 | 458 | 'suppress_filters' => 0, |
| 459 | 459 | ); |
| 460 | 460 | |
| 461 | - if ( $this->csv_output ) { |
|
| 461 | + if ($this->csv_output) { |
|
| 462 | 462 | $course_args['posts_per_page'] = '-1'; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - if( isset( $args['search'] ) ) { |
|
| 465 | + if (isset($args['search'])) { |
|
| 466 | 466 | $course_args['s'] = $args['search']; |
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 470 | - $courses_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_courses', $course_args ) ); |
|
| 470 | + $courses_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_courses', $course_args)); |
|
| 471 | 471 | $this->total_items = $courses_query->found_posts; |
| 472 | 472 | return $courses_query->posts; |
| 473 | 473 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @since 1.7.0 |
| 479 | 479 | * @return array lessons |
| 480 | 480 | */ |
| 481 | - private function get_lessons( $args ) { |
|
| 481 | + private function get_lessons($args) { |
|
| 482 | 482 | $lessons_args = array( |
| 483 | 483 | 'post_type' => 'lesson', |
| 484 | 484 | 'post_status' => array('publish', 'private'), |
@@ -489,16 +489,16 @@ discard block |
||
| 489 | 489 | 'suppress_filters' => 0, |
| 490 | 490 | ); |
| 491 | 491 | |
| 492 | - if ( $this->csv_output ) { |
|
| 492 | + if ($this->csv_output) { |
|
| 493 | 493 | $lessons_args['posts_per_page'] = '-1'; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - if( isset( $args['search'] ) ) { |
|
| 496 | + if (isset($args['search'])) { |
|
| 497 | 497 | $lessons_args['s'] = $args['search']; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // Using WP_Query as get_posts() doesn't support 'found_posts' |
| 501 | - $lessons_query = new WP_Query( apply_filters( 'sensei_analysis_overview_filter_lessons', $lessons_args ) ); |
|
| 501 | + $lessons_query = new WP_Query(apply_filters('sensei_analysis_overview_filter_lessons', $lessons_args)); |
|
| 502 | 502 | $this->total_items = $lessons_query->found_posts; |
| 503 | 503 | return $lessons_query->posts; |
| 504 | 504 | } // End get_lessons() |
@@ -508,24 +508,24 @@ discard block |
||
| 508 | 508 | * @since 1.7.0 |
| 509 | 509 | * @return array learners |
| 510 | 510 | */ |
| 511 | - private function get_learners( $args ) { |
|
| 511 | + private function get_learners($args) { |
|
| 512 | 512 | |
| 513 | - if ( !empty($args['search']) ) { |
|
| 513 | + if ( ! empty($args['search'])) { |
|
| 514 | 514 | $args = array( |
| 515 | - 'search' => '*' . trim( $args['search'], '*' ) . '*', |
|
| 515 | + 'search' => '*'.trim($args['search'], '*').'*', |
|
| 516 | 516 | ); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | // This stops the full meta data of each user being loaded |
| 520 | - $args['fields'] = array( 'ID', 'user_login', 'user_email', 'user_registered', 'display_name' ); |
|
| 520 | + $args['fields'] = array('ID', 'user_login', 'user_email', 'user_registered', 'display_name'); |
|
| 521 | 521 | |
| 522 | 522 | /** |
| 523 | 523 | * Filter the WP_User_Query arguments |
| 524 | 524 | * @since 1.6.0 |
| 525 | 525 | * @param $args |
| 526 | 526 | */ |
| 527 | - $args = apply_filters( 'sensei_analysis_overview_filter_users', $args ); |
|
| 528 | - $wp_user_search = new WP_User_Query( $args ); |
|
| 527 | + $args = apply_filters('sensei_analysis_overview_filter_users', $args); |
|
| 528 | + $wp_user_search = new WP_User_Query($args); |
|
| 529 | 529 | $learners = $wp_user_search->get_results(); |
| 530 | 530 | $this->total_items = $wp_user_search->get_total(); |
| 531 | 531 | |
@@ -538,18 +538,18 @@ discard block |
||
| 538 | 538 | * @since 1.2.0 |
| 539 | 539 | * @return array $stats_to_render of stats boxes and values |
| 540 | 540 | */ |
| 541 | - public function stats_boxes () { |
|
| 541 | + public function stats_boxes() { |
|
| 542 | 542 | |
| 543 | 543 | // Get the data required |
| 544 | 544 | $user_count = count_users(); |
| 545 | - $user_count = apply_filters( 'sensei_analysis_total_users', $user_count['total_users'], $user_count ); |
|
| 546 | - $total_courses = Sensei()->course->course_count( array('publish', 'private') ); |
|
| 547 | - $total_lessons = Sensei()->lesson->lesson_count( array('publish', 'private') ); |
|
| 545 | + $user_count = apply_filters('sensei_analysis_total_users', $user_count['total_users'], $user_count); |
|
| 546 | + $total_courses = Sensei()->course->course_count(array('publish', 'private')); |
|
| 547 | + $total_lessons = Sensei()->lesson->lesson_count(array('publish', 'private')); |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * filter the analysis tot grades query args |
| 551 | 551 | */ |
| 552 | - $grade_args = apply_filters( 'sensei_analysis_total_quiz_grades', array( |
|
| 552 | + $grade_args = apply_filters('sensei_analysis_total_quiz_grades', array( |
|
| 553 | 553 | 'type' => 'sensei_lesson_status', |
| 554 | 554 | 'status' => 'any', |
| 555 | 555 | |
@@ -559,8 +559,8 @@ discard block |
||
| 559 | 559 | $total_grade_count = Sensei_Grading::get_graded_lessons_count(); |
| 560 | 560 | $total_grade_total = Sensei_Grading::get_graded_lessons_sum(); |
| 561 | 561 | $total_average_grade = 0; |
| 562 | - if( $total_grade_total > 0 && $total_grade_count >0 ){ |
|
| 563 | - $total_average_grade = abs( round( doubleval( $total_grade_total / $total_grade_count ), 2 ) ); |
|
| 562 | + if ($total_grade_total > 0 && $total_grade_count > 0) { |
|
| 563 | + $total_average_grade = abs(round(doubleval($total_grade_total / $total_grade_count), 2)); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | |
@@ -568,24 +568,24 @@ discard block |
||
| 568 | 568 | 'type' => 'sensei_course_status', |
| 569 | 569 | 'status' => 'any', |
| 570 | 570 | ); |
| 571 | - $total_courses_started = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_started', $course_args ) ); |
|
| 571 | + $total_courses_started = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_started', $course_args)); |
|
| 572 | 572 | $course_args = array( |
| 573 | 573 | 'type' => 'sensei_course_status', |
| 574 | 574 | 'status' => 'complete', |
| 575 | 575 | ); |
| 576 | - $total_courses_ended = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_total_courses_ended', $course_args ) ); |
|
| 577 | - $average_courses_per_learner = abs( round( doubleval( $total_courses_started / $user_count ), 2 ) ); |
|
| 576 | + $total_courses_ended = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_total_courses_ended', $course_args)); |
|
| 577 | + $average_courses_per_learner = abs(round(doubleval($total_courses_started / $user_count), 2)); |
|
| 578 | 578 | |
| 579 | 579 | // Setup the boxes to render |
| 580 | 580 | $stats_to_render = array( |
| 581 | - __( 'Total Courses', 'woothemes-sensei' ) => $total_courses, |
|
| 582 | - __( 'Total Lessons', 'woothemes-sensei' ) => $total_lessons, |
|
| 583 | - __( 'Total Learners', 'woothemes-sensei' ) => $user_count, |
|
| 584 | - __( 'Average Courses per Learner', 'woothemes-sensei' ) => $average_courses_per_learner, |
|
| 585 | - __( 'Average Grade', 'woothemes-sensei' ) => $total_average_grade . '%', |
|
| 586 | - __( 'Total Completed Courses', 'woothemes-sensei' ) => $total_courses_ended, |
|
| 581 | + __('Total Courses', 'woothemes-sensei') => $total_courses, |
|
| 582 | + __('Total Lessons', 'woothemes-sensei') => $total_lessons, |
|
| 583 | + __('Total Learners', 'woothemes-sensei') => $user_count, |
|
| 584 | + __('Average Courses per Learner', 'woothemes-sensei') => $average_courses_per_learner, |
|
| 585 | + __('Average Grade', 'woothemes-sensei') => $total_average_grade.'%', |
|
| 586 | + __('Total Completed Courses', 'woothemes-sensei') => $total_courses_ended, |
|
| 587 | 587 | ); |
| 588 | - return apply_filters( 'sensei_analysis_stats_boxes', $stats_to_render ); |
|
| 588 | + return apply_filters('sensei_analysis_stats_boxes', $stats_to_render); |
|
| 589 | 589 | } // End stats_boxes() |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -595,12 +595,12 @@ discard block |
||
| 595 | 595 | * @return void |
| 596 | 596 | */ |
| 597 | 597 | public function no_items() { |
| 598 | - if( ! $this->view || 'users' == $this->view ) { |
|
| 598 | + if ( ! $this->view || 'users' == $this->view) { |
|
| 599 | 599 | $type = 'learners'; |
| 600 | 600 | } else { |
| 601 | 601 | $type = $this->view; |
| 602 | 602 | } |
| 603 | - echo sprintf( __( '%1$sNo %2$s found%3$s', 'woothemes-sensei' ), '<em>', $type, '</em>' ); |
|
| 603 | + echo sprintf(__('%1$sNo %2$s found%3$s', 'woothemes-sensei'), '<em>', $type, '</em>'); |
|
| 604 | 604 | } // End no_items() |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | 'page' => $this->page_slug, |
| 616 | 616 | ); |
| 617 | 617 | $learners_class = $courses_class = $lessons_class = ''; |
| 618 | - switch( $this->type ) { |
|
| 618 | + switch ($this->type) { |
|
| 619 | 619 | case 'courses': |
| 620 | 620 | $courses_class = 'current'; |
| 621 | 621 | break; |
@@ -633,18 +633,18 @@ discard block |
||
| 633 | 633 | $lesson_args['view'] = 'lessons'; |
| 634 | 634 | $courses_args['view'] = 'courses'; |
| 635 | 635 | |
| 636 | - $menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ). '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>'; |
|
| 637 | - $menu['courses'] = '<a class="' . $courses_class . '" href="' . esc_url ( add_query_arg( $courses_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Courses', 'woothemes-sensei' ) . '</a>'; |
|
| 638 | - $menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>'; |
|
| 636 | + $menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>'; |
|
| 637 | + $menu['courses'] = '<a class="'.$courses_class.'" href="'.esc_url(add_query_arg($courses_args, admin_url('admin.php'))).'">'.__('Courses', 'woothemes-sensei').'</a>'; |
|
| 638 | + $menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>'; |
|
| 639 | 639 | |
| 640 | - $menu = apply_filters( 'sensei_analysis_overview_sub_menu', $menu ); |
|
| 641 | - if ( !empty($menu) ) { |
|
| 642 | - echo '<ul class="subsubsub">' . "\n"; |
|
| 643 | - foreach ( $menu as $class => $item ) { |
|
| 644 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
| 640 | + $menu = apply_filters('sensei_analysis_overview_sub_menu', $menu); |
|
| 641 | + if ( ! empty($menu)) { |
|
| 642 | + echo '<ul class="subsubsub">'."\n"; |
|
| 643 | + foreach ($menu as $class => $item) { |
|
| 644 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
| 645 | 645 | } |
| 646 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
| 647 | - echo '</ul>' . "\n"; |
|
| 646 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
| 647 | + echo '</ul>'."\n"; |
|
| 648 | 648 | } |
| 649 | 649 | } // End data_table_header() |
| 650 | 650 | |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * @return void |
| 655 | 655 | */ |
| 656 | 656 | public function data_table_footer() { |
| 657 | - switch ( $this->type ) { |
|
| 657 | + switch ($this->type) { |
|
| 658 | 658 | case 'courses': |
| 659 | 659 | $report = 'courses-overview'; |
| 660 | 660 | break; |
@@ -668,8 +668,8 @@ discard block |
||
| 668 | 668 | $report = 'user-overview'; |
| 669 | 669 | break; |
| 670 | 670 | } // End Switch Statement |
| 671 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
| 672 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
| 671 | + $url = add_query_arg(array('page' => $this->page_slug, 'view' => $this->type, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
| 672 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
| 673 | 673 | } // End data_table_footer() |
| 674 | 674 | |
| 675 | 675 | /** |
@@ -677,19 +677,19 @@ discard block |
||
| 677 | 677 | * @since 1.7.0 |
| 678 | 678 | * @return string $text |
| 679 | 679 | */ |
| 680 | - public function search_button( $text = '' ) { |
|
| 681 | - switch( $this->type ) { |
|
| 680 | + public function search_button($text = '') { |
|
| 681 | + switch ($this->type) { |
|
| 682 | 682 | case 'courses': |
| 683 | - $text = __( 'Search Courses', 'woothemes-sensei' ); |
|
| 683 | + $text = __('Search Courses', 'woothemes-sensei'); |
|
| 684 | 684 | break; |
| 685 | 685 | |
| 686 | 686 | case 'lessons': |
| 687 | - $text = __( 'Search Lessons', 'woothemes-sensei' ); |
|
| 687 | + $text = __('Search Lessons', 'woothemes-sensei'); |
|
| 688 | 688 | break; |
| 689 | 689 | |
| 690 | 690 | case 'users': |
| 691 | 691 | default: |
| 692 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
| 692 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
| 693 | 693 | break; |
| 694 | 694 | } // End Switch Statement |
| 695 | 695 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if ( ! defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Sensei Modules Class |
@@ -21,33 +21,33 @@ discard block |
||
| 21 | 21 | private $order_page_slug; |
| 22 | 22 | public $taxonomy; |
| 23 | 23 | |
| 24 | - public function __construct( $file ) |
|
| 24 | + public function __construct($file) |
|
| 25 | 25 | { |
| 26 | 26 | $this->file = $file; |
| 27 | 27 | $this->dir = dirname($this->file); |
| 28 | - $this->assets_dir = trailingslashit($this->dir) . 'assets'; |
|
| 28 | + $this->assets_dir = trailingslashit($this->dir).'assets'; |
|
| 29 | 29 | $this->assets_url = esc_url(trailingslashit(plugins_url('/assets/', $this->file))); |
| 30 | 30 | $this->taxonomy = 'module'; |
| 31 | 31 | $this->order_page_slug = 'module-order'; |
| 32 | 32 | |
| 33 | 33 | // setup taxonomy |
| 34 | - add_action( 'init', array( $this, 'setup_modules_taxonomy' ), 10 ); |
|
| 34 | + add_action('init', array($this, 'setup_modules_taxonomy'), 10); |
|
| 35 | 35 | |
| 36 | 36 | // Manage lesson meta boxes for taxonomy |
| 37 | - add_action('add_meta_boxes', array($this, 'modules_metaboxes'), 20, 2 ); |
|
| 37 | + add_action('add_meta_boxes', array($this, 'modules_metaboxes'), 20, 2); |
|
| 38 | 38 | |
| 39 | 39 | // Save lesson meta box |
| 40 | 40 | add_action('save_post', array($this, 'save_lesson_module'), 10, 1); |
| 41 | 41 | |
| 42 | 42 | //Reset the none modules lessons transient |
| 43 | - add_action( 'save_post', array( 'Sensei_Core_Modules', 'reset_none_modules_transient' ) ); |
|
| 43 | + add_action('save_post', array('Sensei_Core_Modules', 'reset_none_modules_transient')); |
|
| 44 | 44 | |
| 45 | 45 | // Frontend styling |
| 46 | 46 | add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); |
| 47 | 47 | |
| 48 | 48 | // Admin styling |
| 49 | 49 | add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_styles')); |
| 50 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 20 , 2 ); |
|
| 50 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 20, 2); |
|
| 51 | 51 | |
| 52 | 52 | // Handle module completion record |
| 53 | 53 | add_action('sensei_lesson_status_updated', array($this, 'update_lesson_status_module_progress'), 10, 3); |
@@ -55,20 +55,20 @@ discard block |
||
| 55 | 55 | add_action('wp', array($this, 'save_module_progress'), 10); |
| 56 | 56 | |
| 57 | 57 | // Handle module ordering |
| 58 | - add_action('admin_menu', array($this, 'register_modules_admin_menu_items'), 30 ); |
|
| 58 | + add_action('admin_menu', array($this, 'register_modules_admin_menu_items'), 30); |
|
| 59 | 59 | add_filter('manage_edit-course_columns', array($this, 'course_columns'), 11, 1); |
| 60 | 60 | add_action('manage_posts_custom_column', array($this, 'course_column_content'), 11, 2); |
| 61 | 61 | |
| 62 | 62 | // Ensure modules always show under courses |
| 63 | - add_action( 'admin_menu', array( $this, 'remove_lessons_menu_model_taxonomy' ) , 10 ); |
|
| 64 | - add_action( 'admin_menu', array( $this, 'remove_courses_menu_model_taxonomy' ) , 10 ); |
|
| 65 | - add_action( 'admin_menu', array( $this, 'redirect_to_lesson_module_taxonomy_to_course' ) , 20 ); |
|
| 63 | + add_action('admin_menu', array($this, 'remove_lessons_menu_model_taxonomy'), 10); |
|
| 64 | + add_action('admin_menu', array($this, 'remove_courses_menu_model_taxonomy'), 10); |
|
| 65 | + add_action('admin_menu', array($this, 'redirect_to_lesson_module_taxonomy_to_course'), 20); |
|
| 66 | 66 | |
| 67 | 67 | // Add course field to taxonomy |
| 68 | - add_action($this->taxonomy . '_add_form_fields', array($this, 'add_module_fields'), 50, 1); |
|
| 69 | - add_action($this->taxonomy . '_edit_form_fields', array($this, 'edit_module_fields'), 1, 1); |
|
| 70 | - add_action('edited_' . $this->taxonomy, array($this, 'save_module_course'), 10, 2); |
|
| 71 | - add_action('created_' . $this->taxonomy, array($this, 'save_module_course'), 10, 2); |
|
| 68 | + add_action($this->taxonomy.'_add_form_fields', array($this, 'add_module_fields'), 50, 1); |
|
| 69 | + add_action($this->taxonomy.'_edit_form_fields', array($this, 'edit_module_fields'), 1, 1); |
|
| 70 | + add_action('edited_'.$this->taxonomy, array($this, 'save_module_course'), 10, 2); |
|
| 71 | + add_action('created_'.$this->taxonomy, array($this, 'save_module_course'), 10, 2); |
|
| 72 | 72 | add_action('wp_ajax_sensei_json_search_courses', array($this, 'search_courses_json')); |
| 73 | 73 | |
| 74 | 74 | // Manage module taxonomy archive page |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | add_filter('body_class', array($this, 'module_archive_body_class')); |
| 81 | 81 | |
| 82 | 82 | // add modules to the single course template |
| 83 | - add_action( 'sensei_single_course_content_inside_after', array($this, 'load_course_module_content_template') , 8 ); |
|
| 83 | + add_action('sensei_single_course_content_inside_after', array($this, 'load_course_module_content_template'), 8); |
|
| 84 | 84 | |
| 85 | 85 | //Single Course modules actions. Add to single-course/course-modules.php |
| 86 | - add_action('sensei_single_course_modules_before',array( $this,'course_modules_title' ), 20); |
|
| 86 | + add_action('sensei_single_course_modules_before', array($this, 'course_modules_title'), 20); |
|
| 87 | 87 | |
| 88 | 88 | // Set up display on single lesson page |
| 89 | 89 | add_filter('sensei_breadcrumb_output', array($this, 'module_breadcrumb_link'), 10, 2); |
@@ -95,22 +95,22 @@ discard block |
||
| 95 | 95 | add_filter('sensei_analysis_course_column_data', array($this, 'analysis_course_column_data'), 10, 3); |
| 96 | 96 | |
| 97 | 97 | // Manage module taxonomy columns |
| 98 | - add_filter('manage_edit-' . $this->taxonomy . '_columns', array($this, 'taxonomy_column_headings'), 1, 1); |
|
| 99 | - add_filter('manage_' . $this->taxonomy . '_custom_column', array($this, 'taxonomy_column_content'), 1, 3); |
|
| 98 | + add_filter('manage_edit-'.$this->taxonomy.'_columns', array($this, 'taxonomy_column_headings'), 1, 1); |
|
| 99 | + add_filter('manage_'.$this->taxonomy.'_custom_column', array($this, 'taxonomy_column_content'), 1, 3); |
|
| 100 | 100 | add_filter('sensei_module_lesson_list_title', array($this, 'sensei_course_preview_titles'), 10, 2); |
| 101 | 101 | |
| 102 | 102 | //store new modules created on the course edit screen |
| 103 | - add_action( 'wp_ajax_sensei_add_new_module_term', array( 'Sensei_Core_Modules','add_new_module_term' ) ); |
|
| 103 | + add_action('wp_ajax_sensei_add_new_module_term', array('Sensei_Core_Modules', 'add_new_module_term')); |
|
| 104 | 104 | |
| 105 | 105 | // for non admin users, only show taxonomies that belong to them |
| 106 | - add_filter('get_terms', array( $this, 'filter_module_terms' ), 20, 3 ); |
|
| 107 | - add_filter('get_object_terms', array( $this, 'filter_course_selected_terms' ), 20, 3 ); |
|
| 106 | + add_filter('get_terms', array($this, 'filter_module_terms'), 20, 3); |
|
| 107 | + add_filter('get_object_terms', array($this, 'filter_course_selected_terms'), 20, 3); |
|
| 108 | 108 | |
| 109 | 109 | // add the teacher name next to the module term in for admin users |
| 110 | - add_filter('get_terms', array( $this, 'append_teacher_name_to_module' ), 70, 3 ); |
|
| 110 | + add_filter('get_terms', array($this, 'append_teacher_name_to_module'), 70, 3); |
|
| 111 | 111 | |
| 112 | 112 | // remove the default modules metabox |
| 113 | - add_action('admin_init',array( 'Sensei_Core_Modules' , 'remove_default_modules_box' )); |
|
| 113 | + add_action('admin_init', array('Sensei_Core_Modules', 'remove_default_modules_box')); |
|
| 114 | 114 | |
| 115 | 115 | } // end constructor |
| 116 | 116 | |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | * @return void |
| 128 | 128 | * @deprecated since 1.9.0 |
| 129 | 129 | */ |
| 130 | - public function change_module_term_slug( $term_id, $tt_id, $taxonomy ){ |
|
| 130 | + public function change_module_term_slug($term_id, $tt_id, $taxonomy) { |
|
| 131 | 131 | |
| 132 | - _deprecated_function('change_module_term_slug', '1.9.0' ); |
|
| 132 | + _deprecated_function('change_module_term_slug', '1.9.0'); |
|
| 133 | 133 | |
| 134 | 134 | }// end add_module_term_group |
| 135 | 135 | |
@@ -143,20 +143,20 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return void |
| 145 | 145 | */ |
| 146 | - public function modules_metaboxes( $post_type, $post ) |
|
| 146 | + public function modules_metaboxes($post_type, $post) |
|
| 147 | 147 | { |
| 148 | - if ('lesson' == $post_type ) { |
|
| 148 | + if ('lesson' == $post_type) { |
|
| 149 | 149 | |
| 150 | 150 | // Remove default taxonomy meta box from Lesson edit screen |
| 151 | - remove_meta_box($this->taxonomy . 'div', 'lesson', 'side'); |
|
| 151 | + remove_meta_box($this->taxonomy.'div', 'lesson', 'side'); |
|
| 152 | 152 | |
| 153 | 153 | // Add custom meta box to limit module selection to one per lesson |
| 154 | - add_meta_box($this->taxonomy . '_select', __('Lesson Module', 'woothemes-sensei'), array($this, 'lesson_module_metabox'), 'lesson', 'side', 'default'); |
|
| 154 | + add_meta_box($this->taxonomy.'_select', __('Lesson Module', 'woothemes-sensei'), array($this, 'lesson_module_metabox'), 'lesson', 'side', 'default'); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if( 'course' == $post_type ){ |
|
| 157 | + if ('course' == $post_type) { |
|
| 158 | 158 | // Course modules selection metabox |
| 159 | - add_meta_box( $this->taxonomy . '_course_mb', __('Course Modules', 'woothemes-sensei'), array( $this, 'course_module_metabox'), 'course', 'side', 'core'); |
|
| 159 | + add_meta_box($this->taxonomy.'_course_mb', __('Course Modules', 'woothemes-sensei'), array($this, 'course_module_metabox'), 'course', 'side', 'core'); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -192,21 +192,21 @@ discard block |
||
| 192 | 192 | $modules = $this->get_course_modules($lesson_course); |
| 193 | 193 | |
| 194 | 194 | // Build the HTML to output |
| 195 | - $html .= '<input type="hidden" name="' . esc_attr('woo_lesson_' . $this->taxonomy . '_nonce') . '" id="' . esc_attr('woo_lesson_' . $this->taxonomy . '_nonce') . '" value="' . esc_attr(wp_create_nonce(plugin_basename($this->file))) . '" />'; |
|
| 195 | + $html .= '<input type="hidden" name="'.esc_attr('woo_lesson_'.$this->taxonomy.'_nonce').'" id="'.esc_attr('woo_lesson_'.$this->taxonomy.'_nonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename($this->file))).'" />'; |
|
| 196 | 196 | if (is_array($modules) && count($modules) > 0) { |
| 197 | - $html .= '<select id="lesson-module-options" name="lesson_module" class="widefat">' . "\n"; |
|
| 198 | - $html .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; |
|
| 197 | + $html .= '<select id="lesson-module-options" name="lesson_module" class="widefat">'."\n"; |
|
| 198 | + $html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'; |
|
| 199 | 199 | foreach ($modules as $module) { |
| 200 | - $html .= '<option value="' . esc_attr(absint($module->term_id)) . '"' . selected($module->term_id, $lesson_module, false) . '>' . esc_html($module->name) . '</option>' . "\n"; |
|
| 200 | + $html .= '<option value="'.esc_attr(absint($module->term_id)).'"'.selected($module->term_id, $lesson_module, false).'>'.esc_html($module->name).'</option>'."\n"; |
|
| 201 | 201 | } |
| 202 | - $html .= '</select>' . "\n"; |
|
| 202 | + $html .= '</select>'."\n"; |
|
| 203 | 203 | } else { |
| 204 | - $course_url = admin_url('post.php?post=' . urlencode($lesson_course) . '&action=edit'); |
|
| 205 | - $html .= '<p>' . sprintf(__('No modules are available for this lesson yet. %1$sPlease add some to %3$sthe course%4$s.%2$s', 'woothemes-sensei'), '<em>', '</em>', '<a href="' . esc_url($course_url) . '">', '</a>') . '</p>'; |
|
| 204 | + $course_url = admin_url('post.php?post='.urlencode($lesson_course).'&action=edit'); |
|
| 205 | + $html .= '<p>'.sprintf(__('No modules are available for this lesson yet. %1$sPlease add some to %3$sthe course%4$s.%2$s', 'woothemes-sensei'), '<em>', '</em>', '<a href="'.esc_url($course_url).'">', '</a>').'</p>'; |
|
| 206 | 206 | } // End If Statement |
| 207 | 207 | |
| 208 | 208 | } else { |
| 209 | - $html .= '<p>' . sprintf(__('No modules are available for this lesson yet. %1$sPlease select a course first.%2$s', 'woothemes-sensei'), '<em>', '</em>') . '</p>'; |
|
| 209 | + $html .= '<p>'.sprintf(__('No modules are available for this lesson yet. %1$sPlease select a course first.%2$s', 'woothemes-sensei'), '<em>', '</em>').'</p>'; |
|
| 210 | 210 | } // End If Statement |
| 211 | 211 | |
| 212 | 212 | // Output the HTML |
@@ -225,38 +225,38 @@ discard block |
||
| 225 | 225 | global $post; |
| 226 | 226 | |
| 227 | 227 | // Verify post type and nonce |
| 228 | - if ((get_post_type() != 'lesson') || !isset($_POST['woo_lesson_' . $this->taxonomy . '_nonce'] ) |
|
| 229 | - ||!wp_verify_nonce($_POST['woo_lesson_' . $this->taxonomy . '_nonce'], plugin_basename($this->file))) { |
|
| 228 | + if ((get_post_type() != 'lesson') || ! isset($_POST['woo_lesson_'.$this->taxonomy.'_nonce']) |
|
| 229 | + ||! wp_verify_nonce($_POST['woo_lesson_'.$this->taxonomy.'_nonce'], plugin_basename($this->file))) { |
|
| 230 | 230 | return $post_id; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Check if user has permissions to edit lessons |
| 234 | 234 | $post_type = get_post_type_object($post->post_type); |
| 235 | - if (!current_user_can($post_type->cap->edit_post, $post_id)) { |
|
| 235 | + if ( ! current_user_can($post_type->cap->edit_post, $post_id)) { |
|
| 236 | 236 | return $post_id; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Check if user has permissions to edit this specific post |
| 240 | - if (!current_user_can('edit_post', $post_id)) { |
|
| 240 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 241 | 241 | return $post_id; |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | // Cast module ID as an integer if selected, otherwise leave as empty string |
| 245 | - if ( isset( $_POST['lesson_module'] ) ) { |
|
| 245 | + if (isset($_POST['lesson_module'])) { |
|
| 246 | 246 | |
| 247 | - if( empty ( $_POST['lesson_module'] ) ){ |
|
| 248 | - wp_delete_object_term_relationships($post_id, $this->taxonomy ); |
|
| 247 | + if (empty ($_POST['lesson_module'])) { |
|
| 248 | + wp_delete_object_term_relationships($post_id, $this->taxonomy); |
|
| 249 | 249 | return true; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - $module_id = intval( $_POST['lesson_module'] ); |
|
| 252 | + $module_id = intval($_POST['lesson_module']); |
|
| 253 | 253 | |
| 254 | 254 | // Assign lesson to selected module |
| 255 | 255 | wp_set_object_terms($post_id, $module_id, $this->taxonomy, false); |
| 256 | 256 | |
| 257 | 257 | // Set default order for lesson inside module |
| 258 | - if (!get_post_meta($post_id, '_order_module_' . $module_id, true)) { |
|
| 259 | - update_post_meta($post_id, '_order_module_' . $module_id, 0); |
|
| 258 | + if ( ! get_post_meta($post_id, '_order_module_'.$module_id, true)) { |
|
| 259 | + update_post_meta($post_id, '_order_module_'.$module_id, 0); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $module_courses = array(); |
| 315 | 315 | if (isset($courses) && is_array($courses)) { |
| 316 | 316 | foreach ($courses as $course) { |
| 317 | - $module_courses[] = array( 'id' =>$course->ID, 'details'=>$course->post_title ); |
|
| 317 | + $module_courses[] = array('id' =>$course->ID, 'details'=>$course->post_title); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | for="module_courses"><?php _e('Course(s)', 'woothemes-sensei'); ?></label></th> |
| 325 | 325 | <td> |
| 326 | 326 | <input type="hidden" |
| 327 | - data-defaults="<?php echo esc_attr( json_encode($module_courses)); ?>" |
|
| 328 | - value="<?php echo esc_attr( json_encode($module_courses) ); ?>" |
|
| 327 | + data-defaults="<?php echo esc_attr(json_encode($module_courses)); ?>" |
|
| 328 | + value="<?php echo esc_attr(json_encode($module_courses)); ?>" |
|
| 329 | 329 | id="module_courses" name="module_courses" |
| 330 | 330 | class="ajax_chosen_select_courses" |
| 331 | 331 | placeholder="<?php esc_attr_e('Search for courses...', 'woothemes-sensei'); ?>" |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | // Add module to selected courses |
| 373 | - if ( isset( $_POST['module_courses'] ) && ! empty( $_POST['module_courses'] ) ) { |
|
| 373 | + if (isset($_POST['module_courses']) && ! empty($_POST['module_courses'])) { |
|
| 374 | 374 | |
| 375 | - $course_ids = explode( ",", $_POST['module_courses'] ); |
|
| 375 | + $course_ids = explode(",", $_POST['module_courses']); |
|
| 376 | 376 | |
| 377 | - foreach ( $course_ids as $course_id ) { |
|
| 377 | + foreach ($course_ids as $course_id) { |
|
| 378 | 378 | |
| 379 | 379 | wp_set_object_terms($course_id, $module_id, $this->taxonomy, true); |
| 380 | 380 | |
@@ -438,11 +438,11 @@ discard block |
||
| 438 | 438 | * @since 1.8.0 |
| 439 | 439 | * @return void |
| 440 | 440 | */ |
| 441 | - public function single_course_modules(){ |
|
| 441 | + public function single_course_modules() { |
|
| 442 | 442 | |
| 443 | - _deprecated_function('Sensei_Modules->single_course_modules','Sensei 1.9.0', 'Sensei()->modules->load_course_module_content_template'); |
|
| 443 | + _deprecated_function('Sensei_Modules->single_course_modules', 'Sensei 1.9.0', 'Sensei()->modules->load_course_module_content_template'); |
|
| 444 | 444 | // only show modules on the course that has modules |
| 445 | - if( is_singular( 'course' ) && has_term( '', 'module' ) ) { |
|
| 445 | + if (is_singular('course') && has_term('', 'module')) { |
|
| 446 | 446 | |
| 447 | 447 | $this->load_course_module_content_template(); |
| 448 | 448 | |
@@ -459,15 +459,15 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | if (method_exists('Sensei_Utils', 'is_preview_lesson') && Sensei_Utils::is_preview_lesson($lesson_id)) { |
| 461 | 461 | $is_user_taking_course = Sensei_Utils::sensei_check_for_activity(array('post_id' => $course_id, 'user_id' => $current_user->ID, 'type' => 'sensei_course_status')); |
| 462 | - if (!$is_user_taking_course) { |
|
| 462 | + if ( ! $is_user_taking_course) { |
|
| 463 | 463 | if (method_exists('WooThemes_Sensei_Frontend', 'sensei_lesson_preview_title_text')) { |
| 464 | 464 | $title_text = Sensei()->frontend->sensei_lesson_preview_title_text($course_id); |
| 465 | 465 | // Remove brackets for display here |
| 466 | 466 | $title_text = str_replace('(', '', $title_text); |
| 467 | 467 | $title_text = str_replace(')', '', $title_text); |
| 468 | - $title_text = '<span class="preview-label">' . $title_text . '</span>'; |
|
| 468 | + $title_text = '<span class="preview-label">'.$title_text.'</span>'; |
|
| 469 | 469 | } |
| 470 | - $title .= ' ' . $title_text; |
|
| 470 | + $title .= ' '.$title_text; |
|
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | |
@@ -481,8 +481,8 @@ discard block |
||
| 481 | 481 | if (is_singular('lesson')) { |
| 482 | 482 | if (has_term('', $this->taxonomy, $post->ID)) { |
| 483 | 483 | $module = $this->get_lesson_module($post->ID); |
| 484 | - if( $module ) { |
|
| 485 | - $html .= ' ' . $separator . ' <a href="' . esc_url($module->url) . '" title="' . __('Back to the module', 'woothemes-sensei') . '">' . $module->name . '</a>'; |
|
| 484 | + if ($module) { |
|
| 485 | + $html .= ' '.$separator.' <a href="'.esc_url($module->url).'" title="'.__('Back to the module', 'woothemes-sensei').'">'.$module->name.'</a>'; |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | if (is_tax($this->taxonomy)) { |
| 491 | 491 | if (isset($_GET['course_id']) && 0 < intval($_GET['course_id'])) { |
| 492 | 492 | $course_id = intval($_GET['course_id']); |
| 493 | - $html .= '<a href="' . esc_url(get_permalink($course_id)) . '" title="' . __('Back to the course', 'woothemes-sensei') . '">' . get_the_title($course_id) . '</a>'; |
|
| 493 | + $html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>'; |
|
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | return $html; |
@@ -505,18 +505,18 @@ discard block |
||
| 505 | 505 | */ |
| 506 | 506 | public function module_archive_template($template) { |
| 507 | 507 | |
| 508 | - if ( ! is_tax($this->taxonomy) ) { |
|
| 508 | + if ( ! is_tax($this->taxonomy)) { |
|
| 509 | 509 | return $template; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | $file = 'archive-lesson.php'; |
| 513 | - $find = array( $file, Sensei()->template_url . $file ); |
|
| 513 | + $find = array($file, Sensei()->template_url.$file); |
|
| 514 | 514 | |
| 515 | 515 | // locate the template file |
| 516 | 516 | $template = locate_template($find); |
| 517 | - if (!$template) { |
|
| 517 | + if ( ! $template) { |
|
| 518 | 518 | |
| 519 | - $template = Sensei()->plugin_path() . 'templates/' . $file; |
|
| 519 | + $template = Sensei()->plugin_path().'templates/'.$file; |
|
| 520 | 520 | |
| 521 | 521 | } |
| 522 | 522 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | // Set order of lessons |
| 543 | 543 | if (version_compare(Sensei()->version, '1.6.0', '>=')) { |
| 544 | 544 | $module_id = $query->queried_object_id; |
| 545 | - $query->set('meta_key', '_order_module_' . $module_id); |
|
| 545 | + $query->set('meta_key', '_order_module_'.$module_id); |
|
| 546 | 546 | $query->set('orderby', 'meta_value_num date'); |
| 547 | 547 | } else { |
| 548 | 548 | $query->set('orderby', 'menu_order'); |
@@ -603,10 +603,10 @@ discard block |
||
| 603 | 603 | $status = __('In progress', 'woothemes-sensei'); |
| 604 | 604 | $class = 'in-progress'; |
| 605 | 605 | } |
| 606 | - echo '<p class="status ' . esc_attr($class) . '">' . $status . '</p>'; |
|
| 606 | + echo '<p class="status '.esc_attr($class).'">'.$status.'</p>'; |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - echo '<p class="archive-description module-description">' . apply_filters('sensei_module_archive_description', nl2br($module->description), $module->term_id) . '</p>'; |
|
| 609 | + echo '<p class="archive-description module-description">'.apply_filters('sensei_module_archive_description', nl2br($module->description), $module->term_id).'</p>'; |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | public function save_user_module_progress($module_id = 0, $course_id = 0, $user_id = 0) |
| 732 | 732 | { |
| 733 | 733 | $module_progress = $this->calculate_user_module_progress($user_id, $module_id, $course_id); |
| 734 | - update_user_meta(intval($user_id), '_module_progress_' . intval($course_id) . '_' . intval($module_id), intval($module_progress)); |
|
| 734 | + update_user_meta(intval($user_id), '_module_progress_'.intval($course_id).'_'.intval($module_id), intval($module_progress)); |
|
| 735 | 735 | |
| 736 | 736 | do_action('sensei_module_save_user_progress', $course_id, $module_id, $user_id, $module_progress); |
| 737 | 737 | } |
@@ -748,9 +748,9 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | public function get_user_module_progress($module_id = 0, $course_id = 0, $user_id = 0) |
| 750 | 750 | { |
| 751 | - $module_progress = get_user_meta(intval($user_id), '_module_progress_' . intval($course_id) . '_' . intval($module_id), true); |
|
| 751 | + $module_progress = get_user_meta(intval($user_id), '_module_progress_'.intval($course_id).'_'.intval($module_id), true); |
|
| 752 | 752 | if ($module_progress) { |
| 753 | - return (float)$module_progress; |
|
| 753 | + return (float) $module_progress; |
|
| 754 | 754 | } |
| 755 | 755 | return false; |
| 756 | 756 | } |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | } |
| 804 | 804 | $module_progress = ($completed_count / $lesson_count) * 100; |
| 805 | 805 | |
| 806 | - return (float)$module_progress; |
|
| 806 | + return (float) $module_progress; |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | /** |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | public function register_modules_admin_menu_items() |
| 817 | 817 | { |
| 818 | 818 | //add the modules link under the Course main menu |
| 819 | - add_submenu_page('edit.php?post_type=course', __('Modules', 'woothemes-sensei'), __('Modules', 'woothemes-sensei'), 'manage_categories', 'edit-tags.php?taxonomy=module','' ); |
|
| 819 | + add_submenu_page('edit.php?post_type=course', __('Modules', 'woothemes-sensei'), __('Modules', 'woothemes-sensei'), 'manage_categories', 'edit-tags.php?taxonomy=module', ''); |
|
| 820 | 820 | |
| 821 | 821 | // Regsiter new admin page for module ordering |
| 822 | 822 | $hook = add_submenu_page('edit.php?post_type=course', __('Order Modules', 'woothemes-sensei'), __('Order Modules', 'woothemes-sensei'), 'edit_lessons', $this->order_page_slug, array($this, 'module_order_screen')); |
@@ -843,19 +843,19 @@ discard block |
||
| 843 | 843 | $ordered = $this->save_course_module_order(esc_attr($_POST['module-order']), esc_attr($_POST['course_id'])); |
| 844 | 844 | |
| 845 | 845 | if ($ordered) { |
| 846 | - $html .= '<div class="updated fade">' . "\n"; |
|
| 847 | - $html .= '<p>' . __('The module order has been saved for this course.', 'woothemes-sensei') . '</p>' . "\n"; |
|
| 848 | - $html .= '</div>' . "\n"; |
|
| 846 | + $html .= '<div class="updated fade">'."\n"; |
|
| 847 | + $html .= '<p>'.__('The module order has been saved for this course.', 'woothemes-sensei').'</p>'."\n"; |
|
| 848 | + $html .= '</div>'."\n"; |
|
| 849 | 849 | } |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | $courses = Sensei()->course->get_all_courses(); |
| 853 | 853 | |
| 854 | - $html .= '<form action="' . admin_url('edit.php') . '" method="get">' . "\n"; |
|
| 855 | - $html .= '<input type="hidden" name="post_type" value="course" />' . "\n"; |
|
| 856 | - $html .= '<input type="hidden" name="page" value="' . esc_attr($this->order_page_slug) . '" />' . "\n"; |
|
| 857 | - $html .= '<select id="module-order-course" name="course_id">' . "\n"; |
|
| 858 | - $html .= '<option value="">' . __('Select a course', 'woothemes-sensei') . '</option>' . "\n"; |
|
| 854 | + $html .= '<form action="'.admin_url('edit.php').'" method="get">'."\n"; |
|
| 855 | + $html .= '<input type="hidden" name="post_type" value="course" />'."\n"; |
|
| 856 | + $html .= '<input type="hidden" name="page" value="'.esc_attr($this->order_page_slug).'" />'."\n"; |
|
| 857 | + $html .= '<select id="module-order-course" name="course_id">'."\n"; |
|
| 858 | + $html .= '<option value="">'.__('Select a course', 'woothemes-sensei').'</option>'."\n"; |
|
| 859 | 859 | |
| 860 | 860 | foreach ($courses as $course) { |
| 861 | 861 | if (has_term('', $this->taxonomy, $course->ID)) { |
@@ -863,30 +863,30 @@ discard block |
||
| 863 | 863 | if (isset($_GET['course_id'])) { |
| 864 | 864 | $course_id = intval($_GET['course_id']); |
| 865 | 865 | } |
| 866 | - $html .= '<option value="' . esc_attr(intval($course->ID)) . '" ' . selected($course->ID, $course_id, false) . '>' . get_the_title($course->ID) . '</option>' . "\n"; |
|
| 866 | + $html .= '<option value="'.esc_attr(intval($course->ID)).'" '.selected($course->ID, $course_id, false).'>'.get_the_title($course->ID).'</option>'."\n"; |
|
| 867 | 867 | } |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - $html .= '</select>' . "\n"; |
|
| 871 | - $html .= '<input type="submit" class="button-primary module-order-select-course-submit" value="' . __('Select', 'woothemes-sensei') . '" />' . "\n"; |
|
| 872 | - $html .= '</form>' . "\n"; |
|
| 870 | + $html .= '</select>'."\n"; |
|
| 871 | + $html .= '<input type="submit" class="button-primary module-order-select-course-submit" value="'.__('Select', 'woothemes-sensei').'" />'."\n"; |
|
| 872 | + $html .= '</form>'."\n"; |
|
| 873 | 873 | |
| 874 | 874 | if (isset($_GET['course_id'])) { |
| 875 | 875 | $course_id = intval($_GET['course_id']); |
| 876 | 876 | if ($course_id > 0) { |
| 877 | 877 | $modules = $this->get_course_modules($course_id); |
| 878 | - $modules = $this->append_teacher_name_to_module( $modules, array( 'module' ), array() ); |
|
| 878 | + $modules = $this->append_teacher_name_to_module($modules, array('module'), array()); |
|
| 879 | 879 | if ($modules) { |
| 880 | 880 | |
| 881 | 881 | $order = $this->get_course_module_order($course_id); |
| 882 | 882 | |
| 883 | - $order_string=''; |
|
| 883 | + $order_string = ''; |
|
| 884 | 884 | if ($order) { |
| 885 | 885 | $order_string = implode(',', $order); |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
|
| 889 | - $html .= '<ul class="sortable-module-list">' . "\n"; |
|
| 888 | + $html .= '<form id="editgrouping" method="post" action="" class="validate">'."\n"; |
|
| 889 | + $html .= '<ul class="sortable-module-list">'."\n"; |
|
| 890 | 890 | $count = 0; |
| 891 | 891 | foreach ($modules as $module) { |
| 892 | 892 | $count++; |
@@ -900,14 +900,14 @@ discard block |
||
| 900 | 900 | if ($count % 2 != 0) { |
| 901 | 901 | $class .= ' alternate'; |
| 902 | 902 | } |
| 903 | - $html .= '<li class="' . esc_attr($class) . '"><span rel="' . esc_attr($module->term_id) . '" style="width: 100%;"> ' . $module->name . '</span></li>' . "\n"; |
|
| 903 | + $html .= '<li class="'.esc_attr($class).'"><span rel="'.esc_attr($module->term_id).'" style="width: 100%;"> '.$module->name.'</span></li>'."\n"; |
|
| 904 | 904 | } |
| 905 | - $html .= '</ul>' . "\n"; |
|
| 905 | + $html .= '</ul>'."\n"; |
|
| 906 | 906 | |
| 907 | - $html .= '<input type="hidden" name="module-order" value="' . $order_string . '" />' . "\n"; |
|
| 908 | - $html .= '<input type="hidden" name="course_id" value="' . $course_id . '" />' . "\n"; |
|
| 909 | - $html .= '<input type="submit" class="button-primary" value="' . __('Save module order', 'woothemes-sensei') . '" />' . "\n"; |
|
| 910 | - $html .= '<a href="' . admin_url('post.php?post=' . $course_id . '&action=edit') . '" class="button-secondary">' . __('Edit course', 'woothemes-sensei') . '</a>' . "\n"; |
|
| 907 | + $html .= '<input type="hidden" name="module-order" value="'.$order_string.'" />'."\n"; |
|
| 908 | + $html .= '<input type="hidden" name="course_id" value="'.$course_id.'" />'."\n"; |
|
| 909 | + $html .= '<input type="submit" class="button-primary" value="'.__('Save module order', 'woothemes-sensei').'" />'."\n"; |
|
| 910 | + $html .= '<a href="'.admin_url('post.php?post='.$course_id.'&action=edit').'" class="button-secondary">'.__('Edit course', 'woothemes-sensei').'</a>'."\n"; |
|
| 911 | 911 | } |
| 912 | 912 | } |
| 913 | 913 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | { |
| 945 | 945 | if ($column == 'module_order') { |
| 946 | 946 | if (has_term('', $this->taxonomy, $course_id)) { |
| 947 | - echo '<a class="button-secondary" href="' . admin_url('edit.php?post_type=course&page=module-order&course_id=' . urlencode(intval($course_id))) . '">' . __('Order modules', 'woothemes-sensei') . '</a>'; |
|
| 947 | + echo '<a class="button-secondary" href="'.admin_url('edit.php?post_type=course&page=module-order&course_id='.urlencode(intval($course_id))).'">'.__('Order modules', 'woothemes-sensei').'</a>'; |
|
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | } |
@@ -1036,7 +1036,7 @@ discard block |
||
| 1036 | 1036 | $args['post_type'] = 'lesson'; |
| 1037 | 1037 | $lessons = get_posts($args); |
| 1038 | 1038 | $total_lessons = count($lessons); |
| 1039 | - $column_data = '<a href="' . admin_url('edit.php?module=' . urlencode($module->slug) . '&post_type=lesson') . '">' . intval($total_lessons) . '</a>'; |
|
| 1039 | + $column_data = '<a href="'.admin_url('edit.php?module='.urlencode($module->slug).'&post_type=lesson').'">'.intval($total_lessons).'</a>'; |
|
| 1040 | 1040 | break; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | public function analysis_overview_column_title($columns) |
| 1055 | 1055 | { |
| 1056 | 1056 | |
| 1057 | - if ( isset( $_GET['view'] ) && 'lessons' == $_GET['view'] ) { |
|
| 1057 | + if (isset($_GET['view']) && 'lessons' == $_GET['view']) { |
|
| 1058 | 1058 | $new_columns = array(); |
| 1059 | 1059 | if (is_array($columns) && 0 < count($columns)) { |
| 1060 | 1060 | foreach ($columns as $column => $title) { |
@@ -1082,15 +1082,15 @@ discard block |
||
| 1082 | 1082 | * @param WP_Post $lesson |
| 1083 | 1083 | * @return array Updated column data |
| 1084 | 1084 | */ |
| 1085 | - public function analysis_overview_column_data($columns, $lesson ) |
|
| 1085 | + public function analysis_overview_column_data($columns, $lesson) |
|
| 1086 | 1086 | { |
| 1087 | 1087 | |
| 1088 | - if ( isset( $_GET['view'] ) && 'lessons' == $_GET['view'] ) { |
|
| 1088 | + if (isset($_GET['view']) && 'lessons' == $_GET['view']) { |
|
| 1089 | 1089 | $lesson_module = ''; |
| 1090 | 1090 | $lesson_module_list = wp_get_post_terms($lesson->ID, $this->taxonomy); |
| 1091 | 1091 | if (is_array($lesson_module_list) && count($lesson_module_list) > 0) { |
| 1092 | 1092 | foreach ($lesson_module_list as $single_module) { |
| 1093 | - $lesson_module = '<a href="' . esc_url(admin_url('edit-tags.php?action=edit&taxonomy=' . urlencode($this->taxonomy) . '&tag_ID=' . urlencode($single_module->term_id))) . '">' . $single_module->name . '</a>'; |
|
| 1093 | + $lesson_module = '<a href="'.esc_url(admin_url('edit-tags.php?action=edit&taxonomy='.urlencode($this->taxonomy).'&tag_ID='.urlencode($single_module->term_id))).'">'.$single_module->name.'</a>'; |
|
| 1094 | 1094 | break; |
| 1095 | 1095 | } |
| 1096 | 1096 | } |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | */ |
| 1112 | 1112 | public function analysis_course_column_title($columns) |
| 1113 | 1113 | { |
| 1114 | - if ( isset( $_GET['view'] ) && 'lessons' == $_GET['view'] ) { |
|
| 1114 | + if (isset($_GET['view']) && 'lessons' == $_GET['view']) { |
|
| 1115 | 1115 | $columns['lesson_module'] = __('Module', 'woothemes-sensei'); |
| 1116 | 1116 | } |
| 1117 | 1117 | return $columns; |
@@ -1126,15 +1126,15 @@ discard block |
||
| 1126 | 1126 | * @param WP_Post $lesson |
| 1127 | 1127 | * @return array Updated columns data |
| 1128 | 1128 | */ |
| 1129 | - public function analysis_course_column_data($columns, $lesson ) |
|
| 1129 | + public function analysis_course_column_data($columns, $lesson) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | |
| 1132 | - if ( isset( $_GET['course_id'] ) ) { |
|
| 1132 | + if (isset($_GET['course_id'])) { |
|
| 1133 | 1133 | $lesson_module = ''; |
| 1134 | 1134 | $lesson_module_list = wp_get_post_terms($lesson->ID, $this->taxonomy); |
| 1135 | 1135 | if (is_array($lesson_module_list) && count($lesson_module_list) > 0) { |
| 1136 | 1136 | foreach ($lesson_module_list as $single_module) { |
| 1137 | - $lesson_module = '<a href="' . esc_url(admin_url('edit-tags.php?action=edit&taxonomy=' . urlencode($this->taxonomy) . '&tag_ID=' . urlencode($single_module->term_id))) . '">' . $single_module->name . '</a>'; |
|
| 1137 | + $lesson_module = '<a href="'.esc_url(admin_url('edit-tags.php?action=edit&taxonomy='.urlencode($this->taxonomy).'&tag_ID='.urlencode($single_module->term_id))).'">'.$single_module->name.'</a>'; |
|
| 1138 | 1138 | break; |
| 1139 | 1139 | } |
| 1140 | 1140 | } |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | public function get_lesson_module($lesson_id = 0) |
| 1162 | 1162 | { |
| 1163 | 1163 | $lesson_id = intval($lesson_id); |
| 1164 | - if ( ! ( intval( $lesson_id > 0) ) ) { |
|
| 1164 | + if ( ! (intval($lesson_id > 0))) { |
|
| 1165 | 1165 | return false; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
@@ -1169,9 +1169,9 @@ discard block |
||
| 1169 | 1169 | $modules = wp_get_post_terms($lesson_id, $this->taxonomy); |
| 1170 | 1170 | |
| 1171 | 1171 | //check if error returned |
| 1172 | - if( empty( $modules ) |
|
| 1173 | - || is_wp_error( $modules ) |
|
| 1174 | - || isset( $modules['errors'] ) ){ |
|
| 1172 | + if (empty($modules) |
|
| 1173 | + || is_wp_error($modules) |
|
| 1174 | + || isset($modules['errors'])) { |
|
| 1175 | 1175 | |
| 1176 | 1176 | return false; |
| 1177 | 1177 | |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | |
| 1180 | 1180 | // get the last item in the array there should be only be 1 really. |
| 1181 | 1181 | // this method works for all php versions. |
| 1182 | - foreach( $modules as $module ){ |
|
| 1182 | + foreach ($modules as $module) { |
|
| 1183 | 1183 | break; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | if (isset($course_id) && 0 < $course_id) { |
| 1193 | 1193 | |
| 1194 | 1194 | // the course should contain the same module taxonomy term for this to be valid |
| 1195 | - if( ! has_term( $module, $this->taxonomy, $course_id)){ |
|
| 1195 | + if ( ! has_term($module, $this->taxonomy, $course_id)) { |
|
| 1196 | 1196 | return false; |
| 1197 | 1197 | } |
| 1198 | 1198 | |
@@ -1264,8 +1264,8 @@ discard block |
||
| 1264 | 1264 | */ |
| 1265 | 1265 | public function enqueue_styles() { |
| 1266 | 1266 | |
| 1267 | - wp_register_style($this->taxonomy . '-frontend', esc_url($this->assets_url) . 'css/modules-frontend.css', Sensei()->version ); |
|
| 1268 | - wp_enqueue_style($this->taxonomy . '-frontend'); |
|
| 1267 | + wp_register_style($this->taxonomy.'-frontend', esc_url($this->assets_url).'css/modules-frontend.css', Sensei()->version); |
|
| 1268 | + wp_enqueue_style($this->taxonomy.'-frontend'); |
|
| 1269 | 1269 | |
| 1270 | 1270 | } |
| 1271 | 1271 | |
@@ -1276,37 +1276,37 @@ discard block |
||
| 1276 | 1276 | * |
| 1277 | 1277 | * @return void |
| 1278 | 1278 | */ |
| 1279 | - public function admin_enqueue_scripts( $hook ) { |
|
| 1279 | + public function admin_enqueue_scripts($hook) { |
|
| 1280 | 1280 | |
| 1281 | 1281 | /** |
| 1282 | 1282 | * Filter the page hooks where modules admin script can be loaded on. |
| 1283 | 1283 | * |
| 1284 | 1284 | * @param array $white_listed_pages |
| 1285 | 1285 | */ |
| 1286 | - $script_on_pages_white_list = apply_filters( 'sensei_module_admin_script_page_white_lists', array( |
|
| 1286 | + $script_on_pages_white_list = apply_filters('sensei_module_admin_script_page_white_lists', array( |
|
| 1287 | 1287 | 'edit-tags.php', |
| 1288 | 1288 | 'course_page_module-order', |
| 1289 | 1289 | 'post-new.php', |
| 1290 | 1290 | 'post.php' |
| 1291 | - ) ); |
|
| 1291 | + )); |
|
| 1292 | 1292 | |
| 1293 | - if ( ! in_array( $hook, $script_on_pages_white_list ) ) { |
|
| 1293 | + if ( ! in_array($hook, $script_on_pages_white_list)) { |
|
| 1294 | 1294 | return; |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1297 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 1298 | 1298 | |
| 1299 | - wp_enqueue_script( 'sensei-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true); |
|
| 1300 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version , true ); |
|
| 1301 | - wp_enqueue_script( $this->taxonomy . '-admin', esc_url( $this->assets_url ) . 'js/modules-admin' . $suffix . '.js', array( 'jquery', 'sensei-chosen', 'sensei-chosen-ajax', 'jquery-ui-sortable', 'sensei-core-select2' ), Sensei()->version, true ); |
|
| 1299 | + wp_enqueue_script('sensei-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true); |
|
| 1300 | + wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-chosen'), Sensei()->version, true); |
|
| 1301 | + wp_enqueue_script($this->taxonomy.'-admin', esc_url($this->assets_url).'js/modules-admin'.$suffix.'.js', array('jquery', 'sensei-chosen', 'sensei-chosen-ajax', 'jquery-ui-sortable', 'sensei-core-select2'), Sensei()->version, true); |
|
| 1302 | 1302 | |
| 1303 | 1303 | // localized module data |
| 1304 | 1304 | $localize_modulesAdmin = array( |
| 1305 | - 'search_courses_nonce' => wp_create_nonce( 'search-courses' ), |
|
| 1306 | - 'selectPlaceholder' => __( 'Search for courses', 'woothemes-sensei' ) |
|
| 1305 | + 'search_courses_nonce' => wp_create_nonce('search-courses'), |
|
| 1306 | + 'selectPlaceholder' => __('Search for courses', 'woothemes-sensei') |
|
| 1307 | 1307 | ); |
| 1308 | 1308 | |
| 1309 | - wp_localize_script( $this->taxonomy . '-admin' ,'modulesAdmin', $localize_modulesAdmin ); |
|
| 1309 | + wp_localize_script($this->taxonomy.'-admin', 'modulesAdmin', $localize_modulesAdmin); |
|
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | /** |
@@ -1318,8 +1318,8 @@ discard block |
||
| 1318 | 1318 | */ |
| 1319 | 1319 | public function admin_enqueue_styles() { |
| 1320 | 1320 | |
| 1321 | - wp_register_style($this->taxonomy . '-sortable', esc_url($this->assets_url) . 'css/modules-admin.css','',Sensei()->version ); |
|
| 1322 | - wp_enqueue_style($this->taxonomy . '-sortable'); |
|
| 1321 | + wp_register_style($this->taxonomy.'-sortable', esc_url($this->assets_url).'css/modules-admin.css', '', Sensei()->version); |
|
| 1322 | + wp_enqueue_style($this->taxonomy.'-sortable'); |
|
| 1323 | 1323 | |
| 1324 | 1324 | } |
| 1325 | 1325 | |
@@ -1333,9 +1333,9 @@ discard block |
||
| 1333 | 1333 | */ |
| 1334 | 1334 | public function course_modules_title( ) { |
| 1335 | 1335 | |
| 1336 | - if( sensei_module_has_lessons() ){ |
|
| 1336 | + if (sensei_module_has_lessons()) { |
|
| 1337 | 1337 | |
| 1338 | - echo '<header><h2>' . __('Modules', 'woothemes-sensei') . '</h2></header>'; |
|
| 1338 | + echo '<header><h2>'.__('Modules', 'woothemes-sensei').'</h2></header>'; |
|
| 1339 | 1339 | |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1348,22 +1348,22 @@ discard block |
||
| 1348 | 1348 | * @since 1.8.0 |
| 1349 | 1349 | * @return void |
| 1350 | 1350 | */ |
| 1351 | - public function load_course_module_content_template(){ |
|
| 1351 | + public function load_course_module_content_template() { |
|
| 1352 | 1352 | |
| 1353 | - if ( ! is_singular( 'course' ) ) { |
|
| 1353 | + if ( ! is_singular('course')) { |
|
| 1354 | 1354 | return; |
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | // load backwards compatible template name if it exists in the users theme |
| 1358 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-modules.php' ); |
|
| 1359 | - if( $located_template ){ |
|
| 1358 | + $located_template = locate_template(Sensei()->template_url.'single-course/course-modules.php'); |
|
| 1359 | + if ($located_template) { |
|
| 1360 | 1360 | |
| 1361 | - Sensei_Templates::get_template( 'single-course/course-modules.php' ); |
|
| 1361 | + Sensei_Templates::get_template('single-course/course-modules.php'); |
|
| 1362 | 1362 | return; |
| 1363 | 1363 | |
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | - Sensei_Templates::get_template( 'single-course/modules.php' ); |
|
| 1366 | + Sensei_Templates::get_template('single-course/modules.php'); |
|
| 1367 | 1367 | |
| 1368 | 1368 | } // end course_module_content |
| 1369 | 1369 | |
@@ -1376,15 +1376,15 @@ discard block |
||
| 1376 | 1376 | * @param $term_id |
| 1377 | 1377 | * @return array $lessons |
| 1378 | 1378 | */ |
| 1379 | - public function get_lessons( $course_id , $term_id ){ |
|
| 1379 | + public function get_lessons($course_id, $term_id) { |
|
| 1380 | 1380 | |
| 1381 | - $lesson_query = $this->get_lessons_query( $course_id, $term_id ); |
|
| 1381 | + $lesson_query = $this->get_lessons_query($course_id, $term_id); |
|
| 1382 | 1382 | |
| 1383 | - if( isset( $lesson_query->posts ) ){ |
|
| 1383 | + if (isset($lesson_query->posts)) { |
|
| 1384 | 1384 | |
| 1385 | 1385 | return $lesson_query->posts; |
| 1386 | 1386 | |
| 1387 | - }else{ |
|
| 1387 | + } else { |
|
| 1388 | 1388 | |
| 1389 | 1389 | return array(); |
| 1390 | 1390 | |
@@ -1401,9 +1401,9 @@ discard block |
||
| 1401 | 1401 | * @param $term_id |
| 1402 | 1402 | * @return WP_Query $lessons_query |
| 1403 | 1403 | */ |
| 1404 | - public function get_lessons_query( $course_id , $term_id ){ |
|
| 1404 | + public function get_lessons_query($course_id, $term_id) { |
|
| 1405 | 1405 | |
| 1406 | - if( empty( $term_id ) || empty( $course_id ) ){ |
|
| 1406 | + if (empty($term_id) || empty($course_id)) { |
|
| 1407 | 1407 | |
| 1408 | 1408 | return array(); |
| 1409 | 1409 | |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | array( |
| 1425 | 1425 | 'taxonomy' => 'module', |
| 1426 | 1426 | 'field' => 'id', |
| 1427 | - 'terms' => intval( $term_id ) |
|
| 1427 | + 'terms' => intval($term_id) |
|
| 1428 | 1428 | ) |
| 1429 | 1429 | ), |
| 1430 | 1430 | 'orderby' => 'menu_order', |
@@ -1432,12 +1432,12 @@ discard block |
||
| 1432 | 1432 | 'suppress_filters' => 0 |
| 1433 | 1433 | ); |
| 1434 | 1434 | |
| 1435 | - if (version_compare( Sensei()->version, '1.6.0', '>=')) { |
|
| 1436 | - $args['meta_key'] = '_order_module_' . intval( $term_id ); |
|
| 1435 | + if (version_compare(Sensei()->version, '1.6.0', '>=')) { |
|
| 1436 | + $args['meta_key'] = '_order_module_'.intval($term_id); |
|
| 1437 | 1437 | $args['orderby'] = 'meta_value_num date'; |
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | - $lessons_query = new WP_Query( $args ); |
|
| 1440 | + $lessons_query = new WP_Query($args); |
|
| 1441 | 1441 | |
| 1442 | 1442 | return $lessons_query; |
| 1443 | 1443 | |
@@ -1452,37 +1452,37 @@ discard block |
||
| 1452 | 1452 | * |
| 1453 | 1453 | * @return array $non_module_lessons |
| 1454 | 1454 | */ |
| 1455 | - public function get_none_module_lessons( $course_id ){ |
|
| 1455 | + public function get_none_module_lessons($course_id) { |
|
| 1456 | 1456 | |
| 1457 | 1457 | $non_module_lessons = array(); |
| 1458 | 1458 | |
| 1459 | 1459 | //exit if there is no course id passed in |
| 1460 | - if( empty( $course_id ) || 'course' != get_post_type( $course_id ) ) { |
|
| 1460 | + if (empty($course_id) || 'course' != get_post_type($course_id)) { |
|
| 1461 | 1461 | |
| 1462 | 1462 | return $non_module_lessons; |
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | 1465 | //save some time and check if we already have the saved |
| 1466 | - if( get_transient( 'sensei_'. $course_id .'_none_module_lessons') ){ |
|
| 1466 | + if (get_transient('sensei_'.$course_id.'_none_module_lessons')) { |
|
| 1467 | 1467 | |
| 1468 | - return get_transient( 'sensei_'. $course_id .'_none_module_lessons'); |
|
| 1468 | + return get_transient('sensei_'.$course_id.'_none_module_lessons'); |
|
| 1469 | 1469 | |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | // create terms array which must be excluded from other arrays |
| 1473 | - $course_modules = $this->get_course_modules( $course_id ); |
|
| 1473 | + $course_modules = $this->get_course_modules($course_id); |
|
| 1474 | 1474 | |
| 1475 | 1475 | //exit if there are no module on this course |
| 1476 | - if( empty( $course_modules ) || ! is_array( $course_modules ) ){ |
|
| 1476 | + if (empty($course_modules) || ! is_array($course_modules)) { |
|
| 1477 | 1477 | |
| 1478 | - return Sensei()->course->course_lessons( $course_id ); |
|
| 1478 | + return Sensei()->course->course_lessons($course_id); |
|
| 1479 | 1479 | |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | 1482 | $terms = array(); |
| 1483 | - foreach( $course_modules as $module ){ |
|
| 1483 | + foreach ($course_modules as $module) { |
|
| 1484 | 1484 | |
| 1485 | - array_push( $terms , $module->term_id ); |
|
| 1485 | + array_push($terms, $module->term_id); |
|
| 1486 | 1486 | |
| 1487 | 1487 | } |
| 1488 | 1488 | |
@@ -1493,7 +1493,7 @@ discard block |
||
| 1493 | 1493 | 'meta_query' => array( |
| 1494 | 1494 | array( |
| 1495 | 1495 | 'key' => '_lesson_course', |
| 1496 | - 'value' => intval( $course_id ), |
|
| 1496 | + 'value' => intval($course_id), |
|
| 1497 | 1497 | 'compare' => '=' |
| 1498 | 1498 | ) |
| 1499 | 1499 | ), |
@@ -1510,11 +1510,11 @@ discard block |
||
| 1510 | 1510 | 'suppress_filters' => 0 |
| 1511 | 1511 | ); |
| 1512 | 1512 | |
| 1513 | - $wp_lessons_query = new WP_Query( $args ); |
|
| 1513 | + $wp_lessons_query = new WP_Query($args); |
|
| 1514 | 1514 | |
| 1515 | - if( isset( $wp_lessons_query->posts) && count( $wp_lessons_query->posts ) > 0 ){ |
|
| 1515 | + if (isset($wp_lessons_query->posts) && count($wp_lessons_query->posts) > 0) { |
|
| 1516 | 1516 | $non_module_lessons = $wp_lessons_query->get_posts(); |
| 1517 | - set_transient( 'sensei_'. $course_id .'_none_module_lessons', $non_module_lessons, 10 * DAY_IN_SECONDS ); |
|
| 1517 | + set_transient('sensei_'.$course_id.'_none_module_lessons', $non_module_lessons, 10 * DAY_IN_SECONDS); |
|
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | 1520 | return $non_module_lessons; |
@@ -1525,7 +1525,7 @@ discard block |
||
| 1525 | 1525 | * |
| 1526 | 1526 | * @since 1.8.0 |
| 1527 | 1527 | */ |
| 1528 | - public function setup_modules_taxonomy(){ |
|
| 1528 | + public function setup_modules_taxonomy() { |
|
| 1529 | 1529 | |
| 1530 | 1530 | $labels = array( |
| 1531 | 1531 | 'name' => __('Modules', 'woothemes-sensei'), |
@@ -1562,11 +1562,11 @@ discard block |
||
| 1562 | 1562 | 'show_in_nav_menus' => false, |
| 1563 | 1563 | 'show_in_quick_edit' => false, |
| 1564 | 1564 | 'show_ui' => true, |
| 1565 | - 'rewrite' => array('slug' => $modules_rewrite_slug ), |
|
| 1565 | + 'rewrite' => array('slug' => $modules_rewrite_slug), |
|
| 1566 | 1566 | 'labels' => $labels |
| 1567 | 1567 | ); |
| 1568 | 1568 | |
| 1569 | - register_taxonomy( 'module' , array('course', 'lesson'), $args); |
|
| 1569 | + register_taxonomy('module', array('course', 'lesson'), $args); |
|
| 1570 | 1570 | |
| 1571 | 1571 | }// end setup_modules_taxonomy |
| 1572 | 1572 | |
@@ -1578,12 +1578,12 @@ discard block |
||
| 1578 | 1578 | * @since 1.8.0 |
| 1579 | 1579 | * @return void |
| 1580 | 1580 | */ |
| 1581 | - function redirect_to_lesson_module_taxonomy_to_course( ){ |
|
| 1581 | + function redirect_to_lesson_module_taxonomy_to_course( ) { |
|
| 1582 | 1582 | |
| 1583 | - global $typenow , $taxnow; |
|
| 1583 | + global $typenow, $taxnow; |
|
| 1584 | 1584 | |
| 1585 | - if( 'lesson'== $typenow && 'module'==$taxnow ){ |
|
| 1586 | - wp_safe_redirect( esc_url_raw( 'edit-tags.php?taxonomy=module&post_type=course' ) ); |
|
| 1585 | + if ('lesson' == $typenow && 'module' == $taxnow) { |
|
| 1586 | + wp_safe_redirect(esc_url_raw('edit-tags.php?taxonomy=module&post_type=course')); |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | }// end redirect to course taxonomy |
@@ -1596,18 +1596,18 @@ discard block |
||
| 1596 | 1596 | * @since 1.8.0 |
| 1597 | 1597 | * @return void |
| 1598 | 1598 | */ |
| 1599 | - public function remove_lessons_menu_model_taxonomy(){ |
|
| 1599 | + public function remove_lessons_menu_model_taxonomy() { |
|
| 1600 | 1600 | global $submenu; |
| 1601 | 1601 | |
| 1602 | - if( ! isset( $submenu['edit.php?post_type=lesson'] ) || !is_array( $submenu['edit.php?post_type=lesson'] ) ){ |
|
| 1602 | + if ( ! isset($submenu['edit.php?post_type=lesson']) || ! is_array($submenu['edit.php?post_type=lesson'])) { |
|
| 1603 | 1603 | return; // exit |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | 1606 | $lesson_main_menu = $submenu['edit.php?post_type=lesson']; |
| 1607 | - foreach( $lesson_main_menu as $index => $sub_item ){ |
|
| 1607 | + foreach ($lesson_main_menu as $index => $sub_item) { |
|
| 1608 | 1608 | |
| 1609 | - if( 'edit-tags.php?taxonomy=module&post_type=lesson' == $sub_item[2] ){ |
|
| 1610 | - unset( $submenu['edit.php?post_type=lesson'][ $index ]); |
|
| 1609 | + if ('edit-tags.php?taxonomy=module&post_type=lesson' == $sub_item[2]) { |
|
| 1610 | + unset($submenu['edit.php?post_type=lesson'][$index]); |
|
| 1611 | 1611 | } |
| 1612 | 1612 | } |
| 1613 | 1613 | |
@@ -1621,18 +1621,18 @@ discard block |
||
| 1621 | 1621 | * @since 1.8.0 |
| 1622 | 1622 | * @return void |
| 1623 | 1623 | */ |
| 1624 | - public function remove_courses_menu_model_taxonomy(){ |
|
| 1624 | + public function remove_courses_menu_model_taxonomy() { |
|
| 1625 | 1625 | global $submenu; |
| 1626 | 1626 | |
| 1627 | - if( ! isset( $submenu['edit.php?post_type=course'] ) || !is_array( $submenu['edit.php?post_type=course'] ) ){ |
|
| 1627 | + if ( ! isset($submenu['edit.php?post_type=course']) || ! is_array($submenu['edit.php?post_type=course'])) { |
|
| 1628 | 1628 | return; // exit |
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | $course_main_menu = $submenu['edit.php?post_type=course']; |
| 1632 | - foreach( $course_main_menu as $index => $sub_item ){ |
|
| 1632 | + foreach ($course_main_menu as $index => $sub_item) { |
|
| 1633 | 1633 | |
| 1634 | - if( 'edit-tags.php?taxonomy=module&post_type=course' == $sub_item[2] ){ |
|
| 1635 | - unset( $submenu['edit.php?post_type=course'][ $index ]); |
|
| 1634 | + if ('edit-tags.php?taxonomy=module&post_type=course' == $sub_item[2]) { |
|
| 1635 | + unset($submenu['edit.php?post_type=course'][$index]); |
|
| 1636 | 1636 | } |
| 1637 | 1637 | } |
| 1638 | 1638 | |
@@ -1648,12 +1648,12 @@ discard block |
||
| 1648 | 1648 | * @param string $term_name |
| 1649 | 1649 | * @return array $owners { type WP_User }. Empty array if none if found. |
| 1650 | 1650 | */ |
| 1651 | - public static function get_term_authors( $term_name ){ |
|
| 1651 | + public static function get_term_authors($term_name) { |
|
| 1652 | 1652 | |
| 1653 | - $terms = get_terms( array( 'module') , array( 'name__like'=>$term_name, 'hide_empty' => false ) ); |
|
| 1653 | + $terms = get_terms(array('module'), array('name__like'=>$term_name, 'hide_empty' => false)); |
|
| 1654 | 1654 | |
| 1655 | 1655 | $owners = array(); |
| 1656 | - if( empty( $terms ) ){ |
|
| 1656 | + if (empty($terms)) { |
|
| 1657 | 1657 | |
| 1658 | 1658 | return $owners; |
| 1659 | 1659 | |
@@ -1663,11 +1663,11 @@ discard block |
||
| 1663 | 1663 | |
| 1664 | 1664 | |
| 1665 | 1665 | //if there are more handle them appropriately and get the ones we really need that matches the desired name exactly |
| 1666 | - foreach( $terms as $term){ |
|
| 1667 | - if( $term->name == $term_name ){ |
|
| 1666 | + foreach ($terms as $term) { |
|
| 1667 | + if ($term->name == $term_name) { |
|
| 1668 | 1668 | |
| 1669 | 1669 | // look for the author in the slug |
| 1670 | - $owners[] = Sensei_Core_Modules::get_term_author( $term->slug ); |
|
| 1670 | + $owners[] = Sensei_Core_Modules::get_term_author($term->slug); |
|
| 1671 | 1671 | |
| 1672 | 1672 | }// end if term name |
| 1673 | 1673 | |
@@ -1688,30 +1688,30 @@ discard block |
||
| 1688 | 1688 | * @param $slug |
| 1689 | 1689 | * @return WP_User $author if no author is found or invalid term is passed the admin user will be returned. |
| 1690 | 1690 | */ |
| 1691 | - public static function get_term_author( $slug='' ){ |
|
| 1691 | + public static function get_term_author($slug = '') { |
|
| 1692 | 1692 | |
| 1693 | - $term_owner = get_user_by( 'email', get_bloginfo( 'admin_email' ) ); |
|
| 1693 | + $term_owner = get_user_by('email', get_bloginfo('admin_email')); |
|
| 1694 | 1694 | |
| 1695 | - if( empty( $slug ) ){ |
|
| 1695 | + if (empty($slug)) { |
|
| 1696 | 1696 | |
| 1697 | 1697 | return $term_owner; |
| 1698 | 1698 | |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | 1701 | // look for the author in the slug |
| 1702 | - $slug_parts = explode( '-', $slug ); |
|
| 1702 | + $slug_parts = explode('-', $slug); |
|
| 1703 | 1703 | |
| 1704 | - if( count( $slug_parts ) > 1 ){ |
|
| 1704 | + if (count($slug_parts) > 1) { |
|
| 1705 | 1705 | |
| 1706 | 1706 | // get the user data |
| 1707 | 1707 | $possible_user_id = $slug_parts[0]; |
| 1708 | - $author = get_userdata( $possible_user_id ); |
|
| 1708 | + $author = get_userdata($possible_user_id); |
|
| 1709 | 1709 | |
| 1710 | 1710 | // if the user doesnt exist for the first part of the slug |
| 1711 | 1711 | // then this slug was also created by admin |
| 1712 | - if( is_a( $author, 'WP_User' ) ){ |
|
| 1712 | + if (is_a($author, 'WP_User')) { |
|
| 1713 | 1713 | |
| 1714 | - $term_owner = $author; |
|
| 1714 | + $term_owner = $author; |
|
| 1715 | 1715 | |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
@@ -1728,48 +1728,48 @@ discard block |
||
| 1728 | 1728 | * |
| 1729 | 1729 | * @param WP_Post $post Post object. |
| 1730 | 1730 | */ |
| 1731 | - public function course_module_metabox( $post ) { |
|
| 1731 | + public function course_module_metabox($post) { |
|
| 1732 | 1732 | |
| 1733 | 1733 | $tax_name = 'module'; |
| 1734 | - $taxonomy = get_taxonomy( 'module' ); |
|
| 1734 | + $taxonomy = get_taxonomy('module'); |
|
| 1735 | 1735 | |
| 1736 | 1736 | ?> |
| 1737 | 1737 | <div id="taxonomy-<?php echo $tax_name; ?>" class="categorydiv"> |
| 1738 | 1738 | <ul id="<?php echo $tax_name; ?>-tabs" class="category-tabs"> |
| 1739 | 1739 | <li class="tabs"><a href="#<?php echo $tax_name; ?>-all"><?php echo $taxonomy->labels->all_items; ?></a></li> |
| 1740 | - <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e( 'Most Used' ); ?></a></li> |
|
| 1740 | + <li class="hide-if-no-js"><a href="#<?php echo $tax_name; ?>-pop"><?php _e('Most Used'); ?></a></li> |
|
| 1741 | 1741 | </ul> |
| 1742 | 1742 | |
| 1743 | 1743 | <div id="<?php echo $tax_name; ?>-pop" class="tabs-panel" style="display: none;"> |
| 1744 | 1744 | <ul id="<?php echo $tax_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
| 1745 | - <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> |
|
| 1745 | + <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> |
|
| 1746 | 1746 | </ul> |
| 1747 | 1747 | </div> |
| 1748 | 1748 | |
| 1749 | 1749 | <div id="<?php echo $tax_name; ?>-all" class="tabs-panel"> |
| 1750 | 1750 | <?php |
| 1751 | - $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
| 1751 | + $name = ($tax_name == 'category') ? 'post_category' : 'tax_input['.$tax_name.']'; |
|
| 1752 | 1752 | echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
| 1753 | 1753 | ?> |
| 1754 | 1754 | <ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear"> |
| 1755 | - <?php wp_terms_checklist( $post->ID, array( 'taxonomy'=>$tax_name , 'popular_cats' => $popular_ids ) ); ?> |
|
| 1755 | + <?php wp_terms_checklist($post->ID, array('taxonomy'=>$tax_name, 'popular_cats' => $popular_ids)); ?> |
|
| 1756 | 1756 | </ul> |
| 1757 | 1757 | </div> |
| 1758 | - <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
| 1758 | + <?php if (current_user_can($taxonomy->cap->edit_terms)) : ?> |
|
| 1759 | 1759 | <div id="<?php echo $tax_name; ?>-adder" class="wp-hidden-children"> |
| 1760 | 1760 | <h4> |
| 1761 | 1761 | <a id="sensei-<?php echo $tax_name; ?>-add-toggle" href="#<?php echo $tax_name; ?>-add" class="hide-if-no-js"> |
| 1762 | 1762 | <?php |
| 1763 | 1763 | /* translators: %s: add new taxonomy label */ |
| 1764 | - printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); |
|
| 1764 | + printf(__('+ %s'), $taxonomy->labels->add_new_item); |
|
| 1765 | 1765 | ?> |
| 1766 | 1766 | </a> |
| 1767 | 1767 | </h4> |
| 1768 | 1768 | <p id="sensei-<?php echo $tax_name; ?>-add" class="category-add wp-hidden-child"> |
| 1769 | 1769 | <label class="screen-reader-text" for="new<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> |
| 1770 | - <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" aria-required="true"/> |
|
| 1771 | - <a class="button" id="sensei-<?php echo $tax_name; ?>-add-submit" class="button category-add-submit"><?php echo esc_attr( $taxonomy->labels->add_new_item ); ?></a> |
|
| 1772 | - <?php wp_nonce_field( '_ajax_nonce-add-' . $tax_name, 'add_module_nonce' ); ?> |
|
| 1770 | + <input type="text" name="new<?php echo $tax_name; ?>" id="new<?php echo $tax_name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" aria-required="true"/> |
|
| 1771 | + <a class="button" id="sensei-<?php echo $tax_name; ?>-add-submit" class="button category-add-submit"><?php echo esc_attr($taxonomy->labels->add_new_item); ?></a> |
|
| 1772 | + <?php wp_nonce_field('_ajax_nonce-add-'.$tax_name, 'add_module_nonce'); ?> |
|
| 1773 | 1773 | <span id="<?php echo $tax_name; ?>-ajax-response"></span> |
| 1774 | 1774 | </p> |
| 1775 | 1775 | </div> |
@@ -1789,55 +1789,55 @@ discard block |
||
| 1789 | 1789 | public static function add_new_module_term( ) { |
| 1790 | 1790 | |
| 1791 | 1791 | |
| 1792 | - if( ! isset( $_POST[ 'security' ] ) || ! wp_verify_nonce( $_POST[ 'security' ], '_ajax_nonce-add-module' ) ){ |
|
| 1793 | - wp_send_json_error( array('error'=> 'wrong security nonce') ); |
|
| 1792 | + if ( ! isset($_POST['security']) || ! wp_verify_nonce($_POST['security'], '_ajax_nonce-add-module')) { |
|
| 1793 | + wp_send_json_error(array('error'=> 'wrong security nonce')); |
|
| 1794 | 1794 | } |
| 1795 | 1795 | |
| 1796 | 1796 | // get the term an create the new term storing infomration |
| 1797 | - $term_name = sanitize_text_field( $_POST['newTerm'] ); |
|
| 1797 | + $term_name = sanitize_text_field($_POST['newTerm']); |
|
| 1798 | 1798 | |
| 1799 | - if( current_user_can('manage_options' ) ) { |
|
| 1799 | + if (current_user_can('manage_options')) { |
|
| 1800 | 1800 | |
| 1801 | - $term_slug = str_ireplace(' ', '-', trim( $term_name ) ); |
|
| 1801 | + $term_slug = str_ireplace(' ', '-', trim($term_name)); |
|
| 1802 | 1802 | |
| 1803 | 1803 | } else { |
| 1804 | 1804 | |
| 1805 | - $term_slug = get_current_user_id() . '-' . str_ireplace(' ', '-', trim( $term_name ) ); |
|
| 1805 | + $term_slug = get_current_user_id().'-'.str_ireplace(' ', '-', trim($term_name)); |
|
| 1806 | 1806 | |
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | - $course_id = sanitize_text_field( $_POST['course_id'] ); |
|
| 1809 | + $course_id = sanitize_text_field($_POST['course_id']); |
|
| 1810 | 1810 | |
| 1811 | 1811 | // save the term |
| 1812 | - $slug = wp_insert_term( $term_name,'module', array('slug'=> $term_slug) ); |
|
| 1812 | + $slug = wp_insert_term($term_name, 'module', array('slug'=> $term_slug)); |
|
| 1813 | 1813 | |
| 1814 | 1814 | // send error for all errors except term exits |
| 1815 | - if( is_wp_error( $slug ) ){ |
|
| 1815 | + if (is_wp_error($slug)) { |
|
| 1816 | 1816 | |
| 1817 | 1817 | // prepare for possible term name and id to be passed down if term exists |
| 1818 | 1818 | $term_data = array(); |
| 1819 | 1819 | |
| 1820 | 1820 | // if term exists also send back the term name and id |
| 1821 | - if( isset( $slug->errors['term_exists'] ) ){ |
|
| 1821 | + if (isset($slug->errors['term_exists'])) { |
|
| 1822 | 1822 | |
| 1823 | - $term = get_term_by( 'slug', $term_slug, 'module'); |
|
| 1823 | + $term = get_term_by('slug', $term_slug, 'module'); |
|
| 1824 | 1824 | $term_data['name'] = $term_name; |
| 1825 | 1825 | $term_data['id'] = $term->term_id; |
| 1826 | 1826 | |
| 1827 | 1827 | // set the object terms |
| 1828 | - wp_set_object_terms( $course_id, $term->term_id, 'module', true ); |
|
| 1828 | + wp_set_object_terms($course_id, $term->term_id, 'module', true); |
|
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | - wp_send_json_error(array( 'errors'=>$slug->errors , 'term'=> $term_data ) ); |
|
| 1831 | + wp_send_json_error(array('errors'=>$slug->errors, 'term'=> $term_data)); |
|
| 1832 | 1832 | |
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | 1835 | //make sure the new term is checked for this course |
| 1836 | 1836 | |
| 1837 | - wp_set_object_terms( $course_id, $slug['term_id'], 'module', true ); |
|
| 1837 | + wp_set_object_terms($course_id, $slug['term_id'], 'module', true); |
|
| 1838 | 1838 | |
| 1839 | 1839 | // Handle request then generate response using WP_Ajax_Response |
| 1840 | - wp_send_json_success( array( 'termId' => $slug['term_id'], 'termName' => $term_name ) ); |
|
| 1840 | + wp_send_json_success(array('termId' => $slug['term_id'], 'termName' => $term_name)); |
|
| 1841 | 1841 | |
| 1842 | 1842 | } |
| 1843 | 1843 | |
@@ -1849,26 +1849,26 @@ discard block |
||
| 1849 | 1849 | * |
| 1850 | 1850 | * @since 1.8.0 |
| 1851 | 1851 | */ |
| 1852 | - public function filter_module_terms( $terms, $taxonomies, $args ){ |
|
| 1852 | + public function filter_module_terms($terms, $taxonomies, $args) { |
|
| 1853 | 1853 | |
| 1854 | 1854 | //dont limit for admins and other taxonomies. This should also only apply to admin |
| 1855 | - if( current_user_can( 'manage_options' ) || !in_array( 'module', $taxonomies ) || ! is_admin() ){ |
|
| 1855 | + if (current_user_can('manage_options') || ! in_array('module', $taxonomies) || ! is_admin()) { |
|
| 1856 | 1856 | return $terms; |
| 1857 | 1857 | } |
| 1858 | 1858 | |
| 1859 | 1859 | // avoid infinite call loop |
| 1860 | - remove_filter('get_terms', array( $this, 'filter_module_terms' ), 20, 3 ); |
|
| 1860 | + remove_filter('get_terms', array($this, 'filter_module_terms'), 20, 3); |
|
| 1861 | 1861 | |
| 1862 | 1862 | // in certain cases the array is passed in as reference to the parent term_id => parent_id |
| 1863 | - if( isset( $args['fields'] ) && 'id=>parent' == $args['fields'] ){ |
|
| 1863 | + if (isset($args['fields']) && 'id=>parent' == $args['fields']) { |
|
| 1864 | 1864 | // change only scrub the terms ids form the array keys |
| 1865 | - $terms = array_keys( $terms ); |
|
| 1865 | + $terms = array_keys($terms); |
|
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | - $teachers_terms = $this->filter_terms_by_owner( $terms, get_current_user_id() ); |
|
| 1868 | + $teachers_terms = $this->filter_terms_by_owner($terms, get_current_user_id()); |
|
| 1869 | 1869 | |
| 1870 | 1870 | // add filter again as removed above |
| 1871 | - add_filter('get_terms', array( $this, 'filter_module_terms' ), 20, 3 ); |
|
| 1871 | + add_filter('get_terms', array($this, 'filter_module_terms'), 20, 3); |
|
| 1872 | 1872 | |
| 1873 | 1873 | return $teachers_terms; |
| 1874 | 1874 | }// end filter_module_terms |
@@ -1881,25 +1881,25 @@ discard block |
||
| 1881 | 1881 | * |
| 1882 | 1882 | * @since 1.8.0 |
| 1883 | 1883 | */ |
| 1884 | - public function filter_course_selected_terms( $terms, $course_ids_array, $taxonomies ){ |
|
| 1884 | + public function filter_course_selected_terms($terms, $course_ids_array, $taxonomies) { |
|
| 1885 | 1885 | |
| 1886 | 1886 | //dont limit for admins and other taxonomies. This should also only apply to admin |
| 1887 | - if( current_user_can( 'manage_options' ) || ! is_admin() || empty( $terms ) |
|
| 1887 | + if (current_user_can('manage_options') || ! is_admin() || empty($terms) |
|
| 1888 | 1888 | // only apply this to module only taxonomy queries so 1 taxonomy only: |
| 1889 | - || count( $taxonomies ) > 1 || !in_array( 'module', $taxonomies ) ){ |
|
| 1889 | + || count($taxonomies) > 1 || ! in_array('module', $taxonomies)) { |
|
| 1890 | 1890 | return $terms; |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | - $term_objects = $this->filter_terms_by_owner( $terms, get_current_user_id() ); |
|
| 1893 | + $term_objects = $this->filter_terms_by_owner($terms, get_current_user_id()); |
|
| 1894 | 1894 | |
| 1895 | 1895 | // if term objects were passed in send back objects |
| 1896 | 1896 | // if term id were passed in send that back |
| 1897 | - if( is_object( $terms[0] ) ){ |
|
| 1897 | + if (is_object($terms[0])) { |
|
| 1898 | 1898 | return $term_objects; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | 1901 | $terms = array(); |
| 1902 | - foreach( $term_objects as $term_object ){ |
|
| 1902 | + foreach ($term_objects as $term_object) { |
|
| 1903 | 1903 | $terms[] = $term_object->term_id; |
| 1904 | 1904 | } |
| 1905 | 1905 | |
@@ -1917,20 +1917,20 @@ discard block |
||
| 1917 | 1917 | * @param $user_id |
| 1918 | 1918 | * @return array |
| 1919 | 1919 | */ |
| 1920 | - public function filter_terms_by_owner( $terms, $user_id ){ |
|
| 1920 | + public function filter_terms_by_owner($terms, $user_id) { |
|
| 1921 | 1921 | |
| 1922 | 1922 | $users_terms = array(); |
| 1923 | 1923 | |
| 1924 | - foreach( $terms as $index => $term ){ |
|
| 1924 | + foreach ($terms as $index => $term) { |
|
| 1925 | 1925 | |
| 1926 | - if( is_numeric( $term ) ){ |
|
| 1926 | + if (is_numeric($term)) { |
|
| 1927 | 1927 | // the term id was given, get the term object |
| 1928 | - $term = get_term( $term, 'module' ); |
|
| 1928 | + $term = get_term($term, 'module'); |
|
| 1929 | 1929 | } |
| 1930 | 1930 | |
| 1931 | - $author = Sensei_Core_Modules::get_term_author( $term->slug ); |
|
| 1931 | + $author = Sensei_Core_Modules::get_term_author($term->slug); |
|
| 1932 | 1932 | |
| 1933 | - if ( $user_id == $author->ID ) { |
|
| 1933 | + if ($user_id == $author->ID) { |
|
| 1934 | 1934 | // add the term to the teachers terms |
| 1935 | 1935 | $users_terms[] = $term; |
| 1936 | 1936 | } |
@@ -1949,34 +1949,34 @@ discard block |
||
| 1949 | 1949 | * |
| 1950 | 1950 | * @since 1.8.0 |
| 1951 | 1951 | */ |
| 1952 | - public function append_teacher_name_to_module( $terms, $taxonomies, $args ) |
|
| 1952 | + public function append_teacher_name_to_module($terms, $taxonomies, $args) |
|
| 1953 | 1953 | { |
| 1954 | 1954 | |
| 1955 | 1955 | // only for admin users ont he module taxonomy |
| 1956 | - if ( empty( $terms ) || !current_user_can('manage_options') || !in_array('module', $taxonomies) || !is_admin()) { |
|
| 1956 | + if (empty($terms) || ! current_user_can('manage_options') || ! in_array('module', $taxonomies) || ! is_admin()) { |
|
| 1957 | 1957 | return $terms; |
| 1958 | 1958 | } |
| 1959 | 1959 | |
| 1960 | 1960 | // in certain cases the array is passed in as reference to the parent term_id => parent_id |
| 1961 | 1961 | // simply return this as wp doesn't need an array of stdObject Term |
| 1962 | - if (isset( $args['fields'] ) && 'id=>parent' == $args['fields']) { |
|
| 1962 | + if (isset($args['fields']) && 'id=>parent' == $args['fields']) { |
|
| 1963 | 1963 | |
| 1964 | 1964 | return $terms; |
| 1965 | 1965 | |
| 1966 | 1966 | } |
| 1967 | 1967 | |
| 1968 | 1968 | // loop through and update all terms adding the author name |
| 1969 | - foreach( $terms as $index => $term ){ |
|
| 1969 | + foreach ($terms as $index => $term) { |
|
| 1970 | 1970 | |
| 1971 | - if( is_numeric( $term ) ){ |
|
| 1971 | + if (is_numeric($term)) { |
|
| 1972 | 1972 | // the term id was given, get the term object |
| 1973 | - $term = get_term( $term, 'module' ); |
|
| 1973 | + $term = get_term($term, 'module'); |
|
| 1974 | 1974 | } |
| 1975 | 1975 | |
| 1976 | - $author = Sensei_Core_Modules::get_term_author( $term->slug ); |
|
| 1976 | + $author = Sensei_Core_Modules::get_term_author($term->slug); |
|
| 1977 | 1977 | |
| 1978 | - if( ! user_can( $author, 'manage_options' ) && isset( $term->name ) ) { |
|
| 1979 | - $term->name = $term->name . ' (' . $author->display_name . ') '; |
|
| 1978 | + if ( ! user_can($author, 'manage_options') && isset($term->name)) { |
|
| 1979 | + $term->name = $term->name.' ('.$author->display_name.') '; |
|
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | 1982 | // add the term to the teachers terms |
@@ -2005,23 +2005,23 @@ discard block |
||
| 2005 | 2005 | * @sine 1.9.0 |
| 2006 | 2006 | * @param $post_id |
| 2007 | 2007 | */ |
| 2008 | - public static function reset_none_modules_transient ( $post_id ){ |
|
| 2008 | + public static function reset_none_modules_transient($post_id) { |
|
| 2009 | 2009 | |
| 2010 | 2010 | // this should only apply to course and lesson post types |
| 2011 | - if( in_array( get_post_type( $post_id ), array( 'course', 'lesson' ) ) ){ |
|
| 2011 | + if (in_array(get_post_type($post_id), array('course', 'lesson'))) { |
|
| 2012 | 2012 | |
| 2013 | 2013 | $course_id = ''; |
| 2014 | 2014 | |
| 2015 | - if( 'lesson' == get_post_type( $post_id ) ){ |
|
| 2015 | + if ('lesson' == get_post_type($post_id)) { |
|
| 2016 | 2016 | |
| 2017 | - $course_id = Sensei()->lesson->get_course_id( $post_id ); |
|
| 2017 | + $course_id = Sensei()->lesson->get_course_id($post_id); |
|
| 2018 | 2018 | |
| 2019 | 2019 | } |
| 2020 | 2020 | |
| 2021 | 2021 | |
| 2022 | - if( !empty( $course_id ) ){ |
|
| 2022 | + if ( ! empty($course_id)) { |
|
| 2023 | 2023 | |
| 2024 | - delete_transient( 'sensei_'. $course_id .'_none_module_lessons' ); |
|
| 2024 | + delete_transient('sensei_'.$course_id.'_none_module_lessons'); |
|
| 2025 | 2025 | |
| 2026 | 2026 | } |
| 2027 | 2027 | |
@@ -2036,9 +2036,9 @@ discard block |
||
| 2036 | 2036 | * @deprecated since 1.9.0 |
| 2037 | 2037 | * |
| 2038 | 2038 | */ |
| 2039 | - public static function deprecate_sensei_single_course_modules_content(){ |
|
| 2039 | + public static function deprecate_sensei_single_course_modules_content() { |
|
| 2040 | 2040 | |
| 2041 | - sensei_do_deprecated_action( 'sensei_single_course_modules_content','1.9.0','sensei_single_course_modules_before or sensei_single_course_modules_after' ); |
|
| 2041 | + sensei_do_deprecated_action('sensei_single_course_modules_content', '1.9.0', 'sensei_single_course_modules_before or sensei_single_course_modules_after'); |
|
| 2042 | 2042 | |
| 2043 | 2043 | } |
| 2044 | 2044 | |
@@ -2049,12 +2049,12 @@ discard block |
||
| 2049 | 2049 | * |
| 2050 | 2050 | * @since 1.9.0 |
| 2051 | 2051 | */ |
| 2052 | - public static function setup_single_course_module_loop(){ |
|
| 2052 | + public static function setup_single_course_module_loop() { |
|
| 2053 | 2053 | |
| 2054 | 2054 | global $sensei_modules_loop, $post; |
| 2055 | 2055 | $course_id = $post->ID; |
| 2056 | 2056 | |
| 2057 | - $modules = Sensei()->modules->get_course_modules( $course_id ); |
|
| 2057 | + $modules = Sensei()->modules->get_course_modules($course_id); |
|
| 2058 | 2058 | |
| 2059 | 2059 | //initial setup |
| 2060 | 2060 | $sensei_modules_loop['total'] = 0; |
@@ -2062,22 +2062,22 @@ discard block |
||
| 2062 | 2062 | $sensei_modules_loop['current'] = -1; |
| 2063 | 2063 | |
| 2064 | 2064 | // exit if this course doesn't have modules |
| 2065 | - if( !$modules || empty( $modules ) ){ |
|
| 2065 | + if ( ! $modules || empty($modules)) { |
|
| 2066 | 2066 | return; |
| 2067 | 2067 | } |
| 2068 | 2068 | |
| 2069 | 2069 | |
| 2070 | 2070 | $lessons_in_all_modules = array(); |
| 2071 | - foreach( $modules as $term ){ |
|
| 2071 | + foreach ($modules as $term) { |
|
| 2072 | 2072 | |
| 2073 | - $lessons_in_this_module = Sensei()->modules->get_lessons( $course_id , $term->term_id); |
|
| 2074 | - $lessons_in_all_modules = array_merge( $lessons_in_all_modules, $lessons_in_this_module ); |
|
| 2073 | + $lessons_in_this_module = Sensei()->modules->get_lessons($course_id, $term->term_id); |
|
| 2074 | + $lessons_in_all_modules = array_merge($lessons_in_all_modules, $lessons_in_this_module); |
|
| 2075 | 2075 | |
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | |
| 2079 | 2079 | //setup all of the modules loop variables |
| 2080 | - $sensei_modules_loop['total'] = count( $modules ); |
|
| 2080 | + $sensei_modules_loop['total'] = count($modules); |
|
| 2081 | 2081 | $sensei_modules_loop['modules'] = $modules; |
| 2082 | 2082 | $sensei_modules_loop['current'] = -1; |
| 2083 | 2083 | $sensei_modules_loop['course_id'] = $course_id; |
@@ -2090,7 +2090,7 @@ discard block |
||
| 2090 | 2090 | * @since 1.9.0 |
| 2091 | 2091 | * |
| 2092 | 2092 | */ |
| 2093 | - public static function teardown_single_course_module_loop(){ |
|
| 2093 | + public static function teardown_single_course_module_loop() { |
|
| 2094 | 2094 | |
| 2095 | 2095 | global $sensei_modules_loop, $wp_query, $post; |
| 2096 | 2096 | |
@@ -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 Post Types Class |
@@ -40,43 +40,43 @@ discard block |
||
| 40 | 40 | * Constructor |
| 41 | 41 | * @since 1.0.0 |
| 42 | 42 | */ |
| 43 | - public function __construct () { |
|
| 43 | + public function __construct() { |
|
| 44 | 44 | |
| 45 | 45 | // Setup Post Types |
| 46 | 46 | $this->labels = array(); |
| 47 | 47 | $this->token = 'woothemes-sensei-posttypes'; |
| 48 | 48 | |
| 49 | 49 | $this->setup_post_type_labels_base(); |
| 50 | - add_action( 'init', array( $this, 'setup_course_post_type' ), 100 ); |
|
| 51 | - add_action( 'init', array( $this, 'setup_lesson_post_type' ), 100 ); |
|
| 52 | - add_action( 'init', array( $this, 'setup_quiz_post_type' ), 100 ); |
|
| 53 | - add_action( 'init', array( $this, 'setup_question_post_type' ), 100 ); |
|
| 54 | - add_action( 'init', array( $this, 'setup_multiple_question_post_type' ), 100 ); |
|
| 55 | - add_action( 'init', array( $this, 'setup_sensei_message_post_type' ), 100 ); |
|
| 50 | + add_action('init', array($this, 'setup_course_post_type'), 100); |
|
| 51 | + add_action('init', array($this, 'setup_lesson_post_type'), 100); |
|
| 52 | + add_action('init', array($this, 'setup_quiz_post_type'), 100); |
|
| 53 | + add_action('init', array($this, 'setup_question_post_type'), 100); |
|
| 54 | + add_action('init', array($this, 'setup_multiple_question_post_type'), 100); |
|
| 55 | + add_action('init', array($this, 'setup_sensei_message_post_type'), 100); |
|
| 56 | 56 | |
| 57 | 57 | // Setup Taxonomies |
| 58 | - add_action( 'init', array( $this, 'setup_course_category_taxonomy' ), 100 ); |
|
| 59 | - add_action( 'init', array( $this, 'setup_quiz_type_taxonomy' ), 100 ); |
|
| 60 | - add_action( 'init', array( $this, 'setup_question_type_taxonomy' ), 100 ); |
|
| 61 | - add_action( 'init', array( $this, 'setup_question_category_taxonomy' ), 100 ); |
|
| 62 | - add_action( 'init', array( $this, 'setup_lesson_tag_taxonomy' ), 100 ); |
|
| 58 | + add_action('init', array($this, 'setup_course_category_taxonomy'), 100); |
|
| 59 | + add_action('init', array($this, 'setup_quiz_type_taxonomy'), 100); |
|
| 60 | + add_action('init', array($this, 'setup_question_type_taxonomy'), 100); |
|
| 61 | + add_action('init', array($this, 'setup_question_category_taxonomy'), 100); |
|
| 62 | + add_action('init', array($this, 'setup_lesson_tag_taxonomy'), 100); |
|
| 63 | 63 | |
| 64 | 64 | // Load Post Type Objects |
| 65 | - $default_post_types = array( 'course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages' ) ; |
|
| 66 | - $this->load_posttype_objects( $default_post_types ); |
|
| 65 | + $default_post_types = array('course' => 'Course', 'lesson' => 'Lesson', 'quiz' => 'Quiz', 'question' => 'Question', 'messages' => 'Messages'); |
|
| 66 | + $this->load_posttype_objects($default_post_types); |
|
| 67 | 67 | |
| 68 | 68 | // Admin functions |
| 69 | - if ( is_admin() ) { |
|
| 70 | - $this->set_role_cap_defaults( $default_post_types ); |
|
| 69 | + if (is_admin()) { |
|
| 70 | + $this->set_role_cap_defaults($default_post_types); |
|
| 71 | 71 | global $pagenow; |
| 72 | - if ( ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) ) { |
|
| 73 | - add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10 ); |
|
| 74 | - add_filter( 'post_updated_messages', array( $this, 'setup_post_type_messages' ) ); |
|
| 72 | + if (($pagenow == 'post.php' || $pagenow == 'post-new.php')) { |
|
| 73 | + add_filter('enter_title_here', array($this, 'enter_title_here'), 10); |
|
| 74 | + add_filter('post_updated_messages', array($this, 'setup_post_type_messages')); |
|
| 75 | 75 | } // End If Statement |
| 76 | 76 | } // End If Statement |
| 77 | 77 | |
| 78 | 78 | // Add 'Edit Quiz' link to admin bar |
| 79 | - add_action( 'admin_bar_menu', array( $this, 'quiz_admin_bar_menu' ), 81 ); |
|
| 79 | + add_action('admin_bar_menu', array($this, 'quiz_admin_bar_menu'), 81); |
|
| 80 | 80 | |
| 81 | 81 | } // End __construct() |
| 82 | 82 | |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * @param array $posttypes (default: array()) |
| 88 | 88 | * @return void |
| 89 | 89 | */ |
| 90 | - public function load_posttype_objects( $posttypes = array() ) { |
|
| 90 | + public function load_posttype_objects($posttypes = array()) { |
|
| 91 | 91 | |
| 92 | - foreach ( $posttypes as $posttype_token => $posttype_name ) { |
|
| 92 | + foreach ($posttypes as $posttype_token => $posttype_name) { |
|
| 93 | 93 | |
| 94 | 94 | // Load the files |
| 95 | - $class_name = 'WooThemes_Sensei_' . $posttype_name; |
|
| 95 | + $class_name = 'WooThemes_Sensei_'.$posttype_name; |
|
| 96 | 96 | $this->$posttype_token = new $class_name(); |
| 97 | 97 | $this->$posttype_token->token = $posttype_token; |
| 98 | 98 | |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | * @uses Sensei() |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function setup_course_post_type () { |
|
| 109 | + public function setup_course_post_type() { |
|
| 110 | 110 | |
| 111 | 111 | $args = array( |
| 112 | - 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
| 112 | + 'labels' => $this->create_post_type_labels($this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu']), |
|
| 113 | 113 | 'public' => true, |
| 114 | 114 | 'publicly_queryable' => true, |
| 115 | 115 | 'show_ui' => true, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | 'show_in_admin_bar' => true, |
| 118 | 118 | 'query_var' => true, |
| 119 | 119 | 'rewrite' => array( |
| 120 | - 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
| 120 | + 'slug' => esc_attr(apply_filters('sensei_course_slug', _x('course', 'post type single url base', 'woothemes-sensei'))), |
|
| 121 | 121 | 'with_front' => true, |
| 122 | 122 | 'feeds' => true, |
| 123 | 123 | 'pages' => true |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | 'has_archive' => $this->get_course_post_type_archive_slug(), |
| 128 | 128 | 'hierarchical' => false, |
| 129 | 129 | 'menu_position' => 51, |
| 130 | - 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
| 130 | + 'supports' => array('title', 'editor', 'excerpt', 'thumbnail') |
|
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @since 1.9.0 |
| 137 | 137 | * @param array $args |
| 138 | 138 | */ |
| 139 | - register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) ); |
|
| 139 | + register_post_type('course', apply_filters('sensei_register_post_type_course', $args)); |
|
| 140 | 140 | |
| 141 | 141 | } // End setup_course_post_type() |
| 142 | 142 | |
@@ -155,17 +155,17 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return false|string |
| 157 | 157 | */ |
| 158 | - public function get_course_post_type_archive_slug(){ |
|
| 158 | + public function get_course_post_type_archive_slug() { |
|
| 159 | 159 | |
| 160 | - $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
| 160 | + $settings_course_page = get_post(Sensei()->settings->get('course_page')); |
|
| 161 | 161 | |
| 162 | 162 | // for a valid post that doesn't have any of the old short codes set the archive the same |
| 163 | 163 | // as the page URI |
| 164 | - if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
| 164 | + if (is_a($settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes($settings_course_page->post_content)) { |
|
| 165 | 165 | |
| 166 | - return get_page_uri( $settings_course_page->ID ); |
|
| 166 | + return get_page_uri($settings_course_page->ID); |
|
| 167 | 167 | |
| 168 | - }else{ |
|
| 168 | + } else { |
|
| 169 | 169 | |
| 170 | 170 | return 'courses'; |
| 171 | 171 | |
@@ -183,12 +183,12 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | - public function has_old_shortcodes( $content ){ |
|
| 186 | + public function has_old_shortcodes($content) { |
|
| 187 | 187 | |
| 188 | - return ( has_shortcode( $content, 'newcourses') |
|
| 189 | - || has_shortcode( $content, 'featuredcourses') |
|
| 190 | - || has_shortcode( $content, 'freecourses') |
|
| 191 | - || has_shortcode( $content, 'paidcourses') ); |
|
| 188 | + return (has_shortcode($content, 'newcourses') |
|
| 189 | + || has_shortcode($content, 'featuredcourses') |
|
| 190 | + || has_shortcode($content, 'freecourses') |
|
| 191 | + || has_shortcode($content, 'paidcourses')); |
|
| 192 | 192 | |
| 193 | 193 | }// end has old shortcodes |
| 194 | 194 | |
@@ -199,26 +199,26 @@ discard block |
||
| 199 | 199 | * @uses Sensei() |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - public function setup_lesson_post_type () { |
|
| 202 | + public function setup_lesson_post_type() { |
|
| 203 | 203 | |
| 204 | - $supports_array = array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ); |
|
| 204 | + $supports_array = array('title', 'editor', 'excerpt', 'thumbnail', 'page-attributes'); |
|
| 205 | 205 | $allow_comments = false; |
| 206 | - if ( isset( Sensei()->settings->settings[ 'lesson_comments' ] ) ) { |
|
| 207 | - $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ]; |
|
| 206 | + if (isset(Sensei()->settings->settings['lesson_comments'])) { |
|
| 207 | + $allow_comments = Sensei()->settings->settings['lesson_comments']; |
|
| 208 | 208 | } // End If Statement |
| 209 | - if ( $allow_comments ) { |
|
| 210 | - array_push( $supports_array, 'comments' ); |
|
| 209 | + if ($allow_comments) { |
|
| 210 | + array_push($supports_array, 'comments'); |
|
| 211 | 211 | } // End If Statement |
| 212 | 212 | |
| 213 | 213 | $args = array( |
| 214 | - 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
| 214 | + 'labels' => $this->create_post_type_labels($this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu']), |
|
| 215 | 215 | 'public' => true, |
| 216 | 216 | 'publicly_queryable' => true, |
| 217 | 217 | 'show_ui' => true, |
| 218 | 218 | 'show_in_menu' => true, |
| 219 | 219 | 'query_var' => true, |
| 220 | 220 | 'rewrite' => array( |
| 221 | - 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 221 | + 'slug' => esc_attr(apply_filters('sensei_lesson_slug', _x('lesson', 'post type single slug', 'woothemes-sensei'))), |
|
| 222 | 222 | 'with_front' => true, |
| 223 | 223 | 'feeds' => true, |
| 224 | 224 | 'pages' => true |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @since 1.9.0 |
| 238 | 238 | * @param array $args |
| 239 | 239 | */ |
| 240 | - register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) ); |
|
| 240 | + register_post_type('lesson', apply_filters('sensei_register_post_type_lesson', $args)); |
|
| 241 | 241 | |
| 242 | 242 | } // End setup_lesson_post_type() |
| 243 | 243 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * @uses Sensei() |
| 248 | 248 | * @return void |
| 249 | 249 | */ |
| 250 | - public function setup_quiz_post_type () { |
|
| 250 | + public function setup_quiz_post_type() { |
|
| 251 | 251 | |
| 252 | 252 | $args = array( |
| 253 | 253 | 'labels' => $this->create_post_type_labels( |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | 'query_var' => true, |
| 264 | 264 | 'exclude_from_search' => true, |
| 265 | 265 | 'rewrite' => array( |
| 266 | - 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 266 | + 'slug' => esc_attr(apply_filters('sensei_quiz_slug', _x('quiz', 'post type single slug', 'woothemes-sensei'))), |
|
| 267 | 267 | 'with_front' => true, |
| 268 | 268 | 'feeds' => true, |
| 269 | 269 | 'pages' => true |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | 'has_archive' => false, |
| 274 | 274 | 'hierarchical' => false, |
| 275 | 275 | 'menu_position' => 20, // Below "Pages" |
| 276 | - 'supports' => array( '' ) |
|
| 276 | + 'supports' => array('') |
|
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * @since 1.9.0 |
| 283 | 283 | * @param array $args |
| 284 | 284 | */ |
| 285 | - register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) ); |
|
| 285 | + register_post_type('quiz', apply_filters('sensei_register_post_type_quiz', $args)); |
|
| 286 | 286 | |
| 287 | 287 | } // End setup_quiz_post_type() |
| 288 | 288 | |
@@ -292,10 +292,10 @@ discard block |
||
| 292 | 292 | * @since 1.0.0 |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | - public function setup_question_post_type () { |
|
| 295 | + public function setup_question_post_type() { |
|
| 296 | 296 | |
| 297 | 297 | $args = array( |
| 298 | - 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
| 298 | + 'labels' => $this->create_post_type_labels($this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu']), |
|
| 299 | 299 | 'public' => false, |
| 300 | 300 | 'publicly_queryable' => true, |
| 301 | 301 | 'show_ui' => true, |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | 'query_var' => true, |
| 305 | 305 | 'exclude_from_search' => true, |
| 306 | 306 | 'rewrite' => array( |
| 307 | - 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 307 | + 'slug' => esc_attr(apply_filters('sensei_question_slug', _x('question', 'post type single slug', 'woothemes-sensei'))), |
|
| 308 | 308 | 'with_front' => true, |
| 309 | 309 | 'feeds' => true, |
| 310 | 310 | 'pages' => true |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | 'has_archive' => true, |
| 315 | 315 | 'hierarchical' => false, |
| 316 | 316 | 'menu_position' => 51, |
| 317 | - 'supports' => array( 'title' ) |
|
| 317 | + 'supports' => array('title') |
|
| 318 | 318 | ); |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @since 1.9.0 |
| 324 | 324 | * @param array $args |
| 325 | 325 | */ |
| 326 | - register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) ); |
|
| 326 | + register_post_type('question', apply_filters('sensei_register_post_type_question', $args)); |
|
| 327 | 327 | |
| 328 | 328 | } // End setup_question_post_type() |
| 329 | 329 | |
@@ -332,10 +332,10 @@ discard block |
||
| 332 | 332 | * @since 1.6.0 |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - public function setup_multiple_question_post_type () { |
|
| 335 | + public function setup_multiple_question_post_type() { |
|
| 336 | 336 | |
| 337 | 337 | $args = array( |
| 338 | - 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
| 338 | + 'labels' => $this->create_post_type_labels($this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu']), |
|
| 339 | 339 | 'public' => false, |
| 340 | 340 | 'publicly_queryable' => false, |
| 341 | 341 | 'show_ui' => false, |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | 'query_var' => false, |
| 345 | 345 | 'exclude_from_search' => true, |
| 346 | 346 | 'rewrite' => array( |
| 347 | - 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 347 | + 'slug' => esc_attr(apply_filters('sensei_multiple_question_slug', _x('multiple_question', 'post type single slug', 'woothemes-sensei'))), |
|
| 348 | 348 | 'with_front' => false, |
| 349 | 349 | 'feeds' => false, |
| 350 | 350 | 'pages' => false |
@@ -354,10 +354,10 @@ discard block |
||
| 354 | 354 | 'has_archive' => false, |
| 355 | 355 | 'hierarchical' => false, |
| 356 | 356 | 'menu_position' => 51, |
| 357 | - 'supports' => array( 'title', 'custom-fields' ) |
|
| 357 | + 'supports' => array('title', 'custom-fields') |
|
| 358 | 358 | ); |
| 359 | 359 | |
| 360 | - register_post_type( 'multiple_question', $args ); |
|
| 360 | + register_post_type('multiple_question', $args); |
|
| 361 | 361 | } // End setup_multiple_question_post_type() |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -365,12 +365,12 @@ discard block |
||
| 365 | 365 | * @since 1.6.0 |
| 366 | 366 | * @return void |
| 367 | 367 | */ |
| 368 | - public function setup_sensei_message_post_type () { |
|
| 368 | + public function setup_sensei_message_post_type() { |
|
| 369 | 369 | |
| 370 | - if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) { |
|
| 370 | + if ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable']) { |
|
| 371 | 371 | |
| 372 | 372 | $args = array( |
| 373 | - 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
| 373 | + 'labels' => $this->create_post_type_labels($this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu']), |
|
| 374 | 374 | 'public' => true, |
| 375 | 375 | 'publicly_queryable' => true, |
| 376 | 376 | 'show_ui' => true, |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | 'query_var' => true, |
| 380 | 380 | 'exclude_from_search' => true, |
| 381 | 381 | 'rewrite' => array( |
| 382 | - 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
| 382 | + 'slug' => esc_attr(apply_filters('sensei_messages_slug', _x('messages', 'post type single slug', 'woothemes-sensei'))), |
|
| 383 | 383 | 'with_front' => false, |
| 384 | 384 | 'feeds' => false, |
| 385 | 385 | 'pages' => true |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | 'has_archive' => true, |
| 390 | 390 | 'hierarchical' => false, |
| 391 | 391 | 'menu_position' => 50, |
| 392 | - 'supports' => array( 'title', 'editor', 'comments' ), |
|
| 392 | + 'supports' => array('title', 'editor', 'comments'), |
|
| 393 | 393 | ); |
| 394 | 394 | |
| 395 | 395 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | * @since 1.9.0 |
| 399 | 399 | * @param array $args |
| 400 | 400 | */ |
| 401 | - register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args ) ); |
|
| 401 | + register_post_type('sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args)); |
|
| 402 | 402 | } |
| 403 | 403 | } // End setup_sensei_message_post_type() |
| 404 | 404 | |
@@ -407,20 +407,20 @@ discard block |
||
| 407 | 407 | * @since 1.1.0 |
| 408 | 408 | * @return void |
| 409 | 409 | */ |
| 410 | - public function setup_course_category_taxonomy () { |
|
| 410 | + public function setup_course_category_taxonomy() { |
|
| 411 | 411 | // "Course Categories" Custom Taxonomy |
| 412 | 412 | $labels = array( |
| 413 | - 'name' => _x( 'Course Categories', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 414 | - 'singular_name' => _x( 'Course Category', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 415 | - 'search_items' => __( 'Search Course Categories', 'woothemes-sensei' ), |
|
| 416 | - 'all_items' => __( 'All Course Categories', 'woothemes-sensei' ), |
|
| 417 | - 'parent_item' => __( 'Parent Course Category', 'woothemes-sensei' ), |
|
| 418 | - 'parent_item_colon' => __( 'Parent Course Category:', 'woothemes-sensei' ), |
|
| 419 | - 'edit_item' => __( 'Edit Course Category', 'woothemes-sensei' ), |
|
| 420 | - 'update_item' => __( 'Update Course Category', 'woothemes-sensei' ), |
|
| 421 | - 'add_new_item' => __( 'Add New Course Category', 'woothemes-sensei' ), |
|
| 422 | - 'new_item_name' => __( 'New Course Category Name', 'woothemes-sensei' ), |
|
| 423 | - 'menu_name' => __( 'Course Categories', 'woothemes-sensei' ), |
|
| 413 | + 'name' => _x('Course Categories', 'taxonomy general name', 'woothemes-sensei'), |
|
| 414 | + 'singular_name' => _x('Course Category', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 415 | + 'search_items' => __('Search Course Categories', 'woothemes-sensei'), |
|
| 416 | + 'all_items' => __('All Course Categories', 'woothemes-sensei'), |
|
| 417 | + 'parent_item' => __('Parent Course Category', 'woothemes-sensei'), |
|
| 418 | + 'parent_item_colon' => __('Parent Course Category:', 'woothemes-sensei'), |
|
| 419 | + 'edit_item' => __('Edit Course Category', 'woothemes-sensei'), |
|
| 420 | + 'update_item' => __('Update Course Category', 'woothemes-sensei'), |
|
| 421 | + 'add_new_item' => __('Add New Course Category', 'woothemes-sensei'), |
|
| 422 | + 'new_item_name' => __('New Course Category Name', 'woothemes-sensei'), |
|
| 423 | + 'menu_name' => __('Course Categories', 'woothemes-sensei'), |
|
| 424 | 424 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 425 | 425 | ); |
| 426 | 426 | |
@@ -435,10 +435,10 @@ discard block |
||
| 435 | 435 | 'edit_terms' => 'edit_courses', |
| 436 | 436 | 'delete_terms' => 'manage_categories', |
| 437 | 437 | 'assign_terms' => 'edit_courses',), |
| 438 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 438 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_course_category_slug', _x('course-category', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 439 | 439 | ); |
| 440 | 440 | |
| 441 | - register_taxonomy( 'course-category', array( 'course' ), $args ); |
|
| 441 | + register_taxonomy('course-category', array('course'), $args); |
|
| 442 | 442 | |
| 443 | 443 | } // End setup_course_category_taxonomy() |
| 444 | 444 | |
@@ -447,21 +447,21 @@ discard block |
||
| 447 | 447 | * @since 1.0.0 |
| 448 | 448 | * @return void |
| 449 | 449 | */ |
| 450 | - public function setup_quiz_type_taxonomy () { |
|
| 450 | + public function setup_quiz_type_taxonomy() { |
|
| 451 | 451 | |
| 452 | 452 | // "Quiz Types" Custom Taxonomy |
| 453 | 453 | $labels = array( |
| 454 | - 'name' => _x( 'Quiz Types', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 455 | - 'singular_name' => _x( 'Quiz Type', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 456 | - 'search_items' => __( 'Search Quiz Types', 'woothemes-sensei' ), |
|
| 457 | - 'all_items' => __( 'All Quiz Types', 'woothemes-sensei' ), |
|
| 458 | - 'parent_item' => __( 'Parent Quiz Type', 'woothemes-sensei' ), |
|
| 459 | - 'parent_item_colon' => __( 'Parent Quiz Type:', 'woothemes-sensei' ), |
|
| 460 | - 'edit_item' => __( 'Edit Quiz Type', 'woothemes-sensei' ), |
|
| 461 | - 'update_item' => __( 'Update Quiz Type', 'woothemes-sensei' ), |
|
| 462 | - 'add_new_item' => __( 'Add New Quiz Type', 'woothemes-sensei' ), |
|
| 463 | - 'new_item_name' => __( 'New Quiz Type Name', 'woothemes-sensei' ), |
|
| 464 | - 'menu_name' => __( 'Quiz Types', 'woothemes-sensei' ), |
|
| 454 | + 'name' => _x('Quiz Types', 'taxonomy general name', 'woothemes-sensei'), |
|
| 455 | + 'singular_name' => _x('Quiz Type', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 456 | + 'search_items' => __('Search Quiz Types', 'woothemes-sensei'), |
|
| 457 | + 'all_items' => __('All Quiz Types', 'woothemes-sensei'), |
|
| 458 | + 'parent_item' => __('Parent Quiz Type', 'woothemes-sensei'), |
|
| 459 | + 'parent_item_colon' => __('Parent Quiz Type:', 'woothemes-sensei'), |
|
| 460 | + 'edit_item' => __('Edit Quiz Type', 'woothemes-sensei'), |
|
| 461 | + 'update_item' => __('Update Quiz Type', 'woothemes-sensei'), |
|
| 462 | + 'add_new_item' => __('Add New Quiz Type', 'woothemes-sensei'), |
|
| 463 | + 'new_item_name' => __('New Quiz Type Name', 'woothemes-sensei'), |
|
| 464 | + 'menu_name' => __('Quiz Types', 'woothemes-sensei'), |
|
| 465 | 465 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 466 | 466 | ); |
| 467 | 467 | |
@@ -472,10 +472,10 @@ discard block |
||
| 472 | 472 | 'query_var' => true, |
| 473 | 473 | 'show_in_nav_menus' => false, |
| 474 | 474 | 'public' => false, |
| 475 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 475 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_quiz_type_slug', _x('quiz-type', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 476 | 476 | ); |
| 477 | 477 | |
| 478 | - register_taxonomy( 'quiz-type', array( 'quiz' ), $args ); |
|
| 478 | + register_taxonomy('quiz-type', array('quiz'), $args); |
|
| 479 | 479 | } // End setup_quiz_type_taxonomy() |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -483,21 +483,21 @@ discard block |
||
| 483 | 483 | * @since 1.3.0 |
| 484 | 484 | * @return void |
| 485 | 485 | */ |
| 486 | - public function setup_question_type_taxonomy () { |
|
| 486 | + public function setup_question_type_taxonomy() { |
|
| 487 | 487 | |
| 488 | 488 | // "Question Types" Custom Taxonomy |
| 489 | 489 | $labels = array( |
| 490 | - 'name' => _x( 'Question Types', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 491 | - 'singular_name' => _x( 'Question Type', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 492 | - 'search_items' => __( 'Search Question Types', 'woothemes-sensei' ), |
|
| 493 | - 'all_items' => __( 'All Question Types', 'woothemes-sensei' ), |
|
| 494 | - 'parent_item' => __( 'Parent Question Type', 'woothemes-sensei' ), |
|
| 495 | - 'parent_item_colon' => __( 'Parent Question Type:', 'woothemes-sensei' ), |
|
| 496 | - 'edit_item' => __( 'Edit Question Type', 'woothemes-sensei' ), |
|
| 497 | - 'update_item' => __( 'Update Question Type', 'woothemes-sensei' ), |
|
| 498 | - 'add_new_item' => __( 'Add New Question Type', 'woothemes-sensei' ), |
|
| 499 | - 'new_item_name' => __( 'New Question Type Name', 'woothemes-sensei' ), |
|
| 500 | - 'menu_name' => __( 'Question Types', 'woothemes-sensei' ), |
|
| 490 | + 'name' => _x('Question Types', 'taxonomy general name', 'woothemes-sensei'), |
|
| 491 | + 'singular_name' => _x('Question Type', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 492 | + 'search_items' => __('Search Question Types', 'woothemes-sensei'), |
|
| 493 | + 'all_items' => __('All Question Types', 'woothemes-sensei'), |
|
| 494 | + 'parent_item' => __('Parent Question Type', 'woothemes-sensei'), |
|
| 495 | + 'parent_item_colon' => __('Parent Question Type:', 'woothemes-sensei'), |
|
| 496 | + 'edit_item' => __('Edit Question Type', 'woothemes-sensei'), |
|
| 497 | + 'update_item' => __('Update Question Type', 'woothemes-sensei'), |
|
| 498 | + 'add_new_item' => __('Add New Question Type', 'woothemes-sensei'), |
|
| 499 | + 'new_item_name' => __('New Question Type Name', 'woothemes-sensei'), |
|
| 500 | + 'menu_name' => __('Question Types', 'woothemes-sensei'), |
|
| 501 | 501 | 'popular_items' => null // Hides the "Popular" section above the "add" form in the admin. |
| 502 | 502 | ); |
| 503 | 503 | |
@@ -509,10 +509,10 @@ discard block |
||
| 509 | 509 | 'query_var' => false, |
| 510 | 510 | 'show_in_nav_menus' => false, |
| 511 | 511 | 'show_admin_column' => true, |
| 512 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_type_slug', _x( 'question-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 512 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_type_slug', _x('question-type', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | - register_taxonomy( 'question-type', array( 'question' ), $args ); |
|
| 515 | + register_taxonomy('question-type', array('question'), $args); |
|
| 516 | 516 | } // End setup_question_type_taxonomy() |
| 517 | 517 | |
| 518 | 518 | /** |
@@ -520,20 +520,20 @@ discard block |
||
| 520 | 520 | * @since 1.3.0 |
| 521 | 521 | * @return void |
| 522 | 522 | */ |
| 523 | - public function setup_question_category_taxonomy () { |
|
| 523 | + public function setup_question_category_taxonomy() { |
|
| 524 | 524 | // "Question Categories" Custom Taxonomy |
| 525 | 525 | $labels = array( |
| 526 | - 'name' => _x( 'Question Categories', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 527 | - 'singular_name' => _x( 'Question Category', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 528 | - 'search_items' => __( 'Search Question Categories', 'woothemes-sensei' ), |
|
| 529 | - 'all_items' => __( 'All Question Categories', 'woothemes-sensei' ), |
|
| 530 | - 'parent_item' => __( 'Parent Question Category', 'woothemes-sensei' ), |
|
| 531 | - 'parent_item_colon' => __( 'Parent Question Category:', 'woothemes-sensei' ), |
|
| 532 | - 'edit_item' => __( 'Edit Question Category', 'woothemes-sensei' ), |
|
| 533 | - 'update_item' => __( 'Update Question Category', 'woothemes-sensei' ), |
|
| 534 | - 'add_new_item' => __( 'Add New Question Category', 'woothemes-sensei' ), |
|
| 535 | - 'new_item_name' => __( 'New Question Category Name', 'woothemes-sensei' ), |
|
| 536 | - 'menu_name' => __( 'Categories', 'woothemes-sensei' ), |
|
| 526 | + 'name' => _x('Question Categories', 'taxonomy general name', 'woothemes-sensei'), |
|
| 527 | + 'singular_name' => _x('Question Category', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 528 | + 'search_items' => __('Search Question Categories', 'woothemes-sensei'), |
|
| 529 | + 'all_items' => __('All Question Categories', 'woothemes-sensei'), |
|
| 530 | + 'parent_item' => __('Parent Question Category', 'woothemes-sensei'), |
|
| 531 | + 'parent_item_colon' => __('Parent Question Category:', 'woothemes-sensei'), |
|
| 532 | + 'edit_item' => __('Edit Question Category', 'woothemes-sensei'), |
|
| 533 | + 'update_item' => __('Update Question Category', 'woothemes-sensei'), |
|
| 534 | + 'add_new_item' => __('Add New Question Category', 'woothemes-sensei'), |
|
| 535 | + 'new_item_name' => __('New Question Category Name', 'woothemes-sensei'), |
|
| 536 | + 'menu_name' => __('Categories', 'woothemes-sensei'), |
|
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | 539 | $args = array( |
@@ -549,10 +549,10 @@ discard block |
||
| 549 | 549 | 'edit_terms' => 'edit_questions', |
| 550 | 550 | 'delete_terms' => 'manage_categories', |
| 551 | 551 | 'assign_terms' => 'edit_questions',), |
| 552 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 552 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_question_category_slug', _x('question-category', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 553 | 553 | ); |
| 554 | 554 | |
| 555 | - register_taxonomy( 'question-category', array( 'question' ), $args ); |
|
| 555 | + register_taxonomy('question-category', array('question'), $args); |
|
| 556 | 556 | } // End setup_question_type_taxonomy() |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -560,20 +560,20 @@ discard block |
||
| 560 | 560 | * @since 1.5.0 |
| 561 | 561 | * @return void |
| 562 | 562 | */ |
| 563 | - public function setup_lesson_tag_taxonomy () { |
|
| 563 | + public function setup_lesson_tag_taxonomy() { |
|
| 564 | 564 | // "Lesson Tags" Custom Taxonomy |
| 565 | 565 | $labels = array( |
| 566 | - 'name' => _x( 'Lesson Tags', 'taxonomy general name', 'woothemes-sensei' ), |
|
| 567 | - 'singular_name' => _x( 'Lesson Tag', 'taxonomy singular name', 'woothemes-sensei' ), |
|
| 568 | - 'search_items' => __( 'Search Lesson Tags', 'woothemes-sensei' ), |
|
| 569 | - 'all_items' => __( 'All Lesson Tags', 'woothemes-sensei' ), |
|
| 570 | - 'parent_item' => __( 'Parent Tag', 'woothemes-sensei' ), |
|
| 571 | - 'parent_item_colon' => __( 'Parent Tag:', 'woothemes-sensei' ), |
|
| 572 | - 'edit_item' => __( 'Edit Lesson Tag', 'woothemes-sensei' ), |
|
| 573 | - 'update_item' => __( 'Update Lesson Tag', 'woothemes-sensei' ), |
|
| 574 | - 'add_new_item' => __( 'Add New Lesson Tag', 'woothemes-sensei' ), |
|
| 575 | - 'new_item_name' => __( 'New Tag Name', 'woothemes-sensei' ), |
|
| 576 | - 'menu_name' => __( 'Lesson Tags', 'woothemes-sensei' ) |
|
| 566 | + 'name' => _x('Lesson Tags', 'taxonomy general name', 'woothemes-sensei'), |
|
| 567 | + 'singular_name' => _x('Lesson Tag', 'taxonomy singular name', 'woothemes-sensei'), |
|
| 568 | + 'search_items' => __('Search Lesson Tags', 'woothemes-sensei'), |
|
| 569 | + 'all_items' => __('All Lesson Tags', 'woothemes-sensei'), |
|
| 570 | + 'parent_item' => __('Parent Tag', 'woothemes-sensei'), |
|
| 571 | + 'parent_item_colon' => __('Parent Tag:', 'woothemes-sensei'), |
|
| 572 | + 'edit_item' => __('Edit Lesson Tag', 'woothemes-sensei'), |
|
| 573 | + 'update_item' => __('Update Lesson Tag', 'woothemes-sensei'), |
|
| 574 | + 'add_new_item' => __('Add New Lesson Tag', 'woothemes-sensei'), |
|
| 575 | + 'new_item_name' => __('New Tag Name', 'woothemes-sensei'), |
|
| 576 | + 'menu_name' => __('Lesson Tags', 'woothemes-sensei') |
|
| 577 | 577 | ); |
| 578 | 578 | |
| 579 | 579 | $args = array( |
@@ -587,10 +587,10 @@ discard block |
||
| 587 | 587 | 'edit_terms' => 'edit_lessons', |
| 588 | 588 | 'delete_terms' => 'manage_categories', |
| 589 | 589 | 'assign_terms' => 'edit_lessons',), |
| 590 | - 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
|
| 590 | + 'rewrite' => array('slug' => esc_attr(apply_filters('sensei_lesson_tag_slug', _x('lesson-tag', 'taxonomy archive slug', 'woothemes-sensei')))) |
|
| 591 | 591 | ); |
| 592 | 592 | |
| 593 | - register_taxonomy( 'lesson-tag', array( 'lesson' ), $args ); |
|
| 593 | + register_taxonomy('lesson-tag', array('lesson'), $args); |
|
| 594 | 594 | } // End setup_lesson_tag_taxonomy() |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -598,15 +598,15 @@ discard block |
||
| 598 | 598 | * @since 1.0.0 |
| 599 | 599 | * @return void |
| 600 | 600 | */ |
| 601 | - private function setup_post_type_labels_base () { |
|
| 602 | - $this->labels = array( 'course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array() ); |
|
| 601 | + private function setup_post_type_labels_base() { |
|
| 602 | + $this->labels = array('course' => array(), 'lesson' => array(), 'quiz' => array(), 'question' => array()); |
|
| 603 | 603 | |
| 604 | - $this->labels['course'] = array( 'singular' => __( 'Course', 'woothemes-sensei' ), 'plural' => __( 'Courses', 'woothemes-sensei' ), 'menu' => __( 'Courses', 'woothemes-sensei' ) ); |
|
| 605 | - $this->labels['lesson'] = array( 'singular' => __( 'Lesson', 'woothemes-sensei' ), 'plural' => __( 'Lessons', 'woothemes-sensei' ), 'menu' => __( 'Lessons', 'woothemes-sensei' ) ); |
|
| 606 | - $this->labels['quiz'] = array( 'singular' => __( 'Quiz', 'woothemes-sensei' ), 'plural' => __( 'Quizzes', 'woothemes-sensei' ), 'menu' => __( 'Quizzes', 'woothemes-sensei' ) ); |
|
| 607 | - $this->labels['question'] = array( 'singular' => __( 'Question', 'woothemes-sensei' ), 'plural' => __( 'Questions', 'woothemes-sensei' ), 'menu' => __( 'Questions', 'woothemes-sensei' ) ); |
|
| 608 | - $this->labels['multiple_question'] = array( 'singular' => __( 'Multiple Question', 'woothemes-sensei' ), 'plural' => __( 'Multiple Questions', 'woothemes-sensei' ), 'menu' => __( 'Multiple Questions', 'woothemes-sensei' ) ); |
|
| 609 | - $this->labels['sensei_message'] = array( 'singular' => __( 'Message', 'woothemes-sensei' ), 'plural' => __( 'Messages', 'woothemes-sensei' ), 'menu' => __( 'Messages', 'woothemes-sensei' ) ); |
|
| 604 | + $this->labels['course'] = array('singular' => __('Course', 'woothemes-sensei'), 'plural' => __('Courses', 'woothemes-sensei'), 'menu' => __('Courses', 'woothemes-sensei')); |
|
| 605 | + $this->labels['lesson'] = array('singular' => __('Lesson', 'woothemes-sensei'), 'plural' => __('Lessons', 'woothemes-sensei'), 'menu' => __('Lessons', 'woothemes-sensei')); |
|
| 606 | + $this->labels['quiz'] = array('singular' => __('Quiz', 'woothemes-sensei'), 'plural' => __('Quizzes', 'woothemes-sensei'), 'menu' => __('Quizzes', 'woothemes-sensei')); |
|
| 607 | + $this->labels['question'] = array('singular' => __('Question', 'woothemes-sensei'), 'plural' => __('Questions', 'woothemes-sensei'), 'menu' => __('Questions', 'woothemes-sensei')); |
|
| 608 | + $this->labels['multiple_question'] = array('singular' => __('Multiple Question', 'woothemes-sensei'), 'plural' => __('Multiple Questions', 'woothemes-sensei'), 'menu' => __('Multiple Questions', 'woothemes-sensei')); |
|
| 609 | + $this->labels['sensei_message'] = array('singular' => __('Message', 'woothemes-sensei'), 'plural' => __('Messages', 'woothemes-sensei'), 'menu' => __('Messages', 'woothemes-sensei')); |
|
| 610 | 610 | |
| 611 | 611 | } // End setup_post_type_labels_base() |
| 612 | 612 | |
@@ -618,24 +618,24 @@ discard block |
||
| 618 | 618 | * @param string $menu The menu item label |
| 619 | 619 | * @return array An array of the labels to be used |
| 620 | 620 | */ |
| 621 | - private function create_post_type_labels ( $singular, $plural, $menu ) { |
|
| 621 | + private function create_post_type_labels($singular, $plural, $menu) { |
|
| 622 | 622 | |
| 623 | - $lower_case_plural = function_exists( 'mb_strtolower' ) ? mb_strtolower( $plural, 'UTF-8') : strtolower( $plural ); |
|
| 623 | + $lower_case_plural = function_exists('mb_strtolower') ? mb_strtolower($plural, 'UTF-8') : strtolower($plural); |
|
| 624 | 624 | |
| 625 | 625 | $labels = array( |
| 626 | - 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
| 627 | - 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
| 628 | - 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
| 629 | - 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
| 630 | - 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
| 631 | - 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
| 632 | - 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
| 633 | - 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
| 634 | - 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
| 635 | - 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), $lower_case_plural ) , |
|
| 636 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), $lower_case_plural ), |
|
| 626 | + 'name' => sprintf(_x('%s', 'post type general name', 'woothemes-sensei'), $plural), |
|
| 627 | + 'singular_name' => sprintf(_x('%s', 'post type singular name', 'woothemes-sensei'), $singular), |
|
| 628 | + 'add_new' => __('Add New', 'woothemes-sensei'), |
|
| 629 | + 'add_new_item' => sprintf(__('Add New %s', 'woothemes-sensei'), $singular), |
|
| 630 | + 'edit_item' => sprintf(__('Edit %s', 'woothemes-sensei'), $singular), |
|
| 631 | + 'new_item' => sprintf(__('New %s', 'woothemes-sensei'), $singular), |
|
| 632 | + 'all_items' => sprintf(__('All %s', 'woothemes-sensei'), $plural), |
|
| 633 | + 'view_item' => sprintf(__('View %s', 'woothemes-sensei'), $singular), |
|
| 634 | + 'search_items' => sprintf(__('Search %s', 'woothemes-sensei'), $plural), |
|
| 635 | + 'not_found' => sprintf(__('No %s found', 'woothemes-sensei'), $lower_case_plural), |
|
| 636 | + 'not_found_in_trash' => sprintf(__('No %s found in Trash', 'woothemes-sensei'), $lower_case_plural), |
|
| 637 | 637 | 'parent_item_colon' => '', |
| 638 | - 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
| 638 | + 'menu_name' => sprintf(__('%s', 'woothemes-sensei'), $menu) |
|
| 639 | 639 | ); |
| 640 | 640 | |
| 641 | 641 | return $labels; |
@@ -647,14 +647,14 @@ discard block |
||
| 647 | 647 | * @param array $messages The existing array of messages for post types. |
| 648 | 648 | * @return array The modified array of messages for post types. |
| 649 | 649 | */ |
| 650 | - public function setup_post_type_messages ( $messages ) { |
|
| 650 | + public function setup_post_type_messages($messages) { |
|
| 651 | 651 | global $post, $post_ID; |
| 652 | 652 | |
| 653 | - $messages['course'] = $this->create_post_type_messages( 'course' ); |
|
| 654 | - $messages['lesson'] = $this->create_post_type_messages( 'lesson' ); |
|
| 655 | - $messages['quiz'] = $this->create_post_type_messages( 'quiz' ); |
|
| 656 | - $messages['question'] = $this->create_post_type_messages( 'question' ); |
|
| 657 | - $messages['multiple_question'] = $this->create_post_type_messages( 'multiple_question' ); |
|
| 653 | + $messages['course'] = $this->create_post_type_messages('course'); |
|
| 654 | + $messages['lesson'] = $this->create_post_type_messages('lesson'); |
|
| 655 | + $messages['quiz'] = $this->create_post_type_messages('quiz'); |
|
| 656 | + $messages['question'] = $this->create_post_type_messages('question'); |
|
| 657 | + $messages['multiple_question'] = $this->create_post_type_messages('multiple_question'); |
|
| 658 | 658 | |
| 659 | 659 | return $messages; |
| 660 | 660 | } // End setup_post_type_messages() |
@@ -665,23 +665,23 @@ discard block |
||
| 665 | 665 | * @param string $post_type The post type for which to create messages. |
| 666 | 666 | * @return array An array of messages (empty array if the post type isn't one we're looking to work with). |
| 667 | 667 | */ |
| 668 | - private function create_post_type_messages ( $post_type ) { |
|
| 668 | + private function create_post_type_messages($post_type) { |
|
| 669 | 669 | global $post, $post_ID; |
| 670 | 670 | |
| 671 | - if ( ! isset( $this->labels[$post_type] ) ) { return array(); } |
|
| 671 | + if ( ! isset($this->labels[$post_type])) { return array(); } |
|
| 672 | 672 | |
| 673 | 673 | $messages = array( |
| 674 | 674 | 0 => '', |
| 675 | - 1 => sprintf( __( '%1$s updated. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ), |
|
| 676 | - 2 => __( 'Custom field updated.' , 'woothemes-sensei' ), |
|
| 677 | - 3 => __( 'Custom field deleted.' , 'woothemes-sensei' ), |
|
| 678 | - 4 => sprintf( __( '%1$s updated.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ), |
|
| 679 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( '%1$s restored to revision from %2$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 680 | - 6 => sprintf( __( '%1$s published. %2$sView %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a href="' . esc_url( get_permalink( $post_ID ) ) . '">', '</a>' ), |
|
| 681 | - 7 => sprintf( __( '%1$s saved.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'] ), |
|
| 682 | - 8 => sprintf( __( '%1$s submitted. %2$sPreview %1$s%3$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', '</a>' ), |
|
| 683 | - 9 => sprintf( __( '%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<strong>' . date_i18n( __( 'M j, Y @ G:i' , 'woothemes-sensei' ), strtotime( $post->post_date ) ) . '</strong>', '<a target="_blank" href="' . esc_url( get_permalink( $post_ID ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ), |
|
| 684 | - 10 => sprintf( __( '%1$s draft updated. %2$sPreview %3$s%4$s.' , 'woothemes-sensei' ), $this->labels[$post_type]['singular'], '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) . '">', $this->labels[$post_type]['singular'], '</a>' ), |
|
| 675 | + 1 => sprintf(__('%1$s updated. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'), |
|
| 676 | + 2 => __('Custom field updated.', 'woothemes-sensei'), |
|
| 677 | + 3 => __('Custom field deleted.', 'woothemes-sensei'), |
|
| 678 | + 4 => sprintf(__('%1$s updated.', 'woothemes-sensei'), $this->labels[$post_type]['singular']), |
|
| 679 | + 5 => isset($_GET['revision']) ? sprintf(__('%1$s restored to revision from %2$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 680 | + 6 => sprintf(__('%1$s published. %2$sView %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a href="'.esc_url(get_permalink($post_ID)).'">', '</a>'), |
|
| 681 | + 7 => sprintf(__('%1$s saved.', 'woothemes-sensei'), $this->labels[$post_type]['singular']), |
|
| 682 | + 8 => sprintf(__('%1$s submitted. %2$sPreview %1$s%3$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', '</a>'), |
|
| 683 | + 9 => sprintf(__('%1$s scheduled for: %2$s. %3$sPreview %4$s%5$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<strong>'.date_i18n(__('M j, Y @ G:i', 'woothemes-sensei'), strtotime($post->post_date)).'</strong>', '<a target="_blank" href="'.esc_url(get_permalink($post_ID)).'">', $this->labels[$post_type]['singular'], '</a>'), |
|
| 684 | + 10 => sprintf(__('%1$s draft updated. %2$sPreview %3$s%4$s.', 'woothemes-sensei'), $this->labels[$post_type]['singular'], '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))).'">', $this->labels[$post_type]['singular'], '</a>'), |
|
| 685 | 685 | ); |
| 686 | 686 | |
| 687 | 687 | return $messages; |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | * @param string $title |
| 695 | 695 | * @return string $title |
| 696 | 696 | */ |
| 697 | - public function enter_title_here ( $title ) { |
|
| 698 | - if ( get_post_type() == 'course' ) { |
|
| 699 | - $title = __( 'Enter a title for this course here', 'woothemes-sensei' ); |
|
| 700 | - } elseif ( get_post_type() == 'lesson' ) { |
|
| 701 | - $title = __( 'Enter a title for this lesson here', 'woothemes-sensei' ); |
|
| 697 | + public function enter_title_here($title) { |
|
| 698 | + if (get_post_type() == 'course') { |
|
| 699 | + $title = __('Enter a title for this course here', 'woothemes-sensei'); |
|
| 700 | + } elseif (get_post_type() == 'lesson') { |
|
| 701 | + $title = __('Enter a title for this lesson here', 'woothemes-sensei'); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | return $title; |
@@ -712,60 +712,60 @@ discard block |
||
| 712 | 712 | * @param array $post_types |
| 713 | 713 | * @return void |
| 714 | 714 | */ |
| 715 | - public function set_role_cap_defaults( $post_types = array() ) { |
|
| 715 | + public function set_role_cap_defaults($post_types = array()) { |
|
| 716 | 716 | |
| 717 | - foreach ( $post_types as $post_type_item => $post_type_name ) { |
|
| 717 | + foreach ($post_types as $post_type_item => $post_type_name) { |
|
| 718 | 718 | // Super Admin |
| 719 | - $this->role_caps[] = array( 'administrator' => array( 'edit_' . $post_type_item, |
|
| 720 | - 'read_' . $post_type_item, |
|
| 721 | - 'delete_' . $post_type_item, |
|
| 722 | - 'create_' . $post_type_item . 's', |
|
| 723 | - 'edit_' . $post_type_item . 's', |
|
| 724 | - 'edit_others_' . $post_type_item . 's', |
|
| 725 | - 'publish_' . $post_type_item . 's', |
|
| 726 | - 'read_private_' . $post_type_item . 's', |
|
| 719 | + $this->role_caps[] = array('administrator' => array('edit_'.$post_type_item, |
|
| 720 | + 'read_'.$post_type_item, |
|
| 721 | + 'delete_'.$post_type_item, |
|
| 722 | + 'create_'.$post_type_item.'s', |
|
| 723 | + 'edit_'.$post_type_item.'s', |
|
| 724 | + 'edit_others_'.$post_type_item.'s', |
|
| 725 | + 'publish_'.$post_type_item.'s', |
|
| 726 | + 'read_private_'.$post_type_item.'s', |
|
| 727 | 727 | 'read', |
| 728 | - 'delete_' . $post_type_item . 's', |
|
| 729 | - 'delete_private_' . $post_type_item . 's', |
|
| 730 | - 'delete_published_' . $post_type_item . 's', |
|
| 731 | - 'delete_others_' . $post_type_item . 's', |
|
| 732 | - 'edit_private_' . $post_type_item . 's', |
|
| 733 | - 'edit_published_' . $post_type_item . 's', |
|
| 728 | + 'delete_'.$post_type_item.'s', |
|
| 729 | + 'delete_private_'.$post_type_item.'s', |
|
| 730 | + 'delete_published_'.$post_type_item.'s', |
|
| 731 | + 'delete_others_'.$post_type_item.'s', |
|
| 732 | + 'edit_private_'.$post_type_item.'s', |
|
| 733 | + 'edit_published_'.$post_type_item.'s', |
|
| 734 | 734 | 'manage_sensei', |
| 735 | - 'manage_sensei_grades' ), |
|
| 736 | - 'editor' => array( 'edit_' . $post_type_item, |
|
| 737 | - 'read_' . $post_type_item, |
|
| 738 | - 'delete_' . $post_type_item, |
|
| 739 | - 'create_' . $post_type_item . 's', |
|
| 740 | - 'edit_' . $post_type_item . 's', |
|
| 741 | - 'edit_others_' . $post_type_item . 's', |
|
| 742 | - 'publish_' . $post_type_item . 's', |
|
| 743 | - 'read_private_' . $post_type_item . 's', |
|
| 735 | + 'manage_sensei_grades'), |
|
| 736 | + 'editor' => array('edit_'.$post_type_item, |
|
| 737 | + 'read_'.$post_type_item, |
|
| 738 | + 'delete_'.$post_type_item, |
|
| 739 | + 'create_'.$post_type_item.'s', |
|
| 740 | + 'edit_'.$post_type_item.'s', |
|
| 741 | + 'edit_others_'.$post_type_item.'s', |
|
| 742 | + 'publish_'.$post_type_item.'s', |
|
| 743 | + 'read_private_'.$post_type_item.'s', |
|
| 744 | 744 | 'read', |
| 745 | - 'delete_' . $post_type_item . 's', |
|
| 746 | - 'delete_private_' . $post_type_item . 's', |
|
| 747 | - 'delete_published_' . $post_type_item . 's', |
|
| 748 | - 'delete_others_' . $post_type_item . 's', |
|
| 749 | - 'edit_private_' . $post_type_item . 's', |
|
| 750 | - 'edit_published_' . $post_type_item . 's' ), |
|
| 751 | - 'author' => array( 'edit_' . $post_type_item, |
|
| 752 | - 'read_' . $post_type_item, |
|
| 753 | - 'delete_' . $post_type_item, |
|
| 754 | - 'create_' . $post_type_item . 's', |
|
| 755 | - 'edit_' . $post_type_item . 's', |
|
| 756 | - 'publish_' . $post_type_item . 's', |
|
| 745 | + 'delete_'.$post_type_item.'s', |
|
| 746 | + 'delete_private_'.$post_type_item.'s', |
|
| 747 | + 'delete_published_'.$post_type_item.'s', |
|
| 748 | + 'delete_others_'.$post_type_item.'s', |
|
| 749 | + 'edit_private_'.$post_type_item.'s', |
|
| 750 | + 'edit_published_'.$post_type_item.'s'), |
|
| 751 | + 'author' => array('edit_'.$post_type_item, |
|
| 752 | + 'read_'.$post_type_item, |
|
| 753 | + 'delete_'.$post_type_item, |
|
| 754 | + 'create_'.$post_type_item.'s', |
|
| 755 | + 'edit_'.$post_type_item.'s', |
|
| 756 | + 'publish_'.$post_type_item.'s', |
|
| 757 | 757 | 'read', |
| 758 | - 'delete_' . $post_type_item . 's', |
|
| 759 | - 'delete_published_' . $post_type_item . 's', |
|
| 760 | - 'edit_published_' . $post_type_item . 's' ), |
|
| 761 | - 'contributor' => array( 'edit_' . $post_type_item, |
|
| 762 | - 'read_' . $post_type_item, |
|
| 763 | - 'delete_' . $post_type_item, |
|
| 764 | - 'create_' . $post_type_item . 's', |
|
| 765 | - 'edit_' . $post_type_item . 's', |
|
| 758 | + 'delete_'.$post_type_item.'s', |
|
| 759 | + 'delete_published_'.$post_type_item.'s', |
|
| 760 | + 'edit_published_'.$post_type_item.'s'), |
|
| 761 | + 'contributor' => array('edit_'.$post_type_item, |
|
| 762 | + 'read_'.$post_type_item, |
|
| 763 | + 'delete_'.$post_type_item, |
|
| 764 | + 'create_'.$post_type_item.'s', |
|
| 765 | + 'edit_'.$post_type_item.'s', |
|
| 766 | 766 | 'read', |
| 767 | - 'delete_' . $post_type_item . 's' ), |
|
| 768 | - 'subscriber' => array( 'read' ) |
|
| 767 | + 'delete_'.$post_type_item.'s'), |
|
| 768 | + 'subscriber' => array('read') |
|
| 769 | 769 | |
| 770 | 770 | ); |
| 771 | 771 | } // End For Loop |
@@ -779,16 +779,16 @@ discard block |
||
| 779 | 779 | * @param WP_Admin_Bar $bar |
| 780 | 780 | * @return void |
| 781 | 781 | */ |
| 782 | - public function quiz_admin_bar_menu( $bar ) { |
|
| 783 | - if ( is_single() && 'quiz' == get_queried_object()->post_type ) { |
|
| 784 | - $lesson_id = get_post_meta( get_queried_object()->ID, '_quiz_lesson', true ); |
|
| 785 | - if ( $lesson_id ) { |
|
| 782 | + public function quiz_admin_bar_menu($bar) { |
|
| 783 | + if (is_single() && 'quiz' == get_queried_object()->post_type) { |
|
| 784 | + $lesson_id = get_post_meta(get_queried_object()->ID, '_quiz_lesson', true); |
|
| 785 | + if ($lesson_id) { |
|
| 786 | 786 | $object_type = get_post_type_object('quiz'); |
| 787 | - $bar->add_menu( array( |
|
| 787 | + $bar->add_menu(array( |
|
| 788 | 788 | 'id' => 'edit', |
| 789 | 789 | 'title' => $object_type->labels->edit_item, |
| 790 | - 'href' => get_edit_post_link( $lesson_id ), |
|
| 791 | - ) ); |
|
| 790 | + 'href' => get_edit_post_link($lesson_id), |
|
| 791 | + )); |
|
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | } |
@@ -800,4 +800,4 @@ discard block |
||
| 800 | 800 | * @ignore only for backward compatibility |
| 801 | 801 | * @since 1.9.0 |
| 802 | 802 | */ |
| 803 | -class WooThemes_Sensei_PostTypes extends Sensei_PostTypes{} |
|
| 803 | +class WooThemes_Sensei_PostTypes extends Sensei_PostTypes {} |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP |
|
| 3 | 3 | /** |
| 4 | 4 | * Sensei Template Class |
| 5 | 5 | * |
@@ -21,38 +21,38 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | - public static function get_part( $slug, $name = '' ){ |
|
| 24 | + public static function get_part($slug, $name = '') { |
|
| 25 | 25 | |
| 26 | 26 | $template = ''; |
| 27 | 27 | $plugin_template_url = Sensei()->template_url; |
| 28 | - $plugin_template_path = Sensei()->plugin_path() . "/templates/"; |
|
| 28 | + $plugin_template_path = Sensei()->plugin_path()."/templates/"; |
|
| 29 | 29 | |
| 30 | 30 | // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php |
| 31 | - if ( $name ){ |
|
| 31 | + if ($name) { |
|
| 32 | 32 | |
| 33 | - $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) ); |
|
| 33 | + $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php")); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Get default slug-name.php |
| 38 | - if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){ |
|
| 38 | + if ( ! $template && $name && file_exists($plugin_template_path."{$slug}-{$name}.php")) { |
|
| 39 | 39 | |
| 40 | - $template = $plugin_template_path . "{$slug}-{$name}.php"; |
|
| 40 | + $template = $plugin_template_path."{$slug}-{$name}.php"; |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php |
| 46 | - if ( !$template ){ |
|
| 46 | + if ( ! $template) { |
|
| 47 | 47 | |
| 48 | - $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) ); |
|
| 48 | + $template = locate_template(array("{$slug}.php", "{$plugin_template_url}{$slug}.php")); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - if ( $template ){ |
|
| 53 | + if ($template) { |
|
| 54 | 54 | |
| 55 | - load_template( $template, false ); |
|
| 55 | + load_template($template, false); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -68,20 +68,20 @@ discard block |
||
| 68 | 68 | * @param string $template_path |
| 69 | 69 | * @param string $default_path |
| 70 | 70 | */ |
| 71 | - public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 71 | + public static function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 72 | 72 | |
| 73 | - if ( $args && is_array($args) ) |
|
| 74 | - extract( $args ); |
|
| 73 | + if ($args && is_array($args)) |
|
| 74 | + extract($args); |
|
| 75 | 75 | |
| 76 | - $located = self::locate_template( $template_name, $template_path, $default_path ); |
|
| 76 | + $located = self::locate_template($template_name, $template_path, $default_path); |
|
| 77 | 77 | |
| 78 | - if( ! empty( $located ) ){ |
|
| 78 | + if ( ! empty($located)) { |
|
| 79 | 79 | |
| 80 | - do_action( 'sensei_before_template_part', $template_name, $template_path, $located ); |
|
| 80 | + do_action('sensei_before_template_part', $template_name, $template_path, $located); |
|
| 81 | 81 | |
| 82 | - include( $located ); |
|
| 82 | + include($located); |
|
| 83 | 83 | |
| 84 | - do_action( 'sensei_after_template_part', $template_name, $template_path, $located ); |
|
| 84 | + do_action('sensei_after_template_part', $template_name, $template_path, $located); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return mixed|void |
| 100 | 100 | */ |
| 101 | - public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 101 | + public static function locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 102 | 102 | |
| 103 | - if ( ! $template_path ) $template_path = Sensei()->template_url; |
|
| 104 | - if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/'; |
|
| 103 | + if ( ! $template_path) $template_path = Sensei()->template_url; |
|
| 104 | + if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/'; |
|
| 105 | 105 | |
| 106 | 106 | // Look within passed path within the theme - this is priority |
| 107 | 107 | $template = locate_template( |
| 108 | 108 | array( |
| 109 | - $template_path . $template_name, |
|
| 109 | + $template_path.$template_name, |
|
| 110 | 110 | $template_name |
| 111 | 111 | ) |
| 112 | 112 | ); |
| 113 | 113 | |
| 114 | 114 | // Get default template |
| 115 | - if ( ! $template ){ |
|
| 115 | + if ( ! $template) { |
|
| 116 | 116 | |
| 117 | - $template = $default_path . $template_name; |
|
| 117 | + $template = $default_path.$template_name; |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | // return nothing for file that do not exist |
| 121 | - if( !file_exists( $template ) ){ |
|
| 121 | + if ( ! file_exists($template)) { |
|
| 122 | 122 | $template = ''; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // Return what we found |
| 126 | - return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path ); |
|
| 126 | + return apply_filters('sensei_locate_template', $template, $template_name, $template_path); |
|
| 127 | 127 | |
| 128 | 128 | } // end locate |
| 129 | 129 | |
@@ -136,30 +136,30 @@ discard block |
||
| 136 | 136 | * @param string $template |
| 137 | 137 | * @return string $template |
| 138 | 138 | */ |
| 139 | - public static function template_loader ( $template = '' ) { |
|
| 139 | + public static function template_loader($template = '') { |
|
| 140 | 140 | |
| 141 | 141 | global $wp_query, $email_template; |
| 142 | 142 | |
| 143 | - $find = array( 'woothemes-sensei.php' ); |
|
| 143 | + $find = array('woothemes-sensei.php'); |
|
| 144 | 144 | $file = ''; |
| 145 | 145 | |
| 146 | - if ( isset( $email_template ) && $email_template ) { |
|
| 146 | + if (isset($email_template) && $email_template) { |
|
| 147 | 147 | |
| 148 | - $file = 'emails/' . $email_template; |
|
| 148 | + $file = 'emails/'.$email_template; |
|
| 149 | 149 | $find[] = $file; |
| 150 | - $find[] = Sensei()->template_url . $file; |
|
| 150 | + $find[] = Sensei()->template_url.$file; |
|
| 151 | 151 | |
| 152 | - } elseif ( is_single() && get_post_type() == 'course' ) { |
|
| 152 | + } elseif (is_single() && get_post_type() == 'course') { |
|
| 153 | 153 | |
| 154 | - if ( Sensei()->check_user_permissions( 'course-single' ) ) { |
|
| 154 | + if (Sensei()->check_user_permissions('course-single')) { |
|
| 155 | 155 | |
| 156 | 156 | // possible backward compatible template include if theme overrides content-single-course.php |
| 157 | 157 | // this template was removed in 1.9.0 and code all moved into the main single-course.php file |
| 158 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true ); |
|
| 158 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true); |
|
| 159 | 159 | |
| 160 | - $file = 'single-course.php'; |
|
| 160 | + $file = 'single-course.php'; |
|
| 161 | 161 | $find[] = $file; |
| 162 | - $find[] = Sensei()->template_url . $file; |
|
| 162 | + $find[] = Sensei()->template_url.$file; |
|
| 163 | 163 | |
| 164 | 164 | } else { |
| 165 | 165 | |
@@ -168,17 +168,17 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | } // End If Statement |
| 170 | 170 | |
| 171 | - } elseif ( is_single() && get_post_type() == 'lesson' ) { |
|
| 171 | + } elseif (is_single() && get_post_type() == 'lesson') { |
|
| 172 | 172 | |
| 173 | - if ( Sensei()->check_user_permissions( 'lesson-single' ) ) { |
|
| 173 | + if (Sensei()->check_user_permissions('lesson-single')) { |
|
| 174 | 174 | |
| 175 | 175 | // possible backward compatible template include if theme overrides content-single-lesson.php |
| 176 | 176 | // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file |
| 177 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true ); |
|
| 177 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true); |
|
| 178 | 178 | |
| 179 | - $file = 'single-lesson.php'; |
|
| 179 | + $file = 'single-lesson.php'; |
|
| 180 | 180 | $find[] = $file; |
| 181 | - $find[] = Sensei()->template_url . $file; |
|
| 181 | + $find[] = Sensei()->template_url.$file; |
|
| 182 | 182 | |
| 183 | 183 | } else { |
| 184 | 184 | |
@@ -187,17 +187,17 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | } // End If Statement |
| 189 | 189 | |
| 190 | - } elseif ( is_single() && get_post_type() == 'quiz' ) { |
|
| 190 | + } elseif (is_single() && get_post_type() == 'quiz') { |
|
| 191 | 191 | |
| 192 | - if ( Sensei()->check_user_permissions( 'quiz-single' ) ) { |
|
| 192 | + if (Sensei()->check_user_permissions('quiz-single')) { |
|
| 193 | 193 | |
| 194 | 194 | // possible backward compatible template include if theme overrides content-single-quiz.php |
| 195 | 195 | // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file |
| 196 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true); |
|
| 196 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true); |
|
| 197 | 197 | |
| 198 | - $file = 'single-quiz.php'; |
|
| 198 | + $file = 'single-quiz.php'; |
|
| 199 | 199 | $find[] = $file; |
| 200 | - $find[] = Sensei()->template_url . $file; |
|
| 200 | + $find[] = Sensei()->template_url.$file; |
|
| 201 | 201 | |
| 202 | 202 | } else { |
| 203 | 203 | |
@@ -206,76 +206,76 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | } // End If Statement |
| 208 | 208 | |
| 209 | - } elseif ( is_single() && get_post_type() == 'sensei_message' ) { |
|
| 209 | + } elseif (is_single() && get_post_type() == 'sensei_message') { |
|
| 210 | 210 | |
| 211 | 211 | // possible backward compatible template include if theme overrides content-single-message.php |
| 212 | 212 | // this template was removed in 1.9.0 and code all moved into the main single-message.php file |
| 213 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true ); |
|
| 213 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true); |
|
| 214 | 214 | |
| 215 | - $file = 'single-message.php'; |
|
| 215 | + $file = 'single-message.php'; |
|
| 216 | 216 | $find[] = $file; |
| 217 | - $find[] = Sensei()->template_url . $file; |
|
| 217 | + $find[] = Sensei()->template_url.$file; |
|
| 218 | 218 | |
| 219 | - } elseif ( is_post_type_archive( 'course' ) |
|
| 220 | - || is_page( Sensei()->get_page_id( 'courses' ) ) |
|
| 221 | - || is_tax( 'course-category' )) { |
|
| 219 | + } elseif (is_post_type_archive('course') |
|
| 220 | + || is_page(Sensei()->get_page_id('courses')) |
|
| 221 | + || is_tax('course-category')) { |
|
| 222 | 222 | |
| 223 | 223 | // possible backward compatible template include if theme overrides 'taxonomy-course-category' |
| 224 | 224 | // this template was removed in 1.9.0 and replaced by archive-course.php |
| 225 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php'); |
|
| 225 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php'); |
|
| 226 | 226 | |
| 227 | - $file = 'archive-course.php'; |
|
| 227 | + $file = 'archive-course.php'; |
|
| 228 | 228 | $find[] = $file; |
| 229 | - $find[] = Sensei()->template_url . $file; |
|
| 229 | + $find[] = Sensei()->template_url.$file; |
|
| 230 | 230 | |
| 231 | - } elseif ( is_post_type_archive( 'sensei_message' ) ) { |
|
| 231 | + } elseif (is_post_type_archive('sensei_message')) { |
|
| 232 | 232 | |
| 233 | - $file = 'archive-message.php'; |
|
| 233 | + $file = 'archive-message.php'; |
|
| 234 | 234 | $find[] = $file; |
| 235 | - $find[] = Sensei()->template_url . $file; |
|
| 235 | + $find[] = Sensei()->template_url.$file; |
|
| 236 | 236 | |
| 237 | - } elseif( is_tax( 'lesson-tag' ) ) { |
|
| 237 | + } elseif (is_tax('lesson-tag')) { |
|
| 238 | 238 | |
| 239 | 239 | // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php' |
| 240 | 240 | // this template was removed in 1.9.0 and replaced by archive-lesson.php |
| 241 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' ); |
|
| 241 | + self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php'); |
|
| 242 | 242 | |
| 243 | - $file = 'archive-lesson.php'; |
|
| 243 | + $file = 'archive-lesson.php'; |
|
| 244 | 244 | $find[] = $file; |
| 245 | - $find[] = Sensei()->template_url . $file; |
|
| 245 | + $find[] = Sensei()->template_url.$file; |
|
| 246 | 246 | |
| 247 | - } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) { |
|
| 247 | + } elseif (isset($wp_query->query_vars['learner_profile'])) { |
|
| 248 | 248 | |
| 249 | 249 | // Override for sites with static home page |
| 250 | 250 | $wp_query->is_home = false; |
| 251 | 251 | |
| 252 | - $file = 'learner-profile.php'; |
|
| 252 | + $file = 'learner-profile.php'; |
|
| 253 | 253 | $find[] = $file; |
| 254 | - $find[] = Sensei()->template_url . $file; |
|
| 254 | + $find[] = Sensei()->template_url.$file; |
|
| 255 | 255 | |
| 256 | - } elseif ( isset( $wp_query->query_vars['course_results'] ) ) { |
|
| 256 | + } elseif (isset($wp_query->query_vars['course_results'])) { |
|
| 257 | 257 | |
| 258 | 258 | // Override for sites with static home page |
| 259 | 259 | $wp_query->is_home = false; |
| 260 | 260 | |
| 261 | 261 | $file = 'course-results.php'; |
| 262 | 262 | $find[] = $file; |
| 263 | - $find[] = Sensei()->template_url . $file; |
|
| 263 | + $find[] = Sensei()->template_url.$file; |
|
| 264 | 264 | |
| 265 | - }elseif( is_author() |
|
| 266 | - && Sensei_Teacher::is_a_teacher( get_query_var('author') ) |
|
| 267 | - && ! user_can( get_query_var('author'), 'manage_options' ) ){ |
|
| 265 | + }elseif (is_author() |
|
| 266 | + && Sensei_Teacher::is_a_teacher(get_query_var('author')) |
|
| 267 | + && ! user_can(get_query_var('author'), 'manage_options')) { |
|
| 268 | 268 | |
| 269 | 269 | $file = 'teacher-archive.php'; |
| 270 | 270 | $find[] = $file; |
| 271 | - $find[] = Sensei()->template_url . $file; |
|
| 271 | + $find[] = Sensei()->template_url.$file; |
|
| 272 | 272 | |
| 273 | 273 | } // Load the template file |
| 274 | 274 | |
| 275 | - if ( $file ) { |
|
| 275 | + if ($file) { |
|
| 276 | 276 | |
| 277 | - $template = locate_template( $find ); |
|
| 278 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 277 | + $template = locate_template($find); |
|
| 278 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 279 | 279 | |
| 280 | 280 | } // End If Statement |
| 281 | 281 | |
@@ -295,21 +295,21 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @since 1.9.0 |
| 297 | 297 | */ |
| 298 | - public static function get_no_permission_template( ){ |
|
| 298 | + public static function get_no_permission_template( ) { |
|
| 299 | 299 | |
| 300 | 300 | // possible backward compatible template loading |
| 301 | 301 | // this template was removed in 1.9.0 and code all moved into the no-permissions.php file |
| 302 | - self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true ); |
|
| 302 | + self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true); |
|
| 303 | 303 | |
| 304 | - $file = 'no-permissions.php'; |
|
| 304 | + $file = 'no-permissions.php'; |
|
| 305 | 305 | $find[] = $file; |
| 306 | - $find[] = Sensei()->template_url . $file; |
|
| 306 | + $find[] = Sensei()->template_url.$file; |
|
| 307 | 307 | |
| 308 | - $template = locate_template( $find ); |
|
| 309 | - if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file; |
|
| 308 | + $template = locate_template($find); |
|
| 309 | + if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file; |
|
| 310 | 310 | |
| 311 | 311 | // set a global constant so that we know that we're in this template |
| 312 | - define('SENSEI_NO_PERMISSION', true ); |
|
| 312 | + define('SENSEI_NO_PERMISSION', true); |
|
| 313 | 313 | |
| 314 | 314 | return $template; |
| 315 | 315 | |
@@ -328,20 +328,20 @@ discard block |
||
| 328 | 328 | * @param string $template |
| 329 | 329 | * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true |
| 330 | 330 | */ |
| 331 | - public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){ |
|
| 331 | + public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) { |
|
| 332 | 332 | |
| 333 | - $found_template = locate_template( array( $template ) ); |
|
| 334 | - if( $found_template ){ |
|
| 333 | + $found_template = locate_template(array($template)); |
|
| 334 | + if ($found_template) { |
|
| 335 | 335 | |
| 336 | - if( $load_header_footer ){ |
|
| 336 | + if ($load_header_footer) { |
|
| 337 | 337 | |
| 338 | 338 | get_sensei_header(); |
| 339 | - include( $found_template ); |
|
| 339 | + include($found_template); |
|
| 340 | 340 | get_sensei_footer(); |
| 341 | 341 | |
| 342 | - }else{ |
|
| 342 | + } else { |
|
| 343 | 343 | |
| 344 | - include( $found_template ); |
|
| 344 | + include($found_template); |
|
| 345 | 345 | |
| 346 | 346 | } |
| 347 | 347 | |
@@ -358,9 +358,9 @@ discard block |
||
| 358 | 358 | * |
| 359 | 359 | * @deprecated since 1.9.0 |
| 360 | 360 | */ |
| 361 | - public static function deprecated_archive_course_content_hook(){ |
|
| 361 | + public static function deprecated_archive_course_content_hook() { |
|
| 362 | 362 | |
| 363 | - sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' ); |
|
| 363 | + sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before'); |
|
| 364 | 364 | |
| 365 | 365 | }// end deprecated_archive_hook |
| 366 | 366 | |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | * @since 1.9.0 |
| 371 | 371 | * @param WP_Post $post |
| 372 | 372 | */ |
| 373 | - public static function the_title( $post ){ |
|
| 373 | + public static function the_title($post) { |
|
| 374 | 374 | |
| 375 | 375 | // ID passed in |
| 376 | - if( is_numeric( $post ) ){ |
|
| 377 | - $post = get_post( $post ); |
|
| 376 | + if (is_numeric($post)) { |
|
| 377 | + $post = get_post($post); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @param $title_html_tag default is 'h3' |
| 386 | 386 | */ |
| 387 | - $title_html_tag = apply_filters('sensei_the_title_html_tag','h3'); |
|
| 387 | + $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3'); |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Filter the title classes |
@@ -392,14 +392,14 @@ discard block |
||
| 392 | 392 | * @since 1.9.0 |
| 393 | 393 | * @param string $title_classes defaults to $post_type-title |
| 394 | 394 | */ |
| 395 | - $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' ); |
|
| 395 | + $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title'); |
|
| 396 | 396 | |
| 397 | - $html= ''; |
|
| 398 | - $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >'; |
|
| 399 | - $html .= '<a href="' . get_permalink( $post->ID ) . '" >'; |
|
| 400 | - $html .= $post->post_title ; |
|
| 397 | + $html = ''; |
|
| 398 | + $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >'; |
|
| 399 | + $html .= '<a href="'.get_permalink($post->ID).'" >'; |
|
| 400 | + $html .= $post->post_title; |
|
| 401 | 401 | $html .= '</a>'; |
| 402 | - $html .= '</'. $title_html_tag. '>'; |
|
| 402 | + $html .= '</'.$title_html_tag.'>'; |
|
| 403 | 403 | echo $html; |
| 404 | 404 | |
| 405 | 405 | }// end the title |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | * @since 1.9.0 |
| 412 | 412 | * @deprecated 1.9.0 |
| 413 | 413 | */ |
| 414 | - public static function deprecated_single_course_inside_before_hooks(){ |
|
| 414 | + public static function deprecated_single_course_inside_before_hooks() { |
|
| 415 | 415 | |
| 416 | - sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) ); |
|
| 417 | - sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 418 | - sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 416 | + sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID())); |
|
| 417 | + sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 418 | + sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 419 | 419 | |
| 420 | 420 | }// end deprecated_single_course_inside_before_hooks |
| 421 | 421 | |
@@ -426,9 +426,9 @@ discard block |
||
| 426 | 426 | * @since 1.9.0 |
| 427 | 427 | * @deprecated 1.9.0 |
| 428 | 428 | */ |
| 429 | - public static function deprecate_sensei_course_single_lessons_hook(){ |
|
| 429 | + public static function deprecate_sensei_course_single_lessons_hook() { |
|
| 430 | 430 | |
| 431 | - sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 431 | + sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after'); |
|
| 432 | 432 | |
| 433 | 433 | }// deprecate_sensei_course_single_lessons_hook |
| 434 | 434 | |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | * @since 1.9.0 |
| 441 | 441 | * @deprecated 1.9.0 |
| 442 | 442 | */ |
| 443 | - public static function deprecated_single_main_content_hook(){ |
|
| 443 | + public static function deprecated_single_main_content_hook() { |
|
| 444 | 444 | |
| 445 | - if( is_singular( 'course' ) ) { |
|
| 445 | + if (is_singular('course')) { |
|
| 446 | 446 | |
| 447 | 447 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after'); |
| 448 | 448 | |
| 449 | - } elseif( is_singular( 'message' ) ){ |
|
| 449 | + } elseif (is_singular('message')) { |
|
| 450 | 450 | |
| 451 | 451 | sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after'); |
| 452 | 452 | } |
@@ -458,9 +458,9 @@ discard block |
||
| 458 | 458 | * @since 1.9.0 |
| 459 | 459 | * @deprecated since 1.9.0 |
| 460 | 460 | */ |
| 461 | - public static function deprecate_module_before_hook(){ |
|
| 461 | + public static function deprecate_module_before_hook() { |
|
| 462 | 462 | |
| 463 | - sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' ); |
|
| 463 | + sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 464 | 464 | |
| 465 | 465 | } |
| 466 | 466 | |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | * @since 1.9.0 |
| 470 | 470 | * @deprecated since 1.9.0 |
| 471 | 471 | */ |
| 472 | - public static function deprecate_module_after_hook(){ |
|
| 472 | + public static function deprecate_module_after_hook() { |
|
| 473 | 473 | |
| 474 | - sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' ); |
|
| 474 | + sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after'); |
|
| 475 | 475 | |
| 476 | 476 | } |
| 477 | 477 | |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | * @since 1.9.0 |
| 482 | 482 | * @deprecated since 1.9.0 |
| 483 | 483 | */ |
| 484 | - public static function deprecate_all_post_type_single_title_hooks(){ |
|
| 484 | + public static function deprecate_all_post_type_single_title_hooks() { |
|
| 485 | 485 | |
| 486 | - if( is_singular( 'sensei_message' ) ){ |
|
| 486 | + if (is_singular('sensei_message')) { |
|
| 487 | 487 | |
| 488 | - sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' ); |
|
| 488 | + sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before'); |
|
| 489 | 489 | |
| 490 | 490 | } |
| 491 | 491 | |
@@ -501,10 +501,10 @@ discard block |
||
| 501 | 501 | public static function deprecate_course_single_meta_hooks() { |
| 502 | 502 | |
| 503 | 503 | // deprecate all these hooks |
| 504 | - sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 505 | - sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 506 | - sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 507 | - sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' ); |
|
| 504 | + sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 505 | + sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 506 | + sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 507 | + sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before'); |
|
| 508 | 508 | |
| 509 | 509 | } // End deprecate_course_single_meta_hooks |
| 510 | 510 | |
@@ -514,10 +514,10 @@ discard block |
||
| 514 | 514 | */ |
| 515 | 515 | public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() { |
| 516 | 516 | |
| 517 | - if( is_singular( 'lesson' ) ){ |
|
| 517 | + if (is_singular('lesson')) { |
|
| 518 | 518 | |
| 519 | - sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 520 | - sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content', get_the_ID() ); |
|
| 519 | + sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 520 | + sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID()); |
|
| 521 | 521 | |
| 522 | 522 | } |
| 523 | 523 | |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | * |
| 532 | 532 | * @deprecated since 1.9.0 |
| 533 | 533 | */ |
| 534 | - public static function deprecate_sensei_lesson_course_signup_hook(){ |
|
| 534 | + public static function deprecate_sensei_lesson_course_signup_hook() { |
|
| 535 | 535 | |
| 536 | - $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true ); |
|
| 537 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() ); |
|
| 536 | + $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true); |
|
| 537 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()); |
|
| 538 | 538 | |
| 539 | - if( !$user_taking_course ) { |
|
| 539 | + if ( ! $user_taking_course) { |
|
| 540 | 540 | |
| 541 | - sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id ); |
|
| 541 | + sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id); |
|
| 542 | 542 | |
| 543 | 543 | } |
| 544 | 544 | }// end deprecate_sensei_lesson_course_signup_hook |
@@ -549,11 +549,11 @@ discard block |
||
| 549 | 549 | * @since 1.9.0 |
| 550 | 550 | * @deprecated since 1.9.0 |
| 551 | 551 | */ |
| 552 | - public static function deprecate_sensei_lesson_single_meta_hook(){ |
|
| 552 | + public static function deprecate_sensei_lesson_single_meta_hook() { |
|
| 553 | 553 | |
| 554 | - if ( sensei_can_user_view_lesson() ) { |
|
| 554 | + if (sensei_can_user_view_lesson()) { |
|
| 555 | 555 | |
| 556 | - sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' ); |
|
| 556 | + sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after'); |
|
| 557 | 557 | |
| 558 | 558 | |
| 559 | 559 | } |
@@ -564,9 +564,9 @@ discard block |
||
| 564 | 564 | * Deprecate the sensei lesson single title hook |
| 565 | 565 | * @deprecated since 1.9.0 |
| 566 | 566 | */ |
| 567 | - public static function deprecate_sensei_lesson_single_title(){ |
|
| 567 | + public static function deprecate_sensei_lesson_single_title() { |
|
| 568 | 568 | |
| 569 | - sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 569 | + sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 570 | 570 | |
| 571 | 571 | }// end deprecate_sensei_lesson_single_title |
| 572 | 572 | |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | * hook in the deperecated single main content to the lesson |
| 575 | 575 | * @deprecated since 1.9.0 |
| 576 | 576 | */ |
| 577 | - public static function deprecate_lesson_single_main_content_hook(){ |
|
| 577 | + public static function deprecate_lesson_single_main_content_hook() { |
|
| 578 | 578 | |
| 579 | - sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' ); |
|
| 579 | + sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before'); |
|
| 580 | 580 | |
| 581 | 581 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 582 | 582 | |
@@ -584,9 +584,9 @@ discard block |
||
| 584 | 584 | * hook in the deperecated single main content to the lesson |
| 585 | 585 | * @deprecated since 1.9.0 |
| 586 | 586 | */ |
| 587 | - public static function deprecate_lesson_image_hook(){ |
|
| 587 | + public static function deprecate_lesson_image_hook() { |
|
| 588 | 588 | |
| 589 | - sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() ); |
|
| 589 | + sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID()); |
|
| 590 | 590 | |
| 591 | 591 | }// end sensei_deprecate_lesson_single_main_content_hook |
| 592 | 592 | |
@@ -597,9 +597,9 @@ discard block |
||
| 597 | 597 | * @since 1.9.0 |
| 598 | 598 | * @deprecated since 1.9.0 |
| 599 | 599 | */ |
| 600 | - public static function deprecate_sensei_login_form_hook(){ |
|
| 600 | + public static function deprecate_sensei_login_form_hook() { |
|
| 601 | 601 | |
| 602 | - sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' ); |
|
| 602 | + sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before'); |
|
| 603 | 603 | |
| 604 | 604 | } // end deprecate_sensei_login_form_hook |
| 605 | 605 | |
@@ -612,9 +612,9 @@ discard block |
||
| 612 | 612 | * |
| 613 | 613 | * @since 1.9.0 |
| 614 | 614 | */ |
| 615 | - public static function fire_sensei_complete_course_hook(){ |
|
| 615 | + public static function fire_sensei_complete_course_hook() { |
|
| 616 | 616 | |
| 617 | - do_action( 'sensei_complete_course' ); |
|
| 617 | + do_action('sensei_complete_course'); |
|
| 618 | 618 | |
| 619 | 619 | } //fire_sensei_complete_course_hook |
| 620 | 620 | |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | * |
| 624 | 624 | * @since 1.9.0 |
| 625 | 625 | */ |
| 626 | - public static function fire_frontend_messages_hook(){ |
|
| 626 | + public static function fire_frontend_messages_hook() { |
|
| 627 | 627 | |
| 628 | - do_action( 'sensei_frontend_messages' ); |
|
| 628 | + do_action('sensei_frontend_messages'); |
|
| 629 | 629 | |
| 630 | 630 | }// end sensei_complete_course_action |
| 631 | 631 | |
@@ -635,9 +635,9 @@ discard block |
||
| 635 | 635 | * |
| 636 | 636 | * @deprected since 1.9.0 |
| 637 | 637 | */ |
| 638 | - public static function deprecate_sensei_before_user_course_content_hook(){ |
|
| 638 | + public static function deprecate_sensei_before_user_course_content_hook() { |
|
| 639 | 639 | |
| 640 | - sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() ); |
|
| 640 | + sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user()); |
|
| 641 | 641 | |
| 642 | 642 | }// deprecate_sensei_before_user_course_content_hook |
| 643 | 643 | |
@@ -647,9 +647,9 @@ discard block |
||
| 647 | 647 | * |
| 648 | 648 | * @deprected since 1.9.0 |
| 649 | 649 | */ |
| 650 | - public static function deprecate_sensei_after_user_course_content_hook(){ |
|
| 650 | + public static function deprecate_sensei_after_user_course_content_hook() { |
|
| 651 | 651 | |
| 652 | - sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() ); |
|
| 652 | + sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user()); |
|
| 653 | 653 | |
| 654 | 654 | }// deprecate_sensei_after_user_course_content_hook |
| 655 | 655 | |
@@ -659,10 +659,10 @@ discard block |
||
| 659 | 659 | * @deprecated since 1.9.0 |
| 660 | 660 | * @since 1.9.0 |
| 661 | 661 | */ |
| 662 | - public static function deprecated_archive_message_hooks (){ |
|
| 662 | + public static function deprecated_archive_message_hooks() { |
|
| 663 | 663 | |
| 664 | - sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' ); |
|
| 665 | - sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' ); |
|
| 664 | + sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop'); |
|
| 665 | + sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop'); |
|
| 666 | 666 | |
| 667 | 667 | } |
| 668 | 668 | |
@@ -672,9 +672,9 @@ discard block |
||
| 672 | 672 | * |
| 673 | 673 | * @deprecated since 1.9.0 |
| 674 | 674 | */ |
| 675 | - public static function deprecate_sensei_complete_quiz_action(){ |
|
| 675 | + public static function deprecate_sensei_complete_quiz_action() { |
|
| 676 | 676 | |
| 677 | - sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' ); |
|
| 677 | + sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before'); |
|
| 678 | 678 | |
| 679 | 679 | } |
| 680 | 680 | |
@@ -684,7 +684,7 @@ discard block |
||
| 684 | 684 | * |
| 685 | 685 | * @deprecated since 1.9.0 |
| 686 | 686 | */ |
| 687 | - public static function deprecate_sensei_quiz_question_type_action(){ |
|
| 687 | + public static function deprecate_sensei_quiz_question_type_action() { |
|
| 688 | 688 | |
| 689 | 689 | // Question Type |
| 690 | 690 | global $sensei_question_loop; |