Version Description
Download this release
Release Info
Developer | danieliser |
Plugin | Popup Maker – Popup Forms, Optins & More |
Version | 1.8.1 |
Comparing to | |
See all releases |
Code changes from version 1.8.0 to 1.8.1
- classes/Model/Theme.php +499 -499
- classes/Utils/Alerts.php +2 -2
- includes/integrations/class-pum-buddypress-integration.php +248 -248
- languages/popup-maker.pot +48 -0
- popup-maker.php +423 -423
- readme.txt +5 -1
classes/Model/Theme.php
CHANGED
@@ -1,499 +1,499 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright (c) 2018, WP Popup Maker
|
4 |
-
******************************************************************************/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit;
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class PUM_Model_Theme
|
12 |
-
*
|
13 |
-
* @since 1.8
|
14 |
-
*/
|
15 |
-
class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
16 |
-
|
17 |
-
/** @var string */
|
18 |
-
protected $required_post_type = 'popup_theme';
|
19 |
-
|
20 |
-
/** @var array */
|
21 |
-
public $settings;
|
22 |
-
|
23 |
-
/** @var bool */
|
24 |
-
public $doing_passive_migration = false;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* The current model version.
|
28 |
-
*
|
29 |
-
* 1 - v1.0.0
|
30 |
-
* 2 - v1.3.0
|
31 |
-
* 3 - v1.8.0
|
32 |
-
*
|
33 |
-
* @var int
|
34 |
-
*/
|
35 |
-
public $model_version = 3;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* The version of the data currently stored for the current item.
|
39 |
-
*
|
40 |
-
* 1 - v1.0.0
|
41 |
-
* 2 - v1.3.0
|
42 |
-
* 3 - v1.8.0
|
43 |
-
*
|
44 |
-
* @var int
|
45 |
-
*/
|
46 |
-
public $data_version;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Returns array of all theme settings.
|
50 |
-
*
|
51 |
-
* @return array
|
52 |
-
*/
|
53 |
-
public function get_settings() {
|
54 |
-
$this->settings = $this->get_meta( 'popup_theme_settings' );
|
55 |
-
|
56 |
-
if ( ! is_array( $this->settings ) ) {
|
57 |
-
$this->settings = array();
|
58 |
-
}
|
59 |
-
|
60 |
-
return apply_filters( 'pum_theme_settings', $this->settings, $this->ID );
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Returns a specific theme setting with optional default value when not found.
|
65 |
-
*
|
66 |
-
* @param $key
|
67 |
-
* @param bool $default
|
68 |
-
*
|
69 |
-
* @return bool|mixed
|
70 |
-
*/
|
71 |
-
public function get_setting( $key, $default = false ) {
|
72 |
-
$settings = $this->get_settings();
|
73 |
-
|
74 |
-
return isset( $settings[ $key ] ) ? $settings[ $key ] : $default;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* @param string $key
|
79 |
-
* @param mixed $value
|
80 |
-
*
|
81 |
-
* @return bool|int
|
82 |
-
*/
|
83 |
-
public function update_setting( $key, $value ) {
|
84 |
-
$settings = $this->get_settings();
|
85 |
-
|
86 |
-
$settings[ $key ] = $value;
|
87 |
-
|
88 |
-
return $this->update_meta( 'popup_theme_settings', $settings );
|
89 |
-
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* @param array $merge_settings
|
93 |
-
*
|
94 |
-
* @return bool|int
|
95 |
-
*/
|
96 |
-
public function update_settings( $merge_settings = array() ) {
|
97 |
-
$settings = $this->get_settings();
|
98 |
-
|
99 |
-
foreach ( $merge_settings as $key => $value ) {
|
100 |
-
$settings[ $key ] = $value;
|
101 |
-
}
|
102 |
-
|
103 |
-
return $this->update_meta( 'popup_theme_settings', $settings );
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Returns array of all google font variations used for this theme.
|
108 |
-
*
|
109 |
-
* @return array
|
110 |
-
*/
|
111 |
-
public function get_google_fonts_used() {
|
112 |
-
$fonts_used = array();
|
113 |
-
|
114 |
-
$settings = $this->get_settings();
|
115 |
-
|
116 |
-
$google_fonts = PUM_Integration_GoogleFonts::fetch_fonts();
|
117 |
-
|
118 |
-
if ( ! empty( $settings['title_font_family'] ) && is_string( $settings['title_font_family'] ) && array_key_exists( $settings['title_font_family'], $google_fonts ) ) {
|
119 |
-
$variant = ! empty( $settings['title_font_weight'] ) && $settings['title_font_weight'] != 'normal' ? $settings['title_font_weight'] : '';
|
120 |
-
if ( isset( $settings['title_font_style'] ) && $settings['title_font_style'] == 'italic' ) {
|
121 |
-
$variant .= 'italic';
|
122 |
-
}
|
123 |
-
$fonts_used[ $settings['title_font_family'] ][ $variant ] = $variant;
|
124 |
-
}
|
125 |
-
if ( ! empty( $settings['content_font_family'] ) && is_string( $settings['content_font_family'] ) && array_key_exists( $settings['content_font_family'], $google_fonts ) ) {
|
126 |
-
$variant = ! empty( $settings['content_font_weight'] ) && $settings['content_font_weight'] != 'normal' ? $settings['content_font_weight'] : '';
|
127 |
-
if ( isset( $settings['content_font_style'] ) && $settings['content_font_style'] == 'italic' ) {
|
128 |
-
$variant .= 'italic';
|
129 |
-
}
|
130 |
-
$fonts_used[ $settings['content_font_family'] ][ $variant ] = $variant;
|
131 |
-
}
|
132 |
-
if ( ! empty( $settings['close_font_family'] ) && is_string( $settings['close_font_family'] ) && array_key_exists( $settings['close_font_family'], $google_fonts ) ) {
|
133 |
-
$variant = ! empty( $settings['close_font_weight'] ) && $settings['close_font_weight'] != 'normal' ? $settings['close_font_weight'] : '';
|
134 |
-
if ( isset( $settings['close_font_style'] ) && $settings['close_font_style'] == 'italic' ) {
|
135 |
-
$variant .= 'italic';
|
136 |
-
}
|
137 |
-
$fonts_used[ $settings['close_font_family'] ][ $variant ] = $variant;
|
138 |
-
}
|
139 |
-
|
140 |
-
return $fonts_used;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @return array
|
145 |
-
*/
|
146 |
-
public function get_generated_styles() {
|
147 |
-
|
148 |
-
$styles = array(
|
149 |
-
'overlay' => array(),
|
150 |
-
'container' => array(),
|
151 |
-
'title' => array(),
|
152 |
-
'content' => array(),
|
153 |
-
'close' => array(),
|
154 |
-
);
|
155 |
-
|
156 |
-
/*
|
157 |
-
* Overlay Styles
|
158 |
-
*/
|
159 |
-
if (
|
160 |
-
$styles['overlay']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'overlay_background_color' ), $this->get_setting( 'overlay_background_opacity' ) );
|
161 |
-
}
|
162 |
-
|
163 |
-
/*
|
164 |
-
* Container Styles
|
165 |
-
*/
|
166 |
-
$styles['container'] = array(
|
167 |
-
'padding' => "{$this->get_setting('container_padding')}px",
|
168 |
-
'border-radius' => "{$this->get_setting('container_border_radius')}px",
|
169 |
-
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'container_border_width' ), $this->get_setting( 'container_border_style' ), $this->get_setting( 'container_border_color' ) ),
|
170 |
-
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'container_boxshadow_horizontal' ), $this->get_setting( 'container_boxshadow_vertical' ), $this->get_setting( 'container_boxshadow_blur' ), $this->get_setting( 'container_boxshadow_spread' ), $this->get_setting( 'container_boxshadow_color' ), $this->get_setting( 'container_boxshadow_opacity' ), $this->get_setting( 'container_boxshadow_inset' ) ),
|
171 |
-
);
|
172 |
-
|
173 |
-
if (
|
174 |
-
$styles['container']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'container_background_color' ), $this->get_setting( 'container_background_opacity' ) );
|
175 |
-
}
|
176 |
-
|
177 |
-
/*
|
178 |
-
* Title Styles
|
179 |
-
*/
|
180 |
-
$styles['title'] = array(
|
181 |
-
'color' => $this->get_setting( 'title_font_color' ),
|
182 |
-
'text-align' => $this->get_setting( 'title_text_align' ),
|
183 |
-
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'title_textshadow_horizontal' ), $this->get_setting( 'title_textshadow_vertical' ), $this->get_setting( 'title_textshadow_blur' ), $this->get_setting( 'title_textshadow_color' ), $this->get_setting( 'title_textshadow_opacity' ) ),
|
184 |
-
'font-family' => $this->get_setting( 'title_font_family' ),
|
185 |
-
'font-weight' => $this->get_setting( 'title_font_weight' ),
|
186 |
-
'font-size' => "{$this->get_setting( 'title_font_size' )}px",
|
187 |
-
'font-style' => $this->get_setting( 'title_font_style' ),
|
188 |
-
'line-height' => "{$this->get_setting( 'title_line_height' )}px",
|
189 |
-
);
|
190 |
-
|
191 |
-
/*
|
192 |
-
* Content Styles
|
193 |
-
*/
|
194 |
-
$styles['content'] = array(
|
195 |
-
'color' => $this->get_setting( 'content_font_color' ),
|
196 |
-
'font-family' => $this->get_setting( 'content_font_family' ),
|
197 |
-
'font-weight' => $this->get_setting( 'content_font_weight' ),
|
198 |
-
'font-style' => $this->get_setting( 'content_font_style' ),
|
199 |
-
);
|
200 |
-
|
201 |
-
/*
|
202 |
-
* Close Styles
|
203 |
-
*/
|
204 |
-
$styles['close'] = array(
|
205 |
-
'position' => $this->get_setting( 'close_position_outside' ) ? 'fixed' : 'absolute',
|
206 |
-
'height' =>
|
207 |
-
'width' =>
|
208 |
-
'left' => 'auto',
|
209 |
-
'right' => 'auto',
|
210 |
-
'bottom' => 'auto',
|
211 |
-
'top' => 'auto',
|
212 |
-
'padding' => "{$this->get_setting('close_padding')}px",
|
213 |
-
'color' => $this->get_setting( 'close_font_color' ),
|
214 |
-
'font-family' => $this->get_setting( 'close_font_family' ),
|
215 |
-
'font-weight' => $this->get_setting( 'close_font_weight' ),
|
216 |
-
'font-size' => "{$this->get_setting('close_font_size')}px",
|
217 |
-
'font-style' => $this->get_setting( 'close_font_style' ),
|
218 |
-
'line-height' => "{$this->get_setting('close_line_height')}px",
|
219 |
-
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'close_border_width' ), $this->get_setting( 'close_border_style' ), $this->get_setting( 'close_border_color' ) ),
|
220 |
-
'border-radius' => "{$this->get_setting('close_border_radius')}px",
|
221 |
-
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'close_boxshadow_horizontal' ), $this->get_setting( 'close_boxshadow_vertical' ), $this->get_setting( 'close_boxshadow_blur' ), $this->get_setting( 'close_boxshadow_spread' ), $this->get_setting( 'close_boxshadow_color' ), $this->get_setting( 'close_boxshadow_opacity' ), $this->get_setting( 'close_boxshadow_inset' ) ),
|
222 |
-
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'close_textshadow_horizontal' ), $this->get_setting( 'close_textshadow_vertical' ), $this->get_setting( 'close_textshadow_blur' ), $this->get_setting( 'close_textshadow_color' ), $this->get_setting( 'close_textshadow_opacity' ) ),
|
223 |
-
);
|
224 |
-
|
225 |
-
if (
|
226 |
-
$styles['close']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'close_background_color' ), $this->get_setting( 'close_background_opacity' ) );
|
227 |
-
}
|
228 |
-
|
229 |
-
$top = "{$this->get_setting('close_position_top')}px";
|
230 |
-
$left = "{$this->get_setting('close_position_left')}px";
|
231 |
-
$right = "{$this->get_setting('close_position_right')}px";
|
232 |
-
$bottom = "{$this->get_setting('close_position_bottom')}px";
|
233 |
-
|
234 |
-
switch ( $this->get_setting( 'close_location' ) ) {
|
235 |
-
case "topleft":
|
236 |
-
$styles['close']['top'] = $top;
|
237 |
-
$styles['close']['left'] = $left;
|
238 |
-
break;
|
239 |
-
case "topcenter":
|
240 |
-
$styles['close']['top'] = $top;
|
241 |
-
$styles['close']['left'] = "50%";
|
242 |
-
$styles['close']['transform'] = "translateX(-50%)";
|
243 |
-
break;
|
244 |
-
case "topright":
|
245 |
-
$styles['close']['top'] = $top;
|
246 |
-
$styles['close']['right'] = $right;
|
247 |
-
break;
|
248 |
-
case 'middleleft':
|
249 |
-
$styles['close']['top'] = "50%";
|
250 |
-
$styles['close']['left'] = $left;
|
251 |
-
$styles['close']['transform'] = "translate(0, -50%)";
|
252 |
-
break;
|
253 |
-
case 'middleright':
|
254 |
-
$styles['close']['top'] = "50%";
|
255 |
-
$styles['close']['right'] = $right;
|
256 |
-
$styles['close']['transform'] = "translate(0, -50%)";
|
257 |
-
break;
|
258 |
-
case "bottomleft":
|
259 |
-
$styles['close']['bottom'] = $bottom;
|
260 |
-
$styles['close']['left'] = $left;
|
261 |
-
break;
|
262 |
-
case "bottomcenter":
|
263 |
-
$styles['close']['bottom'] = $bottom;
|
264 |
-
$styles['close']['left'] = "50%";
|
265 |
-
$styles['close']['transform'] = "translateX(-50%)";
|
266 |
-
break;
|
267 |
-
case "bottomright":
|
268 |
-
$styles['close']['bottom'] = $bottom;
|
269 |
-
$styles['close']['right'] = $right;
|
270 |
-
break;
|
271 |
-
}
|
272 |
-
|
273 |
-
/** @deprecated 1.8.0 filter */
|
274 |
-
$styles = (array) apply_filters( 'popmake_generate_theme_styles', (array) $styles, $this->ID, $this->get_deprecated_settings() );
|
275 |
-
|
276 |
-
return (array) apply_filters( 'pum_theme_get_generated_styles', (array) $styles, $this->ID );
|
277 |
-
}
|
278 |
-
|
279 |
-
public function get_deprecated_settings() {
|
280 |
-
return array(
|
281 |
-
'overlay' => $this->_dep_get_settings_group( 'overlay' ),
|
282 |
-
'container' => $this->_dep_get_settings_group( 'container' ),
|
283 |
-
'title' => $this->_dep_get_settings_group( 'title' ),
|
284 |
-
'content' => $this->_dep_get_settings_group( 'content' ),
|
285 |
-
'close' => $this->_dep_get_settings_group( 'close' ),
|
286 |
-
);
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Retrieve settings in the form of deprecated grouped arrays.
|
291 |
-
*
|
292 |
-
* @param $group
|
293 |
-
* @param null $key
|
294 |
-
*
|
295 |
-
* @return mixed
|
296 |
-
*/
|
297 |
-
public function _dep_get_settings_group( $group, $key = null ) {
|
298 |
-
if ( ! isset( $this->$group ) ) {
|
299 |
-
/**
|
300 |
-
* Remap old meta settings to new settings location for v1.7. This acts as a passive migration when needed.
|
301 |
-
*/
|
302 |
-
$remapped_keys = $this->remapped_meta_settings_keys( $group );
|
303 |
-
|
304 |
-
// This will only return data from extensions as core data has been migrated already.
|
305 |
-
$group_values = $this->get_meta( "popup_theme_$group" );
|
306 |
-
|
307 |
-
if ( ! $group_values || ! is_array( $group_values ) ) {
|
308 |
-
$group_values = array();
|
309 |
-
}
|
310 |
-
|
311 |
-
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
312 |
-
foreach ( $remapped_keys as $old_key => $new_key ) {
|
313 |
-
$group_values[ $old_key ] = $this->get_setting( $new_key );
|
314 |
-
}
|
315 |
-
|
316 |
-
$deprecated_values = pum_get_theme_v1_meta( $group, $this->ID );
|
317 |
-
|
318 |
-
if ( ! empty( $deprecated_values ) ) {
|
319 |
-
foreach ( $deprecated_values as $old_key => $value ) {
|
320 |
-
|
321 |
-
if ( ! isset( $group_values[ $old_key ] ) ) {
|
322 |
-
$group_values[ $old_key ] = $value;
|
323 |
-
}
|
324 |
-
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
|
329 |
-
$this->$group = $group_values;
|
330 |
-
}
|
331 |
-
|
332 |
-
$values = apply_filters( "pum_theme_get_$group", $this->$group, $this->ID );
|
333 |
-
|
334 |
-
if ( ! $key ) {
|
335 |
-
return $values;
|
336 |
-
}
|
337 |
-
|
338 |
-
$value = isset ( $values[ $key ] ) ? $values[ $key ] : null;
|
339 |
-
|
340 |
-
if ( ! isset( $value ) ) {
|
341 |
-
$value = $this->get_meta( "popup_theme_{$group}_{$key}" );
|
342 |
-
}
|
343 |
-
|
344 |
-
return apply_filters( "pum_theme_get_{$group}_" . $key, $value, $this->ID );
|
345 |
-
}
|
346 |
-
|
347 |
-
/**
|
348 |
-
* @param $group
|
349 |
-
*
|
350 |
-
* @return array|mixed
|
351 |
-
*/
|
352 |
-
public function remapped_meta_settings_keys( $group ) {
|
353 |
-
$remapped_meta_settings_keys = array(
|
354 |
-
'overlay' => array(
|
355 |
-
'background_color' => 'overlay_background_color',
|
356 |
-
'background_opacity' => 'overlay_background_opacity',
|
357 |
-
),
|
358 |
-
'container' => array(
|
359 |
-
'padding' => 'container_padding',
|
360 |
-
'background_color' => 'container_background_color',
|
361 |
-
'background_opacity' => 'container_background_opacity',
|
362 |
-
'border_style' => 'container_border_style',
|
363 |
-
'border_color' => 'container_border_color',
|
364 |
-
'border_width' => 'container_border_width',
|
365 |
-
'border_radius' => 'container_border_radius',
|
366 |
-
'boxshadow_inset' => 'container_boxshadow_inset',
|
367 |
-
'boxshadow_horizontal' => 'container_boxshadow_horizontal',
|
368 |
-
'boxshadow_vertical' => 'container_boxshadow_vertical',
|
369 |
-
'boxshadow_blur' => 'container_boxshadow_blur',
|
370 |
-
'boxshadow_spread' => 'container_boxshadow_spread',
|
371 |
-
'boxshadow_color' => 'container_boxshadow_color',
|
372 |
-
'boxshadow_opacity' => 'container_boxshadow_opacity',
|
373 |
-
),
|
374 |
-
'title' => array(
|
375 |
-
'font_color' => 'title_font_color',
|
376 |
-
'line_height' => 'title_line_height',
|
377 |
-
'font_size' => 'title_font_size',
|
378 |
-
'font_family' => 'title_font_family',
|
379 |
-
'font_weight' => 'title_font_weight',
|
380 |
-
'font_style' => 'title_font_style',
|
381 |
-
'text_align' => 'title_text_align',
|
382 |
-
'textshadow_horizontal' => 'title_textshadow_horizontal',
|
383 |
-
'textshadow_vertical' => 'title_textshadow_vertical',
|
384 |
-
'textshadow_blur' => 'title_textshadow_blur',
|
385 |
-
'textshadow_color' => 'title_textshadow_color',
|
386 |
-
'textshadow_opacity' => 'title_textshadow_opacity',
|
387 |
-
),
|
388 |
-
'content' => array(
|
389 |
-
'font_color' => 'content_font_color',
|
390 |
-
'font_family' => 'content_font_family',
|
391 |
-
'font_weight' => 'content_font_weight',
|
392 |
-
'font_style' => 'content_font_style',
|
393 |
-
),
|
394 |
-
'close' => array(
|
395 |
-
'text' => 'close_text',
|
396 |
-
'location' => 'close_location',
|
397 |
-
'position_top' => 'close_position_top',
|
398 |
-
'position_left' => 'close_position_left',
|
399 |
-
'position_bottom' => 'close_position_bottom',
|
400 |
-
'position_right' => 'close_position_right',
|
401 |
-
'padding' => 'close_padding',
|
402 |
-
'height' => 'close_height',
|
403 |
-
'width' => 'close_width',
|
404 |
-
'background_color' => 'close_background_color',
|
405 |
-
'background_opacity' => 'close_background_opacity',
|
406 |
-
'font_color' => 'close_font_color',
|
407 |
-
'line_height' => 'close_line_height',
|
408 |
-
'font_size' => 'close_font_size',
|
409 |
-
'font_family' => 'close_font_family',
|
410 |
-
'font_weight' => 'close_font_weight',
|
411 |
-
'font_style' => 'close_font_style',
|
412 |
-
'border_style' => 'close_border_style',
|
413 |
-
'border_color' => 'close_border_color',
|
414 |
-
'border_width' => 'close_border_width',
|
415 |
-
'border_radius' => 'close_border_radius',
|
416 |
-
'boxshadow_inset' => 'close_boxshadow_inset',
|
417 |
-
'boxshadow_horizontal' => 'close_boxshadow_horizontal',
|
418 |
-
'boxshadow_vertical' => 'close_boxshadow_vertical',
|
419 |
-
'boxshadow_blur' => 'close_boxshadow_blur',
|
420 |
-
'boxshadow_spread' => 'close_boxshadow_spread',
|
421 |
-
'boxshadow_color' => 'close_boxshadow_color',
|
422 |
-
'boxshadow_opacity' => 'close_boxshadow_opacity',
|
423 |
-
'textshadow_horizontal' => 'close_textshadow_horizontal',
|
424 |
-
'textshadow_vertical' => 'close_textshadow_vertical',
|
425 |
-
'textshadow_blur' => 'close_textshadow_blur',
|
426 |
-
'textshadow_color' => 'close_textshadow_color',
|
427 |
-
'textshadow_opacity' => 'close_textshadow_opacity',
|
428 |
-
),
|
429 |
-
);
|
430 |
-
|
431 |
-
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] : array();
|
432 |
-
}
|
433 |
-
|
434 |
-
/**
|
435 |
-
* @param WP_Post $post
|
436 |
-
*/
|
437 |
-
public function setup( $post ) {
|
438 |
-
parent::setup( $post );
|
439 |
-
|
440 |
-
if ( ! $this->is_valid() ) {
|
441 |
-
return;
|
442 |
-
}
|
443 |
-
|
444 |
-
if ( $this->ID === 5 ) {
|
445 |
-
$test = '1';
|
446 |
-
}
|
447 |
-
|
448 |
-
if ( ! isset( $this->data_version ) ) {
|
449 |
-
$this->data_version = (int) $this->get_meta( 'popup_theme_data_version' );
|
450 |
-
|
451 |
-
if ( ! $this->data_version ) {
|
452 |
-
$theme_overlay_v1 = $this->get_meta( 'popup_theme_overlay_background_color' );
|
453 |
-
$theme_overlay_v2 = $this->get_meta( 'popup_theme_overlay' );
|
454 |
-
|
455 |
-
// If there are existing settings set the data version to 1/2 so they can be updated.
|
456 |
-
// Otherwise set to the current version as this is a new popup.
|
457 |
-
if ( ! empty( $theme_overlay_v1 ) ) {
|
458 |
-
$this->data_version = 1;
|
459 |
-
} else if ( ! empty( $theme_overlay_v2 ) && is_array( $theme_overlay_v2 ) ) {
|
460 |
-
$this->data_version = 2;
|
461 |
-
} else {
|
462 |
-
$this->data_version = $this->model_version;
|
463 |
-
}
|
464 |
-
|
465 |
-
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
466 |
-
}
|
467 |
-
}
|
468 |
-
|
469 |
-
if ( $this->data_version < $this->model_version && pum_passive_theme_upgrades_enabled() ) {
|
470 |
-
/**
|
471 |
-
* Process passive settings migration as each popup is loaded. The will only run each migration routine once for each popup.
|
472 |
-
*/
|
473 |
-
$this->passive_migration();
|
474 |
-
}
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Allows for passive migration routines based on the current data version.
|
479 |
-
*/
|
480 |
-
public function passive_migration() {
|
481 |
-
$this->doing_passive_migration = true;
|
482 |
-
|
483 |
-
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
484 |
-
// Process migration for current version. ex. current version is 2, runs pum_theme_passive_migration_2.
|
485 |
-
do_action_ref_array( 'pum_theme_passive_migration_' . $this->data_version, array( &$this ) );
|
486 |
-
$this->data_version ++;
|
487 |
-
|
488 |
-
/**
|
489 |
-
* Update the themes data version.
|
490 |
-
*/
|
491 |
-
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
492 |
-
}
|
493 |
-
|
494 |
-
do_action_ref_array( 'pum_theme_passive_migration', array( &$this, $this->data_version ) );
|
495 |
-
|
496 |
-
$this->doing_passive_migration = false;
|
497 |
-
}
|
498 |
-
}
|
499 |
-
|
1 |
+
<?php
|
2 |
+
/*******************************************************************************
|
3 |
+
* Copyright (c) 2018, WP Popup Maker
|
4 |
+
******************************************************************************/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit;
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class PUM_Model_Theme
|
12 |
+
*
|
13 |
+
* @since 1.8
|
14 |
+
*/
|
15 |
+
class PUM_Model_Theme extends PUM_Abstract_Model_Post {
|
16 |
+
|
17 |
+
/** @var string */
|
18 |
+
protected $required_post_type = 'popup_theme';
|
19 |
+
|
20 |
+
/** @var array */
|
21 |
+
public $settings;
|
22 |
+
|
23 |
+
/** @var bool */
|
24 |
+
public $doing_passive_migration = false;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The current model version.
|
28 |
+
*
|
29 |
+
* 1 - v1.0.0
|
30 |
+
* 2 - v1.3.0
|
31 |
+
* 3 - v1.8.0
|
32 |
+
*
|
33 |
+
* @var int
|
34 |
+
*/
|
35 |
+
public $model_version = 3;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* The version of the data currently stored for the current item.
|
39 |
+
*
|
40 |
+
* 1 - v1.0.0
|
41 |
+
* 2 - v1.3.0
|
42 |
+
* 3 - v1.8.0
|
43 |
+
*
|
44 |
+
* @var int
|
45 |
+
*/
|
46 |
+
public $data_version;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Returns array of all theme settings.
|
50 |
+
*
|
51 |
+
* @return array
|
52 |
+
*/
|
53 |
+
public function get_settings() {
|
54 |
+
$this->settings = $this->get_meta( 'popup_theme_settings' );
|
55 |
+
|
56 |
+
if ( ! is_array( $this->settings ) ) {
|
57 |
+
$this->settings = array();
|
58 |
+
}
|
59 |
+
|
60 |
+
return apply_filters( 'pum_theme_settings', $this->settings, $this->ID );
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Returns a specific theme setting with optional default value when not found.
|
65 |
+
*
|
66 |
+
* @param $key
|
67 |
+
* @param bool $default
|
68 |
+
*
|
69 |
+
* @return bool|mixed
|
70 |
+
*/
|
71 |
+
public function get_setting( $key, $default = false ) {
|
72 |
+
$settings = $this->get_settings();
|
73 |
+
|
74 |
+
return isset( $settings[ $key ] ) ? $settings[ $key ] : $default;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param string $key
|
79 |
+
* @param mixed $value
|
80 |
+
*
|
81 |
+
* @return bool|int
|
82 |
+
*/
|
83 |
+
public function update_setting( $key, $value ) {
|
84 |
+
$settings = $this->get_settings();
|
85 |
+
|
86 |
+
$settings[ $key ] = $value;
|
87 |
+
|
88 |
+
return $this->update_meta( 'popup_theme_settings', $settings );
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @param array $merge_settings
|
93 |
+
*
|
94 |
+
* @return bool|int
|
95 |
+
*/
|
96 |
+
public function update_settings( $merge_settings = array() ) {
|
97 |
+
$settings = $this->get_settings();
|
98 |
+
|
99 |
+
foreach ( $merge_settings as $key => $value ) {
|
100 |
+
$settings[ $key ] = $value;
|
101 |
+
}
|
102 |
+
|
103 |
+
return $this->update_meta( 'popup_theme_settings', $settings );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Returns array of all google font variations used for this theme.
|
108 |
+
*
|
109 |
+
* @return array
|
110 |
+
*/
|
111 |
+
public function get_google_fonts_used() {
|
112 |
+
$fonts_used = array();
|
113 |
+
|
114 |
+
$settings = $this->get_settings();
|
115 |
+
|
116 |
+
$google_fonts = PUM_Integration_GoogleFonts::fetch_fonts();
|
117 |
+
|
118 |
+
if ( ! empty( $settings['title_font_family'] ) && is_string( $settings['title_font_family'] ) && array_key_exists( $settings['title_font_family'], $google_fonts ) ) {
|
119 |
+
$variant = ! empty( $settings['title_font_weight'] ) && $settings['title_font_weight'] != 'normal' ? $settings['title_font_weight'] : '';
|
120 |
+
if ( isset( $settings['title_font_style'] ) && $settings['title_font_style'] == 'italic' ) {
|
121 |
+
$variant .= 'italic';
|
122 |
+
}
|
123 |
+
$fonts_used[ $settings['title_font_family'] ][ $variant ] = $variant;
|
124 |
+
}
|
125 |
+
if ( ! empty( $settings['content_font_family'] ) && is_string( $settings['content_font_family'] ) && array_key_exists( $settings['content_font_family'], $google_fonts ) ) {
|
126 |
+
$variant = ! empty( $settings['content_font_weight'] ) && $settings['content_font_weight'] != 'normal' ? $settings['content_font_weight'] : '';
|
127 |
+
if ( isset( $settings['content_font_style'] ) && $settings['content_font_style'] == 'italic' ) {
|
128 |
+
$variant .= 'italic';
|
129 |
+
}
|
130 |
+
$fonts_used[ $settings['content_font_family'] ][ $variant ] = $variant;
|
131 |
+
}
|
132 |
+
if ( ! empty( $settings['close_font_family'] ) && is_string( $settings['close_font_family'] ) && array_key_exists( $settings['close_font_family'], $google_fonts ) ) {
|
133 |
+
$variant = ! empty( $settings['close_font_weight'] ) && $settings['close_font_weight'] != 'normal' ? $settings['close_font_weight'] : '';
|
134 |
+
if ( isset( $settings['close_font_style'] ) && $settings['close_font_style'] == 'italic' ) {
|
135 |
+
$variant .= 'italic';
|
136 |
+
}
|
137 |
+
$fonts_used[ $settings['close_font_family'] ][ $variant ] = $variant;
|
138 |
+
}
|
139 |
+
|
140 |
+
return $fonts_used;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @return array
|
145 |
+
*/
|
146 |
+
public function get_generated_styles() {
|
147 |
+
|
148 |
+
$styles = array(
|
149 |
+
'overlay' => array(),
|
150 |
+
'container' => array(),
|
151 |
+
'title' => array(),
|
152 |
+
'content' => array(),
|
153 |
+
'close' => array(),
|
154 |
+
);
|
155 |
+
|
156 |
+
/*
|
157 |
+
* Overlay Styles
|
158 |
+
*/
|
159 |
+
if ( $this->get_setting( 'overlay_background_color' ) ) {
|
160 |
+
$styles['overlay']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'overlay_background_color' ), $this->get_setting( 'overlay_background_opacity' ) );
|
161 |
+
}
|
162 |
+
|
163 |
+
/*
|
164 |
+
* Container Styles
|
165 |
+
*/
|
166 |
+
$styles['container'] = array(
|
167 |
+
'padding' => "{$this->get_setting('container_padding')}px",
|
168 |
+
'border-radius' => "{$this->get_setting('container_border_radius')}px",
|
169 |
+
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'container_border_width' ), $this->get_setting( 'container_border_style' ), $this->get_setting( 'container_border_color' ) ),
|
170 |
+
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'container_boxshadow_horizontal' ), $this->get_setting( 'container_boxshadow_vertical' ), $this->get_setting( 'container_boxshadow_blur' ), $this->get_setting( 'container_boxshadow_spread' ), $this->get_setting( 'container_boxshadow_color' ), $this->get_setting( 'container_boxshadow_opacity' ), $this->get_setting( 'container_boxshadow_inset' ) ),
|
171 |
+
);
|
172 |
+
|
173 |
+
if ( $this->get_setting( 'container_background_color' ) ) {
|
174 |
+
$styles['container']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'container_background_color' ), $this->get_setting( 'container_background_opacity' ) );
|
175 |
+
}
|
176 |
+
|
177 |
+
/*
|
178 |
+
* Title Styles
|
179 |
+
*/
|
180 |
+
$styles['title'] = array(
|
181 |
+
'color' => $this->get_setting( 'title_font_color' ),
|
182 |
+
'text-align' => $this->get_setting( 'title_text_align' ),
|
183 |
+
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'title_textshadow_horizontal' ), $this->get_setting( 'title_textshadow_vertical' ), $this->get_setting( 'title_textshadow_blur' ), $this->get_setting( 'title_textshadow_color' ), $this->get_setting( 'title_textshadow_opacity' ) ),
|
184 |
+
'font-family' => $this->get_setting( 'title_font_family' ),
|
185 |
+
'font-weight' => $this->get_setting( 'title_font_weight' ),
|
186 |
+
'font-size' => "{$this->get_setting( 'title_font_size' )}px",
|
187 |
+
'font-style' => $this->get_setting( 'title_font_style' ),
|
188 |
+
'line-height' => "{$this->get_setting( 'title_line_height' )}px",
|
189 |
+
);
|
190 |
+
|
191 |
+
/*
|
192 |
+
* Content Styles
|
193 |
+
*/
|
194 |
+
$styles['content'] = array(
|
195 |
+
'color' => $this->get_setting( 'content_font_color' ),
|
196 |
+
'font-family' => $this->get_setting( 'content_font_family' ),
|
197 |
+
'font-weight' => $this->get_setting( 'content_font_weight' ),
|
198 |
+
'font-style' => $this->get_setting( 'content_font_style' ),
|
199 |
+
);
|
200 |
+
|
201 |
+
/*
|
202 |
+
* Close Styles
|
203 |
+
*/
|
204 |
+
$styles['close'] = array(
|
205 |
+
'position' => $this->get_setting( 'close_position_outside' ) ? 'fixed' : 'absolute',
|
206 |
+
'height' => ! $this->get_setting( 'close_height' ) || $this->get_setting( 'close_height' ) <= 0 ? 'auto' : "{$this->get_setting('close_height')}px",
|
207 |
+
'width' => ! $this->get_setting( 'close_width' ) || $this->get_setting( 'close_width' ) <= 0 ? 'auto' : "{$this->get_setting('close_width')}px",
|
208 |
+
'left' => 'auto',
|
209 |
+
'right' => 'auto',
|
210 |
+
'bottom' => 'auto',
|
211 |
+
'top' => 'auto',
|
212 |
+
'padding' => "{$this->get_setting('close_padding')}px",
|
213 |
+
'color' => $this->get_setting( 'close_font_color' ),
|
214 |
+
'font-family' => $this->get_setting( 'close_font_family' ),
|
215 |
+
'font-weight' => $this->get_setting( 'close_font_weight' ),
|
216 |
+
'font-size' => "{$this->get_setting('close_font_size')}px",
|
217 |
+
'font-style' => $this->get_setting( 'close_font_style' ),
|
218 |
+
'line-height' => "{$this->get_setting('close_line_height')}px",
|
219 |
+
'border' => PUM_Utils_CSS::border_style( $this->get_setting( 'close_border_width' ), $this->get_setting( 'close_border_style' ), $this->get_setting( 'close_border_color' ) ),
|
220 |
+
'border-radius' => "{$this->get_setting('close_border_radius')}px",
|
221 |
+
'box-shadow' => PUM_Utils_CSS::box_shadow_style( $this->get_setting( 'close_boxshadow_horizontal' ), $this->get_setting( 'close_boxshadow_vertical' ), $this->get_setting( 'close_boxshadow_blur' ), $this->get_setting( 'close_boxshadow_spread' ), $this->get_setting( 'close_boxshadow_color' ), $this->get_setting( 'close_boxshadow_opacity' ), $this->get_setting( 'close_boxshadow_inset' ) ),
|
222 |
+
'text-shadow' => PUM_Utils_CSS::text_shadow_style( $this->get_setting( 'close_textshadow_horizontal' ), $this->get_setting( 'close_textshadow_vertical' ), $this->get_setting( 'close_textshadow_blur' ), $this->get_setting( 'close_textshadow_color' ), $this->get_setting( 'close_textshadow_opacity' ) ),
|
223 |
+
);
|
224 |
+
|
225 |
+
if ( $this->get_setting( 'close_background_color' ) ) {
|
226 |
+
$styles['close']['background-color'] = PUM_Utils_CSS::hex2rgba( $this->get_setting( 'close_background_color' ), $this->get_setting( 'close_background_opacity' ) );
|
227 |
+
}
|
228 |
+
|
229 |
+
$top = "{$this->get_setting('close_position_top')}px";
|
230 |
+
$left = "{$this->get_setting('close_position_left')}px";
|
231 |
+
$right = "{$this->get_setting('close_position_right')}px";
|
232 |
+
$bottom = "{$this->get_setting('close_position_bottom')}px";
|
233 |
+
|
234 |
+
switch ( $this->get_setting( 'close_location' ) ) {
|
235 |
+
case "topleft":
|
236 |
+
$styles['close']['top'] = $top;
|
237 |
+
$styles['close']['left'] = $left;
|
238 |
+
break;
|
239 |
+
case "topcenter":
|
240 |
+
$styles['close']['top'] = $top;
|
241 |
+
$styles['close']['left'] = "50%";
|
242 |
+
$styles['close']['transform'] = "translateX(-50%)";
|
243 |
+
break;
|
244 |
+
case "topright":
|
245 |
+
$styles['close']['top'] = $top;
|
246 |
+
$styles['close']['right'] = $right;
|
247 |
+
break;
|
248 |
+
case 'middleleft':
|
249 |
+
$styles['close']['top'] = "50%";
|
250 |
+
$styles['close']['left'] = $left;
|
251 |
+
$styles['close']['transform'] = "translate(0, -50%)";
|
252 |
+
break;
|
253 |
+
case 'middleright':
|
254 |
+
$styles['close']['top'] = "50%";
|
255 |
+
$styles['close']['right'] = $right;
|
256 |
+
$styles['close']['transform'] = "translate(0, -50%)";
|
257 |
+
break;
|
258 |
+
case "bottomleft":
|
259 |
+
$styles['close']['bottom'] = $bottom;
|
260 |
+
$styles['close']['left'] = $left;
|
261 |
+
break;
|
262 |
+
case "bottomcenter":
|
263 |
+
$styles['close']['bottom'] = $bottom;
|
264 |
+
$styles['close']['left'] = "50%";
|
265 |
+
$styles['close']['transform'] = "translateX(-50%)";
|
266 |
+
break;
|
267 |
+
case "bottomright":
|
268 |
+
$styles['close']['bottom'] = $bottom;
|
269 |
+
$styles['close']['right'] = $right;
|
270 |
+
break;
|
271 |
+
}
|
272 |
+
|
273 |
+
/** @deprecated 1.8.0 filter */
|
274 |
+
$styles = (array) apply_filters( 'popmake_generate_theme_styles', (array) $styles, $this->ID, $this->get_deprecated_settings() );
|
275 |
+
|
276 |
+
return (array) apply_filters( 'pum_theme_get_generated_styles', (array) $styles, $this->ID );
|
277 |
+
}
|
278 |
+
|
279 |
+
public function get_deprecated_settings() {
|
280 |
+
return array(
|
281 |
+
'overlay' => $this->_dep_get_settings_group( 'overlay' ),
|
282 |
+
'container' => $this->_dep_get_settings_group( 'container' ),
|
283 |
+
'title' => $this->_dep_get_settings_group( 'title' ),
|
284 |
+
'content' => $this->_dep_get_settings_group( 'content' ),
|
285 |
+
'close' => $this->_dep_get_settings_group( 'close' ),
|
286 |
+
);
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Retrieve settings in the form of deprecated grouped arrays.
|
291 |
+
*
|
292 |
+
* @param $group
|
293 |
+
* @param null $key
|
294 |
+
*
|
295 |
+
* @return mixed
|
296 |
+
*/
|
297 |
+
public function _dep_get_settings_group( $group, $key = null ) {
|
298 |
+
if ( ! isset( $this->$group ) ) {
|
299 |
+
/**
|
300 |
+
* Remap old meta settings to new settings location for v1.7. This acts as a passive migration when needed.
|
301 |
+
*/
|
302 |
+
$remapped_keys = $this->remapped_meta_settings_keys( $group );
|
303 |
+
|
304 |
+
// This will only return data from extensions as core data has been migrated already.
|
305 |
+
$group_values = $this->get_meta( "popup_theme_$group" );
|
306 |
+
|
307 |
+
if ( ! $group_values || ! is_array( $group_values ) ) {
|
308 |
+
$group_values = array();
|
309 |
+
}
|
310 |
+
|
311 |
+
// Data manipulation begins here. We don't want any of this saved, only returned for backward compatibility.
|
312 |
+
foreach ( $remapped_keys as $old_key => $new_key ) {
|
313 |
+
$group_values[ $old_key ] = $this->get_setting( $new_key );
|
314 |
+
}
|
315 |
+
|
316 |
+
$deprecated_values = pum_get_theme_v1_meta( $group, $this->ID );
|
317 |
+
|
318 |
+
if ( ! empty( $deprecated_values ) ) {
|
319 |
+
foreach ( $deprecated_values as $old_key => $value ) {
|
320 |
+
|
321 |
+
if ( ! isset( $group_values[ $old_key ] ) ) {
|
322 |
+
$group_values[ $old_key ] = $value;
|
323 |
+
}
|
324 |
+
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
|
329 |
+
$this->$group = $group_values;
|
330 |
+
}
|
331 |
+
|
332 |
+
$values = apply_filters( "pum_theme_get_$group", $this->$group, $this->ID );
|
333 |
+
|
334 |
+
if ( ! $key ) {
|
335 |
+
return $values;
|
336 |
+
}
|
337 |
+
|
338 |
+
$value = isset ( $values[ $key ] ) ? $values[ $key ] : null;
|
339 |
+
|
340 |
+
if ( ! isset( $value ) ) {
|
341 |
+
$value = $this->get_meta( "popup_theme_{$group}_{$key}" );
|
342 |
+
}
|
343 |
+
|
344 |
+
return apply_filters( "pum_theme_get_{$group}_" . $key, $value, $this->ID );
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* @param $group
|
349 |
+
*
|
350 |
+
* @return array|mixed
|
351 |
+
*/
|
352 |
+
public function remapped_meta_settings_keys( $group ) {
|
353 |
+
$remapped_meta_settings_keys = array(
|
354 |
+
'overlay' => array(
|
355 |
+
'background_color' => 'overlay_background_color',
|
356 |
+
'background_opacity' => 'overlay_background_opacity',
|
357 |
+
),
|
358 |
+
'container' => array(
|
359 |
+
'padding' => 'container_padding',
|
360 |
+
'background_color' => 'container_background_color',
|
361 |
+
'background_opacity' => 'container_background_opacity',
|
362 |
+
'border_style' => 'container_border_style',
|
363 |
+
'border_color' => 'container_border_color',
|
364 |
+
'border_width' => 'container_border_width',
|
365 |
+
'border_radius' => 'container_border_radius',
|
366 |
+
'boxshadow_inset' => 'container_boxshadow_inset',
|
367 |
+
'boxshadow_horizontal' => 'container_boxshadow_horizontal',
|
368 |
+
'boxshadow_vertical' => 'container_boxshadow_vertical',
|
369 |
+
'boxshadow_blur' => 'container_boxshadow_blur',
|
370 |
+
'boxshadow_spread' => 'container_boxshadow_spread',
|
371 |
+
'boxshadow_color' => 'container_boxshadow_color',
|
372 |
+
'boxshadow_opacity' => 'container_boxshadow_opacity',
|
373 |
+
),
|
374 |
+
'title' => array(
|
375 |
+
'font_color' => 'title_font_color',
|
376 |
+
'line_height' => 'title_line_height',
|
377 |
+
'font_size' => 'title_font_size',
|
378 |
+
'font_family' => 'title_font_family',
|
379 |
+
'font_weight' => 'title_font_weight',
|
380 |
+
'font_style' => 'title_font_style',
|
381 |
+
'text_align' => 'title_text_align',
|
382 |
+
'textshadow_horizontal' => 'title_textshadow_horizontal',
|
383 |
+
'textshadow_vertical' => 'title_textshadow_vertical',
|
384 |
+
'textshadow_blur' => 'title_textshadow_blur',
|
385 |
+
'textshadow_color' => 'title_textshadow_color',
|
386 |
+
'textshadow_opacity' => 'title_textshadow_opacity',
|
387 |
+
),
|
388 |
+
'content' => array(
|
389 |
+
'font_color' => 'content_font_color',
|
390 |
+
'font_family' => 'content_font_family',
|
391 |
+
'font_weight' => 'content_font_weight',
|
392 |
+
'font_style' => 'content_font_style',
|
393 |
+
),
|
394 |
+
'close' => array(
|
395 |
+
'text' => 'close_text',
|
396 |
+
'location' => 'close_location',
|
397 |
+
'position_top' => 'close_position_top',
|
398 |
+
'position_left' => 'close_position_left',
|
399 |
+
'position_bottom' => 'close_position_bottom',
|
400 |
+
'position_right' => 'close_position_right',
|
401 |
+
'padding' => 'close_padding',
|
402 |
+
'height' => 'close_height',
|
403 |
+
'width' => 'close_width',
|
404 |
+
'background_color' => 'close_background_color',
|
405 |
+
'background_opacity' => 'close_background_opacity',
|
406 |
+
'font_color' => 'close_font_color',
|
407 |
+
'line_height' => 'close_line_height',
|
408 |
+
'font_size' => 'close_font_size',
|
409 |
+
'font_family' => 'close_font_family',
|
410 |
+
'font_weight' => 'close_font_weight',
|
411 |
+
'font_style' => 'close_font_style',
|
412 |
+
'border_style' => 'close_border_style',
|
413 |
+
'border_color' => 'close_border_color',
|
414 |
+
'border_width' => 'close_border_width',
|
415 |
+
'border_radius' => 'close_border_radius',
|
416 |
+
'boxshadow_inset' => 'close_boxshadow_inset',
|
417 |
+
'boxshadow_horizontal' => 'close_boxshadow_horizontal',
|
418 |
+
'boxshadow_vertical' => 'close_boxshadow_vertical',
|
419 |
+
'boxshadow_blur' => 'close_boxshadow_blur',
|
420 |
+
'boxshadow_spread' => 'close_boxshadow_spread',
|
421 |
+
'boxshadow_color' => 'close_boxshadow_color',
|
422 |
+
'boxshadow_opacity' => 'close_boxshadow_opacity',
|
423 |
+
'textshadow_horizontal' => 'close_textshadow_horizontal',
|
424 |
+
'textshadow_vertical' => 'close_textshadow_vertical',
|
425 |
+
'textshadow_blur' => 'close_textshadow_blur',
|
426 |
+
'textshadow_color' => 'close_textshadow_color',
|
427 |
+
'textshadow_opacity' => 'close_textshadow_opacity',
|
428 |
+
),
|
429 |
+
);
|
430 |
+
|
431 |
+
return isset( $remapped_meta_settings_keys[ $group ] ) ? $remapped_meta_settings_keys[ $group ] : array();
|
432 |
+
}
|
433 |
+
|
434 |
+
/**
|
435 |
+
* @param WP_Post $post
|
436 |
+
*/
|
437 |
+
public function setup( $post ) {
|
438 |
+
parent::setup( $post );
|
439 |
+
|
440 |
+
if ( ! $this->is_valid() ) {
|
441 |
+
return;
|
442 |
+
}
|
443 |
+
|
444 |
+
if ( $this->ID === 5 ) {
|
445 |
+
$test = '1';
|
446 |
+
}
|
447 |
+
|
448 |
+
if ( ! isset( $this->data_version ) ) {
|
449 |
+
$this->data_version = (int) $this->get_meta( 'popup_theme_data_version' );
|
450 |
+
|
451 |
+
if ( ! $this->data_version ) {
|
452 |
+
$theme_overlay_v1 = $this->get_meta( 'popup_theme_overlay_background_color' );
|
453 |
+
$theme_overlay_v2 = $this->get_meta( 'popup_theme_overlay' );
|
454 |
+
|
455 |
+
// If there are existing settings set the data version to 1/2 so they can be updated.
|
456 |
+
// Otherwise set to the current version as this is a new popup.
|
457 |
+
if ( ! empty( $theme_overlay_v1 ) ) {
|
458 |
+
$this->data_version = 1;
|
459 |
+
} else if ( ! empty( $theme_overlay_v2 ) && is_array( $theme_overlay_v2 ) ) {
|
460 |
+
$this->data_version = 2;
|
461 |
+
} else {
|
462 |
+
$this->data_version = $this->model_version;
|
463 |
+
}
|
464 |
+
|
465 |
+
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
if ( $this->data_version < $this->model_version && pum_passive_theme_upgrades_enabled() ) {
|
470 |
+
/**
|
471 |
+
* Process passive settings migration as each popup is loaded. The will only run each migration routine once for each popup.
|
472 |
+
*/
|
473 |
+
$this->passive_migration();
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Allows for passive migration routines based on the current data version.
|
479 |
+
*/
|
480 |
+
public function passive_migration() {
|
481 |
+
$this->doing_passive_migration = true;
|
482 |
+
|
483 |
+
for ( $i = $this->data_version; $this->data_version < $this->model_version; $i ++ ) {
|
484 |
+
// Process migration for current version. ex. current version is 2, runs pum_theme_passive_migration_2.
|
485 |
+
do_action_ref_array( 'pum_theme_passive_migration_' . $this->data_version, array( &$this ) );
|
486 |
+
$this->data_version ++;
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Update the themes data version.
|
490 |
+
*/
|
491 |
+
$this->update_meta( 'popup_theme_data_version', $this->data_version );
|
492 |
+
}
|
493 |
+
|
494 |
+
do_action_ref_array( 'pum_theme_passive_migration', array( &$this, $this->data_version ) );
|
495 |
+
|
496 |
+
$this->doing_passive_migration = false;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
|
classes/Utils/Alerts.php
CHANGED
@@ -253,9 +253,9 @@ class PUM_Utils_Alerts {
|
|
253 |
if ( $integration['conditions'] ) {
|
254 |
|
255 |
$path = "{$integration['slug']}/{$integration['slug']}.php";
|
256 |
-
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $path, false, false );
|
257 |
|
258 |
-
$installed = $plugin_data['Name'] === $integration['name'];
|
259 |
|
260 |
$text = $installed ? __( 'activate it now', 'popup-maker' ) : __( 'install it now', 'popup-maker' );
|
261 |
$url = $installed ? esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) : esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker-buddypress-integration' ), 'install-plugin_popup-maker-buddypress-integration' ) );
|
253 |
if ( $integration['conditions'] ) {
|
254 |
|
255 |
$path = "{$integration['slug']}/{$integration['slug']}.php";
|
256 |
+
$plugin_data = file_exists( WP_PLUGIN_DIR . '/' . $path ) ? get_plugin_data( WP_PLUGIN_DIR . '/' . $path, false, false ) : false;
|
257 |
|
258 |
+
$installed = $plugin_data && ! empty( $plugin_data['Name'] ) && $plugin_data['Name'] === $integration['name'];
|
259 |
|
260 |
$text = $installed ? __( 'activate it now', 'popup-maker' ) : __( 'install it now', 'popup-maker' );
|
261 |
$url = $installed ? esc_url( wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=' . $path ), 'activate-plugin_' . $path ) ) : esc_url( wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=popup-maker-buddypress-integration' ), 'install-plugin_popup-maker-buddypress-integration' ) );
|
includes/integrations/class-pum-buddypress-integration.php
CHANGED
@@ -1,248 +1,248 @@
|
|
1 |
-
<?php
|
2 |
-
/*******************************************************************************
|
3 |
-
* Copyright (c) 2018, WP Popup Maker
|
4 |
-
******************************************************************************/
|
5 |
-
|
6 |
-
// Exit if accessed directly
|
7 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
-
exit;
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Class PUM_BuddyPress_Integration
|
13 |
-
*/
|
14 |
-
class PUM_BuddyPress_Integration {
|
15 |
-
|
16 |
-
/**
|
17 |
-
*
|
18 |
-
*/
|
19 |
-
public static function init() {
|
20 |
-
add_filter( 'pum_registered_conditions', array( __CLASS__, 'registered_conditions' ) );
|
21 |
-
add_filter( 'pum_condition_sort_order', array( __CLASS__, 'condition_sort_order' ) );
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @param array $conditions
|
26 |
-
*
|
27 |
-
* @return array
|
28 |
-
*/
|
29 |
-
public static function registered_conditions( $conditions = array() ) {
|
30 |
-
|
31 |
-
$conditions = array_merge( $conditions, array(
|
32 |
-
// Add Additional Conditions
|
33 |
-
'is_buddypress' => array(
|
34 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
35 |
-
'name' => __( 'BP: Is a BuddyPress Page', 'popup-maker
|
36 |
-
'callback' => 'is_buddypress',
|
37 |
-
),
|
38 |
-
|
39 |
-
'bp_is_user' => array(
|
40 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
41 |
-
'name' => __( 'BP: Is User Page', 'popup-maker
|
42 |
-
'callback' => 'bp_is_user',
|
43 |
-
),
|
44 |
-
|
45 |
-
'bp_is_group' => array(
|
46 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
47 |
-
'name' => __( 'BP: Is Group Page', 'popup-maker
|
48 |
-
'callback' => 'bp_is_group',
|
49 |
-
),
|
50 |
-
|
51 |
-
'bp_is_user_messages' => array(
|
52 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
53 |
-
'name' => __( 'BP: Is User Messages Page', 'popup-maker
|
54 |
-
'callback' => 'bp_is_user_messages',
|
55 |
-
),
|
56 |
-
|
57 |
-
'bp_is_activation_page' => array(
|
58 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
59 |
-
'name' => __( 'BP: Is Activation Page', 'popup-maker
|
60 |
-
'callback' => 'bp_is_activation_page',
|
61 |
-
),
|
62 |
-
|
63 |
-
'bp_is_register_page' => array(
|
64 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
65 |
-
'name' => __( 'BP: Is Register Page', 'popup-maker
|
66 |
-
'callback' => 'bp_is_register_page',
|
67 |
-
),
|
68 |
-
|
69 |
-
'bp_is_item_admin' => array(
|
70 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
71 |
-
'name' => __( 'BP: Is Item Admin', 'popup-maker
|
72 |
-
'callback' => 'bp_is_item_admin',
|
73 |
-
),
|
74 |
-
|
75 |
-
'bp_is_item_mod' => array(
|
76 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
77 |
-
'name' => __( 'BP: Is Item Mod', 'popup-maker
|
78 |
-
'callback' => 'bp_is_item_mod',
|
79 |
-
),
|
80 |
-
|
81 |
-
'bp_is_directory' => array(
|
82 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
83 |
-
'name' => __( 'BP: Is Directory', 'popup-maker
|
84 |
-
'callback' => 'bp_is_directory',
|
85 |
-
),
|
86 |
-
'bp_is_current_component' => array(
|
87 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
88 |
-
'name' => __( 'BP: Is Current Component', 'popup-maker
|
89 |
-
'fields' => array(
|
90 |
-
'selected' => array(
|
91 |
-
'type' => 'select',
|
92 |
-
'multiple' => true,
|
93 |
-
'as_array' => true,
|
94 |
-
'select2' => true,
|
95 |
-
'options' => self::component_option_list(),
|
96 |
-
'label' => __( 'Which components?' ),
|
97 |
-
),
|
98 |
-
),
|
99 |
-
'callback' => array( __CLASS__, 'bp_is_current_component' ),
|
100 |
-
),
|
101 |
-
|
102 |
-
'bp_is_current_action' => array(
|
103 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
104 |
-
'name' => __( 'BP: Is Current Action', 'popup-maker
|
105 |
-
'fields' => array(
|
106 |
-
'selected' => array(
|
107 |
-
'type' => 'text',
|
108 |
-
'label' => __( 'Which actions?' ),
|
109 |
-
),
|
110 |
-
),
|
111 |
-
'callback' => array( __CLASS__, 'bp_is_current_action' ),
|
112 |
-
),
|
113 |
-
|
114 |
-
'bp_is_action_variable' => array(
|
115 |
-
'group' => __( 'BuddyPress', 'buddypress' ),
|
116 |
-
'name' => __( 'BP: Is Action Variable', 'popup-maker
|
117 |
-
'fields' => array(
|
118 |
-
'selected' => array(
|
119 |
-
'type' => 'text',
|
120 |
-
'label' => __( 'Which action variables?' ),
|
121 |
-
),
|
122 |
-
),
|
123 |
-
'callback' => array( __CLASS__, 'bp_is_action_variable' ),
|
124 |
-
),
|
125 |
-
|
126 |
-
) );
|
127 |
-
|
128 |
-
return $conditions;
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* @return array
|
133 |
-
*/
|
134 |
-
public static function component_option_list() {
|
135 |
-
global $bp;
|
136 |
-
|
137 |
-
$components = array();
|
138 |
-
|
139 |
-
foreach ( $bp->active_components as $component => $key ) {
|
140 |
-
$components[ $component ] = ucfirst( $component );
|
141 |
-
}
|
142 |
-
|
143 |
-
return $components;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Checks if the current page is the selected bp components.
|
148 |
-
*
|
149 |
-
* @param array $settings
|
150 |
-
*
|
151 |
-
* @return bool
|
152 |
-
*/
|
153 |
-
public static function bp_is_current_component( $settings = array() ) {
|
154 |
-
global $bp;
|
155 |
-
|
156 |
-
if ( empty ( $settings['selected'] ) ) {
|
157 |
-
return false;
|
158 |
-
}
|
159 |
-
|
160 |
-
if ( ! is_array( $settings['selected'] ) ) {
|
161 |
-
$settings['selected'] = array( $settings['selected'] );
|
162 |
-
}
|
163 |
-
|
164 |
-
$found = false;
|
165 |
-
|
166 |
-
foreach ( $settings['selected'] as $component ) {
|
167 |
-
if ( ! array_key_exists( $component, $bp->active_components ) ) {
|
168 |
-
continue;
|
169 |
-
}
|
170 |
-
|
171 |
-
if ( bp_is_current_component( $component ) ) {
|
172 |
-
$found = true;
|
173 |
-
}
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
return $found;
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Checks if the current page is the selected bp action.
|
182 |
-
*
|
183 |
-
* @param array $settings
|
184 |
-
*
|
185 |
-
* @return bool
|
186 |
-
*/
|
187 |
-
public static function bp_is_current_action( $settings = array() ) {
|
188 |
-
|
189 |
-
if ( empty ( $settings['selected'] ) ) {
|
190 |
-
return false;
|
191 |
-
}
|
192 |
-
|
193 |
-
if ( ! is_array( $settings['selected'] ) ) {
|
194 |
-
$settings['selected'] = array_map( 'trim', explode( ',', $settings['selected'] ) );
|
195 |
-
}
|
196 |
-
|
197 |
-
$found = false;
|
198 |
-
|
199 |
-
foreach ( $settings['selected'] as $action ) {
|
200 |
-
if ( bp_is_current_action( $action ) ) {
|
201 |
-
$found = true;
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
return $found;
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Checks if the current page is the selected bp action variable.
|
211 |
-
*
|
212 |
-
* @param array $settings
|
213 |
-
*
|
214 |
-
* @return bool
|
215 |
-
*/
|
216 |
-
public static function bp_is_action_variable( $settings = array() ) {
|
217 |
-
|
218 |
-
if ( empty ( $settings['selected'] ) ) {
|
219 |
-
return false;
|
220 |
-
}
|
221 |
-
|
222 |
-
if ( ! is_array( $settings['selected'] ) ) {
|
223 |
-
$settings['selected'] = array_map( 'trim', explode( ',', $settings['selected'] ) );
|
224 |
-
}
|
225 |
-
|
226 |
-
$found = false;
|
227 |
-
|
228 |
-
foreach ( $settings['selected'] as $variable ) {
|
229 |
-
if ( bp_is_action_variable( $variable ) ) {
|
230 |
-
$found = true;
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
return $found;
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* @param array $order
|
239 |
-
*
|
240 |
-
* @return array
|
241 |
-
*/
|
242 |
-
public static function condition_sort_order( $order = array() ) {
|
243 |
-
$order[ __( 'BuddyPress', 'buddypress' ) ] = 5.756;
|
244 |
-
|
245 |
-
return $order;
|
246 |
-
}
|
247 |
-
|
248 |
-
}
|
1 |
+
<?php
|
2 |
+
/*******************************************************************************
|
3 |
+
* Copyright (c) 2018, WP Popup Maker
|
4 |
+
******************************************************************************/
|
5 |
+
|
6 |
+
// Exit if accessed directly
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
+
exit;
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class PUM_BuddyPress_Integration
|
13 |
+
*/
|
14 |
+
class PUM_BuddyPress_Integration {
|
15 |
+
|
16 |
+
/**
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
public static function init() {
|
20 |
+
add_filter( 'pum_registered_conditions', array( __CLASS__, 'registered_conditions' ) );
|
21 |
+
add_filter( 'pum_condition_sort_order', array( __CLASS__, 'condition_sort_order' ) );
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param array $conditions
|
26 |
+
*
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
public static function registered_conditions( $conditions = array() ) {
|
30 |
+
|
31 |
+
$conditions = array_merge( $conditions, array(
|
32 |
+
// Add Additional Conditions
|
33 |
+
'is_buddypress' => array(
|
34 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
35 |
+
'name' => __( 'BP: Is a BuddyPress Page', 'popup-maker' ),
|
36 |
+
'callback' => 'is_buddypress',
|
37 |
+
),
|
38 |
+
|
39 |
+
'bp_is_user' => array(
|
40 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
41 |
+
'name' => __( 'BP: Is User Page', 'popup-maker' ),
|
42 |
+
'callback' => 'bp_is_user',
|
43 |
+
),
|
44 |
+
|
45 |
+
'bp_is_group' => array(
|
46 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
47 |
+
'name' => __( 'BP: Is Group Page', 'popup-maker' ),
|
48 |
+
'callback' => 'bp_is_group',
|
49 |
+
),
|
50 |
+
|
51 |
+
'bp_is_user_messages' => array(
|
52 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
53 |
+
'name' => __( 'BP: Is User Messages Page', 'popup-maker' ),
|
54 |
+
'callback' => 'bp_is_user_messages',
|
55 |
+
),
|
56 |
+
|
57 |
+
'bp_is_activation_page' => array(
|
58 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
59 |
+
'name' => __( 'BP: Is Activation Page', 'popup-maker' ),
|
60 |
+
'callback' => 'bp_is_activation_page',
|
61 |
+
),
|
62 |
+
|
63 |
+
'bp_is_register_page' => array(
|
64 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
65 |
+
'name' => __( 'BP: Is Register Page', 'popup-maker' ),
|
66 |
+
'callback' => 'bp_is_register_page',
|
67 |
+
),
|
68 |
+
|
69 |
+
'bp_is_item_admin' => array(
|
70 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
71 |
+
'name' => __( 'BP: Is Item Admin', 'popup-maker' ),
|
72 |
+
'callback' => 'bp_is_item_admin',
|
73 |
+
),
|
74 |
+
|
75 |
+
'bp_is_item_mod' => array(
|
76 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
77 |
+
'name' => __( 'BP: Is Item Mod', 'popup-maker' ),
|
78 |
+
'callback' => 'bp_is_item_mod',
|
79 |
+
),
|
80 |
+
|
81 |
+
'bp_is_directory' => array(
|
82 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
83 |
+
'name' => __( 'BP: Is Directory', 'popup-maker' ),
|
84 |
+
'callback' => 'bp_is_directory',
|
85 |
+
),
|
86 |
+
'bp_is_current_component' => array(
|
87 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
88 |
+
'name' => __( 'BP: Is Current Component', 'popup-maker' ),
|
89 |
+
'fields' => array(
|
90 |
+
'selected' => array(
|
91 |
+
'type' => 'select',
|
92 |
+
'multiple' => true,
|
93 |
+
'as_array' => true,
|
94 |
+
'select2' => true,
|
95 |
+
'options' => self::component_option_list(),
|
96 |
+
'label' => __( 'Which components?' ),
|
97 |
+
),
|
98 |
+
),
|
99 |
+
'callback' => array( __CLASS__, 'bp_is_current_component' ),
|
100 |
+
),
|
101 |
+
|
102 |
+
'bp_is_current_action' => array(
|
103 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
104 |
+
'name' => __( 'BP: Is Current Action', 'popup-maker' ),
|
105 |
+
'fields' => array(
|
106 |
+
'selected' => array(
|
107 |
+
'type' => 'text',
|
108 |
+
'label' => __( 'Which actions?' ),
|
109 |
+
),
|
110 |
+
),
|
111 |
+
'callback' => array( __CLASS__, 'bp_is_current_action' ),
|
112 |
+
),
|
113 |
+
|
114 |
+
'bp_is_action_variable' => array(
|
115 |
+
'group' => __( 'BuddyPress', 'buddypress' ),
|
116 |
+
'name' => __( 'BP: Is Action Variable', 'popup-maker' ),
|
117 |
+
'fields' => array(
|
118 |
+
'selected' => array(
|
119 |
+
'type' => 'text',
|
120 |
+
'label' => __( 'Which action variables?' ),
|
121 |
+
),
|
122 |
+
),
|
123 |
+
'callback' => array( __CLASS__, 'bp_is_action_variable' ),
|
124 |
+
),
|
125 |
+
|
126 |
+
) );
|
127 |
+
|
128 |
+
return $conditions;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @return array
|
133 |
+
*/
|
134 |
+
public static function component_option_list() {
|
135 |
+
global $bp;
|
136 |
+
|
137 |
+
$components = array();
|
138 |
+
|
139 |
+
foreach ( $bp->active_components as $component => $key ) {
|
140 |
+
$components[ $component ] = ucfirst( $component );
|
141 |
+
}
|
142 |
+
|
143 |
+
return $components;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Checks if the current page is the selected bp components.
|
148 |
+
*
|
149 |
+
* @param array $settings
|
150 |
+
*
|
151 |
+
* @return bool
|
152 |
+
*/
|
153 |
+
public static function bp_is_current_component( $settings = array() ) {
|
154 |
+
global $bp;
|
155 |
+
|
156 |
+
if ( empty ( $settings['selected'] ) ) {
|
157 |
+
return false;
|
158 |
+
}
|
159 |
+
|
160 |
+
if ( ! is_array( $settings['selected'] ) ) {
|
161 |
+
$settings['selected'] = array( $settings['selected'] );
|
162 |
+
}
|
163 |
+
|
164 |
+
$found = false;
|
165 |
+
|
166 |
+
foreach ( $settings['selected'] as $component ) {
|
167 |
+
if ( ! array_key_exists( $component, $bp->active_components ) ) {
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
|
171 |
+
if ( bp_is_current_component( $component ) ) {
|
172 |
+
$found = true;
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
return $found;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Checks if the current page is the selected bp action.
|
182 |
+
*
|
183 |
+
* @param array $settings
|
184 |
+
*
|
185 |
+
* @return bool
|
186 |
+
*/
|
187 |
+
public static function bp_is_current_action( $settings = array() ) {
|
188 |
+
|
189 |
+
if ( empty ( $settings['selected'] ) ) {
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
|
193 |
+
if ( ! is_array( $settings['selected'] ) ) {
|
194 |
+
$settings['selected'] = array_map( 'trim', explode( ',', $settings['selected'] ) );
|
195 |
+
}
|
196 |
+
|
197 |
+
$found = false;
|
198 |
+
|
199 |
+
foreach ( $settings['selected'] as $action ) {
|
200 |
+
if ( bp_is_current_action( $action ) ) {
|
201 |
+
$found = true;
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
return $found;
|
206 |
+
}
|
207 |
+
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Checks if the current page is the selected bp action variable.
|
211 |
+
*
|
212 |
+
* @param array $settings
|
213 |
+
*
|
214 |
+
* @return bool
|
215 |
+
*/
|
216 |
+
public static function bp_is_action_variable( $settings = array() ) {
|
217 |
+
|
218 |
+
if ( empty ( $settings['selected'] ) ) {
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
if ( ! is_array( $settings['selected'] ) ) {
|
223 |
+
$settings['selected'] = array_map( 'trim', explode( ',', $settings['selected'] ) );
|
224 |
+
}
|
225 |
+
|
226 |
+
$found = false;
|
227 |
+
|
228 |
+
foreach ( $settings['selected'] as $variable ) {
|
229 |
+
if ( bp_is_action_variable( $variable ) ) {
|
230 |
+
$found = true;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
return $found;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* @param array $order
|
239 |
+
*
|
240 |
+
* @return array
|
241 |
+
*/
|
242 |
+
public static function condition_sort_order( $order = array() ) {
|
243 |
+
$order[ __( 'BuddyPress', 'buddypress' ) ] = 5.756;
|
244 |
+
|
245 |
+
return $order;
|
246 |
+
}
|
247 |
+
|
248 |
+
}
|
languages/popup-maker.pot
CHANGED
@@ -2631,6 +2631,54 @@ msgstr ""
|
|
2631 |
msgid "Please check your email and confirm your subscription."
|
2632 |
msgstr ""
|
2633 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2634 |
#: includes/integrations/class-pum-cf7.php:97
|
2635 |
msgid "Contact Form 7 Success"
|
2636 |
msgstr ""
|
2631 |
msgid "Please check your email and confirm your subscription."
|
2632 |
msgstr ""
|
2633 |
|
2634 |
+
#: includes/integrations/class-pum-buddypress-integration.php:35
|
2635 |
+
msgid "BP: Is a BuddyPress Page"
|
2636 |
+
msgstr ""
|
2637 |
+
|
2638 |
+
#: includes/integrations/class-pum-buddypress-integration.php:41
|
2639 |
+
msgid "BP: Is User Page"
|
2640 |
+
msgstr ""
|
2641 |
+
|
2642 |
+
#: includes/integrations/class-pum-buddypress-integration.php:47
|
2643 |
+
msgid "BP: Is Group Page"
|
2644 |
+
msgstr ""
|
2645 |
+
|
2646 |
+
#: includes/integrations/class-pum-buddypress-integration.php:53
|
2647 |
+
msgid "BP: Is User Messages Page"
|
2648 |
+
msgstr ""
|
2649 |
+
|
2650 |
+
#: includes/integrations/class-pum-buddypress-integration.php:59
|
2651 |
+
msgid "BP: Is Activation Page"
|
2652 |
+
msgstr ""
|
2653 |
+
|
2654 |
+
#: includes/integrations/class-pum-buddypress-integration.php:65
|
2655 |
+
msgid "BP: Is Register Page"
|
2656 |
+
msgstr ""
|
2657 |
+
|
2658 |
+
#: includes/integrations/class-pum-buddypress-integration.php:71
|
2659 |
+
msgid "BP: Is Item Admin"
|
2660 |
+
msgstr ""
|
2661 |
+
|
2662 |
+
#: includes/integrations/class-pum-buddypress-integration.php:77
|
2663 |
+
msgid "BP: Is Item Mod"
|
2664 |
+
msgstr ""
|
2665 |
+
|
2666 |
+
#: includes/integrations/class-pum-buddypress-integration.php:83
|
2667 |
+
msgid "BP: Is Directory"
|
2668 |
+
msgstr ""
|
2669 |
+
|
2670 |
+
#: includes/integrations/class-pum-buddypress-integration.php:88
|
2671 |
+
msgid "BP: Is Current Component"
|
2672 |
+
msgstr ""
|
2673 |
+
|
2674 |
+
#: includes/integrations/class-pum-buddypress-integration.php:104
|
2675 |
+
msgid "BP: Is Current Action"
|
2676 |
+
msgstr ""
|
2677 |
+
|
2678 |
+
#: includes/integrations/class-pum-buddypress-integration.php:116
|
2679 |
+
msgid "BP: Is Action Variable"
|
2680 |
+
msgstr ""
|
2681 |
+
|
2682 |
#: includes/integrations/class-pum-cf7.php:97
|
2683 |
msgid "Contact Form 7 Success"
|
2684 |
msgstr ""
|
popup-maker.php
CHANGED
@@ -1,423 +1,423 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Plugin Name: Popup Maker
|
4 |
-
* Plugin URI: https://wppopupmaker.com/?utm_campaign=PluginInfo&utm_source=plugin-header&utm_medium=plugin-uri
|
5 |
-
* Description: Easily create & style popups with any content. Theme editor to quickly style your popups. Add forms, social media boxes, videos & more.
|
6 |
-
* Version: 1.8.
|
7 |
-
* Author: WP Popup Maker
|
8 |
-
* Author URI: https://wppopupmaker.com/?utm_campaign=PluginInfo&utm_source=plugin-header&utm_medium=author-uri
|
9 |
-
* License: GPL2 or later
|
10 |
-
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
-
* Text Domain: popup-maker
|
12 |
-
* Domain Path: /languages/
|
13 |
-
*
|
14 |
-
* @package POPMAKE
|
15 |
-
* @category Core
|
16 |
-
* @author Daniel Iser
|
17 |
-
* @copyright Copyright (c) 2018, Wizard Internet Solutions
|
18 |
-
* @since 1.0
|
19 |
-
*/
|
20 |
-
|
21 |
-
// Exit if accessed directly
|
22 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
23 |
-
exit;
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Class Autoloader
|
28 |
-
*
|
29 |
-
* @param $class
|
30 |
-
*/
|
31 |
-
function pum_autoloader( $class ) {
|
32 |
-
|
33 |
-
if ( strncmp( 'PUM_Newsletter_', $class, strlen( 'PUM_Newsletter_' ) ) === 0 && class_exists( 'PUM_MCI' ) && ! empty( PUM_MCI::$VER ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) {
|
34 |
-
return;
|
35 |
-
}
|
36 |
-
|
37 |
-
$pum_autoloaders = apply_filters( 'pum_autoloaders', array(
|
38 |
-
array(
|
39 |
-
'prefix' => 'PUM_',
|
40 |
-
'dir' => dirname( __FILE__ ) . '/classes/',
|
41 |
-
),
|
42 |
-
) );
|
43 |
-
|
44 |
-
foreach ( $pum_autoloaders as $autoloader ) {
|
45 |
-
$autoloader = wp_parse_args( $autoloader, array(
|
46 |
-
'prefix' => 'PUM_',
|
47 |
-
'dir' => dirname( __FILE__ ) . '/classes/',
|
48 |
-
'search' => '_',
|
49 |
-
'replace' => '/',
|
50 |
-
) );
|
51 |
-
|
52 |
-
// project-specific namespace prefix
|
53 |
-
$prefix = $autoloader['prefix'];
|
54 |
-
|
55 |
-
// does the class use the namespace prefix?
|
56 |
-
$len = strlen( $prefix );
|
57 |
-
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
|
58 |
-
// no, move to the next registered autoloader
|
59 |
-
continue;
|
60 |
-
}
|
61 |
-
|
62 |
-
// get the relative class name
|
63 |
-
$relative_class = substr( $class, $len );
|
64 |
-
|
65 |
-
// replace the namespace prefix with the base directory, replace namespace
|
66 |
-
// separators with directory separators in the relative class name, append
|
67 |
-
// with .php
|
68 |
-
$file = $autoloader['dir'] . str_replace( $autoloader['search'], $autoloader['replace'], $relative_class ) . '.php';
|
69 |
-
|
70 |
-
// if the file exists, require it
|
71 |
-
if ( file_exists( $file ) ) {
|
72 |
-
require_once $file;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
if ( ! function_exists( 'spl_autoload_register' ) ) {
|
78 |
-
include 'includes/compat.php';
|
79 |
-
}
|
80 |
-
|
81 |
-
spl_autoload_register( 'pum_autoloader' ); // Register autoloader
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Main Popup_Maker Class
|
85 |
-
*
|
86 |
-
* @since 1.0
|
87 |
-
*/
|
88 |
-
class Popup_Maker {
|
89 |
-
|
90 |
-
/**
|
91 |
-
* @var string Plugin Name
|
92 |
-
*/
|
93 |
-
public static $NAME = 'Popup Maker';
|
94 |
-
|
95 |
-
/**
|
96 |
-
* @var string Plugin Version
|
97 |
-
*/
|
98 |
-
public static $VER = '1.8.
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @var int DB Version
|
102 |
-
*/
|
103 |
-
public static $DB_VER = 8;
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @var string License API URL
|
107 |
-
*/
|
108 |
-
public static $API_URL = 'https://wppopupmaker.com';
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @var string
|
112 |
-
*/
|
113 |
-
public static $MIN_PHP_VER = '5.2.17';
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @var string
|
117 |
-
*/
|
118 |
-
public static $MIN_WP_VER = '3.6';
|
119 |
-
|
120 |
-
/**
|
121 |
-
* @var string Plugin URL
|
122 |
-
*/
|
123 |
-
public static $URL;
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @var string Plugin Directory
|
127 |
-
*/
|
128 |
-
public static $DIR;
|
129 |
-
|
130 |
-
/**
|
131 |
-
* @var string Plugin FILE
|
132 |
-
*/
|
133 |
-
public static $FILE;
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Used to test if debug_mode is enabled.
|
137 |
-
*
|
138 |
-
* @var bool
|
139 |
-
*/
|
140 |
-
public static $DEBUG_MODE = false;
|
141 |
-
|
142 |
-
/**
|
143 |
-
* @var PUM_Utils_Cron
|
144 |
-
*/
|
145 |
-
public $cron;
|
146 |
-
|
147 |
-
/**
|
148 |
-
* @var PUM_Repository_Popups
|
149 |
-
*/
|
150 |
-
public $popups;
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @var PUM_Repository_Themes
|
154 |
-
*/
|
155 |
-
public $themes;
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @var null|PUM_Model_Popup
|
159 |
-
*/
|
160 |
-
public $current_popup;
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @var null|PUM_Model_Theme
|
164 |
-
*/
|
165 |
-
public $current_theme;
|
166 |
-
|
167 |
-
/**
|
168 |
-
* @var Popup_Maker The one true Popup_Maker
|
169 |
-
*/
|
170 |
-
private static $instance;
|
171 |
-
|
172 |
-
/**
|
173 |
-
* Main instance
|
174 |
-
*
|
175 |
-
* @return Popup_Maker
|
176 |
-
*/
|
177 |
-
public static function instance() {
|
178 |
-
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Popup_Maker ) ) {
|
179 |
-
self::$instance = new Popup_Maker;
|
180 |
-
self::$instance->setup_constants();
|
181 |
-
self::$instance->includes();
|
182 |
-
add_action( 'init', array( self::$instance, 'load_textdomain' ) );
|
183 |
-
self::$instance->init();
|
184 |
-
}
|
185 |
-
|
186 |
-
return self::$instance;
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Setup plugin constants
|
191 |
-
*/
|
192 |
-
private function setup_constants() {
|
193 |
-
|
194 |
-
self::$DIR = plugin_dir_path( __FILE__ );
|
195 |
-
self::$URL = plugins_url( '/', __FILE__ );
|
196 |
-
self::$FILE = __FILE__;
|
197 |
-
|
198 |
-
if ( isset( $_GET['pum_debug'] ) || PUM_Utils_Options::get( 'debug_mode', false ) ) {
|
199 |
-
self::$DEBUG_MODE = true;
|
200 |
-
}
|
201 |
-
|
202 |
-
if ( ! defined( 'POPMAKE' ) ) {
|
203 |
-
define( 'POPMAKE', self::$FILE );
|
204 |
-
}
|
205 |
-
|
206 |
-
if ( ! defined( 'POPMAKE_NAME' ) ) {
|
207 |
-
define( 'POPMAKE_NAME', self::$NAME );
|
208 |
-
}
|
209 |
-
|
210 |
-
if ( ! defined( 'POPMAKE_SLUG' ) ) {
|
211 |
-
define( 'POPMAKE_SLUG', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
|
212 |
-
}
|
213 |
-
|
214 |
-
if ( ! defined( 'POPMAKE_DIR' ) ) {
|
215 |
-
define( 'POPMAKE_DIR', self::$DIR );
|
216 |
-
}
|
217 |
-
|
218 |
-
if ( ! defined( 'POPMAKE_URL' ) ) {
|
219 |
-
define( 'POPMAKE_URL', self::$URL );
|
220 |
-
}
|
221 |
-
|
222 |
-
if ( ! defined( 'POPMAKE_NONCE' ) ) {
|
223 |
-
define( 'POPMAKE_NONCE', 'popmake_nonce' );
|
224 |
-
}
|
225 |
-
|
226 |
-
if ( ! defined( 'POPMAKE_VERSION' ) ) {
|
227 |
-
define( 'POPMAKE_VERSION', self::$VER );
|
228 |
-
}
|
229 |
-
|
230 |
-
if ( ! defined( 'POPMAKE_DB_VERSION' ) ) {
|
231 |
-
define( 'POPMAKE_DB_VERSION', self::$DB_VER );
|
232 |
-
}
|
233 |
-
|
234 |
-
if ( ! defined( 'POPMAKE_API_URL' ) ) {
|
235 |
-
define( 'POPMAKE_API_URL', self::$API_URL );
|
236 |
-
}
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Include required files
|
241 |
-
*/
|
242 |
-
private function includes() {
|
243 |
-
|
244 |
-
require_once self::$DIR . 'includes/compat.php';
|
245 |
-
|
246 |
-
// Initialize global options
|
247 |
-
PUM_Utils_Options::init();
|
248 |
-
|
249 |
-
/** Loads most of our core functions */
|
250 |
-
require_once self::$DIR . 'includes/functions.php';
|
251 |
-
|
252 |
-
/** Deprecated functionality */
|
253 |
-
require_once self::$DIR . 'includes/functions-backcompat.php';
|
254 |
-
require_once self::$DIR . 'includes/functions-deprecated.php';
|
255 |
-
require_once self::$DIR . 'includes/deprecated-classes.php';
|
256 |
-
require_once self::$DIR . 'includes/integrations.php';
|
257 |
-
|
258 |
-
// Old Stuff.
|
259 |
-
require_once self::$DIR . 'includes/defaults.php';
|
260 |
-
require_once self::$DIR . 'includes/input-options.php';
|
261 |
-
|
262 |
-
require_once self::$DIR . 'includes/importer/easy-modal-v2.php';
|
263 |
-
|
264 |
-
// Phasing Out
|
265 |
-
require_once self::$DIR . 'includes/class-popmake-fields.php';
|
266 |
-
require_once self::$DIR . 'includes/class-popmake-popup-fields.php';
|
267 |
-
|
268 |
-
/**
|
269 |
-
* v1.4 Additions
|
270 |
-
*/
|
271 |
-
require_once self::$DIR . 'includes/class-pum-fields.php';
|
272 |
-
require_once self::$DIR . 'includes/class-pum-form.php';
|
273 |
-
|
274 |
-
// Modules
|
275 |
-
require_once self::$DIR . 'includes/modules/menus.php';
|
276 |
-
require_once self::$DIR . 'includes/modules/admin-bar.php';
|
277 |
-
require_once self::$DIR . 'includes/modules/reviews.php';
|
278 |
-
|
279 |
-
require_once self::$DIR . 'includes/pum-install-functions.php';
|
280 |
-
}
|
281 |
-
|
282 |
-
/**
|
283 |
-
* Loads the plugin language files
|
284 |
-
*/
|
285 |
-
public function load_textdomain() {
|
286 |
-
// Set filter for plugin's languages directory
|
287 |
-
$lang_dir = apply_filters( 'pum_lang_dir', dirname( plugin_basename( POPMAKE ) ) . '/languages/' );
|
288 |
-
$lang_dir = apply_filters( 'popmake_languages_directory', $lang_dir );
|
289 |
-
|
290 |
-
// Try to load Langpacks first, if they are not available fallback to local files.
|
291 |
-
if ( ! load_plugin_textdomain( 'popup-maker', false, $lang_dir ) ) {
|
292 |
-
// Traditional WordPress plugin locale filter
|
293 |
-
$locale = apply_filters( 'plugin_locale', get_locale(), 'popup-maker' );
|
294 |
-
$mofile = sprintf( '%1$s-%2$s.mo', 'popup-maker', $locale );
|
295 |
-
|
296 |
-
// Setup paths to current locale file
|
297 |
-
$mofile_local = $lang_dir . $mofile;
|
298 |
-
$mofile_global = WP_LANG_DIR . '/popup-maker/' . $mofile;
|
299 |
-
|
300 |
-
if ( file_exists( $mofile_global ) ) {
|
301 |
-
// Look in global /wp-content/languages/popup-maker folder
|
302 |
-
load_textdomain( 'popup-maker', $mofile_global );
|
303 |
-
} elseif ( file_exists( $mofile_local ) ) {
|
304 |
-
// Look in local /wp-content/plugins/popup-maker/languages/ folder
|
305 |
-
load_textdomain( 'popup-maker', $mofile_local );
|
306 |
-
}
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
public function init() {
|
311 |
-
$this->cron = new PUM_Utils_Cron;
|
312 |
-
$this->popups = new PUM_Repository_Popups();
|
313 |
-
$this->themes = new PUM_Repository_Themes();
|
314 |
-
|
315 |
-
PUM_Types::init();
|
316 |
-
PUM_AssetCache::init();
|
317 |
-
PUM_Site::init();
|
318 |
-
PUM_Admin::init();
|
319 |
-
PUM_Utils_Upgrades::instance();
|
320 |
-
PUM_Newsletters::init();
|
321 |
-
PUM_Previews::init();
|
322 |
-
PUM_Integrations::init();
|
323 |
-
PUM_Privacy::init();
|
324 |
-
|
325 |
-
PUM_Utils_Alerts::init();
|
326 |
-
|
327 |
-
PUM_Shortcode_Popup::init();
|
328 |
-
PUM_Shortcode_PopupTrigger::init();
|
329 |
-
PUM_Shortcode_PopupClose::init();
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Here we check for previous FS optin.
|
333 |
-
* If no test has been performed we initialize Freemius one last time to check optin status.
|
334 |
-
*/
|
335 |
-
$has_opted_in = get_option( 'pum_previously_opted_using_freemius' );
|
336 |
-
if ( false === $has_opted_in ) {
|
337 |
-
PUM_Freemius::instance();
|
338 |
-
update_option( 'pum_previously_opted_using_freemius', PUM_Freemius::instance()->fs()->is_registered() ? 1 : 0 );
|
339 |
-
} else if ( 1 === $has_opted_in ) {
|
340 |
-
/**
|
341 |
-
* The user has previously opted via Freemius. Lets show custom messages in the new optin requests.
|
342 |
-
*/
|
343 |
-
} else {
|
344 |
-
/**
|
345 |
-
* The user never opted via Freemius. Show default optin request.
|
346 |
-
*/
|
347 |
-
}
|
348 |
-
}
|
349 |
-
|
350 |
-
/**
|
351 |
-
* Returns true when debug mode is enabled.
|
352 |
-
*
|
353 |
-
* @return bool
|
354 |
-
*/
|
355 |
-
public static function debug_mode() {
|
356 |
-
return true === self::$DEBUG_MODE;
|
357 |
-
}
|
358 |
-
|
359 |
-
}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Initialize the plugin.
|
363 |
-
*/
|
364 |
-
Popup_Maker::instance();
|
365 |
-
|
366 |
-
/**
|
367 |
-
* The code that runs during plugin activation.
|
368 |
-
* This action is documented in classes/Activator.php
|
369 |
-
*/
|
370 |
-
register_activation_hook( __FILE__, array( 'PUM_Activator', 'activate' ) );
|
371 |
-
|
372 |
-
/**
|
373 |
-
* The code that runs during plugin deactivation.
|
374 |
-
* This action is documented in classes/Deactivator.php
|
375 |
-
*/
|
376 |
-
register_deactivation_hook( __FILE__, array( 'PUM_Deactivator', 'deactivate' ) );
|
377 |
-
|
378 |
-
/**
|
379 |
-
* @deprecated 1.7.0
|
380 |
-
*/
|
381 |
-
function popmake_initialize() {
|
382 |
-
// Disable Unlimited Themes extension if active.
|
383 |
-
remove_action( 'popmake_initialize', 'popmake_ut_initialize' );
|
384 |
-
|
385 |
-
// Initialize old PUM extensions
|
386 |
-
do_action( 'pum_initialize' );
|
387 |
-
do_action( 'popmake_initialize' );
|
388 |
-
}
|
389 |
-
|
390 |
-
add_action( 'plugins_loaded', 'popmake_initialize' );
|
391 |
-
|
392 |
-
/**
|
393 |
-
* The main function responsible for returning the one true Popup_Maker
|
394 |
-
* Instance to functions everywhere.
|
395 |
-
*
|
396 |
-
* Use this function like you would a global variable, except without needing
|
397 |
-
* to declare the global.
|
398 |
-
*
|
399 |
-
* Example: <?php $popmake = PopMake(); ?>
|
400 |
-
*
|
401 |
-
* @since 1.0
|
402 |
-
* @deprecated 1.7.0
|
403 |
-
*
|
404 |
-
* @return object The one true Popup_Maker Instance
|
405 |
-
*/
|
406 |
-
function PopMake() {
|
407 |
-
return Popup_Maker::instance();
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* The main function responsible for returning the one true Popup_Maker
|
412 |
-
* Instance to functions everywhere.
|
413 |
-
*
|
414 |
-
* Use this function like you would a global variable, except without needing
|
415 |
-
* to declare the global.
|
416 |
-
*
|
417 |
-
* @since 1.8.0
|
418 |
-
*
|
419 |
-
* @return Popup_Maker
|
420 |
-
*/
|
421 |
-
function pum() {
|
422 |
-
return Popup_Maker::instance();
|
423 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Popup Maker
|
4 |
+
* Plugin URI: https://wppopupmaker.com/?utm_campaign=PluginInfo&utm_source=plugin-header&utm_medium=plugin-uri
|
5 |
+
* Description: Easily create & style popups with any content. Theme editor to quickly style your popups. Add forms, social media boxes, videos & more.
|
6 |
+
* Version: 1.8.1
|
7 |
+
* Author: WP Popup Maker
|
8 |
+
* Author URI: https://wppopupmaker.com/?utm_campaign=PluginInfo&utm_source=plugin-header&utm_medium=author-uri
|
9 |
+
* License: GPL2 or later
|
10 |
+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
* Text Domain: popup-maker
|
12 |
+
* Domain Path: /languages/
|
13 |
+
*
|
14 |
+
* @package POPMAKE
|
15 |
+
* @category Core
|
16 |
+
* @author Daniel Iser
|
17 |
+
* @copyright Copyright (c) 2018, Wizard Internet Solutions
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
|
21 |
+
// Exit if accessed directly
|
22 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
23 |
+
exit;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Class Autoloader
|
28 |
+
*
|
29 |
+
* @param $class
|
30 |
+
*/
|
31 |
+
function pum_autoloader( $class ) {
|
32 |
+
|
33 |
+
if ( strncmp( 'PUM_Newsletter_', $class, strlen( 'PUM_Newsletter_' ) ) === 0 && class_exists( 'PUM_MCI' ) && ! empty( PUM_MCI::$VER ) && version_compare( PUM_MCI::$VER, '1.3.0', '<' ) ) {
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
$pum_autoloaders = apply_filters( 'pum_autoloaders', array(
|
38 |
+
array(
|
39 |
+
'prefix' => 'PUM_',
|
40 |
+
'dir' => dirname( __FILE__ ) . '/classes/',
|
41 |
+
),
|
42 |
+
) );
|
43 |
+
|
44 |
+
foreach ( $pum_autoloaders as $autoloader ) {
|
45 |
+
$autoloader = wp_parse_args( $autoloader, array(
|
46 |
+
'prefix' => 'PUM_',
|
47 |
+
'dir' => dirname( __FILE__ ) . '/classes/',
|
48 |
+
'search' => '_',
|
49 |
+
'replace' => '/',
|
50 |
+
) );
|
51 |
+
|
52 |
+
// project-specific namespace prefix
|
53 |
+
$prefix = $autoloader['prefix'];
|
54 |
+
|
55 |
+
// does the class use the namespace prefix?
|
56 |
+
$len = strlen( $prefix );
|
57 |
+
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
|
58 |
+
// no, move to the next registered autoloader
|
59 |
+
continue;
|
60 |
+
}
|
61 |
+
|
62 |
+
// get the relative class name
|
63 |
+
$relative_class = substr( $class, $len );
|
64 |
+
|
65 |
+
// replace the namespace prefix with the base directory, replace namespace
|
66 |
+
// separators with directory separators in the relative class name, append
|
67 |
+
// with .php
|
68 |
+
$file = $autoloader['dir'] . str_replace( $autoloader['search'], $autoloader['replace'], $relative_class ) . '.php';
|
69 |
+
|
70 |
+
// if the file exists, require it
|
71 |
+
if ( file_exists( $file ) ) {
|
72 |
+
require_once $file;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
if ( ! function_exists( 'spl_autoload_register' ) ) {
|
78 |
+
include 'includes/compat.php';
|
79 |
+
}
|
80 |
+
|
81 |
+
spl_autoload_register( 'pum_autoloader' ); // Register autoloader
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Main Popup_Maker Class
|
85 |
+
*
|
86 |
+
* @since 1.0
|
87 |
+
*/
|
88 |
+
class Popup_Maker {
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @var string Plugin Name
|
92 |
+
*/
|
93 |
+
public static $NAME = 'Popup Maker';
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @var string Plugin Version
|
97 |
+
*/
|
98 |
+
public static $VER = '1.8.1';
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @var int DB Version
|
102 |
+
*/
|
103 |
+
public static $DB_VER = 8;
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @var string License API URL
|
107 |
+
*/
|
108 |
+
public static $API_URL = 'https://wppopupmaker.com';
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @var string
|
112 |
+
*/
|
113 |
+
public static $MIN_PHP_VER = '5.2.17';
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @var string
|
117 |
+
*/
|
118 |
+
public static $MIN_WP_VER = '3.6';
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @var string Plugin URL
|
122 |
+
*/
|
123 |
+
public static $URL;
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @var string Plugin Directory
|
127 |
+
*/
|
128 |
+
public static $DIR;
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @var string Plugin FILE
|
132 |
+
*/
|
133 |
+
public static $FILE;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Used to test if debug_mode is enabled.
|
137 |
+
*
|
138 |
+
* @var bool
|
139 |
+
*/
|
140 |
+
public static $DEBUG_MODE = false;
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @var PUM_Utils_Cron
|
144 |
+
*/
|
145 |
+
public $cron;
|
146 |
+
|
147 |
+
/**
|
148 |
+
* @var PUM_Repository_Popups
|
149 |
+
*/
|
150 |
+
public $popups;
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @var PUM_Repository_Themes
|
154 |
+
*/
|
155 |
+
public $themes;
|
156 |
+
|
157 |
+
/**
|
158 |
+
* @var null|PUM_Model_Popup
|
159 |
+
*/
|
160 |
+
public $current_popup;
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @var null|PUM_Model_Theme
|
164 |
+
*/
|
165 |
+
public $current_theme;
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @var Popup_Maker The one true Popup_Maker
|
169 |
+
*/
|
170 |
+
private static $instance;
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Main instance
|
174 |
+
*
|
175 |
+
* @return Popup_Maker
|
176 |
+
*/
|
177 |
+
public static function instance() {
|
178 |
+
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Popup_Maker ) ) {
|
179 |
+
self::$instance = new Popup_Maker;
|
180 |
+
self::$instance->setup_constants();
|
181 |
+
self::$instance->includes();
|
182 |
+
add_action( 'init', array( self::$instance, 'load_textdomain' ) );
|
183 |
+
self::$instance->init();
|
184 |
+
}
|
185 |
+
|
186 |
+
return self::$instance;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Setup plugin constants
|
191 |
+
*/
|
192 |
+
private function setup_constants() {
|
193 |
+
|
194 |
+
self::$DIR = plugin_dir_path( __FILE__ );
|
195 |
+
self::$URL = plugins_url( '/', __FILE__ );
|
196 |
+
self::$FILE = __FILE__;
|
197 |
+
|
198 |
+
if ( isset( $_GET['pum_debug'] ) || PUM_Utils_Options::get( 'debug_mode', false ) ) {
|
199 |
+
self::$DEBUG_MODE = true;
|
200 |
+
}
|
201 |
+
|
202 |
+
if ( ! defined( 'POPMAKE' ) ) {
|
203 |
+
define( 'POPMAKE', self::$FILE );
|
204 |
+
}
|
205 |
+
|
206 |
+
if ( ! defined( 'POPMAKE_NAME' ) ) {
|
207 |
+
define( 'POPMAKE_NAME', self::$NAME );
|
208 |
+
}
|
209 |
+
|
210 |
+
if ( ! defined( 'POPMAKE_SLUG' ) ) {
|
211 |
+
define( 'POPMAKE_SLUG', trim( dirname( plugin_basename( __FILE__ ) ), '/' ) );
|
212 |
+
}
|
213 |
+
|
214 |
+
if ( ! defined( 'POPMAKE_DIR' ) ) {
|
215 |
+
define( 'POPMAKE_DIR', self::$DIR );
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( ! defined( 'POPMAKE_URL' ) ) {
|
219 |
+
define( 'POPMAKE_URL', self::$URL );
|
220 |
+
}
|
221 |
+
|
222 |
+
if ( ! defined( 'POPMAKE_NONCE' ) ) {
|
223 |
+
define( 'POPMAKE_NONCE', 'popmake_nonce' );
|
224 |
+
}
|
225 |
+
|
226 |
+
if ( ! defined( 'POPMAKE_VERSION' ) ) {
|
227 |
+
define( 'POPMAKE_VERSION', self::$VER );
|
228 |
+
}
|
229 |
+
|
230 |
+
if ( ! defined( 'POPMAKE_DB_VERSION' ) ) {
|
231 |
+
define( 'POPMAKE_DB_VERSION', self::$DB_VER );
|
232 |
+
}
|
233 |
+
|
234 |
+
if ( ! defined( 'POPMAKE_API_URL' ) ) {
|
235 |
+
define( 'POPMAKE_API_URL', self::$API_URL );
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Include required files
|
241 |
+
*/
|
242 |
+
private function includes() {
|
243 |
+
|
244 |
+
require_once self::$DIR . 'includes/compat.php';
|
245 |
+
|
246 |
+
// Initialize global options
|
247 |
+
PUM_Utils_Options::init();
|
248 |
+
|
249 |
+
/** Loads most of our core functions */
|
250 |
+
require_once self::$DIR . 'includes/functions.php';
|
251 |
+
|
252 |
+
/** Deprecated functionality */
|
253 |
+
require_once self::$DIR . 'includes/functions-backcompat.php';
|
254 |
+
require_once self::$DIR . 'includes/functions-deprecated.php';
|
255 |
+
require_once self::$DIR . 'includes/deprecated-classes.php';
|
256 |
+
require_once self::$DIR . 'includes/integrations.php';
|
257 |
+
|
258 |
+
// Old Stuff.
|
259 |
+
require_once self::$DIR . 'includes/defaults.php';
|
260 |
+
require_once self::$DIR . 'includes/input-options.php';
|
261 |
+
|
262 |
+
require_once self::$DIR . 'includes/importer/easy-modal-v2.php';
|
263 |
+
|
264 |
+
// Phasing Out
|
265 |
+
require_once self::$DIR . 'includes/class-popmake-fields.php';
|
266 |
+
require_once self::$DIR . 'includes/class-popmake-popup-fields.php';
|
267 |
+
|
268 |
+
/**
|
269 |
+
* v1.4 Additions
|
270 |
+
*/
|
271 |
+
require_once self::$DIR . 'includes/class-pum-fields.php';
|
272 |
+
require_once self::$DIR . 'includes/class-pum-form.php';
|
273 |
+
|
274 |
+
// Modules
|
275 |
+
require_once self::$DIR . 'includes/modules/menus.php';
|
276 |
+
require_once self::$DIR . 'includes/modules/admin-bar.php';
|
277 |
+
require_once self::$DIR . 'includes/modules/reviews.php';
|
278 |
+
|
279 |
+
require_once self::$DIR . 'includes/pum-install-functions.php';
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Loads the plugin language files
|
284 |
+
*/
|
285 |
+
public function load_textdomain() {
|
286 |
+
// Set filter for plugin's languages directory
|
287 |
+
$lang_dir = apply_filters( 'pum_lang_dir', dirname( plugin_basename( POPMAKE ) ) . '/languages/' );
|
288 |
+
$lang_dir = apply_filters( 'popmake_languages_directory', $lang_dir );
|
289 |
+
|
290 |
+
// Try to load Langpacks first, if they are not available fallback to local files.
|
291 |
+
if ( ! load_plugin_textdomain( 'popup-maker', false, $lang_dir ) ) {
|
292 |
+
// Traditional WordPress plugin locale filter
|
293 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), 'popup-maker' );
|
294 |
+
$mofile = sprintf( '%1$s-%2$s.mo', 'popup-maker', $locale );
|
295 |
+
|
296 |
+
// Setup paths to current locale file
|
297 |
+
$mofile_local = $lang_dir . $mofile;
|
298 |
+
$mofile_global = WP_LANG_DIR . '/popup-maker/' . $mofile;
|
299 |
+
|
300 |
+
if ( file_exists( $mofile_global ) ) {
|
301 |
+
// Look in global /wp-content/languages/popup-maker folder
|
302 |
+
load_textdomain( 'popup-maker', $mofile_global );
|
303 |
+
} elseif ( file_exists( $mofile_local ) ) {
|
304 |
+
// Look in local /wp-content/plugins/popup-maker/languages/ folder
|
305 |
+
load_textdomain( 'popup-maker', $mofile_local );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
public function init() {
|
311 |
+
$this->cron = new PUM_Utils_Cron;
|
312 |
+
$this->popups = new PUM_Repository_Popups();
|
313 |
+
$this->themes = new PUM_Repository_Themes();
|
314 |
+
|
315 |
+
PUM_Types::init();
|
316 |
+
PUM_AssetCache::init();
|
317 |
+
PUM_Site::init();
|
318 |
+
PUM_Admin::init();
|
319 |
+
PUM_Utils_Upgrades::instance();
|
320 |
+
PUM_Newsletters::init();
|
321 |
+
PUM_Previews::init();
|
322 |
+
PUM_Integrations::init();
|
323 |
+
PUM_Privacy::init();
|
324 |
+
|
325 |
+
PUM_Utils_Alerts::init();
|
326 |
+
|
327 |
+
PUM_Shortcode_Popup::init();
|
328 |
+
PUM_Shortcode_PopupTrigger::init();
|
329 |
+
PUM_Shortcode_PopupClose::init();
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Here we check for previous FS optin.
|
333 |
+
* If no test has been performed we initialize Freemius one last time to check optin status.
|
334 |
+
*/
|
335 |
+
$has_opted_in = get_option( 'pum_previously_opted_using_freemius' );
|
336 |
+
if ( false === $has_opted_in ) {
|
337 |
+
PUM_Freemius::instance();
|
338 |
+
update_option( 'pum_previously_opted_using_freemius', PUM_Freemius::instance()->fs()->is_registered() ? 1 : 0 );
|
339 |
+
} else if ( 1 === $has_opted_in ) {
|
340 |
+
/**
|
341 |
+
* The user has previously opted via Freemius. Lets show custom messages in the new optin requests.
|
342 |
+
*/
|
343 |
+
} else {
|
344 |
+
/**
|
345 |
+
* The user never opted via Freemius. Show default optin request.
|
346 |
+
*/
|
347 |
+
}
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Returns true when debug mode is enabled.
|
352 |
+
*
|
353 |
+
* @return bool
|
354 |
+
*/
|
355 |
+
public static function debug_mode() {
|
356 |
+
return true === self::$DEBUG_MODE;
|
357 |
+
}
|
358 |
+
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Initialize the plugin.
|
363 |
+
*/
|
364 |
+
Popup_Maker::instance();
|
365 |
+
|
366 |
+
/**
|
367 |
+
* The code that runs during plugin activation.
|
368 |
+
* This action is documented in classes/Activator.php
|
369 |
+
*/
|
370 |
+
register_activation_hook( __FILE__, array( 'PUM_Activator', 'activate' ) );
|
371 |
+
|
372 |
+
/**
|
373 |
+
* The code that runs during plugin deactivation.
|
374 |
+
* This action is documented in classes/Deactivator.php
|
375 |
+
*/
|
376 |
+
register_deactivation_hook( __FILE__, array( 'PUM_Deactivator', 'deactivate' ) );
|
377 |
+
|
378 |
+
/**
|
379 |
+
* @deprecated 1.7.0
|
380 |
+
*/
|
381 |
+
function popmake_initialize() {
|
382 |
+
// Disable Unlimited Themes extension if active.
|
383 |
+
remove_action( 'popmake_initialize', 'popmake_ut_initialize' );
|
384 |
+
|
385 |
+
// Initialize old PUM extensions
|
386 |
+
do_action( 'pum_initialize' );
|
387 |
+
do_action( 'popmake_initialize' );
|
388 |
+
}
|
389 |
+
|
390 |
+
add_action( 'plugins_loaded', 'popmake_initialize' );
|
391 |
+
|
392 |
+
/**
|
393 |
+
* The main function responsible for returning the one true Popup_Maker
|
394 |
+
* Instance to functions everywhere.
|
395 |
+
*
|
396 |
+
* Use this function like you would a global variable, except without needing
|
397 |
+
* to declare the global.
|
398 |
+
*
|
399 |
+
* Example: <?php $popmake = PopMake(); ?>
|
400 |
+
*
|
401 |
+
* @since 1.0
|
402 |
+
* @deprecated 1.7.0
|
403 |
+
*
|
404 |
+
* @return object The one true Popup_Maker Instance
|
405 |
+
*/
|
406 |
+
function PopMake() {
|
407 |
+
return Popup_Maker::instance();
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* The main function responsible for returning the one true Popup_Maker
|
412 |
+
* Instance to functions everywhere.
|
413 |
+
*
|
414 |
+
* Use this function like you would a global variable, except without needing
|
415 |
+
* to declare the global.
|
416 |
+
*
|
417 |
+
* @since 1.8.0
|
418 |
+
*
|
419 |
+
* @return Popup_Maker
|
420 |
+
*/
|
421 |
+
function pum() {
|
422 |
+
return Popup_Maker::instance();
|
423 |
+
}
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Tags: marketing, popup, popups, optin, advertising, conversion, responsive popu
|
|
7 |
Requires at least: 4.1
|
8 |
Tested up to: 5.1
|
9 |
Requires PHP: 5.2.17
|
10 |
-
Stable tag: 1.8.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -103,6 +103,10 @@ There are several common causes for this which include:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= v1.8.0 - 02/20/2019 =
|
107 |
* Feature: New popup theme settings:
|
108 |
* New close button positions top center, bottom center, middle left & middle right.
|
7 |
Requires at least: 4.1
|
8 |
Tested up to: 5.1
|
9 |
Requires PHP: 5.2.17
|
10 |
+
Stable tag: 1.8.1
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= v1.8.1 - 02/22/2019 =
|
107 |
+
* Fix: Error on older versions of PHP when calling get_plugin_data on a plugin that wasn't installed.
|
108 |
+
* Fix: "Fatal error: Can not use method return value in write context" on older versions of PHP.
|
109 |
+
|
110 |
= v1.8.0 - 02/20/2019 =
|
111 |
* Feature: New popup theme settings:
|
112 |
* New close button positions top center, bottom center, middle left & middle right.
|