-
Notifications
You must be signed in to change notification settings - Fork 63
Add support for term meta data. #18
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
Conversation
|
+1 |
|
Thanks for the PR, and apologies for the delayed response! Going to hold off on this until the core one is merged. :) |
This ensures we don't try to incorrectly map authors.
wp_handle_import_upload() sets status to private, which is one of the only things we can query by. We could also query by _wp_attachment_context, but the JS won't let us send that.
This is added as an action, but refers to media-new.php directly, so doesn't make sense outside of that.
Adds .xml to allowed mime types & improves "Import Completed" notice appearance.
Enable XML files to be selected in files dialogue
Currently the code is doing an `isset` on the `$_POST` to check if the
user was mapped, however this value is always `isset` because the HTML
form field is always present, it's just set to "0" ("- Select -").
|
This still looks good! |
Check for path errors when running via CLI
Fix creating users instead of mapping.
Icrement progress delta when skipped / already imported items are processed
class-wxr-importer.php
Outdated
| $key = apply_filters( 'import_term_meta_key', $meta_item['key'], $term_id, $term ); | ||
| $value = false; | ||
|
|
||
| if ( $key ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be if ( ! $key ) { continue' }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
| return false; | ||
| } | ||
|
|
||
| $key = apply_filters( 'import_term_meta_key', $meta_item['key'], $term_id, $term ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an existing filter in the v1 importer? If not, should be wxr_importer.process_term_meta.key. Needs documentation too.
If it's not an existing filter, not sure what it offers over the above wxr_importer.pre_process.term_meta filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is adapted from https://github.com/humanmade/WordPress-Importer/blob/master/class-wxr-importer.php#L1151
In view of that, do we still want the name changed? What about post meta?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, these hooks are in the v1 importer - but they were added after this PR was opened.
| * @param array $meta_item Meta data. (Return empty to skip.) | ||
| * @param int $term_id Term the meta is attached to. | ||
| */ | ||
| $meta_item = apply_filters( 'wxr_importer.pre_process.term_meta', $meta_item, $term_id ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should pass $term here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy too, but I wrote this to be consistent with post meta, so we ought to change https://github.com/humanmade/WordPress-Importer/blob/master/class-wxr-importer.php#L1146 too.
(Is backwards compatibility a concern here? If not, we could just replace $term_id with $term, and similarly for posts).
class-wxr-importer.php
Outdated
| } | ||
|
|
||
| add_term_meta( $term_id, $key, $value ); | ||
| do_action( 'import_term_meta', $term_id, $key, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this also an existing action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See earlier comments :)
class-wxr-importer.php
Outdated
| $key = array_search( $child->tagName, $tag_name ); | ||
| if ( $key ) { | ||
| $data[ $key ] = $child->textContent; | ||
| } else if ( $child->tagName == 'wp:termmeta' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else if -> elseif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
|
@stephenharris Sorry for the long delay here :( Submitted a review; if you don't have time to fix this up, I can do so for you. |
Also removes redundant if statement.
Also removes redundant if statement.
…s-Importer into feature/term-meta
|
I clearly messed up re-basing this. I'm going to squash my commits into one and forcibly push it onto my feature branch... |
|
Decided to open a new PR for this: #106 Sorry for the noise all. |
|
In future, please don't rebase, just merge |
WordPress 4.4 adds term meta data, and trac ticket 34602, adds term meta data to the WXR export file. Although that ticket is still open, and is unlikely to be in 4.4, this PR adds support for importing term meta data, following the schema set out in that ticket.