PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | _inc/lib/core-api/wpcom-endpoints/sites-posts-featured-media-url.php +10 -0 12.7.3 → 16.3-beta View file →
@@ -5,8 +5,12 @@
5 5 *
6 6 * @package automattic/jetpack
7 7 */
8 8
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit( 0 );
11 +}
12 +
9 13 /**
10 14 * Add featured media url to API post responses.
11 15 */
12 16 class WPCOM_REST_API_V2_Sites_Posts_Add_Featured_Media_URL {
@@ -37,10 +41,16 @@
37 41 *
38 42 * @param mixed $object What the endpoint returns.
39 43 * @param string $field_name Should always match `->field_name`.
40 44 * @param WP_REST_Request $request WP API request.
45 + *
46 + * @return string
41 47 */
42 48 public function get_featured_media_url( $object, $field_name, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
49 + if ( ! isset( $object['id'] ) ) {
50 + return '';
51 + }
52 +
43 53 $featured_media_url = '';
44 54 $image_attributes = wp_get_attachment_image_src(
45 55 get_post_thumbnail_id( $object['id'] ),
46 56 'full'