Version 1.0.35

This commit is contained in:
ultimatemember
2015-02-01 01:30:04 +02:00
parent df37a3164f
commit 539ebf10d7
41 changed files with 938 additions and 226 deletions
+1 -1
View File
@@ -61,7 +61,7 @@
$post_id = get_option('woocommerce_shop_page_id');
} else if ( is_archive() ) {
} else if ( is_archive() || is_front_page() || is_search() || in_the_loop() ) {
return;
+4
View File
@@ -65,6 +65,10 @@
$success = __('You have successfully changed your password.','ultimatemember');
break;
case 'account_active':
$success = __('Your account is now active! You can login.','ultimatemember');
break;
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
/***
*** @Search results
***/
add_action('pre_get_posts','um_pre_get_posts');
function um_pre_get_posts($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ( $query->is_search || $query->is_archive() || $query->is_home ) {
if ( $query->is_home && !um_get_option('exclude_from_main_loop' ) ) return;
if ( $query->is_archive && !um_get_option('exclude_from_archive_loop' ) ) return;
if ( $query->is_search && !um_get_option('exclude_from_search_loop' ) ) return;
if ( is_user_logged_in() ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array(
'key'=>'_um_accessible',
'value'=>'1',
'compare'=>'!=',
);
$meta_query[] = array(
'key'=>'_um_accessible',
'compare'=>'NOT EXISTS',
);
$query->set('meta_query',$meta_query);
}
if ( !is_user_logged_in() ) {
$meta_query['relation'] = 'OR';
$meta_query[] = array(
'key'=>'_um_accessible',
'value'=>'2',
'compare'=>'!=',
);
$meta_query[] = array(
'key'=>'_um_accessible',
'compare'=>'NOT EXISTS',
);
$query->set('meta_query',$meta_query);
}
}
}
}
+45 -17
View File
@@ -141,9 +141,11 @@
add_action('um_profile_header_cover_area', 'um_profile_header_cover_area' );
function um_profile_header_cover_area( $args ) {
global $ultimatemember;
if ( $args['cover_enabled'] == 1 ) {
if ( $args['cover_enabled'] == 1 ) {
$default_cover = um_get_option('default_cover');
$overlay = '<span class="um-cover-overlay">
<span class="um-cover-overlay-s">
<ins>
@@ -155,7 +157,7 @@
?>
<div class="um-cover <?php if ( um_profile('cover_photo') ) echo 'has-cover'; ?>" data-user_id="<?php echo um_profile_id(); ?>" data-ratio="<?php echo $args['cover_ratio']; ?>">
<div class="um-cover <?php if ( um_profile('cover_photo') || ( $default_cover && $default_cover['url'] ) ) echo 'has-cover'; ?>" data-user_id="<?php echo um_profile_id(); ?>" data-ratio="<?php echo $args['cover_ratio']; ?>">
<?php
@@ -170,7 +172,6 @@
echo $ultimatemember->menu->new_ui( 'bc', 'div.um-cover', 'click', $items );
}
?>
<?php $ultimatemember->fields->add_hidden_field( 'cover_photo' ); ?>
@@ -195,13 +196,21 @@
?>
<?php } else { ?>
<?php } elseif ( $default_cover && $default_cover['url'] ) {
$default_cover = $default_cover['url'];
echo '<img src="'. $default_cover . '" alt="" />';
} else {
<?php if ( !isset( $ultimatemember->user->cannot_edit ) ) { ?>
<a href="#" class="um-cover-add um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" title="<?php _e('Upload a cover photo','ultimatemember'); ?>"></i></span></a>
<?php } ?>
if ( !isset( $ultimatemember->user->cannot_edit ) ) { ?>
<?php } ?>
<a href="#" class="um-cover-add um-manual-trigger" data-parent=".um-cover" data-child=".um-btn-auto-width"><span class="um-cover-add-i"><i class="um-icon-plus um-tip-n" title="<?php _e('Upload a cover photo','ultimatemember'); ?>"></i></span></a>
<?php }
} ?>
</div>
@@ -505,12 +514,21 @@
function um_profile_navbar( $args ) {
global $ultimatemember;
$tabs = $ultimatemember->profile->tabs();
$tabs = $ultimatemember->profile->tabs_active();
if ( count( $tabs ) == 1 ) return;
$tabs = apply_filters('um_user_profile_tabs', $tabs );
$active_tab = $ultimatemember->profile->active_tab;
$ultimatemember->user->tabs = $tabs;
if ( count( $tabs ) <= 1 ) return;
$active_tab = $ultimatemember->profile->active_tab();
if ( !isset( $tabs[$active_tab] ) )
$active_tab = 'main';
$ultimatemember->profile->active_tab = $active_tab;
$ultimatemember->profile->active_subnav = null;
?>
<div class="um-profile-nav">
@@ -523,20 +541,30 @@
$nav_link = add_query_arg('profiletab', $id, $nav_link )
?>
<div class="um-profile-nav-item <?php if ( $id == $active_tab ) echo 'active'; ?>"><a href="<?php echo $nav_link; ?>" title="<?php echo $tab['name']; ?>"><i class="<?php echo $tab['icon']; ?> uimob500-show uimob340-show uimob800-show"></i><span class="uimob500-hide uimob340-hide uimob800-hide"><?php echo $tab['name']; ?></span></a></div>
<div class="um-profile-nav-item <?php if ( !um_get_option('profile_menu_icons') ) { echo 'without-icon'; } ?> <?php if ( $id == $active_tab ) { echo 'active'; } ?>">
<a href="<?php echo $nav_link; ?>" title="<?php echo $tab['name']; ?>">
<i class="<?php echo $tab['icon']; ?>"></i>
<span class="uimob500-hide uimob340-hide uimob800-hide title"><?php echo $tab['name']; ?></span>
<?php if ( um_get_option('profile_menu_counts') && isset( $tab['count'] ) ) { ?>
<span class="uimob500-hide uimob340-hide uimob800-hide count"><?php echo $tab['count']; ?></span>
<?php } ?>
</a>
</div>
<?php } ?>
<div class="um-clear"></div>
</div>
<?php
foreach( $tabs as $id => $tab ) {
<?php foreach( $tabs as $id => $tab ) {
if ( isset( $tab['subnav'] ) && $active_tab == $id ) {
$active_subnav = (isset($ultimatemember->profile->active_subnav)) ? $ultimatemember->profile->active_subnav : $tab['subnav_default'];
$active_subnav = ( $ultimatemember->profile->active_subnav() ) ? $ultimatemember->profile->active_subnav() : $tab['subnav_default'];
echo '<div class="um-profile-subnav">';
foreach( $tab['subnav'] as $id => $subtab ) {
+4 -1
View File
@@ -64,7 +64,10 @@
*** @hide admin bar appropriately
***/
function um_control_admin_bar(){
if( !is_admin() && !um_user('can_access_wpadmin')) {
if ( um_user('can_not_see_adminbar') )
return false;
if( !is_admin() && !um_user('can_access_wpadmin') ) {
return false;
} else {
um_fetch_user( get_current_user_id() );
+27 -32
View File
@@ -48,7 +48,6 @@ class UM_Fields {
echo $output;
echo '</div>';
}
/***
@@ -448,28 +447,6 @@ class UM_Fields {
return false;
}
/***
*** @Fix for children custom fields
***/
function find_custom_field_data($key, $fields) {
foreach ($fields as $k => $v) {
if ( $k == $key ){
return $fields[$key];
}
if (isset($fields[$k]['fields'])) {
foreach( $fields[$k]['fields'] as $k1 => $v1 ){
if ($k1 == $key){
return $fields[$k]['fields'][$k1];
}
}
}
}
return array('');
}
/***
*** @Get Field Icon
@@ -509,9 +486,9 @@ class UM_Fields {
global $ultimatemember;
$fields = $this->get_fields();
if ( isset( $fields ) && is_array( $fields ) ) {
$array = $this->find_custom_field_data($key, $fields);
if ( isset( $fields ) && is_array( $fields ) && isset( $fields[$key] ) ) {
$array = $fields[$key];
} else {
$array = $ultimatemember->builtin->predefined_fields[$key];
}
@@ -607,6 +584,7 @@ class UM_Fields {
$array['disabled_weekdays'] = '[' . implode(',',$array['disabled_weekdays']) . ']';
}
// When date range is strictly defined
if ( $array['range'] == 'date_range' ) {
$array['date_min'] = str_replace('/',',',$array['range_start']);
@@ -615,14 +593,31 @@ class UM_Fields {
} else {
if ( $array['years_x'] == 'past' ) {
$array['date_min'] = date('Y,n,d', mktime(0, 0, 0, date("n") , date("d"), date("Y") - $array['years'] ) );
$date = new DateTime( date('Y-n-d') );
$past = $date->modify('-'.$array['years'].' years')->format('Y,n,d');
$array['date_min'] = $past;
$array['date_max'] = date('Y,n,d');
} else if ( $array['years_x'] == 'future' ) {
$date = new DateTime( date('Y-n-d') );
$future = $date->modify('+'.$array['years'].' years')->format('Y,n,d');
$array['date_min'] = date('Y,n,d');
$array['date_max'] = date('Y,n,d', mktime(0, 0, 0, date("n") , date("d"), date("Y") + $array['years'] ) );
$array['date_max'] = $future;
} else {
$array['date_min'] = date('Y,n,d', mktime(0, 0, 0, date("n") , date("d"), date("Y") - ( $array['years'] / 2 ) ) );
$array['date_max'] = date('Y,n,d', mktime(0, 0, 0, date("n") , date("d"), date("Y") + ( $array['years'] / 2 ) ) );
$date = new DateTime( date('Y-n-d') );
$date_f = new DateTime( date('Y-n-d') );
$past = $date->modify('-'. ( $array['years'] / 2 ).' years')->format('Y,n,d');
$future = $date_f->modify('+'. ( $array['years'] / 2 ).' years')->format('Y,n,d');
$array['date_min'] = $past;
$array['date_max'] = $future;
}
}
@@ -1340,7 +1335,7 @@ class UM_Fields {
$v = rtrim($v);
if ( !is_numeric( $k ) ) {
if ( !is_numeric( $k ) && in_array($form_key, array('role') ) ) {
$option_value = $k;
} else {
$option_value = $v;
@@ -1438,7 +1433,7 @@ class UM_Fields {
$v = rtrim($v);
if ( !is_numeric( $k ) ) {
if ( !is_numeric( $k ) && in_array($form_key, array('role') ) ) {
$option_value = $k;
} else {
$option_value = $v;
+14 -13
View File
@@ -129,24 +129,25 @@ class UM_Files {
*** @fix image orientation
***/
function fix_image_orientation($rotate, $source){
$exif = @exif_read_data($source);
if ( extension_loaded('exif') ){
$exif = @exif_read_data($source);
if (isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3:
$rotate = imagerotate($rotate, 180, 0);
break;
if (isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3:
$rotate = imagerotate($rotate, 180, 0);
break;
case 6:
$rotate = imagerotate($rotate, -90, 0);
break;
case 6:
$rotate = imagerotate($rotate, -90, 0);
break;
case 8:
$rotate = imagerotate($rotate, 90, 0);
break;
case 8:
$rotate = imagerotate($rotate, 90, 0);
break;
}
}
}
return $rotate;
}
+2 -2
View File
@@ -9,13 +9,13 @@
if ( is_multisite() ) { // Need to the work
if ( get_current_blog_id() == '1' ) return;
if ( get_current_blog_id() == '1' ) return $dir;
$split = explode('sites',$dir);
$um_dir = 'ultimatemember/';
$dir = $split[0] . $um_dir;
}
return $dir;
}
+7 -3
View File
@@ -66,12 +66,16 @@
foreach( $query as $field => $value ) {
$operator = 'LIKE';
if ( in_array( $field, array('gender') ) ) {
$operator = '=';
} else {
$operator = 'LIKE';
}
if ( in_array( $ultimatemember->fields->get_field_type( $field ), array('checkbox','multiselect') ) ) {
$operator = 'LIKE';
}
if ( $value && $field != 'um_search' ) {
if ( !in_array( $field, $ultimatemember->members->core_search_fields ) ) {
+10
View File
@@ -0,0 +1,10 @@
<?php
/***
*** @formats numbers nicely
***/
add_filter('um_pretty_number_formatting', 'um_pretty_number_formatting');
function um_pretty_number_formatting( $count ) {
$count = (int)$count;
return number_format( $count );
}
+1 -1
View File
@@ -40,7 +40,7 @@
switch( $mode ) {
case 2:
if (isset($roles) && !empty($roles)) {
if ( is_user_logged_in() && isset($roles) && !empty($roles)) {
if ( in_array( um_user('role'), (array)$roles) ) {
$visible = true;
} else {
+1 -1
View File
@@ -18,7 +18,7 @@
*** @dynamic profile page title
***/
add_filter('wp_title', 'um_dynamic_user_profile_pagetitle', 100000, 2 );
function um_dynamic_user_profile_pagetitle( $title, $sep ) {
function um_dynamic_user_profile_pagetitle( $title, $sep = '' ) {
global $paged, $page, $ultimatemember;
$profile_title = um_get_option('profile_title');
+6
View File
@@ -50,6 +50,9 @@ class UM_Mail {
$search = array(
'{display_name}',
'{first_name}',
'{last_name}',
'{gender}',
'{username}',
'{email}',
'{password}',
@@ -66,6 +69,9 @@ class UM_Mail {
$replace = array(
um_user('display_name'),
um_user('first_name'),
um_user('last_name'),
um_user('gender'),
um_user('user_login'),
um_user('user_email'),
um_user('_um_cool_but_hard_to_guess_plain_pw'),
+1 -1
View File
@@ -5,7 +5,7 @@ if ( ! class_exists( 'UM_Menu_Item_Custom_Fields' ) ) :
class UM_Menu_Item_Custom_Fields {
public static function load() {
add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 99 );
add_filter( 'wp_edit_nav_menu_walker', array( __CLASS__, '_filter_walker' ), 200 );
}
public static function _filter_walker( $walker ) {
+2
View File
@@ -73,6 +73,8 @@ class UM_Permalinks {
um_reset_user();
exit( wp_redirect( um_get_core_page('login', 'account_active') ) );
}
}
+39 -4
View File
@@ -5,31 +5,66 @@ class UM_Profile {
function __construct() {
add_action('template_redirect', array(&$this, 'active_tab'), 10002);
$this->active_tab = 'main';
add_action('template_redirect', array(&$this, 'active_subnav'), 10002);
}
/***
*** @Global tabs
*** @all tab data
***/
function tabs(){
return apply_filters('um_profile_tabs', $tabs = array() );
}
/***
*** @Get active tab
*** @tabs that are active
***/
function tabs_active(){
$tabs = $this->tabs();
foreach( $tabs as $id => $info ) {
if ( !um_get_option('profile_tab_'.$id) )
unset( $tabs[$id] );
}
return $tabs;
}
/***
*** @primary tabs only
***/
function tabs_primary(){
$tabs = $this->tabs();
foreach( $tabs as $id => $info ){
$primary[$id] = $info['name'];
}
return $primary;
}
/***
*** @Get active_tab
***/
function active_tab() {
$this->active_tab = um_get_option('profile_menu_default_tab');
if ( get_query_var('profiletab') ) {
$this->active_tab = get_query_var('profiletab');
}
return $this->active_tab;
}
/***
*** @Get active active_subnav
***/
function active_subnav() {
$this->active_subnav = null;
if ( get_query_var('subnav') ) {
$this->active_subnav = get_query_var('subnav');
}
return $this->active_subnav;
}
/***
+14 -3
View File
@@ -21,9 +21,20 @@ class UM_Query {
extract( $args );
$custom_posts = new WP_Query();
$custom_posts->query( $args );
return $custom_posts;
if ( $post_type == 'comment' ) { // comments
unset( $args['post_type'] );
$comments = get_comments($args);
return $comments;
} else {
$custom_posts = new WP_Query();
$custom_posts->query( $args );
return $custom_posts;
}
}
/***
+8 -3
View File
@@ -34,17 +34,22 @@ class UM_Rewrite {
if ( isset( $ultimatemember->permalinks->core['user'] ) ) {
$user_page_id = $ultimatemember->permalinks->core['user'];
$account_page_id = $ultimatemember->permalinks->core['account'];
$user = get_post($user_page_id);
$user_slug = $user->post_name;
$account = get_post($account_page_id);
$account_slug = $account->post_name;
add_rewrite_rule(
'^user/([^/]*)$',
'^'.$user_slug.'/([^/]*)$',
'index.php?page_id='.$user_page_id.'&um_user=$matches[1]',
'top'
);
add_rewrite_rule(
'^account/([^/]*)$',
'^'.$account_slug.'/([^/]*)$',
'index.php?page_id='.$account_page_id.'&um_tab=$matches[1]',
'top'
);
+4
View File
@@ -147,6 +147,8 @@ class UM_Setup {
'_um_login_secondary_btn_hover' => '#e5e5e5',
'_um_login_secondary_btn_text' => '#666',
'_um_directory_template' => 'members',
'_um_directory_header' => __('{total_users} Members','ultimatemember'),
'_um_directory_header_single' => __('{total_users} Member','ultimatemember'),
);
$this->core_form_meta_all = apply_filters('um_core_form_meta_all', $this->core_form_meta_all );
@@ -176,6 +178,7 @@ class UM_Setup {
$this->perms = array(
'core' => 'admin',
'can_access_wpadmin' => 1,
'can_not_see_adminbar' => 0,
'can_edit_everyone' => 1,
'can_delete_everyone' => 1,
'can_edit_profile' => 1,
@@ -194,6 +197,7 @@ class UM_Setup {
$this->nonadmin_perms = array(
'core' => 'member',
'can_access_wpadmin' => 0,
'can_not_see_adminbar' => 1,
'can_edit_everyone' => 0,
'can_delete_everyone' => 0,
'can_make_private_profile' => 0,
+30 -6
View File
@@ -391,9 +391,10 @@
function um_edit_my_profile_uri() {
global $ultimatemember;
$url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
$url = remove_query_arg( 'profiletab', $url );
$url = remove_query_arg( 'subnav', $url );
$url = add_query_arg( 'um_action', 'edit', $url );
$url = remove_query_arg('profiletab', $url);
$url = remove_query_arg('subnav', $url);
$url = add_query_arg('profiletab', 'main', $url);
$url = add_query_arg('um_action', 'edit', $url);
return $url;
}
@@ -710,6 +711,17 @@
return $uri;
}
/***
*** @default cover
***/
function um_get_default_cover_uri() {
$uri = um_get_option('default_cover');
$uri = $uri['url'];
if ( $uri )
return $uri;
return '';
}
/***
*** @get user data
***/
@@ -846,15 +858,27 @@
$avatar_uri = um_get_default_avatar_uri();
}
return '<img src="' . $avatar_uri . '" class="gravatar avatar avatar-'.$attrs.' um-avatar" width="'.$attrs.'" height="'.$attrs.'" alt="" />';
if ( $avatar_uri )
return '<img src="' . $avatar_uri . '" class="gravatar avatar avatar-'.$attrs.' um-avatar" width="'.$attrs.'" height="'.$attrs.'" alt="" />';
if ( !$avatar_uri )
return '';
break;
case 'cover_photo':
if ( um_profile('cover_photo') ) {
$cover_uri = um_get_cover_uri( um_profile('cover_photo'), $attrs );
return '<img src="'. $cover_uri .'" alt="" />';
} else {
$cover_uri = um_get_default_cover_uri();
}
if ( $cover_uri )
return '<img src="'. $cover_uri .'" alt="" />';
if ( !$cover_uri )
return '';
break;
}
+14 -11
View File
@@ -219,22 +219,25 @@ class UM_Shortcodes {
$pattern_array = apply_filters('um_allowed_user_tags_patterns', $pattern_array);
$matches = false;
foreach ( $pattern_array as $pattern )
{
if (preg_match($pattern, $str))
{
foreach ( $pattern_array as $pattern ) {
if (preg_match($pattern, $str)) {
$usermeta = str_replace('{','',$pattern);
$usermeta = str_replace('}','',$usermeta);
if ( um_user( $usermeta ) ){
$str = preg_replace('/'.$pattern.'/', um_user($usermeta) , $str );
}
}
}
if ( get_option('permalink_structure') ) {
$str = str_replace( untrailingslashit( um_get_core_page('user') ), untrailingslashit( um_user_profile_url() ), $str );
} else {
$str = str_replace( um_get_core_page('user'), um_user_profile_url(), $str );
if ( get_option('permalink_structure') ) {
$str = str_replace( untrailingslashit( um_get_core_page('user') ), untrailingslashit( um_user_profile_url() ), $str );
} else {
$str = str_replace( um_get_core_page('user'), um_user_profile_url(), $str );
}
}
}
return $str;
+125
View File
@@ -0,0 +1,125 @@
<?php
class UM_User_posts {
function __construct() {
add_filter('um_profile_tabs', array(&$this, 'add_tab'), 100);
add_action('um_profile_content_posts', array(&$this, 'add_posts') );
add_action('um_profile_content_comments', array(&$this, 'add_comments') );
add_action('um_ajax_load_posts__um_load_posts', array(&$this, 'load_posts') );
add_action('um_ajax_load_posts__um_load_comments', array(&$this, 'load_comments') );
}
/***
*** @dynamic load of posts
***/
function load_posts( $args ) {
global $ultimatemember;
$array = explode(',', $args );
$post_type = $array[0];
$posts_per_page = $array[1];
$offset = $array[2];
$author = $array[3];
$offset_n = $posts_per_page + $offset;
$modified_args = "$post_type,$posts_per_page,$offset_n,$author";
$loop = $ultimatemember->query->make("post_type=$post_type&posts_per_page=$posts_per_page&offset=$offset&author=$author");
include_once um_path . 'templates/profile/posts-single.php';
}
/***
*** @dynamic load of comments
***/
function load_comments( $args ) {
global $ultimatemember;
$array = explode(',', $args );
$post_type = $array[0];
$posts_per_page = $array[1];
$offset = $array[2];
$author = $array[3];
$offset_n = $posts_per_page + $offset;
$modified_args = "$post_type,$posts_per_page,$offset_n,$author";
$loop = $ultimatemember->query->make("post_type=$post_type&number=$posts_per_page&offset=$offset&author_email=$author");
include_once um_path . 'templates/profile/comments-single.php';
}
/***
*** @adds a tab
***/
function add_tab( $tabs ){
$tabs['posts'] = array(
'name' => __('Posts','ultimatemember'),
'icon' => 'um-faicon-pencil',
'count' => $this->count_user_posts_by_type(),
);
$tabs['comments'] = array(
'name' => __('Comments','ultimatemember'),
'icon' => 'um-faicon-comment',
'count' => $this->count_user_comments(),
);
return $tabs;
}
/***
*** @add posts
***/
function add_posts() {
global $ultimatemember;
include_once um_path . 'templates/profile/posts.php';
}
/***
*** @add comments
***/
function add_comments() {
global $ultimatemember;
include_once um_path . 'templates/profile/comments.php';
}
/***
*** @count posts
***/
function count_user_posts_by_type( $user_id= '', $post_type = 'post' ) {
global $wpdb;
if ( !$user_id )
$user_id = um_user('ID');
$where = get_posts_by_author_sql( $post_type, true, $user_id );
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
return apply_filters('um_pretty_number_formatting', $count);
}
/***
*** @count comments
***/
function count_user_comments( $user_id = null ) {
global $wpdb;
if ( !$user_id )
$user_id = um_user('ID');
$count = $wpdb->get_var('
SELECT COUNT(comment_ID)
FROM ' . $wpdb->comments. '
WHERE user_id = "' . $user_id . '"');
return apply_filters('um_pretty_number_formatting', $count);
}
}