diff --git a/admin/assets/css/um-admin-dashboard.css b/admin/assets/css/um-admin-dashboard.css
index 6b73d889..6f530367 100644
--- a/admin/assets/css/um-admin-dashboard.css
+++ b/admin/assets/css/um-admin-dashboard.css
@@ -81,55 +81,6 @@
padding-left: 4px;
}
-/*
- - Nav
-*/
-
-.um-admin-dash-nav {
- float: left;
- width: 202px;
- min-height: 300px;
- display: none !important;
-}
-
-.um-admin-dash-nav a {
- font-family: Open Sans;
- font-size: 14px;
- position: relative;
- display: block;
- padding: 10px 4px 10px 14px;
- border-width: 1px 0px;
- border-style: solid;
- border-bottom: 1px solid #E7E7E7;
- border-top: 0px none;
- font-weight: 700;
- text-decoration: none;
- transition: none 0s ease 0s;
- background: transparent !important;
- color: #555 !important;
-}
-
-.um-admin-dash-nav-title {
- padding-left: 30px;
-}
-
-.um-admin-dash-nav a:hover {
- background: #ddd !important;
-}
-
-.um-admin-dash-nav a.active,
-.um-admin-dash-nav a.active:hover {
- color: #3ba1da !important;
- background: transparent !important;
-}
-
-.um-admin-dash-nav a i {
- vertical-align: middle;
- font-size: 1.35em;
- position: absolute;
- top: 8px;
-}
-
/*
- Main
*/
@@ -139,8 +90,6 @@
border-left: 1px solid #D8D8D8;
padding: 0 30px 30px 30px;
box-shadow: 0px 1px 0px #FFF inset;
- min-height: 300px;
-
border-left: none;
margin-left: 0;
}
@@ -151,9 +100,10 @@
margin: 0 !important;
}
-.um-admin-dash-content {
- display: none;
- display: block;
+.um-admin-dash-main h4{
+ font-weight: 500;
+ padding: 30px 0 10px 0;
+ margin: 0 !important;
}
.um-admin-dash-review {
@@ -187,6 +137,20 @@
- Dashboard styles
*/
+.um-admin-dash-four-col .um-admin-dash-col {
+ float: left;
+ width: 25%;
+ text-align: center;
+}
+
+.um-admin-dash-three-col {border-bottom: 1px solid #ddd;padding-bottom: 25px}
+
+.um-admin-dash-three-col .um-admin-dash-col {
+ float: left;
+ width: 33%;
+ text-align: center;
+}
+
.um-admin-dash-two-col .um-admin-dash-col {
display: inline-block;
width: 46%;
@@ -197,6 +161,13 @@
.um-admin-dash-col a:hover {text-decoration: underline}
.um-admin-dash-col a {text-decoration: none}
+.um-admin-dash-num {
+ display: inline-block;
+ margin: 8px 0 0 0;
+ font-size: 28px;
+ font-weight: 300;
+}
+
.um-admin-dash-item {
padding: 5px 0;
vertical-align: middle;
diff --git a/admin/assets/css/um-admin-misc.css b/admin/assets/css/um-admin-misc.css
index 684fef91..8b9c49cc 100644
--- a/admin/assets/css/um-admin-misc.css
+++ b/admin/assets/css/um-admin-misc.css
@@ -95,13 +95,13 @@ body.um-admin-modal-open {
.um-admin a.button-primary,
.um-admin input.button-primary {
- background: #3ba1da !important;
+ background: #3ba1da;
box-shadow: none !important;
border-radius: 2px;
color: #fff;
}
.um-admin a.button-primary:hover,
-.um-admin input.button-primary:hover {background: #44b0ec !important;}
+.um-admin input.button-primary:hover {background: #44b0ec;}
/*
- Form Inputs
diff --git a/admin/core/um-admin-enqueue.php b/admin/core/um-admin-enqueue.php
index 3ab317f2..b08d8130 100644
--- a/admin/core/um-admin-enqueue.php
+++ b/admin/core/um-admin-enqueue.php
@@ -232,9 +232,7 @@ class UM_Admin_Enqueue {
if ( strstr( $screen_id, 'ultimatemember') || strstr( $screen_id, 'um_') || strstr($screen_id, 'user') || strstr($screen_id, 'profile') )return true;
if ( $screen_id == 'nav-menus' ) return true;
-
- if ( isset( $post->post_type ) ) return true;
-
+
return false;
}
@@ -252,36 +250,33 @@ class UM_Admin_Enqueue {
*** @Enqueue scripts and styles
***/
function admin_enqueue_scripts(){
- global $ultimatemember;
+ global $ultimatemember, $post;
if ( $this->is_UM_admin() ) {
- $ultimatemember->styles->wp_enqueue_scripts();
-
- $this->load_global_css();
-
- $this->load_form();
-
- $this->load_modal();
-
- $this->load_dashboard();
-
- $this->load_field();
-
- $this->load_users_js();
-
- $this->load_builder();
-
- $this->load_redux_css();
-
- $this->load_css();
-
- $this->load_core_wp();
-
- $this->load_ajax_js();
-
- $this->load_custom_scripts();
+ $ultimatemember->styles->wp_enqueue_scripts();
+
+ $this->load_global_css();
+ $this->load_form();
+ $this->load_modal();
+ $this->load_dashboard();
+ $this->load_field();
+ $this->load_users_js();
+ $this->load_builder();
+ $this->load_redux_css();
+ $this->load_css();
+ $this->load_core_wp();
+ $this->load_ajax_js();
+ $this->load_custom_scripts();
+ } else if ( isset( $post->post_type ) ) {
+
+ $ultimatemember->styles->wp_enqueue_scripts();
+
+ $this->load_global_css();
+ $this->load_css();
+ $this->load_custom_scripts();
+
}
}
diff --git a/admin/templates/dashboard.php b/admin/templates/dashboard.php
index 36081002..343446d7 100644
--- a/admin/templates/dashboard.php
+++ b/admin/templates/dashboard.php
@@ -7,35 +7,21 @@
Dashboard
-
-
-
-
+
+
diff --git a/core/um-actions-user.php b/core/um-actions-user.php
index fd84cfc8..76cdf7a4 100644
--- a/core/um-actions-user.php
+++ b/core/um-actions-user.php
@@ -1,8 +1,26 @@
user->profile;
+ $files = glob( um_user_uploads_dir() . '*', GLOB_BRACE);
+ foreach($files as $file) {
+ $str = basename($file);
+ if ( !strstr( $str, 'profile_photo') && !strstr( $str, 'cover_photo') && !preg_grep('/' . $str . '/', $array ) )
+ unlink( $file );
+ }
+ um_reset_user();
+ }
+
/***
*** @listen to a new user creation in backend
***/
+ add_action( 'user_register', 'um_new_user_via_wpadmin', 10, 1 );
function um_new_user_via_wpadmin( $user_id ) {
if ( is_admin() ) {
@@ -21,5 +39,4 @@
}
- }
- add_action( 'user_register', 'um_new_user_via_wpadmin', 10, 1 );
\ No newline at end of file
+ }
\ No newline at end of file
diff --git a/core/um-files.php b/core/um-files.php
index 813e80a4..833f7e44 100644
--- a/core/um-files.php
+++ b/core/um-files.php
@@ -502,15 +502,10 @@ class UM_Files {
rmdir( $dir );
// update user's meta
- $existing = get_user_meta( $user_id, $key, true );
- if ( $existing ) {
- $file = basename( $existing );
- if ( $file != $filename ) {
- $delete_src = $this->upload_basedir . $user_id . '/' . basename( $existing );
- unlink( $delete_src );
- }
- }
update_user_meta( $user_id, $key, $filename );
+
+ // this action is executed after upload
+ do_action('um_after_user_upload', $user_id );
// the url of upload
return $this->upload_baseurl . $user_id . '/' . $filename;
diff --git a/core/um-short-functions.php b/core/um-short-functions.php
index 012870b3..bac05db3 100644
--- a/core/um-short-functions.php
+++ b/core/um-short-functions.php
@@ -1,17 +1,34 @@
+ *
+ * @returns Returns the user's IP address.
+ *
+ * @example The example below can retrieve the user's IP address
- } else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- return $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- return $_SERVER['REMOTE_ADDR'];
+
+
+ *
+ *
+ */
+function um_user_ip() {
+ if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
+ return $_SERVER['HTTP_CLIENT_IP'];
+ } else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
+ return $_SERVER['REMOTE_ADDR'];
+}
/***
*** @If conditions are met return true;
@@ -144,19 +161,40 @@
return $value;
}
- /***
- *** @profile user ID
- ***/
- function um_profile_id() {
+/**
+ * @function um_profile_id()
+ *
+ * @description This function returns the user ID for current profile.
+ *
+ * @usage
+ *
+ * @returns Returns the user ID of profile if found, or current user ID if user is logged in. Also returns blank
+ if no user ID is set.
+ *
+ * @example The example below will retrieve the user ID when viewing someone profile.
+
+
+
+ *
+ *
+ */
+function um_profile_id() {
+
+ if ( um_get_requested_user() ) {
+ return um_get_requested_user();
+ } else if ( is_user_logged_in() && get_current_user_id() ) {
+ return get_current_user_id();
}
+
+ return 0;
+}
/***
*** @Check that temp upload is valid
@@ -346,21 +384,49 @@
return $ultimatemember->members->results[ $argument ];
}
- /***
- *** @reset user clean
- ***/
- function um_reset_user_clean() {
- global $ultimatemember;
- $ultimatemember->user->reset( true );
- }
+/**
+ * @function um_reset_user_clean()
+ *
+ * @description This function is similar to um_reset_user() with a difference that it will not use the logged-in user
+ data after resetting. It is a hard-reset function for all user data.
+ *
+ * @usage
+ *
+ * @returns Clears the user data. You need to fetch a user manually after using this function.
+ *
+ * @example You can reset user data by using the following line in your code
+
+
+
+ *
+ *
+ */
+function um_reset_user_clean() {
+ global $ultimatemember;
+ $ultimatemember->user->reset( true );
+}
- /***
- *** @reset user
- ***/
- function um_reset_user() {
- global $ultimatemember;
- $ultimatemember->user->reset();
- }
+/**
+ * @function um_reset_user()
+ *
+ * @description This function resets the current user. You can use it to reset user data after
+ retrieving the details of a specific user.
+ *
+ * @usage
+ *
+ * @returns Clears the user data. If a user is logged in, the user data will be reset to that user's data
+ *
+ * @example You can reset user data by using the following line in your code
+
+
+
+ *
+ *
+ */
+function um_reset_user() {
+ global $ultimatemember;
+ $ultimatemember->user->reset();
+}
/***
*** @gets the queried user
@@ -479,7 +545,10 @@
***/
function um_can_edit_field( $data ) {
global $ultimatemember;
- if ( $ultimatemember->fields->editing == true && $ultimatemember->fields->set_mode == 'profile' ) {
+
+ if ( isset( $ultimatemember->fields->editing ) && $ultimatemember->fields->editing == true &&
+ isset( $ultimatemember->fields->set_mode ) && $ultimatemember->fields->set_mode == 'profile' ) {
+
if ( is_user_logged_in() && isset( $data['editable'] ) && $data['editable'] == 0 ) {
if ( um_is_user_himself() && !um_user('can_edit_everyone') )
@@ -489,8 +558,11 @@
return false;
}
+
}
+
return true;
+
}
/***
@@ -567,29 +639,49 @@
return um_get_option('admin_email');
}
- /***
- *** @Gets an option from DB
- ***/
- function um_get_option($option_id) {
- global $ultimatemember;
- $um_options = $ultimatemember->options;
- if ( isset($um_options[$option_id]) && !empty( $um_options[$option_id] ) ) {
- return $um_options[$option_id];
- }
-
- switch($option_id){
-
- case 'site_name':
- return get_bloginfo('name');
- break;
-
- case 'admin_email':
- return get_bloginfo('admin_email');
- break;
-
- }
-
+/**
+ * @function um_get_option()
+ *
+ * @description This function returns the value of an option or setting.
+ *
+ * @usage
+ *
+ * @param $option_id (string) (required) The option or setting that you want to retrieve
+ *
+ * @returns Returns the value of the setting you requested, or a blank value if the setting
+ does not exist.
+ *
+ * @example Get default user role set in global options
+
+
+
+ *
+ * @example Get blocked IP addresses set in backend
+
+
+
+ *
+ */
+function um_get_option($option_id) {
+ global $ultimatemember;
+ $um_options = $ultimatemember->options;
+ if ( isset($um_options[$option_id]) && !empty( $um_options[$option_id] ) ) {
+ return $um_options[$option_id];
}
+
+ switch($option_id){
+
+ case 'site_name':
+ return get_bloginfo('name');
+ break;
+
+ case 'admin_email':
+ return get_bloginfo('admin_email');
+ break;
+
+ }
+
+}
/***
*** @Display a link to profile page
@@ -607,13 +699,42 @@
return $ultimatemember->query->get_roles();
}
- /***
- *** @Sets up a user profile by ID
- ***/
- function um_fetch_user( $user_id ) {
- global $ultimatemember;
- $ultimatemember->user->set( $user_id );
- }
+/**
+ * @function um_fetch_user()
+ *
+ * @description This function sets a user and allow you to retrieve any information for the retrieved user
+ *
+ * @usage
+ *
+ * @param $user_id (numeric) (required) A user ID is required. This is the user's ID that you wish to set/retrieve
+ *
+ * @returns Sets a specific user and prepares profile data and user permissions and makes them accessible.
+ *
+ * @example The example below will set user ID 5 prior to retrieving his profile information.
+
+
+
+ *
+ * @example In the following example you can fetch the profile of a logged-in user dynamically.
+
+
+
+ *
+ */
+function um_fetch_user( $user_id ) {
+ global $ultimatemember;
+ $ultimatemember->user->set( $user_id );
+}
/***
*** @Load profile key
@@ -724,164 +845,192 @@
return '';
}
- /***
- *** @get user data
- ***/
- function um_user( $data, $attrs = null ) {
- global $ultimatemember;
+/**
+ * @function um_user()
+ *
+ * @description This function can be used to get user's data. This can be user profile data or user permissions.
+ *
+ * @usage
+ *
+ * @param $data (string) (required) The field or data you want to retrieve for user.
+ * @param $attrs (string) (optional) Additional attribute for profile data that may need extra configuration.
+ *
+ * @returns Returns the user data requested If found. A user must be previously set using um_fetch_user() to
+ properly retrieve user data.
+ *
+ * @example The example below can retrieve the user's display name
+
+
+
+ *
+ * @example The example below can retrieve user's community role
+
+
+
+ *
+ */
+function um_user( $data, $attrs = null ) {
+
+ global $ultimatemember;
- default:
+ switch($data){
+
+ default:
- $value = um_profile($data);
+ $value = um_profile($data);
- if ( $ultimatemember->validation->is_serialized( $value ) ) {
- $value = unserialize( $value );
- }
+ if ( $ultimatemember->validation->is_serialized( $value ) ) {
+ $value = unserialize( $value );
+ }
- return $value;
+ return $value;
+ break;
- break;
+ case 'full_name':
+
+ if ( !um_profile( $data ) ) {
- case 'full_name':
- if ( !um_profile( $data ) ) {
-
- if ( um_user('first_name') && um_user('last_name') ) {
- $full_name = um_user('first_name') . '.' . um_user('last_name');
- } else {
- $full_name = um_user('display_name');
- }
-
- $full_name = $ultimatemember->validation->safe_name_in_url( $full_name );
- update_user_meta( um_user('ID'), 'full_name', $full_name );
-
- return $full_name;
-
+ if ( um_user('first_name') && um_user('last_name') ) {
+ $full_name = um_user('first_name') . '.' . um_user('last_name');
} else {
-
- return um_profile( $data );
+ $full_name = um_user('display_name');
+ }
- }
- break;
-
- case 'display_name':
-
- $op = um_get_option('display_name');
-
- if ( $op == 'full_name' ) {
- if ( um_user('first_name') && um_user('last_name') ) {
- return um_user('first_name') . ' ' . um_user('last_name');
- } else {
- return um_profile( $data );
- }
- }
-
- if ( $op == 'sur_name' ) {
- if ( um_user('first_name') && um_user('last_name') ) {
- return um_user('last_name') . ', ' . um_user('first_name');
- } else {
- return um_profile( $data );
- }
- }
-
- if ( $op == 'first_name' ) {
- if ( um_user('first_name') ) {
- return um_user('first_name');
- } else {
- return um_profile( $data );
- }
- }
-
- if ( $op == 'username' ) {
- return um_user('user_login');
- }
-
- if ( $op == 'initial_name' ) {
- if ( um_user('first_name') && um_user('last_name') ) {
- $initial = um_user('last_name');
- return um_user('first_name') . ' ' . $initial[0];
- } else {
- return um_profile( $data );
- }
- }
-
- if ( $op == 'initial_name_f' ) {
- if ( um_user('first_name') && um_user('last_name') ) {
- $initial = um_user('first_name');
- return $initial[0] . ' ' . um_user('last_name');
- } else {
- return um_profile( $data );
- }
- }
-
- if ( $op == 'public_name' ) {
- return um_profile( $data );
- }
-
- if ( $op == 'field' && um_get_option('display_name_field') != '' ) {
- $fields = array_filter(preg_split('/[,\s]+/', um_get_option('display_name_field') ));
- $output = '';
- foreach( $fields as $field ) {
- $output .= um_profile( $field ) . ' ';
- }
- return $output;
- }
+ $full_name = $ultimatemember->validation->safe_name_in_url( $full_name );
+ update_user_meta( um_user('ID'), 'full_name', $full_name );
+
+ return $full_name;
+
+ } else {
return um_profile( $data );
+
+ }
+ break;
- break;
+ case 'display_name':
+
+ $op = um_get_option('display_name');
- case 'role_select':
- case 'role_radio':
- return um_user('role_name');
- break;
-
- case 'submitted':
- $array = um_profile($data);
- if ( empty( $array ) ) return '';
- $array = unserialize( $array );
- return $array;
- break;
-
- case 'password_reset_link':
- return $ultimatemember->password->reset_url();
- break;
-
- case 'account_activation_link':
- return $ultimatemember->permalinks->activate_url();
- break;
-
- case 'profile_photo':
-
- if ( um_profile('profile_photo') ) {
- $avatar_uri = um_get_avatar_uri( um_profile('profile_photo'), $attrs );
+ if ( $op == 'full_name' ) {
+ if ( um_user('first_name') && um_user('last_name') ) {
+ return um_user('first_name') . ' ' . um_user('last_name');
} else {
- $avatar_uri = um_get_default_avatar_uri();
+ return um_profile( $data );
}
+ }
- if ( $avatar_uri )
- return '
';
-
- if ( !$avatar_uri )
- return '';
-
- break;
-
- case 'cover_photo':
- if ( um_profile('cover_photo') ) {
- $cover_uri = um_get_cover_uri( um_profile('cover_photo'), $attrs );
+ if ( $op == 'sur_name' ) {
+ if ( um_user('first_name') && um_user('last_name') ) {
+ return um_user('last_name') . ', ' . um_user('first_name');
} else {
- $cover_uri = um_get_default_cover_uri();
+ return um_profile( $data );
}
+ }
- if ( $cover_uri )
- return '
';
+ if ( $op == 'first_name' ) {
+ if ( um_user('first_name') ) {
+ return um_user('first_name');
+ } else {
+ return um_profile( $data );
+ }
+ }
- if ( !$cover_uri )
- return '';
+ if ( $op == 'username' ) {
+ return um_user('user_login');
+ }
- break;
+ if ( $op == 'initial_name' ) {
+ if ( um_user('first_name') && um_user('last_name') ) {
+ $initial = um_user('last_name');
+ return um_user('first_name') . ' ' . $initial[0];
+ } else {
+ return um_profile( $data );
+ }
+ }
- }
- }
\ No newline at end of file
+ if ( $op == 'initial_name_f' ) {
+ if ( um_user('first_name') && um_user('last_name') ) {
+ $initial = um_user('first_name');
+ return $initial[0] . ' ' . um_user('last_name');
+ } else {
+ return um_profile( $data );
+ }
+ }
+
+ if ( $op == 'public_name' ) {
+ return um_profile( $data );
+ }
+
+ if ( $op == 'field' && um_get_option('display_name_field') != '' ) {
+ $fields = array_filter(preg_split('/[,\s]+/', um_get_option('display_name_field') ));
+ $output = '';
+ foreach( $fields as $field ) {
+ $output .= um_profile( $field ) . ' ';
+ }
+ return $output;
+ }
+
+ return um_profile( $data );
+
+ break;
+
+ case 'role_select':
+ case 'role_radio':
+ return um_user('role_name');
+ break;
+
+ case 'submitted':
+ $array = um_profile($data);
+ if ( empty( $array ) ) return '';
+ $array = unserialize( $array );
+ return $array;
+ break;
+
+ case 'password_reset_link':
+ return $ultimatemember->password->reset_url();
+ break;
+
+ case 'account_activation_link':
+ return $ultimatemember->permalinks->activate_url();
+ break;
+
+ case 'profile_photo':
+
+ if ( um_profile('profile_photo') ) {
+ $avatar_uri = um_get_avatar_uri( um_profile('profile_photo'), $attrs );
+ } else {
+ $avatar_uri = um_get_default_avatar_uri();
+ }
+
+ if ( $avatar_uri )
+ return '
';
+
+ if ( !$avatar_uri )
+ return '';
+
+ break;
+
+ case 'cover_photo':
+ if ( um_profile('cover_photo') ) {
+ $cover_uri = um_get_cover_uri( um_profile('cover_photo'), $attrs );
+ } else {
+ $cover_uri = um_get_default_cover_uri();
+ }
+
+ if ( $cover_uri )
+ return '
';
+
+ if ( !$cover_uri )
+ return '';
+
+ break;
+
+ }
+
+}
\ No newline at end of file
diff --git a/core/um-user.php b/core/um-user.php
index 3258af5d..097c5eac 100644
--- a/core/um-user.php
+++ b/core/um-user.php
@@ -26,10 +26,11 @@ class UM_User {
'user_email',
'user_pass',
'user_password',
+ 'display_name',
);
$this->target_id = null;
-
+
}
/***
@@ -127,7 +128,7 @@ class UM_User {
foreach($this->usermeta as $k=>$v){
$this->profile[$k] = $v[0];
}
-
+
// add user stuff
$this->profile['post_count'] = $ultimatemember->query->count_posts($this->id);
$this->profile['comment_count'] = $ultimatemember->query->count_comments($this->id);
diff --git a/index.php b/index.php
index a6d2844a..4b9b8191 100644
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
Plugin Name: Ultimate Member
Plugin URI: http://ultimatemember.com/
Description: Ultimate Member is a powerful community and membership plugin that allows you to create beautiful community and membership sites with WordPress
-Version: 1.0.43
+Version: 1.0.44
Author: Ultimate Member
Author URI: http://ultimatemember.com/
*/
diff --git a/readme.txt b/readme.txt
index 09aa7f37..940e3f18 100644
--- a/readme.txt
+++ b/readme.txt
@@ -7,7 +7,7 @@ Tags: access control, author, authors, author profile, comments, community, comm
Requires at least: 4.1
Tested up to: 4.1
-Stable Tag: 1.0.43
+Stable Tag: 1.0.44
License: GNU Version 2 or Any Later Version
@@ -185,6 +185,14 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
== Changelog ==
+= 1.0.44: February 8, 2015 =
+
+* Tweak: improved performance: unused user photos are deleted when user upload
+* Tweak: cleaned up dashboard code
+* Tweak: updated current translations
+* Fixed: display name field should be updated with wp_update_user and not in usermeta
+* Fixed: admin js and css should are loaded in UM backend only
+
= 1.0.43: February 7, 2015 =
* New: added German (Deutsch) language support