mirror of
https://github.com/10h30/wp-strava.git
synced 2026-06-05 15:10:01 +09:00
Updated version to 1.1
Added Lance Willet Tested WP 4.2 Check for WP error on Strava POST Fix static method in RideShortcode Add Title to Latest Map Widget
This commit is contained in:
@@ -26,6 +26,9 @@ class WPStrava_API {
|
||||
|
||||
$response = wp_remote_post( $url . $uri, $args );
|
||||
|
||||
if ( is_wp_error( $response ) )
|
||||
return $response;
|
||||
|
||||
if ( $response['response']['code'] != 200 ) {
|
||||
//see if there's useful info in the body
|
||||
$body = json_decode( $response['body'] );
|
||||
|
||||
@@ -16,6 +16,7 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
||||
|
||||
public function form( $instance ) {
|
||||
// outputs the options form on admin
|
||||
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : __( 'Latest Activity', 'wp-strava' );
|
||||
$distance_min = isset( $instance['distance_min'] ) ? esc_attr( $instance['distance_min'] ) : '';
|
||||
$strava_club_id = isset( $instance['strava_club_id'] ) ? esc_attr( $instance['strava_club_id'] ) : '';
|
||||
|
||||
@@ -23,6 +24,10 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
||||
//$ride_index_params = $ride_index_params ? $ride_index_params : 'athleteId=21';
|
||||
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'distance_min' ); ?>"><?php echo sprintf( __( 'Min. Distance (%s):', 'wp-strava' ), $this->som->get_distance_label() ); ?></label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id( 'distance_min' ); ?>" name="<?php echo $this->get_field_name( 'distance_min' ); ?>" type="text" value="<?php echo $distance_min; ?>" />
|
||||
@@ -37,6 +42,7 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
// processes widget options to be saved from the admin
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags( $new_instance['title'] );
|
||||
$instance['strava_club_id'] = strip_tags( $new_instance['strava_club_id'] );
|
||||
$instance['distance_min'] = strip_tags( $new_instance['distance_min'] );
|
||||
return $instance;
|
||||
@@ -44,6 +50,8 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
||||
|
||||
public function widget( $args, $instance ) {
|
||||
extract( $args );
|
||||
|
||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Latest Activity', 'wp-strava' ) : $instance['title'] );
|
||||
$distance_min = $instance['distance_min'];
|
||||
$strava_club_id = empty( $instance['strava_club_id'] ) ? NULL : $instance['strava_club_id'];
|
||||
$build_new = false;
|
||||
@@ -92,8 +100,8 @@ class WPStrava_LatestMapWidget extends WP_Widget {
|
||||
|
||||
if ( $ride ):
|
||||
echo $before_widget;
|
||||
?><h3 class="widget-title">Latest Ride</h3>
|
||||
<a title="<?php echo $ride->name ?>" href="http://app.strava.com/activities/<?php echo $ride->id ?>"><?php
|
||||
if ( $title ) echo $before_title . $title . $after_title;
|
||||
?><a title="<?php echo $ride->name ?>" href="http://app.strava.com/activities/<?php echo $ride->id ?>"><?php
|
||||
echo $this->getStaticImage( $ride->id, $build_new );
|
||||
?></a><?php
|
||||
echo $after_widget;
|
||||
|
||||
@@ -30,7 +30,7 @@ class WPStrava_LatestRidesWidget extends WP_Widget {
|
||||
?>
|
||||
<?php echo $before_widget; ?>
|
||||
<?php if ( $title ) echo $before_title . $title . $after_title; ?>
|
||||
<?php echo $this->strava_request_handler( $strava_club_id, $strava_som_option, $quantity ); ?>
|
||||
<?php echo $this->strava_request_handler( $strava_club_id, $quantity ); ?>
|
||||
<?php echo $after_widget; ?>
|
||||
<?php
|
||||
}
|
||||
@@ -39,11 +39,6 @@ class WPStrava_LatestRidesWidget extends WP_Widget {
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags( $new_instance['title'] );
|
||||
if( in_array( $new_instance['strava_som_option'], array( 'metric', 'english' ) ) ) {
|
||||
$instance['strava_som_option'] = $new_instance['strava_som_option'];
|
||||
} else {
|
||||
$instance['strava_som_option'] = 'metric';
|
||||
}
|
||||
$instance['strava_club_id'] = strip_tags( $new_instance['strava_club_id'] );
|
||||
$instance['quantity'] = $new_instance['quantity'];
|
||||
|
||||
@@ -74,7 +69,7 @@ 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_club_id, $strava_som_option, $quantity ) {
|
||||
private function strava_request_handler( $strava_club_id, $quantity ) {
|
||||
|
||||
$strava_rides = WPStrava::get_instance()->rides;
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
class WPStrava_RideShortcode {
|
||||
static $add_script;
|
||||
private static $add_script;
|
||||
|
||||
static function init() {
|
||||
add_shortcode('ride', array(__CLASS__, 'handler'));
|
||||
add_action('wp_footer', array(__CLASS__, 'printScripts'));
|
||||
public static function init() {
|
||||
add_shortcode( 'ride', array( __CLASS__, 'handler' ) );
|
||||
add_shortcode( 'activity', array( __CLASS__, 'handler' ) );
|
||||
add_action( 'wp_footer', array( __CLASS__, 'printScripts' ) );
|
||||
}
|
||||
|
||||
// Shortcode handler function
|
||||
// [ride id=id som=metric map_width="100%" map_height="400px"]
|
||||
function handler($atts) {
|
||||
public static function handler($atts) {
|
||||
self::$add_script = true;
|
||||
|
||||
$defaults = array(
|
||||
@@ -31,7 +32,7 @@ class WPStrava_RideShortcode {
|
||||
$map_height = str_replace( '%', '', $map_height );
|
||||
$map_width = str_replace( 'px', '', $map_width );
|
||||
$map_height = str_replace( 'px', '', $map_height );
|
||||
|
||||
|
||||
if( $rideDetails ) {
|
||||
return '
|
||||
<div id="ride-header-' . $id . '" class="wp-strava-ride-container">
|
||||
@@ -70,7 +71,7 @@ class WPStrava_RideShortcode {
|
||||
}
|
||||
} // handler
|
||||
|
||||
static function printScripts() {
|
||||
public static function printScripts() {
|
||||
if (self::$add_script) {
|
||||
wp_enqueue_style('wp-strava-style');
|
||||
|
||||
|
||||
+11
-5
@@ -1,10 +1,10 @@
|
||||
=== Plugin Name ===
|
||||
Contributors: cmanon, jrfoell
|
||||
Contributors: cmanon, jrfoell, lancewillett
|
||||
Donate link: http://cmanon.com/
|
||||
Tags: strava, bicycle, cycling, biking, running, run, swimming, swim, gps, shortcode, widget, plugin
|
||||
Requires at least: 3.0
|
||||
Tested up to: 4.0
|
||||
Stable tag: 1.0
|
||||
Requires at least: 4.0
|
||||
Tested up to: 4.2
|
||||
Stable tag: 1.1
|
||||
License: GPLv2 or later
|
||||
|
||||
Show your Strava activity on your WordPress site.
|
||||
@@ -17,7 +17,7 @@ widgets and shortcodes for showing maps and activity summaries.
|
||||
|
||||
= Shortcodes =
|
||||
|
||||
[ride id=NUMBER] - add to any page or post. Also takes the following
|
||||
[activity id=NUMBER] - add to any page or post. Also takes the following
|
||||
optional parameters:
|
||||
|
||||
* som - english/metric (system of measure - override from default setting)
|
||||
@@ -33,6 +33,12 @@ latest map to activities of a certain minimum distance
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.1 =
|
||||
Added [activity] short code to deprecate [ride] in the future
|
||||
Fixed static method call error in shortcode
|
||||
Added title to Strava Latest Map Widget
|
||||
Added Lance Willet to contributors
|
||||
|
||||
= 1.0 =
|
||||
Change to Strava API V3
|
||||
Switch ride shortcode to use static map
|
||||
|
||||
+8
-8
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: WP Strava
|
||||
Plugin URI: http://cmanon.com
|
||||
Description: Plugin to show your strava.com information in your wordpress blog. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
|
||||
Version: 1.0
|
||||
Author: Carlos Santa Cruz (cmanon), Justin Foell <justin@foell.org>
|
||||
Author URI: http://cmanon.com
|
||||
License: GPL2
|
||||
*/
|
||||
* Plugin Name: WP Strava
|
||||
* Plugin URI: http://cmanon.com
|
||||
* Description: Plugin to show your strava.com information in your wordpress blog. Some Icons are Copyright © Yusuke Kamiyamane. All rights reserved. Licensed under a Creative Commons Attribution 3.0 license.
|
||||
* Version: 1.1
|
||||
* Author: Carlos Santa Cruz, Justin Foell, Lance Willet
|
||||
* License: GPL2
|
||||
*/
|
||||
|
||||
/* Copyright 2011 Carlos Santa Cruz (email : cmanon at gmail dot com)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user