PluginProbe
Search & Replace Everything – Quick and Easy Way to Find and Replace Text, Links / trunk
Search & Replace Everything – Quick and Easy Way to Find and Replace Text, Links vtrunk
1.5.2 1.5.0 1.5.1 1.4.7 1.4.6 1.4.4 1.4.5 1.4.3 trunk 1.0.2 1.0.3 1.0.4 1.0.4.1 1.1 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.2 1.2.3 1.2.4 1.2.5 All 34 releases
update-urls / lite / includes / Promo.php

Promo.php in Search & Replace Everything – Quick and Easy Way to Find and Replace Text, Links trunk, at lite/includes/Promo.php

157 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace KaizenCoders\UpdateURLS;
4
5 /**
6 * Class Promo
7 *
8 * Handle Promotional Campaign
9 *
10 * @since 1.8.0
11 * @package KaizenCoders\URL_Shortify
12 *
13 */
14 class Promo {
15 /**
16 * Initialize Promotions
17 *
18 * @since 1.8.0
19 */
20 public function init() {
21 add_action( 'admin_init', [ $this, 'dismiss_promotions' ] );
22 add_action( 'admin_notices', [ $this, 'handle_promotions' ] );
23 }
24
25 /**
26 * Get Valid Promotions.
27 *
28 * @return string[]
29 *
30 * @since 1.5.12.2
31 */
32 public function get_valid_promotions() {
33 return [
34 'price_increase_notification',
35 'magic_link_launch_offer',
36 'pre_launch_offer',
37 'major_upgrade_pro',
38 'off_50',
39 ];
40 }
41
42 /**
43 * Dismiss Promotions.
44 *
45 * @since 1.5.12.2
46 */
47 public function dismiss_promotions() {
48 if ( isset( $_GET['kc_uu_dismiss_admin_notice'] ) && $_GET['kc_uu_dismiss_admin_notice'] == '1' && isset( $_GET['option_name'] ) ) {
49 $option_name = sanitize_text_field( $_GET['option_name'] );
50
51 $valid_options = $this->get_valid_promotions();
52
53 if ( in_array( $option_name, $valid_options ) ) {
54 update_option( 'kc_uu_' . $option_name . '_dismissed', 'yes', false );
55
56 if ( isset( $_GET['redirect_to'] ) && ! empty( $_GET['redirect_to'] ) ) {
57 $redirect_to = esc_url_raw( $_GET['redirect_to'] );
58 wp_redirect( $redirect_to );
59 } else {
60 $referer = wp_get_referer();
61 wp_safe_redirect( $referer );
62 }
63
64 exit();
65 }
66 }
67 }
68
69 /**
70 * Handle promotions activity.
71 *
72 * @since 1.4.2
73 */
74 public function handle_promotions() {
75 $off_50 = [
76 'title' => "<b class='text-red-600 text-xl'>Get 50% Off</b>",
77 'start_date' => '2026-07-09',
78 'end_date' => '2026-07-16',
79 'start_after_installation_days' => 0,
80 'pricing_url' => 'https://kaizencoders.com/update-urls/#pricing?utm_source=update-urls-in-app&utm_medium=banner&utm_campaign=july-2026-offer',
81 'promotion' => 'off_50',
82 'message' => __( '<p class="text-xl">Get Dry-Run, One Click Export/Import Database, History and much more at flat 50% OFF until <b class="text-red-600 text-xl">July 15, 2026</b></p>', 'update-urls' ),
83 'coupon_message' => '<p class="text-xl">Use Coupon Code - <b class="text-red-600">SPECIAL50</b></p>',
84 'check_plan' => 'free',
85 ];
86
87 // Promotion.
88 if ( Helper::can_show_promotion( $off_50 ) ) {
89 $this->show_promotion( 'off_50', $off_50 );
90 }
91 }
92
93 /**
94 * Show Promotion.
95 *
96 * @param $data array
97 * @param $promotion string
98 *
99 * @since 1.5.12.2
100 *
101 */
102 public function show_promotion( $promotion, $data ) {
103 $current_screen_id = Helper::get_current_screen_id();
104
105 if ( in_array( $promotion, [
106 'initial_upgrade',
107 'regular_upgrade_banner',
108 ] ) && Helper::is_plugin_admin_screen( $current_screen_id ) ) {
109 $action = Helper::get_data( $_GET, 'action' );
110 if ( 'statistics' === $action ) {
111 ?>
112 <div class="wrap">
113 <?php
114 Helper::get_upgrade_banner( null, null, $data ); ?>
115 </div>
116 <?php
117 }
118 } else {
119 $query_strings = [
120 'kc_uu_dismiss_admin_notice' => 1,
121 'option_name' => $promotion,
122 ];
123
124 if ( isset( $data['redirect_to'] ) && ! empty( $data['redirect_to'] ) ) {
125 $query_strings['redirect_to'] = esc_url( $data['redirect_to'] );
126 }
127 ?>
128
129 <div class="wrap">
130 <?php
131 Helper::get_upgrade_banner( $query_strings, true, $data ); ?>
132 </div>
133 <?php
134 }
135 }
136
137 /**
138 * Is Promo displayed and dismissed by user?
139 *
140 * @param $promo
141 *
142 * @return bool
143 *
144 * @since 1.5.12.2
145 *
146 */
147 public function is_promotion_dismissed( $promotion ) {
148 if ( empty( $promotion ) ) {
149 return false;
150 }
151
152 $promotion_dismissed_option = 'kc_us_' . trim( $promotion ) . '_dismissed';
153
154 return 'yes' === get_option( $promotion_dismissed_option );
155 }
156 }
157