| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Exit Popup |
| 4 |
Plugin URI: https://www.brontobytes.com/ |
| 5 |
Description: Exit Popup enables you to display a jQuery modal before a visitor leaves your website. |
| 6 |
Author: Brontobytes |
| 7 |
Author URI: https://www.brontobytes.com/ |
| 8 |
Version: 3.5 |
| 9 |
License: GPLv2 |
| 10 |
Text Domain: exit-popup |
| 11 |
Domain Path: /languages |
| 12 |
*/ |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) |
| 15 |
exit; |
| 16 |
|
| 17 |
function exit_popup_menu() { |
| 18 |
add_options_page(__('Exit Popup Settings', 'exit-popup'), __('Exit Popup', 'exit-popup'), 'administrator', 'exit-popup-settings', 'exit_popup_settings_page'); |
| 19 |
} |
| 20 |
add_action('admin_menu', 'exit_popup_menu'); |
| 21 |
|
| 22 |
|
| 23 |
function my_admin_enqueue($hook_suffix) { |
| 24 |
if($hook_suffix == 'settings_page_exit-popup-settings') { |
| 25 |
wp_register_style( 'select2css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css', false, '1.0', 'all' ); |
| 26 |
wp_register_script( 'select2', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js', array( 'jquery' ), '1.0', true ); |
| 27 |
wp_enqueue_style( 'select2css' ); |
| 28 |
wp_enqueue_script( 'select2' ); |
| 29 |
|
| 30 |
wp_enqueue_style( 'wp-color-picker' ); |
| 31 |
|
| 32 |
} |
| 33 |
} |
| 34 |
add_action('admin_enqueue_scripts', 'my_admin_enqueue'); |
| 35 |
|
| 36 |
|
| 37 |
add_filter( 'plugin_action_links', 'exis_popup_settings_plugin_link', 10, 2 ); |
| 38 |
|
| 39 |
function exis_popup_settings_plugin_link( $links, $file ) |
| 40 |
{ |
| 41 |
if ( $file == plugin_basename(dirname(__FILE__) . '/exit-popup.php') ) |
| 42 |
{ |
| 43 |
/* |
| 44 |
* Insert the link at the beginning |
| 45 |
*/ |
| 46 |
// $in = '<a href="options-general.php?page=cookie-bar-settings">' . __('Settings','mtt') . '</a>'; |
| 47 |
// array_unshift($links, $in); |
| 48 |
|
| 49 |
/* |
| 50 |
* Insert at the end |
| 51 |
*/ |
| 52 |
$links[] = '<a href="options-general.php?page=exit-popup-settings">'.__('Settings','mtt').'</a>'; |
| 53 |
} |
| 54 |
return $links; |
| 55 |
} |
| 56 |
|
| 57 |
function exit_popup_get_dimension( $option_name, $default = '' ) { |
| 58 |
$value = trim( (string) get_option( $option_name, $default ) ); |
| 59 |
|
| 60 |
if ( '' === $value ) { |
| 61 |
return $default; |
| 62 |
} |
| 63 |
|
| 64 |
if ( preg_match( '/^\d+(\.\d+)?(px|%)?$/', $value ) !== 1 ) { |
| 65 |
return $default; |
| 66 |
} |
| 67 |
|
| 68 |
if ( preg_match( '/(px|%)$/', $value ) !== 1 ) { |
| 69 |
$value .= 'px'; |
| 70 |
} |
| 71 |
|
| 72 |
return $value; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
function exit_popup_settings_page() { ?> |
| 77 |
<style type="text/css" > |
| 78 |
|
| 79 |
|
| 80 |
.wrap.exit_popup { |
| 81 |
max-width: 960px; |
| 82 |
padding: 26px 30px 30px; |
| 83 |
background: #fff; |
| 84 |
border-radius: 12px; |
| 85 |
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04); |
| 86 |
} |
| 87 |
|
| 88 |
.postbox .inside h2, .wrap [class$="icon32"] + h2, .wrap h1, .wrap > h2:first-child { |
| 89 |
padding: 0px; |
| 90 |
} |
| 91 |
|
| 92 |
@media screen and (max-width: 768px) { |
| 93 |
input[type="text"] { |
| 94 |
max-width: 200px !important; |
| 95 |
; } |
| 96 |
|
| 97 |
xmp { |
| 98 |
display: block; |
| 99 |
white-space: pre-wrap; |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
</style> |
| 104 |
<div class="wrap exit_popup"> |
| 105 |
<h2><?php echo __('Exit Popup Settings', 'exit-popup'); ?></h2> |
| 106 |
<p><?php echo __('Exit Popup enables you to display a jQuery modal before a visitor leaves your website.', 'exit-popup'); ?></p> |
| 107 |
<form method="post" action="options.php"> |
| 108 |
<?php |
| 109 |
settings_fields( 'exit-popup-settings' ); |
| 110 |
do_settings_sections( 'exit-popup-settings' ); |
| 111 |
?> |
| 112 |
<table class="form-table"> |
| 113 |
<tr valign="top"> |
| 114 |
<th scope="row"><?php echo __('Cookie expiration (days)', 'exit-popup'); ?></th> |
| 115 |
<td> |
| 116 |
<input type="text" size="10" name="exit_popup_cookie_expire" value="<?php echo esc_attr( get_option('exit_popup_cookie_expire') ); ?>" /><br /><small><?php echo __('E.g.: 10', 'exit-popup'); ?></small><br /><small><?php echo __('Enter -1 to have the cookies last for the session.', 'exit-popup'); ?></small> |
| 117 |
</td> |
| 118 |
</tr> |
| 119 |
<tr valign="top"> |
| 120 |
<th scope="row"><?php echo __('Prevent close on click outside of modal box', 'exit-popup'); ?></th> |
| 121 |
<td> |
| 122 |
<input type="checkbox" name="exit_popup_click_outside" value="true" <?php echo ( get_option('exit_popup_click_outside') == true ) ? ' checked="checked" />' : ' />'; ?> <br /><small></small> |
| 123 |
</td> |
| 124 |
</tr> |
| 125 |
<tr valign="top"> |
| 126 |
<th scope="row"><?php echo __('Show for logged out users only', 'exit-popup'); ?></th> |
| 127 |
<td> |
| 128 |
<input type="checkbox" name="exit_popup_logged_out_users_only" value="true" <?php echo ( get_option('exit_popup_logged_out_users_only') == true ) ? ' checked="checked" />' : ' />'; ?> <br /><small></small> |
| 129 |
</td> |
| 130 |
</tr> |
| 131 |
<tr valign="top"> |
| 132 |
<th scope="row"><?php echo __('Modal width (px or %)', 'exit-popup'); ?></th> |
| 133 |
<td> |
| 134 |
<input type="text" size="10" name="exit_popup_modal_width" value="<?php echo esc_attr( get_option('exit_popup_modal_width') ); ?>" /><br /><small><?php echo __('E.g.: 500px or 50%', 'exit-popup'); ?></small> |
| 135 |
</td> |
| 136 |
</tr> |
| 137 |
<tr valign="top"> |
| 138 |
<th scope="row"><?php echo __('Modal height (px or %)', 'exit-popup'); ?></th> |
| 139 |
<td> |
| 140 |
<input type="text" size="10" name="exit_popup_modal_height" value="<?php echo esc_attr( get_option('exit_popup_modal_height') ); ?>" /><br /><small><?php echo __('E.g.: 500px or 50%', 'exit-popup'); ?></small> |
| 141 |
</td> |
| 142 |
</tr> |
| 143 |
<tr valign="top"> |
| 144 |
<th scope="row"><?php echo __('Mobile modal width (px or %)', 'exit-popup'); ?></th> |
| 145 |
<td> |
| 146 |
<input type="text" size="10" name="exit_popup_mobile_modal_width" value="<?php echo esc_attr( get_option('exit_popup_mobile_modal_width') ); ?>" /><br /><small><?php echo __('Leave empty to use the desktop width. E.g.: 92% or 340px', 'exit-popup'); ?></small> |
| 147 |
</td> |
| 148 |
</tr> |
| 149 |
<tr valign="top"> |
| 150 |
<th scope="row"><?php echo __('Mobile modal height (px or %)', 'exit-popup'); ?></th> |
| 151 |
<td> |
| 152 |
<input type="text" size="10" name="exit_popup_mobile_modal_height" value="<?php echo esc_attr( get_option('exit_popup_mobile_modal_height') ); ?>" /><br /><small><?php echo __('Leave empty to use the desktop height. E.g.: 80% or 500px', 'exit-popup'); ?></small> |
| 153 |
</td> |
| 154 |
</tr> |
| 155 |
<tr valign="top"> |
| 156 |
<th scope="row"><?php echo __('Title background colour', 'exit-popup'); ?></th> |
| 157 |
<td> |
| 158 |
<input id="exit_popup_popup_title_color" type="text" size="10" name="exit_popup_popup_title_color" value="<?php echo esc_attr( get_option('exit_popup_popup_title_color') ); ?>" /><br /> |
| 159 |
</td> |
| 160 |
</tr> |
| 161 |
<tr valign="top"> |
| 162 |
<th scope="row"><?php echo __('Title (Text)', 'exit-popup'); ?></th> |
| 163 |
<td> |
| 164 |
<input type="text" size="40" name="exit_popup_popup_title" value="<?php echo esc_attr( get_option('exit_popup_popup_title') ); ?>" /><br /><small><?php echo __('E.g.: Don\'t Leave Yet!', 'exit-popup'); ?></small> |
| 165 |
</td> |
| 166 |
</tr> |
| 167 |
<tr valign="top"> |
| 168 |
<th scope="row"><?php echo __('Footer (Text)', 'exit-popup'); ?></th> |
| 169 |
<td> |
| 170 |
<input type="text" size="40" name="exit_popup_popup_footer" value="<?php echo esc_attr( get_option('exit_popup_popup_footer') ); ?>" /><br /><small><?php echo __('E.g.: Thank You!', 'exit-popup'); ?></small><br /><small><?php echo __('This is a clickable text/button that closes the popup when clicked. Leave empty to hide the footer.', 'exit-popup'); ?></small> |
| 171 |
</td> |
| 172 |
</tr> |
| 173 |
<tr valign="top"> |
| 174 |
<th scope="row"><?php echo __('Body (HTML)', 'exit-popup'); ?></th> |
| 175 |
<td><textarea rows="10" cols="100" name="exit_popup_popup_body"><?php echo esc_html( get_option('exit_popup_popup_body') ); ?></textarea> |
| 176 |
<small> |
| 177 |
<xmp> |
| 178 |
<?php echo __('HTML code example: |
| 179 |
<style> |
| 180 |
.discount-box { |
| 181 |
font-size: 2em; |
| 182 |
font-weight: bold; |
| 183 |
display: inline; |
| 184 |
background: #ec971f; |
| 185 |
color: #fff; |
| 186 |
padding: 20px; |
| 187 |
padding-left: 5px; |
| 188 |
padding-right: 5px; |
| 189 |
box-shadow: 10px 0 0 #777, -10px 0 0 #777; |
| 190 |
align: center; |
| 191 |
} |
| 192 |
</style> |
| 193 |
|
| 194 |
<h4>Best Offer</h4> |
| 195 |
<p style="padding-top: 20px"></p> |
| 196 |
<p><span class="discount-box">3 For The Price Of 2!</span></p> |
| 197 |
<p style="padding-top: 20px"></p> |
| 198 |
<p><small>The offer is available to all.</small></p>', 'exit-popup'); ?> |
| 199 |
</xmp> |
| 200 |
</small> |
| 201 |
</td> |
| 202 |
</tr> |
| 203 |
<?php if( array_key_exists( 'wpml_object_id' , $GLOBALS['wp_filter']) ): // check for WPML ?> |
| 204 |
<tr valign="top"> |
| 205 |
<th scope="row"><?php _e('Enabled language','exit-popup');?></th> |
| 206 |
<td> |
| 207 |
<?php $languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' ); |
| 208 |
$enabled_languages = get_option('exit_popup_languages'); |
| 209 |
$enabled_languages = is_array( $enabled_languages ) ? $enabled_languages : array(); |
| 210 |
$languages = is_array( $languages ) ? $languages : array(); |
| 211 |
foreach ($languages as $key => $value) : ?> |
| 212 |
<label style="padding-right: 15px;"><input type="checkbox" name="exit_popup_languages[<?php echo $key;?>]" value="<?php echo $key; ?>" <?php checked( $key, isset( $enabled_languages[$key] ) ? $enabled_languages[$key] : '', true); ?> /> <?php echo $value['native_name']; ?></label> |
| 213 |
<?php endforeach; ?> |
| 214 |
</td> |
| 215 |
</tr> |
| 216 |
|
| 217 |
<?php endif; ?> |
| 218 |
<tr valign="top"> |
| 219 |
<th scope="row"><?php _e('Exclude from Posts/Pages','exit-popup');?></th> |
| 220 |
<td> |
| 221 |
<?php |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
$ep_post_types = get_post_types(); |
| 227 |
|
| 228 |
|
| 229 |
$selected_posts_to_exclude = get_option('exit-popup-exclude-from-posts') ; |
| 230 |
|
| 231 |
if(empty($selected_posts_to_exclude)) { |
| 232 |
$selected_posts_to_exclude = array(); |
| 233 |
} |
| 234 |
|
| 235 |
|
| 236 |
echo '<label for="exit-popup-exclude-from-posts"></label>'; |
| 237 |
echo '<select id="js-hide-search-multi" name="exit-popup-exclude-from-posts[]" multiple="multiple" class="request-schedule-select" >'; |
| 238 |
|
| 239 |
|
| 240 |
foreach($ep_post_types as $post_type) { |
| 241 |
if($post_type == 'attachment' || $post_type == 'nav_menu_item' || $post_type == 'revision' || $post_type == 'custom_css' |
| 242 |
|| $post_type == 'customize_changeset' || $post_type == 'oembed_cache' || $post_type == 'user_request' || $post_type == 'wp_block' |
| 243 |
|| $post_type == 'wp_template' || $post_type == 'wp_template_part' || $post_type == 'wp_global_styles' || $post_type == 'wp_navigation' |
| 244 |
|
| 245 |
) { |
| 246 |
break ; |
| 247 |
} |
| 248 |
|
| 249 |
$args = array( |
| 250 |
'post_type' => $post_type, |
| 251 |
'order' => 'DESC', |
| 252 |
'post_status' => 'publish', |
| 253 |
'posts_per_page' => -1 |
| 254 |
); |
| 255 |
|
| 256 |
$query = new WP_Query($args); |
| 257 |
|
| 258 |
if ($query->have_posts()) { |
| 259 |
echo '<optgroup label="' . $post_type . '" >'; |
| 260 |
|
| 261 |
|
| 262 |
while ($query->have_posts()) : $query->the_post(); |
| 263 |
$id = get_the_ID(); |
| 264 |
echo '<option value="' . $id . '" ' . ((in_array($id, $selected_posts_to_exclude)) ? ('selected') : '') . ' . >' . get_the_title() . '</option>'; |
| 265 |
|
| 266 |
endwhile; |
| 267 |
echo '</optgroup >'; |
| 268 |
} |
| 269 |
} |
| 270 |
echo '</select>'; |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
?> |
| 275 |
</td> |
| 276 |
</tr> |
| 277 |
<tr valign="top"> |
| 278 |
<th scope="row"><label for="exit_popup_powered_by"><?php echo __("Show 'Powered by' link",'exit-popup');?></label></th> |
| 279 |
<td> |
| 280 |
<input type="checkbox" name="exit_popup_powered_by" value="true" <?php echo ( get_option('exit_popup_powered_by') == true ) ? ' checked="checked" />' : ' />'; ?><br /><small><?php echo __('We are very happy to be able to provide this for free along with other <a href="https://www.brontobytes.com/blog |
| 281 |
/c/wordpress-plugins/" target="_blank">free WordPress plugins</a>.', 'exit-popup');?> </small> |
| 282 |
</td> |
| 283 |
</tr> |
| 284 |
</table> |
| 285 |
<script type="text/javascript" > |
| 286 |
jQuery(document).ready(function(){ |
| 287 |
jQuery("#exit_popup_popup_title_color").wpColorPicker(); |
| 288 |
|
| 289 |
jQuery('#js-hide-search-multi').select2(); |
| 290 |
|
| 291 |
|
| 292 |
}); |
| 293 |
|
| 294 |
</script> |
| 295 |
<?php |
| 296 |
submit_button(); |
| 297 |
?> |
| 298 |
</form> |
| 299 |
<p><?php echo __('Plugin developed by ','exit-popup');?><a href="https://www.brontobytes.com/" target="_blank" >Brontobytes</a></p> |
| 300 |
<a href="https://www.brontobytes.com/" target="_blank"><img width="100" style="vertical-align:middle" src="<?php echo plugins_url( 'images/brontobytes.svg', __FILE__ ) ?>" alt="<?php echo __('Web & VPS hosting provider','exit-popup');?>"></a> |
| 301 |
</div> |
| 302 |
<?php } |
| 303 |
|
| 304 |
function exit_popup_settings() { |
| 305 |
register_setting( 'exit-popup-settings', 'exit_popup_cookie_expire' ); |
| 306 |
register_setting( 'exit-popup-settings', 'exit_popup_click_outside' ); |
| 307 |
register_setting( 'exit-popup-settings', 'exit_popup_modal_width' ); |
| 308 |
register_setting( 'exit-popup-settings', 'exit_popup_modal_height' ); |
| 309 |
register_setting( 'exit-popup-settings', 'exit_popup_mobile_modal_width' ); |
| 310 |
register_setting( 'exit-popup-settings', 'exit_popup_mobile_modal_height' ); |
| 311 |
register_setting( 'exit-popup-settings', 'exit_popup_popup_title_color' ); |
| 312 |
register_setting( 'exit-popup-settings', 'exit_popup_popup_title' ); |
| 313 |
register_setting( 'exit-popup-settings', 'exit_popup_popup_body' ); |
| 314 |
register_setting( 'exit-popup-settings', 'exit_popup_popup_footer' ); |
| 315 |
register_setting( 'exit-popup-settings', 'exit_popup_languages' ); |
| 316 |
register_setting( 'exit-popup-settings', 'exit-popup-exclude-from-posts' ); |
| 317 |
register_setting( 'exit-popup-settings', 'exit_popup_powered_by' ); |
| 318 |
register_setting( 'exit-popup-settings', 'exit_popup_logged_out_users_only' ); |
| 319 |
|
| 320 |
} |
| 321 |
add_action( 'admin_init', 'exit_popup_settings' ); |
| 322 |
|
| 323 |
function exit_popup_deactivation() { |
| 324 |
delete_option( 'exit_popup_cookie_expire' ); |
| 325 |
delete_option( 'exit_popup_click_outside' ); |
| 326 |
delete_option( 'exit_popup_modal_width' ); |
| 327 |
delete_option( 'exit_popup_modal_height' ); |
| 328 |
delete_option( 'exit_popup_mobile_modal_width' ); |
| 329 |
delete_option( 'exit_popup_mobile_modal_height' ); |
| 330 |
delete_option( 'exit_popup_popup_title_color' ); |
| 331 |
delete_option( 'exit_popup_popup_title' ); |
| 332 |
delete_option( 'exit_popup_popup_body' ); |
| 333 |
delete_option( 'exit_popup_popup_footer' ); |
| 334 |
delete_option( 'exit_popup_languages' ); |
| 335 |
delete_option( 'exit_popup_powered_by' ); |
| 336 |
delete_option( 'exit-popup-exclude-from-posts' ); |
| 337 |
delete_option( 'exit_popup_logged_out_users_only' ); |
| 338 |
} |
| 339 |
register_deactivation_hook( __FILE__, 'exit_popup_deactivation' ); |
| 340 |
|
| 341 |
function exit_popup_dependencies() { |
| 342 |
wp_register_script( 'js-cookie-js', plugins_url('js/js-cookie.js', __FILE__), array('jquery'), time(), false ); |
| 343 |
wp_enqueue_script( 'js-cookie-js' ); |
| 344 |
wp_register_script( 'exit-popup-js', plugins_url('js/exit-popup.js', __FILE__), array('jquery'), time(), false ); |
| 345 |
wp_enqueue_script( 'exit-popup-js' ); |
| 346 |
wp_register_style( 'exit-popup-css', plugins_url('css/exit-popup.css', __FILE__) ); |
| 347 |
wp_enqueue_style( 'exit-popup-css' ); |
| 348 |
} |
| 349 |
add_action( 'wp_enqueue_scripts', 'exit_popup_dependencies' ); |
| 350 |
|
| 351 |
function exit_popup() { |
| 352 |
|
| 353 |
|
| 354 |
$show_for_logged_out_users_only = get_option('exit_popup_logged_out_users_only' , false ) ; |
| 355 |
|
| 356 |
if(!$show_for_logged_out_users_only ) { |
| 357 |
|
| 358 |
} |
| 359 |
else { |
| 360 |
if(is_user_logged_in()) { |
| 361 |
return; |
| 362 |
} |
| 363 |
|
| 364 |
} |
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
$selected_posts_to_exclude = get_option('exit-popup-exclude-from-posts') ; |
| 370 |
|
| 371 |
|
| 372 |
if(empty($selected_posts_to_exclude)) { |
| 373 |
$selected_posts_to_exclude = array(); |
| 374 |
} |
| 375 |
|
| 376 |
if (in_array(get_the_ID(), $selected_posts_to_exclude) ) |
| 377 |
{ |
| 378 |
return; |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
// Check for language |
| 383 |
$check_lg = true; |
| 384 |
if( array_key_exists( 'wpml_object_id' , $GLOBALS['wp_filter']) ) { |
| 385 |
$epp_lg = get_option('exit_popup_languages'); |
| 386 |
$epp_lg = is_array( $epp_lg ) ? $epp_lg : array(); |
| 387 |
|
| 388 |
$current_lg = ICL_LANGUAGE_CODE; |
| 389 |
|
| 390 |
$check_lg = false; |
| 391 |
|
| 392 |
if( in_array($current_lg, $epp_lg) ) $check_lg = true; |
| 393 |
} |
| 394 |
|
| 395 |
if($check_lg) { // v3.0 |
| 396 |
//if($check_lg && !isset($_COOKIE['viewedExitPopupWP']) && $_COOKIE['viewedExitPopupWP'] != 'true') { |
| 397 |
|
| 398 |
if(esc_attr( get_option('exit_popup_click_outside') ) == "true") { |
| 399 |
$exit_popup_click_outside = ""; |
| 400 |
} else { |
| 401 |
$exit_popup_click_outside = " |
| 402 |
$('body').on('click', function() { |
| 403 |
exitPopupCloseModal(); |
| 404 |
}); |
| 405 |
"; |
| 406 |
} |
| 407 |
|
| 408 |
$modal_width = exit_popup_get_dimension( 'exit_popup_modal_width', '500px' ); |
| 409 |
$modal_height = exit_popup_get_dimension( 'exit_popup_modal_height', '300px' ); |
| 410 |
$mobile_modal_width = exit_popup_get_dimension( 'exit_popup_mobile_modal_width', $modal_width ); |
| 411 |
$mobile_modal_height = exit_popup_get_dimension( 'exit_popup_mobile_modal_height', $modal_height ); |
| 412 |
?> |
| 413 |
<!-- Exit Popup --> |
| 414 |
<style type="text/css"> |
| 415 |
html.exit-popup-open, |
| 416 |
body.exit-popup-open { |
| 417 |
overflow: hidden !important; |
| 418 |
} |
| 419 |
|
| 420 |
#exitpopup-modal { |
| 421 |
overflow-y: auto; |
| 422 |
-webkit-overflow-scrolling: touch; |
| 423 |
} |
| 424 |
|
| 425 |
#exitpopup-modal .exitpopup-modal-window { |
| 426 |
width: <?php echo esc_attr( $modal_width ); ?> !important; |
| 427 |
height: <?php echo esc_attr( $modal_height ); ?> !important; |
| 428 |
max-width: calc(100vw - 32px); |
| 429 |
max-height: calc(100vh - 32px); |
| 430 |
overflow-y: auto; |
| 431 |
} |
| 432 |
|
| 433 |
@media screen and (max-width: 768px) { |
| 434 |
#exitpopup-modal .exitpopup-modal-window { |
| 435 |
width: <?php echo esc_attr( $mobile_modal_width ); ?> !important; |
| 436 |
height: <?php echo esc_attr( $mobile_modal_height ); ?> !important; |
| 437 |
} |
| 438 |
} |
| 439 |
</style> |
| 440 |
<div id='exitpopup-modal'> |
| 441 |
<div class='underlay'></div> |
| 442 |
<div class='exitpopup-modal-window'> |
| 443 |
<?php $title_background_color = get_option('exit_popup_popup_title_color'); |
| 444 |
if(!empty($title_background_color)) |
| 445 |
{ |
| 446 |
|
| 447 |
// echo $title_background_color . ' ' . strpos($title_background_color, '#' ) . 'yay'; |
| 448 |
if(strpos($title_background_color, '#' ) !== false) |
| 449 |
{ |
| 450 |
$title_background_color = $title_background_color; |
| 451 |
} |
| 452 |
else { |
| 453 |
$title_background_color = '#' . $title_background_color; |
| 454 |
} |
| 455 |
} |
| 456 |
?> |
| 457 |
|
| 458 |
<div class='modal-title' style='background-color:<?php echo esc_attr( $title_background_color ); ?> !important;'> |
| 459 |
<h3><?php echo esc_html( get_option('exit_popup_popup_title') ); ?></h3> |
| 460 |
</div> |
| 461 |
<div class='modal-body'> |
| 462 |
<?php echo do_shortcode(html_entity_decode(get_option('exit_popup_popup_body'))); ?> |
| 463 |
</div> |
| 464 |
<div class='exitpopup-modal-footer'> |
| 465 |
<p><?php echo esc_html( get_option('exit_popup_popup_footer') ); ?></p> |
| 466 |
</div> |
| 467 |
<?php if (get_option('exit_popup_powered_by') == true) { ?> <div style="bottom: -25px;position: absolute;right: 0px;"><a style="font-size:x-small;color:white;text-decoration:none;" target="_blank" href="https://www.brontobytes.com/blog/exit-popup-free-wordpress-plugin/"><?php echo __('Exit Popup for WordPress','exit-popup');?></a></div> <?php } ?> |
| 468 |
</div> |
| 469 |
</div> |
| 470 |
|
| 471 |
<script type='text/javascript'> |
| 472 |
jQuery(document).ready(function($) { |
| 473 |
var exit_popup_value = Cookies.get('viewedExitPopupWP'); // v3.0 |
| 474 |
if(!exit_popup_value){ // v3.0 |
| 475 |
function exitPopupCloseModal() { |
| 476 |
$('#exitpopup-modal').hide(); |
| 477 |
$('html, body').removeClass('exit-popup-open'); |
| 478 |
} |
| 479 |
var _exitpopup = exitpopup(document.getElementById('exitpopup-modal'), { |
| 480 |
aggressive: true, |
| 481 |
timer: 0, |
| 482 |
sensitivity: 20, |
| 483 |
delay: 0, |
| 484 |
sitewide: true, |
| 485 |
cookieExpire: <?php echo esc_attr( get_option('exit_popup_cookie_expire') ); ?>, |
| 486 |
callback: function() { |
| 487 |
$('html, body').addClass('exit-popup-open'); |
| 488 |
console.log('exitpopup fired!'); |
| 489 |
} |
| 490 |
}); |
| 491 |
|
| 492 |
<?php echo $exit_popup_click_outside; ?> |
| 493 |
$('#exitpopup-modal .exitpopup-modal-footer').on('click', function() { |
| 494 |
exitPopupCloseModal(); |
| 495 |
}); |
| 496 |
$('#exitpopup-modal .exitpopup-modal-window').on('click', function(e) { |
| 497 |
e.stopPropagation(); |
| 498 |
}); |
| 499 |
} // v3.0 |
| 500 |
}); |
| 501 |
</script> |
| 502 |
<!-- End Exit Popup --> |
| 503 |
<?php |
| 504 |
}//if viewedExitPopupWP |
| 505 |
}//function exit_popup |
| 506 |
add_action( 'wp_footer', 'exit_popup', 10 ); |
| 507 |
|