Commit e9c146c7 authored by everaldomatias's avatar everaldomatias
Browse files

Adds login menu when Tutor plugin is installed

parent 47b9e400
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M23.5769 0.408281C23.7161 0.540801 23.8256 0.701249 23.8984 0.879099C23.9712 1.05695 24.0056 1.24818 23.9993 1.44024V22.5595C24.0042 22.75 23.9692 22.9394 23.8964 23.1155C23.8237 23.2916 23.7148 23.4504 23.5769 23.5819C23.4442 23.7165 23.2857 23.8229 23.1108 23.8947C22.9359 23.9664 22.7484 24.0021 22.5594 23.9995H1.44065C1.25012 24.0048 1.06051 23.9711 0.883413 23.9006C0.706321 23.8302 0.545467 23.7243 0.410689 23.5895C0.27591 23.4547 0.17004 23.2939 0.0995524 23.1168C0.0290645 22.9397 -0.00455978 22.75 0.000735862 22.5595V1.44024C-0.00557729 1.24818 0.0287896 1.05695 0.101582 0.879099C0.174374 0.701249 0.283946 0.540801 0.42311 0.408281C0.556923 0.275831 0.715888 0.1715 0.890641 0.101432C1.06539 0.0313646 1.2524 -0.00302312 1.44065 0.000294874H22.5594C22.7477 -0.00356867 22.9348 0.0305686 23.1097 0.100667C23.2845 0.170766 23.4434 0.275387 23.5769 0.408281ZM19.2572 13.0078C19.521 12.7387 19.6688 12.3768 19.6688 11.9999C19.6688 11.623 19.521 11.2611 19.2572 10.9919C19.1333 10.8566 18.9828 10.7484 18.8152 10.674C18.6475 10.5997 18.4662 10.5608 18.2828 10.5599H13.4399V5.76009C13.4445 5.57039 13.4093 5.38183 13.3365 5.20657C13.2638 5.0313 13.1551 4.87323 13.0175 4.74253C12.7484 4.47869 12.3865 4.33091 12.0096 4.33091C11.6327 4.33091 11.2708 4.47869 11.0017 4.74253C10.8606 4.87152 10.7484 5.02884 10.6723 5.20418C10.5962 5.37953 10.558 5.56896 10.5601 5.76009V10.5599H5.76038C5.57068 10.5553 5.38213 10.5906 5.20687 10.6633C5.03161 10.7361 4.87354 10.8447 4.74285 10.9823C4.47901 11.2515 4.33124 11.6134 4.33124 11.9903C4.33124 12.3672 4.47901 12.7291 4.74285 12.9982C4.87184 13.1393 5.02914 13.2515 5.20449 13.3276C5.37983 13.4037 5.56925 13.442 5.76038 13.4398H10.5601V18.2829C10.5571 18.4688 10.5931 18.6533 10.6659 18.8244C10.7386 18.9956 10.8465 19.1496 10.9825 19.2764C11.2516 19.5403 11.6135 19.688 11.9904 19.688C12.3673 19.688 12.7292 19.5403 12.9983 19.2764C13.1378 19.1513 13.2492 18.9981 13.3253 18.8268C13.4014 18.6556 13.4405 18.4702 13.4399 18.2829V13.4398H18.2828C18.4695 13.4416 18.6544 13.4041 18.8256 13.3296C18.9968 13.2552 19.1503 13.1456 19.2764 13.0078H19.2572Z" fill="white"/>
</svg>
document.addEventListener('DOMContentLoaded', () => {
var menuItems = document.querySelector(".tutor-header-profile-menu-items");
if (null !== menuItems) {
menuItems.addEventListener("click", function () {
menuItems.classList.toggle("active");
});
}
})
\ No newline at end of file
header.header-default {
border-bottom: 2px solid #f8f8f8;
}
.tutor-header-profile-menu-items {
display: flex;
position: relative;
align-items: center;
}
.tutor-header-profile-content {
padding-left: 7px;
.tutor-header-profile-content-text {
font-size: 13px;
line-height: 1.1em;
color: var(--wp--preset--color--high-pure);
}
.tutor-header-profile-submenu {
display: flex;
align-items: center;
justify-content: center;
.tutor-header-profile-name {
line-height: 1.2;
font-weight: 600;
color: var(--wp--preset--color--high-pure);
font-size: 14px;
@media (min-width: 1200px) {
font-size: 16px;
}
}
}
}
.tutor-header-login {
margin-right: 15px;
a {
font-weight: 700;
}
}
.tutor-header-submenu-icon {
font-size: 12px;
color: #212327;
padding: 0 5px;
transition: 0.3s ease;
}
.tutor-header-submenu {
background-color: #f5f7fa;
display: flex;
opacity: 0;
}
.tutor-header-profile-menu-items .tutor-header-submenu {
position: absolute;
z-index: 999;
width: 655px;
top: 70px;
right: 88px;
transition: 0.3s;
height: auto;
visibility: hidden;
}
.tutor-header-profile-menu-items:hover .tutor-header-submenu {
opacity: 1;
visibility: visible;
}
.tutor-submenu-login-section {
background: linear-gradient(318.61deg, #ec653b, #9d1878 96.92%), #fff;
}
.tutor-submenu-login-section,
.tutor-submenu-login-section-instructor {
display: flex;
flex-direction: column;
justify-content: center;
padding: 30px;
width: 33.33%;
}
.tutor-submenu-login-section-instructor {
background-color: var(--wp--preset--color--primary-pure);
}
.tutor-submenu-login-content {
font-size: 24px;
color: #fff;
padding-top: 10px;
padding-bottom: 10px;
p {
color: var(--wp--preset--color--high-pure) !important;
}
}
.tutor-submenu-login-profile {
font-weight: 600;
}
.tutor-submenu-login {
align-items: center;
background-color: rgba(0, 0, 0, 0.2);
border-radius: 50%;
color: #fff !important;
display: flex;
font-size: 16px;
height: 44px;
justify-content: center;
width: 44px;
&:hover {
text-decoration: none;
}
}
.tutor-submenu-links {
width: 33.33%;
position: relative;
padding: 30px 10px;
ul {
display: block !important;
}
}
.navbar-utils .tutor-header-profile-menu-items .tutor-header-profile-photo span.tutor-text-avatar {
display: inline-block;
text-align: center;
line-height: 30px;
height: 30px;
width: 30px;
border-radius: 50%;
}
.tutor-header-submenu .tutor-submenu-links ul li a {
display: block;
font-size: 15px;
font-weight: 400;
color: #212327;
line-height: 1.75em;
padding: 3px 6px;
}
.tutor-header-profile-menu-items ul li a:hover {
color: #456bed;
}
.tutor-header-submenu:before {
content: "";
position: absolute;
top: -20px;
right: 45px;
z-index: 1024;
border-color: rgba(0, 0, 255, 0) rgba(102, 51, 153, 0) #f5f7fa rgba(255, 0, 0, 0);
border-style: solid;
border-width: 10px 12px;
}
.burger-icon {
width: 30px;
cursor: pointer;
display: none;
}
.burger-icon span {
display: block;
height: 2px;
background-color: #091e42;
margin: 6px 0;
transition: background-color 0.3s ease-in, opacity 0.3s ease-in, transform 0.3s ease-in;
}
@media (max-width: 992px) {
.tutor-header-profile-menu-items {
margin: 15px 0 !important;
order: 9;
.tutor-header-submenu {
display: grid;
left: 0;
padding-top: 20px;
right: 0;
top: 56px;
width: 100% !important;
&:before {
top: -18px;
left: 6px;
right: auto;
}
.tutor-submenu-links ul li a {
font-size: 14px;
font-weight: 500;
line-height: 1.5em;
padding: 10px 25px;
}
}
}
.tutor-submenu-login-content {
font-size: 16px;
line-height: 1.2em;
padding-bottom: 15px;
padding-top: 5px;
}
.tutor-submenu-login-section,
.tutor-submenu-login-section-instructor {
padding-left: 30px;
padding-top: 10px;
display: flex;
flex-direction: column;
justify-content: center;
}
}
@media (max-width: 767px) {
.navbar-brand {
order: 1;
}
.navbar-utils {
order: 2;
}
.burger-icon {
display: block;
}
.tutor-submenu-login-section,
.tutor-submenu-login-section-instructor {
width: 100%;
padding-left: 25px;
padding-top: 10px;
order: 3;
}
.tutor-submenu-links {
width: 100%;
padding: 0;
order: 1;
}
.tutor-submenu-links ul {
padding-left: 0;
}
.tutor-submenu-login-avatar {
display: none;
}
.tutor-submenu-login-btn {
position: absolute;
right: 40px;
bottom: 12px;
}
.tutor-header-profile-menu-items:hover .tutor-header-submenu {
opacity: 0;
visibility: hidden;
}
.tutor-header-profile-menu-items.active .tutor-header-submenu {
opacity: 1;
visibility: visible;
}
.tutor-header-profile-menu-items.active .tutor-header-submenu-icon {
transform: rotate(180deg);
}
}
@media (max-width: 500px) {
.navbar {
display: grid;
grid-gap: 0;
}
.tutor-header-submenu-icon {
font-size: 14px;
padding: 0 8px;
}
}
\ No newline at end of file
......@@ -19,6 +19,14 @@ function add_image_credits($content,$attributes, $post){
return $content;
}
if ( ! function_exists( 'is_plugin_active' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
}
if ( is_plugin_active( 'tutor/tutor.php' ) ) {
require __DIR__ . '/library/tutorstarter.php';
}
require __DIR__ . '/library/supports.php';
require __DIR__ . '/library/sidebars.php';
require __DIR__ . '/library/menus.php';
......@@ -30,5 +38,3 @@ require __DIR__ . '/library/template-tags/index.php';
require __DIR__ . '/library/customizer/index.php';
require __DIR__ . '/library/blocks/index.php';
require __DIR__ . '/library/utils.php';
......@@ -35,6 +35,12 @@
<?= wp_nav_menu(['theme_location' => 'main-menu', 'container' => 'nav', 'menu_id' => 'main-menu', 'menu_class' => 'menu', 'container_class' => 'primary-menu']) ?>
<?= the_social_networks_menu() ?>
<?php if ( is_plugin_active( 'tutor/tutor.php' ) ) : ?>
<div class="tutor-header-profile-menu-items">
<?php tutor_multi_column_dropdown(); ?>
</div><!-- .tutor-header-profile-menu -->
<?php endif; ?>
<div class="search-component">
<?php get_search_form(); ?>
</div><!-- .search-component -->
......
......@@ -364,7 +364,15 @@ class Assets {
'preload_callback' => function() {
return is_page_template( 'page-anchor.php' );
},
]
],
// Tutor
'tutorstarter' => [
'file' => '_p-tutorstarter.css',
'preload_callback' => function() {
return is_plugin_active( 'tutor/tutor.php' );
},
]
];
/**
......@@ -419,6 +427,12 @@ class Assets {
'global' => true,
],
// Tutor
'tutorstarter' => [
'file' => 'tutorstarter.js',
'global' => true,
],
'scroll-behavior' => [
'file' => 'anchor-behavior.js',
'global' => true,
......
<?php
/**
* Tutor multi-column dropdown menu
*/
function tutor_multi_column_dropdown() {
$default_menus = apply_filters( 'tutor_dashboard/nav_items', default_menus() );
$current_user = wp_get_current_user();
?>
<?php if ( is_user_logged_in() ) : ?>
<div class="tutor-header-profile-photo">
<?php
if ( function_exists( 'tutor_utils' ) ) {
echo tutor_utils()->get_tutor_avatar( get_current_user_id(), 'thumbnail' );
} else {
$get_avatar_url = get_avatar_url( get_current_user_id(), 'thumbnail' );
echo "<img alt='' src='$get_avatar_url' />";
}
?>
</div><!-- .tutor-header-profile-photo -->
<div class="tutor-header-profile-content">
<div class="tutor-header-profile-content-text"><?php esc_html_e( 'Hello', 'tutorstarter' ); ?></div>
<div class="tutor-header-profile-submenu">
<div class="tutor-header-profile-name"><?php echo esc_html( ucfirst( $current_user->display_name ) ); ?></div>
<div class="tutor-header-submenu-icon tutor-icon-icon-light-down-line tutor-font-size-20 tutor-text-400">
</div>
</div>
</div>
<div class="tutor-header-submenu">
<?php if ( ! defined( 'TDC_VERSION' ) && is_user_priviledged() ) : ?>
<div class="tutor-submenu-login-section-instructor">
<div class="tutor-submenu-login-avatar">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/instructor-submenu-icon.svg' ); ?>" alt="profile avatar">
</div>
<div class="tutor-submenu-login-content">
<div class="tutor-submenu-login-profile" style="margin-top: 10px;"><?php wp_kses_post( _e( 'Create a<br />New Course', 'tutorstarter' ) ) ?></div>
<p class="tutor-mt-10 tutor-font-size-14" style="line-height: 1.5em; font-size:14px; margin-top:10px;"><?php wp_kses_post( _e( 'Get started with topics,<br />lessons and more', 'tutorstarter' ) ); ?></p>
</div>
<div class="tutor-submenu-login-btn">
<a id="tutor-starter-create-course" class="tutor-submenu-login" href="<?php echo admin_url( 'post-new.php?post_type=' . tutor()->course_post_type ); ?>"><span class="dashicons dashicons-arrow-right-alt2" style="font-weight: bold;"></span></a>
</div>
</div>
<?php endif; ?>
<div class="tutor-submenu-links">
<ul>
<?php
foreach ( $default_menus as $menu_key => $menu_item ) {
$menu_title = $menu_item;
$menu_link = tutor_utils()->get_tutor_dashboard_page_permalink( $menu_key );
if ( is_array( $menu_item ) ) {
$menu_title = tutor_utils()->array_get( 'title', $menu_item );
if ( isset( $menu_item['url'] ) ) {
$menu_link = $menu_item['url'];
}
}
if ( $menu_key === 'index' ) $menu_key = '';
echo "<li><a href='" . esc_url( $menu_link ) . "'>" . esc_html( $menu_title ) . " </a></li>";
}
?>
</ul>
</div>
<div class="tutor-submenu-links">
<ul>
<?php
$filtered_nav_items = filtered_nav();
foreach ( $filtered_nav_items as $nav_key => $nav_item ) {
$menu_title = $nav_item;
$menu_link = tutor_utils()->get_tutor_dashboard_page_permalink( $nav_key );
if ( is_array( $nav_item ) ) {
$menu_title = tutor_utils()->array_get( 'title', $nav_item );
if ( isset( $nav_item['url'] ) ) {
$menu_link = $nav_item['url'];
}
}
if ( isset( $nav_item['type'] ) && 'separator' === $nav_item['type'] ) {
echo '';
} else {
echo "<li><a href='" . esc_url( $menu_link ) . "'>" . esc_html( $menu_title ) . " </a></li>";
}
}
?>
</ul>
</div>
</div>
<?php else : ?>
<div class="tutor-header-login">
<a href="<?php echo wp_login_url(); ?>">Acessar conta</a>
</div><!-- .tutor-header-login -->
<?php endif; ?>
<?php }
/**
* Default Menus
*/
function default_menus() {
return array(
'index' => array(
'title' => __( 'Dashboard', 'tutorstarter' ),
'icon' => 'tutor-icon-dashboard-filled',
),
'my-profile' => array(
'title' => __( 'My Profile', 'tutorstarter' ),
'icon' => 'tutor-icon-man-user-filled',
),
'enrolled-courses' => array(
'title' => __( 'Enrolled Courses', 'tutorstarter' ),
'icon' => 'tutor-icon-college-graduation-filled',
),
'wishlist' => array(
'title' => __( 'Wishlist', 'tutorstarter' ),
'icon' => 'tutor-icon-fav-full-filled',
),
'reviews' => array(
'title' => __( 'Reviews', 'tutorstarter' ),
'icon' => 'tutor-icon-star-full-filled',
),
'my-quiz-attempts' => array(
'title' => __( 'My Quiz Attempts', 'tutorstarter' ),
'icon' => 'tutor-icon-quiz-attempt-filled',
),
'purchase_history' => array(
'title' => __( 'Order History', 'tutorstarter' ),
'icon' => 'tutor-icon-cart-filled',
),
'question-answer' => array(
'title' => __( 'Question & Answer', 'tutorstarter' ),
'icon' => 'tutor-icon-question-filled',
),
);
}
/**
* Check role
*
* @return bool
*/
function is_user_priviledged() {
$user_is_priviledged = false;
$current_user = wp_get_current_user();
$predefined_roles = apply_filters( 'tutor_user_is_priviledged', array(
'administrator',
'tutor_instructor'
) );
if ( array_intersect( $current_user->roles, $predefined_roles ) ) {
$user_is_priviledged = true;
} else {
$user_is_priviledged = false;
}
return $user_is_priviledged;
}
/**
* Filtered nav items based on capabilities
*
* @return array
*/
function filtered_nav() {
$instructor_menu = apply_filters( 'tutor_dashboard/instructor_nav_items', instructor_menus() );
$common_navs = array(
'settings' => array(
'title' => __( 'Settings', 'tutorstarter' ),
'icon' => 'tutor-icon-settings-filled',
),
'logout' => array(
'title' => __( 'Logout', 'tutorstarter' ),
'icon' => 'tutor-icon-signout-filled',
),
);
$all_nav_items = array_merge( $instructor_menu, $common_navs );
foreach ( $all_nav_items as $nav_key => $nav_item ) {
if ( is_array( $nav_item ) ) {
if ( isset( $nav_item['show_ui'] ) && ! tutor_utils()->array_get( 'show_ui', $nav_item ) ) {
unset( $all_nav_items[ $nav_key ] );
}
if ( isset( $nav_item['auth_cap'] ) && ! current_user_can( $nav_item['auth_cap'] ) ) {
unset( $all_nav_items[ $nav_key ] );
}
}
}
return $all_nav_items;
}
/**
* Instructor Menus
*/
function instructor_menus() {
return array(
'separator-1' => array(
'title' => __( 'Instructor', 'tutorstarter' ),
'auth_cap' => tutor()->instructor_role,
'type' => 'separator',
),
'create-course' => array(
'title' => __( 'Create Course', 'tutorstarter' ),
'show_ui' => false,
'auth_cap' => tutor()->instructor_role,
),
'my-courses' => array(
'title' => __( 'My Courses', 'tutorstarter' ),
'auth_cap' => tutor()->instructor_role,
'icon' => 'tutor-icon-space-filled',
),
'announcements' => array(
'title' => __( 'Announcements', 'tutorstarter' ),
'auth_cap' => tutor()->instructor_role,
'icon' => 'tutor-icon-speaker-filled',
),
'withdraw' => array(
'title' => __( 'Withdrawals', 'tutorstarter' ),
'auth_cap' => tutor()->instructor_role,
'icon' => 'tutor-icon-wallet-filled',
),
'quiz-attempts' => array(
'title' => __( 'Quiz Attempts', 'tutorstarter' ),
'auth_cap' => tutor()->instructor_role,
'icon' => 'tutor-icon-quiz-filled',
),
);
}
\ No newline at end of file
......@@ -25,6 +25,7 @@
"/css/_p-projects.css": "/css/_p-projects.css",
"/css/_p-search.css": "/css/_p-search.css",
"/css/_p-single.css": "/css/_p-single.css",
"/css/_p-tutorstarter.css": "/css/_p-tutorstarter.css",
"/css/.gitkeep.css": "/css/.gitkeep.css",
"/css/_c-top-menu.css": "/css/_c-top-menu.css",
"/css/menu-sempre-hamburguer.css": "/css/menu-sempre-hamburguer.css",
......@@ -36,5 +37,6 @@
"/js/functionalities/perguntas-frequentes.js": "/js/functionalities/perguntas-frequentes.js",
"/js/functionalities/query-slider.js": "/js/functionalities/query-slider.js",
"/js/functionalities/search.js": "/js/functionalities/search.js",
"/js/functionalities/tutorstarter.js": "/js/functionalities/tutorstarter.js",
"/js/functionalities/video-gallery.js": "/js/functionalities/video-gallery.js"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment