/**
  * @param string|bool $canonical_url
  * @param WP_Post     $post
  *
  * @return string|bool
  */
 public function get_canonical_url($canonical_url, $post)
 {
     if ($post && $this->sitepress->get_wp_api()->is_front_end()) {
         $post_element = new WPML_Post_Element($post->ID, $this->sitepress);
         if (!$post_element->is_translatable()) {
             $canonical_url = $this->sitepress->convert_url($canonical_url, $this->sitepress->get_default_language());
         } else {
             $wpml_translations = new WPML_Translations($this->sitepress);
             if ($wpml_translations->is_a_duplicate_of($post_element)) {
                 $canonical_url = (string) $this->get_canonical_of_duplicate($post_element);
             }
         }
     }
     return $canonical_url;
 }