mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-14 04:06:36 +09:00
- fixed conditional logic with not selected default radio button;
This commit is contained in:
+25
-21
@@ -29,6 +29,11 @@ jQuery(document).ready( function (){
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
if ($dom.find('input[type=radio]:checked').length >= 1) {
|
||||
default_value = $dom.find('input[type=radio]:checked').val();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'checkbox':
|
||||
|
||||
if ($dom.find('input[type=checkbox]:checked').length >= 1) {
|
||||
@@ -42,14 +47,7 @@ jQuery(document).ready( function (){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($dom.find('input[type=radio]:checked').length >= 1) {
|
||||
default_value = $dom.find('input[type=radio]:checked').val();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
return {type: type, value: default_value};
|
||||
@@ -200,7 +198,6 @@ jQuery(document).ready( function (){
|
||||
*/
|
||||
function um_apply_conditions($dom, is_single_update) {
|
||||
var operators = ['empty', 'not empty', 'equals to', 'not equals', 'greater than', 'less than', 'contains'];
|
||||
|
||||
var key = $dom.parents('.um-field[data-key]').data('key');
|
||||
|
||||
var conditions = um_field_conditions[key];
|
||||
@@ -306,13 +303,13 @@ jQuery(document).ready( function (){
|
||||
* Restores default field value
|
||||
* @param object $dom
|
||||
*/
|
||||
function um_field_restore_default_value($dom) {
|
||||
um_field_default_values
|
||||
function um_field_restore_default_value( $dom ) {
|
||||
//um_field_default_values
|
||||
|
||||
var type = um_get_field_type($dom);
|
||||
var type = um_get_field_type( $dom );
|
||||
var key = $dom.data('key');
|
||||
var field = um_field_default_values[key];
|
||||
switch (type) {
|
||||
switch ( type ) {
|
||||
|
||||
case 'text':
|
||||
case 'number':
|
||||
@@ -335,10 +332,9 @@ jQuery(document).ready( function (){
|
||||
$dom.find('select').trigger('change');
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
|
||||
if ($dom.find('input[type=checkbox]:checked').length >= 1) {
|
||||
if ( $dom.find('input[type=checkbox]:checked').length >= 1 ) {
|
||||
|
||||
$dom.find('input[type=checkbox]:checked').removeAttr('checked');
|
||||
$dom.find('span.um-field-checkbox-state i').removeClass('um-icon-android-checkbox-outline');
|
||||
@@ -363,7 +359,10 @@ jQuery(document).ready( function (){
|
||||
|
||||
}
|
||||
|
||||
if ($dom.find('input[type=radio]:checked').length >= 1) {
|
||||
break;
|
||||
case 'radio':
|
||||
|
||||
if ( $dom.find('input[type=radio]:checked').length >= 1 ) {
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
@@ -382,17 +381,22 @@ jQuery(document).ready( function (){
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
} // end switch type
|
||||
|
||||
if (!$dom.hasClass('um-field-has-changed')) {
|
||||
var me = um_get_field_element($dom);
|
||||
if (me) {
|
||||
me.trigger('change');
|
||||
$dom.addClass('um-field-has-changed');
|
||||
|
||||
if ( ! $dom.hasClass( 'um-field-has-changed' ) ) {
|
||||
var me = um_get_field_element( $dom );
|
||||
|
||||
if ( type == 'radio' ) {
|
||||
me = me.find( ':checked' );
|
||||
}
|
||||
|
||||
if ( me ) {
|
||||
me.trigger( 'change' );
|
||||
$dom.addClass( 'um-field-has-changed' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,21 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
|
||||
}
|
||||
closedir( $handle );
|
||||
|
||||
sort( $update_versions );
|
||||
usort( $update_versions, array( &$this, 'version_compare_sort' ) );
|
||||
|
||||
$this->update_versions = $update_versions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort versions by version compare function
|
||||
* @param $a
|
||||
* @param $b
|
||||
* @return mixed
|
||||
*/
|
||||
function version_compare_sort( $a, $b ) {
|
||||
return version_compare( $a, $b );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -553,70 +553,54 @@ if ( ! class_exists( 'Fields' ) ) {
|
||||
* @param array $data
|
||||
* @return boolean
|
||||
*/
|
||||
function is_radio_checked($key, $value, $data){
|
||||
if ( isset( UM()->form()->post_form[$key] ) && is_array( UM()->form()->post_form[$key] ) ) {
|
||||
|
||||
if ( in_array( $value, UM()->form()->post_form[$key] ) ){
|
||||
function is_radio_checked( $key, $value, $data ) {
|
||||
if ( isset( UM()->form()->post_form[$key] ) ) {
|
||||
if ( is_array( UM()->form()->post_form[$key] ) && in_array( $value, UM()->form()->post_form[$key] ) ) {
|
||||
return true;
|
||||
} elseif ( $value == UM()->form()->post_form[$key] ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( um_user( $key ) && $this->editing == true ) {
|
||||
|
||||
if ( ! isset( UM()->form()->post_form[$key] ) ) {
|
||||
|
||||
if ( um_user( $key ) && $this->editing == true ) {
|
||||
|
||||
if ( strstr( $key, 'role_' ) ) {
|
||||
$key = 'role';
|
||||
}
|
||||
|
||||
$um_user_value = um_user( $key );
|
||||
|
||||
if ( $key == 'role' ) {
|
||||
$um_user_value = strtolower( $um_user_value );
|
||||
|
||||
$role_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $role_keys ) ) {
|
||||
if ( in_array( $um_user_value, $role_keys ) ) {
|
||||
$um_user_value = 'um_' . $um_user_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $um_user_value == $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_array( $um_user_value ) ){
|
||||
foreach( $um_user_value as $u) {
|
||||
if( $u == html_entity_decode( $value ) ){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if ( isset($data['default']) && $data['default'] == $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( strstr( $key, 'role_' ) ) {
|
||||
$key = 'role';
|
||||
}
|
||||
|
||||
} else {
|
||||
$um_user_value = um_user( $key );
|
||||
|
||||
if ( $value == UM()->form()->post_form[$key] ) {
|
||||
if ( $key == 'role' ) {
|
||||
$um_user_value = strtolower( $um_user_value );
|
||||
|
||||
$role_keys = get_option( 'um_roles' );
|
||||
|
||||
if ( ! empty( $role_keys ) ) {
|
||||
if ( in_array( $um_user_value, $role_keys ) ) {
|
||||
$um_user_value = 'um_' . $um_user_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $um_user_value == $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if ( is_array( $um_user_value ) && in_array( $value, $um_user_value ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_array( $um_user_value ) ) {
|
||||
foreach ( $um_user_value as $u ) {
|
||||
if ( $u == html_entity_decode( $value ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} elseif ( isset( $data['default'] ) && $data['default'] == $value ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -2099,7 +2083,7 @@ if ( ! class_exists( 'Fields' ) ) {
|
||||
$col_class = '';
|
||||
}
|
||||
|
||||
if ( $this->is_radio_checked($key, $option_value, $data) ) {
|
||||
if ( $this->is_radio_checked( $key, $option_value, $data ) ) {
|
||||
$active = 'active';
|
||||
$class = "um-icon-android-radio-button-on";
|
||||
} else {
|
||||
@@ -2111,8 +2095,6 @@ if ( ! class_exists( 'Fields' ) ) {
|
||||
$col_class .= " um-field-radio-state-disabled";
|
||||
}
|
||||
|
||||
|
||||
|
||||
$output .= '<label class="um-field-radio '.$active.' um-field-half '.$col_class.'">';
|
||||
|
||||
$option_value = apply_filters('um_field_non_utf8_value',$option_value );
|
||||
|
||||
Reference in New Issue
Block a user