Version 1.0.29

This commit is contained in:
ultimatemember
2015-01-28 17:16:04 +02:00
parent 31dc7962bf
commit 78833fa2e3
24 changed files with 290 additions and 41 deletions
+3 -3
View File
@@ -29,8 +29,8 @@
$redirect = um_get_option('access_redirect');
$redirects[] = trailingslashit( um_get_core_page('login') );
$redirects[] = trailingslashit( um_get_option('access_redirect') );
$redirects[] = um_get_core_page('login');
$redirects[] = um_get_option('access_redirect');
$exclude_uris = um_get_option('access_exclude_uris');
@@ -38,7 +38,7 @@
$redirects = array_merge( $redirects, $exclude_uris );
}
$current_url = trailingslashit( $ultimatemember->permalinks->get_current_url(true) );
$current_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
if ( isset( $post->ID ) && in_array( $current_url, $redirects ) ) {
// allow
+1 -1
View File
@@ -51,7 +51,7 @@
return;
$ips = array_map("rtrim", explode("\n", $ips));
$user_ip = $_SERVER['REMOTE_ADDR'];
$user_ip = um_user_ip();
foreach($ips as $ip) {
$ip = str_replace('*','',$ip);
+3 -1
View File
@@ -517,7 +517,9 @@
<?php foreach( $tabs as $id => $tab ) {
$nav_link = $ultimatemember->permalinks->get_current_url(true);
$nav_link = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
$nav_link = remove_query_arg( 'um_action', $nav_link );
$nav_link = remove_query_arg( 'subnav', $nav_link );
$nav_link = add_query_arg('profiletab', $id, $nav_link )
?>
+5 -1
View File
@@ -9,8 +9,10 @@
// Login screen
if ( isset( $pagenow ) && $pagenow == 'wp-login.php' && !is_user_logged_in() && !isset( $_REQUEST['action'] ) ) {
$allowed = um_get_option('wpadmin_login');
$allowed = apply_filters('um_whitelisted_wpadmin_access', $allowed );
if ( !$allowed ) {
$act = um_get_option('wpadmin_login_redirect');
@@ -29,6 +31,8 @@
if ( isset( $pagenow ) && $pagenow == 'wp-login.php' && !is_user_logged_in() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'register' ) {
$allowed = um_get_option('wpadmin_register');
$allowed = apply_filters('um_whitelisted_wpadmin_access', $allowed );
if ( !$allowed ) {
$act = um_get_option('wpadmin_register_redirect');
+1 -1
View File
@@ -398,7 +398,7 @@ class UM_Builtin {
'divider' => array(
'name' => 'Divider',
'col1' => array('_title','_width','_visibility'),
'col1' => array('_title','_width','_divider_text','_visibility'),
'col2' => array('_style','_color'),
'form_only' => true,
'validate' => array(
+25 -2
View File
@@ -3,22 +3,45 @@
class UM_Enqueue {
function __construct() {
add_action('wp_head', array(&$this, 'wp_head'), 999); // high-priority
add_action('wp_enqueue_scripts', array(&$this, 'wp_enqueue_scripts'), 0);
}
/***
*** @Enqueue inline css globally
***/
function wp_head() {
$css = um_get_option('custom_css');
if ( !$css ) return; ?><!-- ULTIMATE MEMBER INLINE CSS BEGIN --><style type="text/css"><?php print $this->minify( $css ); ?></style><!-- ULTIMATE MEMBER INLINE CSS END --><?php
}
/***
*** @Minify css string
***/
function minify( $css ) {
$css = str_replace(array("\r", "\n"), '', $css);
$css = str_replace(' {','{', $css );
$css = str_replace('{ ','{', $css );
$css = str_replace('; ',';', $css );
$css = str_replace(';}','}', $css );
$css = str_replace(': ',':', $css );
return $css;
}
/***
*** @Enqueue scripts and styles
***/
function wp_enqueue_scripts(){
function wp_enqueue_scripts() {
global $ultimatemember;
$exclude = um_get_option('js_css_exclude');
if ( $exclude && is_array( $exclude ) ) {
$c_url = trailingslashit( $ultimatemember->permalinks->get_current_url(true) );
$c_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
foreach( $exclude as $match ) {
if ( strstr( $c_url, $match ) )
+14 -2
View File
@@ -697,6 +697,10 @@ class UM_Fields {
$array['borderstyle'] = 'solid';
}
if ( !isset( $array['divider_text'] ) ) {
$array['divider_text'] = '';
}
break;
case 'image':
@@ -1135,7 +1139,11 @@ class UM_Fields {
/* A line divider */
case 'divider':
$output .= '<div class="um-field-divider" style="border-bottom: '.$borderwidth.'px '.$borderstyle.' '.$bordercolor.'"></div>';
$output .= '<div class="um-field-divider" style="border-bottom: '.$borderwidth.'px '.$borderstyle.' '.$bordercolor.'">';
if ( $divider_text ) {
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
}
$output .= '</div>';
break;
/* Single Image Upload */
@@ -1857,7 +1865,11 @@ class UM_Fields {
/* A line divider */
case 'divider':
$output .= '<div class="um-field-divider" style="border-bottom: '.$borderwidth.'px '.$borderstyle.' '.$bordercolor.'"></div>';
$output .= '<div class="um-field-divider" style="border-bottom: '.$borderwidth.'px '.$borderstyle.' '.$bordercolor.'">';
if ( $divider_text ) {
$output .= '<div class="um-field-divider-text"><span>' . $divider_text . '</span></div>';
}
$output .= '</div>';
break;
/* Rating */
+22 -1
View File
@@ -1,10 +1,31 @@
<?php
/***
*** @filter to allow whitelisted IP to access the wp-admin login
***/
add_filter('um_whitelisted_wpadmin_access', 'um_whitelisted_wpadmin_access');
function um_whitelisted_wpadmin_access( $allowed ) {
$ips = um_get_option('wpadmin_allow_ips');
if ( !$ips )
return $allowed;
$ips = array_map("rtrim", explode("\n", $ips));
$user_ip = um_user_ip();
if ( in_array( $user_ip, $ips ) )
$allowed = 1;
return $allowed;
}
/***
*** @filter to customize errors
***/
add_filter('login_message', 'um_custom_wp_err_messages');
function um_custom_wp_err_messages( $message) {
function um_custom_wp_err_messages( $message ) {
if ( isset( $_REQUEST['err'] ) && !empty( $_REQUEST['err'] ) ) {
switch( $_REQUEST['err'] ) {
+13 -1
View File
@@ -1,7 +1,19 @@
<?php
/***
*** @Excludes menu items
*** @add dynamic profile headers
***/
add_filter( 'wp_nav_menu_items', 'um_add_custom_message_to_menu', 10, 2 );
function um_add_custom_message_to_menu( $items, $args ) {
global $ultimatemember;
if ( !is_user_logged_in() )
return $items;
$items = $ultimatemember->shortcodes->convert_user_tags( $items );
return $items;
}
/***
*** @conditional menu items
***/
if ( ! is_admin() ) {
+14
View File
@@ -3,7 +3,21 @@
class UM_Mail {
function __construct() {
add_filter('mandrill_nl2br', array(&$this, 'mandrill_nl2br') );
}
/***
*** @mandrill compatibility
***/
function mandrill_nl2br($nl2br, $message) {
// text emails
$nl2br = true;
return $nl2br;
}
/***
+24 -8
View File
@@ -1,5 +1,18 @@
<?php
/***
*** @Get user IP
***/
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;
***/
@@ -211,12 +224,12 @@
function um_is_core_uri() {
global $ultimatemember;
$array = $ultimatemember->permalinks->core;
$current_url = trailingslashit( $ultimatemember->permalinks->get_current_url(true) );
$current_url = $ultimatemember->permalinks->get_current_url( get_option('permalink_structure') );
if ( !isset( $array ) || !is_array( $array ) ) return false;
foreach( $array as $k => $id ) {
$page_url = trailingslashit( get_permalink( $id ) );
$page_url = get_permalink( $id );
if ( strstr( $current_url, $page_url ) )
return true;
}
@@ -377,7 +390,9 @@
***/
function um_edit_my_profile_uri() {
global $ultimatemember;
$url = $ultimatemember->permalinks->get_current_url(true);
$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 );
return $url;
}
@@ -483,6 +498,7 @@
$user_id = get_current_user_id();
$role = get_user_meta( $user_id, 'role', true );
$permissions = $ultimatemember->query->role_data( $role );
$permissions = apply_filters('um_user_permissions_filter', $permissions, $user_id);
if ( $permissions[ $permission ] == 1 )
return true;
return false;
@@ -514,14 +530,14 @@
case 'edit':
if ( get_current_user_id() == $user_id && um_user('can_edit_profile') ) $return = 1;
if ( !um_user('can_edit_everyone') ) $return = 0;
if ( get_current_user_id() == $user_id && !um_user('can_edit_profile') ) $return = 0;
if ( um_user('can_edit_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_edit_roles') ) ) $return = 0;
elseif ( !um_user('can_edit_everyone') ) $return = 0;
elseif ( get_current_user_id() == $user_id && !um_user('can_edit_profile') ) $return = 0;
elseif ( um_user('can_edit_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_edit_roles') ) ) $return = 0;
break;
case 'delete':
if ( !um_user('can_delete_everyone') ) $return = 0;
if ( um_user('can_delete_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_delete_roles') ) ) $return = 0;
elseif ( um_user('can_delete_roles') && !in_array( $ultimatemember->query->get_role_by_userid( $user_id ), um_user('can_delete_roles') ) ) $return = 0;
break;
}
+44
View File
@@ -113,12 +113,21 @@ class UM_Shortcodes {
*** @Load dynamic css
***/
function dynamic_css( $args=array() ) {
global $ultimatemember;
extract($args);
$global = um_path . 'assets/dynamic_css/dynamic_global.php';
$file = um_path . 'assets/dynamic_css/dynamic_'.$mode.'.php';
include $global;
if ( file_exists( $file ) )
include $file;
if ( isset( $args['custom_css'] ) ) {
$css = $args['custom_css'];
?><!-- ULTIMATE MEMBER FORM INLINE CSS BEGIN --><style type="text/css"><?php print $ultimatemember->styles->minify( $css ); ?></style><!-- ULTIMATE MEMBER FORM INLINE CSS END --><?php
}
}
/***
@@ -195,5 +204,40 @@ class UM_Shortcodes {
$shortcode = '[ultimatemember form_id='.$post_id.']';
return $shortcode;
}
/***
*** @convert user tags in a string
***/
function convert_user_tags( $str ) {
$pattern_array = array(
'{first_name}',
'{last_name}',
'{display_name}'
);
$pattern_array = apply_filters('um_allowed_user_tags_patterns', $pattern_array);
$matches = false;
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 );
}
return $str;
}
}
+1 -1
View File
@@ -135,7 +135,7 @@ class UM_User {
$user_role = $this->get_role();
$this->role_meta = $ultimatemember->query->role_data( $user_role );
$this->role_meta = apply_filters('um_user_permissions_filter', $this->role_meta, $this->id);
$this->profile = array_merge( $this->profile, (array)$this->role_meta);
$this->profile['super_admin'] = ( is_super_admin( $this->id ) ) ? 1 : 0;