Simplify assignments but disable until migration is ready
This commit is contained in:
@@ -48,9 +48,7 @@ class SP_Player_List extends SP_Secondary_Post {
|
|||||||
$order = get_post_meta( $this->ID, 'sp_order', true );
|
$order = get_post_meta( $this->ID, 'sp_order', true );
|
||||||
$select = get_post_meta( $this->ID, 'sp_select', true );
|
$select = get_post_meta( $this->ID, 'sp_select', true );
|
||||||
//Player Assignments
|
//Player Assignments
|
||||||
$enable_assignments = get_option( 'sportspress_load_player_assignments_module', 'yes' );
|
|
||||||
$assignments = array();
|
$assignments = array();
|
||||||
if ( $enable_assignments == 'yes' ) {
|
|
||||||
foreach ( $league_ids as $l_id ) {
|
foreach ( $league_ids as $l_id ) {
|
||||||
foreach ( $season_ids as $s_id ) {
|
foreach ( $season_ids as $s_id ) {
|
||||||
if ( $team != '0' ) {
|
if ( $team != '0' ) {
|
||||||
@@ -58,7 +56,6 @@ class SP_Player_List extends SP_Secondary_Post {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->date = $this->__get( 'date' );
|
$this->date = $this->__get( 'date' );
|
||||||
|
|
||||||
@@ -112,7 +109,7 @@ class SP_Player_List extends SP_Secondary_Post {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
//Use the Player Assignments to filter players
|
//Use the Player Assignments to filter players
|
||||||
if ( !empty( $assignments ) ) {
|
if ( false ) {
|
||||||
$args['meta_query'] = array(
|
$args['meta_query'] = array(
|
||||||
array(
|
array(
|
||||||
'key' => 'sp_assignments',
|
'key' => 'sp_assignments',
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ class SportsPress_Player_Assignments {
|
|||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
add_action( 'sportspress_save_meta_player_statistics', array( $this, 'save_additional_statistics' ), 10, 2 );
|
add_action( 'sportspress_save_meta_player_statistics', array( $this, 'save_additional_statistics' ), 10, 2 );
|
||||||
|
|
||||||
// Filters
|
|
||||||
add_filter( 'sportspress_player_list_options', array( $this, 'add_settings' ) );
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Define constants.
|
* Define constants.
|
||||||
@@ -46,57 +43,19 @@ class SportsPress_Player_Assignments {
|
|||||||
* Save Additional Statistics
|
* Save Additional Statistics
|
||||||
*/
|
*/
|
||||||
public function save_additional_statistics( $post_id, $post_data ) {
|
public function save_additional_statistics( $post_id, $post_data ) {
|
||||||
$old = (array) get_post_custom_values( 'sp_assignments', $post_id );
|
delete_post_meta( $post_id, 'sp_assignments' );
|
||||||
|
|
||||||
$leagues = $post_data['sp_leagues'];
|
$leagues = $post_data['sp_leagues'];
|
||||||
$transfers = get_post_meta($post_id, 'sp_assignments', true);
|
|
||||||
|
|
||||||
foreach ( $leagues as $l_id => $season ) {
|
foreach ( $leagues as $l_id => $season ) {
|
||||||
foreach ( $season as $s_id => $team_id ) {
|
foreach ( $season as $s_id => $team_id ) {
|
||||||
if ( $team_id != '-1' ) {
|
if ( $team_id != '-1' ) {
|
||||||
$serialized = $l_id.'_'.$s_id.'_'.$team_id;
|
$serialized = $l_id.'_'.$s_id.'_'.$team_id;
|
||||||
if( !in_array( $serialized, $old ) ){
|
|
||||||
add_post_meta( $post_id, 'sp_assignments', $serialized, false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Check if there are any Mid-Season transfers
|
|
||||||
if ( isset( $transfers[$l_id][$s_id] ) ){
|
|
||||||
foreach ( $transfers[$l_id][$s_id] as $t_id => $performance ) {
|
|
||||||
$serialized = $l_id.'_'.$s_id.'_'.$t_id;
|
|
||||||
if( !in_array( $serialized, $old ) ){
|
|
||||||
add_post_meta( $post_id, 'sp_assignments', $serialized, false );
|
add_post_meta( $post_id, 'sp_assignments', $serialized, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add settings.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function add_settings( $settings ) {
|
|
||||||
|
|
||||||
$settings = array_merge( $settings,
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'title' => __( 'Filter by player assignment', 'sportspress' ),
|
|
||||||
'desc' => __( 'Use a stronger connection between leagues, seasons and teams', 'sportspress' ),
|
|
||||||
'id' => 'sportspress_list_player_assignments',
|
|
||||||
'default' => 'yes',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array( 'type' => 'sectionend', 'id' => 'timelines_options' ),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return $settings;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
endif;
|
endif;
|
||||||
if ( get_option( 'sportspress_load_player_assignments_module', 'yes' ) == 'yes' ) { //Is it needed?
|
//new SportsPress_Player_Assignments();
|
||||||
new SportsPress_Player_Assignments();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user