Changeset 837766
- Timestamp:
- 01/13/2014 04:53:56 PM (12 years ago)
- Location:
- runkeeper-activity-feed/trunk
- Files:
-
- 1 deleted
- 2 edited
-
assets-wp-repo (deleted)
-
readme.txt (modified) (1 diff)
-
runkeeper-wordpress-activity-feed.php (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
runkeeper-activity-feed/trunk/readme.txt
r819400 r837766 2 2 Contributors: phikai 3 3 Donate link: http://runkeeper.thinkonezero.com 4 Tags: runkeeper, widget, 4 Tags: runkeeper, widget, 5 5 Requires at least: 3.5 6 Tested up to: 3.8 -RC27 Stable tag: 1.7. 06 Tested up to: 3.8 7 Stable tag: 1.7.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
runkeeper-activity-feed/trunk/runkeeper-wordpress-activity-feed.php
r784096 r837766 6 6 Description: A plugin to automatically draft posts of all your Runkeeper Activities. 7 7 Author: A. Kai Armstrong 8 Version: 1.7. 08 Version: 1.7.1 9 9 Author URI: http://www.kaiarmstrong.com 10 10 */ … … 59 59 exit(); 60 60 } 61 61 62 62 /* Stores the access values we'll need after we've authorized our account. */ 63 63 if ( isset($_GET['code']) && isset($_GET['access_token']) ) { … … 65 65 update_option('toz_rk_access_token', $_GET['access_token']); 66 66 } 67 67 68 68 //Set the Acess Token for API Use 69 69 $toz_rk_auth_code = get_option( 'toz_rk_auth_code' ); … … 71 71 $toz_rkAPI->setRunkeeperToken( get_option( 'toz_rk_access_token' ) ); 72 72 } 73 73 74 74 //Update Plugin Options 75 75 if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_update_options' )){ … … 96 96 //Do Nothing 97 97 } 98 98 99 99 ?> 100 100 <div class="wrap"> … … 113 113 <h3>Plugin Settings</h3> 114 114 <p><form method="post" action=""> 115 115 116 116 <!-- Author Options --> 117 117 <table class="form-table"><tbody> … … 135 135 </tr> 136 136 </tbody></table> 137 137 138 138 <!-- Units Table --> 139 139 <table class="form-table"><tbody> … … 150 150 </tr> 151 151 </tbody></table> 152 152 153 153 <!-- Post Content Options //3 Columns --> 154 154 <table class="form-table"><tbody> … … 206 206 </tr> 207 207 </tbody></table> 208 208 209 209 <input type="hidden" name="action" value="toz_rk_update_options" /> 210 210 <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p> 211 211 </form></p> 212 212 <p><form method="post" action=""> 213 <p>Reset (so you can authorize again): 213 <p>Reset (so you can authorize again): 214 214 <input type="hidden" name="action" value="toz_rk_reset_options" /> 215 215 <input type="submit" class="button-primary" value="<?php _e('Reset Options') ?>" /></p> … … 224 224 <hr /> 225 225 <p><form method="post" action=""> 226 <p>Import all (1000) of your previous activities: 226 <p>Import all (1000) of your previous activities: 227 227 <input type="hidden" name="action" value="toz_rk_import_old" /> 228 228 <input type="submit" class="button-primary" value="<?php _e('Import') ?>" /></p> … … 231 231 <?php if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_import_old' )) { ?> 232 232 <h3>Historical Import</h3> 233 <?php toz_rk_import_old(); 233 <?php toz_rk_import_old(); 234 234 } else if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_import_single' )) { ?> 235 235 <h3>Single Activity Import</h3> … … 278 278 foreach ($rkActivitiesFeedImport_array['items'] as $rkActivitiesItem) { 279 279 $rkActivity_uri = $rkActivitiesItem->uri; 280 280 281 281 $rkActivity_id = explode('/', $rkActivity_uri); 282 282 $rkActivity_id = $rkActivity_id[2]; 283 283 284 284 if ( intval($rkActivity_id) > intval(get_option('toz_rk_last_event')) ) { 285 285 $rkActivity_detailed = $toz_schedule_rkAPI->doRunkeeperRequest('FitnessActivity','Read', '', $rkActivity_uri); … … 287 287 288 288 toz_rk_post($rkActivity_detailed_array); 289 289 290 290 update_option('toz_rk_last_event', $rkActivity_id); 291 291 292 292 } else { 293 293 update_option('toz_rk_schedule_result', 'failure: '.time()); 294 294 } 295 295 296 296 } 297 297 } else { … … 315 315 $toz_import_single_rkAPI->setRunkeeperToken( get_option( 'toz_rk_access_token' ) ); 316 316 } 317 317 318 318 if ( !empty($rkActivity_id) ) { 319 319 320 320 $rkActivity_uri = '/fitnessActivities/' . $rkActivity_id; 321 321 … … 323 323 $rkActivity_detailed_array = (array) $rkActivity_detailed; 324 324 325 toz_rk_post($rkActivity_detailed_array); 326 325 toz_rk_post($rkActivity_detailed_array); 326 327 327 } else { 328 328 echo $toz_import_single_rkAPI->api_last_error; … … 359 359 360 360 toz_rk_post($rkActivity_detailed_array); 361 362 toz_rk_import_progress($rkActivity_uri); 363 361 362 toz_rk_import_progress($rkActivity_uri); 363 364 364 } 365 365 } else { … … 372 372 373 373 $publish_date = date_create_from_format('*, j M Y H:i:s', $rkActivity_detailed_array['start_time']); 374 374 375 375 $post_import_content = ''; 376 376 377 377 //Get all the Post Options and build the post_content 378 378 $post_options = array ( … … 387 387 'time' => get_option('toz_rk_post_options_time') 388 388 ); 389 389 390 390 $post_options_notes = get_option('toz_rk_post_options_notes'); 391 391 392 392 if ( !empty($post_options_notes) ) { 393 393 if ( !empty($rkActivity_detailed_array['notes']) ) { … … 399 399 //Do Nothing 400 400 } 401 401 402 402 if ( !empty($post_options) ) { 403 403 404 404 $post_import_content .= '<ul>'; 405 405 406 406 if ( !empty($post_options['type']) ) { 407 407 if ( !empty($rkActivity_detailed_array['type']) ) { … … 413 413 //Do Nothing 414 414 } 415 415 416 416 if ( !empty($post_options['distance']) ) { 417 417 if ( !empty($rkActivity_detailed_array['total_distance']) ) { … … 429 429 //Do Nothing 430 430 } 431 431 432 432 if ( !empty($post_options['duration']) ) { 433 433 if ( !empty($rkActivity_detailed_array['duration']) ) { … … 439 439 //Do Nothing 440 440 } 441 441 442 442 if ( !empty($post_options['speed']) ) { 443 443 if ( !empty($rkActivity_detailed_array['duration']) && !empty($rkActivity_detailed_array['total_distance']) ) { … … 445 445 list($hours, $minutes, $seconds) = explode(":",$hms); 446 446 $total_seconds = $hours * 60 * 60 + $minutes * 60 + $seconds; 447 447 448 448 if ( get_option('toz_rk_units') == 'standard' ) { 449 449 $dps = round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2) / $total_seconds; … … 458 458 $sph = round($dps * 60 * 60, 2); 459 459 $post_import_content .= '<li>Average Speed: ' . $sph . ' mph</li>'; 460 } 461 462 } else { 463 //Do Nothing 464 } 465 } else { 466 //Do Nothing 467 } 468 460 } 461 462 } else { 463 //Do Nothing 464 } 465 } else { 466 //Do Nothing 467 } 468 469 469 if ( !empty($post_options['pace']) ) { 470 470 if ( !empty($rkActivity_detailed_array['duration']) && !empty($rkActivity_detailed_array['total_distance']) ) { … … 472 472 list($hours, $minutes, $seconds) = explode(":",$hms); 473 473 $total_seconds = $hours * 60 * 60 + $minutes * 60 + $seconds; 474 474 475 475 if ( get_option('toz_rk_units') == 'standard' ) { 476 476 $pps = $total_seconds / round($rkActivity_detailed_array['total_distance'] * 0.00062137, 2); … … 485 485 $ppm = date('i:s', $pps); 486 486 $post_import_content .= '<li>Average Pace: ' . $ppm . ' min/mi</li>'; 487 } 488 489 } else { 490 //Do Nothing 491 } 492 } else { 493 //Do Nothing 494 } 495 487 } 488 489 } else { 490 //Do Nothing 491 } 492 } else { 493 //Do Nothing 494 } 495 496 496 if ( !empty($post_options['calories']) ) { 497 497 if ( !empty($rkActivity_detailed_array['total_calories']) ) { … … 503 503 //Do Nothing 504 504 } 505 505 506 506 if ( !empty($post_options['heartrate']) ) { 507 507 if ( !empty($rkActivity_detailed_array['average_heart_rate']) ) { … … 513 513 //Do Nothing 514 514 } 515 515 516 516 if ( !empty($post_options['url']) ) { 517 517 if ( !empty($rkActivity_detailed_array['activity']) ) { … … 523 523 //Do Nothing 524 524 } 525 525 526 526 if ( !empty($post_options['time']) ) { 527 527 if ( !empty($rkActivity_detailed_array['start_time']) ) { … … 533 533 //Do Nothing 534 534 } 535 535 536 536 $post_import_content .= '</ul>'; 537 537 538 538 } else { 539 539 //Do Nothing 540 540 } 541 541 542 542 $toz_rk_post_import = array ( 543 543 'post_title' => $rkActivity_detailed_array['type'] . ': ' . $rkActivity_detailed_array['start_time'], … … 549 549 'tags_input' => $rkActivity_detailed_array['type'] 550 550 ); 551 551 552 552 $post_id = wp_insert_post( $toz_rk_post_import ); 553 553 554 554 if (isset($rkActivity_detailed_array['images']['0'])) { 555 555 $rkActivity_detailed_array_images = (array) $rkActivity_detailed_array['images']['0']; … … 586 586 'post_status' => 'inherit' 587 587 ); 588 588 589 589 $attach_id = wp_insert_attachment( $attachment, $file, $post_id ); 590 590 require_once(ABSPATH . 'wp-admin/includes/image.php');
Note: See TracChangeset
for help on using the changeset viewer.