Skip to content

Commit

Permalink
Merge pull request #506 from themeum/harun
Browse files Browse the repository at this point in the history
Hook added to extend tutor
  • Loading branch information
sifat009 authored Jul 18, 2023
2 parents 047978e + 76e8066 commit 4d2003e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
16 changes: 4 additions & 12 deletions classes/Options_V2.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public function reset_settings_data() {
wp_send_json_error( tutor_utils()->error_message() );
}

$reset_fields = $return_fields = $return_fields_group = array();
$reset_fields = $return_fields = $return_fields_group = array(); //phpcs:ignore
$reset_page = Input::post( 'reset_page' );
$setting_data = $this->get_setting_fields()['option_fields'][ $reset_page ]['blocks'];

Expand Down Expand Up @@ -400,7 +400,7 @@ public function tutor_option_save() {

do_action( 'tutor_option_save_before' );

$option = (array) tutor_utils()->array_get( 'tutor_option', $_POST, array() );
$option = (array) tutor_utils()->array_get( 'tutor_option', $_POST, array() ); //phpcs:ignore

$option = tutor_utils()->sanitize_recursively( $option, array( 'email_footer_text' ) );

Expand Down Expand Up @@ -482,7 +482,7 @@ public function tutor_option_default_save() {
* @return void
*/
public function load_settings_page() {
extract( $this->get_setting_fields() );
extract( $this->get_setting_fields() ); //phpcs:ignore

if ( ! $template_path ) {
$template_path = tutor()->path . '/views/options/settings.php';
Expand All @@ -508,7 +508,7 @@ public function get_setting_fields() {
$lesson_key = $this->get( 'lesson_permalink_base', 'lessons' );
$course_base = tutor_utils()->get_option( 'course_permalink_base', tutor()->course_post_type );
$course_url = site_url() . '/<code>' . $course_base . '</code>/sample-course';
$lesson_url = site_url() . '/' . $course_base . '/' . 'sample-course/<code>' . $lesson_key . '</code>/sample-lesson/';
$lesson_url = site_url() . '/' . $course_base . '/sample-course/<code>' . $lesson_key . '</code>/sample-lesson/';
$student_url = tutor_utils()->profile_url( 0, false );

$methods_array = array();
Expand Down Expand Up @@ -1531,14 +1531,6 @@ public function get_setting_fields() {
'options' => $pages,
'desc' => __( 'Choose the page for student registration.', 'tutor' ),
),
// TODO
// array(
// 'key' => 'course_permalink_base',
// 'type' => 'text',
// 'label' => __('Course Permalink Base', 'tutor'),
// 'default' => tutor()->course_post_type,
// 'desc' => $course_url,
// ),
array(
'key' => 'lesson_permalink_base',
'type' => 'text',
Expand Down
4 changes: 1 addition & 3 deletions classes/Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,9 @@ public function instructor_registration_form() {
* @return string
*/
public function tutor_course( $atts ) {
$course_post_type = tutor()->course_post_type;

$a = shortcode_atts(
array(
'post_type' => $course_post_type,
'post_type' => apply_filters( 'tutor_course_archive_post_types', array( tutor()->course_post_type ) ),
'post_status' => 'publish',

'id' => '',
Expand Down
9 changes: 7 additions & 2 deletions classes/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ public function __construct() {
public function load_course_archive_template( $template ) {
global $wp_query;

$post_type = get_query_var( 'post_type' );
$post_type = get_query_var( 'post_type' );
if ( ! is_array( $post_type ) ) {
$post_type = array( $post_type );
}

$course_category = get_query_var( 'course-category' );

if ( ( $post_type === $this->course_post_type || ! empty( $course_category ) ) && $wp_query->is_archive ) {
if ( ( in_array( $this->course_post_type, $post_type, true ) || ! empty( $course_category ) ) && $wp_query->is_archive ) {
$template = tutor_get_template( 'archive-course' );
return $template;
}
Expand Down Expand Up @@ -118,6 +122,7 @@ public function limit_course_query_archive( $query ) {
$course_category = get_query_var( 'course-category' );
if ( ( $post_type === $this->course_post_type || ! empty( $course_category ) ) ) {
$query->set( 'posts_per_page', $courses_per_page );
$query->set( 'post_type', apply_filters( 'tutor_course_archive_post_types', array( $this->course_post_type ) ) );

$course_filter = 'newest_first';
if ( ! empty( Input::get( 'tutor_course_filter', '' ) ) ) {
Expand Down

0 comments on commit 4d2003e

Please sign in to comment.