Completed
Push — develop ( 36a199...920e68 )
by David
01:14
created
src/modules/super-resolution/vendor/composer/platform_check.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -4,23 +4,23 @@
 block discarded – undo
4 4
 
5 5
 $issues = array();
6 6
 
7
-if (!(PHP_VERSION_ID >= 50600)) {
8
-    $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.';
7
+if ( ! (PHP_VERSION_ID >= 50600)) {
8
+    $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running '.PHP_VERSION.'.';
9 9
 }
10 10
 
11 11
 if ($issues) {
12
-    if (!headers_sent()) {
12
+    if ( ! headers_sent()) {
13 13
         header('HTTP/1.1 500 Internal Server Error');
14 14
     }
15
-    if (!ini_get('display_errors')) {
15
+    if ( ! ini_get('display_errors')) {
16 16
         if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
17
-            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
18
-        } elseif (!headers_sent()) {
19
-            echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
17
+            fwrite(STDERR, 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.implode(PHP_EOL, $issues).PHP_EOL.PHP_EOL);
18
+        } elseif ( ! headers_sent()) {
19
+            echo 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)).PHP_EOL.PHP_EOL;
20 20
         }
21 21
     }
22 22
     trigger_error(
23
-        'Composer detected issues in your platform: ' . implode(' ', $issues),
23
+        'Composer detected issues in your platform: '.implode(' ', $issues),
24 24
         E_USER_ERROR
25 25
     );
26 26
 }
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/ClassLoader.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getPrefixes()
115 115
     {
116
-        if (!empty($this->prefixesPsr0)) {
116
+        if ( ! empty($this->prefixesPsr0)) {
117 117
             return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
118 118
         }
119 119
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function add($prefix, $paths, $prepend = false)
185 185
     {
186
-        if (!$prefix) {
186
+        if ( ! $prefix) {
187 187
             if ($prepend) {
188 188
                 $this->fallbackDirsPsr0 = array_merge(
189 189
                     (array) $paths,
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         }
201 201
 
202 202
         $first = $prefix[0];
203
-        if (!isset($this->prefixesPsr0[$first][$prefix])) {
203
+        if ( ! isset($this->prefixesPsr0[$first][$prefix])) {
204 204
             $this->prefixesPsr0[$first][$prefix] = (array) $paths;
205 205
 
206 206
             return;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function addPsr4($prefix, $paths, $prepend = false)
234 234
     {
235
-        if (!$prefix) {
235
+        if ( ! $prefix) {
236 236
             // Register directories for the root namespace.
237 237
             if ($prepend) {
238 238
                 $this->fallbackDirsPsr4 = array_merge(
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     (array) $paths
246 246
                 );
247 247
             }
248
-        } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
248
+        } elseif ( ! isset($this->prefixDirsPsr4[$prefix])) {
249 249
             // Register directories for a new namespace.
250 250
             $length = strlen($prefix);
251 251
             if ('\\' !== $prefix[$length - 1]) {
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function set($prefix, $paths)
281 281
     {
282
-        if (!$prefix) {
282
+        if ( ! $prefix) {
283 283
             $this->fallbackDirsPsr0 = (array) $paths;
284 284
         } else {
285 285
             $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      */
300 300
     public function setPsr4($prefix, $paths)
301 301
     {
302
-        if (!$prefix) {
302
+        if ( ! $prefix) {
303 303
             $this->fallbackDirsPsr4 = (array) $paths;
304 304
         } else {
305 305
             $length = strlen($prefix);
@@ -493,18 +493,18 @@  discard block
 block discarded – undo
493 493
     private function findFileWithExtension($class, $ext)
494 494
     {
495 495
         // PSR-4 lookup
496
-        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
496
+        $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext;
497 497
 
498 498
         $first = $class[0];
499 499
         if (isset($this->prefixLengthsPsr4[$first])) {
500 500
             $subPath = $class;
501 501
             while (false !== $lastPos = strrpos($subPath, '\\')) {
502 502
                 $subPath = substr($subPath, 0, $lastPos);
503
-                $search = $subPath . '\\';
503
+                $search = $subPath.'\\';
504 504
                 if (isset($this->prefixDirsPsr4[$search])) {
505
-                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
505
+                    $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1);
506 506
                     foreach ($this->prefixDirsPsr4[$search] as $dir) {
507
-                        if (file_exists($file = $dir . $pathEnd)) {
507
+                        if (file_exists($file = $dir.$pathEnd)) {
508 508
                             return $file;
509 509
                         }
510 510
                     }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
         // PSR-4 fallback dirs
516 516
         foreach ($this->fallbackDirsPsr4 as $dir) {
517
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
517
+            if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) {
518 518
                 return $file;
519 519
             }
520 520
         }
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
                 . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
527 527
         } else {
528 528
             // PEAR-like class name
529
-            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
529
+            $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext;
530 530
         }
531 531
 
532 532
         if (isset($this->prefixesPsr0[$first])) {
533 533
             foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
534 534
                 if (0 === strpos($class, $prefix)) {
535 535
                     foreach ($dirs as $dir) {
536
-                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
536
+                        if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) {
537 537
                             return $file;
538 538
                         }
539 539
                     }
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 
544 544
         // PSR-0 fallback dirs
545 545
         foreach ($this->fallbackDirsPsr0 as $dir) {
546
-            if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
546
+            if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) {
547 547
                 return $file;
548 548
             }
549 549
         }
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/installed.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
         'version' => 'dev-develop',
6 6
         'reference' => 'dda97f31765f2ae4ff280705bde62ef2fe76ce01',
7 7
         'type' => 'wordpress-plugin',
8
-        'install_path' => __DIR__ . '/../../',
8
+        'install_path' => __DIR__.'/../../',
9 9
         'aliases' => array(),
10 10
         'dev' => true,
11 11
     ),
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             'version' => 'dev-develop',
16 16
             'reference' => 'dda97f31765f2ae4ff280705bde62ef2fe76ce01',
17 17
             'type' => 'wordpress-plugin',
18
-            'install_path' => __DIR__ . '/../../',
18
+            'install_path' => __DIR__.'/../../',
19 19
             'aliases' => array(),
20 20
             'dev_requirement' => false,
21 21
         ),
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/InstalledVersions.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     {
99 99
         foreach (self::getInstalled() as $installed) {
100 100
             if (isset($installed['versions'][$packageName])) {
101
-                return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
101
+                return $includeDevRequirements || ! isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
102 102
             }
103 103
         }
104 104
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     public static function getVersionRanges($packageName)
138 138
     {
139 139
         foreach (self::getInstalled() as $installed) {
140
-            if (!isset($installed['versions'][$packageName])) {
140
+            if ( ! isset($installed['versions'][$packageName])) {
141 141
                 continue;
142 142
             }
143 143
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             return implode(' || ', $ranges);
159 159
         }
160 160
 
161
-        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
161
+        throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed');
162 162
     }
163 163
 
164 164
     /**
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
     public static function getVersion($packageName)
169 169
     {
170 170
         foreach (self::getInstalled() as $installed) {
171
-            if (!isset($installed['versions'][$packageName])) {
171
+            if ( ! isset($installed['versions'][$packageName])) {
172 172
                 continue;
173 173
             }
174 174
 
175
-            if (!isset($installed['versions'][$packageName]['version'])) {
175
+            if ( ! isset($installed['versions'][$packageName]['version'])) {
176 176
                 return null;
177 177
             }
178 178
 
179 179
             return $installed['versions'][$packageName]['version'];
180 180
         }
181 181
 
182
-        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
182
+        throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed');
183 183
     }
184 184
 
185 185
     /**
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
     public static function getPrettyVersion($packageName)
190 190
     {
191 191
         foreach (self::getInstalled() as $installed) {
192
-            if (!isset($installed['versions'][$packageName])) {
192
+            if ( ! isset($installed['versions'][$packageName])) {
193 193
                 continue;
194 194
             }
195 195
 
196
-            if (!isset($installed['versions'][$packageName]['pretty_version'])) {
196
+            if ( ! isset($installed['versions'][$packageName]['pretty_version'])) {
197 197
                 return null;
198 198
             }
199 199
 
200 200
             return $installed['versions'][$packageName]['pretty_version'];
201 201
         }
202 202
 
203
-        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
203
+        throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed');
204 204
     }
205 205
 
206 206
     /**
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
     public static function getReference($packageName)
211 211
     {
212 212
         foreach (self::getInstalled() as $installed) {
213
-            if (!isset($installed['versions'][$packageName])) {
213
+            if ( ! isset($installed['versions'][$packageName])) {
214 214
                 continue;
215 215
             }
216 216
 
217
-            if (!isset($installed['versions'][$packageName]['reference'])) {
217
+            if ( ! isset($installed['versions'][$packageName]['reference'])) {
218 218
                 return null;
219 219
             }
220 220
 
221 221
             return $installed['versions'][$packageName]['reference'];
222 222
         }
223 223
 
224
-        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
224
+        throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed');
225 225
     }
226 226
 
227 227
     /**
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
     public static function getInstallPath($packageName)
232 232
     {
233 233
         foreach (self::getInstalled() as $installed) {
234
-            if (!isset($installed['versions'][$packageName])) {
234
+            if ( ! isset($installed['versions'][$packageName])) {
235 235
                 continue;
236 236
             }
237 237
 
238 238
             return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
239 239
         }
240 240
 
241
-        throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
241
+        throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed');
242 242
     }
243 243
 
244 244
     /**
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
             // only require the installed.php file if this file is loaded from its dumped location,
268 268
             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
269 269
             if (substr(__DIR__, -8, 1) !== 'C') {
270
-                self::$installed = include __DIR__ . '/installed.php';
270
+                self::$installed = include __DIR__.'/installed.php';
271 271
             } else {
272 272
                 self::$installed = array();
273 273
             }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
             // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
344 344
             if (substr(__DIR__, -8, 1) !== 'C') {
345 345
                 /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
346
-                $required = require __DIR__ . '/installed.php';
346
+                $required = require __DIR__.'/installed.php';
347 347
                 self::$installed = $required;
348 348
             } else {
349 349
                 self::$installed = array();
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/autoload_classmap.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 $baseDir = dirname($vendorDir);
7 7
 
8 8
 return array(
9
-    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
9
+    'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php',
10 10
 );
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/autoload_static.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitc7889f9177279227eb0dae26d07e5354
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'W' => 
11
-        array (
11
+        array(
12 12
             'Wordlift\\Modules\\Super_Resolution\\' => 34,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'Wordlift\\Modules\\Super_Resolution\\' => 
18
-        array (
19
-            0 => __DIR__ . '/../..' . '/includes',
18
+        array(
19
+            0 => __DIR__.'/../..'.'/includes',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
23
+    public static $classMap = array(
24
+        'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php',
25 25
     );
26 26
 
27 27
     public static function getInitializer(ClassLoader $loader)
28 28
     {
29
-        return \Closure::bind(function () use ($loader) {
29
+        return \Closure::bind(function() use ($loader) {
30 30
             $loader->prefixLengthsPsr4 = ComposerStaticInitc7889f9177279227eb0dae26d07e5354::$prefixLengthsPsr4;
31 31
             $loader->prefixDirsPsr4 = ComposerStaticInitc7889f9177279227eb0dae26d07e5354::$prefixDirsPsr4;
32 32
             $loader->classMap = ComposerStaticInitc7889f9177279227eb0dae26d07e5354::$classMap;
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/autoload_psr4.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 $baseDir = dirname($vendorDir);
7 7
 
8 8
 return array(
9
-    'Wordlift\\Modules\\Super_Resolution\\' => array($baseDir . '/includes'),
9
+    'Wordlift\\Modules\\Super_Resolution\\' => array($baseDir.'/includes'),
10 10
 );
Please login to merge, or discard this patch.
src/modules/super-resolution/vendor/composer/autoload_real.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     public static function loadClassLoader($class)
10 10
     {
11 11
         if ('Composer\Autoload\ClassLoader' === $class) {
12
-            require __DIR__ . '/ClassLoader.php';
12
+            require __DIR__.'/ClassLoader.php';
13 13
         }
14 14
     }
15 15
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
             return self::$loader;
23 23
         }
24 24
 
25
-        require __DIR__ . '/platform_check.php';
25
+        require __DIR__.'/platform_check.php';
26 26
 
27 27
         spl_autoload_register(array('ComposerAutoloaderInitc7889f9177279227eb0dae26d07e5354', 'loadClassLoader'), true, true);
28 28
         self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
29 29
         spl_autoload_unregister(array('ComposerAutoloaderInitc7889f9177279227eb0dae26d07e5354', 'loadClassLoader'));
30 30
 
31
-        require __DIR__ . '/autoload_static.php';
31
+        require __DIR__.'/autoload_static.php';
32 32
         call_user_func(\Composer\Autoload\ComposerStaticInitc7889f9177279227eb0dae26d07e5354::getInitializer($loader));
33 33
 
34 34
         $loader->register(true);
Please login to merge, or discard this patch.
src/modules/super-resolution/includes/Super_Resolution_Controller.php 2 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -7,214 +7,214 @@
 block discarded – undo
7 7
 
8 8
 class Super_Resolution_Controller {
9 9
 
10
-	public function register_hooks() {
11
-		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
12
-	}
13
-
14
-	public function rest_api_init() {
15
-		register_rest_route(
16
-			'wordlift/v1/super-resolution',
17
-			'/attachments/(?P<attachment_id>\d+)/image',
18
-			array(
19
-				'methods'             => 'GET',
20
-				'callback'            => array( $this, 'get_post_featured_image' ),
21
-				'permission_callback' => function ( $request ) {
22
-					$post_id = $request->get_param( 'attachment_id' );
23
-					return current_user_can( 'edit_post', $post_id );
24
-				},
25
-			)
26
-		);
27
-
28
-		register_rest_route(
29
-			'wordlift/v1/super-resolution',
30
-			'/attachments/(?P<attachment_id>\d+)/image',
31
-			array(
32
-				'methods'             => 'POST',
33
-				'callback'            => array( $this, 'replace_post_featured_image' ),
34
-				'permission_callback' => function ( $request ) {
35
-					$post_id = $request->get_param( 'attachment_id' );
36
-					return current_user_can( 'edit_post', $post_id );
37
-				},
38
-			)
39
-		);
40
-
41
-		register_rest_route(
42
-			'wordlift/v1/super-resolution',
43
-			'/attachments/(?P<attachment_id>\d+)/image-upscale',
44
-			array(
45
-				'methods'             => 'GET',
46
-				'callback'            => array( $this, 'create_post_featured_image_upscale' ),
47
-				'permission_callback' => function ( $request ) {
48
-					$post_id = $request->get_param( 'attachment_id' );
49
-					return current_user_can( 'edit_post', $post_id );
50
-				},
51
-			)
52
-		);
53
-	}
54
-
55
-	/**
56
-	 * @param WP_REST_Request $request
57
-	 */
58
-	public function get_post_featured_image( $request ) {
59
-
60
-		$attachment_id = $request->get_param( 'attachment_id' );
61
-		// Get the path to the image file on the local disk
62
-		$image_path = get_attached_file( $attachment_id );
63
-
64
-		// Read the contents of the **local file** image file into a string
65
-		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
66
-		$image_data = file_get_contents( $image_path );
67
-
68
-		if ( ! $image_data ) {
69
-			// If image data is false, return a 404 response
70
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
71
-		}
72
-
73
-		// Set the content type header to the appropriate image MIME type
74
-		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
75
-		header( 'Content-Type: image/jpeg' );
76
-
77
-		// Sending image binary data.
78
-		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
79
-		exit( $image_data );
80
-	}
81
-
82
-	/**
83
-	 * @param WP_REST_Request $request
84
-	 */
85
-	public function create_post_featured_image_upscale( $request ) {
86
-		$attachment_id = $request->get_param( 'attachment_id' );
87
-
88
-		// Get the path to the image file on the local disk
89
-		$image_path = get_attached_file( $attachment_id );
90
-
91
-		// Read the contents of the **local** image file into a string
92
-		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
93
-		$image_data = file_get_contents( $image_path );
94
-
95
-		if ( ! $image_data ) {
96
-			// If image data is false, return a 404 response
97
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
98
-		}
99
-
100
-			$boundary = '__X_SUPER_RESOLUTION__';
101
-			$body     = "--$boundary\r\n";
102
-			$body    .= "content-disposition: form-data; name=\"image\"; filename=\"image.jpg\"\r\n";
103
-			$body    .= "content-type: image/jpeg\r\n\r\n";
104
-			$body    .= $image_data . "\r\n";
105
-			$body    .= "--$boundary\r\n";
106
-
107
-			$endpoint = 'https://super-resolution.wordlift.io/upscales';
108
-			// Create a new HTTP POST request
109
-			$request = wp_remote_post(
110
-				$endpoint,
111
-				array(
112
-					// Set the content type header to multipart/form-data
113
-					'headers' => array(
114
-						'Accept'       => 'image/jpeg',
115
-						'Content-Type' => "multipart/form-data; boundary=$boundary",
116
-					),
117
-					// Set the request body to the image file
118
-					'body'    => $body,
119
-					// Set the timeout to 30 seconds
120
-					'timeout' => 100,
121
-				)
122
-			);
123
-
124
-		if ( is_wp_error( $request ) ) {
125
-			// If the request resulted in an error, return it
126
-			return $request;
127
-		}
128
-
129
-		if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
130
-			// If the response code is not 200 OK, return an error
131
-			return new WP_Error(
132
-				'api_error',
133
-				wp_remote_retrieve_response_message( $request ),
134
-				array(
135
-					'status' => wp_remote_retrieve_response_code( $request ),
136
-				)
137
-			);
138
-		}
139
-
140
-		// Get the response body, which contains the binary data of the upscaled image
141
-		$response_body = wp_remote_retrieve_body( $request );
142
-
143
-		// Set the content type header to the appropriate image MIME type
144
-		header( 'Content-Type: image/jpeg' );
145
-
146
-		// Sending the image binary data.
147
-		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
148
-		exit( $response_body );
149
-
150
-	}
151
-
152
-	/**
153
-	 * @param $request WP_REST_Request
154
-	 */
155
-	public function replace_post_featured_image( $request ) {
156
-
157
-		// It receives the image binary data (**not** base64 encoded) in the `image` field.
158
-
159
-		// Will replace the original image for the post featured image with the upscaled image.
160
-
161
-		// Will make sure that the WL image sizes (1:1, 4:3 and 16:9) will be regenerated.
162
-
163
-		// Get the post ID from the request.
164
-		$attachment_id = $request->get_param( 'attachment_id' );
165
-
166
-		$files = $request->get_file_params();
167
-
168
-		if ( ! array_key_exists( 'image', $files ) ) {
169
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
170
-		}
171
-
172
-		$request_file = $files['image'];
173
-
174
-		if ( ! isset( $request_file['type'] ) ) {
175
-			return new WP_Error( '400', 'File mime type is not supported', array( 'status' => 400 ) );
176
-		}
177
-
178
-		if ( strpos( $request_file['type'], 'image' ) === false ) {
179
-			return new WP_Error( '400', 'Only image files are supported', array( 'status' => 400 ) );
180
-		}
181
-
182
-		// Get the attachment metadata
183
-		$attachment_metadata = wp_get_attachment_metadata( $attachment_id );
184
-		if ( ! $attachment_metadata ) {
185
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
186
-		}
187
-
188
-		// Get the original image file path
189
-		$original_image_path = get_attached_file( $attachment_id );
190
-		if ( ! $original_image_path ) {
191
-			return new WP_Error( '404', 'Image path not found.', array( 'status' => 404 ) );
192
-		}
193
-
194
-		// Delete the existing resized images
195
-		foreach ( $attachment_metadata['sizes'] as $size ) {
196
-			$resized_image_path = path_join( dirname( $original_image_path ), $size['file'] );
197
-			if ( file_exists( $resized_image_path ) ) {
198
-				unlink( $resized_image_path );
199
-			}
200
-		}
201
-
202
-		// Copy the new image to the old image path.
203
-		rename( $request_file['tmp_name'], $original_image_path );
204
-
205
-		// Regenerate the resized images
206
-		$metadata_updated = wp_generate_attachment_metadata( $attachment_id, get_attached_file( $attachment_id ) );
207
-
208
-		if ( is_wp_error( $metadata_updated ) ) {
209
-			/**
210
-			 * @var $metadata_updated WP_Error
211
-			 */
212
-			return new WP_Error( '500', 'Unable to generate resized images.', array( 'status' => 500 ) );
213
-		}
214
-
215
-		// Update the attachment metadata with the regenerated sizes
216
-		wp_update_attachment_metadata( $attachment_id, $metadata_updated );
217
-
218
-	}
10
+    public function register_hooks() {
11
+        add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
12
+    }
13
+
14
+    public function rest_api_init() {
15
+        register_rest_route(
16
+            'wordlift/v1/super-resolution',
17
+            '/attachments/(?P<attachment_id>\d+)/image',
18
+            array(
19
+                'methods'             => 'GET',
20
+                'callback'            => array( $this, 'get_post_featured_image' ),
21
+                'permission_callback' => function ( $request ) {
22
+                    $post_id = $request->get_param( 'attachment_id' );
23
+                    return current_user_can( 'edit_post', $post_id );
24
+                },
25
+            )
26
+        );
27
+
28
+        register_rest_route(
29
+            'wordlift/v1/super-resolution',
30
+            '/attachments/(?P<attachment_id>\d+)/image',
31
+            array(
32
+                'methods'             => 'POST',
33
+                'callback'            => array( $this, 'replace_post_featured_image' ),
34
+                'permission_callback' => function ( $request ) {
35
+                    $post_id = $request->get_param( 'attachment_id' );
36
+                    return current_user_can( 'edit_post', $post_id );
37
+                },
38
+            )
39
+        );
40
+
41
+        register_rest_route(
42
+            'wordlift/v1/super-resolution',
43
+            '/attachments/(?P<attachment_id>\d+)/image-upscale',
44
+            array(
45
+                'methods'             => 'GET',
46
+                'callback'            => array( $this, 'create_post_featured_image_upscale' ),
47
+                'permission_callback' => function ( $request ) {
48
+                    $post_id = $request->get_param( 'attachment_id' );
49
+                    return current_user_can( 'edit_post', $post_id );
50
+                },
51
+            )
52
+        );
53
+    }
54
+
55
+    /**
56
+     * @param WP_REST_Request $request
57
+     */
58
+    public function get_post_featured_image( $request ) {
59
+
60
+        $attachment_id = $request->get_param( 'attachment_id' );
61
+        // Get the path to the image file on the local disk
62
+        $image_path = get_attached_file( $attachment_id );
63
+
64
+        // Read the contents of the **local file** image file into a string
65
+        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
66
+        $image_data = file_get_contents( $image_path );
67
+
68
+        if ( ! $image_data ) {
69
+            // If image data is false, return a 404 response
70
+            return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
71
+        }
72
+
73
+        // Set the content type header to the appropriate image MIME type
74
+        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
75
+        header( 'Content-Type: image/jpeg' );
76
+
77
+        // Sending image binary data.
78
+        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
79
+        exit( $image_data );
80
+    }
81
+
82
+    /**
83
+     * @param WP_REST_Request $request
84
+     */
85
+    public function create_post_featured_image_upscale( $request ) {
86
+        $attachment_id = $request->get_param( 'attachment_id' );
87
+
88
+        // Get the path to the image file on the local disk
89
+        $image_path = get_attached_file( $attachment_id );
90
+
91
+        // Read the contents of the **local** image file into a string
92
+        // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
93
+        $image_data = file_get_contents( $image_path );
94
+
95
+        if ( ! $image_data ) {
96
+            // If image data is false, return a 404 response
97
+            return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
98
+        }
99
+
100
+            $boundary = '__X_SUPER_RESOLUTION__';
101
+            $body     = "--$boundary\r\n";
102
+            $body    .= "content-disposition: form-data; name=\"image\"; filename=\"image.jpg\"\r\n";
103
+            $body    .= "content-type: image/jpeg\r\n\r\n";
104
+            $body    .= $image_data . "\r\n";
105
+            $body    .= "--$boundary\r\n";
106
+
107
+            $endpoint = 'https://super-resolution.wordlift.io/upscales';
108
+            // Create a new HTTP POST request
109
+            $request = wp_remote_post(
110
+                $endpoint,
111
+                array(
112
+                    // Set the content type header to multipart/form-data
113
+                    'headers' => array(
114
+                        'Accept'       => 'image/jpeg',
115
+                        'Content-Type' => "multipart/form-data; boundary=$boundary",
116
+                    ),
117
+                    // Set the request body to the image file
118
+                    'body'    => $body,
119
+                    // Set the timeout to 30 seconds
120
+                    'timeout' => 100,
121
+                )
122
+            );
123
+
124
+        if ( is_wp_error( $request ) ) {
125
+            // If the request resulted in an error, return it
126
+            return $request;
127
+        }
128
+
129
+        if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
130
+            // If the response code is not 200 OK, return an error
131
+            return new WP_Error(
132
+                'api_error',
133
+                wp_remote_retrieve_response_message( $request ),
134
+                array(
135
+                    'status' => wp_remote_retrieve_response_code( $request ),
136
+                )
137
+            );
138
+        }
139
+
140
+        // Get the response body, which contains the binary data of the upscaled image
141
+        $response_body = wp_remote_retrieve_body( $request );
142
+
143
+        // Set the content type header to the appropriate image MIME type
144
+        header( 'Content-Type: image/jpeg' );
145
+
146
+        // Sending the image binary data.
147
+        // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
148
+        exit( $response_body );
149
+
150
+    }
151
+
152
+    /**
153
+     * @param $request WP_REST_Request
154
+     */
155
+    public function replace_post_featured_image( $request ) {
156
+
157
+        // It receives the image binary data (**not** base64 encoded) in the `image` field.
158
+
159
+        // Will replace the original image for the post featured image with the upscaled image.
160
+
161
+        // Will make sure that the WL image sizes (1:1, 4:3 and 16:9) will be regenerated.
162
+
163
+        // Get the post ID from the request.
164
+        $attachment_id = $request->get_param( 'attachment_id' );
165
+
166
+        $files = $request->get_file_params();
167
+
168
+        if ( ! array_key_exists( 'image', $files ) ) {
169
+            return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
170
+        }
171
+
172
+        $request_file = $files['image'];
173
+
174
+        if ( ! isset( $request_file['type'] ) ) {
175
+            return new WP_Error( '400', 'File mime type is not supported', array( 'status' => 400 ) );
176
+        }
177
+
178
+        if ( strpos( $request_file['type'], 'image' ) === false ) {
179
+            return new WP_Error( '400', 'Only image files are supported', array( 'status' => 400 ) );
180
+        }
181
+
182
+        // Get the attachment metadata
183
+        $attachment_metadata = wp_get_attachment_metadata( $attachment_id );
184
+        if ( ! $attachment_metadata ) {
185
+            return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
186
+        }
187
+
188
+        // Get the original image file path
189
+        $original_image_path = get_attached_file( $attachment_id );
190
+        if ( ! $original_image_path ) {
191
+            return new WP_Error( '404', 'Image path not found.', array( 'status' => 404 ) );
192
+        }
193
+
194
+        // Delete the existing resized images
195
+        foreach ( $attachment_metadata['sizes'] as $size ) {
196
+            $resized_image_path = path_join( dirname( $original_image_path ), $size['file'] );
197
+            if ( file_exists( $resized_image_path ) ) {
198
+                unlink( $resized_image_path );
199
+            }
200
+        }
201
+
202
+        // Copy the new image to the old image path.
203
+        rename( $request_file['tmp_name'], $original_image_path );
204
+
205
+        // Regenerate the resized images
206
+        $metadata_updated = wp_generate_attachment_metadata( $attachment_id, get_attached_file( $attachment_id ) );
207
+
208
+        if ( is_wp_error( $metadata_updated ) ) {
209
+            /**
210
+             * @var $metadata_updated WP_Error
211
+             */
212
+            return new WP_Error( '500', 'Unable to generate resized images.', array( 'status' => 500 ) );
213
+        }
214
+
215
+        // Update the attachment metadata with the regenerated sizes
216
+        wp_update_attachment_metadata( $attachment_id, $metadata_updated );
217
+
218
+    }
219 219
 
220 220
 }
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 class Super_Resolution_Controller {
9 9
 
10 10
 	public function register_hooks() {
11
-		add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
11
+		add_action('rest_api_init', array($this, 'rest_api_init'));
12 12
 	}
13 13
 
14 14
 	public function rest_api_init() {
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 			'/attachments/(?P<attachment_id>\d+)/image',
18 18
 			array(
19 19
 				'methods'             => 'GET',
20
-				'callback'            => array( $this, 'get_post_featured_image' ),
21
-				'permission_callback' => function ( $request ) {
22
-					$post_id = $request->get_param( 'attachment_id' );
23
-					return current_user_can( 'edit_post', $post_id );
20
+				'callback'            => array($this, 'get_post_featured_image'),
21
+				'permission_callback' => function($request) {
22
+					$post_id = $request->get_param('attachment_id');
23
+					return current_user_can('edit_post', $post_id);
24 24
 				},
25 25
 			)
26 26
 		);
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 			'/attachments/(?P<attachment_id>\d+)/image',
31 31
 			array(
32 32
 				'methods'             => 'POST',
33
-				'callback'            => array( $this, 'replace_post_featured_image' ),
34
-				'permission_callback' => function ( $request ) {
35
-					$post_id = $request->get_param( 'attachment_id' );
36
-					return current_user_can( 'edit_post', $post_id );
33
+				'callback'            => array($this, 'replace_post_featured_image'),
34
+				'permission_callback' => function($request) {
35
+					$post_id = $request->get_param('attachment_id');
36
+					return current_user_can('edit_post', $post_id);
37 37
 				},
38 38
 			)
39 39
 		);
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 			'/attachments/(?P<attachment_id>\d+)/image-upscale',
44 44
 			array(
45 45
 				'methods'             => 'GET',
46
-				'callback'            => array( $this, 'create_post_featured_image_upscale' ),
47
-				'permission_callback' => function ( $request ) {
48
-					$post_id = $request->get_param( 'attachment_id' );
49
-					return current_user_can( 'edit_post', $post_id );
46
+				'callback'            => array($this, 'create_post_featured_image_upscale'),
47
+				'permission_callback' => function($request) {
48
+					$post_id = $request->get_param('attachment_id');
49
+					return current_user_can('edit_post', $post_id);
50 50
 				},
51 51
 			)
52 52
 		);
@@ -55,53 +55,53 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @param WP_REST_Request $request
57 57
 	 */
58
-	public function get_post_featured_image( $request ) {
58
+	public function get_post_featured_image($request) {
59 59
 
60
-		$attachment_id = $request->get_param( 'attachment_id' );
60
+		$attachment_id = $request->get_param('attachment_id');
61 61
 		// Get the path to the image file on the local disk
62
-		$image_path = get_attached_file( $attachment_id );
62
+		$image_path = get_attached_file($attachment_id);
63 63
 
64 64
 		// Read the contents of the **local file** image file into a string
65 65
 		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
66
-		$image_data = file_get_contents( $image_path );
66
+		$image_data = file_get_contents($image_path);
67 67
 
68
-		if ( ! $image_data ) {
68
+		if ( ! $image_data) {
69 69
 			// If image data is false, return a 404 response
70
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
70
+			return new WP_Error('404', 'Image not found.', array('status' => 404));
71 71
 		}
72 72
 
73 73
 		// Set the content type header to the appropriate image MIME type
74 74
 		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
75
-		header( 'Content-Type: image/jpeg' );
75
+		header('Content-Type: image/jpeg');
76 76
 
77 77
 		// Sending image binary data.
78 78
 		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
79
-		exit( $image_data );
79
+		exit($image_data);
80 80
 	}
81 81
 
82 82
 	/**
83 83
 	 * @param WP_REST_Request $request
84 84
 	 */
85
-	public function create_post_featured_image_upscale( $request ) {
86
-		$attachment_id = $request->get_param( 'attachment_id' );
85
+	public function create_post_featured_image_upscale($request) {
86
+		$attachment_id = $request->get_param('attachment_id');
87 87
 
88 88
 		// Get the path to the image file on the local disk
89
-		$image_path = get_attached_file( $attachment_id );
89
+		$image_path = get_attached_file($attachment_id);
90 90
 
91 91
 		// Read the contents of the **local** image file into a string
92 92
 		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
93
-		$image_data = file_get_contents( $image_path );
93
+		$image_data = file_get_contents($image_path);
94 94
 
95
-		if ( ! $image_data ) {
95
+		if ( ! $image_data) {
96 96
 			// If image data is false, return a 404 response
97
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
97
+			return new WP_Error('404', 'Image not found.', array('status' => 404));
98 98
 		}
99 99
 
100 100
 			$boundary = '__X_SUPER_RESOLUTION__';
101 101
 			$body     = "--$boundary\r\n";
102 102
 			$body    .= "content-disposition: form-data; name=\"image\"; filename=\"image.jpg\"\r\n";
103 103
 			$body    .= "content-type: image/jpeg\r\n\r\n";
104
-			$body    .= $image_data . "\r\n";
104
+			$body    .= $image_data."\r\n";
105 105
 			$body    .= "--$boundary\r\n";
106 106
 
107 107
 			$endpoint = 'https://super-resolution.wordlift.io/upscales';
@@ -121,38 +121,38 @@  discard block
 block discarded – undo
121 121
 				)
122 122
 			);
123 123
 
124
-		if ( is_wp_error( $request ) ) {
124
+		if (is_wp_error($request)) {
125 125
 			// If the request resulted in an error, return it
126 126
 			return $request;
127 127
 		}
128 128
 
129
-		if ( wp_remote_retrieve_response_code( $request ) !== 200 ) {
129
+		if (wp_remote_retrieve_response_code($request) !== 200) {
130 130
 			// If the response code is not 200 OK, return an error
131 131
 			return new WP_Error(
132 132
 				'api_error',
133
-				wp_remote_retrieve_response_message( $request ),
133
+				wp_remote_retrieve_response_message($request),
134 134
 				array(
135
-					'status' => wp_remote_retrieve_response_code( $request ),
135
+					'status' => wp_remote_retrieve_response_code($request),
136 136
 				)
137 137
 			);
138 138
 		}
139 139
 
140 140
 		// Get the response body, which contains the binary data of the upscaled image
141
-		$response_body = wp_remote_retrieve_body( $request );
141
+		$response_body = wp_remote_retrieve_body($request);
142 142
 
143 143
 		// Set the content type header to the appropriate image MIME type
144
-		header( 'Content-Type: image/jpeg' );
144
+		header('Content-Type: image/jpeg');
145 145
 
146 146
 		// Sending the image binary data.
147 147
 		// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
148
-		exit( $response_body );
148
+		exit($response_body);
149 149
 
150 150
 	}
151 151
 
152 152
 	/**
153 153
 	 * @param $request WP_REST_Request
154 154
 	 */
155
-	public function replace_post_featured_image( $request ) {
155
+	public function replace_post_featured_image($request) {
156 156
 
157 157
 		// It receives the image binary data (**not** base64 encoded) in the `image` field.
158 158
 
@@ -161,59 +161,59 @@  discard block
 block discarded – undo
161 161
 		// Will make sure that the WL image sizes (1:1, 4:3 and 16:9) will be regenerated.
162 162
 
163 163
 		// Get the post ID from the request.
164
-		$attachment_id = $request->get_param( 'attachment_id' );
164
+		$attachment_id = $request->get_param('attachment_id');
165 165
 
166 166
 		$files = $request->get_file_params();
167 167
 
168
-		if ( ! array_key_exists( 'image', $files ) ) {
169
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
168
+		if ( ! array_key_exists('image', $files)) {
169
+			return new WP_Error('404', 'Image not found.', array('status' => 404));
170 170
 		}
171 171
 
172 172
 		$request_file = $files['image'];
173 173
 
174
-		if ( ! isset( $request_file['type'] ) ) {
175
-			return new WP_Error( '400', 'File mime type is not supported', array( 'status' => 400 ) );
174
+		if ( ! isset($request_file['type'])) {
175
+			return new WP_Error('400', 'File mime type is not supported', array('status' => 400));
176 176
 		}
177 177
 
178
-		if ( strpos( $request_file['type'], 'image' ) === false ) {
179
-			return new WP_Error( '400', 'Only image files are supported', array( 'status' => 400 ) );
178
+		if (strpos($request_file['type'], 'image') === false) {
179
+			return new WP_Error('400', 'Only image files are supported', array('status' => 400));
180 180
 		}
181 181
 
182 182
 		// Get the attachment metadata
183
-		$attachment_metadata = wp_get_attachment_metadata( $attachment_id );
184
-		if ( ! $attachment_metadata ) {
185
-			return new WP_Error( '404', 'Image not found.', array( 'status' => 404 ) );
183
+		$attachment_metadata = wp_get_attachment_metadata($attachment_id);
184
+		if ( ! $attachment_metadata) {
185
+			return new WP_Error('404', 'Image not found.', array('status' => 404));
186 186
 		}
187 187
 
188 188
 		// Get the original image file path
189
-		$original_image_path = get_attached_file( $attachment_id );
190
-		if ( ! $original_image_path ) {
191
-			return new WP_Error( '404', 'Image path not found.', array( 'status' => 404 ) );
189
+		$original_image_path = get_attached_file($attachment_id);
190
+		if ( ! $original_image_path) {
191
+			return new WP_Error('404', 'Image path not found.', array('status' => 404));
192 192
 		}
193 193
 
194 194
 		// Delete the existing resized images
195
-		foreach ( $attachment_metadata['sizes'] as $size ) {
196
-			$resized_image_path = path_join( dirname( $original_image_path ), $size['file'] );
197
-			if ( file_exists( $resized_image_path ) ) {
198
-				unlink( $resized_image_path );
195
+		foreach ($attachment_metadata['sizes'] as $size) {
196
+			$resized_image_path = path_join(dirname($original_image_path), $size['file']);
197
+			if (file_exists($resized_image_path)) {
198
+				unlink($resized_image_path);
199 199
 			}
200 200
 		}
201 201
 
202 202
 		// Copy the new image to the old image path.
203
-		rename( $request_file['tmp_name'], $original_image_path );
203
+		rename($request_file['tmp_name'], $original_image_path);
204 204
 
205 205
 		// Regenerate the resized images
206
-		$metadata_updated = wp_generate_attachment_metadata( $attachment_id, get_attached_file( $attachment_id ) );
206
+		$metadata_updated = wp_generate_attachment_metadata($attachment_id, get_attached_file($attachment_id));
207 207
 
208
-		if ( is_wp_error( $metadata_updated ) ) {
208
+		if (is_wp_error($metadata_updated)) {
209 209
 			/**
210 210
 			 * @var $metadata_updated WP_Error
211 211
 			 */
212
-			return new WP_Error( '500', 'Unable to generate resized images.', array( 'status' => 500 ) );
212
+			return new WP_Error('500', 'Unable to generate resized images.', array('status' => 500));
213 213
 		}
214 214
 
215 215
 		// Update the attachment metadata with the regenerated sizes
216
-		wp_update_attachment_metadata( $attachment_id, $metadata_updated );
216
+		wp_update_attachment_metadata($attachment_id, $metadata_updated);
217 217
 
218 218
 	}
219 219
 
Please login to merge, or discard this patch.