Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'vodi_header_user_account' ) ) {
- /**
- * Displays user account in header
- */
- function vodi_header_user_account() {
- if ( apply_filters( 'vodi_enable_header_user_account', true ) ) {
- $myaccount_page_url = function_exists( 'masvideos_get_page_permalink' ) ? masvideos_get_page_permalink( 'myaccount' ) : wp_login_url( get_permalink() );
- $register_page_url = apply_filters( 'vodi_header_register_page_url', $myaccount_page_url );
- $login_page_url = apply_filters( 'vodi_header_login_page_url', $myaccount_page_url );
- if ( is_user_logged_in() ) {
- $user_id = get_current_user_id();
- $current_user = wp_get_current_user();
- if ( current_user_can( 'read' ) ) {
- $profile_url = get_edit_profile_url( $user_id );
- } elseif ( is_multisite() ) {
- $profile_url = get_dashboard_url( $user_id, 'profile.php' );
- } else {
- $profile_url = false;
- }
- $user_info = "<span class='display-name'>{$current_user->display_name}</span>";
- if ( $current_user->display_name !== $current_user->user_login ) {
- $user_info .= "<span class='username'>{$current_user->user_login}</span>";
- }
- $user_account_menu_items = array(
- 'user-info' => array(
- 'title' => $user_info,
- 'href' => $profile_url,
- ),
- 'edit-profile' => array(
- 'title' => esc_html__( 'Edit My Profile', 'vodi' ),
- 'href' => $profile_url,
- ),
- );
- if( function_exists( 'masvideos_get_page_permalink' ) && function_exists( 'masvideos_get_endpoint_url' ) ) {
- $movie_playlists_page_url = masvideos_get_endpoint_url( 'movie-playlists', '', $myaccount_page_url );
- if( $movie_playlists_page_url ) {
- $user_account_menu_items['movie-playlists'] = array(
- 'title' => esc_html__( 'Movie Playlists', 'vodi' ),
- 'href' => $movie_playlists_page_url,
- );
- }
- $video_playlists_page_url = masvideos_get_endpoint_url( 'video-playlists', '', $myaccount_page_url );
- if( $video_playlists_page_url ) {
- $user_account_menu_items['video-playlists'] = array(
- 'title' => esc_html__( 'Video Playlists', 'vodi' ),
- 'href' => $video_playlists_page_url,
- );
- }
- $tv_show_playlists_page_url = masvideos_get_endpoint_url( 'tv-show-playlists', '', $myaccount_page_url );
- if( $tv_show_playlists_page_url ) {
- $user_account_menu_items['tv-show-playlists'] = array(
- 'title' => esc_html__( 'TV Show Playlists', 'vodi' ),
- 'href' => $tv_show_playlists_page_url,
- );
- }
- }
- $user_account_menu_items['logout'] = array(
- 'title' => esc_html__( 'Log Out', 'vodi' ),
- 'href' => wp_logout_url(),
- );
- $user_account_menu_items = apply_filters( 'vodi_header_user_account_menu_items', $user_account_menu_items );
- ?>
- <div class="site-header__user-account dropdown">
- <a href="<?php echo esc_url( $profile_url ); ?>" class="site-header__user-account--link" data-toggle="dropdown">
- <?php echo get_avatar( $user_id, 32 ); ?>
- </a>
- <ul class="dropdown-menu sub-menu">
- <?php foreach ( $user_account_menu_items as $user_account_menu_item ) : ?>
- <li><a href="<?php echo esc_url( $user_account_menu_item['href'] ); ?>"><?php echo wp_kses_post( $user_account_menu_item['title'] ); ?></a></li>
- <?php endforeach; ?>
- </ul>
- </div>
- <?php
- } else {
- $outline_theme = ( apply_filters( 'vodi_header_theme', 'light' ) === 'light' ) ? 'dark' : 'light';
- ?>
- <div class="site-header__user-account dropdown">
- <a href="<?php echo esc_url( $login_page_url ); ?>" class="site-header__user-account--link" data-toggle="dropdown">
- <?php vodi_default_user_account_gravatar(); ?>
- </a>
- <ul class="dropdown-menu sub-menu">
- <li><a href="<?php echo esc_url( $login_page_url ); ?>" <?php echo vodi_is_header_register_login_modal_form() ? 'data-toggle="modal" data-target="#modal-register-login"' : ''?>><?php echo esc_html__( 'Sign in', 'vodi' ); ?></a></li>
- <?php if ( 'yes' === get_option( 'masvideos_enable_myaccount_registration' ) ) : ?>
- <li><a href="<?php echo esc_url( $register_page_url ); ?>" <?php echo vodi_is_header_register_login_modal_form() ? 'data-toggle="modal" data-target="#modal-register-login"' : ''?>><?php echo esc_html__( 'Register', 'vodi' ); ?></a></li>
- <?php endif; ?>
- </ul>
- </div>
- <?php
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement