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