Skip to content

Commit 23a864b

Browse files
author
mohamedhk2
committed
refactor code
1 parent f730b7a commit 23a864b

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

main.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,9 @@
3131
} );
3232

3333
if ( ! file_exists( $patcher_file = __DIR__ . DIRECTORY_SEPARATOR . 'Patcher.php' ) ) {
34-
$patcher = file_get_contents( $githubusercontent = 'https://raw.githubusercontent.com/mohamedhk2/php-patcher/v1.0.6/src/Patcher.php' );
35-
if ( $patcher ) {
36-
put_content:
37-
$put_contents = file_put_contents( $patcher_file, $patcher );
38-
if ( $put_contents === false ) {
39-
unlink( $patcher_file );
40-
41-
return;
42-
}
43-
} else {
44-
$res = wp_remote_get( $githubusercontent );
45-
if ( ! is_wp_error( $res ) && ( $res['response']['code'] == 200 ) ) {
46-
$patcher = $res['body'];
47-
goto put_content;
48-
} else {
49-
return;
50-
}
34+
$patcher = $download_file( 'https://raw.githubusercontent.com/mohamedhk2/php-patcher/v1.0.6/src/Patcher.php', $patcher_file );
35+
if ( ! $patcher ) {
36+
return;
5137
}
5238
}
5339
if ( ! class_exists( 'Mohamedhk2\PhpPatcher\Patcher' ) ) {

0 commit comments

Comments
 (0)