# DawsonyWeb - Bulk Edit Tabs

A WordPress plugin that adds "Open in tabs" controls to admin list tables, allowing you to open multiple post edit screens in new browser tabs.

## Features

- **Open Selected in Tabs**: Open edit screens for checked items in new browser tabs
- **Open All on Page**: Open edit screens for all items on the current page
- **Safety Limits**: Hard limit of 25 tabs with confirmation dialog at 10+ tabs
- **Universal Support**: Works with all post types (Posts, Pages, Custom Post Types, WooCommerce Products)
- **Capability Checks**: Only shows for users who can edit the specific post type
- **No Configuration**: Works out of the box after activation

## Installation

### Manual Installation

1. Download or clone this repository
2. Upload the `dawsony-bulk-edit-tabs` folder to `/wp-content/plugins/` directory
3. Activate the plugin through the 'Plugins' menu in WordPress
4. Navigate to any post list table to see the new buttons

### Direct File Placement

If you have direct server access:

```bash
cd /path/to/wordpress/wp-content/plugins/
mkdir -p dawsony-bulk-edit-tabs/assets
# Copy the three files:
# - dawsony-bulk-edit-tabs.php (main plugin file)
# - assets/admin.js (JavaScript)
# - assets/admin.css (CSS)
```

## Usage

### Basic Usage

1. Go to any post list table in WordPress admin:
   - Posts: `/wp-admin/edit.php`
   - Pages: `/wp-admin/edit.php?post_type=page`
   - Custom Post Type: `/wp-admin/edit.php?post_type=your_cpt`
   - WooCommerce Products: `/wp-admin/edit.php?post_type=product`

2. You'll see two new buttons above (and below) the list table:
   - **"Open Selected in Tabs"** - Opens edit screens for checked items only
   - **"Open All on Page"** - Opens edit screens for all items on the current page

3. Select items using checkboxes and click "Open Selected in Tabs"
   - Or skip selection and click "Open All on Page" to open everything

4. A confirmation dialog appears when trying to open 10 or more tabs

5. A hard limit of 25 tabs is enforced for safety with an alert message

### Button Behavior

- **"Open Selected in Tabs"** button:
  - Disabled when no items are selected
  - Shows count when items are selected: "Open Selected (5) in Tabs"
  - Updates automatically as you check/uncheck items

- **"Open All on Page"** button:
  - Always enabled if there are items on the page
  - Respects current filters, search, and pagination

### Safety Features

- **Confirmation Dialog**: When opening 10+ tabs, you'll see:
  - "You are about to open X tabs. Continue?"
  - Click OK to proceed or Cancel to abort

- **Hard Limit**: Maximum of 25 tabs enforced:
  - If you try to open more, an alert shows:
  - "Cannot open more than 25 tabs. Only the first 25 will be opened."
  - Only the first 25 tabs are opened

### Popup Blocker Compatibility

The plugin opens all tabs **synchronously** in the click handler to avoid popup blockers. If your browser still blocks popups:

1. Allow popups for your WordPress admin domain
2. Most modern browsers will show an icon in the address bar to allow popups
3. Add your site to the browser's popup whitelist

## Requirements

- **WordPress**: 5.0 or higher
- **PHP**: 7.0 or higher
- **Browser**: Modern browser with `window.open()` support and popup permission
- **Permissions**: User must have edit capabilities for the post type

## Compatibility

### Post Types

Works with all post types that use WordPress standard list tables:
- Posts
- Pages
- Custom Post Types
- WooCommerce Products
- Any CPT registered with `show_ui => true`

### WordPress Versions

- Tested with WordPress 5.0+
- Compatible with latest WordPress versions
- Uses standard WordPress hooks and APIs

### Themes & Plugins

- No conflicts with standard WordPress themes
- Compatible with WooCommerce
- Works with most admin theme customization plugins

## Customization

### Filters

The plugin provides two filters for customization:

#### Change Tab Limit

```php
// Change maximum tabs from 25 to 50
add_filter('dawsony_bulk_edit_tabs_limit', function($limit) {
    return 50;
});
```

#### Change Confirmation Threshold

```php
// Show confirmation dialog at 5 tabs instead of 10
add_filter('dawsony_bulk_edit_tabs_confirm_threshold', function($threshold) {
    return 5;
});
```

Add these filters to your theme's `functions.php` or a custom plugin.

## Technical Details

### File Structure

```
dawsony-bulk-edit-tabs/
├── dawsony-bulk-edit-tabs.php    # Main plugin file (PHP)
├── assets/
│   ├── admin.js             # JavaScript functionality
│   └── admin.css            # Minimal styling
└── README.md                # This file
```

### Hooks Used

- `admin_enqueue_scripts` - Load assets only on list table screens
- `manage_posts_extra_tablenav` - Inject buttons above/below the table

### Security

- **Capability checks**: Only shows UI to users with `edit_posts` capability for that post type
- **WordPress handles edit permissions**: Each edit URL is protected by WordPress's standard capability checks
- **No server-side actions**: Pure client-side implementation (no nonces needed)
- **No AJAX calls**: Post IDs come from WordPress-generated checkboxes

### Browser Compatibility

- Chrome/Edge: ✓ Full support
- Firefox: ✓ Full support
- Safari: ✓ Full support
- Internet Explorer 11: ✗ Not supported

## Troubleshooting

### Buttons Don't Appear

1. Check if you're on a post list table screen (`edit.php`)
2. Verify you have edit permissions for the post type
3. Clear browser cache and refresh
4. Check browser console for JavaScript errors

### Popups Are Blocked

**This is the most common issue.** When opening multiple tabs, your browser may block them as popups:

1. **Look for the popup icon** in your browser's address bar (usually shows a notification)
2. **Click "Always allow popups"** for your WordPress admin site
3. **Browser-specific instructions:**
   - **Chrome/Edge**: Click the popup blocked icon in the address bar → "Always allow popups and redirects"
   - **Firefox**: Click the popup blocked icon → Preferences → Allow popups for this site
   - **Safari**: Safari → Preferences → Websites → Pop-up Windows → Allow for your site
4. After allowing popups, click the button again to open the tabs

### Buttons Are Visible But Disabled

- The "Open Selected" button is disabled when no items are selected
- Select at least one item using the checkboxes
- The "Open All" button should always be enabled if items exist

### Too Many Tabs Open

- The plugin enforces a limit of 25 tabs
- You can adjust this using the `dawsony_bulk_edit_tabs_limit` filter
- Consider opening smaller batches

## Frequently Asked Questions

### Does this work with WooCommerce?

Yes! The plugin works with WooCommerce products and any other custom post type that uses WordPress standard list tables.

### Can I change the tab limit?

Yes, use the `dawsony_bulk_edit_tabs_limit` filter (see Customization section).

### Does it work with Quick Edit?

No, this plugin opens the full edit screen in new tabs. It doesn't interact with Quick Edit.

### Is this compatible with Gutenberg?

Yes, it opens the edit screen for each post, which uses Gutenberg by default for post types that support it.

### Can I open tabs for Media Library items?

The plugin is designed for post list tables. Media Library uses a different list table class and typically doesn't use `edit.php`.

## Changelog

### 1.0.1
- Change name of plugin and new assets

### 1.0.0
- Initial release
- Open selected posts in tabs
- Open all posts on page in tabs
- Configurable safety limits
- Capability checks
- Support for all post types

## License

GPL v2 or later

## Support

For issues, questions, or contributions, please visit:
- **Website**: https://dawsony.com
- **Author**: dawsonyweb

## Credits

Built by **dawsonyweb**  
https://dawsony.com
