Add primary performance and preset color schemes
This commit is contained in:
@@ -150,6 +150,18 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sportspress table.form-table .sp-color-option {
|
||||||
|
max-width: 225px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sportspress table.form-table .sp-color-option table {
|
||||||
|
outline: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sportspress table.form-table .sp-custom-colors {
|
||||||
|
padding: 5px 15px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.sportspress table.form-table .sp-color-box {
|
.sportspress table.form-table .sp-color-box {
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
box-shadow: 1px 1px 3px rgba(0,0,0,.2);
|
||||||
@@ -208,7 +220,8 @@ table.widefat.sp-data-table img {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.widefat.sp-data-table th.column-outcome {
|
table.widefat.sp-data-table th.column-outcome,
|
||||||
|
table.widefat.sp-data-table th.column-position {
|
||||||
width: 10em;
|
width: 10em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,7 +297,12 @@ table.widefat.sp-data-table tfoot td {
|
|||||||
border-top: 1px solid #e1e1e1;
|
border-top: 1px solid #e1e1e1;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.widefat select.sp-outcome {
|
table.widefat.sp-data-table tfoot tr.sp-total {
|
||||||
|
background: #f9f9f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.widefat select.sp-outcome,
|
||||||
|
table.widefat select.sp-position {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -468,7 +468,16 @@ jQuery(document).ready(function($){
|
|||||||
$.post( ajaxurl, {
|
$.post( ajaxurl, {
|
||||||
action: "sp-save-primary-result",
|
action: "sp-save-primary-result",
|
||||||
primary_result: $(this).val(),
|
primary_result: $(this).val(),
|
||||||
nonce: $("#sp-config-nonce").val()
|
nonce: $("#sp-primary-result-nonce").val()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configure primary performance option (Ajax)
|
||||||
|
$(".sp-admin-config-table").on("click", ".sp-primary-performance-option", function() {
|
||||||
|
$.post( ajaxurl, {
|
||||||
|
action: "sp-save-primary-performance",
|
||||||
|
primary_performance: $(this).val(),
|
||||||
|
nonce: $("#sp-primary-performance-nonce").val()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -548,6 +557,14 @@ jQuery(document).ready(function($){
|
|||||||
});
|
});
|
||||||
$(".sp-date-selector select").trigger("change");
|
$(".sp-date-selector select").trigger("change");
|
||||||
|
|
||||||
|
// Apply color scheme
|
||||||
|
$(".sp-color-option").on("click", function() {
|
||||||
|
colors = $(this).find("label").data("sp-colors").split(",");
|
||||||
|
$(".sp-custom-colors").find(".sp-color-box").each(function(index) {
|
||||||
|
$(this).find("input").val("#"+colors[index]).css("background-color", "#"+colors[index]);
|
||||||
|
});;
|
||||||
|
});
|
||||||
|
|
||||||
// Edit inline results
|
// Edit inline results
|
||||||
$("#the-list").on("click, focus", ".sp-result, .sp-edit-results", function(){
|
$("#the-list").on("click, focus", ".sp-result, .sp-edit-results", function(){
|
||||||
team = $(this).data("team");
|
team = $(this).data("team");
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class SP_Admin_AJAX {
|
|||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
add_action( 'wp_ajax_sp-save-primary-result', array( $this, 'save_primary_result' ), 1 );
|
add_action( 'wp_ajax_sp-save-primary-result', array( $this, 'save_primary_result' ), 1 );
|
||||||
|
add_action( 'wp_ajax_sp-save-primary-performance', array( $this, 'save_primary_performance' ), 1 );
|
||||||
add_action( 'wp_ajax_sp-save-inline-results', array( $this, 'save_inline_results' ) );
|
add_action( 'wp_ajax_sp-save-inline-results', array( $this, 'save_inline_results' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,20 @@ class SP_Admin_AJAX {
|
|||||||
wp_send_json_success();
|
wp_send_json_success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-save the selected primary performance.
|
||||||
|
*
|
||||||
|
* @since 1.7
|
||||||
|
*/
|
||||||
|
function save_primary_performance() {
|
||||||
|
check_ajax_referer( 'sp-save-primary-performance', 'nonce' );
|
||||||
|
|
||||||
|
$primary_performance = sanitize_key( $_POST['primary_performance'] );
|
||||||
|
|
||||||
|
update_option( 'sportspress_primary_performance', $primary_performance );
|
||||||
|
wp_send_json_success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save event results inline.
|
* Save event results inline.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -282,36 +282,68 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function frontend_styles_setting() {
|
public function frontend_styles_setting() {
|
||||||
|
// Define color schemes each with 5 colors: Primary, Background, Text, Heading, Link
|
||||||
|
$color_schemes = apply_filters( 'sportspress_color_schemes', array(
|
||||||
|
'ThemeBoy' => array( '2b353e', 'f4f4f4', '222222', 'ffffff', '00a69c' ),
|
||||||
|
'Gold' => array( '333333', 'f7f7f7', '333333', 'd8bf94', '9f8958' ),
|
||||||
|
'Denim' => array( '0e2440', 'eae5e0', '0e2440', 'ffffff', '2b6291' ),
|
||||||
|
'Freedom' => array( '0d4785', 'ecedee', '333333', 'ffffff', 'c51d27' ),
|
||||||
|
'Metro' => array( '3a7895', '223344', 'ffffff', 'ffffff', 'ffa800' ),
|
||||||
|
'Stellar' => array( '313150', '050528', 'ffffff', 'ffffff', 'e00034' ),
|
||||||
|
'Carbon' => array( '353535', '191919', 'ededed', 'ffffff', 'f67f17' ),
|
||||||
|
'Avocado' => array( '00241e', '013832', 'ffffff', 'ffffff', 'efb11e' ),
|
||||||
|
) );
|
||||||
?><tr valign="top" class="sportspress_frontend_css_colors">
|
?><tr valign="top" class="sportspress_frontend_css_colors">
|
||||||
<th scope="row" class="titledesc">
|
<th scope="row" class="titledesc">
|
||||||
<?php _e( 'Frontend Styles', 'sportspress' ); ?>
|
<?php _e( 'Frontend Styles', 'sportspress' ); ?>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp"><?php
|
<td class="forminp">
|
||||||
|
<fieldset>
|
||||||
|
<?php foreach ( $color_schemes as $name => $colors ) { ?>
|
||||||
|
<div class="color-option sp-color-option">
|
||||||
|
<label data-sp-colors="<?php echo implode( ',', $colors ); ?>"><?php echo $name; ?></label>
|
||||||
|
<table class="color-palette">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="background-color: #<?php echo $colors[0]; ?>"> </td>
|
||||||
|
<td style="background-color: #<?php echo $colors[0]; ?>"> </td>
|
||||||
|
<td style="background-color: #<?php echo $colors[4]; ?>"> </td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<div class="sp-custom-colors">
|
||||||
|
<label data-sp-colors="<?php echo implode( ',', $colors ); ?>"><?php _e( 'Customize', 'sportspress' ); ?></label><br>
|
||||||
|
<?php
|
||||||
|
// Get settings
|
||||||
|
$colors = array_map( 'esc_attr', (array) get_option( 'sportspress_frontend_css_colors', array() ) );
|
||||||
|
|
||||||
// Get settings
|
// Defaults
|
||||||
$colors = array_map( 'esc_attr', (array) get_option( 'sportspress_frontend_css_colors', array() ) );
|
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#2b353e';
|
||||||
|
if ( empty( $colors['background'] ) ) $colors['background'] = '#f4f4f4';
|
||||||
|
if ( empty( $colors['text'] ) ) $colors['text'] = '#222222';
|
||||||
|
if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff';
|
||||||
|
if ( empty( $colors['link'] ) ) $colors['link'] = '#00a69c';
|
||||||
|
|
||||||
// Defaults
|
// Show inputs
|
||||||
if ( empty( $colors['primary'] ) ) $colors['primary'] = '#2b353e';
|
$this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
|
||||||
if ( empty( $colors['background'] ) ) $colors['background'] = '#f4f4f4';
|
$this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
|
||||||
if ( empty( $colors['text'] ) ) $colors['text'] = '#222222';
|
$this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
|
||||||
if ( empty( $colors['heading'] ) ) $colors['heading'] = '#ffffff';
|
$this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
|
||||||
if ( empty( $colors['link'] ) ) $colors['link'] = '#00a69c';
|
$this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
|
||||||
|
|
||||||
// Show inputs
|
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && array_key_exists( 'sportspress-general', $styles ) ):
|
||||||
$this->color_picker( __( 'Primary', 'sportspress' ), 'sportspress_frontend_css_primary', $colors['primary'] );
|
?><br>
|
||||||
$this->color_picker( __( 'Background', 'sportspress' ), 'sportspress_frontend_css_background', $colors['background'] );
|
<label for="sportspress_enable_frontend_css">
|
||||||
$this->color_picker( __( 'Text', 'sportspress' ), 'sportspress_frontend_css_text', $colors['text'] );
|
<input name="sportspress_enable_frontend_css" id="sportspress_enable_frontend_css" type="checkbox" value="1" <?php checked( get_option( 'sportspress_enable_frontend_css', 'yes' ), 'yes' ); ?>>
|
||||||
$this->color_picker( __( 'Heading', 'sportspress' ), 'sportspress_frontend_css_heading', $colors['heading'] );
|
<?php _e( 'Enable', 'sportspress' ); ?>
|
||||||
$this->color_picker( __( 'Link', 'sportspress' ), 'sportspress_frontend_css_link', $colors['link'] );
|
</label>
|
||||||
|
<?php endif; ?>
|
||||||
if ( ( $styles = SP_Frontend_Scripts::get_styles() ) && ! current_theme_supports( 'sportspress' ) && array_key_exists( 'sportspress-general', $styles ) ):
|
</div>
|
||||||
?><br>
|
</fieldset>
|
||||||
<label for="sportspress_enable_frontend_css">
|
|
||||||
<input name="sportspress_enable_frontend_css" id="sportspress_enable_frontend_css" type="checkbox" value="1" <?php checked( get_option( 'sportspress_enable_frontend_css', 'yes' ), 'yes' ); ?>>
|
|
||||||
<?php _e( 'Enable', 'sportspress' ); ?>
|
|
||||||
</label>
|
|
||||||
<?php endif; ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr><?php
|
</tr><?php
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user