diff --git a/includes/admin/class-sp-admin-sports.php b/includes/admin/class-sp-admin-sports.php index 4609853a..33576416 100644 --- a/includes/admin/class-sp-admin-sports.php +++ b/includes/admin/class-sp-admin-sports.php @@ -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'; diff --git a/includes/admin/post-types/class-sp-admin-cpt-spec.php b/includes/admin/post-types/class-sp-admin-cpt-spec.php new file mode 100644 index 00000000..8318949d --- /dev/null +++ b/includes/admin/post-types/class-sp-admin-cpt-spec.php @@ -0,0 +1,70 @@ +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' => '', + '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 '' . $post->post_excerpt . ''; + break; + endswitch; + } +} + +endif; + +return new SP_Admin_CPT_Spec(); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-specs.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-specs.php new file mode 100644 index 00000000..1e4e17c2 --- /dev/null +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-specs.php @@ -0,0 +1,53 @@ +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 ): + ?> +
post_title; ?>
+ + ID, 'sp_visible', true ); + if ( '' === $visible ) $visible = 1; + ?> ++
+ + +
++ + +
+