Make the theme wmpl ready wpml-config

I am using trega theme. As theme parameters, you can set and change the texts that will be displayed on the site (for example, texts for "copyright text" and "logo URL"). How can I make this multilingual language with WPML? I want to do this using the wpml-config.xml file

example code in functions.options.php

        $of_options[] = array(  "name"      => "Header",
                                "type"      => "heading"
        );

        $of_options[] = array(  "name"      => "Logo",
                                "desc"      => "Upload logo here.",
                                "id"        => "site_logo",
                                "std"       => get_template_directory_uri().'/images/logo.png',
                                "type"      => "media"
        );

        $of_options[] = array(  "name"      => "Logo (only Gallery Template)",
                                "desc"      => "Upload logo here.",
                                "id"        => "site_logo2",
                                "std"       => get_template_directory_uri().'/images/logo.png',
                                "type"      => "media"
        );

      

and this is my attempt at wpml-config.xml (but doesn't work)

    <wpml-config>

        <admin-texts>
            <key name="of_options">
                <key name="site_logo" />
                <key name="site_logo2" />
                <key name="copyright">
                </key>

        </admin-texts>
    </wpml-config>

      

any help?

+3


source to share


2 answers


thanx @kkarpieszuk I solved it by searching my sql about site_logo and I found it in WP options in option_name file. I found the key from which the store data is stored in it.

enter image description here and the right wpml-config.xml:



<wpml-config>
<admin-texts>
            <key name="theme_mods_trego">
            <key name="site_logo" />
            <key name="site_logo2" /> 
        </key>
    </key>

</admin-texts>
</wpml-config>

      

it works like a charm

+1


source


here Konrad from WPML dev / comp command :)

First, you need the strings to be internationalized ready. So don't use "Logo"

but__("Logo", "yourthemedomain");

Then ... well, it depends on how you store your options. Is it executed $of_options

directly on update_option('of_options', $of_options);

? If so, you are quite ready. If not, rewrite it like this.



Oh, I see that yours $of_options

is actually three arrays. So the xml shoul looks like this:

<wpml-config>

    <admin-texts>
        <key name="of_options">
            <key name="1">
             <key name="id" />
            </key>
        </key>

    </admin-texts>
</wpml-config>

      

So use indices of internal arrays (in this case name = 1) and don't use values ​​(file_name) but their indices (file_name has array index id

)

+3


source







All Articles