PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.12.3
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.12.3
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
sureforms / inc / blocks / base.php
base.php
73 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The blocks base file.
4 *
5 * @link https://sureforms.com
6 * @since 0.0.1
7 * @package SureForms
8 * @author SureForms <https://sureforms.com/>
9 */
10
11 namespace SRFM\Inc\Blocks;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 /**
18 * Block base class.
19 */
20 abstract class Base {
21 /**
22 * Optional directory to .json block data files.
23 *
24 * @var string
25 * @since 0.0.1
26 */
27 protected $directory = '';
28
29 /**
30 * Register the block for dynamic output
31 *
32 * @return void
33 * @since 0.0.1
34 */
35 public function register() {
36 register_block_type_from_metadata(
37 $this->get_dir(),
38 apply_filters(
39 'srfm_block_registration_args',
40 [ 'render_callback' => [ $this, 'render' ] ]
41 )
42 );
43 }
44
45 /**
46 * Get the called class directory path
47 *
48 * @return string
49 * @since 0.0.1
50 */
51 public function get_dir() {
52 if ( $this->directory ) {
53 return $this->directory;
54 }
55
56 $reflector = new \ReflectionClass( $this );
57 $fn = (string) $reflector->getFileName();
58 return dirname( $fn );
59 }
60
61 /**
62 * Render the block
63 *
64 * @param array<mixed> $attributes Block attributes.
65 *
66 * @return string
67 * @since 0.0.1
68 */
69 public function render( $attributes ) {
70 return '';
71 }
72 }
73