Popup Maker – Popup Forms, Optins & More - Version 1.8.7

Version Description

Download this release

Release Info

Developer danieliser
Plugin Icon 128x128 Popup Maker – Popup Forms, Optins & More
Version 1.8.7
Comparing to
See all releases

Code changes from version 1.8.6 to 1.8.7

CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  ### v1.8.6 - 05/05/2019
2
  * Fix: Typo in GDPR eraser that could sometimes result in errors when processing GDPR requests
3
  * Fix: Added function exists check to prevent errors on WP 4.1
1
+ ### v1.8.7 - 06/29/2019
2
+ * Tweak: Restricted the admin toolbar to only show under strict circumstances.
3
+ * Tweak: Updated available WooCommerce endpoints in our targeting conditions
4
+ * Fix: Issue with instance based shortcodes when asset caching was enabled but running on every request.
5
+
6
  ### v1.8.6 - 05/05/2019
7
  * Fix: Typo in GDPR eraser that could sometimes result in errors when processing GDPR requests
8
  * Fix: Added function exists check to prevent errors on WP 4.1
classes/AssetCache.php CHANGED
@@ -235,7 +235,7 @@ class PUM_AssetCache {
235
  pum()->current_popup = $popup;
236
 
237
  // Preprocess the content for shortcodes that need to enqueue their own assets.
238
- PUM_Helpers::do_shortcode( $popup->post_content );
239
 
240
  ob_start();
241
 
@@ -372,7 +372,7 @@ class PUM_AssetCache {
372
  pum()->current_popup = $popup;
373
 
374
  // Preprocess the content for shortcodes that need to enqueue their own assets.
375
- PUM_Helpers::do_shortcode( $popup->post_content );
376
 
377
  $popup = pum_get_popup( $popup->ID );
378
 
235
  pum()->current_popup = $popup;
236
 
237
  // Preprocess the content for shortcodes that need to enqueue their own assets.
238
+ // PUM_Helpers::do_shortcode( $popup->post_content );
239
 
240
  ob_start();
241
 
372
  pum()->current_popup = $popup;
373
 
374
  // Preprocess the content for shortcodes that need to enqueue their own assets.
375
+ // PUM_Helpers::do_shortcode( $popup->post_content );
376
 
377
  $popup = pum_get_popup( $popup->ID );
378
 
classes/Site/Popups.php CHANGED
@@ -99,7 +99,7 @@ class PUM_Site_Popups {
99
 
100
  foreach ( $popups as $popup ) {
101
  // Set this popup as the global $current.
102
- pum()->current_theme = $popup;
103
 
104
  // If the popup is loadable (passes conditions) load it.
105
  if ( pum_is_popup_loadable( $popup->ID ) ) {
99
 
100
  foreach ( $popups as $popup ) {
101
  // Set this popup as the global $current.
102
+ pum()->current_popup = $popup;
103
 
104
  // If the popup is loadable (passes conditions) load it.
105
  if ( pum_is_popup_loadable( $popup->ID ) ) {
includes/functions/admin/general.php CHANGED
@@ -1,97 +1,82 @@
1
- <?php
2
- /*******************************************************************************
3
- * Copyright (c) 2018, WP Popup Maker
4
- ******************************************************************************/
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit; // Exit if accessed directly
8
- }
9
-
10
- /**
11
- * Gets the current admin screen post type.
12
- *
13
- * @return bool|string
14
- */
15
- function pum_typenow() {
16
- if ( ! empty ( $GLOBALS['typenow'] ) ) {
17
- return $GLOBALS['typenow'];
18
- }
19
-
20
- // when editing pages, $typenow isn't set until later!
21
- // try to pick it up from the query string
22
- if ( ! empty( $_GET['post_type'] ) ) {
23
- return sanitize_text_field( $_GET['post_type'] );
24
- } elseif ( ! empty( $_GET['post'] ) ) {
25
- $post = get_post( $_GET['post'] );
26
-
27
- return $post->post_type;
28
- } elseif ( ! empty( $_POST['post_ID'] ) ) {
29
- $post = get_post( $_POST['post_ID'] );
30
-
31
- return $post->post_type;
32
- }
33
-
34
- return false;
35
- }
36
-
37
- /**
38
- * Generates an Popup Maker admin URL based on the given type.
39
- *
40
- * @since 1.7.0
41
- *
42
- * @param string $type Optional. Type of admin URL. Accepts 'tools', 'settings'. Default empty
43
- * @param array $query_args Optional. Query arguments to append to the admin URL. Default empty array.
44
- *
45
- * @return string Constructed admin URL.
46
- */
47
- function pum_admin_url( $type = '', $query_args = array() ) {
48
- $page = '';
49
-
50
- $whitelist = PUM_Admin_Pages::$pages;
51
-
52
- if ( in_array( $type, $whitelist, true ) ) {
53
- $page = "pum-{$type}";
54
- }
55
-
56
- $admin_query_args = array_merge( array( 'page' => $page ), $query_args );
57
-
58
- $url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
59
-
60
- /**
61
- * Filters the Popup Maker admin URL.
62
- *
63
- * @param string $url Admin URL.
64
- * @param string $type Admin URL type.
65
- * @param array $query_args Query arguments originally passed to pum_admin_url().
66
- */
67
- return apply_filters( 'pum_admin_url', $url, $type, $query_args );
68
- }
69
-
70
- /**
71
- * Returns $_POST key.
72
- *
73
- * @since 1.0
74
- *
75
- * @param string $name is the key you are looking for. Can use dot notation for arrays such as my_meta.field1 which will resolve to $_POST['my_meta']['field1'].
76
- *
77
- * @return mixed results of lookup
78
- */
79
- function popmake_post( $name, $do_stripslashes = true ) {
80
- $value = popmake_resolve( $_POST, $name, false );
81
-
82
- return $do_stripslashes ? stripslashes_deep( $value ) : $value;
83
- }
84
-
85
- /**
86
- * @return array
87
- */
88
- function pum_support_assist_args() {
89
- return array(
90
- // Forces the dashboard to force logout any users.
91
- 'nouser' => true,
92
- 'fname' => wp_get_current_user()->first_name,
93
- 'lname' => wp_get_current_user()->last_name,
94
- 'email' => wp_get_current_user()->user_email,
95
- 'url' => home_url(),
96
- );
97
  }
1
+ <?php
2
+ /*******************************************************************************
3
+ * Copyright (c) 2018, WP Popup Maker
4
+ ******************************************************************************/
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ /**
11
+ * Gets the current admin screen post type.
12
+ *
13
+ * @return bool|string
14
+ */
15
+ function pum_typenow() {
16
+ if ( ! empty ( $GLOBALS['typenow'] ) ) {
17
+ return $GLOBALS['typenow'];
18
+ }
19
+
20
+ // when editing pages, $typenow isn't set until later!
21
+ // try to pick it up from the query string
22
+ if ( ! empty( $_GET['post_type'] ) ) {
23
+ return sanitize_text_field( $_GET['post_type'] );
24
+ } elseif ( ! empty( $_GET['post'] ) ) {
25
+ $post = get_post( $_GET['post'] );
26
+
27
+ return $post->post_type;
28
+ } elseif ( ! empty( $_POST['post_ID'] ) ) {
29
+ $post = get_post( $_POST['post_ID'] );
30
+
31
+ return $post->post_type;
32
+ }
33
+
34
+ return false;
35
+ }
36
+
37
+ /**
38
+ * Generates an Popup Maker admin URL based on the given type.
39
+ *
40
+ * @since 1.7.0
41
+ *
42
+ * @param string $type Optional. Type of admin URL. Accepts 'tools', 'settings'. Default empty
43
+ * @param array $query_args Optional. Query arguments to append to the admin URL. Default empty array.
44
+ *
45
+ * @return string Constructed admin URL.
46
+ */
47
+ function pum_admin_url( $type = '', $query_args = array() ) {
48
+ $page = '';
49
+
50
+ $whitelist = PUM_Admin_Pages::$pages;
51
+
52
+ if ( in_array( $type, $whitelist, true ) ) {
53
+ $page = "pum-{$type}";
54
+ }
55
+
56
+ $admin_query_args = array_merge( array( 'page' => $page ), $query_args );
57
+
58
+ $url = add_query_arg( $admin_query_args, admin_url( 'edit.php?post_type=popup' ) );
59
+
60
+ /**
61
+ * Filters the Popup Maker admin URL.
62
+ *
63
+ * @param string $url Admin URL.
64
+ * @param string $type Admin URL type.
65
+ * @param array $query_args Query arguments originally passed to pum_admin_url().
66
+ */
67
+ return apply_filters( 'pum_admin_url', $url, $type, $query_args );
68
+ }
69
+
70
+ /**
71
+ * @return array
72
+ */
73
+ function pum_support_assist_args() {
74
+ return array(
75
+ // Forces the dashboard to force logout any users.
76
+ 'nouser' => true,
77
+ 'fname' => wp_get_current_user()->first_name,
78
+ 'lname' => wp_get_current_user()->last_name,
79
+ 'email' => wp_get_current_user()->user_email,
80
+ 'url' => home_url(),
81
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
includes/functions/general.php CHANGED
@@ -1,172 +1,187 @@
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
- * Get the current blog db_ver.
13
- *
14
- * @return mixed
15
- */
16
- function pum_get_db_ver() {
17
- return get_option( 'pum_db_ver', false );
18
- }
19
-
20
- /**
21
- * Returns the default theme_id from global settings.
22
- *
23
- * Returns false if none set.
24
- *
25
- * @since 1.8.0
26
- *
27
- * @return int|false
28
- */
29
- function pum_get_default_theme_id() {
30
- $default_theme_id = pum_get_option( 'default_theme_id' );
31
-
32
- if ( false === $default_theme_id ) {
33
- $default_theme_id = get_option( 'popmake_default_theme' );
34
-
35
- if ( false === $default_theme_id ) {
36
- $default_theme_id = pum_install_default_theme();
37
- if ( pum_update_option( 'default_theme_id', $default_theme_id ) ) {
38
- // Self cleanup old version.
39
- delete_option( 'popmake_default_theme' );
40
- }
41
- }
42
- }
43
-
44
- return absint( $default_theme_id );
45
- }
46
-
47
- /**
48
- * Gets the cache close_text of a theme from wp_options to prevent un-needed queries on the front end.
49
- *
50
- * @since 1.8.0
51
- *
52
- * @param int $theme_id
53
- *
54
- * @return string
55
- */
56
- function pum_get_theme_close_text( $theme_id = 0 ) {
57
- $close_texts = pum_get_all_themes_close_text();
58
-
59
- return isset( $close_texts[ $theme_id ] ) ? $close_texts[ $theme_id ] : '';
60
- }
61
-
62
- /**
63
- * Gets the cache of theme close text from wp_options to prevent un-needed queries on the front end.
64
- *
65
- * @since 1.8.0
66
- *
67
- * @return array|mixed
68
- */
69
- function pum_get_all_themes_close_text() {
70
- $all_themes_close_text = get_option( 'pum_all_theme_close_text_cache' );
71
-
72
- if ( false === $all_themes_close_text ) {
73
- $all_themes_close_text = pum_update_all_themes_close_text_cache();
74
- }
75
-
76
- return $all_themes_close_text;
77
- }
78
-
79
- /**
80
- * Updates the cache of theme close text to prevent un-needed queries on the front end.
81
- *
82
- * @since 1.8.0
83
- *
84
- * @return array
85
- */
86
- function pum_update_all_themes_close_text_cache() {
87
- $all_themes_close_text = array();
88
-
89
- $themes = pum_get_all_themes();
90
-
91
- foreach( $themes as $theme ) {
92
- $all_themes_close_text[ $theme->ID ] = $theme->get_setting( 'close_text', '' );
93
- }
94
-
95
- update_option( 'pum_all_theme_close_text_cache', $all_themes_close_text );
96
-
97
- return $all_themes_close_text;
98
- }
99
-
100
- add_action( 'pum_save_theme', 'pum_update_all_themes_close_text_cache', 100 );
101
-
102
- /**
103
- * @param string $path
104
- *
105
- * @return string
106
- */
107
- function pum_asset_path( $path = '' ) {
108
- return Popup_Maker::$DIR . 'assets/' . ltrim( $path,'/' );
109
- }
110
-
111
- /**
112
- * @param string $path
113
- *
114
- * @return string
115
- */
116
- function pum_asset_url( $path = '' ) {
117
- return Popup_Maker::$URL . 'assets/' . ltrim( $path,'/' );
118
- }
119
-
120
- /**
121
- * Resets both asset cached files & transient CSS storage to be regenerated.
122
- *
123
- * @since 1.8.0
124
- */
125
- function pum_reset_assets() {
126
- // Reset/regenerate asset cache.
127
- PUM_AssetCache::reset_cache();
128
- // Reset/regenerate stored theme CSS styles.
129
- delete_transient( 'popmake_theme_styles' );
130
- }
131
-
132
- /**
133
- * Returns array key from dot notated array key..
134
- *
135
- * @since 1.0
136
- *
137
- * @deprecated 1.8.0
138
- *
139
- * @param array $a is the array you are searching.
140
- * @param string $path is the dot notated path.
141
- * @param string $default is the default returned if key empty or not found.
142
- *
143
- * @return mixed results of lookup
144
- */
145
- function popmake_resolve( array $a, $path, $default = null ) {
146
- $current = $a;
147
- $p = strtok( $path, '.' );
148
- while ( $p !== false ) {
149
- if ( ! isset( $current[ $p ] ) ) {
150
- return $default;
151
- }
152
- $current = $current[ $p ];
153
- $p = strtok( '.' );
154
- }
155
-
156
- return $current;
157
- }
158
-
159
- /**
160
- * Checks whether function is disabled.
161
- *
162
- * @since 1.4
163
- *
164
- * @param string $function Name of the function.
165
- *
166
- * @return bool Whether or not function is disabled.
167
- */
168
- function pum_is_func_disabled( $function ) {
169
- $disabled = explode( ',', ini_get( 'disable_functions' ) );
170
-
171
- return in_array( $function, $disabled );
172
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Get the current blog db_ver.
13
+ *
14
+ * @return mixed
15
+ */
16
+ function pum_get_db_ver() {
17
+ return get_option( 'pum_db_ver', false );
18
+ }
19
+
20
+ /**
21
+ * Returns the default theme_id from global settings.
22
+ *
23
+ * Returns false if none set.
24
+ *
25
+ * @since 1.8.0
26
+ *
27
+ * @return int|false
28
+ */
29
+ function pum_get_default_theme_id() {
30
+ $default_theme_id = pum_get_option( 'default_theme_id' );
31
+
32
+ if ( false === $default_theme_id ) {
33
+ $default_theme_id = get_option( 'popmake_default_theme' );
34
+
35
+ if ( false === $default_theme_id ) {
36
+ $default_theme_id = pum_install_default_theme();
37
+ if ( pum_update_option( 'default_theme_id', $default_theme_id ) ) {
38
+ // Self cleanup old version.
39
+ delete_option( 'popmake_default_theme' );
40
+ }
41
+ }
42
+ }
43
+
44
+ return absint( $default_theme_id );
45
+ }
46
+
47
+ /**
48
+ * Gets the cache close_text of a theme from wp_options to prevent un-needed queries on the front end.
49
+ *
50
+ * @since 1.8.0
51
+ *
52
+ * @param int $theme_id
53
+ *
54
+ * @return string
55
+ */
56
+ function pum_get_theme_close_text( $theme_id = 0 ) {
57
+ $close_texts = pum_get_all_themes_close_text();
58
+
59
+ return isset( $close_texts[ $theme_id ] ) ? $close_texts[ $theme_id ] : '';
60
+ }
61
+
62
+ /**
63
+ * Gets the cache of theme close text from wp_options to prevent un-needed queries on the front end.
64
+ *
65
+ * @since 1.8.0
66
+ *
67
+ * @return array|mixed
68
+ */
69
+ function pum_get_all_themes_close_text() {
70
+ $all_themes_close_text = get_option( 'pum_all_theme_close_text_cache' );
71
+
72
+ if ( false === $all_themes_close_text ) {
73
+ $all_themes_close_text = pum_update_all_themes_close_text_cache();
74
+ }
75
+
76
+ return $all_themes_close_text;
77
+ }
78
+
79
+ /**
80
+ * Updates the cache of theme close text to prevent un-needed queries on the front end.
81
+ *
82
+ * @since 1.8.0
83
+ *
84
+ * @return array
85
+ */
86
+ function pum_update_all_themes_close_text_cache() {
87
+ $all_themes_close_text = array();
88
+
89
+ $themes = pum_get_all_themes();
90
+
91
+ foreach( $themes as $theme ) {
92
+ $all_themes_close_text[ $theme->ID ] = $theme->get_setting( 'close_text', '' );
93
+ }
94
+
95
+ update_option( 'pum_all_theme_close_text_cache', $all_themes_close_text );
96
+
97
+ return $all_themes_close_text;
98
+ }
99
+
100
+ add_action( 'pum_save_theme', 'pum_update_all_themes_close_text_cache', 100 );
101
+
102
+ /**
103
+ * @param string $path
104
+ *
105
+ * @return string
106
+ */
107
+ function pum_asset_path( $path = '' ) {
108
+ return Popup_Maker::$DIR . 'assets/' . ltrim( $path,'/' );
109
+ }
110
+
111
+ /**
112
+ * @param string $path
113
+ *
114
+ * @return string
115
+ */
116
+ function pum_asset_url( $path = '' ) {
117
+ return Popup_Maker::$URL . 'assets/' . ltrim( $path,'/' );
118
+ }
119
+
120
+ /**
121
+ * Resets both asset cached files & transient CSS storage to be regenerated.
122
+ *
123
+ * @since 1.8.0
124
+ */
125
+ function pum_reset_assets() {
126
+ // Reset/regenerate asset cache.
127
+ PUM_AssetCache::reset_cache();
128
+ // Reset/regenerate stored theme CSS styles.
129
+ delete_transient( 'popmake_theme_styles' );
130
+ }
131
+
132
+ /**
133
+ * Returns array key from dot notated array key..
134
+ *
135
+ * @since 1.0
136
+ *
137
+ * @deprecated 1.8.0
138
+ *
139
+ * @param array $a is the array you are searching.
140
+ * @param string $path is the dot notated path.
141
+ * @param string $default is the default returned if key empty or not found.
142
+ *
143
+ * @return mixed results of lookup
144
+ */
145
+ function popmake_resolve( array $a, $path, $default = null ) {
146
+ $current = $a;
147
+ $p = strtok( $path, '.' );
148
+ while ( $p !== false ) {
149
+ if ( ! isset( $current[ $p ] ) ) {
150
+ return $default;
151
+ }
152
+ $current = $current[ $p ];
153
+ $p = strtok( '.' );
154
+ }
155
+
156
+ return $current;
157
+ }
158
+
159
+ /**
160
+ * Returns $_POST key.
161
+ *
162
+ * @since 1.0
163
+ *
164
+ * @param string $name is the key you are looking for. Can use dot notation for arrays such as my_meta.field1 which will resolve to $_POST['my_meta']['field1'].
165
+ *
166
+ * @return mixed results of lookup
167
+ */
168
+ function popmake_post( $name, $do_stripslashes = true ) {
169
+ $value = popmake_resolve( $_POST, $name, false );
170
+
171
+ return $do_stripslashes ? stripslashes_deep( $value ) : $value;
172
+ }
173
+
174
+ /**
175
+ * Checks whether function is disabled.
176
+ *
177
+ * @since 1.4
178
+ *
179
+ * @param string $function Name of the function.
180
+ *
181
+ * @return bool Whether or not function is disabled.
182
+ */
183
+ function pum_is_func_disabled( $function ) {
184
+ $disabled = explode( ',', ini_get( 'disable_functions' ) );
185
+
186
+ return in_array( $function, $disabled );
187
+ }
includes/functions/popups/getters.php CHANGED
@@ -1,59 +1,57 @@
1
- <?php
2
- /*******************************************************************************
3
- * Copyright (c) 2018, WP Popup Maker
4
- ******************************************************************************/
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit; // Exit if accessed directly
8
- }
9
-
10
- /**
11
- * Return the popup id.
12
- *
13
- * @param int $popup_id
14
- *
15
- * @return int
16
- */
17
- function pum_get_popup_id( $popup_id = 0 ) {
18
- if ( ! empty( $popup_id ) && is_numeric( $popup_id ) ) {
19
- $_popup_id = $popup_id;
20
- } elseif ( is_object( pum()->current_popup ) && is_numeric( pum()->current_popup->ID ) ) {
21
- $_popup_id = pum()->current_popup->ID;
22
- } else {
23
- $_popup_id = 0;
24
- }
25
-
26
- return (int) apply_filters( 'pum_get_popup_id', (int) $_popup_id, $popup_id );
27
- }
28
-
29
- /**
30
- * @param int $popup_id
31
- *
32
- * @return string
33
- */
34
- function pum_get_popup_title( $popup_id = 0 ) {
35
- $popup = pum_get_popup( $popup_id );
36
-
37
- if ( ! pum_is_popup_object( $popup ) ) {
38
- return "";
39
- }
40
-
41
- return $popup->get_title();
42
- }
43
-
44
- /**
45
- * @deprecated 1.8.0
46
- *
47
- * @param int $popup_id
48
- *
49
- * @return array
50
- */
51
- function pum_get_popup_triggers( $popup_id = 0 ) {
52
- $popup = pum_get_popup( $popup_id );
53
-
54
- if ( ! pum_is_popup_object( $popup ) ) {
55
- return array();
56
- }
57
-
58
- return $popup->get_triggers();
59
- }
1
+ <?php
2
+ /*******************************************************************************
3
+ * Copyright (c) 2018, WP Popup Maker
4
+ ******************************************************************************/
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ /**
11
+ * Return the popup id.
12
+ *
13
+ * @param int $popup_id
14
+ *
15
+ * @return int
16
+ */
17
+ function pum_get_popup_id( $popup_id = null ) {
18
+ if ( null === $popup_id && pum_is_popup( pum()->current_popup ) ) {
19
+ $_popup_id = pum()->current_popup->ID;
20
+ } else {
21
+ $_popup_id = ! empty( $popup_id ) && is_numeric( $popup_id ) ? $popup_id : 0;
22
+ }
23
+
24
+ return (int) apply_filters( 'pum_get_popup_id', (int) $_popup_id, $popup_id );
25
+ }
26
+
27
+ /**
28
+ * @param int $popup_id
29
+ *
30
+ * @return string
31
+ */
32
+ function pum_get_popup_title( $popup_id = 0 ) {
33
+ $popup = pum_get_popup( $popup_id );
34
+
35
+ if ( ! pum_is_popup_object( $popup ) ) {
36
+ return "";
37
+ }
38
+
39
+ return $popup->get_title();
40
+ }
41
+
42
+ /**
43
+ * @param int $popup_id
44
+ *
45
+ * @return array
46
+ * @deprecated 1.8.0
47
+ *
48
+ */
49
+ function pum_get_popup_triggers( $popup_id = 0 ) {
50
+ $popup = pum_get_popup( $popup_id );
51
+
52
+ if ( ! pum_is_popup_object( $popup ) ) {
53
+ return array();
54
+ }
55
+
56
+ return $popup->get_triggers();
57
+ }
 
 
includes/functions/popups/queries.php CHANGED
@@ -1,71 +1,70 @@
1
- <?php
2
- /*******************************************************************************
3
- * Copyright (c) 2018, WP Popup Maker
4
- ******************************************************************************/
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit; // Exit if accessed directly
8
- }
9
-
10
- /**
11
- * Get a popup model instance.
12
- *
13
- * @param int $popup_id
14
- *
15
- * @return PUM_Model_Popup
16
- */
17
- function pum_get_popup( $popup_id = null ) {
18
- if ( ! $popup_id ) {
19
- if ( pum_is_popup( pum()->current_popup ) ) {
20
- return pum()->current_popup;
21
- } else {
22
- $popup_id = pum_get_popup_id();
23
- }
24
- }
25
-
26
- try {
27
- return pum()->popups->get_item( $popup_id );
28
- } catch ( InvalidArgumentException $e ) {
29
- // Return empty object
30
- return new PUM_Model_Popup( $popup_id );
31
- }
32
- }
33
-
34
- /**
35
- * Queries popups and returns them in a specific format.
36
- *
37
- * @param array $args
38
- *
39
- * @return PUM_Model_Popup[]
40
- */
41
- function pum_get_popups( $args = array() ) {
42
- return pum()->popups->get_items( $args );
43
- }
44
-
45
- /**
46
- * Queries popups and returns them in a specific format.
47
- *
48
- * @param array $args
49
- *
50
- * @return PUM_Model_Popup[]
51
- */
52
- function pum_get_all_popups( $args = array() ) {
53
- $args['posts_per_page'] = -1;
54
-
55
- return pum_get_popups( $args );
56
- }
57
-
58
- /**
59
- * Gets a count popups with specified args.
60
- *
61
- * @param array $args
62
- *
63
- * @return int
64
- */
65
- function pum_count_popups( $args = array() ) {
66
- $args = wp_parse_args( $args, array(
67
- 'post_status' => 'publish',
68
- ) );
69
-
70
- return pum()->popups->count_items( $args );
71
- }
1
+ <?php
2
+ /*******************************************************************************
3
+ * Copyright (c) 2018, WP Popup Maker
4
+ ******************************************************************************/
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly
8
+ }
9
+
10
+ /**
11
+ * Get a popup model instance.
12
+ *
13
+ * @param int $popup_id
14
+ *
15
+ * @return PUM_Model_Popup
16
+ */
17
+ function pum_get_popup( $popup_id = null ) {
18
+ if ( null === $popup_id && pum_is_popup( pum()->current_popup ) ) {
19
+ return pum()->current_popup;
20
+ }
21
+
22
+ /** @var int $popup_id filtered $popup_id */
23
+ $popup_id = pum_get_popup_id( $popup_id );
24
+
25
+ try {
26
+ return pum()->popups->get_item( $popup_id );
27
+ } catch ( InvalidArgumentException $e ) {
28
+ // Return empty object
29
+ return new PUM_Model_Popup( $popup_id );
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Queries popups and returns them in a specific format.
35
+ *
36
+ * @param array $args
37
+ *
38
+ * @return PUM_Model_Popup[]
39
+ */
40
+ function pum_get_popups( $args = array() ) {
41
+ return pum()->popups->get_items( $args );
42
+ }
43
+
44
+ /**
45
+ * Queries popups and returns them in a specific format.
46
+ *
47
+ * @param array $args
48
+ *
49
+ * @return PUM_Model_Popup[]
50
+ */
51
+ function pum_get_all_popups( $args = array() ) {
52
+ $args['posts_per_page'] = -1;
53
+
54
+ return pum_get_popups( $args );
55
+ }
56
+
57
+ /**
58
+ * Gets a count popups with specified args.
59
+ *
60
+ * @param array $args
61
+ *
62
+ * @return int
63
+ */
64
+ function pum_count_popups( $args = array() ) {
65
+ $args = wp_parse_args( $args, array(
66
+ 'post_status' => 'publish',
67
+ ) );
68
+
69
+ return pum()->popups->count_items( $args );
70
+ }
 
includes/functions/popups/template.php CHANGED
@@ -13,13 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  * @param null|int|string $popup_id
14
  */
15
  function pum_popup_ID( $popup_id = null ) {
16
- $popup = pum_get_popup( $popup_id );
17
-
18
- if ( ! pum_is_popup( $popup ) ) {
19
- return;
20
- }
21
-
22
- echo $popup->ID;
23
  }
24
 
25
  /**
@@ -43,7 +37,7 @@ function pum_popup_content( $popup_id = null ) {
43
  return;
44
  }
45
 
46
- $cached_content = PUM_Site_Popups::get_cache_content( $popup_id );
47
 
48
  echo false !== $cached_content ? $cached_content : $popup->get_content();
49
  }
13
  * @param null|int|string $popup_id
14
  */
15
  function pum_popup_ID( $popup_id = null ) {
16
+ echo pum_get_popup_id( $popup_id );
 
 
 
 
 
 
17
  }
18
 
19
  /**
37
  return;
38
  }
39
 
40
+ $cached_content = PUM_Site_Popups::get_cache_content( $popup->ID );
41
 
42
  echo false !== $cached_content ? $cached_content : $popup->get_content();
43
  }
includes/integrations/class-pum-woocommerce-integration.php CHANGED
@@ -1,89 +1,95 @@
1
- <?php
2
-
3
- // Exit if accessed directly
4
- if ( ! defined( 'ABSPATH' ) ) {
5
- exit;
6
- }
7
-
8
- class PUM_Woocommerce_Integration {
9
-
10
- public static function init() {
11
- add_filter( 'pum_registered_conditions', array( __CLASS__, 'register_conditions' ) );
12
- add_filter( 'pum_condition_sort_order', array( __CLASS__, 'condition_sort_order' ) );
13
- }
14
-
15
- public static function is_wc_endpoint_url( $settings = array() ) {
16
- $results = array();
17
-
18
- foreach ( $settings['selected'] as $key ) {
19
- $results[] = is_wc_endpoint_url( $key );
20
- }
21
-
22
- return in_array( true, $results );
23
- }
24
-
25
- public static function register_conditions( $conditions = array() ) {
26
-
27
- // Add Additional Conditions
28
- $conditions['is_woocommerce'] = array(
29
- 'group' => __( 'WooCommerce', 'woocommerce' ),
30
- 'name' => __( 'All WooCommerce', 'popup-maker' ),
31
- 'callback' => 'is_woocommerce',
32
- );
33
- $conditions['is_shop'] = array(
34
- 'group' => __( 'WooCommerce', 'woocommerce' ),
35
- 'name' => __( 'Shop Page', 'popup-maker' ),
36
- 'callback' => 'is_shop',
37
- );
38
- $conditions['is_cart'] = array(
39
- 'group' => __( 'WooCommerce', 'woocommerce' ),
40
- 'name' => __( 'Cart Page', 'popup-maker' ),
41
- 'callback' => 'is_cart',
42
- );
43
- $conditions['is_checkout'] = array(
44
- 'group' => __( 'WooCommerce', 'woocommerce' ),
45
- 'name' => __( 'Checkout Page', 'popup-maker' ),
46
- 'callback' => 'is_checkout',
47
- );
48
- $conditions['is_account_page'] = array(
49
- 'group' => __( 'WooCommerce', 'woocommerce' ),
50
- 'name' => __( 'Account Page', 'popup-maker' ),
51
- 'callback' => 'is_account_page',
52
- );
53
-
54
- $conditions['is_wc_endpoint_url'] = array(
55
- 'group' => __( 'WooCommerce', 'woocommerce' ),
56
- 'name' => __( 'Is Endpoint', 'popup-maker' ),
57
- 'fields' => array(
58
- 'selected' => array(
59
- 'placeholder' => __( 'Selected Endpoints', 'popup-maker' ),
60
- 'type' => 'select',
61
- 'select2' => true,
62
- 'multiple' => true,
63
- 'as_array' => true,
64
- 'options' => array(
65
- 'order-pay' => 'order-pay',
66
- 'order-received' => 'order-received',
67
- 'view-order' => 'view-order',
68
- 'edit-account' => 'edit-account',
69
- 'edit-address' => 'edit-address',
70
- 'lost-password' => 'lost-password',
71
- 'customer-logout' => 'customer-logout',
72
- 'add-payment-method' => 'add-payment-method',
73
- ),
74
- ),
75
- ),
76
- 'callback' => array( __CLASS__, 'is_wc_endpoint_url' ),
77
- );
78
-
79
- return $conditions;
80
- }
81
-
82
- public static function condition_sort_order( $order = array() ) {
83
- $order[ __( 'WooCommerce', 'woocommerce' ) ] = 5.256;
84
-
85
- return $order;
86
- }
87
-
88
- }
89
-
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) {
5
+ exit;
6
+ }
7
+
8
+ class PUM_Woocommerce_Integration {
9
+
10
+ public static function init() {
11
+ add_filter( 'pum_registered_conditions', array( __CLASS__, 'register_conditions' ) );
12
+ add_filter( 'pum_condition_sort_order', array( __CLASS__, 'condition_sort_order' ) );
13
+ }
14
+
15
+ public static function is_wc_endpoint_url( $settings = array() ) {
16
+ $results = array();
17
+
18
+ foreach ( $settings['selected'] as $key ) {
19
+ $results[] = is_wc_endpoint_url( $key );
20
+ }
21
+
22
+ return in_array( true, $results );
23
+ }
24
+
25
+ public static function register_conditions( $conditions = array() ) {
26
+
27
+ // Add Additional Conditions
28
+ $conditions['is_woocommerce'] = array(
29
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
30
+ 'name' => __( 'All WooCommerce', 'popup-maker' ),
31
+ 'callback' => 'is_woocommerce',
32
+ );
33
+ $conditions['is_shop'] = array(
34
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
35
+ 'name' => __( 'Shop Page', 'popup-maker' ),
36
+ 'callback' => 'is_shop',
37
+ );
38
+ $conditions['is_cart'] = array(
39
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
40
+ 'name' => __( 'Cart Page', 'popup-maker' ),
41
+ 'callback' => 'is_cart',
42
+ );
43
+ $conditions['is_checkout'] = array(
44
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
45
+ 'name' => __( 'Checkout Page', 'popup-maker' ),
46
+ 'callback' => 'is_checkout',
47
+ );
48
+ $conditions['is_account_page'] = array(
49
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
50
+ 'name' => __( 'Account Page', 'popup-maker' ),
51
+ 'callback' => 'is_account_page',
52
+ );
53
+
54
+ $conditions['is_wc_endpoint_url'] = array(
55
+ 'group' => __( 'WooCommerce', 'woocommerce' ),
56
+ 'name' => __( 'Is Endpoint', 'popup-maker' ),
57
+ 'fields' => array(
58
+ 'selected' => array(
59
+ 'placeholder' => __( 'Selected Endpoints', 'popup-maker' ),
60
+ 'type' => 'select',
61
+ 'select2' => true,
62
+ 'multiple' => true,
63
+ 'as_array' => true,
64
+ 'options' => array(
65
+ 'order-pay' => 'order-pay',
66
+ 'order-received' => 'order-received',
67
+ // My account actions.
68
+ 'orders' => 'orders',
69
+ 'view-order' => 'view-order',
70
+ 'downloads' => 'downloads',
71
+ 'edit-account' => 'edit-account',
72
+ 'edit-address' => 'edit-address',
73
+ 'payment-methods' => 'payment-methods',
74
+ 'lost-password' => 'lost-password',
75
+ 'customer-logout' => 'customer-logout',
76
+ 'add-payment-method' => 'add-payment-method',
77
+ 'delete-payment-method' => 'delete-payment-method',
78
+ 'set-default-payment-method' => 'set-default-payment-method',
79
+ ),
80
+ ),
81
+ ),
82
+ 'callback' => array( __CLASS__, 'is_wc_endpoint_url' ),
83
+ );
84
+
85
+ return $conditions;
86
+ }
87
+
88
+ public static function condition_sort_order( $order = array() ) {
89
+ $order[ __( 'WooCommerce', 'woocommerce' ) ] = 5.256;
90
+
91
+ return $order;
92
+ }
93
+
94
+ }
95
+
includes/modules/admin-bar.php CHANGED
@@ -1,554 +1,584 @@
1
- <?php
2
- /*******************************************************************************
3
- * Copyright (c) 2018, WP Popup Maker
4
- ******************************************************************************/
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- /**
11
- * Class PUM_Modules_Admin_Bar
12
- *
13
- * This class adds admin bar menu for Popup Management.
14
- */
15
- class PUM_Modules_Admin_Bar {
16
-
17
- /**
18
- * Initializes this module.
19
- */
20
- public static function init() {
21
- add_action( 'admin_bar_menu', array( __CLASS__, 'toolbar_links' ), 999 );
22
- add_action( 'wp_footer', array( __CLASS__, 'admin_bar_styles' ), 999 );
23
- add_action( 'init', array( __CLASS__, 'show_debug_bar' ) );
24
- }
25
-
26
- /**
27
- * Renders the admin debug bar when PUM Debug is enabled.
28
- */
29
- public static function show_debug_bar() {
30
- if ( current_user_can( 'manage_options' ) && Popup_Maker::debug_mode() ) {
31
- show_admin_bar( true );
32
- }
33
- }
34
-
35
- public static function admin_bar_styles() {
36
-
37
- if ( is_admin() || ! is_admin_bar_showing() || PUM_Utils_Options::get( 'disabled_admin_bar', false ) ) {
38
- return;
39
- } ?>
40
-
41
- <style id="pum-admin-bar-styles">
42
- /* Layer admin bar over popups. */
43
- #wpadminbar {
44
- z-index: 999999999999;
45
- }
46
-
47
- #wp-admin-bar-popup-maker > .ab-item::before {
48
- background: url("<?php echo POPMAKE_URL; ?>/assets/images/admin/icon-info-21x21.png") center center no-repeat transparent !important;
49
- top: 3px;
50
- content: "";
51
- width: 20px;
52
- height: 20px;
53
- }
54
-
55
- #wp-admin-bar-popup-maker:hover > .ab-item::before {
56
- background-image: url("<?php echo POPMAKE_URL; ?>/assets/images/admin/icon-info-21x21.png") !important;
57
- }
58
- </style>
59
- <script id="pum-admin-bar-tools" type="text/javascript">
60
- /**
61
- * CssSelectorGenerator
62
- */
63
- (function () {
64
- var CssSelectorGenerator, root,
65
- indexOf = [].indexOf || function (item) {
66
- for (var i = 0, l = this.length; i < l; i++) {
67
- if (i in this && this[i] === item) return i;
68
- }
69
- return -1;
70
- };
71
-
72
- CssSelectorGenerator = (function () {
73
- CssSelectorGenerator.prototype.default_options = {
74
- selectors: ['id', 'class', 'tag', 'nthchild']
75
- };
76
-
77
- function CssSelectorGenerator(options) {
78
- if (options == null) {
79
- options = {};
80
- }
81
- this.options = {};
82
- this.setOptions(this.default_options);
83
- this.setOptions(options);
84
- }
85
-
86
- CssSelectorGenerator.prototype.setOptions = function (options) {
87
- var key, results, val;
88
- if (options == null) {
89
- options = {};
90
- }
91
- results = [];
92
- for (key in options) {
93
- val = options[key];
94
- if (this.default_options.hasOwnProperty(key)) {
95
- results.push(this.options[key] = val);
96
- } else {
97
- results.push(void 0);
98
- }
99
- }
100
- return results;
101
- };
102
-
103
- CssSelectorGenerator.prototype.isElement = function (element) {
104
- return !!((element != null ? element.nodeType : void 0) === 1);
105
- };
106
-
107
- CssSelectorGenerator.prototype.getParents = function (element) {
108
- var current_element, result;
109
- result = [];
110
- if (this.isElement(element)) {
111
- current_element = element;
112
- while (this.isElement(current_element)) {
113
- result.push(current_element);
114
- current_element = current_element.parentNode;
115
- }
116
- }
117
- return result;
118
- };
119
-
120
- CssSelectorGenerator.prototype.getTagSelector = function (element) {
121
- return this.sanitizeItem(element.tagName.toLowerCase());
122
- };
123
-
124
- CssSelectorGenerator.prototype.sanitizeItem = function (item) {
125
- var characters;
126
- characters = (item.split('')).map(function (character) {
127
- if (character === ':') {
128
- return "\\" + (':'.charCodeAt(0).toString(16).toUpperCase()) + " ";
129
- } else if (/[ !"#$%&'()*+,.\/;<=>?@\[\\\]^`{|}~]/.test(character)) {
130
- return "\\" + character;
131
- } else {
132
- return escape(character).replace(/\%/g, '\\');
133
- }
134
- });
135
- return characters.join('');
136
- };
137
-
138
- CssSelectorGenerator.prototype.getIdSelector = function (element) {
139
- var id, sanitized_id;
140
- id = element.getAttribute('id');
141
- if ((id != null) && (id !== '') && !(/\s/.exec(id)) && !(/^\d/.exec(id))) {
142
- sanitized_id = "#" + (this.sanitizeItem(id));
143
- if (element.ownerDocument.querySelectorAll(sanitized_id).length === 1) {
144
- return sanitized_id;
145
- }
146
- }
147
- return null;
148
- };
149
-
150
- CssSelectorGenerator.prototype.getClassSelectors = function (element) {
151
- var class_string, item, result;
152
- result = [];
153
- class_string = element.getAttribute('class');
154
- if (class_string != null) {
155
- class_string = class_string.replace(/\s+/g, ' ');
156
- class_string = class_string.replace(/^\s|\s$/g, '');
157
- if (class_string !== '') {
158
- result = (function () {
159
- var k, len, ref, results;
160
- ref = class_string.split(/\s+/);
161
- results = [];
162
- for (k = 0, len = ref.length; k < len; k++) {
163
- item = ref[k];
164
- results.push("." + (this.sanitizeItem(item)));
165
- }
166
- return results;
167
- }).call(this);
168
- }
169
- }
170
- return result;
171
- };
172
-
173
- CssSelectorGenerator.prototype.getAttributeSelectors = function (element) {
174
- var attribute, blacklist, k, len, ref, ref1, result;
175
- result = [];
176
- blacklist = ['id', 'class'];
177
- ref = element.attributes;
178
- for (k = 0, len = ref.length; k < len; k++) {
179
- attribute = ref[k];
180
- if (ref1 = attribute.nodeName, indexOf.call(blacklist, ref1) < 0) {
181
- result.push("[" + attribute.nodeName + "=" + attribute.nodeValue + "]");
182
- }
183
- }
184
- return result;
185
- };
186
-
187
- CssSelectorGenerator.prototype.getNthChildSelector = function (element) {
188
- var counter, k, len, parent_element, sibling, siblings;
189
- parent_element = element.parentNode;
190
- if (parent_element != null) {
191
- counter = 0;
192
- siblings = parent_element.childNodes;
193
- for (k = 0, len = siblings.length; k < len; k++) {
194
- sibling = siblings[k];
195
- if (this.isElement(sibling)) {
196
- counter++;
197
- if (sibling === element) {
198
- return ":nth-child(" + counter + ")";
199
- }
200
- }
201
- }
202
- }
203
- return null;
204
- };
205
-
206
- CssSelectorGenerator.prototype.testSelector = function (element, selector) {
207
- var is_unique, result;
208
- is_unique = false;
209
- if ((selector != null) && selector !== '') {
210
- result = element.ownerDocument.querySelectorAll(selector);
211
- if (result.length === 1 && result[0] === element) {
212
- is_unique = true;
213
- }
214
- }
215
- return is_unique;
216
- };
217
-
218
- CssSelectorGenerator.prototype.getAllSelectors = function (element) {
219
- var result;
220
- result = {
221
- t: null,
222
- i: null,
223
- c: null,
224
- a: null,
225
- n: null
226
- };
227
- if (indexOf.call(this.options.selectors, 'tag') >= 0) {
228
- result.t = this.getTagSelector(element);
229
- }
230
- if (indexOf.call(this.options.selectors, 'id') >= 0) {
231
- result.i = this.getIdSelector(element);
232
- }
233
- if (indexOf.call(this.options.selectors, 'class') >= 0) {
234
- result.c = this.getClassSelectors(element);
235
- }
236
- if (indexOf.call(this.options.selectors, 'attribute') >= 0) {
237
- result.a = this.getAttributeSelectors(element);
238
- }
239
- if (indexOf.call(this.options.selectors, 'nthchild') >= 0) {
240
- result.n = this.getNthChildSelector(element);
241
- }
242
- return result;
243
- };
244
-
245
- CssSelectorGenerator.prototype.testUniqueness = function (element, selector) {
246
- var found_elements, parent;
247
- parent = element.parentNode;
248
- found_elements = parent.querySelectorAll(selector);
249
- return found_elements.length === 1 && found_elements[0] === element;
250
- };
251
-
252
- CssSelectorGenerator.prototype.testCombinations = function (element, items, tag) {
253
- var item, k, l, len, len1, ref, ref1;
254
- ref = this.getCombinations(items);
255
- for (k = 0, len = ref.length; k < len; k++) {
256
- item = ref[k];
257
- if (this.testUniqueness(element, item)) {
258
- return item;
259
- }
260
- }
261
- if (tag != null) {
262
- ref1 = items.map(function (item) {
263
- return tag + item;
264
- });
265
- for (l = 0, len1 = ref1.length; l < len1; l++) {
266
- item = ref1[l];
267
- if (this.testUniqueness(element, item)) {
268
- return item;
269
- }
270
- }
271
- }
272
- return null;
273
- };
274
-
275
- CssSelectorGenerator.prototype.getUniqueSelector = function (element) {
276
- var found_selector, k, len, ref, selector_type, selectors;
277
- selectors = this.getAllSelectors(element);
278
- ref = this.options.selectors;
279
- for (k = 0, len = ref.length; k < len; k++) {
280
- selector_type = ref[k];
281
- switch (selector_type) {
282
- case 'id':
283
- if (selectors.i != null) {
284
- return selectors.i;
285
- }
286
- break;
287
- case 'tag':
288
- if (selectors.t != null) {
289
- if (this.testUniqueness(element, selectors.t)) {
290
- return selectors.t;
291
- }
292
- }
293
- break;
294
- case 'class':
295
- if ((selectors.c != null) && selectors.c.length !== 0) {
296
- found_selector = this.testCombinations(element, selectors.c, selectors.t);
297
- if (found_selector) {
298
- return found_selector;
299
- }
300
- }
301
- break;
302
- case 'attribute':
303
- if ((selectors.a != null) && selectors.a.length !== 0) {
304
- found_selector = this.testCombinations(element, selectors.a, selectors.t);
305
- if (found_selector) {
306
- return found_selector;
307
- }
308
- }
309
- break;
310
- case 'nthchild':
311
- if (selectors.n != null) {
312
- return selectors.n;
313
- }
314
- }
315
- }
316
- return '*';
317
- };
318
-
319
- CssSelectorGenerator.prototype.getSelector = function (element) {
320
- var all_selectors, item, k, l, len, len1, parents, result, selector, selectors;
321
- all_selectors = [];
322
- parents = this.getParents(element);
323
- for (k = 0, len = parents.length; k < len; k++) {
324
- item = parents[k];
325
- selector = this.getUniqueSelector(item);
326
- if (selector != null) {
327
- all_selectors.push(selector);
328
- }
329
- }
330
- selectors = [];
331
- for (l = 0, len1 = all_selectors.length; l < len1; l++) {
332
- item = all_selectors[l];
333
- selectors.unshift(item);
334
- result = selectors.join(' > ');
335
- if (this.testSelector(element, result)) {
336
- return result;
337
- }
338
- }
339
- return null;
340
- };
341
-
342
- CssSelectorGenerator.prototype.getCombinations = function (items) {
343
- var i, j, k, l, ref, ref1, result;
344
- if (items == null) {
345
- items = [];
346
- }
347
- result = [[]];
348
- for (i = k = 0, ref = items.length - 1; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
349
- for (j = l = 0, ref1 = result.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
350
- result.push(result[j].concat(items[i]));
351
- }
352
- }
353
- result.shift();
354
- result = result.sort(function (a, b) {
355
- return a.length - b.length;
356
- });
357
- result = result.map(function (item) {
358
- return item.join('');
359
- });
360
- return result;
361
- };
362
-
363
- return CssSelectorGenerator;
364
-
365
- })();
366
-
367
- if (typeof define !== "undefined" && define !== null ? define.amd : void 0) {
368
- define([], function () {
369
- return CssSelectorGenerator;
370
- });
371
- } else {
372
- root = typeof exports !== "undefined" && exports !== null ? exports : this;
373
- root.CssSelectorGenerator = CssSelectorGenerator;
374
- }
375
-
376
- }).call(this);
377
-
378
- (function ($) {
379
- var selector_generator = new CssSelectorGenerator;
380
-
381
- $(document).on('click', '#wp-admin-bar-pum-get-selector', function (event) {
382
-
383
- alert("<?php _e( 'After clicking ok, click the element you want a selector for.', 'popup-maker' ); ?>");
384
-
385
- event.preventDefault();
386
- event.stopPropagation();
387
-
388
- $(document).one('click', function (event) {
389
- // get reference to the element user clicked on
390
- var element = event.target,
391
- // get unique CSS selector for that element
392
- selector = selector_generator.getSelector(element);
393
-
394
- alert("<?php _ex( 'Selector', 'JS alert for CSS get selector tool', 'popup-maker' ); ?>: " + selector);
395
-
396
- event.preventDefault();
397
- event.stopPropagation();
398
- });
399
- });
400
- }(jQuery));
401
- </script><?php
402
- }
403
-
404
- /**
405
- * Add additional toolbar menu items to the front end.
406
- *
407
- * @param $wp_admin_bar
408
- */
409
- public static function toolbar_links( $wp_admin_bar ) {
410
-
411
- if ( is_admin() || ! is_admin_bar_showing() || PUM_Utils_Options::get( 'disabled_admin_bar', false ) ) {
412
- return;
413
- }
414
-
415
- $wp_admin_bar->add_node( array(
416
- 'id' => 'popup-maker',
417
- 'title' => __( 'Popup Maker', 'popup-maker' ),
418
- 'href' => '#popup-maker',
419
- 'meta' => array( 'class' => 'popup-maker-toolbar' ),
420
- 'parent' => false,
421
- ) );
422
-
423
- $popups_url = current_user_can( 'edit_posts' ) ? admin_url( 'edit.php?post_type=popup' ) : '#';
424
-
425
- $wp_admin_bar->add_node( array(
426
- 'id' => 'popups',
427
- 'title' => __( 'Popups', 'popup-maker' ),
428
- 'href' => $popups_url,
429
- 'parent' => 'popup-maker',
430
- ) );
431
-
432
- $popups = PUM_Modules_Admin_Bar::loaded_popups();
433
-
434
- if ( count( $popups ) ) {
435
-
436
- foreach ( $popups as $popup ) {
437
- /** @var WP_Post $popup */
438
-
439
- $node_id = 'popup-' . $popup->ID;
440
-
441
- $can_edit = current_user_can( 'edit_post', $popup->ID );
442
-
443
- $edit_url = $can_edit ? admin_url( 'post.php?post=' . $popup->ID . '&action=edit' ) : '#';
444
-
445
- // Single Popup Menu Node
446
- $wp_admin_bar->add_node( array(
447
- 'id' => $node_id,
448
- 'title' => $popup->post_title,
449
- 'href' => $edit_url,
450
- 'parent' => 'popups',
451
- ) );
452
-
453
- // Trigger Link
454
- $wp_admin_bar->add_node( array(
455
- 'id' => $node_id . '-open',
456
- 'title' => __( 'Open Popup', 'popup-maker' ),
457
- 'meta' => array(
458
- 'onclick' => 'PUM.open(' . $popup->ID . '); return false;',
459
- ),
460
- 'href' => '#popup-maker-open-popup-' . $popup->ID,
461
- 'parent' => $node_id,
462
- ) );
463
-
464
- $wp_admin_bar->add_node( array(
465
- 'id' => $node_id . '-close',
466
- 'title' => __( 'Close Popup', 'popup-maker' ),
467
- 'meta' => array(
468
- 'onclick' => 'PUM.close(' . $popup->ID . '); return false;',
469
- ),
470
- 'href' => '#popup-maker-close-popup-' . $popup->ID,
471
- 'parent' => $node_id,
472
- ) );
473
-
474
- if ( pum_get_popup( $popup->ID )->has_conditions( array( 'js_only' => true ) ) ) {
475
- $wp_admin_bar->add_node( array(
476
- 'id' => $node_id . '-conditions',
477
- 'title' => __( 'Check Conditions', 'popup-maker' ),
478
- 'meta' => array(
479
- 'onclick' => 'alert(PUM.checkConditions(' . $popup->ID . ') ? "Pass" : "Fail"); return false;',
480
- ),
481
- 'href' => '#popup-maker-check-conditions-popup-' . $popup->ID,
482
- 'parent' => $node_id,
483
- ) );
484
- }
485
-
486
- $wp_admin_bar->add_node( array(
487
- 'id' => $node_id . '-reset-cookies',
488
- 'title' => __( 'Reset Cookies', 'popup-maker' ),
489
- 'meta' => array(
490
- 'onclick' => 'PUM.clearCookies(' . $popup->ID . '); alert("' . __( 'Success', 'popup-maker' ) . '"); return false;',
491
- ),
492
- 'href' => '#popup-maker-reset-cookies-popup-' . $popup->ID,
493
- 'parent' => $node_id,
494
- ) );
495
-
496
- if ( $can_edit ) {
497
- // Edit Popup Link
498
- $wp_admin_bar->add_node( array(
499
- 'id' => $node_id . '-edit',
500
- 'title' => __( 'Edit Popup', 'popup-maker' ),
501
- 'href' => $edit_url,
502
- 'parent' => $node_id,
503
- ) );
504
- }
505
-
506
- }
507
- } else {
508
- $wp_admin_bar->add_node( array(
509
- 'id' => 'no-popups-loaded',
510
- 'title' => __( 'No Popups Loaded', 'popup-maker' ) . '<strong style="color:#fff; margin-left: 5px;">?</strong>',
511
- 'href' => 'https://docs.wppopupmaker.com/article/265-my-popup-wont-work-how-can-i-fix-it?utm_capmaign=Self+Help&utm_source=No+Popups&utm_medium=Admin+Bar',
512
- 'parent' => 'popups',
513
- 'meta' => array(
514
- 'target' => '_blank',
515
- ),
516
-
517
- ) );
518
- }
519
-
520
- /**
521
- * Tools
522
- */
523
- $wp_admin_bar->add_node( array(
524
- 'id' => 'pum-tools',
525
- 'title' => __( 'Tools', 'popup-maker' ),
526
- 'href' => '#popup-maker-tools',
527
- 'parent' => 'popup-maker',
528
- ) );
529
-
530
- /**
531
- * Get Selector
532
- */
533
- $wp_admin_bar->add_node( array(
534
- 'id' => 'pum-get-selector',
535
- 'title' => __( 'Get Selector', 'popup-maker' ),
536
- 'href' => '#popup-maker-get-selector-tool',
537
- 'parent' => 'pum-tools',
538
- ) );
539
-
540
- }
541
-
542
- public static function loaded_popups() {
543
- static $popups;
544
-
545
- if ( ! isset( $popups ) ) {
546
- $loaded = PUM_Site_Popups::get_loaded_popups();
547
- $popups = $loaded->posts;
548
- }
549
-
550
- return $popups;
551
- }
552
- }
553
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  PUM_Modules_Admin_Bar::init();
1
+ <?php
2
+ /*******************************************************************************
3
+ * Copyright (c) 2018, WP Popup Maker
4
+ ******************************************************************************/
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ /**
11
+ * Class PUM_Modules_Admin_Bar
12
+ *
13
+ * This class adds admin bar menu for Popup Management.
14
+ */
15
+ class PUM_Modules_Admin_Bar {
16
+
17
+ /**
18
+ * Initializes this module.
19
+ */
20
+ public static function init() {
21
+ add_action( 'admin_bar_menu', array( __CLASS__, 'toolbar_links' ), 999 );
22
+ add_action( 'wp_footer', array( __CLASS__, 'admin_bar_styles' ), 999 );
23
+ add_action( 'init', array( __CLASS__, 'show_debug_bar' ) );
24
+ }
25
+
26
+ /**
27
+ * Renders the admin debug bar when PUM Debug is enabled.
28
+ */
29
+ public static function show_debug_bar() {
30
+ if ( self::should_render() && Popup_Maker::debug_mode() ) {
31
+ show_admin_bar( true );
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Returns true only if all of the following are true:
37
+ * - User is logged in.
38
+ * - Not in WP Admin.
39
+ * - The admin bar is showing.
40
+ * - PUM Admin bar is not disabled.
41
+ * - Current user can edit others posts or manage options.
42
+ *
43
+ * @return bool
44
+ */
45
+ public static function should_render() {
46
+ $tests = [
47
+ is_user_logged_in(),
48
+ ! is_admin(),
49
+ is_admin_bar_showing(),
50
+ ! pum_get_option( 'disabled_admin_bar' ),
51
+ ( current_user_can( 'edit_others_posts' ) || current_user_can( 'manage_options' ) ),
52
+ ];
53
+
54
+ return ! in_array( false, $tests );
55
+ }
56
+
57
+ /**
58
+ * Render admin bar scripts & styles if the toolbar button should show.
59
+ *
60
+ * TODO move this to external assets & use wp_enqueue_*
61
+ */
62
+ public static function admin_bar_styles() {
63
+
64
+ if ( ! self::should_render() ) {
65
+ return;
66
+ } ?>
67
+
68
+ <style id="pum-admin-bar-styles">
69
+ /* Layer admin bar over popups. */
70
+ #wpadminbar {
71
+ z-index: 999999999999;
72
+ }
73
+
74
+ #wp-admin-bar-popup-maker > .ab-item::before {
75
+ background: url("<?php echo POPMAKE_URL; ?>/assets/images/admin/icon-info-21x21.png") center center no-repeat transparent !important;
76
+ top: 3px;
77
+ content: "";
78
+ width: 20px;
79
+ height: 20px;
80
+ }
81
+
82
+ #wp-admin-bar-popup-maker:hover > .ab-item::before {
83
+ background-image: url("<?php echo POPMAKE_URL; ?>/assets/images/admin/icon-info-21x21.png") !important;
84
+ }
85
+ </style>
86
+ <script id="pum-admin-bar-tools" type="text/javascript">
87
+ /**
88
+ * CssSelectorGenerator
89
+ */
90
+ (function () {
91
+ var CssSelectorGenerator, root,
92
+ indexOf = [].indexOf || function (item) {
93
+ for (var i = 0, l = this.length; i < l; i++) {
94
+ if (i in this && this[i] === item) return i;
95
+ }
96
+ return -1;
97
+ };
98
+
99
+ CssSelectorGenerator = (function () {
100
+ CssSelectorGenerator.prototype.default_options = {
101
+ selectors: ['id', 'class', 'tag', 'nthchild']
102
+ };
103
+
104
+ function CssSelectorGenerator(options) {
105
+ if (options == null) {
106
+ options = {};
107
+ }
108
+ this.options = {};
109
+ this.setOptions(this.default_options);
110
+ this.setOptions(options);
111
+ }
112
+
113
+ CssSelectorGenerator.prototype.setOptions = function (options) {
114
+ var key, results, val;
115
+ if (options == null) {
116
+ options = {};
117
+ }
118
+ results = [];
119
+ for (key in options) {
120
+ val = options[key];
121
+ if (this.default_options.hasOwnProperty(key)) {
122
+ results.push(this.options[key] = val);
123
+ } else {
124
+ results.push(void 0);
125
+ }
126
+ }
127
+ return results;
128
+ };
129
+
130
+ CssSelectorGenerator.prototype.isElement = function (element) {
131
+ return !!((element != null ? element.nodeType : void 0) === 1);
132
+ };
133
+
134
+ CssSelectorGenerator.prototype.getParents = function (element) {
135
+ var current_element, result;
136
+ result = [];
137
+ if (this.isElement(element)) {
138
+ current_element = element;
139
+ while (this.isElement(current_element)) {
140
+ result.push(current_element);
141
+ current_element = current_element.parentNode;
142
+ }
143
+ }
144
+ return result;
145
+ };
146
+
147
+ CssSelectorGenerator.prototype.getTagSelector = function (element) {
148
+ return this.sanitizeItem(element.tagName.toLowerCase());
149
+ };
150
+
151
+ CssSelectorGenerator.prototype.sanitizeItem = function (item) {
152
+ var characters;
153
+ characters = (item.split('')).map(function (character) {
154
+ if (character === ':') {
155
+ return "\\" + (':'.charCodeAt(0).toString(16).toUpperCase()) + " ";
156
+ } else if (/[ !"#$%&'()*+,.\/;<=>?@\[\\\]^`{|}~]/.test(character)) {
157
+ return "\\" + character;
158
+ } else {
159
+ return escape(character).replace(/\%/g, '\\');
160
+ }
161
+ });
162
+ return characters.join('');
163
+ };
164
+
165
+ CssSelectorGenerator.prototype.getIdSelector = function (element) {
166
+ var id, sanitized_id;
167
+ id = element.getAttribute('id');
168
+ if ((id != null) && (id !== '') && !(/\s/.exec(id)) && !(/^\d/.exec(id))) {
169
+ sanitized_id = "#" + (this.sanitizeItem(id));
170
+ if (element.ownerDocument.querySelectorAll(sanitized_id).length === 1) {
171
+ return sanitized_id;
172
+ }
173
+ }
174
+ return null;
175
+ };
176
+
177
+ CssSelectorGenerator.prototype.getClassSelectors = function (element) {
178
+ var class_string, item, result;
179
+ result = [];
180
+ class_string = element.getAttribute('class');
181
+ if (class_string != null) {
182
+ class_string = class_string.replace(/\s+/g, ' ');
183
+ class_string = class_string.replace(/^\s|\s$/g, '');
184
+ if (class_string !== '') {
185
+ result = (function () {
186
+ var k, len, ref, results;
187
+ ref = class_string.split(/\s+/);
188
+ results = [];
189
+ for (k = 0, len = ref.length; k < len; k++) {
190
+ item = ref[k];
191
+ results.push("." + (this.sanitizeItem(item)));
192
+ }
193
+ return results;
194
+ }).call(this);
195
+ }
196
+ }
197
+ return result;
198
+ };
199
+
200
+ CssSelectorGenerator.prototype.getAttributeSelectors = function (element) {
201
+ var attribute, blacklist, k, len, ref, ref1, result;
202
+ result = [];
203
+ blacklist = ['id', 'class'];
204
+ ref = element.attributes;
205
+ for (k = 0, len = ref.length; k < len; k++) {
206
+ attribute = ref[k];
207
+ if (ref1 = attribute.nodeName, indexOf.call(blacklist, ref1) < 0) {
208
+ result.push("[" + attribute.nodeName + "=" + attribute.nodeValue + "]");
209
+ }
210
+ }
211
+ return result;
212
+ };
213
+
214
+ CssSelectorGenerator.prototype.getNthChildSelector = function (element) {
215
+ var counter, k, len, parent_element, sibling, siblings;
216
+ parent_element = element.parentNode;
217
+ if (parent_element != null) {
218
+ counter = 0;
219
+ siblings = parent_element.childNodes;
220
+ for (k = 0, len = siblings.length; k < len; k++) {
221
+ sibling = siblings[k];
222
+ if (this.isElement(sibling)) {
223
+ counter++;
224
+ if (sibling === element) {
225
+ return ":nth-child(" + counter + ")";
226
+ }
227
+ }
228
+ }
229
+ }
230
+ return null;
231
+ };
232
+
233
+ CssSelectorGenerator.prototype.testSelector = function (element, selector) {
234
+ var is_unique, result;
235
+ is_unique = false;
236
+ if ((selector != null) && selector !== '') {
237
+ result = element.ownerDocument.querySelectorAll(selector);
238
+ if (result.length === 1 && result[0] === element) {
239
+ is_unique = true;
240
+ }
241
+ }
242
+ return is_unique;
243
+ };
244
+
245
+ CssSelectorGenerator.prototype.getAllSelectors = function (element) {
246
+ var result;
247
+ result = {
248
+ t: null,
249
+ i: null,
250
+ c: null,
251
+ a: null,
252
+ n: null
253
+ };
254
+ if (indexOf.call(this.options.selectors, 'tag') >= 0) {
255
+ result.t = this.getTagSelector(element);
256
+ }
257
+ if (indexOf.call(this.options.selectors, 'id') >= 0) {
258
+ result.i = this.getIdSelector(element);
259
+ }
260
+ if (indexOf.call(this.options.selectors, 'class') >= 0) {
261
+ result.c = this.getClassSelectors(element);
262
+ }
263
+ if (indexOf.call(this.options.selectors, 'attribute') >= 0) {
264
+ result.a = this.getAttributeSelectors(element);
265
+ }
266
+ if (indexOf.call(this.options.selectors, 'nthchild') >= 0) {
267
+ result.n = this.getNthChildSelector(element);
268
+ }
269
+ return result;
270
+ };
271
+
272
+ CssSelectorGenerator.prototype.testUniqueness = function (element, selector) {
273
+ var found_elements, parent;
274
+ parent = element.parentNode;
275
+ found_elements = parent.querySelectorAll(selector);
276
+ return found_elements.length === 1 && found_elements[0] === element;
277
+ };
278
+
279
+ CssSelectorGenerator.prototype.testCombinations = function (element, items, tag) {
280
+ var item, k, l, len, len1, ref, ref1;
281
+ ref = this.getCombinations(items);
282
+ for (k = 0, len = ref.length; k < len; k++) {
283
+ item = ref[k];
284
+ if (this.testUniqueness(element, item)) {
285
+ return item;
286
+ }
287
+ }
288
+ if (tag != null) {
289
+ ref1 = items.map(function (item) {
290
+ return tag + item;
291
+ });
292
+ for (l = 0, len1 = ref1.length; l < len1; l++) {
293
+ item = ref1[l];
294
+ if (this.testUniqueness(element, item)) {
295
+ return item;
296
+ }
297
+ }
298
+ }
299
+ return null;
300
+ };
301
+
302
+ CssSelectorGenerator.prototype.getUniqueSelector = function (element) {
303
+ var found_selector, k, len, ref, selector_type, selectors;
304
+ selectors = this.getAllSelectors(element);
305
+ ref = this.options.selectors;
306
+ for (k = 0, len = ref.length; k < len; k++) {
307
+ selector_type = ref[k];
308
+ switch (selector_type) {
309
+ case 'id':
310
+ if (selectors.i != null) {
311
+ return selectors.i;
312
+ }
313
+ break;
314
+ case 'tag':
315
+ if (selectors.t != null) {
316
+ if (this.testUniqueness(element, selectors.t)) {
317
+ return selectors.t;
318
+ }
319
+ }
320
+ break;
321
+ case 'class':
322
+ if ((selectors.c != null) && selectors.c.length !== 0) {
323
+ found_selector = this.testCombinations(element, selectors.c, selectors.t);
324
+ if (found_selector) {
325
+ return found_selector;
326
+ }
327
+ }
328
+ break;
329
+ case 'attribute':
330
+ if ((selectors.a != null) && selectors.a.length !== 0) {
331
+ found_selector = this.testCombinations(element, selectors.a, selectors.t);
332
+ if (found_selector) {
333
+ return found_selector;
334
+ }
335
+ }
336
+ break;
337
+ case 'nthchild':
338
+ if (selectors.n != null) {
339
+ return selectors.n;
340
+ }
341
+ }
342
+ }
343
+ return '*';
344
+ };
345
+
346
+ CssSelectorGenerator.prototype.getSelector = function (element) {
347
+ var all_selectors, item, k, l, len, len1, parents, result, selector, selectors;
348
+ all_selectors = [];
349
+ parents = this.getParents(element);
350
+ for (k = 0, len = parents.length; k < len; k++) {
351
+ item = parents[k];
352
+ selector = this.getUniqueSelector(item);
353
+ if (selector != null) {
354
+ all_selectors.push(selector);
355
+ }
356
+ }
357
+ selectors = [];
358
+ for (l = 0, len1 = all_selectors.length; l < len1; l++) {
359
+ item = all_selectors[l];
360
+ selectors.unshift(item);
361
+ result = selectors.join(' > ');
362
+ if (this.testSelector(element, result)) {
363
+ return result;
364
+ }
365
+ }
366
+ return null;
367
+ };
368
+
369
+ CssSelectorGenerator.prototype.getCombinations = function (items) {
370
+ var i, j, k, l, ref, ref1, result;
371
+ if (items == null) {
372
+ items = [];
373
+ }
374
+ result = [[]];
375
+ for (i = k = 0, ref = items.length - 1; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
376
+ for (j = l = 0, ref1 = result.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; j = 0 <= ref1 ? ++l : --l) {
377
+ result.push(result[j].concat(items[i]));
378
+ }
379
+ }
380
+ result.shift();
381
+ result = result.sort(function (a, b) {
382
+ return a.length - b.length;
383
+ });
384
+ result = result.map(function (item) {
385
+ return item.join('');
386
+ });
387
+ return result;
388
+ };
389
+
390
+ return CssSelectorGenerator;
391
+
392
+ })();
393
+
394
+ if (typeof define !== "undefined" && define !== null ? define.amd : void 0) {
395
+ define([], function () {
396
+ return CssSelectorGenerator;
397
+ });
398
+ } else {
399
+ root = typeof exports !== "undefined" && exports !== null ? exports : this;
400
+ root.CssSelectorGenerator = CssSelectorGenerator;
401
+ }
402
+
403
+ }).call(this);
404
+
405
+ (function ($) {
406
+ var selector_generator = new CssSelectorGenerator;
407
+
408
+ $(document).on('click', '#wp-admin-bar-pum-get-selector', function (event) {
409
+
410
+ alert("<?php _e( 'After clicking ok, click the element you want a selector for.', 'popup-maker' ); ?>");
411
+
412
+ event.preventDefault();
413
+ event.stopPropagation();
414
+
415
+ $(document).one('click', function (event) {
416
+ // get reference to the element user clicked on
417
+ var element = event.target,
418
+ // get unique CSS selector for that element
419
+ selector = selector_generator.getSelector(element);
420
+
421
+ alert("<?php _ex( 'Selector', 'JS alert for CSS get selector tool', 'popup-maker' ); ?>: " + selector);
422
+
423
+ event.preventDefault();
424
+ event.stopPropagation();
425
+ });
426
+ });
427
+ }(jQuery));
428
+ </script><?php
429
+ }
430
+
431
+ /**
432
+ * Add additional toolbar menu items to the front end.
433
+ *
434
+ * @param WP_Admin_Bar $wp_admin_bar
435
+ */
436
+ public static function toolbar_links( $wp_admin_bar ) {
437
+
438
+ if ( ! self::should_render() ) {
439
+ return;
440
+ }
441
+
442
+ $wp_admin_bar->add_node( array(
443
+ 'id' => 'popup-maker',
444
+ 'title' => __( 'Popup Maker', 'popup-maker' ),
445
+ 'href' => '#popup-maker',
446
+ 'meta' => array( 'class' => 'popup-maker-toolbar' ),
447
+ 'parent' => false,
448
+ ) );
449
+
450
+ $popups_url = current_user_can( 'edit_posts' ) ? admin_url( 'edit.php?post_type=popup' ) : '#';
451
+
452
+ $wp_admin_bar->add_node( array(
453
+ 'id' => 'popups',
454
+ 'title' => __( 'Popups', 'popup-maker' ),
455
+ 'href' => $popups_url,
456
+ 'parent' => 'popup-maker',
457
+ ) );
458
+
459
+ $popups = PUM_Modules_Admin_Bar::loaded_popups();
460
+
461
+ if ( count( $popups ) ) {
462
+
463
+ foreach ( $popups as $popup ) {
464
+ /** @var WP_Post $popup */
465
+
466
+ $node_id = 'popup-' . $popup->ID;
467
+
468
+ $can_edit = current_user_can( 'edit_post', $popup->ID );
469
+
470
+ $edit_url = $can_edit ? admin_url( 'post.php?post=' . $popup->ID . '&action=edit' ) : '#';
471
+
472
+ // Single Popup Menu Node
473
+ $wp_admin_bar->add_node( array(
474
+ 'id' => $node_id,
475
+ 'title' => $popup->post_title,
476
+ 'href' => $edit_url,
477
+ 'parent' => 'popups',
478
+ ) );
479
+
480
+ // Trigger Link
481
+ $wp_admin_bar->add_node( array(
482
+ 'id' => $node_id . '-open',
483
+ 'title' => __( 'Open Popup', 'popup-maker' ),
484
+ 'meta' => array(
485
+ 'onclick' => 'PUM.open(' . $popup->ID . '); return false;',
486
+ ),
487
+ 'href' => '#popup-maker-open-popup-' . $popup->ID,
488
+ 'parent' => $node_id,
489
+ ) );
490
+
491
+ $wp_admin_bar->add_node( array(
492
+ 'id' => $node_id . '-close',
493
+ 'title' => __( 'Close Popup', 'popup-maker' ),
494
+ 'meta' => array(
495
+ 'onclick' => 'PUM.close(' . $popup->ID . '); return false;',
496
+ ),
497
+ 'href' => '#popup-maker-close-popup-' . $popup->ID,
498
+ 'parent' => $node_id,
499
+ ) );
500
+
501
+ if ( pum_get_popup( $popup->ID )->has_conditions( array( 'js_only' => true ) ) ) {
502
+ $wp_admin_bar->add_node( array(
503
+ 'id' => $node_id . '-conditions',
504
+ 'title' => __( 'Check Conditions', 'popup-maker' ),
505
+ 'meta' => array(
506
+ 'onclick' => 'alert(PUM.checkConditions(' . $popup->ID . ') ? "Pass" : "Fail"); return false;',
507
+ ),
508
+ 'href' => '#popup-maker-check-conditions-popup-' . $popup->ID,
509
+ 'parent' => $node_id,
510
+ ) );
511
+ }
512
+
513
+ $wp_admin_bar->add_node( array(
514
+ 'id' => $node_id . '-reset-cookies',
515
+ 'title' => __( 'Reset Cookies', 'popup-maker' ),
516
+ 'meta' => array(
517
+ 'onclick' => 'PUM.clearCookies(' . $popup->ID . '); alert("' . __( 'Success', 'popup-maker' ) . '"); return false;',
518
+ ),
519
+ 'href' => '#popup-maker-reset-cookies-popup-' . $popup->ID,
520
+ 'parent' => $node_id,
521
+ ) );
522
+
523
+ if ( $can_edit ) {
524
+ // Edit Popup Link
525
+ $wp_admin_bar->add_node( array(
526
+ 'id' => $node_id . '-edit',
527
+ 'title' => __( 'Edit Popup', 'popup-maker' ),
528
+ 'href' => $edit_url,
529
+ 'parent' => $node_id,
530
+ ) );
531
+ }
532
+
533
+ }
534
+ } else {
535
+ $wp_admin_bar->add_node( array(
536
+ 'id' => 'no-popups-loaded',
537
+ 'title' => __( 'No Popups Loaded', 'popup-maker' ) . '<strong style="color:#fff; margin-left: 5px;">?</strong>',
538
+ 'href' => 'https://docs.wppopupmaker.com/article/265-my-popup-wont-work-how-can-i-fix-it?utm_capmaign=Self+Help&utm_source=No+Popups&utm_medium=Admin+Bar',
539
+ 'parent' => 'popups',
540
+ 'meta' => array(
541
+ 'target' => '_blank',
542
+ ),
543
+
544
+ ) );
545
+ }
546
+
547
+ /**
548
+ * Tools
549
+ */
550
+ $wp_admin_bar->add_node( array(
551
+ 'id' => 'pum-tools',
552
+ 'title' => __( 'Tools', 'popup-maker' ),
553
+ 'href' => '#popup-maker-tools',
554
+ 'parent' => 'popup-maker',
555
+ ) );
556
+
557
+ /**
558
+ * Get Selector
559
+ */
560
+ $wp_admin_bar->add_node( array(
561
+ 'id' => 'pum-get-selector',
562
+ 'title' => __( 'Get Selector', 'popup-maker' ),
563
+ 'href' => '#popup-maker-get-selector-tool',
564
+ 'parent' => 'pum-tools',
565
+ ) );
566
+
567
+ }
568
+
569
+ /**
570
+ * @return array
571
+ */
572
+ public static function loaded_popups() {
573
+ static $popups;
574
+
575
+ if ( ! isset( $popups ) ) {
576
+ $loaded = PUM_Site_Popups::get_loaded_popups();
577
+ $popups = $loaded->posts;
578
+ }
579
+
580
+ return $popups;
581
+ }
582
+ }
583
+
584
  PUM_Modules_Admin_Bar::init();
languages/popup-maker.pot CHANGED
@@ -295,7 +295,7 @@ msgstr ""
295
  msgid "To receive updates, please enter your valid %s license key."
296
  msgstr ""
297
 
298
- #: classes/Privacy.php:33, classes/Types.php:23, classes/Site/Assets.php:250, classes/Utils/Alerts.php:329, includes/admin/class-pum-admin-upgrades.php:250, includes/integrations/class-pum-gravity-forms.php:51, includes/modules/admin-bar.php:417
299
  msgid "Popup Maker"
300
  msgstr ""
301
 
@@ -547,7 +547,7 @@ msgstr ""
547
  msgid "Popup"
548
  msgstr ""
549
 
550
- #: classes/Types.php:21, classes/Upsell.php:92, includes/modules/admin-bar.php:427
551
  msgid "Popups"
552
  msgstr ""
553
 
@@ -995,7 +995,7 @@ msgstr ""
995
  msgid "Help & Support"
996
  msgstr ""
997
 
998
- #: classes/Admin/Pages.php:72, classes/Admin/Pages.php:151, includes/modules/admin-bar.php:525
999
  msgid "Tools"
1000
  msgstr ""
1001
 
@@ -2394,11 +2394,11 @@ msgstr ""
2394
  msgid "Radio forces the user to make a choice, often resulting in more optins."
2395
  msgstr ""
2396
 
2397
- #: classes/Shortcode/Subscribe.php:390, includes/integrations/class-pum-cf7.php:135, includes/integrations/class-pum-gravity-forms.php:130, includes/modules/admin-bar.php:466, includes/integrations/ninja-forms/Actions/ClosePopup.php:36
2398
  msgid "Close Popup"
2399
  msgstr ""
2400
 
2401
- #: classes/Shortcode/Subscribe.php:406, includes/integrations/class-pum-cf7.php:155, includes/integrations/class-pum-gravity-forms.php:150, includes/modules/admin-bar.php:456, includes/integrations/ninja-forms/Actions/OpenPopup.php:35
2402
  msgid "Open Popup"
2403
  msgstr ""
2404
 
@@ -2739,36 +2739,36 @@ msgstr ""
2739
  msgid "Selected Endpoints"
2740
  msgstr ""
2741
 
2742
- #: includes/modules/admin-bar.php:383
2743
  msgid "After clicking ok, click the element you want a selector for."
2744
  msgstr ""
2745
 
2746
- #: includes/modules/admin-bar.php:394
2747
  msgctxt "JS alert for CSS get selector tool"
2748
  msgid "Selector"
2749
  msgstr ""
2750
 
2751
- #: includes/modules/admin-bar.php:477
2752
  msgid "Check Conditions"
2753
  msgstr ""
2754
 
2755
- #: includes/modules/admin-bar.php:488
2756
  msgid "Reset Cookies"
2757
  msgstr ""
2758
 
2759
- #: includes/modules/admin-bar.php:490, classes/Admin/Subscribers/Table.php:340
2760
  msgid "Success"
2761
  msgstr ""
2762
 
2763
- #: includes/modules/admin-bar.php:500
2764
  msgid "Edit Popup"
2765
  msgstr ""
2766
 
2767
- #: includes/modules/admin-bar.php:510
2768
  msgid "No Popups Loaded"
2769
  msgstr ""
2770
 
2771
- #: includes/modules/admin-bar.php:535
2772
  msgid "Get Selector"
2773
  msgstr ""
2774
 
295
  msgid "To receive updates, please enter your valid %s license key."
296
  msgstr ""
297
 
298
+ #: classes/Privacy.php:33, classes/Types.php:23, classes/Site/Assets.php:250, classes/Utils/Alerts.php:329, includes/admin/class-pum-admin-upgrades.php:250, includes/integrations/class-pum-gravity-forms.php:51, includes/modules/admin-bar.php:444
299
  msgid "Popup Maker"
300
  msgstr ""
301
 
547
  msgid "Popup"
548
  msgstr ""
549
 
550
+ #: classes/Types.php:21, classes/Upsell.php:92, includes/modules/admin-bar.php:454
551
  msgid "Popups"
552
  msgstr ""
553
 
995
  msgid "Help & Support"
996
  msgstr ""
997
 
998
+ #: classes/Admin/Pages.php:72, classes/Admin/Pages.php:151, includes/modules/admin-bar.php:552
999
  msgid "Tools"
1000
  msgstr ""
1001
 
2394
  msgid "Radio forces the user to make a choice, often resulting in more optins."
2395
  msgstr ""
2396
 
2397
+ #: classes/Shortcode/Subscribe.php:390, includes/integrations/class-pum-cf7.php:135, includes/integrations/class-pum-gravity-forms.php:130, includes/modules/admin-bar.php:493, includes/integrations/ninja-forms/Actions/ClosePopup.php:36
2398
  msgid "Close Popup"
2399
  msgstr ""
2400
 
2401
+ #: classes/Shortcode/Subscribe.php:406, includes/integrations/class-pum-cf7.php:155, includes/integrations/class-pum-gravity-forms.php:150, includes/modules/admin-bar.php:483, includes/integrations/ninja-forms/Actions/OpenPopup.php:35
2402
  msgid "Open Popup"
2403
  msgstr ""
2404
 
2739
  msgid "Selected Endpoints"
2740
  msgstr ""
2741
 
2742
+ #: includes/modules/admin-bar.php:410
2743
  msgid "After clicking ok, click the element you want a selector for."
2744
  msgstr ""
2745
 
2746
+ #: includes/modules/admin-bar.php:421
2747
  msgctxt "JS alert for CSS get selector tool"
2748
  msgid "Selector"
2749
  msgstr ""
2750
 
2751
+ #: includes/modules/admin-bar.php:504
2752
  msgid "Check Conditions"
2753
  msgstr ""
2754
 
2755
+ #: includes/modules/admin-bar.php:515
2756
  msgid "Reset Cookies"
2757
  msgstr ""
2758
 
2759
+ #: includes/modules/admin-bar.php:517, classes/Admin/Subscribers/Table.php:340
2760
  msgid "Success"
2761
  msgstr ""
2762
 
2763
+ #: includes/modules/admin-bar.php:527
2764
  msgid "Edit Popup"
2765
  msgstr ""
2766
 
2767
+ #: includes/modules/admin-bar.php:537
2768
  msgid "No Popups Loaded"
2769
  msgstr ""
2770
 
2771
+ #: includes/modules/admin-bar.php:562
2772
  msgid "Get Selector"
2773
  msgstr ""
2774
 
package.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "popup-maker",
3
+ "version": "1.8.7",
4
+ "description": "WordPress Popup Plugin",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/PopupMaker/Popup-Maker.git"
11
+ },
12
+ "author": "WP Popup Maker",
13
+ "license": "GPL-3.0",
14
+ "bugs": {
15
+ "url": "https://github.com/PopupMaker/Popup-Maker/issues"
16
+ },
17
+ "homepage": "https://github.com/PopupMaker/Popup-Maker#readme",
18
+ "dependencies": {},
19
+ "devDependencies": {
20
+ "gulp": "^4.0.0",
21
+ "gulp-autoprefixer": "^6.0.0",
22
+ "gulp-clean": "^0.4.0",
23
+ "gulp-clean-css": "^3.10.0",
24
+ "gulp-combine-mq": "^0.4.0",
25
+ "gulp-concat": "^2.6.0",
26
+ "gulp-csso": "^3.0.1",
27
+ "gulp-filter": "^5.1.0",
28
+ "gulp-git": "^2.0.0",
29
+ "gulp-ignore": "^2.0.1",
30
+ "gulp-jshint": "^2.0.0",
31
+ "gulp-livereload": "^4.0.0",
32
+ "gulp-load-plugins": "^1.6.0",
33
+ "gulp-notify": "^3.2.0",
34
+ "gulp-order": "^1.2.0",
35
+ "gulp-plumber": "^1.1.0",
36
+ "gulp-rename": "^1.2.2",
37
+ "gulp-sane-watch": "^2.0.6",
38
+ "gulp-sass": "^4.0.2",
39
+ "gulp-sass-lint": "^1.4.0",
40
+ "gulp-scss-lint": "^0.7.1",
41
+ "gulp-sort": "^2.0.0",
42
+ "gulp-sourcemaps": "^2.6.4",
43
+ "gulp-uglify": "^3.0.1",
44
+ "gulp-watch": "^5.0.1",
45
+ "gulp-wp-pot": "^2.3.2",
46
+ "gulp-zip": "^4.2.0",
47
+ "jshint": "^2.9.1",
48
+ "merge-stream": "^1.0.1",
49
+ "notify-send": "^0.1.2",
50
+ "run-sequence": "^2.2.1"
51
+ }
52
+ }
popup-maker.php CHANGED
@@ -3,7 +3,7 @@
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.6
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
@@ -95,7 +95,7 @@ class Popup_Maker {
95
  /**
96
  * @var string Plugin Version
97
  */
98
- public static $VER = '1.8.6';
99
 
100
  /**
101
  * @var int DB Version
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
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
95
  /**
96
  * @var string Plugin Version
97
  */
98
+ public static $VER = '1.8.7';
99
 
100
  /**
101
  * @var int DB Version
readme.txt CHANGED
@@ -5,9 +5,9 @@ Plugin URI: https://wppopupmaker.com/?utm_capmaign=Readme&utm_source=readme-head
5
  Donate link:
6
  Tags: marketing, popup, popups, optin, advertising, conversion, responsive popups, promotion, popover, pop-up, pop over, lightbox, conversion, modal
7
  Requires at least: 4.1
8
- Tested up to: 5.2
9
  Requires PHP: 5.2.17
10
- Stable tag: 1.8.6
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
@@ -98,6 +98,7 @@ There are several common causes for this, check [this guide for help](https://do
98
 
99
  View our [complete changelog](https://github.com/PopupMaker/Popup-Maker/blob/master/CHANGELOG.md) for up-to-date information on what has been going on with the development of Popup Maker.
100
 
101
- = v1.8.6 - 05/05/2019 =
102
- * Fix: Typo in GDPR eraser that could sometimes result in errors when processing GDPR requests
103
- * Fix: Added function exists check to prevent errors on WP 4.1
 
5
  Donate link:
6
  Tags: marketing, popup, popups, optin, advertising, conversion, responsive popups, promotion, popover, pop-up, pop over, lightbox, conversion, modal
7
  Requires at least: 4.1
8
+ Tested up to: 5.3
9
  Requires PHP: 5.2.17
10
+ Stable tag: 1.8.7
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
98
 
99
  View our [complete changelog](https://github.com/PopupMaker/Popup-Maker/blob/master/CHANGELOG.md) for up-to-date information on what has been going on with the development of Popup Maker.
100
 
101
+ = v1.8.7 - 06/29/2019 =
102
+ * Tweak: Restricted the admin toolbar to only show under strict circumstances.
103
+ * Tweak: Updated available WooCommerce endpoints in our targeting conditions
104
+ * Fix: Issue with instance based shortcodes when asset caching was enabled but running on every request.