Viewing 15 replies - 1 through 15 (of 20 total)
  • This can be worked around, but the workaround is on the much-work side.

    First, you need to add Polylang translations to the actual Media Library entries you want to be able to display in a Foo Gallery in other languages than default. Don’t bother doing it with the bare-bones Media Library; you wil lose hours. Instead install the excellent and free Media Library Assistant plugin (no affiliation, I’m just a happy user), and it will provide an alternative media listing with a Translate bulk action. Heed the warning not to upload new media through MLA when Polylang is in All Languages mode!

    Once you are done translating media, then for each collection of images you want to display as a Foo Gallery you must create a separate Foo Gallery instance for each relevant language. Then to each gallery you add attachments in the correct language. The last step is to use the right gallery on the right translation of the page.

    For example if you want to make a gallery of early 20th century poscards from Zache?mie, Poland (then Saalberg, Germany), and you want to show it both on the English page and on the German page, then you need to add German translations to all the postcards attachments. Then you create a Foo gallery titled “Zache?mie in Old Postcards”, populate it with English attachments and insert it on the English page, and then you must also create a Foo gallery titled “Saalberg am alten Ansichtskarten”, populate it with the corresponding German attachments and insert it on the German page.

    Phew!

    hey Rulatir, thanks for the workaround.
    I was hoping there was a smarter and quicker way to make FooGallery galleries and albums work with PolyLang…

    hey guys, what needs to change in the FooGallery code for it to work better with Polylang? Any help or assistance will be great, as the suggested work-around seems like waaaaay too much work

    @chouby, can you please assist. From looking at the above workaround, what do I need to change in FooGallery to make our plugins work better together?

    Plugin Support Chrystl

    (@chrystl)

    You can use the code below in a custom plugin to enable multilingual capabalities for the galleries.

    add_filter('pll_get_post_types', 'add_cpt_to_pll', 10, 2);
    function add_cpt_to_pll($post_types, $settings) {
    
      // add Foogallery post types in Polylang settings as 'public' is set to false
    
        if ($settings)
            $post_types['foogallery'] = 'foogallery';
        return $post_types;
    }
    
    // add polylang metabox 'ml_box' because Foogallery block it by default
    
    add_filter('foogallery_metabox_sanity_foogallery', 'add_pll_metaboxes');
    function add_pll_metaboxes ($metabox_ids) {
    	$metabox_ids[] = 'ml_box';
    	return $metabox_ids;
    }
    
    add_filter('pll_copy_post_metas', 'function_unset', 10, 2);
    function function_unset($metas, $sync) {
    
    /*unset the copy and synchronization of the gallery items because the custom fields attachments are publics.
     * And Polylang copies by default the public custom fields.
    A better solution will be to rewritte a copy function to get the translation*/
    
    	$key = array_search('foogallery_attachments', $metas);
    		unset($metas[$key]);
    
    	return $metas;
    
    }

    Hi@Chrystl
    Where I have to copy the above code when I open FooGallery/Edit to make the plugin work together with the activated Polylang plugin?
    My site https://k-i-n-g.ch/pinarello-special-1975 with a [foogallery id=”1724″]
    Thanks.

    Plugin Support Chrystl

    (@chrystl)

    Hi
    In a custom plugin.

    Hi@bradvin
    I’have no idea how to write a custom plugin. Can you take care and make the code supported by Chrystl work for the FooGallery?
    Thanks.

    Plugin Support Chrystl

    (@chrystl)

    @kickintonextgear

    In your text editor create a new file. Then paste the code below in your file. Save as foo_poly.php. Then put this file in your wp-content/plugins folder.
    Then activate it thanks to your wp admin.

    <?php
    /*
    Plugin name: Compatibility Foogallery Polylang 
    
    */
    
    add_filter('pll_get_post_types', 'add_cpt_to_pll', 10, 2);
    function add_cpt_to_pll($post_types, $settings) {
      // add Foogallery post types in Polylang settings as 'public' is set to false
        if ($settings)
            $post_types['foogallery'] = 'foogallery';
        return $post_types;
    }
    
    // add polylang metabox 'ml_box' because Foogallery block it by default
    add_filter('foogallery_metabox_sanity_foogallery', 'add_pll_metaboxes');
    function add_pll_metaboxes ($metabox_ids) {
    	$metabox_ids[] = 'ml_box';
    	return $metabox_ids;
    }
    
    add_filter('pll_copy_post_metas', 'function_unset', 10, 2);
    function function_unset($metas, $sync) {
    /*unset the copy and synchronization of the gallery items because the custom fields attachments are publics.
     * And Polylang copies by default the public custom fields.
    A better solution will be to rewritte a copy function to get the translation*/
    	$key = array_search('foogallery_attachments', $metas);
    		unset($metas[$key]);
    
    	return $metas;
    
    }

    @chrystl
    Thank you very much for your support. I copied the code and named the plugin as you suggested. I put the plugin in the right folder and have have activated it. Unfortunately the pages with FooGallery content are still blank.
    https://k-i-n-g.ch/pinarello-special-1975
    What went wrong?
    Thanks.

    Plugin Support Chrystl

    (@chrystl)

    It works for me.
    Did you test it by creating new pages?

    @kickintonextgear looks like you got it working?

    @chrystl thanks for your code. I am going to add this to the FooGallery plugin

    @chrystl – in your code comments, you mention:

    “A better solution will be to rewritte a copy function to get the translation”

    How can I go about doing that? Or can you point me in the right direction please

    @bradvin
    under polylang/settings/settings I have deactivated the box Media, Activate languages and translations for media. I had to reinstall a plugin backup to go back to the FooGallery Version 1.2.4 and deactivate a custom plugin containing the code from Chrystl because I had a conflict with displaying the correct footer hight.
    Now so far it works fine for me.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Polylang conflict with Foo Gallery’ is closed to new replies.