| @@ -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.10' ); | |
| 26 | + $this->define( 'NOTIFIER_VERSION', '2.1.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. |
| @@ -62,9 +60,8 @@ | ||
| 62 | 60 | private function includes() { |
| 63 | 61 | // Functions |
| 64 | 62 | require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-helpers.php'; |
| 65 | 63 | require_once NOTIFIER_PATH . 'includes/functions/functions-notifier-meta-box-fields.php'; |
| 66 | - require_once NOTIFIER_PATH . 'libraries/action-scheduler/action-scheduler.php'; | |
| 67 | 64 | |
| 68 | 65 | // Classes |
| 69 | 66 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-admin-notices.php'; |
| 70 | 67 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-dashboard.php'; |
| @@ -71,9 +68,8 @@ | ||
| 71 | 68 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-merge-tags.php'; |
| 72 | 69 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-notification-triggers.php'; |
| 73 | 70 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-settings.php'; |
| 74 | 71 | require_once NOTIFIER_PATH . 'includes/classes/class-notifier-frontend.php'; |
| 75 | - require_once NOTIFIER_PATH . 'includes/classes/class-notifier-tools.php'; | |
| 76 | 72 | } |
| 77 | 73 | |
| 78 | 74 | /** |
| 79 | 75 | * Hook into actions and filters. |
| @@ -78,10 +74,9 @@ | ||
| 78 | 74 | /** |
| 79 | 75 | * Hook into actions and filters. |
| 80 | 76 | */ |
| 81 | 77 | private function init_hooks() { |
| 82 | - register_activation_hook ( NOTIFIER_FILE, array( $this, 'activate') ); | |
| 83 | - register_deactivation_hook ( NOTIFIER_FILE, array( $this, 'deactivate') ); | |
| 78 | + register_activation_hook ( NOTIFIER_FILE, array( $this, 'install') ); | |
| 84 | 79 | |
| 85 | 80 | add_action( 'after_setup_theme', array( 'Notifier_Admin_Notices', 'init' ) ); |
| 86 | 81 | add_action( 'after_setup_theme', array( 'Notifier_Dashboard', 'init' ) ); |
| 87 | 82 | add_action( 'after_setup_theme', array( 'Notifier_Notification_Merge_Tags', 'init' ) ); |
| @@ -92,56 +87,17 @@ | ||
| 92 | 87 | add_action( 'wp_enqueue_scripts', array( $this , 'frontend_scripts') ); |
| 93 | 88 | add_action( 'in_admin_header', array( $this , 'embed_page_header' ) ); |
| 94 | 89 | |
| 95 | 90 | 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 | 91 | } |
| 103 | 92 | |
| 104 | 93 | /** |
| 105 | 94 | * Setup during plugin activation |
| 106 | 95 | */ |
| 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 | - } | |
| 96 | + public function install() { | |
| 114 | 97 | |
| 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 | 98 | } |
| 125 | 99 | |
| 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 | 100 | /** |
| 145 | 101 | * Check if plugin's page |
| 146 | 102 | */ |
| 147 | 103 | public static function is_notifier_page() { |
| @@ -205,27 +161,8 @@ | ||
| 205 | 161 | null, |
| 206 | 162 | NOTIFIER_VERSION |
| 207 | 163 | ); |
| 208 | 164 | } |
| 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 | 165 | } |
| 229 | 166 | |
| 230 | 167 | /** |
| 231 | 168 | * Set up a div for the header embed to render into. |
| @@ -240,14 +177,12 @@ | ||
| 240 | 177 | $tax = ( '' !== $current_screen->taxonomy) ? $current_screen->taxonomy : ''; |
| 241 | 178 | ?> |
| 242 | 179 | <div id="notifier-admin-header" data-post-type="<?php echo esc_attr($cpt); ?>"> |
| 243 | 180 | <div class="notifier-admin-header-content"> |
| 244 | - <div class="header-page-title w-30 d-flex align-content-center"> | |
| 245 | - <a class="header-logo" href="admin.php?page=notifier"><img src="<?php echo NOTIFIER_URL; ?>assets/images/favicon.svg"></a> | |
| 181 | + <div class="header-page-title w-30"> | |
| 246 | 182 | <h2><?php echo esc_attr(get_admin_page_title()); ?></h2> |
| 247 | 183 | </div> |
| 248 | 184 | <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 | 185 | <span class="header-version">Version: <?php echo esc_html(NOTIFIER_VERSION); ?></span> |
| 251 | 186 | <a href="https://wanotifier.com/support/" target="_blank">Help</a> |
| 252 | 187 | </div> |
| 253 | 188 | </div> |
| @@ -270,9 +205,9 @@ | ||
| 270 | 205 | 'Content-Type' => 'application/json; charset=utf-8' |
| 271 | 206 | ); |
| 272 | 207 | } |
| 273 | 208 | |
| 274 | - $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . esc_attr($api_key); | |
| 209 | + $request_url = NOTIFIER_APP_API_URL . $endpoint . '?key=' . $api_key; | |
| 275 | 210 | $request_args = array( |
| 276 | 211 | 'method' => $method, |
| 277 | 212 | 'headers' => $headers, |
| 278 | 213 | 'timeout' => 120, |
| @@ -279,9 +214,9 @@ | ||
| 279 | 214 | 'body' => json_encode($args), |
| 280 | 215 | 'sslverify' => false |
| 281 | 216 | ); |
| 282 | 217 | |
| 283 | - $response = wp_remote_request( $request_url, $request_args ); | |
| 218 | + $response = wp_remote_request( $request_url, $request_args); | |
| 284 | 219 | |
| 285 | 220 | $response_body = wp_remote_retrieve_body( $response ); |
| 286 | 221 | |
| 287 | 222 | if ( is_wp_error( $response ) ) { |
| @@ -298,9 +233,9 @@ | ||
| 298 | 233 | */ |
| 299 | 234 | public static function maybe_include_integrations () { |
| 300 | 235 | // Woocommerce |
| 301 | 236 | if ( class_exists( 'WooCommerce' ) ) { |
| 302 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-woocommerce.php'; | |
| 237 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-woocommerce.php'; | |
| 303 | 238 | Notifier_Woocommerce::init(); |
| 304 | 239 | } |
| 305 | 240 | if ( ! class_exists( 'WC_Session' ) ) { |
| 306 | 241 | include_once( WP_PLUGIN_DIR . '/woocommerce/includes/abstracts/abstract-wc-session.php' ); |
| @@ -305,47 +240,41 @@ | ||
| 305 | 240 | if ( ! class_exists( 'WC_Session' ) ) { |
| 306 | 241 | include_once( WP_PLUGIN_DIR . '/woocommerce/includes/abstracts/abstract-wc-session.php' ); |
| 307 | 242 | } |
| 308 | 243 | |
| 309 | - // WooCommerce Cart Abandonment Recovery by CartFlows | |
| 310 | - if ( class_exists( 'CARTFLOWS_CA_Loader' ) && defined('CARTFLOWS_CA_VER') && version_compare(CARTFLOWS_CA_VER, '1.2.25', '>=')) { | |
| 311 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-wcar.php'; | |
| 312 | - Notifier_WCAR::init(); | |
| 313 | - } | |
| 314 | - | |
| 315 | 244 | // Gravity Forms |
| 316 | 245 | if ( class_exists( 'GFCommon' ) ) { |
| 317 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-gravityforms.php'; | |
| 246 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-gravityforms.php'; | |
| 318 | 247 | Notifier_GravityForms::init(); |
| 319 | 248 | } |
| 320 | 249 | |
| 321 | 250 | // Contact Form 7 |
| 322 | 251 | if ( class_exists( 'WPCF7' ) ) { |
| 323 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-cf7.php'; | |
| 252 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-cf7.php'; | |
| 324 | 253 | Notifier_ContactForm7::init(); |
| 325 | 254 | } |
| 326 | 255 | |
| 327 | 256 | // WPForms |
| 328 | 257 | if ( class_exists( 'WPForms' ) ) { |
| 329 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-wpforms.php'; | |
| 258 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-wpforms.php'; | |
| 330 | 259 | Notifier_WPForms::init(); |
| 331 | 260 | } |
| 332 | 261 | |
| 333 | 262 | // Ninja Forms |
| 334 | 263 | if ( class_exists( 'Ninja_Forms' ) ) { |
| 335 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-ninjaforms.php'; | |
| 264 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-ninjaforms.php'; | |
| 336 | 265 | Notifier_NinjaForms::init(); |
| 337 | 266 | } |
| 338 | 267 | |
| 339 | 268 | //FrmForm |
| 340 | 269 | if ( class_exists( 'FrmForm' ) ) { |
| 341 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-formidable.php'; | |
| 270 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-formidable.php'; | |
| 342 | 271 | Notifier_Formidable::init(); |
| 343 | 272 | } |
| 344 | 273 | |
| 345 | 274 | //WPFluentForm |
| 346 | 275 | if ( function_exists( 'fluentFormApi' ) ) { |
| 347 | - require_once NOTIFIER_PATH . 'includes/classes/integrations/class-notifier-fluentforms.php'; | |
| 276 | + require_once NOTIFIER_PATH . 'includes/classes/class-notifier-fluentforms.php'; | |
| 348 | 277 | Notifier_FluentForms::init(); |
| 349 | 278 | } |
| 350 | 279 | } |
| 351 | 280 | |
| @@ -361,76 +290,5 @@ | ||
| 361 | 290 | return false; |
| 362 | 291 | } |
| 363 | 292 | } |
| 364 | 293 | |
| 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 | 294 | } |