All through the WordPress documentation I see callbacks being inserted as strings as an alternative of operate variables or closures. Let me examplify that;
operate wpdocs_my_save_posts( $post_ID, $put up, $replace ) {
// do stuff right here
}
add_action( 'save_post', 'wpdocs_my_save_post', 10, 3 );
there is a little bit of a catch right here. This would possibly not work and no editor (vscode) would have the ability to discover out why. Whereas this might red-line:
$wpdocs_my_save_posts = operate( $post_ID, $put up, $replace ) {
// do stuff right here
};
add_action( 'save_post', $wpdocs_my_save_post, 10, 3 );
as $wpdocs_my_save_post shouldn’t be outlined.
What’s the purpose to make use of a string as an alternative of a operate variable on this case?
Not opinionated I simply attempt to perceive.