mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 06:03:38 +09:00
- fixed Edit Profile mode;
- added esc functions; - added Unsplash extension; - added new conditional setting for admin forms;
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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}\" ";
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 <a href="https://unsplash.com/" target="_blank">Unsplash</a> from their profile',
|
||||
);
|
||||
|
||||
$free['forumwp'] = array(
|
||||
'url' => 'https://ultimatemember.com/extensions/forumwp/',
|
||||
'name' => 'ForumWP',
|
||||
|
||||
Reference in New Issue
Block a user