From 165c4d80ecb12a4b43777489db20bc3accaba7f8 Mon Sep 17 00:00:00 2001 From: ThemeBoy Date: Wed, 4 Dec 2013 14:47:10 +1100 Subject: [PATCH] Install defaults once --- sportspress-defaults.php | 56 ++++++++++++++++++++++++++++++++++++++++ sportspress.php | 3 +++ 2 files changed, 59 insertions(+) create mode 100644 sportspress-defaults.php diff --git a/sportspress-defaults.php b/sportspress-defaults.php new file mode 100644 index 00000000..8dc06e1b --- /dev/null +++ b/sportspress-defaults.php @@ -0,0 +1,56 @@ + 'Goals', 'post_name' => 'goals', 'post_status' => 'publish', 'post_type' => 'sp_result' ), + array( 'post_title' => '1st Half', 'post_name' => 'firsthalf', 'post_status' => 'publish', 'post_type' => 'sp_result' ), + array( 'post_title' => '2nd Half', 'post_name' => 'secondhalf', 'post_status' => 'publish', 'post_type' => 'sp_result' ), + + // Outcomes + array( 'post_title' => 'Win', 'post_name' => 'win', 'post_status' => 'publish', 'post_type' => 'sp_outcome' ), + array( 'post_title' => 'Draw', 'post_name' => 'draw', 'post_status' => 'publish', 'post_type' => 'sp_outcome' ), + array( 'post_title' => 'Loss', 'post_name' => 'loss', 'post_status' => 'publish', 'post_type' => 'sp_outcome' ), + + // Statistics + array( 'post_title' => 'P', 'post_name' => 'p', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$eventsplayed' ) ), + array( 'post_title' => 'W', 'post_name' => 'w', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$win' ) ), + array( 'post_title' => 'D', 'post_name' => 'd', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$draw' ) ), + array( 'post_title' => 'L', 'post_name' => 'l', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$loss' ) ), + array( 'post_title' => 'F', 'post_name' => 'f', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsfor', 'sp_priority' => '3', 'sp_order' => 'DESC' ) ), + array( 'post_title' => 'A', 'post_name' => 'a', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsagainst' ) ), + array( 'post_title' => 'GD', 'post_name' => 'gd', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$goalsfor - $goalsagainst', 'sp_priority' => '2', 'sp_order' => 'DESC' ) ), + array( 'post_title' => 'PTS', 'post_name' => 'pts', 'post_status' => 'publish', 'post_type' => 'sp_stat', 'meta' => array( 'sp_equation' => '$win x 3 + $draw', 'sp_priority' => '1', 'sp_order' => 'DESC' ) ), + + // Metrics + array( 'post_title' => 'Appearances', 'post_name' => 'appearances', 'post_status' => 'publish', 'post_type' => 'sp_metric', 'meta' => array( 'sp_equation' => '$eventsplayed' ) ), + array( 'post_title' => 'Goals', 'post_name' => 'goals', 'post_status' => 'publish', 'post_type' => 'sp_metric' ), + array( 'post_title' => 'Assists', 'post_name' => 'assists', 'post_status' => 'publish', 'post_type' => 'sp_metric' ), + array( 'post_title' => 'Yellow Cards', 'post_name' => 'yellowcards', 'post_status' => 'publish', 'post_type' => 'sp_metric' ), + array( 'post_title' => 'Red Cards', 'post_name' => 'redcards', 'post_status' => 'publish', 'post_type' => 'sp_metric' ) + ); + + $i = 1; + foreach( $pages as $args ): + if ( ! get_page_by_path( $args['post_name'], OBJECT, $args['post_type'] ) ): + $args['menu_order'] = $i; + $id = wp_insert_post( $args ); + if ( array_key_exists( 'meta', $args ) ): + foreach ( $args['meta'] as $key => $value ): + update_post_meta( $id, $key, $value ); + endforeach; + endif; + $i++; + endif; + endforeach; + + update_option( 'sportspress_installed', 1 ); + endif; + } +} +sp_install_defaults(); +?> \ No newline at end of file diff --git a/sportspress.php b/sportspress.php index 9e5646bb..73870da0 100644 --- a/sportspress.php +++ b/sportspress.php @@ -52,6 +52,9 @@ require_once dirname( __FILE__ ) . '/admin/terms/pos.php'; // Shortcodes // require_once dirname( __FILE__ ) . '/classes/shortcodes/table.php'; +// Defaults +include dirname( __FILE__ ) . '/sportspress-defaults.php'; + // Hooks, Actions, and Filters require_once dirname( __FILE__ ) . '/sportspress-hooks.php'; require_once dirname( __FILE__ ) . '/sportspress-actions.php';