humanmade / authorship

A modern approach to author attribution in WordPress.
GNU General Public License v3.0
66 stars 7 forks source link

WP authors migration command - post type argument. #122

Closed mattheu closed 11 months ago

mattheu commented 1 year ago

The recently added wp authors migration command uses query_posts, but does not provide a way to query multiple post types.

New param defaults to just posts, but supports passing another post type, or comma separated list of post types.

e.g.

wp authorship migrate wp-authors // default post
wp authorship migrate wp-authors --post-type=page
wp authorship migrate wp-authors --post-type=post,page
mattheu commented 11 months ago

Hey @mikelittle - digging up an old pull request here! But the need for this functionality came up again.

We don't have any precedence in the Authorship plugin for writing tests against CLI command functionaltiy... so I did something very basic by calling the function directly and verifying the data changed as expected.

To the cases you suggest...

  1. default - as I'm calling the function directly, the default is not set. But can re-create by passing post
  2. Posts and pages. This is passed as comma separated string, so a case I reckon we should test for.
  3. CPT. I actually don't think this is necessary and a bit of a hassle to register a CPT etc.
mattheu commented 11 months ago

Ha me neither. I didn’t really try TBH, I just relied on the CI to run them!

mikelittle commented 11 months ago

All the tests passed. (though they were marked risky because of the output).