get_options()->get_option('webp_conversion', false); $webp_converters = WP_Optimize()->get_options()->get_option('webp_converters', false); return $webp_conversion && !empty($webp_converters); } /** * Convert given image file to webp format * * @param string $source Path of image file * * @return void */ public static function do_webp_conversion($source) { $webp_converter = new WPO_WebP_Convert(); $webp_converter->convert($source); } /** * Returns an array of allowed extensions * * @return array */ public static function get_allowed_extensions() { return array('gif', 'jpeg', 'jpg', 'png'); } /** * Returns given file extension * * @param string $file * * @return mixed */ public static function get_extension($file) { $file_type = wp_check_filetype($file); return $file_type['ext']; } /** * Tests if given extension is present in allowed extensions array * * @param string $ext Extension to check * @param array $allowed_extensions Array of allowed extensions * * @return bool */ public static function is_supported_extension($ext, $allowed_extensions) { return in_array($ext, $allowed_extensions); } } endif;