Last active
August 1, 2017 21:23
-
-
Save kadamwhite/551fc4ebfbfb09a7769945fc2cb9d6a9 to your computer and use it in GitHub Desktop.
"guess" at author mappings when importing WordPress WXR file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...document.getElementById('authors').querySelectorAll('li')].forEach(li => { | |
const author = li.querySelector('strong').innerText; | |
const select = li.querySelector('select'); | |
const options = [...select.querySelectorAll('option')].map(node => ({ | |
value: node.value, | |
name: node.text, | |
})); | |
const match = options.reduce((match, option) => { | |
if (match) { | |
return match; | |
} | |
return author.indexOf(option.name) > -1 ? option.value : null; | |
}, null); | |
if (match) { | |
select.value = match; | |
} else { | |
console.log(`Could not match ${author}`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider adding this as a feature to the name mapping screen of https://github.com/humanmade/WordPress-Importer ?