PluginProbe
WANotifier for Forms and Actions / 2.4.3
WANotifier for Forms and Actions v2.4.3
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 +5 -147 2.7.132.4.3 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.13' );
26 + $this->define( 'NOTIFIER_VERSION', '2.4.3' );
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() {
@@ -180,17 +137,9 @@
180 137 );
181 138 wp_localize_script(
182 139 NOTIFIER_NAME . '-admin-js',
183 140 'notifierObj',
184 - apply_filters( 'notifier_js_variables', array(
185 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
186 - 'nonces' => array(
187 - 'preview_btn_style' => wp_create_nonce( 'notifier_preview_btn_style' ),
188 - 'fetch_activity_logs' => wp_create_nonce( 'notifier_fetch_activity_logs' ),
189 - 'change_trigger_status' => wp_create_nonce( 'notifier_change_trigger_status' ),
190 - 'fetch_trigger_fields' => wp_create_nonce( 'notifier_fetch_trigger_fields' )
191 - )
192 - ) )
141 + apply_filters( 'notifier_js_variables', array('ajaxurl' => admin_url( 'admin-ajax.php' ) ) )
193 142 );
194 143
195 144 // Styles
196 145 wp_enqueue_style(
@@ -213,27 +162,8 @@
213 162 null,
214 163 NOTIFIER_VERSION
215 164 );
216 165 }
217 -
218 - if ('yes' === get_option('notifier_enable_abandonment_cart_tracking', 'no') && class_exists('WooCommerce') && is_checkout() ) {
219 - wp_enqueue_script(
220 - NOTIFIER_NAME . '-js',
221 - NOTIFIER_URL . 'assets/js/script.js',
222 - array('jquery'),
223 - NOTIFIER_VERSION,
224 - true
225 - );
226 -
227 - wp_localize_script(
228 - NOTIFIER_NAME . '-js',
229 - 'notifierFrontObj',
230 - array(
231 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
232 - 'security' => wp_create_nonce('notifier_save_cart_abandonment_data'),
233 - )
234 - );
235 - }
236 166 }
237 167
238 168 /**
239 169 * Set up a div for the header embed to render into.
@@ -253,9 +183,8 @@
253 183 <a class="header-logo" href="admin.php?page=notifier"><img src="<?php echo NOTIFIER_URL; ?>assets/images/favicon.svg"></a>
254 184 <h2><?php echo esc_attr(get_admin_page_title()); ?></h2>
255 185 </div>
256 186 <div class="header-action-links w-30 d-flex justify-content-end">
257 - <span class="review-us-link">Review us: <a href="https://wordpress.org/support/plugin/notifier/reviews/#new-post" target="_blank">⭐⭐⭐⭐⭐</a></span>
258 187 <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span>
259 188 <a href="https://wanotifier.com/support/" target="_blank">Help</a>
260 189 </div>
261 190 </div>
@@ -278,9 +207,9 @@
278 207 'Content-Type' => 'application/json; charset=utf-8'
279 208 );
280 209 }
281 210
282 - $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . esc_attr($api_key);
211 + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key;
283 212 $request_args = array(
284 213 'method' => $method,
285 214 'headers' => $headers,
286 215 'timeout' => 120,
@@ -369,76 +298,5 @@
369 298 return false;
370 299 }
371 300 }
372 301
373 - /**
374 - * Create New db table-- wanotifier_activity_log
375 - */
376 - public static function create_notifier_activity_log_table() {
377 - global $wpdb;
378 - $table_name = $wpdb->prefix . NOTIFIER_ACTIVITY_TABLE_NAME;
379 -
380 - $charset_collate = $wpdb->get_charset_collate();
381 -
382 - // Include IF NOT EXISTS clause in the CREATE TABLE query
383 - $sql = "CREATE TABLE IF NOT EXISTS $table_name (
384 - log_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
385 - timestamp timestamp NOT NULL,
386 - message text NOT NULL,
387 - type varchar(16) NOT NULL,
388 - PRIMARY KEY (log_id),
389 - INDEX idx_timestamp (timestamp)
390 - ) $charset_collate;";
391 -
392 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
393 - dbDelta( $sql );
394 -
395 - $notifier_plugin_data = get_option('notifier_meta', array());
396 - $notifier_plugin_data['activity_log_table'] = 'yes';
397 - update_option('notifier_meta', $notifier_plugin_data);
398 - }
399 -
400 - /**
401 - * Delete old log from activity table according to interval
402 - */
403 - public function notifier_delete_old_activity_logs() {
404 - global $wpdb;
405 - $table_name = $wpdb->prefix . NOTIFIER_ACTIVITY_TABLE_NAME;
406 - $retention_time = apply_filters( 'notifier_logs_retention_time', 7 );
407 - $retention_time = intval($retention_time);
408 - $wpdb->query( $wpdb->prepare( "DELETE FROM `$table_name` WHERE timestamp <= DATE_SUB(NOW(), INTERVAL %d DAY)", $retention_time ) );
409 - }
410 -
411 - /**
412 - * Create New db table-- notifier_cart_abandonment
413 - */
414 - public static function create_cart_abandonment_table() {
415 - $notifier_plugin_data = get_option('notifier_meta', array());
416 - if (!isset($notifier_plugin_data['cart_abandonment_table']) && $notifier_plugin_data['cart_abandonment_table'] !== 'yes') {
417 - global $wpdb;
418 - $table_name = $wpdb->prefix . NOTIFIER_CART_ABANDONMENT_TABLE;
419 - $charset_collate = $wpdb->get_charset_collate();
420 -
421 - // Updated CREATE TABLE query for notifier_cart_abandonment table
422 - $sql = "CREATE TABLE IF NOT EXISTS $table_name (
423 - session_id BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
424 - session_key VARCHAR(16) NULL,
425 - phone_number VARCHAR(15) NULL,
426 - cart_data LONGTEXT NULL,
427 - cart_total DECIMAL(10,2) NULL,
428 - coupon_data LONGTEXT NULL,
429 - customer_data LONGTEXT NULL,
430 - order_id BIGINT(11) DEFAULT 0,
431 - triggered TINYINT(1) DEFAULT 0,
432 - created_time DATETIME NULL,
433 - updated_time DATETIME NULL,
434 - KEY session_key (session_key) -- Index for session_key
435 - ) $charset_collate;";
436 -
437 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
438 - dbDelta( $sql );
439 -
440 - $notifier_plugin_data['cart_abandonment_table'] = 'yes';
441 - update_option('notifier_meta', $notifier_plugin_data);
442 - }
443 - }
444 302 }