Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Don't filter URLs used for hreflangs. (#203)
Browse files Browse the repository at this point in the history
Close #202.
  • Loading branch information
tfrommen committed May 9, 2016
2 parents 813754a + 54eb19b commit 39ca260
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/inc/hreflang-header/Mlp_Hreflang_Header_Output.php
Expand Up @@ -108,7 +108,10 @@ private function get_translations() {
$this->translations = array();

/** @var Mlp_Translation_Interface[] $translations */
$translations = $this->language_api->get_translations( array( 'include_base' => true ) );
$translations = $this->language_api->get_translations( array(
'include_base' => true,
'suppress_filters' => true,
) );
if ( ! $translations ) {
return $this->translations;
}
Expand Down
19 changes: 11 additions & 8 deletions src/inc/language-api/Mlp_Language_Api.php
Expand Up @@ -341,6 +341,8 @@ public function get_translations( Array $args = array() ) {
$arr[ 'icon' ] = '';
}

$arr['suppress_filters'] = $arguments['suppress_filters'];

$arr = new Mlp_Translation( $arr, new Mlp_Language( $data ) );
}

Expand Down Expand Up @@ -660,16 +662,17 @@ private function get_request_post_type() {
*/
private function prepare_translation_arguments( Array $args ) {

$defaults = array (
$defaults = array(
// always greater than 0
'site_id' => get_current_blog_id(),
'site_id' => get_current_blog_id(),
// 0 if missing
'content_id' => $this->get_query_id(),
'type' => $this->get_request_type(),
'strict' => TRUE,
'search_term' => get_search_query(),
'post_type' => $this->get_request_post_type(),
'include_base' => FALSE
'content_id' => $this->get_query_id(),
'type' => $this->get_request_type(),
'strict' => true,
'search_term' => get_search_query(),
'post_type' => $this->get_request_post_type(),
'include_base' => false,
'suppress_filters' => false,
);

$arguments = wp_parse_args( $args, $defaults );
Expand Down
13 changes: 13 additions & 0 deletions src/inc/types/Mlp_Translation.php
Expand Up @@ -48,6 +48,11 @@ class Mlp_Translation implements Mlp_Translation_Interface {
*/
private $target_title;

/**
* @var bool
*/
private $suppress_filters = false;

/**
* @param array $params
* @param Mlp_Language_Interface $language
Expand All @@ -62,6 +67,10 @@ public function __construct( Array $params, Mlp_Language_Interface $language ) {
$this->page_type = $params['type'];
$this->icon_url = $params['icon'];
$this->language = $language;

if ( isset( $params['suppress_filters'] ) ) {
$this->suppress_filters = (bool) $params['suppress_filters'];
}
}

/**
Expand Down Expand Up @@ -109,6 +118,10 @@ public function get_page_type() {
*/
public function get_remote_url() {

if ( $this->suppress_filters ) {
return (string) $this->remote_url;
}

/**
* Filter the remote URL of the linked element.
*
Expand Down

0 comments on commit 39ca260

Please sign in to comment.