Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorial to lesson migration command #3041

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

adamwoodnz
Copy link
Contributor

@adamwoodnz adamwoodnz commented Nov 27, 2024

See #2393
Closes #3043

Adds a CLI command to mu-plugins for converting tutorials to lessons, by changing the post type. Takes a single post URL, or file with a list of URLs, which will be created from this sheet.

By default runs in dry mode, which prints the details of the post(s).

I plan to update the sync script to copy this into wporg/public_html/wp-content/mu-plugins/pub

@adamwoodnz adamwoodnz self-assigned this Nov 27, 2024
@adamwoodnz adamwoodnz requested review from dd32 and pkevan November 27, 2024 04:41
* : The URL of the tutorial post to convert, or path to a file containing URLs (one per line)
*
* [--live]
* : Actually perform the conversion (default is dry-run)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in most cases having a dry-run variable is how it's normally done, but this is a minor nitpick and not a blocker.

*/
private function process_url( $url, $is_dry_run ) {
// Get post ID from URL
$post_id = url_to_postid( $url );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url_to_postid is an expensive operation, so it should be considered if running through a large amount of items (which I think this instance isn't).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

$urls = array( $source );
}

foreach ( $urls as $url ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some consideration should be made for memory expensive operations when looping through an indeterminate number of items

Copy link
Contributor

@pkevan pkevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of my comments are minor given the extend of the command being used (less than 100 items)

@adamwoodnz
Copy link
Contributor Author

most of my comments are minor given the extend of the command being used (less than 100 items)

All fair, thanks!

@adamwoodnz adamwoodnz merged commit 284c6ef into trunk Nov 27, 2024
1 check passed
@adamwoodnz adamwoodnz deleted the add/2393-tutorial-lesson-migration-command branch November 27, 2024 21:05
bazza pushed a commit to WordPress/wordpress.org that referenced this pull request Nov 27, 2024
Add CLI script to convert Tutorials to Lessons

See WordPress/Learn#3041


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14214 74240141-8908-4e6f-9713-ba540dce6ec7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Convert Tutorials to Lessons
2 participants