jax_referrer() { check_ajax_referer( 'wp-smush-ajax', '_nonce' ); // Check capability. if ( ! Helper::is_user_allowed( 'manage_options' ) ) { wp_die( esc_html__( 'Unauthorized', 'wp-smushit' ), 403 ); } } private function register_ajax_handler( $action, $handler ) { add_action( "wp_ajax_$action", $handler ); } /** * @return Smush_Background_Task[] */ private function prepare_background_tasks() { $smush_tasks = $this->prepare_smush_tasks(); $resmush_tasks = $this->prepare_resmush_tasks(); return array_merge( $smush_tasks, $resmush_tasks ); } private function prepare_smush_tasks() { $to_smush = $this->global_stats->get_optimize_list()->get_ids(); if ( empty( $to_smush ) || ! is_array( $to_smush ) ) { $to_smush = array(); } return array_map( function ( $image_id ) { return new Smush_Background_Task( Smush_Background_Task::TASK_TYPE_SMUSH, $image_id ); }, $to_smush ); } private function prepare_resmush_tasks() { $to_resmush = $this->global_stats->get_redo_ids(); return array_map( function ( $image_id ) { return new Smush_Background_Task( Smush_Background_Task::TASK_TYPE_RESMUSH, $image_id ); }, $to_resmush ); } private function prepare_error_tasks() { $error_items_to_retry = $this->global_stats->get_error_list()->get_ids(); return array_map( function ( $image_id ) { return new Smush_Background_Task( Smush_Background_Task::TASK_TYPE_ERROR, $image_id ); }, $error_items_to_retry ); } public function localize_background_stats( $script_data ) { global $current_screen; $is_bulk_smush_page = isset( $current_screen->id ) && strpos( $current_screen->id, '_page_smush-bulk' ) !== false; if ( $is_bulk_smush_page ) { $script_data['bo_stats'] = $this->background_process->get_status()->to_array(); } return $script_data; } /** * Whether BO is in processing or not. * * @return boolean */ public function is_in_processing() { return $this->background_process->get_status()->is_in_processing(); } /** * Whether BO is completed or not. * * @return boolean */ public function is_completed() { return $this->background_process->get_status()->is_completed(); } /** * Whether BO is dead or not. * * @return boolean */ public function is_dead() { return $this->background_process->get_status()->is_dead(); } /** * Get total items. * * @return int */ public function get_total_items() { return $this->background_process->get_status()->get_total_items(); } /** * Get processed items. * * @return int */ public function get_processed_items() { return $this->background_process->get_status()->get_processed_items(); } /** * Get failed items. * * @return int */ public function get_failed_items() { return $this->background_process->get_status()->get_failed_items(); } /** * Get revival count. * * @return int */ public function get_revival_count() { return $this->background_process->get_revival_count(); } /** * Get process id. */ public function get_process_id() { return $this->background_process->get_process_id(); } /** * Get email address of recipient. * * @return string */ public function get_mail_recipient() { $emails = $this->mail->get_mail_recipients(); return ! empty( $emails ) ? $emails[0] : get_option( 'admin_email' ); } public function get_in_process_notice() { return $this->mail->reporting_email_enabled() ? $this->get_email_enabled_notice() : $this->get_email_disabled_notice(); } private function get_email_disabled_notice() { $email_setting_link = sprintf( '%s', esc_html__( 'Enable the email notification', 'wp-smushit' ) ); /* translators: %s: a link */ return sprintf( __( 'Feel free to close this page while Smush works its magic in the background. %s to receive an email when the process finishes.', 'wp-smushit' ), $email_setting_link ); } private function get_email_enabled_notice() { $mail_recipient = $this->get_mail_recipient(); /* translators: %s: Email address */ return sprintf( __( 'Feel free to close this page while Smush works its magic in the background. We’ll email you at %s when it’s done.', 'wp-smushit' ), $mail_recipient ); } public function is_background_enabled() { if ( ! $this->can_use_background() ) { return false; } return defined( 'WP_SMUSH_BACKGROUND' ) && WP_SMUSH_BACKGROUND; } public function should_use_background() { return $this->is_background_enabled() && $this->is_background_supported(); } public function is_background_supported() { return $this->is_mysql_requirement_met(); } public function can_use_background() { return WP_Smush::is_pro() || ! empty( get_site_option( 'wp_smush_pre_3_12_6_site' ) ); } /** * We need the right version of MySQL for locks used by the Mutex class * @return bool|int */ private function is_mysql_requirement_met() { return version_compare( $this->get_actual_mysql_version(), $this->get_required_mysql_version(), '>=' ); } public function get_required_mysql_version() { return self::REQUIRED_MYSQL_VERSION; } public function get_actual_mysql_version() { return $this->server_utils->get_mysql_version(); } public function start_bulk_smush_direct() { if ( ! $this->should_use_background() ) { return false; } $process = $this->background_process; $in_processing = $process->get_status()->is_in_processing(); if ( $in_processing ) { return $process->get_status()->to_array(); } if ( ! Helper::loopback_supported() ) { $this->logger->error( 'Loopback check failed. Not starting a new background process.' ); return false; } $tasks = $this->prepare_background_tasks(); if ( $tasks ) { do_action( 'wp_smush_bulk_smush_start' ); $process->start( $tasks ); } return $process->get_status()->to_array(); } }
Fatal error: Uncaught Error: Class "Smush\Core\Modules\Bulk\Background_Bulk_Smush" not found in /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/core/class-modules.php:153 Stack trace: #0 /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/core/class-core.php(158): Smush\Core\Modules->__construct() #1 /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/core/class-stats.php(104): Smush\Core\Core->init() #2 /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/wp-smush.php(366): Smush\Core\Stats->__construct() #3 /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/wp-smush.php(286): WP_Smush->init() #4 /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/wp-smush.php(259): WP_Smush->__construct() #5 /htdocs/sansmonportable.com/prod/wp-includes/class-wp-hook.php(324): WP_Smush::get_instance('') #6 /htdocs/sansmonportable.com/prod/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #7 /htdocs/sansmonportable.com/prod/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #8 /htdocs/sansmonportable.com/prod/wp-settings.php(578): do_action('plugins_loaded') #9 /htdocs/sansmonportable.com/prod/wp-config.php(98): require_once('/htdocs/sansmon...') #10 /htdocs/sansmonportable.com/prod/wp-load.php(50): require_once('/htdocs/sansmon...') #11 /htdocs/sansmonportable.com/prod/wp-blog-header.php(13): require_once('/htdocs/sansmon...') #12 /htdocs/sansmonportable.com/index.php(17): require('/htdocs/sansmon...') #13 {main} thrown in /htdocs/sansmonportable.com/prod/wp-content/plugins/wp-smushit/core/class-modules.php on line 153