anttiviljami / wp-pdf-templates

Add PDF templates to your WordPress theme
https://wordpress.org/plugins/wp-pdf-templates
GNU General Public License v3.0
42 stars 18 forks source link

WPML integration #33

Open thrasherstudios77 opened 6 years ago

thrasherstudios77 commented 6 years ago

This is not an issue but looking for some advice. I am using WPML translation plugin for my pages and I am having a difficult time generating the PDF for different languages.

I am looking for the best way to modify the plugin using a filter, if possible, without modifying the default code. But, if that is the only way that's fine too.

I am using a customized template added to my child theme's root folder index-pdf.php. The custom template works perfectly for displaying all my CPT information. Only problem is with getting the correct language.

So, if the URL for a translated page is something like this: https://example.com/mypage/?lang=fr // french translation

currently my custom link in my button to the PDF generator looks like this (doesn't work though obviously): https://example.com/mypage/pdf/?lang=fr

I am unable to $_GET the current language from my custom template, index-pdf.php. The only url param that exists at this point is the "pdf-template". Also, when referencing the current $post and ID, it thinks it's the default language's, "English in this case", not the current language French.

What can be done to get in front of the query var 'pdf' to add some information about the current language of the page, possibly add the language before /pdf/: `https://example.com/mypage/fr/pdf/

Any help is appreciated if I can't figure this out I will need to manually create 100's of PDF's in different languages so hoping there is way.