From 47a2aca3f74bbfe22b029bb450b45b8c00b56193 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 15 Aug 2014 22:25:14 +1000 Subject: [PATCH] Add highlighting option to league tables --- assets/js/admin/sportspress-admin.js | 10 ++++ .../class-sp-meta-box-table-data.php | 9 ++- templates/league-table.php | 55 +++++++++++++++++-- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index 802601b5..7bea5462 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -25,6 +25,16 @@ jQuery(document).ready(function($){ // Activate auto key placeholder $("#poststuff #title").keyup(); + // Radio input toggle + $(".sp-radio-toggle").click(function() { + if($(this).data("sp-checked")) { + $(this).attr("checked", false ); + $(this).data("sp-checked", false ); + } else { + $(this).data("sp-checked", true ); + } + }); + // Table switcher $(".sp-table-panel").siblings(".sp-table-bar").find("a").click(function() { $(this).closest("li").find("a").addClass("current").closest("li").siblings().find("a").removeClass("current").closest(".sp-table-bar").siblings($(this).attr("href")).show().siblings(".sp-table-panel").hide(); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php index 446b4f40..c524f64b 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-table-data.php @@ -22,13 +22,15 @@ class SP_Meta_Box_Table_Data { $table = new SP_League_Table( $post ); list( $columns, $usecolumns, $data, $placeholders, $merged ) = $table->data( true ); $adjustments = $table->adjustments; - self::table( $columns, $usecolumns, $data, $placeholders, $adjustments ); + $highlight = get_post_meta( $table->ID, 'sp_highlight', true ); + self::table( $columns, $usecolumns, $data, $placeholders, $adjustments, $highlight ); } /** * Save meta box data */ public static function save( $post_id, $post ) { + update_post_meta( $post_id, 'sp_highlight', sp_array_value( $_POST, 'sp_highlight', array() ) ); update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) ); update_post_meta( $post_id, 'sp_adjustments', sp_array_value( $_POST, 'sp_adjustments', array() ) ); update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) ); @@ -37,11 +39,12 @@ class SP_Meta_Box_Table_Data { /** * Admin edit table */ - public static function table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array() ) { + public static function table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array(), $highlight = null ) { if ( is_array( $usecolumns ) ) $usecolumns = array_filter( $usecolumns ); $show_team_logo = get_option( 'sportspress_table_show_logos', 'no' ) == 'yes' ? true : false; ?> +