Skip to content

Instantly share code, notes, and snippets.

@spencermorin
Last active December 18, 2015 19:39
Show Gist options
  • Save spencermorin/5834601 to your computer and use it in GitHub Desktop.
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.
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