@@ -38,217 +38,217 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | |
64 | 64 | } else { |
65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | - /** |
|
68 | - * espresso_minimum_php_version_error |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - function espresso_minimum_php_version_error() |
|
73 | - { |
|
74 | - ?> |
|
65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
67 | + /** |
|
68 | + * espresso_minimum_php_version_error |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + function espresso_minimum_php_version_error() |
|
73 | + { |
|
74 | + ?> |
|
75 | 75 | <div class="error"> |
76 | 76 | <p> |
77 | 77 | <?php |
78 | - printf( |
|
79 | - esc_html__( |
|
80 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - EE_MIN_PHP_VER_REQUIRED, |
|
84 | - PHP_VERSION, |
|
85 | - '<br/>', |
|
86 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | - ); |
|
88 | - ?> |
|
78 | + printf( |
|
79 | + esc_html__( |
|
80 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + EE_MIN_PHP_VER_REQUIRED, |
|
84 | + PHP_VERSION, |
|
85 | + '<br/>', |
|
86 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
87 | + ); |
|
88 | + ?> |
|
89 | 89 | </p> |
90 | 90 | </div> |
91 | 91 | <?php |
92 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | - } |
|
92 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
93 | + } |
|
94 | 94 | |
95 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | - } else { |
|
97 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | - /** |
|
99 | - * espresso_version |
|
100 | - * Returns the plugin version |
|
101 | - * |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - function espresso_version() |
|
105 | - { |
|
106 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.000'); |
|
107 | - } |
|
95 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
96 | + } else { |
|
97 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
98 | + /** |
|
99 | + * espresso_version |
|
100 | + * Returns the plugin version |
|
101 | + * |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + function espresso_version() |
|
105 | + { |
|
106 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.000'); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * espresso_plugin_activation |
|
111 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | - */ |
|
113 | - function espresso_plugin_activation() |
|
114 | - { |
|
115 | - update_option('ee_espresso_activation', true); |
|
116 | - } |
|
109 | + /** |
|
110 | + * espresso_plugin_activation |
|
111 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
112 | + */ |
|
113 | + function espresso_plugin_activation() |
|
114 | + { |
|
115 | + update_option('ee_espresso_activation', true); |
|
116 | + } |
|
117 | 117 | |
118 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | - /** |
|
120 | - * espresso_load_error_handling |
|
121 | - * this function loads EE's class for handling exceptions and errors |
|
122 | - */ |
|
123 | - function espresso_load_error_handling() |
|
124 | - { |
|
125 | - static $error_handling_loaded = false; |
|
126 | - if ($error_handling_loaded) { |
|
127 | - return; |
|
128 | - } |
|
129 | - // load debugging tools |
|
130 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | - \EEH_Debug_Tools::instance(); |
|
133 | - } |
|
134 | - // load error handling |
|
135 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | - } else { |
|
138 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | - } |
|
140 | - $error_handling_loaded = true; |
|
141 | - } |
|
118 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
119 | + /** |
|
120 | + * espresso_load_error_handling |
|
121 | + * this function loads EE's class for handling exceptions and errors |
|
122 | + */ |
|
123 | + function espresso_load_error_handling() |
|
124 | + { |
|
125 | + static $error_handling_loaded = false; |
|
126 | + if ($error_handling_loaded) { |
|
127 | + return; |
|
128 | + } |
|
129 | + // load debugging tools |
|
130 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
131 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
132 | + \EEH_Debug_Tools::instance(); |
|
133 | + } |
|
134 | + // load error handling |
|
135 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
136 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
137 | + } else { |
|
138 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
139 | + } |
|
140 | + $error_handling_loaded = true; |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * espresso_load_required |
|
145 | - * given a class name and path, this function will load that file or throw an exception |
|
146 | - * |
|
147 | - * @param string $classname |
|
148 | - * @param string $full_path_to_file |
|
149 | - * @throws EE_Error |
|
150 | - */ |
|
151 | - function espresso_load_required($classname, $full_path_to_file) |
|
152 | - { |
|
153 | - if (is_readable($full_path_to_file)) { |
|
154 | - require_once $full_path_to_file; |
|
155 | - } else { |
|
156 | - throw new \EE_Error ( |
|
157 | - sprintf( |
|
158 | - esc_html__( |
|
159 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - $classname |
|
163 | - ) |
|
164 | - ); |
|
165 | - } |
|
166 | - } |
|
143 | + /** |
|
144 | + * espresso_load_required |
|
145 | + * given a class name and path, this function will load that file or throw an exception |
|
146 | + * |
|
147 | + * @param string $classname |
|
148 | + * @param string $full_path_to_file |
|
149 | + * @throws EE_Error |
|
150 | + */ |
|
151 | + function espresso_load_required($classname, $full_path_to_file) |
|
152 | + { |
|
153 | + if (is_readable($full_path_to_file)) { |
|
154 | + require_once $full_path_to_file; |
|
155 | + } else { |
|
156 | + throw new \EE_Error ( |
|
157 | + sprintf( |
|
158 | + esc_html__( |
|
159 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + $classname |
|
163 | + ) |
|
164 | + ); |
|
165 | + } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * @since 4.9.27 |
|
170 | - * @throws \EE_Error |
|
171 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | - * @throws \OutOfBoundsException |
|
179 | - */ |
|
180 | - function bootstrap_espresso() |
|
181 | - { |
|
182 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | - try { |
|
184 | - espresso_load_error_handling(); |
|
185 | - espresso_load_required( |
|
186 | - 'EEH_Base', |
|
187 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | - ); |
|
189 | - espresso_load_required( |
|
190 | - 'EEH_File', |
|
191 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | - ); |
|
193 | - espresso_load_required( |
|
194 | - 'EEH_File', |
|
195 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | - ); |
|
197 | - espresso_load_required( |
|
198 | - 'EEH_Array', |
|
199 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | - ); |
|
201 | - // instantiate and configure PSR4 autoloader |
|
202 | - espresso_load_required( |
|
203 | - 'Psr4Autoloader', |
|
204 | - EE_CORE . 'Psr4Autoloader.php' |
|
205 | - ); |
|
206 | - espresso_load_required( |
|
207 | - 'EE_Psr4AutoloaderInit', |
|
208 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | - ); |
|
210 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | - $AutoloaderInit->initializeAutoloader(); |
|
212 | - espresso_load_required( |
|
213 | - 'EE_Request', |
|
214 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | - ); |
|
216 | - espresso_load_required( |
|
217 | - 'EE_Response', |
|
218 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | - ); |
|
220 | - espresso_load_required( |
|
221 | - 'EE_Bootstrap', |
|
222 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | - ); |
|
224 | - // bootstrap EE and the request stack |
|
225 | - new EE_Bootstrap( |
|
226 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | - new EE_Response() |
|
228 | - ); |
|
229 | - } catch (Exception $e) { |
|
230 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | - } |
|
233 | - } |
|
234 | - bootstrap_espresso(); |
|
235 | - } |
|
168 | + /** |
|
169 | + * @since 4.9.27 |
|
170 | + * @throws \EE_Error |
|
171 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
172 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
173 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
174 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
175 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
177 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
178 | + * @throws \OutOfBoundsException |
|
179 | + */ |
|
180 | + function bootstrap_espresso() |
|
181 | + { |
|
182 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
183 | + try { |
|
184 | + espresso_load_error_handling(); |
|
185 | + espresso_load_required( |
|
186 | + 'EEH_Base', |
|
187 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
188 | + ); |
|
189 | + espresso_load_required( |
|
190 | + 'EEH_File', |
|
191 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
192 | + ); |
|
193 | + espresso_load_required( |
|
194 | + 'EEH_File', |
|
195 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
196 | + ); |
|
197 | + espresso_load_required( |
|
198 | + 'EEH_Array', |
|
199 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
200 | + ); |
|
201 | + // instantiate and configure PSR4 autoloader |
|
202 | + espresso_load_required( |
|
203 | + 'Psr4Autoloader', |
|
204 | + EE_CORE . 'Psr4Autoloader.php' |
|
205 | + ); |
|
206 | + espresso_load_required( |
|
207 | + 'EE_Psr4AutoloaderInit', |
|
208 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
209 | + ); |
|
210 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
211 | + $AutoloaderInit->initializeAutoloader(); |
|
212 | + espresso_load_required( |
|
213 | + 'EE_Request', |
|
214 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
215 | + ); |
|
216 | + espresso_load_required( |
|
217 | + 'EE_Response', |
|
218 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
219 | + ); |
|
220 | + espresso_load_required( |
|
221 | + 'EE_Bootstrap', |
|
222 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
223 | + ); |
|
224 | + // bootstrap EE and the request stack |
|
225 | + new EE_Bootstrap( |
|
226 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
227 | + new EE_Response() |
|
228 | + ); |
|
229 | + } catch (Exception $e) { |
|
230 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
231 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
232 | + } |
|
233 | + } |
|
234 | + bootstrap_espresso(); |
|
235 | + } |
|
236 | 236 | } |
237 | 237 | if (! function_exists('espresso_deactivate_plugin')) { |
238 | - /** |
|
239 | - * deactivate_plugin |
|
240 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | - { |
|
248 | - if (! function_exists('deactivate_plugins')) { |
|
249 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | - } |
|
251 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | - deactivate_plugins($plugin_basename); |
|
253 | - } |
|
238 | + /** |
|
239 | + * deactivate_plugin |
|
240 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
247 | + { |
|
248 | + if (! function_exists('deactivate_plugins')) { |
|
249 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
250 | + } |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | + } |
|
254 | 254 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | 9 | if (!defined('EVENT_ESPRESSO_VERSION')) |
10 | - exit('NO direct script access allowed'); |
|
10 | + exit('NO direct script access allowed'); |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * |
@@ -24,343 +24,343 @@ discard block |
||
24 | 24 | { |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * The following are the properties that this messenger requires for generating pdf |
|
29 | - */ |
|
30 | - |
|
31 | - /** |
|
32 | - * This is the pdf body generated by the template via the message type. |
|
33 | - * |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $_content; |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
41 | - * |
|
42 | - * @var string |
|
43 | - */ |
|
44 | - protected $_subject; |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return EE_Pdf_messenger |
|
49 | - */ |
|
50 | - public function __construct() |
|
51 | - { |
|
52 | - //set properties |
|
53 | - $this->name = 'pdf'; |
|
54 | - $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
55 | - $this->label = array( |
|
56 | - 'singular' => __('PDF', 'event_espresso'), |
|
57 | - 'plural' => __('PDFs', 'event_espresso') |
|
58 | - ); |
|
59 | - $this->activate_on_install = TRUE; |
|
60 | - |
|
61 | - parent::__construct(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * PDF Messenger desires execution immediately. |
|
67 | - * @see parent::send_now() for documentation. |
|
68 | - * @since 4.9.0 |
|
69 | - * @return bool |
|
70 | - */ |
|
71 | - public function send_now() |
|
72 | - { |
|
73 | - return true; |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * HTML Messenger allows an empty to field. |
|
79 | - * @see parent::allow_empty_to_field() for documentation |
|
80 | - * @since 4.9.0 |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function allow_empty_to_field() |
|
84 | - { |
|
85 | - return true; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @see abstract declaration in EE_messenger for details. |
|
91 | - */ |
|
92 | - protected function _set_admin_pages() |
|
93 | - { |
|
94 | - $this->admin_registered_pages = array('events_edit' => false); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @see abstract declaration in EE_messenger for details. |
|
100 | - */ |
|
101 | - protected function _set_valid_shortcodes() |
|
102 | - { |
|
103 | - $this->_valid_shortcodes = array(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @see abstract declaration in EE_messenger for details. |
|
109 | - */ |
|
110 | - protected function _set_validator_config() |
|
111 | - { |
|
112 | - $this->_validator_config = array( |
|
113 | - 'subject' => array( |
|
114 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
115 | - ), |
|
116 | - 'content' => array( |
|
117 | - 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
118 | - ), |
|
119 | - 'attendee_list' => array( |
|
120 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
121 | - 'required' => array('[ATTENDEE_LIST]') |
|
122 | - ), |
|
123 | - 'event_list' => array( |
|
124 | - 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
125 | - 'required' => array('[EVENT_LIST]') |
|
126 | - ), |
|
127 | - 'ticket_list' => array( |
|
128 | - 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
129 | - 'required' => array('[TICKET_LIST]') |
|
130 | - ), |
|
131 | - 'datetime_list' => array( |
|
132 | - 'shortcodes' => array('datetime'), |
|
133 | - 'required' => array('[DATETIME_LIST]') |
|
134 | - ), |
|
135 | - ); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
141 | - * |
|
142 | - * @return void. |
|
143 | - */ |
|
144 | - public function enqueue_scripts_styles() |
|
145 | - { |
|
146 | - parent::enqueue_scripts_styles(); |
|
147 | - do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * _set_template_fields |
|
153 | - * This sets up the fields that a messenger requires for the message to go out. |
|
154 | - * |
|
155 | - * @access protected |
|
156 | - * @return void |
|
157 | - */ |
|
158 | - protected function _set_template_fields() |
|
159 | - { |
|
160 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
161 | - $this->_template_fields = array( |
|
162 | - 'subject' => array( |
|
163 | - 'input' => 'text', |
|
164 | - 'label' => __('Page Title', 'event_espresso'), |
|
165 | - 'type' => 'string', |
|
166 | - 'required' => TRUE, |
|
167 | - 'validation' => TRUE, |
|
168 | - 'css_class' => 'large-text', |
|
169 | - 'format' => '%s' |
|
170 | - ), |
|
171 | - 'content' => '', //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
172 | - 'extra' => array( |
|
173 | - 'content' => array( |
|
174 | - 'main' => array( |
|
175 | - 'input' => 'wp_editor', |
|
176 | - 'label' => __('Main Content', 'event_espresso'), |
|
177 | - 'type' => 'string', |
|
178 | - 'required' => TRUE, |
|
179 | - 'validation' => TRUE, |
|
180 | - 'format' => '%s', |
|
181 | - 'rows' => '15' |
|
182 | - ), |
|
183 | - 'event_list' => array( |
|
184 | - 'input' => 'wp_editor', |
|
185 | - 'label' => '[EVENT_LIST]', |
|
186 | - 'type' => 'string', |
|
187 | - 'required' => TRUE, |
|
188 | - 'validation' => TRUE, |
|
189 | - 'format' => '%s', |
|
190 | - 'rows' => '15', |
|
191 | - 'shortcodes_required' => array('[EVENT_LIST]') |
|
192 | - ), |
|
193 | - 'attendee_list' => array( |
|
194 | - 'input' => 'textarea', |
|
195 | - 'label' => '[ATTENDEE_LIST]', |
|
196 | - 'type' => 'string', |
|
197 | - 'required' => TRUE, |
|
198 | - 'validation' => TRUE, |
|
199 | - 'format' => '%s', |
|
200 | - 'css_class' => 'large-text', |
|
201 | - 'rows' => '5', |
|
202 | - 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
203 | - ), |
|
204 | - 'ticket_list' => array( |
|
205 | - 'input' => 'textarea', |
|
206 | - 'label' => '[TICKET_LIST]', |
|
207 | - 'type' => 'string', |
|
208 | - 'required' => TRUE, |
|
209 | - 'validation' => TRUE, |
|
210 | - 'format' => '%s', |
|
211 | - 'css_class' => 'large-text', |
|
212 | - 'rows' => '10', |
|
213 | - 'shortcodes_required' => array('[TICKET_LIST]') |
|
214 | - ), |
|
215 | - 'datetime_list' => array( |
|
216 | - 'input' => 'textarea', |
|
217 | - 'label' => '[DATETIME_LIST]', |
|
218 | - 'type' => 'string', |
|
219 | - 'required' => TRUE, |
|
220 | - 'validation' => TRUE, |
|
221 | - 'format' => '%s', |
|
222 | - 'css_class' => 'large-text', |
|
223 | - 'rows' => '10', |
|
224 | - 'shortcodes_required' => array('[DATETIME_LIST]') |
|
225 | - ) |
|
226 | - ) |
|
227 | - ) |
|
228 | - ); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * @see definition of this method in parent |
|
234 | - * |
|
235 | - * @since 4.5.0 |
|
236 | - * |
|
237 | - */ |
|
238 | - protected function _set_default_message_types() |
|
239 | - { |
|
240 | - //note currently PDF is only a secondary messenger so it never has any associated message types. |
|
241 | - $this->_default_message_types = array(); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @see definition of this method in parent |
|
247 | - * |
|
248 | - * @since 4.5.0 |
|
249 | - */ |
|
250 | - protected function _set_valid_message_types() |
|
251 | - { |
|
252 | - $this->_valid_message_types = array(); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Generates html version of the message content and then sends it to the pdf generator. |
|
258 | - * |
|
259 | - * |
|
260 | - * @since 4.5.0 |
|
261 | - * |
|
262 | - * @return string. |
|
263 | - */ |
|
264 | - protected function _send_message() |
|
265 | - { |
|
266 | - $this->_template_args = array( |
|
267 | - 'page_title' => stripslashes($this->_subject), |
|
268 | - 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
|
269 | - 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
|
270 | - 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
|
271 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
272 | - 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep($this->_content)), $this->_content) |
|
273 | - ); |
|
274 | - $this->_deregister_wp_hooks(); |
|
275 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
276 | - $content = $this->_get_main_template(); |
|
27 | + /** |
|
28 | + * The following are the properties that this messenger requires for generating pdf |
|
29 | + */ |
|
30 | + |
|
31 | + /** |
|
32 | + * This is the pdf body generated by the template via the message type. |
|
33 | + * |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $_content; |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * This is for the page title that gets displayed. This will end up being the filename for the generated pdf. |
|
41 | + * |
|
42 | + * @var string |
|
43 | + */ |
|
44 | + protected $_subject; |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return EE_Pdf_messenger |
|
49 | + */ |
|
50 | + public function __construct() |
|
51 | + { |
|
52 | + //set properties |
|
53 | + $this->name = 'pdf'; |
|
54 | + $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso'); |
|
55 | + $this->label = array( |
|
56 | + 'singular' => __('PDF', 'event_espresso'), |
|
57 | + 'plural' => __('PDFs', 'event_espresso') |
|
58 | + ); |
|
59 | + $this->activate_on_install = TRUE; |
|
60 | + |
|
61 | + parent::__construct(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * PDF Messenger desires execution immediately. |
|
67 | + * @see parent::send_now() for documentation. |
|
68 | + * @since 4.9.0 |
|
69 | + * @return bool |
|
70 | + */ |
|
71 | + public function send_now() |
|
72 | + { |
|
73 | + return true; |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * HTML Messenger allows an empty to field. |
|
79 | + * @see parent::allow_empty_to_field() for documentation |
|
80 | + * @since 4.9.0 |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function allow_empty_to_field() |
|
84 | + { |
|
85 | + return true; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @see abstract declaration in EE_messenger for details. |
|
91 | + */ |
|
92 | + protected function _set_admin_pages() |
|
93 | + { |
|
94 | + $this->admin_registered_pages = array('events_edit' => false); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @see abstract declaration in EE_messenger for details. |
|
100 | + */ |
|
101 | + protected function _set_valid_shortcodes() |
|
102 | + { |
|
103 | + $this->_valid_shortcodes = array(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @see abstract declaration in EE_messenger for details. |
|
109 | + */ |
|
110 | + protected function _set_validator_config() |
|
111 | + { |
|
112 | + $this->_validator_config = array( |
|
113 | + 'subject' => array( |
|
114 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
115 | + ), |
|
116 | + 'content' => array( |
|
117 | + 'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime') |
|
118 | + ), |
|
119 | + 'attendee_list' => array( |
|
120 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
121 | + 'required' => array('[ATTENDEE_LIST]') |
|
122 | + ), |
|
123 | + 'event_list' => array( |
|
124 | + 'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'), |
|
125 | + 'required' => array('[EVENT_LIST]') |
|
126 | + ), |
|
127 | + 'ticket_list' => array( |
|
128 | + 'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'), |
|
129 | + 'required' => array('[TICKET_LIST]') |
|
130 | + ), |
|
131 | + 'datetime_list' => array( |
|
132 | + 'shortcodes' => array('datetime'), |
|
133 | + 'required' => array('[DATETIME_LIST]') |
|
134 | + ), |
|
135 | + ); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this messenger can add their own js. |
|
141 | + * |
|
142 | + * @return void. |
|
143 | + */ |
|
144 | + public function enqueue_scripts_styles() |
|
145 | + { |
|
146 | + parent::enqueue_scripts_styles(); |
|
147 | + do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles'); |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * _set_template_fields |
|
153 | + * This sets up the fields that a messenger requires for the message to go out. |
|
154 | + * |
|
155 | + * @access protected |
|
156 | + * @return void |
|
157 | + */ |
|
158 | + protected function _set_template_fields() |
|
159 | + { |
|
160 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field they relate to. This is important for the Messages_admin to know what fields to display to the user. Also, notice that the "values" are equal to the field type that messages admin will use to know what kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and will not be displayed/parsed. |
|
161 | + $this->_template_fields = array( |
|
162 | + 'subject' => array( |
|
163 | + 'input' => 'text', |
|
164 | + 'label' => __('Page Title', 'event_espresso'), |
|
165 | + 'type' => 'string', |
|
166 | + 'required' => TRUE, |
|
167 | + 'validation' => TRUE, |
|
168 | + 'css_class' => 'large-text', |
|
169 | + 'format' => '%s' |
|
170 | + ), |
|
171 | + 'content' => '', //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
172 | + 'extra' => array( |
|
173 | + 'content' => array( |
|
174 | + 'main' => array( |
|
175 | + 'input' => 'wp_editor', |
|
176 | + 'label' => __('Main Content', 'event_espresso'), |
|
177 | + 'type' => 'string', |
|
178 | + 'required' => TRUE, |
|
179 | + 'validation' => TRUE, |
|
180 | + 'format' => '%s', |
|
181 | + 'rows' => '15' |
|
182 | + ), |
|
183 | + 'event_list' => array( |
|
184 | + 'input' => 'wp_editor', |
|
185 | + 'label' => '[EVENT_LIST]', |
|
186 | + 'type' => 'string', |
|
187 | + 'required' => TRUE, |
|
188 | + 'validation' => TRUE, |
|
189 | + 'format' => '%s', |
|
190 | + 'rows' => '15', |
|
191 | + 'shortcodes_required' => array('[EVENT_LIST]') |
|
192 | + ), |
|
193 | + 'attendee_list' => array( |
|
194 | + 'input' => 'textarea', |
|
195 | + 'label' => '[ATTENDEE_LIST]', |
|
196 | + 'type' => 'string', |
|
197 | + 'required' => TRUE, |
|
198 | + 'validation' => TRUE, |
|
199 | + 'format' => '%s', |
|
200 | + 'css_class' => 'large-text', |
|
201 | + 'rows' => '5', |
|
202 | + 'shortcodes_required' => array('[ATTENDEE_LIST]') |
|
203 | + ), |
|
204 | + 'ticket_list' => array( |
|
205 | + 'input' => 'textarea', |
|
206 | + 'label' => '[TICKET_LIST]', |
|
207 | + 'type' => 'string', |
|
208 | + 'required' => TRUE, |
|
209 | + 'validation' => TRUE, |
|
210 | + 'format' => '%s', |
|
211 | + 'css_class' => 'large-text', |
|
212 | + 'rows' => '10', |
|
213 | + 'shortcodes_required' => array('[TICKET_LIST]') |
|
214 | + ), |
|
215 | + 'datetime_list' => array( |
|
216 | + 'input' => 'textarea', |
|
217 | + 'label' => '[DATETIME_LIST]', |
|
218 | + 'type' => 'string', |
|
219 | + 'required' => TRUE, |
|
220 | + 'validation' => TRUE, |
|
221 | + 'format' => '%s', |
|
222 | + 'css_class' => 'large-text', |
|
223 | + 'rows' => '10', |
|
224 | + 'shortcodes_required' => array('[DATETIME_LIST]') |
|
225 | + ) |
|
226 | + ) |
|
227 | + ) |
|
228 | + ); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * @see definition of this method in parent |
|
234 | + * |
|
235 | + * @since 4.5.0 |
|
236 | + * |
|
237 | + */ |
|
238 | + protected function _set_default_message_types() |
|
239 | + { |
|
240 | + //note currently PDF is only a secondary messenger so it never has any associated message types. |
|
241 | + $this->_default_message_types = array(); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @see definition of this method in parent |
|
247 | + * |
|
248 | + * @since 4.5.0 |
|
249 | + */ |
|
250 | + protected function _set_valid_message_types() |
|
251 | + { |
|
252 | + $this->_valid_message_types = array(); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Generates html version of the message content and then sends it to the pdf generator. |
|
258 | + * |
|
259 | + * |
|
260 | + * @since 4.5.0 |
|
261 | + * |
|
262 | + * @return string. |
|
263 | + */ |
|
264 | + protected function _send_message() |
|
265 | + { |
|
266 | + $this->_template_args = array( |
|
267 | + 'page_title' => stripslashes($this->_subject), |
|
268 | + 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
|
269 | + 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
|
270 | + 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
|
271 | + 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
272 | + 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep($this->_content)), $this->_content) |
|
273 | + ); |
|
274 | + $this->_deregister_wp_hooks(); |
|
275 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
276 | + $content = $this->_get_main_template(); |
|
277 | 277 | // die( $content ); |
278 | - $this->_do_pdf($content); |
|
279 | - exit(0); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
285 | - * |
|
286 | - * @since 4.5.0 |
|
287 | - * |
|
288 | - * @return void |
|
289 | - */ |
|
290 | - protected function _deregister_wp_hooks() |
|
291 | - { |
|
292 | - remove_all_actions('wp_head'); |
|
293 | - remove_all_actions('wp_footer'); |
|
294 | - remove_all_actions('wp_print_footer_scripts'); |
|
295 | - remove_all_actions('wp_enqueue_scripts'); |
|
296 | - global $wp_scripts, $wp_styles; |
|
297 | - $wp_scripts = $wp_styles = array(); |
|
298 | - |
|
299 | - //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
300 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
301 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
302 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * Overwrite parent _get_main_template for pdf purposes. |
|
308 | - * |
|
309 | - * @since 4.5.0 |
|
310 | - * |
|
311 | - * @param bool $preview |
|
312 | - * @return string |
|
313 | - */ |
|
314 | - protected function _get_main_template($preview = FALSE) |
|
315 | - { |
|
316 | - $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
317 | - //add message type to template_args |
|
318 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
319 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * This takes care of loading the dompdf library and generating the actual pdf |
|
325 | - * |
|
326 | - * @param string $content This is the generated html content being converted into a pdf. |
|
327 | - * |
|
328 | - * @return void |
|
329 | - */ |
|
330 | - protected function _do_pdf($content = '') |
|
331 | - { |
|
332 | - $invoice_name = $this->_subject; |
|
333 | - |
|
334 | - //only load dompdf if nobody else has yet... |
|
335 | - if (!defined('DOMPDF_DIR')) { |
|
336 | - define('DOMPDF_ENABLE_REMOTE', TRUE); |
|
337 | - define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
|
338 | - define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
|
339 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
340 | - } |
|
341 | - $dompdf = new DOMPDF(); |
|
342 | - if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
343 | - $dompdf->set_paper(DOMPDF_DEFAULT_PAPER_SIZE); |
|
344 | - } |
|
345 | - //Remove all spaces between HTML tags |
|
346 | - $content = preg_replace('/>\s+</', '><', $content); |
|
347 | - $dompdf->load_html($content); |
|
348 | - $dompdf->render(); |
|
349 | - //forcing the browser to open a download dialog. |
|
350 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => TRUE)); |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * @return string |
|
356 | - */ |
|
357 | - protected function _preview() |
|
358 | - { |
|
359 | - return $this->_send_message(); |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - protected function _set_admin_settings_fields() |
|
364 | - { |
|
365 | - } |
|
278 | + $this->_do_pdf($content); |
|
279 | + exit(0); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't interfere with our templates. If users want to add any custom styles or scripts they must use the AHEE__EE_Pdf_messenger__enqueue_scripts_styles hook. |
|
285 | + * |
|
286 | + * @since 4.5.0 |
|
287 | + * |
|
288 | + * @return void |
|
289 | + */ |
|
290 | + protected function _deregister_wp_hooks() |
|
291 | + { |
|
292 | + remove_all_actions('wp_head'); |
|
293 | + remove_all_actions('wp_footer'); |
|
294 | + remove_all_actions('wp_print_footer_scripts'); |
|
295 | + remove_all_actions('wp_enqueue_scripts'); |
|
296 | + global $wp_scripts, $wp_styles; |
|
297 | + $wp_scripts = $wp_styles = array(); |
|
298 | + |
|
299 | + //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
300 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
301 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
302 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * Overwrite parent _get_main_template for pdf purposes. |
|
308 | + * |
|
309 | + * @since 4.5.0 |
|
310 | + * |
|
311 | + * @param bool $preview |
|
312 | + * @return string |
|
313 | + */ |
|
314 | + protected function _get_main_template($preview = FALSE) |
|
315 | + { |
|
316 | + $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main'); |
|
317 | + //add message type to template_args |
|
318 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
319 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * This takes care of loading the dompdf library and generating the actual pdf |
|
325 | + * |
|
326 | + * @param string $content This is the generated html content being converted into a pdf. |
|
327 | + * |
|
328 | + * @return void |
|
329 | + */ |
|
330 | + protected function _do_pdf($content = '') |
|
331 | + { |
|
332 | + $invoice_name = $this->_subject; |
|
333 | + |
|
334 | + //only load dompdf if nobody else has yet... |
|
335 | + if (!defined('DOMPDF_DIR')) { |
|
336 | + define('DOMPDF_ENABLE_REMOTE', TRUE); |
|
337 | + define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
|
338 | + define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
|
339 | + require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
340 | + } |
|
341 | + $dompdf = new DOMPDF(); |
|
342 | + if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
|
343 | + $dompdf->set_paper(DOMPDF_DEFAULT_PAPER_SIZE); |
|
344 | + } |
|
345 | + //Remove all spaces between HTML tags |
|
346 | + $content = preg_replace('/>\s+</', '><', $content); |
|
347 | + $dompdf->load_html($content); |
|
348 | + $dompdf->render(); |
|
349 | + //forcing the browser to open a download dialog. |
|
350 | + $dompdf->stream($invoice_name . ".pdf", array('Attachment' => TRUE)); |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * @return string |
|
356 | + */ |
|
357 | + protected function _preview() |
|
358 | + { |
|
359 | + return $this->_send_message(); |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + protected function _set_admin_settings_fields() |
|
364 | + { |
|
365 | + } |
|
366 | 366 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | 11 | |
12 | 12 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | 'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'base', $this->_variation), |
269 | 269 | 'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'print', $this->_variation), |
270 | 270 | 'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, TRUE, 'main', $this->_variation), |
271 | - 'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css', |
|
271 | + 'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css', |
|
272 | 272 | 'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop(stripslashes_deep($this->_content)), $this->_content) |
273 | 273 | ); |
274 | 274 | $this->_deregister_wp_hooks(); |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | $invoice_name = $this->_subject; |
333 | 333 | |
334 | 334 | //only load dompdf if nobody else has yet... |
335 | - if (!defined('DOMPDF_DIR')) { |
|
335 | + if ( ! defined('DOMPDF_DIR')) { |
|
336 | 336 | define('DOMPDF_ENABLE_REMOTE', TRUE); |
337 | 337 | define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
338 | 338 | define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
339 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
339 | + require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php'); |
|
340 | 340 | } |
341 | 341 | $dompdf = new DOMPDF(); |
342 | 342 | if (defined('DOMPDF_DEFAULT_PAPER_SIZE')) { |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $dompdf->load_html($content); |
348 | 348 | $dompdf->render(); |
349 | 349 | //forcing the browser to open a download dialog. |
350 | - $dompdf->stream($invoice_name . ".pdf", array('Attachment' => TRUE)); |
|
350 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => TRUE)); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (!defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -16,554 +16,554 @@ discard block |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * The following are the properties that this messenger requires for displaying the html |
|
21 | - */ |
|
22 | - /** |
|
23 | - * This is the html body generated by the template via the message type. |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected $_content; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * This is for the page title that gets displayed. (Why use "subject"? Because the "title" tag in html is |
|
32 | - * equivalent to the "subject" of the page. |
|
33 | - * |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $_subject; |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * EE_Html_messenger constructor. |
|
41 | - */ |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - //set properties |
|
45 | - $this->name = 'html'; |
|
46 | - $this->description = __('This messenger outputs a message to a browser for display.', 'event_espresso'); |
|
47 | - $this->label = array( |
|
48 | - 'singular' => __('html', 'event_espresso'), |
|
49 | - 'plural' => __('html', 'event_espresso'), |
|
50 | - ); |
|
51 | - $this->activate_on_install = true; |
|
52 | - // add the "powered by EE" credit link to the HTML receipt and invoice |
|
53 | - add_filter( |
|
54 | - 'FHEE__EE_Html_messenger___send_message__main_body', |
|
55 | - array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'), |
|
56 | - 10, |
|
57 | - 3 |
|
58 | - ); |
|
59 | - parent::__construct(); |
|
60 | - } |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * HTML Messenger desires execution immediately. |
|
65 | - * |
|
66 | - * @see parent::send_now() for documentation. |
|
67 | - * @since 4.9.0 |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function send_now() |
|
71 | - { |
|
72 | - return true; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * HTML Messenger allows an empty to field. |
|
78 | - * |
|
79 | - * @see parent::allow_empty_to_field() for documentation |
|
80 | - * @since 4.9.0 |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - public function allow_empty_to_field() |
|
84 | - { |
|
85 | - return true; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @see abstract declaration in EE_messenger for details. |
|
91 | - */ |
|
92 | - protected function _set_admin_pages() |
|
93 | - { |
|
94 | - $this->admin_registered_pages = array('events_edit' => true); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @see abstract declaration in EE_messenger for details. |
|
100 | - */ |
|
101 | - protected function _set_valid_shortcodes() |
|
102 | - { |
|
103 | - $this->_valid_shortcodes = array(); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @see abstract declaration in EE_messenger for details. |
|
109 | - */ |
|
110 | - protected function _set_validator_config() |
|
111 | - { |
|
112 | - $this->_validator_config = array( |
|
113 | - 'subject' => array( |
|
114 | - 'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'), |
|
115 | - ), |
|
116 | - 'content' => array( |
|
117 | - 'shortcodes' => array( |
|
118 | - 'organization', |
|
119 | - 'primary_registration_list', |
|
120 | - 'primary_registration_details', |
|
121 | - 'email', |
|
122 | - 'transaction', |
|
123 | - 'event_list', |
|
124 | - 'payment_list', |
|
125 | - 'venue', |
|
126 | - 'line_item_list', |
|
127 | - 'messenger', |
|
128 | - 'ticket_list', |
|
129 | - ), |
|
130 | - ), |
|
131 | - 'event_list' => array( |
|
132 | - 'shortcodes' => array( |
|
133 | - 'event', |
|
134 | - 'ticket_list', |
|
135 | - 'venue', |
|
136 | - 'primary_registration_details', |
|
137 | - 'primary_registration_list', |
|
138 | - 'event_author', |
|
139 | - ), |
|
140 | - 'required' => array('[EVENT_LIST]'), |
|
141 | - ), |
|
142 | - 'ticket_list' => array( |
|
143 | - 'shortcodes' => array( |
|
144 | - 'attendee_list', |
|
145 | - 'ticket', |
|
146 | - 'datetime_list', |
|
147 | - 'primary_registration_details', |
|
148 | - 'line_item_list', |
|
149 | - 'venue', |
|
150 | - ), |
|
151 | - 'required' => array('[TICKET_LIST]'), |
|
152 | - ), |
|
153 | - 'ticket_line_item_no_pms' => array( |
|
154 | - 'shortcodes' => array('line_item', 'ticket'), |
|
155 | - 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
156 | - ), |
|
157 | - 'ticket_line_item_pms' => array( |
|
158 | - 'shortcodes' => array('line_item', 'ticket', 'line_item_list'), |
|
159 | - 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
160 | - ), |
|
161 | - 'price_modifier_line_item_list' => array( |
|
162 | - 'shortcodes' => array('line_item'), |
|
163 | - 'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
164 | - ), |
|
165 | - 'datetime_list' => array( |
|
166 | - 'shortcodes' => array('datetime'), |
|
167 | - 'required' => array('[DATETIME_LIST]'), |
|
168 | - ), |
|
169 | - 'attendee_list' => array( |
|
170 | - 'shortcodes' => array('attendee'), |
|
171 | - 'required' => array('[ATTENDEE_LIST]'), |
|
172 | - ), |
|
173 | - 'tax_line_item_list' => array( |
|
174 | - 'shortcodes' => array('line_item'), |
|
175 | - 'required' => array('[TAX_LINE_ITEM_LIST]'), |
|
176 | - ), |
|
177 | - 'additional_line_item_list' => array( |
|
178 | - 'shortcodes' => array('line_item'), |
|
179 | - 'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
180 | - ), |
|
181 | - 'payment_list' => array( |
|
182 | - 'shortcodes' => array('payment'), |
|
183 | - 'required' => array('[PAYMENT_LIST_*]'), |
|
184 | - ), |
|
185 | - ); |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger |
|
191 | - * is a different messenger. Child messengers can set hooks for the sending messenger to callback on if necessary |
|
192 | - * (i.e. swap out css files or something else). |
|
193 | - * |
|
194 | - * @since 4.5.0 |
|
195 | - * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed. |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public function do_secondary_messenger_hooks($sending_messenger_name) |
|
199 | - { |
|
200 | - if ($sending_messenger_name = 'pdf') { |
|
201 | - add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8); |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @param $variation_path |
|
208 | - * @param \EE_Messages_Template_Pack $template_pack |
|
209 | - * @param $messenger_name |
|
210 | - * @param $message_type_name |
|
211 | - * @param $url |
|
212 | - * @param $type |
|
213 | - * @param $variation |
|
214 | - * @param $skip_filters |
|
215 | - * @return string |
|
216 | - */ |
|
217 | - public function add_html_css( |
|
218 | - $variation_path, |
|
219 | - EE_Messages_Template_Pack $template_pack, |
|
220 | - $messenger_name, |
|
221 | - $message_type_name, |
|
222 | - $url, |
|
223 | - $type, |
|
224 | - $variation, |
|
225 | - $skip_filters |
|
226 | - ) |
|
227 | - { |
|
228 | - $variation = $template_pack->get_variation( |
|
229 | - $this->name, |
|
230 | - $message_type_name, |
|
231 | - $type, |
|
232 | - $variation, |
|
233 | - $url, |
|
234 | - '.css', |
|
235 | - $skip_filters |
|
236 | - ); |
|
237 | - return $variation; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this |
|
243 | - * messenger can add their own js. |
|
244 | - * |
|
245 | - * @return void. |
|
246 | - */ |
|
247 | - public function enqueue_scripts_styles() |
|
248 | - { |
|
249 | - parent::enqueue_scripts_styles(); |
|
250 | - do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles'); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * _set_template_fields |
|
256 | - * This sets up the fields that a messenger requires for the message to go out. |
|
257 | - * |
|
258 | - * @access protected |
|
259 | - * @return void |
|
260 | - */ |
|
261 | - protected function _set_template_fields() |
|
262 | - { |
|
263 | - // any extra template fields that are NOT used by the messenger |
|
264 | - // but will get used by a messenger field for shortcode replacement |
|
265 | - // get added to the 'extra' key in an associated array |
|
266 | - // indexed by the messenger field they relate to. |
|
267 | - // This is important for the Messages_admin to know what fields to display to the user. |
|
268 | - // Also, notice that the "values" are equal to the field type |
|
269 | - // that messages admin will use to know what kind of field to display. |
|
270 | - // The values ALSO have one index labeled "shortcode". |
|
271 | - // The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) |
|
272 | - // is required in order for this extra field to be displayed. |
|
273 | - // If the required shortcode isn't part of the shortcodes array |
|
274 | - // then the field is not needed and will not be displayed/parsed. |
|
275 | - $this->_template_fields = array( |
|
276 | - 'subject' => array( |
|
277 | - 'input' => 'text', |
|
278 | - 'label' => __('Page Title', 'event_espresso'), |
|
279 | - 'type' => 'string', |
|
280 | - 'required' => true, |
|
281 | - 'validation' => true, |
|
282 | - 'css_class' => 'large-text', |
|
283 | - 'format' => '%s', |
|
284 | - ), |
|
285 | - 'content' => '', |
|
286 | - //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
287 | - 'extra' => array( |
|
288 | - 'content' => array( |
|
289 | - 'main' => array( |
|
290 | - 'input' => 'wp_editor', |
|
291 | - 'label' => __('Main Content', 'event_espresso'), |
|
292 | - 'type' => 'string', |
|
293 | - 'required' => true, |
|
294 | - 'validation' => true, |
|
295 | - 'format' => '%s', |
|
296 | - 'rows' => '15', |
|
297 | - ), |
|
298 | - 'event_list' => array( |
|
299 | - 'input' => 'wp_editor', |
|
300 | - 'label' => '[EVENT_LIST]', |
|
301 | - 'type' => 'string', |
|
302 | - 'required' => true, |
|
303 | - 'validation' => true, |
|
304 | - 'format' => '%s', |
|
305 | - 'rows' => '15', |
|
306 | - 'shortcodes_required' => array('[EVENT_LIST]'), |
|
307 | - ), |
|
308 | - 'ticket_list' => array( |
|
309 | - 'input' => 'textarea', |
|
310 | - 'label' => '[TICKET_LIST]', |
|
311 | - 'type' => 'string', |
|
312 | - 'required' => true, |
|
313 | - 'validation' => true, |
|
314 | - 'format' => '%s', |
|
315 | - 'css_class' => 'large-text', |
|
316 | - 'rows' => '10', |
|
317 | - 'shortcodes_required' => array('[TICKET_LIST]'), |
|
318 | - ), |
|
319 | - 'ticket_line_item_no_pms' => array( |
|
320 | - 'input' => 'textarea', |
|
321 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
322 | - 'Ticket Line Item List with no Price Modifiers', |
|
323 | - 'event_espresso' |
|
324 | - ), |
|
325 | - 'type' => 'string', |
|
326 | - 'required' => false, |
|
327 | - 'validation' => true, |
|
328 | - 'format' => '%s', |
|
329 | - 'css_class' => 'large-text', |
|
330 | - 'rows' => '5', |
|
331 | - 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
332 | - ), |
|
333 | - 'ticket_line_item_pms' => array( |
|
334 | - 'input' => 'textarea', |
|
335 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
336 | - 'Ticket Line Item List with Price Modifiers', |
|
337 | - 'event_espresso' |
|
338 | - ), |
|
339 | - 'type' => 'string', |
|
340 | - 'required' => false, |
|
341 | - 'validation' => true, |
|
342 | - 'format' => '%s', |
|
343 | - 'css_class' => 'large-text', |
|
344 | - 'rows' => '5', |
|
345 | - 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
346 | - ), |
|
347 | - 'price_modifier_line_item_list' => array( |
|
348 | - 'input' => 'textarea', |
|
349 | - 'label' => '[PRICE_MODIFIER_LINE_ITEM_LIST]', |
|
350 | - 'type' => 'string', |
|
351 | - 'required' => false, |
|
352 | - 'validation' => true, |
|
353 | - 'format' => '%s', |
|
354 | - 'css_class' => 'large-text', |
|
355 | - 'rows' => '5', |
|
356 | - 'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
357 | - ), |
|
358 | - 'datetime_list' => array( |
|
359 | - 'input' => 'textarea', |
|
360 | - 'label' => '[DATETIME_LIST]', |
|
361 | - 'type' => 'string', |
|
362 | - 'required' => true, |
|
363 | - 'validation' => true, |
|
364 | - 'format' => '%s', |
|
365 | - 'css_class' => 'large-text', |
|
366 | - 'rows' => '5', |
|
367 | - 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
368 | - ), |
|
369 | - 'attendee_list' => array( |
|
370 | - 'input' => 'textarea', |
|
371 | - 'label' => '[ATTENDEE_LIST]', |
|
372 | - 'type' => 'string', |
|
373 | - 'required' => true, |
|
374 | - 'validation' => true, |
|
375 | - 'format' => '%s', |
|
376 | - 'css_class' => 'large-text', |
|
377 | - 'rows' => '5', |
|
378 | - 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
379 | - ), |
|
380 | - 'tax_line_item_list' => array( |
|
381 | - 'input' => 'textarea', |
|
382 | - 'label' => '[TAX_LINE_ITEM_LIST]', |
|
383 | - 'type' => 'string', |
|
384 | - 'required' => false, |
|
385 | - 'validation' => true, |
|
386 | - 'format' => '%s', |
|
387 | - 'css_class' => 'large-text', |
|
388 | - 'rows' => '5', |
|
389 | - 'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'), |
|
390 | - ), |
|
391 | - 'additional_line_item_list' => array( |
|
392 | - 'input' => 'textarea', |
|
393 | - 'label' => '[ADDITIONAL_LINE_ITEM_LIST]', |
|
394 | - 'type' => 'string', |
|
395 | - 'required' => false, |
|
396 | - 'validation' => true, |
|
397 | - 'format' => '%s', |
|
398 | - 'css_class' => 'large-text', |
|
399 | - 'rows' => '5', |
|
400 | - 'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
401 | - ), |
|
402 | - 'payment_list' => array( |
|
403 | - 'input' => 'textarea', |
|
404 | - 'label' => '[PAYMENT_LIST]', |
|
405 | - 'type' => 'string', |
|
406 | - 'required' => true, |
|
407 | - 'validation' => true, |
|
408 | - 'format' => '%s', |
|
409 | - 'css_class' => 'large-text', |
|
410 | - 'rows' => '5', |
|
411 | - 'shortcodes_required' => array('[PAYMENT_LIST_*]'), |
|
412 | - ), |
|
413 | - ), |
|
414 | - ), |
|
415 | - ); |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * @see definition of this method in parent |
|
421 | - * @since 4.5.0 |
|
422 | - */ |
|
423 | - protected function _set_default_message_types() |
|
424 | - { |
|
425 | - $this->_default_message_types = array('receipt', 'invoice'); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * @see definition of this method in parent |
|
431 | - * @since 4.5.0 |
|
432 | - */ |
|
433 | - protected function _set_valid_message_types() |
|
434 | - { |
|
435 | - $this->_valid_message_types = array('receipt', 'invoice'); |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Displays the message in the browser. |
|
441 | - * |
|
442 | - * @since 4.5.0 |
|
443 | - * @return string. |
|
444 | - */ |
|
445 | - protected function _send_message() |
|
446 | - { |
|
447 | - $this->_template_args = array( |
|
448 | - 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
449 | - 'base_css' => $this->get_variation( |
|
450 | - $this->_tmp_pack, |
|
451 | - $this->_incoming_message_type->name, |
|
452 | - true, |
|
453 | - 'base', |
|
454 | - $this->_variation |
|
455 | - ), |
|
456 | - 'print_css' => $this->get_variation( |
|
457 | - $this->_tmp_pack, |
|
458 | - $this->_incoming_message_type->name, |
|
459 | - true, |
|
460 | - 'print', |
|
461 | - $this->_variation |
|
462 | - ), |
|
463 | - 'main_css' => $this->get_variation( |
|
464 | - $this->_tmp_pack, |
|
465 | - $this->_incoming_message_type->name, |
|
466 | - true, |
|
467 | - 'main', |
|
468 | - $this->_variation |
|
469 | - ), |
|
470 | - 'main_body' => wpautop( |
|
471 | - stripslashes_deep( |
|
472 | - apply_filters( |
|
473 | - 'FHEE__EE_Html_messenger___send_message__main_body', |
|
474 | - $this->_content, |
|
475 | - $this->_content, |
|
476 | - $this->_incoming_message_type |
|
477 | - ) |
|
478 | - ) |
|
479 | - ), |
|
480 | - ); |
|
481 | - $this->_deregister_wp_hooks(); |
|
482 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
483 | - echo $this->_get_main_template(); |
|
484 | - exit(); |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't |
|
490 | - * interfere with our templates. If users want to add any custom styles or scripts they must use the |
|
491 | - * AHEE__EE_Html_messenger__enqueue_scripts_styles hook. |
|
492 | - * |
|
493 | - * @since 4.5.0 |
|
494 | - * @return void |
|
495 | - */ |
|
496 | - protected function _deregister_wp_hooks() |
|
497 | - { |
|
498 | - remove_all_actions('wp_head'); |
|
499 | - remove_all_actions('wp_footer'); |
|
500 | - remove_all_actions('wp_print_footer_scripts'); |
|
501 | - remove_all_actions('wp_enqueue_scripts'); |
|
502 | - global $wp_scripts, $wp_styles; |
|
503 | - $wp_scripts = $wp_styles = array(); |
|
504 | - //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
505 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
506 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
507 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Overwrite parent _get_main_template for display_html purposes. |
|
513 | - * |
|
514 | - * @since 4.5.0 |
|
515 | - * @param bool $preview |
|
516 | - * @return string |
|
517 | - */ |
|
518 | - protected function _get_main_template($preview = false) |
|
519 | - { |
|
520 | - $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
521 | - //include message type as a template arg |
|
522 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
523 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
524 | - } |
|
525 | - |
|
526 | - |
|
527 | - /** |
|
528 | - * @return string |
|
529 | - */ |
|
530 | - protected function _preview() |
|
531 | - { |
|
532 | - return $this->_send_message(); |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - protected function _set_admin_settings_fields() |
|
537 | - { |
|
538 | - } |
|
539 | - |
|
540 | - |
|
541 | - /** |
|
542 | - * add the "powered by EE" credit link to the HTML receipt and invoice |
|
543 | - * |
|
544 | - * @param string $content |
|
545 | - * @param string $content_again |
|
546 | - * @param \EE_message_type $incoming_message_type |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function add_powered_by_credit_link_to_receipt_and_invoice( |
|
550 | - $content = '', |
|
551 | - $content_again = '', |
|
552 | - EE_message_type $incoming_message_type |
|
553 | - ) |
|
554 | - { |
|
555 | - if ( |
|
556 | - ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
557 | - && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
558 | - ) { |
|
559 | - $content .= \EEH_Template::powered_by_event_espresso( |
|
560 | - 'aln-cntr', |
|
561 | - '', |
|
562 | - array('utm_content' => 'messages_system') |
|
563 | - ) |
|
564 | - . EEH_HTML::div(EEH_HTML::p(' ')); |
|
565 | - } |
|
566 | - return $content; |
|
567 | - } |
|
19 | + /** |
|
20 | + * The following are the properties that this messenger requires for displaying the html |
|
21 | + */ |
|
22 | + /** |
|
23 | + * This is the html body generated by the template via the message type. |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected $_content; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * This is for the page title that gets displayed. (Why use "subject"? Because the "title" tag in html is |
|
32 | + * equivalent to the "subject" of the page. |
|
33 | + * |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $_subject; |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * EE_Html_messenger constructor. |
|
41 | + */ |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + //set properties |
|
45 | + $this->name = 'html'; |
|
46 | + $this->description = __('This messenger outputs a message to a browser for display.', 'event_espresso'); |
|
47 | + $this->label = array( |
|
48 | + 'singular' => __('html', 'event_espresso'), |
|
49 | + 'plural' => __('html', 'event_espresso'), |
|
50 | + ); |
|
51 | + $this->activate_on_install = true; |
|
52 | + // add the "powered by EE" credit link to the HTML receipt and invoice |
|
53 | + add_filter( |
|
54 | + 'FHEE__EE_Html_messenger___send_message__main_body', |
|
55 | + array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'), |
|
56 | + 10, |
|
57 | + 3 |
|
58 | + ); |
|
59 | + parent::__construct(); |
|
60 | + } |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * HTML Messenger desires execution immediately. |
|
65 | + * |
|
66 | + * @see parent::send_now() for documentation. |
|
67 | + * @since 4.9.0 |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function send_now() |
|
71 | + { |
|
72 | + return true; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * HTML Messenger allows an empty to field. |
|
78 | + * |
|
79 | + * @see parent::allow_empty_to_field() for documentation |
|
80 | + * @since 4.9.0 |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + public function allow_empty_to_field() |
|
84 | + { |
|
85 | + return true; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @see abstract declaration in EE_messenger for details. |
|
91 | + */ |
|
92 | + protected function _set_admin_pages() |
|
93 | + { |
|
94 | + $this->admin_registered_pages = array('events_edit' => true); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @see abstract declaration in EE_messenger for details. |
|
100 | + */ |
|
101 | + protected function _set_valid_shortcodes() |
|
102 | + { |
|
103 | + $this->_valid_shortcodes = array(); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @see abstract declaration in EE_messenger for details. |
|
109 | + */ |
|
110 | + protected function _set_validator_config() |
|
111 | + { |
|
112 | + $this->_validator_config = array( |
|
113 | + 'subject' => array( |
|
114 | + 'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'), |
|
115 | + ), |
|
116 | + 'content' => array( |
|
117 | + 'shortcodes' => array( |
|
118 | + 'organization', |
|
119 | + 'primary_registration_list', |
|
120 | + 'primary_registration_details', |
|
121 | + 'email', |
|
122 | + 'transaction', |
|
123 | + 'event_list', |
|
124 | + 'payment_list', |
|
125 | + 'venue', |
|
126 | + 'line_item_list', |
|
127 | + 'messenger', |
|
128 | + 'ticket_list', |
|
129 | + ), |
|
130 | + ), |
|
131 | + 'event_list' => array( |
|
132 | + 'shortcodes' => array( |
|
133 | + 'event', |
|
134 | + 'ticket_list', |
|
135 | + 'venue', |
|
136 | + 'primary_registration_details', |
|
137 | + 'primary_registration_list', |
|
138 | + 'event_author', |
|
139 | + ), |
|
140 | + 'required' => array('[EVENT_LIST]'), |
|
141 | + ), |
|
142 | + 'ticket_list' => array( |
|
143 | + 'shortcodes' => array( |
|
144 | + 'attendee_list', |
|
145 | + 'ticket', |
|
146 | + 'datetime_list', |
|
147 | + 'primary_registration_details', |
|
148 | + 'line_item_list', |
|
149 | + 'venue', |
|
150 | + ), |
|
151 | + 'required' => array('[TICKET_LIST]'), |
|
152 | + ), |
|
153 | + 'ticket_line_item_no_pms' => array( |
|
154 | + 'shortcodes' => array('line_item', 'ticket'), |
|
155 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
156 | + ), |
|
157 | + 'ticket_line_item_pms' => array( |
|
158 | + 'shortcodes' => array('line_item', 'ticket', 'line_item_list'), |
|
159 | + 'required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
160 | + ), |
|
161 | + 'price_modifier_line_item_list' => array( |
|
162 | + 'shortcodes' => array('line_item'), |
|
163 | + 'required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
164 | + ), |
|
165 | + 'datetime_list' => array( |
|
166 | + 'shortcodes' => array('datetime'), |
|
167 | + 'required' => array('[DATETIME_LIST]'), |
|
168 | + ), |
|
169 | + 'attendee_list' => array( |
|
170 | + 'shortcodes' => array('attendee'), |
|
171 | + 'required' => array('[ATTENDEE_LIST]'), |
|
172 | + ), |
|
173 | + 'tax_line_item_list' => array( |
|
174 | + 'shortcodes' => array('line_item'), |
|
175 | + 'required' => array('[TAX_LINE_ITEM_LIST]'), |
|
176 | + ), |
|
177 | + 'additional_line_item_list' => array( |
|
178 | + 'shortcodes' => array('line_item'), |
|
179 | + 'required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
180 | + ), |
|
181 | + 'payment_list' => array( |
|
182 | + 'shortcodes' => array('payment'), |
|
183 | + 'required' => array('[PAYMENT_LIST_*]'), |
|
184 | + ), |
|
185 | + ); |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger |
|
191 | + * is a different messenger. Child messengers can set hooks for the sending messenger to callback on if necessary |
|
192 | + * (i.e. swap out css files or something else). |
|
193 | + * |
|
194 | + * @since 4.5.0 |
|
195 | + * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed. |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public function do_secondary_messenger_hooks($sending_messenger_name) |
|
199 | + { |
|
200 | + if ($sending_messenger_name = 'pdf') { |
|
201 | + add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8); |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @param $variation_path |
|
208 | + * @param \EE_Messages_Template_Pack $template_pack |
|
209 | + * @param $messenger_name |
|
210 | + * @param $message_type_name |
|
211 | + * @param $url |
|
212 | + * @param $type |
|
213 | + * @param $variation |
|
214 | + * @param $skip_filters |
|
215 | + * @return string |
|
216 | + */ |
|
217 | + public function add_html_css( |
|
218 | + $variation_path, |
|
219 | + EE_Messages_Template_Pack $template_pack, |
|
220 | + $messenger_name, |
|
221 | + $message_type_name, |
|
222 | + $url, |
|
223 | + $type, |
|
224 | + $variation, |
|
225 | + $skip_filters |
|
226 | + ) |
|
227 | + { |
|
228 | + $variation = $template_pack->get_variation( |
|
229 | + $this->name, |
|
230 | + $message_type_name, |
|
231 | + $type, |
|
232 | + $variation, |
|
233 | + $url, |
|
234 | + '.css', |
|
235 | + $skip_filters |
|
236 | + ); |
|
237 | + return $variation; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * Takes care of enqueuing any necessary scripts or styles for the page. A do_action() so message types using this |
|
243 | + * messenger can add their own js. |
|
244 | + * |
|
245 | + * @return void. |
|
246 | + */ |
|
247 | + public function enqueue_scripts_styles() |
|
248 | + { |
|
249 | + parent::enqueue_scripts_styles(); |
|
250 | + do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles'); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * _set_template_fields |
|
256 | + * This sets up the fields that a messenger requires for the message to go out. |
|
257 | + * |
|
258 | + * @access protected |
|
259 | + * @return void |
|
260 | + */ |
|
261 | + protected function _set_template_fields() |
|
262 | + { |
|
263 | + // any extra template fields that are NOT used by the messenger |
|
264 | + // but will get used by a messenger field for shortcode replacement |
|
265 | + // get added to the 'extra' key in an associated array |
|
266 | + // indexed by the messenger field they relate to. |
|
267 | + // This is important for the Messages_admin to know what fields to display to the user. |
|
268 | + // Also, notice that the "values" are equal to the field type |
|
269 | + // that messages admin will use to know what kind of field to display. |
|
270 | + // The values ALSO have one index labeled "shortcode". |
|
271 | + // The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) |
|
272 | + // is required in order for this extra field to be displayed. |
|
273 | + // If the required shortcode isn't part of the shortcodes array |
|
274 | + // then the field is not needed and will not be displayed/parsed. |
|
275 | + $this->_template_fields = array( |
|
276 | + 'subject' => array( |
|
277 | + 'input' => 'text', |
|
278 | + 'label' => __('Page Title', 'event_espresso'), |
|
279 | + 'type' => 'string', |
|
280 | + 'required' => true, |
|
281 | + 'validation' => true, |
|
282 | + 'css_class' => 'large-text', |
|
283 | + 'format' => '%s', |
|
284 | + ), |
|
285 | + 'content' => '', |
|
286 | + //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
287 | + 'extra' => array( |
|
288 | + 'content' => array( |
|
289 | + 'main' => array( |
|
290 | + 'input' => 'wp_editor', |
|
291 | + 'label' => __('Main Content', 'event_espresso'), |
|
292 | + 'type' => 'string', |
|
293 | + 'required' => true, |
|
294 | + 'validation' => true, |
|
295 | + 'format' => '%s', |
|
296 | + 'rows' => '15', |
|
297 | + ), |
|
298 | + 'event_list' => array( |
|
299 | + 'input' => 'wp_editor', |
|
300 | + 'label' => '[EVENT_LIST]', |
|
301 | + 'type' => 'string', |
|
302 | + 'required' => true, |
|
303 | + 'validation' => true, |
|
304 | + 'format' => '%s', |
|
305 | + 'rows' => '15', |
|
306 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
307 | + ), |
|
308 | + 'ticket_list' => array( |
|
309 | + 'input' => 'textarea', |
|
310 | + 'label' => '[TICKET_LIST]', |
|
311 | + 'type' => 'string', |
|
312 | + 'required' => true, |
|
313 | + 'validation' => true, |
|
314 | + 'format' => '%s', |
|
315 | + 'css_class' => 'large-text', |
|
316 | + 'rows' => '10', |
|
317 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
318 | + ), |
|
319 | + 'ticket_line_item_no_pms' => array( |
|
320 | + 'input' => 'textarea', |
|
321 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
322 | + 'Ticket Line Item List with no Price Modifiers', |
|
323 | + 'event_espresso' |
|
324 | + ), |
|
325 | + 'type' => 'string', |
|
326 | + 'required' => false, |
|
327 | + 'validation' => true, |
|
328 | + 'format' => '%s', |
|
329 | + 'css_class' => 'large-text', |
|
330 | + 'rows' => '5', |
|
331 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
332 | + ), |
|
333 | + 'ticket_line_item_pms' => array( |
|
334 | + 'input' => 'textarea', |
|
335 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
336 | + 'Ticket Line Item List with Price Modifiers', |
|
337 | + 'event_espresso' |
|
338 | + ), |
|
339 | + 'type' => 'string', |
|
340 | + 'required' => false, |
|
341 | + 'validation' => true, |
|
342 | + 'format' => '%s', |
|
343 | + 'css_class' => 'large-text', |
|
344 | + 'rows' => '5', |
|
345 | + 'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'), |
|
346 | + ), |
|
347 | + 'price_modifier_line_item_list' => array( |
|
348 | + 'input' => 'textarea', |
|
349 | + 'label' => '[PRICE_MODIFIER_LINE_ITEM_LIST]', |
|
350 | + 'type' => 'string', |
|
351 | + 'required' => false, |
|
352 | + 'validation' => true, |
|
353 | + 'format' => '%s', |
|
354 | + 'css_class' => 'large-text', |
|
355 | + 'rows' => '5', |
|
356 | + 'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'), |
|
357 | + ), |
|
358 | + 'datetime_list' => array( |
|
359 | + 'input' => 'textarea', |
|
360 | + 'label' => '[DATETIME_LIST]', |
|
361 | + 'type' => 'string', |
|
362 | + 'required' => true, |
|
363 | + 'validation' => true, |
|
364 | + 'format' => '%s', |
|
365 | + 'css_class' => 'large-text', |
|
366 | + 'rows' => '5', |
|
367 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
368 | + ), |
|
369 | + 'attendee_list' => array( |
|
370 | + 'input' => 'textarea', |
|
371 | + 'label' => '[ATTENDEE_LIST]', |
|
372 | + 'type' => 'string', |
|
373 | + 'required' => true, |
|
374 | + 'validation' => true, |
|
375 | + 'format' => '%s', |
|
376 | + 'css_class' => 'large-text', |
|
377 | + 'rows' => '5', |
|
378 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
379 | + ), |
|
380 | + 'tax_line_item_list' => array( |
|
381 | + 'input' => 'textarea', |
|
382 | + 'label' => '[TAX_LINE_ITEM_LIST]', |
|
383 | + 'type' => 'string', |
|
384 | + 'required' => false, |
|
385 | + 'validation' => true, |
|
386 | + 'format' => '%s', |
|
387 | + 'css_class' => 'large-text', |
|
388 | + 'rows' => '5', |
|
389 | + 'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'), |
|
390 | + ), |
|
391 | + 'additional_line_item_list' => array( |
|
392 | + 'input' => 'textarea', |
|
393 | + 'label' => '[ADDITIONAL_LINE_ITEM_LIST]', |
|
394 | + 'type' => 'string', |
|
395 | + 'required' => false, |
|
396 | + 'validation' => true, |
|
397 | + 'format' => '%s', |
|
398 | + 'css_class' => 'large-text', |
|
399 | + 'rows' => '5', |
|
400 | + 'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'), |
|
401 | + ), |
|
402 | + 'payment_list' => array( |
|
403 | + 'input' => 'textarea', |
|
404 | + 'label' => '[PAYMENT_LIST]', |
|
405 | + 'type' => 'string', |
|
406 | + 'required' => true, |
|
407 | + 'validation' => true, |
|
408 | + 'format' => '%s', |
|
409 | + 'css_class' => 'large-text', |
|
410 | + 'rows' => '5', |
|
411 | + 'shortcodes_required' => array('[PAYMENT_LIST_*]'), |
|
412 | + ), |
|
413 | + ), |
|
414 | + ), |
|
415 | + ); |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * @see definition of this method in parent |
|
421 | + * @since 4.5.0 |
|
422 | + */ |
|
423 | + protected function _set_default_message_types() |
|
424 | + { |
|
425 | + $this->_default_message_types = array('receipt', 'invoice'); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * @see definition of this method in parent |
|
431 | + * @since 4.5.0 |
|
432 | + */ |
|
433 | + protected function _set_valid_message_types() |
|
434 | + { |
|
435 | + $this->_valid_message_types = array('receipt', 'invoice'); |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Displays the message in the browser. |
|
441 | + * |
|
442 | + * @since 4.5.0 |
|
443 | + * @return string. |
|
444 | + */ |
|
445 | + protected function _send_message() |
|
446 | + { |
|
447 | + $this->_template_args = array( |
|
448 | + 'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
449 | + 'base_css' => $this->get_variation( |
|
450 | + $this->_tmp_pack, |
|
451 | + $this->_incoming_message_type->name, |
|
452 | + true, |
|
453 | + 'base', |
|
454 | + $this->_variation |
|
455 | + ), |
|
456 | + 'print_css' => $this->get_variation( |
|
457 | + $this->_tmp_pack, |
|
458 | + $this->_incoming_message_type->name, |
|
459 | + true, |
|
460 | + 'print', |
|
461 | + $this->_variation |
|
462 | + ), |
|
463 | + 'main_css' => $this->get_variation( |
|
464 | + $this->_tmp_pack, |
|
465 | + $this->_incoming_message_type->name, |
|
466 | + true, |
|
467 | + 'main', |
|
468 | + $this->_variation |
|
469 | + ), |
|
470 | + 'main_body' => wpautop( |
|
471 | + stripslashes_deep( |
|
472 | + apply_filters( |
|
473 | + 'FHEE__EE_Html_messenger___send_message__main_body', |
|
474 | + $this->_content, |
|
475 | + $this->_content, |
|
476 | + $this->_incoming_message_type |
|
477 | + ) |
|
478 | + ) |
|
479 | + ), |
|
480 | + ); |
|
481 | + $this->_deregister_wp_hooks(); |
|
482 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
483 | + echo $this->_get_main_template(); |
|
484 | + exit(); |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't |
|
490 | + * interfere with our templates. If users want to add any custom styles or scripts they must use the |
|
491 | + * AHEE__EE_Html_messenger__enqueue_scripts_styles hook. |
|
492 | + * |
|
493 | + * @since 4.5.0 |
|
494 | + * @return void |
|
495 | + */ |
|
496 | + protected function _deregister_wp_hooks() |
|
497 | + { |
|
498 | + remove_all_actions('wp_head'); |
|
499 | + remove_all_actions('wp_footer'); |
|
500 | + remove_all_actions('wp_print_footer_scripts'); |
|
501 | + remove_all_actions('wp_enqueue_scripts'); |
|
502 | + global $wp_scripts, $wp_styles; |
|
503 | + $wp_scripts = $wp_styles = array(); |
|
504 | + //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
505 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
506 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
507 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Overwrite parent _get_main_template for display_html purposes. |
|
513 | + * |
|
514 | + * @since 4.5.0 |
|
515 | + * @param bool $preview |
|
516 | + * @return string |
|
517 | + */ |
|
518 | + protected function _get_main_template($preview = false) |
|
519 | + { |
|
520 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
521 | + //include message type as a template arg |
|
522 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
523 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
524 | + } |
|
525 | + |
|
526 | + |
|
527 | + /** |
|
528 | + * @return string |
|
529 | + */ |
|
530 | + protected function _preview() |
|
531 | + { |
|
532 | + return $this->_send_message(); |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + protected function _set_admin_settings_fields() |
|
537 | + { |
|
538 | + } |
|
539 | + |
|
540 | + |
|
541 | + /** |
|
542 | + * add the "powered by EE" credit link to the HTML receipt and invoice |
|
543 | + * |
|
544 | + * @param string $content |
|
545 | + * @param string $content_again |
|
546 | + * @param \EE_message_type $incoming_message_type |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function add_powered_by_credit_link_to_receipt_and_invoice( |
|
550 | + $content = '', |
|
551 | + $content_again = '', |
|
552 | + EE_message_type $incoming_message_type |
|
553 | + ) |
|
554 | + { |
|
555 | + if ( |
|
556 | + ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
557 | + && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
558 | + ) { |
|
559 | + $content .= \EEH_Template::powered_by_event_espresso( |
|
560 | + 'aln-cntr', |
|
561 | + '', |
|
562 | + array('utm_content' => 'messages_system') |
|
563 | + ) |
|
564 | + . EEH_HTML::div(EEH_HTML::p(' ')); |
|
565 | + } |
|
566 | + return $content; |
|
567 | + } |
|
568 | 568 | |
569 | 569 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | ), |
319 | 319 | 'ticket_line_item_no_pms' => array( |
320 | 320 | 'input' => 'textarea', |
321 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
321 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
322 | 322 | 'Ticket Line Item List with no Price Modifiers', |
323 | 323 | 'event_espresso' |
324 | 324 | ), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | ), |
333 | 333 | 'ticket_line_item_pms' => array( |
334 | 334 | 'input' => 'textarea', |
335 | - 'label' => '[TICKET_LINE_ITEM_LIST] <br>' . __( |
|
335 | + 'label' => '[TICKET_LINE_ITEM_LIST] <br>'.__( |
|
336 | 336 | 'Ticket Line Item List with Price Modifiers', |
337 | 337 | 'event_espresso' |
338 | 338 | ), |
@@ -8,645 +8,645 @@ |
||
8 | 8 | class EE_Email_messenger extends EE_messenger |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * To field for email |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $_to = ''; |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * CC field for email. |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $_cc = ''; |
|
23 | - |
|
24 | - /** |
|
25 | - * From field for email |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_from = ''; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * Subject field for email |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_subject = ''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Content field for email |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - protected $_content = ''; |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * constructor |
|
47 | - * |
|
48 | - * @access public |
|
49 | - */ |
|
50 | - public function __construct() |
|
51 | - { |
|
52 | - //set name and description properties |
|
53 | - $this->name = 'email'; |
|
54 | - $this->description = sprintf( |
|
55 | - esc_html__( |
|
56 | - 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - '<code>wp_mail</code>' |
|
60 | - ); |
|
61 | - $this->label = array( |
|
62 | - 'singular' => esc_html__('email', 'event_espresso'), |
|
63 | - 'plural' => esc_html__('emails', 'event_espresso'), |
|
64 | - ); |
|
65 | - $this->activate_on_install = true; |
|
66 | - |
|
67 | - //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
68 | - // properties |
|
69 | - parent::__construct(); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * see abstract declaration in parent class for details. |
|
75 | - */ |
|
76 | - protected function _set_admin_pages() |
|
77 | - { |
|
78 | - $this->admin_registered_pages = array( |
|
79 | - 'events_edit' => true, |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * see abstract declaration in parent class for details |
|
86 | - */ |
|
87 | - protected function _set_valid_shortcodes() |
|
88 | - { |
|
89 | - //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
90 | - // message type. |
|
91 | - $this->_valid_shortcodes = array( |
|
92 | - 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
93 | - 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
94 | - 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * see abstract declaration in parent class for details |
|
101 | - * |
|
102 | - * @access protected |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - protected function _set_validator_config() |
|
106 | - { |
|
107 | - $valid_shortcodes = $this->get_valid_shortcodes(); |
|
108 | - |
|
109 | - $this->_validator_config = array( |
|
110 | - 'to' => array( |
|
111 | - 'shortcodes' => $valid_shortcodes['to'], |
|
112 | - 'type' => 'email', |
|
113 | - ), |
|
114 | - 'cc' => array( |
|
115 | - 'shortcodes' => $valid_shortcodes['to'], |
|
116 | - 'type' => 'email', |
|
117 | - ), |
|
118 | - 'from' => array( |
|
119 | - 'shortcodes' => $valid_shortcodes['from'], |
|
120 | - 'type' => 'email', |
|
121 | - ), |
|
122 | - 'subject' => array( |
|
123 | - 'shortcodes' => array( |
|
124 | - 'organization', |
|
125 | - 'primary_registration_details', |
|
126 | - 'event_author', |
|
127 | - 'primary_registration_details', |
|
128 | - 'recipient_details', |
|
129 | - ), |
|
130 | - ), |
|
131 | - 'content' => array( |
|
132 | - 'shortcodes' => array( |
|
133 | - 'event_list', |
|
134 | - 'attendee_list', |
|
135 | - 'ticket_list', |
|
136 | - 'organization', |
|
137 | - 'primary_registration_details', |
|
138 | - 'primary_registration_list', |
|
139 | - 'event_author', |
|
140 | - 'recipient_details', |
|
141 | - 'recipient_list', |
|
142 | - 'transaction', |
|
143 | - 'messenger', |
|
144 | - ), |
|
145 | - ), |
|
146 | - 'attendee_list' => array( |
|
147 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
148 | - 'required' => array('[ATTENDEE_LIST]'), |
|
149 | - ), |
|
150 | - 'event_list' => array( |
|
151 | - 'shortcodes' => array( |
|
152 | - 'event', |
|
153 | - 'attendee_list', |
|
154 | - 'ticket_list', |
|
155 | - 'venue', |
|
156 | - 'datetime_list', |
|
157 | - 'attendee', |
|
158 | - 'primary_registration_details', |
|
159 | - 'primary_registration_list', |
|
160 | - 'event_author', |
|
161 | - 'recipient_details', |
|
162 | - 'recipient_list', |
|
163 | - ), |
|
164 | - 'required' => array('[EVENT_LIST]'), |
|
165 | - ), |
|
166 | - 'ticket_list' => array( |
|
167 | - 'shortcodes' => array( |
|
168 | - 'event_list', |
|
169 | - 'attendee_list', |
|
170 | - 'ticket', |
|
171 | - 'datetime_list', |
|
172 | - 'primary_registration_details', |
|
173 | - 'recipient_details', |
|
174 | - ), |
|
175 | - 'required' => array('[TICKET_LIST]'), |
|
176 | - ), |
|
177 | - 'datetime_list' => array( |
|
178 | - 'shortcodes' => array('datetime'), |
|
179 | - 'required' => array('[DATETIME_LIST]'), |
|
180 | - ), |
|
181 | - ); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @see parent EE_messenger class for docs |
|
187 | - * @since 4.5.0 |
|
188 | - */ |
|
189 | - public function do_secondary_messenger_hooks($sending_messenger_name) |
|
190 | - { |
|
191 | - if ($sending_messenger_name = 'html') { |
|
192 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - public function add_email_css( |
|
198 | - $variation_path, |
|
199 | - $messenger, |
|
200 | - $message_type, |
|
201 | - $type, |
|
202 | - $variation, |
|
203 | - $file_extension, |
|
204 | - $url, |
|
205 | - EE_Messages_Template_Pack $template_pack |
|
206 | - ) { |
|
207 | - //prevent recursion on this callback. |
|
208 | - remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
209 | - $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
210 | - |
|
211 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
212 | - return $variation; |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * See parent for details |
|
218 | - * |
|
219 | - * @access protected |
|
220 | - * @return void |
|
221 | - */ |
|
222 | - protected function _set_test_settings_fields() |
|
223 | - { |
|
224 | - $this->_test_settings_fields = array( |
|
225 | - 'to' => array( |
|
226 | - 'input' => 'text', |
|
227 | - 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
228 | - 'type' => 'email', |
|
229 | - 'required' => true, |
|
230 | - 'validation' => true, |
|
231 | - 'css_class' => 'large-text', |
|
232 | - 'format' => '%s', |
|
233 | - 'default' => get_bloginfo('admin_email'), |
|
234 | - ), |
|
235 | - 'subject' => array( |
|
236 | - 'input' => 'hidden', |
|
237 | - 'label' => '', |
|
238 | - 'type' => 'string', |
|
239 | - 'required' => false, |
|
240 | - 'validation' => false, |
|
241 | - 'format' => '%s', |
|
242 | - 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
243 | - 'default' => '', |
|
244 | - 'css_class' => '', |
|
245 | - ), |
|
246 | - ); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * _set_template_fields |
|
252 | - * This sets up the fields that a messenger requires for the message to go out. |
|
253 | - * |
|
254 | - * @access protected |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - protected function _set_template_fields() |
|
258 | - { |
|
259 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
260 | - // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
261 | - // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
262 | - // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
263 | - // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
264 | - // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
265 | - // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
266 | - // will not be displayed/parsed. |
|
267 | - $this->_template_fields = array( |
|
268 | - 'to' => array( |
|
269 | - 'input' => 'text', |
|
270 | - 'label' => esc_html_x( |
|
271 | - 'To', |
|
272 | - 'Label for the "To" field for email addresses', |
|
273 | - 'event_espresso' |
|
274 | - ), |
|
275 | - 'type' => 'string', |
|
276 | - 'required' => true, |
|
277 | - 'validation' => true, |
|
278 | - 'css_class' => 'large-text', |
|
279 | - 'format' => '%s', |
|
280 | - ), |
|
281 | - 'cc' => array( |
|
282 | - 'input' => 'text', |
|
283 | - 'label' => esc_html_x( |
|
284 | - 'CC', |
|
285 | - 'Label for the "Carbon Copy" field used for additional email addresses', |
|
286 | - 'event_espresso' |
|
287 | - ), |
|
288 | - 'type' => 'string', |
|
289 | - 'required' => false, |
|
290 | - 'validation' => true, |
|
291 | - 'css_class' => 'large-text', |
|
292 | - 'format' => '%s', |
|
293 | - ), |
|
294 | - 'from' => array( |
|
295 | - 'input' => 'text', |
|
296 | - 'label' => esc_html_x( |
|
297 | - 'From', |
|
298 | - 'Label for the "From" field for email addresses.', |
|
299 | - 'event_espresso' |
|
300 | - ), |
|
301 | - 'type' => 'string', |
|
302 | - 'required' => true, |
|
303 | - 'validation' => true, |
|
304 | - 'css_class' => 'large-text', |
|
305 | - 'format' => '%s', |
|
306 | - ), |
|
307 | - 'subject' => array( |
|
308 | - 'input' => 'text', |
|
309 | - 'label' => esc_html_x( |
|
310 | - 'Subject', |
|
311 | - 'Label for the "Subject" field (short description of contents) for emails.', |
|
312 | - 'event_espresso' |
|
313 | - ), |
|
314 | - 'type' => 'string', |
|
315 | - 'required' => true, |
|
316 | - 'validation' => true, |
|
317 | - 'css_class' => 'large-text', |
|
318 | - 'format' => '%s', |
|
319 | - ), |
|
320 | - 'content' => '', |
|
321 | - //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
322 | - 'extra' => array( |
|
323 | - 'content' => array( |
|
324 | - 'main' => array( |
|
325 | - 'input' => 'wp_editor', |
|
326 | - 'label' => esc_html__('Main Content', 'event_espresso'), |
|
327 | - 'type' => 'string', |
|
328 | - 'required' => true, |
|
329 | - 'validation' => true, |
|
330 | - 'format' => '%s', |
|
331 | - 'rows' => '15', |
|
332 | - ), |
|
333 | - 'event_list' => array( |
|
334 | - 'input' => 'wp_editor', |
|
335 | - 'label' => '[EVENT_LIST]', |
|
336 | - 'type' => 'string', |
|
337 | - 'required' => true, |
|
338 | - 'validation' => true, |
|
339 | - 'format' => '%s', |
|
340 | - 'rows' => '15', |
|
341 | - 'shortcodes_required' => array('[EVENT_LIST]'), |
|
342 | - ), |
|
343 | - 'attendee_list' => array( |
|
344 | - 'input' => 'textarea', |
|
345 | - 'label' => '[ATTENDEE_LIST]', |
|
346 | - 'type' => 'string', |
|
347 | - 'required' => true, |
|
348 | - 'validation' => true, |
|
349 | - 'format' => '%s', |
|
350 | - 'css_class' => 'large-text', |
|
351 | - 'rows' => '5', |
|
352 | - 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
353 | - ), |
|
354 | - 'ticket_list' => array( |
|
355 | - 'input' => 'textarea', |
|
356 | - 'label' => '[TICKET_LIST]', |
|
357 | - 'type' => 'string', |
|
358 | - 'required' => true, |
|
359 | - 'validation' => true, |
|
360 | - 'format' => '%s', |
|
361 | - 'css_class' => 'large-text', |
|
362 | - 'rows' => '10', |
|
363 | - 'shortcodes_required' => array('[TICKET_LIST]'), |
|
364 | - ), |
|
365 | - 'datetime_list' => array( |
|
366 | - 'input' => 'textarea', |
|
367 | - 'label' => '[DATETIME_LIST]', |
|
368 | - 'type' => 'string', |
|
369 | - 'required' => true, |
|
370 | - 'validation' => true, |
|
371 | - 'format' => '%s', |
|
372 | - 'css_class' => 'large-text', |
|
373 | - 'rows' => '10', |
|
374 | - 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
375 | - ), |
|
376 | - ), |
|
377 | - ), |
|
378 | - ); |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * See definition of this class in parent |
|
384 | - */ |
|
385 | - protected function _set_default_message_types() |
|
386 | - { |
|
387 | - $this->_default_message_types = array( |
|
388 | - 'payment', |
|
389 | - 'payment_refund', |
|
390 | - 'registration', |
|
391 | - 'not_approved_registration', |
|
392 | - 'pending_approval', |
|
393 | - ); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - /** |
|
398 | - * @see definition of this class in parent |
|
399 | - * @since 4.5.0 |
|
400 | - */ |
|
401 | - protected function _set_valid_message_types() |
|
402 | - { |
|
403 | - $this->_valid_message_types = array( |
|
404 | - 'payment', |
|
405 | - 'registration', |
|
406 | - 'not_approved_registration', |
|
407 | - 'declined_registration', |
|
408 | - 'cancelled_registration', |
|
409 | - 'pending_approval', |
|
410 | - 'registration_summary', |
|
411 | - 'payment_reminder', |
|
412 | - 'payment_declined', |
|
413 | - 'payment_refund', |
|
414 | - ); |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - /** |
|
419 | - * setting up admin_settings_fields for messenger. |
|
420 | - */ |
|
421 | - protected function _set_admin_settings_fields() |
|
422 | - { |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * We just deliver the messages don't kill us!! |
|
427 | - * |
|
428 | - * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
429 | - * present. |
|
430 | - * @throws EE_Error |
|
431 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
432 | - */ |
|
433 | - protected function _send_message() |
|
434 | - { |
|
435 | - $success = wp_mail( |
|
436 | - $this->_to, |
|
437 | - stripslashes($this->_subject), |
|
438 | - $this->_body(), |
|
439 | - $this->_headers() |
|
440 | - ); |
|
441 | - if (! $success) { |
|
442 | - EE_Error::add_error( |
|
443 | - sprintf( |
|
444 | - esc_html__( |
|
445 | - 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
446 | - 'event_espresso' |
|
447 | - ), |
|
448 | - $this->_to, |
|
449 | - $this->_from, |
|
450 | - '<br />' |
|
451 | - ), |
|
452 | - __FILE__, |
|
453 | - __FUNCTION__, |
|
454 | - __LINE__ |
|
455 | - ); |
|
456 | - } |
|
457 | - return $success; |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * see parent for definition |
|
463 | - * |
|
464 | - * @return string html body of the message content and the related css. |
|
465 | - * @throws EE_Error |
|
466 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
467 | - */ |
|
468 | - protected function _preview() |
|
469 | - { |
|
470 | - return $this->_body(true); |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * Setup headers for email |
|
476 | - * |
|
477 | - * @access protected |
|
478 | - * @return string formatted header for email |
|
479 | - */ |
|
480 | - protected function _headers() |
|
481 | - { |
|
482 | - $this->_ensure_has_from_email_address(); |
|
483 | - $from = stripslashes_deep($this->_from, ENT_QUOTES, "UTF-8"); |
|
484 | - $headers = array( |
|
485 | - 'From:' . $from, |
|
486 | - 'Reply-To:' . $from, |
|
487 | - 'Content-Type:text/html; charset=utf-8', |
|
488 | - ); |
|
489 | - |
|
490 | - if (! empty($this->_cc)) { |
|
491 | - $headers[] = 'cc: ' . $this->_cc; |
|
492 | - } |
|
493 | - |
|
494 | - //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
495 | - // header. |
|
496 | - add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
497 | - add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
498 | - return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
504 | - * address for the from address to avoid problems with sending emails. |
|
505 | - */ |
|
506 | - protected function _ensure_has_from_email_address() |
|
507 | - { |
|
508 | - if (empty($this->_from)) { |
|
509 | - $this->_from = get_bloginfo('admin_email'); |
|
510 | - } |
|
511 | - } |
|
512 | - |
|
513 | - |
|
514 | - /** |
|
515 | - * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
516 | - * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
517 | - * be empty |
|
518 | - * |
|
519 | - * @since 4.3.1 |
|
520 | - * @return array |
|
521 | - */ |
|
522 | - private function _parse_from() |
|
523 | - { |
|
524 | - if (strpos($this->_from, '<') !== false) { |
|
525 | - $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
526 | - $from_name = str_replace('"', '', $from_name); |
|
527 | - $from_name = trim($from_name); |
|
528 | - |
|
529 | - $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
530 | - $from_email = str_replace('>', '', $from_email); |
|
531 | - $from_email = trim($from_email); |
|
532 | - } elseif (trim($this->_from) !== '') { |
|
533 | - $from_name = ''; |
|
534 | - $from_email = trim($this->_from); |
|
535 | - } else { |
|
536 | - $from_name = $from_email = ''; |
|
537 | - } |
|
538 | - return array($from_name, $from_email); |
|
539 | - } |
|
540 | - |
|
541 | - |
|
542 | - /** |
|
543 | - * Callback for the wp_mail_from filter. |
|
544 | - * |
|
545 | - * @since 4.3.1 |
|
546 | - * @param string $from_email What the original from_email is. |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function set_from_address($from_email) |
|
550 | - { |
|
551 | - $parsed_from = $this->_parse_from(); |
|
552 | - //includes fallback if the parsing failed. |
|
553 | - $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
554 | - ? $parsed_from[1] |
|
555 | - : get_bloginfo('admin_email'); |
|
556 | - return $from_email; |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * Callback fro the wp_mail_from_name filter. |
|
562 | - * |
|
563 | - * @since 4.3.1 |
|
564 | - * @param string $from_name The original from_name. |
|
565 | - * @return string |
|
566 | - */ |
|
567 | - public function set_from_name($from_name) |
|
568 | - { |
|
569 | - $parsed_from = $this->_parse_from(); |
|
570 | - if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
571 | - $from_name = $parsed_from[0]; |
|
572 | - } |
|
573 | - |
|
574 | - //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
575 | - $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
|
576 | - |
|
577 | - return stripslashes_deep($from_name); |
|
578 | - } |
|
579 | - |
|
580 | - |
|
581 | - /** |
|
582 | - * setup body for email |
|
583 | - * |
|
584 | - * @param bool $preview will determine whether this is preview template or not. |
|
585 | - * @return string formatted body for email. |
|
586 | - * @throws EE_Error |
|
587 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
588 | - */ |
|
589 | - protected function _body($preview = false) |
|
590 | - { |
|
591 | - //setup template args! |
|
592 | - $this->_template_args = array( |
|
593 | - 'subject' => $this->_subject, |
|
594 | - 'from' => $this->_from, |
|
595 | - 'main_body' => wpautop( |
|
596 | - stripslashes_deep( |
|
597 | - $this->_content |
|
598 | - ) |
|
599 | - ), |
|
600 | - ); |
|
601 | - $body = $this->_get_main_template($preview); |
|
602 | - |
|
603 | - /** |
|
604 | - * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
605 | - * |
|
606 | - * @type bool $preview Indicates whether a preview is being generated or not. |
|
607 | - * @return bool true indicates to use the inliner, false bypasses it. |
|
608 | - */ |
|
609 | - if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
610 | - //require CssToInlineStyles library and its dependencies via composer autoloader |
|
611 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
612 | - |
|
613 | - //now if this isn't a preview, let's setup the body so it has inline styles |
|
614 | - if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
615 | - $style = file_get_contents( |
|
616 | - $this->get_variation( |
|
617 | - $this->_tmp_pack, |
|
618 | - $this->_incoming_message_type->name, |
|
619 | - false, |
|
620 | - 'main', |
|
621 | - $this->_variation |
|
622 | - ), |
|
623 | - true |
|
624 | - ); |
|
625 | - $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
626 | - //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
627 | - $body = ltrim($CSS->convert(true), ">\n"); |
|
628 | - //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
629 | - $body = ltrim($body, "<?"); |
|
630 | - } |
|
631 | - |
|
632 | - } |
|
633 | - return $body; |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * This just returns any existing test settings that might be saved in the database |
|
639 | - * |
|
640 | - * @access public |
|
641 | - * @return array |
|
642 | - */ |
|
643 | - public function get_existing_test_settings() |
|
644 | - { |
|
645 | - $settings = parent::get_existing_test_settings(); |
|
646 | - //override subject if present because we always want it to be fresh. |
|
647 | - if (is_array($settings) && ! empty($settings['subject'])) { |
|
648 | - $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
649 | - } |
|
650 | - return $settings; |
|
651 | - } |
|
11 | + /** |
|
12 | + * To field for email |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $_to = ''; |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * CC field for email. |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $_cc = ''; |
|
23 | + |
|
24 | + /** |
|
25 | + * From field for email |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_from = ''; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * Subject field for email |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_subject = ''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * Content field for email |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + protected $_content = ''; |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * constructor |
|
47 | + * |
|
48 | + * @access public |
|
49 | + */ |
|
50 | + public function __construct() |
|
51 | + { |
|
52 | + //set name and description properties |
|
53 | + $this->name = 'email'; |
|
54 | + $this->description = sprintf( |
|
55 | + esc_html__( |
|
56 | + 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + '<code>wp_mail</code>' |
|
60 | + ); |
|
61 | + $this->label = array( |
|
62 | + 'singular' => esc_html__('email', 'event_espresso'), |
|
63 | + 'plural' => esc_html__('emails', 'event_espresso'), |
|
64 | + ); |
|
65 | + $this->activate_on_install = true; |
|
66 | + |
|
67 | + //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
68 | + // properties |
|
69 | + parent::__construct(); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * see abstract declaration in parent class for details. |
|
75 | + */ |
|
76 | + protected function _set_admin_pages() |
|
77 | + { |
|
78 | + $this->admin_registered_pages = array( |
|
79 | + 'events_edit' => true, |
|
80 | + ); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * see abstract declaration in parent class for details |
|
86 | + */ |
|
87 | + protected function _set_valid_shortcodes() |
|
88 | + { |
|
89 | + //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
90 | + // message type. |
|
91 | + $this->_valid_shortcodes = array( |
|
92 | + 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
93 | + 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
94 | + 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * see abstract declaration in parent class for details |
|
101 | + * |
|
102 | + * @access protected |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + protected function _set_validator_config() |
|
106 | + { |
|
107 | + $valid_shortcodes = $this->get_valid_shortcodes(); |
|
108 | + |
|
109 | + $this->_validator_config = array( |
|
110 | + 'to' => array( |
|
111 | + 'shortcodes' => $valid_shortcodes['to'], |
|
112 | + 'type' => 'email', |
|
113 | + ), |
|
114 | + 'cc' => array( |
|
115 | + 'shortcodes' => $valid_shortcodes['to'], |
|
116 | + 'type' => 'email', |
|
117 | + ), |
|
118 | + 'from' => array( |
|
119 | + 'shortcodes' => $valid_shortcodes['from'], |
|
120 | + 'type' => 'email', |
|
121 | + ), |
|
122 | + 'subject' => array( |
|
123 | + 'shortcodes' => array( |
|
124 | + 'organization', |
|
125 | + 'primary_registration_details', |
|
126 | + 'event_author', |
|
127 | + 'primary_registration_details', |
|
128 | + 'recipient_details', |
|
129 | + ), |
|
130 | + ), |
|
131 | + 'content' => array( |
|
132 | + 'shortcodes' => array( |
|
133 | + 'event_list', |
|
134 | + 'attendee_list', |
|
135 | + 'ticket_list', |
|
136 | + 'organization', |
|
137 | + 'primary_registration_details', |
|
138 | + 'primary_registration_list', |
|
139 | + 'event_author', |
|
140 | + 'recipient_details', |
|
141 | + 'recipient_list', |
|
142 | + 'transaction', |
|
143 | + 'messenger', |
|
144 | + ), |
|
145 | + ), |
|
146 | + 'attendee_list' => array( |
|
147 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
148 | + 'required' => array('[ATTENDEE_LIST]'), |
|
149 | + ), |
|
150 | + 'event_list' => array( |
|
151 | + 'shortcodes' => array( |
|
152 | + 'event', |
|
153 | + 'attendee_list', |
|
154 | + 'ticket_list', |
|
155 | + 'venue', |
|
156 | + 'datetime_list', |
|
157 | + 'attendee', |
|
158 | + 'primary_registration_details', |
|
159 | + 'primary_registration_list', |
|
160 | + 'event_author', |
|
161 | + 'recipient_details', |
|
162 | + 'recipient_list', |
|
163 | + ), |
|
164 | + 'required' => array('[EVENT_LIST]'), |
|
165 | + ), |
|
166 | + 'ticket_list' => array( |
|
167 | + 'shortcodes' => array( |
|
168 | + 'event_list', |
|
169 | + 'attendee_list', |
|
170 | + 'ticket', |
|
171 | + 'datetime_list', |
|
172 | + 'primary_registration_details', |
|
173 | + 'recipient_details', |
|
174 | + ), |
|
175 | + 'required' => array('[TICKET_LIST]'), |
|
176 | + ), |
|
177 | + 'datetime_list' => array( |
|
178 | + 'shortcodes' => array('datetime'), |
|
179 | + 'required' => array('[DATETIME_LIST]'), |
|
180 | + ), |
|
181 | + ); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @see parent EE_messenger class for docs |
|
187 | + * @since 4.5.0 |
|
188 | + */ |
|
189 | + public function do_secondary_messenger_hooks($sending_messenger_name) |
|
190 | + { |
|
191 | + if ($sending_messenger_name = 'html') { |
|
192 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + public function add_email_css( |
|
198 | + $variation_path, |
|
199 | + $messenger, |
|
200 | + $message_type, |
|
201 | + $type, |
|
202 | + $variation, |
|
203 | + $file_extension, |
|
204 | + $url, |
|
205 | + EE_Messages_Template_Pack $template_pack |
|
206 | + ) { |
|
207 | + //prevent recursion on this callback. |
|
208 | + remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
209 | + $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
210 | + |
|
211 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
212 | + return $variation; |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * See parent for details |
|
218 | + * |
|
219 | + * @access protected |
|
220 | + * @return void |
|
221 | + */ |
|
222 | + protected function _set_test_settings_fields() |
|
223 | + { |
|
224 | + $this->_test_settings_fields = array( |
|
225 | + 'to' => array( |
|
226 | + 'input' => 'text', |
|
227 | + 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
228 | + 'type' => 'email', |
|
229 | + 'required' => true, |
|
230 | + 'validation' => true, |
|
231 | + 'css_class' => 'large-text', |
|
232 | + 'format' => '%s', |
|
233 | + 'default' => get_bloginfo('admin_email'), |
|
234 | + ), |
|
235 | + 'subject' => array( |
|
236 | + 'input' => 'hidden', |
|
237 | + 'label' => '', |
|
238 | + 'type' => 'string', |
|
239 | + 'required' => false, |
|
240 | + 'validation' => false, |
|
241 | + 'format' => '%s', |
|
242 | + 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
243 | + 'default' => '', |
|
244 | + 'css_class' => '', |
|
245 | + ), |
|
246 | + ); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * _set_template_fields |
|
252 | + * This sets up the fields that a messenger requires for the message to go out. |
|
253 | + * |
|
254 | + * @access protected |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + protected function _set_template_fields() |
|
258 | + { |
|
259 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
260 | + // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
261 | + // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
262 | + // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
263 | + // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
264 | + // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
265 | + // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
266 | + // will not be displayed/parsed. |
|
267 | + $this->_template_fields = array( |
|
268 | + 'to' => array( |
|
269 | + 'input' => 'text', |
|
270 | + 'label' => esc_html_x( |
|
271 | + 'To', |
|
272 | + 'Label for the "To" field for email addresses', |
|
273 | + 'event_espresso' |
|
274 | + ), |
|
275 | + 'type' => 'string', |
|
276 | + 'required' => true, |
|
277 | + 'validation' => true, |
|
278 | + 'css_class' => 'large-text', |
|
279 | + 'format' => '%s', |
|
280 | + ), |
|
281 | + 'cc' => array( |
|
282 | + 'input' => 'text', |
|
283 | + 'label' => esc_html_x( |
|
284 | + 'CC', |
|
285 | + 'Label for the "Carbon Copy" field used for additional email addresses', |
|
286 | + 'event_espresso' |
|
287 | + ), |
|
288 | + 'type' => 'string', |
|
289 | + 'required' => false, |
|
290 | + 'validation' => true, |
|
291 | + 'css_class' => 'large-text', |
|
292 | + 'format' => '%s', |
|
293 | + ), |
|
294 | + 'from' => array( |
|
295 | + 'input' => 'text', |
|
296 | + 'label' => esc_html_x( |
|
297 | + 'From', |
|
298 | + 'Label for the "From" field for email addresses.', |
|
299 | + 'event_espresso' |
|
300 | + ), |
|
301 | + 'type' => 'string', |
|
302 | + 'required' => true, |
|
303 | + 'validation' => true, |
|
304 | + 'css_class' => 'large-text', |
|
305 | + 'format' => '%s', |
|
306 | + ), |
|
307 | + 'subject' => array( |
|
308 | + 'input' => 'text', |
|
309 | + 'label' => esc_html_x( |
|
310 | + 'Subject', |
|
311 | + 'Label for the "Subject" field (short description of contents) for emails.', |
|
312 | + 'event_espresso' |
|
313 | + ), |
|
314 | + 'type' => 'string', |
|
315 | + 'required' => true, |
|
316 | + 'validation' => true, |
|
317 | + 'css_class' => 'large-text', |
|
318 | + 'format' => '%s', |
|
319 | + ), |
|
320 | + 'content' => '', |
|
321 | + //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
322 | + 'extra' => array( |
|
323 | + 'content' => array( |
|
324 | + 'main' => array( |
|
325 | + 'input' => 'wp_editor', |
|
326 | + 'label' => esc_html__('Main Content', 'event_espresso'), |
|
327 | + 'type' => 'string', |
|
328 | + 'required' => true, |
|
329 | + 'validation' => true, |
|
330 | + 'format' => '%s', |
|
331 | + 'rows' => '15', |
|
332 | + ), |
|
333 | + 'event_list' => array( |
|
334 | + 'input' => 'wp_editor', |
|
335 | + 'label' => '[EVENT_LIST]', |
|
336 | + 'type' => 'string', |
|
337 | + 'required' => true, |
|
338 | + 'validation' => true, |
|
339 | + 'format' => '%s', |
|
340 | + 'rows' => '15', |
|
341 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
342 | + ), |
|
343 | + 'attendee_list' => array( |
|
344 | + 'input' => 'textarea', |
|
345 | + 'label' => '[ATTENDEE_LIST]', |
|
346 | + 'type' => 'string', |
|
347 | + 'required' => true, |
|
348 | + 'validation' => true, |
|
349 | + 'format' => '%s', |
|
350 | + 'css_class' => 'large-text', |
|
351 | + 'rows' => '5', |
|
352 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
353 | + ), |
|
354 | + 'ticket_list' => array( |
|
355 | + 'input' => 'textarea', |
|
356 | + 'label' => '[TICKET_LIST]', |
|
357 | + 'type' => 'string', |
|
358 | + 'required' => true, |
|
359 | + 'validation' => true, |
|
360 | + 'format' => '%s', |
|
361 | + 'css_class' => 'large-text', |
|
362 | + 'rows' => '10', |
|
363 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
364 | + ), |
|
365 | + 'datetime_list' => array( |
|
366 | + 'input' => 'textarea', |
|
367 | + 'label' => '[DATETIME_LIST]', |
|
368 | + 'type' => 'string', |
|
369 | + 'required' => true, |
|
370 | + 'validation' => true, |
|
371 | + 'format' => '%s', |
|
372 | + 'css_class' => 'large-text', |
|
373 | + 'rows' => '10', |
|
374 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
375 | + ), |
|
376 | + ), |
|
377 | + ), |
|
378 | + ); |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * See definition of this class in parent |
|
384 | + */ |
|
385 | + protected function _set_default_message_types() |
|
386 | + { |
|
387 | + $this->_default_message_types = array( |
|
388 | + 'payment', |
|
389 | + 'payment_refund', |
|
390 | + 'registration', |
|
391 | + 'not_approved_registration', |
|
392 | + 'pending_approval', |
|
393 | + ); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + /** |
|
398 | + * @see definition of this class in parent |
|
399 | + * @since 4.5.0 |
|
400 | + */ |
|
401 | + protected function _set_valid_message_types() |
|
402 | + { |
|
403 | + $this->_valid_message_types = array( |
|
404 | + 'payment', |
|
405 | + 'registration', |
|
406 | + 'not_approved_registration', |
|
407 | + 'declined_registration', |
|
408 | + 'cancelled_registration', |
|
409 | + 'pending_approval', |
|
410 | + 'registration_summary', |
|
411 | + 'payment_reminder', |
|
412 | + 'payment_declined', |
|
413 | + 'payment_refund', |
|
414 | + ); |
|
415 | + } |
|
416 | + |
|
417 | + |
|
418 | + /** |
|
419 | + * setting up admin_settings_fields for messenger. |
|
420 | + */ |
|
421 | + protected function _set_admin_settings_fields() |
|
422 | + { |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * We just deliver the messages don't kill us!! |
|
427 | + * |
|
428 | + * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
429 | + * present. |
|
430 | + * @throws EE_Error |
|
431 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
432 | + */ |
|
433 | + protected function _send_message() |
|
434 | + { |
|
435 | + $success = wp_mail( |
|
436 | + $this->_to, |
|
437 | + stripslashes($this->_subject), |
|
438 | + $this->_body(), |
|
439 | + $this->_headers() |
|
440 | + ); |
|
441 | + if (! $success) { |
|
442 | + EE_Error::add_error( |
|
443 | + sprintf( |
|
444 | + esc_html__( |
|
445 | + 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
446 | + 'event_espresso' |
|
447 | + ), |
|
448 | + $this->_to, |
|
449 | + $this->_from, |
|
450 | + '<br />' |
|
451 | + ), |
|
452 | + __FILE__, |
|
453 | + __FUNCTION__, |
|
454 | + __LINE__ |
|
455 | + ); |
|
456 | + } |
|
457 | + return $success; |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * see parent for definition |
|
463 | + * |
|
464 | + * @return string html body of the message content and the related css. |
|
465 | + * @throws EE_Error |
|
466 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
467 | + */ |
|
468 | + protected function _preview() |
|
469 | + { |
|
470 | + return $this->_body(true); |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * Setup headers for email |
|
476 | + * |
|
477 | + * @access protected |
|
478 | + * @return string formatted header for email |
|
479 | + */ |
|
480 | + protected function _headers() |
|
481 | + { |
|
482 | + $this->_ensure_has_from_email_address(); |
|
483 | + $from = stripslashes_deep($this->_from, ENT_QUOTES, "UTF-8"); |
|
484 | + $headers = array( |
|
485 | + 'From:' . $from, |
|
486 | + 'Reply-To:' . $from, |
|
487 | + 'Content-Type:text/html; charset=utf-8', |
|
488 | + ); |
|
489 | + |
|
490 | + if (! empty($this->_cc)) { |
|
491 | + $headers[] = 'cc: ' . $this->_cc; |
|
492 | + } |
|
493 | + |
|
494 | + //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
495 | + // header. |
|
496 | + add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
497 | + add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
498 | + return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
504 | + * address for the from address to avoid problems with sending emails. |
|
505 | + */ |
|
506 | + protected function _ensure_has_from_email_address() |
|
507 | + { |
|
508 | + if (empty($this->_from)) { |
|
509 | + $this->_from = get_bloginfo('admin_email'); |
|
510 | + } |
|
511 | + } |
|
512 | + |
|
513 | + |
|
514 | + /** |
|
515 | + * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
516 | + * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
517 | + * be empty |
|
518 | + * |
|
519 | + * @since 4.3.1 |
|
520 | + * @return array |
|
521 | + */ |
|
522 | + private function _parse_from() |
|
523 | + { |
|
524 | + if (strpos($this->_from, '<') !== false) { |
|
525 | + $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
526 | + $from_name = str_replace('"', '', $from_name); |
|
527 | + $from_name = trim($from_name); |
|
528 | + |
|
529 | + $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
530 | + $from_email = str_replace('>', '', $from_email); |
|
531 | + $from_email = trim($from_email); |
|
532 | + } elseif (trim($this->_from) !== '') { |
|
533 | + $from_name = ''; |
|
534 | + $from_email = trim($this->_from); |
|
535 | + } else { |
|
536 | + $from_name = $from_email = ''; |
|
537 | + } |
|
538 | + return array($from_name, $from_email); |
|
539 | + } |
|
540 | + |
|
541 | + |
|
542 | + /** |
|
543 | + * Callback for the wp_mail_from filter. |
|
544 | + * |
|
545 | + * @since 4.3.1 |
|
546 | + * @param string $from_email What the original from_email is. |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function set_from_address($from_email) |
|
550 | + { |
|
551 | + $parsed_from = $this->_parse_from(); |
|
552 | + //includes fallback if the parsing failed. |
|
553 | + $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
554 | + ? $parsed_from[1] |
|
555 | + : get_bloginfo('admin_email'); |
|
556 | + return $from_email; |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * Callback fro the wp_mail_from_name filter. |
|
562 | + * |
|
563 | + * @since 4.3.1 |
|
564 | + * @param string $from_name The original from_name. |
|
565 | + * @return string |
|
566 | + */ |
|
567 | + public function set_from_name($from_name) |
|
568 | + { |
|
569 | + $parsed_from = $this->_parse_from(); |
|
570 | + if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
571 | + $from_name = $parsed_from[0]; |
|
572 | + } |
|
573 | + |
|
574 | + //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
575 | + $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
|
576 | + |
|
577 | + return stripslashes_deep($from_name); |
|
578 | + } |
|
579 | + |
|
580 | + |
|
581 | + /** |
|
582 | + * setup body for email |
|
583 | + * |
|
584 | + * @param bool $preview will determine whether this is preview template or not. |
|
585 | + * @return string formatted body for email. |
|
586 | + * @throws EE_Error |
|
587 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
588 | + */ |
|
589 | + protected function _body($preview = false) |
|
590 | + { |
|
591 | + //setup template args! |
|
592 | + $this->_template_args = array( |
|
593 | + 'subject' => $this->_subject, |
|
594 | + 'from' => $this->_from, |
|
595 | + 'main_body' => wpautop( |
|
596 | + stripslashes_deep( |
|
597 | + $this->_content |
|
598 | + ) |
|
599 | + ), |
|
600 | + ); |
|
601 | + $body = $this->_get_main_template($preview); |
|
602 | + |
|
603 | + /** |
|
604 | + * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
605 | + * |
|
606 | + * @type bool $preview Indicates whether a preview is being generated or not. |
|
607 | + * @return bool true indicates to use the inliner, false bypasses it. |
|
608 | + */ |
|
609 | + if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
610 | + //require CssToInlineStyles library and its dependencies via composer autoloader |
|
611 | + require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
612 | + |
|
613 | + //now if this isn't a preview, let's setup the body so it has inline styles |
|
614 | + if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
615 | + $style = file_get_contents( |
|
616 | + $this->get_variation( |
|
617 | + $this->_tmp_pack, |
|
618 | + $this->_incoming_message_type->name, |
|
619 | + false, |
|
620 | + 'main', |
|
621 | + $this->_variation |
|
622 | + ), |
|
623 | + true |
|
624 | + ); |
|
625 | + $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
626 | + //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
627 | + $body = ltrim($CSS->convert(true), ">\n"); |
|
628 | + //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
629 | + $body = ltrim($body, "<?"); |
|
630 | + } |
|
631 | + |
|
632 | + } |
|
633 | + return $body; |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * This just returns any existing test settings that might be saved in the database |
|
639 | + * |
|
640 | + * @access public |
|
641 | + * @return array |
|
642 | + */ |
|
643 | + public function get_existing_test_settings() |
|
644 | + { |
|
645 | + $settings = parent::get_existing_test_settings(); |
|
646 | + //override subject if present because we always want it to be fresh. |
|
647 | + if (is_array($settings) && ! empty($settings['subject'])) { |
|
648 | + $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
649 | + } |
|
650 | + return $settings; |
|
651 | + } |
|
652 | 652 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ), |
59 | 59 | '<code>wp_mail</code>' |
60 | 60 | ); |
61 | - $this->label = array( |
|
61 | + $this->label = array( |
|
62 | 62 | 'singular' => esc_html__('email', 'event_espresso'), |
63 | 63 | 'plural' => esc_html__('emails', 'event_espresso'), |
64 | 64 | ); |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->_body(), |
439 | 439 | $this->_headers() |
440 | 440 | ); |
441 | - if (! $success) { |
|
441 | + if ( ! $success) { |
|
442 | 442 | EE_Error::add_error( |
443 | 443 | sprintf( |
444 | 444 | esc_html__( |
@@ -482,13 +482,13 @@ discard block |
||
482 | 482 | $this->_ensure_has_from_email_address(); |
483 | 483 | $from = stripslashes_deep($this->_from, ENT_QUOTES, "UTF-8"); |
484 | 484 | $headers = array( |
485 | - 'From:' . $from, |
|
486 | - 'Reply-To:' . $from, |
|
485 | + 'From:'.$from, |
|
486 | + 'Reply-To:'.$from, |
|
487 | 487 | 'Content-Type:text/html; charset=utf-8', |
488 | 488 | ); |
489 | 489 | |
490 | - if (! empty($this->_cc)) { |
|
491 | - $headers[] = 'cc: ' . $this->_cc; |
|
490 | + if ( ! empty($this->_cc)) { |
|
491 | + $headers[] = 'cc: '.$this->_cc; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | ) |
599 | 599 | ), |
600 | 600 | ); |
601 | - $body = $this->_get_main_template($preview); |
|
601 | + $body = $this->_get_main_template($preview); |
|
602 | 602 | |
603 | 603 | /** |
604 | 604 | * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
@@ -608,10 +608,10 @@ discard block |
||
608 | 608 | */ |
609 | 609 | if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
610 | 610 | //require CssToInlineStyles library and its dependencies via composer autoloader |
611 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
611 | + require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php'; |
|
612 | 612 | |
613 | 613 | //now if this isn't a preview, let's setup the body so it has inline styles |
614 | - if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
614 | + if ( ! $preview || ($preview && defined('DOING_AJAX'))) { |
|
615 | 615 | $style = file_get_contents( |
616 | 616 | $this->get_variation( |
617 | 617 | $this->_tmp_pack, |