# Easy Bulk Date Editor — Installation & How-to

**Plugin filename:** `easy-bulk-date-editor/easy-bulk-date-editor.php`  
**Companion files (place alongside the PHP):** `bde.js`, `bde.css`  
**Plugin version:** 1.1

---

## Overview

This document explains how to install the Easy Bulk Date Editor plugin, how to use it to edit post dates in bulk, and an optional section showing how to add the client-side "Shift selected by" feature (useful to move many dates by a fixed offset).

The plugin provides an admin interface under **Tools → Easy Bulk Date Editor** where you can filter posts by category, see a table of posts (ID, title, current date, editable date field) and submit updates to the database in one action.

> Important: always back up your database before running bulk operations. Changing many `post_date` values can affect scheduled posts, sorting, and feeds.

---

## Files you need

- `easy-bulk-date-editor.php` — main plugin file (placed inside the plugin folder).  
- `bde.js` — front-end JavaScript handling table rendering and AJAX calls. The plugin expects this file next to the PHP file.  
- `bde.css` — small CSS helpers for the admin table (optional but recommended).

Your plugin folder structure should look like:

- `wp-content/plugins/easy-bulk-date-editor/`
  - `easy-bulk-date-editor.php`
  - `bde.js`
  - `bde.css`
  - `readme.txt`
  - `license.txt`
  - `INSTALL.md`

## Installation (manual)

1. On your server, open your WordPress installation folder and go to: `wp-content/plugins/`.
2. Create a new folder named `easy-bulk-date-editor`.
3. Put the plugin PHP file into that folder: `easy-bulk-date-editor/easy-bulk-date-editor.php`.
4. Create two files in the same folder:
   - `bde.js` — paste the JS content shipped with the plugin.
   - `bde.css` — paste the CSS content shipped with the plugin.
5. Ensure file permissions allow WordPress to read the files (typical `644`).
6. In the WordPress admin, go to **Plugins** and activate **Easy Bulk Date Editor**.

If activation fails, check `wp-config.php` for `WP_DEBUG` and inspect server error logs — common issues are syntax errors when copying files or stray invisible characters.

---

## Quick usage guide

1. In WordPress Admin go to **Tools → Easy Bulk Date Editor**.
2. Choose a category from the dropdown (or "All categories"). Click **Load posts**. The UI will fetch up to 500 posts matching the filter.
3. The table shows: checkbox, post ID, title (links to edit), current date, and an editable **New date** field (browser `datetime-local`).
4. Edit dates inline using your browser's date/time picker or type `YYYY-MM-DDTHH:MM` directly.
5. Use the **Shift selected by** controls to add/subtract days or hours before saving, if desired.
6. Click **Save changes**. The plugin will send all values to the server and update `post_date` and `post_date_gmt` for each post.
7. Check the `Updated` / `Failed` counts shown after save. If some updates failed, investigate permission issues or invalid date formats.

---

## Important notes & gotchas

- **Back up first.** Use a DB backup (mysqldump or a backup plugin) before bulk editing dates. You can restore if something goes wrong.
- **Permissions:** Only users with the `edit_posts` capability can use the tool. Additionally, each post change checks `edit_post` capability per post.
- **Date format & timezone:** The UI uses your browser's local time (the `datetime-local` input). On save the plugin sets `post_date_gmt` using WordPress utilities. If your site uses a non-standard timezone setup, test on a few posts first.
- **Scale:** By default the plugin loads up to **500 posts**. Loading many rows in the browser may be slow in older machines.
- **Browser compatibility:** `datetime-local` UI is available in modern browsers. If a browser doesn't support it, users will need to type the value manually.

---

## Optional: Add bulk "Shift selected by" feature (client-side)

If you want to be able to select rows and shift their dates by an offset (days/hours) before saving, make sure you have the included `bde.js` version which adds checkboxes, the shift controls and the client-side date math.

> NOTE: the PHP in the plugin already handles saving whatever values are present in the `datetime-local` inputs; this JS only improves the UX.

---

## Rollback

1. If you need to revert date changes, restore your database backup. There is no automatic undo for mass date changes.
2. To prevent accidental changes, only grant `edit_posts` to trusted users while using this plugin.
