← All changes
|
app/Shared/Controllers/PatternPlaceholderController.php
+8
-8
3.1.5
→
3.2.1
View file →
| @@ -52,9 +52,16 @@ | ||
| 52 | 52 | $handlerClass = isset(self::PLUGIN_HANDLERS[$pluginDependency]) |
| 53 | 53 | ? self::PLUGIN_HANDLERS[$pluginDependency] |
| 54 | 54 | : null; |
| 55 | 55 | if ($handlerClass && isset($metadata['key'])) { |
| 56 | - $pattern['code'] = $handlerClass::create($pattern['code'], $metadata['key'], $newCode); | |
| 56 | + $code = $handlerClass::create($pattern['code'], $metadata['key'], $newCode); | |
| 57 | + if (is_wp_error($code)) { | |
| 58 | + // The caller renders whatever is in code, so leaving it is the fallback. | |
| 59 | + $pattern['pluginDependencyFailed'] = true; | |
| 60 | + return $pattern; | |
| 61 | + } | |
| 62 | + | |
| 63 | + $pattern['code'] = $code; | |
| 57 | 64 | return $pattern; |
| 58 | 65 | } |
| 59 | 66 | |
| 60 | 67 | // We added a feature this version doesn't yet support. |
| @@ -59,15 +66,8 @@ | ||
| 59 | 66 | |
| 60 | 67 | // We added a feature this version doesn't yet support. |
| 61 | 68 | return $pattern; |
| 62 | 69 | }, $patterns); |
| 63 | - | |
| 64 | - // if any of the pattern code is a wp_error, we need to fail. | |
| 65 | - foreach ($patterns as $pattern) { | |
| 66 | - if (is_wp_error($pattern['code'])) { | |
| 67 | - return new \WP_REST_Response($pattern['code'], 422); | |
| 68 | - } | |
| 69 | - } | |
| 70 | 70 | |
| 71 | 71 | return new \WP_REST_Response($patterns); |
| 72 | 72 | } |
| 73 | 73 | } |