Code Duplication    Length = 16-17 lines in 2 locations

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

@@ 321-336 (lines=16) @@
318
		} elseif ( strstr( $theme->{'Author URI'}, 'woothemes' ) ) {
319
			$theme_dir = substr( strtolower( str_replace( ' ','', $theme->Name ) ), 0, 45 );
320
321
			if ( false === ( $theme_version_data = get_transient( $theme_dir . '_version_data' ) ) ) {
322
				$theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' );
323
				$cl_lines  = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) );
324
				if ( ! empty( $cl_lines ) ) {
325
					foreach ( $cl_lines as $line_num => $cl_line ) {
326
						if ( preg_match( '/^[0-9]/', $cl_line ) ) {
327
							$theme_date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
328
							$theme_version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
329
							$theme_update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
330
							$theme_version_data = array( 'date' => $theme_date , 'version' => $theme_version , 'update' => $theme_update , 'changelog' => $theme_changelog );
331
							set_transient( $theme_dir . '_version_data', $theme_version_data , DAY_IN_SECONDS );
332
							break;
333
						}
334
					}
335
				}
336
			}
337
338
			if ( ! empty( $theme_version_data['version'] ) ) {
339
				$update_theme_version = $theme_version_data['version'];

includes/admin/views/html-admin-page-status-report.php 1 location

@@ 428-444 (lines=17) @@
425
426
				if ( strstr( $dirname, 'woocommerce-' ) && strstr( $plugin_data['PluginURI'], 'woothemes.com' ) ) {
427
428
					if ( false === ( $version_data = get_transient( md5( $plugin ) . '_version_data' ) ) ) {
429
						$changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $dirname . '/changelog.txt' );
430
						$cl_lines  = explode( "\n", wp_remote_retrieve_body( $changelog ) );
431
						if ( ! empty( $cl_lines ) ) {
432
							foreach ( $cl_lines as $line_num => $cl_line ) {
433
								if ( preg_match( '/^[0-9]/', $cl_line ) ) {
434
435
									$date         = str_replace( '.' , '-' , trim( substr( $cl_line , 0 , strpos( $cl_line , '-' ) ) ) );
436
									$version      = preg_replace( '~[^0-9,.]~' , '' ,stristr( $cl_line , "version" ) );
437
									$update       = trim( str_replace( "*" , "" , $cl_lines[ $line_num + 1 ] ) );
438
									$version_data = array( 'date' => $date , 'version' => $version , 'update' => $update , 'changelog' => $changelog );
439
									set_transient( md5( $plugin ) . '_version_data', $version_data, DAY_IN_SECONDS );
440
									break;
441
								}
442
							}
443
						}
444
					}
445
446
					if ( ! empty( $version_data['version'] ) && version_compare( $version_data['version'], $plugin_data['Version'], '>' ) ) {
447
						$version_string = ' &ndash; <strong style="color:red;">' . esc_html( sprintf( _x( '%s is available', 'Version info', 'woocommerce' ), $version_data['version'] ) ) . '</strong>';