diff --git a/lib/API.class.php b/lib/API.class.php index 3506b9c..a547a1f 100755 --- a/lib/API.class.php +++ b/lib/API.class.php @@ -20,7 +20,7 @@ class WPStrava_API { 'body' => http_build_query( $data ), 'sslverify' => false, 'headers' => array( - 'Authorization' => 'Bearer: ' . $this->access_token, + 'Authorization' => 'Bearer ' . $this->access_token, ) ); @@ -53,7 +53,7 @@ class WPStrava_API { $get_args = array( 'headers' => array( - 'Authorization' => 'Bearer: ' . $this->access_token, + 'Authorization' => 'Bearer ' . $this->access_token, ) ); diff --git a/lib/LatestRidesWidget.class.php b/lib/LatestRidesWidget.class.php index e84a4bb..30d4369 100644 --- a/lib/LatestRidesWidget.class.php +++ b/lib/LatestRidesWidget.class.php @@ -6,73 +6,58 @@ class WPStrava_LatestRidesWidget extends WP_Widget { public function __construct() { - $widget_ops = array('classname' => 'LatestRidesWidget', 'description' => __( 'Will publish your latest rides activity from strava.com.') ); - parent::__construct('wp-strava', $name = 'Strava Latest Rides', $widget_ops); - wp_enqueue_style('wp-strava'); //TODO only load this when wigit is loaded + $widget_ops = array( 'classname' => 'LatestRidesWidget', 'description' => __( 'Will publish your latest rides activity from strava.com.' ) ); + parent::__construct( 'wp-strava', $name = 'Strava Latest Rides', $widget_ops ); + wp_enqueue_style( 'wp-strava' ); //TODO only load this when wigit is loaded } /** @see WP_Widget::widget */ public function widget( $args, $instance ) { - extract($args); + extract( $args ); //$widget_id = $args['widget_id']; - $title = apply_filters('widget_title', empty($instance['title']) ? _e('Rides', 'wp-strava') : $instance['title']); - $strava_search_option = empty($instance['strava_search_option']) ? 'athlete' : $instance['strava_search_option']; - $strava_search_id = empty($instance['strava_search_id']) ? '' : $instance['strava_search_id']; - $quantity = empty($instance['quantity']) ? '5' : $instance['quantity']; + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Rides', 'wp-strava' ) : $instance['title'] ); + $strava_club_id = empty( $instance['strava_club_id'] ) ? '' : $instance['strava_club_id']; + $quantity = empty( $instance['quantity'] ) ? '5' : $instance['quantity']; $this->som = WPStrava_SOM::get_som(); ?> - strava_request_handler($strava_search_option, $strava_search_id, $strava_som_option, $quantity); ?> + strava_request_handler( $strava_club_id, $strava_som_option, $quantity ); ?>

- - -

- -

- - + +

- - + +

@@ -83,41 +68,29 @@ class WPStrava_LatestRidesWidget extends WP_Widget { // The handler to the ajax call, we will avoid this if Strava support jsonp request and we can do it // the parsing directly on the jQuery ajax call, the returned text will be enclosed in the $response variable. - private function strava_request_handler( $strava_search_option, $strava_search_id, $strava_som_option, $quantity ) { + private function strava_request_handler( $strava_club_id, $strava_som_option, $quantity ) { - //Check if the username is empty. - if ( empty( $strava_search_id ) ) - return __("Please configure the Strava search id on the widget options.", "wp-strava"); - //else $strava_rides = WPStrava::get_instance()->rides; - $rides = $strava_rides->getRidesSimple( $strava_search_option, $strava_search_id ); + $rides = $strava_rides->getRides( $quantity, $strava_club_id ); if ( is_wp_error( $rides ) ) return $rides->get_error_message(); - - //adjust quantity - $rides = array_slice( $rides, 0, $quantity ); - $rides_details = $strava_rides->getRidesDetails( $rides ); - if ( is_wp_error( $rides_details ) ) - return $rides_details->get_error_message(); - $response = "