| 1 |
<?php |
| 2 |
namespace Imagify\CDN; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 5 |
|
| 6 |
/** |
| 7 |
* Interface to use for Push CDNs. |
| 8 |
* |
| 9 |
* @since 1.9 |
| 10 |
* @author Grégory Viguier |
| 11 |
*/ |
| 12 |
interface PushCDNInterface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Tell if the CDN is ready (not necessarily reachable). |
| 16 |
* |
| 17 |
* @since 1.9 |
| 18 |
* @access public |
| 19 |
* @author Grégory Viguier |
| 20 |
* |
| 21 |
* @return bool |
| 22 |
*/ |
| 23 |
public function is_ready(); |
| 24 |
|
| 25 |
/** |
| 26 |
* Tell if the media is on the CDN. |
| 27 |
* |
| 28 |
* @since 1.9 |
| 29 |
* @access public |
| 30 |
* @author Grégory Viguier |
| 31 |
* |
| 32 |
* @return bool |
| 33 |
*/ |
| 34 |
public function media_is_on_cdn(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Get files from the CDN. |
| 38 |
* |
| 39 |
* @since 1.9 |
| 40 |
* @access public |
| 41 |
* @author Grégory Viguier |
| 42 |
* |
| 43 |
* @param array $file_paths A list of file paths. |
| 44 |
* @return bool|\WP_Error True on success. A \WP_error object on failure. |
| 45 |
*/ |
| 46 |
public function get_files_from_cdn( $file_paths ); |
| 47 |
|
| 48 |
/** |
| 49 |
* Remove files from the CDN. |
| 50 |
* Don't use this to empty a folder. |
| 51 |
* |
| 52 |
* @since 1.9 |
| 53 |
* @access public |
| 54 |
* @author Grégory Viguier |
| 55 |
* |
| 56 |
* @param array $file_paths A list of file paths. Those paths are not necessary absolute, and can be also file names. |
| 57 |
* @return bool|\WP_Error True on success. A \WP_error object on failure. |
| 58 |
*/ |
| 59 |
public function remove_files_from_cdn( $file_paths ); |
| 60 |
|
| 61 |
/** |
| 62 |
* Send all files from a media to the CDN. |
| 63 |
* |
| 64 |
* @since 1.9 |
| 65 |
* @access public |
| 66 |
* @author Grégory Viguier |
| 67 |
* |
| 68 |
* @param bool $is_new_upload Tell if the current media is a new upload. If not, it means it's a media being regenerated, restored, etc. |
| 69 |
* @return bool|\WP_Error True/False if sent or not. A \WP_error object on failure. |
| 70 |
*/ |
| 71 |
public function send_to_cdn( $is_new_upload ); |
| 72 |
|
| 73 |
/** |
| 74 |
* Get a file URL. |
| 75 |
* |
| 76 |
* @since 1.9 |
| 77 |
* @access public |
| 78 |
* @author Grégory Viguier |
| 79 |
* |
| 80 |
* @param string $file_name Name of the file. Leave empty for the full size file. |
| 81 |
* @return string URL to the file. |
| 82 |
*/ |
| 83 |
public function get_file_url( $file_name = false ); |
| 84 |
|
| 85 |
/** |
| 86 |
* Get a file path. |
| 87 |
* |
| 88 |
* @since 1.9 |
| 89 |
* @access public |
| 90 |
* @author Grégory Viguier |
| 91 |
* |
| 92 |
* @param string $file_name Name of the file. Leave empty for the full size file. Use 'original' to get the path to the original file. |
| 93 |
* @return string Path to the file. |
| 94 |
*/ |
| 95 |
public function get_file_path( $file_name = false ); |
| 96 |
} |
| 97 |
|