- code review;

This commit is contained in:
nikitasinelnikov
2019-07-16 14:35:57 +03:00
parent 77a98acc2f
commit b5f4cd723e
3 changed files with 48 additions and 47 deletions
+12 -12
View File
@@ -215,8 +215,8 @@ function um_user_edit_profile( $args ) {
*/
do_action( 'um_user_before_updating_profile', $userinfo );
if ( !empty( $args[ 'custom_fields' ] ) ) {
$fields = apply_filters( 'um_user_edit_profile_fields', unserialize( $args[ 'custom_fields' ] ), $args );
if ( ! empty( $args['custom_fields'] ) ) {
$fields = apply_filters( 'um_user_edit_profile_fields', unserialize( $args['custom_fields'] ), $args );
}
// loop through fields
@@ -251,19 +251,19 @@ function um_user_edit_profile( $args ) {
* Returns dropdown/multi-select options keys from a callback function
* @since 2019-05-30
*/
$has_custom_source = apply_filters("um_has_dropdown_options_source__{$key}", false );
if ( isset( $array[ 'options' ] ) && in_array( $array[ 'type' ], array( 'select', 'multiselect' ) ) ) {
if ( !empty( $array[ 'custom_dropdown_options_source' ] ) && function_exists( $array[ 'custom_dropdown_options_source' ] ) && ! $has_custom_source ) {
$options = call_user_func( $array[ 'custom_dropdown_options_source' ], $array[ 'options' ] );
if( is_array( $options ) ){
$array[ 'options' ] = apply_filters("um_custom_dropdown_options__{$key}", array_keys( $options ) );
$has_custom_source = apply_filters( "um_has_dropdown_options_source__{$key}", false );
if ( isset( $array['options'] ) && in_array( $array['type'], array( 'select', 'multiselect' ) ) ) {
$options = array();
if ( ! empty( $array['custom_dropdown_options_source'] ) && function_exists( $array['custom_dropdown_options_source'] ) && ! $has_custom_source ) {
$callback_result = call_user_func( $array['custom_dropdown_options_source'], $array['options'] );
if ( is_array( $callback_result ) ) {
$options = array_keys( $callback_result );
}
}else{
$array[ 'options' ] = apply_filters("um_custom_dropdown_options__{$key}", array() );
}
$array['options'] = apply_filters( "um_custom_dropdown_options__{$key}", $options );
}