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