Table of Contents
- What It Is
- CycloPress API
- Notes and To Do List
What It Is
CycloPress is a WordPress Plugin for cyclists designed by Andrew M. Whalen. It allows you to track your statistics from each ride you take. After each ride you can copy down the data from your cyclocomputer and enter it into CycloPress. Graphs and a summary of your statistics will be generated. See my cycling page for an example of what this plugin can do.
- Graph of average speed.
- Graph of distance.
- The CycloPress Options page.
- Statistics output of CycloPress.
- The “Add a Ride” page.
- PHP version 4.3.1 or higher.
- GD library version 1 or 2.
- WordPress version 2.5 or higher. Older versions may work, but don’t count on it.
- Unzip and upload the cyclopress folder to the /wp-content/plugins/ directory.
- Activate the plugin through the Plugins menu in WordPress.
- Make the /wp-content/plugins/cyclopress/graphs/ directory writable by your web server by setting the correct permissions, e.g.
chmod 775 graphs. Some server setups may not require this step. Check the CycloPress options page first to see if the graphs directory is writable.
- Add your cycling stats through the Write -> Ride interface.
- Add the CycloPress widget to your sidebar, and create a cycling stats page through the CycloPress admin.
- Manage/edit your cycling stats through the Manage -> Rides interface.
If you know what you’re doing, these are the function calls that you can insert into your WordPress templates. If you also use a plugin for WordPress that allows PHP in posts and pages, you can paste these there as well.
cy_get_brief_stats($before='<p>', $separator=', ', $after='</p>')
- Returns your total miles traveled and average speed wrapped in a paragraph tag. Returns `false` if no data is available. This is how the widget data is generated. This works best in a sidebar, since it’s just a teaser of all the information available.
cy_get_summary( [ bool $compare=false, string $year=false ] )
- Returns a summary of your lifetime stats as an XHTML definition list (
falseif no data is available. The parameter
$comparetakes a boolean (true or false) and will add text that compares your lifetime statistics to how you’ve done so far this year. The parameter
$yeartakes a 4-digit year and will give you statistics on that year instead of your lifetime statistics.
cy_get_first_ride_date($format='F jS, Y')
- Returns the date of the least recent ride (e.g. the first ride) in the database. If the earliest date you entered stats for was June 16, 1999, then this would return
June 16, 1999. You can use this to do something like ‘These stats have been tracked since June 16, 1999.’ To change the format, see PHP’s date format codes.
cy_get_last_ride_date($format='F jS, Y')
- Returns the date of the most recent ride in the database. If the most recent date you entered stats for was August 12, 2008, then this would return
August 12, 2008. You can use this to do something like ‘The last ride was on August 12, 1999.’ To change the format, see PHP’s date format codes.
cy_get_graph_img_tag( $type='distance' )
- The parameter
average_speed. This returns a complete XHTML image tag for either a distance graph or an average speed graph. Set the width, height, and other parameters for these graphs in the CycloPress Options page found under the Plugins tab.
Notes and To Do List
- As of version 1.3.9 CycloPress is getting very bulky (around 3000 lines). It’s in desperate need of a good rewrite before I add some features (like i18n).
- Although CycloPress tracks many stats, most of them can’t yet be graphed.
- A ‘type’ of ride would be nice. Personally, I only track rides for ‘training’, but I don’t track ‘fun’ rides at all. I’ll add a way (maybe just tags?) to differentiate between these types so they can be graphed separately.
- User-controllable graphs. The graphs that are produced now are simple and only track distance and average speed over time. I want to add an interface to produce graphs ‘on the fly’ with parameters the user chooses.
- Translations into other languages will probably not happen for quite some time. I’ll need to rewrite a lot of the code for internationalization (i18n).
The WordPress upgrade.php file throws a few errors now when CycloPress is installed or upgraded. It looks like the WP SQL dbDelta function may be to blame again.– Fixed in version 1.4.3 More statistics data. I only have a simple cyclocomputer, so I need to find out first what kinds of data the more complex computers actually track.– Added in version 1.3.9 Ride more than one bike? I’ll find a nice way to track what bike(s) you ride.– Added in version 1.3.9 If you want a Cycling page, there is no way to do this without modifying your templates and/or adding a plugin to parse PHP in your pages. I want to find a nice way of making this automatic.– Added in version 1.3.6 Currently there is no way to edit previously entered statistics. This will be in a future version.– Added in version 1.2.8 An option to enter statistics in other units (such as kilometers) will be added in a future version.– Added in version 1.2.8
1.5.1 – January 4, 2010
- Fixed some display errors resulting from having no data in the new year.
1.5.0 – December 2, 2009
- Updated the highest compatible version to WordPress 2.9.
1.4.9 – August 18, 2009
- Updated the readme file.
1.4.8 – August 18, 2009
- Updated to use get_option(‘siteurl’) instead of get_bloginfo(‘url’). This should make it so that graphs show up even if WP’s home page is outside of the wordpress code directory.
1.4.7 – August 18, 2009
- A couple places were missing the code to convert miles to kilometers if the user had that option set.
1.4.6 – July 23, 2009
- Fixes a few places where times were showing incorrectly.
1.4.5 – July 20, 2009
- Updates the compatible version to 2.8.2.
1.4.4 – July 20, 2009
- Fixes the error “Only variables can be passed by reference” on like 1948.
1.4.3 – June 7, 2009
- Fixes a problem with calling the WordPress upgrade.php file, specifically the dbDelta() function. This was giving warnings to users when they upgraded or installed CycloPress.
- This update also makes CycloPress ready for WP 2.8 which will be released June 10th.
1.4.2 – May 17, 2009
- There was something going wrong with the cy_bikes SQL so the table wasn’t being created when CycloPress was installed/upgraded. I removed the ‘default’ field as I wasn’t using it, and it all works now.
1.4.1 – May 16, 2009
- Added additional stats to the calendar view
- Added title tags to the calendar view links so you can hover and get a quick glimpse of a ride (I may add more robust hover information in the future)
- Made the time formats more consistent (i.e. “1 hour, 36 minutes” instead of “1.6 hours”)
1.4.0 – May 8, 2009
- Nothing new. I just messed up the wordpress svn stuff again.
1.3.9 – May 7, 2009
- Added a way to track which bike you used on a given ride.
- Added a calendar view so you can see your stats by month.
- Added a bunch of new fields to the database like heart rate, elevation, calories, and weight.
- Organized the admin navigation.
1.3.8 – January 31, 2009
- Fixed a problem with the WordPress function dbDelta that resulted from the way I wrote SQL. Specifically I had back-ticks around the table names, and dbDelta wouldn’t recognize those table names so it could apply any schema changes I made.
1.3.7 – January 31, 2009
- Fixed a bug that wouldn’t allow rides to be saved.
1.3.6 – January 26, 2009
- You can now create a cycling stats page without a third-party PHP plugin.
- Export your stats in XML and CSV format.
1.3.5 – December 12, 2008
- WordPress 2.7 changed the admin navigation up a little, so the Add a Ride and Manage Rides pages were showing up at the same time. They were separated once again.
- The table column header links in Manage Rides were showing up too light in the 2.7 admin theme. They were made darker.
1.3.4 – December 8, 2008
- Graphs were being created any time a CycloPress function was called. That’s a bad thing. It’s been fixed. Thanks, Dave.
1.3.3 – September 14, 2008
- Changed the way the stats display in the admin stats page.
1.3.2 – September 12, 2008
- Added a stats page to the admin interface.
1.3.1 – September 10, 2008
- Added an admin nav bar to easily switch between CycloPress pages.
- Made the debug page nicer.
- ‘Editors’ were given permissions to add and edit rides.
- Sort-by-column for the management page.
- Various bugs were fixed.
1.3.0 – September 8, 2008
- Fixed a bug with the new CYRide PHP object where it wasn’t being instantiated before use in certain cases.
1.2.9 – September 3, 2008
- No changes. The 1.2.9 tag was added to make the WordPress Plugin repository host the most current version.
1.2.8 – August 26, 2008
- Added ability to manage/edit previous rides.
- Added option to change units between miles/kilometers.
1.2.7 – August 14, 2008
- Now checks the PHP version (4 or 5) to see what version of JPGraph to use.
- A simple sidebar widget is now also included.
1.2.6 – August 13, 2008
- Added code for a sidebar widget, but didn’t make it functional.
1.2.5 – August 10, 2008
- Fixed tiny bug in displaying CycloPress version.
1.2.4 – August 10, 2008
- Fix the problem where ‘upgrade automatically’ doesn’t call cy_install, so the graphs get deleted but never rewritten.
1.2.3 – August 8, 2008
- Removed the final remnants of php short tags (<?= ?>).
- Added conversion functions for miles to kilometers and back and an option to set what distance unit to use, although these new functions and option are not in use yet.
1.2.2 – August 6, 2008
- Readme cleanup.
1.2.1 – July 9, 2008
- Added a file to the graphs directory so that directory is present in the CycloPress ZIP download.
- The readme file was cleaned a little as well.
1.2 – July 1, 2008
- Readme cleanup.
1.1 – July 1, 2008
- Readme cleanup.
1.0.1 – July 1, 2008
- Readme cleanup.
1.0 – July 1, 2008
- First version of CycloPress.