The reason it’s going to be infinite is that every time you save the post, it’s calling change_year
…which then calls wp_update_post
… which fires the save_post
filter.
After some review and research, I’m thinking that you should probably avoid the save_post
filter.
Try using this filter:
http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data
It gives you really what you want.
Here’s an example of it editing posted data:
function filter_handler( $data , $postarr ) {
$data[ 'post_title' ] = $postarr[ 'post_title' ] . 'RAWR!';
return $data;
}
add_filter( 'wp_insert_post_data' , 'filter_handler' , '99', 2 );
That will take any post that I save and add ‘RAWR!’ to the end of the string.
Hope this helps.