beans_render_function

Calls function given by the first parameter and passes the remaining parameters as arguments.

The main purpose of this function is to store the content echoed by a function in a variable.

beans_render_function( callback $callback )

Return: (string) The callback content.

Parameters

NameTypeRequiredDefaultDescription
$callbackcallbacktrue-The callback to be called.
$varmixedtrue-Additional parameters to be passed to the callback.

Source

function beans_render_function( $callback ) {

	if ( ! is_callable( $callback ) ) {
		return;
	}

	$args = func_get_args();

	ob_start();

		call_user_func_array( $callback, array_slice( $args, 1 ) );

	return ob_get_clean();

}