Create CPT classes for config post types
This commit is contained in:
@@ -30,6 +30,12 @@ class SP_Admin_Post_Types {
|
||||
*/
|
||||
public function include_post_type_handlers() {
|
||||
//include( 'post-types/class-sp-admin-meta-boxes.php' );
|
||||
include( 'post-types/class-sp-admin-cpt-result.php' );
|
||||
include( 'post-types/class-sp-admin-cpt-outcome.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-metric.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' );
|
||||
|
||||
@@ -39,23 +39,6 @@ class SP_Admin_CPT_Calendar extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_calendar' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_calendar' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_calendar' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
|
||||
77
includes/admin/post-types/class-sp-admin-cpt-column.php
Normal file
77
includes/admin/post-types/class-sp-admin-cpt-column.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
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_Column' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Column Class
|
||||
*/
|
||||
class SP_Admin_CPT_Column extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_column';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_column_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_column_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' => __( 'Key', 'sportspress' ),
|
||||
'sp_equation' => __( 'Equation', 'sportspress' ),
|
||||
'sp_precision' => __( 'Rounding', 'sportspress' ),
|
||||
'sp_order' => __( 'Sort Order', 'sportspress' ),
|
||||
);
|
||||
return $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_equation':
|
||||
echo sportspress_get_post_equation( $post_id );
|
||||
break;
|
||||
case 'sp_precision':
|
||||
echo sportspress_get_post_precision( $post_id );
|
||||
break;
|
||||
case 'sp_order':
|
||||
echo sportspress_get_post_order( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Column();
|
||||
@@ -45,23 +45,6 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_event' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_event' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_event' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
|
||||
@@ -39,23 +39,6 @@ class SP_Admin_CPT_List extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_list' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_list' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_list' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
|
||||
64
includes/admin/post-types/class-sp-admin-cpt-metric.php
Normal file
64
includes/admin/post-types/class-sp-admin-cpt-metric.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the columns post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
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_Metric' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Metric Class
|
||||
*/
|
||||
class SP_Admin_CPT_Metric extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_metric';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_metric_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_metric_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_position' => __( 'Positions', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define our custom columns shown in admin.
|
||||
* @param string $column
|
||||
*/
|
||||
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' ) : '—';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Metric();
|
||||
65
includes/admin/post-types/class-sp-admin-cpt-outcome.php
Normal file
65
includes/admin/post-types/class-sp-admin-cpt-outcome.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the outcomes post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
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_Outcome' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Outcome Class
|
||||
*/
|
||||
class SP_Admin_CPT_Outcome extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_outcome';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_outcome_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_outcome_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' => __( 'Key', 'sportspress' ),
|
||||
);
|
||||
return $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;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Outcome();
|
||||
73
includes/admin/post-types/class-sp-admin-cpt-performance.php
Normal file
73
includes/admin/post-types/class-sp-admin-cpt-performance.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the performance post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
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_Performance' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Performance Class
|
||||
*/
|
||||
class SP_Admin_CPT_Performance extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_performance';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_performance_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_performance_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' => __( 'Key', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_calculate' => __( 'Calculate', 'sportspress' ),
|
||||
);
|
||||
return $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_position':
|
||||
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '—';
|
||||
break;
|
||||
case 'sp_calculate':
|
||||
echo sportspress_get_post_calculate( $post_id );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Performance();
|
||||
@@ -42,23 +42,6 @@ class SP_Admin_CPT_Player extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_player' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_player' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_player' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
|
||||
65
includes/admin/post-types/class-sp-admin-cpt-result.php
Normal file
65
includes/admin/post-types/class-sp-admin-cpt-result.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin functions for the results post type
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Post Types
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
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_Result' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Admin_CPT_Result Class
|
||||
*/
|
||||
class SP_Admin_CPT_Result extends SP_Admin_CPT {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->type = 'sp_result';
|
||||
|
||||
// Admin Columns
|
||||
add_filter( 'manage_edit-sp_result_columns', array( $this, 'edit_columns' ) );
|
||||
add_action( 'manage_sp_result_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' => __( 'Key', 'sportspress' ),
|
||||
);
|
||||
return $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;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new SP_Admin_CPT_Result();
|
||||
@@ -42,23 +42,6 @@ class SP_Admin_CPT_Staff extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_staff' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_staff' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_staff' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
|
||||
@@ -39,23 +39,6 @@ class SP_Admin_CPT_Table extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_table' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_table' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_table' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the columns shown in admin.
|
||||
*/
|
||||
|
||||
@@ -41,23 +41,6 @@ class SP_Admin_CPT_Team extends SP_Admin_CPT {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding a team
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && 'sp_team' == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && 'sp_team' == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && 'sp_team' == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change title boxes in admin.
|
||||
* @param string $text
|
||||
|
||||
@@ -40,13 +40,30 @@ class SP_Admin_CPT {
|
||||
if ( $post_type == $this->type ) {
|
||||
$obj = get_post_type_object( $this->type );
|
||||
|
||||
$strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'woocommerce' ), $obj->labels->singular_name );
|
||||
$strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'woocommerce' ), $obj->labels->singular_name );
|
||||
$strings['insertIntoPost'] = sprintf( __( 'Insert into %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
$strings['uploadedToThisPost'] = sprintf( __( 'Uploaded to this %s', 'sportspress' ), $obj->labels->singular_name );
|
||||
}
|
||||
|
||||
return $strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we're editing or adding an event
|
||||
* @return boolean
|
||||
*/
|
||||
private function is_editing() {
|
||||
if ( ! empty( $_GET['post_type'] ) && $this->type == $_GET['post_type'] ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_GET['post'] ) && $this->type == get_post_type( $_GET['post'] ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( ! empty( $_REQUEST['post_id'] ) && $this->type == get_post_type( $_REQUEST['post_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom column orderby
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user