mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- profile tabs changes;
This commit is contained in:
@@ -137,7 +137,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
|
||||
foreach ( $tabs as $id => $tab ) {
|
||||
|
||||
if ( isset( $tab['hidden'] ) ) {
|
||||
if ( ! empty( $tab['hidden'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -546,7 +546,13 @@ if ( ! class_exists( 'um\Config' ) ) {
|
||||
add_filter( 'um_get_tabs_from_config', '__return_true' );
|
||||
|
||||
$tabs = UM()->profile()->tabs();
|
||||
|
||||
foreach ( $tabs as $id => $tab ) {
|
||||
|
||||
if ( ! empty( $tab['hidden'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->settings_defaults[ 'profile_tab_' . $id ] = 1;
|
||||
|
||||
if ( ! isset( $tab['default_privacy'] ) ) {
|
||||
|
||||
@@ -242,6 +242,31 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_profile_tabs
|
||||
* @description Extend profile tabs
|
||||
* @input_vars
|
||||
* [{"var":"$tabs","type":"array","desc":"Profile Tabs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_profile_tabs', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_profile_tabs', 'my_user_profile_tabs', 10, 1 );
|
||||
* function my_user_profile_tabs( $tabs ) {
|
||||
* // your code here
|
||||
* return $tabs;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$tabs = apply_filters( 'um_user_profile_tabs', $tabs );
|
||||
}
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
@@ -253,10 +278,45 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
*/
|
||||
function active_tab() {
|
||||
|
||||
$this->active_tab = UM()->options()->get('profile_menu_default_tab');
|
||||
// get active tabs
|
||||
$tabs = UM()->profile()->tabs_active();
|
||||
|
||||
if ( get_query_var('profiletab') ) {
|
||||
$this->active_tab = get_query_var('profiletab');
|
||||
if ( ! UM()->options()->get( 'profile_menu' ) ) {
|
||||
|
||||
$query_arg = get_query_var( 'profiletab' );
|
||||
if ( ! empty( $query_arg ) && ! empty( $tabs[ $query_arg ]['hidden'] ) ) {
|
||||
$this->active_tab = $query_arg;
|
||||
} else {
|
||||
if ( ! empty( $tabs ) ) {
|
||||
foreach ( $tabs as $k => $tab ) {
|
||||
if ( ! empty( $tab['hidden'] ) ) {
|
||||
$this->active_tab = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$query_arg = get_query_var( 'profiletab' );
|
||||
if ( ! empty( $query_arg ) && ! empty( $tabs[ $query_arg ] ) ) {
|
||||
$this->active_tab = $query_arg;
|
||||
} else {
|
||||
$default_tab = UM()->options()->get( 'profile_menu_default_tab' );
|
||||
|
||||
if ( ! empty( $tabs[ $default_tab ] ) ) {
|
||||
$this->active_tab = $default_tab;
|
||||
} else {
|
||||
if ( ! empty( $tabs ) ) {
|
||||
foreach ( $tabs as $k => $tab ) {
|
||||
if ( ! empty( $tab['hidden'] ) ) {
|
||||
$this->active_tab = $k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
$this->data = null;
|
||||
$this->profile = null;
|
||||
$this->cannot_edit = null;
|
||||
$this->tabs = null;
|
||||
|
||||
$this->banned_keys = array(
|
||||
'metabox','postbox','meta-box',
|
||||
|
||||
@@ -1320,160 +1320,144 @@ function um_profile_menu( $args ) {
|
||||
// get active tabs
|
||||
$tabs = UM()->profile()->tabs_active();
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_user_profile_tabs
|
||||
* @description Extend profile tabs
|
||||
* @input_vars
|
||||
* [{"var":"$tabs","type":"array","desc":"Profile Tabs"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_user_profile_tabs', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_user_profile_tabs', 'my_user_profile_tabs', 10, 1 );
|
||||
* function my_user_profile_tabs( $tabs ) {
|
||||
* // your code here
|
||||
* return $tabs;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$tabs = apply_filters( 'um_user_profile_tabs', $tabs );
|
||||
$all_tabs = $tabs;
|
||||
|
||||
UM()->user()->tabs = $tabs;
|
||||
|
||||
// need enough tabs to continue
|
||||
if ( count( $tabs ) <= 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$active_tab = UM()->profile()->active_tab();
|
||||
|
||||
if ( ! isset( $tabs[ $active_tab ] ) ) {
|
||||
$active_tab = 'main';
|
||||
UM()->profile()->active_tab = $active_tab;
|
||||
UM()->profile()->active_subnav = null;
|
||||
}
|
||||
|
||||
// Move default tab priority
|
||||
$default_tab = UM()->options()->get( 'profile_menu_default_tab' );
|
||||
$dtab = ( isset( $tabs[ $default_tab ] ) ) ? $tabs[ $default_tab ] : 'main';
|
||||
if ( isset( $tabs[ $default_tab ] ) ) {
|
||||
unset( $tabs[ $default_tab ] );
|
||||
$dtabs[ $default_tab ] = $dtab;
|
||||
$tabs = $dtabs + $tabs;
|
||||
}
|
||||
|
||||
$tabs_in_nav = array_filter( $tabs, function( $item ) {
|
||||
$tabs = array_filter( $tabs, function( $item ) {
|
||||
if ( ! empty( $item['hidden'] ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
if ( ! empty( $tabs_in_nav ) ) { ?>
|
||||
$active_tab = UM()->profile()->active_tab();
|
||||
//check here tabs with hidden also, to make correct check of active tab
|
||||
if ( ! isset( $all_tabs[ $active_tab ] ) ) {
|
||||
$active_tab = 'main';
|
||||
UM()->profile()->active_tab = $active_tab;
|
||||
UM()->profile()->active_subnav = null;
|
||||
}
|
||||
|
||||
<div class="um-profile-nav">
|
||||
$has_subnav = false;
|
||||
if ( count( $tabs ) == 1 ) {
|
||||
foreach ( $tabs as $tab ) {
|
||||
if ( isset( $tab['subnav'] ) ) {
|
||||
$has_subnav = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<?php foreach ( $tabs as $id => $tab ) {
|
||||
// need enough tabs to continue
|
||||
if ( count( $tabs ) <= 1 && ! $has_subnav && count( $all_tabs ) === count( $tabs ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $tab['hidden'] ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( count( $tabs ) > 1 || count( $all_tabs ) > count( $tabs ) ) {
|
||||
// Move default tab priority
|
||||
$default_tab = UM()->options()->get( 'profile_menu_default_tab' );
|
||||
$dtab = ( isset( $tabs[ $default_tab ] ) ) ? $tabs[ $default_tab ] : 'main';
|
||||
if ( isset( $tabs[ $default_tab ] ) ) {
|
||||
unset( $tabs[ $default_tab ] );
|
||||
$dtabs[ $default_tab ] = $dtab;
|
||||
$tabs = $dtabs + $tabs;
|
||||
}
|
||||
|
||||
$nav_link = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
||||
$nav_link = remove_query_arg( 'um_action', $nav_link );
|
||||
$nav_link = remove_query_arg( 'subnav', $nav_link );
|
||||
$nav_link = add_query_arg( 'profiletab', $id, $nav_link );
|
||||
if ( ! empty( $tabs ) ) { ?>
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_menu_link_{$id}
|
||||
* @description Change profile menu link by tab $id
|
||||
* @input_vars
|
||||
* [{"var":"$nav_link","type":"string","desc":"Profile Tab Link"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_menu_link_{$id}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_menu_link_{$id}', 'my_profile_menu_link', 10, 1 );
|
||||
* function my_profile_menu_link( $nav_link ) {
|
||||
* // your code here
|
||||
* return $nav_link;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link );
|
||||
<div class="um-profile-nav">
|
||||
|
||||
$profile_nav_class = '';
|
||||
if ( ! UM()->options()->get( 'profile_menu_icons' ) ) {
|
||||
$profile_nav_class .= ' without-icon';
|
||||
}
|
||||
<?php foreach ( $tabs as $id => $tab ) {
|
||||
|
||||
if ( $id == $active_tab ) {
|
||||
$profile_nav_class .= ' active';
|
||||
} ?>
|
||||
$nav_link = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
|
||||
$nav_link = remove_query_arg( 'um_action', $nav_link );
|
||||
$nav_link = remove_query_arg( 'subnav', $nav_link );
|
||||
$nav_link = add_query_arg( 'profiletab', $id, $nav_link );
|
||||
|
||||
<div class="um-profile-nav-item um-profile-nav-<?php echo $id . ' ' . $profile_nav_class; ?>">
|
||||
<?php if ( UM()->options()->get( 'profile_menu_icons' ) ) { ?>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_profile_menu_link_{$id}
|
||||
* @description Change profile menu link by tab $id
|
||||
* @input_vars
|
||||
* [{"var":"$nav_link","type":"string","desc":"Profile Tab Link"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_profile_menu_link_{$id}', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_profile_menu_link_{$id}', 'my_profile_menu_link', 10, 1 );
|
||||
* function my_profile_menu_link( $nav_link ) {
|
||||
* // your code here
|
||||
* return $nav_link;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link );
|
||||
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
$profile_nav_class = '';
|
||||
if ( ! UM()->options()->get( 'profile_menu_icons' ) ) {
|
||||
$profile_nav_class .= ' without-icon';
|
||||
}
|
||||
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
if ( $id == $active_tab ) {
|
||||
$profile_nav_class .= ' active';
|
||||
} ?>
|
||||
|
||||
<span class="uimob800-hide uimob500-hide uimob340-hide title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
<div class="um-profile-nav-item um-profile-nav-<?php echo $id . ' ' . $profile_nav_class; ?>">
|
||||
<?php if ( UM()->options()->get( 'profile_menu_icons' ) ) { ?>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<span class="title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
<span class="uimob800-hide uimob500-hide uimob340-hide title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
</a>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0) { ?>
|
||||
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
<span class="title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-show uimob500-show uimob340-show um-tip-n"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>" original-title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
|
||||
<span class="title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<i class="<?php echo $tab['icon']; ?>"></i>
|
||||
|
||||
<?php } ?>
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0 ) { ?>
|
||||
<span class="um-tab-notifier uimob800-show uimob500-show uimob340-show"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
</a>
|
||||
<a href="<?php echo $nav_link; ?>" class="uimob800-hide uimob500-hide uimob340-hide"
|
||||
title="<?php echo esc_attr( $tab['name'] ); ?>">
|
||||
|
||||
<div class="um-clear"></div>
|
||||
<?php if ( isset( $tab['notifier'] ) && $tab['notifier'] > 0) { ?>
|
||||
<span class="um-tab-notifier"><?php echo $tab['notifier']; ?></span>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
<span class="title"><?php echo $tab['name']; ?></span>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
<?php } ?>
|
||||
|
||||
<div class="um-clear"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
}
|
||||
|
||||
foreach ( $tabs as $id => $tab ) {
|
||||
|
||||
|
||||
+56
-48
@@ -142,59 +142,67 @@
|
||||
*/
|
||||
do_action( 'um_profile_menu', $args );
|
||||
|
||||
$nav = UM()->profile()->active_tab;
|
||||
$subnav = ( get_query_var('subnav') ) ? get_query_var('subnav') : 'default'; ?>
|
||||
$menu_enabled = UM()->options()->get( 'profile_menu' );
|
||||
$tabs = UM()->profile()->tabs_active();
|
||||
|
||||
<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
|
||||
$nav = UM()->profile()->active_tab();
|
||||
$subnav = UM()->profile()->active_subnav();
|
||||
$subnav = ! empty( $subnav ) ? $subnav : 'default';
|
||||
|
||||
<?php
|
||||
// Custom hook to display tabbed content
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_profile_content_{$nav}
|
||||
* @description Custom hook to display tabbed content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_profile_content_{$nav}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_profile_content_{$nav}', 'my_profile_content', 10, 1 );
|
||||
* function my_profile_content( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action("um_profile_content_{$nav}", $args);
|
||||
if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?>
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_profile_content_{$nav}_{$subnav}
|
||||
* @description Custom hook to display tabbed content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_profile_content_{$nav}_{$subnav}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_profile_content_{$nav}_{$subnav}', 'my_profile_content', 10, 1 );
|
||||
* function my_profile_content( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
|
||||
<div class="um-profile-body <?php echo esc_attr( $nav . ' ' . $nav . '-' . $subnav ); ?>">
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php
|
||||
// Custom hook to display tabbed content
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_profile_content_{$nav}
|
||||
* @description Custom hook to display tabbed content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_profile_content_{$nav}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_profile_content_{$nav}', 'my_profile_content', 10, 1 );
|
||||
* function my_profile_content( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action("um_profile_content_{$nav}", $args);
|
||||
|
||||
<?php if ( um_is_on_edit_profile() ) { ?>
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_profile_content_{$nav}_{$subnav}
|
||||
* @description Custom hook to display tabbed content
|
||||
* @input_vars
|
||||
* [{"var":"$args","type":"array","desc":"Profile form shortcode arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_profile_content_{$nav}_{$subnav}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_profile_content_{$nav}_{$subnav}', 'my_profile_content', 10, 1 );
|
||||
* function my_profile_content( $args ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
|
||||
if ( um_is_on_edit_profile() ) { ?>
|
||||
</form>
|
||||
<?php }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user