| 1 |
<?php |
| 2 |
defined( 'WPINC' ) OR exit; |
| 3 |
|
| 4 |
/** |
| 5 |
* All methods within this class may be considered "documented" and |
| 6 |
* developers may rely on their existence moving forward. If there is |
| 7 |
* a need to remove a method in this class, it will go through a |
| 8 |
* deprecation period before being removed. |
| 9 |
* |
| 10 |
* This guarantee is only provided for this file and class-logger. All |
| 11 |
* other methods throughout Document Gallery may be removed or |
| 12 |
* significantly changed from version-to-version and should not be relied |
| 13 |
* on in any way for external development. |
| 14 |
* |
| 15 |
* NOTE: If you are performing actions related to Document Gallery, you |
| 16 |
* you are encouraged to log important events through the Document Gallery |
| 17 |
* logging interface. This interface is available under the DG_Logger class. |
| 18 |
* |
| 19 |
* @author drossiter |
| 20 |
*/ |
| 21 |
class DG_API { |
| 22 |
/** |
| 23 |
* Sets the thumbnail for the given attachment ID. |
| 24 |
* |
| 25 |
* @param int $ID Document ID. |
| 26 |
* @param string $path System path to thumbnail. |
| 27 |
* @param string $generator Descriptor for generation method -- usually method name. |
| 28 |
* |
| 29 |
* @return bool Whether set was successful. |
| 30 |
*/ |
| 31 |
public static function setThumbnail( $ID, $path, $generator = 'unknown' ) { |
| 32 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 33 |
|
| 34 |
return DG_Thumber::setThumbnail( $ID, $path, $generator ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Sets the thumbnail for the given attachment ID to a failed state. |
| 39 |
* This prevents the plugin attempting to generate a thumbnail for this |
| 40 |
* plugin in the future. |
| 41 |
* |
| 42 |
* @param int $ID The attachment ID. |
| 43 |
*/ |
| 44 |
public static function setThumbnailFailed( $ID ) { |
| 45 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 46 |
|
| 47 |
return DG_Thumber::setThumbnailFailed( $ID ); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* |
| 52 |
* @param int $ID The attachment ID. |
| 53 |
* @param int $pg The page number to use (1-based numbering). |
| 54 |
* @param bool $generate_if_missing Whether to generate the thumbnail if it has not yet been generated. |
| 55 |
* |
| 56 |
* @return string The URL for the thumbnail NULL. Note that if generate_if_missing |
| 57 |
* is true then you will never get NULL -- you will get a default icon if generation fails. |
| 58 |
*/ |
| 59 |
public static function getThumbnail( $ID, $pg = 1, $generate_if_missing = false ) { |
| 60 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 61 |
|
| 62 |
return DG_Thumber::getThumbnail( $ID, $pg, $generate_if_missing ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Removes all metadata related to a thumbnail for the given attachment ID(s). This allows |
| 67 |
* the plugin to attempt to re-generate the thumbnail for this attachment next time it |
| 68 |
* is requested in a gallery or through some other means. |
| 69 |
* |
| 70 |
* @param int|array $ids Which thumbnails to delete. |
| 71 |
* |
| 72 |
* @return array All IDs that were deleted -- some subset of IDs requested to be deleted. |
| 73 |
*/ |
| 74 |
public static function deleteThumbnails( $ids ) { |
| 75 |
include_once DG_PATH . 'inc/class-thumber.php'; |
| 76 |
|
| 77 |
return DG_Thumber::deleteThumbMeta( $ids ); |
| 78 |
} |
| 79 |
} |