mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 14:13:46 +09:00
- prepared for 2.4.0 release;
This commit is contained in:
@@ -144,6 +144,20 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$fields[ $id ] = $args;
|
||||
|
||||
if ( array_key_exists( 'custom_dropdown_options_source', $args ) && function_exists( $args['custom_dropdown_options_source'] ) ) {
|
||||
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
||||
if ( ! empty( $allowed_callbacks ) ) {
|
||||
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
||||
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
||||
} else {
|
||||
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
||||
}
|
||||
$allowed_callbacks = array_unique( $allowed_callbacks );
|
||||
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
||||
|
||||
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
||||
}
|
||||
|
||||
unset( $fields[ $id ]['in_row'] );
|
||||
unset( $fields[ $id ]['in_sub_row'] );
|
||||
unset( $fields[ $id ]['in_column'] );
|
||||
@@ -185,6 +199,20 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
$fields[ $id ] = $args;
|
||||
|
||||
if ( array_key_exists( 'custom_dropdown_options_source', $args ) && function_exists( $args['custom_dropdown_options_source'] ) ) {
|
||||
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
||||
if ( ! empty( $allowed_callbacks ) ) {
|
||||
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
||||
$allowed_callbacks[] = $args['custom_dropdown_options_source'];
|
||||
} else {
|
||||
$allowed_callbacks = array( $args['custom_dropdown_options_source'] );
|
||||
}
|
||||
$allowed_callbacks = array_unique( $allowed_callbacks );
|
||||
$allowed_callbacks = implode( "\r\n", $allowed_callbacks );
|
||||
|
||||
UM()->options()->update( 'allowed_choice_callbacks', $allowed_callbacks );
|
||||
}
|
||||
|
||||
// for group field only
|
||||
if ( $args['type'] == 'group' ) {
|
||||
$fields[ $id ]['in_group'] = '';
|
||||
|
||||
@@ -114,6 +114,39 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
$arr_options['status'] = 'success';
|
||||
$arr_options['post'] = $_POST;
|
||||
|
||||
// Callback validation
|
||||
if ( empty( $_POST['child_callback'] ) ) {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
}
|
||||
|
||||
$ajax_source_func = sanitize_text_field( $_POST['child_callback'] );
|
||||
|
||||
if ( ! function_exists( $ajax_source_func ) ) {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'Wrong callback.', 'ultimate-member' );
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
}
|
||||
|
||||
$allowed_callbacks = UM()->options()->get( 'allowed_choice_callbacks' );
|
||||
if ( empty( $allowed_callbacks ) ) {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
||||
wp_send_json( $arr_options );
|
||||
}
|
||||
|
||||
$allowed_callbacks = array_map( 'rtrim', explode( "\n", $allowed_callbacks ) );
|
||||
|
||||
if ( ! in_array( $ajax_source_func, $allowed_callbacks, true ) ) {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
}
|
||||
|
||||
if ( isset( $_POST['form_id'] ) ) {
|
||||
UM()->fields()->set_id = absint( $_POST['form_id'] );
|
||||
}
|
||||
@@ -122,37 +155,34 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
$arr_options['fields'] = $form_fields;
|
||||
|
||||
if ( isset( $arr_options['post']['members_directory'] ) && 'yes' === $arr_options['post']['members_directory'] ) {
|
||||
$ajax_source_func = $_POST['child_callback'];
|
||||
if ( function_exists( $ajax_source_func ) ) {
|
||||
global $wpdb;
|
||||
global $wpdb;
|
||||
|
||||
$values_array = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT DISTINCT meta_value
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = %s AND
|
||||
meta_value != ''",
|
||||
$arr_options['post']['child_name']
|
||||
)
|
||||
);
|
||||
$values_array = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT DISTINCT meta_value
|
||||
FROM $wpdb->usermeta
|
||||
WHERE meta_key = %s AND
|
||||
meta_value != ''",
|
||||
$arr_options['post']['child_name']
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $values_array ) ) {
|
||||
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
|
||||
if ( ! empty( $values_array ) ) {
|
||||
$parent_dropdown = isset( $arr_options['field']['parent_dropdown_relationship'] ) ? $arr_options['field']['parent_dropdown_relationship'] : '';
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $parent_dropdown );
|
||||
|
||||
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
|
||||
// array with dropdown items is associative
|
||||
$arr_options['items'] = array_intersect_key( array_map( 'trim', $arr_options['items'] ), array_flip( $values_array ) );
|
||||
} else {
|
||||
// array with dropdown items has sequential numeric keys, starting from 0 and there are intersected values with $values_array
|
||||
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
||||
}
|
||||
if ( array_keys( $arr_options['items'] ) !== range( 0, count( $arr_options['items'] ) - 1 ) ) {
|
||||
// array with dropdown items is associative
|
||||
$arr_options['items'] = array_intersect_key( array_map( 'trim', $arr_options['items'] ), array_flip( $values_array ) );
|
||||
} else {
|
||||
$arr_options['items'] = array();
|
||||
// array with dropdown items has sequential numeric keys, starting from 0 and there are intersected values with $values_array
|
||||
$arr_options['items'] = array_intersect( $arr_options['items'], $values_array );
|
||||
}
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
} else {
|
||||
$arr_options['items'] = array();
|
||||
}
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
} else {
|
||||
/**
|
||||
* UM hook
|
||||
@@ -184,9 +214,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST['child_callback'] ) && isset( $form_fields[ $_POST['child_name'] ] ) ) {
|
||||
|
||||
$ajax_source_func = $_POST['child_callback'];
|
||||
|
||||
// If the requested callback function is added in the form or added in the field option, execute it with call_user_func.
|
||||
if ( isset( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
||||
! empty( $form_fields[ $_POST['child_name'] ]['custom_dropdown_options_source'] ) &&
|
||||
@@ -194,9 +221,7 @@ if ( ! class_exists( 'um\core\Form' ) ) {
|
||||
|
||||
$arr_options['field'] = $form_fields[ $_POST['child_name'] ];
|
||||
|
||||
if ( function_exists( $ajax_source_func ) ) {
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
||||
}
|
||||
$arr_options['items'] = call_user_func( $ajax_source_func, $arr_options['field']['parent_dropdown_relationship'] );
|
||||
} else {
|
||||
$arr_options['status'] = 'error';
|
||||
$arr_options['message'] = __( 'This is not possible for security reasons.', 'ultimate-member' );
|
||||
|
||||
@@ -422,6 +422,15 @@ if ( ! class_exists( 'um\core\Profile' ) ) {
|
||||
$data['in_profile_meta'] = true;
|
||||
|
||||
$value = um_filtered_value( $key, $data );
|
||||
if ( 'description' === $key ) {
|
||||
if ( UM()->options()->get( 'profile_show_html_bio' ) ) {
|
||||
$res = make_clickable( wpautop( wp_kses_post( $value ) ) );
|
||||
} else {
|
||||
$res = esc_html( $value );
|
||||
}
|
||||
|
||||
$value = nl2br( $res );
|
||||
}
|
||||
if ( ! $value && ( ! array_key_exists( 'type', $data ) || ! in_array( $data['type'], $fields_without_metakey ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -357,15 +357,17 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
function um_loggedin( $args = array(), $content = "" ) {
|
||||
ob_start();
|
||||
|
||||
$defaults = array(
|
||||
'lock_text' => __( 'This content has been restricted to logged in users only. Please <a href="{login_referrer}">login</a> to view this content.', 'ultimate-member' ),
|
||||
'show_lock' => 'yes',
|
||||
$args = shortcode_atts(
|
||||
array(
|
||||
'lock_text' => __( 'This content has been restricted to logged in users only. Please <a href="{login_referrer}">login</a> to view this content.', 'ultimate-member' ),
|
||||
'show_lock' => 'yes',
|
||||
),
|
||||
$args,
|
||||
'um_loggedin'
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
if ( ! is_user_logged_in() ) {
|
||||
if ( $args['show_lock'] == 'no' ) {
|
||||
if ( 'no' === $args['show_lock'] ) {
|
||||
echo '';
|
||||
} else {
|
||||
$args['lock_text'] = $this->convert_locker_tags( $args['lock_text'] );
|
||||
@@ -380,7 +382,7 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
|
||||
}
|
||||
|
||||
$output = ob_get_clean();
|
||||
|
||||
|
||||
return htmlspecialchars_decode( $output, ENT_NOQUOTES );
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ function um_profile_field_filter_hook__( $value, $data, $type = '' ) {
|
||||
$value = str_replace('http://https://','https://',$value);
|
||||
|
||||
$onclick_alert = '';
|
||||
if ( $value !== wp_validate_redirect( $value ) ) {
|
||||
if ( UM()->options()->get( 'allow_url_redirect_confirm' ) && $value !== wp_validate_redirect( $value ) ) {
|
||||
$onclick_alert = ' onclick="return confirm( \'' . sprintf( __( 'This link leads to a 3rd-party website. Make sure the link is safe and you really want to go to this website: `%s`', 'ultimate-member' ), $value ) . '\' );"';
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ if ( ! is_admin() ) {
|
||||
* @return array
|
||||
*/
|
||||
function um_add_custom_message_to_menu( $sorted_menu_items, $args ) {
|
||||
if ( empty( $sorted_menu_items ) ) {
|
||||
return $sorted_menu_items;
|
||||
}
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
um_fetch_user( get_current_user_id() );
|
||||
|
||||
Reference in New Issue
Block a user