Created
August 6, 2013 11:49
-
-
Save thisislawatts/6163831 to your computer and use it in GitHub Desktop.
WordPress Importer - When you've got a stack of users to import and there's a decent mix of one's that already exist, sorting them out is an unnecessary pain ->
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
jQuery('#authors li').each(function() { | |
var $self = jQuery(this); | |
var $strong = $self.find('strong'); | |
var $select = $self.find('select'); | |
var username = $strong.text().match(/\(([\w]*)\)/); | |
var matched = false; | |
console.log(username[1]) | |
if (username) { | |
$select.find('option').each(function() { | |
if (jQuery(this).text() === username[1]) { | |
jQuery(this).attr('selected', true); | |
matched = true; | |
} | |
}); | |
} | |
if (!matched) { | |
$self.find('input[type="text"]').val(username[1]); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment