diff --git a/assets/img/extensions/unsplash.png b/assets/img/extensions/unsplash.png new file mode 100644 index 00000000..e7ed16c8 Binary files /dev/null and b/assets/img/extensions/unsplash.png differ diff --git a/includes/admin/assets/js/um-admin-forms.js b/includes/admin/assets/js/um-admin-forms.js index c6b6aca7..d8a20f04 100644 --- a/includes/admin/assets/js/um-admin-forms.js +++ b/includes/admin/assets/js/um-admin-forms.js @@ -203,16 +203,27 @@ jQuery(document).ready( function() { var value = conditional[2]; var prefix = form_line.data( 'prefix' ); - //var prefix = form_line.parents( '.um-form-table' ).data( 'prefix' ); - - var condition_field = jQuery( '#' + prefix + '_' + conditional[0] ); var parent_condition = true; - if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) { - parent_condition = check_condition( condition_field.parents('.um-forms-line') ); + + if ( condition === '=' || condition === '!=' ) { + var condition_field = jQuery( '#' + prefix + '_' + conditional[0] ); + + if ( typeof condition_field.parents('.um-forms-line').data('conditional') !== 'undefined' ) { + parent_condition = check_condition( condition_field.parents('.um-forms-line') ); + } + } else if ( condition === '~' ) { + var selectors = conditional[0].split('|'); + var condition_fields = []; + jQuery.each( selectors, function(i) { + condition_fields.push( jQuery( '#' + prefix + '_' + selectors[i] ) ); + }); + if ( typeof condition_fields[0].parents('.um-forms-line').data('conditional') !== 'undefined' ) { + parent_condition = check_condition( condition_fields[0].parents('.um-forms-line') ); + } } var own_condition = false; - if ( condition == '=' ) { + if ( condition === '=' ) { var tagName = condition_field.prop("tagName").toLowerCase(); if ( tagName == 'input' ) { @@ -225,7 +236,7 @@ jQuery(document).ready( function() { } else if ( tagName == 'select' ) { own_condition = ( condition_field.val() == value ); } - } else if ( condition == '!=' ) { + } else if ( condition === '!=' ) { var tagName = condition_field.prop("tagName").toLowerCase(); if ( tagName == 'input' ) { @@ -238,6 +249,42 @@ jQuery(document).ready( function() { } else if ( tagName == 'select' ) { own_condition = ( condition_field.val() != value ); } + } else if ( condition === '~' ) { + + var field_id = form_line.find( form_line.data('field_type') ).data('field_id'); + var visible_options = []; + jQuery.each( condition_fields, function(i) { + var condition_field = condition_fields[ i ]; + + var tagName = condition_field.prop("tagName").toLowerCase(); + + if ( tagName === 'input' ) { + var input_type = condition_field.attr('type'); + if ( input_type === 'checkbox' ) { + if ( value == '1' && condition_field.is(':checked') ) { + visible_options.push( condition_field.data( 'fill_' + field_id ) ); + } + } + } + }); + + var lines_field = jQuery( '[data-field_id="' + field_id + '"]' ); + + if ( visible_options.length ) { + lines_field.find( 'option' ).hide(); + jQuery.each( visible_options, function(i) { + lines_field.find( 'option[value="' + visible_options[ i ] + '"]' ).show(); + }); + if ( visible_options.indexOf( lines_field.val() ) === -1 ) { + lines_field.val( visible_options[0] ); + lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false ); + lines_field.find( 'option[value="' + visible_options[0] + '"]' ).attr( 'selected', true ).prop( 'selected', true ); + } + own_condition = true; + } else { + lines_field.val( null ); + lines_field.find( 'option' ).attr( 'selected', false ).prop( 'selected', false ); + } } return ( own_condition && parent_condition ); diff --git a/includes/admin/class-admin-functions.php b/includes/admin/class-admin-functions.php index 62c65cdb..57f6707e 100644 --- a/includes/admin/class-admin-functions.php +++ b/includes/admin/class-admin-functions.php @@ -46,23 +46,25 @@ if ( ! class_exists( 'um\admin\Admin_Functions' ) ) { global $current_screen; $screen_id = $current_screen->id; + $is_um_screen = false; + if ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr( $screen_id, 'user' ) || strstr( $screen_id, 'profile' ) || $screen_id == 'nav-menus' ) { - return true; + $is_um_screen = true; } if ( $this->is_plugin_post_type() ) { - return true; + $is_um_screen = true; } if ( $this->is_restricted_entity() ) { - return true; + $is_um_screen = true; } - return false; + return apply_filters( 'um_is_ultimatememeber_admin_screen', $is_um_screen ); } diff --git a/includes/admin/core/class-admin-forms.php b/includes/admin/core/class-admin-forms.php index b3042930..8f43eb69 100644 --- a/includes/admin/core/class-admin-forms.php +++ b/includes/admin/core/class-admin-forms.php @@ -691,6 +691,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Forms' ) ) { 'field_id' => $field_data['id'] ); + if ( ! empty( $field_data['data'] ) ) { + $data = array_merge( $data, $field_data['data'] ); + } + $data_attr = ''; foreach ( $data as $key => $value ) { $data_attr .= " data-{$key}=\"{$value}\" "; diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php index 9d2bd2e6..46c3e20f 100644 --- a/includes/admin/core/class-admin-settings.php +++ b/includes/admin/core/class-admin-settings.php @@ -135,12 +135,19 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $tabs = UM()->profile()->tabs(); + $tabs_options = array(); + $tabs_condition = array(); foreach ( $tabs as $id => $tab ) { if ( ! empty( $tab['hidden'] ) ) { continue; } + if ( isset( $tab['name'] ) ) { + $tabs_options[ $id ] = $tab['name']; + $tabs_condition[] = 'profile_tab_' . $id; + } + if ( isset( $tab['default_privacy'] ) ) { $fields = array( array( @@ -148,6 +155,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'type' => 'checkbox', 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), 'conditional' => array( 'profile_menu', '=', 1 ), + 'data' => array( 'fill_profile_menu_default_tab' => $id ), ), ); } else { @@ -158,6 +166,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { 'type' => 'checkbox', 'label' => sprintf( __( '%s Tab', 'ultimate-member' ), $tab['name'] ), 'conditional' => array( 'profile_menu', '=', 1 ), + 'data' => array( 'fill_profile_menu_default_tab' => $id ), ), array( 'id' => 'profile_tab_' . $id . '_privacy', @@ -185,27 +194,15 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) { $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, $fields ); } - $active_tabs = array(); - $tabs = UM()->profile()->tabs_active(); - if ( ! empty( $tabs ) ) { - foreach ( $tabs as $id => $info ) { - if ( isset( $info['name'] ) ) { - $active_tabs[ $id ] = $info['name']; - } - } - } - - if ( count( $active_tabs ) ) { - $appearances_profile_menu_fields[] = array( - 'id' => 'profile_menu_default_tab', - 'type' => 'select', - 'label' => __( 'Profile menu default tab', 'ultimate-member' ), - 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ), - 'options' => $active_tabs, - 'conditional' => array( 'profile_menu', '=', 1 ), - 'size' => 'small' - ); - } + $appearances_profile_menu_fields[] = array( + 'id' => 'profile_menu_default_tab', + 'type' => 'select', + 'label' => __( 'Profile menu default tab', 'ultimate-member' ), + 'tooltip' => __( 'This will be the default tab on user profile page', 'ultimate-member' ), + 'options' => $tabs_options, + 'conditional' => array( implode( '|', $tabs_condition ), '~', 1 ), + 'size' => 'small' + ); $appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array( array( diff --git a/includes/admin/templates/extensions.php b/includes/admin/templates/extensions.php index f34102a6..eb5c688e 100644 --- a/includes/admin/templates/extensions.php +++ b/includes/admin/templates/extensions.php @@ -122,6 +122,12 @@ $premium['user-bookmarks'] = array( 'desc' => 'Allow users to bookmark content from your website', ); +$premium['unsplash'] = array( + 'url' => 'https://ultimatemember.com/extensions/unsplash/', + 'name' => 'Unsplash', + 'desc' => 'Allow users to select a profile cover photo from Unsplash from their profile', +); + $free['forumwp'] = array( 'url' => 'https://ultimatemember.com/extensions/forumwp/', 'name' => 'ForumWP', diff --git a/includes/class-init.php b/includes/class-init.php index 552ac2c0..54e52c73 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -27,7 +27,7 @@ if ( ! class_exists( 'UM' ) ) { * @method UM_User_Tags_API User_Tags_API() * @method UM_Verified_Users_API Verified_Users_API() * @method UM_WooCommerce_API WooCommerce_API() - * @method UM_Terms_Conditions_API Terms_Conditions_API() + * @method UM_Terms_Conditions Terms_Conditions() * @method UM_Private_Content_API Private_Content_API() * @method UM_User_Location_API User_Location_API() * @method UM_Photos_API Photos_API() diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 7e22f258..0620e881 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -9,8 +9,9 @@ function um_profile_content_main( $args ) { extract( $args ); - if ( ! UM()->options()->get( 'profile_tab_main' ) && ! isset( $_REQUEST['um_action'] ) ) + if ( ! UM()->options()->get( 'profile_tab_main' ) && ! isset( $_REQUEST['um_action'] ) ) { return; + } /** * UM hook @@ -164,7 +165,12 @@ function um_profile_content_main( $args ) { do_action( "um_after_form", $args ); } else { ?> -
- - + +
options()->get( 'profile_menu' ); - $tabs = UM()->profile()->tabs_active(); + if ( um_is_on_edit_profile() ) { - $nav = UM()->profile()->active_tab(); - $subnav = UM()->profile()->active_subnav(); - $subnav = ! empty( $subnav ) ? $subnav : 'default'; - - if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?> + $nav = 'main'; + $subnav = UM()->profile()->active_subnav(); + $subnav = ! empty( $subnav ) ? $subnav : 'default'; ?>