• Resolved Ced

    (@cedriccharles)


    Hi there!

    First of all, thank you for this great plugin.

    I have a question related WPML compatibility. My website has 4 languages (EN – FR – DE – IT). Right now, the posts are duplicated with WPML in each language from the FR version. I have a blog post with a podcast episode linked to it. In my feed, I see only one item, which is good: https://lexing.ch/feed/podcast/
    But if I use the [powerpress_playlist] shortcode, I have 4 times the same podcast in the player: https://snag.gy/9upa3v.jpg. So it seems that the shortcode player returns the podcast in 4 languages, instead of one time for the good language.

    Thank you in advance,
    Cedric

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Shawn

    (@shawnogordo)

    What is the exact shortcode you’re using for the Playlist Player?

    Thread Starter Ced

    (@cedriccharles)

    Hi Shawn,

    Thank you for your answer. I’m using this shortcode:
    [powerpress_playlist image=”https://lexing.ch/wp-content/uploads/2019/07/lexing-ch-300×300.jpg”%5D

    Thank you,
    Cedric

    Plugin Author Angelo Mandato

    (@amandato)

    Hello Cedric,

    The Blubrry Playlist player queries based on the channel or category specified in the shortcode. We do not have any code that integrates with the fields that WPML adds to store multi-language. This is something we can add if we had some guidance from the WPML developers. Can you reach out to the WPML developers to contact me at cio [at] rawvoice.com ? Making this work with podcasting may be as simple as adding another condition to the SQL query and to include an additional tag name-value pair to the shortcode to specify the language.

    Thanks,
    Angelo

    Thread Starter Ced

    (@cedriccharles)

    Hi Angelo ??

    I asked WPML on their PRO support and here is what they (Bobby) told me:

    Hello,

    If possible please provide the following link the plugin’s developer as they will be able to get in direct access to our developers through our go global program here to help them make the plugin compatible with WPML.

    https://wpml.org/documentation/theme-compatibility/go-global-program/

    I hope you’ll be able to resolve this with them ?? !

    Thank you in advance

    Thread Starter Ced

    (@cedriccharles)

    Hi Angelo!

    WPML answered me on their support. The code provided by Bobby from WPML is working fine. Could you do something about it? Maybe integrate this code in your plugin?

    https://wpml.org/forums/topic/compatibility-issue-with-powerpress-podcasting-plugin/#post-4665255

    Thank you in advance,
    Cedric

    Hi,

    This is David from WPML compatibility team.

    I worked a bit further in the integration and came up with the following solution (based on Bobby’s code shared earlier).

    1) The “cleanest” way to integrate this is that you add a couple of filters in the playlist query, for example like this (in patch format):

    diff --git a/powerpress-playlist.php b/powerpress-playlist.php
    index b93c01b..24adc03 100644
    --- a/powerpress-playlist.php
    +++ b/powerpress-playlist.php
    @@ -129,12 +129,12 @@ function powerpress_playlist_episodes($args)
            // Start the SQL query
            $query = "SELECT p.ID, p.post_title, p.post_date, pm.meta_value ";
            $query .= "FROM {$wpdb->posts} AS p ";
    -       $query .= "INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id ";
    +       $query .= apply_filters( 'powerpress_join', "INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id " );
            
            if( !empty($TaxonomyObj->term_taxonomy_id) )
                    $query .= "INNER JOIN {$wpdb->term_relationships} AS tr ON p.ID = tr.object_id ";
            
    -       $query .= "WHERE (pm.meta_key = %s) ";
    +       $query .= apply_filters( 'powerpress_where', "WHERE (pm.meta_key = %s) " );
            $query .= "AND p.post_type = %s ";
            $query .= "AND p.post_status = 'publish' ";
            if( !empty($TaxonomyObj->term_taxonomy_id) ) {

    2) With these filters we can hook when WPML is active and adjust the query accordingly:

    if ( apply_filters( 'wpml_setting', false, 'setup_complete' ) ) {
            add_filter( 'powerpress_join', function( $join ) {
                    global $wpdb;
    
                    $join .= "JOIN {$wpdb->prefix}icl_translations ON element_type = CONCAT('post_', p.post_type) AND element_id = p.ID ";
    
                    return $join;
            } );
            add_filter( 'powerpress_where', function( $where ) {
                    $lang = apply_filters( 'wpml_current_language', false );
                    $where .= "AND language_code = '$lang' ";
    
                    return $where;
            } );
    }

    3) It would also be interesting to add a language configuration file so that WPML copies the ‘enclosure’ field to translations. Just drop a wpml-config.xml file in the root folder of your plugin with this in it:

    <wpml-config>
        <custom-fields>
            <custom-field action="copy">enclosure</custom-field>
        </custom-fields>
    </wpml-config>

    Lastly, if you would like to join our Go Global program, we can test both plugins to see if anything else needs adjusting:

    https://wpml.org/documentation/theme-compatibility/go-global-program/

    Best,
    David

    Plugin Author Angelo Mandato

    (@amandato)

    Hello David and Bobby,

    Thanks for your contribution! I’ve passed this onto our developer working on PowerPress to add to our next bugfix release. He will reply with a follow up to this thread when everything is added.

    Thanks!

    –angelo

    Plugin Author benbeecroft

    (@benbeecroft)

    Hi David and Cedric,

    I just added the above code to support the WPML plugin in PowerPress. This is a part of a hotfix release that we will set loose later today. Thank you for your patience and for your help!

    Ben

    Thread Starter Ced

    (@cedriccharles)

    Hi Ben ??

    Thank you for your quick fix ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WPML compatibility’ is closed to new replies.