PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.5.3
Order Tracking – WordPress Status Tracking Plugin v3.5.3
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / order-tracking.php

order-tracking.php in Order Tracking – WordPress Status Tracking Plugin 3.5.3, at order-tracking.php

636 lines 22.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Order Tracking - WordPress Status Tracking Plugin
4 Plugin URI: https://www.etoilewebdesign.com/order-tracking/
5 Description: Order tracking, status and project management plugin that lets you create tickets and tracking numbers and send email updates. Works standalone and with WooCommerce.
6 Author: Etoile Web Design
7 Author URI: https://www.etoilewebdesign.com/
8 Terms and Conditions: https://www.etoilewebdesign.com/plugin-terms-and-conditions/
9 Text Domain: order-tracking
10 Version: 3.5.3
11 WC requires at least: 7.1
12 WC tested up to: 10.9
13 */
14
15
16 if ( ! defined( 'ABSPATH' ) )
17 exit;
18
19 if ( ! class_exists( 'ewdotpInit' ) ) {
20 class ewdotpInit {
21
22 // pointers to classes used by the plugin, where needed
23 public $admin_customers;
24 public $admin_custom_fields;
25 public $admin_orders;
26 public $admin_sales_reps;
27 public $customer_manager;
28 public $exports;
29 public $order_manager;
30 public $permissions;
31 public $sales_rep_manager;
32 public $settings;
33 public $woocommerce;
34 public $zendesk ;
35
36 // Any data that needs to be passed from PHP to our JS files
37 public $front_end_php_js_data = array();
38
39 /**
40 * Initialize the plugin and register hooks
41 */
42 public function __construct() {
43
44 self::constants();
45 self::includes();
46 self::instantiate();
47 self::wp_hooks();
48 }
49
50 /**
51 * Define plugin constants.
52 *
53 * @since 3.0.0
54 * @access protected
55 * @return void
56 */
57 protected function constants() {
58
59 define( 'EWD_OTP_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
60 define( 'EWD_OTP_PLUGIN_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
61 define( 'EWD_OTP_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
62 define( 'EWD_OTP_TEMPLATE_DIR', 'ewd-otp-templates' );
63 define( 'EWD_OTP_VERSION', '3.5.3' );
64 }
65
66 /**
67 * Include necessary classes.
68 *
69 * @since 3.0.0
70 * @access protected
71 * @return void
72 */
73 protected function includes() {
74
75 require_once( EWD_OTP_PLUGIN_DIR . '/includes/AboutUs.class.php' );
76 require_once( EWD_OTP_PLUGIN_DIR . '/includes/AdminOrders.class.php' );
77 require_once( EWD_OTP_PLUGIN_DIR . '/includes/AdminCustomFields.class.php' );
78 require_once( EWD_OTP_PLUGIN_DIR . '/includes/AdminCustomers.class.php' );
79 require_once( EWD_OTP_PLUGIN_DIR . '/includes/AdminSalesReps.class.php' );
80 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Ajax.class.php' );
81 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Blocks.class.php' );
82 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Customer.class.php' );
83 require_once( EWD_OTP_PLUGIN_DIR . '/includes/CustomerManager.class.php' );
84 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Dashboard.class.php' );
85 require_once( EWD_OTP_PLUGIN_DIR . '/includes/DeactivationSurvey.class.php' );
86 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Export.class.php' );
87 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Helper.class.php' );
88 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Import.class.php' );
89 require_once( EWD_OTP_PLUGIN_DIR . '/includes/InstallationWalkthrough.class.php' );
90 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Notifications.class.php' );
91 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Order.class.php' );
92 require_once( EWD_OTP_PLUGIN_DIR . '/includes/OrderManager.class.php' );
93 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Permissions.class.php' );
94 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Phone.class.php' );
95 require_once( EWD_OTP_PLUGIN_DIR . '/includes/ReviewAsk.class.php' );
96 require_once( EWD_OTP_PLUGIN_DIR . '/includes/SalesRep.class.php' );
97 require_once( EWD_OTP_PLUGIN_DIR . '/includes/SalesRepManager.class.php' );
98 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Settings.class.php' );
99 require_once( EWD_OTP_PLUGIN_DIR . '/includes/template-functions.php' );
100 require_once( EWD_OTP_PLUGIN_DIR . '/includes/UltimateWPMail.class.php' );
101 require_once( EWD_OTP_PLUGIN_DIR . '/includes/WooCommerce.class.php' );
102 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Zendesk.class.php' );
103 }
104
105 /**
106 * Spin up instances of our plugin classes.
107 *
108 * @since 3.0.0
109 * @access protected
110 * @return void
111 */
112 protected function instantiate() {
113
114 new ewdotpDashboard();
115 new ewdotpDeactivationSurvey();
116 new ewdotpInstallationWalkthrough();
117 new ewdotpReviewAsk();
118
119 $this->admin_customers = new ewdotpAdminCustomers();
120 $this->admin_custom_fields = new ewdotpAdminCustomFields();
121 $this->admin_orders = new ewdotpAdminOrders();
122 $this->admin_sales_reps = new ewdotpAdminSalesReps();
123 $this->customer_manager = new ewdotpCustomerManager();
124 $this->exports = new ewdotpExport();
125 $this->order_manager = new ewdotpOrderManager();
126 $this->permissions = new ewdotpPermissions();
127 $this->sales_rep_manager = new ewdotpSalesRepManager();
128 $this->settings = new ewdotpSettings();
129
130 if ( $this->settings->get_setting( 'woocommerce-integration' ) ) {
131
132 $this->woocommerce = new ewdotpWooCommerce();
133 }
134
135 if ( $this->settings->get_setting( 'zendesk-integration' ) ) {
136
137 $this->zendesk = new ewdotpZendesk();
138 }
139
140 new ewdotpAJAX();
141 new ewdotpBlocks();
142 new ewdotpImport();
143 new ewdotpNotifications();
144 new ewdotpPhone();
145 new ewdotpUltimateWPMail();
146
147 new ewdotpAboutUs();
148 }
149
150 /**
151 * Run walk-through, load assets, add links to plugin listing, etc.
152 *
153 * @since 3.0.0
154 * @access protected
155 * @return void
156 */
157 protected function wp_hooks() {
158
159 register_activation_hook( __FILE__, array( $this, 'run_walkthrough' ) );
160 register_activation_hook( __FILE__, array( $this, 'convert_options' ) );
161 register_activation_hook( __FILE__, array( $this, 'create_default_statuses_and_emails' ) );
162 register_activation_hook( __FILE__, array( $this, 'create_tables' ) );
163
164 register_deactivation_hook( __FILE__, array( $this, 'revert_wc_statuses' ) );
165
166 add_action( 'init', array( $this, 'load_view_files' ) );
167
168 add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
169
170 add_action( 'admin_notices', array( $this, 'display_header_area' ), 99 );
171 add_action( 'admin_notices', array( $this, 'maybe_display_helper_notice' ) );
172 add_action( 'admin_notices', array( $this, 'maybe_display_new_plugin_notice' ) );
173
174 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ), 10, 1 );
175 add_action( 'admin_enqueue_scripts', array( $this, 'register_assets' ) );
176 add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
177 add_action( 'wp_head', 'ewd_add_frontend_ajax_url' );
178 add_action( 'wp_footer', array( $this, 'assets_footer' ), 2 );
179
180 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
181
182 add_action( 'wp_ajax_ewd_otp_hide_helper_notice', array( $this, 'hide_helper_notice' ) );
183 add_action( 'wp_ajax_ewd_otp_hide_new_plugin_notice', array( $this, 'hide_new_plugin_notice' ) );
184
185 add_action( 'upgrader_process_complete', array( $this, 'update_tables_post_plugin_update' ), 10, 2 );
186
187 add_action( 'before_woocommerce_init', array( $this, 'declare_wc_hpos' ) );
188 }
189
190 /**
191 * Run the options conversion function on update if necessary
192 *
193 * @since 3.0.0
194 * @access protected
195 * @return void
196 */
197 public function convert_options() {
198
199 require_once( EWD_OTP_PLUGIN_DIR . '/includes/BackwardsCompatibility.class.php' );
200 new ewdotpBackwardsCompatibility();
201 }
202
203 /**
204 * Run the default status and emails creation function if necessary
205 *
206 * @since 3.0.0
207 * @access protected
208 * @return void
209 */
210 public function create_default_statuses_and_emails() {
211
212 $this->settings->create_default_statuses_and_emails();
213 }
214
215 /**
216 * Creates the tables where orders and their meta information are stored
217 *
218 * @since 3.0.0
219 * @access protected
220 * @return void
221 */
222 public function create_tables() {
223
224 $this->customer_manager->create_tables();
225 $this->order_manager->create_tables();
226 $this->sales_rep_manager->create_tables();
227 }
228
229 /**
230 * Update the tables used by the plugin is updated, in case of any structure changes
231 *
232 * @since 3.2.1
233 * @access protected
234 * @return void
235 */
236 public function update_tables_post_plugin_update( $upgrader, $options ) {
237
238 if ( empty( $options['action'] ) or $options['action'] != 'update' ) { return; }
239
240 if ( empty( $options['type'] ) or $options['type'] != 'plugin' ) { return; }
241
242 foreach ( $options['plugins'] as $plugin ) {
243
244 if ( $plugin == EWD_OTP_PLUGIN_FNAME ) {
245
246 set_transient( 'ewd-otp-update-tables', true, 30 );
247
248 wp_remote_get( site_url() );
249 }
250 }
251 }
252
253 /**
254 * Load files needed for views
255 * @since 3.0.0
256 * @note Can be filtered to add new classes as needed
257 */
258 public function load_view_files() {
259
260 $files = array(
261 EWD_OTP_PLUGIN_DIR . '/views/Base.class.php' // This will load all default classes
262 );
263
264 $files = apply_filters( 'ewd_otp_load_view_files', $files );
265
266 foreach( $files as $file ) {
267 require_once( $file );
268 }
269
270 }
271
272 /**
273 * Load the plugin textdomain for localisation
274 * @since 3.0.0
275 */
276 public function load_textdomain() {
277
278 load_plugin_textdomain( 'order-tracking', false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
279 }
280
281 /**
282 * Set a transient so that the walk-through gets run
283 * @since 3.0.0
284 */
285 public function run_walkthrough() {
286
287 set_transient( 'ewd-otp-getting-started', true, 30 );
288 }
289
290 /**
291 * Returns WooCommerce orders to their default statuses, if required
292 * @since 3.0.0
293 */
294 public function revert_wc_statuses() {
295
296 require_once( EWD_OTP_PLUGIN_DIR . '/includes/WooCommerce.class.php' );
297 require_once( EWD_OTP_PLUGIN_DIR . '/includes/Settings.class.php' );
298
299 $settings = new ewdotpSettings();
300
301 if ( empty( $settings->get_setting( 'woocommerce-integration' ) ) ) { return; }
302
303 if ( ! empty( $settings->get_setting( 'disable-woocommerce-revert-statuses' ) ) ) { return; }
304
305 $woocommerce = new ewdotpWooCommerce();
306
307 $woocommerce->revert_statuses();
308 }
309
310 /**
311 * Enqueue the admin-only CSS and Javascript
312 * @since 3.0.0
313 */
314 public function enqueue_admin_assets( $hook ) {
315 global $post;
316
317 wp_enqueue_script( 'ewd-otp-helper-notice', EWD_OTP_PLUGIN_URL . '/assets/js/ewd-otp-helper-install-notice.js', array( 'jquery' ), EWD_OTP_VERSION, true );
318 wp_localize_script(
319 'ewd-otp-helper-notice',
320 'ewd_otp_helper_notice',
321 array( 'nonce' => wp_create_nonce( 'ewd-otp-helper-notice' ) )
322 );
323
324 wp_enqueue_style( 'ewd-otp-helper-notice', EWD_OTP_PLUGIN_URL . '/assets/css/ewd-otp-helper-install-notice.css', array(), EWD_OTP_VERSION );
325
326 $screen = get_current_screen();
327
328 $candidates = array(
329
330 'tracking_page_ewd-otp-dashboard',
331 'toplevel_page_ewd-otp-orders',
332 'tracking_page_ewd-otp-add-edit-order',
333 'tracking_page_ewd-otp-customers',
334 'tracking_page_ewd-otp-add-edit-customer',
335 'tracking_page_ewd-otp-sales-reps',
336 'tracking_page_ewd-otp-add-edit-sales-rep',
337 'toplevel_page_ewd-otp-sales-rep-orders',
338 'tracking_page_ewd-otp-import',
339 'tracking_page_ewd-otp-export',
340 'tracking_page_ewd-otp-custom-fields',
341 'tracking_page_ewd-otp-settings',
342 'tracking_page_ewd-otp-about-us',
343 );
344
345 // Return if not one of the OTP post types, we're not on a post-type page, or we're not on the settings or widget pages
346 if ( ! in_array( $hook, $candidates )
347 and ( empty( $screen->post_type ) or ! in_array ( $screen->post_type, $candidates ) )
348 and ! in_array( $screen->id, $candidates )
349 ) {
350 return;
351 }
352
353 wp_enqueue_style( 'ewd-otp-admin-css', EWD_OTP_PLUGIN_URL . '/assets/css/ewd-otp-admin.css', array(), EWD_OTP_VERSION );
354 wp_enqueue_script( 'ewd-otp-admin-js', EWD_OTP_PLUGIN_URL . '/assets/js/ewd-otp-admin.js', array( 'jquery' ), EWD_OTP_VERSION, true );
355
356 $args = array(
357 'nonce' => wp_create_nonce( 'ewd-otp-admin-js' )
358 );
359
360 wp_localize_script( 'ewd-otp-admin-js', 'ewd_otp_php_admin_data', $args );
361
362 if ( $screen->id == 'toplevel_page_ewd-otp-orders' ) {
363
364 wp_enqueue_style( 'sap-spectrium-css', EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/css/spectrum.css', array(), EWD_OTP_VERSION );
365 wp_enqueue_style( 'sap-admin-settings-css', EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/css/admin-settings.css', array(), EWD_OTP_VERSION );
366 wp_enqueue_script( 'sap-spectrum-js', EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/js/spectrum.js', array( 'jquery' ), EWD_OTP_VERSION, true );
367 wp_enqueue_script( 'sap-admin-settings-js', EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/js/admin-settings.js', array( 'jquery' ), EWD_OTP_VERSION, true );
368 }
369 }
370
371 /**
372 * Register the front-end CSS and Javascript for the FAQs
373 * @since 3.0.0
374 */
375 function register_assets() {
376 global $ewd_otp_controller;
377
378 wp_register_style( 'ewd-otp-css', EWD_OTP_PLUGIN_URL . '/assets/css/ewd-otp.css', EWD_OTP_VERSION );
379
380 wp_register_script( 'ewd-otp-js', EWD_OTP_PLUGIN_URL . '/assets/js/ewd-otp.js', array( 'jquery' ), EWD_OTP_VERSION, true );
381 }
382
383 /**
384 * Print out any PHP data needed for our JS to work correctly
385 * @since 3.1.0
386 */
387 public function assets_footer() {
388
389 if ( empty( $this->front_end_php_js_data ) ) { return; }
390
391 $print_variables = array();
392
393 foreach ( (array) $this->front_end_php_js_data as $variable => $values ) {
394
395 if ( empty( $values ) ) { continue; }
396
397 $print_variables[ $variable ] = ewdotpHelper::escape_js_recursive( $values );
398 }
399
400 foreach ( $print_variables as $variable => $values ) {
401
402 echo "<script type='text/javascript'>\n";
403 echo "/* <![CDATA[ */\n";
404 echo 'var ' . esc_attr( $variable ) . ' = ' . wp_json_encode( $values ) . "\n";
405 echo "/* ]]> */\n";
406 echo "</script>\n";
407 }
408 }
409
410 /**
411 * Adds a variable to be passed to our front-end JS
412 * @since 3.1.0
413 */
414 public function add_front_end_php_data( $handle, $variable, $data ) {
415
416 $this->front_end_php_js_data[ $variable ] = $data;
417 }
418
419 /**
420 * Returns the corresponding front-end JS variable if it exists, otherwise an empty array
421 * @since 3.1.0
422 */
423 public function get_front_end_php_data( $handle, $variable ) {
424
425 return ! empty( $this->front_end_php_js_data[ $variable ] ) ? $this->front_end_php_js_data[ $variable ] : array();
426 }
427
428 /**
429 * Add links to the plugin listing on the installed plugins page
430 * @since 3.0.0
431 */
432 public function plugin_action_links( $links, $plugin ) {
433 global $ewd_otp_controller;
434
435 if ( $plugin == EWD_OTP_PLUGIN_FNAME ) {
436
437 if ( ! $ewd_otp_controller->permissions->check_permission( 'premium' ) ) {
438
439 array_unshift( $links, '<a class="ewd-otp-plugin-page-upgrade-link" href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1&utm_source=wp_admin_plugins_page" title="' . __( 'Try Premium', 'order-tracking' ) . '" target="_blank">' . __( 'Try Premium', 'order-tracking' ) . '</a>' );
440 }
441
442 $links['settings'] = '<a href="admin.php?page=ewd-otp-settings" title="' . __( 'Head to the settings page for Order Tracking', 'order-tracking' ) . '">' . __( 'Settings', 'order-tracking' ) . '</a>';
443 }
444
445 return $links;
446
447 }
448
449
450
451 /**
452 * Adds in a menu bar for the plugin
453 * @since 3.0.0
454 */
455 public function display_header_area() {
456 global $ewd_otp_controller;
457
458 $screen = get_current_screen();
459
460 if ( empty( $screen->parent_file ) or $screen->parent_file != 'ewd-otp-orders' ) { return; }
461
462 if ( ! current_user_can( $ewd_otp_controller->settings->get_setting( 'access-role' ) ) ) { return; }
463
464 if ( ! $ewd_otp_controller->permissions->check_permission( 'styling' ) or get_option( 'EWD_OTP_Trial_Happening' ) == 'Yes' ) {
465 ?>
466 <div class="ewd-otp-dashboard-new-upgrade-banner">
467 <div class="ewd-otp-dashboard-banner-icon"></div>
468 <div class="ewd-otp-dashboard-banner-buttons">
469 <a class="ewd-otp-dashboard-new-upgrade-button" href="https://www.etoilewebdesign.com/license-payment/?Selected=OTP&Quantity=1&utm_source=otp_admin&utm_content=banner" target="_blank">UPGRADE NOW</a>
470 </div>
471 <div class="ewd-otp-dashboard-banner-text">
472 <div class="ewd-otp-dashboard-banner-title">
473 GET FULL ACCESS WITH OUR PREMIUM VERSION
474 </div>
475 <div class="ewd-otp-dashboard-banner-brief">
476 Includes locations, custom fields, a customer order form, advanced WooCommerce integration, advanced styling options and more!
477 </div>
478 </div>
479 </div>
480 <?php
481 }
482
483 ?>
484 <div class="ewd-otp-admin-header-menu">
485 <h2 class="nav-tab-wrapper">
486 <a id="ewd-otp-dash-mobile-menu-open" href="#" class="menu-tab nav-tab ewd-otp-hidden"><span class="dashicons dashicons-menu"></span><?php _e("Menu", 'order-tracking'); ?></a>
487 <a id="dashboard-menu" href='admin.php?page=ewd-otp-dashboard' class="menu-tab nav-tab <?php if ( $screen->id == 'tracking_page_ewd-otp-dashboard' ) {echo 'nav-tab-active';}?>"><?php _e("Dashboard", 'order-tracking'); ?></a>
488 <a id="orders-menu" href='admin.php?page=ewd-otp-orders' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_ewd-otp-orders' ) {echo 'nav-tab-active';}?>"><?php _e("Orders", 'order-tracking'); ?></a>
489 <a id="customers-menu" href='admin.php?page=ewd-otp-customers' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_ewd-otp-customers' ) {echo 'nav-tab-active';}?>"><?php _e("Customers", 'order-tracking'); ?></a>
490 <a id="sales-reps-menu" href='admin.php?page=ewd-otp-sales-reps' class="menu-tab nav-tab <?php if ( $screen->id == 'toplevel_page_ewd-otp-sales-reps' ) {echo 'nav-tab-active';}?>"><?php _e("Sales Reps", 'order-tracking'); ?></a>
491 <a id="export-menu" href='admin.php?page=ewd-otp-export' class="menu-tab nav-tab <?php if ( $screen->id == 'ewd-otp-export' ) {echo 'nav-tab-active';}?>"><?php _e("Export", 'order-tracking'); ?></a>
492 <a id="import-menu" href='admin.php?page=ewd-otp-import' class="menu-tab nav-tab <?php if ( $screen->id == 'ewd-otp-import' ) {echo 'nav-tab-active';}?>"><?php _e("Import", 'order-tracking'); ?></a>
493 <a id="custom-fields-menu" href='admin.php?page=ewd-otp-custom-fields' class="menu-tab nav-tab <?php if ( $screen->id == 'ewd-otp-custom-fields' ) {echo 'nav-tab-active';}?>"><?php _e("Custom Fields", 'order-tracking'); ?></a>
494 <a id="options-menu" href='admin.php?page=ewd-otp-settings' class="menu-tab nav-tab <?php if ( $screen->id == 'ewd_otp_page_ewd-otp-settings' ) {echo 'nav-tab-active';}?>"><?php _e("Settings", 'order-tracking'); ?></a>
495 </h2>
496 </div>
497 <?php
498 }
499
500 public function maybe_display_helper_notice() {
501 global $ewd_otp_controller;
502
503 if ( empty( $ewd_otp_controller->permissions->check_permission( 'premium' ) ) ) { return; }
504
505 if ( is_plugin_active( 'ewd-premium-helper/ewd-premium-helper.php' ) ) { return; }
506
507 if ( get_transient( 'ewd-helper-notice-dismissed' ) ) { return; }
508
509 ?>
510
511 <div class='notice notice-error is-dismissible ewd-otp-helper-install-notice'>
512
513 <div class='ewd-otp-helper-install-notice-img'>
514 <img src='<?php echo EWD_OTP_PLUGIN_URL . '/lib/simple-admin-pages/img/options-asset-exclamation.png' ; ?>' />
515 </div>
516
517 <div class='ewd-otp-helper-install-notice-txt'>
518 <?php _e( 'You\'re using the Order Tracking premium version, but the premium helper plugin is not active.', 'order-tracking' ); ?>
519 <br />
520 <?php echo sprintf( __( 'Please re-activate the helper plugin, or <a target=\'_blank\' href=\'%s\'>download and install it</a> if the plugin is no longer installed to ensure continued access to the premium features of the plugin.', 'order-tracking' ), 'https://www.etoilewebdesign.com/2021/12/11/requiring-premium-helper-plugin/' ); ?>
521 </div>
522
523 <div class='ewd-otp-clear'></div>
524
525 </div>
526
527 <?php
528 }
529
530 public function hide_helper_notice() {
531
532 // Authenticate request
533 if ( ! check_ajax_referer( 'ewd-otp-helper-notice', 'nonce' ) or ! current_user_can( 'manage_options' ) ) {
534 ewdotpHelper::admin_nopriv_ajax();
535 }
536
537 set_transient( 'ewd-helper-notice-dismissed', true, 3600*24*7 );
538
539 die();
540 }
541
542 public function maybe_display_new_plugin_notice() {
543
544 if ( ! current_user_can( 'activate_plugins' ) ) { return; }
545
546 $screen = get_current_screen();
547
548 if ( ! isset( $screen->id ) ) { return; }
549
550 $allowed_screens = array(
551 'plugins',
552 'update-core',
553 'dashboard',
554 'options-general',
555 'options-writing',
556 'options-reading',
557 'options-discussion',
558 'options-media',
559 'options-permalink',
560 'options-privacy'
561 );
562
563 if ( strpos( $screen->id, 'tracking_page_' ) === false and
564 ! in_array( $screen->id, $allowed_screens ) ) {
565 return;
566 }
567
568 if ( get_transient( 'ait-aiaa-plugin-notice-dismissed' ) ) { return; }
569
570 // May 22nd, 2026
571 if ( time() > 1779508748 ) { return; }
572
573 $hook_lines = array(
574 __( 'Tired of digging through settings? Let <strong>AI Admin Assistance</strong> guide you!', 'order-tracking' ),
575 __( 'Stop wasting time searching for answers—use <strong>AI Admin Assistance</strong> to bring AI-powered help directly into your dashboard!', 'order-tracking' ),
576 __( 'Overwhelmed in the WordPress admin? <strong>AI Admin Assistance</strong> has you covered with AI-powered help directly in your dashboard!', 'order-tracking' ),
577 );
578
579 $selection = array_rand( $hook_lines );
580
581 ?>
582
583 <div class='notice notice-error is-dismissible ait-aiaa-new-plugin-notice'>
584
585 <div class='ewd-otp-new-plugin-notice-img'>
586 <img src='<?php echo EWD_OTP_PLUGIN_URL . '/assets/img/ait-aiaa-plugin-icon.png' ; ?>' />
587 </div>
588
589 <div class='ewd-otp-new-plugin-notice-txt'>
590 <p><?php echo $hook_lines[ $selection ]; ?></p>
591 <p><?php echo sprintf( __( 'As a thank you to our customers, for a limited time you can get a <strong>free pro license</strong>! Try the <a target=\'_blank\' href=\'%s\'>free version</a> today or use code <code>early_adopter_pro</code> to <a target=\'_blank\' href=\'%s\'>get your pro version license</a>!', 'order-tracking' ), admin_url( 'plugin-install.php?tab=plugin-information&plugin=ait-ai-admin-assistance' ), 'https://www.wpaiplugins.dev/wordpress-ai-admin-assistance/?utm_source=' . dirname( EWD_OTP_PLUGIN_FNAME ) . '_aiaa_notice&utm_content=' . $selection ); ?></p>
592 </div>
593
594 <div class='ewd-otp-clear'></div>
595
596 </div>
597
598 <?php
599 }
600
601 public function hide_new_plugin_notice() {
602 global $ewd_otp_controller;
603
604 // Authenticate request
605 if (
606 ! check_ajax_referer( 'ewd-otp-helper-notice', 'nonce' )
607 ||
608 ! current_user_can( $ewd_otp_controller->settings->get_setting( 'access-role' ) )
609 ) {
610 ewdotpHelper::admin_nopriv_ajax();
611
612 }
613
614 set_transient( 'ait-aiaa-plugin-notice-dismissed', true, 3600*24*7 );
615
616 die();
617 }
618
619 /**
620 * Declares compatibility with WooCommerce High-Performance Order Storage
621 * @since 3.3.7
622 */
623 public function declare_wc_hpos() {
624
625 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
626
627 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
628 }
629 }
630 }
631 } // endif;
632
633 global $ewd_otp_controller;
634 $ewd_otp_controller = new ewdotpInit();
635
636 do_action( 'ewd_otp_initialized' );