Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 7
CRAP
0.00% covered (danger)
0.00%
0 / 1
Jetpack_Post
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 7
90
0.00% covered (danger)
0.00%
0 / 1
 get_like_count
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_liked
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_reblogged
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 is_following
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_global_id
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_geo
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_avatar_url
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
12
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
12if ( ! defined( 'ABSPATH' ) ) {
13    exit( 0 );
14}
15
16/**
17 * Base class for Jetpack_Post.
18 */
19class Jetpack_Post extends SAL_Post {
20    /**
21     * Defines a default value for the like counts on a post, if this hasn't been defined yet.
22     *
23     * @return int Returns 0.
24     **/
25    public function get_like_count() {
26        return 0;
27    }
28
29    /**
30     * Defines a default value for whether or not the current user likes this post, if this hasn't been defined yet.
31     *
32     * @return bool Returns false
33     **/
34    public function is_liked() {
35        return false;
36    }
37
38    /**
39     * Defines a default value for whether or not the current user reblogged this post, if this hasn't been defined yet.
40     *
41     * @return bool Returns false
42     **/
43    public function is_reblogged() {
44        return false;
45    }
46
47    /**
48     * Defines a default value for whether or not the current user is following this blog, if this hasn't been defined yet.
49     *
50     * @return bool Returns false
51     **/
52    public function is_following() {
53        return false;
54    }
55
56    /**
57     * Defines the unique WordPress.com-wide representation of a post, if this hasn't been defined yet.
58     *
59     * @return string Returns an empty string
60     **/
61    public function get_global_id() {
62        return '';
63    }
64
65    /**
66     * Defines a default value for whether or not there is gelocation data for this post, if this hasn't been defined yet.
67     *
68     * @return bool Returns false
69     **/
70    public function get_geo() {
71        return false;
72    }
73
74    /**
75     * Returns the avatar URL for a user, or an empty string if there isn't a valid avatar.
76     *
77     * @param string $email The user's email.
78     * @param int    $avatar_size The size of the avatar in pixels.
79     *
80     * @return string
81     */
82    protected function get_avatar_url( $email, $avatar_size = 96 ) {
83        $avatar_url = get_avatar_url(
84            $email,
85            array(
86                'size' => $avatar_size,
87            )
88        );
89
90        if ( ! $avatar_url || is_wp_error( $avatar_url ) ) {
91            return '';
92        }
93        return $avatar_url;
94    }
95}