| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Frontend\Schema |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Returns schema image data. |
| 10 |
* |
| 11 |
* @since 11.1 |
| 12 |
* |
| 13 |
* @deprecated 14.0 |
| 14 |
* |
| 15 |
* @property string $schema_id The `@id` to use for the returned image. |
| 16 |
* @property array $data The ImageObject Schema array. |
| 17 |
* @property int $attachment_id The ID of the attachment used to generate the object. |
| 18 |
*/ |
| 19 |
class WPSEO_Schema_Image { |
| 20 |
|
| 21 |
/** |
| 22 |
* Value to use as the image id. |
| 23 |
* |
| 24 |
* @var string |
| 25 |
*/ |
| 26 |
private $schema_id; |
| 27 |
|
| 28 |
/** |
| 29 |
* WPSEO_Schema_Image constructor. |
| 30 |
* |
| 31 |
* @codeCoverageIgnore |
| 32 |
* @deprecated 14.0 |
| 33 |
* |
| 34 |
* @param string $schema_id The string to use in an image's `@id`. |
| 35 |
*/ |
| 36 |
public function __construct( $schema_id ) { |
| 37 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image' ); |
| 38 |
$this->schema_id = $schema_id; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Find an image based on its URL and generate a Schema object for it. |
| 43 |
* |
| 44 |
* @codeCoverageIgnore |
| 45 |
* @deprecated 14.0 |
| 46 |
* |
| 47 |
* @param string $url The image URL to base our object on. |
| 48 |
* @param string $caption An optional caption. |
| 49 |
* |
| 50 |
* @return array Schema ImageObject array. |
| 51 |
*/ |
| 52 |
public function generate_from_url( $url, $caption = '' ) { |
| 53 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_url' ); |
| 54 |
return YoastSEO()->helpers->schema->image->generate_from_url( $this->schema_id, $url, $caption ); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Retrieve data about an image from the database and use it to generate a Schema object. |
| 59 |
* |
| 60 |
* @codeCoverageIgnore |
| 61 |
* @deprecated 14.0 |
| 62 |
* |
| 63 |
* @param int $attachment_id The attachment to retrieve data from. |
| 64 |
* @param string $caption The caption string, if there is one. |
| 65 |
* |
| 66 |
* @return array Schema ImageObject array. |
| 67 |
*/ |
| 68 |
public function generate_from_attachment_id( $attachment_id, $caption = '' ) { |
| 69 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->generate_from_attachment_id' ); |
| 70 |
return YoastSEO()->helpers->schema->image->generate_from_attachment_id( $this->schema_id, $attachment_id, $caption ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* If we can't find $url in our database, we output a simple ImageObject. |
| 75 |
* |
| 76 |
* @codeCoverageIgnore |
| 77 |
* @deprecated 14.0 |
| 78 |
* |
| 79 |
* @param string $url The image URL. |
| 80 |
* @param string $caption A caption, if set. |
| 81 |
* |
| 82 |
* @return array Schema ImageObject array. |
| 83 |
*/ |
| 84 |
public function simple_image_object( $url, $caption = '' ) { |
| 85 |
_deprecated_function( __METHOD__, 'WPSEO 14.0', 'YoastSEO()->helpers->schema->image->simple_image_object' ); |
| 86 |
return YoastSEO()->helpers->schema->image->simple_image_object( $this->schema_id, $url, $caption ); |
| 87 |
} |
| 88 |
} |
| 89 |
|