Enable custom event teams delimiter
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
function sportspress_insert_post_data( $data, $postarr ) {
|
function sportspress_insert_post_data( $data, $postarr ) {
|
||||||
|
global $sportspress_options;
|
||||||
|
|
||||||
if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
||||||
|
|
||||||
@@ -10,7 +11,7 @@ function sportspress_insert_post_data( $data, $postarr ) {
|
|||||||
$team_names[] = get_the_title( $team );
|
$team_names[] = get_the_title( $team );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$data['post_title'] = implode( ' ' . __( 'vs', 'sportspress' ) . ' ', $team_names );
|
$data['post_title'] = implode( ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ', $team_names );
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,14 @@ class SportsPressEventSettingsPage {
|
|||||||
'sportspress_events'
|
'sportspress_events'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'delimiter',
|
||||||
|
__( 'Delimiter', 'sportspress' ),
|
||||||
|
array( $this, 'delimiter_callback' ),
|
||||||
|
'sportspress_events',
|
||||||
|
'event'
|
||||||
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'results',
|
'results',
|
||||||
__( 'Results', 'sportspress' ),
|
__( 'Results', 'sportspress' ),
|
||||||
@@ -37,6 +45,21 @@ class SportsPressEventSettingsPage {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delimiter_callback() {
|
||||||
|
$teams_delimiter = sportspress_array_value( $this->options, 'event_teams_delimiter', __( 'vs', 'sportspress' ) );
|
||||||
|
?>
|
||||||
|
<fieldset class="sp-custom-input-wrapper">
|
||||||
|
<legend class="screen-reader-text"><span><?php _e( 'Delimiter', 'sportspress' ); ?></span></legend>
|
||||||
|
<?php $delimiters = array( 'vs', 'v', '—', '/' ); ?>
|
||||||
|
<?php foreach ( $delimiters as $delimiter ): ?>
|
||||||
|
<label title="<?php echo $delimiter; ?>"><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="<?php echo $delimiter; ?>" data-example="<?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?>" <?php checked( $delimiter, $teams_delimiter ); ?>> <span><?php _e( 'Team', 'sportspress' ); ?> <?php echo $delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?></span></label><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<label><input type="radio" class="preset" name="sportspress_event_teams_delimiter_preset" value="\c\u\s\t\o\m" <?php checked( false, in_array( $teams_delimiter, $delimiters ) ); ?>> <?php _e( 'Custom:', 'sportspress' ); ?> </label><input type="text" class="small-text value" name="sportspress[event_teams_delimiter]" value="<?php echo $teams_delimiter; ?>">
|
||||||
|
<span class="example"><?php _e( 'Team', 'sportspress' ); ?> <?php echo $teams_delimiter; ?> <?php _e( 'Team', 'sportspress' ); ?></span>
|
||||||
|
</fieldset>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
function results_callback() {
|
function results_callback() {
|
||||||
$main_result = sportspress_array_value( $this->options, 'main_result', 0 );
|
$main_result = sportspress_array_value( $this->options, 'main_result', 0 );
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function import( $file ) {
|
function import( $file ) {
|
||||||
global $wpdb;
|
global $wpdb, $sportspress_options;
|
||||||
|
|
||||||
$this->imported = $this->skipped = 0;
|
$this->imported = $this->skipped = 0;
|
||||||
|
|
||||||
@@ -311,7 +311,7 @@ if ( class_exists( 'WP_Importer' ) ) {
|
|||||||
|
|
||||||
// Add delimiter if event name is set
|
// Add delimiter if event name is set
|
||||||
if ( $title ):
|
if ( $title ):
|
||||||
$title .= ' ' . __( 'vs', 'sportspress' ) . ' ';
|
$title .= ' ' . sportspress_array_value( $sportspress_options, 'event_teams_delimiter', 'vs' ) . ' ';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Append team name to event name
|
// Append team name to event name
|
||||||
|
|||||||
@@ -303,6 +303,19 @@ jQuery(document).ready(function($){
|
|||||||
// Trigger status selector
|
// Trigger status selector
|
||||||
$(".sp-status-selector select:first-child").change();
|
$(".sp-status-selector select:first-child").change();
|
||||||
|
|
||||||
|
// Preset field modifier
|
||||||
|
$(".sp-custom-input-wrapper .preset").click(function() {
|
||||||
|
val = $(this).val();
|
||||||
|
if(val == "\\c\\u\\s\\t\\o\\m") return true;
|
||||||
|
example = $(this).attr("data-example");
|
||||||
|
$(this).closest(".sp-custom-input-wrapper").find(".value").val(val).siblings(".example").html(example);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select custom preset when field is brought to focus
|
||||||
|
$(".sp-custom-input-wrapper .value").focus(function() {
|
||||||
|
$(this).siblings("label").find(".preset").prop("checked", true);
|
||||||
|
});
|
||||||
|
|
||||||
// Remove slug editor in quick edit for slug-sensitive post types
|
// Remove slug editor in quick edit for slug-sensitive post types
|
||||||
$(".inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_column, .inline-edit-sp_statistic").find("input[name=post_name]").closest("label").remove();
|
$(".inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_column, .inline-edit-sp_statistic").find("input[name=post_name]").closest("label").remove();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user