Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. if ( ! function_exists( 'vodi_header_user_account' ) ) {
  2. /**
  3. * Displays user account in header
  4. */
  5. function vodi_header_user_account() {
  6. if ( apply_filters( 'vodi_enable_header_user_account', true ) ) {
  7. $myaccount_page_url = function_exists( 'masvideos_get_page_permalink' ) ? masvideos_get_page_permalink( 'myaccount' ) : wp_login_url( get_permalink() );
  8. $register_page_url = apply_filters( 'vodi_header_register_page_url', $myaccount_page_url );
  9. $login_page_url = apply_filters( 'vodi_header_login_page_url', $myaccount_page_url );
  10.  
  11. if ( is_user_logged_in() ) {
  12. $user_id = get_current_user_id();
  13. $current_user = wp_get_current_user();
  14.  
  15. if ( current_user_can( 'read' ) ) {
  16. $profile_url = get_edit_profile_url( $user_id );
  17. } elseif ( is_multisite() ) {
  18. $profile_url = get_dashboard_url( $user_id, 'profile.php' );
  19. } else {
  20. $profile_url = false;
  21. }
  22.  
  23. $user_info = "<span class='display-name'>{$current_user->display_name}</span>";
  24.  
  25. if ( $current_user->display_name !== $current_user->user_login ) {
  26. $user_info .= "<span class='username'>{$current_user->user_login}</span>";
  27. }
  28.  
  29. $user_account_menu_items = array(
  30. 'user-info' => array(
  31. 'title' => $user_info,
  32. 'href' => $profile_url,
  33. ),
  34. 'edit-profile' => array(
  35. 'title' => esc_html__( 'Edit My Profile', 'vodi' ),
  36. 'href' => $profile_url,
  37. ),
  38. );
  39.  
  40. if( function_exists( 'masvideos_get_page_permalink' ) && function_exists( 'masvideos_get_endpoint_url' ) ) {
  41. $movie_playlists_page_url = masvideos_get_endpoint_url( 'movie-playlists', '', $myaccount_page_url );
  42. if( $movie_playlists_page_url ) {
  43. $user_account_menu_items['movie-playlists'] = array(
  44. 'title' => esc_html__( 'Movie Playlists', 'vodi' ),
  45. 'href' => $movie_playlists_page_url,
  46. );
  47. }
  48.  
  49. $video_playlists_page_url = masvideos_get_endpoint_url( 'video-playlists', '', $myaccount_page_url );
  50. if( $video_playlists_page_url ) {
  51. $user_account_menu_items['video-playlists'] = array(
  52. 'title' => esc_html__( 'Video Playlists', 'vodi' ),
  53. 'href' => $video_playlists_page_url,
  54. );
  55. }
  56.  
  57. $tv_show_playlists_page_url = masvideos_get_endpoint_url( 'tv-show-playlists', '', $myaccount_page_url );
  58. if( $tv_show_playlists_page_url ) {
  59. $user_account_menu_items['tv-show-playlists'] = array(
  60. 'title' => esc_html__( 'TV Show Playlists', 'vodi' ),
  61. 'href' => $tv_show_playlists_page_url,
  62. );
  63. }
  64. }
  65.  
  66. $user_account_menu_items['logout'] = array(
  67. 'title' => esc_html__( 'Log Out', 'vodi' ),
  68. 'href' => wp_logout_url(),
  69. );
  70.  
  71. $user_account_menu_items = apply_filters( 'vodi_header_user_account_menu_items', $user_account_menu_items );
  72.  
  73. ?>
  74. <div class="site-header__user-account dropdown">
  75. <a href="<?php echo esc_url( $profile_url ); ?>" class="site-header__user-account--link" data-toggle="dropdown">
  76. <?php echo get_avatar( $user_id, 32 ); ?>
  77. </a>
  78. <ul class="dropdown-menu sub-menu">
  79. <?php foreach ( $user_account_menu_items as $user_account_menu_item ) : ?>
  80. <li><a href="<?php echo esc_url( $user_account_menu_item['href'] ); ?>"><?php echo wp_kses_post( $user_account_menu_item['title'] ); ?></a></li>
  81. <?php endforeach; ?>
  82. </ul>
  83. </div>
  84. <?php
  85. } else {
  86. $outline_theme = ( apply_filters( 'vodi_header_theme', 'light' ) === 'light' ) ? 'dark' : 'light';
  87. ?>
  88. <div class="site-header__user-account dropdown">
  89. <a href="<?php echo esc_url( $login_page_url ); ?>" class="site-header__user-account--link" data-toggle="dropdown">
  90. <?php vodi_default_user_account_gravatar(); ?>
  91. </a>
  92. <ul class="dropdown-menu sub-menu">
  93. <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>
  94. <?php if ( 'yes' === get_option( 'masvideos_enable_myaccount_registration' ) ) : ?>
  95. <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>
  96. <?php endif; ?>
  97. </ul>
  98. </div>
  99. <?php
  100. }
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement