From dfa38ea40f3ea565a3599e29c73b365ff2681198 Mon Sep 17 00:00:00 2001 From: shewa12 Date: Tue, 5 Sep 2023 22:03:15 +0600 Subject: [PATCH] classes/Options_V2: Update the permalink when changing the course slug Also, fold a variable that was only used once. Co-authored-by: Bernhard Kaindl --- classes/Options_V2.php | 9 +++++++++ classes/Post_types.php | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/classes/Options_V2.php b/classes/Options_V2.php index f1a32532a3..e2b53d84b4 100644 --- a/classes/Options_V2.php +++ b/classes/Options_V2.php @@ -635,6 +635,15 @@ public function get_setting_fields() { 'slug' => 'course', 'block_type' => 'uniform', 'fields' => array( + array( + 'key' => 'course_permalink_base', + 'type' => 'text', + 'label' => __( 'Course Slug', 'tutor' ), + 'placeholder' => __( 'Course Slug', 'tutor' ), + 'label_title' => '', + 'default' => tutor()->course_post_type, + 'desc' => __( 'Update the permalink when changing the course slug', 'tutor' ), + ), array( 'key' => 'student_must_login_to_view_course', 'type' => 'toggle_switch', diff --git a/classes/Post_types.php b/classes/Post_types.php index 707a61c574..b2b2904a51 100644 --- a/classes/Post_types.php +++ b/classes/Post_types.php @@ -84,8 +84,6 @@ public function __construct() { * @return void */ public function register_course_post_types() { - $course_post_type = $this->course_post_type; - $labels = array( 'name' => _x( 'Courses', 'post type general name', 'tutor' ), 'singular_name' => _x( 'Course', 'post type singular name', 'tutor' ), @@ -112,7 +110,7 @@ public function register_course_post_types() { // 'show_in_menu' => 'tutor', 'query_var' => true, 'rewrite' => array( - 'slug' => tutor_utils()->get_option( 'course_permalink_base', $course_post_type ), + 'slug' => tutor_utils()->get_option( 'course_permalink_base', $this->course_post_type ), 'with_front' => true, ), 'menu_icon' => 'dashicons-book-alt',