WordPress.org

Ready to get started?Download WordPress

Forums

Pass a php variable to a plugin (2 posts)

  1. elsnare
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    You can study this code using setlocale()

    http://pastebin.com/8VTjR7fx

Topic Closed

This topic has been closed to new replies.

About this Topic