This would be an good use PHP 5.3+ anonymous functions.
Closure example:
<?php
function Twit_the_url( $post_ID )
{
//connect to twitter api
//send tweet with url
//get twitter response
//send response to admin notice :
add_action('admin_notices', function() use ($httpstatus) {
echo '<div class="error"><p>', esc_html($httpstatus), '</p></div>';
});
return $post_ID;
}
add_action( 'publish_post', 'Twit_the_url');
Alternatively, you could wrap up both the Twit_the_url
and admin_notices
callback into a class and use class property.