Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

169 #16

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

169 #16

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
85 changes: 58 additions & 27 deletions templates/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
/**
* Template for displaying frontend dashboard
*
* @author Themeum
* @package Tutor\Templates
* @author Themeum <[email protected]>
* @link https://themeum.com
* @package TutorLMS/Templates
* @since 1.0.0
* @version 1.4.3
* @since 1.4.3
*/

$is_by_short_code = isset( $is_shortcode ) && $is_shortcode === true;
$is_by_short_code = isset( $is_shortcode ) && true === $is_shortcode;
if ( ! $is_by_short_code && ! defined( 'OTLMS_VERSION' ) ) {
tutor_utils()->tutor_custom_header();
}

global $wp_query;

Expand All @@ -28,6 +30,7 @@
$dashboard_page_name = $dashboard_page_slug . '/' . $dashboard_page_name;
}
}
$dashboard_page_name = apply_filters( 'tutor_dashboard_sub_page_template', $dashboard_page_name );

$user_id = get_current_user_id();
$user = get_user_by( 'ID', $user_id );
Expand All @@ -42,19 +45,19 @@
// Footer links
$footer_links = array(
array(
'title' => $is_instructor ? __( 'My Courses', 'oxygen-tutor-lms' ) : __( 'Dashboard', 'oxygen-tutor-lms' ),
'title' => $is_instructor ? __( 'My Courses', 'tutor' ) : __( 'Dashboard', 'tutor' ),
'url' => $footer_url_1,
'is_active' => $footer_url_1 == $current_url,
'icon_class' => 'ttr tutor-icon-dashboard',
),
array(
'title' => $is_instructor ? __( 'Q&A', 'oxygen-tutor-lms' ) : __( 'Quiz Attempts', 'oxygen-tutor-lms' ),
'title' => $is_instructor ? __( 'Q&A', 'tutor' ) : __( 'Quiz Attempts', 'tutor' ),
'url' => $footer_url_2,
'is_active' => $footer_url_2 == $current_url,
'icon_class' => $is_instructor ? 'ttr tutor-icon-question' : 'ttr tutor-icon-quiz-attempt',
),
array(
'title' => __( 'Menu', 'oxygen-tutor-lms' ),
'title' => __( 'Menu', 'tutor' ),
'url' => '#',
'is_active' => false,
'icon_class' => 'ttr tutor-icon-hamburger-o tutor-dashboard-menu-toggler',
Expand All @@ -69,7 +72,12 @@
<div class="tutor-row tutor-d-flex tutor-justify-between tutor-frontend-dashboard-header">
<div class="tutor-header-left-side tutor-dashboard-header tutor-col-md-6 tutor-d-flex tutor-align-center" style="border: none;">
<div class="tutor-dashboard-header-avatar">
<?php echo tutor_utils()->get_tutor_avatar( $user_id, 'xl' ); ?>
<?php
echo wp_kses(
tutor_utils()->get_tutor_avatar( $user_id, 'xl' ),
tutor_utils()->allowed_avatar_tags()
);
?>
</div>

<div class="tutor-user-info tutor-ml-24">
Expand All @@ -91,7 +99,7 @@
?>
<div class="tutor-dashboard-header-display-name tutor-color-black">
<div class="tutor-fs-5 tutor-dashboard-header-greetings">
<?php _e( 'Hello', 'oxygen-tutor-lms' ); ?>,
<?php esc_html_e( 'Hello', 'tutor' ); ?>,
</div>
<div class="tutor-fs-4 tutor-fw-medium tutor-dashboard-header-username">
<?php echo esc_html( $user->display_name ); ?>
Expand All @@ -106,7 +114,7 @@
<div class="tutor-d-flex tutor-align-center">
<?php
do_action( 'tutor_dashboard/before_header_button' );
$instructor_status = tutor_utils()->instructor_status();
$instructor_status = tutor_utils()->instructor_status( 0, false );
$instructor_status = is_string( $instructor_status ) ? strtolower( $instructor_status ) : '';
$rejected_on = get_user_meta( $user->ID, '_is_tutor_instructor_rejected', true );
$info_style = 'vertical-align: middle; margin-right: 7px;';
Expand All @@ -116,7 +124,7 @@
if ( tutor_utils()->get_option( 'enable_become_instructor_btn' ) ) {
?>
<a id="tutor-become-instructor-button" class="tutor-btn tutor-btn-outline-primary" href="<?php echo esc_url( tutor_utils()->instructor_register_url() ); ?>">
<i class="tutor-icon-user-bold"></i> &nbsp; <?php _e( 'Become an instructor', 'oxygen-tutor-lms' ); ?>
<i class="tutor-icon-user-bold"></i> &nbsp; <?php esc_html_e( 'Become an instructor', 'tutor' ); ?>
</a>
<?php
}
Expand All @@ -137,19 +145,19 @@
<?php else : ?>
<a href="<?php echo esc_url( admin_url( "post-new.php?post_type=$course_type" ) ); ?>" class="tutor-btn tutor-btn-outline-primary">
<i class="tutor-icon-plus-square tutor-my-n4 tutor-mr-8"></i>
<?php esc_html_e( 'Create a New Course', 'oxygen-tutor-lms' ); ?>
<?php esc_html_e( 'Create a New Course', 'tutor' ); ?>
</a>
<?php endif; ?>
<?php
} elseif ( $instructor_status == 'pending' ) {
} elseif ( 'pending' == $instructor_status ) {
$on = get_user_meta( $user->ID, '_is_tutor_instructor', true );
$on = date( 'd F, Y', $on );
echo '<span style="' . $info_message_style . '">
<i class="dashicons dashicons-info tutor-color-warning" style=" ' . $info_style . '"></i>',
__( 'Your Application is pending as of', 'oxygen-tutor-lms' ), ' <b>', $on, '</b>',
echo '<span style="' . esc_attr( $info_message_style ) . '">
<i class="dashicons dashicons-info tutor-color-warning" style=" ' . esc_attr( $info_style ) . '"></i>',
esc_html__( 'Your Application is pending as of', 'tutor' ), ' <b>', esc_html( $on ), '</b>',
'</span>';
} elseif ( $rejected_on || $instructor_status !== 'blocked' ) {
echo $become_button;
echo $become_button; //phpcs:ignore --data escaped above
}
?>
</div>
Expand Down Expand Up @@ -195,17 +203,35 @@
if ( $separator ) {
echo '<li class="tutor-dashboard-menu-divider"></li>';
if ( $menu_title ) {
echo "<li class='tutor-dashboard-menu-divider-header'>{$menu_title}</li>";
?>
<li class='tutor-dashboard-menu-divider-header'>
<?php echo esc_html( $menu_title ); ?>
</li>
<?php
}
} else {
$li_class = "tutor-dashboard-menu-{$dashboard_key}";
if ( $dashboard_key === 'index' ) {
if ( 'index' === $dashboard_key ) {
$dashboard_key = '';
}
$active_class = $dashboard_key == $dashboard_page_slug ? 'active' : '';
$data_no_instant = 'logout' == $dashboard_key ? 'data-no-instant' : '';

echo "<li class='tutor-dashboard-menu-item {$li_class} {$active_class}'><a {$data_no_instant} href='" . $menu_link . "' class='tutor-dashboard-menu-item-link tutor-fs-6 tutor-color-black'>{$menu_icon} <span class='tutor-dashboard-menu-item-text tutor-ml-12'>{$menu_title}</span></a></li>";
$menu_link = apply_filters( 'tutor_dashboard_menu_link', $menu_link, $menu_title );
?>
<li class='tutor-dashboard-menu-item <?php echo esc_attr( $li_class . ' ' . $active_class ); ?>'>
<a <?php echo esc_html( $data_no_instant ); ?> href="<?php echo esc_url( $menu_link ); ?>" class='tutor-dashboard-menu-item-link tutor-fs-6 tutor-color-black'>
<?php
echo wp_kses(
$menu_icon,
tutor_utils()->allowed_icon_tags()
);
?>
<span class='tutor-dashboard-menu-item-text tutor-ml-12'>
<?php echo esc_html( $menu_title ); ?>
</span>
</a>
</li>
<?php
}
}
?>
Expand All @@ -222,17 +248,17 @@
/**
* Load dashboard template part from other location
*
* this filter is basically added for adding templates from respective addons
* This filter is basically added for adding templates from respective addons
*
* @since version 1.9.3
*/
$other_location = '';
$from_other_location = apply_filters( 'load_dashboard_template_part_from_other_location', $other_location );

if ( $from_other_location == '' ) {
if ( '' == $from_other_location ) {
tutor_load_template( 'dashboard.' . $dashboard_page_name );
} else {
// load template from other location full abspath
// Load template from other location full abspath.
include_once $from_other_location;
}

Expand All @@ -250,8 +276,8 @@
<div class="tutor-row">
<?php foreach ( $footer_links as $link ) : ?>
<a class="tutor-col-4 <?php echo $link['is_active'] ? 'active' : ''; ?>" href="<?php echo esc_url( $link['url'] ); ?>">
<i class="<?php echo $link['icon_class']; ?>"></i>
<span><?php echo $link['title']; ?></span>
<i class="<?php echo esc_attr( $link['icon_class'] ); ?>"></i>
<span><?php echo esc_html( $link['title'] ); ?></span>
</a>
<?php endforeach; ?>
</div>
Expand All @@ -260,3 +286,8 @@
</div>

<?php do_action( 'tutor_dashboard/after/wrap' ); ?>

<?php
if ( ! $is_by_short_code && ! defined( 'OTLMS_VERSION' ) ) {
tutor_utils()->tutor_custom_footer();
}
74 changes: 64 additions & 10 deletions templates/login-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,65 @@
/**
* Tutor login form template
*
* @author themeum
* @package Tutor\Templates
* @author Themeum <[email protected]>
* @link https://themeum.com
* @package TutorLMS/Templates
* @since 2.0.1
*/

use TUTOR\Ajax;

$lost_pass = apply_filters( 'tutor_lostpassword_url', wp_lostpassword_url() );
/**
* Get login validation errors & print
*
* @since 2.1.3
*/
$login_errors = get_transient( Ajax::LOGIN_ERRORS_TRANSIENT_KEY ) ? get_transient( Ajax::LOGIN_ERRORS_TRANSIENT_KEY ) : array();
foreach ( $login_errors as $login_error ) {
?>
<div class="tutor-alert tutor-warning tutor-mb-12" style="display:block; grid-gap: 0px 10px;">
<?php
echo wp_kses(
$login_error,
array(
'strong' => true,
'a' => array(
'href' => true,
'class' => true,
'id' => true,
),
'p' => array(
'class' => true,
'id' => true,
),
'div' => array(
'class' => true,
'id' => true,
),
)
);
?>
</div>
<?php
}

do_action( 'tutor_before_login_form' );
?>
<form id="tutor-login-form" method="post">
<?php if ( is_single_course() ) : ?>
<input type="hidden" name="tutor_course_enroll_attempt" value="<?php echo esc_attr( get_the_ID() ); ?>">
<?php endif; ?>

<?php tutor_nonce_field(); ?>
<input type="hidden" name="tutor_action" value="tutor_user_login" />
<input type="hidden" name="redirect_to" value="<?php echo esc_url( apply_filters( 'tutor_after_login_redirect_url', tutor()->current_url ) ); ?>" />

<div class="tutor-mb-20">
<input type="text" class="tutor-form-control" placeholder="<?php esc_html_e( 'Username or Email Address', 'oxygen-tutor-lms' ); ?>" name="log" value="" size="20" />
<input type="text" class="tutor-form-control" placeholder="<?php esc_html_e( 'Username or Email Address', 'tutor' ); ?>" name="log" value="" size="20" required/>
</div>

<div class="tutor-mb-32">
<input type="password" class="tutor-form-control" placeholder="<?php esc_html_e( 'Password', 'oxygen-tutor-lms' ); ?>" name="pwd" value="" size="20" />
<input type="password" class="tutor-form-control" placeholder="<?php esc_html_e( 'Password', 'tutor' ); ?>" name="pwd" value="" size="20" required/>
</div>

<div class="tutor-login-error"></div>
Expand All @@ -36,18 +73,19 @@
<div class="tutor-form-check">
<input id="tutor-login-agmnt-1" type="checkbox" class="tutor-form-check-input tutor-bg-black-40" name="rememberme" value="forever" />
<label for="tutor-login-agmnt-1" class="tutor-fs-7 tutor-color-muted">
<?php esc_html_e( 'Keep me signed in', 'oxygen-tutor-lms' ); ?>
<?php esc_html_e( 'Keep me signed in', 'tutor' ); ?>
</label>
</div>
<a href="<?php echo esc_url( $lost_pass ); ?>" class="tutor-btn tutor-btn-ghost">
<?php esc_html_e( 'Forgot?', 'oxygen-tutor-lms' ); ?>
<?php esc_html_e( 'Forgot?', 'tutor' ); ?>
</a>
</div>

<?php do_action( 'tutor_login_form_end' ); ?>
<button type="submit" class="tutor-btn tutor-btn-primary tutor-btn-block">
<?php esc_html_e( 'Sign In', 'oxygen-tutor-lms' ); ?>
<?php esc_html_e( 'Sign In', 'tutor' ); ?>
</button>

<?php if ( get_option( 'users_can_register', false ) ) : ?>
<?php
$url_arg = array(
Expand All @@ -58,10 +96,26 @@
}
?>
<div class="tutor-text-center tutor-fs-6 tutor-color-secondary tutor-mt-20">
<?php esc_html_e( 'Don\'t have an account?', 'oxygen-tutor-lms' ); ?>&nbsp;
<?php esc_html_e( 'Don\'t have an account?', 'tutor' ); ?>&nbsp;
<a href="<?php echo esc_url( add_query_arg( $url_arg, tutor_utils()->student_register_url() ) ); ?>" class="tutor-btn tutor-btn-link">
<?php esc_html_e( 'Register Now', 'oxygen-tutor-lms' ); ?>
<?php esc_html_e( 'Register Now', 'tutor' ); ?>
</a>
</div>
<?php endif; ?>
<?php do_action( 'tutor_after_sign_in_button' ); ?>
</form>
<?php
do_action( 'tutor_after_login_form' );
if ( ! tutor_utils()->is_tutor_frontend_dashboard() ) : ?>
<script>
document.addEventListener('DOMContentLoaded', function() {
var { __ } = wp.i18n;
var loginModal = document.querySelector('.tutor-modal.tutor-login-modal');
var errors = <?php echo wp_json_encode( $login_errors ); ?>;
if (loginModal && errors.length) {
loginModal.classList.add('tutor-is-active');
}
});
</script>
<?php endif; ?>
<?php delete_transient( Ajax::LOGIN_ERRORS_TRANSIENT_KEY ); ?>
19 changes: 12 additions & 7 deletions templates/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@
/**
* Display single login
*
* @author themeum
* @package Tutor\Templates
* @author Themeum <[email protected]>
* @link https://themeum.com
* @package TutorLMS/Templates
* @since 1.0.0
* @version 1.4.3
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

if ( ! tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ) ) {
// Refer to login oage
header( 'Location: ' . wp_login_url( $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
// Redirect to wp native login page.
header( 'Location: ' . wp_login_url( tutor_utils()->get_current_url() ) );
exit;
}

tutor_utils()->tutor_custom_header();
$login_url = tutor_utils()->get_option( 'enable_tutor_native_login', null, true, true ) ? '' : wp_login_url( tutor()->current_url );
?>

<?php do_action( 'tutor/template/login/before/wrap' ); ?>
<?php
//phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
do_action( 'tutor/template/login/before/wrap' );
?>
<div <?php tutor_post_class( 'tutor-page-wrap' ); ?>>
<div class="tutor-template-segment tutor-login-wrap">

Expand All @@ -38,10 +41,12 @@
false
);
?>
<?php do_action( 'tutor_after_login_form' ); ?>
</div>
<?php do_action( 'tutor_after_login_form_wrapper' ); ?>
</div>
</div>
<?php
//phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
do_action( 'tutor/template/login/after/wrap' );
tutor_utils()->tutor_custom_footer();
?>