mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-19 14:43:49 +09:00
Merge branch 'master' of https://github.com/ultimatemember/ultimatemember into fix/password_field
This commit is contained in:
@@ -524,14 +524,15 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
*/
|
||||
function get_post_privacy_settings( $post ) {
|
||||
//if logged in administrator all pages are visible
|
||||
if ( current_user_can( 'administrator' ) )
|
||||
if ( current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//exlude from privacy UM default pages (except Members list and User(Profile) page)
|
||||
if ( ! empty( $post->post_type ) && $post->post_type == 'page' ) {
|
||||
if ( um_is_core_post( $post, 'login' ) || um_is_core_post( $post, 'register' ) ||
|
||||
um_is_core_post( $post, 'account' ) || um_is_core_post( $post, 'logout' ) ||
|
||||
um_is_core_post( $post, 'password-reset' ) )
|
||||
um_is_core_post( $post, 'password-reset' ) || um_is_core_post( $post, 'user' ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -541,7 +542,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
|
||||
|
||||
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
|
||||
if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] )
|
||||
if ( ! isset( $restriction['_um_accessible'] ) )
|
||||
return false;
|
||||
else
|
||||
return $restriction;
|
||||
@@ -624,6 +625,7 @@ if ( ! class_exists( 'um\core\Access' ) ) {
|
||||
|
||||
//post is private
|
||||
if ( '0' == $restriction['_um_accessible'] ) {
|
||||
$this->singular_page = true;
|
||||
$filtered_posts[] = $post;
|
||||
continue;
|
||||
} elseif ( '1' == $restriction['_um_accessible'] ) {
|
||||
|
||||
@@ -463,7 +463,7 @@ if ( ! class_exists( 'um\core\Enqueue' ) ) {
|
||||
wp_register_script('um_responsive', um_url . 'assets/js/um-responsive' . $this->suffix . '.js' );
|
||||
wp_enqueue_script('um_responsive');
|
||||
|
||||
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css' );
|
||||
wp_register_style('um_responsive', um_url . 'assets/css/um-responsive.css', array( 'um_profile' ) );
|
||||
wp_enqueue_style('um_responsive');
|
||||
|
||||
}
|
||||
|
||||
@@ -43,9 +43,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
<div class="um-field um-field-c">
|
||||
<div class="um-field-area">
|
||||
<label class="um-field-checkbox active">
|
||||
<input type="checkbox" name="<?php echo $id; ?>" value="1" checked/><span
|
||||
class="um-field-checkbox-state"><i
|
||||
class="um-icon-android-checkbox-outline"></i></span>
|
||||
<input type="checkbox" name="<?php echo $id; ?>" value="1" checked/>
|
||||
<span class="um-field-checkbox-state"><i class="um-icon-android-checkbox-outline"></i></span>
|
||||
<span class="um-field-checkbox-option"> <?php echo $title; ?></span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -800,6 +799,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$stripslashed = array_map( 'stripslashes', UM()->form()->post_form[ $key ] );
|
||||
if ( in_array( $value, $stripslashed ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( in_array( html_entity_decode( $value ), UM()->form()->post_form[ $key ] ) ) {
|
||||
return true;
|
||||
}
|
||||
@@ -1530,10 +1534,11 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @param string $key
|
||||
* @param array $data
|
||||
* @param boolean $rule
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function edit_field( $key, $data, $rule = false ) {
|
||||
function edit_field( $key, $data, $rule = false, $args = array() ) {
|
||||
global $_um_profile_id;
|
||||
$output = null;
|
||||
$disabled = '';
|
||||
@@ -1567,7 +1572,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* @var boolean $required
|
||||
* @var string $validate
|
||||
* @var string $default
|
||||
* @var string $conditional
|
||||
* @var string $conditional
|
||||
*/
|
||||
extract( $data );
|
||||
}
|
||||
@@ -1579,7 +1584,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
if ($visibility == 'view' && $this->set_mode != 'register') return;
|
||||
|
||||
if (( $visibility == 'view' && $this->set_mode == 'register' ) ||
|
||||
if ( ( $visibility == 'view' && $this->set_mode == 'register' ) ||
|
||||
( isset( $data['editable'] ) && $data['editable'] == 0 && $this->set_mode == 'profile' )
|
||||
) {
|
||||
|
||||
@@ -1663,7 +1668,47 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
* ?>
|
||||
*/
|
||||
$type = apply_filters( "um_hook_for_field_{$type}", $type );
|
||||
switch ( $type ) {
|
||||
|
||||
case 'textarea':
|
||||
case 'multiselect':
|
||||
$field_id = $field_name = $key;
|
||||
$field_value = $this->field_value( $key, $default, $data );
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
case 'radio':
|
||||
$form_key = str_replace( 'role_select', 'role', $key );
|
||||
$field_id = $form_key;
|
||||
break;
|
||||
default:
|
||||
$field_id = '';
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_completeness_field_id
|
||||
* @description use for change core id not allowed duplicate
|
||||
* @input_vars
|
||||
* [{"var":"$field_id","type":"string","desc":"Field id"},
|
||||
* {"var":"$data","type":"array","desc":"Field Data"}]
|
||||
* {"var":"$args","type":"array","desc":"Optional field arguments"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0.13"]
|
||||
* @usage add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_completeness_field_id', 'function_name', 10, 3 );
|
||||
* function function_name( $field_id, $data, $args ) {
|
||||
* // your code here
|
||||
* return $field_id;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$field_id = apply_filters( 'um_completeness_field_id', $field_id, $data, $args );
|
||||
/* Begin by field type */
|
||||
switch ( $type ) {
|
||||
|
||||
@@ -1722,8 +1767,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
|
||||
</div>';
|
||||
|
||||
if (!empty( $disabled )) {
|
||||
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
||||
if (!empty( $disabled )) {
|
||||
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
||||
}
|
||||
|
||||
if ($this->is_error( $key )) {
|
||||
@@ -2033,8 +2078,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
$output .= '<div class="um-field-area">';
|
||||
$field_name = $key;
|
||||
$field_value = $this->field_value( $key, $default, $data );
|
||||
|
||||
if (isset( $data['html'] ) && $data['html'] != 0 && $key != "description") {
|
||||
|
||||
@@ -2085,16 +2128,17 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
// add the contents of the buffer to the output variable
|
||||
$output .= ob_get_clean();
|
||||
|
||||
} else $output .= '<textarea ' . $disabled . ' style="height: ' . $height . ';" class="' . $this->get_class( $key, $data ) . '" name="' . $key . '" id="' . $key . '" placeholder="' . $placeholder . '">' . $field_value . '</textarea>';
|
||||
} else {
|
||||
$output .= '<textarea ' . $disabled . ' style="height: ' . $height . ';" class="' . $this->get_class( $key, $data ) . '" name="' . $field_name . '" id="' . $field_id . '" placeholder="' . $placeholder . '">' . $field_value . '</textarea>';
|
||||
}
|
||||
|
||||
$output .= '
|
||||
</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
if (!empty( $disabled )) {
|
||||
if ( ! empty( $disabled ) ) {
|
||||
$output .= $this->disabled_hidden_field( $field_name, $field_value );
|
||||
}
|
||||
|
||||
if ($this->is_error( $key )) {
|
||||
if ( $this->is_error( $key ) ) {
|
||||
$output .= $this->field_error( $this->show_error( $key ) );
|
||||
}
|
||||
|
||||
@@ -2112,7 +2156,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= '<div class="um-field-area">';
|
||||
|
||||
$output .= '<div class="um-rating um-raty" id="' . $key . '" data-key="' . $key . '" data-number="' . $data['number'] . '" data-score="' . $this->field_value( $key, $default, $data ) . '"></div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '</div>';
|
||||
@@ -2314,8 +2357,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
/* Select dropdown */
|
||||
case 'select':
|
||||
|
||||
$form_key = str_replace( 'role_select', 'role', $key );
|
||||
|
||||
$output .= '<div class="um-field' . $classes . '"' . $conditional . ' data-key="' . $key . '">';
|
||||
|
||||
|
||||
@@ -2435,10 +2476,10 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
}
|
||||
|
||||
if( ! empty( $placeholder ) ) {
|
||||
$placeholder = strip_tags( $placeholder );
|
||||
}
|
||||
$placeholder = strip_tags( $placeholder );
|
||||
}
|
||||
|
||||
$output .= '<select ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . $form_key . '" id="' . $form_key . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . $placeholder . '" ' . $atts_ajax . '>';
|
||||
$output .= '<select ' . $disabled . ' ' . $select_original_option_value . ' ' . $disabled_by_parent_option . ' name="' . $form_key . '" id="' . $field_id . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . '" style="width: 100%" data-placeholder="' . $placeholder . '" ' . $atts_ajax . '>';
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
@@ -2632,7 +2673,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
$output .= '<div class="um-field-icon"><i class="' . $icon . '"></i></div>';
|
||||
}
|
||||
|
||||
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . $key . '[]" id="' . $key . '" data-maxsize="' . $max_selections . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
|
||||
$output .= '<select ' . $disabled . ' multiple="multiple" name="' . $field_name . '[]" id="' . $field_id . '" data-maxsize="' . $max_selections . '" data-validate="' . $validate . '" data-key="' . $key . '" class="' . $this->get_class( $key, $data, $class ) . ' um-user-keyword_' . $use_keyword . '" style="width: 100%" data-placeholder="' . $placeholder . '">';
|
||||
|
||||
|
||||
if ( isset( $options ) && $options == 'builtin' ) {
|
||||
@@ -2769,8 +2810,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) {
|
||||
/* Radio */
|
||||
case 'radio':
|
||||
|
||||
$form_key = str_replace( 'role_radio', 'role', $key );
|
||||
|
||||
if ( isset( $options ) ) {
|
||||
/**
|
||||
* UM hook
|
||||
|
||||
@@ -136,22 +136,15 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
$um_port_forwarding_url = UM()->options()->get( 'um_port_forwarding_url' );
|
||||
$um_port_forwarding_url = ! empty( $um_port_forwarding_url ) ? $um_port_forwarding_url : '';
|
||||
|
||||
$page_url = '';
|
||||
if ( is_multisite() ) {
|
||||
|
||||
$page_url = '';
|
||||
$blog_id = get_current_blog_id();
|
||||
$siteurl = get_site_url( $blog_id );
|
||||
|
||||
$network_permalink_structure = UM()->options()->get( 'network_permalink_structure' );
|
||||
|
||||
if( $network_permalink_structure == "sub-directory" ){
|
||||
if ( is_ssl() ) {
|
||||
$page_url = 'https';
|
||||
} else {
|
||||
$page_url = 'http';
|
||||
}
|
||||
$page_url .= "://";
|
||||
|
||||
$page_url .= "//";
|
||||
$page_url .= $_SERVER[ $server_name_method ];
|
||||
}else{
|
||||
$page_url .= $siteurl;
|
||||
@@ -159,7 +152,6 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
|
||||
if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) {
|
||||
$page_url .= ":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
|
||||
} else {
|
||||
$page_url .= $_SERVER["REQUEST_URI"];
|
||||
}
|
||||
@@ -168,13 +160,7 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
if ( !isset( $_SERVER['SERVER_NAME'] ) )
|
||||
return '';
|
||||
|
||||
|
||||
if ( is_ssl() ) {
|
||||
$page_url = 'https';
|
||||
} else {
|
||||
$page_url = 'http';
|
||||
}
|
||||
$page_url .= "://";
|
||||
$page_url .= "//";
|
||||
|
||||
if ( $um_port_forwarding_url == 1 && isset( $_SERVER["SERVER_PORT"] ) ) {
|
||||
$page_url .= $_SERVER[ $server_name_method ].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
||||
@@ -210,7 +196,7 @@ if ( ! class_exists( 'um\core\Permalinks' ) ) {
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
return apply_filters( 'um_get_current_page_url', $page_url );
|
||||
return apply_filters( 'um_get_current_page_url', set_url_scheme( $page_url ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -524,9 +524,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
|
||||
$val->first_name = um_user('first_name');
|
||||
$val->last_name = um_user('last_name');
|
||||
$val->account_status = um_user('account_status');
|
||||
$val->profile_pic_original = $this->getsrc( um_user('profile_photo', 'original') );
|
||||
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
|
||||
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
|
||||
$val->profile_pic_original = um_get_user_avatar_url('', 'original');
|
||||
$val->profile_pic_normal = um_get_user_avatar_url('', 200);
|
||||
$val->profile_pic_small = um_get_user_avatar_url('', 40);
|
||||
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
|
||||
|
||||
/**
|
||||
@@ -667,9 +667,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
|
||||
break;
|
||||
|
||||
case 'profile_pic':
|
||||
$response['profile_pic_original'] = $this->getsrc( um_user('profile_photo', 'original') );
|
||||
$response['profile_pic_normal'] = $this->getsrc( um_user('profile_photo', 200) );
|
||||
$response['profile_pic_small'] = $this->getsrc( um_user('profile_photo', 40) );
|
||||
$response['profile_pic_original'] = um_get_user_avatar_url('', 'original');
|
||||
$response['profile_pic_normal'] = um_get_user_avatar_url('', 200);
|
||||
$response['profile_pic_small'] = um_get_user_avatar_url('', 40);
|
||||
break;
|
||||
|
||||
case 'status':
|
||||
@@ -699,9 +699,9 @@ if ( ! class_exists( 'um\core\REST_API' ) ) {
|
||||
$val->first_name = um_user('first_name');
|
||||
$val->last_name = um_user('last_name');
|
||||
$val->account_status = um_user('account_status');
|
||||
$val->profile_pic_original = $this->getsrc( um_user('profile_photo', 'original') );
|
||||
$val->profile_pic_normal = $this->getsrc( um_user('profile_photo', 200) );
|
||||
$val->profile_pic_small = $this->getsrc( um_user('profile_photo', 40) );
|
||||
$val->profile_pic_original = um_get_user_avatar_url('', 'original');
|
||||
$val->profile_pic_normal = um_get_user_avatar_url('', 200);
|
||||
$val->profile_pic_small = um_get_user_avatar_url('', 40);
|
||||
$val->cover_photo = $this->getsrc( um_user('cover_photo', 1000) );
|
||||
|
||||
/**
|
||||
|
||||
@@ -506,13 +506,20 @@ if ( ! class_exists( 'um\core\Roles_Capabilities' ) ) {
|
||||
* @return mixed|void
|
||||
*/
|
||||
function role_data( $roleID ) {
|
||||
if ( strpos( $roleID, 'um_' ) === 0 )
|
||||
$roleID = substr( $roleID, 3 );
|
||||
if ( strpos( $roleID, 'um_' ) === 0 ) {
|
||||
$role_data = get_option( "um_role_{$roleID}_meta" );
|
||||
|
||||
$role_data = get_option( "um_role_{$roleID}_meta" );
|
||||
if ( ! $role_data ) {
|
||||
$roleID = substr( $roleID, 3 );
|
||||
$role_data = get_option( "um_role_{$roleID}_meta" );
|
||||
}
|
||||
} else {
|
||||
$role_data = get_option( "um_role_{$roleID}_meta" );
|
||||
}
|
||||
|
||||
if ( ! $role_data )
|
||||
if ( ! $role_data ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$temp = array();
|
||||
foreach ( $role_data as $key=>$value ) {
|
||||
|
||||
@@ -890,6 +890,20 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
unset( $submitted['confirm_user_password'] );
|
||||
}
|
||||
|
||||
//remove all password field values from submitted details
|
||||
$password_fields = array();
|
||||
foreach ( $submitted as $k => $v ) {
|
||||
if ( UM()->fields()->get_field_type( $k ) == 'password' ) {
|
||||
$password_fields[] = $k;
|
||||
$password_fields[] = 'confirm_' . $k;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $password_fields as $pw_field ) {
|
||||
unset( $submitted[ $pw_field ] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
|
||||
@@ -221,6 +221,9 @@ function um_user_edit_profile( $args ) {
|
||||
|
||||
foreach ( $fields as $key => $array ) {
|
||||
|
||||
/*if ( ! um_can_edit_field( $fields[ $key ] ) )
|
||||
continue;*/
|
||||
|
||||
if ( ! um_can_edit_field( $fields[ $key ] ) && isset( $fields[ $key ]['editable'] ) && ! $fields[ $key ]['editable'] )
|
||||
continue;
|
||||
|
||||
@@ -524,11 +527,7 @@ function um_profile_dynamic_meta_desc() {
|
||||
$user_id = um_user( 'ID' );
|
||||
$url = um_user_profile_url();
|
||||
|
||||
if (um_profile( 'profile_photo' )) {
|
||||
$avatar = um_user_uploads_uri() . um_profile( 'profile_photo' );
|
||||
} else {
|
||||
$avatar = um_get_default_avatar_uri();
|
||||
}
|
||||
$avatar = um_get_user_avatar_url( $user_id, 'original' );
|
||||
|
||||
um_reset_user(); ?>
|
||||
|
||||
|
||||
@@ -54,8 +54,9 @@ function um_after_insert_user( $user_id, $args ) {
|
||||
//clear Users cached queue
|
||||
UM()->user()->remove_cached_queue();
|
||||
|
||||
um_fetch_user( $user_id );
|
||||
UM()->user()->set_status( um_user('status') );
|
||||
if ( ! empty( $args['submitted'] ) ) {
|
||||
um_fetch_user( $user_id );
|
||||
UM()->user()->set_registration_details( $args['submitted'] );
|
||||
}
|
||||
|
||||
@@ -103,7 +104,7 @@ function um_after_insert_user( $user_id, $args ) {
|
||||
*/
|
||||
do_action( 'um_registration_complete', $user_id, $args );
|
||||
}
|
||||
add_action( 'um_user_register', 'um_after_insert_user', 10, 2 );
|
||||
add_action( 'um_user_register', 'um_after_insert_user', 1, 2 );
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,7 +119,7 @@ function um_send_registration_notification( $user_id, $args ) {
|
||||
$emails = um_multi_admin_email();
|
||||
if ( ! empty( $emails ) ) {
|
||||
foreach ( $emails as $email ) {
|
||||
if ( um_user( 'status' ) != 'pending' ) {
|
||||
if ( um_user( 'account_status' ) != 'pending' ) {
|
||||
UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
|
||||
} else {
|
||||
UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
|
||||
@@ -136,7 +137,7 @@ add_action( 'um_registration_complete', 'um_send_registration_notification', 10,
|
||||
* @param $args
|
||||
*/
|
||||
function um_check_user_status( $user_id, $args ) {
|
||||
$status = um_user( 'status' );
|
||||
$status = um_user( 'account_status' );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
|
||||
@@ -27,7 +27,6 @@ add_filter( 'avatar_defaults', 'um_avatar_defaults', 99999 );
|
||||
* @return string returns avatar in image html elements
|
||||
*/
|
||||
function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '' ) {
|
||||
|
||||
if ( is_numeric($id_or_email) )
|
||||
$user_id = (int) $id_or_email;
|
||||
elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) )
|
||||
@@ -41,64 +40,6 @@ function um_get_avatar( $avatar = '', $id_or_email='', $size = '96', $avatar_cla
|
||||
|
||||
$avatar = um_user('profile_photo', $size);
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_avatar_image_alternate_text
|
||||
* @description Change avatar image alt
|
||||
* @input_vars
|
||||
* [{"var":"$avatar_alt","type":"string","desc":"Image alternate text. Display name by default"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage
|
||||
* <?php add_filter( 'um_avatar_image_alternate_text', 'function_name', 10, 1 ); ?>
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_avatar_image_alternate_text', 'my_avatar_image_alternate_text', 10, 1 );
|
||||
* function my_avatar_image_alternate_text( $avatar_alt ) {
|
||||
* // your code here
|
||||
* return $avatar_alt;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$image_alt = apply_filters( "um_avatar_image_alternate_text", um_user("display_name") );
|
||||
|
||||
if ( ! $avatar && UM()->options()->get( 'use_gravatars' ) ) {
|
||||
|
||||
$default = get_option( 'avatar_default', 'mystery' );
|
||||
if ( $default == 'gravatar_default' ) {
|
||||
$default = '';
|
||||
}
|
||||
|
||||
$rating = get_option('avatar_rating');
|
||||
if ( !empty( $rating ) ) {
|
||||
$rating = "&r={$rating}";
|
||||
}
|
||||
|
||||
if ( UM()->options()->get('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){
|
||||
$avatar_url = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id');
|
||||
$avatar_url = add_query_arg('s',400, $avatar_url);
|
||||
$gravatar_type = UM()->options()->get( 'use_um_gravatar_default_builtin_image' );
|
||||
|
||||
if ( $gravatar_type == 'default' ) {
|
||||
if ( UM()->options()->get( 'use_um_gravatar_default_image' ) ) {
|
||||
$avatar_url = add_query_arg('d', um_get_default_avatar_uri(), $avatar_url );
|
||||
}
|
||||
} else {
|
||||
$avatar_url = add_query_arg('d', $gravatar_type, $avatar_url );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$avatar = '<img src="' .$avatar_url .'?d='. $default . '&s=' . $size . $rating .'" class="func-um_get_avatar gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />';
|
||||
|
||||
}else if( empty( $avatar ) ){
|
||||
$default_avatar_uri = um_get_default_avatar_uri();
|
||||
|
||||
$avatar = '<img src="' .$default_avatar_uri .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />';
|
||||
}
|
||||
|
||||
return $avatar;
|
||||
}
|
||||
add_filter( 'get_avatar', 'um_get_avatar', 99999, 5 );
|
||||
@@ -367,18 +367,70 @@ add_filter( 'um_get_form_fields', 'um_get_form_fields', 99 );
|
||||
*/
|
||||
function um_get_custom_field_array( $array, $fields ) {
|
||||
|
||||
if ( isset( $array['conditions'] ) ) {
|
||||
for ( $a = 0; $a < count( $array['conditions'] ); $a++ ) {
|
||||
if ( isset( $array['conditional_value'] ) || isset( $array['conditional_value' . $a] ) ) {
|
||||
foreach ( $array['conditions'] as $key => $value ) {
|
||||
$condition_metakey = $fields[ $value[1] ]['metakey'];
|
||||
if ( ! empty( $array['conditions'] ) ) {
|
||||
foreach ( $array['conditions'] as $key => $value ) {
|
||||
$condition_metakey = $fields[ $value[1] ]['metakey'];
|
||||
if ( isset( $_POST[ $condition_metakey ] ) ) {
|
||||
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
||||
list( $visibility, $parent_key, $op, $parent_value ) = $value;
|
||||
|
||||
if ( isset( $_POST[ $condition_metakey ] ) ) {
|
||||
$cond_value = ( $fields[ $value[1] ]['type'] == 'radio' ) ? $_POST[ $condition_metakey ][0] : $_POST[ $condition_metakey ];
|
||||
|
||||
if ( isset( $array['conditional_value'] ) && $cond_value !== $array['conditional_value'] ) {
|
||||
if ( $visibility == 'hide' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
} elseif ( isset( $array['conditional_value'.$a] ) && $cond_value !== $array['conditional_value'.$a] ) {
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value > $op ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value < $op ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( strstr( $cond_value, $parent_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
}
|
||||
} elseif ( $visibility == 'show' ) {
|
||||
if ( $op == 'empty' ) {
|
||||
if ( ! empty( $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'not empty' ) {
|
||||
if ( empty( $cond_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'equals to' ) {
|
||||
if ( $cond_value != $parent_value ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'not equals' ) {
|
||||
if ( $cond_value == $parent_value ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'greater than' ) {
|
||||
if ( $cond_value <= $op ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'less than' ) {
|
||||
if ( $cond_value >= $op ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
} elseif ( $op == 'contains' ) {
|
||||
if ( ! strstr( $cond_value, $parent_value ) ) {
|
||||
$array['required'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
if ( empty( $_POST['menu-item-db-id'] ) || ! in_array( $menu_item_db_id, $_POST['menu-item-db-id'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//var_dump($_POST['menu-item-um_nav_roles']); exit;
|
||||
foreach ( self::$fields as $_key => $label ) {
|
||||
|
||||
$key = sprintf( 'menu-item-%s', $_key );
|
||||
@@ -55,7 +55,8 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
// Sanitize
|
||||
if ( ! empty( $_POST[ $key ][ $menu_item_db_id ] ) ) {
|
||||
// Do some checks here...
|
||||
$value = $_POST[ $key ][ $menu_item_db_id ];
|
||||
$value = is_array( $_POST[ $key ][ $menu_item_db_id ] ) ?
|
||||
array_keys( $_POST[ $key ][ $menu_item_db_id ] ) : $_POST[ $key ][ $menu_item_db_id ];
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
@@ -165,7 +166,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields_Editor' ) ) {
|
||||
$id_attr = ' id="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$for_attr = ' for="edit-menu-item-um_nav_roles-{{data.menuItemID}}_' . $k . '" ';
|
||||
$html .= "<label $for_attr>
|
||||
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][]' value='{$k}' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
|
||||
<input type='checkbox' {$id_attr} name='menu-item-um_nav_roles[{{data.menuItemID}}][{$k}]' value='1' <# if( _.contains( data.restriction_data.um_nav_roles,'{$k}' ) ){ #>checked='checked'<# } #> />
|
||||
<span>{$title}</span>
|
||||
</label>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user