| 1 |
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 |
/** |
| 3 |
* This class extends the SAL_Post class, providing the implementation for |
| 4 |
* functions that were declared in that SAL_Post class. |
| 5 |
* |
| 6 |
* @see WPCOM_JSON_API_Post_v1_1_Endpoint in class.wpcom-json-api-post-v1-1-endpoint.php for more context on |
| 7 |
* the functions implemented here. |
| 8 |
* |
| 9 |
* @package automattic/jetpack |
| 10 |
*/ |
| 11 |
/** |
| 12 |
* Base class for Jetpack_Post. |
| 13 |
*/ |
| 14 |
class Jetpack_Post extends SAL_Post { |
| 15 |
/** |
| 16 |
* Defines a default value for the like counts on a post, if this hasn't been defined yet. |
| 17 |
* |
| 18 |
* @return int Returns 0. |
| 19 |
**/ |
| 20 |
public function get_like_count() { |
| 21 |
return 0; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Defines a default value for whether or not the current user likes this post, if this hasn't been defined yet. |
| 26 |
* |
| 27 |
* @return bool Returns false |
| 28 |
**/ |
| 29 |
public function is_liked() { |
| 30 |
return false; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Defines a default value for whether or not the current user reblogged this post, if this hasn't been defined yet. |
| 35 |
* |
| 36 |
* @return bool Returns false |
| 37 |
**/ |
| 38 |
public function is_reblogged() { |
| 39 |
return false; |
| 40 |
} |
| 41 |
|
| 42 |
/** |
| 43 |
* Defines a default value for whether or not the current user is following this blog, if this hasn't been defined yet. |
| 44 |
* |
| 45 |
* @return bool Returns false |
| 46 |
**/ |
| 47 |
public function is_following() { |
| 48 |
return false; |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Defines the unique WordPress.com-wide representation of a post, if this hasn't been defined yet. |
| 53 |
* |
| 54 |
* @return string Returns an empty string |
| 55 |
**/ |
| 56 |
public function get_global_id() { |
| 57 |
return ''; |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Defines a default value for whether or not there is gelocation data for this post, if this hasn't been defined yet. |
| 62 |
* |
| 63 |
* @return bool Returns false |
| 64 |
**/ |
| 65 |
public function get_geo() { |
| 66 |
return false; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Returns the avatar URL for a user, or an empty string if there isn't a valid avatar. |
| 71 |
* |
| 72 |
* @param string $email The user's email. |
| 73 |
* @param int $avatar_size The size of the avatar in pixels. |
| 74 |
* |
| 75 |
* @return string |
| 76 |
*/ |
| 77 |
protected function get_avatar_url( $email, $avatar_size = 96 ) { |
| 78 |
$avatar_url = get_avatar_url( |
| 79 |
$email, |
| 80 |
array( |
| 81 |
'size' => $avatar_size, |
| 82 |
) |
| 83 |
); |
| 84 |
|
| 85 |
if ( ! $avatar_url || is_wp_error( $avatar_url ) ) { |
| 86 |
return ''; |
| 87 |
} |
| 88 |
return $avatar_url; |
| 89 |
} |
| 90 |
} |
| 91 |
|