Domain Mapping 4.3.0.2 with WPML

Hi there, hope everyone is doing well

Like other people here, I had issues with the new domain mapping, and reverted to 4.2.0.6 as it's a live site, with customers.

While reverting back, I also had to reupload the "old" sunrise.php in wp-content

I had added code to sunrise.php to make it work with WPML and now I see WPML has it included in the plugin's subfolders.

So I tried this with 4.3.0.2
I tried to add below those lines :

"dm_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/domain-mapping/inc/sunrise.php",
"md_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/multi-domains/inc/sunrise.php"

adding a comma at the end of the last line, and add this :

"wpml_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/sitepress-multilingual-cms/inc/tools/sunrise.php" : dirname( __FILE__ ) .  "/sitepress-multilingual-cms/inc/tools/sunrise.php"

(inspired by your code above)

but it doesn't work, same issues !

so, in short, on the same install:
- domain mapping for sites WITHOUT WPML : everything is ok with 4.3.0.2
- domain mapping for sites WITH WPML : the menus, images, every url, take the mainsite.net instead of the mapped domain.

Ideally, I would like to see a conditional code into sunrise.php to test if WPML is there, then add the WPML sunrise :
/wp-content/plugins/sitepress-multilingual-cms/inc/tools/sunrise.php

Thank you in advance to help me (us) make it work with the latest version.

Regards
Patricia

    Patricia BT

    yes, but under the condition that the WPML sunrise was added to your sunrise. It was actually a home-made sunrise I did last year with WPMU Domain mapping + Multi-domain sunrises, + the one from WPML which is found under /wp-content/plugins/sitepress-multilingual-cms/inc/tools/sunrise.php
    I have customers with a domain mapped and WPML. you can see this here
    main site : virtuaza.net (+ a multi-domain added to main = lessites.ch)
    my customer using WPML : pjmartin.ch (mapped to paula.lessites.ch)

    I attach here
    - the WPML sunrise as found in their plugin
    - and the "home made" sunrise (a mix of the 3) as well (old_sunrise_with_WPML.php.txt)

    I added .txt to both to allow upload here, and obviously, once under wp-content, their name is sunrise.php

    Thx a LOT
    Patricia

    Patricia BT

    Oops, I see the upload of my files faild, even renamed with txt, so please find them there :

    the one I have under wp-content, working with version 4.2.0.6
    http://virtuaza.net/wp-content/uploads/temp/old_sunrise_with_WPML.php.txt

    the WPML "only" sunrise, found in their plugin /sitepress-multilingual-cms/inc/tools/
    http://virtuaza.net/wp-content/uploads/temp/sunrise_wpml_new.php.txt

    the WPML code has a small difference between old and new

    Thx

    Patricia BT

    Hi,

    Writing to see if you have some news or just to be sure you passed the info to the dev, in order to maybe add that to the next version (or document how to add support for WPML). I know there are tons of support questions about Domain Mapping at the time writing that, and that's precisely why it's a good time be sure everything is included for the next release

    Thx a lot

    Patricia BT

    still open question, and still the same with 4.3.0.4.
    I understand that you may not be able to add WPML code for everyone, but at least to help me include it (as it was possible with 4.2.0.6).
    Thanks @Patrick and sorry to bump again, it's because I'm not sure you saw the latest replies and if you can confirm to me you sent all that to the dev, it would be great.

    Talk soon

    Vinod Dalvi

    Hi Patricia,

    Thank you for your patience here.

    Ideally, I would like to see a conditional code into sunrise.php to test if WPML is there, then add the WPML sunrise :
    /wp-content/plugins/sitepress-multilingual-cms/inc/tools/sunrise.php

    I am new here so i read this whole thread and found you want to to achieve as above to resolve this issue.

    If it is then you can try using the following code into sunrise.php to test if WPML is there and load the WPML sunrise file.

    if ( function_exists('icl_object_id') ) {
         //add the WPML sunrise here
    }

    Regards,
    Vinod Dalvi

    Patricia BT

    Hi Vinod and thank you for your reply..

    yeah the test if WPML is there was a suggestion for you dev if you want to insert it for all of your customers (as stated as WPML compatible).
    but anyway first I need to understand how to insert the WPML sunrise, as I tried to add in sunrise.php :
    "wpml_sunrise" => defined( "WP_PLUGIN_DIR" ) ? rtrim( WP_PLUGIN_DIR, '/\\' ) . "/sitepress-multilingual-cms/inc/tools/sunrise.php" : dirname( __FILE__ ) . "/sitepress-multilingual-cms/inc/tools/sunrise.php"
    Actually, I'm back to the 1st post...
    - domain mapping for sites WITHOUT WPML : everything is ok with 4.3.0.4
    - domain mapping for sites WITH WPML : the menus, images, every url, take the mainsite.net instead of the mapped domain.
    Hence I reverted back to 4.2.0.6 as it's a live site.

    Thx in advance

    Patricia BT

    Hi again @Vinod Dalvi

    Can you help me integrates WPML sunrise in your sunrise as stated just above?

    btw the site where it doesn't work with WPML is a site where domain mapping AND multi-domain are used. On another site with only domain mapping and WPML (no multi-domain), it seems ok. (in case that helps you...)

    Thx (I would like to update asap, I'm nervous when I must leave older versions )

    Vinod Dalvi

    Hi Patricia,

    You can specify the path to your custom sunrise in wp-config.php file by defining DM_CUSTOM_SUNRISE

    You can see in sunrise.php it’s doing:

    $sunrises = array(
        "dm_sunrise" => defined("DM_CUSTOM_SUNRISE") ? DM_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/domain-mapping/inc/sunrise.php" ),
        "md_sunrise" => defined("MD_CUSTOM_SUNRISE") ? MD_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/multi-domains/inc/sunrise.php" )
    );
    
    foreach( $sunrises as $sunrise ){
        if( is_readable( $sunrise ) ){
            include $sunrise;
        }
    }

    So if DM_CUSTOM_SUNRISE is defined, it’ll load the custom sunrise instead of the one shipped with Domain Mapping plugin.

    Regards,
    Vinod Dalvi

    Patricia BT

    Hello @Vinod Dalvi and @Sam

    Sorry for the delay but I don't understand your last reply. Sam you say "What i think of is to make a new file, have a mix of the sunrises you want to have in it and then define DM_CUSTOM_SUNRISE in wp-config.php to point to this new file and you should be good to go."

    but this is actually what I ask in the first question, and it doesn't work. Can you help me integrate it all.
    in 1st post I say :
    ---copy---
    Like other people here, I had issues with the new domain mapping, and reverted to 4.2.0.6 as it's a live site, with customers.

    While reverting back, I also had to reupload the "old" sunrise.php in wp-content

    I had added code to sunrise.php to make it work with WPML and now I see WPML has it included in the plugin's subfolders.

    So I tried this with 4.3.0.2
    I tried to add below those lines :

    "dm_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/domain-mapping/inc/sunrise.php",
    "md_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/multi-domains/inc/sunrise.php"

    adding a comma at the end of the last line, and add this :

    "wpml_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/sitepress-multilingual-cms/inc/tools/sunrise.php" : dirname( __FILE__ ) .  "/sitepress-multilingual-cms/inc/tools/sunrise.php"

    (inspired by your code above)

    but it doesn't work, same issues !

    so, in short, on the same install:
    - domain mapping for sites WITHOUT WPML : everything is ok with 4.3.0.2
    - domain mapping for sites WITH WPML : the menus, images, every url, take the mainsite.net instead of the mapped domain.

    ---end copy ---
    I tried with 4.3.0.4, it's the same as with 4.3.0.2, so my install is still on 4.2.0.6

    Did I just missed something, or wrong syntax, on the define line?

    Thanks a lot
    Patricia

    Ash

    Hello @Patricia

    I hope you are well today.

    Please follow the following as Sam explained:
    1. Create a file customsunrise.php and same it anywhere in your server, maybe inside of wp-content folder.
    2. Then go to domain-mapping/inc/sunrise.php and copies the content to customsunrise.php
    3. Then go to sitepress-multilingual-cms/inc/tools/sunrise.php, copy and paste the content to the end of customsunrise.php
    4. The add the following in wp-config.php:

    define("DM_CUSTOM_SUNRISE",  "path to the customsunrise.php")

    Please let us know if that works.

    Cheers
    Ash

    Patricia BT

    Hi there,

    I'm sorry to insist, but if as you say I see 2 problems:
    - it will be including code for domain mapping and WPML, but not multi-domain
    - if the sunrise code change in one of the 3 plugins, I will have to redo the custom file

    I found that it was clever from you to make a sunrise file that define the path to those of domain mapping and multi domain (then if one of those files change at a release, nothing to do manually), and I just want to add the same to include the one from WPML

    where is my error in the above code to just add a 3rd define line to your 2 lines ?

    Thx

    Vinod Dalvi

    Hi @Patricia,

    - it will be including code for domain mapping and WPML, but not multi-domain

    The Domain mapping sunrise.php file also loads the sunrise.php file of Multi domains plugin using the following code.

    $sunrises = array(
    	"dm_sunrise" => defined("DM_CUSTOM_SUNRISE") ? DM_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/domain-mapping/inc/sunrise.php" ),
    	"md_sunrise" => defined("MD_CUSTOM_SUNRISE") ? MD_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/multi-domains/inc/sunrise.php" )
    );

    - if the sunrise code change in one of the 3 plugins, I will have to redo the custom file

    You don't have to do this if you use the code from sunrise.php files added in the root directory of these plugins. The sunrise.php files added in the root directory of these plugins contains the code like following which loads the actual sunrise.php files from the plugin directory like "/plugins/multi-domains/inc/sunrise.php" and "/plugins/domain-mapping/inc/sunrise.php" .

    <?php
    $sunrises = array(
    	"dm_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : __DIR__ .  "/plugins/domain-mapping/inc/sunrise.php",
    	"md_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : __DIR__ .  "/plugins/multi-domains/inc/sunrise.php"
    );
    
    foreach( $sunrises as $sunrise ){
      if( is_readable( $sunrise ) ){
    	include $sunrise;
      }
    }

    Regards,
    Vinod Dalvi

    Patricia BT

    Hi Vinod

    Ok, so we are on the same way, yes indeed I want to use that sunrise that load for both plugins: domain mapping and multi site, AND ADD for WPML to that same sunrise

    hence my initial question where I ask you how to do that :
    ----
    I tried to add below those lines :

    "dm_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/domain-mapping/inc/sunrise.php",
    "md_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) .  "/plugins/multi-domains/inc/sunrise.php"

    adding a comma at the end of the last line, and add this :

    "wpml_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/sitepress-multilingual-cms/inc/tools/sunrise.php" : dirname( __FILE__ ) .  "/sitepress-multilingual-cms/inc/tools/sunrise.php"

    (inspired by your code above)

    but it doesn't work
    ---
    Can you help me to integrate WPML path to their sunrise, then it will be added into that sunrise which includes already domain mapping and multi domain? so I have that sunrise.php which will call all 3 different sunrises.

    I think we go in circles here (no problem though, it can be my fault, if I'm not clear enough) or maybe there is something I do not understand in your replies...

    Thx and cheers

    Vinod Dalvi

    Hi @Patricia,

    Would you mind if I access your site using FTP and did some testing? This might help get to the bottom of this faster. If this is ok, just send log in info through our secured contact form: https://premium.wpmudev.org/contact/
    - Choose "I have a different question"
    - Include my name in the subject "Vinod Dalvi"
    - Include the URL of this post in your message so that I may track this issue better
    - Include login information (Wordpress admin info username + password )
    - Include FTP Details

    Regards,
    Vinod Dalvi

    Patricia BT

    Hi @Vinod Dalvi

    I hope you are doing well.

    We will forget this test for 2 reasons.

    1. I have not enough unused domain names to create a test install with main domain, multi-domain and customer mapped domain, so it was a bad idea when I told you we'll do that with a test install

    2. I tried the Domain Mapping beta version in Sam's thread announcing the beta release, and it looks that what was not working = what I wrote above, (or at least the WPML sunrise insertion into DM+MD sunrise) is now OK with the beta.

    if you want to read my reply there :
    https://premium.wpmudev.org/forums/topic/domain-mapping-beta-huge-update-sso-async-rewritten?replies=50#post-870549

    I guess we can close this now, and if a new issue is discovered I'll open a new one.
    I thank you very much as you bore with me over the past weeks!!

    Have a great day
    Patricia BT