is->track(
'Opt In',
array(
'Location' => 'reactivate',
'active_plugins' => $this->get_active_plugins(),
)
);
}
public function track_plugin_deactivation() {
$location = $this->get_deactivation_location();
$this->track(
'Opt Out',
array(
'Location' => $location,
'active_plugins' => $this->get_active_plugins(),
)
);
}
private function get_deactivation_location() {
$is_hub_request = ! empty( $_REQUEST['wpmudev-hub'] );
if ( $is_hub_request ) {
return 'deactivate_hub';
}
$is_dashboard_request = wp_doing_ajax() &&
! empty( $_REQUEST['action'] ) &&
'wdp-project-deactivate' === wp_unslash( $_REQUEST['action'] );
if ( $is_dashboard_request ) {
return 'deactivate_dashboard';
}
return 'deactivate_pluginlist';
}
private function get_active_plugins() {
$active_plugins = array();
$active_plugin_files = $this->get_active_and_valid_plugin_files();
foreach ( $active_plugin_files as $plugin_file ) {
$plugin_name = $this->get_plugin_name( $plugin_file );
if ( $plugin_name ) {
$active_plugins[] = $plugin_name;
}
}
return $active_plugins;
}
private function get_active_and_valid_plugin_files() {
$active_plugins = is_multisite() ? wp_get_active_network_plugins() : array();
$active_plugins = array_merge( $active_plugins, wp_get_active_and_valid_plugins() );
return array_unique( $active_plugins );
}
private function get_plugin_name( $plugin_file ) {
$plugin_data = get_plugin_data( $plugin_file );
return ! empty( $plugin_data['Name'] ) ? $plugin_data['Name'] : '';
}
private function get_cron_healthy_status() {
return $this->is_cron_healthy() ? 'Enabled' : 'Disabled';
}
private function is_cron_healthy() {
$wp_core_cron_hooks = array(
'wp_privacy_delete_old_export_files',
'wp_version_check',
'wp_update_plugins',
'wp_update_themes',
);
foreach ( $wp_core_cron_hooks as $hook ) {
$next_scheduled_time = wp_next_scheduled( $hook );
if ( ! $next_scheduled_time ) {
continue;
}
$delayed_time = time() - $next_scheduled_time;
// If any of the core cron hooks are delayed by more than 30 minutes, then cron is unhealthy.
return $delayed_time < ( HOUR_IN_SECONDS / 2 );
}
return false;
}
private function get_background_optimization_status() {
$bg_optimization = WP_Smush::get_instance()->core()->mod->bg_optimization;
return $bg_optimization->is_background_enabled() ? 'Enabled' : 'Disabled';
}
public function ajax_handle_track_request() {
$event_name = $this->get_event_name();
if ( ! check_ajax_referer( 'wp-smush-ajax' ) || ! Helper::is_user_allowed() || empty( $event_name ) ) {
wp_send_json_error();
}
$this->track(
$event_name,
$this->get_event_properties( $event_name )
);
wp_send_json_success();
}
private function get_event_name() {
return isset( $_POST['event'] ) ? sanitize_text_field( wp_unslash( $_POST['event'] ) ) : '';
}
private function get_event_properties( $event_name ) {
$properties = isset( $_POST['properties'] ) ? wp_unslash( $_POST['properties'] ) : array();
$properties = array_map( 'sanitize_text_field', $properties );
$filter_callback = $this->get_filter_properties_callback( $event_name );
if ( method_exists( $this, $filter_callback ) ) {
$properties = call_user_func( array( $this, $filter_callback ), $properties );
}
return $properties;
}
private function get_filter_properties_callback( $event_name ) {
$event_name = str_replace( ' ', '_', $event_name );
$event_name = sanitize_key( $event_name );
return "filter_{$event_name}_properties";
}
/**
* Filter properties for Scan Interrupted event.
*
* @param array $properties JS properties.
*/
protected function filter_scan_interrupted_properties( $properties ) {
$properties = array_merge(
$properties,
array(
'Slice Size' => $this->get_scanner_slice_size(),
'Background Optimization' => $this->get_background_optimization_status(),
'Cron' => $this->get_cron_healthy_status(),
'Time Elapsed' => $this->media_library_last_process->get_process_elapsed_time(),
'Smush Type' => $this->get_smush_type(),
'Mode' => $this->get_current_lossy_level_label(),
),
$this->get_scan_background_process_properties(),
$this->get_last_image_process_properties()
);
return $properties;
}
private function get_last_image_process_properties() {
$last_image_id = $this->media_library_last_process->get_last_process_attachment_id();
if ( ! $last_image_id ) {
return array();
}
$media_item = Media_Item_Cache::get_instance()->get( $last_image_id );
$last_image_time_elapsed = $this->media_library_last_process->get_last_process_attachment_elapsed_time();
$properties = array(
'Last Image Time Elapsed' => $last_image_time_elapsed,
);
if ( ! $media_item->is_valid() ) {
return $properties;
}
$full_size = $media_item->get_full_or_scaled_size();
if ( ! $full_size ) {
return $properties;
}
$file_size = $this->convert_to_megabytes( $full_size->get_filesize() );
$image_width = $full_size->get_width();
$image_height = $full_size->get_height();
$image_type = strtoupper( $full_size->get_extension() );
return array(
'Last Image Time Elapsed' => $last_image_time_elapsed,
'Last Image Size' => $file_size,
'Last Image Width' => $image_width,
'Last Image Height' => $image_height,
'Last Image Type' => $image_type,
);
}
/**
* Filter properties for Bulk Smush interrupted event.
*
* @param array $properties JS properties.
*/
protected function filter_bulk_smush_interrupted_properties( $properties ) {
return array_merge(
$properties,
array(
'Background Optimization' => $this->get_background_optimization_status(),
'Cron' => $this->get_cron_healthy_status(),
'Parallel Processing' => $this->get_parallel_processing_status(),
'Time Elapsed' => $this->media_library_last_process->get_process_elapsed_time(),
'Smush Type' => $this->get_smush_type(),
'Mode' => $this->get_current_lossy_level_label(),
),
$this->get_bulk_background_process_properties(),
$this->get_last_image_process_properties()
);
}
public function track_bulk_smush_progress_stuck() {
$properties = array(
'Trigger' => 'stuck_notice',
'Modal Action' => 'na',
'Troubleshoot' => 'na',
);
$properties = $this->filter_bulk_smush_interrupted_properties( $properties );
$this->track( 'Bulk Smush Interrupted', $properties );
}
}
Fatal error: Uncaught Error: Class 'Smush\Core\Modules\Product_Analytics_Controller' not found in /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/core/class-modules.php:146
Stack trace:
#0 /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/core/class-core.php(157): Smush\Core\Modules->__construct()
#1 /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/core/class-stats.php(104): Smush\Core\Core->init()
#2 /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/wp-smush.php(359): Smush\Core\Stats->__construct()
#3 /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/wp-smush.php(279): WP_Smush->init()
#4 /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/wp-smush.php(257): WP_Smush->__construct()
#5 /var/www/html/revistarealce.com/web/wp-includes/class-wp-hook.php(324): WP_Smush::get_instance('')
#6 /var/www/html/revistarealce.com/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#7 /var/www/html/revistarealce.com in /var/www/html/revistarealce.com/web/wp-content/plugins/wp-smushit/core/class-modules.php on line 146