| 1 |
<?php |
| 2 |
namespace Imagify\Context; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 5 |
|
| 6 |
/** |
| 7 |
* Interface to use for contexts. |
| 8 |
* |
| 9 |
* @since 1.9 |
| 10 |
* @author Grégory Viguier |
| 11 |
*/ |
| 12 |
interface ContextInterface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Get the main Instance. |
| 16 |
* |
| 17 |
* @since 1.9 |
| 18 |
* @access protected |
| 19 |
* @author Grégory Viguier |
| 20 |
* |
| 21 |
* @return object Main instance. |
| 22 |
*/ |
| 23 |
public static function get_instance(); |
| 24 |
|
| 25 |
/** |
| 26 |
* Get the context "short name". |
| 27 |
* |
| 28 |
* @since 1.9 |
| 29 |
* @access public |
| 30 |
* @author Grégory Viguier |
| 31 |
* |
| 32 |
* @return string |
| 33 |
*/ |
| 34 |
public function get_name(); |
| 35 |
|
| 36 |
/** |
| 37 |
* Tell if the context is network-wide. |
| 38 |
* |
| 39 |
* @since 1.9 |
| 40 |
* @access public |
| 41 |
* @author Grégory Viguier |
| 42 |
* |
| 43 |
* @return bool |
| 44 |
*/ |
| 45 |
public function is_network_wide(); |
| 46 |
|
| 47 |
/** |
| 48 |
* Get the type of files this context allows. |
| 49 |
* |
| 50 |
* @since 1.9 |
| 51 |
* @access protected |
| 52 |
* @see imagify_get_mime_types() |
| 53 |
* @author Grégory Viguier |
| 54 |
* |
| 55 |
* @return string Possible values are: |
| 56 |
* - 'all' to allow all types. |
| 57 |
* - 'image' to allow only images. |
| 58 |
* - 'not-image' to allow only pdf files. |
| 59 |
*/ |
| 60 |
public function get_allowed_mime_types(); |
| 61 |
|
| 62 |
/** |
| 63 |
* Get the thumbnail sizes for this context, except the full size. |
| 64 |
* |
| 65 |
* @since 1.9 |
| 66 |
* @access public |
| 67 |
* @author Grégory Viguier |
| 68 |
* |
| 69 |
* @return array { |
| 70 |
* Data for the currently registered thumbnail sizes. |
| 71 |
* Size names are used as array keys. |
| 72 |
* |
| 73 |
* @type int $width The image width. |
| 74 |
* @type int $height The image height. |
| 75 |
* @type bool $crop True to crop, false to resize. |
| 76 |
* @type string $name The size name. |
| 77 |
* } |
| 78 |
*/ |
| 79 |
public function get_thumbnail_sizes(); |
| 80 |
|
| 81 |
/** |
| 82 |
* Tell if the optimization process is allowed resize in this context. |
| 83 |
* |
| 84 |
* @since 1.9 |
| 85 |
* @access public |
| 86 |
* @author Grégory Viguier |
| 87 |
* |
| 88 |
* @return bool |
| 89 |
*/ |
| 90 |
public function can_resize(); |
| 91 |
|
| 92 |
/** |
| 93 |
* Tell if the optimization process is allowed to backup in this context. |
| 94 |
* |
| 95 |
* @since 1.9 |
| 96 |
* @access public |
| 97 |
* @author Grégory Viguier |
| 98 |
* |
| 99 |
* @return bool |
| 100 |
*/ |
| 101 |
public function can_backup(); |
| 102 |
|
| 103 |
/** |
| 104 |
* Tell if the optimization process is allowed to keep exif in this context. |
| 105 |
* |
| 106 |
* @since 1.9 |
| 107 |
* @access public |
| 108 |
* @author Grégory Viguier |
| 109 |
* |
| 110 |
* @return bool |
| 111 |
*/ |
| 112 |
public function can_keep_exif(); |
| 113 |
|
| 114 |
/** |
| 115 |
* Tell if the current user is allowed to operate Imagify in this context. |
| 116 |
* |
| 117 |
* @since 1.9 |
| 118 |
* @access public |
| 119 |
* @author Grégory Viguier |
| 120 |
* |
| 121 |
* @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity. |
| 122 |
* @param int $media_id A media ID. |
| 123 |
* @return bool |
| 124 |
*/ |
| 125 |
public function current_user_can( $describer, $media_id = null ); |
| 126 |
|
| 127 |
/** |
| 128 |
* Tell if a user is allowed to operate Imagify in this context. |
| 129 |
* |
| 130 |
* @since 1.9 |
| 131 |
* @access public |
| 132 |
* @author Grégory Viguier |
| 133 |
* |
| 134 |
* @param int $user_id A user ID. |
| 135 |
* @param string $describer Capacity describer. See $this->get_capacity() for possible values. Can also be a "real" user capacity. |
| 136 |
* @param int $media_id A media ID. |
| 137 |
* @return bool |
| 138 |
*/ |
| 139 |
public function user_can( $user_id, $describer, $media_id = null ); |
| 140 |
|
| 141 |
/** |
| 142 |
* Get user capacity to operate Imagify in this context. |
| 143 |
* |
| 144 |
* @since 1.9 |
| 145 |
* @since 1.9 The describer 'auto-optimize' is not used anymore. |
| 146 |
* @access public |
| 147 |
* @author Grégory Viguier |
| 148 |
* |
| 149 |
* @param string $describer Capacity describer. Possible values are like 'manage', 'bulk-optimize', 'manual-optimize', 'auto-optimize'. |
| 150 |
* @return string |
| 151 |
*/ |
| 152 |
public function get_capacity( $describer ); |
| 153 |
} |
| 154 |
|