diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index d9ee22a9..ba3d4f14 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -1214,198 +1214,204 @@ add_action( 'um_after_user_updated', 'um_restore_default_roles', 10, 3 ); options()->get( 'profile_menu' ) ) - return; - // get active tabs - $tabs = UM()->profile()->tabs_active(); +/** + * Display the available profile tabs + * + * @param array $args + */ +function um_profile_menu( $args ) { + if ( ! UM()->options()->get( 'profile_menu' ) ) + return; - /** - * 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 - * - * @example - * - */ - $tabs = apply_filters( 'um_user_profile_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; - } - - ?> - -
- - $tab) { - - if (isset( $tab['hidden'] )) continue; - - $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 ); - - /** - * 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 - * - * @example - * - */ - $nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link ); - - ?> - -
- options()->get( 'profile_menu_icons' ) ) { ?> - - - - - 0) { ?> - - - - - - - - - - - 0) { ?> - - - - - - - - - - 0) { ?> - - - - - - - -
- - - -
- -
- - $tab) { - - if (isset( $tab['subnav'] ) && $active_tab == $id) { - - $active_subnav = ( UM()->profile()->active_subnav() ) ? UM()->profile()->active_subnav() : $tab['subnav_default']; - - echo '
'; - foreach ($tab['subnav'] as $id => $subtab) { - - ?> - - - - '; - } - - } - - } + // get active tabs + $tabs = UM()->profile()->tabs_active(); /** - * Clean up file for new uploaded files + * UM hook * - * @param integer $user_id - * @param array $arr_files + * @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 + * + * @example + * */ - function um_before_user_upload( $user_id, $arr_files ) { - um_fetch_user( $user_id ); + $tabs = apply_filters( 'um_user_profile_tabs', $tabs ); - foreach ( $arr_files as $key => $filename ) { - if ( um_user( $key ) ) { - $old_filename = um_user( $key ); + UM()->user()->tabs = $tabs; - if ( basename( $filename ) != basename( um_user( $key ) ) || - in_array( $old_filename, array( basename( um_user( $key ) ), basename( $filename ) ) ) || - $filename == 'empty_file' ) { + // need enough tabs to continue + if ( count( $tabs ) <= 1 ) { + return; + } - $path = UM()->files()->upload_basedir; - delete_user_meta( $user_id, $old_filename ); - if (file_exists( $path . $user_id . '/' . $old_filename )) { - unlink( $path . $user_id . '/' . $old_filename ); - } + $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; + } ?> + +
+ + $tab ) { + + if ( isset( $tab['hidden'] ) ) { + continue; + } + + $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 ); + + /** + * 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 + * + * @example + * + */ + $nav_link = apply_filters( "um_profile_menu_link_{$id}", $nav_link ); + + $profile_nav_class = ''; + if ( ! UM()->options()->get( 'profile_menu_icons' ) ) { + $profile_nav_class .= ' without-icon'; + } + + if ( $id == $active_tab ) { + $profile_nav_class .= ' active'; + } ?> + +
+ options()->get( 'profile_menu_icons' ) ) { ?> + + + + + 0 ) { ?> + + + + + + + + + + + 0 ) { ?> + + + + + + + + + + 0) { ?> + + + + + + + +
+ + + +
+ +
+ + $tab ) { + + if ( isset( $tab['subnav'] ) && $active_tab == $id ) { + + $active_subnav = ( UM()->profile()->active_subnav() ) ? UM()->profile()->active_subnav() : $tab['subnav_default']; ?> + +
+ $subtab ) { ?> + + + + + + +
+ $filename ) { + if ( um_user( $key ) ) { + $old_filename = um_user( $key ); + + if ( basename( $filename ) != basename( um_user( $key ) ) || + in_array( $old_filename, array( basename( um_user( $key ) ), basename( $filename ) ) ) || + $filename == 'empty_file' ) { + + $path = UM()->files()->upload_basedir; + delete_user_meta( $user_id, $old_filename ); + if (file_exists( $path . $user_id . '/' . $old_filename )) { + unlink( $path . $user_id . '/' . $old_filename ); } } } } - add_action( "um_before_user_upload", "um_before_user_upload", 10, 2 ); \ No newline at end of file +} +add_action( "um_before_user_upload", "um_before_user_upload", 10, 2 ); \ No newline at end of file