| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Admin\AdminSettings ; |
| 6 |
/** |
| 7 |
* Author Name: Liton Arefin |
| 8 |
* Author URL: https://jeweltheme.com |
| 9 |
* Date: 25/07/2021 |
| 10 |
*/ |
| 11 |
if ( !defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
// No, Direct access Sir !!! |
| 15 |
class AdminifyPromo |
| 16 |
{ |
| 17 |
public $timenow ; |
| 18 |
private static $instance = null ; |
| 19 |
public static function get_instance() |
| 20 |
{ |
| 21 |
if ( !self::$instance ) { |
| 22 |
self::$instance = new self(); |
| 23 |
} |
| 24 |
return self::$instance; |
| 25 |
} |
| 26 |
|
| 27 |
public function __construct() |
| 28 |
{ |
| 29 |
if ( !is_admin() ) { |
| 30 |
return; |
| 31 |
} |
| 32 |
$this->options = (array) AdminSettings::get_instance()->get(); |
| 33 |
$this->timenow = strtotime( "now" ); |
| 34 |
// Admin Notices |
| 35 |
add_action( 'admin_init', [ $this, 'jltwp_adminify_admin_notice_init' ] ); |
| 36 |
//Notices |
| 37 |
add_action( 'admin_notices', [ $this, 'jltwp_adminify_latest_update_details' ], 10 ); |
| 38 |
add_action( 'network_admin_notices', [ $this, 'jltwp_adminify_latest_update_details' ], 10 ); |
| 39 |
add_action( 'admin_notices', [ $this, 'jltwp_adminify_review_notice_generator' ], 10 ); |
| 40 |
add_action( 'admin_notices', [ $this, 'jltwp_adminify_upgrade_pro_notice_generator' ], 10 ); |
| 41 |
// Black Friday & Cyber Monday Offer |
| 42 |
add_action( 'admin_notices', [ $this, 'jltwp_adminify_black_friday_cyber_monday_deals' ] ); |
| 43 |
// Styles |
| 44 |
add_action( 'admin_print_styles', [ $this, 'jltwp_adminify_admin_notice_styles' ] ); |
| 45 |
} |
| 46 |
|
| 47 |
public function jltwp_adminify_admin_notice_init() |
| 48 |
{ |
| 49 |
add_action( 'wp_ajax_adminify_dismiss_admin_notice', [ $this, 'jltwp_adminify_dismiss_admin_notice' ] ); |
| 50 |
} |
| 51 |
|
| 52 |
public function jltwp_adminify_latest_update_details() |
| 53 |
{ |
| 54 |
if ( !self::is_admin_notice_active( 'wp-adminify-update-notice-forever' ) ) { |
| 55 |
return; |
| 56 |
} |
| 57 |
$jltwp_adminify_changelog_message = sprintf( |
| 58 |
__( '%3$s %4$s %5$s %6$s %7$s %8$s <br> <strong>Check Changelogs for </strong> <a href="%1$s" target="__blank">%2$s</a>', WP_ADMINIFY_TD ), |
| 59 |
esc_url_raw( 'https://wpadminify.com/changelogs/' ), |
| 60 |
__( 'More Details', WP_ADMINIFY_TD ), |
| 61 |
/** Changelog Items |
| 62 |
* Starts from: %3$s |
| 63 |
*/ |
| 64 |
'<h3 class="adminify-update-head">' . WP_ADMINIFY . ' <span><small><em>v' . WP_ADMINIFY_VER . '</em></small>' . __( ' has some Major updates..', WP_ADMINIFY_TD ) . '</span></h3><br>', |
| 65 |
// %3$s |
| 66 |
__( '<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> Admin Notices not translating issue fixed </span><br>', WP_ADMINIFY_TD ), |
| 67 |
__( '<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> WooCommerce All Products page not working issue fixed </span><br>', WP_ADMINIFY_TD ), |
| 68 |
__( '<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> Search Bar not hiding for Pro version issue fixed </span><br>', WP_ADMINIFY_TD ), |
| 69 |
__( '<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> Menu Editor Icon Picker script loading issue fixed. Compatability given with jQuery </span><br>', WP_ADMINIFY_TD ), |
| 70 |
__( '<span class="dashicons dashicons-yes"></span> <span class="adminify-changes-list"> Admin Bar Logo grayscale issue fixed. Requested by @Philip </span><br>', WP_ADMINIFY_TD ) |
| 71 |
); |
| 72 |
printf( '<div data-dismissible="wp-adminify-update-notice-forever" id="wp-adminify-notice-forever" class="wp-adminify-notice updated notice notice-success is-dismissible"><p>%1$s</p></div>', $jltwp_adminify_changelog_message ); |
| 73 |
} |
| 74 |
|
| 75 |
public function jltwp_adminify_admin_notice_ask_for_review( $notice_key ) |
| 76 |
{ |
| 77 |
if ( !self::is_admin_notice_active( $notice_key ) ) { |
| 78 |
return; |
| 79 |
} |
| 80 |
$this->jltwp_adminify_notice_header( $notice_key ); |
| 81 |
echo sprintf( |
| 82 |
__( '<p>Enjoying <strong>%1$s ?</strong></p> <p>Seems like you are enjoying <strong>%1$s</strong>. Would you please show us a little love by rating us on <a href="%2$s" target="_blank" style="background:yellow; padding:2px 5px;">%3$s?</a></p> |
| 83 |
<ul class="wp-adminify-review-ul"> |
| 84 |
<li><a href="%2$s" target="_blank" class="button adminify-sure-do-btn is-warning mt-4 upgrade-btn pt-1 pb-1 pr-4 pl-4" style="background-color: transparent; color: #fff;"><span class="dashicons dashicons-external" style="line-height:inherit"></span>Sure! I\'d love to!</a></li> |
| 85 |
<li><a href="#" target="_blank" class="adminify-notice-dismiss button upgrade-btn mt-4 pt-1 pb-1 pr-4 pl-4"><span class="dashicons dashicons-smiley" style="line-height:inherit"></span>I\'ve already left a review</a></li> |
| 86 |
<li><a href="#" target="_blank" class="adminify-notice-dismiss button is-danger upgrade-btn mt-4 pt-1 pb-1 pr-4 pl-4" style="background-color: #f14668 !important; color:#fff !important; border:1px solid #f14668;"><span class="dashicons dashicons-dismiss" style="line-height:inherit"></span>Never show again</a></li> |
| 87 |
</ul>', WP_ADMINIFY_TD ), |
| 88 |
WP_ADMINIFY, |
| 89 |
esc_url_raw( 'https://wordpress.org/support/plugin/adminify/reviews/?filter=5' ), |
| 90 |
__( "WordPress.org", WP_ADMINIFY_TD ) |
| 91 |
) ; |
| 92 |
$this->jltwp_adminify_notice_footer(); |
| 93 |
} |
| 94 |
|
| 95 |
public function jltwp_adminify_admin_upgrade_pro_notice( $notice_key ) |
| 96 |
{ |
| 97 |
if ( !self::is_admin_notice_active( $notice_key ) ) { |
| 98 |
return; |
| 99 |
} |
| 100 |
$this->jltwp_adminify_notice_header( $notice_key ); |
| 101 |
echo sprintf( |
| 102 |
__( ' <p> %1$s <strong>%2$s</strong> %3$s </p> <p><a class="button upgrade-btn mt-4" href="https://wpadminify.com/pricing" target="_blank">Upgrade Now</a></p>', WP_ADMINIFY_TD ), |
| 103 |
__( "Unlock all possiblities - Schedule Dark Mode, hide all admin Notices, Pagespeed Insights, unlock Folders etc.. <br>", WP_ADMINIFY_TD ), |
| 104 |
__( '20% Discount on all pricing, enjoy the freedom.<br>', WP_ADMINIFY_TD ), |
| 105 |
__( "Coupon Code: <strong style='background:yellow; padding:1px 5px; color: #0347FF;'>ENJOY25</strong>", WP_ADMINIFY_TD ) |
| 106 |
) ; |
| 107 |
$this->jltwp_adminify_notice_footer(); |
| 108 |
} |
| 109 |
|
| 110 |
// Black Friday & Cyber Monday Offer |
| 111 |
public function jltwp_adminify_admin_black_friday_cyber_monday_notice( $notice_key ) |
| 112 |
{ |
| 113 |
if ( !self::is_admin_notice_active( $notice_key ) ) { |
| 114 |
return; |
| 115 |
} |
| 116 |
$this->jltwp_adminify_notice_header( $notice_key ); |
| 117 |
echo sprintf( |
| 118 |
__( ' <p> %1$s <strong>%2$s</strong> %3$s </p> <p><a class="button upgrade-btn mt-4" href="https://wpadminify.com/pricing" target="_blank">Upgrade Now</a></p>', WP_ADMINIFY_TD ), |
| 119 |
__( "Unlock all possiblities - Schedule Dark Mode, hide all Admin Notices, Pagespeed Insights, unlock Folders etc.. <br>", WP_ADMINIFY_TD ), |
| 120 |
__( '50% Huge Discount for <span style="background:#111; padding:2px 10px; color: #fff;">Black Friday and Cyber Monday Deals</span><br>', WP_ADMINIFY_TD ), |
| 121 |
__( "Coupon Code: <strong style='background:yellow; padding:2px 10px; color: #0347FF;'>BFCM50</strong>", WP_ADMINIFY_TD ) |
| 122 |
) ; |
| 123 |
$this->jltwp_adminify_notice_footer(); |
| 124 |
} |
| 125 |
|
| 126 |
public function jltwp_adminify_notice_header( $notice_key ) |
| 127 |
{ |
| 128 |
?> |
| 129 |
<div data-dismissible="<?php |
| 130 |
echo esc_attr( $notice_key ) ; |
| 131 |
?>" id="<?php |
| 132 |
echo esc_attr( $notice_key ) ; |
| 133 |
?>" class="wp-adminify-notice adminify-review-notice-banner updated notice notice-success is-dismissible"> |
| 134 |
<div id="wp-adminify-bfcm-upgrade-notice" class="wp-adminify-review-notice"> |
| 135 |
<div class="wp-adminify-notice-banner"> |
| 136 |
<div class="wp-adminify-notice-contents columns is-tablet is-align-items-center"> |
| 137 |
<ul class="adminify-notice-left-nav column is-2-tablet"> |
| 138 |
<li> |
| 139 |
<a class="is-flex is-align-items-center" target="_blank" href="https://wpadminify.com/kb"> |
| 140 |
<i class="is-rounded is-pulled-left mr-2 dashicons dashicons-book"></i> |
| 141 |
<?php |
| 142 |
echo __( 'Docs', WP_ADMINIFY_TD ) ; |
| 143 |
?> |
| 144 |
</a> |
| 145 |
</li> |
| 146 |
<li> |
| 147 |
<a class="is-flex is-align-items-center" target="_blank" href="https://demo.wpadminify.com/"> |
| 148 |
<i class="is-rounded is-pulled-left mr-2 dashicons dashicons-fullscreen-alt"></i> |
| 149 |
<?php |
| 150 |
echo __( 'Live Demo', WP_ADMINIFY_TD ) ; |
| 151 |
?> |
| 152 |
</a> |
| 153 |
</li> |
| 154 |
<li> |
| 155 |
<a class="is-flex is-align-items-center" target="_blank" href="https://wpadminify.com/faqs/"> |
| 156 |
<i class="is-rounded is-pulled-left mr-2 dashicons dashicons-editor-help"></i> |
| 157 |
<?php |
| 158 |
echo __( 'F.A.Q.', WP_ADMINIFY_TD ) ; |
| 159 |
?> |
| 160 |
</a> |
| 161 |
</li> |
| 162 |
<li> |
| 163 |
<a class="is-flex is-align-items-center" target="_blank" href="https://wpadminify.com/contact/"> |
| 164 |
<i class="is-rounded is-pulled-left mr-2 dashicons dashicons-phone"></i> |
| 165 |
<?php |
| 166 |
echo __( 'Contact Us', WP_ADMINIFY_TD ) ; |
| 167 |
?> |
| 168 |
</a> |
| 169 |
</li> |
| 170 |
</ul> |
| 171 |
<div class="adminify-notice-middle column is-8-tablet has-text-centered"> |
| 172 |
|
| 173 |
<?php |
| 174 |
} |
| 175 |
|
| 176 |
public function jltwp_adminify_notice_footer() |
| 177 |
{ |
| 178 |
?> |
| 179 |
</div> |
| 180 |
|
| 181 |
<div class="adminify-notice-right column is-2-tablet has-text-centered"> |
| 182 |
<ul class="adminify-notice-right-nav"> |
| 183 |
<li> |
| 184 |
<a class="adminify-logo" href="https://wpadminify.com/" target="_blank"> |
| 185 |
<img src="<?php |
| 186 |
echo WP_ADMINIFY_ASSETS_IMAGE ; |
| 187 |
?>/logos/logo-text-dark.svg" alt="WP Adminify"> |
| 188 |
</a> |
| 189 |
</li> |
| 190 |
<li class="adminify-notice-social"> |
| 191 |
<a class="adminify-notice-social-icon" target="_blank" href="https://www.facebook.com/groups/jeweltheme"> |
| 192 |
<i class="is-rounded dashicons dashicons-facebook-alt"></i> |
| 193 |
</a> |
| 194 |
<a class="adminify-notice-social-icon" target="_blank" href="https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8"> |
| 195 |
<i class="is-rounded dashicons dashicons-youtube"></i> |
| 196 |
</a> |
| 197 |
<a class="adminify-notice-social-icon" target="_blank" href="https://twitter.com/jwthemeltd"> |
| 198 |
<i class="is-rounded dashicons dashicons-twitter"></i> |
| 199 |
</a> |
| 200 |
</li> |
| 201 |
<li class="adminify-rate-us mt-3"> |
| 202 |
<div class="adminify-rate-contents"> |
| 203 |
<label class="adminify-rating-label">Rate us:</label> |
| 204 |
<a class="adminify-rating is-inline-block" href="https://wordpress.org/support/plugin/adminify/reviews/?filter=5" target="_blank"> |
| 205 |
<span class="star"> |
| 206 |
<i class="dashicons dashicons-star-half"></i> |
| 207 |
</span> |
| 208 |
<span class="star"> |
| 209 |
<i class="dashicons dashicons-star-filled"></i> |
| 210 |
</span> |
| 211 |
<span class="star"> |
| 212 |
<i class="dashicons dashicons-star-filled"></i> |
| 213 |
</span> |
| 214 |
<span class="star"> |
| 215 |
<i class="dashicons dashicons-star-filled"></i> |
| 216 |
</span> |
| 217 |
<span class="star"> |
| 218 |
<i class="dashicons dashicons-star-filled"></i> |
| 219 |
</span> |
| 220 |
</a> |
| 221 |
</div> |
| 222 |
</li> |
| 223 |
</ul> |
| 224 |
</div> |
| 225 |
</div> |
| 226 |
</div> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
|
| 230 |
<?php |
| 231 |
} |
| 232 |
|
| 233 |
public function jltwp_adminify_dismiss_admin_notice() |
| 234 |
{ |
| 235 |
$option_name = sanitize_text_field( $_POST['option_name'] ); |
| 236 |
$dismissible_length = sanitize_text_field( $_POST['dismissible_length'] ); |
| 237 |
|
| 238 |
if ( 'forever' != $dismissible_length ) { |
| 239 |
// If $dismissible_length is not an integer default to 1 |
| 240 |
$dismissible_length = ( 0 == absint( $dismissible_length ) ? 1 : $dismissible_length ); |
| 241 |
$dismissible_length = strtotime( absint( $dismissible_length ) . ' days' ); |
| 242 |
} |
| 243 |
|
| 244 |
check_ajax_referer( 'adminify-notice-nonce', 'notice_nonce' ); |
| 245 |
self::set_admin_notice_cache( $option_name, $dismissible_length ); |
| 246 |
wp_die(); |
| 247 |
} |
| 248 |
|
| 249 |
public static function set_admin_notice_cache( $id, $timeout ) |
| 250 |
{ |
| 251 |
$cache_key = 'wp-adminify-notice-' . md5( $id ); |
| 252 |
update_site_option( $cache_key, $timeout ); |
| 253 |
return true; |
| 254 |
} |
| 255 |
|
| 256 |
public static function is_admin_notice_active( $arg ) |
| 257 |
{ |
| 258 |
$array = explode( '-', $arg ); |
| 259 |
$length = array_pop( $array ); |
| 260 |
$option_name = implode( '-', $array ); |
| 261 |
$db_record = self::get_admin_notice_cache( $option_name ); |
| 262 |
|
| 263 |
if ( 'forever' === $db_record ) { |
| 264 |
return false; |
| 265 |
} elseif ( absint( $db_record ) >= time() ) { |
| 266 |
return false; |
| 267 |
} else { |
| 268 |
return true; |
| 269 |
} |
| 270 |
|
| 271 |
} |
| 272 |
|
| 273 |
public static function get_admin_notice_cache( $id = false ) |
| 274 |
{ |
| 275 |
if ( !$id ) { |
| 276 |
return false; |
| 277 |
} |
| 278 |
$cache_key = 'wp-adminify-notice-' . md5( $id ); |
| 279 |
$timeout = get_site_option( $cache_key ); |
| 280 |
$timeout = ( 'forever' === $timeout ? time() + 45 : $timeout ); |
| 281 |
if ( empty($timeout) || time() > $timeout ) { |
| 282 |
return false; |
| 283 |
} |
| 284 |
return $timeout; |
| 285 |
} |
| 286 |
|
| 287 |
public function jltwp_adminify_admin_notice_styles() |
| 288 |
{ |
| 289 |
$jltwp_adminify_promo_css = ''; |
| 290 |
$jltwp_adminify_promo_css .= '.wp-adminify-review-notice .notice-dismiss{padding:0 0 0 26px}.wp-adminify-notice .adminify-update-head{margin:0}.wp-adminify-notice .adminify-update-head span{font-size:.9em}.wp-adminify-notice .adminify-changes-list{padding-left:.5em}.wp-adminify-review-notice .notice-dismiss:before{display:none}.wp-adminify-review-notice.wp-adminify-review-notice{background-color:#fff;border-radius:3px;border-left:4px solid transparent;display:flex;align-items:center;padding:10px 10px 10px 0}.wp-adminify-review-notice .wp-adminify-review-thumbnail{width:160px;float:left;margin-right:20px;padding-top:20px;text-align:center;border-right:4px solid transparent}.wp-adminify-review-notice .wp-adminify-review-thumbnail img{vertical-align:middle}.wp-adminify-review-notice .wp-adminify-review-text{flex:0 0 1;overflow:hidden}.wp-adminify-review-notice .wp-adminify-review-text h3{font-size:24px;margin:0 0 5px;font-weight:400;line-height:1.3}.wp-adminify-review-notice .wp-adminify-review-text p{margin:0 0 5px}.wp-adminify-review-notice .wp-adminify-review-ul{margin:5px 0 0;padding:0}.wp-adminify-review-notice .wp-adminify-review-ul li{display:inline-block;margin:5px 15px 0 0}.wp-adminify-review-notice .wp-adminify-review-ul li a{display:inline-block;color:#4b00e7;text-decoration:none;padding-top:10px;position:relative}.wp-adminify-review-notice .wp-adminify-review-ul li a:not(.notice-dismiss) span.dashicons{font-size:17px;float:left;height:auto;width:auto;margin-right:3px}.wp-adminify #wpbody-content .wp-adminify-notice.adminify-review-notice-banner{background-color:#0347ff;border-left:0;padding-right:.5rem}.wp-adminify #wpbody-content .adminify-review-notice-banner .wp-adminify-notice-banner{-webkit-box-flex:0;-webkit-flex:0 0 100%;-ms-flex:0 0 100%;flex:0 0 100%}.wp-adminify-notice-banner .columns{margin-top:-2em!important;margin-bottom:-2em!important}.wp-adminify #wpbody-content .adminify-review-notice-banner .wp-adminify-review-notice{background-color:transparent;font-size:15px}.wp-adminify #wpbody-content .adminify-review-notice-banner #wp-adminify-bfcm-upgrade-notice p{color:#fff;font-size:15px}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-left-nav{margin:0}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-left-nav li{margin-bottom:5px}.wp-adminify #wpbody-content .adminify-review-notice-banner #wp-adminify-bfcm-upgrade-notice .adminify-notice-left-nav a{color:#fff}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-left-nav a i{background-color:#fff;color:#0347ff;font-size:20px;height:26px;width:26px;line-height:26px}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-middle .upgrade-btn{background-color:#fff;border:1px solid #fff;color:#0347ff;font-size:16px;font-weight:800;border-radius:8px}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-middle .upgrade-btn:hover{border:1px solid #fff!important;background:#0347ff!important;color:#fff!important}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-middle .upgrade-btn:focus{background-color:#fff}.adminify-review-notice-banner .adminify-logo{display:flex;margin:0 auto 1rem;max-width:135px}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-social-icon i{background-color:#fff;height:40px;width:40px;line-height:40px;margin:3px}.adminify-review-notice-banner .adminify-logo{max-width:135px}.wp-adminify #wpbody-content .adminify-review-notice-banner #wp-adminify-bfcm-upgrade-notice .adminify-rate-contents,.wp-adminify #wpbody-content .adminify-review-notice-banner #wp-adminify-bfcm-upgrade-notice .adminify-rate-contents a{color:#fff}.wp-adminify .adminify-review-notice-banner .adminify-rating{direction:rtl}.wp-adminify .adminify-review-notice-banner .adminify-rating label{font-size:0;line-height:0}.wp-adminify .adminify-review-notice-banner .adminify-rate-contents i{font-size:14px;height:auto;width:auto;line-height:0;vertical-align:middle}.adminify-rating input{display:none!important}.adminify-rating:hover span i:before{content:"\\f154"}.adminify-rating span:hover i:before,.adminify-rating span:hover~span i:before{content:"\\f155"}.wp-adminify #wpbody-content .adminify-review-notice-banner .notice-dismiss{border-color:#fff}.wp-adminify #wpbody-content .adminify-review-notice-banner .notice-dismiss:before{color:#fff}.wp-adminify #wpbody-content .adminify-review-notice-banner .adminify-notice-middle .adminify-sure-do-btn:hover{background-color:#00d1b2!important;border-color:transparent!important}'; |
| 291 |
$jltwp_adminify_promo_css = preg_replace( '#/\\*.*?\\*/#s', '', $jltwp_adminify_promo_css ); |
| 292 |
$jltwp_adminify_promo_css = preg_replace( '/\\s*([{}|:;,])\\s+/', '$1', $jltwp_adminify_promo_css ); |
| 293 |
$jltwp_adminify_promo_css = preg_replace( '/\\s\\s+(.*)/', '$1', $jltwp_adminify_promo_css ); |
| 294 |
|
| 295 |
if ( !empty($this->options['admin_ui']) ) { |
| 296 |
wp_add_inline_style( 'wp-adminify-admin', wp_strip_all_tags( $jltwp_adminify_promo_css ) ); |
| 297 |
} else { |
| 298 |
wp_add_inline_style( 'wp-adminify-default-ui', wp_strip_all_tags( $jltwp_adminify_promo_css ) ); |
| 299 |
} |
| 300 |
|
| 301 |
} |
| 302 |
|
| 303 |
public function jltwp_adminify_get_total_interval( $interval, $type ) |
| 304 |
{ |
| 305 |
switch ( $type ) { |
| 306 |
case 'years': |
| 307 |
return $interval->format( '%Y' ); |
| 308 |
break; |
| 309 |
case 'months': |
| 310 |
$years = $interval->format( '%Y' ); |
| 311 |
$months = 0; |
| 312 |
if ( $years ) { |
| 313 |
$months += $years * 12; |
| 314 |
} |
| 315 |
$months += $interval->format( '%m' ); |
| 316 |
return $months; |
| 317 |
break; |
| 318 |
case 'days': |
| 319 |
return $interval->format( '%a' ); |
| 320 |
break; |
| 321 |
case 'hours': |
| 322 |
$days = $interval->format( '%a' ); |
| 323 |
$hours = 0; |
| 324 |
if ( $days ) { |
| 325 |
$hours += 24 * $days; |
| 326 |
} |
| 327 |
$hours += $interval->format( '%H' ); |
| 328 |
return $hours; |
| 329 |
break; |
| 330 |
case 'minutes': |
| 331 |
$days = $interval->format( '%a' ); |
| 332 |
$minutes = 0; |
| 333 |
if ( $days ) { |
| 334 |
$minutes += 24 * 60 * $days; |
| 335 |
} |
| 336 |
$hours = $interval->format( '%H' ); |
| 337 |
if ( $hours ) { |
| 338 |
$minutes += 60 * $hours; |
| 339 |
} |
| 340 |
$minutes += $interval->format( '%i' ); |
| 341 |
return $minutes; |
| 342 |
break; |
| 343 |
case 'seconds': |
| 344 |
$days = $interval->format( '%a' ); |
| 345 |
$seconds = 0; |
| 346 |
if ( $days ) { |
| 347 |
$seconds += 24 * 60 * 60 * $days; |
| 348 |
} |
| 349 |
$hours = $interval->format( '%H' ); |
| 350 |
if ( $hours ) { |
| 351 |
$seconds += 60 * 60 * $hours; |
| 352 |
} |
| 353 |
$minutes = $interval->format( '%i' ); |
| 354 |
if ( $minutes ) { |
| 355 |
$seconds += 60 * $minutes; |
| 356 |
} |
| 357 |
$seconds += $interval->format( '%s' ); |
| 358 |
return $seconds; |
| 359 |
break; |
| 360 |
case 'milliseconds': |
| 361 |
$days = $interval->format( '%a' ); |
| 362 |
$seconds = 0; |
| 363 |
if ( $days ) { |
| 364 |
$seconds += 24 * 60 * 60 * $days; |
| 365 |
} |
| 366 |
$hours = $interval->format( '%H' ); |
| 367 |
if ( $hours ) { |
| 368 |
$seconds += 60 * 60 * $hours; |
| 369 |
} |
| 370 |
$minutes = $interval->format( '%i' ); |
| 371 |
if ( $minutes ) { |
| 372 |
$seconds += 60 * $minutes; |
| 373 |
} |
| 374 |
$seconds += $interval->format( '%s' ); |
| 375 |
$milliseconds = $seconds * 1000; |
| 376 |
return $milliseconds; |
| 377 |
break; |
| 378 |
default: |
| 379 |
return NULL; |
| 380 |
} |
| 381 |
} |
| 382 |
|
| 383 |
public function jltwp_adminify_days_differences() |
| 384 |
{ |
| 385 |
$install_date = get_option( 'jltwp_adminify_activation_time' ); |
| 386 |
// $install_date = strtotime('2021-02-11 14:39:05'); // Testing datetime |
| 387 |
$jltwp_adminify_datetime1 = \DateTime::createFromFormat( 'U', $install_date ); |
| 388 |
$jltwp_adminify_datetime2 = \DateTime::createFromFormat( 'U', strtotime( "now" ) ); |
| 389 |
$interval = $jltwp_adminify_datetime2->diff( $jltwp_adminify_datetime1 ); |
| 390 |
$jltwp_adminify_days_diff = $this->jltwp_adminify_get_total_interval( $interval, 'days' ); |
| 391 |
return $jltwp_adminify_days_diff; |
| 392 |
} |
| 393 |
|
| 394 |
public function jltwp_adminify_review_notice_generator() |
| 395 |
{ |
| 396 |
$jltwp_adminify_seven_day_notice = $this->jltwp_adminify_days_differences(); |
| 397 |
$diff_modulas = $jltwp_adminify_seven_day_notice % 15; |
| 398 |
if ( $jltwp_adminify_seven_day_notice <= 7 ) { |
| 399 |
return; |
| 400 |
} |
| 401 |
|
| 402 |
if ( $jltwp_adminify_seven_day_notice < 15 && ($diff_modulas >= 8 && $diff_modulas <= 12) ) { |
| 403 |
$this->jltwp_adminify_admin_notice_ask_for_review( 'jltma-nine-to-twelve' ); |
| 404 |
return; |
| 405 |
} |
| 406 |
|
| 407 |
} |
| 408 |
|
| 409 |
public function jltwp_adminify_upgrade_pro_notice_generator() |
| 410 |
{ |
| 411 |
$jltwp_adminify_seven_day_notice = $this->jltwp_adminify_days_differences(); |
| 412 |
$diff_modulas = $jltwp_adminify_seven_day_notice % 15; |
| 413 |
if ( $jltwp_adminify_seven_day_notice <= 7 ) { |
| 414 |
return; |
| 415 |
} |
| 416 |
|
| 417 |
if ( $jltwp_adminify_seven_day_notice < 15 && $diff_modulas >= 13 ) { |
| 418 |
$this->jltwp_adminify_admin_upgrade_pro_notice( 'jltma-after-thirteen' ); |
| 419 |
return; |
| 420 |
} |
| 421 |
|
| 422 |
if ( $jltwp_adminify_seven_day_notice >= 15 && $diff_modulas >= 5 && $diff_modulas < 11 ) { |
| 423 |
$this->jltwp_adminify_admin_upgrade_pro_notice( 'jltma-five-to-eleventh' ); |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
public function jltwp_adminify_black_friday_cyber_monday_deals() |
| 428 |
{ |
| 429 |
$today = date( "Y-m-d" ); |
| 430 |
$start_date = '2021-11-20'; |
| 431 |
$expire_date = '2021-12-30'; |
| 432 |
$today_time = strtotime( $today ); |
| 433 |
$start_time = strtotime( $start_date ); |
| 434 |
$expire_time = strtotime( $expire_date ); |
| 435 |
if ( $today_time >= $start_time && $today_time <= $expire_time ) { |
| 436 |
$this->jltwp_adminify_admin_black_friday_cyber_monday_notice( 'wp-adminify-bfcm-2021' ); |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
} |