#19863 closed enhancement (fixed)
Add filters to export_wp() process for granular export control
Reported by: | scottconnerly | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.3.1 |
Component: | Export | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The only hook that allows for export customization right now is do_action('export_wp'). There should be a filter on the $args in the same area as well as actions in the export form so additional export filters can be defined on any post type (especially the custom post types)
Use case example would be the shopping experience I'm building as a plugin. Administrators need to be able to export order CSVs for fulfillment systems, inventory systems, accounting systems, etc. I need to be able to filter by date range as well as some custom taxonomies I have defined to manage the order's present status.
Then I need to be able to generate CSVs rather than XMLs in the output. For that I can currently hijack the process at do_action('export_wp'), but it'd be better if there were hooks all through the export process that allowed me to output different headers, adjust the query, and manipulate the retrieved data.
Essentially, we're currently allowed to import any custom post content via CSV in a bespoke manner, but there's no way to get it back out in a similar format.
Attachments (2)
Change History (16)
#2
@
13 years ago
- Cc marty@… added
- Keywords has-patch added; needs-patch removed
Working on a bunch of ideas for importing/exporting and was looking for this exact thing. Here is a quick patch with a filter for export $args and two do_action calls to help add to the potential filters.
Ideally, that whole section of filters could be filtered to make it really customizable. But this is a start.
#3
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
- Summary changed from Add filters to export_wp() process for granular export control to Addd filters to export_wp() process for granular export control
Essentially, we're currently allowed to import any custom post content via CSV in a bespoke manner, but there's no way to get it back out in a similar format.
Writing a CSV exporter from scratch is not hard. Query the posts and output them to a file using fputcsv().
Anyway, the current patch looks good.
#4
@
12 years ago
- Summary changed from Addd filters to export_wp() process for granular export control to Add filters to export_wp() process for granular export control
#5
@
12 years ago
A single 'export_filters' hook at the end is probably sufficient. The args filter also seems sufficient.
#11
@
12 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In 22392:
#13
in reply to:
↑ 12
@
12 years ago
Replying to duck_:
Should that be
export_wp_args
to match the name of the function?
Thought about that. The filter is outside the function itself because it is essentially a way to alter arguments based on export_filters. If we were to add a filter inside, "export_wp_args" would work there. "export_args" probably makes the most sense here, with the wp_ prefix not needed. Thoughts?
+1 for being able to filter which posts get exported through a hook.
Not so sure about the hooks for manipulating the export format.