=== WPGeared Better Export ===
Contributors: wpgeared
Tags: export, posts, csv, wxr, migration
Requires at least: 5.0
Tested up to: 7.1
Stable tag: 1.4.3
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Export selected WordPress content to WXR or CSV, and import WXR in small, resumable batches.

== Description ==

WPGeared Better Export helps you create focused, predictable exports instead of downloading everything and sorting it out later. Filter content by type, status, date, author, category, tag, and item limit, then export posts and pages as WordPress WXR or export public content types as CSV.

= New in 1.4.3: A Clearer Admin Workspace =

Choose content and filters beside a manual export preview. Review matching counts, sample rows and the estimated size, then select **Download WXR**, **Download CSV**, or **View data table**. Compact category/tag selectors support multiple choices; the layout stacks on smaller screens. The Import tab uses the same layout while retaining saved progress, pause and recovery controls.

= New in 1.4.0: Resumable WXR Import =

The **Import** tab uploads XML in 256 KB chunks, checks it in bounded sections, and imports content in short requests with saved progress. Choose author mappings, download media, pause or cancel, return later, and retry failed items. Media downloads and image processing run separately; temporary download errors receive up to three attempts with pauses. The completion report distinguishes complete, skipped, and failed records.

Keep the plugin page open while processing. Temporary connection failures retry automatically with increasing pauses and a saved-progress check before repeating work. Recovery waits for the previous worker to finish and stops after 20 retries or ten minutes, with an actionable error. Closing the page stops scheduling new batches; reopening the Import tab resumes jobs that were running. Deliberately paused or cancelled jobs stay stopped until you select **Continue**. Expired login sessions require signing in again and reloading the page. This limits peak work, but importing still consumes server resources. A single image operation or another plugin's hooks can exceed the normal batch target.

Supported: WXR 1.0–1.2; posts, pages and registered content types; registered taxonomies, comments and their metadata; plain and serialized array/scalar custom fields; featured images, attachment parents, and known imported links. Core media block IDs are remapped when the installed WordPress version provides block serialization. Serialized objects, menus, revisions, site settings, users/passwords, arbitrary plugin-specific ID references, and external side effects triggered by other plugins are outside this importer's migration guarantees. Authors map to existing users without creating accounts. Existing matching terms are reused without overwriting their descriptions or metadata.

Import requirements and limits: PHP DOM/XML; transactional InnoDB WordPress tables (SQLite integration is also supported); available database space for the XML and normalized staging records, potentially several times the XML size. Maximum file 512 MB, individual XML record 8 MB/20,000 tags, nesting 64 levels, and 500 source authors. Media files are limited to 20 MB and images to 20 megapixels, with an additional memory check. Media URLs must be publicly reachable HTTP(S) URLs and files must pass WordPress's allowed-file checks. Missing dependencies and oversized/unsupported records are reported rather than silently dropped.

Saved import data is private database content, not a public XML download. Remove saved jobs when their resume history is no longer needed; uninstalling the plugin removes its staging/history tables. Imported posts and registered media are retained. Files written before an interrupted database commit can remain in the import's uploads folder; a retry reuses their deterministic paths. Removing a job does not remove these files.

Jobs already marked invalid by an earlier version need their source checked and a fresh upload after removing that job's saved history.

The importer resumes its own jobs. It cannot automatically adopt a partially completed native WordPress import. Possible existing matches are reported for review, and the same XML cannot start a second saved job until its earlier history is removed. Test migrations on staging before using a destination with existing content.

= Export Fidelity Improvements in 1.3.1: More Complete WXR Exports =

WXR exports now include other media attached to the selected posts or pages, alongside featured images. Both media options are enabled by default and can be selected independently. Attachment alt text, protected custom fields, comment metadata, taxonomy hierarchy and metadata, original GUIDs, and modification dates are preserved in the export. Featured-image references are written once.

Exports are prepared before downloading. If a value cannot be represented in valid XML, the export stops with a record identifier. You can explicitly choose to skip affected metadata, accepting the omitted data; the XML records the number of skipped rows. Post content is never silently changed, and serialized metadata is never automatically rewritten. This does not modify data on your site.

= Preview Before You Export =

Version 1.3.0 adds an export preview to both the WXR and Data Export tabs. Click **Preview Export** to review the result before starting the download.

* See the total number of items matching your filters.
* See how many items will actually be exported after applying an item limit.
* Confirm the active content type, statuses, dates, author, taxonomies, fields, and output settings.
* Inspect up to five sample items using the values prepared for the export.
* Review an estimated output size before downloading.
* Change a setting and the previous preview is cleared automatically, preventing stale results from being mistaken for the current selection.

Preview and download use the same validated filters and CSV value preparation, helping the preview accurately represent the export you are about to create. The size is an estimate based on the sample and may vary from the final file.

= Highlights =

* Preview matching content, selected settings, sample rows, and estimated size before exporting.
* Export straight to **WXR** for migrations or **CSV** for spreadsheets, reporting, and BI tools.
* Targeted filtering by date range, post status, taxonomy, author, post type, and limits.
* Select exactly which CSV columns to include, including relative URLs and featured images.
* Built-in quick presets (Last Month, This Year, etc.) keep repetitive workflows fast.
* Familiar WordPress-style interface with grouped filters and a sample preview.

= Key Features =

* **Batched WXR Import**: Private chunked uploads, validation, author mapping, saved progress, pause/resume, separate media processing, and failure reports
* **Export Preview**: Check matching and effective counts, active settings, sample rows, and estimated size before downloading
* **Dual Export Formats**: Export posts and pages as WXR for migration, or export public content types as CSV for analysis
* **Advanced Filtering**: Filter by date range, post status, categories, tags, author, content type, and item limit
* **Selective Field Export**: Choose from 18 CSV fields so the file contains only the data you need
* **Related Media**: Independently include featured images and other attached media in WXR, with image alt text and attachment data
* **Quick Date Presets**: Apply common WXR date ranges such as Last Month, This Month, and This Year
* **Custom Filenames**: Choose the downloaded CSV filename
* **Browser Table**: Display selected data in the browser when a downloadable CSV is not required

= WXR Export =

Export filtered posts or pages in WordPress WXR format for migration between WordPress sites. Before downloading, preview the matching count, selected options, sample content, and estimated size. WXR can include:
* Full post/page content
* Categories, tags, and registered custom taxonomies, including hierarchy and term metadata
* Non-spam comments (including pending and trashed comments) and comment metadata
* Public and protected custom fields, preserved in their original serialized form where applicable
* Featured images and other media attached to the selected posts/pages, including image alt text
* Original GUIDs and creation/modification dates
* Author information

= CSV Export =

Export posts, pages, and public custom post types as CSV for data analysis, reporting, or external use. Preview the selected columns and sample values first. Choose from 18 fields including:
* Post ID, Title, Slug, URL
* Content and Excerpt
* Categories and Category URLs
* Tags and Tag URLs
* Author information
* Published and Modified dates
* Status and Post Type
* Comment count
* Featured Image URL

= Advanced Filtering =

* **Date Range**: Filter by specific date ranges with date pickers
* **Quick Presets**: Use preset ranges (Last Month, This Year, etc.)
* **Post Status**: Filter by Published, Draft, Pending, Scheduled, Private, or Trashed
* **Categories & Tags**: Multi-select dropdowns for easy selection
* **Author**: Filter by specific authors
* **Content Limits**: Set maximum number of items to export

= Perfect For =

* Migrating specific content between WordPress sites
* Creating backups of filtered content
* Exporting data for analysis in Excel or other tools
* Exporting content by date range or category
* Testing exports before full site migration

= Why WPGeared Better Export? =

* **Migration specialists** move only the content they need, avoiding bloated XML files.
* **Content teams** track editorial output with CSV datasets filtered by author or taxonomy.
* **Data analysts** receive clean, ready-to-query exports for Excel, Google Sheets, or BI tools.
* **Agencies** streamline QA by exporting smaller test batches before large moves.

Need help or have a feature request? Open a support topic on WordPress.org or visit https://wpgeared.com for priority assistance.

== Installation ==

1. In **Plugins → Add New**, search for “WPGeared Better Export” and click **Install Now** (or upload the ZIP manually).
2. Activate the plugin via **Plugins → Installed Plugins**.
3. Open **Tools → Export Posts** to access WXR Export, Data Export, and Import.
4. Choose your content, filters, fields, and export options.
5. Click **Preview Export** to verify the count, active settings, sample rows, and estimated size.
6. When the preview looks correct, select **Download WXR**, **Download CSV**, or **View data table**, depending on the chosen format.

= Importing on the Destination Site =

1. Open **Tools → Export Posts → Import** on the destination site.
2. Upload a valid WordPress XML file. Wait for **Ready to import**; no destination content is written during this check.
3. Review counts, author mappings, and media/link settings, then click **Start import**.
4. Keep the page open. Use **Pause**, or return later and select the saved job followed by **Continue**.
5. Review the final counts and failures. Correct missing source files, plugins, or other causes and use **Retry failed items**. Dependent records may need a second retry after their missing media/parent is restored.
6. Remove saved import data when you no longer need resume history. Cancellation and cleanup do not undo imported content.

== Frequently Asked Questions ==

= Will importing avoid timeouts completely? =

No. Batches target roughly three seconds of work, up to ten ordinary records or one media stage per request, with a one-second pause. XML preparation is also bounded. A single operation can take longer, and host limits, disk space, slow media servers, or plugin hooks can still cause failures. Progress is saved; completed records do not need to restart. A worker lock may take up to five minutes to expire after an interrupted request. Reload the page if your login or security token expires.

= Does import change the original website? =

No. It reads the uploaded XML and downloads referenced files from the source. Content changes happen on the destination site. Export behavior remains unchanged.


= How do I export posts? =

Go to **Tools → Export Posts**, select your filters, review **Preview export**, then select **Download WXR**. Use the **Data Export** tab for **Download CSV** or **View data table**.

= Can I export pages or CPTs? =

Yes. The WXR tab exports posts or pages for WordPress migration. The Data Export tab exports posts, pages, individual public custom post types, or **All public content types** together.

= Will featured images be included? =

Enable "Featured Images" and "Other Attached Media" to include featured-image records and files whose WordPress parent is one of the selected posts/pages. WXR stores URLs and metadata, not the image files themselves. The source URLs must remain reachable, and the importer must be allowed to download attachments. Images linked from external sites or the media library without one of these relationships are not automatically collected. CSV exports can include the Featured Image URL column.

= What if the export reports invalid XML data? =

The default behavior stops before a download and identifies the affected record. Fix that source value, or explicitly select "Skip affected metadata" to leave those metadata rows out of this export. Skipping can remove plugin-specific data; use it only when you accept that loss. The XML ends with an omission count. Invalid post/comment/term text still stops the export. No source data is changed, and raw serialized values are not edited because doing so can corrupt their structure.

= Are all custom fields included? =

With "Custom Fields" enabled, public and protected post/attachment metadata are exported, except `_edit_lock` and values excluded by native WordPress export filters. Essential attachment file information and alt text are retained when media are included even if custom fields are disabled. Disabling "Featured Images" also excludes the post's thumbnail reference. Term metadata and comment metadata accompany their respective records. Registered custom taxonomies must also exist at the destination to be imported.

= What format should I use? =

* Use **WXR** for migrating content to another WordPress site.
* Use **CSV** for data analysis, reporting, or external use.

= How many columns can I export in CSV? =

You can choose from 18 fields, including ID, title, URL, taxonomies, author data, dates, status, post type, comment count, and featured image URL. Only the selected columns are included.

= Can I check an export before downloading it? =

Yes. Click **Preview Export** to see how many posts/pages match, how many will be exported after applying the limit, the active settings, up to five sample rows, and an estimated output size. Media items are additional to these counts. The sample is not a full integrity check; the complete file is prepared and checked when downloading. Changing any export setting clears the previous preview so stale results are not shown.

= How do I export very large datasets safely? =

Start with **Preview Export** to check the matching count and estimated size. Use non-overlapping date ranges for separate exports; an item limit alone repeatedly selects the same newest matching items. WXR is staged in a temporary file before downloading, requiring temporary disk space roughly equal to the XML size. Exports remain synchronous and subject to server memory and execution-time limits; background processing is not included in this release.

= Do I need special permissions? =

Exports require the WordPress **export** capability. Imports additionally require **import** and **upload_files**, plus the destination post type permissions. Import jobs are bound to the user who created them.

== Screenshots ==

1. WXR Export tab with date presets, taxonomy filters, and export options.
2. Data Export tab showing selectable CSV fields, author filters, and output options.
3. Data Export on a phone, with a preview table that scrolls inside the panel.
4. WXR export preview on a tablet, with matching counts, sample rows and estimated size.
5. Import tab with saved jobs and a completion report separating complete, skipped and failed records.

== Changelog ==

= 1.4.3 =
* Redesign the admin workspace with compact filters, a side-by-side preview and consistent WXR, Data Export and Import tabs.
* Add keyboard-friendly content tabs, labeled compact taxonomy selectors and responsive layouts for smaller screens.
* Keep preview counts and samples beside the download action; clear stale results when settings change and ignore superseded responses.
* Retain every export option, existing format/default, strict XML handling and saved import recovery behavior.
* Clarify that WXR contains media records and source URLs, with file download occurring during import.

= 1.4.2 =
* Keep valid XML and its saved preparation progress resumable after database read/write failures; retry temporary storage failures automatically.
* Keep source-validation errors separate from infrastructure errors and retain transactional checkpoints.
* Restore import controls after removing saved history, including when the following refresh fails.
* Confirm completed upload pauses while preserving safe recovery if the final upload response is lost.
* Validate uploaded chunk fields and document narrow Plugin Check exceptions for existing safe output, local file movement, and plugin-owned database cleanup.


= 1.4.1 =
* Automatically recover from temporary timeout, connection, and server failures during uploads and batches.
* Check saved progress and the worker lease before retrying, including lost responses after committed work.
* Resume running imports when the Import tab is reopened; preserve explicit pause/cancel and persist pauses requested during a batch.
* Report recovery attempts, exhausted retries and expired sessions clearly.


= 1.4.0 =
* Add a dedicated Import tab with private chunked XML upload and bounded validation before destination writes.
* Add durable jobs, a site-wide worker lock, transactional item checkpoints, pause/resume/cancel, and duplicate-file detection.
* Import supported content, comments, taxonomies and metadata with existing-user author mapping.
* Download media and generate image metadata separately, with bounded retries for temporary network errors.
* Reconcile parents, featured images, known imported links, and supported core media block IDs.
* Show saved/complete/skipped/failed counts, actionable failures, retry controls and staging cleanup.
* Retain the 1.3.1 export-fidelity fixes; export processing remains synchronous.

= 1.3.1 =
* Include child attachments and featured images independently, with deduplicated media records.
* Preserve image alt text, protected attachment metadata, comment metadata, and term hierarchy/metadata.
* Export custom taxonomy relationships, original GUIDs, and modification timestamps.
* Honor native content, excerpt, and metadata export filters; remove duplicate thumbnail references.
* Preserve serialized metadata bytes and carriage returns through XML parsing.
* Prepare complete WXR files before download; stop with a record identifier on invalid XML data.
* Add an explicit option to skip invalid metadata, recording the omitted-row count without changing site data.

= 1.3.0 =
* Added **Preview Export** to both the WXR and Data Export tabs.
* Added total matching counts and effective export counts after item limits are applied.
* Added summaries of the active content, status, date, author, taxonomy, field, and output settings.
* Added up to five sample items using the same prepared values as the export.
* Added estimated WXR, CSV, and browser-table output sizes.
* Automatically clears stale previews and cancels an in-progress preview when settings change.
* Unified preview and download query validation so both paths apply the same filters.
* Protected preview requests with WordPress nonces and the standard `export` capability.

= 1.2.4 =
* Added highlights section and refreshed readme copy for better Plugin Directory visibility.
* Clarified installation and FAQ instructions for WXR/CSV workflows.
* Prepared structure for upcoming banner, icon, and screenshot assets.

= 1.2.3 =
* Fixed performance issue - added version parameter to wp_register_style() for proper cache busting

= 1.2.2 =
* Fixed coding standards errors for WordPress core hook usage
* Added phpcs:ignore comments for the_title_rss filter (WordPress core hook)

= 1.2.1 =
* Updated author information to WPGeared
* Updated author URI to https://wpgeared.com
* Updated contributors to match WordPress.org username

= 1.2.0 =
* Fixed deprecated utf8_encode() function - replaced with mb_convert_encoding() for PHP 8.2+ compatibility
* Improved CSS/JS enqueuing - now using wp_add_inline_style() and wp_add_inline_script() following WordPress best practices
* Enhanced encoding detection for better character handling in exports

= 1.1.0 =
* Added tabbed interface with WXR and Data Export tabs
* Added CSV export functionality with 18+ field options
* Added support for custom post types
* Improved UI with Better Search Replace style design
* Added multi-select dropdowns for categories and tags
* Added attachment export for featured images
* Fixed PHP 8+ compatibility issues
* Improved security with proper escaping functions
* Fixed UTC timestamp generation

= 1.1.7 =
* Fixed InputNotSanitized warnings using phpcs:disable/phpcs:enable blocks
* Improved input sanitization handling for Plugin Repo check

= 1.1.6 =
* Fixed MissingUnslash warnings by unslashing directly in assignment
* Improved phpcs:ignore comment placement

= 1.1.5 =
* Fixed remaining Plugin Repo input sanitization warnings
* Added phpcs:ignore comments for proper input handling flow

= 1.1.4 =
* Fixed array input sanitization warnings for Plugin Repo check
* Improved $_POST array handling with proper isset() checks

= 1.1.3 =
* Fixed remaining Plugin Repo coding standards issues
* Fixed array input sanitization warnings
* Improved phpcs:disable/phpcs:enable block usage

= 1.1.2 =
* Fixed Plugin Repo coding standards compliance
* Improved phpcs:ignore comment formatting
* Fixed input sanitization warnings

= 1.1.1 =
* Fixed WordPress coding standards compliance issues
* Improved security with proper input sanitization
* Fixed escaping issues for better security

= 1.1.0 =
* Major update with CSV export, improved UI, and enhanced features
* Added Data Export tab with advanced filtering
* Improved UI design similar to Better Search Replace
* Added multi-select dropdowns for categories and tags
* Enhanced featured image export in WXR format

= 1.0.0 =
* Initial release
* WXR export functionality
* Basic filtering options

== Upgrade Notice ==

= 1.4.3 =
Redesigns the admin interface while retaining export formats and saved import jobs. Replace the plugin without uninstalling; test the new workspace on staging before a full migration.

= 1.4.2 =
Fixes preparation recovery, disabled controls after cleanup and upload-pause feedback. Replace the plugin to keep saved jobs; do not uninstall it.


= 1.4.1 =
Fixes imports stopping after a temporary connection failure. Existing 1.4.0 saved jobs are retained; open Import to resume a running job automatically. Keep the page open while importing.


= 1.4.0 =
Adds resumable WXR imports. Test on staging first, especially after a partial native import. Requires transactional database tables and PHP XML/DOM; see the documented limits. Includes the 1.3.1 export fixes.

= 1.3.1 =
Migration-fidelity fixes: related media, alt text, comment/term metadata, and original post fields. Both media options default on. Invalid source data now stops the download unless metadata omission is explicitly selected.

= 1.3.0 =
Preview matching counts, active settings, sample rows, and estimated size before downloading WXR or CSV exports.

= 1.2.4 =
Documentation refresh and prep for new assets. Update to benefit from clearer workflows.

= 1.1.7 =
Fixed InputNotSanitized warnings for Plugin Repo check. Update recommended.

= 1.1.6 =
Fixed MissingUnslash warnings for Plugin Repo check. Update recommended.

= 1.1.5 =
Fixed remaining Plugin Repo input sanitization warnings. Update recommended.

= 1.1.4 =
Fixed array input sanitization warnings for Plugin Repo check. Update recommended.

= 1.1.3 =
Fixed remaining Plugin Repo coding standards issues. Update recommended.

= 1.1.2 =
Fixed Plugin Repo coding standards compliance. Update recommended.

= 1.1.1 =
Security and coding standards improvements. Update recommended.

= 1.1.0 =
Major update with CSV export, improved UI, and enhanced features. Update recommended.
