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

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

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
* : 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review (PRs only)
Development

Successfully merging this pull request may close these issues.

Convert Tutorials to Lessons
2 participants