Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save purplefeel/883898bb87970669f8476f70537c1efc to your computer and use it in GitHub Desktop.
Save purplefeel/883898bb87970669f8476f70537c1efc to your computer and use it in GitHub Desktop.
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if (-1 !== $(this).html().indexOf(`(${name})`)) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
}
});
});
})(jQuery);
@purplefeel
Copy link
Author

Update Line8 matching condition per WordPress Importer Plugin upgrade

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