Code Duplication    Length = 16-17 lines in 2 locations

includes/api/class-wc-rest-system-status-controller.php 1 location

@@ 585-601 (lines=17) @@
582
			$dirname              = dirname( $plugin );
583
			$theme_version_latest = '';
584
			if ( strstr( $data['PluginURI'], 'woothemes.com' ) ) {
585
				if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
586
					$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
587
					$cl_lines  = explode( "\n", wp_remote_retrieve_body( $changelog ) );
588
					if ( ! empty( $cl_lines ) ) {
589
						foreach ( $cl_lines as $line_num => $cl_line ) {
590
							if ( preg_match( '/^[0-9]/', $cl_line ) ) {
591
								$date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
592
								$version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
593
								$update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
594
								$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
595
								set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
596
								break;
597
							}
598
						}
599
					}
600
				}
601
				$theme_version_latest = $version_data['version'];
602
			} else {
603
				include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
604
				$slug = explode( '/', $plugin );

includes/admin/class-wc-admin-status.php 1 location

@@ 217-232 (lines=16) @@
214
		} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) {
215
			$theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 );
216
217
			if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) {
218
				$theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
219
				$cl_lines  = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
220
				if ( ! empty( $cl_lines ) ) {
221
					foreach ( $cl_lines as $line_num => $cl_line ) {
222
						if ( preg_match( '/^[0-9]/', $cl_line ) ) {
223
							$theme_date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
224
							$theme_version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
225
							$theme_update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
226
							$theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog );
227
							set_transient( $theme_dir . '_version_data', $theme_version_data , DAY_IN_SECONDS );
228
							break;
229
						}
230
					}
231
				}
232
			}
233
234
			if ( ! empty( $theme_version_data['version'] ) ) {
235
				$update_theme_version = $theme_version_data['version'];