Denis ?oljom
Forum Replies Created
-
Forum: Plugins
In reply to: [Gravity Forms Sticky List] Distinguishing new entries?That would be cool. And adding a read class on the entry so that it can be easily styled ??
Yes, and I created a plugin for it xD https://www.ads-software.com/plugins/simple-linked-variations-for-woocommerce/
Forum: Plugins
In reply to: [Loco Translate] Direct bank transfer not translatedOk, my bad. I now realized that this is controlled from the backend.
Forum: Plugins
In reply to: [WC Fields Factory] Notice: id was called incorrectlyThanks for the answer.
Forum: Plugins
In reply to: [WC Fields Factory] Value in the custom field not shown in the orderFor me, the issue was resolved after some time by itself. Maybe it was due to cache or something like that.
Forum: Developing with WordPress
In reply to: Setting up development environment on WordPressI’m looking at more general solution. I cannot dictate what hosting the client is going to have ??
Forum: Developing with WordPress
In reply to: Add theme page without menu link?I guess it’s not possible since
add_theme_page()
uses the parent asthemes.php
always…Forum: Developing with WordPress
In reply to: Change locale inside ajax callGot it to work from your advice on the facebook group. Before initializing the plugin I added
if ( isset( $_POST['language'] ) ) { // Input var okay. add_filter( 'locale', 'mbd_set_my_locale' ); /** * Set locale based on the $_POST choice. * * @param string $locale Locale code. * @return string Selected locale code. */ function mbd_set_my_locale( $locale ) { $language = sanitize_text_field( wp_unslash( $_POST['language'] ) ); // Input var okay. if ( 'hr' === $language ) { $locale = 'hr'; } else { $locale = 'en'; } return $locale; } } // Now init the plugin. $init = new CreateInvoicePluginInit();
Thanks!
Forum: Developing with WordPress
In reply to: Change locale inside ajax callTried that, but didn’t work. The conditional set is not the problem. The problem is getting the pdf to be translated ??
I commented my
$this->set_locale();
method where I load plugin textdomain, and then added both codes to my ajax callback, but I guess this is too late to influence the locale at this point :\Forum: Developing with WordPress
In reply to: Change locale inside ajax callYeah, the problem with this is that I am calling my
load_plugin_textdomain()
function inside a function that is hooked on theplugins_loaded
hook, which is one of the earliest hook to call.So putting
function load_my_locale( $locale, $domain ) { $locale = 'hr'; return $locale; } add_filter( 'plugin_locale', 'load_my_locale', 10, 2 );
Inside my ajax callback isn’t doing anything :\
- This reply was modified 7 years, 8 months ago by Denis ?oljom.
Forum: Developing with WordPress
In reply to: Change locale inside ajax callHmmm not sure I understood you. The only filter I found that worked was
function mbd_change_locale() { return 'hr'; } add_filter( 'locale', 'mbd_change_locale', 10 );
Now I have a dropdown that has languages next to the download pdf button. When you select the language, the
data-language
property on the button changes. On the click of that button I can pick that property up, and pass it to my AJAX.In my AJAX callback function I can get all the things I need –
post_id
andlanguage
through the$_POST
array.With that I can have a simple
if
, orswitch
condition inside it that can check the$_POST[language]
and according to it change the locale (set it up in a variable$locale
for instance).The problem is that I don’t know how to use the filter without it impacting the entire backend of the site. All I need to do is to use it so that I can use the translatable strings in my
.mo
files when creating the pdf.You can check the github link for the entire code if that helps ??
Forum: Developing with WordPress
In reply to: Change locale inside ajax callAlso the pdf creating is happening inside ajax callback, so I’m not sure I can set the filter in there…
Forum: Everything else WordPress
In reply to: Recieving props on track doesn’t show badge@sergeybiryukov Thanks for clearing it up. Major release is like 4.6, 4.7, 4.8, right?
I guess I’ll have to wait for them a while xD
Thanks for clearing it up ??
Forum: Everything else WordPress
In reply to: Recieving props on track doesn’t show badgeI asked before about the meta badge, but the response I got was that it’s going to take a little while to show up. And that was on February 10th.
That’s a bit more than a little while…
Forum: Developing with WordPress
In reply to: Change locale inside ajax callYeah, but I only got it to work outside of the main class. So I must be missing something…