Skip to content
Snippets Groups Projects
Select Git revision
  • 0c73464bc8b02fb0e881486d5691b393244b24b0
  • master default protected
  • bugfix/wordpress-review
  • fix/duplicate
  • bugfix/get_current_screen_fail
  • feature/dismiss-nonce
  • replace-dodgy-path
  • bugfix/notice-not-show
  • devel
  • 3.3.0
  • 3.2.5
  • 3.2.4
  • 3.2.3
  • 3.2.2
  • 3.2.1
  • 3.2.0
  • 3.2.0-beta7
  • 3.2.0-beta6
  • 3.2.0-beta5
  • 3.2.0-beta4
  • 3.2.0-beta3
  • 3.2.0-beta2
  • 3.2.0-beta1
  • 3.1.4
  • 3.1.4-beta1
  • 3.1.3
  • 3.1.1
  • 3.1
  • 3.0
29 results

TestAjaxHandler.php

Blame
  • HTMLDecorator.php 1.51 KiB
    <?php
    
    namespace WPDesk\Library\WPEmail\Parser;
    
    class HTMLDecorator {
    
        public static function style_inline( $content ) {
            if ( in_array( $this->get_content_type(), array( 'text/html', 'multipart/alternative' ), true ) ) {
                ob_start();
                wc_get_template( 'emails/email-styles.php' );
                $css = apply_filters( 'woocommerce_email_styles', ob_get_clean(), $this );
    
                $css_inliner_class = \Pelago\Emogrifier\CssInliner::class;
    
                if ( $this->supports_emogrifier() && class_exists( $css_inliner_class ) ) {
                    try {
                        $css_inliner = \Pelago\Emogrifier\CssInliner::fromHtml( $content )->inlineCss( $css );
    
                        do_action( 'woocommerce_emogrifier', $css_inliner, $this );
    
                        $dom_document = $css_inliner->getDomDocument();
    
                        HtmlPruner::fromDomDocument( $dom_document )->removeElementsWithDisplayNone();
                        $content = CssToAttributeConverter::fromDomDocument( $dom_document )
                                                          ->convertCssToVisualAttributes()
                                                          ->render();
                    } catch ( Exception $e ) {
                        $logger = wc_get_logger();
                        $logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
                    }
                } else {
                    $content = '<style type="text/css">' . $css . '</style>' . $content;
                }
            }
    
            return $content;
        }
    
    }