Code Duplication    Length = 11-12 lines in 2 locations

_inc/lib/class.media.php 1 location

@@ 73-84 (lines=12) @@
70
	 * @param  number $media_id
71
	 * @return string
72
	 */
73
	private function get_time_string_from_guid( $media_id ) {
74
		$time = date( "Y/m", strtotime( current_time( 'mysql' ) ) );
75
76
		if ( $media = get_post( $media_id ) ) {
77
			$pattern = '/\/(\d{4}\/\d{2})\//';
78
			preg_match( $pattern, $media->guid, $matches );
79
			if ( count( $matches ) > 1 ) {
80
				$time = $matches[1];
81
			}
82
		}
83
		return $time;
84
	}
85
86
	/**
87
	 * Return an array of allowed mime_type items used to upload a media file.

json-endpoints/class.wpcom-json-api-edit-media-v1-2-endpoint.php 1 location

@@ 265-275 (lines=11) @@
262
	 *
263
	 * @return string
264
	 */
265
	private function get_time_string_from_guid( $media_id ) {
266
		$time = date( "Y/m", strtotime( current_time( 'mysql' ) ) );
267
		if ( $media = get_post( $media_id ) ) {
268
			$pattern = '/\/(\d{4}\/\d{2})\//';
269
			preg_match( $pattern, $media->guid, $matches );
270
			if ( count( $matches ) > 1 ) {
271
				$time = $matches[1];
272
			}
273
		}
274
		return $time;
275
	}
276
277
	/**
278
	 * Get the image from a remote url and then save it locally.