| @@ -3,8 +3,9 @@ | ||
| 3 | 3 | namespace FluentCart\App\Hooks\Handlers\ShortCodes; |
| 4 | 4 | |
| 5 | 5 | use FluentCart\Api\Contracts\CanEnqueue; |
| 6 | 6 | use FluentCart\App\App; |
| 7 | +use FluentCart\App\Services\Renderer\RenderContext; | |
| 7 | 8 | use FluentCart\Framework\Support\Arr; |
| 8 | 9 | use FluentCart\Framework\Support\Str; |
| 9 | 10 | |
| 10 | 11 | abstract class ShortCode |
| @@ -51,9 +52,18 @@ | ||
| 51 | 52 | |
| 52 | 53 | public static function register() |
| 53 | 54 | { |
| 54 | 55 | add_shortcode(static::getShortCodeName(), function ($shortcodeAttributes, $content, $block) { |
| 55 | - return static::make($shortcodeAttributes)->renderShortcode($block); | |
| 56 | + // WordPress exposes no "shortcode currently rendering" signal, so | |
| 57 | + // this is the one place that has to say so. Every ShortCode | |
| 58 | + // subclass registers through here, so it is the only place. | |
| 59 | + return RenderContext::declaring( | |
| 60 | + RenderContext::SOURCE_SHORTCODE, | |
| 61 | + static::getShortCodeName(), | |
| 62 | + function () use ($shortcodeAttributes, $block) { | |
| 63 | + return static::make($shortcodeAttributes)->renderShortcode($block); | |
| 64 | + } | |
| 65 | + ); | |
| 56 | 66 | }); |
| 57 | 67 | } |
| 58 | 68 | |
| 59 | 69 | protected function generateEnqueueSlug(): string |