Code Duplication    Length = 16-17 lines in 2 locations

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

@@ 337-352 (lines=16) @@
334
		} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) {
335
			$theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 );
336
337
			if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) {
338
				$theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
339
				$cl_lines  = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
340
				if ( ! empty( $cl_lines ) ) {
341
					foreach ( $cl_lines as $line_num => $cl_line ) {
342
						if ( preg_match( '/^[0-9]/', $cl_line ) ) {
343
							$theme_date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
344
							$theme_version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
345
							$theme_update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
346
							$theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog );
347
							set_transient( $theme_dir . '_version_data', $theme_version_data , DAY_IN_SECONDS );
348
							break;
349
						}
350
					}
351
				}
352
			}
353
354
			if ( ! empty( $theme_version_data['version'] ) ) {
355
				$update_theme_version = $theme_version_data['version'];

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 );