mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-17 21:53:43 +09:00
- fixed select-type filters options;
This commit is contained in:
@@ -1150,15 +1150,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
|
||||
* @return boolean
|
||||
*/
|
||||
public function skip_field_validation( $skip, $post_input, $array ) {
|
||||
|
||||
if ( $post_input === '_options' && isset( $array['post']['_custom_dropdown_options_source'] ) ) {
|
||||
$um_callback_func = $array['post']['_custom_dropdown_options_source'];
|
||||
$skip = function_exists( $um_callback_func );
|
||||
$skip = function_exists( $array['post']['_custom_dropdown_options_source'] );
|
||||
}
|
||||
|
||||
return $skip;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves dropdown/multi-select options from a callback function
|
||||
|
||||
@@ -1124,11 +1124,14 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$arr_options = $opts['options'];
|
||||
|
||||
} elseif ( function_exists( $data['custom_dropdown_options_source'] ) ) {
|
||||
if ( isset( $data['parent_dropdown_relationship'] ) ) {
|
||||
$_POST['parent_option_name'] = $data['parent_dropdown_relationship'];
|
||||
$_POST['parent_option'] = um_user( $data['parent_dropdown_relationship'] );
|
||||
|
||||
$arr_options = call_user_func(
|
||||
$data['custom_dropdown_options_source'],
|
||||
( ! empty( $data['parent_dropdown_relationship'] ) ? $data['parent_dropdown_relationship'] : '' )
|
||||
);
|
||||
$arr_options = call_user_func( $data['custom_dropdown_options_source'], $data['parent_dropdown_relationship'] );
|
||||
} else {
|
||||
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $has_custom_source || function_exists( $data['custom_dropdown_options_source'] ) ) {
|
||||
@@ -2783,8 +2786,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
||||
$atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
||||
// todo maybe deprecate
|
||||
// $ajax_source_url = apply_filters( "um_custom_dropdown_options_source_url__{$form_key}", admin_url( 'admin-ajax.php' ), $data );
|
||||
// $atts_ajax .= ' data-um-ajax-url="' . esc_url( $ajax_source_url ) . '" ';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -524,11 +524,25 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
if ( ! empty( $attrs['custom_dropdown_options_source'] ) ) {
|
||||
$attrs['custom'] = true;
|
||||
$attrs['options'] = UM()->fields()->get_options_from_callback( $attrs, $attrs['type'] );
|
||||
$custom_dropdown = ' data-um-ajax-source="' . esc_attr( $attrs['custom_dropdown_options_source'] ) . '"';
|
||||
|
||||
if ( ! empty( $attrs['parent_dropdown_relationship'] ) ) {
|
||||
$custom_dropdown .= ' data-member-directory="yes"';
|
||||
$custom_dropdown .= ' data-um-parent="' . esc_attr( $attrs['parent_dropdown_relationship'] ) . '"';
|
||||
|
||||
if ( isset( $_GET[ 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ] ) ) {
|
||||
$_POST['parent_option_name'] = $attrs['parent_dropdown_relationship'];
|
||||
$_POST['parent_option'] = explode( '||', filter_input( INPUT_GET, 'filter_' . $attrs['parent_dropdown_relationship'] . '_' . $unique_hash ) );
|
||||
}
|
||||
}
|
||||
|
||||
$ajax_source = apply_filters( "um_custom_dropdown_options_source__{$filter}", $attrs['custom_dropdown_options_source'], $attrs );
|
||||
$custom_dropdown .= ' data-um-ajax-source="' . esc_attr( $ajax_source ) . '" ';
|
||||
}
|
||||
|
||||
if ( $attrs['metakey'] != 'role_select' ) {
|
||||
if ( $attrs['metakey'] != 'role_select' && empty( $custom_dropdown ) ) {
|
||||
$attrs['options'] = array_intersect( $attrs['options'], $values_array );
|
||||
} elseif ( ! empty( $custom_dropdown ) ) {
|
||||
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
|
||||
} else {
|
||||
$attrs['options'] = array_intersect_key( $attrs['options'], array_flip( $values_array ) );
|
||||
}
|
||||
@@ -545,7 +559,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
asort( $attrs['options'] ); ?>
|
||||
|
||||
<select class="um-s1" id="<?php echo $filter; ?>" name="<?php echo $filter; ?>"
|
||||
<select class="um-s1" id="<?php echo esc_attr( $filter ); ?>" name="<?php echo esc_attr( $filter ); ?>"
|
||||
data-placeholder="<?php esc_attr_e( stripslashes( $attrs['label'] ), 'ultimate-member' ); ?>"
|
||||
<?php echo $custom_dropdown; ?>>
|
||||
|
||||
@@ -568,7 +582,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
|
||||
|
||||
<option value="<?php echo esc_attr( $opt ); ?>" data-value_label="<?php esc_attr_e( $v, 'ultimate-member' ); ?>"
|
||||
<?php disabled( ! empty( $filter_from_url ) && in_array( $opt, $filter_from_url ) ) ?>
|
||||
<?php selected( $opt == $default_value ) ?>>
|
||||
<?php selected( $opt === $default_value ) ?>>
|
||||
<?php _e( $v, 'ultimate-member' ); ?>
|
||||
</option>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user