Plugin Directory

Changeset 703569


Ignore:
Timestamp:
04/25/2013 04:56:25 PM (13 years ago)
Author:
phikai
Message:

Metric Unit Support

Location:
runkeeper-activity-feed/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • runkeeper-activity-feed/trunk/readme.txt

    r701681 r703569  
    55Requires at least: 3.5
    66Tested up to: 3.5.1
    7 Stable tag: 1.4.0
     7Stable tag: 1.5.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414
    1515The RunKeeper + WordPress Activity Feed plugin automatically posts RunKeeper Activities straight to your blog. All you need to do is activate the plugin and connect your account. After that, track your activities with RunKeeper and they'll show up on your WordPress site for everyone to see!
     16
     17**NEW FEATURE**: Metric Unit Support
     18
     19* Post Options and the Widget now support the use of metric units, just update your options!
    1620
    1721**NEW FEATURE**: RunKeeper Records Widget
     
    5559== Changelog ==
    5660
     61= 1.5.0 =
     62* NEW FEATURE: Metric Unit Support for Posts and Widget
     63
    5764= 1.4.0 =
    5865* NEW FEATURE: Single Activity Import based on Activity ID
  • runkeeper-activity-feed/trunk/runkeeper-wordpress-activity-feed.php

    r701681 r703569  
    66Description: A plugin to automatically draft posts of all your Runkeeper Activities.
    77Author: A. Kai Armstrong
    8 Version: 1.4.0
     8Version: 1.5.0
    99Author URI: http://www.kaiarmstrong.com
    1010*/
     
    2626    add_option('toz_rk_post_options_time', '');
    2727    add_option('toz_rk_last_event', '0');
     28    add_option('toz_rk_units', 'standard');
    2829}
    2930register_activation_hook( __FILE__, 'toz_rk_activate');
     
    8384        if ( isset($_POST['toz_rk_post_options_url']) ) { update_option('toz_rk_post_options_url', $_POST['toz_rk_post_options_url']); }
    8485        if ( isset($_POST['toz_rk_post_options_time']) ) { update_option('toz_rk_post_options_time', $_POST['toz_rk_post_options_time']); }
     86        if ( isset($_POST['toz_rk_units']) ) { update_option('toz_rk_units', $_POST['toz_rk_units']); }
    8587        toz_rk_schedule_activate();
    8688    } else  if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_reset_options' )) {
     
    109111            <h3>Plugin Settings</h3>
    110112            <p><form method="post" action="">
    111                 <table class="form-table"><tbod>
     113                <table class="form-table"><tbody>
    112114                    <tr valign="top">
    113115                        <th scope="row"><label for="toz_rk_author_id">Author ID:</label></th>
     
    125127                    </tr>
    126128                    <tr valign="top">
     129                        <th scope="row"><label for="toz_rk_units">Units:</label></th>
     130                        <td>
     131                            <input type="radio" name="toz_rk_units" value="standard" class="code" <?php if ( get_option('toz_rk_units') == 'standard' ) { echo 'checked'; } else { } ?> />
     132                            <span class="description">Standard</span>
     133                        </td>
     134                    </tr>
     135                    <tr valign="top">
     136                        <th scope="row"></th>
     137                        <td>
     138                            <input type="radio" name="toz_rk_units" value="metric" class="code" <?php if ( get_option('toz_rk_units') == 'metric' ) { echo 'checked'; } else { } ?> />
     139                            <span class="description">Metric</span>
     140                        </td>
     141                    </tr>
     142                    <tr valign="top">
    127143                        <th scope="row"><label for="toz_rk_post_options">Post Options:</label></th>
    128144                        <td>
     
    130146                            <span class="description">Activity Notes</span>
    131147                        </td>
    132                        
    133148                    </tr>
    134149                    <tr valign="top">
     
    396411        if ( !empty($post_options['distance']) ) {
    397412            if ( !empty($rkActivity_detailed_array['total_distance']) ) {
    398                 $post_import_content .= '<li>Distance: ' . round($rkActivity_detailed_array['total_distance']*0.00062137, 2) . '</li>';
     413                if ( get_option('toz_rk_units') == 'standard' ) {
     414                    $post_import_content .= '<li>Distance: ' . round($rkActivity_detailed_array['total_distance']*0.00062137, 2) . ' mi</li>'; //Meters * Miles
     415                } else if ( get_option('toz_rk_units') == 'metric' ) {
     416                    $post_import_content .= '<li>Distance: ' . round($rkActivity_detailed_array['total_distance']/1000, 2) . ' km</li>'; //Meters / KM
     417                } else {
     418                    $post_import_content .= '<li>Distance: ' . round($rkActivity_detailed_array['total_distance']*0.00062137, 2) . ' mi</li>'; //Default to Standard
     419                }
    399420            } else {
    400421                //Do Nothing
     
    419440                list($hours, $minutes, $seconds) = explode(":",$hms);
    420441                $total_seconds = $hours * 60 * 60 + $minutes * 60 + $seconds;
    421                            
    422                 $mps = round($rkActivity_detailed_array['total_distance']*0.00062137, 2) / $total_seconds;
    423                 $mph = round($mps * 60 * 60, 2);
    424                            
    425                 $post_import_content .= '<li>Average Speed: ' . $mph . '</li>';
     442               
     443                if ( get_option('toz_rk_units') == 'standard' ) {
     444                    $dps = round($rkActivity_detailed_array['total_distance']*0.00062137, 2) / $total_seconds;
     445                    $sph = round($dps * 60 * 60, 2);
     446                    $post_import_content .= '<li>Average Speed: ' . $sph . ' mph</li>';
     447                } else if ( get_option('toz_rk_units') == 'metric' ) {
     448                    $dps = round($rkActivity_detailed_array['total_distance']/1000, 2) / $total_seconds;
     449                    $sph = round($dps * 60 * 60, 2);
     450                    $post_import_content .= '<li>Average Speed: ' . $sph . ' kmh</li>';
     451                } else {
     452                    $dps = round($rkActivity_detailed_array['total_distance']*0.00062137, 2) / $total_seconds;
     453                    $sph = round($dps * 60 * 60, 2);
     454                    $post_import_content .= '<li>Average Speed: ' . $sph . ' mph</li>';
     455                }           
     456               
    426457            } else {
    427458                //Do Nothing
  • runkeeper-activity-feed/trunk/runkeeper-wordpress-records-widget.php

    r701681 r703569  
    4949                $toz_widget_rkAPI->setRunkeeperToken( get_option( 'toz_rk_access_token' ) );
    5050            }
     51           
     52            //Get Unit Options
     53            if ( get_option('toz_rk_units') == 'standard' ) {
     54                $toz_rk_units = 'mi';
     55            } else if ( get_option('toz_rk_units') == 'metric' ) {
     56                $toz_rk_units = 'km';
     57            } else {
     58                $toz_rk_units = 'mi';
     59            }
    5160       
    5261            $rkRecordsFeed = $toz_widget_rkAPI->doRunkeeperRequest('Records','Read');
     
    5867                        foreach ($rkRecordsFeed[$i] as $rkRecordsActivity) {
    5968                            $toz_records_content = '<ul>';
    60                             $toz_records_content .= '<li>Best Activity: '.round($rkRecordsActivity[0]->value, 2).' miles</li>';
    61                             $toz_records_content .= '<li>Best Week: '.round($rkRecordsActivity[1]->value, 2).' miles</li>';
    62                             $toz_records_content .= '<li>Last Week: '.round($rkRecordsActivity[2]->value, 2).' miles</li>';
    63                             $toz_records_content .= '<li>This Week: '.round($rkRecordsActivity[3]->value, 2).' miles</li>';
    64                             $toz_records_content .= '<li>Best Month: '.round($rkRecordsActivity[4]->value, 2).' miles</li>';
    65                             $toz_records_content .= '<li>Last Month: '.round($rkRecordsActivity[5]->value, 2).' miles</li>';
    66                             $toz_records_content .= '<li>This Month: '.round($rkRecordsActivity[6]->value, 2).' miles</li>';
     69                            $toz_records_content .= '<li>Best Activity: '.round($rkRecordsActivity[0]->value, 2).' ' . $toz_rk_units . '</li>';
     70                            $toz_records_content .= '<li>Best Week: '.round($rkRecordsActivity[1]->value, 2).' ' . $toz_rk_units . '</li>';
     71                            $toz_records_content .= '<li>Last Week: '.round($rkRecordsActivity[2]->value, 2).' ' . $toz_rk_units . '</li>';
     72                            $toz_records_content .= '<li>This Week: '.round($rkRecordsActivity[3]->value, 2).' ' . $toz_rk_units . '</li>';
     73                            $toz_records_content .= '<li>Best Month: '.round($rkRecordsActivity[4]->value, 2).' ' . $toz_rk_units . '</li>';
     74                            $toz_records_content .= '<li>Last Month: '.round($rkRecordsActivity[5]->value, 2).' ' . $toz_rk_units . '</li>';
     75                            $toz_records_content .= '<li>This Month: '.round($rkRecordsActivity[6]->value, 2).' ' . $toz_rk_units . '</li>';
    6776                            $toz_records_content .= '</ul>';
    6877                   
Note: See TracChangeset for help on using the changeset viewer.