| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/url-shortify/lite/includes/ |
Upload File : |
<?php
namespace Kaizen_Coders\Url_Shortify;
/**
* Class Promo
*
* Handle Promotional Campaign
*
* @package Kaizen_Coders\Url_Shortify
*
* @since 1.5.12.2
*/
class Promo {
/**
* Initialize Promotions
*
* @since 1.5.12.2
*/
public function init() {
add_action( 'admin_init', array( $this, 'dismiss_promotions' ) );
add_action( 'admin_notices', array( $this, 'handle_promotions' ) );
}
/**
* Get Valid Promotions.
*
* @return string[]
*
* @since 1.5.12.2
*/
public function get_valid_promotions() {
return array(
'initial_upgrade',
'welcome_offer',
'anniversary_offer',
'jully_2022_month_end_promotion',
'august_2023_promotion',
);
}
/**
* Dismiss Promotions.
*
* @since 1.5.12.2
*/
public function dismiss_promotions() {
if ( isset( $_GET['kc_us_dismiss_admin_notice'] ) && $_GET['kc_us_dismiss_admin_notice'] == '1' && isset( $_GET['option_name'] ) ) {
$option_name = sanitize_text_field( $_GET['option_name'] );
$valid_options = $this->get_valid_promotions();
if ( in_array( $option_name, $valid_options ) ) {
update_option( 'kc_us_' . $option_name . '_dismissed', 'yes', false );
if ( in_array( $option_name, $valid_options ) ) {
if ( 'lifetime' === sanitize_text_field( $_GET['billing_cycle'] ) ) {
wp_safe_redirect( US()->get_pricing_url( 'lifetime' ) );
} elseif ( true == $_GET['landing'] ) {
wp_safe_redirect( US()->get_landing_page_url() );
} else {
wp_safe_redirect( US()->get_pricing_url() );
}
} else {
$referer = wp_get_referer();
wp_safe_redirect( $referer );
}
exit();
}
}
}
/**
* Handle promotions activity.
*
* @since 1.5.12.2
*/
public function handle_promotions() {
if ( ! US()->is_pro() ) {
$august_2023_promotion = array(
'start_date' => '2023-08-20',
'end_date' => '2023-09-02',
'total_links' => 1,
'start_after_installation_days' => 2,
'pricing_url' => US()->get_pricing_url( 'lifetime' ),
'promotion' => 'august_2023_promotion',
'message' => __( 'Upgrade to URL Shortify PRO at an unbeatable price of <s class="text-2xl">$199</s> <b class="text-3xl">$79</b> till 31st August.', 'url-shortify' ),
'coupon_message' => sprintf( __( 'Use coupon code <b class="text-green-800 px-1 py-1 text-xl">%s</b> to get flat <b class="text-xl">%s</b> off on single-site lifetime license.', 'url-shortify' ), 'LIFETIME', '$120' ),
);
$month_end_sale_data = array(
'start_date' => '2022-07-26',
'end_date' => '2022-08-02',
'total_links' => 1,
'start_after_installation_days' => 2,
'promotion' => 'jully_2022_month_end_promotion',
'message' => __('Your plugin plan is limited to 1 week of historical data. Upgrade your plan to see all historical data.', 'url-shortify'),
'coupon_message' => sprintf( __( 'Use coupon code <b class="text-green-800 px-1 py-1 text-xl">%s</b> to get flat <b class="text-2xl">$30</b> off on any plan', 'url-shortify' ), 'WELCOME30' ),
);
$initial_upgrade_banner_data = array(
'message' => __( 'Your plugin plan is limited to 1 week of historical data. Upgrade your plan to see all historical data.', 'url-shortify' ),
'total_links' => 3,
'start_after_installation_days' => 9,
'end_before_installation_days' => 15,
);
$welcome_offer_data = array(
'total_links' => 3,
'start_after_installation_days' => 18,
'end_before_installation_days' => 27,
'promotion' => 'welcome_offer',
'message' => __( 'Your plugin plan is limited to 1 week of historical data. Upgrade your plan to see all historical data.', 'url-shortify' ),
'coupon_message' => sprintf( __( 'Use coupon code <b class="text-green-800 px-1 py-1 text-xl">%s</b> to get flat <b class="text-2xl">$30</b> off on any plan', 'url-shortify' ), 'WELCOME30' )
);
$regular_upgrade_banner_data = array(
'message' => __( 'Unlock the Full Power of Historical Data with an Upgraded Plugin Plan! Upgrade Today to Access All Historical Data.', 'url-shortify' ),
'total_links' => 2,
);
// Promotion.
if ( Helper::can_show_promotion( $august_2023_promotion ) ) {
$this->show_promotion( 'august_2023_promotion', $august_2023_promotion );
} else if ( Helper::can_show_promotion( $month_end_sale_data ) ) {
$this->show_promotion( 'month_end_sale', $month_end_sale_data );
} else if ( Helper::can_show_promotion( $initial_upgrade_banner_data ) ) {
$this->show_promotion( 'initial_upgrade', $initial_upgrade_banner_data );
} else if ( Helper::can_show_promotion( $welcome_offer_data ) ) {
$this->show_promotion( 'welcome_offer', $welcome_offer_data );
} else {
$this->show_promotion( 'regular_upgrade_banner', $regular_upgrade_banner_data );
}
}
}
/**
* Show Promotion.
*
* @param $promotion string
*
* @param $data array
* @since 1.5.12.2
*/
public function show_promotion( $promotion, $data ) {
$current_screen_id = Helper::get_current_screen_id();
if ( in_array($promotion, array('initial_upgrade', 'regular_upgrade_banner')) && Helper::is_plugin_admin_screen( $current_screen_id ) ) {
$action = Helper::get_data( $_GET, 'action' );
if ( 'statistics' === $action ) {
?>
<div class="wrap">
<?php Helper::get_upgrade_banner(null, null, $data); ?>
</div>
<?php
}
} else {
$query_strings = array(
'kc_us_dismiss_admin_notice' => 1,
'option_name' => $promotion
);
?>
<div class="wrap">
<?php Helper::get_upgrade_banner( $query_strings, true, $data ); ?>
</div>
<?php
}
}
/**
* Is Promo displayed and dismissed by user?
*
* @param $promo
*
* @return bool
*
* @since 1.5.12.2
*/
public function is_promotion_dismissed($promotion) {
if(empty($promotion)) {
return false;
}
$promotion_dismissed_option = 'kc_us_' . trim($promotion) . '_dismissed';
return 'yes' === get_option($promotion_dismissed_option);
}
}