Completed
Branch master (7421d0)
by
unknown
11:25 queued 06:55
created
core/libraries/shortcodes/EE_Primary_Registration_List_Shortcodes.lib.php 1 patch
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -18,204 +18,204 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Primary_Registration_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    public function __construct()
22
-    {
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-    protected function _init_props()
28
-    {
29
-        $this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
-        $this->description = esc_html__(
31
-            'All shortcodes specific primary registrant recipients list type data.',
32
-            'event_espresso'
33
-        );
34
-        $this->_shortcodes = array(
35
-            '[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
-                'Will output a list of tickets that the primary registration received.',
37
-                'event_espresso'
38
-            ),
39
-            '[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
-                'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
-                'event_espresso'
42
-            ),
43
-        );
44
-    }
45
-
46
-
47
-    protected function _parser($shortcode)
48
-    {
49
-        switch ($shortcode) {
50
-            case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
-                return $this->_get_recipient_ticket_list(true);
52
-
53
-            case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
54
-                return $this->_get_recipient_datetime_list(true);
55
-        }
56
-        return '';
57
-    }
58
-
59
-
60
-    /**
61
-     * figure out what the incoming data is and then return the appropriate parsed value
62
-     *
63
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
64
-     * @return string
65
-     */
66
-    private function _get_recipient_ticket_list($primary = false)
67
-    {
68
-        $this->_validate_list_requirements();
69
-
70
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
71
-            return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
72
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
73
-            return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
74
-        } else {
75
-            return '';
76
-        }
77
-    }
78
-
79
-
80
-    private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
81
-    {
82
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
83
-        if (! $registration instanceof EE_Registration) {
84
-            return '';
85
-        }
86
-        // setup valid shortcodes depending on what the status of the $this->_data property is
87
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
88
-            $valid_shortcodes = array(
89
-                'ticket',
90
-                'event_list',
91
-                'attendee_list',
92
-                'datetime_list',
93
-                'registration_details',
94
-                'attendee',
95
-            );
96
-            $template = $this->_data['template'];
97
-            $tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
98
-            $data = $this->_data;
99
-        } elseif ($this->_data['data'] instanceof EE_Event) {
100
-            $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
101
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
102
-                ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
103
-            // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
104
-            $template = str_replace('[EVENT_LIST]', '', $template);
105
-            // data will be tickets for this event for this recipient.
106
-            $tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
107
-            $data = $this->_extra_data;
108
-        } else {
109
-            return '';
110
-        }
111
-
112
-        $tktparsed = '';
113
-        foreach ($tkts as $ticket) {
114
-            $tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
115
-                $template,
116
-                $ticket,
117
-                $valid_shortcodes,
118
-                $data
119
-            );
120
-        }
121
-        return $tktparsed;
122
-    }
123
-
124
-
125
-    private function _get_tickets_from_event(EE_Event $event, $reg = null)
126
-    {
127
-        $evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
128
-        ) ]['tkt_objs'] : array();
129
-
130
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
131
-            $adj_tkts = array();
132
-            // return only tickets for the given attendee
133
-            foreach ($evt_tkts as $tkt) {
134
-                if (
135
-                    isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
136
-                    && $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
137
-                ) {
138
-                    $adj_tkts[] = $tkt;
139
-                }
140
-            }
141
-            $evt_tkts = $adj_tkts;
142
-        }
143
-        return $evt_tkts;
144
-    }
145
-
146
-
147
-    /**
148
-     * figure out what the incoming data is and then return the appropriate parsed value
149
-     *
150
-     * @param  boolean $primary whether we're getting the primary registrant ticket_list.
151
-     * @return string
152
-     */
153
-    private function _get_recipient_datetime_list($primary = false)
154
-    {
155
-        $this->_validate_list_requirements();
156
-
157
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
158
-            return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
159
-        } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
160
-            return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
161
-        } else {
162
-            return '';
163
-        }
164
-
165
-        return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
166
-    }
167
-
168
-
169
-    private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
170
-    {
171
-        $registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
172
-        if (! $registration instanceof EE_Registration) {
173
-            return '';
174
-        }
175
-        // setup valid shortcodes depending on what the status of the $this->_data property is
176
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
177
-            $valid_shortcodes = array('datetime', 'attendee');
178
-            $template = $this->_data['template'];
179
-            $dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
180
-            $data = $this->_data;
181
-        } elseif ($this->_data['data'] instanceof EE_Event) {
182
-            $valid_shortcodes = array('datetime', 'attendee');
183
-            $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
184
-                ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
185
-            $dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
186
-            $data = $this->_extra_data;
187
-        } else {
188
-            return '';
189
-        }
190
-
191
-        $dtt_parsed = '';
192
-        foreach ($dtts as $datetime) {
193
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
194
-                $template,
195
-                $datetime,
196
-                $valid_shortcodes,
197
-                $this->_extra_data
198
-            );
199
-        }
200
-        return $dtt_parsed;
201
-    }
202
-
203
-
204
-    private function _get_datetimes_from_event(EE_Event $event, $reg = null)
205
-    {
206
-        $evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
207
-        ) ]['dtt_objs'] : array();
208
-
209
-        if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
210
-            $adj_dtts = array();
211
-            // return only dtts for the given attendee
212
-            foreach ($evt_dtts as $dtt) {
213
-                if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
214
-                    $adj_dtts[] = $dtt;
215
-                }
216
-            }
217
-            $evt_dtts = $adj_dtts;
218
-        }
219
-        return $evt_dtts;
220
-    }
21
+	public function __construct()
22
+	{
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+	protected function _init_props()
28
+	{
29
+		$this->label = esc_html__('Primary Registrant List Shortcodes', 'event_espresso');
30
+		$this->description = esc_html__(
31
+			'All shortcodes specific primary registrant recipients list type data.',
32
+			'event_espresso'
33
+		);
34
+		$this->_shortcodes = array(
35
+			'[PRIMARY_REGISTRANT_TICKET_LIST]' => esc_html__(
36
+				'Will output a list of tickets that the primary registration received.',
37
+				'event_espresso'
38
+			),
39
+			'[PRIMARY_REGISTRANT_DATETIME_LIST]' => esc_html__(
40
+				'Will output a list of datetimes that the primary registrant for the transaction has been registered for.',
41
+				'event_espresso'
42
+			),
43
+		);
44
+	}
45
+
46
+
47
+	protected function _parser($shortcode)
48
+	{
49
+		switch ($shortcode) {
50
+			case '[PRIMARY_REGISTRANT_TICKET_LIST]':
51
+				return $this->_get_recipient_ticket_list(true);
52
+
53
+			case '[PRIMARY_REGISTRANT_DATETIME_LIST]':
54
+				return $this->_get_recipient_datetime_list(true);
55
+		}
56
+		return '';
57
+	}
58
+
59
+
60
+	/**
61
+	 * figure out what the incoming data is and then return the appropriate parsed value
62
+	 *
63
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
64
+	 * @return string
65
+	 */
66
+	private function _get_recipient_ticket_list($primary = false)
67
+	{
68
+		$this->_validate_list_requirements();
69
+
70
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
71
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
72
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
73
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
74
+		} else {
75
+			return '';
76
+		}
77
+	}
78
+
79
+
80
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = false)
81
+	{
82
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
83
+		if (! $registration instanceof EE_Registration) {
84
+			return '';
85
+		}
86
+		// setup valid shortcodes depending on what the status of the $this->_data property is
87
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
88
+			$valid_shortcodes = array(
89
+				'ticket',
90
+				'event_list',
91
+				'attendee_list',
92
+				'datetime_list',
93
+				'registration_details',
94
+				'attendee',
95
+			);
96
+			$template = $this->_data['template'];
97
+			$tkts = array($data->registrations[ $registration->ID() ]['tkt_obj']);
98
+			$data = $this->_data;
99
+		} elseif ($this->_data['data'] instanceof EE_Event) {
100
+			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
101
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
102
+				? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
103
+			// let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
104
+			$template = str_replace('[EVENT_LIST]', '', $template);
105
+			// data will be tickets for this event for this recipient.
106
+			$tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
107
+			$data = $this->_extra_data;
108
+		} else {
109
+			return '';
110
+		}
111
+
112
+		$tktparsed = '';
113
+		foreach ($tkts as $ticket) {
114
+			$tktparsed .= $this->_shortcode_helper->parse_ticket_list_template(
115
+				$template,
116
+				$ticket,
117
+				$valid_shortcodes,
118
+				$data
119
+			);
120
+		}
121
+		return $tktparsed;
122
+	}
123
+
124
+
125
+	private function _get_tickets_from_event(EE_Event $event, $reg = null)
126
+	{
127
+		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
128
+		) ]['tkt_objs'] : array();
129
+
130
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
131
+			$adj_tkts = array();
132
+			// return only tickets for the given attendee
133
+			foreach ($evt_tkts as $tkt) {
134
+				if (
135
+					isset($this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj'])
136
+					&& $this->_extra_data['data']->registrations[ $reg->ID() ]['tkt_obj']->ID() == $tkt->ID()
137
+				) {
138
+					$adj_tkts[] = $tkt;
139
+				}
140
+			}
141
+			$evt_tkts = $adj_tkts;
142
+		}
143
+		return $evt_tkts;
144
+	}
145
+
146
+
147
+	/**
148
+	 * figure out what the incoming data is and then return the appropriate parsed value
149
+	 *
150
+	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
151
+	 * @return string
152
+	 */
153
+	private function _get_recipient_datetime_list($primary = false)
154
+	{
155
+		$this->_validate_list_requirements();
156
+
157
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
158
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
159
+		} elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) {
160
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
161
+		} else {
162
+			return '';
163
+		}
164
+
165
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
166
+	}
167
+
168
+
169
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = false)
170
+	{
171
+		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
172
+		if (! $registration instanceof EE_Registration) {
173
+			return '';
174
+		}
175
+		// setup valid shortcodes depending on what the status of the $this->_data property is
176
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
177
+			$valid_shortcodes = array('datetime', 'attendee');
178
+			$template = $this->_data['template'];
179
+			$dtts = $data->registrations[ $registration->ID() ]['dtt_objs'];
180
+			$data = $this->_data;
181
+		} elseif ($this->_data['data'] instanceof EE_Event) {
182
+			$valid_shortcodes = array('datetime', 'attendee');
183
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
184
+				? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
185
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
186
+			$data = $this->_extra_data;
187
+		} else {
188
+			return '';
189
+		}
190
+
191
+		$dtt_parsed = '';
192
+		foreach ($dtts as $datetime) {
193
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
194
+				$template,
195
+				$datetime,
196
+				$valid_shortcodes,
197
+				$this->_extra_data
198
+			);
199
+		}
200
+		return $dtt_parsed;
201
+	}
202
+
203
+
204
+	private function _get_datetimes_from_event(EE_Event $event, $reg = null)
205
+	{
206
+		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[ $event->ID(
207
+		) ]['dtt_objs'] : array();
208
+
209
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
210
+			$adj_dtts = array();
211
+			// return only dtts for the given attendee
212
+			foreach ($evt_dtts as $dtt) {
213
+				if (isset($this->_extra_data['data']->registrations[ $reg->ID() ]['dtt_objs'][ $dtt->ID() ])) {
214
+					$adj_dtts[] = $dtt;
215
+				}
216
+			}
217
+			$evt_dtts = $adj_dtts;
218
+		}
219
+		return $evt_dtts;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Attendee_Shortcodes.lib.php 2 patches
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -15,201 +15,201 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Attendee_Shortcodes extends EE_Shortcodes
17 17
 {
18
-    /**
19
-     * hold all extra data.
20
-     *
21
-     * @var array|stdClass|null
22
-     */
23
-    protected $_extra;
24
-
25
-
26
-    protected function _init_props()
27
-    {
28
-        $this->label       = esc_html__('Attendee Shortcodes', 'event_espresso');
29
-        $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso');
30
-        $this->_shortcodes = [
31
-            '[FNAME]'                          => esc_html__('First Name of an attendee.', 'event_espresso'),
32
-            '[LNAME]'                          => esc_html__('Last Name of an attendee.', 'event_espresso'),
33
-            '[ATTENDEE_EMAIL]'                 => esc_html__('Email address for the attendee.', 'event_espresso'),
34
-            '[EDIT_ATTENDEE_LINK]'             => esc_html__(
35
-                'Edit Registration Link (typically you\'d only use this for messages going to event administrators)',
36
-                'event_espresso'
37
-            ),
38
-            '[REGISTRATION_ID]'                => esc_html__(
39
-                'Unique Registration ID for the registration',
40
-                'event_espresso'
41
-            ),
42
-            '[REGISTRATION_CODE]'              => esc_html__(
43
-                'Unique Registration Code for the registration',
44
-                'event_espresso'
45
-            ),
46
-            '[REGISTRATION_STATUS_ID]'         => esc_html__(
47
-                'Parses to the registration status for the attendee',
48
-                'event_espresso'
49
-            ),
50
-            '[REGISTRATION_STATUS_LABEL]'      => esc_html__(
51
-                'Parses to the status label for the registrant',
52
-                'event_espresso'
53
-            ),
54
-            '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__(
55
-                'Parses to the total amount paid for this registration.',
56
-                'event_espresso'
57
-            ),
58
-            '[FRONTEND_EDIT_REG_LINK]'         => esc_html__(
59
-                'Generates a link for the given registration to edit this registration details on the frontend.',
60
-                'event_espresso'
61
-            ),
62
-            '[PHONE_NUMBER]'                   => esc_html__(
63
-                'The Phone Number for the Registration.',
64
-                'event_espresso'
65
-            ),
66
-            '[ADDRESS]'                        => esc_html__('The Address for the Registration', 'event_espresso'),
67
-            '[ADDRESS2]'                       => esc_html__(
68
-                'Whatever was in the address 2 field for the registration.',
69
-                'event_espresso'
70
-            ),
71
-            '[CITY]'                           => esc_html__('The city for the registration.', 'event_espresso'),
72
-            '[ZIP_PC]'                         => esc_html__(
73
-                'The ZIP (or Postal) Code for the Registration.',
74
-                'event_espresso'
75
-            ),
76
-            '[ADDRESS_STATE]'                  => esc_html__(
77
-                'The state/province for the registration.',
78
-                'event_espresso'
79
-            ),
80
-            '[COUNTRY]'                        => esc_html__('The country for the registration.', 'event_espresso'),
81
-        ];
82
-    }
83
-
84
-
85
-    /**
86
-     * handles shortcode parsing
87
-     *
88
-     * @param string $shortcode the shortcode to be parsed.
89
-     * @return string
90
-     * @throws EE_Error
91
-     * @throws ReflectionException
92
-     */
93
-    protected function _parser($shortcode)
94
-    {
95
-        $this->_extra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
96
-            ? $this->_extra_data['data']
97
-            : null;
98
-
99
-        $registration = $this->getRegistration();
100
-        $attendee     = $this->getAttendee($registration);
101
-
102
-        switch ($shortcode) {
103
-            case '[FNAME]':
104
-                return $attendee->fname();
105
-
106
-            case '[LNAME]':
107
-                return $attendee->lname();
108
-
109
-            case '[ATTENDEE_EMAIL]':
110
-                return $attendee->email();
111
-
112
-            case '[EDIT_ATTENDEE_LINK]':
113
-                return $registration->get_admin_edit_url();
114
-
115
-            case '[REGISTRATION_CODE]':
116
-                return $registration->reg_code();
117
-
118
-            case '[REGISTRATION_ID]':
119
-                return $registration->ID();
120
-
121
-            case '[FRONTEND_EDIT_REG_LINK]':
122
-                return $registration->edit_attendee_information_url();
123
-
124
-            case '[PHONE_NUMBER]':
125
-                return $attendee->phone();
126
-
127
-            case '[ADDRESS]':
128
-                return $attendee->address();
129
-
130
-            case '[ADDRESS2]':
131
-                return $attendee->address2();
132
-
133
-            case '[CITY]':
134
-                return $attendee->city();
135
-
136
-            case '[ZIP_PC]':
137
-                return $attendee->zip();
138
-
139
-            case '[ADDRESS_STATE]':
140
-                $state_obj = $attendee->state_obj();
141
-                return $state_obj instanceof EE_State ? $state_obj->name() : '';
142
-
143
-            case '[COUNTRY]':
144
-                $country_obj = $attendee->country_obj();
145
-                return $country_obj instanceof EE_Country ? $country_obj->name() : '';
146
-
147
-            case '[REGISTRATION_STATUS_ID]':
148
-                return $registration->status_ID();
149
-
150
-            case '[REGISTRATION_STATUS_LABEL]':
151
-                return $registration->pretty_status();
152
-
153
-            case '[REGISTRATION_TOTAL_AMOUNT_PAID]':
154
-                return $registration->pretty_paid();
155
-        }
156
-
157
-        return '';
158
-    }
159
-
160
-
161
-    /**
162
-     * @return EE_Registration
163
-     * @throws EE_Error
164
-     * @since 5.0.20.p
165
-     */
166
-    private function getRegistration(): EE_Registration
167
-    {
168
-        // incoming object should only be a registration object.
169
-        if ($this->_data instanceof EE_Registration) {
170
-            return $this->_data;
171
-        }
172
-        // let's attempt to get the txn_id for the error message.
173
-        $txn_id  = isset($this->_extra->txn) && $this->_extra->txn instanceof EE_Transaction
174
-            ? $this->_extra->txn->ID()
175
-            : esc_html__('Unknown', 'event_espresso');
176
-        $msg     = esc_html__(
177
-            'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.',
178
-            'event_espresso'
179
-        );
180
-        $dev_msg = sprintf(
181
-            esc_html__('The transaction ID for this request is: %s', 'event_espresso'),
182
-            $txn_id
183
-        );
184
-        throw new EE_Error("$msg||$msg $dev_msg");
185
-    }
186
-
187
-
188
-    /**
189
-     * @param EE_Registration $registration
190
-     * @return EE_Attendee
191
-     * @throws EE_Error
192
-     * @throws ReflectionException
193
-     * @since 5.0.20.p
194
-     */
195
-    private function getAttendee(EE_Registration $registration): EE_Attendee
196
-    {
197
-        // attendee obj for this registration
198
-        if (
199
-            isset($this->_extra->registrations[ $registration->ID() ]['att_obj'])
200
-            && $this->_extra->registrations[ $registration->ID() ]['att_obj'] instanceof EE_Attendee
201
-        ) {
202
-            return $this->_extra->registrations[ $registration->ID() ]['att_obj'];
203
-        }
204
-
205
-        $msg     = esc_html__(
206
-            'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.',
207
-            'event_espresso'
208
-        );
209
-        $dev_msg = sprintf(
210
-            esc_html__('The registration ID for this request is: %s', 'event_espresso'),
211
-            $registration->ID()
212
-        );
213
-        throw new EE_Error("$msg||$msg $dev_msg");
214
-    }
18
+	/**
19
+	 * hold all extra data.
20
+	 *
21
+	 * @var array|stdClass|null
22
+	 */
23
+	protected $_extra;
24
+
25
+
26
+	protected function _init_props()
27
+	{
28
+		$this->label       = esc_html__('Attendee Shortcodes', 'event_espresso');
29
+		$this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso');
30
+		$this->_shortcodes = [
31
+			'[FNAME]'                          => esc_html__('First Name of an attendee.', 'event_espresso'),
32
+			'[LNAME]'                          => esc_html__('Last Name of an attendee.', 'event_espresso'),
33
+			'[ATTENDEE_EMAIL]'                 => esc_html__('Email address for the attendee.', 'event_espresso'),
34
+			'[EDIT_ATTENDEE_LINK]'             => esc_html__(
35
+				'Edit Registration Link (typically you\'d only use this for messages going to event administrators)',
36
+				'event_espresso'
37
+			),
38
+			'[REGISTRATION_ID]'                => esc_html__(
39
+				'Unique Registration ID for the registration',
40
+				'event_espresso'
41
+			),
42
+			'[REGISTRATION_CODE]'              => esc_html__(
43
+				'Unique Registration Code for the registration',
44
+				'event_espresso'
45
+			),
46
+			'[REGISTRATION_STATUS_ID]'         => esc_html__(
47
+				'Parses to the registration status for the attendee',
48
+				'event_espresso'
49
+			),
50
+			'[REGISTRATION_STATUS_LABEL]'      => esc_html__(
51
+				'Parses to the status label for the registrant',
52
+				'event_espresso'
53
+			),
54
+			'[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__(
55
+				'Parses to the total amount paid for this registration.',
56
+				'event_espresso'
57
+			),
58
+			'[FRONTEND_EDIT_REG_LINK]'         => esc_html__(
59
+				'Generates a link for the given registration to edit this registration details on the frontend.',
60
+				'event_espresso'
61
+			),
62
+			'[PHONE_NUMBER]'                   => esc_html__(
63
+				'The Phone Number for the Registration.',
64
+				'event_espresso'
65
+			),
66
+			'[ADDRESS]'                        => esc_html__('The Address for the Registration', 'event_espresso'),
67
+			'[ADDRESS2]'                       => esc_html__(
68
+				'Whatever was in the address 2 field for the registration.',
69
+				'event_espresso'
70
+			),
71
+			'[CITY]'                           => esc_html__('The city for the registration.', 'event_espresso'),
72
+			'[ZIP_PC]'                         => esc_html__(
73
+				'The ZIP (or Postal) Code for the Registration.',
74
+				'event_espresso'
75
+			),
76
+			'[ADDRESS_STATE]'                  => esc_html__(
77
+				'The state/province for the registration.',
78
+				'event_espresso'
79
+			),
80
+			'[COUNTRY]'                        => esc_html__('The country for the registration.', 'event_espresso'),
81
+		];
82
+	}
83
+
84
+
85
+	/**
86
+	 * handles shortcode parsing
87
+	 *
88
+	 * @param string $shortcode the shortcode to be parsed.
89
+	 * @return string
90
+	 * @throws EE_Error
91
+	 * @throws ReflectionException
92
+	 */
93
+	protected function _parser($shortcode)
94
+	{
95
+		$this->_extra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
96
+			? $this->_extra_data['data']
97
+			: null;
98
+
99
+		$registration = $this->getRegistration();
100
+		$attendee     = $this->getAttendee($registration);
101
+
102
+		switch ($shortcode) {
103
+			case '[FNAME]':
104
+				return $attendee->fname();
105
+
106
+			case '[LNAME]':
107
+				return $attendee->lname();
108
+
109
+			case '[ATTENDEE_EMAIL]':
110
+				return $attendee->email();
111
+
112
+			case '[EDIT_ATTENDEE_LINK]':
113
+				return $registration->get_admin_edit_url();
114
+
115
+			case '[REGISTRATION_CODE]':
116
+				return $registration->reg_code();
117
+
118
+			case '[REGISTRATION_ID]':
119
+				return $registration->ID();
120
+
121
+			case '[FRONTEND_EDIT_REG_LINK]':
122
+				return $registration->edit_attendee_information_url();
123
+
124
+			case '[PHONE_NUMBER]':
125
+				return $attendee->phone();
126
+
127
+			case '[ADDRESS]':
128
+				return $attendee->address();
129
+
130
+			case '[ADDRESS2]':
131
+				return $attendee->address2();
132
+
133
+			case '[CITY]':
134
+				return $attendee->city();
135
+
136
+			case '[ZIP_PC]':
137
+				return $attendee->zip();
138
+
139
+			case '[ADDRESS_STATE]':
140
+				$state_obj = $attendee->state_obj();
141
+				return $state_obj instanceof EE_State ? $state_obj->name() : '';
142
+
143
+			case '[COUNTRY]':
144
+				$country_obj = $attendee->country_obj();
145
+				return $country_obj instanceof EE_Country ? $country_obj->name() : '';
146
+
147
+			case '[REGISTRATION_STATUS_ID]':
148
+				return $registration->status_ID();
149
+
150
+			case '[REGISTRATION_STATUS_LABEL]':
151
+				return $registration->pretty_status();
152
+
153
+			case '[REGISTRATION_TOTAL_AMOUNT_PAID]':
154
+				return $registration->pretty_paid();
155
+		}
156
+
157
+		return '';
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return EE_Registration
163
+	 * @throws EE_Error
164
+	 * @since 5.0.20.p
165
+	 */
166
+	private function getRegistration(): EE_Registration
167
+	{
168
+		// incoming object should only be a registration object.
169
+		if ($this->_data instanceof EE_Registration) {
170
+			return $this->_data;
171
+		}
172
+		// let's attempt to get the txn_id for the error message.
173
+		$txn_id  = isset($this->_extra->txn) && $this->_extra->txn instanceof EE_Transaction
174
+			? $this->_extra->txn->ID()
175
+			: esc_html__('Unknown', 'event_espresso');
176
+		$msg     = esc_html__(
177
+			'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.',
178
+			'event_espresso'
179
+		);
180
+		$dev_msg = sprintf(
181
+			esc_html__('The transaction ID for this request is: %s', 'event_espresso'),
182
+			$txn_id
183
+		);
184
+		throw new EE_Error("$msg||$msg $dev_msg");
185
+	}
186
+
187
+
188
+	/**
189
+	 * @param EE_Registration $registration
190
+	 * @return EE_Attendee
191
+	 * @throws EE_Error
192
+	 * @throws ReflectionException
193
+	 * @since 5.0.20.p
194
+	 */
195
+	private function getAttendee(EE_Registration $registration): EE_Attendee
196
+	{
197
+		// attendee obj for this registration
198
+		if (
199
+			isset($this->_extra->registrations[ $registration->ID() ]['att_obj'])
200
+			&& $this->_extra->registrations[ $registration->ID() ]['att_obj'] instanceof EE_Attendee
201
+		) {
202
+			return $this->_extra->registrations[ $registration->ID() ]['att_obj'];
203
+		}
204
+
205
+		$msg     = esc_html__(
206
+			'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.',
207
+			'event_espresso'
208
+		);
209
+		$dev_msg = sprintf(
210
+			esc_html__('The registration ID for this request is: %s', 'event_espresso'),
211
+			$registration->ID()
212
+		);
213
+		throw new EE_Error("$msg||$msg $dev_msg");
214
+	}
215 215
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -196,13 +196,13 @@
 block discarded – undo
196 196
     {
197 197
         // attendee obj for this registration
198 198
         if (
199
-            isset($this->_extra->registrations[ $registration->ID() ]['att_obj'])
200
-            && $this->_extra->registrations[ $registration->ID() ]['att_obj'] instanceof EE_Attendee
199
+            isset($this->_extra->registrations[$registration->ID()]['att_obj'])
200
+            && $this->_extra->registrations[$registration->ID()]['att_obj'] instanceof EE_Attendee
201 201
         ) {
202
-            return $this->_extra->registrations[ $registration->ID() ]['att_obj'];
202
+            return $this->_extra->registrations[$registration->ID()]['att_obj'];
203 203
         }
204 204
 
205
-        $msg     = esc_html__(
205
+        $msg = esc_html__(
206 206
             'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.',
207 207
             'event_espresso'
208 208
         );
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Datetime_Shortcodes.lib.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -15,76 +15,76 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Datetime_Shortcodes extends EE_Shortcodes
17 17
 {
18
-    /**
19
-     * @return void
20
-     */
21
-    protected function _init_props()
22
-    {
23
-        $this->label = esc_html__('Datetime Shortcodes', 'event_espresso');
24
-        $this->description = esc_html__('All shortcodes specific to datetime related data', 'event_espresso');
25
-        $this->_shortcodes = array(
26
-            '[DATETIME_START]' => esc_html__('The start date and time.', 'event_espresso'),
27
-            '[DATETIME_END]' => esc_html__('The end date and time.', 'event_espresso'),
28
-            '[DATETIME_TIMEZONE]' => esc_html__('The timezone for the date and time', 'event_espresso'),
29
-            '[DATE_START]' => esc_html__('The datetime start date.', 'event_espresso'),
30
-            '[DATE_END]' => esc_html__('The datetime end date.', 'event_espresso'),
31
-            '[TIME_START]' => esc_html__('The datetime start time.', 'event_espresso'),
32
-            '[TIME_END]' => esc_html__('The datetime end time.', 'event_espresso'),
33
-            '[ICAL_LINK_*]' => esc_html__(
34
-                'The datetime iCal link. The optional "link_text" attribute can be used to set custom text within the link (Default is "Add to iCal Calendar").',
35
-                'event_espresso'
36
-            ),
37
-        );
38
-    }
39
-
40
-
41
-    /**
42
-     * @param string $shortcode
43
-     * @return string
44
-     * @throws EE_Error
45
-     * @throws ReflectionException
46
-     */
47
-    protected function _parser($shortcode)
48
-    {
49
-        if (! $this->_data instanceof EE_Datetime) {
50
-            return ''; // get out cause we can only parse with the datetime object.
51
-        }
52
-
53
-        switch ($shortcode) {
54
-            case '[DATETIME_START]':
55
-                return $this->_data->get_i18n_datetime('DTT_EVT_start');
56
-
57
-            case '[DATETIME_END]':
58
-                return $this->_data->get_i18n_datetime('DTT_EVT_end');
59
-
60
-            case '[DATETIME_TIMEZONE]':
61
-                return $this->_data->get_timezone();
62
-
63
-            case '[DATE_START]':
64
-                return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('date_format'));
65
-
66
-            case '[DATE_END]':
67
-                return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('date_format'));
68
-
69
-            case '[TIME_START]':
70
-                return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('time_format'));
71
-
72
-            case '[TIME_END]':
73
-                return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('time_format'));
74
-
75
-        }
76
-
77
-        if (strpos($shortcode, '[ICAL_LINK_*') !== false) {
78
-            $attrs = $this->_get_shortcode_attrs($shortcode);
79
-
80
-            $link_text = empty($attrs['link_text']) ? esc_html__('Add to iCal Calendar', 'event_espresso')
81
-                : $attrs['link_text'];
82
-
83
-            $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url());
84
-
85
-            return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>';
86
-        }
87
-
88
-        return '';
89
-    }
18
+	/**
19
+	 * @return void
20
+	 */
21
+	protected function _init_props()
22
+	{
23
+		$this->label = esc_html__('Datetime Shortcodes', 'event_espresso');
24
+		$this->description = esc_html__('All shortcodes specific to datetime related data', 'event_espresso');
25
+		$this->_shortcodes = array(
26
+			'[DATETIME_START]' => esc_html__('The start date and time.', 'event_espresso'),
27
+			'[DATETIME_END]' => esc_html__('The end date and time.', 'event_espresso'),
28
+			'[DATETIME_TIMEZONE]' => esc_html__('The timezone for the date and time', 'event_espresso'),
29
+			'[DATE_START]' => esc_html__('The datetime start date.', 'event_espresso'),
30
+			'[DATE_END]' => esc_html__('The datetime end date.', 'event_espresso'),
31
+			'[TIME_START]' => esc_html__('The datetime start time.', 'event_espresso'),
32
+			'[TIME_END]' => esc_html__('The datetime end time.', 'event_espresso'),
33
+			'[ICAL_LINK_*]' => esc_html__(
34
+				'The datetime iCal link. The optional "link_text" attribute can be used to set custom text within the link (Default is "Add to iCal Calendar").',
35
+				'event_espresso'
36
+			),
37
+		);
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param string $shortcode
43
+	 * @return string
44
+	 * @throws EE_Error
45
+	 * @throws ReflectionException
46
+	 */
47
+	protected function _parser($shortcode)
48
+	{
49
+		if (! $this->_data instanceof EE_Datetime) {
50
+			return ''; // get out cause we can only parse with the datetime object.
51
+		}
52
+
53
+		switch ($shortcode) {
54
+			case '[DATETIME_START]':
55
+				return $this->_data->get_i18n_datetime('DTT_EVT_start');
56
+
57
+			case '[DATETIME_END]':
58
+				return $this->_data->get_i18n_datetime('DTT_EVT_end');
59
+
60
+			case '[DATETIME_TIMEZONE]':
61
+				return $this->_data->get_timezone();
62
+
63
+			case '[DATE_START]':
64
+				return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('date_format'));
65
+
66
+			case '[DATE_END]':
67
+				return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('date_format'));
68
+
69
+			case '[TIME_START]':
70
+				return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('time_format'));
71
+
72
+			case '[TIME_END]':
73
+				return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('time_format'));
74
+
75
+		}
76
+
77
+		if (strpos($shortcode, '[ICAL_LINK_*') !== false) {
78
+			$attrs = $this->_get_shortcode_attrs($shortcode);
79
+
80
+			$link_text = empty($attrs['link_text']) ? esc_html__('Add to iCal Calendar', 'event_espresso')
81
+				: $attrs['link_text'];
82
+
83
+			$URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url());
84
+
85
+			return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>';
86
+		}
87
+
88
+		return '';
89
+	}
90 90
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     protected function _parser($shortcode)
48 48
     {
49
-        if (! $this->_data instanceof EE_Datetime) {
49
+        if ( ! $this->_data instanceof EE_Datetime) {
50 50
             return ''; // get out cause we can only parse with the datetime object.
51 51
         }
52 52
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
             $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url());
84 84
 
85
-            return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>';
85
+            return '<a class="ee-ical" href="'.$URL.'">'.$link_text.'</a>';
86 86
         }
87 87
 
88 88
         return '';
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Ticket_List_Shortcodes.lib.php 1 patch
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -18,203 +18,203 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Ticket_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    protected function _init_props()
22
-    {
23
-        $this->label       = esc_html__('Ticket List Shortcodes', 'event_espresso');
24
-        $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
25
-        $this->_shortcodes = [
26
-            '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
27
-        ];
28
-    }
29
-
30
-
31
-    /**
32
-     * @param string $shortcode
33
-     * @return string
34
-     * @throws EE_Error
35
-     * @throws ReflectionException
36
-     */
37
-    protected function _parser($shortcode)
38
-    {
39
-        if ($shortcode == '[TICKET_LIST]') {
40
-            return $this->_get_ticket_list();
41
-        }
42
-        return '';
43
-    }
44
-
45
-
46
-    /**
47
-     * figure out what the incoming data is and then return the appropriate parsed value.
48
-     *
49
-     * @return string
50
-     * @throws EE_Error
51
-     * @throws ReflectionException
52
-     */
53
-    private function _get_ticket_list()
54
-    {
55
-        $this->_validate_list_requirements();
56
-
57
-        if ($this->_data['data'] instanceof EE_Messages_Addressee) {
58
-            return $this->_get_ticket_list_for_main();
59
-        }
60
-        if ($this->_data['data'] instanceof EE_Registration) {
61
-            return $this->_get_ticket_list_for_attendee();
62
-        }
63
-        if ($this->_data['data'] instanceof EE_Event) {
64
-            return $this->_get_ticket_list_for_event();
65
-        }
66
-        // prevent recursive loop
67
-        return '';
68
-    }
69
-
70
-
71
-    /**
72
-     * This returns the parsed ticket list for main template;
73
-     */
74
-    private function _get_ticket_list_for_main()
75
-    {
76
-        $valid_shortcodes = [
77
-            'ticket',
78
-            'event_list',
79
-            'attendee_list',
80
-            'datetime_list',
81
-            'attendee',
82
-            'line_item_list',
83
-            'primary_registration_details',
84
-            'recipient_details',
85
-        ];
86
-        $template         = $this->_data['template'];
87
-        $data             = $this->_data['data'];
88
-        $ticket_list      = '';
89
-
90
-
91
-        // now we need to loop through the ticket list and send data to the EE_Parser helper.
92
-        foreach ($data->tickets as $ticket) {
93
-            $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template(
94
-                $template,
95
-                $ticket['ticket'],
96
-                $valid_shortcodes,
97
-                $this->_extra_data
98
-            );
99
-        }
100
-
101
-        return $ticket_list;
102
-    }
103
-
104
-
105
-    /**
106
-     * return parsed list of tickets for an event
107
-     *
108
-     * @return string
109
-     * @throws EE_Error
110
-     * @throws ReflectionException
111
-     */
112
-    private function _get_ticket_list_for_event()
113
-    {
114
-        $valid_shortcodes = [
115
-            'ticket',
116
-            'attendee_list',
117
-            'datetime_list',
118
-            'attendee',
119
-            'venue',
120
-            'line_item_list',
121
-            'primary_registration_details',
122
-            'recipient_details',
123
-        ];
124
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
125
-            ? $this->_data['template']['ticket_list']
126
-            : $this->_extra_data['template']['ticket_list'];
127
-        $event            = $this->_data['data'];
128
-
129
-        // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
130
-        $template = str_replace('[EVENT_LIST]', '', $template);
131
-
132
-        // here we're setting up the tickets for the ticket list template for THIS event.
133
-        $tkt_parsed = '';
134
-        $tickets    = $this->_get_tickets_from_event($event);
135
-
136
-        // each ticket in this case should be an ticket object.
137
-        foreach ($tickets as $ticket) {
138
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
139
-                $template,
140
-                $ticket,
141
-                $valid_shortcodes,
142
-                $this->_extra_data
143
-            );
144
-        }
145
-
146
-        return $tkt_parsed;
147
-    }
148
-
149
-
150
-    /**
151
-     * return parsed list of tickets for an attendee
152
-     *
153
-     * @return string
154
-     * @throws EE_Error
155
-     * @throws ReflectionException
156
-     */
157
-    private function _get_ticket_list_for_attendee()
158
-    {
159
-        $valid_shortcodes = [
160
-            'ticket',
161
-            'event_list',
162
-            'datetime_list',
163
-            'attendee',
164
-            'primary_registration_details',
165
-            'recipient_details',
166
-        ];
167
-
168
-        $template     = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
169
-            ? $this->_data['template']['ticket_list']
170
-            : $this->_extra_data['template']['ticket_list'];
171
-        $registration = $this->_data['data'];
172
-
173
-        // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
174
-        $template = str_replace('[ATTENDEE_LIST]', '', $template);
175
-
176
-        // here we're setting up the tickets for the ticket list template for THIS attendee.
177
-        $tkt_parsed = '';
178
-        $tickets    = $this->_get_ticket_list_from_registration($registration);
179
-
180
-        // each ticket in this case should be an ticket object.
181
-        foreach ($tickets as $ticket) {
182
-            $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
183
-                $template,
184
-                $ticket,
185
-                $valid_shortcodes,
186
-                $this->_extra_data
187
-            );
188
-        }
189
-
190
-        return $tkt_parsed;
191
-    }
192
-
193
-
194
-    /**
195
-     * @param EE_Event $event
196
-     * @return array|mixed
197
-     * @throws EE_Error
198
-     * @throws ReflectionException
199
-     */
200
-    private function _get_tickets_from_event(EE_Event $event)
201
-    {
202
-        return isset($this->_extra_data['data']->events)
203
-            ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs']
204
-            : [];
205
-    }
206
-
207
-
208
-    /**
209
-     * @param EE_Registration $registration
210
-     * @return array
211
-     * @throws EE_Error
212
-     * @throws ReflectionException
213
-     */
214
-    private function _get_ticket_list_from_registration(EE_Registration $registration)
215
-    {
216
-        return isset($this->_extra_data['data']->registrations)
217
-            ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']]
218
-            : [];
219
-    }
21
+	protected function _init_props()
22
+	{
23
+		$this->label       = esc_html__('Ticket List Shortcodes', 'event_espresso');
24
+		$this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso');
25
+		$this->_shortcodes = [
26
+			'[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'),
27
+		];
28
+	}
29
+
30
+
31
+	/**
32
+	 * @param string $shortcode
33
+	 * @return string
34
+	 * @throws EE_Error
35
+	 * @throws ReflectionException
36
+	 */
37
+	protected function _parser($shortcode)
38
+	{
39
+		if ($shortcode == '[TICKET_LIST]') {
40
+			return $this->_get_ticket_list();
41
+		}
42
+		return '';
43
+	}
44
+
45
+
46
+	/**
47
+	 * figure out what the incoming data is and then return the appropriate parsed value.
48
+	 *
49
+	 * @return string
50
+	 * @throws EE_Error
51
+	 * @throws ReflectionException
52
+	 */
53
+	private function _get_ticket_list()
54
+	{
55
+		$this->_validate_list_requirements();
56
+
57
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
58
+			return $this->_get_ticket_list_for_main();
59
+		}
60
+		if ($this->_data['data'] instanceof EE_Registration) {
61
+			return $this->_get_ticket_list_for_attendee();
62
+		}
63
+		if ($this->_data['data'] instanceof EE_Event) {
64
+			return $this->_get_ticket_list_for_event();
65
+		}
66
+		// prevent recursive loop
67
+		return '';
68
+	}
69
+
70
+
71
+	/**
72
+	 * This returns the parsed ticket list for main template;
73
+	 */
74
+	private function _get_ticket_list_for_main()
75
+	{
76
+		$valid_shortcodes = [
77
+			'ticket',
78
+			'event_list',
79
+			'attendee_list',
80
+			'datetime_list',
81
+			'attendee',
82
+			'line_item_list',
83
+			'primary_registration_details',
84
+			'recipient_details',
85
+		];
86
+		$template         = $this->_data['template'];
87
+		$data             = $this->_data['data'];
88
+		$ticket_list      = '';
89
+
90
+
91
+		// now we need to loop through the ticket list and send data to the EE_Parser helper.
92
+		foreach ($data->tickets as $ticket) {
93
+			$ticket_list .= $this->_shortcode_helper->parse_ticket_list_template(
94
+				$template,
95
+				$ticket['ticket'],
96
+				$valid_shortcodes,
97
+				$this->_extra_data
98
+			);
99
+		}
100
+
101
+		return $ticket_list;
102
+	}
103
+
104
+
105
+	/**
106
+	 * return parsed list of tickets for an event
107
+	 *
108
+	 * @return string
109
+	 * @throws EE_Error
110
+	 * @throws ReflectionException
111
+	 */
112
+	private function _get_ticket_list_for_event()
113
+	{
114
+		$valid_shortcodes = [
115
+			'ticket',
116
+			'attendee_list',
117
+			'datetime_list',
118
+			'attendee',
119
+			'venue',
120
+			'line_item_list',
121
+			'primary_registration_details',
122
+			'recipient_details',
123
+		];
124
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
125
+			? $this->_data['template']['ticket_list']
126
+			: $this->_extra_data['template']['ticket_list'];
127
+		$event            = $this->_data['data'];
128
+
129
+		// let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion.
130
+		$template = str_replace('[EVENT_LIST]', '', $template);
131
+
132
+		// here we're setting up the tickets for the ticket list template for THIS event.
133
+		$tkt_parsed = '';
134
+		$tickets    = $this->_get_tickets_from_event($event);
135
+
136
+		// each ticket in this case should be an ticket object.
137
+		foreach ($tickets as $ticket) {
138
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
139
+				$template,
140
+				$ticket,
141
+				$valid_shortcodes,
142
+				$this->_extra_data
143
+			);
144
+		}
145
+
146
+		return $tkt_parsed;
147
+	}
148
+
149
+
150
+	/**
151
+	 * return parsed list of tickets for an attendee
152
+	 *
153
+	 * @return string
154
+	 * @throws EE_Error
155
+	 * @throws ReflectionException
156
+	 */
157
+	private function _get_ticket_list_for_attendee()
158
+	{
159
+		$valid_shortcodes = [
160
+			'ticket',
161
+			'event_list',
162
+			'datetime_list',
163
+			'attendee',
164
+			'primary_registration_details',
165
+			'recipient_details',
166
+		];
167
+
168
+		$template     = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list'])
169
+			? $this->_data['template']['ticket_list']
170
+			: $this->_extra_data['template']['ticket_list'];
171
+		$registration = $this->_data['data'];
172
+
173
+		// let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion.
174
+		$template = str_replace('[ATTENDEE_LIST]', '', $template);
175
+
176
+		// here we're setting up the tickets for the ticket list template for THIS attendee.
177
+		$tkt_parsed = '';
178
+		$tickets    = $this->_get_ticket_list_from_registration($registration);
179
+
180
+		// each ticket in this case should be an ticket object.
181
+		foreach ($tickets as $ticket) {
182
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template(
183
+				$template,
184
+				$ticket,
185
+				$valid_shortcodes,
186
+				$this->_extra_data
187
+			);
188
+		}
189
+
190
+		return $tkt_parsed;
191
+	}
192
+
193
+
194
+	/**
195
+	 * @param EE_Event $event
196
+	 * @return array|mixed
197
+	 * @throws EE_Error
198
+	 * @throws ReflectionException
199
+	 */
200
+	private function _get_tickets_from_event(EE_Event $event)
201
+	{
202
+		return isset($this->_extra_data['data']->events)
203
+			? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs']
204
+			: [];
205
+	}
206
+
207
+
208
+	/**
209
+	 * @param EE_Registration $registration
210
+	 * @return array
211
+	 * @throws EE_Error
212
+	 * @throws ReflectionException
213
+	 */
214
+	private function _get_ticket_list_from_registration(EE_Registration $registration)
215
+	{
216
+		return isset($this->_extra_data['data']->registrations)
217
+			? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']]
218
+			: [];
219
+	}
220 220
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Ticket_Shortcodes.lib.php 2 patches
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -15,133 +15,133 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Ticket_Shortcodes extends EE_Shortcodes
17 17
 {
18
-    /**
19
-     * Will hold the EE_Ticket if available
20
-     *
21
-     * @var EE_Ticket|null
22
-     */
23
-    protected ?EE_Ticket $_ticket = null;
24
-
25
-
26
-    protected function _init_props()
27
-    {
28
-        $this->label       = esc_html__('Ticket Shortcodes', 'event_espresso');
29
-        $this->description = esc_html__('All shortcodes specific to ticket related data', 'event_espresso');
30
-        $this->_shortcodes = [
31
-            '[TICKET_ID]'               => esc_html__(
32
-                'Will be replaced by the ticket ID of a ticket',
33
-                'event_espresso'
34
-            ),
35
-            '[TICKET_NAME]'             => esc_html__('The name of the ticket', 'event_espresso'),
36
-            '[TICKET_DESCRIPTION]'      => esc_html__('The description of the ticket', 'event_espresso'),
37
-            '[TICKET_PRICE]'            => esc_html__('The price of the ticket', 'event_espresso'),
38
-            '[TICKET_PRICE_WITH_TAXES]' => esc_html__(
39
-                'The price of the ticket including any taxes that might be on the ticket',
40
-                'event_espresso'
41
-            ),
42
-            '[TKT_QTY_PURCHASED]'       => esc_html__(
43
-                'The total quantity of the current ticket in the list that has been purchased in this transaction',
44
-                'event_espresso'
45
-            ),
46
-            '[TKT_USES_*]'              => esc_html__(
47
-                    'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
48
-                    'event_espresso'
49
-                ) . '
18
+	/**
19
+	 * Will hold the EE_Ticket if available
20
+	 *
21
+	 * @var EE_Ticket|null
22
+	 */
23
+	protected ?EE_Ticket $_ticket = null;
24
+
25
+
26
+	protected function _init_props()
27
+	{
28
+		$this->label       = esc_html__('Ticket Shortcodes', 'event_espresso');
29
+		$this->description = esc_html__('All shortcodes specific to ticket related data', 'event_espresso');
30
+		$this->_shortcodes = [
31
+			'[TICKET_ID]'               => esc_html__(
32
+				'Will be replaced by the ticket ID of a ticket',
33
+				'event_espresso'
34
+			),
35
+			'[TICKET_NAME]'             => esc_html__('The name of the ticket', 'event_espresso'),
36
+			'[TICKET_DESCRIPTION]'      => esc_html__('The description of the ticket', 'event_espresso'),
37
+			'[TICKET_PRICE]'            => esc_html__('The price of the ticket', 'event_espresso'),
38
+			'[TICKET_PRICE_WITH_TAXES]' => esc_html__(
39
+				'The price of the ticket including any taxes that might be on the ticket',
40
+				'event_espresso'
41
+			),
42
+			'[TKT_QTY_PURCHASED]'       => esc_html__(
43
+				'The total quantity of the current ticket in the list that has been purchased in this transaction',
44
+				'event_espresso'
45
+			),
46
+			'[TKT_USES_*]'              => esc_html__(
47
+					'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
48
+					'event_espresso'
49
+				) . '
50 50
         <ul>
51 51
             <li>
52 52
                 <strong>symbol</strong>:' . esc_html__(
53
-                    'This returns the &infin; symbol.',
54
-                    'event_espresso'
55
-                ) . '
53
+					'This returns the &infin; symbol.',
54
+					'event_espresso'
55
+				) . '
56 56
             </li>
57 57
             <li>
58 58
                 <strong>text</strong>:' . esc_html__(
59
-                    'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
60
-                    'event_espresso'
61
-                ) . '
59
+					'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
60
+					'event_espresso'
61
+				) . '
62 62
             </li>
63 63
             <li>
64 64
                 <strong>{custom}</strong>:' . esc_html__(
65
-                    'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
66
-                    'event_espresso'
67
-                ) . '
65
+					'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
66
+					'event_espresso'
67
+				) . '
68 68
             </li>
69 69
         </ul>',
70
-        ];
71
-    }
72
-
73
-
74
-    /**
75
-     * @param $shortcode
76
-     * @return int|string
77
-     * @throws EE_Error
78
-     * @throws ReflectionException
79
-     */
80
-    protected function _parser($shortcode)
81
-    {
82
-        $this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null;
83
-
84
-        $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
85
-        $aee = ! $aee instanceof EE_Messages_Addressee
86
-        && is_array($this->_extra_data)
87
-        && isset($this->_extra_data['data'])
88
-        && $this->_extra_data['data'] instanceof EE_Messages_Addressee
89
-            ? $this->_extra_data['data']
90
-            : $aee;
91
-
92
-
93
-        // possible EE_Line_Item may be incoming data
94
-        $this->_ticket = empty($this->_ticket)
95
-        && $this->_data instanceof EE_Line_Item
96
-        && $aee instanceof EE_Messages_Addressee
97
-        && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
98
-        && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
99
-            ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
100
-            : $this->_ticket;
101
-
102
-        // if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
103
-        if (empty($this->_ticket)) {
104
-            $this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
105
-                ? $aee->reg_obj->ticket() : null;
106
-        }
107
-
108
-
109
-        // If there is no event object by now then get out.
110
-        if (! $this->_ticket instanceof EE_Ticket) {
111
-            return '';
112
-        }
113
-
114
-        switch ($shortcode) {
115
-            case '[TICKET_ID]':
116
-                return $this->_ticket->ID();
117
-
118
-            case '[TICKET_NAME]':
119
-                return $this->_ticket->get('TKT_name');
120
-
121
-            case '[TICKET_DESCRIPTION]':
122
-                return $this->_ticket->get('TKT_description');
123
-
124
-            case '[TICKET_PRICE]':
125
-                return EEH_Template::format_currency($this->_ticket->get('TKT_price'));
126
-
127
-            case '[TICKET_PRICE_WITH_TAXES]':
128
-                return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
129
-
130
-            case '[TKT_QTY_PURCHASED]':
131
-                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
132
-        }
133
-
134
-        if (strpos($shortcode, '[TKT_USES_*') !== false) {
135
-            $attrs  = $this->_get_shortcode_attrs($shortcode);
136
-            $schema = empty($attrs['schema']) ? null : $attrs['schema'];
137
-            return $this->_ticket->get_pretty('TKT_uses', $schema);
138
-        }
139
-        return '';
140
-    }
141
-
142
-
143
-    public function get_ticket_set(): ?EE_Ticket
144
-    {
145
-        return $this->_ticket;
146
-    }
70
+		];
71
+	}
72
+
73
+
74
+	/**
75
+	 * @param $shortcode
76
+	 * @return int|string
77
+	 * @throws EE_Error
78
+	 * @throws ReflectionException
79
+	 */
80
+	protected function _parser($shortcode)
81
+	{
82
+		$this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null;
83
+
84
+		$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
85
+		$aee = ! $aee instanceof EE_Messages_Addressee
86
+		&& is_array($this->_extra_data)
87
+		&& isset($this->_extra_data['data'])
88
+		&& $this->_extra_data['data'] instanceof EE_Messages_Addressee
89
+			? $this->_extra_data['data']
90
+			: $aee;
91
+
92
+
93
+		// possible EE_Line_Item may be incoming data
94
+		$this->_ticket = empty($this->_ticket)
95
+		&& $this->_data instanceof EE_Line_Item
96
+		&& $aee instanceof EE_Messages_Addressee
97
+		&& ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
98
+		&& $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
99
+			? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
100
+			: $this->_ticket;
101
+
102
+		// if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
103
+		if (empty($this->_ticket)) {
104
+			$this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
105
+				? $aee->reg_obj->ticket() : null;
106
+		}
107
+
108
+
109
+		// If there is no event object by now then get out.
110
+		if (! $this->_ticket instanceof EE_Ticket) {
111
+			return '';
112
+		}
113
+
114
+		switch ($shortcode) {
115
+			case '[TICKET_ID]':
116
+				return $this->_ticket->ID();
117
+
118
+			case '[TICKET_NAME]':
119
+				return $this->_ticket->get('TKT_name');
120
+
121
+			case '[TICKET_DESCRIPTION]':
122
+				return $this->_ticket->get('TKT_description');
123
+
124
+			case '[TICKET_PRICE]':
125
+				return EEH_Template::format_currency($this->_ticket->get('TKT_price'));
126
+
127
+			case '[TICKET_PRICE_WITH_TAXES]':
128
+				return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
129
+
130
+			case '[TKT_QTY_PURCHASED]':
131
+				return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
132
+		}
133
+
134
+		if (strpos($shortcode, '[TKT_USES_*') !== false) {
135
+			$attrs  = $this->_get_shortcode_attrs($shortcode);
136
+			$schema = empty($attrs['schema']) ? null : $attrs['schema'];
137
+			return $this->_ticket->get_pretty('TKT_uses', $schema);
138
+		}
139
+		return '';
140
+	}
141
+
142
+
143
+	public function get_ticket_set(): ?EE_Ticket
144
+	{
145
+		return $this->_ticket;
146
+	}
147 147
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,25 +46,25 @@  discard block
 block discarded – undo
46 46
             '[TKT_USES_*]'              => esc_html__(
47 47
                     'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
48 48
                     'event_espresso'
49
-                ) . '
49
+                ).'
50 50
         <ul>
51 51
             <li>
52 52
                 <strong>symbol</strong>:' . esc_html__(
53 53
                     'This returns the &infin; symbol.',
54 54
                     'event_espresso'
55
-                ) . '
55
+                ).'
56 56
             </li>
57 57
             <li>
58 58
                 <strong>text</strong>:' . esc_html__(
59 59
                     'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
60 60
                     'event_espresso'
61
-                ) . '
61
+                ).'
62 62
             </li>
63 63
             <li>
64 64
                 <strong>{custom}</strong>:' . esc_html__(
65 65
                     'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
66 66
                     'event_espresso'
67
-                ) . '
67
+                ).'
68 68
             </li>
69 69
         </ul>',
70 70
         ];
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
         $this->_ticket = empty($this->_ticket)
95 95
         && $this->_data instanceof EE_Line_Item
96 96
         && $aee instanceof EE_Messages_Addressee
97
-        && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
98
-        && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
99
-            ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
97
+        && ! empty($aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'])
98
+        && $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] instanceof EE_Ticket
99
+            ? $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket']
100 100
             : $this->_ticket;
101 101
 
102 102
         // if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
 
109 109
         // If there is no event object by now then get out.
110
-        if (! $this->_ticket instanceof EE_Ticket) {
110
+        if ( ! $this->_ticket instanceof EE_Ticket) {
111 111
             return '';
112 112
         }
113 113
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                 return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
129 129
 
130 130
             case '[TKT_QTY_PURCHASED]':
131
-                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
131
+                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[$this->_ticket->ID()]['count'] : '';
132 132
         }
133 133
 
134 134
         if (strpos($shortcode, '[TKT_USES_*') !== false) {
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Organization_Shortcodes.lib.php 2 patches
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -17,128 +17,128 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Organization_Shortcodes extends EE_Shortcodes
19 19
 {
20
-    public function __construct()
21
-    {
22
-        parent::__construct();
23
-    }
24
-
25
-
26
-    protected function _init_props()
27
-    {
28
-        $this->label = esc_html__('Organization Shortcodes', 'event_espresso');
29
-        $this->description = esc_html__('All shortcodes specific to organization related data', 'event_espresso');
30
-        $this->_shortcodes = array(
31
-            '[COMPANY]'          => esc_html__('Event organization name', 'event_espresso'),
32
-            '[CO_ADD1]'          => esc_html__('Address 1 value for the organization', 'event_espresso'),
33
-            '[CO_ADD2]'          => esc_html__('Address 2 value for the organization', 'event_espresso'),
34
-            '[CO_CITY]'          => esc_html__('City the organization is in', 'event_espresso'),
35
-            '[CO_STATE]'         => esc_html__('State the organization is located in', 'event_espresso'),
36
-            '[CO_ZIP]'           => esc_html__('The zip code for the organization', 'event_espresso'),
37
-            '[CO_LOGO]'          => esc_html__('The logo image for the organization', 'event_espresso'),
38
-            '[CO_EMAIL]'         => esc_html__('The primary email address for the organization', 'event_espresso'),
39
-            '[CO_PHONE]'         => esc_html__('The phone number for the organization', 'event_espresso'),
40
-            '[CO_LOGO_URL]'      => esc_html__(
41
-                'Just the link to the image used as the logo for the organization',
42
-                'event_espresso'
43
-            ),
44
-            '[CO_FACEBOOK_URL]'  => esc_html__('Link to organization Facebook page', 'event_espresso'),
45
-            '[CO_TWITTER_URL]'   => esc_html__('Link to organization Twitter page', 'event_espresso'),
46
-            '[CO_PINTEREST_URL]' => esc_html__('Link to organization Pinterest page', 'event_espresso'),
47
-            '[CO_GOOGLE_URL]'    => esc_html__('Link to organization Google page', 'event_espresso'),
48
-            '[CO_LINKEDIN_URL]'  => esc_html__('Link to organization LinkedIn page', 'event_espresso'),
49
-            '[CO_INSTAGRAM_URL]' => esc_html__('Link to organization Instagram page', 'event_espresso'),
50
-            '[CO_TAX_NUMBER_*]'  => sprintf(
51
-                esc_html__(
52
-                    'This is the shortcode used for displaying any tax number for the company.  %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is.  It defaults to "VAT/Tax Number:".  To change this prefix you do the following format for this shortcode:  [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56.  Also take note that if you have NO number in your settings, the prefix is not output either.',
53
-                    'event_espresso'
54
-                ),
55
-                '<strong>',
56
-                '</strong>'
57
-            ),
58
-        );
59
-    }
60
-
61
-
62
-    /**
63
-     * @param string $shortcode
64
-     * @throws EE_Error
65
-     * @throws ReflectionException
66
-     */
67
-    protected function _parser($shortcode)
68
-    {
69
-
70
-        switch ($shortcode) {
71
-            case '[COMPANY]':
72
-                return EE_Registry::instance()->CFG->organization->get_pretty('name');
73
-
74
-            case '[CO_ADD1]':
75
-                return EE_Registry::instance()->CFG->organization->get_pretty('address_1');
76
-
77
-            case '[CO_ADD2]':
78
-                return EE_Registry::instance()->CFG->organization->get_pretty('address_2');
79
-
80
-            case '[CO_CITY]':
81
-                return EE_Registry::instance()->CFG->organization->get_pretty('city');
82
-
83
-            case '[CO_STATE]':
84
-                $state = EE_Registry::instance()->load_model('State')->get_one_by_ID(
85
-                    EE_Registry::instance()->CFG->organization->STA_ID
86
-                );
87
-                return $state instanceof EE_State ? $state->name() : '';
88
-
89
-            case '[CO_ZIP]':
90
-                return EE_Registry::instance()->CFG->organization->get_pretty('zip');
91
-
92
-            case '[CO_EMAIL]':
93
-                return EE_Registry::instance()->CFG->organization->get_pretty('email');
94
-
95
-            case '[CO_PHONE]':
96
-                return EE_Registry::instance()->CFG->organization->get_pretty('phone');
97
-
98
-            case '[CO_LOGO]':
99
-                return '<img src="'
100
-                       . EE_Registry::instance()->CFG->organization->get_pretty(
101
-                           'logo_url'
102
-                       ) . '" id="headerImage" />';
103
-
104
-            case '[CO_LOGO_URL]':
105
-                return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
106
-
107
-            case '[CO_FACEBOOK_URL]':
108
-                return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
109
-
110
-            case '[CO_TWITTER_URL]':
111
-                return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
112
-
113
-            case '[CO_PINTEREST_URL]':
114
-                return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
115
-
116
-            case '[CO_LINKEDIN_URL]':
117
-                return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
118
-
119
-            case '[CO_GOOGLE_URL]':
120
-                return EE_Registry::instance()->CFG->organization->get_pretty('google');
121
-
122
-            case '[CO_INSTAGRAM_URL]':
123
-                return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
124
-        }
125
-
126
-        // also allow for parameter shortcode
127
-        if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== false) {
128
-            // first see if there is any company tax number set and bail early if not
129
-            $tax_number = EE_Registry::instance()->CFG->organization->vat;
130
-            if (empty($tax_number)) {
131
-                return '';
132
-            }
133
-
134
-            // see if there are any attributes.
135
-            $attrs = $this->_get_shortcode_attrs($shortcode);
136
-
137
-            // set custom attrs if present (or default)
138
-            $prefix = $attrs['prefix'] ?? esc_html__('VAT/Tax Number: ', 'event_espresso');
139
-            return $prefix . $tax_number;
140
-        }
141
-
142
-        return '';
143
-    }
20
+	public function __construct()
21
+	{
22
+		parent::__construct();
23
+	}
24
+
25
+
26
+	protected function _init_props()
27
+	{
28
+		$this->label = esc_html__('Organization Shortcodes', 'event_espresso');
29
+		$this->description = esc_html__('All shortcodes specific to organization related data', 'event_espresso');
30
+		$this->_shortcodes = array(
31
+			'[COMPANY]'          => esc_html__('Event organization name', 'event_espresso'),
32
+			'[CO_ADD1]'          => esc_html__('Address 1 value for the organization', 'event_espresso'),
33
+			'[CO_ADD2]'          => esc_html__('Address 2 value for the organization', 'event_espresso'),
34
+			'[CO_CITY]'          => esc_html__('City the organization is in', 'event_espresso'),
35
+			'[CO_STATE]'         => esc_html__('State the organization is located in', 'event_espresso'),
36
+			'[CO_ZIP]'           => esc_html__('The zip code for the organization', 'event_espresso'),
37
+			'[CO_LOGO]'          => esc_html__('The logo image for the organization', 'event_espresso'),
38
+			'[CO_EMAIL]'         => esc_html__('The primary email address for the organization', 'event_espresso'),
39
+			'[CO_PHONE]'         => esc_html__('The phone number for the organization', 'event_espresso'),
40
+			'[CO_LOGO_URL]'      => esc_html__(
41
+				'Just the link to the image used as the logo for the organization',
42
+				'event_espresso'
43
+			),
44
+			'[CO_FACEBOOK_URL]'  => esc_html__('Link to organization Facebook page', 'event_espresso'),
45
+			'[CO_TWITTER_URL]'   => esc_html__('Link to organization Twitter page', 'event_espresso'),
46
+			'[CO_PINTEREST_URL]' => esc_html__('Link to organization Pinterest page', 'event_espresso'),
47
+			'[CO_GOOGLE_URL]'    => esc_html__('Link to organization Google page', 'event_espresso'),
48
+			'[CO_LINKEDIN_URL]'  => esc_html__('Link to organization LinkedIn page', 'event_espresso'),
49
+			'[CO_INSTAGRAM_URL]' => esc_html__('Link to organization Instagram page', 'event_espresso'),
50
+			'[CO_TAX_NUMBER_*]'  => sprintf(
51
+				esc_html__(
52
+					'This is the shortcode used for displaying any tax number for the company.  %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is.  It defaults to "VAT/Tax Number:".  To change this prefix you do the following format for this shortcode:  [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56.  Also take note that if you have NO number in your settings, the prefix is not output either.',
53
+					'event_espresso'
54
+				),
55
+				'<strong>',
56
+				'</strong>'
57
+			),
58
+		);
59
+	}
60
+
61
+
62
+	/**
63
+	 * @param string $shortcode
64
+	 * @throws EE_Error
65
+	 * @throws ReflectionException
66
+	 */
67
+	protected function _parser($shortcode)
68
+	{
69
+
70
+		switch ($shortcode) {
71
+			case '[COMPANY]':
72
+				return EE_Registry::instance()->CFG->organization->get_pretty('name');
73
+
74
+			case '[CO_ADD1]':
75
+				return EE_Registry::instance()->CFG->organization->get_pretty('address_1');
76
+
77
+			case '[CO_ADD2]':
78
+				return EE_Registry::instance()->CFG->organization->get_pretty('address_2');
79
+
80
+			case '[CO_CITY]':
81
+				return EE_Registry::instance()->CFG->organization->get_pretty('city');
82
+
83
+			case '[CO_STATE]':
84
+				$state = EE_Registry::instance()->load_model('State')->get_one_by_ID(
85
+					EE_Registry::instance()->CFG->organization->STA_ID
86
+				);
87
+				return $state instanceof EE_State ? $state->name() : '';
88
+
89
+			case '[CO_ZIP]':
90
+				return EE_Registry::instance()->CFG->organization->get_pretty('zip');
91
+
92
+			case '[CO_EMAIL]':
93
+				return EE_Registry::instance()->CFG->organization->get_pretty('email');
94
+
95
+			case '[CO_PHONE]':
96
+				return EE_Registry::instance()->CFG->organization->get_pretty('phone');
97
+
98
+			case '[CO_LOGO]':
99
+				return '<img src="'
100
+					   . EE_Registry::instance()->CFG->organization->get_pretty(
101
+						   'logo_url'
102
+					   ) . '" id="headerImage" />';
103
+
104
+			case '[CO_LOGO_URL]':
105
+				return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
106
+
107
+			case '[CO_FACEBOOK_URL]':
108
+				return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
109
+
110
+			case '[CO_TWITTER_URL]':
111
+				return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
112
+
113
+			case '[CO_PINTEREST_URL]':
114
+				return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
115
+
116
+			case '[CO_LINKEDIN_URL]':
117
+				return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
118
+
119
+			case '[CO_GOOGLE_URL]':
120
+				return EE_Registry::instance()->CFG->organization->get_pretty('google');
121
+
122
+			case '[CO_INSTAGRAM_URL]':
123
+				return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
124
+		}
125
+
126
+		// also allow for parameter shortcode
127
+		if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== false) {
128
+			// first see if there is any company tax number set and bail early if not
129
+			$tax_number = EE_Registry::instance()->CFG->organization->vat;
130
+			if (empty($tax_number)) {
131
+				return '';
132
+			}
133
+
134
+			// see if there are any attributes.
135
+			$attrs = $this->_get_shortcode_attrs($shortcode);
136
+
137
+			// set custom attrs if present (or default)
138
+			$prefix = $attrs['prefix'] ?? esc_html__('VAT/Tax Number: ', 'event_espresso');
139
+			return $prefix . $tax_number;
140
+		}
141
+
142
+		return '';
143
+	}
144 144
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
                 return '<img src="'
100 100
                        . EE_Registry::instance()->CFG->organization->get_pretty(
101 101
                            'logo_url'
102
-                       ) . '" id="headerImage" />';
102
+                       ).'" id="headerImage" />';
103 103
 
104 104
             case '[CO_LOGO_URL]':
105 105
                 return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
             // set custom attrs if present (or default)
138 138
             $prefix = $attrs['prefix'] ?? esc_html__('VAT/Tax Number: ', 'event_espresso');
139
-            return $prefix . $tax_number;
139
+            return $prefix.$tax_number;
140 140
         }
141 141
 
142 142
         return '';
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Line_Item_List_Shortcodes.lib.php 1 patch
Indentation   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -20,204 +20,204 @@
 block discarded – undo
20 20
  */
21 21
 class EE_Line_Item_List_Shortcodes extends EE_Shortcodes
22 22
 {
23
-    protected function _init_props()
24
-    {
25
-        $this->label = esc_html__('Line Item List Shortcodes', 'event_espresso');
26
-        $this->description = esc_html__('All shortcodes specific to line item lists', 'event_espresso');
27
-        $this->_shortcodes = array(
28
-            '[TICKET_LINE_ITEM_LIST]'         => esc_html__('Outputs a list of ticket line items.', 'event_espresso'),
29
-            '[TAX_LINE_ITEM_LIST]'            => esc_html__('Outputs a list of tax line items.', 'event_espresso'),
30
-            '[ADDITIONAL_LINE_ITEM_LIST]'     => esc_html__(
31
-                'Outputs a list of additional line items (other charges or discounts)',
32
-                'event_espresso'
33
-            ),
34
-            '[PRICE_MODIFIER_LINE_ITEM_LIST]' => esc_html__('Outputs a list of price modifier line items', 'event_espresso'),
35
-        );
36
-    }
37
-
38
-
39
-    /**
40
-     * @param string $shortcode
41
-     * @throws EE_Error
42
-     */
43
-    protected function _parser($shortcode)
44
-    {
45
-        switch ($shortcode) {
46
-            case '[TICKET_LINE_ITEM_LIST]':
47
-                return $this->_get_ticket_line_item_list();
48
-
49
-            case '[TAX_LINE_ITEM_LIST]':
50
-                return $this->_get_tax_line_item_list();
51
-
52
-            case '[PRICE_MODIFIER_LINE_ITEM_LIST]':
53
-                return $this->_get_price_mod_line_item_list();
54
-
55
-            case '[ADDITIONAL_LINE_ITEM_LIST]':
56
-                return $this->_get_additional_line_item_list();
57
-
58
-            default:
59
-                return '';
60
-        }
61
-    }
62
-
63
-
64
-    /**
65
-     * verify incoming data contains what is needed for retrieving and parsing each ticket line item for an event.
66
-     *
67
-     * @since 4.5.0
68
-     *
69
-     * @return string parsed ticket line item list.
70
-     */
71
-    private function _get_ticket_line_item_list()
72
-    {
73
-        $this->_validate_list_requirements();
74
-
75
-        if (! $this->_data['data'] instanceof EE_Ticket) {
76
-            return '';
77
-        }
78
-
79
-        $valid_shortcodes = array('line_item', 'line_item_list', 'ticket');
80
-
81
-        $ticket = $this->_data['data'];
82
-        $templates = $this->_extra_data['template'];
83
-        $addressee_obj = $this->_extra_data['data'];
84
-
85
-        // made it here so we have an EE_Ticket, so we should have what we need.
86
-        $ticket_line_item = isset($addressee_obj->tickets[ $ticket->ID() ]['line_item'])
87
-            ? $addressee_obj->tickets[ $ticket->ID() ]['line_item'] : null;
88
-        $sub_line_items = isset($addressee_obj->tickets[ $ticket->ID() ]['sub_line_items'])
89
-            ? $addressee_obj->tickets[ $ticket->ID() ]['sub_line_items'] : array();
90
-
91
-        $template = count($sub_line_items) < 2 ? $templates['ticket_line_item_no_pms']
92
-            : $templates['ticket_line_item_pms'];
93
-
94
-        if (empty($ticket_line_item) || empty($sub_line_items)) {
95
-            return '';
96
-        }
97
-
98
-        // now we just return the appropriate template parsed for each ticket.
99
-        return $this->_shortcode_helper->parse_line_item_list_template(
100
-            $template,
101
-            $ticket_line_item,
102
-            $valid_shortcodes,
103
-            $this->_extra_data
104
-        );
105
-    }
106
-
107
-
108
-    /**
109
-     * Verify incoming data contains what is needed for retrieving and parsing each tax line item for a transaction.
110
-     *
111
-     * @return string  parsed tax line item list.
112
-     * @throws EE_Error
113
-     * @since 4.5.0
114
-     */
115
-    private function _get_tax_line_item_list()
116
-    {
117
-        /** @var EE_Admin_Config $admin_config */
118
-        $admin_config = LoaderFactory::getShared(EE_Admin_Config::class);
119
-        if ($admin_config->useAdvancedEditor()) {
120
-            return '';
121
-        }
122
-        $this->_validate_list_requirements();
123
-
124
-        if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
125
-            return '';
126
-        }
127
-
128
-        // made it here so we're good to go.
129
-        $valid_shortcodes = array('line_item');
130
-        $templates = $this->_data['template'];
131
-
132
-        $tax_line_items = $this->_data['data']->tax_line_items;
133
-        $line_item_list = '';
134
-        foreach ($tax_line_items as $line_item) {
135
-            $line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
136
-                $templates['tax_line_item_list'],
137
-                $line_item,
138
-                $valid_shortcodes,
139
-                $this->_extra_data
140
-            );
141
-        }
142
-
143
-        return $line_item_list;
144
-    }
145
-
146
-    /**
147
-     * Verify incoming data contains what is needed for retrieving and parsing each other line item for a transaction.
148
-     *
149
-     * @since 4.5.0
150
-     *
151
-     * @return string  parsed other line item list.
152
-     */
153
-    private function _get_additional_line_item_list()
154
-    {
155
-
156
-        $this->_validate_list_requirements();
157
-
158
-        if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
159
-            return '';
160
-        }
161
-
162
-        // made it here so we're good to go.
163
-        $valid_shortcodes = array('line_item');
164
-        $templates = $this->_data['template'];
165
-
166
-        $additional_line_items = $this->_data['data']->additional_line_items;
167
-        $line_item_list = '';
168
-        foreach ($additional_line_items as $line_item) {
169
-            $line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
170
-                $templates['additional_line_item_list'],
171
-                $line_item,
172
-                $valid_shortcodes,
173
-                $this->_extra_data
174
-            );
175
-        }
176
-
177
-
178
-        return $line_item_list;
179
-    }
180
-
181
-
182
-    /**
183
-     * Verify incoming data contains what is needed for retrieving and parsing each price modifier line item for a
184
-     * parent ticket line item.
185
-     *
186
-     * @since 4.5.0
187
-     *
188
-     * @return string parsed price modifier line item list.
189
-     */
190
-    private function _get_price_mod_line_item_list()
191
-    {
192
-        $this->_validate_list_requirements();
193
-
194
-        if (! $this->_data['data'] instanceof EE_Line_Item) {
195
-            return '';
196
-        }
197
-
198
-        // made it here so we're good to go.
199
-        $main_line_item = $this->_data['data'];
200
-        $templates = $this->_extra_data['template'];
201
-        $addressee_obj = $this->_extra_data['data'];
202
-
203
-        $valid_shortcodes = array('line_item');
204
-
205
-        $main_line_item_id = $main_line_item->ID();
206
-
207
-        $price_mod_line_items = ! empty($addressee_obj->line_items_with_children[ $main_line_item_id ]['children'])
208
-            ? $addressee_obj->line_items_with_children[ $main_line_item_id ]['children'] : array();
209
-
210
-        $line_item_list = '';
211
-
212
-        foreach ($price_mod_line_items as $line_item) {
213
-            $line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
214
-                $templates['price_modifier_line_item_list'],
215
-                $line_item,
216
-                $valid_shortcodes,
217
-                $this->_extra_data
218
-            );
219
-        }
220
-
221
-        return $line_item_list;
222
-    }
23
+	protected function _init_props()
24
+	{
25
+		$this->label = esc_html__('Line Item List Shortcodes', 'event_espresso');
26
+		$this->description = esc_html__('All shortcodes specific to line item lists', 'event_espresso');
27
+		$this->_shortcodes = array(
28
+			'[TICKET_LINE_ITEM_LIST]'         => esc_html__('Outputs a list of ticket line items.', 'event_espresso'),
29
+			'[TAX_LINE_ITEM_LIST]'            => esc_html__('Outputs a list of tax line items.', 'event_espresso'),
30
+			'[ADDITIONAL_LINE_ITEM_LIST]'     => esc_html__(
31
+				'Outputs a list of additional line items (other charges or discounts)',
32
+				'event_espresso'
33
+			),
34
+			'[PRICE_MODIFIER_LINE_ITEM_LIST]' => esc_html__('Outputs a list of price modifier line items', 'event_espresso'),
35
+		);
36
+	}
37
+
38
+
39
+	/**
40
+	 * @param string $shortcode
41
+	 * @throws EE_Error
42
+	 */
43
+	protected function _parser($shortcode)
44
+	{
45
+		switch ($shortcode) {
46
+			case '[TICKET_LINE_ITEM_LIST]':
47
+				return $this->_get_ticket_line_item_list();
48
+
49
+			case '[TAX_LINE_ITEM_LIST]':
50
+				return $this->_get_tax_line_item_list();
51
+
52
+			case '[PRICE_MODIFIER_LINE_ITEM_LIST]':
53
+				return $this->_get_price_mod_line_item_list();
54
+
55
+			case '[ADDITIONAL_LINE_ITEM_LIST]':
56
+				return $this->_get_additional_line_item_list();
57
+
58
+			default:
59
+				return '';
60
+		}
61
+	}
62
+
63
+
64
+	/**
65
+	 * verify incoming data contains what is needed for retrieving and parsing each ticket line item for an event.
66
+	 *
67
+	 * @since 4.5.0
68
+	 *
69
+	 * @return string parsed ticket line item list.
70
+	 */
71
+	private function _get_ticket_line_item_list()
72
+	{
73
+		$this->_validate_list_requirements();
74
+
75
+		if (! $this->_data['data'] instanceof EE_Ticket) {
76
+			return '';
77
+		}
78
+
79
+		$valid_shortcodes = array('line_item', 'line_item_list', 'ticket');
80
+
81
+		$ticket = $this->_data['data'];
82
+		$templates = $this->_extra_data['template'];
83
+		$addressee_obj = $this->_extra_data['data'];
84
+
85
+		// made it here so we have an EE_Ticket, so we should have what we need.
86
+		$ticket_line_item = isset($addressee_obj->tickets[ $ticket->ID() ]['line_item'])
87
+			? $addressee_obj->tickets[ $ticket->ID() ]['line_item'] : null;
88
+		$sub_line_items = isset($addressee_obj->tickets[ $ticket->ID() ]['sub_line_items'])
89
+			? $addressee_obj->tickets[ $ticket->ID() ]['sub_line_items'] : array();
90
+
91
+		$template = count($sub_line_items) < 2 ? $templates['ticket_line_item_no_pms']
92
+			: $templates['ticket_line_item_pms'];
93
+
94
+		if (empty($ticket_line_item) || empty($sub_line_items)) {
95
+			return '';
96
+		}
97
+
98
+		// now we just return the appropriate template parsed for each ticket.
99
+		return $this->_shortcode_helper->parse_line_item_list_template(
100
+			$template,
101
+			$ticket_line_item,
102
+			$valid_shortcodes,
103
+			$this->_extra_data
104
+		);
105
+	}
106
+
107
+
108
+	/**
109
+	 * Verify incoming data contains what is needed for retrieving and parsing each tax line item for a transaction.
110
+	 *
111
+	 * @return string  parsed tax line item list.
112
+	 * @throws EE_Error
113
+	 * @since 4.5.0
114
+	 */
115
+	private function _get_tax_line_item_list()
116
+	{
117
+		/** @var EE_Admin_Config $admin_config */
118
+		$admin_config = LoaderFactory::getShared(EE_Admin_Config::class);
119
+		if ($admin_config->useAdvancedEditor()) {
120
+			return '';
121
+		}
122
+		$this->_validate_list_requirements();
123
+
124
+		if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
125
+			return '';
126
+		}
127
+
128
+		// made it here so we're good to go.
129
+		$valid_shortcodes = array('line_item');
130
+		$templates = $this->_data['template'];
131
+
132
+		$tax_line_items = $this->_data['data']->tax_line_items;
133
+		$line_item_list = '';
134
+		foreach ($tax_line_items as $line_item) {
135
+			$line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
136
+				$templates['tax_line_item_list'],
137
+				$line_item,
138
+				$valid_shortcodes,
139
+				$this->_extra_data
140
+			);
141
+		}
142
+
143
+		return $line_item_list;
144
+	}
145
+
146
+	/**
147
+	 * Verify incoming data contains what is needed for retrieving and parsing each other line item for a transaction.
148
+	 *
149
+	 * @since 4.5.0
150
+	 *
151
+	 * @return string  parsed other line item list.
152
+	 */
153
+	private function _get_additional_line_item_list()
154
+	{
155
+
156
+		$this->_validate_list_requirements();
157
+
158
+		if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
159
+			return '';
160
+		}
161
+
162
+		// made it here so we're good to go.
163
+		$valid_shortcodes = array('line_item');
164
+		$templates = $this->_data['template'];
165
+
166
+		$additional_line_items = $this->_data['data']->additional_line_items;
167
+		$line_item_list = '';
168
+		foreach ($additional_line_items as $line_item) {
169
+			$line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
170
+				$templates['additional_line_item_list'],
171
+				$line_item,
172
+				$valid_shortcodes,
173
+				$this->_extra_data
174
+			);
175
+		}
176
+
177
+
178
+		return $line_item_list;
179
+	}
180
+
181
+
182
+	/**
183
+	 * Verify incoming data contains what is needed for retrieving and parsing each price modifier line item for a
184
+	 * parent ticket line item.
185
+	 *
186
+	 * @since 4.5.0
187
+	 *
188
+	 * @return string parsed price modifier line item list.
189
+	 */
190
+	private function _get_price_mod_line_item_list()
191
+	{
192
+		$this->_validate_list_requirements();
193
+
194
+		if (! $this->_data['data'] instanceof EE_Line_Item) {
195
+			return '';
196
+		}
197
+
198
+		// made it here so we're good to go.
199
+		$main_line_item = $this->_data['data'];
200
+		$templates = $this->_extra_data['template'];
201
+		$addressee_obj = $this->_extra_data['data'];
202
+
203
+		$valid_shortcodes = array('line_item');
204
+
205
+		$main_line_item_id = $main_line_item->ID();
206
+
207
+		$price_mod_line_items = ! empty($addressee_obj->line_items_with_children[ $main_line_item_id ]['children'])
208
+			? $addressee_obj->line_items_with_children[ $main_line_item_id ]['children'] : array();
209
+
210
+		$line_item_list = '';
211
+
212
+		foreach ($price_mod_line_items as $line_item) {
213
+			$line_item_list .= $this->_shortcode_helper->parse_line_item_list_template(
214
+				$templates['price_modifier_line_item_list'],
215
+				$line_item,
216
+				$valid_shortcodes,
217
+				$this->_extra_data
218
+			);
219
+		}
220
+
221
+		return $line_item_list;
222
+	}
223 223
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Datetime_List_Shortcodes.lib.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -18,168 +18,168 @@
 block discarded – undo
18 18
  */
19 19
 class EE_Datetime_List_Shortcodes extends EE_Shortcodes
20 20
 {
21
-    protected function _init_props()
22
-    {
23
-        $this->label       = esc_html__('Datetime List Shortcodes', 'event_espresso');
24
-        $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso');
25
-        $this->_shortcodes = [
26
-            '[DATETIME_LIST]' => esc_html__(
27
-                'Will output a list of datetimes according to the layout specified in the datetime list field.',
28
-                'event_espresso'
29
-            ),
30
-        ];
31
-    }
32
-
33
-
34
-    /**
35
-     * @param string $shortcode
36
-     * @return string
37
-     * @throws EE_Error
38
-     * @throws ReflectionException
39
-     */
40
-    protected function _parser($shortcode)
41
-    {
42
-        if ($shortcode == '[DATETIME_LIST]') {
43
-            return $this->_get_datetime_list();
44
-        }
45
-        return '';
46
-    }
47
-
48
-
49
-    /**
50
-     * figure out what the incoming data is and then return the appropriate parsed value.
51
-     *
52
-     * @return string
53
-     * @throws EE_Error
54
-     * @throws ReflectionException
55
-     */
56
-    private function _get_datetime_list()
57
-    {
58
-        $this->_validate_list_requirements();
59
-
60
-        if ($this->_data['data'] instanceof EE_Ticket) {
61
-            return $this->_get_datetime_list_for_ticket();
62
-        }
63
-        if ($this->_data['data'] instanceof EE_Event) {
64
-            return $this->_get_datetime_list_for_event();
65
-        }
66
-        if (
67
-            $this->_data['data'] instanceof EE_Messages_Addressee
68
-            && $this->_data['data']->reg_obj instanceof EE_Registration
69
-        ) {
70
-            return $this->_get_datetime_list_for_registration();
71
-        }
72
-        // prevent recursive loop
73
-        return '';
74
-    }
75
-
76
-
77
-    /**
78
-     * return parsed list of datetimes for an event
79
-     *
80
-     * @return string
81
-     * @throws EE_Error
82
-     * @throws ReflectionException
83
-     */
84
-    private function _get_datetime_list_for_event()
85
-    {
86
-        $event            = $this->_data['data'];
87
-        $valid_shortcodes = ['datetime', 'attendee'];
88
-        $template         = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
89
-            ? $this->_data['template']['datetime_list']
90
-            : $this->_extra_data['template']['datetime_list'];
91
-
92
-        // here we're setting up the datetimes for the datetime list template for THIS event.
93
-        $dtt_parsed = '';
94
-        $datetimes  = $this->_get_datetimes_from_event($event);
95
-
96
-        // each datetime in this case should be an datetime object.
97
-        foreach ($datetimes as $datetime) {
98
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
99
-                $template,
100
-                $datetime,
101
-                $valid_shortcodes,
102
-                $this->_extra_data
103
-            );
104
-        }
105
-
106
-        return $dtt_parsed;
107
-    }
108
-
109
-
110
-    /**
111
-     * return parsed list of datetimes for an ticket
112
-     *
113
-     * @return string
114
-     * @throws EE_Error
115
-     */
116
-    private function _get_datetime_list_for_ticket()
117
-    {
118
-        $valid_shortcodes = ['datetime', 'attendee'];
119
-
120
-        $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
121
-            ? $this->_data['template']['datetime_list']
122
-            : $this->_extra_data['template']['datetime_list'];
123
-        $ticket   = $this->_data['data'];
124
-
125
-        // here we're setting up the datetimes for the datetime list template for THIS ticket.
126
-        $dtt_parsed = '';
127
-        $datetimes  = $this->_get_datetimes_from_ticket($ticket);
128
-
129
-        // each datetime in this case should be an datetime object.
130
-        foreach ($datetimes as $datetime) {
131
-            $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
132
-                $template,
133
-                $datetime,
134
-                $valid_shortcodes,
135
-                $this->_extra_data
136
-            );
137
-        }
138
-
139
-        return $dtt_parsed;
140
-    }
141
-
142
-
143
-    /**
144
-     * return parsed list of datetimes from a given registration.
145
-     *
146
-     * @return string
147
-     * @throws EE_Error
148
-     * @throws EE_Error
149
-     */
150
-    private function _get_datetime_list_for_registration()
151
-    {
152
-        $registration = $this->_data['data']->reg_obj;
153
-
154
-        // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket();
155
-        $this->_data['data'] = $registration->ticket();
156
-        return $this->_get_datetime_list_for_ticket();
157
-    }
158
-
159
-
160
-    /**
161
-     * @param EE_Event $event
162
-     * @return array|mixed
163
-     * @throws EE_Error
164
-     * @throws ReflectionException
165
-     */
166
-    private function _get_datetimes_from_event(EE_Event $event)
167
-    {
168
-        return isset($this->_extra_data['data']->events)
169
-            ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs']
170
-            : [];
171
-    }
172
-
173
-
174
-    /**
175
-     * @param EE_Ticket $ticket
176
-     * @return array|mixed
177
-     * @throws EE_Error
178
-     */
179
-    private function _get_datetimes_from_ticket(EE_Ticket $ticket)
180
-    {
181
-        return isset($this->_extra_data['data']->tickets)
182
-            ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs']
183
-            : [];
184
-    }
21
+	protected function _init_props()
22
+	{
23
+		$this->label       = esc_html__('Datetime List Shortcodes', 'event_espresso');
24
+		$this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso');
25
+		$this->_shortcodes = [
26
+			'[DATETIME_LIST]' => esc_html__(
27
+				'Will output a list of datetimes according to the layout specified in the datetime list field.',
28
+				'event_espresso'
29
+			),
30
+		];
31
+	}
32
+
33
+
34
+	/**
35
+	 * @param string $shortcode
36
+	 * @return string
37
+	 * @throws EE_Error
38
+	 * @throws ReflectionException
39
+	 */
40
+	protected function _parser($shortcode)
41
+	{
42
+		if ($shortcode == '[DATETIME_LIST]') {
43
+			return $this->_get_datetime_list();
44
+		}
45
+		return '';
46
+	}
47
+
48
+
49
+	/**
50
+	 * figure out what the incoming data is and then return the appropriate parsed value.
51
+	 *
52
+	 * @return string
53
+	 * @throws EE_Error
54
+	 * @throws ReflectionException
55
+	 */
56
+	private function _get_datetime_list()
57
+	{
58
+		$this->_validate_list_requirements();
59
+
60
+		if ($this->_data['data'] instanceof EE_Ticket) {
61
+			return $this->_get_datetime_list_for_ticket();
62
+		}
63
+		if ($this->_data['data'] instanceof EE_Event) {
64
+			return $this->_get_datetime_list_for_event();
65
+		}
66
+		if (
67
+			$this->_data['data'] instanceof EE_Messages_Addressee
68
+			&& $this->_data['data']->reg_obj instanceof EE_Registration
69
+		) {
70
+			return $this->_get_datetime_list_for_registration();
71
+		}
72
+		// prevent recursive loop
73
+		return '';
74
+	}
75
+
76
+
77
+	/**
78
+	 * return parsed list of datetimes for an event
79
+	 *
80
+	 * @return string
81
+	 * @throws EE_Error
82
+	 * @throws ReflectionException
83
+	 */
84
+	private function _get_datetime_list_for_event()
85
+	{
86
+		$event            = $this->_data['data'];
87
+		$valid_shortcodes = ['datetime', 'attendee'];
88
+		$template         = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
89
+			? $this->_data['template']['datetime_list']
90
+			: $this->_extra_data['template']['datetime_list'];
91
+
92
+		// here we're setting up the datetimes for the datetime list template for THIS event.
93
+		$dtt_parsed = '';
94
+		$datetimes  = $this->_get_datetimes_from_event($event);
95
+
96
+		// each datetime in this case should be an datetime object.
97
+		foreach ($datetimes as $datetime) {
98
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
99
+				$template,
100
+				$datetime,
101
+				$valid_shortcodes,
102
+				$this->_extra_data
103
+			);
104
+		}
105
+
106
+		return $dtt_parsed;
107
+	}
108
+
109
+
110
+	/**
111
+	 * return parsed list of datetimes for an ticket
112
+	 *
113
+	 * @return string
114
+	 * @throws EE_Error
115
+	 */
116
+	private function _get_datetime_list_for_ticket()
117
+	{
118
+		$valid_shortcodes = ['datetime', 'attendee'];
119
+
120
+		$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list'])
121
+			? $this->_data['template']['datetime_list']
122
+			: $this->_extra_data['template']['datetime_list'];
123
+		$ticket   = $this->_data['data'];
124
+
125
+		// here we're setting up the datetimes for the datetime list template for THIS ticket.
126
+		$dtt_parsed = '';
127
+		$datetimes  = $this->_get_datetimes_from_ticket($ticket);
128
+
129
+		// each datetime in this case should be an datetime object.
130
+		foreach ($datetimes as $datetime) {
131
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template(
132
+				$template,
133
+				$datetime,
134
+				$valid_shortcodes,
135
+				$this->_extra_data
136
+			);
137
+		}
138
+
139
+		return $dtt_parsed;
140
+	}
141
+
142
+
143
+	/**
144
+	 * return parsed list of datetimes from a given registration.
145
+	 *
146
+	 * @return string
147
+	 * @throws EE_Error
148
+	 * @throws EE_Error
149
+	 */
150
+	private function _get_datetime_list_for_registration()
151
+	{
152
+		$registration = $this->_data['data']->reg_obj;
153
+
154
+		// now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket();
155
+		$this->_data['data'] = $registration->ticket();
156
+		return $this->_get_datetime_list_for_ticket();
157
+	}
158
+
159
+
160
+	/**
161
+	 * @param EE_Event $event
162
+	 * @return array|mixed
163
+	 * @throws EE_Error
164
+	 * @throws ReflectionException
165
+	 */
166
+	private function _get_datetimes_from_event(EE_Event $event)
167
+	{
168
+		return isset($this->_extra_data['data']->events)
169
+			? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs']
170
+			: [];
171
+	}
172
+
173
+
174
+	/**
175
+	 * @param EE_Ticket $ticket
176
+	 * @return array|mixed
177
+	 * @throws EE_Error
178
+	 */
179
+	private function _get_datetimes_from_ticket(EE_Ticket $ticket)
180
+	{
181
+		return isset($this->_extra_data['data']->tickets)
182
+			? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs']
183
+			: [];
184
+	}
185 185
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Email_Shortcodes.lib.php 2 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -17,164 +17,164 @@
 block discarded – undo
17 17
  */
18 18
 class EE_Email_Shortcodes extends EE_Shortcodes
19 19
 {
20
-    public function __construct()
21
-    {
22
-        parent::__construct();
23
-    }
24
-
25
-
26
-    protected function _init_props()
27
-    {
28
-        $this->label = esc_html__('Email Shortcodes', 'event_espresso');
29
-        $this->description = esc_html__('All shortcodes related to emails', 'event_espresso');
30
-        $this->_shortcodes = array(
31
-            '[SITE_ADMIN_EMAIL]'               => esc_html__(
32
-                'Will be replaced with the admin email for the site that Event Espresso is installed on',
33
-                'event_espresso'
34
-            ),
35
-            '[EVENT_AUTHOR_FORMATTED_EMAIL]'   => sprintf(
36
-                esc_html__(
37
-                    'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.',
38
-                    'event_espresso'
39
-                ),
40
-                '<strong>',
41
-                '</strong>'
42
-            ),
43
-            '[EVENT_AUTHOR_EMAIL]'             => sprintf(
44
-                esc_html__(
45
-                    'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).',
46
-                    'event_espresso'
47
-                ),
48
-                '[EVENT_AUTHOR_FORMATTED_EMAIL]'
49
-            ),
50
-            '[CO_FORMATTED_EMAIL]'             => esc_html__(
51
-                'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
52
-                'event_espresso'
53
-            ),
54
-            '[CO_EMAIL]'                       => esc_html__(
55
-                'This will parse to the email address only for the organization set in Your Organization Settings.',
56
-                'event_espresso'
57
-            ),
58
-            '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__(
59
-                'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
60
-                'event_espresso'
61
-            ),
62
-            '[ESPRESSO_ADMIN_EMAIL]'           => esc_html__(
63
-                'This parses to the email address only for the organization set in Your Organization Settings page.',
64
-                'event_espresso'
65
-            ),
66
-        );
67
-    }
68
-
69
-
70
-    /**
71
-     * @param string $shortcode
72
-     * @throws EE_Error
73
-     */
74
-    protected function _parser($shortcode)
75
-    {
76
-        switch ($shortcode) {
77
-            case '[SITE_ADMIN_EMAIL]':
78
-                return $this->_get_site_admin_email();
79
-
80
-            case '[EVENT_AUTHOR_FORMATTED_EMAIL]':
81
-                return $this->_get_event_admin_emails();
82
-
83
-            case '[EVENT_AUTHOR_EMAIL]':
84
-                return $this->_get_event_admin_emails(false);
85
-
86
-            case '[CO_FORMATTED_EMAIL]':
87
-            case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
88
-                return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
89
-                       . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
90
-
91
-            case '[CO_EMAIL]':
92
-            case '[ESPRESSO_ADMIN_EMAIL]':
93
-                return EE_Registry::instance()->CFG->organization->get_pretty('email');
94
-
95
-            default:
96
-                return '';
97
-        }
98
-    }
99
-
100
-
101
-    /**
102
-     * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode)
103
-     *
104
-     * @access private
105
-     * @return string email address of site admin
106
-     */
107
-    private function _get_site_admin_email()
108
-    {
109
-        return get_bloginfo('admin_email');
110
-    }
111
-
112
-
113
-    private function _get_event_admin_emails($fancy_headers = true)
114
-    {
115
-
116
-        if (! empty($this->_data->admin_email)) {
117
-            if (! $fancy_headers) {
118
-                return $this->_data->admin_email;
119
-            }
120
-            return ! empty($this->_data->fname)
121
-                ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
122
-                : EE_Registry::instance()->CFG->organization->get_pretty(
123
-                    'name'
124
-                ) . ' <' . $this->_data->admin_email . '>';
125
-        }
126
-
127
-        // k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
128
-
129
-        $admin_email = array();
130
-
131
-        // loop through events and set the list of event_ids to retrieve so we can do ONE query.
132
-        foreach ($this->_data->events as $event) {
133
-            $ids[] = $event['ID'];
134
-        }
135
-
136
-        // get all the events
137
-        $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids))));
138
-
139
-        // now loop through each event and setup the details
140
-        $admin_details = array();
141
-        $cnt = 0;
142
-        foreach ($events as $event) {
143
-            $user = get_userdata($event->get('EVT_wp_user'));
144
-            $admin_details[ $cnt ] = new stdClass();
145
-            $admin_details[ $cnt ]->email = $user->user_email;
146
-            $admin_details[ $cnt ]->first_name = $user->user_firstname;
147
-            $admin_details[ $cnt ]->last_name = $user->user_lastname;
148
-            $cnt++;
149
-        }
150
-
151
-        // results?
152
-        if (empty($admin_details) || ! is_array($admin_details)) {
153
-            $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso');
154
-            $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql);
155
-            $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true));
156
-            $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true));
157
-            $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details));
158
-            do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser');
159
-        }
160
-
161
-        foreach ($admin_details as $admin) {
162
-            // only add an admin email if it is present.
163
-            if (empty($admin->email) || $admin->email == '') {
164
-                continue;
165
-            }
166
-
167
-            if (! $fancy_headers) {
168
-                $admin_email[] = $admin->email;
169
-                continue;
170
-            }
171
-
172
-            $admin_email[] = ! empty($admin->first_name)
173
-                ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
174
-                : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
175
-        }
176
-
177
-        $admin_email = implode(',', $admin_email);
178
-        return $admin_email;
179
-    }
20
+	public function __construct()
21
+	{
22
+		parent::__construct();
23
+	}
24
+
25
+
26
+	protected function _init_props()
27
+	{
28
+		$this->label = esc_html__('Email Shortcodes', 'event_espresso');
29
+		$this->description = esc_html__('All shortcodes related to emails', 'event_espresso');
30
+		$this->_shortcodes = array(
31
+			'[SITE_ADMIN_EMAIL]'               => esc_html__(
32
+				'Will be replaced with the admin email for the site that Event Espresso is installed on',
33
+				'event_espresso'
34
+			),
35
+			'[EVENT_AUTHOR_FORMATTED_EMAIL]'   => sprintf(
36
+				esc_html__(
37
+					'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.',
38
+					'event_espresso'
39
+				),
40
+				'<strong>',
41
+				'</strong>'
42
+			),
43
+			'[EVENT_AUTHOR_EMAIL]'             => sprintf(
44
+				esc_html__(
45
+					'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).',
46
+					'event_espresso'
47
+				),
48
+				'[EVENT_AUTHOR_FORMATTED_EMAIL]'
49
+			),
50
+			'[CO_FORMATTED_EMAIL]'             => esc_html__(
51
+				'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
52
+				'event_espresso'
53
+			),
54
+			'[CO_EMAIL]'                       => esc_html__(
55
+				'This will parse to the email address only for the organization set in Your Organization Settings.',
56
+				'event_espresso'
57
+			),
58
+			'[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__(
59
+				'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization &lt;[email protected]&gt;"',
60
+				'event_espresso'
61
+			),
62
+			'[ESPRESSO_ADMIN_EMAIL]'           => esc_html__(
63
+				'This parses to the email address only for the organization set in Your Organization Settings page.',
64
+				'event_espresso'
65
+			),
66
+		);
67
+	}
68
+
69
+
70
+	/**
71
+	 * @param string $shortcode
72
+	 * @throws EE_Error
73
+	 */
74
+	protected function _parser($shortcode)
75
+	{
76
+		switch ($shortcode) {
77
+			case '[SITE_ADMIN_EMAIL]':
78
+				return $this->_get_site_admin_email();
79
+
80
+			case '[EVENT_AUTHOR_FORMATTED_EMAIL]':
81
+				return $this->_get_event_admin_emails();
82
+
83
+			case '[EVENT_AUTHOR_EMAIL]':
84
+				return $this->_get_event_admin_emails(false);
85
+
86
+			case '[CO_FORMATTED_EMAIL]':
87
+			case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
88
+				return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
89
+					   . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
90
+
91
+			case '[CO_EMAIL]':
92
+			case '[ESPRESSO_ADMIN_EMAIL]':
93
+				return EE_Registry::instance()->CFG->organization->get_pretty('email');
94
+
95
+			default:
96
+				return '';
97
+		}
98
+	}
99
+
100
+
101
+	/**
102
+	 * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode)
103
+	 *
104
+	 * @access private
105
+	 * @return string email address of site admin
106
+	 */
107
+	private function _get_site_admin_email()
108
+	{
109
+		return get_bloginfo('admin_email');
110
+	}
111
+
112
+
113
+	private function _get_event_admin_emails($fancy_headers = true)
114
+	{
115
+
116
+		if (! empty($this->_data->admin_email)) {
117
+			if (! $fancy_headers) {
118
+				return $this->_data->admin_email;
119
+			}
120
+			return ! empty($this->_data->fname)
121
+				? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
122
+				: EE_Registry::instance()->CFG->organization->get_pretty(
123
+					'name'
124
+				) . ' <' . $this->_data->admin_email . '>';
125
+		}
126
+
127
+		// k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
128
+
129
+		$admin_email = array();
130
+
131
+		// loop through events and set the list of event_ids to retrieve so we can do ONE query.
132
+		foreach ($this->_data->events as $event) {
133
+			$ids[] = $event['ID'];
134
+		}
135
+
136
+		// get all the events
137
+		$events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids))));
138
+
139
+		// now loop through each event and setup the details
140
+		$admin_details = array();
141
+		$cnt = 0;
142
+		foreach ($events as $event) {
143
+			$user = get_userdata($event->get('EVT_wp_user'));
144
+			$admin_details[ $cnt ] = new stdClass();
145
+			$admin_details[ $cnt ]->email = $user->user_email;
146
+			$admin_details[ $cnt ]->first_name = $user->user_firstname;
147
+			$admin_details[ $cnt ]->last_name = $user->user_lastname;
148
+			$cnt++;
149
+		}
150
+
151
+		// results?
152
+		if (empty($admin_details) || ! is_array($admin_details)) {
153
+			$msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso');
154
+			$msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql);
155
+			$msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true));
156
+			$msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true));
157
+			$msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details));
158
+			do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser');
159
+		}
160
+
161
+		foreach ($admin_details as $admin) {
162
+			// only add an admin email if it is present.
163
+			if (empty($admin->email) || $admin->email == '') {
164
+				continue;
165
+			}
166
+
167
+			if (! $fancy_headers) {
168
+				$admin_email[] = $admin->email;
169
+				continue;
170
+			}
171
+
172
+			$admin_email[] = ! empty($admin->first_name)
173
+				? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
174
+				: EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
175
+		}
176
+
177
+		$admin_email = implode(',', $admin_email);
178
+		return $admin_email;
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 
86 86
             case '[CO_FORMATTED_EMAIL]':
87 87
             case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]':
88
-                return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <'
89
-                       . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>';
88
+                return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'
89
+                       . EE_Registry::instance()->CFG->organization->get_pretty('email').'>';
90 90
 
91 91
             case '[CO_EMAIL]':
92 92
             case '[ESPRESSO_ADMIN_EMAIL]':
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
     private function _get_event_admin_emails($fancy_headers = true)
114 114
     {
115 115
 
116
-        if (! empty($this->_data->admin_email)) {
117
-            if (! $fancy_headers) {
116
+        if ( ! empty($this->_data->admin_email)) {
117
+            if ( ! $fancy_headers) {
118 118
                 return $this->_data->admin_email;
119 119
             }
120 120
             return ! empty($this->_data->fname)
121
-                ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>'
121
+                ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>'
122 122
                 : EE_Registry::instance()->CFG->organization->get_pretty(
123 123
                     'name'
124
-                ) . ' <' . $this->_data->admin_email . '>';
124
+                ).' <'.$this->_data->admin_email.'>';
125 125
         }
126 126
 
127 127
         // k this shortcode has been used else where.  Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events.  We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!.
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
         $cnt = 0;
142 142
         foreach ($events as $event) {
143 143
             $user = get_userdata($event->get('EVT_wp_user'));
144
-            $admin_details[ $cnt ] = new stdClass();
145
-            $admin_details[ $cnt ]->email = $user->user_email;
146
-            $admin_details[ $cnt ]->first_name = $user->user_firstname;
147
-            $admin_details[ $cnt ]->last_name = $user->user_lastname;
144
+            $admin_details[$cnt] = new stdClass();
145
+            $admin_details[$cnt]->email = $user->user_email;
146
+            $admin_details[$cnt]->first_name = $user->user_firstname;
147
+            $admin_details[$cnt]->last_name = $user->user_lastname;
148 148
             $cnt++;
149 149
         }
150 150
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
                 continue;
165 165
             }
166 166
 
167
-            if (! $fancy_headers) {
167
+            if ( ! $fancy_headers) {
168 168
                 $admin_email[] = $admin->email;
169 169
                 continue;
170 170
             }
171 171
 
172 172
             $admin_email[] = ! empty($admin->first_name)
173
-                ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>'
174
-                : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>';
173
+                ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>'
174
+                : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>';
175 175
         }
176 176
 
177 177
         $admin_email = implode(',', $admin_email);
Please login to merge, or discard this patch.