PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.2.8
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.2.8
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / integrations / class-abstract-integration.php

class-abstract-integration.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.2.8, at includes/integrations/class-abstract-integration.php

228 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The Integration abstract class
5 *
6 * @since 1.1.0
7 */
8 abstract class WeForms_Abstract_Integration {
9
10 /**
11 * The integration id
12 *
13 * @var boolean
14 */
15 public $id;
16
17 /**
18 * If the integration is enabled
19 *
20 * @var boolean
21 */
22 public $enabled;
23
24 /**
25 * Integration title
26 *
27 * @var string
28 */
29 public $title;
30
31 /**
32 * URL to the integration icon
33 *
34 * @var string
35 */
36 public $icon;
37
38 /**
39 * The settings fields for this integrations
40 *
41 * @var array
42 */
43 public $settings_fields = array();
44
45 /**
46 * The settings fields for this integrations
47 *
48 * @var array
49 */
50 protected $template = null;
51
52
53 /**
54 * The settings settings_template
55 *
56 * @var array
57 */
58 protected $settings_template = null;
59
60
61 /**
62 * Get the integration title
63 *
64 * @return string
65 */
66 public function get_title() {
67 return apply_filters( 'weforms_integration_title', $this->title, $this );
68 }
69
70 /**
71 * Get the integration id
72 *
73 * @return string
74 */
75 public function get_id() {
76 return apply_filters( 'weforms_integration_title', $this->id, $this );
77 }
78
79 /**
80 * Get intgration icon
81 *
82 * @return string
83 */
84 public function get_icon() {
85 return apply_filters( 'weforms_integration_icon', $this->icon, $this );
86 }
87
88 /**
89 * Check if the integration is enabled
90 *
91 * @return boolean
92 */
93 public function is_enabled() {
94 return $this->enabled == true;
95 }
96
97 /**
98 * Check if it's a pro field
99 *
100 * @return boolean
101 */
102 public function is_pro() {
103 return false;
104 }
105
106 /**
107 * Get the settings fields
108 *
109 * @return array
110 */
111 public function get_settings_fields() {
112 return $this->settings_fields;
113 }
114
115 /**
116 * Get the integration settings for the component
117 *
118 * @return array
119 */
120 public function get_js_settings() {
121 return array(
122 'id' => $this->get_id(),
123 'title' => $this->get_title(),
124 'icon' => $this->get_icon(),
125 'settings' => $this->get_settings_fields(),
126 'pro' => $this->is_pro()
127 );
128 }
129
130
131 /**
132 * Check if it's the forms page
133 *
134 * @return boolean
135 */
136 public function is_weforms_page() {
137 if ( get_current_screen()->base != 'toplevel_page_weforms' ) {
138 return false;
139 }
140
141 return true;
142 }
143
144 /**
145 * Load the individual template file if exists
146 *
147 * @return void
148 */
149 public function load_template() {
150 if ( ! $this->is_weforms_page() ) {
151 return;
152 }
153
154 if ( ! $this->template ) {
155 return;
156 }
157
158 echo '<script type="text/x-template" id="tmpl-wpuf-integration-' . $this->id . '">';
159 include $this->template;
160 echo '</script>';
161 }
162
163 /**
164 * Load settings
165 *
166 * @return void
167 */
168 public function load_settings( $priority = 10 ) {
169
170 if ( ! $this->settings_template ) {
171 return;
172 }
173
174 add_action( 'weforms_settings_tabs', array( $this, 'settings_tabs' ), $priority );
175 add_action( 'weforms_settings_tab_content_' . $this->id, array( $this, 'settings_panel' ), $priority );
176 }
177
178
179 /**
180 * Render the settings panel
181 *
182 * @return void
183 */
184 public function settings_panel() {
185 if( file_exists( $this->settings_template )) {
186 include $this->settings_template;
187 }
188 }
189
190 /**
191 * Add new tab at settings
192 *
193 * @return void
194 */
195 public function settings_tabs( $tabs ) {
196
197 $tabs[ $this->id ] = array(
198 'label' => $this->title,
199 'icon' => $this->icon,
200 );
201
202 return $tabs;
203 }
204
205 /**
206 * Get file prefix
207 *
208 * @return string
209 */
210 public function get_prefix() {
211 $prefix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
212
213 return $prefix;
214 }
215
216 /**
217 * Get default componenet url
218 *
219 * @return string
220 */
221 public function module_component_file( $plugin_file ) {
222
223 $prefix = $this->get_prefix();
224
225 return plugins_url( 'component/index' . $prefix . '.js', $plugin_file );
226 }
227 }
228