Merge branch 'feature-event-specs'
This commit is contained in:
@@ -143,7 +143,7 @@ class SP_Admin_Sports {
|
||||
update_post_meta( $id, 'sp_equation', sp_array_value( $result, 'equation', null ) );
|
||||
}
|
||||
|
||||
// Make sure statistics and metrics have greater menu order than performance
|
||||
// Make sure statistics, metrics and specs have greater menu order than performance
|
||||
$i = 0;
|
||||
|
||||
// Performance
|
||||
@@ -192,6 +192,17 @@ class SP_Admin_Sports {
|
||||
$id = self::insert_preset_post( $post, $i + $index );
|
||||
$i ++;
|
||||
}
|
||||
|
||||
// Event Specs
|
||||
$post_type = 'sp_spec';
|
||||
$specs = sp_array_value( $preset, 'specs', array() );
|
||||
self::delete_preset_posts( $post_type );
|
||||
foreach ( $specs as $index => $spec ) {
|
||||
$post = self::get_post_array( $spec, $post_type );
|
||||
if ( empty( $post ) ) continue;
|
||||
$id = self::insert_preset_post( $post, $i + $index );
|
||||
$i ++;
|
||||
}
|
||||
|
||||
// Statistics
|
||||
$post_type = 'sp_statistic';
|
||||
|
||||
70
includes/admin/post-types/class-sp-admin-cpt-spec.php
Normal file
70
includes/admin/post-types/class-sp-admin-cpt-spec.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post_Types
|
||||
* @version 0.9
|
||||
*/
|
||||
|
||||
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_Spec' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Spec Class
|
||||
*/
|
||||
class SP_Admin_CPT_Spec extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_spec';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_spec_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_spec_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_key' => __( 'Variable', 'sportspress' ),
|
||||
'sp_description' => __( 'Description', 'sportspress' ),
|
||||
);
|
||||
return apply_filters( 'sportspress_spec_admin_columns', $columns );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
public function custom_columns( $column, $post_id ) {
|
||||
switch ( $column ):
|
||||
case 'sp_key':
|
||||
global $post;
|
||||
echo $post->post_name;
|
||||
break;
|
||||
case 'sp_description':
|
||||
global $post;
|
||||
echo '<span class="description">' . $post->post_excerpt . '</span>';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Spec();
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Player Metrics
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.9.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Event_Specs
|
||||
*/
|
||||
class SP_Meta_Box_Event_Specs {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
|
||||
$metrics = get_post_meta( $post->ID, 'sp_specs', true );
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_spec',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
$vars = get_posts( $args );
|
||||
|
||||
if ( $vars ):
|
||||
foreach ( $vars as $var ):
|
||||
?>
|
||||
<p><strong><?php echo $var->post_title; ?></strong></p>
|
||||
<p><input type="text" name="sp_specs[<?php echo $var->post_name; ?>]" value="<?php echo esc_attr( sp_array_value( $metrics, $var->post_name, '' ) ); ?>" /></p>
|
||||
<?php
|
||||
endforeach;
|
||||
else:
|
||||
sp_post_adder( 'sp_spec', __( 'Add New', 'sportspress' ) );
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_specs', sp_array_value( $_POST, 'sp_specs', array() ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Spec Details
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'SP_Meta_Box_Config' ) )
|
||||
include( 'class-sp-meta-box-config.php' );
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Spec_Details
|
||||
*/
|
||||
class SP_Meta_Box_Spec_Details extends SP_Meta_Box_Config {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
wp_nonce_field( 'sportspress_save_data', 'sportspress_meta_nonce' );
|
||||
$visible = get_post_meta( $post->ID, 'sp_visible', true );
|
||||
if ( '' === $visible ) $visible = 1;
|
||||
?>
|
||||
<p><strong><?php _e( 'Variable', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_default_key" type="hidden" id="sp_default_key" value="<?php echo $post->post_name; ?>">
|
||||
<input name="sp_key" type="text" id="sp_key" value="<?php echo $post->post_name; ?>">
|
||||
</p>
|
||||
<p>
|
||||
<strong><?php _e( 'Visible', 'sportspress' ); ?></strong>
|
||||
<i class="dashicons dashicons-editor-help sp-desc-tip" title="<?php _e( 'Display in event pages?', 'sportspress' ); ?>"></i>
|
||||
</p>
|
||||
<ul class="sp-visible-selector">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visible" id="sp_visible_yes" type="radio" value="1" <?php checked( $visible ); ?>>
|
||||
<?php _e( 'Yes', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input name="sp_visible" id="sp_visible_no" type="radio" value="0" <?php checked( ! $visible ); ?>>
|
||||
<?php _e( 'No', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
self::delete_duplicate( $_POST );
|
||||
update_post_meta( $post_id, 'sp_visible', sp_array_value( $_POST, 'sp_visible', 1 ) );
|
||||
}
|
||||
}
|
||||
@@ -295,7 +295,7 @@ $columns = get_option( 'sportspress_player_columns', 'auto' );
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user