Skip to content

Conversation

@stephenharris
Copy link

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.

@anhskohbo
Copy link

+1

@rmccue
Copy link
Member

rmccue commented Feb 12, 2016

Thanks for the PR, and apologies for the delayed response! Going to hold off on this until the core one is merged. :)

raphaelkross and others added 11 commits September 9, 2016 19:19
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 -").
@JJJ
Copy link

JJJ commented Nov 18, 2016

This still looks good!

rmccue and others added 5 commits February 16, 2017 11:01
Check for path errors when running via CLI
Fix creating users instead of mapping.
Icrement progress delta when skipped / already imported items are processed
$key = apply_filters( 'import_term_meta_key', $meta_item['key'], $term_id, $term );
$value = false;

if ( $key ) {
Copy link
Member

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' }

Copy link

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 );
Copy link
Member

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.

Copy link

Choose a reason for hiding this comment

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

Agree.

Copy link
Author

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?

Copy link
Author

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 );
Copy link
Member

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.

Copy link

Choose a reason for hiding this comment

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

Agree.

Copy link
Author

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).

}

add_term_meta( $term_id, $key, $value );
do_action( 'import_term_meta', $term_id, $key, $value );
Copy link
Member

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?

Copy link
Author

Choose a reason for hiding this comment

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

See earlier comments :)

$key = array_search( $child->tagName, $tag_name );
if ( $key ) {
$data[ $key ] = $child->textContent;
} else if ( $child->tagName == 'wp:termmeta' ) {
Copy link
Member

Choose a reason for hiding this comment

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

else if -> elseif

Copy link

Choose a reason for hiding this comment

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

Agree.

@rmccue
Copy link
Member

rmccue commented Mar 8, 2017

@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.

@stephenharris
Copy link
Author

I clearly messed up re-basing this. I'm going to squash my commits into one and forcibly push it onto my feature branch...

@stephenharris
Copy link
Author

Decided to open a new PR for this: #106

Sorry for the noise all.

@rmccue
Copy link
Member

rmccue commented Mar 8, 2017

In future, please don't rebase, just merge master into your branch regularly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.