Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Commit

Permalink
fix(sniff): sniff current route rather than current url
Browse files Browse the repository at this point in the history
  • Loading branch information
hypeJunction committed Oct 25, 2016
1 parent 1e99b00 commit 6a44390
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
8 changes: 6 additions & 2 deletions classes/hypeJunction/Discovery/Discovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public static function prepareAlternateLinks($hook, $type, $return, $params) {

$ia = elgg_set_ignore_access(true);

$entity = get_entity_from_url(current_page_url());
$segments = _elgg_services()->request->getUrlSegments();
$url = elgg_normalize_url(implode('/', $segments));
$entity = get_entity_from_url($url);

if (is_embeddable($entity)) {
$return['links']['json+oembed'] = array(
Expand Down Expand Up @@ -55,7 +57,9 @@ public static function prepareAlternateLinks($hook, $type, $return, $params) {
*/
public static function prepareMetas($hook, $type, $return, $params) {

$metatags = get_discovery_metatags(current_page_url());
$segments = _elgg_services()->request->getUrlSegments();
$url = elgg_normalize_url(implode('/', $segments));
$metatags = get_discovery_metatags($url);

if (empty($metatags)) {
return;
Expand Down
4 changes: 3 additions & 1 deletion classes/hypeJunction/Discovery/Menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public static function entityMenuSetup($hook, $type, $return, $params) {
*/
public static function extrasMenuSetup($hook, $type, $return, $params) {

$entity = get_entity_from_url(current_page_url());
$segments = _elgg_services()->request->getUrlSegments();
$url = elgg_normalize_url(implode('/', $segments));
$entity = get_entity_from_url($url);
if (!is_discoverable($entity)) {
return;
}
Expand Down
5 changes: 4 additions & 1 deletion classes/hypeJunction/Discovery/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ public static function servicesRoute($hook, $type, $return, $params) {
public static function redirectErrorToPermalink($hook, $type, $return, $params) {

$ia = elgg_set_ignore_access(true);
$entity = get_entity_from_url(current_page_url());

$segments = _elgg_services()->request->getUrlSegments();
$url = elgg_normalize_url(implode('/', $segments));
$entity = get_entity_from_url($url);

if (is_discoverable($entity)) {
$return = get_entity_permalink($entity);
Expand Down
4 changes: 3 additions & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ function get_share_action_url($provider, $guid = 0, $referrer = '') {
function get_provider_url($provider, $entity = null, $referrer = '') {

if (!elgg_instanceof($entity)) {
$permalink = ($referrer) ? $referrer : current_page_url();
$segments = _elgg_services()->request->getUrlSegments();
$url = elgg_normalize_url(implode('/', $segments));
$permalink = ($referrer) ? $referrer : $url;
$guid = get_guid_from_url($permalink);
if ($guid) {
$entity = get_entity($guid);
Expand Down

0 comments on commit 6a44390

Please sign in to comment.