PluginProbe
HivePress – Business Directory, Listings & Classified Ads Plugin / trunk
HivePress – Business Directory, Listings & Classified Ads Plugin vtrunk
1.7.31 1.7.30 1.7.29 1.7.28 1.7.27 1.7.26 1.7.25 1.7.24 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 All 98 releases
hivepress / includes / blocks / class-callback.php

class-callback.php in HivePress – Business Directory, Listings & Classified Ads Plugin trunk, at includes/blocks/class-callback.php

65 lines 910 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Callback block.
4 *
5 * @package HivePress\Blocks
6 */
7
8 namespace HivePress\Blocks;
9
10 use HivePress\Helpers as hp;
11
12 // Exit if accessed directly.
13 defined( 'ABSPATH' ) || exit;
14
15 /**
16 * Renders the callback result.
17 */
18 class Callback extends Block {
19
20 /**
21 * Callback name.
22 *
23 * @var string
24 */
25 protected $callback;
26
27 /**
28 * Callback parameters.
29 *
30 * @var array
31 */
32 protected $params = [];
33
34 /**
35 * Return the output?
36 *
37 * @var bool
38 */
39 protected $return = false;
40
41 /**
42 * Renders block HTML.
43 *
44 * @return string
45 */
46 public function render() {
47 $output = '';
48
49 if ( function_exists( $this->callback ) ) {
50 if ( $this->return ) {
51 $output = call_user_func_array( $this->callback, $this->params );
52 } else {
53 ob_start();
54
55 call_user_func_array( $this->callback, $this->params );
56 $output = ob_get_contents();
57
58 ob_end_clean();
59 }
60 }
61
62 return $output;
63 }
64 }
65