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

Commit

Permalink
Pass translation object to mlp_linked_element_link. #98
Browse files Browse the repository at this point in the history
  • Loading branch information
tfrommen committed Mar 31, 2015
1 parent 72a2c5d commit 30498bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions inc/nav-menu/Mlp_Nav_Menu_Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private function prepare_item( WP_Post $item, Array $translations ) {

list ( $url, $translation ) = $this->get_item_details( $translations, $site_id );

$item->url = apply_filters( 'mlp_linked_element_link', $url, $site_id, 0 );
/** This filter is documented in inc/types/Mlp_Translation.php */
$item->url = apply_filters( 'mlp_linked_element_link', $url, $site_id, 0, $translation );

/**
* Filter a nav menu item before it is sent to the walker
Expand Down Expand Up @@ -118,4 +119,4 @@ private function get_site_id( WP_Post $item ) {

return (int) get_post_meta( $item->ID, $this->meta_key, TRUE );
}
}
}
13 changes: 11 additions & 2 deletions inc/types/Mlp_Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ public function get_page_type() {
*/
public function get_remote_url() {

/**
* Customize the remote URL of the linked element.
*
* @param string $remote_url URL of the remote post.
* @param int $target_site_id ID of the target site.
* @param int $target_content_id ID of the target post.
* @param Mlp_Translation_Interface|NULL $translation Translation object. NULL, if there is no translation.
*/
return apply_filters(
'mlp_linked_element_link',
(string) $this->remote_url,
$this->get_target_site_id(),
$this->get_target_content_id()
$this->get_target_content_id(),
$this
);
}

Expand All @@ -132,4 +141,4 @@ public function get_target_site_id() {

return $this->target_site_id;
}
}
}

0 comments on commit 30498bb

Please sign in to comment.