| 1 |
<?php |
| 2 |
namespace epiphyt\Embed_Privacy\thumbnail\provider; |
| 3 |
|
| 4 |
use epiphyt\Embed_Privacy\thumbnail\Thumbnail; |
| 5 |
|
| 6 |
/** |
| 7 |
* An abstract implementation of a thumbnail provider. |
| 8 |
* |
| 9 |
* @author Epiphyt |
| 10 |
* @license GPL2 |
| 11 |
* @package epiphyt\Embed_Privacy |
| 12 |
*/ |
| 13 |
abstract class Thumbnail_Provider implements Thumbnail_Provider_Interface { |
| 14 |
/** |
| 15 |
* @var string[] List of valid domains for the thumbnail provider |
| 16 |
*/ |
| 17 |
public static $domains = []; |
| 18 |
|
| 19 |
/** |
| 20 |
* @var string Thumbnail provider name |
| 21 |
*/ |
| 22 |
public static $name = ''; |
| 23 |
|
| 24 |
/** |
| 25 |
* {@inheritDoc} |
| 26 |
*/ |
| 27 |
public static function get( $data, $url ) { } // phpcs:ignore SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction |
| 28 |
|
| 29 |
/** |
| 30 |
* {@inheritDoc} |
| 31 |
*/ |
| 32 |
public static function get_id( $url ) { } // phpcs:ignore SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction |
| 33 |
|
| 34 |
/** |
| 35 |
* {@inheritDoc} |
| 36 |
*/ |
| 37 |
public static function get_path( $filename ) { |
| 38 |
return Thumbnail::get_directory()['base_dir'] . '/' . $filename; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* {@inheritDoc} |
| 43 |
*/ |
| 44 |
public static function get_title() { |
| 45 |
return ''; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* {@inheritDoc} |
| 50 |
*/ |
| 51 |
public static function get_url( $filename ) { |
| 52 |
return Thumbnail::get_directory()['base_url'] . '/' . $filename; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* {@inheritDoc} |
| 57 |
*/ |
| 58 |
public static function is_provider_embed( $url ) { |
| 59 |
$is_provider_embed = false; |
| 60 |
|
| 61 |
foreach ( static::$domains as $domain ) { |
| 62 |
if ( \str_contains( $url, $domain ) ) { |
| 63 |
$is_provider_embed = true; |
| 64 |
break; |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
return $is_provider_embed; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* {@inheritDoc} |
| 73 |
*/ |
| 74 |
public static function save( $id, $url, $thumbnail_url = '' ) { } // phpcs:ignore SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction |
| 75 |
} |
| 76 |
|