So there is the following scenario.
I add an action to clean logs from the database:
add_action( 'myplugin_clean_logs', array( 'MyPlugin_Logs', 'clean_logs' ) );
Now I want to run this action periodically:
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'myplugin_clean_logs' );
and execute it manually:
do_action( 'myplugin_clean_logs' );
MyPlugin_Logs::clean_logs returns the count of affected rows or false if something went the other direction.
Now I want to display the number of rows that have been deleted. I would imagine something like this:
$affected_rows = do_action( 'myplugin_clean_logs' ); echo $affected_rows . ' entries have been deleted.';
do_action will not return any value, I have no idea how to get the return value.
Should I execute the method directly on a manual run, but use the action on schedule events?