diff --git a/admin/css/wp-allstars-admin.css b/admin/css/wp-allstars-admin.css index 7dd5438..04a62e7 100644 --- a/admin/css/wp-allstars-admin.css +++ b/admin/css/wp-allstars-admin.css @@ -1573,4 +1573,54 @@ body.wp-admin .button.pricing-button:hover, flex-direction: column !important; position: relative !important; box-sizing: border-box !important; +} + +/* Role Checkboxes */ +.wp-allstars-role-checkboxes { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + gap: 10px; + margin-top: 10px; +} + +.wp-allstars-role-checkbox { + display: flex; + align-items: center; + gap: 8px; + padding: 8px; + background: #f8f9fa; + border: 1px solid #ddd; + border-radius: 4px; + cursor: pointer; + transition: all 0.2s ease; +} + +.wp-allstars-role-checkbox:hover { + background: #f0f0f1; + border-color: #2271b1; +} + +.wp-allstars-role-checkbox input[type="checkbox"] { + margin: 0; +} + +.wp-allstars-role-checkbox span { + font-size: 13px; + color: #50575e; +} + +/* Responsive adjustments for role checkboxes */ +@media screen and (max-width: 782px) { + .wp-allstars-role-checkboxes { + grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); + gap: 8px; + } + + .wp-allstars-role-checkbox { + padding: 6px; + } + + .wp-allstars-role-checkbox span { + font-size: 12px; + } } \ No newline at end of file diff --git a/admin/includes/class-access-manager.php b/admin/includes/class-access-manager.php new file mode 100644 index 0000000..ff2c681 --- /dev/null +++ b/admin/includes/class-access-manager.php @@ -0,0 +1,190 @@ +exists()) { + return; + } + + // Get user roles + $user_roles = $user->roles; + + // Get restricted roles from settings + $hide_admin_bar_roles = get_option('wp_allstars_hide_admin_bar_roles', array('guest', 'subscriber', 'customer')); + $restrict_dashboard_roles = get_option('wp_allstars_restrict_dashboard_roles', array('guest', 'subscriber', 'customer')); + + // Check if user's role is in restricted roles + $should_hide_admin_bar = array_intersect($user_roles, $hide_admin_bar_roles); + $should_restrict_dashboard = array_intersect($user_roles, $restrict_dashboard_roles); + + // Hide admin bar if needed + if (!empty($should_hide_admin_bar)) { + add_filter('show_admin_bar', '__return_false'); + } + + // Restrict dashboard access if needed + if (!empty($should_restrict_dashboard) && is_admin() && !wp_doing_ajax()) { + // Allow access to profile page + if (isset($_GET['page']) && $_GET['page'] === 'profile.php') { + return; + } + + // Redirect to home page + wp_redirect(home_url()); + exit; + } + } + + /** + * Display the access control settings in the advanced tab + */ + public static function display_access_settings() { + // Get current settings + $hide_admin_bar_roles = get_option('wp_allstars_hide_admin_bar_roles', array('guest', 'subscriber', 'customer')); + $restrict_dashboard_roles = get_option('wp_allstars_restrict_dashboard_roles', array('guest', 'subscriber', 'customer')); + + // Get all available roles + $roles = wp_roles()->get_names(); + + ?> + +
+ +
+
+ +
+ $role_name): ?> + + +
+
+
+
+ + +
+ +
+
+ +
+ $role_name): ?> + + +
+
+
+
+
- -
- -
-
- - -

-
-
-
+