- fixed custom callback member directories filters with child dropdown filters;

This commit is contained in:
Mykyta Synelnikov
2023-10-13 15:35:39 +03:00
parent 217bfe819b
commit 3ccb9cf619
5 changed files with 24 additions and 15 deletions
+2 -4
View File
@@ -1465,11 +1465,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
*
* @return array $arr_options
*/
function get_options_from_callback( $data, $type ) {
public function get_options_from_callback( $data, $type ) {
$arr_options = array();
if ( in_array( $type, array( 'select', 'multiselect' ) ) && ! empty( $data['custom_dropdown_options_source'] ) ) {
if ( ! empty( $data['custom_dropdown_options_source'] ) && in_array( $type, array( 'select', 'multiselect' ), true ) ) {
if ( $this->is_source_blacklisted( $data['custom_dropdown_options_source'] ) ) {
return $arr_options;
}
@@ -1481,7 +1480,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
$arr_options = call_user_func( $data['custom_dropdown_options_source'] );
}
}
}
return $arr_options;
+1 -1
View File
@@ -181,7 +181,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
);
if ( ! empty( $values_array ) ) {
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
$parent_dropdown = isset( $arr_options['post']['parent_option_name'] ) ? $arr_options['post']['parent_option_name'] : '';
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
+4 -4
View File
@@ -641,9 +641,9 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$values_array = ( ! empty( $users_roles['avail_roles'] ) && is_array( $users_roles['avail_roles'] ) ) ? array_keys( array_filter( $users_roles['avail_roles'] ) ) : array();
}
if ( ! empty( $values_array ) && in_array( $attrs['type'], array( 'select', 'multiselect', 'checkbox', 'radio' ) ) ) {
if ( ! empty( $values_array ) && in_array( $attrs['type'], array( 'select', 'multiselect', 'checkbox', 'radio' ), true ) ) {
$values_array = array_map( 'maybe_unserialize', $values_array );
$temp_values = array();
$temp_values = array();
foreach ( $values_array as $values ) {
if ( is_array( $values ) ) {
$temp_values = array_merge( $temp_values, $values );
@@ -654,7 +654,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$values_array = array_unique( $temp_values );
}
if ( $attrs['metakey'] != 'online_status' && empty( $values_array ) ) {
if ( 'online_status' !== $attrs['metakey'] && empty( $values_array ) ) {
ob_get_clean();
return '';
}
@@ -721,7 +721,7 @@ if ( ! class_exists( 'um\core\Member_Directory' ) ) {
$attrs['options'] = apply_filters( 'um_member_directory_filter_select_options', $attrs['options'], $values_array, $attrs );
if ( empty( $attrs['options'] ) || ! is_array( $attrs['options'] ) ) {
if ( ( empty( $attrs['options'] ) || ! is_array( $attrs['options'] ) ) && ! ( ! empty( $attrs['custom_dropdown_options_source'] ) && ! empty( $attrs['parent_dropdown_relationship'] ) ) ) {
ob_get_clean();
return '';
}