# Simplify Admin Menus

A WordPress plugin that provides granular control over which admin menu items and admin bar items are visible to different user roles.

## Description

Simplify Admin Menus is a powerful WordPress plugin designed to help administrators customize the WordPress admin interface by controlling the visibility of menu items based on user roles. This enhances security and provides a cleaner, more focused admin experience for different types of users.

## Features

- Selectively hide/show admin menu items for specific user roles
- Per-user Inherit / Hide / Show overrides that can bypass role settings
- Protected administrators who always retain full menu access
- Control visibility of admin bar items
- User-friendly interface for managing menu visibility settings
- Role-based access control
- Clean and efficient code implementation
- Compatible with the latest WordPress version

## Installation

1. Download the plugin zip file
2. Go to WordPress admin panel > Plugins > Add New
3. Click on "Upload Plugin" and choose the downloaded zip file
4. Click "Install Now" and then "Activate"

## Development

### Build Process

The plugin uses Vite for asset compilation. Here's how to get started with development:

1. Install dependencies:
   ```bash
   npm install
   ```

2. Development mode with hot reload:
   ```bash
   npm run dev
   ```

3. Build for production:
   ```bash
   npm run build
   ```

The build process will:
- Compile and bundle JavaScript files
- Process SCSS files to CSS
- Generate a manifest file for asset versioning
- Output optimized files to the `dist` directory

### Creating Distribution Package

To prepare the plugin for distribution, first ensure you've built all assets using `npm run build`. Then use the WP-CLI command to create a distribution package:

```bash
wp dist-archive . ./releases/simplify-admin-menus.zip --create-target-dir --format=zip
```

This will:
- Create a `releases` directory if it doesn't exist
- Package all plugin files into a ZIP archive
- Exclude development files and directories (like `node_modules`, `.git`, etc.)
- Create a clean distribution-ready plugin ZIP file

### Build Output Structure

After building, the following files will be generated in the `dist` directory:
- `js/` - Contains compiled JavaScript files with hash-based versioning
- `css/` - Contains compiled CSS files with hash-based versioning
- `.vite/manifest.json` - Contains the mapping of source files to their hashed versions

## Usage

1. Navigate to Settings > Simplify Admin Menus in your WordPress admin panel
2. Optionally configure Protected administrators (first admin is protected by default)
3. Select a user role and check menu items to hide for that role
4. Or select a specific user and set Inherit / Hide / Show per item (Show bypasses role hiding)
5. Save your changes
6. Repeat for other roles or users as needed

## Translations

The plugin comes with support for multiple languages. Here's how to work with translations:

### Updating Translation Template

To update the POT (template) file when new strings are added to the plugin:

```bash
wp i18n make-pot . resources/languages/simplify-admin-menus.pot
```

### Adding a New Translation

1. Copy the template file to create a new PO file for your language:
   ```bash
   cp resources/languages/simplify-admin-menus.pot resources/languages/simplify-admin-menus-{language_code}.po
   ```
   Replace {language_code} with your language code (e.g., sv_SE for Swedish)

2. Edit the PO file using a translation editor like Poedit
3. Save the file - this will automatically generate the required .mo file

### Available Translations

- Swedish (sv_SE)

## Requirements

- WordPress 5.0 or higher
- PHP 7.2 or higher
- Node.js 16.0 or higher (for development)
- npm 8.0 or higher (for development)

## Support

For support questions, feature requests, or bug reports, please create an issue in the plugin's repository.

## License

This plugin is licensed under the GPL v2 or later.

## Author

Created by Adam Alexandersson

## Changelog

### 1.0.0
- Initial release
- Basic functionality for hiding admin menu items
- Role-based access control
- Admin interface for managing settings

### 1.1.0
- Added support for all admin bar items
- Added composer and rewrite of the code with PSR-12 and PSR-4 autoloading
- Added translations support
- Rewrited the javascript from jQuery to Vanilla javacript and updated the CSS to SCSS
- Added Vite build system for asset management 

### 1.2.0
- Renamed the plugin to Simplify Admin
- Added support for wordpress color schemes

### 1.2.1
- Minor changes and improvements
- Translations updates

### 1.2.2
- Improved security and code quality for WordPress plugin repository

### 1.3.0
- Added support for user specific settings 
- Improved security and code quality for WordPress plugin repository
- Renamed plugin to Simplify Admin Menus

### 1.3.1
- General improvements

### 1.3.2
- Tested with Wordpress 6.9

### 2.0.0
- Added protected administrators who always retain full menu and admin bar access
- Added per-user Inherit / Hide / Show overrides that can bypass role settings
- Migrated legacy user hide maps to the new override format automatically
- Protected access is controlled only by the protected administrators list (not network/super admin status alone)
- Improved menu removal using WordPress core menu APIs
- Restructured plugin code into clearer namespaced app folders
- Hardened settings save/load sanitization and redirects
- Tested with Wordpress 7.0
