I have to send a Firebase Cloud Message (FCM) to an android application when a new post is inserted in a wordpress blog, I already put my code in the wp_includes\post.php , but this will not work, cause of the future WP update(post.php will be replaced and I can't insert my code evry time), so I have to put my code(it works no problem in this) in another place.. where I can put my file?? I have to write a plugin? It's possible to write a plugin that override a function? in this case wp_insert_post? And if this is possible where i retrieve the post data to send via FCM? Can you make an example or link a good example of code if this is possible?
Now my code is inside the wp_insert_post function and so it's executed when you push the button "publish" in new post area.