diff --git a/lib/WPStrava.php b/lib/WPStrava.php index e323aca..b5a94d7 100644 --- a/lib/WPStrava.php +++ b/lib/WPStrava.php @@ -14,11 +14,13 @@ private function __construct() { if ( is_admin() ) { $this->settings->hook(); } else { + add_action( 'init', array( $this, 'register_shortcodes') ); add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); } // Register widgets. add_action( 'widgets_init', array( $this, 'register_widgets' ) ); + } public static function get_instance() { @@ -82,4 +84,11 @@ public function register_widgets() { register_widget( 'WPStrava_LatestActivitiesWidget' ); register_widget( 'WPStrava_LatestMapWidget' ); } + + public function register_shortcodes() { + add_shortcode( 'ride', array( 'WPStrava_ActivityShortcode', 'handler' ) ); // @deprecated 1.1 + add_shortcode( 'activity', array( 'WPStrava_ActivityShortcode', 'handler' ) ); + add_shortcode( 'activities', array( 'WPStrava_LatestActivitiesShortcode', 'handler' ) ); + add_shortcode( 'route', array( 'WPStrava_RouteShortcode', 'handler' ) ); + } } diff --git a/lib/WPStrava/ActivityShortcode.php b/lib/WPStrava/ActivityShortcode.php index fd50c89..8ceba13 100644 --- a/lib/WPStrava/ActivityShortcode.php +++ b/lib/WPStrava/ActivityShortcode.php @@ -4,8 +4,6 @@ class WPStrava_ActivityShortcode { private static $add_script; public static function init() { - add_shortcode( 'ride', array( __CLASS__, 'handler' ) ); // @deprecated 1.1 - add_shortcode( 'activity', array( __CLASS__, 'handler' ) ); add_action( 'wp_footer', array( __CLASS__, 'print_scripts' ) ); } diff --git a/lib/WPStrava/LatestActivities.php b/lib/WPStrava/LatestActivities.php index 683ab97..ded9150 100644 --- a/lib/WPStrava/LatestActivities.php +++ b/lib/WPStrava/LatestActivities.php @@ -23,14 +23,22 @@ public static function get_activities_html( $args ) { $response = "
- +
@@ -36,11 +36,11 @@ public function form( $instance ) {
- +
- +
map ) ) { $strava_activity = WPStrava::get_instance()->activity; $activities = $strava_activity->get_activities( $athlete_token, $strava_club_id ); @@ -127,9 +127,11 @@ public function widget( $args, $instance ) { echo $args['before_title'] . $title . $args['after_title']; } - echo ""; - echo $this->get_static_image( $id, $activity, $build_new ); - echo ''; + echo empty( $activity->map ) ? + sprintf( __( 'Map not available for activity "%s"', 'wp-strava' ), $activity->name ) : + "" . + $this->get_static_image( $id, $activity, $build_new ) . + ''; echo $args['after_widget']; } } diff --git a/lib/WPStrava/RouteShortcode.php b/lib/WPStrava/RouteShortcode.php index c7f848d..cce6f9f 100644 --- a/lib/WPStrava/RouteShortcode.php +++ b/lib/WPStrava/RouteShortcode.php @@ -10,7 +10,6 @@ class WPStrava_RouteShortcode { private static $add_script; public static function init() { - add_shortcode( 'route', array( __CLASS__, 'handler' ) ); add_action( 'wp_footer', array( __CLASS__, 'print_scripts' ) ); } diff --git a/readme.txt b/readme.txt index fbe7366..5350b21 100755 --- a/readme.txt +++ b/readme.txt @@ -76,6 +76,7 @@ If your API key works with other Google Maps plugins but not WP Strava, you may = 1.5.0 = +Added additional checks for abridged club data to avoid undefined index/property errors https://wordpress.org/support/topic/club-activities-bugs-strava/ Added composer with PSR-0 autoloader (will switch to PSR-4 once WP's PHP 5.2 requirement goes away). Moved files into appropriate place to support autoloader. Added WordPress-Extra coding standards rule definition to project diff --git a/wp-strava.php b/wp-strava.php index b265d9c..94d4cc4 100755 --- a/wp-strava.php +++ b/wp-strava.php @@ -3,7 +3,7 @@ * Plugin Name: WP Strava * Plugin URI: https://wordpress.org/plugins/wp-strava/ * Description: Show your strava.com activity on your WordPress site. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license. - * Version: 1.5.0-r1 + * Version: 1.5.0-rc2 * Author: Carlos Santa Cruz, Justin Foell, Lance Willett, Daniel Lintott * License: GPL2 * Text Domain: wp-strava