Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jonfalcon
2016-04-02 16:21:39 -07:00
11 changed files with 177 additions and 66 deletions
+6 -4
View File
@@ -85,10 +85,12 @@ jQuery(document).ready(function() {
Tooltips
**/
jQuery('.um-admin-tipsy-n,#redux-share a').tipsy({gravity: 'n', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-s').tipsy({gravity: 's', opacity: 1, live: 'a.live' });
if( typeof tipsy !== 'undefined' ){
jQuery('.um-admin-tipsy-n,#redux-share a').tipsy({gravity: 'n', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live' });
jQuery('.um-admin-tipsy-s').tipsy({gravity: 's', opacity: 1, live: 'a.live' });
}
/**
Conditional fields
+9 -1
View File
@@ -139,7 +139,15 @@
</select>
</p>
<p><label for="_um_profile_photo_required"><?php _e('Make Profile Photo Required','ultimatemember'); ?><?php $this->tooltip('Require user to update a profile photo when updating their profile', 'e'); ?></label>
<span>
<?php $this->ui_on_off('_um_profile_photo_required'); ?>
</span>
</p>
<p><label for="_um_profile_header_bg"><?php _e('Header Background Color','ultimatemember'); ?></label>
<input type="text" value="<?php echo $ultimatemember->query->get_meta_value('_um_profile_header_bg', null, um_get_option('profile_header_bg') ); ?>" class="um-admin-colorpicker" name="_um_profile_header_bg" id="_um_profile_header_bg" data-default-color="<?php echo um_get_option('profile_header_bg'); ?>" />
</p>
+1 -1
View File
@@ -33,7 +33,7 @@ if(isset($_FILES[$id]['name'])) {
} else {
$file = "stream_photo_".md5($file)."_".uniqid().".".$ext;
$ret[] = $ultimatemember->files->new_image_upload_temp( $temp, $file, um_get_option('image_compression') );
$ret[ ] = $ultimatemember->files->new_image_upload_temp( $temp, $file, um_get_option('image_compression') );
}
+22 -1
View File
@@ -152,6 +152,10 @@
$form_id = $args['form_id'];
$mode = $args['mode'];
$fields = unserialize( $args['custom_fields'] );
if ( get_post_meta( $form_id, '_um_profile_photo_required', true ) && empty( $args['profile_photo'] ) ) {
$ultimatemember->form->add_error('profile_photo', sprintf(__('%s is required.','ultimatemember'), 'Profile Photo' ) );
}
if( isset( $fields ) && ! empty( $fields ) ){
foreach( $fields as $key => $array ) {
@@ -162,6 +166,10 @@
$ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $array['title'] ) );
}
if ( isset( $array['type'] ) && $array['type'] == 'user_tags' && isset( $array['required'] ) && $array['required'] == 1 && !isset( $args[$key] ) ) {
$ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $array['title'] ) );
}
if ( isset( $array['type'] ) && $array['type'] == 'radio' && isset( $array['required'] ) && $array['required'] == 1 && !isset( $args[$key] ) && !in_array($key, array('role_radio','role_select') ) ) {
$ultimatemember->form->add_error($key, sprintf(__('%s is required.','ultimatemember'), $array['title'] ) );
}
@@ -350,7 +358,9 @@
if ( $args[$key] == '' && in_array( $key, array('user_email') ) ) {
$ultimatemember->form->add_error($key, __('You must provide your email','ultimatemember') );
} else if ( $mode == 'register' && email_exists( $args[$key] ) ) {
} else if ( in_array( $mode, array('register') ) && email_exists( $args[$key] ) ) {
$ultimatemember->form->add_error($key, __('This email is already linked to an existing account','ultimatemember') );
} else if ( in_array( $mode, array('profile') ) && email_exists( $args[$key] ) != $args['user_id'] ) {
$ultimatemember->form->add_error($key, __('This email is already linked to an existing account','ultimatemember') );
} else if ( !is_email( $args[$key] ) ) {
$ultimatemember->form->add_error($key, __('This is not a valid email','ultimatemember') );
@@ -364,6 +374,17 @@
$ultimatemember->form->add_error($key, __('This is not a valid email','ultimatemember') );
} else if ( $args[$key] != '' && email_exists( $args[$key] ) ) {
$ultimatemember->form->add_error($key, __('This email is already linked to an existing account','ultimatemember') );
} else if ( $args[$key] != '' ) {
$users = get_users('meta_value='.$args[ $key ]);
foreach ( $users as $user ) {
if( $user->ID != $args['user_id'] ){
$ultimatemember->form->add_error($key, __('This email is already linked to an existing account','ultimatemember') );
}
}
}
}
+6
View File
@@ -406,6 +406,12 @@
<?php do_action('um_after_header_meta', um_user('ID'), $args ); ?>
</div><div class="um-clear"></div>
<?php
if ( $ultimatemember->fields->is_error( 'profile_photo' ) ) {
echo $ultimatemember->fields->field_error( $ultimatemember->fields->show_error('profile_photo'), 'force_show' );
}
?>
<?php do_action('um_after_header_info', um_user('ID'), $args); ?>
+10
View File
@@ -649,6 +649,16 @@ class UM_Builtin {
'label' => __('E-mail Address','ultimatemember'),
'required' => 0,
'public' => 1,
'validate' => 'unique_email',
),
'secondary_user_email' => array(
'title' => __('Secondary E-mail Address','ultimatemember'),
'metakey' => 'secondary_user_email',
'type' => 'text',
'label' => __('Secondary E-mail Address','ultimatemember'),
'required' => 0,
'public' => 1,
'editable' => 1,
'validate' => 'unique_email',
),
+7 -1
View File
@@ -909,7 +909,13 @@ class UM_Fields {
if ( !um_can_edit_field( $data ) ) return;
// fields that need to be disabled in edit mode (profile)
if ( in_array( $key, array('user_email','username','user_login','user_password') ) && $this->editing == true && $this->set_mode == 'profile' ) {
$arr_restricted_fields = array('user_email','username','user_login','user_password');
if( um_get_option('editable_primary_email_in_profile') == 1 ){
unset( $arr_restricted_fields[0] ); // remove user_email
}
if ( in_array( $key, $arr_restricted_fields ) && $this->editing == true && $this->set_mode == 'profile' ) {
return;
}
+67 -34
View File
@@ -211,16 +211,28 @@ class UM_Files {
$new_w = um_get_option('image_max_width');
$new_h = round( $new_w / $ratio, 2 );
$image_p = imagecreatetruecolor( $new_w, $new_h );
imagecopyresampled( $image_p, $image, 0, 0, 0, 0, $new_w, $new_h, $w, $h );
$image_p = $this->fix_image_orientation( $image_p, $source );
if ( $info['mime'] == 'image/jpeg' || $info['mime'] == 'image/gif' ){
$image_p = imagecreatetruecolor( $new_w, $new_h );
imagecopyresampled( $image_p, $image, 0, 0, 0, 0, $new_w, $new_h, $w, $h );
$image_p = $this->fix_image_orientation( $image_p, $source );
}else if( $info['mime'] == 'image/png' ){
$srcImage = $image;
$targetImage = imagecreatetruecolor( $new_w, $new_h );
imagealphablending( $targetImage, false );
imagesavealpha( $targetImage, true );
imagecopyresampled( $targetImage, $srcImage, 0, 0, 0, 0, $new_w, $new_h, $w, $h );
}
if ( $info['mime'] == 'image/jpeg' ){
$has_copied = imagejpeg( $image_p, $destination, $quality );
}else if ( $info['mime'] == 'image/gif' ){
$has_copied = imagegif( $image_p, $destination );
}else if ( $info['mime'] == 'image/png' ){
$has_copied = imagepng( $image_p, $destination, $quality );
$has_copied = imagepng( $targetImage, $destination, 0 ,PNG_ALL_FILTERS);
}
$info['um_has_max_width'] = 'custom';
@@ -230,18 +242,20 @@ class UM_Files {
$image = $this->fix_image_orientation( $image, $source );
if ( $info['mime'] == 'image/jpeg' ){
$has_copied = imagejpeg( $image, $destination, $quality );
}else if ( $info['mime'] == 'image/gif' ){
$has_copied = imagegif( $image, $destination );
}else if ( $info['mime'] == 'image/png' ){
$has_copied = imagepng( $image, $destination );
$has_copied = imagepng( $image , $destination , 0 ,PNG_ALL_FILTERS);
}
$info['um_has_max_width'] = 'default';
$info['um_has_copied'] = $has_copied ? 'yes':'no';
}
return $info;
}
@@ -265,7 +279,7 @@ class UM_Files {
$info = $this->create_and_copy_image( $source, $unique_dir['dir'] . $destination, $quality );
$url = $unique_dir['url'] . $destination;
$url = $unique_dir['url'] . $destination ;
return $url;
@@ -469,27 +483,28 @@ class UM_Files {
$info = @getimagesize( $file );
if ( $info['mime'] == 'image/gif' ){
$img_r = imagecreatefromgif( $file );
} else if ( $info['mime'] == 'image/png' ){
$img_r = imagecreatefrompng( $file );
}else{
$img_r = imagecreatefromjpeg( $file );
}
$dst_r = imagecreatetruecolor( $targ_x2, $targ_y2 );
imagecopy( $dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2 );
if ( $info['mime'] == 'image/gif' ){
$dst_r = imagecreatetruecolor( $targ_x2, $targ_y2 );
imagecopy( $dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2 );
imagegif( $dst_r, $this->path_only( $file ) . basename( $file ) );
} else if ( $info['mime'] == 'image/png' ){
imagepng( $dst_r, $this->path_only( $file ) . basename( $file ), 9, PNG_NO_FILTER );
$srcImage = imagecreatefrompng( $file );
$targetImage = imagecreatetruecolor( $targ_x2, $targ_y2 );
imagealphablending( $targetImage, false );
imagesavealpha( $targetImage, true );
imagecopyresampled( $targetImage, $srcImage, 0, 0, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2 );
imagepng( $srcImage, $this->path_only( $file ) . basename( $file ) );
}else{
$img_r = imagecreatefromjpeg( $file );
$dst_r = imagecreatetruecolor( $targ_x2, $targ_y2 );
imagecopy( $dst_r, $img_r, 0, 0, $targ_x1, $targ_y1, $targ_x2, $targ_y2 );
imagejpeg( $dst_r, $this->path_only( $file ) . basename( $file ), 100 );
}
$split = explode('/ultimatemember/temp/', $file );
@@ -564,21 +579,32 @@ class UM_Files {
if ( $info['mime'] == 'image/jpeg' ){
$thumb_s = imagecreatefromjpeg( $source );
$thumb = imagecreatetruecolor( $size, $size );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $size, $w, $h );
}else if ( $info['mime'] == 'image/gif' ){
$thumb_s = imagecreatefromgif( $source );
}else if ( $info['mime'] == 'image/png' ){
$thumb_s = imagecreatefrompng( $source );
$thumb = imagecreatetruecolor( $size, $size );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $size, $w, $h );
}
$thumb = imagecreatetruecolor( $size, $size );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $size, $w, $h );
if ( $info['mime'] == 'image/jpeg' ){
imagejpeg( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
}else if ( $info['mime'] == 'image/png' ){
imagepng( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 9,PNG_NO_FILTER);
$srcImage = imagecreatefrompng( $source );
$targetImage = imagecreatetruecolor( $size, $size );
imagealphablending( $targetImage, false );
imagesavealpha( $targetImage, true );
imagecopyresampled( $targetImage, $srcImage, 0, 0, 0, 0, $size, $size, $w, $h );
imagepng( $srcImage, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 0 ,PNG_ALL_FILTERS);
}else if ( $info['mime'] == 'image/gif' ){
imagegif( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext);
}
}
@@ -606,20 +632,27 @@ class UM_Files {
if ( $size < $w ) {
if ( $info['mime'] == 'image/jpeg' ){
$thumb = imagecreatetruecolor( $size, $height );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $height, $w, $h );
$thumb_s = imagecreatefromjpeg( $source );
}else if ( $info['mime'] == 'image/gif' ){
$thumb = imagecreatetruecolor( $size, $height );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $height, $w, $h );
$thumb_s = imagecreatefromgif( $source );
}else if ( $info['mime'] == 'image/png' ){
$thumb_s = imagecreatefrompng( $source );
}
$thumb = imagecreatetruecolor( $size, $height );
imagecopyresampled( $thumb, $thumb_s, 0, 0, 0, 0, $size, $height, $w, $h );
if ( $info['mime'] == 'image/jpeg' ){
imagejpeg( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 100);
}else if ( $info['mime'] == 'image/png' ){
imagepng( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 9,PNG_NO_FILTER);
$srcImage = imagecreatefrompng( $source );
$targetImage = imagecreatetruecolor( $size, $height );
imagealphablending( $targetImage, false );
imagesavealpha( $targetImage, true );
imagecopyresampled( $targetImage, $srcImage, 0, 0, 0, 0, $size, $height, $w, $h );
imagepng($srcImage, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext, 0 ,PNG_ALL_FILTERS);
}else if ( $info['mime'] == 'image/gif' ){
imagegif( $thumb, $this->upload_basedir . $user_id . '/' . $name . '-' . $size . $ext);
}
+18 -7
View File
@@ -1481,16 +1481,27 @@ function um_fetch_user( $user_id ) {
* @param mixed $value
* @return integer
*/
function um_is_meta_value_exists( $key, $value ){
function um_is_meta_value_exists( $key, $value, $return_user_id = false ){
global $wpdb;
$count = $wpdb->get_var( $wpdb->prepare(
"SELECT COUNT(*) as count FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s ",
$key,
$value
) );
if( ! $return_user_id ){
$count = $wpdb->get_var( $wpdb->prepare(
"SELECT COUNT(*) as count FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s ",
$key,
$value
) );
return $count;
}
$user_id = $wpdb->get_var( $wpdb->prepare(
"SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value = %s ",
$key,
$value
) );
return $user_id;
return $count;
}
/**
+21 -17
View File
@@ -416,33 +416,37 @@ class UM_Shortcodes {
$paths[] = glob(get_stylesheet_directory() . '/ultimate-member/templates/' . '*.php');
}
foreach ($paths as $k => $files) {
if( isset( $paths ) && ! empty( $paths ) ){
foreach ($paths as $k => $files) {
foreach ($files as $file) {
foreach ($files as $file) {
$clean_filename = $this->get_template_name($file);
$clean_filename = $this->get_template_name($file);
if (0 === strpos($clean_filename, $excluded)) {
if (0 === strpos($clean_filename, $excluded)) {
$source = file_get_contents($file);
$tokens = token_get_all($source);
$comment = array(
T_COMMENT, // All comments since PHP5
T_DOC_COMMENT, // PHPDoc comments
);
foreach ($tokens as $token) {
if (in_array($token[0], $comment) && strstr($token[1], '/* Template:') && $clean_filename != $excluded) {
$txt = $token[1];
$txt = str_replace('/* Template: ', '', $txt);
$txt = str_replace(' */', '', $txt);
$array[$clean_filename] = $txt;
$source = file_get_contents($file);
$tokens = token_get_all($source);
$comment = array(
T_COMMENT, // All comments since PHP5
T_DOC_COMMENT, // PHPDoc comments
);
foreach ($tokens as $token) {
if (in_array($token[0], $comment) && strstr($token[1], '/* Template:') && $clean_filename != $excluded) {
$txt = $token[1];
$txt = str_replace('/* Template: ', '', $txt);
$txt = str_replace(' */', '', $txt);
$array[$clean_filename] = $txt;
}
}
}
}
}
}
return $array;
+10
View File
@@ -202,6 +202,16 @@ $this->sections[] = array(
'off' => __('Off','ultimatemember'),
),
array(
'id' => 'editable_primary_email_in_profile',
'type' => 'switch',
'title' => __( 'Editable primary email field in profile view','ultimatemember' ),
'default' => 0,
'desc' => __('Allow users to edit their primary emails in profile view ( when email address field is added only )','ultimatemember'),
'on' => __('On','ultimatemember'),
'off' => __('Off','ultimatemember'),
),
)
);