From 702febcc8ca9988c4bcd927df888c29179636987 Mon Sep 17 00:00:00 2001 From: Justin Foell Date: Fri, 23 Mar 2018 16:52:06 -0500 Subject: [PATCH] Added some missing 'Translators:' comments Added class documentation Changed phpcs ignores to new style --- lib/WPStrava.php | 76 ++++++++++++++++++++++++++++-- lib/WPStrava/API.php | 2 +- lib/WPStrava/ActivityShortcode.php | 2 +- lib/WPStrava/LatestMapWidget.php | 11 ++++- lib/WPStrava/RouteShortcode.php | 2 +- lib/WPStrava/Settings.php | 2 +- 6 files changed, 84 insertions(+), 11 deletions(-) diff --git a/lib/WPStrava.php b/lib/WPStrava.php index 754301a..91ef906 100644 --- a/lib/WPStrava.php +++ b/lib/WPStrava.php @@ -1,13 +1,43 @@ settings = new WPStrava_Settings(); @@ -23,6 +53,11 @@ class WPStrava { } + /** + * Get a singleton instance. + * + * @return WPStrava + */ public static function get_instance() { if ( ! self::$instance ) { $class = __CLASS__; @@ -31,6 +66,12 @@ class WPStrava { return self::$instance; } + /** + * Magic method to access activity, routes, settings, etc. + * + * @param string $name One of activity, routes, settings. + * @return mixed|null + */ public function __get( $name ) { // On-demand classes. if ( 'activity' === $name ) { @@ -48,6 +89,12 @@ class WPStrava { return null; } + /** + * Get an API object for the given athelete token. + * + * @param string $token Athlete token. + * @return WPStrava_API + */ public function get_api( $token = null ) { if ( ! $token ) { $token = $this->settings->get_default_token(); @@ -60,6 +107,11 @@ class WPStrava { return $this->api[ $token ]; } + /** + * Get the activity object. + * + * @return WPStrava_Activity + */ public function get_activity() { if ( ! $this->activity ) { $this->activity = new WPStrava_Activity(); @@ -68,6 +120,11 @@ class WPStrava { return $this->activity; } + /** + * Get the routes object. + * + * @return WPStrava_Routes + */ public function get_routes() { if ( ! $this->routes ) { $this->routes = new WPStrava_Routes(); @@ -75,16 +132,25 @@ class WPStrava { return $this->routes; } + /** + * Register the wp-strava stylesheet. + */ public function register_scripts() { // Register a personalized stylesheet. wp_register_style( 'wp-strava-style', WPSTRAVA_PLUGIN_URL . 'css/wp-strava.css' ); } + /** + * Register the widgets. + */ public function register_widgets() { register_widget( 'WPStrava_LatestActivitiesWidget' ); register_widget( 'WPStrava_LatestMapWidget' ); } + /** + * Register the shortcodes. + */ public function register_shortcodes() { add_shortcode( 'ride', array( 'WPStrava_ActivityShortcode', 'handler' ) ); // @deprecated 1.1 add_shortcode( 'activity', array( 'WPStrava_ActivityShortcode', 'handler' ) ); diff --git a/lib/WPStrava/API.php b/lib/WPStrava/API.php index 63fb753..4a1a6e9 100755 --- a/lib/WPStrava/API.php +++ b/lib/WPStrava/API.php @@ -38,7 +38,7 @@ class WPStrava_API { if ( ! empty( $body->error ) ) { $error = $body->error; } else { - $error = print_r( $response, true ); // @codingStandardsIgnoreLine + $error = print_r( $response, true ); // phpcs:ignore -- Debug output. } return new WP_Error( diff --git a/lib/WPStrava/ActivityShortcode.php b/lib/WPStrava/ActivityShortcode.php index 8ceba13..e2b261b 100644 --- a/lib/WPStrava/ActivityShortcode.php +++ b/lib/WPStrava/ActivityShortcode.php @@ -29,7 +29,7 @@ class WPStrava_ActivityShortcode { if ( is_wp_error( $activity_details ) ) { if ( WPSTRAVA_DEBUG ) { - return '
' . print_r( $activity_details, true ) . '
'; // @codingStandardsIgnoreLine + return '
' . print_r( $activity_details, true ) . '
'; // phpcs:ignore -- Debug output. } else { return $activity_details->get_error_message(); } diff --git a/lib/WPStrava/LatestMapWidget.php b/lib/WPStrava/LatestMapWidget.php index 69bdbe7..a17009b 100644 --- a/lib/WPStrava/LatestMapWidget.php +++ b/lib/WPStrava/LatestMapWidget.php @@ -24,7 +24,10 @@ class WPStrava_LatestMapWidget extends WP_Widget { ?>

- +

@@ -36,7 +39,10 @@ class WPStrava_LatestMapWidget extends WP_Widget {

- +

@@ -128,6 +134,7 @@ class WPStrava_LatestMapWidget extends WP_Widget { } echo empty( $activity->map ) ? + // Translators: Text with activity name shown in place of image if not available. sprintf( __( 'Map not available for activity "%s"', 'wp-strava' ), $activity->name ) : "" . $this->get_static_image( $id, $activity, $build_new ) . diff --git a/lib/WPStrava/RouteShortcode.php b/lib/WPStrava/RouteShortcode.php index cce6f9f..371f12d 100644 --- a/lib/WPStrava/RouteShortcode.php +++ b/lib/WPStrava/RouteShortcode.php @@ -35,7 +35,7 @@ class WPStrava_RouteShortcode { if ( is_wp_error( $route_details ) ) { if ( WPSTRAVA_DEBUG ) { - return '

' . print_r( $route_details, true ) . '
'; // @codingStandardsIgnoreLine + return '
' . print_r( $route_details, true ) . '
'; // phpcs:ignore -- Debug output. } else { return $route_details->get_error_message(); } diff --git a/lib/WPStrava/Settings.php b/lib/WPStrava/Settings.php index 4342ccc..c4c9a46 100644 --- a/lib/WPStrava/Settings.php +++ b/lib/WPStrava/Settings.php @@ -308,7 +308,7 @@ class WPStrava_Settings { } } else { // Translators: error message from Strava - $this->feedback .= sprintf( __( 'There was an error receiving data from Strava: %s', 'wp-strava' ), print_r( $strava_info, true ) ); // @codingStandardsIgnoreLine + $this->feedback .= sprintf( __( 'There was an error receiving data from Strava: %s', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output. return false; } } else {