=== CSV Export for MetForm ===
Contributors: innersitesolutions
Tags: metform, csv, export, entries, forms
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Export selected MetForm entries as a formatted CSV file, a feature the free version of MetForm lacks.

== Description ==

Adds CSV export to the free MetForm plugin:

* **Bulk action** - on the MetForm > Entries screen, tick the entries you want, choose "Export to CSV" from the Bulk actions dropdown, and click Apply. A CSV downloads immediately.
* **Per-entry button** - every entry row gets a small "CSV" button in an Export column (MetForm hides the usual hover links on its Entries screen).
* **Formatted output** - column headers use the real field labels from your form design (not raw keys like `mf-listing-fname`), plus Entry ID, Date Submitted, and Form columns.
* **Excel-friendly** - UTF-8 BOM so accented characters open correctly in Excel; checkbox/multi-select values joined with commas; file uploads exported as URLs.
* **Safe** - capability checks, nonces, and CSV formula-injection protection.
* No settings, no external requests, nothing added to the front end.

This is an unofficial add-on. It is not affiliated with, endorsed by, or supported by Wpmet, the authors of MetForm. "MetForm" is a trademark of its respective owner.

= Developer filters =

* `mfcsv_capability` - capability required to export at all (default `manage_options`)
* `mfcsv_can_export_entry` - per-entry check, receives `$allowed, $entry_id` (default: the user can edit that entry)
* `mfcsv_delimiter` - CSV delimiter (default `,`; use `;` for some EU locales)
* `mfcsv_bom` - whether to prepend a UTF-8 BOM (default true)
* `mfcsv_headers`, `mfcsv_row`, `mfcsv_filename`, `mfcsv_skip_fields`

== Installation ==

1. Install and activate MetForm if you have not already.
2. Upload the `csv-export-for-metform` folder to `/wp-content/plugins/`, or upload the zip via Plugins > Add New > Upload Plugin.
3. Activate the plugin.
4. Go to MetForm > Entries, select entries, and use the "Export to CSV" bulk action.

== Frequently Asked Questions ==

= Does it work without MetForm? =

No. It only adds actions to the MetForm entries list. Without MetForm active you will see a warning notice in wp-admin.

= Who can export? =

Administrators (the `manage_options` capability) by default, because entries contain whatever your visitors typed in. Change that with the `mfcsv_capability` filter, for example to `edit_others_posts` to let Editors export. Whatever the gate, a user only ever receives entries they could open in the editor; entries they cannot edit are left out of the file.

= Excel shows one long column instead of separate columns =

Some locales expect a semicolon separator. Add `add_filter( 'mfcsv_delimiter', function () { return ';'; } );` to a small plugin or your theme's functions.php.

= Why do some cells start with an apostrophe? =

Values that begin with `=`, `+`, `-` or `@` are prefixed so a spreadsheet will not treat them as formulas. This protects you from formula injection in submitted data.

= Is this an official MetForm product? =

No. It is an independent add-on by Innersite Solutions and is not affiliated with Wpmet.

== Screenshots ==

1. MetForm > Entries: the Export column's "CSV" button downloads that one entry.
2. Tick several entries, choose "Export to CSV" from Bulk actions, and click Apply.

== Changelog ==

= 1.0.3 =
* Fix: the per-entry export link never showed because MetForm removes and hides all row actions on its Entries screen. Entries now get a visible "CSV" button in an Export column; the row action stays for keyboard users.

= 1.0.2 =
* Security: export now requires `manage_options` by default (was `edit_posts`). Lower it with the `mfcsv_capability` filter if Editors need it.
* Security: each entry is checked with `edit_post` before it is written, and the per-entry "Export CSV" link's nonce is tied to that entry's ID, so a link cannot be edited to fetch other entries. New `mfcsv_can_export_entry` filter.

= 1.0.1 =
* Renamed to "CSV Export for MetForm" to follow WordPress.org trademark guidelines. No functional changes.
* The download filename is now passed through `sanitize_file_name()` after the `mfcsv_filename` filter.

= 1.0.0 =
* Initial release: bulk-action and per-entry CSV export with label-aware headers.
