Throughout the WordPress documentation I see callbacks being inserted as strings instead of function variables or closures. Let me examplify that;
function wpdocs_my_save_posts( $post_ID, $post, $update ) {
// do stuff here
}
add_action( 'save_post', 'wpdocs_my_save_post', 10, 3 );
there's a bit of a catch here. This won't work and no editor (vscode) would be able to find out why. Whereas this would red-line:
$wpdocs_my_save_posts = function( $post_ID, $post, $update ) {
// do stuff here
};
add_action( 'save_post', $wpdocs_my_save_post, 10, 3 );
as $wpdocs_my_save_post is not defined.
as apposed to
What is the reason to use a string instead of a function variable in this case?
Not opinionated I just try to understand.