Make WordPress Core

Opened 11 years ago

Last modified 6 months ago

#36340 new enhancement

Other options ignored when using a custom post type with export_wp()

Reported by: theMikeD Owned by:
Priority: normal Milestone: Future Release
Component: Export Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description (last modified by DrewAPicture)

While writing the improved docblock for export_wp(), I noticed something that may be an issue when a custom post type is supplied.

For the built-in post types you can filter the exported content by start date, end date and/or author. But not with a custom post type: with them it's everything. Is this by design?

The fix could be to modify line 113 to include the custom post type option because by that point we know that it's both valid and can_export is true thanks to the stuff starting on line 88.

I don't use this code myself but it did jump out at me. Thoughts?

Change History (4)

#1 @DrewAPicture
11 years ago

  • Description modified (diff)
  • Summary Other options ignored when using a custom post type with wp_export → Other options ignored when using a custom post type with export_wp()

#2 @chriscct7
11 years ago

  • Version trunk

#3 @earnjam
6 years ago

  • Keywords needs-patch added
  • Milestone → Future Release
  • Type defect (bug) → enhancement

The UI on the export screen doesn't allow filtering when exporting just an individual custom post type or when exporting all content, so this is just going to occur on direct calls to the export_wp() function itself.

The documentation for the function arguments of author, start_date and end_date each say:

Used only when $content is 'post', 'page' or 'attachment'

Given all of that, I think this is an enhancement and not a bug, since it's a documented design.

This ticket was mentioned in ​PR #12106 on ​WordPress/wordpress-develop by ​@shreya0shrivastava.


6 months ago
#4

  • Keywords has-patch added; needs-patch removed

Previously, the author, start_date, and end_date arguments passed to export_wp() were silently ignored when exporting a custom post type. Only the built-in post types (post, page, attachment) respected these filters due to an in_array() guard that excluded CPTs.

Remove the in_array() restriction and replace it with a simpler 'all' !== $argscontent check. By this point in the function, any invalid CPT has already fallen back to 'post' and any CPT with can_export disabled has also fallen back to 'post', so all remaining non-'all' values are guaranteed to be valid exportable post types.

Update the docblock for the author, start_date, and end_date params to reflect that these arguments now apply to all post types except when content is 'all'.

Note: the export UI does not yet show author, date, or status filter controls when a CPT is selected — that is a separate follow-up.

Trac ticket: https://core.trac.wordpress.org/ticket/36340

## Use of AI Tools

AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.6
Used for: Initial code skeleton; final implementation was reviewed and edited by me.

Note: See TracTickets for help on using tickets.