| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); |
| 3 |
|
| 4 |
/* |
| 5 |
* Get all mime type which could be optimized by Imagify. |
| 6 |
* |
| 7 |
* @since 1.3 |
| 8 |
* |
| 9 |
* @return array $mime_type The mime type. |
| 10 |
*/ |
| 11 |
function get_imagify_mime_type() { |
| 12 |
$mime_type = array( |
| 13 |
'image/jpeg', |
| 14 |
'image/png', |
| 15 |
'image/gif' |
| 16 |
); |
| 17 |
|
| 18 |
return $mime_type; |
| 19 |
} |
| 20 |
|
| 21 |
/* |
| 22 |
* Get the backup path of a specific attachement. |
| 23 |
* |
| 24 |
* @since 1.0 |
| 25 |
* |
| 26 |
* @param int $file_path The attachment path. |
| 27 |
* @return string $backup_path The backup path. |
| 28 |
*/ |
| 29 |
function get_imagify_attachment_backup_path( $file_path ) { |
| 30 |
$upload_dir = wp_upload_dir(); |
| 31 |
$upload_basedir = trailingslashit( $upload_dir['basedir'] ); |
| 32 |
$backup_dir = $upload_basedir . 'backup/'; |
| 33 |
|
| 34 |
/** |
| 35 |
* Filter the backup directory path |
| 36 |
* |
| 37 |
* @since 1.0 |
| 38 |
* |
| 39 |
* @param string $backup_dir The backup directory path |
| 40 |
*/ |
| 41 |
$backup_dir = apply_filters( 'imagify_backup_directory', $backup_dir ); |
| 42 |
$backup_dir = trailingslashit( $backup_dir ); |
| 43 |
|
| 44 |
$backup_path = str_replace( $upload_basedir, $backup_dir, $file_path ); |
| 45 |
return $backup_path; |
| 46 |
} |