Merge pull request #359 from ultimatemember/release/2.0

Release/2.0
This commit is contained in:
Champ Camba
2017-12-06 15:53:54 +08:00
committed by GitHub
38 changed files with 1407 additions and 1585 deletions
+26 -1
View File
@@ -1,5 +1,8 @@
### Ultimate Member Version
Tell us what UM core version you use. Do you use UM extensions? Tell us which UM extensions and what are their versions.
Tell us what UM core version you use.
- [x] 1.3.88 ( latest )
- [ ] 2.0 ( beta )
### Subject of the issue
Describe your issue here.
@@ -12,3 +15,25 @@ Tell us what happens instead
### Steps to reproduce the behavior
Tell us how to reproduce this issue.
### Do you use UM extensions?
- [ ] Private Content
- [ ] Instagram
- [ ] User Tags
- [ ] Social Activity
- [ ] WooCommerce
- [ ] Private Messages
- [ ] Followers
- [ ] Real-time Notifications
- [ ] Social Login
- [ ] bbPress
- [ ] MailChimp
- [ ] User Reviews
- [ ] Verified Users
- [ ] myCRED
- [ ] Notices
- [ ] Profile Completeness
- [ ] Friends
- [ ] Terms & Conditions
- [ ] Google reCAPTCHA
- [ ] Online Users
+1 -1
View File
@@ -23,7 +23,7 @@ jQuery(document).ready(function() {
jQuery(this).addClass('active');
});
jQuery(document).on('click', '.um-cover a, .um-photo a', function(e){
jQuery(document).on('click', '.um-cover a.um-cover-add, .um-photo a', function(e){
e.preventDefault();
return false;
});
+2 -1
View File
@@ -40,5 +40,6 @@ function um_admin_update_builder() {
}
jQuery(document).ready(function() {
if ( um_admin_builder_data.hide_footer )
jQuery('#wpfooter').hide();
});
@@ -9,4 +9,13 @@ jQuery( document ).ready( function() {
}
}).trigger('change');
jQuery( '#adduser-role' ).change( function() {
if ( jQuery.inArray( jQuery(this).val().substr(3), um_roles ) !== -1 ) {
jQuery( '#um_role_existing_selector_wrapper' ).hide();
jQuery( '#um-role' ).val('');
} else {
jQuery( '#um_role_existing_selector_wrapper' ).show();
}
}).trigger('change');
});
@@ -19,6 +19,8 @@ if ( ! class_exists( 'Admin_Columns' ) ) {
add_filter('post_row_actions', array(&$this, 'post_row_actions'), 99, 2);
// Add a post display state for special UM pages.
add_filter( 'display_post_states', array( &$this, 'add_display_post_states' ), 10, 2 );
}
/***
@@ -117,5 +119,25 @@ if ( ! class_exists( 'Admin_Columns' ) ) {
}
/**
* Add a post display state for special UM pages in the page list table.
*
* @param array $post_states An array of post display states.
* @param WP_Post $post The current post object.
*/
public function add_display_post_states( $post_states, $post ) {
foreach ( UM()->config()->core_pages as $page_key => $page_value ) {
$page_id = UM()->um_get_option( apply_filters( 'um_core_page_id_filter', 'core_' . $page_key ) );
if ( $page_id == $post->ID )
$post_states['um_core_page_' . $page_key] = sprintf('UM %s', $page_value['title'] ) ;
}
return $post_states;
}
}
}
@@ -227,8 +227,20 @@ if ( ! class_exists( 'Admin_Enqueue' ) ) {
wp_register_script( 'um_admin_builder', $this->js_url . 'um-admin-builder.js', '', '', true );
wp_enqueue_script( 'um_admin_builder' );
//hide footer text on add/edit UM Forms
//layouts crashed because we load and hide metaboxes
//and WP calculate page height
$hide_footer = false;
global $pagenow, $post;
if ( ( 'post.php' == $pagenow || 'post-new.php' == $pagenow ) &&
( ( isset( $_GET['post_type'] ) && 'um_form' == $_GET['post_type'] ) ||
( isset( $post->post_type ) && 'um_form' == $post->post_type ) ) ) {
$hide_footer = true;
}
$localize_data = array(
'ajax_url' => UM()->get_ajax_route( 'um\admin\core\Admin_Builder', 'update_builder' ),
'hide_footer' => $hide_footer,
);
wp_localize_script( 'um_admin_builder', 'um_admin_builder_data', $localize_data );
+241 -230
View File
@@ -22,9 +22,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
add_action( 'load-post.php', array(&$this, 'add_metabox'), 9 );
add_action( 'load-post-new.php', array(&$this, 'add_metabox'), 9 );
add_action( 'plugins_loaded', array(&$this, 'add_taxonomy_metabox'), 9 );
add_action( 'admin_init', array(&$this, 'add_taxonomy_metabox'), 9 );
//roles metaboxes
add_action( 'um_roles_add_meta_boxes', array( &$this, 'add_metabox_role' ) );
@@ -103,8 +101,13 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
//restrict content metabox
$post_types = um_get_option( 'restricted_access_post_metabox' );
if ( ! empty( $post_types[ $current_screen->id ] ) ) {
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
$hide_metabox = apply_filters( 'um_restrict_content_hide_metabox', false );
if ( ! $hide_metabox ) {
add_action( 'add_meta_boxes', array(&$this, 'add_metabox_restrict_content'), 1 );
add_action( 'save_post', array( &$this, 'save_metabox_restrict_content' ), 10, 2 );
}
if ( $current_screen->id == 'attachment' ) {
add_action( 'add_attachment', array( &$this, 'save_attachment_metabox_restrict_content' ), 10, 2 );
@@ -209,111 +212,113 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
function um_category_access_fields_create() {
$data = array();
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
array(
'id' => '_um_custom_access_settings',
'type' => 'checkbox',
'name' => '_um_custom_access_settings',
'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
),
array(
'id' => '_um_accessible',
'type' => 'select',
'name' => '_um_accessible',
'label' => __( 'Who can access this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
'options' => array(
'0' => __( 'Everyone', 'ultimate-member' ),
'1' => __( 'Logged out users', 'ultimate-member' ),
'2' => __( 'Logged in users', 'ultimate-member' ),
),
'conditional' => array( '_um_custom_access_settings', '=', '1' )
),
array(
'id' => '_um_access_roles',
'type' => 'multi_checkbox',
'name' => '_um_access_roles',
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
array(
'id' => '_um_noaccess_action',
'type' => 'select',
'name' => '_um_noaccess_action',
'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
'options' => array(
'0' => __( 'Show access restricted message', 'ultimate-member' ),
'1' => __( 'Redirect user', 'ultimate-member' ),
),
'conditional' => array( '_um_accessible', '!=', '0' )
),
array(
'id' => '_um_restrict_by_custom_message',
'type' => 'select',
'name' => '_um_restrict_by_custom_message',
'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
'options' => array(
'0' => __( 'Global default message (default)', 'ultimate-member' ),
'1' => __( 'Custom message', 'ultimate-member' ),
),
'conditional' => array( '_um_noaccess_action', '=', '0' )
),
array(
'id' => '_um_restrict_custom_message',
'type' => 'wp_editor',
'name' => '_um_restrict_custom_message',
'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
),
array(
'id' => '_um_access_redirect',
'type' => 'select',
'name' => '_um_access_redirect',
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
'conditional' => array( '_um_noaccess_action', '=', '1' ),
'options' => array(
'0' => __( 'Login page', 'ultimate-member' ),
'1' => __( 'Custom URL', 'ultimate-member' ),
),
),
array(
'id' => '_um_access_redirect_url',
'type' => 'text',
'name' => '_um_access_redirect_url',
'label' => __( 'Redirect URL', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
'conditional' => array( '_um_access_redirect', '=', '1' )
),
array(
'id' => '_um_access_hide_from_queries',
'type' => 'checkbox',
'name' => '_um_access_hide_from_queries',
'label' => __( 'Hide from queries', 'ultimate-member' ),
'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
'conditional' => array( '_um_accessible', '!=', '0' )
)
), $data, 'create' );
UM()->admin_forms( array(
'class' => 'um-restrict-content um-third-column',
'prefix_id' => 'um_content_restriction',
'without_wrapper' => true,
'div_line' => true,
'fields' => array(
array(
'id' => '_um_custom_access_settings',
'type' => 'checkbox',
'name' => '_um_custom_access_settings',
'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
),
array(
'id' => '_um_accessible',
'type' => 'select',
'name' => '_um_accessible',
'label' => __( 'Who can access this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
'options' => array(
'0' => __( 'Everyone', 'ultimate-member' ),
'1' => __( 'Logged out users', 'ultimate-member' ),
'2' => __( 'Logged in users', 'ultimate-member' ),
),
'conditional' => array( '_um_custom_access_settings', '=', '1' )
),
array(
'id' => '_um_access_roles',
'type' => 'multi_checkbox',
'name' => '_um_access_roles',
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
array(
'id' => '_um_noaccess_action',
'type' => 'select',
'name' => '_um_noaccess_action',
'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
'options' => array(
'0' => __( 'Show access restricted message', 'ultimate-member' ),
'1' => __( 'Redirect user', 'ultimate-member' ),
),
'conditional' => array( '_um_accessible', '!=', '0' )
),
array(
'id' => '_um_restrict_by_custom_message',
'type' => 'select',
'name' => '_um_restrict_by_custom_message',
'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
'options' => array(
'0' => __( 'Global default message (default)', 'ultimate-member' ),
'1' => __( 'Custom message', 'ultimate-member' ),
),
'conditional' => array( '_um_noaccess_action', '=', '0' )
),
array(
'id' => '_um_restrict_custom_message',
'type' => 'wp_editor',
'name' => '_um_restrict_custom_message',
'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
),
array(
'id' => '_um_access_redirect',
'type' => 'select',
'name' => '_um_access_redirect',
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
'conditional' => array( '_um_noaccess_action', '=', '1' ),
'options' => array(
'0' => __( 'Login page', 'ultimate-member' ),
'1' => __( 'Custom URL', 'ultimate-member' ),
),
),
array(
'id' => '_um_access_redirect_url',
'type' => 'text',
'name' => '_um_access_redirect_url',
'label' => __( 'Redirect URL', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
'conditional' => array( '_um_access_redirect', '=', '1' )
),
array(
'id' => '_um_access_hide_from_queries',
'type' => 'checkbox',
'name' => '_um_access_hide_from_queries',
'label' => __( 'Hide from queries', 'ultimate-member' ),
'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
'conditional' => array( '_um_accessible', '!=', '0' )
)
)
'fields' => $fields
) )->render_form();
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
@@ -334,120 +339,122 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
}
$fields = apply_filters( 'um_admin_category_access_settings_fields', array(
array(
'id' => '_um_custom_access_settings',
'type' => 'checkbox',
'class' => 'form-field',
'name' => '_um_custom_access_settings',
'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
),
array(
'id' => '_um_accessible',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_accessible',
'label' => __( 'Who can access this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
'options' => array(
'0' => __( 'Everyone', 'ultimate-member' ),
'1' => __( 'Logged out users', 'ultimate-member' ),
'2' => __( 'Logged in users', 'ultimate-member' ),
),
'conditional' => array( '_um_custom_access_settings', '=', '1' )
),
array(
'id' => '_um_access_roles',
'type' => 'multi_checkbox',
'class' => 'form-field',
'name' => '_um_access_roles',
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => $_um_access_roles_value,
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
array(
'id' => '_um_noaccess_action',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_noaccess_action',
'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
'options' => array(
'0' => __( 'Show access restricted message', 'ultimate-member' ),
'1' => __( 'Redirect user', 'ultimate-member' ),
),
'conditional' => array( '_um_accessible', '!=', '0' )
),
array(
'id' => '_um_restrict_by_custom_message',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_restrict_by_custom_message',
'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
'options' => array(
'0' => __( 'Global default message (default)', 'ultimate-member' ),
'1' => __( 'Custom message', 'ultimate-member' ),
),
'conditional' => array( '_um_noaccess_action', '=', '0' )
),
array(
'id' => '_um_restrict_custom_message',
'type' => 'wp_editor',
'class' => 'form-field',
'name' => '_um_restrict_custom_message',
'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
),
array(
'id' => '_um_access_redirect',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_access_redirect',
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
'conditional' => array( '_um_noaccess_action', '=', '1' ),
'options' => array(
'0' => __( 'Login page', 'ultimate-member' ),
'1' => __( 'Custom URL', 'ultimate-member' ),
),
),
array(
'id' => '_um_access_redirect_url',
'type' => 'text',
'class' => 'form-field',
'name' => '_um_access_redirect_url',
'label' => __( 'Redirect URL', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
'conditional' => array( '_um_access_redirect', '=', '1' )
),
array(
'id' => '_um_access_hide_from_queries',
'type' => 'checkbox',
'class' => 'form-field',
'name' => '_um_access_hide_from_queries',
'label' => __( 'Hide from queries', 'ultimate-member' ),
'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
'conditional' => array( '_um_accessible', '!=', '0' )
)
), $data, 'edit' );
UM()->admin_forms( array(
'class' => 'um-restrict-content um-third-column',
'prefix_id' => 'um_content_restriction',
'without_wrapper' => true,
'fields' => array(
array(
'id' => '_um_custom_access_settings',
'type' => 'checkbox',
'class' => 'form-field',
'name' => '_um_custom_access_settings',
'label' => __( 'Restrict access to this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0,
),
array(
'id' => '_um_accessible',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_accessible',
'label' => __( 'Who can access this content?', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0,
'options' => array(
'0' => __( 'Everyone', 'ultimate-member' ),
'1' => __( 'Logged out users', 'ultimate-member' ),
'2' => __( 'Logged in users', 'ultimate-member' ),
),
'conditional' => array( '_um_custom_access_settings', '=', '1' )
),
array(
'id' => '_um_access_roles',
'type' => 'multi_checkbox',
'class' => 'form-field',
'name' => '_um_access_roles',
'label' => __( 'Select which roles can access this content', 'ultimate-member' ),
'description' => __( 'Activate content restriction for this post', 'ultimate-member' ),
'value' => $_um_access_roles_value,
'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ),
'columns' => 3,
'conditional' => array( '_um_accessible', '=', '2' )
),
array(
'id' => '_um_noaccess_action',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_noaccess_action',
'label' => __( 'What happens when users without access tries to view the content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_noaccess_action'] ) ? $data['_um_noaccess_action'] : 0,
'options' => array(
'0' => __( 'Show access restricted message', 'ultimate-member' ),
'1' => __( 'Redirect user', 'ultimate-member' ),
),
'conditional' => array( '_um_accessible', '!=', '0' )
),
array(
'id' => '_um_restrict_by_custom_message',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_restrict_by_custom_message',
'label' => __( 'Would you like to use the global default message or apply a custom message to this content?', 'ultimate-member' ),
'description' => __( 'Action when users without access tries to view the content', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_by_custom_message'] ) ? $data['_um_restrict_by_custom_message'] : '0',
'options' => array(
'0' => __( 'Global default message (default)', 'ultimate-member' ),
'1' => __( 'Custom message', 'ultimate-member' ),
),
'conditional' => array( '_um_noaccess_action', '=', '0' )
),
array(
'id' => '_um_restrict_custom_message',
'type' => 'wp_editor',
'class' => 'form-field',
'name' => '_um_restrict_custom_message',
'label' => __( 'Custom Restrict Content message', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_restrict_custom_message'] ) ? $data['_um_restrict_custom_message'] : '',
'conditional' => array( '_um_restrict_by_custom_message', '=', '1' )
),
array(
'id' => '_um_access_redirect',
'type' => 'select',
'class' => 'form-field',
'name' => '_um_access_redirect',
'label' => __( 'Where should users be redirected to?', 'ultimate-member' ),
'description' => __( 'Select redirect to page when user hasn\'t access to content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect'] ) ? $data['_um_access_redirect'] : '0',
'conditional' => array( '_um_noaccess_action', '=', '1' ),
'options' => array(
'0' => __( 'Login page', 'ultimate-member' ),
'1' => __( 'Custom URL', 'ultimate-member' ),
),
),
array(
'id' => '_um_access_redirect_url',
'type' => 'text',
'class' => 'form-field',
'name' => '_um_access_redirect_url',
'label' => __( 'Redirect URL', 'ultimate-member' ),
'description' => __( 'Changed global restrict message', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '',
'conditional' => array( '_um_access_redirect', '=', '1' )
),
array(
'id' => '_um_access_hide_from_queries',
'type' => 'checkbox',
'class' => 'form-field',
'name' => '_um_access_hide_from_queries',
'label' => __( 'Hide from queries', 'ultimate-member' ),
'description' => __( 'Hide this content from archives, RSS feeds etc for users who do not have permission to view this content', 'ultimate-member' ),
'value' => ! empty( $data['_um_access_hide_from_queries'] ) ? $data['_um_access_hide_from_queries'] : '',
'conditional' => array( '_um_accessible', '!=', '0' )
)
)
'fields' => $fields
) )->render_form();
wp_nonce_field( basename( __FILE__ ), 'um_admin_save_taxonomy_restrict_content_nonce' );
@@ -620,15 +627,21 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
'screen' => 'um_role_meta',
'context' => 'normal',
'priority' => 'default'
),
array(
)
);
if ( ! isset( $_GET['id'] ) || 'administrator' != $_GET['id'] ) {
$roles_metaboxes[] = array(
'id' => 'um-admin-form-home',
'title' => __( 'Homepage Options', 'ultimate-member' ),
'callback' => $callback,
'screen' => 'um_role_meta',
'context' => 'normal',
'priority' => 'default'
),
);
}
$roles_metaboxes = array_merge( $roles_metaboxes, array(
array(
'id' => 'um-admin-form-register',
'title' => __( 'Registration Options', 'ultimate-member' ),
@@ -669,7 +682,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
'context' => 'side',
'priority' => 'default'
)
);
) );
$roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes );
@@ -856,7 +869,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
}
// needed on forms only
if ( !isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
if ( ! isset( $this->is_loaded ) && isset( $screen->id ) && strstr( $screen->id, 'um_form' ) ) {
$settings['textarea_rows'] = 8;
@@ -868,6 +881,7 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
wp_editor( '', 'um_editor_new', $settings );
echo '</div>';
$this->is_loaded = true;
}
}
@@ -1952,20 +1966,17 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
case '_parent_dropdown_relationship':
?>
<p><label for="_parent_dropdown_relationship">Parent Option<?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
<p><label for="_parent_dropdown_relationship"><?php _e( 'Parent Option', 'ultimate-member' ) ?><?php UM()->tooltip( __( 'Dynamically populates the option based from selected parent option.', 'ultimate-member' ) ); ?></label>
<select name="_parent_dropdown_relationship" id="_parent_dropdown_relationship" style="width: 100%">
<option value="">No Selected</option>
<?php
if ( UM()->builtin()->custom_fields ) {
foreach (UM()->builtin()->custom_fields as $field_key => $array) {
if( in_array( $array['type'], array( 'select' ) )
&& $field_args['metakey'] != $array['metakey'] ){
<option value=""><?php _e( 'No Selected', 'ultimate-member' ) ?></option>
<?php if ( UM()->builtin()->custom_fields ) {
foreach ( UM()->builtin()->custom_fields as $field_key => $array ) {
if ( in_array( $array['type'], array( 'select' ) ) && ( ! isset( $field_args['metakey'] ) || $field_args['metakey'] != $array['metakey'] ) ) {
echo "<option value='".$array['metakey']."' ".selected( $array['metakey'], $this->edit_mode_value ).">".$array['title']."</option>";
}
}
}
?>
} ?>
</select>
</p>
+8 -5
View File
@@ -115,6 +115,9 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
$tabs = UM()->profile()->tabs_primary();
foreach( $tabs as $id => $tab ) {
$profile_tab_roles = UM()->um_get_option( 'profile_tab_' . $id . '_roles' );
$appearances_profile_menu_fields = array_merge( $appearances_profile_menu_fields, array(
array(
'id' => 'profile_tab_' . $id,
@@ -144,7 +147,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
'options' => UM()->roles()->get_roles(),
'placeholder' => __( 'Choose user roles...','ultimate-member' ),
'conditional' => array( 'profile_tab_' . $id . '_privacy', '=', 4 ),
'value' => ! empty( UM()->um_get_option( 'profile_tab_' . $id . '_roles' ) ) ? UM()->um_get_option( 'profile_tab_' . $id . '_roles' ) : array(),
'value' => ! empty( $profile_tab_roles ) ? $profile_tab_roles : array(),
'default' => UM()->um_get_default( 'profile_tab_' . $id . '_roles' ),
'size' => 'small'
)
@@ -1121,11 +1124,11 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
)
),
array(
'id' => 'allow_tracking',
'id' => 'um_allow_tracking',
'type' => 'checkbox',
'label' => __( 'Allow Tracking','ultimate-member' ),
'value' => UM()->um_get_option( 'allow_tracking' ),
'default' => UM()->um_get_default( 'allow_tracking' ),
'value' => UM()->um_get_option( 'um_allow_tracking' ),
'default' => UM()->um_get_default( 'um_allow_tracking' ),
),
array(
'id' => 'uninstall_on_delete',
@@ -1404,7 +1407,7 @@ if ( ! class_exists( 'Admin_Settings' ) ) {
$filtered_settings[$key] = $value;
foreach( $fields as $field ) {
if ( $field['id'] == $key && $field['type'] == 'multi_text' ) {
if ( $field['id'] == $key && isset( $field['type'] ) && $field['type'] == 'multi_text' ) {
$filtered_settings[$key] = array_filter( $settings[$key] );
}
}
+9 -9
View File
@@ -56,17 +56,17 @@ if ( ! class_exists( 'Admin_Upgrade' ) ) {
function set_update_versions() {
$update_versions = array();
$handle = opendir( $this->packages_dir );
while ( false !== ( $filename = readdir( $handle ) ) ) {
if ( $handle ) {
while ( false !== ( $filename = readdir( $handle ) ) ) {
if ( $filename != '.' && $filename != '..' )
$update_versions[] = preg_replace( '/(.*?)\.php/i', '$1', $filename );
}
closedir( $handle );
if ( $filename != '.' && $filename != '..' )
$update_versions[] = preg_replace( '/(.*?)\.php/i', '$1', $filename );
usort( $update_versions, array( &$this, 'version_compare_sort' ) );
}
closedir( $handle );
usort( $update_versions, array( &$this, 'version_compare_sort' ) );
$this->update_versions = $update_versions;
$this->update_versions = $update_versions;
}
}
@@ -135,8 +135,7 @@ class UM_Emails_List_Table extends WP_List_Table {
function column_email( $item ) {
$active = um_get_option( $item['key'] . '_on' );
if ( $active === '' )
$active = ! empty( $item['default_active'] );
return '<span class="dashicons um-notification-status ' . ( ! empty( $active ) ? 'um-notification-is-active dashicons-yes' : 'dashicons-no-alt' ) . '"></span><a href="' . add_query_arg( array( 'email' => $item['key'] ) ) . '"><strong>'. $item['title'] . '</strong></a>';
}
@@ -39,6 +39,8 @@ if ( isset( $_GET['action'] ) ) {
delete_option( "um_role_{$role_key}_meta" );
$um_roles = array_diff( $um_roles, array( $role_key ) );
$role_keys[$k] = 'um_' . $role_key;
}
@@ -67,6 +69,8 @@ if ( isset( $_GET['action'] ) ) {
}
}
update_option( 'um_roles', $um_roles );
um_js_redirect( add_query_arg( 'msg', 'd', $redirect ) );
break;
}
+67 -28
View File
@@ -1014,16 +1014,48 @@ if ( ! empty( $um_roles ) ) {
update_option( 'um_roles', $role_keys );
global $wp_roles, $wp_version;
if ( version_compare( $wp_version, '4.9', '<' ) ) {
$wp_roles->_init();
} elseif ( method_exists( $wp_roles, 'for_site' ) ) {
$wp_roles->for_site( get_current_blog_id() );
}
//Content Restriction transfer
//for check all post types and taxonomies
$all_post_types = get_post_types( array( 'public' => true ) );
$all_taxonomies = get_taxonomies( array( 'public' => true ) );
$exclude_taxonomies = UM()->excluded_taxonomies();
foreach ( $all_taxonomies as $key => $taxonomy ) {
if( in_array( $key, $exclude_taxonomies ) )
unset( $all_taxonomies[ $key ] );
}
foreach ( $all_post_types as $key => $value ) {
$all_post_types[ $key ] = true;
}
foreach ( $all_taxonomies as $key => $value ) {
$all_taxonomies[ $key ] = true;
}
um_update_option( 'restricted_access_post_metabox', $all_post_types );
um_update_option( 'restricted_access_taxonomy_metabox', $all_taxonomies );
$roles_array = UM()->roles()->get_roles( false, array( 'administrator' ) );
$posts = get_posts( array(
'meta_key' => '_um_custom_access_settings',
'meta_value' => '1',
'fields' => 'ids'
'post_type' => 'any',
'meta_key' => '_um_custom_access_settings',
'meta_value' => '1',
'fields' => 'ids',
'numberposts' => -1
) );
if ( ! empty( $posts ) ) {
foreach ( $posts as $post_id ) {
$um_accessible = get_post_meta( $post_id, '_um_accessible', true );
@@ -1032,17 +1064,18 @@ if ( ! empty( $posts ) ) {
$access_roles = array();
if ( ! empty( $um_access_roles ) ) {
foreach ( $roles_array as $role ) {
foreach ( $roles_array as $role => $role_label ) {
if ( in_array( substr( $role, 3 ), $um_access_roles ) )
$access_roles[$role] = '1';
$access_roles[ $role ] = '1';
else
$access_roles[$role] = '0';
$access_roles[ $role ] = '0';
}
} else {
foreach ( $roles_array as $role ) {
$access_roles[$role] = '0';
foreach ( $roles_array as $role => $role_label ) {
$access_roles[ $role ] = '0';
}
}
$restrict_options = array(
'_um_custom_access_settings' => '1',
'_um_accessible' => $um_accessible,
@@ -1073,31 +1106,36 @@ foreach ( $all_taxonomies as $key => $taxonomy ) {
'fields' => 'ids'
) );
if ( empty( $terms ) )
continue;
foreach ( $terms as $term_id ) {
$term_meta = get_option( "{$taxonomy}_{$term_id}" );
$term_meta = get_option( "category_{$term_id}" );
if ( empty( $term_meta ) )
continue;
$um_accessible = $term_meta['_um_accessible'];
$um_access_roles = $term_meta['_um_access_roles'];
$um_access_redirect = ( $um_accessible == '2' ) ? $term_meta['_um_access_redirect'] : $term_meta['_um_access_redirect2'];
$um_accessible = ! empty( $term_meta['_um_accessible'] ) ? $term_meta['_um_accessible'] : false;
$um_access_roles = ! empty( $term_meta['_um_roles'] ) ? $term_meta['_um_roles'] : array();
$redirect = ! empty( $term_meta['_um_redirect'] ) ? $term_meta['_um_redirect'] : '';
$redirect2 = ! empty( $term_meta['_um_redirect2'] ) ? $term_meta['_um_redirect2'] : '';
$um_access_redirect = ( $um_accessible == '2' ) ? $redirect : $redirect2;
$access_roles = array();
if ( ! empty( $um_access_roles ) ) {
foreach ( $roles_array as $role ) {
if ( in_array( substr( $role, 3 ), $um_access_roles ) )
$access_roles[$role] = '1';
else
$access_roles[$role] = '0';
}
} else {
foreach ( $roles_array as $role ) {
$access_roles[$role] = '0';
}
}
$access_roles = array();
if ( ! empty( $um_access_roles ) ) {
foreach ( $roles_array as $role => $role_label ) {
if ( in_array( substr( $role, 3 ), $um_access_roles ) )
$access_roles[ $role ] = '1';
else
$access_roles[ $role ] = '0';
}
} else {
foreach ( $roles_array as $role => $role_label ) {
$access_roles[ $role ] = '0';
}
}
$restrict_options = array(
$restrict_options = array(
'_um_custom_access_settings' => '1',
'_um_accessible' => $um_accessible,
'_um_access_roles' => $access_roles,
@@ -1216,7 +1254,8 @@ $menus = get_posts( array(
'key' => 'menu-item-um_nav_roles',
'compare' => 'EXISTS',
)
)
),
'numberposts' => -1,
) );
foreach ( $menus as $menu ) {
@@ -7,22 +7,27 @@
function um_admin_pre_save_field_to_form( $array ){
unset( $array['conditions'] );
if ( isset($array['conditional_field']) && !empty( $array['conditional_action'] ) && !empty( $array['conditional_operator'] ) ) {
$array['conditional_value'] = ! empty( $array['conditional_value'] ) ? $array['conditional_value'] : '';
$array['conditions'][] = array( $array['conditional_action'], $array['conditional_field'], $array['conditional_operator'], $array['conditional_value'] );
}
if ( isset($array['conditional_field1']) && !empty( $array['conditional_action1'] ) && !empty( $array['conditional_operator1'] ) ) {
$array['conditional_value1'] = ! empty( $array['conditional_value1'] ) ? $array['conditional_value1'] : '';
$array['conditions'][] = array( $array['conditional_action1'], $array['conditional_field1'], $array['conditional_operator1'], $array['conditional_value1'] );
}
if ( isset($array['conditional_field2']) && !empty( $array['conditional_action2'] ) && !empty( $array['conditional_operator2'] ) ) {
$array['conditional_value2'] = ! empty( $array['conditional_value2'] ) ? $array['conditional_value2'] : '';
$array['conditions'][] = array( $array['conditional_action2'], $array['conditional_field2'], $array['conditional_operator2'], $array['conditional_value2'] );
}
if ( isset($array['conditional_field3']) && !empty( $array['conditional_action3'] ) && !empty( $array['conditional_operator3'] ) ) {
$array['conditional_value3'] = ! empty( $array['conditional_value3'] ) ? $array['conditional_value3'] : '';
$array['conditions'][] = array( $array['conditional_action3'], $array['conditional_field3'], $array['conditional_operator3'], $array['conditional_value3'] );
}
if ( isset($array['conditional_field4']) && !empty( $array['conditional_action4'] ) && !empty( $array['conditional_operator4'] ) ) {
$array['conditional_value4'] = ! empty( $array['conditional_value4'] ) ? $array['conditional_value4'] : '';
$array['conditions'][] = array( $array['conditional_action4'], $array['conditional_field4'], $array['conditional_operator4'], $array['conditional_value4'] );
}
@@ -126,3 +131,15 @@
return $break;
}
add_filter( 'um_restrict_content_hide_metabox', 'um_hide_metabox_restrict_content_shop', 10, 1 );
function um_hide_metabox_restrict_content_shop( $hide ) {
if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) &&
$_GET['post'] == wc_get_page_id( 'shop' ) ) {
return true;
}
return $hide;
}
+2 -2
View File
@@ -3,9 +3,9 @@
$all_options = wp_load_alloptions();
$count = 0;
foreach( $all_options as $k => $v ) {
foreach ( $all_options as $k => $v ) {
if ( strstr( $k, 'um_cache_userdata_' ) ) {
if ( strstr( $k, 'um_cache_userdata_' ) !== false ) {
$count++;
}
+23 -23
View File
@@ -20,29 +20,29 @@ if ( ! class_exists( 'um\Dependencies' ) ) {
* @var array
*/
public $ext_required_version = array(
'bbpress' => '2.0-beta1',
'followers' => '2.0-beta1',
'friends' => '2.0-beta1',
'groups' => '2.0-beta1',
'instagram' => '2.0-beta1',
'invitations' => '2.0-beta1',
'mailchimp' => '2.0-beta1',
'messaging' => '2.0-beta1',
'mycred' => '2.0-beta1',
'notices' => '2.0-beta1',
'notifications' => '2.0-beta1',
'online' => '2.0-beta1',
'private-content' => '2.0-beta1',
'profile-completeness' => '2.0-beta1',
'recaptcha' => '2.0-beta1',
'reviews' => '2.0-beta1',
'social-activity' => '2.0-beta1',
'social-login' => '2.0-beta1',
'terms-conditions' => '2.0-beta1',
'user-location' => '2.0-beta1',
'user-tags' => '2.0-beta1',
'verified-users' => '2.0-beta1',
'woocommerce' => '2.0-beta1',
'bbpress' => '2.0',
'followers' => '2.0',
'friends' => '2.0',
'groups' => '2.0',
'instagram' => '2.0',
'invitations' => '2.0',
'mailchimp' => '2.0',
'messaging' => '2.0',
'mycred' => '2.0',
'notices' => '2.0',
'notifications' => '2.0',
'online' => '2.0',
'private-content' => '2.0',
'profile-completeness' => '2.0',
'recaptcha' => '2.0',
'reviews' => '2.0',
'social-activity' => '2.0',
'social-login' => '2.0',
'terms-conditions' => '2.0',
'user-location' => '2.0',
'user-tags' => '2.0',
'verified-users' => '2.0',
'woocommerce' => '2.0',
);
/**
+1 -1
View File
@@ -192,7 +192,7 @@ if ( ! class_exists( 'UM_Functions' ) ) {
*
* @access public
* @param string $template_name
* @param string $path (default: '')
* @param string $basename (default: '')
* @param array $t_args (default: array())
* @param bool $echo
*
+7 -5
View File
@@ -220,7 +220,7 @@ if ( ! class_exists( 'UM' ) ) {
$path = implode( DIRECTORY_SEPARATOR, $array );
$path = str_replace( '_', '-', $path );
$full_path .= $path . '.php';
} else {
} else if ( strpos( $class, 'um\\' ) === 0 ) {
$class = implode( '\\', $array );
$slash = DIRECTORY_SEPARATOR;
$path = str_replace(
@@ -230,7 +230,9 @@ if ( ! class_exists( 'UM' ) ) {
$full_path = um_path . 'includes' . $path . '.php';
}
include_once $full_path;
if( isset( $full_path ) && file_exists( $full_path ) ) {
include_once $full_path;
}
}
}
@@ -296,12 +298,12 @@ if ( ! class_exists( 'UM' ) ) {
$this->register();
$this->user_posts();
$this->access();
$this->mail();
$this->members();
$this->logout();
}
//common includes
$this->mail();
$this->rest_api();
$this->shortcodes();
$this->roles();
@@ -987,11 +989,11 @@ if ( ! class_exists( 'UM' ) ) {
/**
* @since 2.0
*
* @return um\lib\mobiledetect\Mobile_Detect
* @return um\lib\mobiledetect\Um_Mobile_Detect
*/
function mobile() {
if ( empty( $this->classes['mobile'] ) ) {
$this->classes['mobile'] = new um\lib\mobiledetect\Mobile_Detect();
$this->classes['mobile'] = new um\lib\mobiledetect\Um_Mobile_Detect();
}
return $this->classes['mobile'];
+344 -100
View File
@@ -5,102 +5,332 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Access' ) ) {
class Access {
class Access {
function __construct() {
$this->redirect_handler = false;
$this->allow_access = false;
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
//protect posts types
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
//protect pages for wp_list_pages func
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
//filter menu items
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
}
/**
* If true then we use individual restrict content options
* for post
*
* @var bool
*/
private $singular_page;
/**
* Set custom access actions and redirection
*
* Old global restrict content logic
*/
function template_redirect() {
global $post;
do_action('um_access_global_settings');
do_action('um_access_category_settings');
do_action('um_access_tags_settings');
do_action('um_access_user_custom_homepage');
do_action('um_access_frontpage_per_role');
do_action('um_access_homepage_per_role');
if ( $this->redirect_handler && $this->allow_access == false &&
( ! um_is_core_page('login') || um_is_core_page( 'login' ) && is_user_logged_in() ) ) {
// login page add protected page automatically
if ( strstr( $this->redirect_handler, um_get_core_page('login') ) ){
$curr = UM()->permalinks()->get_current_url();
$this->redirect_handler = esc_url( add_query_arg('redirect_to', urlencode_deep( $curr ), $this->redirect_handler) );
}
wp_redirect( $this->redirect_handler );
}
}
/**
* @var bool
*/
private $redirect_handler;
/**
* Get custom access settings meta
* @param integer $post_id
* @return array
*/
function get_meta( $post_id ) {
global $post;
$meta = get_post_custom( $post_id );
if ( isset( $meta ) && is_array( $meta ) ) {
foreach ($meta as $k => $v){
if ( strstr($k, '_um_') ) {
$k = str_replace('_um_', '', $k);
$array[$k] = $v[0];
}
}
}
if ( isset( $array ) )
return (array)$array;
else
return array('');
}
/**
* @var bool
*/
private $allow_access;
/**
* Sets a custom access referer in a redirect URL
*
* @param string $url
* @param string $referer
*
* @return string
*/
function set_referer( $url, $referer ) {
/**
* Access constructor.
*/
function __construct() {
$enable_referer = apply_filters( "um_access_enable_referer", false );
if( ! $enable_referer ) return $url;
$this->singular_page = false;
$url = add_query_arg( 'um_ref', $referer, $url );
return $url;
}
$this->redirect_handler = false;
$this->allow_access = false;
//there is posts (Posts/Page/CPT) filtration if site is accessible
//there also will be redirects if they need
//protect posts types
add_filter( 'the_posts', array( &$this, 'filter_protected_posts' ), 99, 2 );
//protect pages for wp_list_pages func
add_filter( 'get_pages', array( &$this, 'filter_protected_posts' ), 99, 2 );
//filter menu items
add_filter( 'wp_nav_menu_objects', array( &$this, 'filter_menu' ), 99, 2 );
//check the site's accessible more priority have Individual Post/Term Restriction settings
add_action( 'template_redirect', array( &$this, 'template_redirect' ), 1000 );
//add_action( 'um_access_global_settings', array( &$this, 'um_access_global_settings' ) );
//add_action( 'um_access_home_page', array( &$this, 'um_access_home_page' ) );
//add_action( 'um_access_taxonomy_settings', array( &$this, 'um_access_taxonomy_settings' ) );
add_action( 'um_access_check_individual_term_settings', array( &$this, 'um_access_check_individual_term_settings' ) );
add_action( 'um_access_check_global_settings', array( &$this, 'um_access_check_global_settings' ) );
}
/**
* Check individual term Content Restriction settings
*/
function um_access_check_individual_term_settings() {
//check only tax|tags|categories - skip archive, author, and date lists
if ( ! ( is_tax() || is_tag() || is_category() ) ) {
return;
}
if ( is_tag() ) {
$restricted_taxonomies = um_get_option( 'restricted_access_taxonomy_metabox' );
if ( empty( $restricted_taxonomies['post_tag'] ) )
return;
$tag_id = get_query_var( 'tag_id' );
if ( ! empty( $tag_id ) ) {
$restriction = get_term_meta( $tag_id, 'um_content_restriction', true );
}
} elseif ( is_category() ) {
$um_category = get_the_category();
$um_category = current( $um_category );
$restricted_taxonomies = um_get_option( 'restricted_access_taxonomy_metabox' );
if ( empty( $restricted_taxonomies[ $um_category->taxonomy ] ) )
return;
if ( ! empty( $um_category->term_id ) ) {
$restriction = get_term_meta( $um_category->term_id, 'um_content_restriction', true );
}
} elseif ( is_tax() ) {
$tax_name = get_query_var( 'taxonomy' );
$restricted_taxonomies = um_get_option( 'restricted_access_taxonomy_metabox' );
if ( empty( $restricted_taxonomies[ $tax_name ] ) )
return;
$term_name = get_query_var( 'term' );
$term = get_term_by( 'slug', $term_name, $tax_name );
if ( ! empty( $term->term_id ) ) {
$restriction = get_term_meta( $term->term_id, 'um_content_restriction', true );
}
}
if ( ! isset( $restriction ) || empty( $restriction['_um_custom_access_settings'] ) )
return;
//post is private
if ( '0' == $restriction['_um_accessible'] ) {
$this->allow_access = true;
return;
} elseif ( '1' == $restriction['_um_accessible'] ) {
//if post for not logged in users and user is not logged in
if ( ! is_user_logged_in() ) {
$this->allow_access = true;
return;
}
} elseif ( '2' == $restriction['_um_accessible'] ) {
//if post for logged in users and user is not logged in
if ( is_user_logged_in() ) {
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
if ( ! empty( $restriction['_um_access_roles'] ) )
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
$this->allow_access = true;
return;
} else {
//restrict terms page by 404 for logged in users with wrong role
global $wp_query;
$wp_query->set_404();
status_header( 404 );
nocache_headers();
}
}
}
if ( '1' == $restriction['_um_noaccess_action'] ) {
$curr = UM()->permalinks()->get_current_url();
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
$this->redirect_handler = $this->set_referer( esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) ), 'individual_term' );
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
$redirect = $restriction['_um_access_redirect_url'];
} else {
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
}
$this->redirect_handler = $this->set_referer( $redirect, 'individual_term' );
}
}
}
/**
* Check global accessible settings
*/
function um_access_check_global_settings() {
global $post;
if ( is_front_page() ) {
if ( is_user_logged_in() ) {
$role_meta = UM()->roles()->role_data( um_user( 'role' ) );
if ( ! empty( $role_meta['default_homepage'] ) )
return;
$redirect_to = ! empty( $role_meta['redirect_homepage'] ) ? $role_meta['redirect_homepage'] : um_get_core_page( 'user' );
$this->redirect_handler = $this->set_referer( $redirect_to, "custom_homepage" );
} else {
$access = um_get_option( 'accessible' );
if ( $access == 2 ) {
//global settings for accessible home page
$home_page_accessible = um_get_option( 'home_page_accessible' );
if ( $home_page_accessible == 0 ) {
//get redirect URL if not set get login page by default
$redirect = um_get_option( 'access_redirect' );
if ( ! $redirect )
$redirect = um_get_core_page( 'login' );
$this->redirect_handler = $this->set_referer( $redirect, 'global' );
}
}
}
} elseif ( is_category() ) {
if ( ! is_user_logged_in() ) {
$access = um_get_option( 'accessible' );
if ( $access == 2 ) {
//global settings for accessible home page
$category_page_accessible = um_get_option( 'category_page_accessible' );
if ( $category_page_accessible == 0 ) {
//get redirect URL if not set get login page by default
$redirect = um_get_option( 'access_redirect' );
if ( ! $redirect )
$redirect = um_get_core_page( 'login' );
$this->redirect_handler = $this->set_referer( $redirect, 'global' );
}
}
}
}
$access = um_get_option( 'accessible' );
if ( $access == 2 && ! is_user_logged_in() ) {
//build exclude URLs pages
$redirects = array();
$redirects[] = untrailingslashit( um_get_option( 'access_redirect' ) );
$exclude_uris = um_get_option( 'access_exclude_uris' );
if ( ! empty( $exclude_uris ) )
$redirects = array_merge( $redirects, $exclude_uris );
$redirects = array_unique( $redirects );
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
$current_url = untrailingslashit( $current_url );
$current_url_slash = trailingslashit( $current_url );
//get redirect URL if not set get login page by default
$redirect = um_get_option( 'access_redirect' );
if ( ! $redirect )
$redirect = um_get_core_page( 'login' );
if ( ! isset( $post->ID ) || ! ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) {
//if current page not in exclude URLs
$this->redirect_handler = $this->set_referer( $redirect, 'global' );
} else {
$this->redirect_handler = false;
}
}
}
/**
* Set custom access actions and redirection
*
* Old global restrict content logic
*/
function template_redirect() {
global $post;
//if we logged by administrator it can access to all content
if ( current_user_can( 'administrator' ) )
return;
//if we use individual restrict content options skip this function
if ( $this->singular_page )
return;
//also skip if we currently at wp-admin or 404 page
if ( is_admin() || is_404() )
return;
//also skip if we currently at UM Register|Login|Reset Password pages
if ( um_is_core_post( $post, 'register' ) ||
um_is_core_post( $post, 'password-reset' ) ||
um_is_core_post( $post, 'login' ) )
return;
//check terms individual restrict options
do_action( 'um_access_check_individual_term_settings' );
//exit from function if term page is accessible
if ( $this->check_access() )
return;
//check global restrict content options
do_action( 'um_access_check_global_settings' );
$this->check_access();
}
/**
* Check access
*
* @return bool
*/
function check_access() {
if ( $this->allow_access == true )
return true;
if ( $this->redirect_handler ) {
// login page add protected page automatically
/*if ( strstr( $this->redirect_handler, um_get_core_page('login') ) ){
$curr = UM()->permalinks()->get_current_url();
$this->redirect_handler = esc_url( add_query_arg('redirect_to', urlencode_deep( $curr ), $this->redirect_handler) );
}*/
wp_redirect( $this->redirect_handler ); exit;
}
return false;
}
/**
* Sets a custom access referer in a redirect URL
*
* @param string $url
* @param string $referer
*
* @return string
*/
function set_referer( $url, $referer ) {
$enable_referer = apply_filters( "um_access_enable_referer", false );
if( ! $enable_referer ) return $url;
$url = add_query_arg( 'um_ref', $referer, $url );
return $url;
}
/**
@@ -141,14 +371,16 @@ if ( ! class_exists( 'Access' ) ) {
return false;
//exlude from privacy UM default pages (except Members list and User(Profile) 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' ) )
return false;
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' ) )
return false;
}
$restricted_posts = um_get_option( 'restricted_access_post_metabox' );
if ( ! empty( $restricted_posts[$post->post_type] ) ) {
if ( ! empty( $post->post_type ) && ! empty( $restricted_posts[ $post->post_type ] ) ) {
$restriction = get_post_meta( $post->ID, 'um_content_restriction', true );
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
@@ -203,7 +435,7 @@ if ( ! class_exists( 'Access' ) ) {
* @return array
*/
function filter_protected_posts( $posts, $query ) {
$filtered_posts = array();
$filtered_posts = array();
//if empty
if ( empty( $posts ) )
@@ -213,15 +445,18 @@ if ( ! class_exists( 'Access' ) ) {
//other filter
foreach ( $posts as $post ) {
$restriction = $this->get_post_privacy_settings( $post );
if ( ! $restriction ) {
if ( ! $restriction ) {
$filtered_posts[] = $post;
continue;
}
//post is private
if ( '1' == $restriction['_um_accessible'] ) {
if ( '0' == $restriction['_um_accessible'] ) {
$filtered_posts[] = $post;
continue;
} elseif ( '1' == $restriction['_um_accessible'] ) {
//if post for not logged in users and user is not logged in
if ( ! is_user_logged_in() ) {
$filtered_posts[] = $post;
@@ -251,6 +486,8 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
} else {
$this->singular_page = true;
//if single post query
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
@@ -292,16 +529,16 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
if ( ! empty( $restriction['_um_access_roles'] ) )
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( isset( $user_can ) && $user_can ) {
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
$filtered_posts[] = $post;
continue;
}
if ( empty( $query->is_singular ) ) {
//if not single query when exclude if set _um_access_hide_from_queries
if ( empty( $restriction['_um_access_hide_from_queries'] ) ) {
@@ -320,6 +557,8 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
} else {
$this->singular_page = true;
//if single post query
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
@@ -379,6 +618,8 @@ if ( ! class_exists( 'Access' ) ) {
continue;
}
} else {
$this->singular_page = true;
//if single post query
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
@@ -468,9 +709,12 @@ if ( ! class_exists( 'Access' ) ) {
//if post for logged in users and user is not logged in
if ( is_user_logged_in() ) {
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
$custom_restrict = apply_filters( 'um_custom_restriction', true, $restriction );
if ( $user_can ) {
if ( ! empty( $restriction['_um_access_roles'] ) )
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( isset( $user_can ) && $user_can && $custom_restrict ) {
$filtered_items[] = $menu_item;
continue;
}
+13 -1
View File
@@ -542,7 +542,19 @@ if ( ! class_exists( 'Builtin' ) ) {
***/
function set_predefined_fields() {
$um_roles = UM()->roles()->get_roles( false, array( 'admin' ) );
global $wp_roles;
$role_keys = get_option( 'um_roles' );
if ( ! empty( $role_keys ) && is_array( $role_keys ) ) {
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, $role_keys );
} else {
$role_keys = array();
}
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
$um_roles = UM()->roles()->get_roles( false, $exclude_roles );
$profile_privacy = apply_filters('um_profile_privacy_options', array( __('Everyone','ultimate-member'), __('Only me','ultimate-member') ) );
+86 -70
View File
@@ -1887,31 +1887,24 @@
$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 . '>';
$enable_options_pair = apply_filters("um_fields_options_enable_pairs__{$key}", false );
if( ! $has_parent_option ){
if ( isset($options) && $options == 'builtin'){
$options = UM()->builtin()->get ( $filter );
}
$enable_options_pair = apply_filters("um_fields_options_enable_pairs__{$key}", false );
if (!isset( $options )) {
if( ! $has_parent_option ) {
if ( isset($options) && $options == 'builtin'){
$options = UM()->builtin()->get ( $filter );
}
if ( ! isset( $options )) {
$options = UM()->builtin()->get( 'countries' );
}
if (isset( $options )) {
if ( isset( $options ) ) {
$options = apply_filters( 'um_select_dropdown_dynamic_options', $options, $data );
$options = apply_filters( "um_select_dropdown_dynamic_options_{$key}", $options );
}
}
// role field
if ($form_key == 'role') {
$roles = UM()->roles()->get_roles( false, array( 'administrator' ) );
if (isset( $options ))
$options = array_intersect( $options, $roles );
else
$options = $roles;
}
$options = $this->get_available_roles( $form_key, $options );
// add an empty option!
$output .= '<option value=""></option>';
@@ -1924,42 +1917,44 @@
}
// add options
foreach ($options as $k => $v) {
if ( ! empty( $options ) ) {
foreach ( $options as $k => $v ) {
$v = rtrim( $v );
$v = rtrim( $v );
$option_value = $v;
$um_field_checkbox_item_title = $v;
if (!is_numeric( $k ) && in_array( $form_key, array( 'role' ) )) {
$option_value = $k;
$option_value = $v;
$um_field_checkbox_item_title = $v;
if (!is_numeric( $k ) && in_array( $form_key, array( 'role' ) )) {
$option_value = $k;
$um_field_checkbox_item_title = $v;
}
if (isset( $options_pair )) {
$option_value = $k;
$um_field_checkbox_item_title = $v;
}
$option_value = apply_filters( 'um_field_non_utf8_value', $option_value );
$output .= '<option value="' . $option_value . '" ';
if ($this->is_selected( $form_key, $option_value, $data )) {
$output .= 'selected';
$field_value = $option_value;
} else if (!isset( $options_pair ) && $this->is_selected( $form_key, $v, $data )) {
$output .= 'selected';
$field_value = $v;
}
$output .= '>' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</option>';
}
if (isset( $options_pair )) {
$option_value = $k;
$um_field_checkbox_item_title = $v;
}
$option_value = apply_filters( 'um_field_non_utf8_value', $option_value );
$output .= '<option value="' . $option_value . '" ';
if ($this->is_selected( $form_key, $option_value, $data )) {
$output .= 'selected';
$field_value = $option_value;
} else if (!isset( $options_pair ) && $this->is_selected( $form_key, $v, $data )) {
$output .= 'selected';
$field_value = $v;
}
$output .= '>' . __( $um_field_checkbox_item_title, UM_TEXTDOMAIN ) . '</option>';
}
if (!empty( $disabled )) {
if ( ! empty( $disabled ) ) {
$output .= $this->disabled_hidden_field( $form_key, $field_value );
}
@@ -2092,34 +2087,14 @@
$output .= '<div class="um-field-area">';
// role field
if ($form_key == 'role') {
$options = UM()->roles()->get_roles( false, array( 'administrator' ) );
/*var_dump( UM()->roles()->get_roles() );
global $wpdb;
if ( ! empty( $options ) ) {
foreach ( $options as $rkey => $val ) {
$val = (string) $val;
$val = trim( $val );
$post_id = $wpdb->get_var(
$wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'um_role' AND ( post_name = %s OR post_title = %s )", $rkey, $val )
);
$_role = get_post( $post_id );
$new_roles[$_role->post_name] = $_role->post_title;
wp_reset_postdata();
}
$options = $new_roles;
}*/
}
$options = $this->get_available_roles( $form_key, $options );
// add options
$i = 0;
$field_value = array();
if (!empty( $options )) {
foreach ($options as $k => $v) {
if ( ! empty( $options ) ) {
foreach ( $options as $k => $v ) {
$v = rtrim( $v );
@@ -2154,7 +2129,7 @@
$option_value = apply_filters( 'um_field_non_utf8_value', $option_value );
$output .= '<input ' . $disabled . ' type="radio" name="' . $form_key . '[]" value="' . $option_value . '" ';
$output .= '<input ' . $disabled . ' type="radio" name="' . ( ( $form_key == 'role' ) ? $form_key : $form_key . '[]' ) . '" value="' . $option_value . '" ';
if ($this->is_radio_checked( $key, $option_value, $data )) {
$output .= 'checked';
@@ -2323,6 +2298,47 @@
return $output;
}
/**
* Filter for user roles
*
* @param $form_key
* @param array $options
* @return array
*/
function get_available_roles( $form_key, $options = array() ) {
if ( $form_key != 'role' ) {
return $options;
}
// role field
global $wp_roles;
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
$roles = UM()->roles()->get_roles( false, $exclude_roles );
if ( ! empty( $options ) ) {
//fix when customers change options for role (radio/dropdown) fields
foreach ( $roles as $role_key => $role_title ) {
if ( false !== $search_key = array_search( $role_title, $options ) ) {
if ( $role_key != $search_key ) {
$options[ $role_key ] = $role_title;
unset( $options[ $search_key ] );
}
}
}
$options = array_intersect( $options, $roles );
} else {
$options = $roles;
}
return $options;
}
/**
* Sorts columns array
*
+10 -6
View File
@@ -170,19 +170,25 @@ if ( ! class_exists( 'Form' ) ) {
$this->post_form = array_merge( $this->form_data, $this->post_form );
if( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ){ // Secure selected role
if ( isset( $this->form_data['custom_fields'] ) && strstr( $this->form_data['custom_fields'], 'role_' ) ) { // Secure selected role
$custom_field_roles = $this->custom_field_roles( $this->form_data['custom_fields'] );
if( ! empty( $_POST['role'] ) ){
if ( ! empty( $_POST['role'] ) ) {
$role = $_POST['role'];
if( is_array( $_POST['role'] ) ){
$role = current( $_POST['role'] );
}
if ( /*isset( $custom_field_roles ) && is_array( $custom_field_roles ) &&*/ ! empty( $role ) && ! in_array( $role , $custom_field_roles ) ) {
global $wp_roles;
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, get_option( 'um_roles' ) );
$exclude_roles = array_diff( array_keys( $wp_roles->roles ), array_merge( $role_keys, array( 'subscriber' ) ) );
if ( ! empty( $role ) &&
( ! in_array( $role , $custom_field_roles ) || in_array( $role , $exclude_roles ) ) ) {
wp_die( __( 'This is not possible for security reasons.','ultimate-member') );
}
@@ -190,8 +196,6 @@ if ( ! class_exists( 'Form' ) ) {
$this->post_form['submitted']['role'] = $role;
}
} elseif ( isset( $this->post_form['mode'] ) && $this->post_form['mode'] == 'register' ) {
$role = $this->assigned_role( $this->form_id );
$this->post_form['role'] = $role;
+252 -247
View File
@@ -5,295 +5,300 @@ namespace um\core;
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mail' ) ) {
class Mail {
class Mail {
var $email_templates = array();
var $email_templates = array();
var $path_by_slug = array();
function __construct() {
function __construct() {
$this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', array() );
//mandrill compatibility
add_filter( 'mandrill_nl2br', array( &$this, 'mandrill_nl2br' ) );
add_action( 'plugins_loaded', array( &$this, 'init_paths' ), 99 );
//mandrill compatibility
add_filter( 'mandrill_nl2br', array( &$this, 'mandrill_nl2br' ) );
}
}
function init_paths() {
$this->path_by_slug = apply_filters( 'um_email_templates_path_by_slug', $this->path_by_slug );
}
/**
* Mandrill compatibility
*
* @param $nl2br
* @param string $message
* @return bool
*/
function mandrill_nl2br( $nl2br, $message = '' ) {
// text emails
if ( ! um_get_option( 'email_html' ) ) {
$nl2br = true;
}
/**
* Mandrill compatibility
*
* @param $nl2br
* @param string $message
* @return bool
*/
function mandrill_nl2br( $nl2br, $message = '' ) {
return $nl2br;
// text emails
if ( ! um_get_option( 'email_html' ) ) {
$nl2br = true;
}
}
return $nl2br;
}
/**
* Send Email function
*
* @param string $email
* @param null $template
* @param array $args
*/
function send( $email, $template, $args = array() ) {
if ( ! is_email( $email ) ) return;
if ( um_get_option( $template . '_on' ) != 1 ) return;
/**
* Send Email function
*
* @param string $email
* @param null $template
* @param array $args
*/
function send( $email, $template, $args = array() ) {
$this->attachments = null;
$this->headers = 'From: '. um_get_option('mail_from') .' <'. um_get_option('mail_from_addr') .'>' . "\r\n";
if ( ! is_email( $email ) ) return;
if ( um_get_option( $template . '_on' ) != 1 ) return;
$this->subject = um_convert_tags( um_get_option( $template . '_sub' ), $args );
$this->attachments = null;
$this->headers = 'From: '. um_get_option('mail_from') .' <'. um_get_option('mail_from_addr') .'>' . "\r\n";
$this->message = $this->prepare_template( $template, $args );
$this->subject = um_convert_tags( um_get_option( $template . '_sub' ), $args );
add_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
// Send mail
wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
remove_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
}
$this->message = $this->prepare_template( $template, $args );
add_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
// Send mail
wp_mail( $email, $this->subject, $this->message, $this->headers, $this->attachments );
remove_filter( 'wp_mail_content_type', array( &$this, 'set_content_type' ) );
}
/**
* @param $slug
* @param $args
* @return bool|string
*/
function get_email_template( $slug, $args = array() ) {
$located = $this->locate_template( $slug );
/**
* @param $slug
* @param $args
* @return bool|string
*/
function get_email_template( $slug, $args = array() ) {
$located = apply_filters( 'um_email_template_path', $located, $slug, $args );
$located = $this->locate_template( $slug );
if ( ! file_exists( $located ) ) {
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
return false;
}
$located = apply_filters( 'um_email_template_path', $located, $slug, $args );
ob_start();
if ( ! file_exists( $located ) ) {
_doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
return false;
}
do_action( 'um_before_email_template_part', $slug, $located, $args );
ob_start();
include( $located );
do_action( 'um_before_email_template_part', $slug, $located, $args );
do_action( 'um_after_email_template_part', $slug, $located, $args );
include( $located );
return ob_get_clean();
}
do_action( 'um_after_email_template_part', $slug, $located, $args );
return ob_get_clean();
}
/**
* Prepare email template to send
*
* @param $slug
* @param $args
* @return mixed|string
*/
function prepare_template( $slug, $args = array() ) {
ob_start();
if ( um_get_option( 'email_html' ) ) { ?>
/**
* Prepare email template to send
*
* @param $slug
* @param $args
* @return mixed|string
*/
function prepare_template( $slug, $args = array() ) {
ob_start();
<html>
<?php do_action( 'um_before_email_template_body', $slug, $args ); ?>
if ( um_get_option( 'email_html' ) ) { ?>
<body <?php echo apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug ) ?>>
<html>
<?php do_action( 'um_before_email_template_body', $slug, $args ); ?>
<?php echo $this->get_email_template( $slug, $args ); ?>
<body <?php echo apply_filters( 'um_email_template_body_attrs', 'style="background: #f2f2f2;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;"', $slug ) ?>>
</body>
</html>
<?php echo $this->get_email_template( $slug, $args ); ?>
<?php } else {
</body>
</html>
echo $this->get_email_template( $slug, $args );
<?php } else {
}
echo $this->get_email_template( $slug, $args );
$message = ob_get_clean();
}
// Convert tags in email template
return um_convert_tags( $message, $args );
}
$message = ob_get_clean();
// Convert tags in email template
return um_convert_tags( $message, $args );
}
/**
* Locate a template and return the path for inclusion.
*
* @access public
* @param string $template_name
* @return string
*/
function locate_template( $template_name ) {
//WPML compatibility and multilingual email templates
$lang = get_locale();
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
$lang = '';
} else {
$lang .= '/';
}
/**
* Locate a template and return the path for inclusion.
*
* @access public
* @param string $template_name
* @return string
*/
function locate_template( $template_name ) {
//WPML compatibility and multilingual email templates
$lang = get_locale();
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
// check if there is template at theme folder
$template = locate_template( array(
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . '.php'
) );
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
$lang = '';
} else {
$lang .= '/';
}
//if there isn't template at theme folder get template file from plugin dir
if ( ! $template ) {
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
$template = trailingslashit( $path ) . $lang . $template_name . '.php';
}
// Return what we found.
return apply_filters( 'um_locate_email_template', $template, $template_name );
}
/**
* Locate a template and return the path for inclusion.
*
* @access public
* @param string $template_name
* @param bool $html
* @return string
*/
function template_in_theme( $template_name, $html = false ) {
//WPML compatibility and multilingual email templates
$lang = get_locale();
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
$lang = '';
} else {
$lang .= '/';
}
$ext = ! $html ? '.php' : '.html';
// check if there is template at theme folder
$template = locate_template( array(
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . $ext
) );
// Return what we found.
return ! $template ? false : true;
}
/**
* Method returns expected path for template
*
* @access public
* @param string $location
* @param string $template_name
* @param bool $html
* @return string
*/
function get_template_file( $location, $template_name, $html = false ) {
$template_path = '';
$ext = ! $html ? '.php' : '.html';
switch( $location ) {
case 'theme':
$template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ) . $template_name . $ext;
break;
case 'plugin':
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
$template_path = trailingslashit( $path ) . $template_name . $ext;
break;
}
//return apply_filters( 'wpc_client_template_location', $template_path, $location, $template_name, $path );
return $template_path;
}
/**
* Set email content type
*
*
* @param $content_type
* @return string
*/
function set_content_type( $content_type ) {
if ( um_get_option( 'email_html' ) ) {
return 'text/html';
} else {
return 'text/plain';
}
}
/**
* Ajax copy template to the theme
*
* @param bool $template
* @return bool
*/
function copy_email_template( $template = false ) {
$in_theme = $this->template_in_theme( $template );
if ( $in_theme ) {
return false;
}
$plugin_template_path = $this->get_template_file( 'plugin', $template );
$theme_template_path = $this->get_template_file( 'theme', $template );
$temp_path = str_replace( trailingslashit( get_stylesheet_directory() ), '', $theme_template_path );
$temp_path = str_replace( '/', DIRECTORY_SEPARATOR, $temp_path );
$folders = explode( DIRECTORY_SEPARATOR, $temp_path );
$folders = array_splice( $folders, 0, count( $folders ) - 1 );
$cur_folder = '';
$theme_dir = trailingslashit( get_stylesheet_directory() );
foreach ( $folders as $folder ) {
$prev_dir = $cur_folder;
$cur_folder .= $folder . DIRECTORY_SEPARATOR;
if ( ! is_dir( $theme_dir . $cur_folder ) && wp_is_writable( $theme_dir . $prev_dir ) ) {
mkdir( $theme_dir . $cur_folder, 0777 );
}
}
if ( copy( $plugin_template_path, $theme_template_path ) ) {
return true;
} else {
return false;
}
}
function delete_email_template() {
$template = $_POST['email_key'];
$in_theme = $this->template_in_theme( $template );
if ( ! $in_theme ) {
wp_send_json_error( new \WP_Error( 'template_in_theme', __( 'Template does not exists in theme', 'ultimate-member' ) ) );
}
$theme_template_path = $this->get_template_file( 'theme', $template );
if ( unlink( $theme_template_path ) ) {
wp_send_json_success();
} else {
wp_send_json_error( new \WP_Error( 'template_not_exists', __( 'Can not remove template from theme', 'ultimate-member' ) ) );
}
}
}
// check if there is template at theme folder
$template = locate_template( array(
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . '.php'
) );
//if there isn't template at theme folder get template file from plugin dir
if ( ! $template ) {
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
$template = trailingslashit( $path ) . $lang . $template_name . '.php';
}
// Return what we found.
return apply_filters( 'um_locate_email_template', $template, $template_name );
}
/**
* Locate a template and return the path for inclusion.
*
* @access public
* @param string $template_name
* @param bool $html
* @return string
*/
function template_in_theme( $template_name, $html = false ) {
//WPML compatibility and multilingual email templates
$lang = get_locale();
$arr_english_lang = array( 'en', 'en_US', 'en_NZ', 'en_ZA', 'en_AU', 'en_GB' );
if ( in_array( $lang, $arr_english_lang ) || strpos( $lang , 'en_' ) > -1 || empty( $lang ) || $lang == 0 ) {
$lang = '';
} else {
$lang .= '/';
}
$ext = ! $html ? '.php' : '.html';
// check if there is template at theme folder
$template = locate_template( array(
trailingslashit( 'ultimate-member/email' ) . $lang . $template_name . $ext
) );
// Return what we found.
return ! $template ? false : true;
}
/**
* Method returns expected path for template
*
* @access public
* @param string $location
* @param string $template_name
* @param bool $html
* @return string
*/
function get_template_file( $location, $template_name, $html = false ) {
$template_path = '';
$ext = ! $html ? '.php' : '.html';
switch( $location ) {
case 'theme':
$template_path = trailingslashit( get_stylesheet_directory() . '/ultimate-member/email' ) . $template_name . $ext;
break;
case 'plugin':
$path = ! empty( $this->path_by_slug[ $template_name ] ) ? $this->path_by_slug[ $template_name ] : um_path . 'templates/email';
$template_path = trailingslashit( $path ) . $template_name . $ext;
break;
}
//return apply_filters( 'wpc_client_template_location', $template_path, $location, $template_name, $path );
return $template_path;
}
/**
* Set email content type
*
*
* @param $content_type
* @return string
*/
function set_content_type( $content_type ) {
if ( um_get_option( 'email_html' ) ) {
return 'text/html';
} else {
return 'text/plain';
}
}
/**
* Ajax copy template to the theme
*
* @param bool $template
* @return bool
*/
function copy_email_template( $template = false ) {
$in_theme = $this->template_in_theme( $template );
if ( $in_theme ) {
return false;
}
$plugin_template_path = $this->get_template_file( 'plugin', $template );
$theme_template_path = $this->get_template_file( 'theme', $template );
$temp_path = str_replace( trailingslashit( get_stylesheet_directory() ), '', $theme_template_path );
$temp_path = str_replace( '/', DIRECTORY_SEPARATOR, $temp_path );
$folders = explode( DIRECTORY_SEPARATOR, $temp_path );
$folders = array_splice( $folders, 0, count( $folders ) - 1 );
$cur_folder = '';
$theme_dir = trailingslashit( get_stylesheet_directory() );
foreach ( $folders as $folder ) {
$prev_dir = $cur_folder;
$cur_folder .= $folder . DIRECTORY_SEPARATOR;
if ( ! is_dir( $theme_dir . $cur_folder ) && wp_is_writable( $theme_dir . $prev_dir ) ) {
mkdir( $theme_dir . $cur_folder, 0777 );
}
}
if ( file_exists( $plugin_template_path ) && copy( $plugin_template_path, $theme_template_path ) ) {
return true;
} else {
return false;
}
}
function delete_email_template() {
$template = $_POST['email_key'];
$in_theme = $this->template_in_theme( $template );
if ( ! $in_theme ) {
wp_send_json_error( new \WP_Error( 'template_in_theme', __( 'Template does not exists in theme', 'ultimate-member' ) ) );
}
$theme_template_path = $this->get_template_file( 'theme', $template );
if ( unlink( $theme_template_path ) ) {
wp_send_json_success();
} else {
wp_send_json_error( new \WP_Error( 'template_not_exists', __( 'Can not remove template from theme', 'ultimate-member' ) ) );
}
}
}
}
+8 -1
View File
@@ -11,7 +11,7 @@ if ( ! class_exists( 'Permalinks' ) ) {
function __construct() {
$this->current_url = $this->get_current_url();
add_action( 'init', array( &$this, 'set_current_url' ), 0 );
add_action( 'init', array( &$this, 'check_for_querystrings' ), 1 );
@@ -25,6 +25,13 @@ if ( ! class_exists( 'Permalinks' ) ) {
}
/**
* Set current URL variable
*/
function set_current_url() {
$this->current_url = $this->get_current_url();
}
/***
*** @SEO canonical href bugfix
+3 -3
View File
@@ -108,13 +108,13 @@ if ( ! class_exists( 'Query' ) ) {
return $comments;
} else {
$custom_posts = new \WP_Query();
$args['post_status'] = explode( ',', $args['post_status'] );
$custom_posts->query( $args );
return $custom_posts;
return $custom_posts;
}
}
/***
+23 -11
View File
@@ -23,7 +23,7 @@ if ( ! class_exists( 'REST_API' ) ) {
add_action( 'template_redirect', array( $this, 'process_query' ), -1 );
add_filter( 'query_vars', array( $this, 'query_vars' ) );
add_action( 'um_user_profile_section', array( $this, 'user_key_field' ), 2 );
add_filter( 'um_user_profile_additional_fields', array( $this, 'user_key_field' ), 3, 2 );
add_action( 'personal_options_update', array( $this, 'update_key' ) );
add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
@@ -278,7 +278,11 @@ if ( ! class_exists( 'REST_API' ) ) {
break;
case 'role':
$wp_user_object = new \WP_User( $id );
$wp_user_object->set_role( $value );
$old_roles = $wp_user_object->roles;
$wp_user_object->set_role( $value );
do_action( 'um_after_member_role_upgrade', array( $value ), $old_roles );
$response['success'] = __('User role has been changed.','ultimate-member');
break;
default:
@@ -598,21 +602,26 @@ if ( ! class_exists( 'REST_API' ) ) {
die();
}
/**
* Modify User Profile
*/
function user_key_field( $user ) {
/**
* Modify User Profile Page fields
*
* @param $content
* @param $user
* @return string
*/
function user_key_field( $content, $user ) {
if ( empty( $user ) )
return;
return $content;
if( ! isset( $user->ID ) )
return;
return $content;
if ( current_user_can( 'edit_users' ) && current_user_can( 'edit_user', $user->ID ) ) {
$user = get_userdata( $user->ID );
?>
<table class="form-table">
ob_start(); ?>
<table class="form-table">
<tbody>
<tr>
<th>
@@ -636,6 +645,9 @@ if ( ! class_exists( 'REST_API' ) ) {
</tbody>
</table>
<?php }
$content .= ob_get_clean();
return $content;
}
/**
+2 -2
View File
@@ -160,8 +160,8 @@ if ( ! class_exists( 'Roles_Capabilities' ) ) {
return array_shift( $user->roles );
$role_keys = array_map( function( $item ) {
return 'um_' . $item;
}, $role_keys );
return 'um_' . $item;
}, $role_keys );
$roles = array_intersect( array_values( $user->roles ), $role_keys );
if ( ! empty( $roles ) ) {
+12 -6
View File
@@ -290,19 +290,25 @@ if ( ! class_exists( 'Shortcodes' ) ) {
$post_data['template'] = $post_data['mode'];
}
$args = array_merge($post_data, $args);
if( 'directory' != $args['mode'] ) {
if ( empty( $args['use_custom_settings'] ) ) {
$args = array_merge( $args, $this->get_css_args( $args ) );
} else {
$args = array_merge( $this->get_css_args( $args ), $args );
}
$args = array_merge( $post_data, $args );
if (empty( $args['use_custom_settings'] )) {
$args = array_merge( $args, $this->get_css_args( $args ) );
} else {
$args = array_merge( $this->get_css_args( $args ), $args );
}
}
// filter for arguments
$args = apply_filters('um_shortcode_args_filter', $args);
extract($args, EXTR_SKIP);
if ( 'register' == $mode && is_user_logged_in() ) {
return __( 'You are already registered', 'ultimate-member' );
}
// for profiles only
if ($mode == 'profile' && um_profile_id() && isset($args['role']) && $args['role'] &&
$args['role'] != UM()->roles()->um_get_user_role( um_profile_id() ) ) {
+118 -39
View File
@@ -36,6 +36,7 @@ if ( ! class_exists( 'User' ) ) {
'user_pass',
'user_password',
'display_name',
'role',
);
$this->target_id = null;
@@ -52,22 +53,67 @@ if ( ! class_exists( 'User' ) ) {
add_action('um_when_role_is_set', array(&$this, 'remove_cache') );
add_action('um_when_status_is_set', array(&$this, 'remove_cache') );
add_action( 'show_user_profile', array( $this, 'community_role_edit' ) );
add_action( 'edit_user_profile', array( $this, 'community_role_edit' ) );
add_action( 'user_new_form', array( $this, 'secondary_role_display' ) );
add_action( 'edit_user_profile', array( $this, 'secondary_role_display' ) );
add_action( 'show_user_profile', array( $this, 'secondary_role_display' ) );
add_action( 'show_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
add_action( 'edit_user_profile', array( $this, 'profile_form_additional_section' ), 10 );
add_filter( 'um_user_profile_additional_fields', array( $this, 'secondary_role_field' ), 1, 2 );
//on every update of user profile (hook from wp_update_user)
add_action( 'profile_update', array( &$this, 'profile_update' ), 10, 2 ); // user_id and old_user_data
add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
//on user update profile page
//add_action( 'edit_user_profile_update', array( &$this, 'profile_update' ), 10, 1 );
add_action( 'user_register', array( &$this, 'user_register_via_admin' ), 10, 1 );
add_action( 'user_register', array( &$this, 'set_gravatar' ), 11, 1 );
add_action( 'added_existing_user', array( &$this, 'add_um_role_existing_user' ), 10, 2 );
add_action( 'wpmu_activate_user', array( &$this, 'add_um_role_wpmu_new_user' ), 10, 1 );
}
/**
* Multisite add existing user
*
* @param $user_id
* @param $result
*/
function add_um_role_existing_user( $user_id, $result ) {
// Bail if no user ID was passed
if ( empty( $user_id ) )
return;
if ( ! empty( $_POST['um-role'] ) ) {
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
}
}
$this->remove_cache( $user_id );
}
/**
* Multisite add existing user
*
* @param $user_id
*/
function add_um_role_wpmu_new_user( $user_id ) {
// Bail if no user ID was passed
if ( empty( $user_id ) )
return;
if ( ! empty( $_POST['um-role'] ) ) {
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
}
}
$this->remove_cache( $user_id );
}
/**
* Get pending users (in queue)
*/
@@ -228,28 +274,63 @@ if ( ! class_exists( 'User' ) ) {
}
function profile_update( $user_id ) {
// Bail if no user ID was passed
if ( empty( $user_id ) )
return;
/**
* On wp_update_user function complete
*
* @param int $user_id
* @param \WP_User $old_data
*/
function profile_update( $user_id, $old_data ) {
// Bail if no user ID was passed
if ( empty( $user_id ) )
return;
if ( ! empty( $_POST['um-role'] ) ) {
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
}
}
$old_roles = $old_data->roles;
$userdata = get_userdata( $user_id );
$new_roles = $userdata->roles;
$this->remove_cache( $user_id );
}
if ( ! empty( $_POST['um-role'] ) ) {
$new_roles = array_merge( $new_roles, array( $_POST['um-role'] ) );
if ( ! user_can( $user_id, $_POST['um-role'] ) ) {
UM()->roles()->set_role( $user_id, $_POST['um-role'] );
}
}
do_action( 'um_after_member_role_upgrade', $new_roles, $old_roles );
$this->remove_cache( $user_id );
}
/**
* Additional section for WP Profile page with UM data fields
*
* @param \WP_User $userdata User data
* @return void
*/
function profile_form_additional_section( $userdata ) {
$section_content = apply_filters( 'um_user_profile_additional_fields', '', $userdata );
if ( ! empty( $section_content ) && ! ( is_multisite() && is_network_admin() ) ) {
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) { ?>
<h3><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
<?php }
echo $section_content;
}
}
/**
* Default interface for setting a ultimatemember role
*
* @param string $content Section HTML
* @param \WP_User $userdata User data
* @return void
* @return string
*/
public static function secondary_role_display( $userdata ) {
public function secondary_role_field( $content, $userdata ) {
$roles = array();
$role_keys = get_option( 'um_roles' );
@@ -265,26 +346,30 @@ if ( ! class_exists( 'User' ) ) {
}
if ( empty( $roles ) )
return;
return $content;
global $pagenow;
if ( 'profile.php' == $pagenow )
return $content;
$style = '';
$user_role = false;
if ( $userdata !== 'add-new-user' ) {
if ( $userdata !== 'add-new-user' && $userdata !== 'add-existing-user' ) {
// Bail if current user cannot edit users
if ( ! current_user_can( 'edit_user', $userdata->ID ) )
return;
return $content;
$user_role = UM()->roles()->um_get_user_role( $userdata->ID );
if ( $user_role && ! empty( $userdata->roles ) && count( $userdata->roles ) == 1 )
$style = 'style="display:none;"';
} ?>
}
<div id="um_role_selector_wrapper" <?php echo $style ?>>
<?php if ( $userdata !== 'add-new-user' ) { ?>
<h3><?php esc_html_e( 'Ultimate Member', 'ultimate-member' ); ?></h3>
<?php } ?>
$class = ( $userdata == 'add-existing-user' ) ? 'um_role_existing_selector_wrapper' : 'um_role_selector_wrapper';
ob_start(); ?>
<div id="<?php echo $class ?>" <?php echo $style ?>>
<table class="form-table">
<tbody>
<tr>
@@ -301,15 +386,10 @@ if ( ! class_exists( 'User' ) ) {
</tbody>
</table>
</div>
<?php
}
<?php $content .= ob_get_clean();
/**
* Allow changing user
*/
function community_role_edit( $user ) {
do_action( 'um_user_profile_section' );
return $content;
}
@@ -1029,9 +1109,9 @@ if ( ! class_exists( 'User' ) ) {
$args['ID'] = $this->id;
$changes = apply_filters('um_before_update_profile', $changes, $this->id);
// save or update profile meta
foreach( $changes as $key => $value ) {
if ( !in_array( $key, $this->update_user_keys ) ) {
// save or update profile meta
foreach ( $changes as $key => $value ) {
if ( ! in_array( $key, $this->update_user_keys ) ) {
update_user_meta( $this->id, $key, $value );
@@ -1043,7 +1123,6 @@ if ( ! class_exists( 'User' ) ) {
}
// update user
if ( count( $args ) > 1 ) {
wp_update_user( $args );
+13 -767
View File
@@ -1,776 +1,22 @@
<?php
/**
* Global Access Settings
*/
function um_access_global_settings() {
global $post, $wp_query;
$access = um_get_option( 'accessible' );
/**
* Profile Access
*
* @param int $user_id
*/
function um_access_profile( $user_id ) {
if ( $access == 2 && ! is_user_logged_in() ) {
if ( ! um_is_myprofile() && um_is_core_page( 'user' ) && ! current_user_can( 'edit_users' ) ) {
if ( um_is_core_post( $post, 'register' ) || um_is_core_post( $post, 'password-reset' ) ) {
um_fetch_user( $user_id );
UM()->access()->allow_access = true;
} else {
$redirect = um_get_option( 'access_redirect' );
if ( ! $redirect )
$redirect = um_get_core_page( 'login' );
$redirects[] = untrailingslashit( um_get_core_page( 'login' ) );
$redirects[] = untrailingslashit( um_get_option( 'access_redirect' ) );
$exclude_uris = um_get_option( 'access_exclude_uris' );
if ( $exclude_uris )
$redirects = array_merge( $redirects, $exclude_uris );
$redirects = array_unique( $redirects );
$current_url = UM()->permalinks()->get_current_url( get_option( 'permalink_structure' ) );
$current_url = untrailingslashit( $current_url );
$current_url_slash = trailingslashit( $current_url );
if ( isset( $post->ID ) && ( in_array( $current_url, $redirects ) || in_array( $current_url_slash, $redirects ) ) ) {
// allow
}else {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
}
// Disallow access in homepage
if( /*is_front_page() ||*/ is_home() ){
$home_page_accessible = um_get_option( "home_page_accessible" );
if ( $home_page_accessible == 0 ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
}
}
// Disallow access in category pages
if ( is_category() ) {
$cat_obj = $wp_query->get_queried_object();
$restriction = get_term_meta( $cat_obj->term_id, 'um_content_restriction', true );
if ( ! empty( $restriction['_um_custom_access_settings'] ) ) {
if ( ! isset( $restriction['_um_accessible'] ) || '0' == $restriction['_um_accessible'] ) {
UM()->access()->allow_access = true;
} else {
//post is private
if ( '1' == $restriction['_um_accessible'] ) {
//if post for not logged in users and user is not logged in
if ( ! is_user_logged_in() || current_user_can( 'administrator' ) ) {
UM()->access()->allow_access = true;
} else {
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
$curr = UM()->permalinks()->get_current_url();
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
$redirect = $restriction['_um_access_redirect_url'];
} else {
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
}
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
}
}
}
} elseif ( '2' == $restriction['_um_accessible'] ) {
//if post for logged in users and user is not logged in
if ( is_user_logged_in() ) {
if ( current_user_can( 'administrator' ) ) {
UM()->access()->allow_access = true;
}
$user_can = $this->user_can( get_current_user_id(), $restriction['_um_access_roles'] );
if ( $user_can ) {
UM()->access()->allow_access = true;
}
//if single post query
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
$curr = UM()->permalinks()->get_current_url();
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
$redirect = $restriction['_um_access_redirect_url'];
} else {
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
}
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
}
}
} else {
//if single post query
if ( ! isset( $restriction['_um_noaccess_action'] ) || '0' == $restriction['_um_noaccess_action'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_noaccess_action'] ) {
$curr = UM()->permalinks()->get_current_url();
if ( ! isset( $restriction['_um_access_redirect'] ) || '0' == $restriction['_um_access_redirect'] ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} elseif ( '1' == $restriction['_um_access_redirect'] ) {
if ( ! empty( $restriction['_um_access_redirect_url'] ) ) {
$redirect = $restriction['_um_access_redirect_url'];
} else {
$redirect = esc_url( add_query_arg( 'redirect_to', urlencode_deep( $curr ), um_get_core_page( 'login' ) ) );
}
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
}
}
}
}
}
} else {
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
UM()->access()->allow_access = true;
} else {
$category_page_accessible = um_get_option( "category_page_accessible" );
if ( $category_page_accessible == 0 ) {
UM()->access()->redirect_handler = UM()->access()->set_referer( $redirect, "global" );
wp_redirect( UM()->access()->redirect_handler ); exit;
} else {
UM()->access()->allow_access = true;
}
}
}
}
}
if ( ! in_array( um_user( 'account_status' ), array( 'approved' ) ) ) {
um_redirect_home();
}
$current_page_type = um_get_current_page_type();
do_action( 'um_access_post_type', $current_page_type );
do_action( "um_access_post_type_{$current_page_type}" );
}
add_action( 'um_access_global_settings', 'um_access_global_settings' );
/**
* Archives/Taxonomies/Categories access settings
*/
add_action( 'um_access_category_settings', 'um_access_category_settings' );
function um_access_category_settings() {
global $post;
if ( is_front_page() ||
is_home() ||
is_feed() ||
is_page() ||
is_404()
) {
return;
}
$access = um_get_option( 'accessible' );
$current_page_type = um_get_current_page_type();
if ( is_category() && !in_array( $current_page_type, array( 'day', 'month', 'year', 'author', 'archive' ) ) ) {
$um_category = get_the_category();
$um_category = current( $um_category );
$term_id = '';
if (isset( $um_category->term_id )) {
$term_id = $um_category->term_id;
}
if (isset( $term_id ) && !empty( $term_id )) {
$opt = get_term_meta($term_id,'um_content_restriction',true);
if (isset( $opt['_um_accessible'] )) {
$redirect = false;
switch ($opt['_um_accessible']) {
case 0:
UM()->access()->allow_access = true;
UM()->access()->redirect_handler = ''; // open to everyone
break;
case 1:
if (is_user_logged_in()) {
if (isset( $opt['_um_redirect2'] ) && !empty( $opt['_um_redirect2'] )) {
$redirect = $opt['_um_redirect2'];
} else {
$redirect = site_url();
}
}
UM()->access()->allow_access = false;
$redirect = UM()->access()->set_referer( $redirect, "category_1" );
UM()->access()->redirect_handler = esc_url( $redirect );
if (!is_user_logged_in() && !empty( $redirect )) {
UM()->access()->allow_access = true;
}
break;
case 2:
if (!is_user_logged_in()) {
if (isset( $opt['_um_redirect'] ) && !empty( $opt['_um_redirect'] )) {
$redirect = $opt['_um_redirect'];
} else {
$redirect = um_get_core_page( 'login' );
}
UM()->access()->allow_access = false;
$redirect = UM()->access()->set_referer( $redirect, "category_2a" );
UM()->access()->redirect_handler = esc_url( $redirect );
}
if (is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] )) {
if (!in_array( um_user( 'role' ), $opt['_um_roles'] )) {
if (isset( $opt['_um_redirect'] )) {
$redirect = $opt['_um_redirect'];
}
$redirect = UM()->access()->set_referer( $redirect, "category_2b" );
UM()->access()->redirect_handler = esc_url( $redirect );
}
}
}
}
}
} else if ($access == 2 && !is_user_logged_in() && is_archive()) {
UM()->access()->allow_access = false;
$redirect = um_get_core_page( 'login' );
$redirect = UM()->access()->set_referer( $redirect, "category_archive" );
UM()->access()->redirect_handler = $redirect;
} else if (is_tax() && get_post_taxonomies( $post )) {
$taxonomies = get_post_taxonomies( $post );
$categories_ids = array();
foreach ($taxonomies as $key => $value) {
$term_list = wp_get_post_terms( $post->ID, $value, array( "fields" => "ids" ) );
foreach ($term_list as $term_id) {
array_push( $categories_ids, $term_id );
}
}
foreach ($categories_ids as $term => $term_id) {
$opt = get_term_meta($term_id,'um_content_restriction',true);
if (isset( $opt['_um_accessible'] )) {
switch ($opt['_um_accessible']) {
case 0:
UM()->access()->allow_access = true;
UM()->access()->redirect_handler = false; // open to everyone
break;
case 1:
if (is_user_logged_in())
$redirect = ( isset( $opt['_um_redirect2'] ) && !empty( $opt['_um_redirect2'] ) ) ? $opt['_um_redirect2'] : site_url();
$redirect = UM()->access()->set_referer( $redirect, "categories_1" );
UM()->access()->redirect_handler = $redirect;
if (!is_user_logged_in())
UM()->access()->allow_access = true;
break;
case 2:
if (!is_user_logged_in()) {
$redirect = ( isset( $opt['_um_redirect'] ) && !empty( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : um_get_core_page( 'login' );
$redirect = UM()->access()->set_referer( $redirect, "categories_2a" );
UM()->access()->redirect_handler = $redirect;
}
if (is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] )) {
if (!in_array( um_user( 'role' ), $opt['_um_roles'] )) {
$redirect = null;
if (is_user_logged_in()) {
$redirect = ( isset( $opt['_um_redirect'] ) ) ? $opt['_um_redirect'] : site_url();
}
if (!is_user_logged_in()) {
$redirect = um_get_core_page( 'login' );
}
$redirect = UM()->access()->set_referer( $redirect, "categories_2b" );
UM()->access()->redirect_handler = $redirect;
}
}
}
}
}
}
}
/**
* Tags access settings
*/
add_action( 'um_access_tags_settings', 'um_access_tags_settings' );
function um_access_tags_settings() {
if ( is_front_page() ||
is_home() ||
is_feed() ||
is_page() ||
is_404()
) {
return;
}
$access = um_get_option( 'accessible' );
$current_page_type = um_get_current_page_type();
$tag_id = get_query_var( 'tag_id' );
if (is_tag() && $current_page_type == 'tag' && $tag_id) {
if (isset( $tag_id ) && !empty( $tag_id )) {
$opt = get_term_meta($tag_id,'um_content_restriction',true);
if (isset( $opt['_um_accessible'] )) {
$redirect = false;
switch ($opt['_um_accessible']) {
case 0:
UM()->access()->allow_access = true;
UM()->access()->redirect_handler = ''; // open to everyone
break;
case 1:
if (is_user_logged_in()) {
if (isset( $opt['_um_redirect2'] ) && !empty( $opt['_um_redirect2'] )) {
$redirect = $opt['_um_redirect2'];
} else {
$redirect = site_url();
}
}
UM()->access()->allow_access = false;
$redirect = UM()->access()->set_referer( $redirect, "tag_1" );
UM()->access()->redirect_handler = esc_url( $redirect );
if (!is_user_logged_in() && !empty( $redirect )) {
UM()->access()->allow_access = true;
}
break;
case 2:
if (!is_user_logged_in()) {
if (isset( $opt['_um_redirect'] ) && !empty( $opt['_um_redirect'] )) {
$redirect = $opt['_um_redirect'];
} else {
$redirect = um_get_core_page( 'login' );
}
UM()->access()->allow_access = false;
$redirect = UM()->access()->set_referer( $redirect, "tag_2" );
UM()->access()->redirect_handler = esc_url( $redirect );
}
if (is_user_logged_in() && isset( $opt['_um_roles'] ) && !empty( $opt['_um_roles'] )) {
if (!in_array( um_user( 'role' ), $opt['_um_roles'] )) {
if (isset( $opt['_um_redirect'] )) {
$redirect = $opt['_um_redirect'];
}
$redirect = UM()->access()->set_referer( $redirect, "tag_2b" );
UM()->access()->redirect_handler = esc_url( $redirect );
}
}
}
}
}
} else if ($access == 2 && !is_user_logged_in() && is_tag()) {
UM()->access()->allow_access = false;
$redirect = um_get_core_page( 'login' );
$redirect = UM()->access()->set_referer( $redirect, "tag" );
UM()->access()->redirect_handler = $redirect;
}
}
/**
* Custom User homepage redirection
*/
function um_access_user_custom_homepage() {
if( ! is_user_logged_in() ) return;
if ( ! is_home() ) return;
$role_meta = UM()->roles()->role_data( um_user( 'role' ) );
if ( empty( $role_meta['default_homepage'] ) ) {
$redirect_to = ! empty( $role_meta['redirect_homepage'] ) ? $role_meta['redirect_homepage'] : um_get_core_page( 'user' );
$redirect_to = UM()->access()->set_referer( $redirect_to, "custom_homepage" );
wp_redirect( $redirect_to );
exit;
}
}
add_action( 'um_access_user_custom_homepage', 'um_access_user_custom_homepage' );
/**
* Front page access settings
*/
function um_access_frontpage_per_role() {
global $post;
if ( is_admin() ) return;
/*if ( ! is_front_page() ) return;*/
if( is_404() ) return;
if ( ! isset( $um_post_id ) && isset( $post->ID ) ){
$um_post_id = $post->ID;
}
if( ! isset( $um_post_id ) ){
return;
}
$args = UM()->access()->get_meta( $um_post_id );
extract( $args );
if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
$um_post_id = apply_filters('um_access_control_for_parent_posts', $um_post_id );
$args = UM()->access()->get_meta( $um_post_id );
extract( $args );
if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
return;
}
}
$redirect_to = null;
if ( !isset( $accessible ) ) return;
switch( $accessible ) {
case 0:
UM()->access()->allow_access = true;
UM()->access()->redirect_handler = false; // open to everyone
break;
case 1:
$redirect_to = $access_redirect2;
if ( is_user_logged_in() ){
UM()->access()->allow_access = false;
}
if ( ! is_user_logged_in() ){
UM()->access()->allow_access = true;
}
if( ! empty( $redirect_to ) ){
$redirect_to = UM()->access()->set_referer( $redirect_to, "frontpage_per_role_1a" );
UM()->access()->redirect_handler = esc_url( $redirect_to );
}else{
if ( ! is_user_logged_in() ){
$redirect_to = um_get_core_page("login");
}else{
$redirect_to = um_get_core_page("user");
}
$redirect_to = UM()->access()->set_referer( $redirect_to, "frontpage_per_role_1b" );
UM()->access()->redirect_handler = esc_url( $redirect_to );
}
break;
case 2:
if ( ! is_user_logged_in() ){
if ( empty( $access_redirect ) ) {
$access_redirect = um_get_core_page('login');
}
$redirect_to = $access_redirect;
$redirect_to = UM()->access()->set_referer( $redirect_to, "frontpage_per_role_2a" );
}
if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
$access_roles = unserialize( $access_roles );
$access_roles = array_filter($access_roles);
if ( ! empty( $access_roles ) && ! in_array( um_user( 'role' ), $access_roles ) ) {
if ( empty( $access_redirect ) ) {
if ( is_user_logged_in() ) {
$access_redirect = site_url();
} else {
$access_redirect = um_get_core_page('login');
}
}
$redirect_to = esc_url( $access_redirect );
$redirect_to = UM()->access()->set_referer( $redirect_to, "frontpage_per_role_2b" );
}
}
UM()->access()->redirect_handler = esc_url( $redirect_to );
break;
}
um_reset_user();
}
add_action( 'um_access_frontpage_per_role', 'um_access_frontpage_per_role' );
/**
* Posts page access settings
*/
function um_access_homepage_per_role() {
global $post;
if ( is_admin() ) return;
if ( ! is_home() ) return;
if ( is_404() ) return;
$access = um_get_option('accessible');
$show_on_front = get_option( 'show_on_front' );
if( $show_on_front == "page" ){
$um_post_id = get_option( 'page_for_posts' );
if ( $access == 2 && ! is_user_logged_in() ) {
UM()->access()->allow_access = false;
}else{
UM()->access()->allow_access = true;
}
}else if( $show_on_front == "posts" ){
UM()->access()->allow_access = true;
}
if ( isset( $um_post_id ) ){
$args = UM()->access()->get_meta( $um_post_id );
extract( $args );
if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
$um_post_id = apply_filters('um_access_control_for_parent_posts', $um_post_id );
$args = UM()->access()->get_meta( $um_post_id );
extract( $args );
if ( !isset( $args['custom_access_settings'] ) || $args['custom_access_settings'] == 0 ) {
return;
}
}
$redirect_to = null;
if ( !isset( $accessible ) ) return;
switch( $accessible ) {
case 0:
UM()->access()->allow_access = true;
UM()->access()->redirect_handler = false; // open to everyone
break;
case 1:
$redirect_to = esc_url( $access_redirect2 );
if ( is_user_logged_in() ){
UM()->access()->allow_access = false;
}
if ( ! is_user_logged_in() ){
UM()->access()->allow_access = true;
}
if( ! empty( $redirect_to ) ){
$redirect_to = UM()->access()->set_referer( $redirect_to, "homepage_per_role_1a" );
UM()->access()->redirect_handler = esc_url( $redirect_to );
}else{
$redirect_to = null;
if ( ! is_user_logged_in() ){
$redirect_to = um_get_core_page("login");
}else{
$redirect_to = um_get_core_page("user");
}
$redirect_to = UM()->access()->set_referer( $redirect_to, "homepage_per_role_1b" );
UM()->access()->redirect_handler = esc_url( $redirect_to );
}
break;
case 2:
if ( ! is_user_logged_in() ){
if ( empty( $access_redirect ) ) {
$access_redirect = um_get_core_page('login');
}
$redirect_to = $access_redirect;
$redirect_to = UM()->access()->set_referer( $redirect_to, "homepage_per_role_2a" );
}
if ( is_user_logged_in() && isset( $access_roles ) && !empty( $access_roles ) ){
$access_roles = unserialize( $access_roles );
$access_roles = array_filter($access_roles);
if ( ! empty( $access_roles ) && ! in_array( um_user( 'role' ), $access_roles ) ) {
if ( ! $access_redirect ) {
if ( is_user_logged_in() ) {
$access_redirect = site_url();
} else {
$access_redirect = um_get_core_page('login');
}
}
$redirect_to = $access_redirect;
$redirect_to = UM()->access()->set_referer( $redirect_to, "homepage_per_role_2b" );
}
}
UM()->access()->redirect_handler = esc_url( $redirect_to );
break;
}
}
}
add_action( 'um_access_homepage_per_role', 'um_access_homepage_per_role' );
/**
* Profile Access
*
* @param int $user_id
*/
function um_access_profile( $user_id ) {
if ( ! um_is_myprofile() && um_is_core_page( 'user' ) && ! current_user_can( 'edit_users' ) ) {
um_fetch_user( $user_id );
if ( ! in_array( um_user( 'account_status' ), array( 'approved' ) ) ) {
um_redirect_home();
}
um_reset_user();
}
}
add_action( 'um_access_profile', 'um_access_profile' );
}
add_action( 'um_access_profile', 'um_access_profile' );
+3
View File
@@ -150,6 +150,9 @@
foreach ( $array['conditions'] as $condition ) {
list( $visibility, $parent_key, $op, $parent_value ) = $condition;
if ( ! isset( $args[ $parent_key ] ) )
continue;
$cond_value = ( $fields[ $parent_key ]['type'] == 'radio' ) ? $args[ $parent_key ][0] : $args[ $parent_key ];
if ( $visibility == 'hide' ) {
+9 -5
View File
@@ -748,14 +748,17 @@
* @param integer $user_id
* @param array $arr_files
*/
add_action( "um_before_user_upload", "um_before_user_upload", 10, 2 );
function um_before_user_upload( $user_id, $arr_files ) {
um_fetch_user( $user_id );
foreach ($arr_files as $key => $filename) {
if (um_user( $key )) {
if (basename( $filename ) != basename( um_user( $key ) ) || in_array( $old_filename, array( basename( um_user( $key ) ), basename( $filename ) ) ) || $filename == 'empty_file') {
$old_filename = um_user( $key );
foreach ( $arr_files as $key => $filename ) {
if ( um_user( $key ) ) {
$old_filename = um_user( $key );
if ( basename( $filename ) != basename( um_user( $key ) ) ||
in_array( $old_filename, array( basename( um_user( $key ) ), basename( $filename ) ) ) ||
$filename == 'empty_file' ) {
$path = UM()->files()->upload_basedir;
delete_user_meta( $user_id, $old_filename );
if (file_exists( $path . $user_id . '/' . $old_filename )) {
@@ -765,3 +768,4 @@
}
}
}
add_action( "um_before_user_upload", "um_before_user_upload", 10, 2 );
+19 -1
View File
@@ -303,6 +303,10 @@
*/
add_action( 'um_registration_set_extra_data', 'um_registration_save_files', 10, 2 );
function um_registration_save_files( $user_id, $args ) {
if ( empty( $args['custom_fields'] ) )
return;
$files = array();
$fields = unserialize( $args['custom_fields'] );
@@ -332,4 +336,18 @@
UM()->user()->update_files( $files );
do_action( 'um_after_user_upload', $user_id, $files );
}
}
}
/**
* Update user Full Name
*
* @profile name update
*
* @param $user_id
* @param $args
*/
function um_registration_set_profile_full_name( $user_id, $args ) {
do_action( 'um_update_profile_full_name', $args );
}
add_action( 'um_registration_set_extra_data', 'um_registration_set_profile_full_name', 10, 2 );
+2 -2
View File
@@ -30,12 +30,12 @@
case 'initial_name':
$fname = get_user_meta( $user_id, 'first_name', true );
$lname = get_user_meta( $user_id, 'last_name', true );
$update_name = $fname . ' ' . $lname[0];
$update_name = $fname . ' ' . ( !empty( $lname ) ? $lname[0] : '' );
break;
case 'initial_name_f':
$fname = get_user_meta( $user_id, 'first_name', true );
$lname = get_user_meta( $user_id, 'last_name', true );
$update_name = $fname[0] . ' ' . $lname;
$update_name = ( !empty($fname) ? $fname[0] : '' ) . ' ' . $lname;
break;
case 'nickname':
$update_name = get_user_meta( $user_id, 'nickname', true );
+1 -1
View File
@@ -120,7 +120,7 @@
return $content;
}
add_filter( 'show_admin_bar' , 'um_control_admin_bar');
add_filter( 'show_admin_bar' , 'um_control_admin_bar', 9999, 1 );
/***
*** @fix permission for admin bar
@@ -4,8 +4,8 @@ namespace um\lib\mobiledetect;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mobile_Detect' ) ) {
class Mobile_Detect {
if ( ! class_exists( 'Um_Mobile_Detect' ) ) {
class Um_Mobile_Detect {
/**
* Mobile detection type.
*
+32 -10
View File
@@ -133,7 +133,6 @@
*** @convert template tags
***/
function um_convert_tags( $content, $args = array() ) {
$search = array(
'{display_name}',
'{first_name}',
@@ -186,12 +185,12 @@
$content = str_replace( $args['tags'], $args['tags_replace'], $content );
}
$regex = '~\{([^}]*)\}~';
$regex = '~\{(usermeta:[^}]*)\}~';
preg_match_all( $regex, $content, $matches );
// Support for all usermeta keys
if (isset( $matches[1] ) && is_array( $matches[1] ) && !empty( $matches[1] )) {
foreach ($matches[1] as $match) {
if ( ! empty( $matches[1] ) && is_array( $matches[1] ) ) {
foreach ( $matches[1] as $match ) {
$strip_key = str_replace( 'usermeta:', '', $match );
$content = str_replace( '{' . $match . '}', um_user( $strip_key ), $content );
}
@@ -585,14 +584,21 @@
return false;
}
/***
*** @Get a translated core page URL
***/
/**
* Get a translated core page URL
*
* @param $post_id
* @param $language
* @return bool|false|string
*/
function um_get_url_for_language( $post_id, $language ) {
if ( ! um_is_wpml_active() )
return '';
$lang_post_id = icl_object_id( $post_id, 'page', true, $language );
$url = "";
if ($lang_post_id != 0) {
if ( $lang_post_id != 0 ) {
$url = get_permalink( $lang_post_id );
} else {
// No page found, it's most likely the homepage
@@ -603,6 +609,22 @@
return $url;
}
/**
* Check if WPML is active
*
* @return bool|mixed
*/
function um_is_wpml_active() {
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
global $sitepress;
return $sitepress->get_setting( 'setup_complete' );
}
return false;
}
/***
*** @Get core page url
***/
@@ -1388,7 +1410,7 @@
function um_get_default_avatar_uri() {
$uri = um_get_option( 'default_avatar' );
$uri = !empty( $uri['url'] ) ? $uri['url'] : '';
if (!$uri) {
if ( ! $uri ) {
$uri = um_url . 'assets/img/default_avatar.jpg';
} else {
+2 -2
View File
@@ -1,4 +1,4 @@
<?php $query_posts = UM()->query()->make('post_type=post&posts_per_page=10&offset=0&author=' . um_user('ID') ); ?>
<?php $query_posts = UM()->query()->make('post_type=post&posts_per_page=10&offset=0&author=' . um_get_requested_user() ); ?>
<?php UM()->shortcodes()->loop = apply_filters('um_profile_query_make_posts', $query_posts ); ?>
@@ -13,7 +13,7 @@
<?php if ( UM()->shortcodes()->loop->found_posts >= 10 ) { ?>
<div class="um-load-items">
<a href="#" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-args="post,10,10,<?php echo um_user('ID'); ?>"><?php _e('load more posts','ultimate-member'); ?></a>
<a href="#" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-args="post,10,10,<?php echo um_get_requested_user(); ?>"><?php _e('load more posts','ultimate-member'); ?></a>
</div>
<?php } ?>
+1 -1
View File
@@ -3,7 +3,7 @@
Plugin Name: Ultimate Member
Plugin URI: http://ultimatemember.com/
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
Version: 2.0-beta1
Version: 2.0
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member