Server IP : 172.67.157.199 / Your IP : 3.142.245.40 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/defender-security/src/ |
Upload File : |
<?php /** * Class to handle mixpanel events functionality. * * @since 4.2.0 * @package WP_Defender */ namespace WP_Defender; use Calotes\Component\Request; use Calotes\Component\Response; use WP_Defender\Model\Setting\Main_Setting; use WP_Defender\Component\Product_Analytics; /** * Abstract class for Mixpanel Events. */ abstract class Event extends Controller { /** * Location of the event * * @var string */ protected $location = ''; /** * Get mixpanel instance. */ private function tracker() { return wd_di()->get( Product_Analytics::class )->get_mixpanel(); } /** * Check if usage tracking is active. * * @return bool */ protected function is_tracking_active() { return wd_di()->get( Main_Setting::class )->usage_tracking; } /** * Has the data changed? * * @param array $old_data Old data to compare. * @param array $new_data New data to compare. * * @return bool */ protected function is_feature_state_changed( $old_data, $new_data ) { return ! empty( array_diff( $old_data, $new_data ) ); } /** * Track data tracking opt in and opt out. * * @param bool $active Toggle value. * @param string $from Triggered method. * * @return void */ protected function track_opt_toggle( $active, $from ) { $this->tracker()->track( $active ? 'Opt In' : 'Opt Out', array( 'Method' => $from, ) ); } /** * Tracks a feature event if tracking is active. * * @param mixed $event The event to track. * @param array $data The data associated with the event. * * @return void */ public function track_feature( $event, $data ) { if ( $this->is_tracking_active() ) { $this->tracker()->track( $event, $data ); } } /** * Save tracking state. * * @param Request $request Request object. * * @return Response * @defender_route */ public function track_feature_handler( Request $request ): Response { if ( $this->is_tracking_active() ) { $data = $request->get_data(); $this->track_feature( $data['event'], $data['data'] ); } return new Response( true, array() ); } /** * Sets the intention of the object to the specified location. * * @param string $location The location to set as the intention. */ public function set_intention( string $location ) { $this->location = $location; } /** * Retrieves the location where the event was triggered. * * @return string The location where the event was triggered. */ public function get_triggered_location() { return $this->location; } }