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 { ?> -
+
+ + + + +
fields()->editing == 1 && UM()->fields()->set_mode == 'profile' && UM()->user()->target_id ) { ?> - + - + - + - - - + + +
+ data-user_id="" data-ratio=""> fields()->add_hidden_field( 'cover_photo' ); ?> -
+
'; + echo ''; } else { @@ -676,7 +682,7 @@ function um_profile_header_cover_area( $args ) { + title=""> '; } ?> -
+
-
+
- + user()->cannot_edit ) ) { @@ -876,8 +882,8 @@ function um_profile_header( $args ) {
- + options()->get( 'profile_show_html_bio' ) ) : ?> - - - - + if ( UM()->options()->get( 'profile_show_html_bio' ) ) { + echo make_clickable( wpautop( wp_kses_post( $description ) ) ); + } else { + echo esc_html( $description ); + } ?>
fields()->editing == true && $args['show_bio']) { ?>
+ data-character-limit="options()->get( 'profile_bio_maxchars' ) ); ?>" + placeholder="" + name="" + id="">fields()->field_value( 'description' ) ?> options()->get( 'profile_bio_maxchars' ); ?> - fields()->is_error( 'description' )) { + + fields()->is_error( 'description' ) ) { echo UM()->fields()->field_error( UM()->fields()->show_error( 'description' ), true ); - } - ?> + } ?>
-
+
@@ -1285,7 +1290,7 @@ function um_add_submit_button_to_profile( $args ) {
@@ -1404,48 +1409,48 @@ function um_profile_menu( $args ) { $profile_nav_class .= ' active'; } ?> -
+
options()->get( 'profile_menu_icons' ) ) { ?> - - + 0 ) { ?> - + - - + 0 ) { ?> - + - - + 0 ) { ?> - 0) { ?> - +
@@ -1471,7 +1476,7 @@ function um_profile_menu( $args ) { $subnav_link = add_query_arg( 'subnav', $id_s ); $subnav_link = apply_filters( 'um_user_profile_subnav_link', $subnav_link, $id_s, $subtab ); ?> - + diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index 6504efe2..5f4cdf33 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -548,7 +548,7 @@ function um_add_submit_button_to_register( $args ) {
diff --git a/includes/core/um-actions-user.php b/includes/core/um-actions-user.php index 7fa6b581..b8d8f8c3 100644 --- a/includes/core/um-actions-user.php +++ b/includes/core/um-actions-user.php @@ -1,6 +1,4 @@ - -
  • -
  • +
  • + + + +
  • +
  • + + + +
  • window.location = "' . $url . '"'; + echo ''; }, $url ); if ( 1 < ob_get_level() ) { @@ -622,7 +622,7 @@ function um_js_redirect( $url ) { } } ?> permalinks()->get_current_url(); } else { $url = um_user_profile_url(); @@ -1587,7 +1585,6 @@ function um_edit_profile_url() { $url = remove_query_arg( 'profiletab', $url ); $url = remove_query_arg( 'subnav', $url ); - $url = add_query_arg( 'profiletab', 'main', $url ); $url = add_query_arg( 'um_action', 'edit', $url ); return $url; diff --git a/includes/widgets/class-um-search-widget.php b/includes/widgets/class-um-search-widget.php index 468b695d..f0b555bd 100644 --- a/includes/widgets/class-um-search-widget.php +++ b/includes/widgets/class-um-search-widget.php @@ -78,8 +78,8 @@ class UM_Search_Widget extends \WP_Widget { ?>

    - - + +

    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'; ?>
    - - if ( um_is_on_edit_profile() ) { ?> - - options()->get( 'profile_menu' ); + $tabs = UM()->profile()->tabs_active(); + $nav = UM()->profile()->active_tab(); + $subnav = UM()->profile()->active_subnav(); + $subnav = ! empty( $subnav ) ? $subnav : 'default'; + + if ( $menu_enabled || ! empty( $tabs[ $nav ]['hidden'] ) ) { ?> + +
    + + + */ + do_action("um_profile_content_{$nav}", $args); + + /** + * 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 + * + */ + do_action( "um_profile_content_{$nav}_{$subnav}", $args ); ?> + +
    +
    + +
    diff --git a/ultimate-member.php b/ultimate-member.php index be28bb21..644a36fb 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.54 +Version: 2.0.55-beta1 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member