nner', 'placeholder' );
foreach ( $items as $item ) {
$settings['animation'][ $item ]['selected'] = isset( $settings['animation']["$item-icon"] ) ? $settings['animation']["$item-icon"] : 1;
unset( $settings['animation']["$item-icon"] );
// Custom spinners.
if ( ! isset( $previous_settings['animation'][ $item ]['custom'] ) || ! is_array( $previous_settings['animation'][ $item ]['custom'] ) ) {
$settings['animation'][ $item ]['custom'] = array();
} else {
// Remove empty values.
$settings['animation'][ $item ]['custom'] = array_filter( $previous_settings['animation'][ $item ]['custom'] );
}
// Add uploaded custom spinner.
if ( isset( $settings['animation']["custom-$item"] ) ) {
if ( ! empty( $settings['animation']["custom-$item"] ) && ! in_array( $settings['animation']["custom-$item"], $settings['animation'][ $item ]['custom'], true ) ) {
$settings['animation'][ $item ]['custom'][] = $settings['animation']["custom-$item"];
$settings['animation'][ $item ]['selected'] = $settings['animation']["custom-$item"];
}
unset( $settings['animation']["custom-$item"] );
}
}
// Custom color for placeholder.
if ( ! isset( $settings['animation']['color'] ) ) {
$settings['animation']['placeholder']['color'] = $previous_settings['animation']['placeholder']['color'];
} else {
$settings['animation']['placeholder']['color'] = $settings['animation']['color'];
unset( $settings['animation']['color'] );
}
/**
* Exclusion rules.
*/
// Convert to array.
if ( ! empty( $settings['exclude-pages'] ) ) {
$settings['exclude-pages'] = preg_split( '/[\r\n\t ]+/', $settings['exclude-pages'] );
} else {
$settings['exclude-pages'] = array();
}
if ( ! empty( $settings['exclude-classes'] ) ) {
$settings['exclude-classes'] = preg_split( '/[\r\n\t ]+/', $settings['exclude-classes'] );
} else {
$settings['exclude-classes'] = array();
}
$this->set_setting( 'wp-smush-lazy_load', $settings );
}
/**
* Parse preload specific settings.
*
* @since 3.20.0
*/
private function parse_preload_settings(){
$args = array(
'exclude-pages' => array(
'filter' => FILTER_CALLBACK,
'options' => 'sanitize_text_field',
),
);
$settings = filter_input_array( INPUT_POST, $args );
/**
* Exclusion rules.
*/
// Convert to array.
if ( ! empty( $settings['exclude-pages'] ) ) {
$settings['exclude-pages'] = array_filter( preg_split( '/[\r\n\t ]+/', $settings['exclude-pages'] ) );
} else {
$settings['exclude-pages'] = array();
}
$this->set_setting( 'wp-smush-preload', $settings );
}
private function parse_next_gen_settings() {
$next_gen_manager = Next_Gen_Manager::get_instance();
$next_gen_format = filter_input( INPUT_POST, 'next-gen-format', FILTER_SANITIZE_SPECIAL_CHARS );
$next_gen_method = filter_input( INPUT_POST, 'next-gen-method', FILTER_SANITIZE_SPECIAL_CHARS );
$next_gen_manager->activate_format( $next_gen_format );
$next_gen_configuration = $next_gen_manager->get_active_format_configuration();
// Update Next-Gen method.
$next_gen_configuration->set_next_gen_method( $next_gen_method );
// Update Next-Gen fallback.
if ( $next_gen_configuration->direct_conversion_enabled() ) {
$next_gen_fallback_active = filter_input( INPUT_POST, 'next-gen-fallback', FILTER_VALIDATE_BOOLEAN );
$next_gen_configuration->set_next_gen_fallback( (bool) $next_gen_fallback_active );
}
}
/**
* Parse access control settings on multisite.
*
* @since 3.2.2
*
* @return mixed
*/
private function parse_access_settings() {
$current_value = get_site_option( self::SUBSITE_CONTROLS_OPTION_KEY );
$new_value = filter_input( INPUT_POST, 'wp-smush-subsite-access', FILTER_SANITIZE_SPECIAL_CHARS );
$access = filter_input( INPUT_POST, 'wp-smush-access', FILTER_SANITIZE_SPECIAL_CHARS, FILTER_REQUIRE_ARRAY );
if ( 'custom' === $new_value ) {
$new_value = $access;
}
if ( $current_value !== $new_value ) {
update_site_option( self::SUBSITE_CONTROLS_OPTION_KEY, $new_value );
}
return $new_value;
}
/**
* Apply a default configuration to lazy loading on first activation.
*
* @since 3.2.0
*/
public function init_lazy_load_defaults() {
$defaults = array(
'format' => array(
'jpeg' => true,
'png' => true,
'webp' => true,
'gif' => true,
'svg' => true,
'iframe' => true,
'embed_video' => false,
),
'output' => array(
'content' => true,
'widgets' => true,
'thumbnails' => true,
'gravatars' => true,
),
'animation' => array(
'selected' => 'fadein', // Accepts: fadein, spinner, placeholder, false.
'fadein' => array(
'duration' => 400,
'delay' => 0,
),
'spinner' => array(
'selected' => 1,
'custom' => array(),
),
'placeholder' => array(
'selected' => 1,
'custom' => array(),
'color' => '#F3F3F3',
),
),
'include' => array(
'frontpage' => true,
'home' => true,
'page' => true,
'single' => true,
'archive' => true,
'category' => true,
'tag' => true,
),
'exclude-pages' => array(),
'exclude-classes' => array(),
'footer' => true,
'native' => false,
'noscript_fallback' => false,
);
$this->set_setting( 'wp-smush-lazy_load', $defaults );
}
/**
* Check if in network admin.
*
* The is_network_admin() check does not work in ajax calls.
*
* @since 3.10.3
*
* @return bool
*/
public static function is_ajax_network_admin() {
return defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_SERVER['HTTP_REFERER'] ) && preg_match( '#^' . network_admin_url() . '#i', wp_unslash( $_SERVER['HTTP_REFERER'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}
public function is_optimize_original_images_active() {
return ! empty( self::get_instance()->get( 'original' ) );
}
public function is_png2jpg_module_active() {
return $this->is_module_active( 'png_to_jpg' );
}
public function is_webp_module_active() {
return $this->is_module_active( 'webp_mod' );
}
public function is_avif_module_active() {
return $this->is_module_active( 'avif_mod' );
}
public function is_avif_fallback_active() {
return $this->is_avif_module_active()
&& ! empty( self::get_instance()->get( 'avif_fallback' ) );
}
public function is_resize_module_active() {
return $this->is_module_active( 'resize' );
}
public function is_backup_active() {
return $this->is_module_active( 'backup' );
}
public function is_s3_active() {
return $this->is_module_active( 's3' );
}
public function is_cdn_webp_conversion_active() {
return $this->is_cdn_active()
&& self::WEBP_CDN_MODE === $this->get_cdn_next_gen_conversion_mode();
}
public function is_cdn_avif_conversion_active() {
return $this->is_cdn_active()
&& self::AVIF_CDN_MODE === $this->get_cdn_next_gen_conversion_mode();
}
public function is_cdn_next_gen_conversion_active() {
return $this->is_cdn_active()
&& ! empty( $this->get_cdn_next_gen_conversion_mode() );
}
public function get_cdn_next_gen_conversion_mode() {
$cdn_next_gen_mode = (int) self::get_instance()->get( self::NEXT_GEN_CDN_KEY );
return $this->sanitize_cdn_next_gen_conversion_mode( $cdn_next_gen_mode );
}
public function get_cdn_next_gen_conversion_label( $cdn_next_gen_mode ) {
$cdn_next_gen_mode = $this->sanitize_cdn_next_gen_conversion_mode( $cdn_next_gen_mode );
$cdn_next_gen_modes = $this->get_cdn_next_gen_modes();
return $cdn_next_gen_modes[ $cdn_next_gen_mode ];
}
public function sanitize_cdn_next_gen_conversion_mode( $cdn_next_gen_mode ) {
$cdn_next_gen_mode = (int) $cdn_next_gen_mode;
$cdn_next_gen_modes = $this->get_cdn_next_gen_modes();
if ( ! isset( $cdn_next_gen_modes[ $cdn_next_gen_mode ] ) ) {
$cdn_next_gen_mode = self::NONE_CDN_MODE;
}
return $cdn_next_gen_mode;
}
private function get_cdn_next_gen_modes() {
return array(
self::NONE_CDN_MODE => __( 'None', 'wp-smushit' ),
self::WEBP_CDN_MODE => __( 'WebP', 'wp-smushit' ),
self::AVIF_CDN_MODE => __( 'AVIF', 'wp-smushit' ),
);
}
public function is_webp_direct_conversion_active() {
return $this->is_webp_module_active()
&& ! empty( self::get_instance()->get( 'webp_direct_conversion' ) );
}
public function is_automatic_compression_active() {
return self::get_instance()->get( 'auto' );
}
public function is_cdn_active() {
return $this->is_module_active( 'cdn' );
}
public function is_webp_fallback_active() {
return $this->is_webp_module_active()
&& ! empty( self::get_instance()->get( 'webp_fallback' ) );
}
public function is_lazyload_active() {
return self::get_instance()->get( 'lazy_load' );
}
public function is_module_active( $module ) {
$pro_modules = array(
'cdn',
'png_to_jpg',
'webp_mod',
'avif_mod',
's3',
'ultra',
'preload_images',
);
$module_active = self::get_instance()->get( $module );
if ( in_array( $module, $pro_modules, true ) ) {
$module_active = $module_active && WP_Smush::is_pro();
}
return $module_active;
}
public function get_lossy_level_setting() {
$current_level = self::get_instance()->get( 'lossy' );
return $this->sanitize_lossy_level( $current_level );
}
public function sanitize_lossy_level( $lossy_level ) {
$highest_level = $this->get_highest_lossy_level();
if ( $lossy_level > $highest_level ) {
return $highest_level;
}
if ( $lossy_level > self::LEVEL_LOSSLESS ) {
return (int) $lossy_level;
}
return self::LEVEL_LOSSLESS;
}
public function get_highest_lossy_level() {
if ( WP_Smush::is_pro() ) {
return self::LEVEL_ULTRA_LOSSY;
}
return self::LEVEL_SUPER_LOSSY;
}
public function get_current_lossy_level_label() {
$current_level = $this->get_lossy_level_setting();
return $this->get_lossy_level_label( $current_level );
}
public function get_lossy_level_label( $lossy_level ) {
$smush_modes = array(
self::LEVEL_LOSSLESS => __( 'Basic', 'wp-smushit' ),
self::LEVEL_SUPER_LOSSY => __( 'Super', 'wp-smushit' ),
self::LEVEL_ULTRA_LOSSY => __( 'Ultra', 'wp-smushit' ),
);
if ( ! isset( $smush_modes[ $lossy_level ] ) ) {
$lossy_level = self::LEVEL_LOSSLESS;
}
return $smush_modes[ $lossy_level ];
}
public function get_large_file_cutoff() {
return apply_filters( 'wp_smush_large_file_cut_off', 32 * 1024 * 1024 );
}
public function has_bulk_smush_page() {
return $this->is_page_active( 'bulk' );
}
public function has_cdn_page() {
return $this->is_page_active( 'cdn' );
}
public function has_webp_page() {
_deprecated_function( __METHOD__, '3.8.0', 'Settings::has_next_gen_page()' );
return $this->has_next_gen_page();
}
public function has_next_gen_page() {
return $this->is_page_active( 'next-gen' );
}
public function has_lazy_preload_page() {
return $this->is_page_active( self::LAZY_PRELOAD_MODULE_NAME );
}
public function streaming_enabled() {
if ( defined( 'WP_SMUSH_USE_STREAMS' ) ) {
return (bool) WP_SMUSH_USE_STREAMS;
}
return self::get_instance()->get( 'disable_streams' ) != WP_SMUSH_VERSION;
}
public function is_lcp_preload_enabled() {
return $this->is_module_active( 'preload_images' );
}
private function is_page_active( $page_slug ) {
if ( ! is_multisite() ) {
return true;
}
$module = $this->slug_to_module( $page_slug );
$is_page_active_on_subsite = in_array( $module, $this->get_activated_subsite_modules(), true );
if ( is_network_admin() ) {
return ! $is_page_active_on_subsite;
}
return $is_page_active_on_subsite;
}
private function slug_to_module( $page_slug ) {
return str_replace( '-', '_', $page_slug );
}
/**
* @return array
*/
private function get_activated_subsite_modules() {
if ( ! is_array( $this->activated_subsite_modules ) ) {
$this->activated_subsite_modules = $this->prepare_activated_subsite_modules();
}
return $this->activated_subsite_modules;
}
/**
* @return array
*/
private function prepare_activated_subsite_modules() {
$subsite_controls = get_site_option( self::SUBSITE_CONTROLS_OPTION_KEY );
// None:false|All:1|Custom:array list page modules.
if ( empty( $subsite_controls ) ) {
return array();
}
$subsite_modules = $this->get_subsite_modules();
if ( is_array( $subsite_controls ) ) {
$subsite_modules = $subsite_controls;
}
return $subsite_modules;
}
private function get_subsite_modules() {
return array(
'bulk',
'integrations',
self::LAZY_PRELOAD_MODULE_NAME,
'cdn',
);
}
/**
* Get $content_width global var value.
*/
public function max_content_width() {
// Get global content width (if content width is empty, set 1920).
$content_width = isset( $GLOBALS['content_width'] ) ? (int) $GLOBALS['content_width'] : 1920;
// Avoid situations, when themes misuse the global.
if ( 0 === $content_width ) {
$content_width = 1920;
}
// Check to see if we are resizing the images (can not go over that value).
$resize_sizes = $this->get_setting( 'wp-smush-resize_sizes' );
if ( isset( $resize_sizes['width'] ) && $resize_sizes['width'] < $content_width ) {
return $resize_sizes['width'];
}
return $content_width;
}
}
Fatal error: Uncaught Error: Class "Smush\Core\Settings" not found in /home/cpaherna/public_html/wp-content/plugins/wp-smushit/core/modules/class-abstract-module.php:53
Stack trace:
#0 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/core/class-modules.php(132): Smush\Core\Modules\Abstract_Module->__construct()
#1 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/core/class-core.php(158): Smush\Core\Modules->__construct()
#2 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/core/class-stats.php(104): Smush\Core\Core->init()
#3 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/wp-smush.php(368): Smush\Core\Stats->__construct()
#4 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/wp-smush.php(288): WP_Smush->init()
#5 /home/cpaherna/public_html/wp-content/plugins/wp-smushit/wp-smush.php(259): WP_Smush->__construct()
#6 /home/cpaherna/public_html/wp-includes/class-wp-hook.php(324): WP_Smush::get_instance('')
#7 /home/cpaherna/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#8 /home/cpaherna/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#9 /home/cpaherna/public_html/wp-settings.php(555): do_action('plugins_loaded')
#10 /home/cpaherna/public_html/wp-config.php(96): require_once('/home/cpaherna/...')
#11 /home/cpaherna/public_html/wp-load.php(50): require_once('/home/cpaherna/...')
#12 /home/cpaherna/public_html/wp-blog-header.php(13): require_once('/home/cpaherna/...')
#13 /home/cpaherna/public_html/index.php(17): require('/home/cpaherna/...')
#14 {main}
thrown in /home/cpaherna/public_html/wp-content/plugins/wp-smushit/core/modules/class-abstract-module.php on line 53