PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.9
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.9
7.8.14 7.8.14.1 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 3 years ago css 3 years ago js 3 years ago abstract-block.php 3 years ago gutenberg.php 3 years ago
abstract-block.php
157 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Hustle_GHBlock_Abstract class
4 *
5 * @package Hustle
6 */
7
8 /**
9 * Class Hustle_GHBlock_Abstract
10 * Extend this class to create new gutenberg block
11 *
12 * @since 1.0 Gutenberg Addon
13 */
14 abstract class Hustle_GHBlock_Abstract {
15
16 /**
17 * Module's dependencies for rendering the preview
18 *
19 * @var array
20 */
21 protected $dependencies = array();
22
23 /**
24 * Type will be used as identifier
25 *
26 * @since 1.0 Gutenber Addon
27 *
28 * @var string
29 */
30 protected $slug;
31
32 /**
33 * Get block type
34 *
35 * @since 1.0 Gutenber Addon
36 * @return string
37 */
38 final public function get_slug() {
39 return $this->slug;
40 }
41
42 /**
43 * Initialize block
44 *
45 * @since 1.0 Gutenberg Addon
46 */
47 public function init() {
48 // Register block.
49 $this->register_block();
50
51 // Load block scripts.
52 add_action( 'enqueue_block_editor_assets', array( $this, 'load_assets' ) );
53 }
54
55 /**
56 * Register block type callback
57 * Shouldn't be overridden on block class
58 *
59 * @since 1.0 Gutenberg Addon
60 */
61 public function register_block() {
62
63 if ( function_exists( 'register_block_type' ) ) {
64
65 register_block_type(
66 'hustle/' . $this->get_slug(),
67 array(
68 'render_callback' => array( $this, 'render_block' ),
69 )
70 );
71 }
72
73 }
74
75 /**
76 * Render block on front-end
77 * Should be overriden in block class
78 *
79 * @since 1.0 Gutenberg Addon
80 * @param array $properties Block properties.
81 *
82 * @return string
83 */
84 public function render_block( $properties = array() ) {
85 return '';
86 }
87
88 /**
89 * Enqueue assets ( scritps / styles )
90 * Should be overriden in block class
91 *
92 * @since 1.0 Gutenberg Addon
93 */
94 public function load_assets() {
95 return true;
96 }
97
98 /**
99 * Get modules list with shortcode
100 *
101 * @since 1.0 Gutenberg Addon
102 *
103 * @param string $type Module type.
104 *
105 * @return array $module_list List of modules with shortcode.
106 */
107 protected function get_modules_by_type( $type ) {
108 $modules = Hustle_Module_Collection::instance()->get_all( true, array( 'module_type' => $type ) );
109 $module_list = array(
110 array(
111 'value' => '',
112 'label' => esc_html__( 'Choose module name', 'hustle' ),
113 ),
114 );
115 if ( is_array( $modules ) ) {
116 foreach ( $modules as $module ) {
117 $shortcode_id = $module->get_shortcode_id();
118 if ( empty( $shortcode_id ) ) {
119 continue;
120 }
121 if ( ! $this->is_module_included( $module ) ) {
122 continue;
123 }
124
125 $this->check_dependencies( $module );
126
127 $module_list[] = array(
128 'value' => esc_html( $shortcode_id ),
129 'label' => esc_html( $module->module_name ),
130 );
131 }
132 }
133 return $module_list;
134 }
135
136 /**
137 * Check for dependencies in each block type.
138 * To be overridden as required.
139 *
140 * @param Hustle_Model $module Module to be checked.
141 * @return void
142 */
143 protected function check_dependencies( Hustle_Model $module ) {}
144
145 /**
146 * Check in every block type if this module should be available.
147 *
148 * @since 4.0.0
149 *
150 * @param Hustle_Model $module Instance of the current module.
151 * @return bool
152 */
153 protected function is_module_included( Hustle_Model $module ) {
154 return true;
155 }
156 }
157