WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
Polylang and Membership plugin (6 posts)

  1. miguelcortereal
    Member
    Posted 10 months ago #

    How do I get a text defined at Membership plugin's settings to translate when that text isn't stored at DB wp_options table but in one different ?

    $wpdb->query($sql);
    
    	$sql = "CREATE TABLE IF NOT EXISTS <code>" . membership_db_prefix($wpdb, 'subscriptions') . "</code> (
    	  <code>id</code> bigint(20) NOT NULL auto_increment,
    	  <code>sub_name</code> varchar(200) default NULL,
    	  <code>sub_active</code> int(11) default '0',
    	  <code>sub_public</code> int(11) default '0',
    	  <code>sub_count</code> bigint(20) default '0',
    	  <code>sub_description</code> text,
    	  <code>sub_pricetext</code> varchar(200) DEFAULT NULL,
    	  PRIMARY KEY  (<code>id</code>)
    	);";

    I'm looking to have 'sub_description' and 'sub_pricetext' translating.

    I'm assuming that with <admin-texts> won't work because it only filters what goes to wp_options table.

    P.S. Above replace code and /code by backticks.

    http://wordpress.org/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 10 months ago #

    I am not sure to understand what you want to translate. You cannot translate DB columns titles.

    You are right wpml-congig.xml file does translate only what is stored in options. However you can use the Polylang API to translate anything else using pll_register_string to make a string appear in the strings translations table and pll__ to translate it on frontend.

  3. miguelcortereal
    Member
    Posted 10 months ago #

    That's exactly what I did, used pll_register_string and then pll_e($string) on plugin's template and it got working.

    I'm not happy yet, my solution hacks plugin's core files but I'll figure out a way to handle it later, so marking the topic as resolved.

  4. miguelcortereal
    Member
    Posted 10 months ago #

    That's right Chouby, I don't really want to translate those DB columns titles, but the content of each row for 'sub_description' and 'sub_pricetext' columns.

    Replacing at plugin's templates files $subscription->sub_description() and $subscription->sub_pricetext() by pll_e('registered string text') was ok while my site had only one row on that DB table. Now it has two and maybe will have a third one.

    Those original templates code, call each DB row content with a foreach and $subscription variable point to the right row position at DB table.

    The content of this table is collected at backend plugins's options, being sub_description associated to a text editor field and sub_pricetext associated to a text field.

    Now the question is:

    Is it possible to represent pll_e('registered string text') with a shortcode and use it to fill those fields at backend?

    I'm convinced that it could even be a feature for you to consider to add to Polylang, if by technical scope it makes sense.

  5. Chouby
    Member
    Plugin Author

    Posted 10 months ago #

    I am not sure to follow you. Shortcodes must be parsed. And by default, WordPress parses shortcodes only in post content. So unless your plugin does parse shortcodes for these two strings, they won't help you.

    Maybe you can ask the author to add filters, the same way there are for get_option. Thus you would be able to use them.

    EDIT: just noticed that. Maybe

    pll_e($subscription->sub_description());

    would be better to be able to output several rows

  6. miguelcortereal
    Member
    Posted 10 months ago #

    You're right, WP doesn't parse shortcodes within fields.

    I ended up using shortcodes within those fields and only could make them trigger by using at the code:

    do_shortcode($subscription->sub_description());

    This does exactly the same as what you just suggested does.

    Your suggestion is more simple.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.