From 6d40c687ea0ad24470126618b3b758d965e35f81 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Tue, 31 Dec 2013 03:52:09 +1100 Subject: [PATCH] Add settings tabs and config page --- admin/options/config.php | 175 ++++++++++++++++++ admin/options/general.php | 7 + .../options/options.php | 31 ++-- sportspress-actions.php | 15 +- sportspress.php | 2 +- 5 files changed, 213 insertions(+), 17 deletions(-) create mode 100644 admin/options/config.php create mode 100644 admin/options/general.php rename sportspress-settings.php => admin/options/options.php (78%) diff --git a/admin/options/config.php b/admin/options/config.php new file mode 100644 index 00000000..aed263d6 --- /dev/null +++ b/admin/options/config.php @@ -0,0 +1,175 @@ + 'sp_column', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $data = get_posts( $args ); +?> +

+ + + + + + + + + + + + + + + + + + + + +
post_title; ?> + ID, 'sp_equation', true ); + if ( $equation ): + echo str_replace( + array( '$', '+', '-', '*', '/' ), + array( '', '+', '−', '×', '÷' ), + $equation + ); + else: + echo '—'; + endif; + ?> + + ID, 'sp_priority', true ); + if ( $priority ): + echo $priority . ' ' . str_replace( + array( 'DESC', 'ASC' ), + array( '↓', '↑' ), + get_post_meta ( $row->ID, 'sp_order', true ) + ); + else: + echo '—'; + endif; + ?> +
+ + 'sp_statistic', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $data = get_posts( $args ); +?> +

+ + + + + + + + + + + + + + + + + + + + +
post_title; ?> + ID, 'sp_equation', true ); + if ( $equation ): + echo str_replace( + array( '$', '+', '-', '*', '/' ), + array( '', '+', '−', '×', '÷' ), + $equation + ); + else: + echo '—'; + endif; + ?> + + ID, 'sp_priority', true ); + if ( $priority ): + echo $priority . ' ' . str_replace( + array( 'DESC', 'ASC' ), + array( '↓', '↑' ), + get_post_meta ( $row->ID, 'sp_order', true ) + ); + else: + echo '—'; + endif; + ?> +
+ + 'sp_result', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $data = get_posts( $args ); +?> +

+ + + + + + + + > + + + + + + + + +
post_title; ?>
+ + 'sp_outcome', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'orderby' => 'menu_order', + 'order' => 'ASC' + ); + $data = get_posts( $args ); +?> +

+ + + + + + + + > + + + + + + + + +
post_title; ?>
\ No newline at end of file diff --git a/admin/options/general.php b/admin/options/general.php new file mode 100644 index 00000000..3df6bf58 --- /dev/null +++ b/admin/options/general.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/sportspress-settings.php b/admin/options/options.php similarity index 78% rename from sportspress-settings.php rename to admin/options/options.php index 9218d3d6..4405ca9f 100644 --- a/sportspress-settings.php +++ b/admin/options/options.php @@ -2,7 +2,7 @@ function sportspress_admin_menu() { add_options_page( - __( 'SportsPress Settings', 'sportspress' ), + __( 'SportsPress', 'sportspress' ), __( 'SportsPress', 'sportspress' ), 'manage_options', 'sportspress', @@ -13,17 +13,26 @@ function sportspress_admin_menu() { add_action( 'admin_menu', 'sportspress_admin_menu' ); function sportspress_settings() { + + $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general'; + ?>
- -
-

+ +
@@ -74,7 +83,7 @@ function sportspress_validate( $input ) { function sportspress_register_settings() { register_setting( - 'sportspress', + 'sportspress_general', 'sportspress', 'sportspress_validate' ); @@ -83,14 +92,14 @@ function sportspress_register_settings() { 'general', '', '', - 'sportspress' + 'sportspress_general' ); add_settings_field( - 'sport', + 'sport', __( 'Sport', 'sportspress' ), 'sportspress_sport_callback', - 'sportspress', + 'sportspress_general', 'general' ); diff --git a/sportspress-actions.php b/sportspress-actions.php index 2bcc08e9..c3faa82f 100644 --- a/sportspress-actions.php +++ b/sportspress-actions.php @@ -55,11 +55,16 @@ function sp_manage_posts_custom_column( $column, $post_id ) { echo get_post_meta ( $post_id, 'sp_team' ) ? sp_the_posts( $post_id, 'sp_team', '', '
', $result, ( empty( $result ) ? ' — ' : ' ' ) ) : '—'; break; case 'sp_equation': - echo str_replace( - array( '$', '+', '-', '*', '/' ), - array( '', '+', '−', '×', '÷' ), - get_post_meta ( $post_id, 'sp_equation', true ) - ); + $equation = get_post_meta ( $post_id, 'sp_equation', true ); + if ( $equation ): + echo str_replace( + array( '$', '+', '-', '*', '/' ), + array( '', '+', '−', '×', '÷' ), + $equation + ); + else: + echo '—'; + endif; break; case 'sp_order': $priority = get_post_meta ( $post_id, 'sp_priority', true ); diff --git a/sportspress.php b/sportspress.php index e0b1927b..f0d90cb8 100644 --- a/sportspress.php +++ b/sportspress.php @@ -31,7 +31,7 @@ include dirname( __FILE__ ) . '/sportspress-globals.php' ; require_once dirname( __FILE__ ) . '/sportspress-functions.php'; // Settings -include dirname( __FILE__ ) . '/sportspress-settings.php' ; +include dirname( __FILE__ ) . '/admin/options/options.php' ; // Custom Post Types require_once dirname( __FILE__ ) . '/admin/post-types/separator.php';