PluginProbe
WANotifier for Forms and Actions / 2.4.5
WANotifier for Forms and Actions v2.4.5
3.1.1 3.1.0 3.0.4 2.7.10 2.7.11 2.7.12 2.7.13 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 3.0.0 3.0.1 3.0.2 3.0.3 trunk 0.1.0 0.1.1 1.0.0 1.0.1 1.0.2 All 67 releases
← All changes | includes/class-notifier.php +4 -138 2.7.112.4.5 View file →
@@ -22,15 +22,13 @@
22 22 /**
23 23 * Define Constants.
24 24 */
25 25 private function define_constants() {
26 - $this->define( 'NOTIFIER_VERSION', '2.7.11' );
26 + $this->define( 'NOTIFIER_VERSION', '2.4.5' );
27 27 $this->define( 'NOTIFIER_NAME', 'notifier' );
28 28 $this->define( 'NOTIFIER_PREFIX', 'notifier_' );
29 29 $this->define( 'NOTIFIER_URL', trailingslashit( plugins_url( '', dirname(__FILE__) ) ) );
30 30 $this->define( 'NOTIFIER_APP_API_URL', 'https://app.wanotifier.com/api/v1/' );
31 - $this->define( 'NOTIFIER_ACTIVITY_TABLE_NAME', 'notifier_activity_log' );
32 - $this->define( 'NOTIFIER_CART_ABANDONMENT_TABLE', 'notifier_cart_abandonment' );
33 31 }
34 32
35 33 /**
36 34 * Define constant if not already set.
@@ -71,9 +69,8 @@
71 69 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-merge-tags.php';
72 70 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-triggers.php';
73 71 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-settings.php';
74 72 require_once NOTIFIER_PATH . 'includes/classes/class-notifier-frontend.php';
75 - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-tools.php';
76 73 }
77 74
78 75 /**
79 76 * Hook into actions and filters.
@@ -78,10 +75,9 @@
78 75 /**
79 76 * Hook into actions and filters.
80 77 */
81 78 private function init_hooks() {
82 - register_activation_hook ( NOTIFIER_FILE, array( $this, 'activate') );
83 - register_deactivation_hook ( NOTIFIER_FILE, array( $this, 'deactivate') );
79 + register_activation_hook ( NOTIFIER_FILE, array( $this, 'install') );
84 80
85 81 add_action( 'after_setup_theme', array( 'Notifier_Admin_Notices', 'init' ) );
86 82 add_action( 'after_setup_theme', array( 'Notifier_Dashboard', 'init' ) );
87 83 add_action( 'after_setup_theme', array( 'Notifier_Notification_Merge_Tags', 'init' ) );
@@ -92,56 +88,17 @@
92 88 add_action( 'wp_enqueue_scripts', array( $this , 'frontend_scripts') );
93 89 add_action( 'in_admin_header', array( $this , 'embed_page_header' ) );
94 90
95 91 add_action( 'after_setup_theme', array( $this, 'maybe_include_integrations' ) );
96 - add_action( 'after_setup_theme', array( 'Notifier_Tools', 'init' ) );
97 -
98 - add_action( 'wp_loaded', array( $this, 'setup_activity_log' ) );
99 - add_action( 'notifier_clean_old_logs', array( $this, 'notifier_delete_old_activity_logs' ) );
100 -
101 - add_action( 'wp_loaded', array( $this, 'create_cart_abandonment_table' ) );
102 92 }
103 93
104 94 /**
105 95 * Setup during plugin activation
106 96 */
107 - public function activate() {
108 - $notifier_plugin_data = get_option('notifier_meta', array());
109 - if (isset($notifier_plugin_data['as_clear_log']) && $notifier_plugin_data['as_clear_log'] === 'yes') {
110 - unset($notifier_plugin_data['as_clear_log']);
111 - update_option('notifier_meta', $notifier_plugin_data);
112 - }
113 - }
97 + public function install() {
114 98
115 - /**
116 - * Setup during plugin deactivation
117 - */
118 - public function deactivate() {
119 - as_unschedule_action('notifier_check_cart_abandonment');
120 - as_unschedule_action('notifier_clean_old_logs');
121 - $notifier_plugin_data = get_option('notifier_meta', array());
122 - $notifier_plugin_data['as_clear_log'] = 'yes';
123 - update_option('notifier_meta', $notifier_plugin_data);
124 99 }
125 100
126 - /**
127 - * Check if the plugin was updated and run the upgrade routine if necessary.
128 - */
129 - public function setup_activity_log() {
130 - $notifier_plugin_data = get_option('notifier_meta', array());
131 - if (!isset($notifier_plugin_data['activity_log_table']) && $notifier_plugin_data['activity_log_table'] !== 'yes') {
132 - self::create_notifier_activity_log_table();
133 - }
134 -
135 - $args = array();
136 - $as_clear_log = isset($notifier_plugin_data['as_clear_log']) ? $notifier_plugin_data['as_clear_log'] : 'no';
137 - if ($as_clear_log !== 'yes') {
138 - if (false === as_next_scheduled_action('notifier_clean_old_logs')) {
139 - as_schedule_recurring_action(time(), DAY_IN_SECONDS, 'notifier_clean_old_logs', $args);
140 - }
141 - }
142 - }
143 -
144 101 /**
145 102 * Check if plugin's page
146 103 */
147 104 public static function is_notifier_page() {
@@ -205,27 +162,8 @@
205 162 null,
206 163 NOTIFIER_VERSION
207 164 );
208 165 }
209 -
210 - if ('yes' === get_option('notifier_enable_abandonment_cart_tracking', 'no') && class_exists('WooCommerce') && is_checkout() ) {
211 - wp_enqueue_script(
212 - NOTIFIER_NAME . '-js',
213 - NOTIFIER_URL . 'assets/js/script.js',
214 - array('jquery'),
215 - NOTIFIER_VERSION,
216 - true
217 - );
218 -
219 - wp_localize_script(
220 - NOTIFIER_NAME . '-js',
221 - 'notifierFrontObj',
222 - array(
223 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
224 - 'security' => wp_create_nonce('notifier_save_cart_abandonment_data'),
225 - )
226 - );
227 - }
228 166 }
229 167
230 168 /**
231 169 * Set up a div for the header embed to render into.
@@ -245,9 +183,8 @@
245 183 <a class="header-logo" href="admin.php?page=notifier"><img src="<?php echo NOTIFIER_URL; ?>assets/images/favicon.svg"></a>
246 184 <h2><?php echo esc_attr(get_admin_page_title()); ?></h2>
247 185 </div>
248 186 <div class="header-action-links w-30 d-flex justify-content-end">
249 - <span class="review-us-link">Review us: <a href="https://wordpress.org/support/plugin/notifier/reviews/#new-post" target="_blank">⭐⭐⭐⭐⭐</a></span>
250 187 <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span>
251 188 <a href="https://wanotifier.com/support/" target="_blank">Help</a>
252 189 </div>
253 190 </div>
@@ -270,9 +207,9 @@
270 207 'Content-Type' => 'application/json; charset=utf-8'
271 208 );
272 209 }
273 210
274 - $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . esc_attr($api_key);
211 + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key;
275 212 $request_args = array(
276 213 'method' => $method,
277 214 'headers' => $headers,
278 215 'timeout' => 120,
@@ -361,76 +298,5 @@
361 298 return false;
362 299 }
363 300 }
364 301
365 - /**
366 - * Create New db table-- wanotifier_activity_log
367 - */
368 - public static function create_notifier_activity_log_table() {
369 - global $wpdb;
370 - $table_name = $wpdb->prefix . NOTIFIER_ACTIVITY_TABLE_NAME;
371 -
372 - $charset_collate = $wpdb->get_charset_collate();
373 -
374 - // Include IF NOT EXISTS clause in the CREATE TABLE query
375 - $sql = "CREATE TABLE IF NOT EXISTS $table_name (
376 - log_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
377 - timestamp timestamp NOT NULL,
378 - message text NOT NULL,
379 - type varchar(16) NOT NULL,
380 - PRIMARY KEY (log_id),
381 - INDEX idx_timestamp (timestamp)
382 - ) $charset_collate;";
383 -
384 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
385 - dbDelta( $sql );
386 -
387 - $notifier_plugin_data = get_option('notifier_meta', array());
388 - $notifier_plugin_data['activity_log_table'] = 'yes';
389 - update_option('notifier_meta', $notifier_plugin_data);
390 - }
391 -
392 - /**
393 - * Delete old log from activity table according to interval
394 - */
395 - public function notifier_delete_old_activity_logs() {
396 - global $wpdb;
397 - $table_name = $wpdb->prefix . NOTIFIER_ACTIVITY_TABLE_NAME;
398 - $retention_time = apply_filters( 'notifier_logs_retention_time', 7 );
399 - $retention_time = intval($retention_time);
400 - $wpdb->query( $wpdb->prepare( "DELETE FROM `$table_name` WHERE timestamp <= DATE_SUB(NOW(), INTERVAL %d DAY)", $retention_time ) );
401 - }
402 -
403 - /**
404 - * Create New db table-- notifier_cart_abandonment
405 - */
406 - public static function create_cart_abandonment_table() {
407 - $notifier_plugin_data = get_option('notifier_meta', array());
408 - if (!isset($notifier_plugin_data['cart_abandonment_table']) && $notifier_plugin_data['cart_abandonment_table'] !== 'yes') {
409 - global $wpdb;
410 - $table_name = $wpdb->prefix . NOTIFIER_CART_ABANDONMENT_TABLE;
411 - $charset_collate = $wpdb->get_charset_collate();
412 -
413 - // Updated CREATE TABLE query for notifier_cart_abandonment table
414 - $sql = "CREATE TABLE IF NOT EXISTS $table_name (
415 - session_id BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
416 - session_key VARCHAR(16) NULL,
417 - phone_number VARCHAR(15) NULL,
418 - cart_data LONGTEXT NULL,
419 - cart_total DECIMAL(10,2) NULL,
420 - coupon_data LONGTEXT NULL,
421 - customer_data LONGTEXT NULL,
422 - order_id BIGINT(11) DEFAULT 0,
423 - triggered TINYINT(1) DEFAULT 0,
424 - created_time DATETIME NULL,
425 - updated_time DATETIME NULL,
426 - KEY session_key (session_key) -- Index for session_key
427 - ) $charset_collate;";
428 -
429 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
430 - dbDelta( $sql );
431 -
432 - $notifier_plugin_data['cart_abandonment_table'] = 'yes';
433 - update_option('notifier_meta', $notifier_plugin_data);
434 - }
435 - }
436 302 }