• I am just starting to work through Polylang to add automatic compatibility with some of my plugins. I thought it would be easy enough but I guess I am missing something. I have a filter that I have confirmed is running when the settings page is saved. All data is there, and at the end of the function is the following line:

    pll_register_string( ‘Option Label’, $label, ‘betrs_labels’, false );
    (Where $label is populated with a single line string entered by the user)

    When I visit the page Languages > Strings translations in my dashboard, I have no new additions. Could you help me understand what I have done wrong? Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chouby

    (@chouby)

    Hi,

    pll_register_string() does not register your string persistantly. Think to all register_ functions in WP that must be called at every page load.

    pll_register_string() is in fact useful only in the strings translations table page. Everywhere else, it does nothing.

    So you should not register the string only in your options page but allow to register it outside your options page.

    You can also have a look a the wpml-config.xml file which allows to register and filter options for both Polylang and WPML.

    Thread Starter Bolder Elements

    (@hystericallyme)

    Is there something else I can do? I see you have a WPML compatibility mode. Can I register strings using those functions? I already have a compatibility for WPML. I thought it would be a simple copy/paste and change a couple functions. I’m not really sure how an XML file is going to help. I have fields in my shipping settings that are custom entered by users so it could literally be anything and have a variety of save names depending on how many methods and rows there are in each method. I just want to register this text when my settings save the same way I would with WPML ??

    Plugin Author Chouby

    (@chouby)

    You can use a lot of the WPML API. I suggest that you use the new API with filters and actions rather than the legacy API with functions. See https://github.com/polylang/polylang/blob/master/modules/wpml/wpml-api.php#L20-L63

    If you register strings the WPML way with the action wpml_register_single_string then it will be persistently registered as in WPML and unlike strings registerd with pll_register_string

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with plugin compatibility’ is closed to new replies.