| @@ -37,19 +37,8 @@ | ||
| 37 | 37 | |
| 38 | 38 | $body = wp_remote_retrieve_body( $response ); |
| 39 | 39 | $headers = wp_remote_retrieve_headers( $response ); |
| 40 | 40 | |
| 41 | - // validate image | |
| 42 | - $filesystem = self::filesystem(); | |
| 43 | - $tmpfile = tempnam( '/tmp', 'assistant' ); | |
| 44 | - $filesystem->put_contents( $tmpfile, $body ); | |
| 45 | - $validimage = wp_get_image_mime( $tmpfile ); | |
| 46 | - $filesystem->delete( $tmpfile ); | |
| 47 | - | |
| 48 | - if ( ! $validimage ) { | |
| 49 | - return false; | |
| 50 | - } | |
| 51 | - | |
| 52 | 41 | if ( ! isset( $headers['content-type'] ) ) { |
| 53 | 42 | return; |
| 54 | 43 | } elseif ( 0 !== strpos( $headers['content-type'], 'image/' ) ) { |
| 55 | 44 | return; |
| @@ -57,17 +46,6 @@ | ||
| 57 | 46 | |
| 58 | 47 | header( 'Content-type: ' . $headers['content-type'] ); |
| 59 | 48 | echo $body; |
| 60 | 49 | die(); |
| 61 | - } | |
| 62 | - | |
| 63 | - private function filesystem() { | |
| 64 | - global $wp_filesystem; | |
| 65 | - | |
| 66 | - if ( is_null( $wp_filesystem ) ) { | |
| 67 | - require_once ABSPATH . '/wp-admin/includes/file.php'; | |
| 68 | - WP_Filesystem(); | |
| 69 | - } | |
| 70 | - | |
| 71 | - return $wp_filesystem; | |
| 72 | 50 | } |
| 73 | 51 | } |