Pass a php variable to a plugin (2 posts)

  1. elsnare
    Posted 2 years ago #

    I have a website with a plugin that generates PDF files out of post content and qTranslate installed for handling multi-language content.

    The problem:
    The PDF plugin unfortunately does not recognize the languages correctly resulting in wrong content being put into the final file. I fixed the issue but the solution requires to pass a current language code to the plugin so it gets the right post content lang version.

    The code:

    if(qtrans_getLanguage()=='en') {
          $code= "en";
        } elseif(qtrans_getLanguage()=='de') {
          $code= "de";

    The code above is used to pass the variable with the current lang code. It works in theme files, does not pasted directly to the plugin or functions.php. (I'm probably doing sth wrong here but I'm def. not a pro at php coding :)

    Other info:

    • Adding the variable $code ='en'; manually in functions.php and calling it in the plugin via global $code; gets the job done nicely.

    Thanks in advance

  2. David Choi
    Posted 2 years ago #

    You can study this code using setlocale()


Topic Closed

This topic has been closed to new replies.

About this Topic