Hi there,
i have a customer-website running with WPML, Woocommerce and Themeco’s “Pro” Theme. For custom product-grids i use the plugin “The Grid” which is involved in Themeco’s Plugin bundle. It is marked as “WPML-compatible” but unfortunately the mix of WPML and The Grid is slowing down my site heavily because of the following string:
SELECT sawp_posts.*
FROM sawp_posts
LEFT JOIN sawp_postmeta
ON ( sawp_posts.ID = sawp_postmeta.post_id )
LEFT JOIN sawp_postmeta AS mt1
ON (sawp_posts.ID = mt1.post_id
AND mt1.meta_key = 'the_grid_language' ) JOIN sawp_icl_translations t
ON sawp_posts.ID = t.element_id
AND t.element_type = CONCAT('post_', sawp_posts.post_type)
WHERE 1=1
AND ( ( ( sawp_postmeta.meta_key = 'the_grid_language'
AND sawp_postmeta.meta_value LIKE '%de%' )
OR mt1.post_id IS NULL ) )
AND sawp_posts.post_type = 'the_grid'
AND ((sawp_posts.post_status <> 'trash'
AND sawp_posts.post_status <> 'auto-draft'
AND sawp_posts.post_status <> 'tco-data'))
AND ( ( ( t.language_code = 'de'
OR 0 )
AND sawp_posts.post_type IN ('post','page','attachment','custom_css','customize_changeset','oembed_cache','cs_header','cs_footer','cs_user_templates','global-blocks','invoice','product','product_variation','shop_order_refund','wpcf7_contact_form','the_grid','wpsl_stores','mc4wp-form','x-portfolio' ) )
OR sawp_posts.post_type NOT IN ('post','page','attachment','custom_css','customize_changeset','oembed_cache','cs_header','cs_footer','cs_user_templates','global-blocks','invoice','product','product_variation','shop_order_refund','wpcf7_contact_form','the_grid','wpsl_stores','mc4wp-form','x-portfolio' ) )
GROUP BY sawp_posts.ID
ORDER BY sawp_posts.post_modified DESC
–> This Query is loaded THREE times and takes 1,5 seconds each (although using w3tc).
I found the regarding code inside “wpml.class.php” inside the “The Grid” Plugin folder:
public static function WPML_meta_query() {
$WPML_meta_query = null;
if(self::WPML_exists()) {
$WPML_current_lang = self::WPML_current_lang();
$WPML_default_lang = self::WPML_default_lang();
$WPML_current_lang = ($WPML_current_lang == 'all') ? '' : $WPML_current_lang;
$WPML_not_exist = array(
'key' => 'the_grid_language',
'value' => '',
'compare' => 'NOT EXISTS'
);
$WPML_not_exist = (($WPML_current_lang == $WPML_default_lang) || empty($WPML_current_lang)) ? $WPML_not_exist : null;
$WPML_meta_query = array (
'relation' => 'OR',
array(
'key' => 'the_grid_language',
'value' => $WPML_current_lang,
'compare' => 'LIKE'
),
$WPML_not_exist
);
}
return $WPML_meta_query;
}
–> When i delete it, the site runs much faster but the translation of the grids do not work anymore… Is there a simple way how i can edit this code so the query is still working but maybe MUCH faster? 
I’m looking forward to hearing from you all soon!
Best regards from Germany,
Max
P.S.: I would have loved to ask the support of “The Grid” about it but i cannot acces their support-area is i need to provide an ENVATO purchase code -.-
