Completed
Branch Gutenberg/master (728124)
by
unknown
65:27 queued 56:02
created
core/libraries/messages/messenger/EE_Pdf_messenger.class.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260 260
             'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261 261
             'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
262
+            'extra_css' => EE_LIBRARIES_URL.'messages/defaults/default/variations/pdf_base_default.css',
263 263
             'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264 264
         );
265 265
         $this->_deregister_wp_hooks();
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
         $invoice_name = $this->_subject;
324 324
 
325 325
         // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
326
+        if ( ! class_exists('Dompdf\Dompdf')) {
327
+            require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
328 328
             Dompdf\Autoloader::register();
329 329
         }
330 330
         $options = new Dompdf\Options();
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         $dompdf->loadHtml($content);
337 337
         $dompdf->render();
338 338
         // forcing the browser to open a download dialog.
339
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
339
+        $dompdf->stream($invoice_name.".pdf", array('Attachment' => true));
340 340
     }
341 341
 
342 342
 
Please login to merge, or discard this patch.
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -15,345 +15,345 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * The following are the properties that this messenger requires for generating pdf
20
-     */
21
-
22
-    /**
23
-     * This is the pdf 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.  This will end up being the filename for the generated pdf.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $_subject;
36
-
37
-
38
-    /**
39
-     * @return EE_Pdf_messenger
40
-     */
41
-    public function __construct()
42
-    {
43
-        // set properties
44
-        $this->name = 'pdf';
45
-        $this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
-        $this->label = array(
47
-            'singular' => __('PDF', 'event_espresso'),
48
-            'plural' => __('PDFs', 'event_espresso')
49
-        );
50
-        $this->activate_on_install = true;
51
-
52
-        parent::__construct();
53
-    }
54
-
55
-
56
-    /**
57
-     * PDF Messenger desires execution immediately.
58
-     * @see  parent::send_now() for documentation.
59
-     * @since  4.9.0
60
-     * @return bool
61
-     */
62
-    public function send_now()
63
-    {
64
-        return true;
65
-    }
66
-
67
-
68
-    /**
69
-     * HTML Messenger allows an empty to field.
70
-     * @see parent::allow_empty_to_field() for documentation
71
-     * @since  4.9.0
72
-     * @return bool
73
-     */
74
-    public function allow_empty_to_field()
75
-    {
76
-        return true;
77
-    }
78
-
79
-
80
-    /**
81
-     * @see abstract declaration in EE_messenger for details.
82
-     */
83
-    protected function _set_admin_pages()
84
-    {
85
-        $this->admin_registered_pages = array('events_edit' => false);
86
-    }
87
-
88
-
89
-    /**
90
-     * @see abstract declaration in EE_messenger for details.
91
-     */
92
-    protected function _set_valid_shortcodes()
93
-    {
94
-        $this->_valid_shortcodes = array();
95
-    }
96
-
97
-
98
-    /**
99
-     * @see abstract declaration in EE_messenger for details.
100
-     */
101
-    protected function _set_validator_config()
102
-    {
103
-        $this->_validator_config = array(
104
-            'subject' => array(
105
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
-            ),
107
-            'content' => array(
108
-                'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
-            ),
110
-            'attendee_list' => array(
111
-                'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
-                'required' => array('[ATTENDEE_LIST]')
113
-            ),
114
-            'event_list' => array(
115
-                'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
-                'required' => array('[EVENT_LIST]')
117
-            ),
118
-            'ticket_list' => array(
119
-                'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
-                'required' => array('[TICKET_LIST]')
121
-            ),
122
-            'datetime_list' => array(
123
-                'shortcodes' => array('datetime'),
124
-                'required' => array('[DATETIME_LIST]')
125
-            ),
126
-        );
127
-    }
128
-
129
-
130
-    /**
131
-     * 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.
132
-     *
133
-     * @return void.
134
-     */
135
-    public function enqueue_scripts_styles()
136
-    {
137
-        parent::enqueue_scripts_styles();
138
-        do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
-    }
140
-
141
-
142
-    /**
143
-     * _set_template_fields
144
-     * This sets up the fields that a messenger requires for the message to go out.
145
-     *
146
-     * @access  protected
147
-     * @return void
148
-     */
149
-    protected function _set_template_fields()
150
-    {
151
-        // 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.
152
-        $this->_template_fields = array(
153
-            'subject' => array(
154
-                'input' => 'text',
155
-                'label' => __('Page Title', 'event_espresso'),
156
-                'type' => 'string',
157
-                'required' => true,
158
-                'validation' => true,
159
-                'css_class' => 'large-text',
160
-                'format' => '%s'
161
-            ),
162
-            'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
-            'extra' => array(
164
-                'content' => array(
165
-                    'main' => array(
166
-                        'input' => 'wp_editor',
167
-                        'label' => __('Main Content', 'event_espresso'),
168
-                        'type' => 'string',
169
-                        'required' => true,
170
-                        'validation' => true,
171
-                        'format' => '%s',
172
-                        'rows' => '15'
173
-                    ),
174
-                    'event_list' => array(
175
-                        'input' => 'wp_editor',
176
-                        'label' => '[EVENT_LIST]',
177
-                        'type' => 'string',
178
-                        'required' => true,
179
-                        'validation' => true,
180
-                        'format' => '%s',
181
-                        'rows' => '15',
182
-                        'shortcodes_required' => array('[EVENT_LIST]')
183
-                    ),
184
-                    'attendee_list' => array(
185
-                        'input' => 'textarea',
186
-                        'label' => '[ATTENDEE_LIST]',
187
-                        'type' => 'string',
188
-                        'required' => true,
189
-                        'validation' => true,
190
-                        'format' => '%s',
191
-                        'css_class' => 'large-text',
192
-                        'rows' => '5',
193
-                        'shortcodes_required' => array('[ATTENDEE_LIST]')
194
-                    ),
195
-                    'ticket_list' => array(
196
-                        'input' => 'textarea',
197
-                        'label' => '[TICKET_LIST]',
198
-                        'type' => 'string',
199
-                        'required' => true,
200
-                        'validation' => true,
201
-                        'format' => '%s',
202
-                        'css_class' => 'large-text',
203
-                        'rows' => '10',
204
-                        'shortcodes_required' => array('[TICKET_LIST]')
205
-                    ),
206
-                    'datetime_list' => array(
207
-                        'input' => 'textarea',
208
-                        'label' => '[DATETIME_LIST]',
209
-                        'type' => 'string',
210
-                        'required' => true,
211
-                        'validation' => true,
212
-                        'format' => '%s',
213
-                        'css_class' => 'large-text',
214
-                        'rows' => '10',
215
-                        'shortcodes_required' => array('[DATETIME_LIST]')
216
-                    )
217
-                )
218
-            )
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     * @see definition of this method in parent
225
-     *
226
-     * @since 4.5.0
227
-     *
228
-     */
229
-    protected function _set_default_message_types()
230
-    {
231
-        // note currently PDF is only a secondary messenger so it never has any associated message types.
232
-        $this->_default_message_types = array();
233
-    }
234
-
235
-
236
-    /**
237
-     * @see definition of this method in parent
238
-     *
239
-     * @since 4.5.0
240
-     */
241
-    protected function _set_valid_message_types()
242
-    {
243
-        $this->_valid_message_types = array();
244
-    }
245
-
246
-
247
-    /**
248
-     * Generates html version of the message content and then sends it to the pdf generator.
249
-     *
250
-     *
251
-     * @since 4.5.0
252
-     *
253
-     * @return string.
254
-     */
255
-    protected function _send_message()
256
-    {
257
-        $this->_template_args = array(
258
-            'page_title' => $this->_subject,
259
-            'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
-            'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
-            'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
-            'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
-            'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
-        );
265
-        $this->_deregister_wp_hooks();
266
-        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
-        $content = $this->_get_main_template();
18
+	/**
19
+	 * The following are the properties that this messenger requires for generating pdf
20
+	 */
21
+
22
+	/**
23
+	 * This is the pdf 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.  This will end up being the filename for the generated pdf.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $_subject;
36
+
37
+
38
+	/**
39
+	 * @return EE_Pdf_messenger
40
+	 */
41
+	public function __construct()
42
+	{
43
+		// set properties
44
+		$this->name = 'pdf';
45
+		$this->description = __('This messenger is used for generating a pdf version of the message.', 'event_espresso');
46
+		$this->label = array(
47
+			'singular' => __('PDF', 'event_espresso'),
48
+			'plural' => __('PDFs', 'event_espresso')
49
+		);
50
+		$this->activate_on_install = true;
51
+
52
+		parent::__construct();
53
+	}
54
+
55
+
56
+	/**
57
+	 * PDF Messenger desires execution immediately.
58
+	 * @see  parent::send_now() for documentation.
59
+	 * @since  4.9.0
60
+	 * @return bool
61
+	 */
62
+	public function send_now()
63
+	{
64
+		return true;
65
+	}
66
+
67
+
68
+	/**
69
+	 * HTML Messenger allows an empty to field.
70
+	 * @see parent::allow_empty_to_field() for documentation
71
+	 * @since  4.9.0
72
+	 * @return bool
73
+	 */
74
+	public function allow_empty_to_field()
75
+	{
76
+		return true;
77
+	}
78
+
79
+
80
+	/**
81
+	 * @see abstract declaration in EE_messenger for details.
82
+	 */
83
+	protected function _set_admin_pages()
84
+	{
85
+		$this->admin_registered_pages = array('events_edit' => false);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @see abstract declaration in EE_messenger for details.
91
+	 */
92
+	protected function _set_valid_shortcodes()
93
+	{
94
+		$this->_valid_shortcodes = array();
95
+	}
96
+
97
+
98
+	/**
99
+	 * @see abstract declaration in EE_messenger for details.
100
+	 */
101
+	protected function _set_validator_config()
102
+	{
103
+		$this->_validator_config = array(
104
+			'subject' => array(
105
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
106
+			),
107
+			'content' => array(
108
+				'shortcodes' => array('recipient_details', 'organization', 'event', 'ticket', 'venue', 'primary_registration_details', 'event_author', 'email', 'event_meta', 'recipient_list', 'transaction', 'datetime_list', 'datetime')
109
+			),
110
+			'attendee_list' => array(
111
+				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
112
+				'required' => array('[ATTENDEE_LIST]')
113
+			),
114
+			'event_list' => array(
115
+				'shortcodes' => array('event', 'attendee_list', 'ticket_list', 'venue', 'datetime_list', 'attendee', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list'),
116
+				'required' => array('[EVENT_LIST]')
117
+			),
118
+			'ticket_list' => array(
119
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
120
+				'required' => array('[TICKET_LIST]')
121
+			),
122
+			'datetime_list' => array(
123
+				'shortcodes' => array('datetime'),
124
+				'required' => array('[DATETIME_LIST]')
125
+			),
126
+		);
127
+	}
128
+
129
+
130
+	/**
131
+	 * 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.
132
+	 *
133
+	 * @return void.
134
+	 */
135
+	public function enqueue_scripts_styles()
136
+	{
137
+		parent::enqueue_scripts_styles();
138
+		do_action('AHEE__EE_Pdf_messenger__enqueue_scripts_styles');
139
+	}
140
+
141
+
142
+	/**
143
+	 * _set_template_fields
144
+	 * This sets up the fields that a messenger requires for the message to go out.
145
+	 *
146
+	 * @access  protected
147
+	 * @return void
148
+	 */
149
+	protected function _set_template_fields()
150
+	{
151
+		// 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.
152
+		$this->_template_fields = array(
153
+			'subject' => array(
154
+				'input' => 'text',
155
+				'label' => __('Page Title', 'event_espresso'),
156
+				'type' => 'string',
157
+				'required' => true,
158
+				'validation' => true,
159
+				'css_class' => 'large-text',
160
+				'format' => '%s'
161
+			),
162
+			'content' => '', // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
163
+			'extra' => array(
164
+				'content' => array(
165
+					'main' => array(
166
+						'input' => 'wp_editor',
167
+						'label' => __('Main Content', 'event_espresso'),
168
+						'type' => 'string',
169
+						'required' => true,
170
+						'validation' => true,
171
+						'format' => '%s',
172
+						'rows' => '15'
173
+					),
174
+					'event_list' => array(
175
+						'input' => 'wp_editor',
176
+						'label' => '[EVENT_LIST]',
177
+						'type' => 'string',
178
+						'required' => true,
179
+						'validation' => true,
180
+						'format' => '%s',
181
+						'rows' => '15',
182
+						'shortcodes_required' => array('[EVENT_LIST]')
183
+					),
184
+					'attendee_list' => array(
185
+						'input' => 'textarea',
186
+						'label' => '[ATTENDEE_LIST]',
187
+						'type' => 'string',
188
+						'required' => true,
189
+						'validation' => true,
190
+						'format' => '%s',
191
+						'css_class' => 'large-text',
192
+						'rows' => '5',
193
+						'shortcodes_required' => array('[ATTENDEE_LIST]')
194
+					),
195
+					'ticket_list' => array(
196
+						'input' => 'textarea',
197
+						'label' => '[TICKET_LIST]',
198
+						'type' => 'string',
199
+						'required' => true,
200
+						'validation' => true,
201
+						'format' => '%s',
202
+						'css_class' => 'large-text',
203
+						'rows' => '10',
204
+						'shortcodes_required' => array('[TICKET_LIST]')
205
+					),
206
+					'datetime_list' => array(
207
+						'input' => 'textarea',
208
+						'label' => '[DATETIME_LIST]',
209
+						'type' => 'string',
210
+						'required' => true,
211
+						'validation' => true,
212
+						'format' => '%s',
213
+						'css_class' => 'large-text',
214
+						'rows' => '10',
215
+						'shortcodes_required' => array('[DATETIME_LIST]')
216
+					)
217
+				)
218
+			)
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 * @see definition of this method in parent
225
+	 *
226
+	 * @since 4.5.0
227
+	 *
228
+	 */
229
+	protected function _set_default_message_types()
230
+	{
231
+		// note currently PDF is only a secondary messenger so it never has any associated message types.
232
+		$this->_default_message_types = array();
233
+	}
234
+
235
+
236
+	/**
237
+	 * @see definition of this method in parent
238
+	 *
239
+	 * @since 4.5.0
240
+	 */
241
+	protected function _set_valid_message_types()
242
+	{
243
+		$this->_valid_message_types = array();
244
+	}
245
+
246
+
247
+	/**
248
+	 * Generates html version of the message content and then sends it to the pdf generator.
249
+	 *
250
+	 *
251
+	 * @since 4.5.0
252
+	 *
253
+	 * @return string.
254
+	 */
255
+	protected function _send_message()
256
+	{
257
+		$this->_template_args = array(
258
+			'page_title' => $this->_subject,
259
+			'base_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'base', $this->_variation),
260
+			'print_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'print', $this->_variation),
261
+			'main_css' => $this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, true, 'main', $this->_variation),
262
+			'extra_css' => EE_LIBRARIES_URL . 'messages/defaults/default/variations/pdf_base_default.css',
263
+			'main_body' => apply_filters('FHEE__EE_Pdf_messenger___send_message__main_body', wpautop($this->_content), $this->_content)
264
+		);
265
+		$this->_deregister_wp_hooks();
266
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
267
+		$content = $this->_get_main_template();
268 268
 //      die( $content );
269
-        $this->_do_pdf($content);
270
-        exit(0);
271
-    }
272
-
273
-
274
-    /**
275
-     * 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.
276
-     *
277
-     * @since 4.5.0
278
-     *
279
-     * @return void
280
-     */
281
-    protected function _deregister_wp_hooks()
282
-    {
283
-        remove_all_actions('wp_head');
284
-        remove_all_actions('wp_footer');
285
-        remove_all_actions('wp_print_footer_scripts');
286
-        remove_all_actions('wp_enqueue_scripts');
287
-        global $wp_scripts, $wp_styles;
288
-        $wp_scripts = $wp_styles = array();
289
-
290
-        // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
-        add_action('wp_head', 'wp_enqueue_scripts');
292
-        add_action('wp_footer', 'wp_print_footer_scripts');
293
-        add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
-    }
295
-
296
-
297
-    /**
298
-     * Overwrite parent _get_main_template for pdf purposes.
299
-     *
300
-     * @since  4.5.0
301
-     *
302
-     * @param bool $preview
303
-     * @return string
304
-     */
305
-    protected function _get_main_template($preview = false)
306
-    {
307
-        $wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
-        // add message type to template_args
309
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
310
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
-    }
312
-
313
-
314
-    /**
315
-     * This takes care of loading the dompdf library and generating the actual pdf
316
-     *
317
-     * @param string $content This is the generated html content being converted into a pdf.
318
-     *
319
-     * @return void
320
-     */
321
-    protected function _do_pdf($content = '')
322
-    {
323
-        $invoice_name = $this->_subject;
324
-
325
-        // only load dompdf if nobody else has yet...
326
-        if (! class_exists('Dompdf\Dompdf')) {
327
-            require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
-            Dompdf\Autoloader::register();
329
-        }
330
-        $options = new Dompdf\Options();
331
-        $options->set('isRemoteEnabled', true);
332
-        $options->set('isJavascriptEnabled', false);
333
-        if (defined('DOMPDF_FONT_DIR')) {
334
-            $options->setFontDir(DOMPDF_FONT_DIR);
335
-            $options->setFontCache(DOMPDF_FONT_DIR);
336
-        }
337
-        $dompdf = new Dompdf\Dompdf($options);
338
-        // Remove all spaces between HTML tags
339
-        $content = preg_replace('/>\s+</', '><', $content);
340
-        $dompdf->loadHtml($content);
341
-        $dompdf->render();
342
-        // forcing the browser to open a download dialog.
343
-        $dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
344
-    }
345
-
346
-
347
-    /**
348
-     * @return string
349
-     */
350
-    protected function _preview()
351
-    {
352
-        return $this->_send_message();
353
-    }
354
-
355
-
356
-    protected function _set_admin_settings_fields()
357
-    {
358
-    }
269
+		$this->_do_pdf($content);
270
+		exit(0);
271
+	}
272
+
273
+
274
+	/**
275
+	 * 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.
276
+	 *
277
+	 * @since 4.5.0
278
+	 *
279
+	 * @return void
280
+	 */
281
+	protected function _deregister_wp_hooks()
282
+	{
283
+		remove_all_actions('wp_head');
284
+		remove_all_actions('wp_footer');
285
+		remove_all_actions('wp_print_footer_scripts');
286
+		remove_all_actions('wp_enqueue_scripts');
287
+		global $wp_scripts, $wp_styles;
288
+		$wp_scripts = $wp_styles = array();
289
+
290
+		// just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
291
+		add_action('wp_head', 'wp_enqueue_scripts');
292
+		add_action('wp_footer', 'wp_print_footer_scripts');
293
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
294
+	}
295
+
296
+
297
+	/**
298
+	 * Overwrite parent _get_main_template for pdf purposes.
299
+	 *
300
+	 * @since  4.5.0
301
+	 *
302
+	 * @param bool $preview
303
+	 * @return string
304
+	 */
305
+	protected function _get_main_template($preview = false)
306
+	{
307
+		$wrapper_template = $this->_tmp_pack->get_wrapper('html', 'main');
308
+		// add message type to template_args
309
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
310
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
311
+	}
312
+
313
+
314
+	/**
315
+	 * This takes care of loading the dompdf library and generating the actual pdf
316
+	 *
317
+	 * @param string $content This is the generated html content being converted into a pdf.
318
+	 *
319
+	 * @return void
320
+	 */
321
+	protected function _do_pdf($content = '')
322
+	{
323
+		$invoice_name = $this->_subject;
324
+
325
+		// only load dompdf if nobody else has yet...
326
+		if (! class_exists('Dompdf\Dompdf')) {
327
+			require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
328
+			Dompdf\Autoloader::register();
329
+		}
330
+		$options = new Dompdf\Options();
331
+		$options->set('isRemoteEnabled', true);
332
+		$options->set('isJavascriptEnabled', false);
333
+		if (defined('DOMPDF_FONT_DIR')) {
334
+			$options->setFontDir(DOMPDF_FONT_DIR);
335
+			$options->setFontCache(DOMPDF_FONT_DIR);
336
+		}
337
+		$dompdf = new Dompdf\Dompdf($options);
338
+		// Remove all spaces between HTML tags
339
+		$content = preg_replace('/>\s+</', '><', $content);
340
+		$dompdf->loadHtml($content);
341
+		$dompdf->render();
342
+		// forcing the browser to open a download dialog.
343
+		$dompdf->stream($invoice_name . ".pdf", array('Attachment' => true));
344
+	}
345
+
346
+
347
+	/**
348
+	 * @return string
349
+	 */
350
+	protected function _preview()
351
+	{
352
+		return $this->_send_message();
353
+	}
354
+
355
+
356
+	protected function _set_admin_settings_fields()
357
+	{
358
+	}
359 359
 }
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/Invoice.class.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
             7 => "union.css",
84 84
         );
85 85
         // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
86
+        if (isset($themes[$theme_requested])) {
87
+            $template_args['invoice_css'] = $themes[$theme_requested];
88 88
         } else {
89 89
             $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90 90
                 'legacy_invoice_css',
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
             );
94 94
         }
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
96
+        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) {
97
+            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/';
98 98
         } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
99
+            $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/';
100 100
         }
101 101
         $primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103 103
         $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104 104
         $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105 105
             'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
106
+        ) : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2');
107 107
         $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108 108
         $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109 109
             $EE->CFG->organization->STA_ID
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         if ($template_args['amount_pd'] != $template_args['total_cost']) {
150 150
             // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151 151
             $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
152
+            if ( ! empty($tax_items)) {
153 153
                 foreach ($tax_items as $tax) {
154 154
                     $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155 155
                 }
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
                 $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184 184
                     array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185 185
                 );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
186
+                $ticket_line_items_per_event[$event_id] = $line_items_for_this_event;
187 187
                 foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188 188
                     $ticket = $line_item->ticket();
189 189
                     $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190 190
                         array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191 191
                     );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
192
+                    $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket;
193 193
                 }
194 194
                 $venues_for_events = array_merge($venues_for_events, $event->venues());
195 195
             }
@@ -219,21 +219,21 @@  discard block
 block discarded – undo
219 219
         // Get the HTML as an object
220 220
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221 221
         $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
222
+            $templates_relative_path.'invoice_header.template.php',
223 223
             $template_args,
224 224
             true,
225 225
             true
226 226
         );
227 227
         if (isset($_GET['receipt'])) {
228 228
             $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
229
+                $templates_relative_path.'receipt_body.template.php',
230 230
                 $template_args,
231 231
                 true,
232 232
                 true
233 233
             );
234 234
         } else {
235 235
             $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
236
+                $templates_relative_path.'invoice_body.template.php',
237 237
                 $template_args,
238 238
                 true,
239 239
                 true
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 
243 243
 
244 244
         $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
245
+            $templates_relative_path.'invoice_footer.template.php',
246 246
             $template_args,
247 247
             true,
248 248
             true
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
         $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259 259
         // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
260
+        if ( ! empty($_REQUEST['html'])) {
261 261
             echo $content;
262 262
             exit(0);
263 263
         }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
264
+        $invoice_name = $template_args['organization'].' '.__(
265 265
             'Invoice #',
266 266
             'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
267
+        ).$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name'];
268 268
         $invoice_name = str_replace(' ', '_', $invoice_name);
269 269
         // Create the PDF
270 270
         if (array_key_exists('html', $_GET)) {
271 271
             echo $content;
272 272
         } else {
273 273
             // only load dompdf if nobody else has yet...
274
-            if (! class_exists('Dompdf\Dompdf')) {
275
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
274
+            if ( ! class_exists('Dompdf\Dompdf')) {
275
+                require_once(EE_THIRD_PARTY.'dompdf/src/Autoloader.php');
276 276
                 Dompdf\Autoloader::register();
277 277
             }
278 278
             $options = new Dompdf\Options();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
             $dompdf = new Dompdf\Dompdf($options);
282 282
             $dompdf->loadHtml($content);
283 283
             $dompdf->render();
284
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
284
+            $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download));
285 285
         }
286 286
         exit(0);
287 287
     }
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
             true,
320 320
             $EE->CFG->organization->logo_url
321 321
         );
322
-        if (! empty($invoice_logo_url)) {
322
+        if ( ! empty($invoice_logo_url)) {
323 323
             $image_size = getimagesize($invoice_logo_url);
324
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
324
+            $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> ';
325 325
         } else {
326 326
             $invoice_logo_image = '';
327 327
         }
@@ -354,14 +354,14 @@  discard block
 block discarded – undo
354 354
             $this->registration->reg_code(),
355 355
             $this->transaction->ID(),
356 356
             $primary_attendee->full_name(),
357
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
358
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
357
+            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
358
+                : EE_GATEWAYS_URL.'Invoice/lib/templates/',
359 359
             $this->registration->invoice_url(),
360 360
             // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
361 361
             $invoice_logo_image,
362 362
             empty($EE->CFG->organization->address_2)
363 363
                 ? $EE->CFG->organization->get_pretty('address_1')
364
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
364
+                : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty(
365 365
                     'address_2'
366 366
                 ),
367 367
             $EE->CFG->organization->get_pretty('city'),
@@ -398,9 +398,9 @@  discard block
 block discarded – undo
398 398
         $find = array(' ');
399 399
         $replace = array('-');
400 400
         $row_id = strtolower(str_replace($find, $replace, $text));
401
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
402
-        $html .= '<td class="item_r">' . $text . '</td>';
403
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
401
+        $html .= '<tr id="'.$row_id.'-tr"><td colspan="4">&nbsp;</td>';
402
+        $html .= '<td class="item_r">'.$text.'</td>';
403
+        $html .= '<td class="item_r">'.$total_cost.'</td>';
404 404
         $html .= '</tr>';
405 405
         return $html;
406 406
     }
Please login to merge, or discard this patch.
Indentation   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -9,403 +9,403 @@
 block discarded – undo
9 9
 class Invoice
10 10
 {
11 11
 
12
-    /**
13
-     *
14
-     * @var EE_Registration
15
-     */
16
-    private $registration;
17
-    /**
18
-     *
19
-     * @var EE_Transaction
20
-     */
21
-    private $transaction;
22
-    /**
23
-     *
24
-     * @var EE_Payment_Method
25
-     */
26
-    private $invoice_payment_method;
27
-    private $EE;
12
+	/**
13
+	 *
14
+	 * @var EE_Registration
15
+	 */
16
+	private $registration;
17
+	/**
18
+	 *
19
+	 * @var EE_Transaction
20
+	 */
21
+	private $transaction;
22
+	/**
23
+	 *
24
+	 * @var EE_Payment_Method
25
+	 */
26
+	private $invoice_payment_method;
27
+	private $EE;
28 28
 
29 29
 
30
-    /**
31
-     * Invoice constructor.
32
-     *
33
-     * @deprecated 4.9.13
34
-     * @param int $url_link
35
-     */
36
-    public function __construct($url_link = 0)
37
-    {
38
-        EE_Error::doing_it_wrong(
39
-            __CLASS__,
40
-            esc_html__(
41
-                'This class has been deprecated and replaced by the new Messages library.',
42
-                'event_espresso'
43
-            ),
44
-            '4.9.12',
45
-            '5.0.0'
46
-        );
47
-        if ($this->registration = EE_Registry::instance()->load_model(
48
-            'Registration'
49
-        )->get_registration_for_reg_url_link($url_link)) {
50
-            $this->transaction = $this->registration->transaction();
51
-            // get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
-            $payment_settings = EE_Config::instance()->gateway->payment_settings;
53
-            $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
-        } else {
55
-            EE_Error::add_error(
56
-                __(
57
-                    'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
-                    'event_espresso'
59
-                ),
60
-                __FILE__,
61
-                __FUNCTION__,
62
-                __LINE__
63
-            );
64
-        }
65
-    }
30
+	/**
31
+	 * Invoice constructor.
32
+	 *
33
+	 * @deprecated 4.9.13
34
+	 * @param int $url_link
35
+	 */
36
+	public function __construct($url_link = 0)
37
+	{
38
+		EE_Error::doing_it_wrong(
39
+			__CLASS__,
40
+			esc_html__(
41
+				'This class has been deprecated and replaced by the new Messages library.',
42
+				'event_espresso'
43
+			),
44
+			'4.9.12',
45
+			'5.0.0'
46
+		);
47
+		if ($this->registration = EE_Registry::instance()->load_model(
48
+			'Registration'
49
+		)->get_registration_for_reg_url_link($url_link)) {
50
+			$this->transaction = $this->registration->transaction();
51
+			// get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE);
52
+			$payment_settings = EE_Config::instance()->gateway->payment_settings;
53
+			$this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice');
54
+		} else {
55
+			EE_Error::add_error(
56
+				__(
57
+					'Your request appears to be missing some required data, and no information for your transaction could be retrieved.',
58
+					'event_espresso'
59
+				),
60
+				__FILE__,
61
+				__FUNCTION__,
62
+				__LINE__
63
+			);
64
+		}
65
+	}
66 66
 
67
-    public function send_invoice($download = false)
68
-    {
69
-        $template_args = array();
70
-        $EE = EE_Registry::instance();
67
+	public function send_invoice($download = false)
68
+	{
69
+		$template_args = array();
70
+		$EE = EE_Registry::instance();
71 71
 
72
-        // allow the request to override the default theme defined in the invoice settings
73
-        $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
-            $_REQUEST['theme']
75
-        ) : null;
76
-        $themes = array(
77
-            1 => "simple.css",
78
-            2 => "bauhaus.css",
79
-            3 => "ejs.css",
80
-            4 => "horizon.css",
81
-            5 => "lola.css",
82
-            6 => "tranquility.css",
83
-            7 => "union.css",
84
-        );
85
-        // Get the CSS file
86
-        if (isset($themes[ $theme_requested ])) {
87
-            $template_args['invoice_css'] = $themes[ $theme_requested ];
88
-        } else {
89
-            $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
-                'legacy_invoice_css',
91
-                true,
92
-                'simple.css'
93
-            );
94
-        }
72
+		// allow the request to override the default theme defined in the invoice settings
73
+		$theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint(
74
+			$_REQUEST['theme']
75
+		) : null;
76
+		$themes = array(
77
+			1 => "simple.css",
78
+			2 => "bauhaus.css",
79
+			3 => "ejs.css",
80
+			4 => "horizon.css",
81
+			5 => "lola.css",
82
+			6 => "tranquility.css",
83
+			7 => "union.css",
84
+		);
85
+		// Get the CSS file
86
+		if (isset($themes[ $theme_requested ])) {
87
+			$template_args['invoice_css'] = $themes[ $theme_requested ];
88
+		} else {
89
+			$template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta(
90
+				'legacy_invoice_css',
91
+				true,
92
+				'simple.css'
93
+			);
94
+		}
95 95
 
96
-        if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
-            $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
-        } else {
99
-            $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
-        }
101
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
96
+		if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) {
97
+			$template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/';
98
+		} else {
99
+			$template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/';
100
+		}
101
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
102 102
 
103
-        $template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
-        $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
-            'address_1'
106
-        ) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
-        $template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
-        $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
-            $EE->CFG->organization->STA_ID
110
-        );
111
-        $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
-            $EE->CFG->organization->CNT_ISO
113
-        );
114
-        $template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
-        $template_args['email'] = $EE->CFG->organization->get_pretty('email');
103
+		$template_args['organization'] = $EE->CFG->organization->get_pretty('name');
104
+		$template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty(
105
+			'address_1'
106
+		) : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty('address_2');
107
+		$template_args['city'] = $EE->CFG->organization->get_pretty('city');
108
+		$template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID(
109
+			$EE->CFG->organization->STA_ID
110
+		);
111
+		$template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID(
112
+			$EE->CFG->organization->CNT_ISO
113
+		);
114
+		$template_args['zip'] = $EE->CFG->organization->get_pretty('zip');
115
+		$template_args['email'] = $EE->CFG->organization->get_pretty('email');
116 116
 
117
-        $template_args['registration_code'] = $this->registration->reg_code();
118
-        $template_args['registration_date'] = $this->registration->date();
119
-        $template_args['name'] = $primary_attendee->full_name();
120
-        $template_args['attendee_address'] = $primary_attendee->address();
121
-        $template_args['attendee_address2'] = $primary_attendee->address2();
122
-        $template_args['attendee_city'] = $primary_attendee->city();
123
-        $attendee_state = $primary_attendee->state_obj();
124
-        if ($attendee_state) {
125
-            $attendee_state_name = $attendee_state->name();
126
-        } else {
127
-            $attendee_state_name = '';
128
-        }
129
-        $template_args['attendee_state'] = $attendee_state_name;
130
-        $template_args['attendee_zip'] = $primary_attendee->zip();
117
+		$template_args['registration_code'] = $this->registration->reg_code();
118
+		$template_args['registration_date'] = $this->registration->date();
119
+		$template_args['name'] = $primary_attendee->full_name();
120
+		$template_args['attendee_address'] = $primary_attendee->address();
121
+		$template_args['attendee_address2'] = $primary_attendee->address2();
122
+		$template_args['attendee_city'] = $primary_attendee->city();
123
+		$attendee_state = $primary_attendee->state_obj();
124
+		if ($attendee_state) {
125
+			$attendee_state_name = $attendee_state->name();
126
+		} else {
127
+			$attendee_state_name = '';
128
+		}
129
+		$template_args['attendee_state'] = $attendee_state_name;
130
+		$template_args['attendee_zip'] = $primary_attendee->zip();
131 131
 
132
-        $template_args['ship_name'] = $template_args['name'];
133
-        $template_args['ship_address'] = $template_args['attendee_address'];
134
-        $template_args['ship_city'] = $template_args['attendee_city'];
135
-        $template_args['ship_state'] = $template_args['attendee_state'];
136
-        $template_args['ship_zip'] = $template_args['attendee_zip'];
132
+		$template_args['ship_name'] = $template_args['name'];
133
+		$template_args['ship_address'] = $template_args['attendee_address'];
134
+		$template_args['ship_city'] = $template_args['attendee_city'];
135
+		$template_args['ship_state'] = $template_args['attendee_state'];
136
+		$template_args['ship_zip'] = $template_args['attendee_zip'];
137 137
 
138
-        $template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
-        $template_args['transaction'] = $this->transaction;
140
-        $template_args['amount_pd'] = $this->transaction->paid();
141
-        $template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
-        $template_args['payments'] = $this->transaction->approved_payments();
143
-        $template_args['net_total'] = '';
144
-        $template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
-        $template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
-        $template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
-            $this->transaction->total_line_item()
148
-        );
149
-        if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
-            // $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
-            $tax_items = $this->transaction->tax_items();
152
-            if (! empty($tax_items)) {
153
-                foreach ($tax_items as $tax) {
154
-                    $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
-                }
156
-            }
138
+		$template_args['total_cost'] = number_format($this->transaction->total(), 2, '.', '');
139
+		$template_args['transaction'] = $this->transaction;
140
+		$template_args['amount_pd'] = $this->transaction->paid();
141
+		$template_args['amount_owed'] = $this->transaction->total() - $this->transaction->paid();
142
+		$template_args['payments'] = $this->transaction->approved_payments();
143
+		$template_args['net_total'] = '';
144
+		$template_args['edit_reg_info_url'] = $this->registration->edit_attendee_information_url();
145
+		$template_args['retry_payment_url'] = $this->registration->payment_overview_url();
146
+		$template_args['show_line_item_description'] = $this->check_if_any_line_items_have_a_description(
147
+			$this->transaction->total_line_item()
148
+		);
149
+		if ($template_args['amount_pd'] != $template_args['total_cost']) {
150
+			// $template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']);
151
+			$tax_items = $this->transaction->tax_items();
152
+			if (! empty($tax_items)) {
153
+				foreach ($tax_items as $tax) {
154
+					$template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total());
155
+				}
156
+			}
157 157
 
158
-            $difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
-            if ($difference < 0) {
160
-                $text = __('Discount', 'event_espresso');
161
-            } else {
162
-                $text = __('Extra', 'event_espresso');
163
-            }
164
-            $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
-        }
158
+			$difference = $template_args['amount_pd'] - $template_args['total_cost'];
159
+			if ($difference < 0) {
160
+				$text = __('Discount', 'event_espresso');
161
+			} else {
162
+				$text = __('Extra', 'event_espresso');
163
+			}
164
+			$template_args['discount'] = $this->espressoInvoiceTotals($text, $difference);
165
+		}
166 166
 
167
-        $template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
-        $template_args['template_payment_instructions'] = wpautop(
169
-            stripslashes_deep(
170
-                html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
-            )
172
-        );
173
-        $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
-        if (isset($_GET['receipt'])) {
175
-            // receipt-specific stuff
176
-            $events_for_txn = EEM_Event::instance()->get_all(
177
-                array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
-            );
179
-            $ticket_line_items_per_event = array();
180
-            $registrations_per_line_item = array();
181
-            $venues_for_events = array();
182
-            foreach ($events_for_txn as $event_id => $event) {
183
-                $line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
-                    array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
-                );
186
-                $ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
-                foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
-                    $ticket = $line_item->ticket();
189
-                    $registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
-                        array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
-                    );
192
-                    $registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
-                }
194
-                $venues_for_events = array_merge($venues_for_events, $event->venues());
195
-            }
196
-            $tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
-                array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
-            );
199
-            $questions_to_skip = array(
200
-                EEM_Attendee::system_question_fname,
201
-                EEM_Attendee::system_question_lname,
202
-                EEM_Attendee::system_question_email,
203
-            );
167
+		$template_args['currency_symbol'] = $EE->CFG->currency->sign;
168
+		$template_args['template_payment_instructions'] = wpautop(
169
+			stripslashes_deep(
170
+				html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', true), ENT_QUOTES)
171
+			)
172
+		);
173
+		$template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true);
174
+		if (isset($_GET['receipt'])) {
175
+			// receipt-specific stuff
176
+			$events_for_txn = EEM_Event::instance()->get_all(
177
+				array(array('Registration.TXN_ID' => $this->transaction->ID()))
178
+			);
179
+			$ticket_line_items_per_event = array();
180
+			$registrations_per_line_item = array();
181
+			$venues_for_events = array();
182
+			foreach ($events_for_txn as $event_id => $event) {
183
+				$line_items_for_this_event = EEM_Line_Item::instance()->get_all(
184
+					array(array('Ticket.Datetime.EVT_ID' => $event_id, 'TXN_ID' => $this->transaction->ID()))
185
+				);
186
+				$ticket_line_items_per_event[ $event_id ] = $line_items_for_this_event;
187
+				foreach ($line_items_for_this_event as $line_item_id => $line_item) {
188
+					$ticket = $line_item->ticket();
189
+					$registrations_for_this_ticket = EEM_Registration::instance()->get_all(
190
+						array(array('TKT_ID' => $ticket->ID(), 'TXN_ID' => $this->transaction->ID()))
191
+					);
192
+					$registrations_per_line_item[ $line_item_id ] = $registrations_for_this_ticket;
193
+				}
194
+				$venues_for_events = array_merge($venues_for_events, $event->venues());
195
+			}
196
+			$tax_total_line_item = EEM_Line_Item::instance()->get_one(
197
+				array(array('TXN_ID' => $this->transaction->ID(), 'LIN_type' => EEM_Line_Item::type_tax_sub_total))
198
+			);
199
+			$questions_to_skip = array(
200
+				EEM_Attendee::system_question_fname,
201
+				EEM_Attendee::system_question_lname,
202
+				EEM_Attendee::system_question_email,
203
+			);
204 204
 
205 205
 
206
-            $template_args['events_for_txn'] = $events_for_txn;
207
-            $template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
-            $template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
-            $template_args['venues_for_events'] = $venues_for_events;
210
-            $template_args['tax_total_line_item'] = $tax_total_line_item;
211
-            $template_args['questions_to_skip'] = $questions_to_skip;
212
-            // d($template_args);
213
-            $template_args['download_link'] = $this->registration->receipt_url('download');
214
-        } else {
215
-            // it's just an invoice we're accessing
216
-            $template_args['download_link'] = $this->registration->invoice_url('download');
217
-        }
206
+			$template_args['events_for_txn'] = $events_for_txn;
207
+			$template_args['ticket_line_items_per_event'] = $ticket_line_items_per_event;
208
+			$template_args['registrations_per_line_item'] = $registrations_per_line_item;
209
+			$template_args['venues_for_events'] = $venues_for_events;
210
+			$template_args['tax_total_line_item'] = $tax_total_line_item;
211
+			$template_args['questions_to_skip'] = $questions_to_skip;
212
+			// d($template_args);
213
+			$template_args['download_link'] = $this->registration->receipt_url('download');
214
+		} else {
215
+			// it's just an invoice we're accessing
216
+			$template_args['download_link'] = $this->registration->invoice_url('download');
217
+		}
218 218
 
219
-        // Get the HTML as an object
220
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
-        $template_header = EEH_Template::locate_template(
222
-            $templates_relative_path . 'invoice_header.template.php',
223
-            $template_args,
224
-            true,
225
-            true
226
-        );
227
-        if (isset($_GET['receipt'])) {
228
-            $template_body = EEH_Template::locate_template(
229
-                $templates_relative_path . 'receipt_body.template.php',
230
-                $template_args,
231
-                true,
232
-                true
233
-            );
234
-        } else {
235
-            $template_body = EEH_Template::locate_template(
236
-                $templates_relative_path . 'invoice_body.template.php',
237
-                $template_args,
238
-                true,
239
-                true
240
-            );
241
-        }
219
+		// Get the HTML as an object
220
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
221
+		$template_header = EEH_Template::locate_template(
222
+			$templates_relative_path . 'invoice_header.template.php',
223
+			$template_args,
224
+			true,
225
+			true
226
+		);
227
+		if (isset($_GET['receipt'])) {
228
+			$template_body = EEH_Template::locate_template(
229
+				$templates_relative_path . 'receipt_body.template.php',
230
+				$template_args,
231
+				true,
232
+				true
233
+			);
234
+		} else {
235
+			$template_body = EEH_Template::locate_template(
236
+				$templates_relative_path . 'invoice_body.template.php',
237
+				$template_args,
238
+				true,
239
+				true
240
+			);
241
+		}
242 242
 
243 243
 
244
-        $template_footer = EEH_Template::locate_template(
245
-            $templates_relative_path . 'invoice_footer.template.php',
246
-            $template_args,
247
-            true,
248
-            true
249
-        );
244
+		$template_footer = EEH_Template::locate_template(
245
+			$templates_relative_path . 'invoice_footer.template.php',
246
+			$template_args,
247
+			true,
248
+			true
249
+		);
250 250
 
251
-        $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
251
+		$copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1;
252 252
 
253
-        $content = $this->espresso_replace_invoice_shortcodes($template_header);
254
-        for ($x = 1; $x <= $copies; $x++) {
255
-            $content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
-        }
257
-        $content .= $this->espresso_replace_invoice_shortcodes($template_footer);
253
+		$content = $this->espresso_replace_invoice_shortcodes($template_header);
254
+		for ($x = 1; $x <= $copies; $x++) {
255
+			$content .= $this->espresso_replace_invoice_shortcodes($template_body);
256
+		}
257
+		$content .= $this->espresso_replace_invoice_shortcodes($template_footer);
258 258
 
259
-        // Check if debugging or mobile is set
260
-        if (! empty($_REQUEST['html'])) {
261
-            echo $content;
262
-            exit(0);
263
-        }
264
-        $invoice_name = $template_args['organization'] . ' ' . __(
265
-            'Invoice #',
266
-            'event_espresso'
267
-        ) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
-        $invoice_name = str_replace(' ', '_', $invoice_name);
269
-        // Create the PDF
270
-        if (array_key_exists('html', $_GET)) {
271
-            echo $content;
272
-        } else {
273
-            // only load dompdf if nobody else has yet...
274
-            if (! class_exists('Dompdf\Dompdf')) {
275
-                require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
276
-                Dompdf\Autoloader::register();
277
-            }
278
-            $options = new Dompdf\Options();
279
-            $options->set('isRemoteEnabled', true);
280
-            $options->set('isJavascriptEnabled', false);
281
-            if (defined('DOMPDF_FONT_DIR')) {
282
-                $options->setFontDir(DOMPDF_FONT_DIR);
283
-                $options->setFontCache(DOMPDF_FONT_DIR);
284
-            }
285
-            $dompdf = new Dompdf\Dompdf($options);
286
-            $dompdf->loadHtml($content);
287
-            $dompdf->render();
288
-            $dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
289
-        }
290
-        exit(0);
291
-    }
259
+		// Check if debugging or mobile is set
260
+		if (! empty($_REQUEST['html'])) {
261
+			echo $content;
262
+			exit(0);
263
+		}
264
+		$invoice_name = $template_args['organization'] . ' ' . __(
265
+			'Invoice #',
266
+			'event_espresso'
267
+		) . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name'];
268
+		$invoice_name = str_replace(' ', '_', $invoice_name);
269
+		// Create the PDF
270
+		if (array_key_exists('html', $_GET)) {
271
+			echo $content;
272
+		} else {
273
+			// only load dompdf if nobody else has yet...
274
+			if (! class_exists('Dompdf\Dompdf')) {
275
+				require_once(EE_THIRD_PARTY . 'dompdf/src/Autoloader.php');
276
+				Dompdf\Autoloader::register();
277
+			}
278
+			$options = new Dompdf\Options();
279
+			$options->set('isRemoteEnabled', true);
280
+			$options->set('isJavascriptEnabled', false);
281
+			if (defined('DOMPDF_FONT_DIR')) {
282
+				$options->setFontDir(DOMPDF_FONT_DIR);
283
+				$options->setFontCache(DOMPDF_FONT_DIR);
284
+			}
285
+			$dompdf = new Dompdf\Dompdf($options);
286
+			$dompdf->loadHtml($content);
287
+			$dompdf->render();
288
+			$dompdf->stream($invoice_name . ".pdf", array('Attachment' => $download));
289
+		}
290
+		exit(0);
291
+	}
292 292
 
293
-    /**
294
-     * Checks if this line item, or any of its children, actually has a description.
295
-     * If none do, then the template can decide to not show any description column
296
-     *
297
-     * @param EE_Line_Item $line_item
298
-     * @return boolean
299
-     */
300
-    public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
301
-    {
302
-        if ($line_item->desc()) {
303
-            return true;
304
-        } else {
305
-            foreach ($line_item->children() as $child_line_item) {
306
-                if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
307
-                    return true;
308
-                }
309
-            }
310
-            // well, if I and my children don't have descriptions, I guess not
311
-            return false;
312
-        }
313
-    }
293
+	/**
294
+	 * Checks if this line item, or any of its children, actually has a description.
295
+	 * If none do, then the template can decide to not show any description column
296
+	 *
297
+	 * @param EE_Line_Item $line_item
298
+	 * @return boolean
299
+	 */
300
+	public function check_if_any_line_items_have_a_description(EE_Line_Item $line_item)
301
+	{
302
+		if ($line_item->desc()) {
303
+			return true;
304
+		} else {
305
+			foreach ($line_item->children() as $child_line_item) {
306
+				if ($this->check_if_any_line_items_have_a_description($child_line_item)) {
307
+					return true;
308
+				}
309
+			}
310
+			// well, if I and my children don't have descriptions, I guess not
311
+			return false;
312
+		}
313
+	}
314 314
 
315 315
 // Perform the shortcode replacement
316
-    public function espresso_replace_invoice_shortcodes($content)
317
-    {
316
+	public function espresso_replace_invoice_shortcodes($content)
317
+	{
318 318
 
319
-        $EE = EE_Registry::instance();
320
-        // Create the logo
321
-        $invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
322
-            'pdf_logo_image',
323
-            true,
324
-            $EE->CFG->organization->logo_url
325
-        );
326
-        if (! empty($invoice_logo_url)) {
327
-            $image_size = getimagesize($invoice_logo_url);
328
-            $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
329
-        } else {
330
-            $invoice_logo_image = '';
331
-        }
332
-        $SearchValues = array(
333
-            "[organization]",
334
-            "[registration_code]",
335
-            "[transaction_id]",
336
-            "[name]",
337
-            "[base_url]",
338
-            "[download_link]",
339
-            "[invoice_logo_image]",
340
-            "[street]",
341
-            "[city]",
342
-            "[state]",
343
-            "[zip]",
344
-            "[email]",
345
-            "[vat]",
346
-            "[registration_date]",
347
-            "[instructions]",
348
-        );
349
-        $primary_attendee = $this->transaction->primary_registration()->attendee();
350
-        $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
351
-        if ($org_state) {
352
-            $org_state_name = $org_state->name();
353
-        } else {
354
-            $org_state_name = '';
355
-        }
356
-        $ReplaceValues = array(
357
-            $EE->CFG->organization->get_pretty('name'),
358
-            $this->registration->reg_code(),
359
-            $this->transaction->ID(),
360
-            $primary_attendee->full_name(),
361
-            (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
362
-                : EE_GATEWAYS_URL . 'Invoice/lib/templates/',
363
-            $this->registration->invoice_url(),
364
-            // home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
365
-            $invoice_logo_image,
366
-            empty($EE->CFG->organization->address_2)
367
-                ? $EE->CFG->organization->get_pretty('address_1')
368
-                : $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
369
-                    'address_2'
370
-                ),
371
-            $EE->CFG->organization->get_pretty('city'),
372
-            $org_state_name,
373
-            $EE->CFG->organization->get_pretty('zip'),
374
-            $EE->CFG->organization->get_pretty('email'),
375
-            $EE->CFG->organization->vat,
376
-            $this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
377
-            $this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
378
-        );
319
+		$EE = EE_Registry::instance();
320
+		// Create the logo
321
+		$invoice_logo_url = $this->invoice_payment_method->get_extra_meta(
322
+			'pdf_logo_image',
323
+			true,
324
+			$EE->CFG->organization->logo_url
325
+		);
326
+		if (! empty($invoice_logo_url)) {
327
+			$image_size = getimagesize($invoice_logo_url);
328
+			$invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> ';
329
+		} else {
330
+			$invoice_logo_image = '';
331
+		}
332
+		$SearchValues = array(
333
+			"[organization]",
334
+			"[registration_code]",
335
+			"[transaction_id]",
336
+			"[name]",
337
+			"[base_url]",
338
+			"[download_link]",
339
+			"[invoice_logo_image]",
340
+			"[street]",
341
+			"[city]",
342
+			"[state]",
343
+			"[zip]",
344
+			"[email]",
345
+			"[vat]",
346
+			"[registration_date]",
347
+			"[instructions]",
348
+		);
349
+		$primary_attendee = $this->transaction->primary_registration()->attendee();
350
+		$org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID);
351
+		if ($org_state) {
352
+			$org_state_name = $org_state->name();
353
+		} else {
354
+			$org_state_name = '';
355
+		}
356
+		$ReplaceValues = array(
357
+			$EE->CFG->organization->get_pretty('name'),
358
+			$this->registration->reg_code(),
359
+			$this->transaction->ID(),
360
+			$primary_attendee->full_name(),
361
+			(is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'
362
+				: EE_GATEWAYS_URL . 'Invoice/lib/templates/',
363
+			$this->registration->invoice_url(),
364
+			// home_url() . '/?download_invoice=true&amp;id=' . $this->registration->reg_url_link(),
365
+			$invoice_logo_image,
366
+			empty($EE->CFG->organization->address_2)
367
+				? $EE->CFG->organization->get_pretty('address_1')
368
+				: $EE->CFG->organization->get_pretty('address_1') . '<br>' . $EE->CFG->organization->get_pretty(
369
+					'address_2'
370
+				),
371
+			$EE->CFG->organization->get_pretty('city'),
372
+			$org_state_name,
373
+			$EE->CFG->organization->get_pretty('zip'),
374
+			$EE->CFG->organization->get_pretty('email'),
375
+			$EE->CFG->organization->vat,
376
+			$this->registration->get_i18n_datetime('REG_date', get_option('date_format')),
377
+			$this->invoice_payment_method->get_extra_meta('pdf_instructions', true),
378
+		);
379 379
 
380
-        return str_replace($SearchValues, $ReplaceValues, $content);
381
-    }
380
+		return str_replace($SearchValues, $ReplaceValues, $content);
381
+	}
382 382
 
383
-    public function espressoLoadData($items)
384
-    {
385
-        $lines = $items;
386
-        $data = array();
387
-        foreach ($lines as $line) {
388
-            $data[] = explode(';', chop($line));
389
-        }
383
+	public function espressoLoadData($items)
384
+	{
385
+		$lines = $items;
386
+		$data = array();
387
+		foreach ($lines as $line) {
388
+			$data[] = explode(';', chop($line));
389
+		}
390 390
 
391
-        return $data;
392
-    }
391
+		return $data;
392
+	}
393 393
 
394 394
 
395
-    public function espressoInvoiceTotals($text, $total_cost)
396
-    {
395
+	public function espressoInvoiceTotals($text, $total_cost)
396
+	{
397 397
 
398
-        $html = '';
399
-        if ($total_cost < 0) {
400
-            $total_cost = (-1) * $total_cost;
401
-        }
402
-        $find = array(' ');
403
-        $replace = array('-');
404
-        $row_id = strtolower(str_replace($find, $replace, $text));
405
-        $html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
406
-        $html .= '<td class="item_r">' . $text . '</td>';
407
-        $html .= '<td class="item_r">' . $total_cost . '</td>';
408
-        $html .= '</tr>';
409
-        return $html;
410
-    }
398
+		$html = '';
399
+		if ($total_cost < 0) {
400
+			$total_cost = (-1) * $total_cost;
401
+		}
402
+		$find = array(' ');
403
+		$replace = array('-');
404
+		$row_id = strtolower(str_replace($find, $replace, $text));
405
+		$html .= '<tr id="' . $row_id . '-tr"><td colspan="4">&nbsp;</td>';
406
+		$html .= '<td class="item_r">' . $text . '</td>';
407
+		$html .= '<td class="item_r">' . $total_cost . '</td>';
408
+		$html .= '</tr>';
409
+		return $html;
410
+	}
411 411
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
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
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            '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.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'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.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.005');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.69.rc.005');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.