1

Is it possible to add to add the following code into a string such as below. I need to give the "Terms" a text-domain such as below.

<?php _e('Terms','footer-text'); ?>

Need to essentially do string interpolation with the php code where the "Terms" string is.

  echo '<div class="col-xs-6 col-md-2 col-md-push-8 social-buttons">
  <div class="row">

          <a class="pull-right" href="'. $instance['facebook'] .'" target="_blank">
            <span class="icon-facebook-icon"></span>
          </a>
          <!--<a class="pull-right" href="'. $instance['tripadvisor'] .'" target="_blank">
            <span class="icon-tripadvisor-icon"></span>
          </a>-->
          <a class="pull-right" href="'. $instance['twitter'] .'" target="_blank">
            <span class="icon-twitter-icon"></span>
          </a>

  </div>
  <div class="row pull-right terms-links">
    <ul>
      <li><a href="'. $instance['tac-url'] .'">Terms</a></li>
      <li><a href="'. $instance['priv-url'] .'">Privacy</a></li>
      <li><a href="'. $instance['sitemap-url'] .'">Sitemap</a></li>
    </ul>
  </div>
</div>';

}

Sorry PHP not my language. Working with translator plugin and need to give the word a text domain for it to find it. Thanks.

Bradley
  • 922
  • 2
  • 8
  • 24

1 Answers1

1

I think what you're looking for is a shortcode: https://codex.wordpress.org/Shortcode_API.

Within the shortcode you can do the translations with _e() if needed, or use conditional statements depending on the current language (use the ICL_LANGUAGE_CODE constant for that).

Sjors
  • 1,205
  • 1
  • 8
  • 24
  • So it's not as easy as just adding the code via some sort of interpolation? The Shortcode_API is a confusing read for somebody who does not know PHP. hmm – Bradley May 15 '19 at 12:18
  • Not that I'm aware of. I don't think WPML offers a way to change the _e method's output. What you're trying to do seems more complicated to me then using the shortcode API or a custom implementation.. :) – Sjors May 15 '19 at 12:28
  • I'll have another look Sjors. I'm literally translating a site somebody else had built. So i'll probably rework their code once I figure out why they've got the links pulling in that way. Thanks dude. – Bradley May 15 '19 at 15:41