Last active
December 18, 2015 19:39
-
-
Save spencermorin/5834601 to your computer and use it in GitHub Desktop.
Auto fill author data in WordPress importer. Very useful for sites with many authors. Note: Should be run from the browser console when on the import-author page.
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
var authors_import = jQuery( '#authors li' ); | |
authors_import.each( function() { | |
var name_data = jQuery( this ).find( 'strong' ).html(); | |
var username, nicename; | |
username = name_data.substring( name_data.indexOf( '(' ) + 1, name_data.indexOf( ')' ) ); | |
nicename = name_data.substring( 0, name_data.indexOf( '(' ) - 1 ); | |
username.toLowerCase(); | |
nicename.toLowerCase(); | |
jQuery( this ).find( 'div select option' ).each( function() { | |
var option = jQuery( this ).html(); | |
if( option.indexOf( username.substring( 2, 8 ) ) > 0 || option.indexOf( nicename.substring( 2, 6 ) ) > 0 ) { | |
jQuery( this ).attr( 'selected', 'selected' ); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment