2013-02-03 20:38:55 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/Settings.class.php';
|
2013-03-31 21:28:49 -05:00
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/SOM.class.php';
|
2013-02-03 20:38:55 -06:00
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestRidesWidget.class.php';
|
2013-03-31 21:28:49 -05:00
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestMapWidget.class.php';
|
2013-02-03 20:38:55 -06:00
|
|
|
|
|
|
|
|
class WPStrava {
|
|
|
|
|
|
|
|
|
|
private static $instance = NULL;
|
2013-02-17 22:14:10 -06:00
|
|
|
private $settings = NULL;
|
2013-03-31 21:28:49 -05:00
|
|
|
private $api = NULL;
|
2013-02-03 20:38:55 -06:00
|
|
|
|
|
|
|
|
private function __construct() {
|
|
|
|
|
$this->settings = new WPStrava_Settings();
|
|
|
|
|
|
|
|
|
|
if ( is_admin() ) {
|
|
|
|
|
$this->settings->hook();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register StravaLatestRidesWidget widget
|
2013-02-17 22:14:10 -06:00
|
|
|
add_action( 'widgets_init', function() { return register_widget( 'WPStrava_LatestRidesWidget' ); } );
|
2013-03-31 21:28:49 -05:00
|
|
|
add_action( 'widgets_init', function() { return register_widget( 'WPStrava_LatestMapWidget' ); } );
|
2013-02-03 20:38:55 -06:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-17 21:19:08 -06:00
|
|
|
public static function get_instance() {
|
2013-02-03 20:38:55 -06:00
|
|
|
if ( ! self::$instance )
|
|
|
|
|
self::$instance = new WPStrava();
|
|
|
|
|
return self::$instance;
|
|
|
|
|
}
|
2013-02-17 22:14:10 -06:00
|
|
|
|
|
|
|
|
public function __get( $name ) {
|
|
|
|
|
if ( isset( $this->{$name} ) )
|
|
|
|
|
return $this->{$name};
|
|
|
|
|
|
2013-03-31 21:28:49 -05:00
|
|
|
if ( $name == 'api' )
|
|
|
|
|
return $this->get_api();
|
|
|
|
|
|
2013-02-17 22:14:10 -06:00
|
|
|
return NULL;
|
|
|
|
|
}
|
2013-03-31 21:28:49 -05:00
|
|
|
|
|
|
|
|
public function get_api() {
|
|
|
|
|
if ( ! $this->api ) {
|
|
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/API.class.php';
|
|
|
|
|
$this->api = new WPStrava_API();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->api;
|
|
|
|
|
}
|
2013-02-03 20:38:55 -06:00
|
|
|
}
|