| 1 |
<?php |
| 2 |
/** |
| 3 |
* The global functions for this plugin |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
|
| 9 |
/** |
| 10 |
* Sanitize a string |
| 11 |
*/ |
| 12 |
function quickwebp_sanitize_name( $name ) { |
| 13 |
|
| 14 |
$extension = pathinfo( $name, PATHINFO_EXTENSION ); |
| 15 |
$name = pathinfo( $name, PATHINFO_FILENAME ); |
| 16 |
$name = mb_convert_encoding( $name, "UTF-8" ); |
| 17 |
$char_not_clean = array('/\?/','/\’/','/\'/','/À/','/Á/','/Â/','/Ã/','/Ä/','/� |
| 18 |
/','/Ç/','/È/','/É/','/Ê/','/Ë/','/Ì/','/Í/','/Î/','/Ï/','/Ò/','/Ó/','/Ô/','/Õ/','/Ö/','/Ù/','/Ú/','/Û/','/Ü/','/Ý/','/à/','/á/','/â/','/ã/','/ä/','/å/','/ç/','/è/','/é/','/ê/','/ë/','/ì/','/í/','/î/','/ï/','/ð/','/ò/','/ó/','/ô/','/õ/','/ö/','/ù/','/ú/','/û/','/ü/','/ý/','/ÿ/', '/©/'); |
| 19 |
$clean = array('','-','-','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','u','u','u','u','y','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i','o','o','o','o','o','o','u','u','u','u','y','y','copy'); |
| 20 |
$friendly_name = preg_replace($char_not_clean, $clean, $name); |
| 21 |
$friendly_name = sanitize_title($friendly_name); |
| 22 |
|
| 23 |
return $friendly_name . '.' . $extension; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Default values for the settings |
| 28 |
*/ |
| 29 |
function quickwebp_settings_default( $id ) { |
| 30 |
|
| 31 |
$settings_arr = array( |
| 32 |
'quickwebp_settings_conversion' => '1', |
| 33 |
'quickwebp_settings_conversion_max_width' => 2000, |
| 34 |
'quickwebp_settings_conversion_max_height' => 2000, |
| 35 |
'quickwebp_settings_conversion_quality' => 75, |
| 36 |
'quickwebp_settings_conversion_sharpen' => 0, |
| 37 |
'quickwebp_settings_completion' => '1', |
| 38 |
'quickwebp_settings_completion_options' => array( |
| 39 |
'title', |
| 40 |
'caption', |
| 41 |
'alt', |
| 42 |
'description' |
| 43 |
), |
| 44 |
'quickwebp_settings_cleanup' => '1', |
| 45 |
'quickwebp_settings_paste_image' => '0' |
| 46 |
); |
| 47 |
|
| 48 |
return isset($settings_arr[$id]) ? $settings_arr[$id] : ''; |
| 49 |
} |