engines = new ADEE_Engines(); $this->converter = new ADEE_Converter( $this->engines ); $this->serve = new ADEE_Serve(); $this->bulk = new ADEE_Bulk( $this->converter ); $this->admin = new ADEE_Admin( $this->engines, $this->converter ); ADEE_Htaccess::init(); } /** * Activation defaults. * * @return void */ public static function activate() { if ( false === get_option( 'adee_settings', false ) ) { add_option( 'adee_settings', self::default_settings() ); } if ( false === get_option( 'adee_stats', false ) ) { add_option( 'adee_stats', array( 'variants' => 0, 'src_bytes' => 0, 'out_bytes' => 0 ) ); } } /** * Deactivation cleanup: remove our .htaccess rules. * * @return void */ public static function deactivate() { require_once ADEE_PATH . 'includes/class-adee-htaccess.php'; ADEE_Htaccess::remove(); } /** * Default settings. * * @return array */ public static function default_settings() { return array( 'auto_convert' => 1, 'convert_webp' => 1, 'convert_avif' => 1, 'webp_quality' => 82, 'avif_quality' => 60, 'serve' => 1, 'serve_mode' => 'picture', 'prefer_avif' => 1, 'batch_size' => 3, 'engine_webp' => 'auto', 'engine_avif' => 'auto', 'cwebp_path' => '', 'avifenc_path' => '', ); } /** * Full settings array merged with defaults. * * @return array */ public static function settings() { $saved = get_option( 'adee_settings', array() ); if ( ! is_array( $saved ) ) { $saved = array(); } return wp_parse_args( $saved, self::default_settings() ); } /** * Single setting value. * * @param string $key Setting key. * @return mixed */ public static function get_setting( $key ) { $settings = self::settings(); return isset( $settings[ $key ] ) ? $settings[ $key ] : null; } /** * Engine detector accessor. * * @return ADEE_Engines */ public function engines() { return $this->engines; } /** * Converter accessor. * * @return ADEE_Converter */ public function converter() { return $this->converter; } }