Save default variable name for config types
This commit is contained in:
@@ -26,7 +26,9 @@ jQuery(document).ready(function($){
|
|||||||
|
|
||||||
// Auto key placeholder
|
// Auto key placeholder
|
||||||
$("#poststuff #title").on("keyup", function() {
|
$("#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
|
// Activate auto key placeholder
|
||||||
|
|||||||
@@ -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-performance.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-column.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-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-event.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-calendar.php' );
|
include( 'post-types/class-sp-admin-cpt-calendar.php' );
|
||||||
include( 'post-types/class-sp-admin-cpt-team.php' );
|
include( 'post-types/class-sp-admin-cpt-team.php' );
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_variable' => __( 'Variable', 'sportspress' ),
|
||||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||||
'sp_precision' => __( 'Rounding', 'sportspress' ),
|
'sp_precision' => __( 'Rounding', 'sportspress' ),
|
||||||
'sp_order' => __( 'Sort Order', '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 ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_key':
|
case 'sp_variable':
|
||||||
global $post;
|
global $post;
|
||||||
echo $post->post_name;
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin/Post Types
|
* @package SportsPress/Admin/Post Types
|
||||||
* @version 0.7
|
* @version 0.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -41,8 +41,7 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_variable' => __( 'Variable', 'sportspress' ),
|
||||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -53,8 +52,9 @@ class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_position':
|
case 'sp_variable':
|
||||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
global $post;
|
||||||
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_variable' => __( 'Variable', 'sportspress' ),
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_key':
|
case 'sp_variable':
|
||||||
global $post;
|
global $post;
|
||||||
echo $post->post_name;
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin/Post Types
|
* @package SportsPress/Admin/Post Types
|
||||||
* @version 0.7
|
* @version 0.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||||
@@ -41,9 +41,7 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_variable' => __( 'Variable', 'sportspress' ),
|
||||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
|
||||||
'sp_calculate' => __( 'Calculate', 'sportspress' ),
|
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -54,16 +52,10 @@ class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_key':
|
case 'sp_variable':
|
||||||
global $post;
|
global $post;
|
||||||
echo $post->post_name;
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
case 'sp_position':
|
|
||||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
|
||||||
break;
|
|
||||||
case 'sp_calculate':
|
|
||||||
echo sp_get_post_calculate( $post_id );
|
|
||||||
break;
|
|
||||||
endswitch;
|
endswitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
|||||||
$columns = array(
|
$columns = array(
|
||||||
'cb' => '<input type="checkbox" />',
|
'cb' => '<input type="checkbox" />',
|
||||||
'title' => __( 'Label', 'sportspress' ),
|
'title' => __( 'Label', 'sportspress' ),
|
||||||
'sp_key' => __( 'Key', 'sportspress' ),
|
'sp_variable' => __( 'Variable', 'sportspress' ),
|
||||||
);
|
);
|
||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
|||||||
*/
|
*/
|
||||||
public function custom_columns( $column, $post_id ) {
|
public function custom_columns( $column, $post_id ) {
|
||||||
switch ( $column ):
|
switch ( $column ):
|
||||||
case 'sp_key':
|
case 'sp_variable':
|
||||||
global $post;
|
global $post;
|
||||||
echo $post->post_name;
|
echo $post->post_name;
|
||||||
break;
|
break;
|
||||||
|
|||||||
73
includes/admin/post-types/class-sp-admin-cpt-statistic.php
Normal file
73
includes/admin/post-types/class-sp-admin-cpt-statistic.php
Normal 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();
|
||||||
@@ -38,6 +38,9 @@ class SP_Admin_Meta_Boxes {
|
|||||||
// Save Performance Meta Boxes
|
// Save Performance Meta Boxes
|
||||||
add_action( 'sportspress_process_sp_performance_meta', 'SP_Meta_Box_Performance_Details::save', 10, 2 );
|
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
|
// Save Column Meta Boxes
|
||||||
add_action( 'sportspress_process_sp_column_meta', 'SP_Meta_Box_Column_Details::save', 10, 2 );
|
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
|
// Performance
|
||||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Performance_Details::output', 'sp_performance', 'normal', 'high' );
|
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
|
// Events
|
||||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Event_Shortcode::output', 'sp_event', 'side', 'default' );
|
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' );
|
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 ( 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 ( 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 ( ! 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 );
|
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,15 +28,16 @@ class SP_Meta_Box_Column_Details {
|
|||||||
// Defaults
|
// Defaults
|
||||||
if ( $precision == '' ) $precision = 0;
|
if ( $precision == '' ) $precision = 0;
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'Key', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||||
<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>
|
||||||
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Equation', 'sportspress' ); ?></strong></p>
|
||||||
<p class="sp-equation-selector">
|
<p class="sp-equation-selector">
|
||||||
<?php
|
<?php
|
||||||
foreach ( $equation as $piece ):
|
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;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin/Meta Boxes
|
* @package SportsPress/Admin/Meta Boxes
|
||||||
* @version 0.7.3
|
* @version 0.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
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' );
|
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||||
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
|
$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>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ class SP_Meta_Box_Outcome_Details {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
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>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
* @category Admin
|
* @category Admin
|
||||||
* @package SportsPress/Admin/Meta Boxes
|
* @package SportsPress/Admin/Meta Boxes
|
||||||
* @version 0.7.3
|
* @version 0.8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
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' );
|
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||||
$calculate = get_post_meta( $post->ID, 'sp_calculate', true );
|
$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>
|
<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; ?>">
|
||||||
</p>
|
<input name="sp_variable" type="text" id="sp_variable" value="<?php echo $post->post_name; ?>">
|
||||||
<p><strong><?php _e( 'Calculate', 'sportspress' ); ?></strong></p>
|
|
||||||
<p class="sp-calculate-selector">
|
|
||||||
<?php sp_calculate_selector( $post->ID, $calculate ); ?>
|
|
||||||
</p>
|
</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -38,6 +35,5 @@ class SP_Meta_Box_Performance_Details {
|
|||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
sp_delete_duplicate_post( $_POST );
|
sp_delete_duplicate_post( $_POST );
|
||||||
update_post_meta( $post_id, 'sp_calculate', sp_array_value( $_POST, 'sp_calculate', 'DESC' ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,10 @@ class SP_Meta_Box_Result_Details {
|
|||||||
public static function output( $post ) {
|
public static function output( $post ) {
|
||||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
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>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -350,9 +350,9 @@ if ( !function_exists( 'sp_get_post_equation' ) ) {
|
|||||||
$equation = get_post_meta ( $post_id, 'sp_equation', true );
|
$equation = get_post_meta ( $post_id, 'sp_equation', true );
|
||||||
if ( $equation ):
|
if ( $equation ):
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array( '$', '+', '-', '*', '/' ),
|
array( '/', '(', ')', '+', '-', '*', '$' ),
|
||||||
array( 'Σ ', '+', '−', '×', '÷' ),
|
array( '<code>÷</code>', '<code>(</code>', '<code>)</code>', '<code>+</code>', '<code>−</code>', '<code>×</code>', '' ),
|
||||||
$equation
|
trim( $equation )
|
||||||
);
|
);
|
||||||
else:
|
else:
|
||||||
return '—';
|
return '—';
|
||||||
@@ -737,19 +737,19 @@ if ( !function_exists( 'sp_equation_selector' ) ) {
|
|||||||
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
|
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
|
||||||
break;
|
break;
|
||||||
case 'result':
|
case 'result':
|
||||||
$options[ __( 'Team Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false );
|
$options[ __( 'Results', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_result', array( 'for' => '→', 'against' => '←' ), null, false );
|
||||||
break;
|
break;
|
||||||
case 'outcome':
|
case 'outcome':
|
||||||
$options[ __( 'Event Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
|
$options[ __( 'Outcomes', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_outcome', array() );
|
||||||
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
|
$options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
|
||||||
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
|
$options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
|
||||||
$options[ __( 'Event Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
|
$options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
|
||||||
break;
|
|
||||||
case 'column':
|
|
||||||
$options[ __( 'Table Columns', 'sportspress' ) ] = sp_get_equation_optgroup_array( $postid, 'sp_column' );
|
|
||||||
break;
|
break;
|
||||||
case 'performance':
|
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;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
endforeach;
|
endforeach;
|
||||||
@@ -2187,7 +2187,7 @@ if ( !function_exists( 'sp_get_league_table_data' ) ) {
|
|||||||
unset( $columns[ $key ] );
|
unset( $columns[ $key ] );
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
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;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2373,7 +2373,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
|
|||||||
);
|
);
|
||||||
$performances = get_posts( $args );
|
$performances = get_posts( $args );
|
||||||
|
|
||||||
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') );
|
$columns = array( 'eventsplayed' => SP()->text->string('Played') );
|
||||||
|
|
||||||
foreach ( $performances as $performance ):
|
foreach ( $performances as $performance ):
|
||||||
|
|
||||||
@@ -2476,7 +2476,7 @@ if ( !function_exists( 'sp_get_player_list_data' ) ) {
|
|||||||
unset( $columns[ $key ] );
|
unset( $columns[ $key ] );
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
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;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2639,7 +2639,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
|
|||||||
);
|
);
|
||||||
$performances = get_posts( $args );
|
$performances = get_posts( $args );
|
||||||
|
|
||||||
$columns = array( 'eventsplayed' => SP()->text->string('Played', 'player') );
|
$columns = array( 'eventsplayed' => SP()->text->string('Played') );
|
||||||
|
|
||||||
foreach ( $performances as $performance ):
|
foreach ( $performances as $performance ):
|
||||||
|
|
||||||
@@ -2735,7 +2735,7 @@ if ( !function_exists( 'sp_get_player_roster_data' ) ) {
|
|||||||
if ( $admin ):
|
if ( $admin ):
|
||||||
return array( $columns, $data, $placeholders, $merged );
|
return array( $columns, $data, $placeholders, $merged );
|
||||||
else:
|
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;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -2841,7 +2841,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
|
|||||||
$performance_labels[ $performance->post_name ] = $performance->post_title;
|
$performance_labels[ $performance->post_name ] = $performance->post_title;
|
||||||
$equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true );
|
$equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true );
|
||||||
endforeach;
|
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
|
// Generate array of all season ids and season names
|
||||||
$div_ids = array();
|
$div_ids = array();
|
||||||
@@ -2976,7 +2976,7 @@ if ( !function_exists( 'sp_get_player_performance_data' ) ) {
|
|||||||
if ( $admin ):
|
if ( $admin ):
|
||||||
return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams );
|
return array( $columns, $tempdata, $placeholders, $merged, $seasons_teams );
|
||||||
else:
|
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;
|
$merged[0] = $labels;
|
||||||
return $merged;
|
return $merged;
|
||||||
endif;
|
endif;
|
||||||
@@ -3003,7 +3003,7 @@ if ( !function_exists( 'sp_delete_duplicate_post' ) ) {
|
|||||||
function sp_delete_duplicate_post( &$post ) {
|
function sp_delete_duplicate_post( &$post ) {
|
||||||
global $wpdb;
|
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'];
|
if ( ! $key ) $key = $post['post_title'];
|
||||||
$id = sp_array_value( $post, 'post_ID', 'var' );
|
$id = sp_array_value( $post, 'post_ID', 'var' );
|
||||||
$title = sp_get_eos_safe_slug( $key, $id );
|
$title = sp_get_eos_safe_slug( $key, $id );
|
||||||
@@ -5280,48 +5280,37 @@ function sp_get_sport_options() {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function sp_get_text_options() {
|
function sp_get_text_options() {
|
||||||
return apply_filters( 'sportspress_text', array(
|
$strings = apply_filters( 'sportspress_text', array(
|
||||||
'general' => array(
|
'article' => __( 'Article', 'sportspress' ),
|
||||||
'league' => __( 'League', 'sportspress' ),
|
'current_team' => __( 'Current Team', 'sportspress' ),
|
||||||
'season' => __( 'Season', 'sportspress' ),
|
'date' => __( 'Date', 'sportspress' ),
|
||||||
),
|
'details' => __( 'Details', 'sportspress' ),
|
||||||
'event' => array(
|
'event' => __( 'Event', 'sportspress' ),
|
||||||
'event' => __( 'Event', 'sportspress' ),
|
'league' => __( 'League', 'sportspress' ),
|
||||||
'date' => __( 'Date', 'sportspress' ),
|
'nationality' => __( 'Nationality', 'sportspress' ),
|
||||||
'time' => __( 'Time', 'sportspress' ),
|
'past_teams' => __( 'Past Teams', 'sportspress' ),
|
||||||
'results' => __( 'Team Results', 'sportspress' ),
|
'played' => __( 'Played', 'sportspress' ),
|
||||||
'team' => __( 'Team', 'sportspress' ),
|
'player' => __( 'Player', 'sportspress' ),
|
||||||
'teams' => __( 'Teams', 'sportspress' ),
|
'pos' => __( 'Pos', 'sportspress' ),
|
||||||
'details' => __( 'Details', 'sportspress' ),
|
'position' => __( 'Position', 'sportspress' ),
|
||||||
'venue' => __( 'Venue', 'sportspress' ),
|
'preview' => __( 'Preview', 'sportspress' ),
|
||||||
'player' => __( 'Player', 'sportspress' ),
|
'rank' => __( 'Rank', 'sportspress' ),
|
||||||
'substitutes' => __( 'Substitutes', 'sportspress' ),
|
'recap' => __( 'Recap', 'sportspress' ),
|
||||||
'total' => __( 'Total', 'sportspress' ),
|
'results' => __( 'Team Results', 'sportspress' ),
|
||||||
'article' => __( 'Article', 'sportspress' ),
|
'season' => __( 'Season', 'sportspress' ),
|
||||||
'preview' => __( 'Preview', 'sportspress' ),
|
'staff' => __( 'Staff', 'sportspress' ),
|
||||||
'recap' => __( 'Recap', 'sportspress' ),
|
'substitutes' => __( 'Substitutes', 'sportspress' ),
|
||||||
'view_all_events' => __( 'View all events', 'sportspress' ),
|
'team' => __( 'Team', 'sportspress' ),
|
||||||
),
|
'teams' => __( 'Teams', 'sportspress' ),
|
||||||
'team' => array(
|
'time' => __( 'Time', 'sportspress' ),
|
||||||
'team' => __( 'Team', 'sportspress' ),
|
'total' => __( 'Total', 'sportspress' ),
|
||||||
'teams' => __( 'Teams', 'sportspress' ),
|
'venue' => __( 'Venue', 'sportspress' ),
|
||||||
'pos' => __( 'Pos', 'sportspress' ),
|
'view_all_events' => __( 'View all events', 'sportspress' ),
|
||||||
'view_full_table' => __( 'View full table', 'sportspress' ),
|
'view_all_players' => __( 'View all players', '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' ),
|
|
||||||
),
|
|
||||||
));
|
));
|
||||||
|
asort( $strings );
|
||||||
|
return $strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sp_is_config_type( $typenow = null ) {
|
function sp_is_config_type( $typenow = null ) {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
|||||||
if ( sp_is_config_type( $typenow ) ):
|
if ( sp_is_config_type( $typenow ) ):
|
||||||
switch ( $untranslated_text ):
|
switch ( $untranslated_text ):
|
||||||
case 'Slug':
|
case 'Slug':
|
||||||
$translated_text = __( 'Key', 'sportspress' );
|
$translated_text = __( 'Variable', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
endif;
|
endif;
|
||||||
@@ -178,11 +178,11 @@ function sportspress_sanitize_title( $title ) {
|
|||||||
|
|
||||||
return $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'];
|
if ( ! $key ) $key = $_POST['post_title'];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user