@@ -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 | * |
@@ -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' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
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(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $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' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"), |
|
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(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $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 = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
|
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 = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
|
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(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8"))), $this->_content) |
273 | 273 | ); |
274 | 274 | $this->_deregister_wp_hooks(); |
@@ -332,11 +332,11 @@ discard block |
||
332 | 332 | $invoice_name = html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8"); |
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 |
@@ -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 | ), |
@@ -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,558 +16,558 @@ 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 | - html_entity_decode( |
|
473 | - apply_filters( |
|
474 | - 'FHEE__EE_Html_messenger___send_message__main_body', |
|
475 | - $this->_content, |
|
476 | - $this->_content, |
|
477 | - $this->_incoming_message_type |
|
478 | - ), |
|
479 | - ENT_QUOTES, |
|
480 | - "UTF-8" |
|
481 | - ) |
|
482 | - ) |
|
483 | - ), |
|
484 | - ); |
|
485 | - $this->_deregister_wp_hooks(); |
|
486 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
487 | - echo $this->_get_main_template(); |
|
488 | - exit(); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't |
|
494 | - * interfere with our templates. If users want to add any custom styles or scripts they must use the |
|
495 | - * AHEE__EE_Html_messenger__enqueue_scripts_styles hook. |
|
496 | - * |
|
497 | - * @since 4.5.0 |
|
498 | - * @return void |
|
499 | - */ |
|
500 | - protected function _deregister_wp_hooks() |
|
501 | - { |
|
502 | - remove_all_actions('wp_head'); |
|
503 | - remove_all_actions('wp_footer'); |
|
504 | - remove_all_actions('wp_print_footer_scripts'); |
|
505 | - remove_all_actions('wp_enqueue_scripts'); |
|
506 | - global $wp_scripts, $wp_styles; |
|
507 | - $wp_scripts = $wp_styles = array(); |
|
508 | - //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
509 | - add_action('wp_footer', 'wp_print_footer_scripts'); |
|
510 | - add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
511 | - add_action('wp_head', 'wp_enqueue_scripts'); |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - /** |
|
516 | - * Overwrite parent _get_main_template for display_html purposes. |
|
517 | - * |
|
518 | - * @since 4.5.0 |
|
519 | - * @param bool $preview |
|
520 | - * @return string |
|
521 | - */ |
|
522 | - protected function _get_main_template($preview = false) |
|
523 | - { |
|
524 | - $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
525 | - //include message type as a template arg |
|
526 | - $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
527 | - return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * @return string |
|
533 | - */ |
|
534 | - protected function _preview() |
|
535 | - { |
|
536 | - return $this->_send_message(); |
|
537 | - } |
|
538 | - |
|
539 | - |
|
540 | - protected function _set_admin_settings_fields() |
|
541 | - { |
|
542 | - } |
|
543 | - |
|
544 | - |
|
545 | - /** |
|
546 | - * add the "powered by EE" credit link to the HTML receipt and invoice |
|
547 | - * |
|
548 | - * @param string $content |
|
549 | - * @param string $content_again |
|
550 | - * @param \EE_message_type $incoming_message_type |
|
551 | - * @return string |
|
552 | - */ |
|
553 | - public function add_powered_by_credit_link_to_receipt_and_invoice( |
|
554 | - $content = '', |
|
555 | - $content_again = '', |
|
556 | - EE_message_type $incoming_message_type |
|
557 | - ) |
|
558 | - { |
|
559 | - if ( |
|
560 | - ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
561 | - && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
562 | - ) { |
|
563 | - $content .= \EEH_Template::powered_by_event_espresso( |
|
564 | - 'aln-cntr', |
|
565 | - '', |
|
566 | - array('utm_content' => 'messages_system') |
|
567 | - ) |
|
568 | - . EEH_HTML::div(EEH_HTML::p(' ')); |
|
569 | - } |
|
570 | - return $content; |
|
571 | - } |
|
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 | + html_entity_decode( |
|
473 | + apply_filters( |
|
474 | + 'FHEE__EE_Html_messenger___send_message__main_body', |
|
475 | + $this->_content, |
|
476 | + $this->_content, |
|
477 | + $this->_incoming_message_type |
|
478 | + ), |
|
479 | + ENT_QUOTES, |
|
480 | + "UTF-8" |
|
481 | + ) |
|
482 | + ) |
|
483 | + ), |
|
484 | + ); |
|
485 | + $this->_deregister_wp_hooks(); |
|
486 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
487 | + echo $this->_get_main_template(); |
|
488 | + exit(); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't |
|
494 | + * interfere with our templates. If users want to add any custom styles or scripts they must use the |
|
495 | + * AHEE__EE_Html_messenger__enqueue_scripts_styles hook. |
|
496 | + * |
|
497 | + * @since 4.5.0 |
|
498 | + * @return void |
|
499 | + */ |
|
500 | + protected function _deregister_wp_hooks() |
|
501 | + { |
|
502 | + remove_all_actions('wp_head'); |
|
503 | + remove_all_actions('wp_footer'); |
|
504 | + remove_all_actions('wp_print_footer_scripts'); |
|
505 | + remove_all_actions('wp_enqueue_scripts'); |
|
506 | + global $wp_scripts, $wp_styles; |
|
507 | + $wp_scripts = $wp_styles = array(); |
|
508 | + //just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load. |
|
509 | + add_action('wp_footer', 'wp_print_footer_scripts'); |
|
510 | + add_action('wp_print_footer_scripts', '_wp_footer_scripts'); |
|
511 | + add_action('wp_head', 'wp_enqueue_scripts'); |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + /** |
|
516 | + * Overwrite parent _get_main_template for display_html purposes. |
|
517 | + * |
|
518 | + * @since 4.5.0 |
|
519 | + * @param bool $preview |
|
520 | + * @return string |
|
521 | + */ |
|
522 | + protected function _get_main_template($preview = false) |
|
523 | + { |
|
524 | + $wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main'); |
|
525 | + //include message type as a template arg |
|
526 | + $this->_template_args['message_type'] = $this->_incoming_message_type; |
|
527 | + return EEH_Template::display_template($wrapper_template, $this->_template_args, true); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * @return string |
|
533 | + */ |
|
534 | + protected function _preview() |
|
535 | + { |
|
536 | + return $this->_send_message(); |
|
537 | + } |
|
538 | + |
|
539 | + |
|
540 | + protected function _set_admin_settings_fields() |
|
541 | + { |
|
542 | + } |
|
543 | + |
|
544 | + |
|
545 | + /** |
|
546 | + * add the "powered by EE" credit link to the HTML receipt and invoice |
|
547 | + * |
|
548 | + * @param string $content |
|
549 | + * @param string $content_again |
|
550 | + * @param \EE_message_type $incoming_message_type |
|
551 | + * @return string |
|
552 | + */ |
|
553 | + public function add_powered_by_credit_link_to_receipt_and_invoice( |
|
554 | + $content = '', |
|
555 | + $content_again = '', |
|
556 | + EE_message_type $incoming_message_type |
|
557 | + ) |
|
558 | + { |
|
559 | + if ( |
|
560 | + ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt') |
|
561 | + && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true) |
|
562 | + ) { |
|
563 | + $content .= \EEH_Template::powered_by_event_espresso( |
|
564 | + 'aln-cntr', |
|
565 | + '', |
|
566 | + array('utm_content' => 'messages_system') |
|
567 | + ) |
|
568 | + . EEH_HTML::div(EEH_HTML::p(' ')); |
|
569 | + } |
|
570 | + return $content; |
|
571 | + } |
|
572 | 572 | |
573 | 573 | } |
@@ -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.001'); |
|
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.001'); |
|
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 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | use RuntimeException; |
15 | 15 | |
16 | 16 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
17 | - exit('No direct script access allowed'); |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | |
@@ -32,155 +32,155 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @param EE_Registration $target_registration |
|
37 | - * @param EE_Registration $registration_to_copy |
|
38 | - * @return bool |
|
39 | - * @throws UnexpectedEntityException |
|
40 | - * @throws EntityNotFoundException |
|
41 | - * @throws RuntimeException |
|
42 | - * @throws EE_Error |
|
43 | - */ |
|
44 | - public function copyRegistrationDetails( |
|
45 | - EE_Registration $target_registration, |
|
46 | - EE_Registration $registration_to_copy |
|
47 | - ) { |
|
48 | - // copy attendee |
|
49 | - $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
50 | - $target_registration->updateStatusBasedOnTotalPaid(false); |
|
51 | - $target_registration->save(); |
|
52 | - // get answers to previous reg questions |
|
53 | - $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
54 | - // get questions to new event reg form |
|
55 | - $new_event = $target_registration->event(); |
|
56 | - $question_groups = $new_event->question_groups( |
|
57 | - array( |
|
58 | - array( |
|
59 | - 'Event.EVT_ID' => $new_event->ID(), |
|
60 | - 'Event_Question_Group.EQG_primary' => $registration_to_copy->is_primary_registrant(), |
|
61 | - ), |
|
62 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
63 | - ) |
|
64 | - ); |
|
65 | - foreach ($question_groups as $question_group) { |
|
66 | - if ($question_group instanceof \EE_Question_Group) { |
|
67 | - foreach ($question_group->questions() as $question) { |
|
68 | - if ($question instanceof EE_Question) { |
|
69 | - $this->generateNewAnswer( |
|
70 | - $question, |
|
71 | - $target_registration, |
|
72 | - $answers |
|
73 | - ); |
|
74 | - } |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - return true; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @param EE_Answer[] $answers |
|
85 | - * @return array |
|
86 | - * @throws EE_Error |
|
87 | - */ |
|
88 | - protected function reindexAnswersByQuestionId(array $answers) |
|
89 | - { |
|
90 | - $reindexed_answers = array(); |
|
91 | - foreach ($answers as $answer) { |
|
92 | - if ($answer instanceof EE_Answer) { |
|
93 | - $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
94 | - } |
|
95 | - } |
|
96 | - return $reindexed_answers; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @param EE_Question $question |
|
103 | - * @param EE_Registration $registration |
|
104 | - * @param $previous_answers |
|
105 | - * @return EE_Answer |
|
106 | - * @throws UnexpectedEntityException |
|
107 | - * @throws EE_Error |
|
108 | - */ |
|
109 | - protected function generateNewAnswer( |
|
110 | - EE_Question $question, |
|
111 | - EE_Registration $registration, |
|
112 | - $previous_answers |
|
113 | - ) { |
|
114 | - $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
115 | - ? $previous_answers[ $question->ID() ] |
|
116 | - : ''; |
|
117 | - $new_answer = EE_Answer::new_instance( |
|
118 | - array( |
|
119 | - 'QST_ID' => $question->ID(), |
|
120 | - 'REG_ID' => $registration->ID(), |
|
121 | - 'ANS_value' => $old_answer_value, |
|
122 | - ) |
|
123 | - ); |
|
124 | - if ( ! $new_answer instanceof EE_Answer) { |
|
125 | - throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
126 | - } |
|
127 | - $new_answer->save(); |
|
128 | - return $new_answer; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @param EE_Registration $target_registration |
|
135 | - * @param EE_Registration $registration_to_copy |
|
136 | - * @return bool |
|
137 | - * @throws RuntimeException |
|
138 | - * @throws UnexpectedEntityException |
|
139 | - * @throws EE_Error |
|
140 | - */ |
|
141 | - public function copyPaymentDetails( |
|
142 | - EE_Registration $target_registration, |
|
143 | - EE_Registration $registration_to_copy |
|
144 | - ) { |
|
145 | - $save = false; |
|
146 | - $previous_registration_payments = $registration_to_copy->registration_payments(); |
|
147 | - $new_registration_payment_total = 0; |
|
148 | - $registration_to_copy_total = $registration_to_copy->paid(); |
|
149 | - foreach ($previous_registration_payments as $previous_registration_payment) { |
|
150 | - if ( |
|
151 | - $previous_registration_payment instanceof EE_Registration_Payment |
|
152 | - && $previous_registration_payment->payment() instanceof EE_Payment |
|
153 | - && $previous_registration_payment->payment()->is_approved() |
|
154 | - ) { |
|
155 | - $payment_amount = $previous_registration_payment->amount(); |
|
156 | - $new_registration_payment = EE_Registration_Payment::new_instance( |
|
157 | - array( |
|
158 | - 'REG_ID' => $target_registration->ID(), |
|
159 | - 'PAY_ID' => $previous_registration_payment->payment()->ID(), |
|
160 | - 'RPY_amount' => $payment_amount, |
|
161 | - ) |
|
162 | - ); |
|
163 | - if ( ! $new_registration_payment instanceof EE_Registration_Payment) { |
|
164 | - throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
165 | - } |
|
166 | - $new_registration_payment->save(); |
|
167 | - // if new reg payment is good, then set old reg payment amount to zero |
|
168 | - $previous_registration_payment->set_amount(0); |
|
169 | - $previous_registration_payment->save(); |
|
170 | - // now increment/decrement payment amounts |
|
171 | - $new_registration_payment_total += $payment_amount; |
|
172 | - $registration_to_copy_total -= $payment_amount; |
|
173 | - $save = true; |
|
174 | - } |
|
175 | - } |
|
176 | - if($save){ |
|
177 | - $target_registration->set_paid($new_registration_payment_total); |
|
178 | - $target_registration->save(); |
|
179 | - $registration_to_copy->set_paid($registration_to_copy_total); |
|
180 | - $registration_to_copy->save(); |
|
181 | - } |
|
182 | - return true; |
|
183 | - } |
|
35 | + /** |
|
36 | + * @param EE_Registration $target_registration |
|
37 | + * @param EE_Registration $registration_to_copy |
|
38 | + * @return bool |
|
39 | + * @throws UnexpectedEntityException |
|
40 | + * @throws EntityNotFoundException |
|
41 | + * @throws RuntimeException |
|
42 | + * @throws EE_Error |
|
43 | + */ |
|
44 | + public function copyRegistrationDetails( |
|
45 | + EE_Registration $target_registration, |
|
46 | + EE_Registration $registration_to_copy |
|
47 | + ) { |
|
48 | + // copy attendee |
|
49 | + $target_registration->set_attendee_id($registration_to_copy->attendee_ID()); |
|
50 | + $target_registration->updateStatusBasedOnTotalPaid(false); |
|
51 | + $target_registration->save(); |
|
52 | + // get answers to previous reg questions |
|
53 | + $answers = $this->reindexAnswersByQuestionId($registration_to_copy->answers()); |
|
54 | + // get questions to new event reg form |
|
55 | + $new_event = $target_registration->event(); |
|
56 | + $question_groups = $new_event->question_groups( |
|
57 | + array( |
|
58 | + array( |
|
59 | + 'Event.EVT_ID' => $new_event->ID(), |
|
60 | + 'Event_Question_Group.EQG_primary' => $registration_to_copy->is_primary_registrant(), |
|
61 | + ), |
|
62 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
63 | + ) |
|
64 | + ); |
|
65 | + foreach ($question_groups as $question_group) { |
|
66 | + if ($question_group instanceof \EE_Question_Group) { |
|
67 | + foreach ($question_group->questions() as $question) { |
|
68 | + if ($question instanceof EE_Question) { |
|
69 | + $this->generateNewAnswer( |
|
70 | + $question, |
|
71 | + $target_registration, |
|
72 | + $answers |
|
73 | + ); |
|
74 | + } |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + return true; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @param EE_Answer[] $answers |
|
85 | + * @return array |
|
86 | + * @throws EE_Error |
|
87 | + */ |
|
88 | + protected function reindexAnswersByQuestionId(array $answers) |
|
89 | + { |
|
90 | + $reindexed_answers = array(); |
|
91 | + foreach ($answers as $answer) { |
|
92 | + if ($answer instanceof EE_Answer) { |
|
93 | + $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
94 | + } |
|
95 | + } |
|
96 | + return $reindexed_answers; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @param EE_Question $question |
|
103 | + * @param EE_Registration $registration |
|
104 | + * @param $previous_answers |
|
105 | + * @return EE_Answer |
|
106 | + * @throws UnexpectedEntityException |
|
107 | + * @throws EE_Error |
|
108 | + */ |
|
109 | + protected function generateNewAnswer( |
|
110 | + EE_Question $question, |
|
111 | + EE_Registration $registration, |
|
112 | + $previous_answers |
|
113 | + ) { |
|
114 | + $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
115 | + ? $previous_answers[ $question->ID() ] |
|
116 | + : ''; |
|
117 | + $new_answer = EE_Answer::new_instance( |
|
118 | + array( |
|
119 | + 'QST_ID' => $question->ID(), |
|
120 | + 'REG_ID' => $registration->ID(), |
|
121 | + 'ANS_value' => $old_answer_value, |
|
122 | + ) |
|
123 | + ); |
|
124 | + if ( ! $new_answer instanceof EE_Answer) { |
|
125 | + throw new UnexpectedEntityException($new_answer, 'EE_Answer'); |
|
126 | + } |
|
127 | + $new_answer->save(); |
|
128 | + return $new_answer; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @param EE_Registration $target_registration |
|
135 | + * @param EE_Registration $registration_to_copy |
|
136 | + * @return bool |
|
137 | + * @throws RuntimeException |
|
138 | + * @throws UnexpectedEntityException |
|
139 | + * @throws EE_Error |
|
140 | + */ |
|
141 | + public function copyPaymentDetails( |
|
142 | + EE_Registration $target_registration, |
|
143 | + EE_Registration $registration_to_copy |
|
144 | + ) { |
|
145 | + $save = false; |
|
146 | + $previous_registration_payments = $registration_to_copy->registration_payments(); |
|
147 | + $new_registration_payment_total = 0; |
|
148 | + $registration_to_copy_total = $registration_to_copy->paid(); |
|
149 | + foreach ($previous_registration_payments as $previous_registration_payment) { |
|
150 | + if ( |
|
151 | + $previous_registration_payment instanceof EE_Registration_Payment |
|
152 | + && $previous_registration_payment->payment() instanceof EE_Payment |
|
153 | + && $previous_registration_payment->payment()->is_approved() |
|
154 | + ) { |
|
155 | + $payment_amount = $previous_registration_payment->amount(); |
|
156 | + $new_registration_payment = EE_Registration_Payment::new_instance( |
|
157 | + array( |
|
158 | + 'REG_ID' => $target_registration->ID(), |
|
159 | + 'PAY_ID' => $previous_registration_payment->payment()->ID(), |
|
160 | + 'RPY_amount' => $payment_amount, |
|
161 | + ) |
|
162 | + ); |
|
163 | + if ( ! $new_registration_payment instanceof EE_Registration_Payment) { |
|
164 | + throw new UnexpectedEntityException($new_registration_payment, 'EE_Registration_Payment'); |
|
165 | + } |
|
166 | + $new_registration_payment->save(); |
|
167 | + // if new reg payment is good, then set old reg payment amount to zero |
|
168 | + $previous_registration_payment->set_amount(0); |
|
169 | + $previous_registration_payment->save(); |
|
170 | + // now increment/decrement payment amounts |
|
171 | + $new_registration_payment_total += $payment_amount; |
|
172 | + $registration_to_copy_total -= $payment_amount; |
|
173 | + $save = true; |
|
174 | + } |
|
175 | + } |
|
176 | + if($save){ |
|
177 | + $target_registration->set_paid($new_registration_payment_total); |
|
178 | + $target_registration->save(); |
|
179 | + $registration_to_copy->set_paid($registration_to_copy_total); |
|
180 | + $registration_to_copy->save(); |
|
181 | + } |
|
182 | + return true; |
|
183 | + } |
|
184 | 184 | |
185 | 185 | |
186 | 186 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $reindexed_answers = array(); |
91 | 91 | foreach ($answers as $answer) { |
92 | 92 | if ($answer instanceof EE_Answer) { |
93 | - $reindexed_answers[ $answer->question_ID() ] = $answer->value(); |
|
93 | + $reindexed_answers[$answer->question_ID()] = $answer->value(); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | return $reindexed_answers; |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | EE_Registration $registration, |
112 | 112 | $previous_answers |
113 | 113 | ) { |
114 | - $old_answer_value = isset($previous_answers[ $question->ID() ]) |
|
115 | - ? $previous_answers[ $question->ID() ] |
|
114 | + $old_answer_value = isset($previous_answers[$question->ID()]) |
|
115 | + ? $previous_answers[$question->ID()] |
|
116 | 116 | : ''; |
117 | 117 | $new_answer = EE_Answer::new_instance( |
118 | 118 | array( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $save = true; |
174 | 174 | } |
175 | 175 | } |
176 | - if($save){ |
|
176 | + if ($save) { |
|
177 | 177 | $target_registration->set_paid($new_registration_payment_total); |
178 | 178 | $target_registration->save(); |
179 | 179 | $registration_to_copy->set_paid($registration_to_copy_total); |