From 6db3e82d6689da4d7f3a257cd37053d7699c9237 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 25 Mar 2014 00:19:34 +1100 Subject: [PATCH] Define main SportsPress class --- admin/hooks/admin-enqueue-scripts.php | 20 +- admin/hooks/admin-print-styles.php | 4 +- admin/hooks/current-screen.php | 2 +- admin/hooks/plugin-action-links.php | 2 +- admin/hooks/plugins-loaded.php | 2 +- admin/hooks/register-activation-hook.php | 2 +- admin/hooks/save-post.php | 2 +- admin/hooks/wp-enqueue-scripts.php | 8 +- admin/includes/globals.php | 30 +- admin/templates/player-metrics.php | 2 +- admin/tools/event-importer.php | 2 +- admin/tools/importers.php | 6 +- admin/tools/player-importer.php | 2 +- admin/tools/team-importer.php | 2 +- functions.php | 2 +- sportspress.php | 437 ++++++++++++++++------- 16 files changed, 357 insertions(+), 168 deletions(-) diff --git a/admin/hooks/admin-enqueue-scripts.php b/admin/hooks/admin-enqueue-scripts.php index 9664fdf1..e2f7268d 100644 --- a/admin/hooks/admin-enqueue-scripts.php +++ b/admin/hooks/admin-enqueue-scripts.php @@ -1,26 +1,26 @@ __( 'None', 'sportspress' ), 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) ); diff --git a/admin/hooks/admin-print-styles.php b/admin/hooks/admin-print-styles.php index 250d688e..5fdd646e 100644 --- a/admin/hooks/admin-print-styles.php +++ b/admin/hooks/admin-print-styles.php @@ -34,7 +34,7 @@ add_action( 'admin_print_styles', 'sportspress_admin_notices_styles' ); * @return void */ function sportspress_admin_install_notices() { -// include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-install.php' ); +// include( dirname( SP_PLUGIN_FILE ) . '/admin/includes/notice-install.php' ); } /** @@ -44,5 +44,5 @@ function sportspress_admin_install_notices() { * @return void */ function sportspress_theme_check_notice() { -// include( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' ); +// include( dirname( SP_PLUGIN_FILE ) . '/admin/includes/notice-theme-support.php' ); } diff --git a/admin/hooks/current-screen.php b/admin/hooks/current-screen.php index a703d512..aa3a64e1 100644 --- a/admin/hooks/current-screen.php +++ b/admin/hooks/current-screen.php @@ -2,6 +2,6 @@ function sportspress_current_screen() { $screen = get_current_screen(); if ( $screen->id == 'dashboard' ) - include_once( dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/dashboard.php' ); + include_once( dirname( SP_PLUGIN_FILE ) . '/admin/tools/dashboard.php' ); } add_action( 'current_screen', 'sportspress_current_screen' ); diff --git a/admin/hooks/plugin-action-links.php b/admin/hooks/plugin-action-links.php index 767097ce..774a97e6 100644 --- a/admin/hooks/plugin-action-links.php +++ b/admin/hooks/plugin-action-links.php @@ -9,5 +9,5 @@ function sportspress_plugin_action_links( $links ) { return $links; } -$plugin = SPORTSPRESS_PLUGIN_BASENAME; +$plugin = plugin_basename( SP_PLUGIN_FILE ); add_filter( "plugin_action_links_$plugin", 'sportspress_plugin_action_links' ); diff --git a/admin/hooks/plugins-loaded.php b/admin/hooks/plugins-loaded.php index c3376089..75d6cd4c 100644 --- a/admin/hooks/plugins-loaded.php +++ b/admin/hooks/plugins-loaded.php @@ -3,7 +3,7 @@ function sportspress_plugins_loaded() { // Load plugin textdomain if ( function_exists( 'load_plugin_textdomain' ) ) { - load_plugin_textdomain ( 'sportspress', false, dirname( SPORTSPRESS_PLUGIN_BASENAME ) . '/languages/' ); + load_plugin_textdomain ( 'sportspress', false, dirname( plugin_basename( SP_PLUGIN_FILE ) ) . '/languages/' ); } // Add image sizes diff --git a/admin/hooks/register-activation-hook.php b/admin/hooks/register-activation-hook.php index e1b8cdf6..3916c483 100644 --- a/admin/hooks/register-activation-hook.php +++ b/admin/hooks/register-activation-hook.php @@ -162,4 +162,4 @@ function sportspress_activation_hook() { sportspress_flush_rewrite_rules(); } -register_activation_hook( SPORTSPRESS_PLUGIN_FILE, 'sportspress_activation_hook' ); +register_activation_hook( SP_PLUGIN_FILE, 'sportspress_activation_hook' ); diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php index 53ff0c5a..b3f3eb84 100644 --- a/admin/hooks/save-post.php +++ b/admin/hooks/save-post.php @@ -3,7 +3,7 @@ function sportspress_save_post( $post_id ) { global $post, $typenow; if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; - if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], SPORTSPRESS_PLUGIN_BASENAME ) ) return $post_id; + if ( !isset( $_POST['sportspress_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_nonce'], plugin_basename( SP_PLUGIN_FILE ) ) ) return $post_id; switch ( $_POST['post_type'] ): case ( 'sp_team' ): diff --git a/admin/hooks/wp-enqueue-scripts.php b/admin/hooks/wp-enqueue-scripts.php index c508b779..c10a23a6 100644 --- a/admin/hooks/wp-enqueue-scripts.php +++ b/admin/hooks/wp-enqueue-scripts.php @@ -1,14 +1,14 @@ __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) ); diff --git a/admin/includes/globals.php b/admin/includes/globals.php index 80fe65b5..5ec2c552 100644 --- a/admin/includes/globals.php +++ b/admin/includes/globals.php @@ -282,21 +282,21 @@ function sportspress_define_globals() { // Sports global $sportspress_sports; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/soccer.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/football.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/footy.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/baseball.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/basketball.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/gaming.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/cricket.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/golf.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/handball.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/hockey.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/racing.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/rugby.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/swimming.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/tennis.php'; - include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/presets/sports/volleyball.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/soccer.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/football.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/footy.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/baseball.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/basketball.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/gaming.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/cricket.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/golf.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/handball.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/hockey.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/racing.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/rugby.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/swimming.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/tennis.php'; + include_once dirname( SP_PLUGIN_FILE ) . '/presets/sports/volleyball.php'; uasort( $sportspress_sports, 'sportspress_sort_sports' ); } diff --git a/admin/templates/player-metrics.php b/admin/templates/player-metrics.php index afdd6259..0731f3ea 100644 --- a/admin/templates/player-metrics.php +++ b/admin/templates/player-metrics.php @@ -23,7 +23,7 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) { $common = array(); if ( $nationality ): $country_name = sportspress_array_value( $sportspress_countries, $nationality, null ); - $common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $r['show_nationality_flag'] ? '' . $nationality . ' ' : '' ) . $country_name : '—'; + $common[ __( 'Nationality', 'sportspress' ) ] = $country_name ? ( $r['show_nationality_flag'] ? '' . $nationality . ' ' : '' ) . $country_name : '—'; endif; $data = array_merge( $common, $metrics ); diff --git a/admin/tools/event-importer.php b/admin/tools/event-importer.php index 1486d7df..d7021c27 100644 --- a/admin/tools/event-importer.php +++ b/admin/tools/event-importer.php @@ -518,7 +518,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; - echo '

' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). Click here to download a sample.', 'sportspress' ), SPORTSPRESS_PLUGIN_URL . 'dummy-data/events-sample.csv' ) . '

'; + echo '

' . sprintf( __( 'Events need to be defined with columns in a specific order (3+ columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/events-sample.csv' ) . '

'; $action = 'admin.php?import=sportspress_event_csv&step=1'; diff --git a/admin/tools/importers.php b/admin/tools/importers.php index ce03d007..c834db2c 100644 --- a/admin/tools/importers.php +++ b/admin/tools/importers.php @@ -9,7 +9,7 @@ function sportspress_event_importer() { } // includes - require dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/event-importer.php'; + require dirname( SP_PLUGIN_FILE ) . '/admin/tools/event-importer.php'; // Dispatch $importer = new SP_Event_Importer(); @@ -26,7 +26,7 @@ function sportspress_team_importer() { } // includes - require dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/team-importer.php'; + require dirname( SP_PLUGIN_FILE ) . '/admin/tools/team-importer.php'; // Dispatch $importer = new SP_Team_Importer(); @@ -43,7 +43,7 @@ function sportspress_player_importer() { } // includes - require dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/tools/player-importer.php'; + require dirname( SP_PLUGIN_FILE ) . '/admin/tools/player-importer.php'; // Dispatch $importer = new SP_Player_Importer(); diff --git a/admin/tools/player-importer.php b/admin/tools/player-importer.php index 09da9dfd..a485e5ed 100644 --- a/admin/tools/player-importer.php +++ b/admin/tools/player-importer.php @@ -285,7 +285,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; - echo '

' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). Click here to download a sample.', 'sportspress' ), SPORTSPRESS_PLUGIN_URL . 'dummy-data/players-sample.csv' ) . '

'; + echo '

' . sprintf( __( 'Players need to be defined with columns in a specific order (7 columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/players-sample.csv' ) . '

'; $action = 'admin.php?import=sportspress_player_csv&step=1'; diff --git a/admin/tools/team-importer.php b/admin/tools/team-importer.php index 897ee445..ffa58c17 100644 --- a/admin/tools/team-importer.php +++ b/admin/tools/team-importer.php @@ -242,7 +242,7 @@ if ( class_exists( 'WP_Importer' ) ) { echo '
'; echo '

' . __( 'Hi there! Choose a .csv file to upload, then click "Upload file and import".', 'sportspress' ).'

'; - echo '

' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). Click here to download a sample.', 'sportspress' ), SPORTSPRESS_PLUGIN_URL . 'dummy-data/teams-sample.csv' ) . '

'; + echo '

' . sprintf( __( 'Teams need to be defined with columns in a specific order (3 columns). Click here to download a sample.', 'sportspress' ), plugin_dir_url( SP_PLUGIN_FILE ) . 'dummy-data/teams-sample.csv' ) . '

'; $action = 'admin.php?import=sportspress_team_csv&step=1'; diff --git a/functions.php b/functions.php index 15b7a996..efd50645 100644 --- a/functions.php +++ b/functions.php @@ -113,7 +113,7 @@ if ( !function_exists( 'sp_flush_rewrite_rules' ) ) { if ( !function_exists( 'sp_nonce' ) ) { function sp_nonce() { - echo ''; + echo ''; } } diff --git a/sportspress.php b/sportspress.php index f1a4cacb..3b482d9d 100644 --- a/sportspress.php +++ b/sportspress.php @@ -1,132 +1,321 @@ define_constants(); + + // Include required files + $this->includes(); + + // Hooks + add_action( 'widgets_init', array( $this, 'include_widgets' ) ); + add_action( 'init', array( $this, 'init' ), 0 ); + add_action( 'after_setup_theme', array( $this, 'setup_environment' ) ); + + // Loaded action + do_action( 'sportspress_loaded' ); + } + + /** + * Define SP Constants + */ + private function define_constants() { + define( 'SP_PLUGIN_FILE', __FILE__ ); + define( 'SP_VERSION', $this->version ); + + if ( ! defined( 'SP_TEMPLATE_PATH' ) ) { + define( 'SP_TEMPLATE_PATH', $this->template_path() ); + } + + if ( ! defined( 'SP_DELIMITER' ) ) { + define( 'SP_DELIMITER', '|' ); + } + } + + /** + * Include required core files used in admin and on the frontend. + */ + private function includes() { + + // Libraries + require_once dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; + + // Globals + require_once dirname( __FILE__ ) . '/admin/includes/globals.php'; + + // Functions + require_once dirname( __FILE__ ) . '/functions.php'; + require_once dirname( __FILE__ ) . '/includes/sp-deprecated-functions.php'; + + // Templates + require_once dirname( __FILE__ ) . '/admin/templates/countdown.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-details.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-performance.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-results.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-calendar.php'; + require_once dirname( __FILE__ ) . '/admin/templates/event-list.php'; + require_once dirname( __FILE__ ) . '/admin/templates/league-table.php'; + require_once dirname( __FILE__ ) . '/admin/templates/player-league-performance.php'; + require_once dirname( __FILE__ ) . '/admin/templates/player-list.php'; + //require_once dirname( __FILE__ ) . '/admin/templates/player-roster.php'; + require_once dirname( __FILE__ ) . '/admin/templates/player-gallery.php'; + require_once dirname( __FILE__ ) . '/admin/templates/player-metrics.php'; + require_once dirname( __FILE__ ) . '/admin/templates/player-performance.php'; + require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php'; + + // Options + require_once dirname( __FILE__ ) . '/admin/settings/settings.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-general.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-event.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-team.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-player.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-text.php'; + require_once dirname( __FILE__ ) . '/admin/settings/options-permalink.php'; + + // Custom post types + require_once dirname( __FILE__ ) . '/admin/post-types/separator.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/column.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/performance.php'; + //require_once dirname( __FILE__ ) . '/admin/post-types/statistic.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/metric.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/result.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/outcome.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/event.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/calendar.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/team.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/table.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/player.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/list.php'; + require_once dirname( __FILE__ ) . '/admin/post-types/staff.php'; + //require_once dirname( __FILE__ ) . '/admin/post-types/directory.php'; + + // Terms + require_once dirname( __FILE__ ) . '/admin/terms/league.php'; + require_once dirname( __FILE__ ) . '/admin/terms/season.php'; + require_once dirname( __FILE__ ) . '/admin/terms/venue.php'; + require_once dirname( __FILE__ ) . '/admin/terms/position.php'; + + // Tools + require_once dirname( __FILE__ ) . '/admin/tools/importers.php'; + + // Typical request actions + require_once dirname( __FILE__ ) . '/admin/hooks/plugins-loaded.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/after-setup-theme.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/wp-enqueue-scripts.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/loop-start.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/the-title.php'; + + // Admin request actions + require_once dirname( __FILE__ ) . '/admin/hooks/admin-init.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/admin-menu.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/admin-enqueue-scripts.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/admin-print-styles.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/current-screen.php'; + + // Administrative actions + require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-columns.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/post-thumbnail-html.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/restrict-manage-posts.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/parse-query.php';; + require_once dirname( __FILE__ ) . '/admin/hooks/save-post.php'; + + // Filters + require_once dirname( __FILE__ ) . '/admin/hooks/admin-post-thumbnail-html.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/gettext.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/pre-get-posts.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/the-posts.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/sanitize-title.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/the-content.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/widget-text.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/wp-insert-post-data.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/plugin-action-links.php'; + require_once dirname( __FILE__ ) . '/admin/hooks/post-updated-messages.php'; + + // Register activation hook + require_once dirname( __FILE__ ) . '/admin/hooks/register-activation-hook.php'; + } + + /** + * Include required frontend files. + */ + public function frontend_includes() { + } + + /** + * Function used to Init SportsPress Template Functions - This makes them pluggable by plugins and themes. + */ + public function include_template_functions() { + } + + /** + * Include core widgets + */ + public function include_widgets() { + require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php'; + require_once dirname( __FILE__ ) . '/admin/widgets/event-calendar.php'; + require_once dirname( __FILE__ ) . '/admin/widgets/event-list.php'; + require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php'; + require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php'; + require_once dirname( __FILE__ ) . '/admin/widgets/player-gallery.php'; + } + + /** + * Init SportsPress when WordPress Initialises. + */ + public function init() { + // Before init action + do_action( 'before_sportspress_init' ); + + // Set up localisation + $this->load_plugin_textdomain(); + + // Init action + do_action( 'sportspress_init' ); + } + + /** + * Load Localisation files. + * + * Note: the first-loaded translation file overrides any following ones if the same translation is present + */ + public function load_plugin_textdomain() { + $locale = apply_filters( 'plugin_locale', get_locale(), 'sportspress' ); + + // Global + Frontend Locale + load_textdomain( 'sportspress', WP_LANG_DIR . "/sportspress/sportspress-$locale.mo" ); + load_plugin_textdomain( 'sportspress', false, plugin_basename( dirname( __FILE__ ) ) . "/languages" ); + } + + /** + * Ensure theme and server variable compatibility and setup image sizes.. + */ + public function setup_environment() { + } + + /** Helper functions ******************************************************/ + + /** + * Get the plugin url. + * + * @return string + */ + public function plugin_url() { + return untrailingslashit( plugins_url( '/', __FILE__ ) ); + } + + /** + * Get the plugin path. + * + * @return string + */ + public function plugin_path() { + return untrailingslashit( plugin_dir_path( __FILE__ ) ); + } + + /** + * Get the template path. + * + * @return string + */ + public function template_path() { + return apply_filters( 'SP_TEMPLATE_PATH', 'sportspress/' ); + } +} -// Make sure we don't expose any info if called directly -if ( !function_exists( 'add_action' ) ): - echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; - exit; endif; -define( 'SPORTSPRESS_VERSION', '0.6.2' ); -define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); -define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); +/** + * Returns the main instance of SP to prevent the need to use globals. + * + * @since 0.7 + * @return SportsPress + */ +function SP() { + return SportsPress::instance(); +} -// Libraries -require_once dirname( __FILE__ ) . '/lib/eos/eos.class.php' ; - -// Globals -require_once dirname( __FILE__ ) . '/admin/includes/globals.php'; - -// Functions -require_once dirname( __FILE__ ) . '/functions.php'; -require_once dirname( __FILE__ ) . '/includes/sp-deprecated-functions.php'; - -// Templates -require_once dirname( __FILE__ ) . '/admin/templates/countdown.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-details.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-performance.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-results.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-calendar.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-list.php'; -require_once dirname( __FILE__ ) . '/admin/templates/league-table.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-league-performance.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-list.php'; -//require_once dirname( __FILE__ ) . '/admin/templates/player-roster.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-gallery.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-metrics.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-performance.php'; -require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php'; - -// Options -require_once dirname( __FILE__ ) . '/admin/settings/settings.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-general.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-event.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-team.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-player.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-text.php'; -require_once dirname( __FILE__ ) . '/admin/settings/options-permalink.php'; - -// Custom post types -require_once dirname( __FILE__ ) . '/admin/post-types/separator.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/column.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/performance.php'; -//require_once dirname( __FILE__ ) . '/admin/post-types/statistic.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/metric.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/result.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/outcome.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/event.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/calendar.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/team.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/table.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/player.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/list.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/staff.php'; -//require_once dirname( __FILE__ ) . '/admin/post-types/directory.php'; - -// Terms -require_once dirname( __FILE__ ) . '/admin/terms/league.php'; -require_once dirname( __FILE__ ) . '/admin/terms/season.php'; -require_once dirname( __FILE__ ) . '/admin/terms/venue.php'; -require_once dirname( __FILE__ ) . '/admin/terms/position.php'; - -// Widgets -require_once dirname( __FILE__ ) . '/admin/widgets/countdown.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/event-calendar.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/event-list.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/player-list.php'; -require_once dirname( __FILE__ ) . '/admin/widgets/player-gallery.php'; - -// Tools -require_once dirname( __FILE__ ) . '/admin/tools/importers.php'; - -// Typical request actions -require_once dirname( __FILE__ ) . '/admin/hooks/plugins-loaded.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/after-setup-theme.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/wp-enqueue-scripts.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/loop-start.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/the-title.php'; - -// Admin request actions -require_once dirname( __FILE__ ) . '/admin/hooks/admin-init.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/admin-menu.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/admin-enqueue-scripts.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/admin-print-styles.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/current-screen.php'; - -// Administrative actions -require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-columns.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/post-thumbnail-html.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/restrict-manage-posts.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/parse-query.php';; -require_once dirname( __FILE__ ) . '/admin/hooks/save-post.php'; - -// Filters -require_once dirname( __FILE__ ) . '/admin/hooks/admin-post-thumbnail-html.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/gettext.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/pre-get-posts.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/the-posts.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/sanitize-title.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/the-content.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/widget-text.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/wp-insert-post-data.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/plugin-action-links.php'; -require_once dirname( __FILE__ ) . '/admin/hooks/post-updated-messages.php'; - -// Register activation hook -require_once dirname( __FILE__ ) . '/admin/hooks/register-activation-hook.php'; +SP();