Save default variable name for config types

This commit is contained in:
Brian Miyaji
2014-04-25 01:06:35 +10:00
parent 88d43e0a4f
commit 727d7d3fe6
17 changed files with 227 additions and 108 deletions

View File

@@ -26,7 +26,9 @@ jQuery(document).ready(function($){
// Auto key placeholder
$("#poststuff #title").on("keyup", function() {
$("#sp_key").attr("placeholder", $(this).val().replace(/[^a-z]/gi,"").toLowerCase());
val = $(this).val().replace(/[^a-z]/gi,"").toLowerCase();
$("#sp_variable").attr("placeholder", val);
$("#sp_default_variable").val(val);
});
// Activate auto key placeholder

View File

@@ -35,7 +35,7 @@ class SP_Admin_Post_Types {
include( 'post-types/class-sp-admin-cpt-performance.php' );
include( 'post-types/class-sp-admin-cpt-column.php' );
include( 'post-types/class-sp-admin-cpt-metric.php' );
//include( 'post-types/class-sp-admin-cpt-statistic.php' );
include( 'post-types/class-sp-admin-cpt-statistic.php' );
include( 'post-types/class-sp-admin-cpt-event.php' );
include( 'post-types/class-sp-admin-cpt-calendar.php' );
include( 'post-types/class-sp-admin-cpt-team.php' );

View File

@@ -41,7 +41,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_precision' => __( 'Rounding', 'sportspress' ),
'sp_order' => __( 'Sort Order', 'sportspress' ),
@@ -55,7 +55,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_key':
case 'sp_variable':
global $post;
echo $post->post_name;
break;

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Post Types
* @version 0.7
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -41,8 +41,7 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
);
return $columns;
}
@@ -53,8 +52,9 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_position':
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '&mdash;';
case 'sp_variable':
global $post;
echo $post->post_name;
break;
endswitch;
}

View File

@@ -41,7 +41,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
);
return $columns;
}
@@ -52,7 +52,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_key':
case 'sp_variable':
global $post;
echo $post->post_name;
break;

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Post Types
* @version 0.7
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -41,9 +41,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_position' => __( 'Positions', 'sportspress' ),
'sp_calculate' => __( 'Calculate', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
);
return $columns;
}
@@ -54,16 +52,10 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_key':
case 'sp_variable':
global $post;
echo $post->post_name;
break;
case 'sp_position':
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '&mdash;';
break;
case 'sp_calculate':
echo sp_get_post_calculate( $post_id );
break;
endswitch;
}
}

View File

@@ -41,7 +41,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_key' => __( 'Key', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
);
return $columns;
}
@@ -52,7 +52,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_key':
case 'sp_variable':
global $post;
echo $post->post_name;
break;

View File

@@ -0,0 +1,73 @@
<?php
/**
* Admin functions for the statistics post type
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Post Types
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'SP_Admin_CPT' ) )
include( 'class-sp-admin-cpt.php' );
if ( ! class_exists( 'SP_Admin_CPT_Statistic' ) ) :
/**
* SP_Admin_CPT_Statistic Class
*/
class SP_Admin_CPT_Statistic extends SP_Admin_CPT {
/**
* Constructor
*/
public function __construct() {
$this->type = 'sp_statistic';
// Admin Columns
add_filter( 'manage_edit-sp_statistic_columns', array( $this, 'edit_columns' ) );
add_action( 'manage_sp_statistic_posts_custom_column', array( $this, 'custom_columns' ), 2, 2 );
// Call SP_Admin_CPT constructor
parent::__construct();
}
/**
* Change the columns shown in admin.
*/
public function edit_columns( $existing_columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Label', 'sportspress' ),
'sp_variable' => __( 'Variable', 'sportspress' ),
'sp_equation' => __( 'Equation', 'sportspress' ),
'sp_precision' => __( 'Rounding', 'sportspress' ),
);
return $columns;
}
/**
* Define our custom columns shown in admin.
* @param string $column
*/
public function custom_columns( $column, $post_id ) {
switch ( $column ):
case 'sp_variable':
global $post;
echo $post->post_name;
break;
case 'sp_equation':
echo sp_get_post_equation( $post_id );
break;
case 'sp_precision':
echo sp_get_post_precision( $post_id );
break;
endswitch;
}
}
endif;
return new SP_Admin_CPT_Statistic();

View File

@@ -38,6 +38,9 @@ class SP_Admin_Meta_Boxes {
// Save Performance Meta Boxes
add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 );
// Save Statistic Meta Boxes
add_action( 'sportspress_process_sp_statistic_meta', 'SP_Meta_Box_Statistic_Details::save', 10, 2 );
// Save Column Meta Boxes
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 );
@@ -95,6 +98,9 @@ class SP_Admin_Meta_Boxes {
// Performance
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' );
// Metrics
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Statistic_Details::output', 'sp_statistic', 'normal', 'high' );
// Events
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' );
add_meta_box( 'sp_formatdiv', __( 'Format', 'sportspress' ), 'SP_Meta_Box_Event_Format::output', 'sp_event', 'side', 'default' );
@@ -200,7 +206,7 @@ class SP_Admin_Meta_Boxes {
if ( is_int( wp_is_post_autosave( $post ) ) ) return;
if ( empty( $_POST['sportspress_meta_nonce'] ) || ! wp_verify_nonce( $_POST['sportspress_meta_nonce'], 'sportspress_save_data' ) ) return;
if ( ! current_user_can( 'edit_post', $post_id )) return;
if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_column', 'sp_metric', 'sp_statistic', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return;
if ( ! in_array( $post->post_type, array( 'sp_result', 'sp_outcome', 'sp_performance', 'sp_statistic', 'sp_column', 'sp_metric', 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) return;
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
}

View File

@@ -28,15 +28,16 @@ class SP_Meta_Box_Column_Details {
// Defaults
if ( $precision == '' ) $precision = 0;
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sp_equation_selector( $post->ID, $piece, array( 'team_event', 'result', 'outcome' ) );
sp_equation_selector( $post->ID, $piece, array( 'team_event', 'outcome', 'result' ) );
endforeach;
?>
</p>

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7.3
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -22,9 +22,10 @@ class SP_Meta_Box_Metric_Details {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<?php
}

View File

@@ -21,9 +21,10 @@ class SP_Meta_Box_Outcome_Details {
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<?php
}

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.7.3
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -22,13 +22,10 @@ class SP_Meta_Box_Performance_Details {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
<p class="sp-calculate-selector">
<?php sp_calculate_selector( $post->ID, $calculate ); ?>
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<?php
}
@@ -38,6 +35,5 @@ class SP_Meta_Box_Performance_Details {
*/
public static function save( $post_id, $post ) {
sp_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_calculate', sp_array_value( $_POST, 'sp_calculate', 'DESC' ) );
}
}

View File

@@ -21,9 +21,10 @@ class SP_Meta_Box_Result_Details {
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
?>
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<?php
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* Statistic Details
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Meta_Box_Statistic_Details
*/
class SP_Meta_Box_Statistic_Details {
/**
* Output the metabox
*/
public static function output( $post ) {
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
$equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) );
$precision = get_post_meta( $post->ID, 'sp_precision', true );
// Defaults
if ( $precision == '' ) $precision = 0;
?>
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
<p>
<input name="sp_default_variable" type="hidden" id="sp_default_variable" value="<?php echo $post->post_name; ?>">
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
</p>
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
<p class="sp-equation-selector">
<?php
foreach ( $equation as $piece ):
sp_equation_selector( $post->ID, $piece, array( 'player_event', 'outcome', 'performance', 'metric' ) );
endforeach;
?>
</p>
<p><strong><?php _e( 'Rounding', 'sportspress' ); ?></strong></p>
<p class="sp-precision-selector">
<input name="sp_precision" type="text" size="4" id="sp_precision" value="<?php echo $precision; ?>" placeholder="0">
</p>
<?php
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sp_delete_duplicate_post( $_POST );
update_post_meta( $post_id, 'sp_equation', implode( ' ', sp_array_value( $_POST, 'sp_equation', array() ) ) );
update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) );
}
}

View File

@@ -350,9 +350,9 @@ if ( !function_exists( 'sp_get_post_equation' ) ) {
$equation = get_post_meta ( $post_id, 'sp_equation', true );
if ( $equation ):
return str_replace(
array( '$', '+', '-', '*', '/' ),
array( '&Sigma; ', '&plus;', '&minus;', '&times;', '&divide' ),
$equation
array( '/', '(', ')', '+', '-', '*', '$' ),
array( '<code>&divide;</code>', '<code>(</code>', '<code>)</code>', '<code>&plus;</code>', '<code>&minus;</code>', '<code>&times;</code>', '' ),
trim( $equation )
);
else:
return '&mdash;';
@@ -737,19 +737,19 @@ if ( !function_exists( 'sp_equation_selector' ) ) {
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
break;
case 'result':
$options[ __( 'Team Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '&rarr;', 'against' => '&larr;' ), null, false );
$options[ __( 'Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '&rarr;', 'against' => '&larr;' ), null, false );
break;
case 'outcome':
$options[ __( 'Event Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
break;
case 'column':
$options[ __( 'Table Columns', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_column' );
$options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
$options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
$options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
$options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
break;
case 'performance':
$options[ __( 'Player Performance', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_performance' );
$options[ __( 'Performance', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_performance' );
break;
case 'metric':
$options[ __( 'Metric', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_metric' );
break;
endswitch;
endforeach;
@@ -2187,7 +2187,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
unset( $columns[ $key ] );
endif;
endforeach;
$labels = array_merge( array( 'name' => SP()->text->string('Team', 'team') ), $columns );
$labels = array_merge( array( 'name' => SP()->text->string('Team') ), $columns );
$merged[0] = $labels;
return $merged;
endif;
@@ -2373,7 +2373,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
);
$performances = get_posts( $args );
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') );
$columns = array( 'eventsplayed' => SP()->text->string('Played') );
foreach ( $performances as $performance ):
@@ -2476,7 +2476,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
unset( $columns[ $key ] );
endif;
endforeach;
$labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns );
$labels = array_merge( array( 'name' => SP()->text->string('Player') ), $columns );
$merged[0] = $labels;
return $merged;
endif;
@@ -2639,7 +2639,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
);
$performances = get_posts( $args );
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') );
$columns = array( 'eventsplayed' => SP()->text->string('Played') );
foreach ( $performances as $performance ):
@@ -2735,7 +2735,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
if ( $admin ):
return array( $columns, $data, $placeholders, $merged );
else:
$labels = array_merge( array( 'name' => SP()->text->string('Player', 'player') ), $columns );
$labels = array_merge( array( 'name' => SP()->text->string('Player') ), $columns );
$merged[0] = $labels;
return $merged;
endif;
@@ -2841,7 +2841,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
$performance_labels[ $performance->post_name ] = $performance->post_title;
$equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true );
endforeach;
$columns = array_merge( array( 'eventsplayed' => SP()->text->string('Played', 'player') ), $performance_labels );
$columns = array_merge( array( 'eventsplayed' => SP()->text->string('Played') ), $performance_labels );
// Generate array of all season ids and season names
$div_ids = array();
@@ -2976,7 +2976,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
if ( $admin ):
return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams );
else:
$labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team', 'player'), 'eventsplayed' => SP()->text->string('Played', 'player') ), $columns );
$labels = array_merge( array( 'name' => SP()->text->string('Season'), 'team' => SP()->text->string('Team'), 'eventsplayed' => SP()->text->string('Played') ), $columns );
$merged[0] = $labels;
return $merged;
endif;
@@ -3003,7 +3003,7 @@ if ( !function_exists( 'sp_delete_duplicate_post' ) ) {
function sp_delete_duplicate_post( &$post ) {
global $wpdb;
$key = isset( $post['sp_key'] ) ? $post['sp_key'] : null;
$key = isset( $post['sp_variable'] ) ? $post['sp_variable'] : null;
if ( ! $key ) $key = $post['post_title'];
$id = sp_array_value( $post, 'post_ID', 'var' );
$title = sp_get_eos_safe_slug( $key, $id );
@@ -5280,48 +5280,37 @@ function sp_get_sport_options() {
* @return array
*/
function sp_get_text_options() {
return apply_filters( 'sportspress_text', array(
'general' => array(
'league' => __( 'League', 'sportspress' ),
'season' => __( 'Season', 'sportspress' ),
),
'event' => array(
'event' => __( 'Event', 'sportspress' ),
'date' => __( 'Date', 'sportspress' ),
'time' => __( 'Time', 'sportspress' ),
'results' => __( 'Team Results', 'sportspress' ),
'team' => __( 'Team', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'details' => __( 'Details', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'player' => __( 'Player', 'sportspress' ),
'substitutes' => __( 'Substitutes', 'sportspress' ),
'total' => __( 'Total', 'sportspress' ),
'article' => __( 'Article', 'sportspress' ),
'preview' => __( 'Preview', 'sportspress' ),
'recap' => __( 'Recap', 'sportspress' ),
'view_all_events' => __( 'View all events', 'sportspress' ),
),
'team' => array(
'team' => __( 'Team', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'pos' => __( 'Pos', 'sportspress' ),
'view_full_table' => __( 'View full table', 'sportspress' ),
),
'player' => array(
'player' => __( 'Player', 'sportspress' ),
'position' => __( 'Position', 'sportspress' ),
'nationality' => __( 'Nationality', 'sportspress' ),
'current_team' => __( 'Current Team', 'sportspress' ),
'past_teams' => __( 'Past Teams', 'sportspress' ),
'rank' => __( 'Rank', 'sportspress' ),
'played' => __( 'Played', 'sportspress' ),
'view_all_players' => __( 'View all players', 'sportspress' ),
),
'staff' => array(
'staff' => __( 'Staff', 'sportspress' ),
),
$strings = apply_filters( 'sportspress_text', array(
'article' => __( 'Article', 'sportspress' ),
'current_team' => __( 'Current Team', 'sportspress' ),
'date' => __( 'Date', 'sportspress' ),
'details' => __( 'Details', 'sportspress' ),
'event' => __( 'Event', 'sportspress' ),
'league' => __( 'League', 'sportspress' ),
'nationality' => __( 'Nationality', 'sportspress' ),
'past_teams' => __( 'Past Teams', 'sportspress' ),
'played' => __( 'Played', 'sportspress' ),
'player' => __( 'Player', 'sportspress' ),
'pos' => __( 'Pos', 'sportspress' ),
'position' => __( 'Position', 'sportspress' ),
'preview' => __( 'Preview', 'sportspress' ),
'rank' => __( 'Rank', 'sportspress' ),
'recap' => __( 'Recap', 'sportspress' ),
'results' => __( 'Team Results', 'sportspress' ),
'season' => __( 'Season', 'sportspress' ),
'staff' => __( 'Staff', 'sportspress' ),
'substitutes' => __( 'Substitutes', 'sportspress' ),
'team' => __( 'Team', 'sportspress' ),
'teams' => __( 'Teams', 'sportspress' ),
'time' => __( 'Time', 'sportspress' ),
'total' => __( 'Total', 'sportspress' ),
'venue' => __( 'Venue', 'sportspress' ),
'view_all_events' => __( 'View all events', 'sportspress' ),
'view_all_players' => __( 'View all players', 'sportspress' ),
'view_full_table' => __( 'View full table', 'sportspress' ),
));
asort( $strings );
return $strings;
}
function sp_is_config_type( $typenow = null ) {

View File

@@ -104,7 +104,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
if ( sp_is_config_type( $typenow ) ):
switch ( $untranslated_text ):
case 'Slug':
$translated_text = __( 'Key', 'sportspress' );
$translated_text = __( 'Variable', 'sportspress' );
break;
endswitch;
endif;
@@ -178,11 +178,11 @@ function sportspress_sanitize_title( $title ) {
return $title;
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ):
elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && sp_is_config_type( $_POST['post_type'] ) ):
$key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null;
$key = isset( $_POST['sp_variable'] ) ? $_POST['sp_variable'] : null;
if ( ! $key ) $key = isset( $_POST['post_name'] ) ? $_POST['post_name'] : null;
if ( ! $key ) $key = isset( $_POST['sp_default_variable'] ) ? $_POST['sp_default_variable'] : null;
if ( ! $key ) $key = $_POST['post_title'];