PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / providers / gutenberg / abstract-block.php
wordpress-popup / inc / providers / gutenberg Last commit date
blocks 5 years ago js 5 years ago abstract-block.php 5 years ago gutenberg.php 5 years ago
abstract-block.php
152 lines
1 <?php
2
3 /**
4 * Class Hustle_GHBlock_Abstract
5 * Extend this class to create new gutenberg block
6 *
7 * @since 1.0 Gutenberg Addon
8 */
9 abstract class Hustle_GHBlock_Abstract {
10
11 /**
12 * Module's dependencies for rendering the preview
13 *
14 * @var array
15 */
16 protected $dependencies = array();
17
18 /**
19 * Type will be used as identifier
20 *
21 * @since 1.0 Gutenber Addon
22 *
23 * @var string
24 */
25 protected $_slug;
26
27 /**
28 * Get block type
29 *
30 * @since 1.0 Gutenber Addon
31 * @return string
32 */
33 final public function get_slug() {
34 return $this->_slug;
35 }
36
37 /**
38 * Initialize block
39 *
40 * @since 1.0 Gutenberg Addon
41 */
42 public function init() {
43 // Register block
44 $this->register_block();
45
46 // Load block scripts
47 add_action( 'enqueue_block_editor_assets', array( $this, 'load_assets' ) );
48 }
49
50 /**
51 * Register block type callback
52 * Shouldn't be overridden on block class
53 *
54 * @since 1.0 Gutenberg Addon
55 */
56 public function register_block() {
57
58 if ( function_exists( 'register_block_type' ) ) {
59
60 register_block_type(
61 'hustle/' . $this->get_slug(),
62 array(
63 'render_callback' => array( $this, 'render_block' ),
64 )
65 );
66 }
67
68 }
69
70 /**
71 * Render block on front-end
72 * Should be overriden in block class
73 *
74 * @since 1.0 Gutenberg Addon
75 * @param array $properties Block properties
76 *
77 * @return string
78 */
79 public function render_block( $properties = array() ) {
80 return '';
81 }
82
83 /**
84 * Enqueue assets ( scritps / styles )
85 * Should be overriden in block class
86 *
87 * @since 1.0 Gutenberg Addon
88 */
89 public function load_assets() {
90 return true;
91 }
92
93 /**
94 * Get modules list with shortcode
95 *
96 * @since 1.0 Gutenberg Addon
97 *
98 * @param string $type Module type.
99 *
100 * @return array $module_list List of modules with shortcode.
101 */
102 protected function get_modules_by_type( $type ) {
103 $modules = Hustle_Module_Collection::instance()->get_all( true, array( 'module_type' => $type ) );
104 $module_list = array(
105 array(
106 'value' => '',
107 'label' => esc_html__( 'Choose module name', 'hustle' ),
108 ),
109 );
110 if ( is_array( $modules ) ) {
111 foreach ( $modules as $module ) {
112 $shortcode_id = $module->get_shortcode_id();
113 if ( empty( $shortcode_id ) ) {
114 continue;
115 }
116 if ( ! $this->is_module_included( $module ) ) {
117 continue;
118 }
119
120 $this->check_dependencies( $module );
121
122 $module_list[] = array(
123 'value' => $shortcode_id,
124 'label' => $module->module_name,
125 );
126 }
127 }
128 return $module_list;
129 }
130
131 /**
132 * Check for dependencies in each block type.
133 * To be overridden as required.
134 *
135 * @param Hustle_Model $module Module to be checked.
136 * @return void
137 */
138 protected function check_dependencies( Hustle_Model $module ) {}
139
140 /**
141 * Check in every block type if this module should be available.
142 *
143 * @since 4.0.0
144 *
145 * @param Hustle_Model $module Instance of the current module.
146 * @return bool
147 */
148 protected function is_module_included( Hustle_Model $module ) {
149 return true;
150 }
151 }
152