 SELECT COUNT(p.ID) FROM wprb_posts p JOIN wprb_icl_translations t ON p.ID=t.element_id AND t.element_type = CONCAT('post_', p.post_type) WHERE p.post_author=10 AND post_type IN ('post') AND post_status='publish' AND (t.language_code = 'es' OR ( t.language_code = 'es' AND p.post_type IN ( 'post' ) AND ( ( ( SELECT COUNT(element_id) FROM wprb_icl_translations WHERE trid = t.trid AND language_code = 'es' ) = 0 ) OR ( ( SELECT COUNT(element_id) FROM wprb_icl_translations t2 JOIN wprb_posts p ON p.id = t2.element_id WHERE t2.trid = t.trid AND t2.language_code = 'es' AND ( p.post_status = 'publish' OR p.post_type='attachment' AND p.post_status = 'inherit' ) ) = 0 ) ) ))  LIMIT 1;