Code Duplication    Length = 19-19 lines in 2 locations

json-endpoints/class.wpcom-json-api-post-endpoint.php 1 location

@@ 590-608 (lines=19) @@
587
	 *
588
	 * @return object
589
	 */
590
	function get_attachment( $attachment ) {
591
		$metadata = wp_get_attachment_metadata( $attachment->ID );
592
593
		$result = array(
594
			'ID'		=> (int) $attachment->ID,
595
			'URL'           => (string) wp_get_attachment_url( $attachment->ID ),
596
			'guid'		=> (string) $attachment->guid,
597
			'mime_type'	=> (string) $attachment->post_mime_type,
598
			'width'		=> (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
599
			'height'	=> (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
600
		);
601
602
		if ( isset( $metadata['duration'] ) ) {
603
			$result['duration'] = (int) $metadata['duration'];
604
		}
605
606
		return (object) apply_filters( 'get_attachment', $result );
607
	}
608
609
	/**
610
	 * Get post-specific user capabilities
611
	 * @param  WP_Post $post              post object

sal/class.json-api-post-base.php 1 location

@@ 288-306 (lines=19) @@
285
		return $format;
286
	}
287
288
	private function get_attachment( $attachment ) {
289
		$metadata = wp_get_attachment_metadata( $attachment->ID );
290
291
		$result = array(
292
			'ID'        => (int) $attachment->ID,
293
			'URL'       => (string) wp_get_attachment_url( $attachment->ID ),
294
			'guid'      => (string) $attachment->guid,
295
			'mime_type' => (string) $attachment->post_mime_type,
296
			'width'     => (int) isset( $metadata['width']  ) ? $metadata['width']  : 0,
297
			'height'    => (int) isset( $metadata['height'] ) ? $metadata['height'] : 0,
298
		);
299
300
		if ( isset( $metadata['duration'] ) ) {
301
			$result['duration'] = (int) $metadata['duration'];
302
		}
303
304
		/** This filter is documented in class.jetpack-sync.php */
305
		return (object) apply_filters( 'get_attachment', $result );
306
	}
307
308
	public function get_date() {
309
		return (string) WPCOM_JSON_API_Date::format_date( $this->post->post_date_gmt, $this->post->post_date );