From df85c9f360ba7f03c5932ea2a653f66962702cda Mon Sep 17 00:00:00 2001 From: Justin Foell <630830+jrfoell@users.noreply.github.com> Date: Thu, 24 Dec 2020 12:24:37 -0600 Subject: [PATCH] Remove map link when doing REST request --- readme.txt | 3 ++- src/WPStrava/Activity.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 0e48f13..f791b3a 100755 --- a/readme.txt +++ b/readme.txt @@ -113,12 +113,13 @@ On the WP-Strava settings page you cannot currently remove and add another athle == Changelog == -= Unreleased = += 2.5.1 = Fix latest_map class replacing echo with return https://wordpress.org/support/topic/latest-activity-map-shortcode-wrong-placed-on-page/ Fix styling on pace activity max speed. Fix broken water pace on activity. Fix pace types and remove 'other' - making 'speed' default. +Fix to remove map link in editor so you don't leave the editor. = 2.5.0 = diff --git a/src/WPStrava/Activity.php b/src/WPStrava/Activity.php index 9623874..242792f 100755 --- a/src/WPStrava/Activity.php +++ b/src/WPStrava/Activity.php @@ -109,11 +109,22 @@ class WPStrava_Activity { * @since 2.3.2 */ public function get_activity_link( $activity_id, $text, $title = '' ) { - if ( WPStrava::get_instance()->settings->no_link ) { + if ( $this->is_rest_request() || WPStrava::get_instance()->settings->no_link ) { return $text; } $url = esc_url( self::ACTIVITIES_URL . $activity_id ); $title_attr = $title ? " title='" . esc_attr( $title ) . "'" : ''; return "{$text}"; } + + /** + * Check if rest request to skip link rendering in block editor. + * + * @return boolean + * @author Justin Foell + * @since 2.5.1 + */ + private function is_rest_request() { + return defined( 'REST_REQUEST' ) && REST_REQUEST; + } }