woothemes /
sensei
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
||
| 3 | |||
| 4 | /* |
||
| 5 | * Sensei Settings Class |
||
| 6 | * |
||
| 7 | * All functionality pertaining to the settings in Sensei. |
||
| 8 | * |
||
| 9 | * @package Core |
||
| 10 | * @author Automattic |
||
| 11 | * |
||
| 12 | * @since 1.0.0 |
||
| 13 | */ |
||
| 14 | class Sensei_Settings extends Sensei_Settings_API { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor. |
||
| 18 | * @access public |
||
| 19 | * @since 1.0.0 |
||
| 20 | */ |
||
| 21 | public function __construct () { |
||
| 22 | parent::__construct(); // Required in extended classes. |
||
| 23 | |||
| 24 | $this->token = 'woothemes-sensei-settings'; |
||
| 25 | add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
||
| 26 | |||
| 27 | // Setup Admin Settings data |
||
| 28 | if ( is_admin() ) { |
||
| 29 | |||
| 30 | $this->has_tabs = true; |
||
| 31 | $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
||
| 32 | $this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
||
| 33 | $this->page_slug = 'woothemes-sensei-settings'; |
||
| 34 | |||
| 35 | } // End If Statement |
||
| 36 | |||
| 37 | $this->register_hook_listener(); |
||
| 38 | $this->get_settings(); |
||
| 39 | |||
| 40 | } // End __construct() |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get settings value |
||
| 44 | * |
||
| 45 | * @since 1.9.0 |
||
| 46 | * @param string $setting_name |
||
| 47 | * @return mixed |
||
| 48 | */ |
||
| 49 | public function get( $setting_name ){ |
||
| 50 | |||
| 51 | if( isset( $this->settings[ $setting_name ] ) ){ |
||
| 52 | |||
| 53 | return $this->settings[ $setting_name ]; |
||
| 54 | |||
| 55 | } |
||
| 56 | |||
| 57 | return false; |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @since 1.9.0 |
||
| 62 | * |
||
| 63 | * @param $setting |
||
| 64 | * @param $new_value |
||
| 65 | */ |
||
| 66 | public function set( $setting, $new_value ){ |
||
| 67 | |||
| 68 | $settings = get_option( $this->token, array() ); |
||
| 69 | $settings[ $setting ] = $new_value; |
||
| 70 | return update_option( $this->token,$settings ); |
||
| 71 | |||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Register the settings screen within the WordPress admin. |
||
| 76 | * @access public |
||
| 77 | * @since 1.0.0 |
||
| 78 | * @return void |
||
| 79 | */ |
||
| 80 | public function register_settings_screen () { |
||
| 81 | |||
| 82 | $this->settings_version = Sensei()->version; // Use the global plugin version on this settings screen. |
||
| 83 | $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
||
| 84 | $this->hook = $hook; |
||
| 85 | |||
| 86 | if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
||
| 87 | add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
||
| 88 | add_action( 'admin_notices', array( $this, 'language_pack_notices' ) ); |
||
| 89 | add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
||
| 90 | add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
||
| 91 | } |
||
| 92 | } // End register_settings_screen() |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Add settings sections. |
||
| 96 | * @access public |
||
| 97 | * @since 1.0.0 |
||
| 98 | * @return void |
||
| 99 | */ |
||
| 100 | public function init_sections () { |
||
| 101 | $sections = array(); |
||
| 102 | |||
| 103 | $sections['default-settings'] = array( |
||
| 104 | 'name' => __( 'General', 'woothemes-sensei' ), |
||
| 105 | 'description' => __( 'Settings that apply to the entire plugin.', 'woothemes-sensei' ) |
||
| 106 | ); |
||
| 107 | |||
| 108 | $sections['course-settings'] = array( |
||
| 109 | 'name' => __( 'Courses', 'woothemes-sensei' ), |
||
| 110 | 'description' => __( 'Settings that apply to all Courses.', 'woothemes-sensei' ) |
||
| 111 | ); |
||
| 112 | |||
| 113 | $sections['lesson-settings'] = array( |
||
| 114 | 'name' => __( 'Lessons', 'woothemes-sensei' ), |
||
| 115 | 'description' => __( 'Settings that apply to all Lessons.', 'woothemes-sensei' ) |
||
| 116 | ); |
||
| 117 | |||
| 118 | $sections['email-notification-settings'] = array( |
||
| 119 | 'name' => __( 'Email Notifications', 'woothemes-sensei' ), |
||
| 120 | 'description' => __( 'Settings for email notifications sent from your site.', 'woothemes-sensei' ) |
||
| 121 | ); |
||
| 122 | |||
| 123 | $sections['learner-profile-settings'] = array( |
||
| 124 | 'name' => __( 'Learner Profiles', 'woothemes-sensei' ), |
||
| 125 | 'description' => __( 'Settings for public Learner Profiles.', 'woothemes-sensei' ) |
||
| 126 | ); |
||
| 127 | |||
| 128 | if ( Sensei_WC::is_woocommerce_present() ) { |
||
| 129 | $sections['woocommerce-settings'] = array( |
||
| 130 | 'name' => __( 'WooCommerce', 'woothemes-sensei' ), |
||
| 131 | 'description' => __( 'Optional settings for WooCommerce functions.', 'woothemes-sensei' ) |
||
| 132 | ); |
||
| 133 | } // End If Statement |
||
| 134 | |||
| 135 | if ( 'en_US' !== get_locale() ) { |
||
| 136 | $sections['language-settings'] = array( |
||
| 137 | 'name' => __( 'Language', 'woothemes-sensei' ), |
||
| 138 | 'description' => __( 'Language options.', 'woothemes-sensei' ) |
||
| 139 | ); |
||
| 140 | } |
||
| 141 | |||
| 142 | $this->sections = apply_filters( 'sensei_settings_tabs', $sections ); |
||
| 143 | } // End init_sections() |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Add settings fields. |
||
| 147 | * @access public |
||
| 148 | * @since 1.0.0 |
||
| 149 | * @uses Sensei_Utils::get_slider_types() |
||
| 150 | * @return void |
||
| 151 | */ |
||
| 152 | public function init_fields () { |
||
| 153 | global $pagenow; |
||
| 154 | |||
| 155 | $pages_array = $this->pages_array(); |
||
| 156 | $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' ); |
||
| 157 | $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' ) ); |
||
| 158 | $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
||
| 159 | |||
| 160 | $fields = array(); |
||
| 161 | |||
| 162 | $fields['access_permission'] = array( |
||
| 163 | 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
||
| 164 | 'description' => __( 'Users must be logged in to view Course and Lesson content.', 'woothemes-sensei', 'woothemes-sensei' ), |
||
| 165 | 'type' => 'checkbox', |
||
| 166 | 'default' => true, |
||
| 167 | 'section' => 'default-settings' |
||
| 168 | ); |
||
| 169 | |||
| 170 | $fields['messages_disable'] = array( |
||
| 171 | 'name' => __( 'Disable Private Messages', 'woothemes-sensei' ), |
||
| 172 | 'description' => __( 'Disable the private message functions between learners and teachers.', 'woothemes-sensei' ), |
||
| 173 | 'type' => 'checkbox', |
||
| 174 | 'default' => false, |
||
| 175 | 'section' => 'default-settings' |
||
| 176 | ); |
||
| 177 | |||
| 178 | $fields['course_page'] = array( |
||
| 179 | 'name' => __( 'Course Archive Page', 'woothemes-sensei' ), |
||
| 180 | 'description' => __( 'The page to use to display courses. If you leave this blank the default custom post type archive will apply.', 'woothemes-sensei' ), |
||
| 181 | 'type' => 'select', |
||
| 182 | 'default' => get_option( 'woothemes-sensei_courses_page_id', 0 ), |
||
| 183 | 'section' => 'default-settings', |
||
| 184 | 'required' => 0, |
||
| 185 | 'options' => $pages_array |
||
| 186 | ); |
||
| 187 | |||
| 188 | $fields['my_course_page'] = array( |
||
| 189 | 'name' => __( 'My Courses Page', 'woothemes-sensei' ), |
||
| 190 | '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' ), |
||
| 191 | 'type' => 'select', |
||
| 192 | 'default' => get_option( 'woothemes-sensei_user_dashboard_page_id', 0 ), |
||
| 193 | 'section' => 'default-settings', |
||
| 194 | 'required' => 0, |
||
| 195 | 'options' => $pages_array |
||
| 196 | ); |
||
| 197 | |||
| 198 | $fields['placeholder_images_enable'] = array( |
||
| 199 | 'name' => __( 'Use placeholder images', 'woothemes-sensei' ), |
||
| 200 | 'description' => __( 'Output a placeholder image when no featured image has been specified for Courses and Lessons.', 'woothemes-sensei' ), |
||
| 201 | 'type' => 'checkbox', |
||
| 202 | 'default' => false, |
||
| 203 | 'section' => 'default-settings' |
||
| 204 | ); |
||
| 205 | |||
| 206 | $fields['styles_disable'] = array( |
||
| 207 | 'name' => __( 'Disable Sensei Styles', 'woothemes-sensei' ), |
||
| 208 | 'description' => __( 'Prevent the frontend stylesheets from loading. This will remove the default styles for all Sensei elements.', 'woothemes-sensei' ), |
||
| 209 | 'type' => 'checkbox', |
||
| 210 | 'default' => false, |
||
| 211 | 'section' => 'default-settings' |
||
| 212 | ); |
||
| 213 | |||
| 214 | $fields['js_disable'] = array( |
||
| 215 | 'name' => __( 'Disable Sensei Javascript', 'woothemes-sensei' ), |
||
| 216 | 'description' => __( 'Prevent the frontend javascript from loading. This affects the progress bars and the My Courses tabs.', 'woothemes-sensei' ), |
||
| 217 | 'type' => 'checkbox', |
||
| 218 | 'default' => false, |
||
| 219 | 'section' => 'default-settings' |
||
| 220 | ); |
||
| 221 | |||
| 222 | // Course Settings |
||
| 223 | |||
| 224 | $fields['course_completion'] = array( |
||
| 225 | 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
||
| 226 | 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
||
| 227 | 'type' => 'select', |
||
| 228 | 'default' => 'passed', |
||
| 229 | 'section' => 'course-settings', |
||
| 230 | 'required' => 0, |
||
| 231 | 'options' => $complete_settings |
||
| 232 | ); |
||
| 233 | |||
| 234 | $fields['course_author'] = array( |
||
| 235 | 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
||
| 236 | 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
||
| 237 | 'type' => 'checkbox', |
||
| 238 | 'default' => true, |
||
| 239 | 'section' => 'course-settings' |
||
| 240 | ); |
||
| 241 | |||
| 242 | $fields['my_course_amount'] = array( |
||
| 243 | 'name' => __( 'My Courses Pagination', 'woothemes-sensei' ), |
||
| 244 | 'description' => __( 'The number of courses to output for the my courses page.', 'woothemes-sensei' ), |
||
| 245 | 'type' => 'range', |
||
| 246 | 'default' => '0', |
||
| 247 | 'section' => 'course-settings', |
||
| 248 | 'required' => 0, |
||
| 249 | 'options' => $posts_per_page_array |
||
| 250 | ); |
||
| 251 | |||
| 252 | $fields['course_archive_image_enable'] = array( |
||
| 253 | 'name' => __( 'Course Archive Image', 'woothemes-sensei' ), |
||
| 254 | 'description' => __( 'Output the Course Image on the Course Archive Page.', 'woothemes-sensei' ), |
||
| 255 | 'type' => 'checkbox', |
||
| 256 | 'default' => true, |
||
| 257 | 'section' => 'course-settings' |
||
| 258 | ); |
||
| 259 | |||
| 260 | $fields['course_archive_image_width'] = array( |
||
| 261 | 'name' => __( 'Image Width - Archive', 'woothemes-sensei' ), |
||
| 262 | 'description' => __( 'The width in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
||
| 263 | 'type' => 'text', |
||
| 264 | 'default' => '100', |
||
| 265 | 'section' => 'course-settings', |
||
| 266 | 'required' => 0 |
||
| 267 | ); |
||
| 268 | |||
| 269 | $fields['course_archive_image_height'] = array( |
||
| 270 | 'name' => __( 'Image Height - Archive', 'woothemes-sensei' ), |
||
| 271 | 'description' => __( 'The height in pixels of the featured image for the Course Archive page.', 'woothemes-sensei' ), |
||
| 272 | 'type' => 'text', |
||
| 273 | 'default' => '100', |
||
| 274 | 'section' => 'course-settings', |
||
| 275 | 'required' => 0 |
||
| 276 | ); |
||
| 277 | |||
| 278 | $fields['course_archive_image_hard_crop'] = array( |
||
| 279 | 'name' => __( 'Image Hard Crop - Archive', 'woothemes-sensei' ), |
||
| 280 | '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>' ), |
||
| 281 | 'type' => 'checkbox', |
||
| 282 | 'default' => false, |
||
| 283 | 'section' => 'course-settings' |
||
| 284 | ); |
||
| 285 | |||
| 286 | $fields['course_single_image_enable'] = array( |
||
| 287 | 'name' => __( 'Single Course Image', 'woothemes-sensei' ), |
||
| 288 | 'description' => __( 'Output the Course Image on the Single Course Page.', 'woothemes-sensei' ), |
||
| 289 | 'type' => 'checkbox', |
||
| 290 | 'default' => false, |
||
| 291 | 'section' => 'course-settings' |
||
| 292 | ); |
||
| 293 | |||
| 294 | $fields['course_single_image_width'] = array( |
||
| 295 | 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
||
| 296 | 'description' => __( 'The width in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
||
| 297 | 'type' => 'text', |
||
| 298 | 'default' => '100', |
||
| 299 | 'section' => 'course-settings', |
||
| 300 | 'required' => 0 |
||
| 301 | ); |
||
| 302 | |||
| 303 | $fields['course_single_image_height'] = array( |
||
| 304 | 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
||
| 305 | 'description' => __( 'The height in pixels of the featured image for the Course single post page.', 'woothemes-sensei' ), |
||
| 306 | 'type' => 'text', |
||
| 307 | 'default' => '100', |
||
| 308 | 'section' => 'course-settings', |
||
| 309 | 'required' => 0 |
||
| 310 | ); |
||
| 311 | |||
| 312 | $fields['course_single_image_hard_crop'] = array( |
||
| 313 | 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
||
| 314 | '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>' ), |
||
| 315 | 'type' => 'checkbox', |
||
| 316 | 'default' => false, |
||
| 317 | 'section' => 'course-settings' |
||
| 318 | ); |
||
| 319 | |||
| 320 | $fields['course_single_content_display'] = array( |
||
| 321 | 'name' => __( 'Single Course page displays:', 'woothemes-sensei' ), |
||
| 322 | 'description' => __( 'Determines what content to display on the single course page.', 'woothemes-sensei' ), |
||
| 323 | 'type' => 'select', |
||
| 324 | 'default' => 'excerpt', |
||
| 325 | 'section' => 'course-settings', |
||
| 326 | 'required' => 0, |
||
| 327 | 'options' => $course_display_settings |
||
| 328 | ); |
||
| 329 | |||
| 330 | $fields['course_archive_featured_enable'] = array( |
||
| 331 | 'name' => __( 'Featured Courses Panel', 'woothemes-sensei' ), |
||
| 332 | 'description' => __( 'Output the Featured Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
||
| 333 | 'type' => 'checkbox', |
||
| 334 | 'default' => true, |
||
| 335 | 'section' => 'course-settings' |
||
| 336 | ); |
||
| 337 | |||
| 338 | $fields['course_archive_more_link_text'] = array( |
||
| 339 | 'name' => __( 'More link text', 'woothemes-sensei' ), |
||
| 340 | 'description' => __( 'The text that will be displayed on the Course Archive for the more courses link.', 'woothemes-sensei' ), |
||
| 341 | 'type' => 'text', |
||
| 342 | 'default' => __ ( 'More', 'woothemes-sensei' ), |
||
| 343 | 'section' => 'course-settings', |
||
| 344 | 'required' => 0 |
||
| 345 | ); |
||
| 346 | |||
| 347 | // Lesson Settings |
||
| 348 | |||
| 349 | $fields['lesson_comments'] = array( |
||
| 350 | 'name' => __( 'Allow Comments for Lessons', 'woothemes-sensei' ), |
||
| 351 | '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' ), |
||
| 352 | 'type' => 'checkbox', |
||
| 353 | 'default' => true, |
||
| 354 | 'section' => 'lesson-settings' |
||
| 355 | ); |
||
| 356 | |||
| 357 | $fields['lesson_author'] = array( |
||
| 358 | 'name' => __( 'Display Lesson Author', 'woothemes-sensei' ), |
||
| 359 | 'description' => __( 'Output the Lesson Author on Course single page & Lesson archive page.', 'woothemes-sensei' ), |
||
| 360 | 'type' => 'checkbox', |
||
| 361 | 'default' => true, |
||
| 362 | 'section' => 'lesson-settings' |
||
| 363 | ); |
||
| 364 | |||
| 365 | $fields['course_lesson_image_enable'] = array( |
||
| 366 | 'name' => __( 'Course Lesson Images', 'woothemes-sensei' ), |
||
| 367 | 'description' => __( 'Output the Lesson Image on the Single Course Page.', 'woothemes-sensei' ), |
||
| 368 | 'type' => 'checkbox', |
||
| 369 | 'default' => false, |
||
| 370 | 'section' => 'lesson-settings' |
||
| 371 | ); |
||
| 372 | |||
| 373 | $fields['lesson_archive_image_width'] = array( |
||
| 374 | 'name' => __( 'Image Width - Course Lessons', 'woothemes-sensei' ), |
||
| 375 | 'description' => __( 'The width in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
||
| 376 | 'type' => 'text', |
||
| 377 | 'default' => '100', |
||
| 378 | 'section' => 'lesson-settings', |
||
| 379 | 'required' => 0 |
||
| 380 | ); |
||
| 381 | |||
| 382 | $fields['lesson_archive_image_height'] = array( |
||
| 383 | 'name' => __( 'Image Height - Course Lessons', 'woothemes-sensei' ), |
||
| 384 | 'description' => __( 'The height in pixels of the featured image for the Lessons on the Course Single page.', 'woothemes-sensei' ), |
||
| 385 | 'type' => 'text', |
||
| 386 | 'default' => '100', |
||
| 387 | 'section' => 'lesson-settings', |
||
| 388 | 'required' => 0 |
||
| 389 | ); |
||
| 390 | |||
| 391 | $fields['lesson_archive_image_hard_crop'] = array( |
||
| 392 | 'name' => __( 'Image Hard Crop - Course Lessons', 'woothemes-sensei' ), |
||
| 393 | '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>' ), |
||
| 394 | 'type' => 'checkbox', |
||
| 395 | 'default' => false, |
||
| 396 | 'section' => 'lesson-settings' |
||
| 397 | ); |
||
| 398 | |||
| 399 | $fields['lesson_single_image_enable'] = array( |
||
| 400 | 'name' => __( 'Single Lesson Images', 'woothemes-sensei' ), |
||
| 401 | 'description' => __( 'Output the Lesson Image on the Single Lesson Page.', 'woothemes-sensei' ), |
||
| 402 | 'type' => 'checkbox', |
||
| 403 | 'default' => false, |
||
| 404 | 'section' => 'lesson-settings' |
||
| 405 | ); |
||
| 406 | |||
| 407 | $fields['lesson_single_image_width'] = array( |
||
| 408 | 'name' => __( 'Image Width - Single', 'woothemes-sensei' ), |
||
| 409 | 'description' => __( 'The width in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
||
| 410 | 'type' => 'text', |
||
| 411 | 'default' => '100', |
||
| 412 | 'section' => 'lesson-settings', |
||
| 413 | 'required' => 0 |
||
| 414 | ); |
||
| 415 | |||
| 416 | $fields['lesson_single_image_height'] = array( |
||
| 417 | 'name' => __( 'Image Height - Single', 'woothemes-sensei' ), |
||
| 418 | 'description' => __( 'The height in pixels of the featured image for the Lessons single post page.', 'woothemes-sensei' ), |
||
| 419 | 'type' => 'text', |
||
| 420 | 'default' => '100', |
||
| 421 | 'section' => 'lesson-settings', |
||
| 422 | 'required' => 0 |
||
| 423 | ); |
||
| 424 | |||
| 425 | $fields['lesson_single_image_hard_crop'] = array( |
||
| 426 | 'name' => __( 'Image Hard Crop - Single', 'woothemes-sensei' ), |
||
| 427 | '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>' ), |
||
| 428 | 'type' => 'checkbox', |
||
| 429 | 'default' => false, |
||
| 430 | 'section' => 'lesson-settings' |
||
| 431 | ); |
||
| 432 | |||
| 433 | // Learner Profile settings |
||
| 434 | |||
| 435 | $profile_url_base = apply_filters( 'sensei_learner_profiles_url_base', __( 'learner', 'woothemes-sensei') ); |
||
| 436 | $profile_url_example = trailingslashit( get_site_url() ) . $profile_url_base . '/%username%'; |
||
| 437 | |||
| 438 | $fields['learner_profile_enable'] = array( |
||
| 439 | 'name' => __( 'Public learner profiles', 'woothemes-sensei' ), |
||
| 440 | 'description' => sprintf( __( 'Enable public learner profiles that will be accessible to everyone. Profile URL format: %s', 'woothemes-sensei' ), $profile_url_example ), |
||
| 441 | 'type' => 'checkbox', |
||
| 442 | 'default' => true, |
||
| 443 | 'section' => 'learner-profile-settings' |
||
| 444 | ); |
||
| 445 | |||
| 446 | $fields['learner_profile_show_courses'] = array( |
||
| 447 | 'name' => __( 'Show learner\'s courses', 'woothemes-sensei' ), |
||
| 448 | 'description' => __( 'Display the learner\'s active and completed courses on their profile.', 'woothemes-sensei' ), |
||
| 449 | 'type' => 'checkbox', |
||
| 450 | 'default' => true, |
||
| 451 | 'section' => 'learner-profile-settings' |
||
| 452 | ); |
||
| 453 | |||
| 454 | // Email notifications |
||
| 455 | |||
| 456 | $learner_email_options = array( |
||
| 457 | 'learner-graded-quiz' => __( 'Their quiz is graded (auto and manual grading)', 'woothemes-sensei' ), |
||
| 458 | 'learner-completed-course' => __( 'They complete a course', 'woothemes-sensei' ), |
||
| 459 | ); |
||
| 460 | |||
| 461 | $teacher_email_options = array( |
||
| 462 | 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
||
| 463 | 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
||
| 464 | 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
||
| 465 | 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
||
| 466 | 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
||
| 467 | ); |
||
| 468 | |||
| 469 | $global_email_options = array( |
||
| 470 | 'new-message-reply' => __( 'They receive a reply to their private message', 'woothemes-sensei' ), |
||
| 471 | ); |
||
| 472 | |||
| 473 | $fields['email_learners'] = array( |
||
| 474 | 'name' => __( 'Emails Sent to Learners', 'woothemes-sensei' ), |
||
| 475 | 'description' => __( 'Select the notifications that will be sent to learners.', 'woothemes-sensei' ), |
||
| 476 | 'type' => 'multicheck', |
||
| 477 | 'options' => $learner_email_options, |
||
| 478 | 'defaults' => array( 'learner-graded-quiz', 'learner-completed-course' ), |
||
| 479 | 'section' => 'email-notification-settings' |
||
| 480 | ); |
||
| 481 | |||
| 482 | $fields['email_teachers'] = array( |
||
| 483 | 'name' => __( 'Emails Sent to Teachers', 'woothemes-sensei' ), |
||
| 484 | 'description' => __( 'Select the notifications that will be sent to teachers.', 'woothemes-sensei' ), |
||
| 485 | 'type' => 'multicheck', |
||
| 486 | 'options' => $teacher_email_options, |
||
| 487 | 'defaults' => array( 'teacher-completed-course', 'teacher-started-course', 'teacher-quiz-submitted', 'teacher-new-message' ), |
||
| 488 | 'section' => 'email-notification-settings' |
||
| 489 | ); |
||
| 490 | |||
| 491 | $fields['email_global'] = array( |
||
| 492 | 'name' => __( 'Emails Sent to All Users', 'woothemes-sensei' ), |
||
| 493 | 'description' => __( 'Select the notifications that will be sent to all users.', 'woothemes-sensei' ), |
||
| 494 | 'type' => 'multicheck', |
||
| 495 | 'options' => $global_email_options, |
||
| 496 | 'defaults' => array( 'new-message-reply' ), |
||
| 497 | 'section' => 'email-notification-settings' |
||
| 498 | ); |
||
| 499 | |||
| 500 | $fields['email_from_name'] = array( |
||
| 501 | 'name' => __( '"From" Name', 'woothemes-sensei' ), |
||
| 502 | 'description' => __( 'The name from which all emails will be sent.', 'woothemes-sensei' ), |
||
| 503 | 'type' => 'text', |
||
| 504 | 'default' => get_bloginfo( 'name' ), |
||
| 505 | 'section' => 'email-notification-settings', |
||
| 506 | 'required' => 1 |
||
| 507 | ); |
||
| 508 | |||
| 509 | $fields['email_from_address'] = array( |
||
| 510 | 'name' => __( '"From" Address', 'woothemes-sensei' ), |
||
| 511 | 'description' => __( 'The address from which all emails will be sent.', 'woothemes-sensei' ), |
||
| 512 | 'type' => 'text', |
||
| 513 | 'default' => get_bloginfo( 'admin_email' ), |
||
| 514 | 'section' => 'email-notification-settings', |
||
| 515 | 'required' => 1 |
||
| 516 | ); |
||
| 517 | |||
| 518 | $fields['email_header_image'] = array( |
||
| 519 | 'name' => __( 'Header Image', 'woothemes-sensei' ), |
||
| 520 | '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>' ), |
||
| 521 | 'type' => 'text', |
||
| 522 | 'default' => '', |
||
| 523 | 'section' => 'email-notification-settings', |
||
| 524 | 'required' => 0 |
||
| 525 | ); |
||
| 526 | |||
| 527 | $fields['email_footer_text'] = array( |
||
| 528 | 'name' => __( 'Email Footer Text', 'woothemes-sensei' ), |
||
| 529 | 'description' => __( 'The text to appear in the footer of Sensei emails.', 'woothemes-sensei' ), |
||
| 530 | 'type' => 'textarea', |
||
| 531 | 'default' => sprintf( __( '%1$s - Powered by Sensei', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), |
||
| 532 | 'section' => 'email-notification-settings', |
||
| 533 | 'required' => 0 |
||
| 534 | ); |
||
| 535 | |||
| 536 | $fields['email_base_color'] = array( |
||
| 537 | 'name' => __( 'Base Colour', 'woothemes-sensei' ), |
||
| 538 | 'description' => sprintf( __( 'The base colour for Sensei email templates. Default %1$s#557da1%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
||
| 539 | 'type' => 'color', |
||
| 540 | 'default' => '#557da1', |
||
| 541 | 'section' => 'email-notification-settings', |
||
| 542 | 'required' => 1 |
||
| 543 | ); |
||
| 544 | |||
| 545 | $fields['email_background_color'] = array( |
||
| 546 | 'name' => __( 'Background Colour', 'woothemes-sensei' ), |
||
| 547 | 'description' => sprintf( __( 'The background colour for Sensei email templates. Default %1$s#f5f5f5%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
||
| 548 | 'type' => 'color', |
||
| 549 | 'default' => '#f5f5f5', |
||
| 550 | 'section' => 'email-notification-settings', |
||
| 551 | 'required' => 1 |
||
| 552 | ); |
||
| 553 | |||
| 554 | $fields['email_body_background_color'] = array( |
||
| 555 | 'name' => __( 'Body Background Colour', 'woothemes-sensei' ), |
||
| 556 | 'description' => sprintf( __( 'The main body background colour for Sensei email templates. Default %1$s#fdfdfd%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
||
| 557 | 'type' => 'color', |
||
| 558 | 'default' => '#fdfdfd', |
||
| 559 | 'section' => 'email-notification-settings', |
||
| 560 | 'required' => 1 |
||
| 561 | ); |
||
| 562 | |||
| 563 | $fields['email_text_color'] = array( |
||
| 564 | 'name' => __( 'Body Text Colour', 'woothemes-sensei' ), |
||
| 565 | 'description' => sprintf( __( 'The main body text colour for Sensei email templates. Default %1$s#505050%2$s.', 'woothemes-sensei' ), '<code>', '</code>' ), |
||
| 566 | 'type' => 'color', |
||
| 567 | 'default' => '#505050', |
||
| 568 | 'section' => 'email-notification-settings', |
||
| 569 | 'required' => 1 |
||
| 570 | ); |
||
| 571 | |||
| 572 | if ( Sensei_WC::is_woocommerce_present() ) { |
||
| 573 | // WooCommerce Settings |
||
| 574 | $fields['woocommerce_enabled'] = array( |
||
| 575 | 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
||
| 576 | 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
||
| 577 | 'type' => 'checkbox', |
||
| 578 | 'default' => true, |
||
| 579 | 'section' => 'woocommerce-settings' |
||
| 580 | ); |
||
| 581 | |||
| 582 | $fields['course_archive_free_enable'] = array( |
||
| 583 | 'name' => __( 'Free Courses Panel', 'woothemes-sensei' ), |
||
| 584 | 'description' => __( 'Output the Free Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
||
| 585 | 'type' => 'checkbox', |
||
| 586 | 'default' => true, |
||
| 587 | 'section' => 'woocommerce-settings' |
||
| 588 | ); |
||
| 589 | |||
| 590 | $fields['course_archive_paid_enable'] = array( |
||
| 591 | 'name' => __( 'Paid Courses Panel', 'woothemes-sensei' ), |
||
| 592 | 'description' => __( 'Output the Paid Courses Panel on the Course Archive Page.', 'woothemes-sensei' ), |
||
| 593 | 'type' => 'checkbox', |
||
| 594 | 'default' => true, |
||
| 595 | 'section' => 'woocommerce-settings' |
||
| 596 | ); |
||
| 597 | |||
| 598 | } // End If Statement |
||
| 599 | |||
| 600 | if ( 'en_US' !== get_locale() ) { |
||
| 601 | $fields['install_language_pack'] = array( |
||
| 602 | 'name' => __( 'Install Language Pack', 'woothemes-sensei' ), |
||
| 603 | 'description' => __( 'Use this action to install or re-install translation for your language if available.', 'woothemes-sensei' ), |
||
| 604 | 'type' => 'button', |
||
| 605 | 'section' => 'language-settings', |
||
| 606 | 'target' => Sensei_Language_Pack_Manager::get_install_uri(), |
||
| 607 | 'label' => __( 'Install', 'woothemes-sensei' ) |
||
| 608 | ); |
||
| 609 | } |
||
| 610 | |||
| 611 | $this->fields = apply_filters( 'sensei_settings_fields', $fields ); |
||
| 612 | |||
| 613 | } // End init_fields() |
||
| 614 | |||
| 615 | /** |
||
| 616 | * Get options for the duration fields. |
||
| 617 | * @since 1.0.0 |
||
| 618 | * @param $include_milliseconds (default: true) Whether or not to include milliseconds between 0 and 1. |
||
| 619 | * @return array Options between 0.1 and 10 seconds. |
||
| 620 | */ |
||
| 621 | private function get_duration_options ( $include_milliseconds = true ) { |
||
| 622 | $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' ); |
||
| 623 | $options = array(); |
||
| 624 | |||
| 625 | if ( true == (bool)$include_milliseconds ) { |
||
| 626 | $milliseconds = array( '0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9' ); |
||
| 627 | foreach ( $milliseconds as $k => $v ) { |
||
| 628 | $options[$v] = $v; |
||
| 629 | } |
||
| 630 | } else { |
||
| 631 | $options['0.5'] = '0.5'; |
||
| 632 | } |
||
| 633 | |||
| 634 | foreach ( $numbers as $k => $v ) { |
||
| 635 | $options[$v] = $v; |
||
| 636 | } |
||
| 637 | |||
| 638 | return $options; |
||
| 639 | } // End get_duration_options() |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Return an array of pages. |
||
| 643 | * @access private |
||
| 644 | * @since 1.0.0 |
||
| 645 | * @return array |
||
| 646 | */ |
||
| 647 | private function pages_array() { |
||
| 648 | // REFACTOR - Transform this into a field type instead. |
||
| 649 | // Setup an array of portfolio gallery terms for a dropdown. |
||
| 650 | $args = array( 'echo' => 0, 'hierarchical' => 1, 'sort_column' => 'post_title', 'sort_order' => 'ASC' ); |
||
| 651 | $pages_dropdown = wp_dropdown_pages( $args ); |
||
| 652 | $page_items = array(); |
||
| 653 | |||
| 654 | // Quick string hack to make sure we get the pages with the indents. |
||
| 655 | $pages_dropdown = str_replace( "<select class='' name='page_id' id='page_id'>", '', $pages_dropdown ); |
||
| 656 | $pages_dropdown = str_replace( '</select>', '', $pages_dropdown ); |
||
| 657 | $pages_split = explode( '</option>', $pages_dropdown ); |
||
| 658 | |||
| 659 | $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
||
| 660 | |||
| 661 | foreach ( $pages_split as $k => $v ) { |
||
| 662 | $id = ''; |
||
|
0 ignored issues
–
show
|
|||
| 663 | // Get the ID value. |
||
| 664 | preg_match( '/value="(.*?)"/i', $v, $matches ); |
||
| 665 | |||
| 666 | if ( isset( $matches[1] ) ) { |
||
| 667 | $id = $matches[1]; |
||
| 668 | $page_items[$id] = trim( strip_tags( $v ) ); |
||
| 669 | } // End If Statement |
||
| 670 | } // End For Loop |
||
| 671 | |||
| 672 | $pages_array = $page_items; |
||
| 673 | |||
| 674 | return $pages_array; |
||
| 675 | } // End pages_array() |
||
| 676 | |||
| 677 | /** |
||
| 678 | * Language packs notices. |
||
| 679 | * |
||
| 680 | * @since 1.9.0 |
||
| 681 | */ |
||
| 682 | public function language_pack_notices() { |
||
| 683 | Sensei_Language_Pack_Manager::messages(); |
||
| 684 | } |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Flush the rewrite rules after the settings have been updated. |
||
| 688 | * This is to ensure that the |
||
| 689 | * |
||
| 690 | * @since 1.9.0 |
||
| 691 | */ |
||
| 692 | public static function flush_rewrite_rules(){ |
||
| 693 | |||
| 694 | if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
||
| 695 | && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
||
| 696 | |||
| 697 | Sensei()->initiate_rewrite_rules_flush(); |
||
| 698 | |||
| 699 | } |
||
| 700 | |||
| 701 | }//end flush_cache |
||
| 702 | } // End Class |
||
| 703 | |||
| 704 | /** |
||
| 705 | * Class WooThemes_Sensei_Settings |
||
| 706 | * @ignore only for backward compatibility |
||
| 707 | * @since 1.9.0 |
||
| 708 | */ |
||
| 709 | class WooThemes_Sensei_Settings extends Sensei_Settings{} |
||
| 710 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.