diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
index f181a25d..fc007e5b 100644
--- a/ISSUE_TEMPLATE.md
+++ b/ISSUE_TEMPLATE.md
@@ -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
diff --git a/assets/js/um-profile.js b/assets/js/um-profile.js
index 12238b55..60a7861c 100644
--- a/assets/js/um-profile.js
+++ b/assets/js/um-profile.js
@@ -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;
});
diff --git a/includes/admin/assets/js/um-admin-builder.js b/includes/admin/assets/js/um-admin-builder.js
index 380a1e0a..432a6d6d 100644
--- a/includes/admin/assets/js/um-admin-builder.js
+++ b/includes/admin/assets/js/um-admin-builder.js
@@ -40,5 +40,6 @@ function um_admin_update_builder() {
}
jQuery(document).ready(function() {
-
+ if ( um_admin_builder_data.hide_footer )
+ jQuery('#wpfooter').hide();
});
\ No newline at end of file
diff --git a/includes/admin/assets/js/um-admin-role-wrapper.js b/includes/admin/assets/js/um-admin-role-wrapper.js
index 6ddddf77..81e6fbc0 100644
--- a/includes/admin/assets/js/um-admin-role-wrapper.js
+++ b/includes/admin/assets/js/um-admin-role-wrapper.js
@@ -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');
+
});
\ No newline at end of file
diff --git a/includes/admin/core/class-admin-columns.php b/includes/admin/core/class-admin-columns.php
index 6c82c74a..8d281747 100644
--- a/includes/admin/core/class-admin-columns.php
+++ b/includes/admin/core/class-admin-columns.php
@@ -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;
+ }
+
}
}
\ No newline at end of file
diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php
index f58eb336..e26be8e7 100644
--- a/includes/admin/core/class-admin-enqueue.php
+++ b/includes/admin/core/class-admin-enqueue.php
@@ -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 );
diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php
index ebf6a0fa..2008749b 100644
--- a/includes/admin/core/class-admin-metabox.php
+++ b/includes/admin/core/class-admin-metabox.php
@@ -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 '';
+ $this->is_loaded = true;
}
}
@@ -1952,20 +1966,17 @@ if ( ! class_exists( 'Admin_Metabox' ) ) {
case '_parent_dropdown_relationship':
?>
-
+
diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php
index 89e1719c..4055e978 100644
--- a/includes/admin/core/class-admin-settings.php
+++ b/includes/admin/core/class-admin-settings.php
@@ -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] );
}
}
diff --git a/includes/admin/core/class-admin-upgrade.php b/includes/admin/core/class-admin-upgrade.php
index 7bfcb0de..884e423b 100644
--- a/includes/admin/core/class-admin-upgrade.php
+++ b/includes/admin/core/class-admin-upgrade.php
@@ -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;
+ }
}
diff --git a/includes/admin/core/list-tables/emails-list-table.php b/includes/admin/core/list-tables/emails-list-table.php
index 3a8ba7e1..67580ccc 100644
--- a/includes/admin/core/list-tables/emails-list-table.php
+++ b/includes/admin/core/list-tables/emails-list-table.php
@@ -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 ''. $item['title'] . '';
}
diff --git a/includes/admin/core/list-tables/roles-list-table.php b/includes/admin/core/list-tables/roles-list-table.php
index 7a0e463c..bbf76009 100644
--- a/includes/admin/core/list-tables/roles-list-table.php
+++ b/includes/admin/core/list-tables/roles-list-table.php
@@ -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;
}
diff --git a/includes/admin/core/packages/2.0-beta1.php b/includes/admin/core/packages/2.0-beta1.php
index 06fb4770..e2e8bf1a 100644
--- a/includes/admin/core/packages/2.0-beta1.php
+++ b/includes/admin/core/packages/2.0-beta1.php
@@ -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 ) {
diff --git a/includes/admin/core/um-admin-filters-fields.php b/includes/admin/core/um-admin-filters-fields.php
index 69034286..c8b553cf 100644
--- a/includes/admin/core/um-admin-filters-fields.php
+++ b/includes/admin/core/um-admin-filters-fields.php
@@ -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;
+ }
diff --git a/includes/admin/templates/dashboard/cache.php b/includes/admin/templates/dashboard/cache.php
index 779c25af..e9161ec9 100644
--- a/includes/admin/templates/dashboard/cache.php
+++ b/includes/admin/templates/dashboard/cache.php
@@ -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++;
}
diff --git a/includes/class-dependencies.php b/includes/class-dependencies.php
index df163cd0..421de273 100644
--- a/includes/class-dependencies.php
+++ b/includes/class-dependencies.php
@@ -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',
);
/**
diff --git a/includes/class-functions.php b/includes/class-functions.php
index c3362c4d..77a58143 100644
--- a/includes/class-functions.php
+++ b/includes/class-functions.php
@@ -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
*
diff --git a/includes/class-init.php b/includes/class-init.php
index 5139305c..bdb0fd2b 100644
--- a/includes/class-init.php
+++ b/includes/class-init.php
@@ -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'];
diff --git a/includes/core/class-access.php b/includes/core/class-access.php
index e03793b6..7cd83a85 100644
--- a/includes/core/class-access.php
+++ b/includes/core/class-access.php
@@ -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;
}
diff --git a/includes/core/class-builtin.php b/includes/core/class-builtin.php
index e8220e8d..a1b17e1a 100644
--- a/includes/core/class-builtin.php
+++ b/includes/core/class-builtin.php
@@ -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') ) );
diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php
index 81c54601..b1ac87b2 100644
--- a/includes/core/class-fields.php
+++ b/includes/core/class-fields.php
@@ -1887,31 +1887,24 @@
$output .= '