PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14.1
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14.1
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 5 months ago css 3 years ago js 5 days ago abstract-block.php 5 days ago gutenberg.php 5 months ago
abstract-block.php
163 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 'editor_style_handles' => array(
70 'hustle_info',
71 'hustle_icons',
72 'hustle_optin',
73 'hustle_inline',
74 'hustle_social',
75 ),
76 )
77 );
78 }
79 }
80
81 /**
82 * Render block on front-end
83 * Should be overriden in block class
84 *
85 * @since 1.0 Gutenberg Addon
86 * @param array $properties Block properties.
87 *
88 * @return string
89 */
90 public function render_block( $properties = array() ) {
91 return '';
92 }
93
94 /**
95 * Enqueue assets ( scritps / styles )
96 * Should be overriden in block class
97 *
98 * @since 1.0 Gutenberg Addon
99 */
100 public function load_assets() {
101 return true;
102 }
103
104 /**
105 * Get modules list with shortcode
106 *
107 * @since 1.0 Gutenberg Addon
108 *
109 * @param string $type Module type.
110 *
111 * @return array $module_list List of modules with shortcode.
112 */
113 protected function get_modules_by_type( $type ) {
114 $modules = Hustle_Module_Collection::instance()->get_all( true, array( 'module_type' => $type ) );
115 $module_list = array(
116 array(
117 'value' => '',
118 'label' => esc_html__( 'Choose module name', 'hustle' ),
119 ),
120 );
121 if ( is_array( $modules ) ) {
122 foreach ( $modules as $module ) {
123 $shortcode_id = $module->get_shortcode_id();
124 if ( empty( $shortcode_id ) ) {
125 continue;
126 }
127 if ( ! $this->is_module_included( $module ) ) {
128 continue;
129 }
130
131 $this->check_dependencies( $module );
132
133 $module_list[] = array(
134 'value' => esc_html( $shortcode_id ),
135 'label' => esc_html( $module->module_name ),
136 );
137 }
138 }
139 return $module_list;
140 }
141
142 /**
143 * Check for dependencies in each block type.
144 * To be overridden as required.
145 *
146 * @param Hustle_Model $module Module to be checked.
147 * @return void
148 */
149 protected function check_dependencies( Hustle_Model $module ) {}
150
151 /**
152 * Check in every block type if this module should be available.
153 *
154 * @since 4.0.0
155 *
156 * @param Hustle_Model $module Instance of the current module.
157 * @return bool
158 */
159 protected function is_module_included( Hustle_Model $module ) {
160 return true;
161 }
162 }
163