diff --git a/includes/admin/assets/css/um-admin-global.css b/includes/admin/assets/css/um-admin-global.css index fa568f62..ee206b9c 100644 --- a/includes/admin/assets/css/um-admin-global.css +++ b/includes/admin/assets/css/um-admin-global.css @@ -173,4 +173,14 @@ a.um-delete{ color: #a00; } .um_tooltip:hover:before { opacity: 0.8; +} + + +.wp-admin p.um-nav-roles label input[type=checkbox] { + margin-top: 0 !important; +} + +.wp-admin p.um-nav-roles label { + margin-top: 2px !important; + margin-bottom: 2px !important; } \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-scripts.js b/includes/admin/assets/js/um-admin-scripts.js index 0ebe1596..000abca8 100644 --- a/includes/admin/assets/js/um-admin-scripts.js +++ b/includes/admin/assets/js/um-admin-scripts.js @@ -187,29 +187,33 @@ jQuery(document).ready(function() { });jQuery('.um-conditional-radio-group input[type=radio]:checked').each(function(){jQuery(this).trigger('click');}); + + + + + + + /** Conditional fields for nav-menu editor options **/ - jQuery('.um-nav-mode').each(function(){ - - if ( jQuery(this).find('input[type=radio]:checked').val() ) { - if ( jQuery(this).find('input[type=radio]:checked').val() == 2 ) { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); - } else { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); - } - } - + jQuery('.um-nav-mode').each( function() { + if ( jQuery(this).find('select').val() == 2 ) { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); + } else { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); + } }); - - jQuery(document).on('click', '.um-nav-mode input[type=radio]', function(){ - if ( jQuery(this).val() == 2 ) { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); - } else { - jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); - } + + + jQuery(document).on('change', '.um-nav-mode select', function(){ + if ( jQuery(this).val() == 2 ) { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').show(); + } else { + jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide(); + } }); }); \ No newline at end of file diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index 9a30d378..9cf083a4 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -574,88 +574,84 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { *** @add role metabox ***/ function add_metabox_role() { - add_meta_box( - 'um-admin-form-admin', - __( 'Administrative Permissions', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' + $callback = array( &$this, 'load_metabox_role' ); + + $roles_metaboxes = array( + array( + 'id' => 'um-admin-form-admin', + 'title' => __( 'Administrative Permissions', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-general', + 'title' => __( 'General Permissions', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-profile', + 'title' => __( 'Profile Access', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-home', + 'title' => __( 'Homepage Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-register', + 'title' => __( 'Registration Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-login', + 'title' => __( 'Login Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-logout', + 'title' => __( 'Logout Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-delete', + 'title' => __( 'Delete Options', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ), + array( + 'id' => 'um-admin-form-publish', + 'title' => __( 'Publish', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'side', + 'priority' => 'default' + ) ); - add_meta_box( - 'um-admin-form-general', - __( 'General Permissions', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-profile', - __( 'Profile Access', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-home', - __( 'Homepage Options', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-register', - __( 'Registration Options', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-login', - __( 'Login Options', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-logout', - __( 'Logout Options', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-delete', - __( 'Delete Options', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' - ); - - add_meta_box( - 'um-admin-form-publish', - __( 'Publish', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'side', - 'default' - ); - - do_action( 'um_admin_custom_role_metaboxes' ); + $roles_metaboxes = apply_filters( 'um_admin_role_metaboxes', $roles_metaboxes ); $wp_caps_metabox = false; if ( ! empty( $_GET['id'] ) ) { @@ -663,15 +659,26 @@ if ( ! class_exists( 'Admin_Metabox' ) ) { if ( ! empty( $data['_um_is_custom'] ) ) $wp_caps_metabox = true; } - if ( 'add' == $_GET['tab'] || $wp_caps_metabox ) { + $roles_metaboxes[] = array( + 'id' => 'um-admin-form-wp-capabilities', + 'title' => __( 'WP Capabilities', 'ultimate-member' ), + 'callback' => $callback, + 'screen' => 'um_role_meta', + 'context' => 'normal', + 'priority' => 'default' + ); + } + + + foreach ( $roles_metaboxes as $metabox ) { add_meta_box( - 'um-admin-form-wp-capabilities', - __( 'WP Capabilities', 'ultimate-member' ), - array( &$this, 'load_metabox_role' ), - 'um_role_meta', - 'normal', - 'default' + $metabox['id'], + $metabox['title'], + $metabox['callback'], + $metabox['screen'], + $metabox['context'], + $metabox['priority'] ); } } diff --git a/includes/admin/templates/access/restrict_content.php b/includes/admin/templates/access/restrict_content.php index e97a2e06..c6034126 100644 --- a/includes/admin/templates/access/restrict_content.php +++ b/includes/admin/templates/access/restrict_content.php @@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; 'type' => 'checkbox', 'name' => '_um_custom_access_settings', 'label' => __( 'Restrict access to this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_custom_access_settings'] ) ? $data['_um_custom_access_settings'] : 0, ), array( @@ -32,7 +32,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; 'type' => 'select', 'name' => '_um_accessible', 'label' => __( 'Who can access this content?', 'ultimate-member' ), - 'description' => __( 'Activate content restriction for this post', 'ultimate-member' ), + 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => ! empty( $data['_um_accessible'] ) ? $data['_um_accessible'] : 0, 'options' => array( '0' => __( 'Everyone', 'ultimate-member' ), @@ -46,7 +46,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; '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' ), + 'tooltip' => __( 'Activate content restriction for this post', 'ultimate-member' ), 'value' => $_um_access_roles_value, 'options' => UM()->roles()->get_roles( false, array( 'administrator' ) ), 'columns' => 3, @@ -57,7 +57,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; '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' ), + 'tooltip' => __( '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' ), @@ -70,7 +70,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; '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' ), + 'tooltip' => __( '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' ), @@ -83,7 +83,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; 'type' => 'wp_editor', 'name' => '_um_restrict_custom_message', 'label' => __( 'Custom Restrict Content message', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'tooltip' => __( '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' ) ), @@ -92,7 +92,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; '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' ), + 'tooltip' => __( '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( @@ -105,7 +105,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; 'type' => 'text', 'name' => '_um_access_redirect_url', 'label' => __( 'Redirect URL', 'ultimate-member' ), - 'description' => __( 'Changed global restrict message', 'ultimate-member' ), + 'tooltip' => __( 'Changed global restrict message', 'ultimate-member' ), 'value' => ! empty( $data['_um_access_redirect_url'] ) ? $data['_um_access_redirect_url'] : '', 'conditional' => array( '_um_access_redirect', '=', '1' ) ), @@ -114,7 +114,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; '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' ), + 'tooltip' => __( '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' ) ) diff --git a/includes/core/um-filters-navmenu.php b/includes/core/um-filters-navmenu.php index 67ace8d7..ae663602 100644 --- a/includes/core/um-filters-navmenu.php +++ b/includes/core/um-filters-navmenu.php @@ -26,30 +26,26 @@ $hide_children_of = array(); - foreach($items as $key => $item){ + foreach( $items as $key => $item ) { - $mode = get_post_meta($item->ID, 'menu-item-um_nav_public', true); - $roles = get_post_meta($item->ID, 'menu-item-um_nav_roles', true); + $mode = get_post_meta( $item->ID, 'menu-item-um_nav_public', true ); + $roles = get_post_meta( $item->ID, 'menu-item-um_nav_roles', true ); $visible = true; // hide any item that is the child of a hidden item - if( in_array( $item->menu_item_parent, $hide_children_of ) ){ + if ( in_array( $item->menu_item_parent, $hide_children_of ) ) { $visible = false; $hide_children_of[] = $item->ID; // for nested menus } - if ( isset( $mode ) && $visible ){ + if ( isset( $mode ) && $visible ) { switch( $mode ) { case 2: - if ( is_user_logged_in() && isset($roles) && !empty($roles)) { - if ( in_array( um_user('role'), (array)$roles) ) { - $visible = true; - } else { - $visible = false; - } + if ( is_user_logged_in() && ! empty( $roles ) ) { + $visible = in_array( um_user('role'), (array)$roles ) ? true : false; } else { $visible = is_user_logged_in() ? true : false; } diff --git a/includes/core/um-navmenu-walker-edit.php b/includes/core/um-navmenu-walker-edit.php index 3a156e80..547974c7 100644 --- a/includes/core/um-navmenu-walker-edit.php +++ b/includes/core/um-navmenu-walker-edit.php @@ -73,59 +73,70 @@ class UM_Menu_Item_Custom_Fields_Editor {
-- - - - - - - -
- -- - roles()->get_roles() as $role_id => $role) { ?> - - - -
- -+ +
+ + + +
+
+
+ roles()->get_roles();
+ $i = 0;
+ $html = '';
+ $columns = 2;
+ while ( $i < $columns ) {
+ $per_page = ceil( count( $options ) / $columns );
+ $section_fields_per_page = array_slice( $options, $i*$per_page, $per_page );
+ $html .= '';
+
+ foreach ( $section_fields_per_page as $k => $title ) {
+ $id_attr = ' id="' . $id . '_' . $k . '" ';
+ $for_attr = ' for="' . $id . '_' . $k . '" ';
+ $name_attr = ' name="' . $role_name . '" ';
+
+ $html .= "";
+ }
+
+ $html .= '';
+ $i++;
+ }
+
+ echo $html; ?>
+