Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions classes/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@

return $sanitized_value;

}

Check failure on line 151 in classes/Input.php

View workflow job for this annotation

GitHub Actions / WPCS

Function closing brace must go on the next line following the body; found 1 blank lines before brace

/**
* Dynamically get value
Expand Down Expand Up @@ -304,7 +304,7 @@
*
* @return array
*/
public static function sanitize_array( array $input, array $sanitize_mapping = array(), $allow_iframe = false ):array {

Check failure on line 307 in classes/Input.php

View workflow job for this annotation

GitHub Actions / WPCS

There must be a single space between the colon and type in a return type declaration
$array = array();

if ( $allow_iframe ) {
Expand Down Expand Up @@ -356,4 +356,64 @@
);
return $tags;
}

/**
* This method is used with wp_kses_allowed_html filter
* to allow svg tags.
*
* @since 4.0.0
*
* @param array $allowed_tags allowed HTML tags.
*
* @return array
*/
public static function allow_svg( $allowed_tags ) {
$svg_tags = array(
'svg' => array(
'class' => true,
'aria-hidden' => true,
'aria-label' => true,
'role' => true,
'xmlns' => true,
'width' => true,
'height' => true,
'viewbox' => true,
'fill' => true,
),
'g' => array(
'fill' => true,
),
'path' => array(
'd' => true,
'fill' => true,
'stroke' => true,
'stroke-width' => true,
),
'circle' => array(
'cx' => true,
'cy' => true,
'r' => true,
),
'rect' => array(
'x' => true,
'y' => true,
'width' => true,
'height' => true,
),
'line' => array(
'x1' => true,
'x2' => true,
'y1' => true,
'y2' => true,
),
'polyline' => array(
'points' => true,
),
'polygon' => array(
'points' => true,
),
);

return array_merge( $allowed_tags, $svg_tags );
}
}
18 changes: 7 additions & 11 deletions classes/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ public function load_single_course_template( $template ) {
global $wp_query;
if ( $wp_query->is_single && ! empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] === $this->course_post_type ) {
// Check if the slug contains subpage of learning area.
$learning_area_subpages = self::make_learning_area_sub_page_nav_items();
$subpage = Input::get( 'subpage' );
$subpage_slugs = array_keys( $learning_area_subpages );

if ( in_array( $subpage, $subpage_slugs, true ) ) {
if ( Input::has( 'subpage' ) ) {
$template = tutor_get_template( 'learning-area.index' );
} else {
do_action( 'single_course_template_before_load', get_the_ID() );
Expand Down Expand Up @@ -537,15 +533,15 @@ public static function make_learning_area_sub_page_nav_items( $base_url = '' ):

$menu_items = array(
'qna' => array(
'title' => __( 'Q&A', 'tutor' ),
'icon' => Icon::QA,
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
'title' => __( 'Q&A', 'tutor' ),
'icon' => Icon::QA,
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'qna' ) ),
'template' => tutor_get_template( 'learning-area.subpages.qna' ),
),
'course-info' => array(
'title' => __( 'Course Info', 'tutor' ),
'icon' => Icon::INFO_OCTAGON,
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
'title' => __( 'Course Info', 'tutor' ),
'icon' => Icon::INFO_OCTAGON,
'url' => UrlHelper::add_query_params( $base_url, array( 'subpage' => 'course-info' ) ),
'template' => tutor_get_template( 'learning-area.subpages.course-info' ),
),
);
Expand Down
22 changes: 9 additions & 13 deletions classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5619,11 +5619,8 @@ public function is_learning_area(): bool {
if ( is_single() && ! empty( $current_post_type ) ) {
if ( in_array( $current_post_type, $post_types, true ) ) {
return true;
} elseif ( tutor()->course_post_type === $current_post_type ) {
// Check if the subpage is belongs to learning area.
$learning_subpage = Input::get( 'subpage' );
$allowed_subpages = array_keys( Template::make_learning_area_sub_page_nav_items() );
return in_array( $learning_subpage, $allowed_subpages, true );
} elseif ( tutor()->course_post_type === $current_post_type && Input::has( 'subpage' ) ) {
return true;
}
}

Expand Down Expand Up @@ -8542,7 +8539,7 @@ public function is_tutor_dashboard( $subpage = null ) {
*
* @since 1.9.4
* @since 4.0.0 Subpage check support added.
* Example: assignments/submitted
* Example: assignments/submitted
*
* @param string $subpage subpage.
*
Expand Down Expand Up @@ -9521,7 +9518,7 @@ public function not_found_text(): string {
*/
public function instructor_menus(): array {
$menus = array(
'index' => array(
'index' => array(
'title' => __( 'Home', 'tutor' ),
'icon' => Icon::HOME,
),
Expand Down Expand Up @@ -9558,9 +9555,8 @@ public function instructor_menus(): array {
),
);


if ( $this->should_show_dicussion_menu() ) {
$other_menus['discussions'] = array (
$other_menus['discussions'] = array(
'title' => __( 'Discussions', 'tutor' ),
'auth_cap' => tutor()->instructor_role,
'icon' => Icon::QA,
Expand Down Expand Up @@ -9606,10 +9602,10 @@ public function default_menus(): array {
'title' => __( 'Courses', 'tutor' ),
'icon' => Icon::COURSES,
),
'account' => array(
'label' => __( 'Account', 'tutor' ),
'show_ui' => false
)
'account' => array(
'label' => __( 'Account', 'tutor' ),
'show_ui' => false,
),
);

if ( $this->should_show_dicussion_menu() ) {
Expand Down
8 changes: 3 additions & 5 deletions templates/learning-area/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

wp_head();

$current_user_id = get_current_user_id();
$subpages = Template::make_learning_area_sub_page_nav_items();

// Tutor global variable for using inside learning area.
$current_user_id = get_current_user_id();
$tutor_current_post_type = get_post_type();
$tutor_current_post = get_post();
$tutor_current_content_id = get_the_ID();
Expand All @@ -30,6 +28,7 @@
$tutor_is_public_course = Course_List::is_public( $tutor_course_id );
$tutor_is_course_instructor = tutor_utils()->has_user_course_content_access( $current_user_id, $tutor_course_id );

$subpages = Template::make_learning_area_sub_page_nav_items();
?>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<body class="tutor-learning-area<?php echo esc_attr( is_admin_bar_showing() ? ' tutor-has-admin-bar' : '' ); ?>">
Expand All @@ -42,9 +41,8 @@
<?php
// Get requested page from query string and sanitize.
$subpage = Input::get( 'subpage' );

if ( $subpage ) {
$template = $subpages[ $subpage ]['template'] ?? '';
$template = $subpages[ $subpage ]['template'] ?? '';
if ( file_exists( $template ) ) {
tutor_load_template_from_custom_path( $template );
} else {
Expand Down
Loading
Loading