C:\xampp\htdocs\landing\wp-content\plugins\wpforms-lite\src\Emails\Styler.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php

namespace WPForms\Emails;

use 
TijsVerkoyen\CssToInlineStyles\CssToInlineStyles;
use 
WPForms\Helpers\Templates;

/**
 * Styler class inline style email templates.
 *
 * @since 1.5.4
 */
class Styler {

    
/**
     * Email message with no styles.
     *
     * @since 1.5.4
     *
     * @var string
     */
    
protected $email;

    
/**
     * Email style templates names.
     *
     * @since 1.5.4
     *
     * @var array
     */
    
protected $style_templates;

    
/**
     * Email style overrides.
     *
     * @since 1.5.4
     *
     * @var array
     */
    
protected $style_overrides;

    
/**
     * Email message with inline styles.
     *
     * @since 1.5.4
     *
     * @var string
     */
    
protected $styled_email;

    
/**
     * Constructor.
     *
     * @since 1.5.4
     *
     * @param string $email           Email with no styles.
     * @param array  $style_templates Email style templates.
     * @param array  $style_overrides Email style overrides.
     */
    
public function __construct$email$style_templates$style_overrides ) {

        
$this->email $email;

        
$this->style_templates = \is_array$style_templates ) ? $style_templates : array();
        
$this->style_overrides = \is_array$style_overrides ) ? $style_overrides : array();
    }

    
/**
     * Template style overrides.
     *
     * @since 1.5.4
     *
     * @return array
     */
    
protected function get_style_overrides() {

        
$defaults = array(
            
'email_background_color' => \wpforms_setting'email-background-color''#e9eaec' ),
        );

        
$overrides = \wp_parse_args$this->style_overrides$defaults );

        return \
apply_filters'wpforms_emails_mailer_get_style_overrides'$overrides$this );
    }

    
/**
     * Locate template name matching styles.
     *
     * @since 1.5.4
     *
     * @param string $name Template file name part.
     *
     * @return string
     */
    
protected function get_styles$name 'style' ) {

        if ( ! \
array_key_exists$name$this->style_templates ) ) {
            return 
'';
        }

        return 
Templates::get_html(
            
$this->style_templates$name ],
            
$this->get_style_overrides(),
            
true
        
);
    }

    
/**
     * Final processing of the template markup.
     *
     * @since 1.5.4
     */
    
public function process_markup() {

        
$this->styled_email = ( new CssToInlineStyles() )->convert$this->email$this->get_styles() );

        
$queries '<style type="text/css">' $this->get_styles'queries' ) . "</style>\n</head>";

        
// Inject media queries, CssToInlineStyles strips them.
        
$this->styled_email = \str_replace'</head>'$queries$this->styled_email );
    }

    
/**
     * Get an email with inline styles.
     *
     * @since 1.5.4
     *
     * @return string
     */
    
public function get() {

        if ( empty( 
$this->styled_email ) ) {
            
$this->process_markup();
        }

        return 
$this->styled_email;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586