/** * @param array $lang * @param WP_Query $current_query * @param bool $icl_lso_link_empty * @param bool $skip_lang * * @return array */ public function add_date_or_cpt_url_to_ls_lang($lang, $current_query, $icl_lso_link_empty, $skip_lang) { list($year, $month, $day) = $this->extract_date_data_from_query($current_query); $post_type = ($_type = $current_query->get('post_type')) ? $_type : 'post'; $lang_code = $lang['code']; $mark_missing = false; $override = false; if ($current_query->is_year() && $this->query_utils->archive_query_has_posts($lang_code, $year, null, null, $post_type)) { $date_archive_url = $this->wp_api->get_year_link($year); } elseif ($current_query->is_month() && $this->query_utils->archive_query_has_posts($lang_code, $year, $month, null, $post_type)) { $date_archive_url = $this->wp_api->get_month_link($year, $month); } elseif ($current_query->is_day() && $this->query_utils->archive_query_has_posts($lang_code, $year, $month, $day, $post_type)) { $date_archive_url = $this->wp_api->get_day_link($year, $month, $day); } else { if (!empty($current_query->query_vars['post_type'])) { $override = !$this->sitepress->is_translated_post_type($post_type); $mark_missing = true; if (!$override && $this->query_utils->archive_query_has_posts($lang_code, null, null, null, $post_type)) { $url = $this->sitepress->convert_url($this->wp_api->get_post_type_archive_link($post_type), $lang_code); $lang['translated_url'] = $this->sitepress->adjust_cpt_in_url($url, $post_type, $lang_code); $mark_missing = false; } } else { $mark_missing = true; } } if ($mark_missing) { list($lang, $skip_lang) = $this->maybe_mark_lang_missing($lang, $skip_lang, $icl_lso_link_empty, $override); } elseif (isset($date_archive_url)) { $lang['translated_url'] = $this->sitepress->convert_url($date_archive_url, $lang_code); } return array($lang, $skip_lang); }