Code Duplication    Length = 16-17 lines in 2 locations

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

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

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

@@ 769-785 (lines=17) @@
766
			$dirname              = dirname( $plugin );
767
			$theme_version_latest = '';
768
			if ( strstr( $data['PluginURI'], 'woothemes.com' ) ) {
769
				if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
770
					$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
771
					$cl_lines  = explode( "\n", wp_remote_retrieve_body( $changelog ) );
772
					if ( ! empty( $cl_lines ) ) {
773
						foreach ( $cl_lines as $line_num => $cl_line ) {
774
							if ( preg_match( '/^[0-9]/', $cl_line ) ) {
775
								$date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
776
								$version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
777
								$update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
778
								$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
779
								set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
780
								break;
781
							}
782
						}
783
					}
784
				}
785
				$theme_version_latest = $version_data['version'];
786
			} else {
787
				include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
788
				$slug = explode( '/', $plugin );