| 1 |
<?php |
| 2 |
namespace ULTP; |
| 3 |
defined('ABSPATH') || exit; |
| 4 |
class Notice { |
| 5 |
public function __construct(){ |
| 6 |
//add_action('admin_notices', array($this, 'ultp_installation_notice_callback')); |
| 7 |
add_action('wp_ajax_ultp_get_pro_notice', array($this, 'set_dismiss_notice_callback')); |
| 8 |
} |
| 9 |
// Dismiss Notice Callback |
| 10 |
public function set_dismiss_notice_callback() { |
| 11 |
if (!wp_verify_nonce($_REQUEST['wpnonce'], 'ultp-free-nonce')) { |
| 12 |
return ; |
| 13 |
} |
| 14 |
set_transient( 'ultp_get_pro_notice_v14', 'off', 2592000 ); // 30 days notice |
| 15 |
} |
| 16 |
public function ultp_installation_notice_callback() { |
| 17 |
if (get_transient('ultp_get_pro_notice_v14') != 'off' && (!defined('ULTP_PRO_VER'))) { |
| 18 |
$this->ultp_notice_css(); |
| 19 |
$this->ultp_notice_js(); |
| 20 |
?> |
| 21 |
<div class="wc-install ultp-pro-notice"> |
| 22 |
<div class="wc-install-body"> |
| 23 |
<a class="wc-dismiss-notice" data-security=<?php echo wp_create_nonce('ultp-free-nonce'); ?> data-ajax=<?php echo admin_url('admin-ajax.php'); ?> href="#"><span class="dashicons dashicons-dismiss"></span></a> |
| 24 |
<div><?php _e('Special offer for <strong>PostX - Gutenberg Post Blocks</strong>. Limited time offer. You can get <strong style="color:#e5561e;">up to 45% Off</strong> for all premium features.', 'ultimate-post'); ?></div> |
| 25 |
<a class="button button-primary button-hero ultp-btn-notice-pro" target="_blank" href="<?php echo ultimate_post()->get_premium_link(); ?>"><span class="dashicons dashicons-image-rotate"></span><?php _e('Get Now', 'ultimate-post'); ?></a> |
| 26 |
</div> |
| 27 |
</div> |
| 28 |
<?php |
| 29 |
} |
| 30 |
} |
| 31 |
public function ultp_notice_css() { |
| 32 |
?> |
| 33 |
<style type="text/css"> |
| 34 |
.wc-install { |
| 35 |
display: flex; |
| 36 |
align-items: center; |
| 37 |
background: #fff; |
| 38 |
margin-top: 40px; |
| 39 |
width: calc(100% - 50px); |
| 40 |
/* width: calc(100% - 40px); */ |
| 41 |
border: 1px solid #ccd0d4; |
| 42 |
/* padding: 8px 8px 4px 8px; */ |
| 43 |
padding: 12px 15px; |
| 44 |
border-radius: 4px; |
| 45 |
border-left: 4px solid #e5561e; |
| 46 |
} |
| 47 |
.wc-install img { |
| 48 |
margin-right: 0; |
| 49 |
max-width: 100%; |
| 50 |
} |
| 51 |
.wc-install-body { |
| 52 |
-ms-flex: 1; |
| 53 |
flex: 1; |
| 54 |
position: relative; |
| 55 |
} |
| 56 |
.wc-install-body > div { |
| 57 |
max-width: 450px; |
| 58 |
margin-bottom: 20px; |
| 59 |
} |
| 60 |
.wc-install-body h3 { |
| 61 |
margin-top: 0; |
| 62 |
font-size: 24px; |
| 63 |
margin-bottom: 15px; |
| 64 |
} |
| 65 |
.ultp-install-btn { |
| 66 |
margin-top: 15px; |
| 67 |
display: inline-block; |
| 68 |
} |
| 69 |
.wc-install .dashicons{ |
| 70 |
display: none; |
| 71 |
animation: dashicons-spin 1s infinite; |
| 72 |
animation-timing-function: linear; |
| 73 |
} |
| 74 |
.wc-install.loading .dashicons { |
| 75 |
display: inline-block; |
| 76 |
margin-top: 12px; |
| 77 |
margin-right: 5px; |
| 78 |
} |
| 79 |
.ultp-pro-notice .wc-install-body h3 { |
| 80 |
font-size: 20px; |
| 81 |
margin-bottom: 5px; |
| 82 |
} |
| 83 |
.ultp-pro-notice .wc-install-body > div { |
| 84 |
max-width: 800px; |
| 85 |
margin-bottom: 10px; |
| 86 |
} |
| 87 |
.ultp-pro-notice .button-hero { |
| 88 |
padding: 8px 14px !important; |
| 89 |
min-height: inherit !important; |
| 90 |
line-height: 1 !important; |
| 91 |
/* background: #46b450; */ |
| 92 |
box-shadow: none; |
| 93 |
border: none; |
| 94 |
transition: 400ms; |
| 95 |
} |
| 96 |
.ultp-pro-notice .ultp-btn-notice-pro { |
| 97 |
background: #e5561e; |
| 98 |
color: #fff; |
| 99 |
} |
| 100 |
.ultp-pro-notice .ultp-btn-notice-pro:hover, |
| 101 |
.ultp-pro-notice .ultp-btn-notice-pro:focus { |
| 102 |
background: #ce4b18; |
| 103 |
} |
| 104 |
.ultp-pro-notice .button-hero:hover, |
| 105 |
.ultp-pro-notice .button-hero:focus { |
| 106 |
/* background: #349a3d; */ |
| 107 |
border: none; |
| 108 |
box-shadow: none; |
| 109 |
} |
| 110 |
@keyframes dashicons-spin { |
| 111 |
0% { |
| 112 |
transform: rotate( 0deg ); |
| 113 |
} |
| 114 |
100% { |
| 115 |
transform: rotate( 360deg ); |
| 116 |
} |
| 117 |
} |
| 118 |
.wc-dismiss-notice { |
| 119 |
position: absolute; |
| 120 |
text-decoration: none; |
| 121 |
float: right; |
| 122 |
right: 0px; |
| 123 |
/* color: #ffffff; */ |
| 124 |
transition: 400ms; |
| 125 |
top: 0px |
| 126 |
} |
| 127 |
.wc-dismiss-notice .dashicons{ |
| 128 |
display: inline-block; |
| 129 |
text-decoration: none; |
| 130 |
animation: none; |
| 131 |
font-size: 20px; |
| 132 |
/* width: 25px; |
| 133 |
height: 25px; |
| 134 |
line-height: 25px; |
| 135 |
border-radius: 100px; |
| 136 |
background: #f81430; */ |
| 137 |
} |
| 138 |
/* .wc-dismiss-notice:hover { |
| 139 |
color: #fff; |
| 140 |
} */ |
| 141 |
/* .wc-dismiss-notice:hover .dashicons{ |
| 142 |
background: #cc142a; |
| 143 |
} */ |
| 144 |
</style> |
| 145 |
<?php |
| 146 |
} |
| 147 |
public function ultp_notice_js() { ?> |
| 148 |
<script type="text/javascript"> |
| 149 |
jQuery(document).ready(function($){ |
| 150 |
'use strict'; |
| 151 |
// Dismiss notice |
| 152 |
$(document).on('click', '.wc-dismiss-notice', function(e){ |
| 153 |
e.preventDefault(); |
| 154 |
const that = $(this); |
| 155 |
$.ajax({ |
| 156 |
url: that.data('ajax'), |
| 157 |
type: 'POST', |
| 158 |
data: { |
| 159 |
action: 'ultp_get_pro_notice', |
| 160 |
wpnonce: that.data('security') |
| 161 |
}, |
| 162 |
success: function (data) { |
| 163 |
that.parents('.wc-install').hide("slow", function() { that.parents('.wc-install').remove(); }); |
| 164 |
}, |
| 165 |
error: function(xhr) { |
| 166 |
console.log('Error occured. Please try again' + xhr.statusText + xhr.responseText ); |
| 167 |
}, |
| 168 |
}); |
| 169 |
}); |
| 170 |
}); |
| 171 |
</script> |
| 172 |
<?php |
| 173 |
} |
| 174 |
} |