Use WP Encrypt with Domain Mapping

I am using WP Encrypt to generate and install SSL certificates from Let's Encrypt. The issue is that the mapped domains (I use subdomains) are not being picked up by WP Encrypt. Apparently WP Encrypt looks for the domain to add to the certificate from the Site URL field. I guess domain mapping doesn't change that field, but leaves it as a subdomain. I tested this by changing the Site URL on one of my mapped sites to see if it would pick it up and it did.

So my question is, is there someway to add a filter or something so that Domain Mapping's virtual domain are picked up by WP Encrypt. The process of generating and maintaining new ssl certificates is so much easier with this plugin, but it does me no good if the mapped domains aren't picked up. The developer of WP Encrypt said that this filter would pick it up, but it doesn't:

/**
* Filters the addon domains to create the certificate for.
*
* Using this filter basically allows to generate the certificate for any URLs,
* even those outside of the WordPress installation.
*
* @since 1.0.0
*
* param array $addon_domains The addon domains.
* param string $domain The root domain for the certificate.
* param bool $network_wide Whether this certificate is created for an entire network.
*/
$addon_domains = apply_filters( 'wpenc_addon_domains', $addon_domains, $domain, $network_wide );`

From: https://wordpress.org/support/topic/multisite-with-domain-mapping-problem/

Would there be some way to use this: https://premium.wpmudev.org/forums/topic/get-domain-mapped-url-from-all-my-sites#post-936438 to create a parameter to add to this filter?

Thanks!

  • Kasia Swiderska
    • Support nomad

    Hello jnkfrancis,

    I'm not familiar with WP Encrypt plugin so let me ping our coding experts from Second Line Support and ask them if this is possible to achieve and how could this be done.
    As soon I'll get a feedback I will update thread.
    Please note that our SLS staff is working on lots of tasks so their answer can be delayed.

    kind regards,
    Kasia

  • Ivan
    • Developer

    Hi jnkfrancis !

    You can try to create MU plugin (for example, create {wordpress folder}/wp-content/mu-plugins/wpmu_lets_encrypt_for_mapped_domains.php file via FTP ) with the following code:

    <?php
    function wpmu_lets_encrypt_for_mapped_domains( $addon_domains, $domain, $network_wide ) {
    	global $wpdb;
    
    	$mapped_domains = $wpdb->get_col( "SELECT domain FROM {$wpdb->base_prefix}domain_mapping" );
    	if ( !empty( $mapped_domains ) ) {
    		$addon_domains = array_merge( $mapped_domains, $addon_domains );
    	}
    
    	return $addon_domains;
    }
    
    add_filter( 'wpenc_addon_domains', 'wpmu_lets_encrypt_for_mapped_domains', 10, 3 );

    If it won't help, please, provide me with additional login credentials, I can look into it more.

    https://premium.wpmudev.org/contact/#i-have-a-different-question
    Please visit our private Contact page and complete the form with the following information:

    Subject: "Attn: Ivan Svyrskyi"

    In the Message box, please provide the following:

    - link back to this thread for reference
    - any other relevant urls

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP/SFTP credentials
    host
    username
    password
    (and port if required)

    Best regards,
    Ivan.

  • northgate
    • The Incredible Code Injector

    Hi ivan

    I've tried this, however if there is a mapped domain which has expired then this would result in stopping the entire renewal process for all other domains.

    Is there are way to check the domain to see if it's expired or skip/exude it so it does not disrupt the renewal process?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.