Support » Plugin: Multiple Domain » Linking to original domain

  • Resolved growe

    (@growe)


    I have essentially the same issue as mentioned here. It states there that there is no support for linking back to the original domain when in a post or page. I am just wondering if any support has since been added.

    If not, how hard would it be to code something like having a class indicate that no translation should occur…
    Example: <a href="OriginalDomain.com">OriginalDomain.com</a>

    • This topic was modified 5 months ago by growe.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • growe

    (@growe)

    I found a solution… not real pretty but it works…

    The original code at starting at line 552 looks like this…

        public function fixContentUrls($content)
        {
            foreach (array_keys($this->domains) as $domain) {
                $content = $this->replaceDomain($domain, $content);
            }
            return $content;
        }
    

    I added one additional line at 557 so it now looks like this…

        public function fixContentUrls($content)
        {
            foreach (array_keys($this->domains) as $domain) {
                $content = $this->replaceDomain($domain, $content);
            }
            $content=str_replace("md_nofix_","",$content);
            return $content;
        }
    

    Now we simply need to add md_nofix_ to the beginning of the url and the magic will happen. Example: <a href="https://md_nofix_mydomain.com">mydomain.com</a>

    The only side effect is that you will never be able to add “md_nofix_” in your content as it will get stripped away but I don’t think that will every be an issue.

    Plugin Author Gustavo Straube

    (@gustavostraube)

    Hello,

    I’m glad you find a solution yourself. In any way, I created an issue on Github to maybe add that as a feature in the future. You can track it here: https://github.com/straube/multiple-domain/issues/69

    QuietNoise

    (@quietnoise)

    Hi @growe,

    I’m onto this issue as well.

    As a rule of thumb you should avoid changing plugin’s code directly as it is not sustainable. Your change will be removed once you update the plugin.

    fixContentUrls is a filter function for the_content called with priority 20. So you can apply your workaround by just adding your own content filter with priority > 20. This will make it run after fixContentUrls().

    For example in your functions.php just add:

    add_filter( 'the_content', function ( $content ) {    
        return str_replace("md_nofix_","",$content);
    }, 21 );

    I will drop some suggestions to your github too @gustavostraube.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.