Modifying sunrise.php for WPML compatibility

Hello !

The new DM & Multidomain plugin come with a new concept of Sunrise.php.

So the one in /wp-content/ just call the one in the DM plugin folder /inc/

Ok.

Now.

We absolutlely need to include int sunrise the modifications to work correctly with WPML in the REAL sunrise.php.

Ok

BUT. (yes, there is one :p )

- Modifying directly the sunrise.php file in the plugin directory is not really a good idea since modifications will go on updates.

- It is not possible to modify the sunrise.php in the /wp-content/directory, since the plugin automatically rewrite it to call the "real" sunrise.php

- it is not possible, consequently, to put the "original" sunrise.php directly in /wp-content/

So :

Would it be possible to :
- Or having the possibility to modify this file so we can put the real sunrise.php out of the plugin folder

- or, even better, directly integrate the /inc/tools/sunrise.php functions included with wpml so we can directly work with it (ie map a domain on a language in ONE particular site in a multisite install).

Cheers ! :slight_smile:

  • Aphrodite
    • The Reaper

    Thanks for your answer :slight_smile:

    But indeed it does not solve the issue.

    The problem is not hacking the original file, which can be done easily, but to hack the "false" one in /wp-content/ to redirect to another place for the original file. The plugin has changed since this thread :slight_smile:

  • Jose
    • Bruno Diaz

    Hi there @Aphrodite,

    At a first glance, I don't see any issue on changing the sunrise path on the include logic.

    Assuming that your modified sunrise file is called custom_sunrise.php and it is located under ../wp-content/, changing the sunrise.php proxy to the following code should work just fine:

    <?php
    $sunrises = array(
    	"dm_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/custom_sunrise.php" : dirname( __FILE__ ) .  "/custom_sunrise.php",
    	"md_sunrise" => defined( "WP_PLUGIN_DIR" ) ?  rtrim( WP_PLUGIN_DIR, '/\\' ) . "/custom_sunrise.php" : dirname( __FILE__ ) .  "/custom_sunrise.php"
    );
    
    foreach( $sunrises as $sunrise ){
      if( is_readable( $sunrise ) ){
    	include $sunrise;
      }
    }

    Anyway, as I didn't had the chance to through the code checking the implicanes of this change, and I didn't had the chance to test it neither, I'll call the lead dev @Sam to have his input.

    He will be able to answer also about integrating your customization into the live version of the plugin.

    Hope this helps in the meantime!

    Cheers,
    Jose

  • Jose
    • Bruno Diaz

    I see the problem now :slight_smile:

    In that case, you can either change the sunrise.php file permissions to read only, or modify the file version to a higher value by changing this:
    define( 'DOMAINMAPPING_SUNRISE_VERSION', '1.0.3.1' );

    into this:
    define( 'DOMAINMAPPING_SUNRISE_VERSION', '5.0' );

    Let me know if it works fine with this workaround.

    Cheers,
    Jose

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.