PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.2
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / settings / class-lp-settings-courses.php

class-lp-settings-courses.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9.2, at inc/settings/class-lp-settings-courses.php

85 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use LP\Helpers\Config;
4
5 /**
6 * Class LP_Settings_Courses
7 *
8 * @author ThimPress <email@email.com>
9 */
10 class LP_Settings_Courses extends LP_Abstract_Settings_Page {
11 /**
12 * LP_Settings_Courses constructor.
13 */
14 public function __construct() {
15 $this->id = 'courses';
16 $this->text = esc_html__( 'Courses', 'learnpress' );
17
18 parent::__construct();
19 }
20
21 public function save() {
22 $course_permalink = LP_Helper::sanitize_params_submitted( $_POST['learn_press_course_base'] ?? '' );
23
24 if ( ! $course_permalink ) {
25 return;
26 }
27
28 if ( $course_permalink == 'custom' ) {
29 $course_permalink = trim( $_POST['course_permalink_structure'], '/' );
30
31 if ( '%course_category%' == $course_permalink ) {
32 $course_permalink = _x( 'courses', 'slug', 'learnpress' ) . '/' . $course_permalink;
33 }
34
35 $course_permalink = '/' . $course_permalink;
36 update_option( 'learn_press_course_base_type', 'custom' );
37
38 } else {
39 delete_option( 'learn_press_course_base_type' );
40 }
41
42 $course_base = untrailingslashit( $course_permalink );
43
44 update_option( 'learn_press_course_base', $course_base );
45 $courses_page_id = learn_press_get_page_id( 'courses' );
46 $courses_permalink = ( $courses_page_id > 0 && get_post( $courses_page_id ) ) ? get_page_uri( $courses_page_id ) : _x( 'courses', 'default-slug', 'learnpress' );
47
48 if ( $courses_page_id && trim( $course_base, '/' ) === $courses_permalink ) {
49 update_option( 'learn_press_use_verbose_page_rules', 'yes' );
50 } else {
51 delete_option( 'learn_press_use_verbose_page_rules' );
52 }
53 }
54
55 /**
56 * Get config settings courses.
57 *
58 * @param string $section
59 * @param string $tab
60 *
61 * @return array
62 */
63 public function get_settings( $section = null, $tab = null ): array {
64 return Config::instance()->get( 'course', 'settings' );
65 }
66
67 /**
68 * Get option enable load courses with ajax.
69 *
70 * @return bool
71 */
72 public static function is_ajax_load_courses(): bool {
73 return LP_Settings::get_option( 'courses_load_ajax', 'yes' ) === 'yes';
74 }
75
76 /**
77 * Get option enable courses archive ajax.
78 *
79 * @return bool
80 */
81 public static function is_no_load_ajax_first_courses(): bool {
82 return self::is_ajax_load_courses() && LP_Settings::get_option( 'courses_first_no_ajax', 'no' ) === 'yes';
83 }
84 }
85