Simplify assignments hook
This commit is contained in:
@@ -81,7 +81,6 @@ class SP_Meta_Box_Player_Statistics {
|
|||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
public static function save( $post_id, $post ) {
|
||||||
do_action( 'sportspress_save_meta_player_statistics', $post_id, $_POST );
|
|
||||||
update_post_meta( $post_id, 'sp_leagues', sp_array_value( $_POST, 'sp_leagues', array() ) );
|
update_post_meta( $post_id, 'sp_leagues', sp_array_value( $_POST, 'sp_leagues', array() ) );
|
||||||
update_post_meta( $post_id, 'sp_statistics', sp_array_value( $_POST, 'sp_statistics', array() ) );
|
update_post_meta( $post_id, 'sp_statistics', sp_array_value( $_POST, 'sp_statistics', array() ) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class SportsPress_Player_Assignments {
|
|||||||
$this->define_constants();
|
$this->define_constants();
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
add_action( 'sportspress_save_meta_player_statistics', array( $this, 'save_additional_statistics' ), 10, 2 );
|
add_action( 'sportspress_process_sp_player_meta', array( $this, 'save' ) );
|
||||||
|
|
||||||
// Filters
|
// Filters
|
||||||
add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10 );
|
add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10 );
|
||||||
@@ -46,10 +46,12 @@ class SportsPress_Player_Assignments {
|
|||||||
/**
|
/**
|
||||||
* Save Additional Statistics
|
* Save Additional Statistics
|
||||||
*/
|
*/
|
||||||
public function save_additional_statistics( $post_id, $post_data ) {
|
public function save( $post_id ) {
|
||||||
delete_post_meta( $post_id, 'sp_assignments' );
|
delete_post_meta( $post_id, 'sp_assignments' );
|
||||||
|
|
||||||
$leagues = $post_data['sp_leagues'];
|
$leagues = sp_array_value( $_POST, 'sp_leagues', array() );
|
||||||
|
|
||||||
|
if ( ! is_array( $leagues ) ) return;
|
||||||
|
|
||||||
foreach ( $leagues as $l_id => $season ) {
|
foreach ( $leagues as $l_id => $season ) {
|
||||||
if ( 0 === $l_id ) continue;
|
if ( 0 === $l_id ) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user