Hack function to bulk import DNS on WP VIP
/**
* Paste this into the console on your /wp-admin/admin.php?page=domains page
* Make sure the 'Edit DNS' tab is selected
* Add entries using add_record( 'example.com', 'A', '127.0.0.1' );
* or add_record( 'example.com', 'MX', '10 mail.example.com' );
* MX records values should be the Priority<space>mailserver
*
*/
add_record = function( record, type, value ) {
var valid_types = {
A:1, MX:1, CNAME:1, TXT:1
};
if( !valid_types.hasOwnProperty( type ) ) {
console.error( 'Invalid type: %s (record: %s, type: %s, value: %s', type, record, type, value );
return false;
}
if( type == 'MX' ) {
var parts = value.split(' ');
var ttl = parts[0];
value = parts[1];
}
if( type == 'TXT' && value.length >= 192 ) {
console.error( 'Val too long: %s (record: %s, type: %s, value: %s', type, record, type, value );
return false;
}
// Change the type
jQuery('.addnew-record .record-type').val( type ).trigger('change');
// Update the primary entry
jQuery('.addnew-record .record-domain').val( record );
// Add the main value
jQuery('.addnew-record .type.type-' + type + ' [name=data]').val( value );
if( type == 'MX' ) {
// Set the TTL
jQuery('.addnew-record .type.type-MX .record-aux').val( ttl );
}
// Save
jQuery('.addnew-record input[type=submit].save.button-secondary').click();
};