| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Classes\Notifications; | |
| 3 | +namespace WPAdminify\Inc\Classes\Notifications; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Classes\Notifications\Base\Date; | |
| 6 | -use PXLBSAdminify\Inc\Classes\Helper; | |
| 5 | +use WPAdminify\Inc\Classes\Notifications\Base\Date; | |
| 6 | +use WPAdminify\Inc\Classes\Helper; | |
| 7 | 7 | // No, Direct access Sir !!! |
| 8 | 8 | if ( !defined( 'ABSPATH' ) ) { |
| 9 | 9 | exit; |
| 10 | 10 | } |
| @@ -25,23 +25,18 @@ | ||
| 25 | 25 | * Construction method |
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | 28 | $this->manager = new Manager(); |
| 29 | - $this->slug = Helper::slug_cleanup(); | |
| 29 | + $this->slug = Helper::jltwp_adminify_slug_cleanup(); | |
| 30 | 30 | add_action( 'admin_print_scripts', array($this, 'init_notifications'), 99999999 ); |
| 31 | 31 | add_action( |
| 32 | - 'pxlbsadminify_display_notice', | |
| 32 | + 'jltwp_adminify_display_notice', | |
| 33 | 33 | array($this, 'display_notice'), |
| 34 | 34 | 10, |
| 35 | 35 | 2 |
| 36 | 36 | ); |
| 37 | - add_action( | |
| 38 | - 'pxlbsadminify_display_popup', | |
| 39 | - array($this, 'display_popup'), | |
| 40 | - 10, | |
| 41 | - 2 | |
| 42 | - ); | |
| 43 | - add_action( 'wp_ajax_pxlbsadminify_notification_action', array($this, 'pxlbsadminify_notification_action') ); | |
| 37 | + // add_action('jltwp_adminify_display_popup', array($this, 'display_popup'), 10, 2); | |
| 38 | + add_action( 'wp_ajax_jltwp_adminify_notification_action', array($this, 'notification_action') ); | |
| 44 | 39 | } |
| 45 | 40 | |
| 46 | 41 | /** |
| 47 | 42 | * Notification Action |
| @@ -47,10 +42,10 @@ | ||
| 47 | 42 | * Notification Action |
| 48 | 43 | * |
| 49 | 44 | * @author Jewel Theme <support@jeweltheme.com> |
| 50 | 45 | */ |
| 51 | - public function pxlbsadminify_notification_action() { | |
| 52 | - check_ajax_referer( 'pxlbsadminify_notification_nonce' ); | |
| 46 | + public function notification_action() { | |
| 47 | + check_ajax_referer( 'jltwp_adminify_notification_nonce' ); | |
| 53 | 48 | // Security check - only administrators can manage notifications |
| 54 | 49 | if ( !current_user_can( 'manage_options' ) ) { |
| 55 | 50 | wp_send_json_error( array( |
| 56 | 51 | 'message' => __( 'You do not have permission to perform this action.', 'adminify' ), |
| @@ -71,9 +66,9 @@ | ||
| 71 | 66 | $notification->is_active = false; |
| 72 | 67 | } |
| 73 | 68 | $notification->fire( $trigger_time, $notification_type )->save(); |
| 74 | 69 | } else { |
| 75 | - $count++; | |
| 70 | + ++$count; | |
| 76 | 71 | $notification->maybe_delay( $this->date_increment( $trigger_time, $this->conflict_days * $count ) )->save(); |
| 77 | 72 | } |
| 78 | 73 | } |
| 79 | 74 | die( 0 ); |
| @@ -89,9 +84,9 @@ | ||
| 89 | 84 | public function setup_notifications_by_type( $type ) { |
| 90 | 85 | // $trigger_time should be today . |
| 91 | 86 | $trigger_time = $this->current_time(); |
| 92 | 87 | // Block if necessary . |
| 93 | - $notification_last_fired = get_option( "pxlbsadminify_{$type}_last_interact" ); | |
| 88 | + $notification_last_fired = get_option( "jltwp_adminify_{$type}_last_interact" ); | |
| 94 | 89 | if ( $notification_last_fired ) { |
| 95 | 90 | $notification_enable_date = $this->date_increment( $notification_last_fired, $this->conflict_days ); |
| 96 | 91 | if ( $this->date_is_prev( $trigger_time, $notification_enable_date ) ) { |
| 97 | 92 | return; |
| @@ -103,9 +98,9 @@ | ||
| 103 | 98 | if ( empty( $exec_notifications ) ) { |
| 104 | 99 | return; |
| 105 | 100 | } |
| 106 | 101 | $notification = $exec_notifications[0]; |
| 107 | - do_action( "pxlbsadminify_display_{$type}", $notification, $trigger_time ); | |
| 102 | + do_action( "jltwp_adminify_display_{$type}", $notification, $trigger_time ); | |
| 108 | 103 | } |
| 109 | 104 | |
| 110 | 105 | /** |
| 111 | 106 | * Notification initialization |
| @@ -152,13 +147,13 @@ | ||
| 152 | 147 | * @return void |
| 153 | 148 | * @author Jewel Theme <support@jeweltheme.com> |
| 154 | 149 | */ |
| 155 | 150 | public function display_popup( $popup, $trigger_time ) { |
| 156 | - $screen = get_current_screen(); | |
| 157 | - if ( !in_array( $screen->id, ['toplevel_page_wp-adminify-settings', 'dashboard'] ) ) { | |
| 151 | + if ( 'FALSE' === $this->get_content( 'is_campaign' ) ) { | |
| 158 | 152 | return; |
| 159 | 153 | } |
| 160 | 154 | $image_url = $popup->get_content( 'image_url' ); |
| 155 | + $notice = ( !empty( $popup->get_content( 'notice' ) ) ? $popup->get_content( 'notice' ) : '' ); | |
| 161 | 156 | ?> |
| 162 | 157 | |
| 163 | 158 | <div class="wp-adminify-popup" id="wp-adminify-popup" data-plugin="<?php |
| 164 | 159 | echo esc_attr( $this->slug ); |
| @@ -179,8 +174,23 @@ | ||
| 179 | 174 | <div class="wp-adminify-popup-modal-footer"> |
| 180 | 175 | |
| 181 | 176 | <!-- countdown --> |
| 182 | 177 | <div class="wp-adminify-popup-countdown" style="display: none;"> |
| 178 | + | |
| 179 | + <?php | |
| 180 | + if ( $notice ) { | |
| 181 | + ?> | |
| 182 | + <span data-counter="notice" style="color:#F4B740; font-size:14px; padding-bottom:20px; font-style:italic;"> | |
| 183 | + <?php | |
| 184 | + echo esc_html__( 'Notice:', 'adminify' ); | |
| 185 | + ?> <?php | |
| 186 | + echo esc_html( $notice ); | |
| 187 | + ?> | |
| 188 | + </span> | |
| 189 | + <?php | |
| 190 | + } | |
| 191 | + ?> | |
| 192 | + | |
| 183 | 193 | <span class="wp-adminify-popup-countdown-text"><?php |
| 184 | 194 | echo esc_html__( 'Deal Ends In', 'adminify' ); |
| 185 | 195 | ?></span> |
| 186 | 196 | <div class="wp-adminify-popup-countdown-time"> |
| @@ -214,9 +224,9 @@ | ||
| 214 | 224 | </div> |
| 215 | 225 | </div> |
| 216 | 226 | |
| 217 | 227 | <!-- button --> |
| 218 | - <a class="wp-adminify-popup-button" style="color: #fff !important" target="_blank" href="<?php | |
| 228 | + <a class="wp-adminify-popup-button" target="_blank" href="<?php | |
| 219 | 229 | echo esc_url( $popup->get_content( 'button_url' ) ); |
| 220 | 230 | ?>"> |
| 221 | 231 | <?php |
| 222 | 232 | if ( jltwp_adminify()->can_use_premium_code() ) { |
| @@ -230,9 +240,9 @@ | ||
| 230 | 240 | </div> |
| 231 | 241 | </div> |
| 232 | 242 | |
| 233 | 243 | <script> |
| 234 | - function pxlbsadminify_popup_action(evt, $this, $action_type) { | |
| 244 | + function jltwp_adminify_popup_action(evt, $this, $action_type) { | |
| 235 | 245 | |
| 236 | 246 | evt.preventDefault(); |
| 237 | 247 | |
| 238 | 248 | $this.closest('.wp-adminify-popup').fadeOut(200); |
| @@ -239,11 +249,11 @@ | ||
| 239 | 249 | |
| 240 | 250 | jQuery.post('<?php |
| 241 | 251 | echo esc_url( admin_url( 'admin-ajax.php' ) ); |
| 242 | 252 | ?>', { |
| 243 | - action: 'pxlbsadminify_notification_action', | |
| 253 | + action: 'jltwp_adminify_notification_action', | |
| 244 | 254 | _wpnonce: '<?php |
| 245 | - echo esc_js( wp_create_nonce( 'pxlbsadminify_notification_nonce' ) ); | |
| 255 | + echo esc_js( wp_create_nonce( 'jltwp_adminify_notification_nonce' ) ); | |
| 246 | 256 | ?>', |
| 247 | 257 | action_type: $action_type, |
| 248 | 258 | notification_type: 'popup', |
| 249 | 259 | trigger_time: '<?php |
| @@ -253,17 +263,17 @@ | ||
| 253 | 263 | } |
| 254 | 264 | |
| 255 | 265 | // Notice Dismiss |
| 256 | 266 | jQuery('body').on('click', '.wp-adminify-popup .popup-dismiss', function(evt) { |
| 257 | - pxlbsadminify_popup_action(evt, jQuery(this), 'dismiss'); | |
| 267 | + jltwp_adminify_popup_action(evt, jQuery(this), 'dismiss'); | |
| 258 | 268 | }); |
| 259 | 269 | |
| 260 | 270 | // Notice Disable |
| 261 | 271 | jQuery('body').on('click', '.wp-adminify-popup .popup-disable', function(evt) { |
| 262 | - pxlbsadminify_popup_action(evt, jQuery(this), 'disable'); | |
| 272 | + jltwp_adminify_popup_action(evt, jQuery(this), 'disable'); | |
| 263 | 273 | }); |
| 264 | 274 | </script> |
| 265 | 275 | |
| 266 | - <?php | |
| 276 | +<?php | |
| 267 | 277 | } |
| 268 | 278 | |
| 269 | 279 | } |