mirror of
https://github.com/10h30/wp-strava.git
synced 2026-06-05 15:10:01 +09:00
414e2648bb
Added SOM classes for English & Metric Use WP HTTP API for requests
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/Settings.class.php';
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/SOM.class.php';
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestRidesWidget.class.php';
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/LatestMapWidget.class.php';
|
|
|
|
class WPStrava {
|
|
|
|
private static $instance = NULL;
|
|
private $settings = NULL;
|
|
private $api = NULL;
|
|
|
|
private function __construct() {
|
|
$this->settings = new WPStrava_Settings();
|
|
|
|
if ( is_admin() ) {
|
|
$this->settings->hook();
|
|
}
|
|
|
|
// Register StravaLatestRidesWidget widget
|
|
add_action( 'widgets_init', function() { return register_widget( 'WPStrava_LatestRidesWidget' ); } );
|
|
add_action( 'widgets_init', function() { return register_widget( 'WPStrava_LatestMapWidget' ); } );
|
|
|
|
}
|
|
|
|
public static function get_instance() {
|
|
if ( ! self::$instance )
|
|
self::$instance = new WPStrava();
|
|
return self::$instance;
|
|
}
|
|
|
|
public function __get( $name ) {
|
|
if ( isset( $this->{$name} ) )
|
|
return $this->{$name};
|
|
|
|
if ( $name == 'api' )
|
|
return $this->get_api();
|
|
|
|
return NULL;
|
|
}
|
|
|
|
public function get_api() {
|
|
if ( ! $this->api ) {
|
|
require_once WPSTRAVA_PLUGIN_DIR . 'lib/API.class.php';
|
|
$this->api = new WPStrava_API();
|
|
}
|
|
|
|
return $this->api;
|
|
}
|
|
} |