Plugin Directory

Changeset 705196


Ignore:
Timestamp:
04/29/2013 03:19:43 AM (13 years ago)
Author:
phikai
Message:

Average Pace Options

Location:
runkeeper-activity-feed/trunk
Files:
1 deleted
2 edited

Legend:

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

    r703569 r705196  
    55Requires at least: 3.5
    66Tested up to: 3.5.1
    7 Stable tag: 1.5.0
     7Stable tag: 1.6.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5959== Changelog ==
    6060
     61= 1.6.0 =
     62* NEW FEATURE: Average Pace Options for Posts
     63
    6164= 1.5.0 =
    6265* NEW FEATURE: Metric Unit Support for Posts and Widget
  • runkeeper-activity-feed/trunk/runkeeper-wordpress-activity-feed.php

    r703569 r705196  
    66Description: A plugin to automatically draft posts of all your Runkeeper Activities.
    77Author: A. Kai Armstrong
    8 Version: 1.5.0
     8Version: 1.6.0
    99Author URI: http://www.kaiarmstrong.com
    1010*/
     
    2121    add_option('toz_rk_post_options_duration', '');
    2222    add_option('toz_rk_post_options_speed', '');
     23    add_option('toz_rk_post_options_pace', '');
    2324    add_option('toz_rk_post_options_calories', '');
    2425    add_option('toz_rk_post_options_heartrate', '');
     
    8081        if ( isset($_POST['toz_rk_post_options_duration']) ) { update_option('toz_rk_post_options_duration', $_POST['toz_rk_post_options_duration']); }
    8182        if ( isset($_POST['toz_rk_post_options_speed']) ) { update_option('toz_rk_post_options_speed', $_POST['toz_rk_post_options_speed']); }
     83        if ( isset($_POST['toz_rk_post_options_pace']) ) { update_option('toz_rk_post_options_pace', $_POST['toz_rk_post_options_pace']); }
    8284        if ( isset($_POST['toz_rk_post_options_calories']) ) { update_option('toz_rk_post_options_calories', $_POST['toz_rk_post_options_calories']); }
    8385        if ( isset($_POST['toz_rk_post_options_heartrate']) ) { update_option('toz_rk_post_options_heartrate', $_POST['toz_rk_post_options_heartrate']); }
     
    111113            <h3>Plugin Settings</h3>
    112114            <p><form method="post" action="">
     115           
     116                <!-- Author Options -->
    113117                <table class="form-table"><tbody>
    114118                    <tr valign="top">
     
    126130                        </td>
    127131                    </tr>
     132                </tbody></table>
     133               
     134                <!-- Units Table -->
     135                <table class="form-table"><tbody>
    128136                    <tr valign="top">
    129137                        <th scope="row"><label for="toz_rk_units">Units:</label></th>
    130                         <td>
     138                        <td width="200px">
    131139                            <input type="radio" name="toz_rk_units" value="standard" class="code" <?php if ( get_option('toz_rk_units') == 'standard' ) { echo 'checked'; } else { } ?> />
    132140                            <span class="description">Standard</span>
    133141                        </td>
    134                     </tr>
    135                     <tr valign="top">
    136                         <th scope="row"></th>
    137142                        <td>
    138143                            <input type="radio" name="toz_rk_units" value="metric" class="code" <?php if ( get_option('toz_rk_units') == 'metric' ) { echo 'checked'; } else { } ?> />
     
    140145                        </td>
    141146                    </tr>
     147                </tbody></table>
     148               
     149                <!-- Post Content Options //3 Columns -->
     150                <table class="form-table"><tbody>
    142151                    <tr valign="top">
    143152                        <th scope="row"><label for="toz_rk_post_options">Post Options:</label></th>
    144                         <td>
     153                        <td width="200px">
    145154                            <input type="checkbox" name="toz_rk_post_options_notes" value="true" class="code" <?php if ( get_option('toz_rk_post_options_notes') == true ) { echo 'checked'; } else { } ?> />
    146155                            <span class="description">Activity Notes</span>
    147156                        </td>
    148                     </tr>
    149                     <tr valign="top">
    150                         <th scope="row"></th>
    151                         <td>
     157                        <td width="200px">
    152158                            <input type="checkbox" name="toz_rk_post_options_type" value="true" class="code" <?php if ( get_option('toz_rk_post_options_type') == true ) { echo 'checked'; } else { } ?> />
    153159                            <span class="description">Activity Type</span>
    154160                        </td>
    155                     </tr>
    156                     <tr valign="top">
    157                         <th scope="row"></th>
    158161                        <td>
    159162                            <input type="checkbox" name="toz_rk_post_options_distance" value="true" class="code" <?php if ( get_option('toz_rk_post_options_distance') == true ) { echo 'checked'; } else { } ?> />
     
    167170                            <span class="description">Total Duration</span>
    168171                        </td>
    169                     </tr>
    170                     <tr valign="top">
    171                         <th scope="row"></th>
    172172                        <td>
    173173                            <input type="checkbox" name="toz_rk_post_options_speed" value="true" class="code" <?php if ( get_option('toz_rk_post_options_speed') == true ) { echo 'checked'; } else { } ?> />
    174174                            <span class="description">Average Speed</span>
    175175                        </td>
     176                        <td>
     177                            <input type="checkbox" name="toz_rk_post_options_pace" value="true" class="code" <?php if ( get_option('toz_rk_post_options_pace') == true ) { echo 'checked'; } else { } ?> />
     178                            <span class="description">Average Pace</span>
     179                        </td>
    176180                    </tr>
    177181                    <tr valign="top">
     
    181185                            <span class="description">Total Calories</span>
    182186                        </td>
    183                     </tr>
    184                     <tr valign="top">
    185                         <th scope="row"></th>
    186187                        <td>
    187188                            <input type="checkbox" name="toz_rk_post_options_heartrate" value="true" class="code" <?php if ( get_option('toz_rk_post_options_heartrate') == true ) { echo 'checked'; } else { } ?> />
    188189                            <span class="description">Heart Rate</span>
    189190                        </td>
    190                     </tr>
    191                     <tr valign="top">
    192                         <th scope="row"></th>
    193191                        <td>
    194192                            <input type="checkbox" name="toz_rk_post_options_url" value="true" class="code" <?php if ( get_option('toz_rk_post_options_url') == true ) { echo 'checked'; } else { } ?> />
     
    204202                    </tr>
    205203                </tbody></table>
     204               
    206205                <input type="hidden" name="action" value="toz_rk_update_options" />
    207206                <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
     
    367366
    368367function toz_rk_post( $rkActivity_detailed_array ) {
     368
    369369    $publish_date = date_create_from_format('*, j M Y H:i:s', $rkActivity_detailed_array['start_time']);
    370370                   
     
    377377        'duration'  => get_option('toz_rk_post_options_duration'),
    378378        'speed'     => get_option('toz_rk_post_options_speed'),
     379        'pace'      => get_option('toz_rk_post_options_pace'),
    379380        'calories'  => get_option('toz_rk_post_options_calories'),
    380381        'heartrate' => get_option('toz_rk_post_options_heartrate'),
     
    442443               
    443444                if ( get_option('toz_rk_units') == 'standard' ) {
    444                     $dps = round($rkActivity_detailed_array['total_distance']*0.00062137, 2) / $total_seconds;
     445                    $dps = round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2) / $total_seconds;
    445446                    $sph = round($dps * 60 * 60, 2);
    446447                    $post_import_content .= '<li>Average Speed: ' . $sph . ' mph</li>';
    447448                } else if ( get_option('toz_rk_units') == 'metric' ) {
    448                     $dps = round($rkActivity_detailed_array['total_distance']/1000, 2) / $total_seconds;
     449                    $dps = round($rkActivity_detailed_array['total_distance'] / 1000, 2) / $total_seconds;
    449450                    $sph = round($dps * 60 * 60, 2);
    450451                    $post_import_content .= '<li>Average Speed: ' . $sph . ' kmh</li>';
    451452                } else {
    452                     $dps = round($rkActivity_detailed_array['total_distance']*0.00062137, 2) / $total_seconds;
     453                    $dps = round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2) / $total_seconds;
    453454                    $sph = round($dps * 60 * 60, 2);
    454455                    $post_import_content .= '<li>Average Speed: ' . $sph . ' mph</li>';
     456                }           
     457               
     458            } else {
     459                //Do Nothing
     460            }
     461        } else {
     462            //Do Nothing
     463        }
     464       
     465        if ( !empty($post_options['pace']) ) {
     466            if ( !empty($rkActivity_detailed_array['duration']) && !empty($rkActivity_detailed_array['total_distance']) ) {
     467                $hms = date('H:i:s', $rkActivity_detailed_array['duration']);
     468                list($hours, $minutes, $seconds) = explode(":",$hms);
     469                $total_seconds = $hours * 60 * 60 + $minutes * 60 + $seconds;
     470               
     471                if ( get_option('toz_rk_units') == 'standard' ) {
     472                    $pps = $total_seconds / round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2);
     473                    $ppm = date('i:s', $pps);
     474                    $post_import_content .= '<li>Average Pace: ' . $ppm . ' min/mi</li>';
     475                } else if ( get_option('toz_rk_units') == 'metric' ) {
     476                    $pps = $total_seconds / round($rkActivity_detailed_array['total_distance'] / 1000, 2);
     477                    $ppm = date('i:s', $pps);
     478                    $post_import_content .= '<li>Average Pace: ' . $ppm . ' min/km</li>';
     479                } else {
     480                    $pps = $total_seconds / round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2);
     481                    $ppm = date('i:s', $pps);
     482                    $post_import_content .= '<li>Average Pace: ' . $ppm . ' min/mi</li>';
    455483                }           
    456484               
Note: See TracChangeset for help on using the changeset viewer.