WPStrava::get_instance()->settings->get_default_id(),
'strava_club_id' => null,
'distance_min' => 0,
);
$args = wp_parse_args( $args, $defaults );
$strava_activity = WPStrava::get_instance()->activity;
$activities = array();
try {
$activities = $strava_activity->get_activities( $args['client_id'], $args['strava_club_id'] );
} catch ( WPStrava_Exception $e ) {
// If athlete_token is still set, warn about that first and foremost.
if ( isset( $args['athlete_token'] ) ) {
// Translators: Message shown when using deprecated athlete_token parameter.
echo wp_kses_post( __( 'The athlete_token parameter is deprecated as of WP-Strava version 2 and should be replaced with client_id.', 'wp-strava' ) );
} else {
echo $e->to_html(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Debug only.
}
}
if ( ! empty( $activities ) ) {
if ( ! empty( $args['distance_min'] ) ) {
$activities = $strava_activity->get_activities_longer_than( $activities, $args['distance_min'] );
}
$activity = current( $activities );
echo empty( $activity->map ) ?
// Translators: Text with activity name shown in place of image if not available.
esc_html( sprintf( __( 'Map not available for activity "%s"', 'wp-strava' ), $activity->name ) ) :
"" .
WPStrava_StaticMap::get_image_tag( $activity ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Image OK.
'';
}
}
}