class-callback.php
<?php
namespace HivePress\Blocks;
use HivePress\Helpers as hp;
defined( 'ABSPATH' ) || exit;
class Callback extends Block {
protected $callback;
protected $params = [];
protected $return = false;
public function render() {
$output = '';
if ( function_exists( $this->callback ) ) {
if ( $this->return ) {
$output = call_user_func_array( $this->callback, $this->params );
} else {
ob_start();
call_user_func_array( $this->callback, $this->params );
$output = ob_get_contents();
ob_end_clean();
}
}
return $output;
}
}