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