diff --git a/event.php b/admin/post-types/event.php similarity index 98% rename from event.php rename to admin/post-types/event.php index 472368ca..16ab2cda 100644 --- a/event.php +++ b/admin/post-types/event.php @@ -12,8 +12,9 @@ function sp_event_cpt_init() { 'supports' => array( 'title', 'author', 'comments' ), 'register_meta_box_cb' => 'sp_event_meta_init', 'rewrite' => array( 'slug' => 'event' ), - 'menu_position' => 44 + 'menu_position' => 42 ); + $args['labels']['menu_name'] = __( 'SportsPress', 'sportspress' ); register_post_type( 'sp_event', $args ); } add_action( 'init', 'sp_event_cpt_init' ); @@ -31,9 +32,9 @@ function sp_event_meta_init() { remove_meta_box( 'submitdiv', 'sp_event', 'side' ); add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' ); add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'side', 'high' ); - add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' ); - add_meta_box( 'sp_resultsdiv', __( 'Results', 'sportspress' ), 'sp_event_results_meta', 'sp_event', 'normal', 'high' ); add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sp_event_stats_meta', 'sp_event', 'normal', 'high' ); + add_meta_box( 'sp_resultsdiv', __( 'Results', 'sportspress' ), 'sp_event_results_meta', 'sp_event', 'normal', 'high' ); + add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' ); } function sp_event_team_meta( $post ) { diff --git a/list.php b/admin/post-types/list.php similarity index 100% rename from list.php rename to admin/post-types/list.php diff --git a/admin/post-types/metric.php b/admin/post-types/metric.php new file mode 100644 index 00000000..ad969bed --- /dev/null +++ b/admin/post-types/metric.php @@ -0,0 +1,24 @@ + $name, + 'labels' => $labels, + 'public' => true, + 'show_in_nav_menus' => false, + 'hierarchical' => false, + 'supports' => array( 'title', 'page-attributes' ), + 'register_meta_box_cb' => 'sp_metric_meta_init', + 'rewrite' => array( 'slug' => 'metric' ), + 'show_in_menu' => 'edit.php?post_type=sp_player' + ); + register_post_type( 'sp_metric', $args ); +} +add_action( 'init', 'sp_metric_cpt_init' ); + +function sp_metric_meta_init() { +} +?> \ No newline at end of file diff --git a/player.php b/admin/post-types/player.php similarity index 99% rename from player.php rename to admin/post-types/player.php index 49ae292b..314edb48 100644 --- a/player.php +++ b/admin/post-types/player.php @@ -12,7 +12,7 @@ function sp_player_cpt_init() { 'supports' => array( 'title', 'author', 'thumbnail' ), 'register_meta_box_cb' => 'sp_player_meta_init', 'rewrite' => array( 'slug' => 'player' ), - 'menu_position' => 45 + 'menu_position' => 44 ); register_post_type( 'sp_player', $args ); } diff --git a/staff.php b/admin/post-types/staff.php similarity index 98% rename from staff.php rename to admin/post-types/staff.php index 60e5f147..27b25de8 100644 --- a/staff.php +++ b/admin/post-types/staff.php @@ -12,7 +12,7 @@ function sp_staff_cpt_init() { 'supports' => array( 'title', 'author', 'thumbnail' ), 'register_meta_box_cb' => 'sp_staff_meta_init', 'rewrite' => array( 'slug' => 'staff' ), - 'menu_position' => 46 + 'menu_position' => 45 ); register_post_type( 'sp_staff', $args ); } diff --git a/admin/post-types/stat.php b/admin/post-types/stat.php new file mode 100644 index 00000000..fadfec98 --- /dev/null +++ b/admin/post-types/stat.php @@ -0,0 +1,100 @@ + $name, + 'labels' => $labels, + 'public' => true, + 'show_in_nav_menus' => false, + 'hierarchical' => false, + 'supports' => array( 'title', 'page-attributes' ), + 'register_meta_box_cb' => 'sp_stat_meta_init', + 'rewrite' => array( 'slug' => 'stat' ), + 'show_in_menu' => 'edit.php?post_type=sp_team' + ); + register_post_type( 'sp_stat', $args ); +} +add_action( 'init', 'sp_stat_cpt_init' ); + +function sp_stat_edit_columns() { + $columns = array( + 'cb' => '', + 'title' => __( 'Label', 'sportspress' ), + 'sp_sport' => __( 'Sport', 'sportspress' ), + 'sp_equation' => __( 'Equation', 'sportspress' ), + ); + return $columns; +} +add_filter( 'manage_edit-sp_stat_columns', 'sp_stat_edit_columns' ); + +function sp_stat_meta_init() { + add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'sp_stat_equation_meta', 'sp_stat', 'normal', 'high' ); +} + +function sp_stat_equation_meta( $post ) { + $args = array( + 'post_type' => 'sp_stat', + 'numberposts' => -1, + 'posts_per_page' => -1, + 'exclude' => $post->ID + ); + $sports = get_the_terms( $post->ID, 'sp_sport' ); + if ( ! empty( $sports ) ): + $terms = array(); + foreach ( $sports as $sport ): + $terms[] = $sport->slug; + endforeach; + $args['tax_query'] = array( + array( + 'taxonomy' => 'sp_sport', + 'field' => 'slug', + 'terms' => $terms + ) + ); + endif; + $stats = get_posts( $args ); + ?> +
+ +
+| ' . __( 'Position', 'sportspress' ) . ' | '; + foreach( $stats as $stat ) { + $output .= '' . $sp_table_stats_labels[$stat] . ' | '; + } + $output .= + '
|---|---|
| ' . $club->place . ' ' . ( $club_links ? '' : '' ) . get_the_post_thumbnail( $club->ID, 'crest-small', array( 'title' => $club->post_title, 'class' => 'crest' ) ) . ' ' . $club->post_title . ( $club_links ? '' : '' ) . ' | '; + foreach( $stats as $stat ) { + $output .= '' . $club_stats[$stat] . ' | '; + } + } + $output.= + '
' . do_shortcode('[sp_table]') . '
'; + } + return $content; +} +add_filter('the_content', 'sportspress_the_content'); ?> \ No newline at end of file diff --git a/globals.php b/sportspress-globals.php similarity index 100% rename from globals.php rename to sportspress-globals.php diff --git a/helpers.php b/sportspress-helpers.php similarity index 94% rename from helpers.php rename to sportspress-helpers.php index f13060a0..55e03c3a 100644 --- a/helpers.php +++ b/sportspress-helpers.php @@ -70,7 +70,7 @@ if ( !function_exists( 'sp_cpt_labels' ) ) { $labels = array( 'name' => $name, 'singular_name' => $singular_name, - 'all_items' => $is_submenu ? $name : sprintf( __( 'All %s', 'sportspress' ), $name ), + 'all_items' => $name, 'add_new_item' => sprintf( __( 'Add New %s', 'sportspress' ), $singular_name ), 'edit_item' => sprintf( __( 'Edit %s', 'sportspress' ), $singular_name ), 'new_item' => sprintf( __( 'New %s', 'sportspress' ), $singular_name ), @@ -141,7 +141,7 @@ if ( !function_exists( 'sp_dropdown_taxonomies' ) ) { printf( '', $args['show_option_none'] ); } foreach ( $terms as $term ) { - printf( '', $term->term_id, selected( true, $args['selected'] == $term->term_id, false ), $term->name ); + printf( '', $term->slug, selected( true, $args['selected'] == $term->slug, false ), $term->name ); } print( '' ); } @@ -193,6 +193,17 @@ if ( !function_exists( 'sp_the_posts' ) ) { } } +if ( !function_exists( 'sp_the_plain_terms' ) ) { + function sp_the_plain_terms( $id, $taxonomy ) { + $terms = get_the_terms( $id, $taxonomy ); + $arr = array(); + foreach( $terms as $term ): + $arr[] = $term->name; + endforeach; + echo implode( ', ', $arr ); + } +} + if ( !function_exists( 'sp_post_checklist' ) ) { function sp_post_checklist( $post_id = null, $meta = 'post', $display = 'block', $filter = null, $index = null ) { if ( ! isset( $post_id ) ) @@ -249,7 +260,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) { if ( !function_exists( 'sp_get_eos_rows' ) ) { function sp_get_eos_rows( $raw ) { $raw = str_replace( array( "\r\n", ' ' ), array( "\n", '' ), $raw ); - $output = explode( "\r\n", $raw ); + $output = explode( "\n", $raw ); return $output; } } @@ -257,7 +268,7 @@ if ( !function_exists( 'sp_get_eos_rows' ) ) { if ( !function_exists( 'sp_get_eos_keys' ) ) { function sp_get_eos_keys( $raw ) { $raw = str_replace( array( "\r\n", ' :' ), array( "\n", ':' ), $raw ); - $arr = explode( "\r\n", $raw ); + $arr = explode( "\n", $raw ); $output = array(); foreach ( $arr as $value ): $output[] = substr( $value, 0, strpos( $value, ':') ); @@ -288,7 +299,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) { case 'sp_team': // Get stats settings columns - $columns = sp_get_eos_rows( $stats_settings['event'] ); + $columns = sp_get_eos_rows( get_option( 'sp_event_stats_columns' ) ); // Setup variables $results = array(); @@ -334,14 +345,14 @@ if ( !function_exists( 'sp_get_stats_row' ) ) { $vars['against'] = 0; foreach( $posts as $post ): $result = $post->sp_result; unset( $result[ $post->sp_team_index ] ); $vars['against'] += array_sum( $result ); endforeach; // Get EOS array - $rows = sp_get_eos_rows( $stats_settings['team'] ); + $rows = sp_get_eos_rows( get_option( 'sp_team_stats_columns' ) ); break; case 'sp_player': // Get stats settings keys - $keys = sp_get_eos_keys( $stats_settings['player'] ); + $keys = sp_get_eos_keys( get_option( 'sp_player_stats_columns' ) ); // Add object properties needed for retreiving event stats foreach( $posts as $post ): @@ -548,6 +559,16 @@ if ( !function_exists( 'sportspress_render_option_field' ) ) { case 'checkbox': echo ''; break; + case 'sport': + $terms = get_terms( 'sp_sport' ); + if ( $terms ) { + printf( '' ); + } + break; default: echo ''; break; diff --git a/hooks.php b/sportspress-hooks.php similarity index 100% rename from hooks.php rename to sportspress-hooks.php diff --git a/settings.php b/sportspress-settings.php similarity index 88% rename from settings.php rename to sportspress-settings.php index 62a04e73..47f462a3 100644 --- a/settings.php +++ b/sportspress-settings.php @@ -1,9 +1,10 @@ \ No newline at end of file diff --git a/styles.php b/styles.php deleted file mode 100644 index c5a00fa9..00000000 --- a/styles.php +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file