PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14.1
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14.1
7.8.14 7.8.14.1 7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / hustle-background-conversion-log.php
wordpress-popup / inc Last commit date
display-conditions 5 months ago front 2 days ago helpers 1 month ago metas 3 months ago multisite 5 months ago palettes 3 years ago provider 1 month ago providers 2 days ago templates 3 years ago update 5 months ago class-hustle-admin-page-abstract.php 1 month ago class-hustle-auth-token.php 5 months ago class-hustle-condition-factory.php 6 years ago class-hustle-cross-sell.php 10 months ago class-hustle-dashboard-admin.php 1 month ago class-hustle-data.php 1 month ago class-hustle-db.php 2 years ago class-hustle-installer.php 4 years ago class-hustle-meta.php 3 years ago class-hustle-module-admin.php 1 month ago class-hustle-module-collection.php 5 months ago class-hustle-module-fields.php 3 months ago class-hustle-module-page-abstract.php 1 month ago class-hustle-module-validator.php 3 months ago class-hustle-notifications.php 2 days ago class-hustle-settings-admin.php 1 month ago class-hustle-wp-dashboard-page.php 5 months ago class-opt-in.php 2 days ago hustle-background-conversion-log.php 3 months ago hustle-deletion.php 3 months ago hustle-embedded-admin.php 3 years ago hustle-entries-admin.php 5 months ago hustle-entry-model.php 1 month ago hustle-general-data-protection.php 5 months ago hustle-init.php 1 month ago hustle-mail.php 5 months ago hustle-migration.php 5 months ago hustle-model.php 2 days ago hustle-module-model.php 1 month ago hustle-module-widget-legacy.php 5 months ago hustle-module-widget.php 5 months ago hustle-modules-common-admin-ajax.php 1 month ago hustle-popup-admin.php 3 years ago hustle-providers-admin.php 1 month ago hustle-providers.php 5 months ago hustle-settings-admin-ajax.php 1 month ago hustle-settings-page.php 3 years ago hustle-slidein-admin.php 3 years ago hustle-sshare-admin.php 2 days ago hustle-sshare-model.php 2 days ago hustle-tracking-model.php 3 months ago interface-hustle-auth-provider.php 5 months ago opt-in-geo.php 5 months ago opt-in-utils.php 2 days ago opt-in-wpmudev-api.php 5 months ago
hustle-background-conversion-log.php
130 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Hustle Background Conversion Log
4 *
5 * @package Hustle
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Class Hustle_Background_Conversion_Log
14 *
15 * Handles background processing for conversion log tasks.
16 */
17 class Hustle_Background_Conversion_Log {
18
19 /**
20 * Instance of this class
21 *
22 * @var Hustle_Background_Conversion_Log
23 */
24 private static $instance = null;
25
26 /**
27 * Cron hook name
28 *
29 * @var string
30 */
31 private $cron_hook = 'hustle_conversion_log_cron';
32
33 /**
34 * Cron interval name
35 *
36 * @var string
37 */
38 private $cron_interval = 'hustle_every_minute';
39
40 /**
41 * Get the singleton instance
42 *
43 * @return Hustle_Background_Conversion_Log
44 */
45 public static function get_instance() {
46 if ( is_null( self::$instance ) ) {
47 self::$instance = new self();
48 }
49 return self::$instance;
50 }
51
52 /**
53 * Constructor
54 */
55 private function __construct() {
56 add_action( $this->cron_hook, array( $this, 'process_task' ) );
57 add_filter( 'cron_schedules', array( $this, 'add_cron_interval' ) );
58 }
59
60 /**
61 * Initialize the background task
62 */
63 public function init() {
64 if ( ! wp_next_scheduled( $this->cron_hook ) ) {
65 wp_schedule_event( time(), $this->cron_interval, $this->cron_hook );
66 }
67 }
68
69 /**
70 * Add custom cron interval (every 15 minutes)
71 *
72 * @param array $schedules Existing schedules.
73 * @return array Modified schedules.
74 */
75 public function add_cron_interval( $schedules ) {
76 $schedules[ $this->cron_interval ] = array(
77 'interval' => 900, // 900 seconds = 15 minutes
78 'display' => esc_html__( 'Every Fifteen Minutes', 'hustle' ),
79 );
80 return $schedules;
81 }
82
83 /**
84 * Process the background task
85 */
86 public function process_task() {
87 self::save_conversion_logs();
88 }
89
90 /**
91 * Save temporary conversion logs.
92 *
93 * @since 7.8.11
94 */
95 public static function save_conversion_logs() {
96 $temp_conversions = get_option( 'hustle_conversion_logs', array() );
97 if ( ! empty( $temp_conversions ) ) {
98 foreach ( $temp_conversions as $conversion ) {
99
100 $date = date_i18n( 'Y-m-d H:i:s', $conversion['time'] );
101 Hustle_Tracking_Model::get_instance()->save_tracking(
102 $conversion['module_id'],
103 $conversion['action'],
104 $conversion['module_type'],
105 $conversion['post_id'],
106 $conversion['module_sub_type'],
107 $date,
108 $conversion['ip']
109 );
110 }
111 delete_option( 'hustle_conversion_logs' );
112 }
113 }
114
115 /**
116 * Stop the scheduled task
117 */
118 public function stop() {
119 $timestamp = wp_next_scheduled( $this->cron_hook );
120 if ( $timestamp ) {
121 wp_unschedule_event( $timestamp, $this->cron_hook );
122 }
123 }
124
125 /**
126 * Prevent cloning of the instance
127 */
128 private function __clone() {}
129 }
130