| @@ -42,8 +42,15 @@ | ||
| 42 | 42 | */ |
| 43 | 43 | private array $globalStyles = array(); |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | + * Block Registry for Pro checks. | |
| 47 | + * | |
| 48 | + * @var BlockRegistry|null | |
| 49 | + */ | |
| 50 | + private ?BlockRegistry $blockRegistry = null; | |
| 51 | + | |
| 52 | + /** | |
| 46 | 53 | * Generate email HTML from blocks. |
| 47 | 54 | * |
| 48 | 55 | * @param array $blocks Array of block data. |
| 49 | 56 | * @param array $globalStyles Optional. Global styles. |
| @@ -49,9 +56,10 @@ | ||
| 49 | 56 | * @param array $globalStyles Optional. Global styles. |
| 50 | 57 | * @return string Generated HTML. |
| 51 | 58 | */ |
| 52 | 59 | public function generate( array $blocks, array $globalStyles = array() ): string { |
| 53 | - $this->globalStyles = wp_parse_args( $globalStyles, $this->defaultStyles ); | |
| 60 | + $this->globalStyles = wp_parse_args( $globalStyles, $this->defaultStyles ); | |
| 61 | + $this->blockRegistry = new BlockRegistry(); | |
| 54 | 62 | |
| 55 | 63 | $contentWidth = (int) $this->globalStyles['contentWidth']; |
| 56 | 64 | $backgroundColor = esc_attr( $this->globalStyles['backgroundColor'] ); |
| 57 | 65 | $fontFamily = esc_attr( $this->globalStyles['fontFamily'] ); |
| @@ -145,12 +153,10 @@ | ||
| 145 | 153 | $customCss = $attributes['customCss'] ?? ''; |
| 146 | 154 | |
| 147 | 155 | $html = $this->renderBlockContent( $type, $attributes, $children, $parentBgColor ); |
| 148 | 156 | |
| 149 | - // Custom CSS saved with the template is always rendered. Only admins | |
| 150 | - // can store it (the editor add-on, manage_options), and a mail must | |
| 151 | - // not change its look because a licence ran out. | |
| 152 | - if ( ! empty( $customCss ) ) { | |
| 157 | + // Inject custom CSS as inline styles (Pro only) | |
| 158 | + if ( ! empty( $customCss ) && $this->blockRegistry && $this->blockRegistry->isProActive() ) { | |
| 153 | 159 | $html = $this->injectCustomCss( $html, $customCss ); |
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | return $html; |