Fix bugs, use plural post slugs, move actions and filters into hooks folder
This commit is contained in:
19
admin/hooks/wp-insert-post-data.php
Normal file
19
admin/hooks/wp-insert-post-data.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
function sportspress_insert_post_data( $data, $postarr ) {
|
||||
|
||||
if( $data['post_type'] == 'sp_event' && $data['post_title'] == '' ):
|
||||
|
||||
$teams = (array)$postarr['sp_team'];
|
||||
|
||||
$team_names = array();
|
||||
foreach( $teams as $team ):
|
||||
$team_names[] = get_the_title( $team );
|
||||
endforeach;
|
||||
|
||||
$data['post_title'] = implode( ' ' . __( 'vs', 'sportspress' ) . ' ', $team_names );
|
||||
|
||||
endif;
|
||||
|
||||
return $data;
|
||||
}
|
||||
add_filter( 'wp_insert_post_data' , 'sportspress_insert_post_data' , '99', 2 );
|
||||
Reference in New Issue
Block a user