@@ -64,14 +64,14 @@ |
||
64 | 64 | //make sure we end up with a copy of the EE_Messages_Addressee object |
65 | 65 | $this->_recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
66 | 66 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
67 | - && is_array( $this->_data ) |
|
68 | - && isset( $this->_data['data'] ) |
|
69 | - && $this->_data['data'] instanceof EE_Messages_Addressee |
|
67 | + && is_array( $this->_data ) |
|
68 | + && isset( $this->_data['data'] ) |
|
69 | + && $this->_data['data'] instanceof EE_Messages_Addressee |
|
70 | 70 | ? $this->_data['data'] : |
71 | 71 | $this->_recipient; |
72 | 72 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
73 | - && ! empty( $this->_extra_data['data'] ) |
|
74 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
73 | + && ! empty( $this->_extra_data['data'] ) |
|
74 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
75 | 75 | ? $this->_extra_data['data'] |
76 | 76 | : $this->_recipient; |
77 | 77 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -37,58 +37,57 @@ discard block |
||
37 | 37 | |
38 | 38 | |
39 | 39 | protected function _init_props() { |
40 | - $this->label = esc_html__( 'Recipient Details Shortcodes', 'event_espresso' ); |
|
41 | - $this->description = esc_html__( 'All shortcodes specific to recipient registration data', 'event_espresso' ); |
|
40 | + $this->label = esc_html__('Recipient Details Shortcodes', 'event_espresso'); |
|
41 | + $this->description = esc_html__('All shortcodes specific to recipient registration data', 'event_espresso'); |
|
42 | 42 | $this->_shortcodes = array( |
43 | - '[RECIPIENT_FNAME]' => esc_html__( 'Parses to the first name of the recipient for the message.', 'event_espresso' ), |
|
44 | - '[RECIPIENT_LNAME]' => esc_html__( 'Parses to the last name of the recipient for the message.', 'event_espresso' ), |
|
45 | - '[RECIPIENT_EMAIL]' => esc_html__( 'Parses to the email address of the recipient for the message.', 'event_espresso' ), |
|
46 | - '[RECIPIENT_REGISTRATION_CODE]' => esc_html__( 'Parses to the registration code of the recipient for the message.', 'event_espresso' ), |
|
47 | - '[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__( 'Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso' ), |
|
48 | - '[RECIPIENT_PHONE_NUMBER]' => esc_html__( 'The Phone Number for the recipient of the message.', 'event_espresso' ), |
|
49 | - '[RECIPIENT_ADDRESS]' => esc_html__( 'The Address for the recipient of the message.', 'event_espresso' ), |
|
50 | - '[RECIPIENT_ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the recipient of the message.', 'event_espresso' ), |
|
51 | - '[RECIPIENT_CITY]' => esc_html__( 'The city for the recipient of the message.', 'event_espresso' ), |
|
52 | - '[RECIPIENT_ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso' ), |
|
53 | - '[RECIPIENT_ADDRESS_STATE]' => esc_html__( 'The state/province for the recipient of the message.', 'event_espresso' ), |
|
54 | - '[RECIPIENT_COUNTRY]' => esc_html__( 'The country for the recipient of the message.', 'event_espresso' ), |
|
55 | - '[RECIPIENT_ANSWER_*]' => esc_html__( 'This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso' ), |
|
56 | - '[RECIPIENT_TOTAL_AMOUNT_PAID]' => esc_html__( 'If a single registration related to the recipient is available, that is used to retrieve the total amount that has been paid for this recipient. Otherwise the value of 0 is printed.', 'event_espresso' ) |
|
43 | + '[RECIPIENT_FNAME]' => esc_html__('Parses to the first name of the recipient for the message.', 'event_espresso'), |
|
44 | + '[RECIPIENT_LNAME]' => esc_html__('Parses to the last name of the recipient for the message.', 'event_espresso'), |
|
45 | + '[RECIPIENT_EMAIL]' => esc_html__('Parses to the email address of the recipient for the message.', 'event_espresso'), |
|
46 | + '[RECIPIENT_REGISTRATION_CODE]' => esc_html__('Parses to the registration code of the recipient for the message.', 'event_espresso'), |
|
47 | + '[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__('Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso'), |
|
48 | + '[RECIPIENT_PHONE_NUMBER]' => esc_html__('The Phone Number for the recipient of the message.', 'event_espresso'), |
|
49 | + '[RECIPIENT_ADDRESS]' => esc_html__('The Address for the recipient of the message.', 'event_espresso'), |
|
50 | + '[RECIPIENT_ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the recipient of the message.', 'event_espresso'), |
|
51 | + '[RECIPIENT_CITY]' => esc_html__('The city for the recipient of the message.', 'event_espresso'), |
|
52 | + '[RECIPIENT_ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso'), |
|
53 | + '[RECIPIENT_ADDRESS_STATE]' => esc_html__('The state/province for the recipient of the message.', 'event_espresso'), |
|
54 | + '[RECIPIENT_COUNTRY]' => esc_html__('The country for the recipient of the message.', 'event_espresso'), |
|
55 | + '[RECIPIENT_ANSWER_*]' => esc_html__('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso'), |
|
56 | + '[RECIPIENT_TOTAL_AMOUNT_PAID]' => esc_html__('If a single registration related to the recipient is available, that is used to retrieve the total amount that has been paid for this recipient. Otherwise the value of 0 is printed.', 'event_espresso') |
|
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | - protected function _parser( $shortcode ) { |
|
62 | + protected function _parser($shortcode) { |
|
63 | 63 | |
64 | 64 | //make sure we end up with a copy of the EE_Messages_Addressee object |
65 | 65 | $this->_recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
66 | 66 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
67 | - && is_array( $this->_data ) |
|
68 | - && isset( $this->_data['data'] ) |
|
67 | + && is_array($this->_data) |
|
68 | + && isset($this->_data['data']) |
|
69 | 69 | && $this->_data['data'] instanceof EE_Messages_Addressee |
70 | - ? $this->_data['data'] : |
|
71 | - $this->_recipient; |
|
70 | + ? $this->_data['data'] : $this->_recipient; |
|
72 | 71 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
73 | - && ! empty( $this->_extra_data['data'] ) |
|
72 | + && ! empty($this->_extra_data['data']) |
|
74 | 73 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
75 | 74 | ? $this->_extra_data['data'] |
76 | 75 | : $this->_recipient; |
77 | 76 | |
78 | - if ( ! $this->_recipient instanceof EE_Messages_Addressee ) { |
|
77 | + if ( ! $this->_recipient instanceof EE_Messages_Addressee) { |
|
79 | 78 | return ''; |
80 | 79 | } |
81 | 80 | |
82 | 81 | $attendee = $this->_recipient->att_obj; |
83 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
82 | + if ( ! $attendee instanceof EE_Attendee) { |
|
84 | 83 | return ''; |
85 | 84 | } |
86 | 85 | |
87 | - $this->_registrations_for_recipient = isset( $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] ) |
|
88 | - ? $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] |
|
86 | + $this->_registrations_for_recipient = isset($this->_recipient->attendees[$attendee->ID()]['reg_objs']) |
|
87 | + ? $this->_recipient->attendees[$attendee->ID()]['reg_objs'] |
|
89 | 88 | : array(); |
90 | 89 | |
91 | - switch ( $shortcode ) { |
|
90 | + switch ($shortcode) { |
|
92 | 91 | case '[RECIPIENT_FNAME]' : |
93 | 92 | return $attendee->fname(); |
94 | 93 | break; |
@@ -102,14 +101,14 @@ discard block |
||
102 | 101 | break; |
103 | 102 | |
104 | 103 | case '[RECIPIENT_REGISTRATION_CODE]' : |
105 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
104 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
106 | 105 | return ''; |
107 | 106 | } |
108 | 107 | return $this->_get_reg_code(); |
109 | 108 | break; |
110 | 109 | |
111 | 110 | case '[RECIPIENT_EDIT_REGISTRATION_LINK]' : |
112 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
111 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
113 | 112 | return ''; |
114 | 113 | } |
115 | 114 | return $this->_recipient->reg_obj->edit_attendee_information_url(); |
@@ -151,23 +150,23 @@ discard block |
||
151 | 150 | break; |
152 | 151 | } |
153 | 152 | |
154 | - if ( strpos( $shortcode, '[RECIPIENT_ANSWER_*' ) !== false ) { |
|
155 | - $shortcode = str_replace( '[RECIPIENT_ANSWER_*', '', $shortcode ); |
|
156 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
153 | + if (strpos($shortcode, '[RECIPIENT_ANSWER_*') !== false) { |
|
154 | + $shortcode = str_replace('[RECIPIENT_ANSWER_*', '', $shortcode); |
|
155 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
157 | 156 | |
158 | 157 | |
159 | 158 | //now let's figure out what question has this text |
160 | - if ( empty( $this->_recipient->questions ) || ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
159 | + if (empty($this->_recipient->questions) || ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
161 | 160 | return ''; |
162 | 161 | } |
163 | 162 | |
164 | - foreach ( $this->_recipient->questions as $ansid => $question ) { |
|
163 | + foreach ($this->_recipient->questions as $ansid => $question) { |
|
165 | 164 | if ( |
166 | 165 | $question instanceof EE_Question |
167 | 166 | && $question->display_text() == $shortcode |
168 | - && isset( $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ] ) |
|
167 | + && isset($this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]) |
|
169 | 168 | ) { |
170 | - return $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ]->get_pretty( 'ANS_value', 'no_wpautop' ); |
|
169 | + return $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
171 | 170 | } |
172 | 171 | } |
173 | 172 | } |
@@ -198,53 +197,53 @@ discard block |
||
198 | 197 | protected function _get_reg_code() { |
199 | 198 | |
200 | 199 | //if only one related registration for the recipient then just return that reg code. |
201 | - if ( count( $this->_registrations_for_recipient ) <= 1 ) { |
|
200 | + if (count($this->_registrations_for_recipient) <= 1) { |
|
202 | 201 | return $this->_recipient->reg_obj->reg_code(); |
203 | 202 | } |
204 | 203 | |
205 | 204 | //k more than one registration so let's see if we can get specific to context |
206 | 205 | //are we parsing event_list? |
207 | - if ( $this->_data instanceof EE_Event ) { |
|
206 | + if ($this->_data instanceof EE_Event) { |
|
208 | 207 | $reg_code = array(); |
209 | 208 | //loop through registrations for recipient and see if there is a match for this event |
210 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
211 | - if ( $reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID() ) { |
|
209 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
210 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID()) { |
|
212 | 211 | $reg_code[] = $reg->reg_code(); |
213 | 212 | } |
214 | 213 | } |
215 | - return implode( ', ', $reg_code ); |
|
214 | + return implode(', ', $reg_code); |
|
216 | 215 | } |
217 | 216 | |
218 | 217 | //are we parsing ticket list? |
219 | - if ( $this->_data instanceof EE_Ticket ) { |
|
218 | + if ($this->_data instanceof EE_Ticket) { |
|
220 | 219 | $reg_code = array(); |
221 | 220 | //loop through each registration for recipient and see if there is a match for this ticket |
222 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
223 | - if ( $reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID() ) { |
|
221 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
222 | + if ($reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID()) { |
|
224 | 223 | $reg_code = $reg->reg_code(); |
225 | 224 | } |
226 | 225 | } |
227 | - return implode( ', ', $reg_code ); |
|
226 | + return implode(', ', $reg_code); |
|
228 | 227 | } |
229 | 228 | |
230 | 229 | //do we have a specific reg_obj? Let's use it |
231 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
230 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
232 | 231 | return $this->_data->reg_obj->reg_code(); |
233 | 232 | } |
234 | 233 | |
235 | 234 | //do we have a specific reg_obj? Let's use it |
236 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
235 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
237 | 236 | return $this->_data->reg_obj->reg_code(); |
238 | 237 | } |
239 | 238 | |
240 | 239 | //not able to determine the single reg code so let's return a comma delimited list of reg codes. |
241 | 240 | $reg_code = array(); |
242 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
243 | - if ( $reg instanceof EE_Registration ) { |
|
241 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
242 | + if ($reg instanceof EE_Registration) { |
|
244 | 243 | $reg_code[] = $reg->reg_code(); |
245 | 244 | } |
246 | 245 | } |
247 | - return implode( ', ', $reg_code ); |
|
246 | + return implode(', ', $reg_code); |
|
248 | 247 | } |
249 | 248 | |
250 | 249 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | /** |
43 | 43 | * EE_Attendee_Shortcodes constructor. |
44 | - */ |
|
44 | + */ |
|
45 | 45 | public function __construct() { |
46 | 46 | parent::__construct(); |
47 | 47 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -49,25 +49,25 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _init_props() { |
52 | - $this->label = esc_html__( 'Attendee Shortcodes', 'event_espresso' ); |
|
53 | - $this->description = esc_html__( 'All shortcodes specific to attendee related data', 'event_espresso' ); |
|
52 | + $this->label = esc_html__('Attendee Shortcodes', 'event_espresso'); |
|
53 | + $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso'); |
|
54 | 54 | $this->_shortcodes = array( |
55 | - '[FNAME]' => esc_html__( 'First Name of an attendee.', 'event_espresso' ), |
|
56 | - '[LNAME]' => esc_html__( 'Last Name of an attendee.', 'event_espresso' ), |
|
57 | - '[ATTENDEE_EMAIL]' => esc_html__( 'Email address for the attendee.', 'event_espresso' ), |
|
58 | - '[EDIT_ATTENDEE_LINK]' => esc_html__( 'Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso' ), |
|
59 | - '[REGISTRATION_CODE]' => esc_html__( 'Unique Registration Code for the registration', 'event_espresso' ), |
|
60 | - '[REGISTRATION_STATUS_ID]' => esc_html__( 'Parses to the registration status for the attendee', 'event_espresso' ), |
|
61 | - '[REGISTRATION_STATUS_LABEL]' => esc_html__( 'Parses to the status label for the registrant', 'event_espresso' ), |
|
62 | - '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( 'Parses to the total amount paid for this registration.', 'event_espresso' ), |
|
63 | - '[FRONTEND_EDIT_REG_LINK]' => esc_html__( 'Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso' ), |
|
64 | - '[PHONE_NUMBER]' => esc_html__( 'The Phone Number for the Registration.', 'event_espresso' ), |
|
65 | - '[ADDRESS]' => esc_html__( 'The Address for the Registration', 'event_espresso' ), |
|
66 | - '[ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the registration.', 'event_espresso' ), |
|
67 | - '[CITY]' => esc_html__( 'The city for the registration.', 'event_espresso' ), |
|
68 | - '[ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the Registration.', 'event_espresso' ), |
|
69 | - '[ADDRESS_STATE]' => esc_html__( 'The state/province for the registration.', 'event_espresso' ), |
|
70 | - '[COUNTRY]' => esc_html__( 'The country for the registration.', 'event_espresso' ) |
|
55 | + '[FNAME]' => esc_html__('First Name of an attendee.', 'event_espresso'), |
|
56 | + '[LNAME]' => esc_html__('Last Name of an attendee.', 'event_espresso'), |
|
57 | + '[ATTENDEE_EMAIL]' => esc_html__('Email address for the attendee.', 'event_espresso'), |
|
58 | + '[EDIT_ATTENDEE_LINK]' => esc_html__('Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso'), |
|
59 | + '[REGISTRATION_CODE]' => esc_html__('Unique Registration Code for the registration', 'event_espresso'), |
|
60 | + '[REGISTRATION_STATUS_ID]' => esc_html__('Parses to the registration status for the attendee', 'event_espresso'), |
|
61 | + '[REGISTRATION_STATUS_LABEL]' => esc_html__('Parses to the status label for the registrant', 'event_espresso'), |
|
62 | + '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__('Parses to the total amount paid for this registration.', 'event_espresso'), |
|
63 | + '[FRONTEND_EDIT_REG_LINK]' => esc_html__('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'), |
|
64 | + '[PHONE_NUMBER]' => esc_html__('The Phone Number for the Registration.', 'event_espresso'), |
|
65 | + '[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'), |
|
66 | + '[ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the registration.', 'event_espresso'), |
|
67 | + '[CITY]' => esc_html__('The city for the registration.', 'event_espresso'), |
|
68 | + '[ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the Registration.', 'event_espresso'), |
|
69 | + '[ADDRESS_STATE]' => esc_html__('The state/province for the registration.', 'event_espresso'), |
|
70 | + '[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso') |
|
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @return string |
82 | 82 | * @throws \EE_Error |
83 | 83 | */ |
84 | - protected function _parser( $shortcode ) { |
|
84 | + protected function _parser($shortcode) { |
|
85 | 85 | |
86 | 86 | |
87 | - $this->_xtra = ! empty( $this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
87 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
88 | 88 | ? $this->_extra_data['data'] |
89 | 89 | : null; |
90 | 90 | |
@@ -93,34 +93,34 @@ discard block |
||
93 | 93 | ? null |
94 | 94 | : $this->_data; |
95 | 95 | |
96 | - if ( ! $registration instanceof EE_Registration ) { |
|
96 | + if ( ! $registration instanceof EE_Registration) { |
|
97 | 97 | //let's attempt to get the txn_id for the error message. |
98 | - $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction |
|
98 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
|
99 | 99 | ? $this->_xtra->txn->ID() |
100 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
101 | - $msg = esc_html__( 'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso' ); |
|
100 | + : esc_html__('Unknown', 'event_espresso'); |
|
101 | + $msg = esc_html__('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso'); |
|
102 | 102 | $dev_msg = sprintf( |
103 | - esc_html__( 'The transaction ID for this request is: %s', 'event_espresso' ), |
|
103 | + esc_html__('The transaction ID for this request is: %s', 'event_espresso'), |
|
104 | 104 | $txn_id |
105 | 105 | ); |
106 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
106 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //attendee obj for this registration |
110 | - $attendee = isset( $this->_xtra->registrations[ $registration->ID() ]['att_obj'] ) |
|
111 | - ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
112 | - : null ; |
|
110 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) |
|
111 | + ? $this->_xtra->registrations[$registration->ID()]['att_obj'] |
|
112 | + : null; |
|
113 | 113 | |
114 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
115 | - $msg = esc_html__( 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso' ); |
|
114 | + if ( ! $attendee instanceof EE_Attendee) { |
|
115 | + $msg = esc_html__('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso'); |
|
116 | 116 | $dev_msg = sprintf( |
117 | - esc_html__( 'The registration ID for this request is: %s', 'event_espresso' ), |
|
117 | + esc_html__('The registration ID for this request is: %s', 'event_espresso'), |
|
118 | 118 | $registration->ID() |
119 | 119 | ); |
120 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
120 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
121 | 121 | } |
122 | 122 | |
123 | - switch ( $shortcode ) { |
|
123 | + switch ($shortcode) { |
|
124 | 124 | |
125 | 125 | case '[FNAME]' : |
126 | 126 | return $attendee->fname(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | 116 | if ( $field_obj instanceof \EE_Infinite_Integer_Field |
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
117 | + && in_array( $original_value, array( null, '' ), true ) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | 120 | } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $original_value, |
175 | 175 | $requested_version |
176 | 176 | ); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | 180 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | $requested_version, |
49 | 49 | $timezone_string = 'UTC' |
50 | 50 | ) { |
51 | - if ( is_array( $original_value_maybe_array ) ) { |
|
51 | + if (is_array($original_value_maybe_array)) { |
|
52 | 52 | $new_value_maybe_array = array(); |
53 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
54 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( |
|
53 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
54 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json( |
|
55 | 55 | $field_obj, |
56 | 56 | $array_item, |
57 | 57 | $requested_version, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param string $request_version (eg 4.8.36) |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ) { |
|
81 | - if ( is_array( $original_value_maybe_array ) ) { |
|
80 | + public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) { |
|
81 | + if (is_array($original_value_maybe_array)) { |
|
82 | 82 | $new_value_maybe_array = array(); |
83 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
84 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( |
|
83 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
84 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json( |
|
85 | 85 | $field_obj, |
86 | 86 | $array_item, |
87 | 87 | $request_version |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | $timezone_string = 'UTC' |
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | - if ( $field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
116 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | + && in_array($original_value, array(null, ''), true) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
120 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
121 | 121 | //treat the provided value as being in this timezone |
122 | - $offset_secs_string = $field_obj->get_timezone_offset( new \DateTimeZone( $timezone_string ) ); |
|
123 | - $offset_secs = (int) substr( $offset_secs_string, 1 ); |
|
124 | - $offset_sign = substr( $offset_secs_string, 0, 1 ) ? substr( $offset_secs_string, 0, 1 ) : '+'; |
|
122 | + $offset_secs_string = $field_obj->get_timezone_offset(new \DateTimeZone($timezone_string)); |
|
123 | + $offset_secs = (int) substr($offset_secs_string, 1); |
|
124 | + $offset_sign = substr($offset_secs_string, 0, 1) ? substr($offset_secs_string, 0, 1) : '+'; |
|
125 | 125 | $offset_string = |
126 | 126 | str_pad( |
127 | - floor( $offset_secs / HOUR_IN_SECONDS ), |
|
127 | + floor($offset_secs / HOUR_IN_SECONDS), |
|
128 | 128 | 2, |
129 | 129 | '0', |
130 | 130 | STR_PAD_LEFT |
131 | 131 | ) |
132 | 132 | . ':' |
133 | 133 | . str_pad( |
134 | - ( $offset_secs % HOUR_IN_SECONDS ) / MINUTE_IN_SECONDS, |
|
134 | + ($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS, |
|
135 | 135 | 2, |
136 | 136 | '0', |
137 | 137 | STR_PAD_LEFT |
138 | 138 | ); |
139 | - $new_value = rest_parse_date( $original_value . $offset_sign . $offset_string ); |
|
139 | + $new_value = rest_parse_date($original_value.$offset_sign.$offset_string); |
|
140 | 140 | } else { |
141 | 141 | $new_value = $original_value; |
142 | 142 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | >>>>>>> master |
158 | 158 | * @return mixed |
159 | 159 | */ |
160 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
161 | - if( $original_value === EE_INF ) { |
|
160 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
161 | + if ($original_value === EE_INF) { |
|
162 | 162 | $new_value = Model_Data_Translator::ee_inf_in_rest; |
163 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
164 | - if( $original_value instanceof \DateTime ) { |
|
165 | - $new_value = $original_value->format( 'Y-m-d H:i:s' ); |
|
166 | - } elseif( is_int( $original_value ) ) { |
|
167 | - $new_value = date( 'Y-m-d H:i:s', $original_value ); |
|
163 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
164 | + if ($original_value instanceof \DateTime) { |
|
165 | + $new_value = $original_value->format('Y-m-d H:i:s'); |
|
166 | + } elseif (is_int($original_value)) { |
|
167 | + $new_value = date('Y-m-d H:i:s', $original_value); |
|
168 | 168 | } else { |
169 | 169 | $new_value = $original_value; |
170 | 170 | } |
171 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
171 | + $new_value = mysql_to_rfc3339($new_value); |
|
172 | 172 | } else { |
173 | 173 | $new_value = $original_value; |
174 | 174 | } |
175 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
175 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
176 | 176 | $new_value, |
177 | 177 | $field_obj, |
178 | 178 | $original_value, |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @return array |
193 | 193 | * @throws \EE_Error |
194 | 194 | */ |
195 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
195 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
196 | 196 | $query_param_for_models = array(); |
197 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
198 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ); |
|
197 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
198 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key); |
|
199 | 199 | $field = Model_Data_Translator::deduce_field_from_query_param( |
200 | 200 | $query_param_sans_stars, |
201 | 201 | $model |
202 | 202 | ); |
203 | 203 | //double-check is it a *_gmt field? |
204 | - if( ! $field instanceof \EE_Model_Field_Base |
|
205 | - && Model_Data_Translator::is_gmt_date_field_name( $query_param_sans_stars ) ) { |
|
204 | + if ( ! $field instanceof \EE_Model_Field_Base |
|
205 | + && Model_Data_Translator::is_gmt_date_field_name($query_param_sans_stars)) { |
|
206 | 206 | //yep, take off '_gmt', and find the field |
207 | - $query_param_key = Model_Data_Translator::remove_gmt_from_field_name( $query_param_sans_stars ); |
|
207 | + $query_param_key = Model_Data_Translator::remove_gmt_from_field_name($query_param_sans_stars); |
|
208 | 208 | $field = Model_Data_Translator::deduce_field_from_query_param( |
209 | 209 | $query_param_key, |
210 | 210 | $model |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | //so it's not a GMT field. Set the timezone on the model to the default |
215 | 215 | $timezone = \EEH_DTT_Helper::get_valid_timezone_string(); |
216 | 216 | } |
217 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
217 | + if ($field instanceof \EE_Model_Field_Base) { |
|
218 | 218 | //did they specify an operator? |
219 | - if( is_array( $query_param_value ) ) { |
|
220 | - $op = $query_param_value[ 0 ]; |
|
221 | - $translated_value = array( $op ); |
|
222 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
223 | - $value = $query_param_value[ 1 ]; |
|
224 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version, $timezone ); |
|
219 | + if (is_array($query_param_value)) { |
|
220 | + $op = $query_param_value[0]; |
|
221 | + $translated_value = array($op); |
|
222 | + if (isset($query_param_value[1])) { |
|
223 | + $value = $query_param_value[1]; |
|
224 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version, $timezone); |
|
225 | 225 | } |
226 | 226 | } else { |
227 | - $translated_value = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version, $timezone ); |
|
227 | + $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version, $timezone); |
|
228 | 228 | } |
229 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
229 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
230 | 230 | } else { |
231 | 231 | //so it's not for a field, assume it's a logic query param key |
232 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
232 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | return $query_param_for_models; |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param string $field_name |
242 | 242 | * @return boolean |
243 | 243 | */ |
244 | - public static function is_gmt_date_field_name( $field_name ) { |
|
244 | + public static function is_gmt_date_field_name($field_name) { |
|
245 | 245 | return substr( |
246 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ), |
|
246 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name), |
|
247 | 247 | -4, |
248 | 248 | 4 |
249 | 249 | ) === '_gmt'; |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | * @param string $field_name |
255 | 255 | * @return string |
256 | 256 | */ |
257 | - public static function remove_gmt_from_field_name( $field_name ) { |
|
258 | - if( ! Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
257 | + public static function remove_gmt_from_field_name($field_name) { |
|
258 | + if ( ! Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
259 | 259 | return $field_name; |
260 | 260 | } |
261 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ); |
|
261 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name); |
|
262 | 262 | $query_param_sans_gmt_and_sans_stars = substr( |
263 | 263 | $query_param_sans_stars, |
264 | 264 | 0, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | '_gmt' |
268 | 268 | ) |
269 | 269 | ); |
270 | - return str_replace( $query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name ); |
|
270 | + return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param string $field_name |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public static function prepare_field_name_from_json( $field_name ) { |
|
279 | - if( Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
280 | - return Model_Data_Translator::remove_gmt_from_field_name( $field_name ); |
|
278 | + public static function prepare_field_name_from_json($field_name) { |
|
279 | + if (Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
280 | + return Model_Data_Translator::remove_gmt_from_field_name($field_name); |
|
281 | 281 | } |
282 | 282 | return $field_name; |
283 | 283 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @param array $field_names |
288 | 288 | * @return array of field names (possibly include model prefixes) |
289 | 289 | */ |
290 | - public static function prepare_field_names_from_json( array $field_names ) { |
|
290 | + public static function prepare_field_names_from_json(array $field_names) { |
|
291 | 291 | $new_array = array(); |
292 | - foreach( $field_names as $key => $field_name ) { |
|
293 | - $new_array[ $key ] = Model_Data_Translator::prepare_field_name_from_json( $field_name ); |
|
292 | + foreach ($field_names as $key => $field_name) { |
|
293 | + $new_array[$key] = Model_Data_Translator::prepare_field_name_from_json($field_name); |
|
294 | 294 | } |
295 | 295 | return $new_array; |
296 | 296 | } |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param array $field_names_as_keys |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public static function prepare_field_names_in_array_keys_from_json( array $field_names_as_keys ) { |
|
304 | + public static function prepare_field_names_in_array_keys_from_json(array $field_names_as_keys) { |
|
305 | 305 | $new_array = array(); |
306 | - foreach( $field_names_as_keys as $field_name => $value ) { |
|
307 | - $new_array[ Model_Data_Translator::prepare_field_name_from_json( $field_name ) ] = $value; |
|
306 | + foreach ($field_names_as_keys as $field_name => $value) { |
|
307 | + $new_array[Model_Data_Translator::prepare_field_name_from_json($field_name)] = $value; |
|
308 | 308 | } |
309 | 309 | return $new_array; |
310 | 310 | } |
@@ -317,27 +317,27 @@ discard block |
||
317 | 317 | * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API |
318 | 318 | * @return array which can be passed into the EE4 REST API when querying a model resource |
319 | 319 | */ |
320 | - public static function prepare_query_params_for_rest_api( array $model_query_params, \EEM_Base $model, $requested_version = null ) { |
|
321 | - if( $requested_version === null ) { |
|
322 | - $requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ; |
|
320 | + public static function prepare_query_params_for_rest_api(array $model_query_params, \EEM_Base $model, $requested_version = null) { |
|
321 | + if ($requested_version === null) { |
|
322 | + $requested_version = \EED_Core_Rest_Api::latest_rest_api_version(); |
|
323 | 323 | } |
324 | 324 | $rest_query_params = $model_query_params; |
325 | - if ( isset( $model_query_params[0] ) ) { |
|
326 | - $rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | - $model_query_params[ 0 ], |
|
325 | + if (isset($model_query_params[0])) { |
|
326 | + $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | + $model_query_params[0], |
|
328 | 328 | $model, |
329 | 329 | $requested_version |
330 | 330 | ); |
331 | - unset( $rest_query_params[0] ); |
|
331 | + unset($rest_query_params[0]); |
|
332 | 332 | } |
333 | - if ( isset( $model_query_params[ 'having' ] ) ) { |
|
334 | - $rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | - $model_query_params[ 'having' ], |
|
333 | + if (isset($model_query_params['having'])) { |
|
334 | + $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | + $model_query_params['having'], |
|
336 | 336 | $model, |
337 | 337 | $requested_version |
338 | 338 | ); |
339 | 339 | } |
340 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version ); |
|
340 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,29 +347,29 @@ discard block |
||
347 | 347 | * @param string $requested_version eg "4.8.36" |
348 | 348 | * @return array ready for use in the rest api query params |
349 | 349 | */ |
350 | - public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
350 | + public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
351 | 351 | $query_param_for_models = array(); |
352 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
352 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
353 | 353 | $field = Model_Data_Translator::deduce_field_from_query_param( |
354 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
354 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
355 | 355 | $model |
356 | 356 | ); |
357 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
357 | + if ($field instanceof \EE_Model_Field_Base) { |
|
358 | 358 | //did they specify an operator? |
359 | - if( is_array( $query_param_value ) ) { |
|
360 | - $op = $query_param_value[ 0 ]; |
|
361 | - $translated_value = array( $op ); |
|
362 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
363 | - $value = $query_param_value[ 1 ]; |
|
364 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version ); |
|
359 | + if (is_array($query_param_value)) { |
|
360 | + $op = $query_param_value[0]; |
|
361 | + $translated_value = array($op); |
|
362 | + if (isset($query_param_value[1])) { |
|
363 | + $value = $query_param_value[1]; |
|
364 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version); |
|
365 | 365 | } |
366 | 366 | } else { |
367 | - $translated_value = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version ); |
|
367 | + $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version); |
|
368 | 368 | } |
369 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
369 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
370 | 370 | } else { |
371 | 371 | //so it's not for a field, assume it's a logic query param key |
372 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version ); |
|
372 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | return $query_param_for_models; |
@@ -381,11 +381,11 @@ discard block |
||
381 | 381 | * @param $condition_query_param_key |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
384 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
385 | 385 | $pos_of_star = strpos($condition_query_param_key, '*'); |
386 | - if($pos_of_star === FALSE){ |
|
386 | + if ($pos_of_star === FALSE) { |
|
387 | 387 | return $condition_query_param_key; |
388 | - }else{ |
|
388 | + } else { |
|
389 | 389 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
390 | 390 | return $condition_query_param_sans_star; |
391 | 391 | } |
@@ -401,26 +401,26 @@ discard block |
||
401 | 401 | * @return \EE_Model_Field_Base |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
404 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
405 | 405 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
406 | 406 | //which will help us find the database table and column |
407 | 407 | |
408 | - $query_param_parts = explode(".",$query_param_name); |
|
409 | - if(empty($query_param_parts)){ |
|
410 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
408 | + $query_param_parts = explode(".", $query_param_name); |
|
409 | + if (empty($query_param_parts)) { |
|
410 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
411 | 411 | } |
412 | 412 | $number_of_parts = count($query_param_parts); |
413 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
414 | - if($number_of_parts == 1){ |
|
413 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
414 | + if ($number_of_parts == 1) { |
|
415 | 415 | $field_name = $last_query_param_part; |
416 | - }else{// $number_of_parts >= 2 |
|
416 | + } else {// $number_of_parts >= 2 |
|
417 | 417 | //the last part is the column name, and there are only 2parts. therefore... |
418 | 418 | $field_name = $last_query_param_part; |
419 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
419 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
420 | 420 | } |
421 | - try{ |
|
421 | + try { |
|
422 | 422 | return $model->field_settings_for($field_name); |
423 | - }catch(\EE_Error $e){ |
|
423 | + } catch (\EE_Error $e) { |
|
424 | 424 | return null; |
425 | 425 | } |
426 | 426 | } |
@@ -6,8 +6,8 @@ discard block |
||
6 | 6 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
7 | 7 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
8 | 8 | |
9 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
10 | - exit( 'No direct script access allowed' ); |
|
9 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * @param \WP_REST_Request $request |
47 | 47 | * @return \WP_REST_Response|\WP_Error |
48 | 48 | */ |
49 | - public static function handle_request_get_all( \WP_REST_Request $request) { |
|
49 | + public static function handle_request_get_all(\WP_REST_Request $request) { |
|
50 | 50 | $controller = new Read(); |
51 | - try{ |
|
51 | + try { |
|
52 | 52 | $matches = $controller->parse_route( |
53 | 53 | $request->get_route(), |
54 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~', |
|
55 | - array( 'version', 'model' ) |
|
54 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~', |
|
55 | + array('version', 'model') |
|
56 | 56 | ); |
57 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
58 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
59 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
57 | + $controller->set_requested_version($matches['version']); |
|
58 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
59 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
60 | 60 | return $controller->send_response( |
61 | 61 | new \WP_Error( |
62 | 62 | 'endpoint_parsing_error', |
63 | 63 | sprintf( |
64 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
64 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
65 | 65 | $model_name_singular |
66 | 66 | ) |
67 | 67 | ) |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | } |
70 | 70 | return $controller->send_response( |
71 | 71 | $controller->get_entities_from_model( |
72 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
72 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
73 | 73 | $request |
74 | 74 | ) |
75 | 75 | ); |
76 | - } catch( \Exception $e ) { |
|
77 | - return $controller->send_response( $e ); |
|
76 | + } catch (\Exception $e) { |
|
77 | + return $controller->send_response($e); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -84,21 +84,21 @@ discard block |
||
84 | 84 | * @param \WP_REST_Request $request |
85 | 85 | * @return \WP_REST_Response|\WP_Error |
86 | 86 | */ |
87 | - public static function handle_request_get_one( \WP_REST_Request $request ) { |
|
87 | + public static function handle_request_get_one(\WP_REST_Request $request) { |
|
88 | 88 | $controller = new Read(); |
89 | - try{ |
|
89 | + try { |
|
90 | 90 | $matches = $controller->parse_route( |
91 | 91 | $request->get_route(), |
92 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~', |
|
93 | - array( 'version', 'model', 'id' ) ); |
|
94 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
95 | - $model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
96 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) { |
|
92 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~', |
|
93 | + array('version', 'model', 'id') ); |
|
94 | + $controller->set_requested_version($matches['version']); |
|
95 | + $model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
96 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) { |
|
97 | 97 | return $controller->send_response( |
98 | 98 | new \WP_Error( |
99 | 99 | 'endpoint_parsing_error', |
100 | 100 | sprintf( |
101 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
101 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
102 | 102 | $model_name_singular |
103 | 103 | ) |
104 | 104 | ) |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | } |
107 | 107 | return $controller->send_response( |
108 | 108 | $controller->get_entity_from_model( |
109 | - $controller->get_model_version_info()->load_model( $model_name_singular ), |
|
109 | + $controller->get_model_version_info()->load_model($model_name_singular), |
|
110 | 110 | $request |
111 | 111 | ) |
112 | 112 | ); |
113 | - } catch( \Exception $e ) { |
|
114 | - return $controller->send_response( $e ); |
|
113 | + } catch (\Exception $e) { |
|
114 | + return $controller->send_response($e); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -123,40 +123,40 @@ discard block |
||
123 | 123 | * @param \WP_REST_Request $request |
124 | 124 | * @return \WP_REST_Response|\WP_Error |
125 | 125 | */ |
126 | - public static function handle_request_get_related( \WP_REST_Request $request ) { |
|
126 | + public static function handle_request_get_related(\WP_REST_Request $request) { |
|
127 | 127 | $controller = new Read(); |
128 | - try{ |
|
128 | + try { |
|
129 | 129 | $matches = $controller->parse_route( |
130 | 130 | $request->get_route(), |
131 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~', |
|
132 | - array( 'version', 'model', 'id', 'related_model' ) |
|
131 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~', |
|
132 | + array('version', 'model', 'id', 'related_model') |
|
133 | 133 | ); |
134 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
135 | - $main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] ); |
|
136 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) { |
|
134 | + $controller->set_requested_version($matches['version']); |
|
135 | + $main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']); |
|
136 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) { |
|
137 | 137 | return $controller->send_response( |
138 | 138 | new \WP_Error( |
139 | 139 | 'endpoint_parsing_error', |
140 | 140 | sprintf( |
141 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
141 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
142 | 142 | $main_model_name_singular |
143 | 143 | ) |
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | } |
147 | - $main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular ); |
|
147 | + $main_model = $controller->get_model_version_info()->load_model($main_model_name_singular); |
|
148 | 148 | //assume the related model name is plural and try to find the model's name |
149 | - $related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] ); |
|
150 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
149 | + $related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']); |
|
150 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
151 | 151 | //so the word didn't singularize well. Maybe that's just because it's a singular word? |
152 | - $related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] ); |
|
152 | + $related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']); |
|
153 | 153 | } |
154 | - if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) { |
|
154 | + if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) { |
|
155 | 155 | return $controller->send_response( |
156 | 156 | new \WP_Error( |
157 | 157 | 'endpoint_parsing_error', |
158 | 158 | sprintf( |
159 | - __( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ), |
|
159 | + __('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'), |
|
160 | 160 | $related_model_name_singular |
161 | 161 | ) |
162 | 162 | ) |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | |
166 | 166 | return $controller->send_response( |
167 | 167 | $controller->get_entities_from_relation( |
168 | - $request->get_param( 'id' ), |
|
169 | - $main_model->related_settings_for( $related_model_name_singular ) , |
|
168 | + $request->get_param('id'), |
|
169 | + $main_model->related_settings_for($related_model_name_singular), |
|
170 | 170 | $request |
171 | 171 | ) |
172 | 172 | ); |
173 | - } catch( \Exception $e ) { |
|
174 | - return $controller->send_response( $e ); |
|
173 | + } catch (\Exception $e) { |
|
174 | + return $controller->send_response($e); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -184,28 +184,28 @@ discard block |
||
184 | 184 | * @param \WP_REST_Request $request |
185 | 185 | * @return array|\WP_Error |
186 | 186 | */ |
187 | - public function get_entities_from_model( $model, $request) { |
|
188 | - $query_params = $this->create_model_query_params( $model, $request->get_params() ); |
|
189 | - if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) { |
|
190 | - $model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ); |
|
187 | + public function get_entities_from_model($model, $request) { |
|
188 | + $query_params = $this->create_model_query_params($model, $request->get_params()); |
|
189 | + if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) { |
|
190 | + $model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()); |
|
191 | 191 | return new \WP_Error( |
192 | - sprintf( 'rest_%s_cannot_list', $model_name_plural ), |
|
192 | + sprintf('rest_%s_cannot_list', $model_name_plural), |
|
193 | 193 | sprintf( |
194 | - __( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ), |
|
194 | + __('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'), |
|
195 | 195 | $model_name_plural, |
196 | - Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) |
|
196 | + Capabilities::get_missing_permissions_string($model, $query_params['caps']) |
|
197 | 197 | ), |
198 | - array( 'status' => 403 ) |
|
198 | + array('status' => 403) |
|
199 | 199 | ); |
200 | 200 | } |
201 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
202 | - $this->_set_headers_from_query_params( $model, $query_params ); |
|
201 | + if ( ! $request->get_header('no_rest_headers')) { |
|
202 | + $this->_set_headers_from_query_params($model, $query_params); |
|
203 | 203 | } |
204 | 204 | /** @type array $results */ |
205 | - $results = $model->get_all_wpdb_results( $query_params ); |
|
205 | + $results = $model->get_all_wpdb_results($query_params); |
|
206 | 206 | $nice_results = array( ); |
207 | - foreach ( $results as $result ) { |
|
208 | - $nice_results[ ] = $this->create_entity_from_wpdb_result( |
|
207 | + foreach ($results as $result) { |
|
208 | + $nice_results[] = $this->create_entity_from_wpdb_result( |
|
209 | 209 | $model, |
210 | 210 | $result, |
211 | 211 | $request |
@@ -225,64 +225,64 @@ discard block |
||
225 | 225 | * @param \WP_REST_Request $request |
226 | 226 | * @return array|\WP_Error |
227 | 227 | */ |
228 | - public function get_entities_from_relation( $id, $relation, $request ) { |
|
229 | - $context = $this->validate_context( $request->get_param( 'caps' )); |
|
228 | + public function get_entities_from_relation($id, $relation, $request) { |
|
229 | + $context = $this->validate_context($request->get_param('caps')); |
|
230 | 230 | $model = $relation->get_this_model(); |
231 | 231 | $related_model = $relation->get_other_model(); |
232 | 232 | //check if they can access the 1st model object |
233 | - $query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 ); |
|
234 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
233 | + $query_params = array(array($model->primary_key_name() => $id), 'limit' => 1); |
|
234 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
235 | 235 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
236 | 236 | } |
237 | 237 | $restricted_query_params = $query_params; |
238 | - $restricted_query_params[ 'caps' ] = $context; |
|
239 | - $this->_set_debug_info( 'main model query params', $restricted_query_params ); |
|
240 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) ); |
|
238 | + $restricted_query_params['caps'] = $context; |
|
239 | + $this->_set_debug_info('main model query params', $restricted_query_params); |
|
240 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context)); |
|
241 | 241 | |
242 | - if( |
|
242 | + if ( |
|
243 | 243 | ! ( |
244 | - Capabilities::current_user_has_partial_access_to( $related_model, $context ) |
|
245 | - && $model->exists( $restricted_query_params ) |
|
244 | + Capabilities::current_user_has_partial_access_to($related_model, $context) |
|
245 | + && $model->exists($restricted_query_params) |
|
246 | 246 | ) |
247 | - ){ |
|
248 | - if( $relation instanceof \EE_Belongs_To_Relation ) { |
|
249 | - $related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() ); |
|
250 | - }else{ |
|
251 | - $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() ); |
|
247 | + ) { |
|
248 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
249 | + $related_model_name_maybe_plural = strtolower($related_model->get_this_model_name()); |
|
250 | + } else { |
|
251 | + $related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name()); |
|
252 | 252 | } |
253 | 253 | return new \WP_Error( |
254 | - sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ), |
|
254 | + sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural), |
|
255 | 255 | sprintf( |
256 | - __( 'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ), |
|
256 | + __('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'), |
|
257 | 257 | $related_model_name_maybe_plural, |
258 | 258 | $relation->get_this_model()->get_this_model_name(), |
259 | 259 | implode( |
260 | 260 | ',', |
261 | 261 | array_keys( |
262 | - Capabilities::get_missing_permissions( $related_model, $context ) |
|
262 | + Capabilities::get_missing_permissions($related_model, $context) |
|
263 | 263 | ) |
264 | 264 | ) |
265 | 265 | ), |
266 | - array( 'status' => 403 ) |
|
266 | + array('status' => 403) |
|
267 | 267 | ); |
268 | 268 | } |
269 | - $query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() ); |
|
270 | - $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id; |
|
271 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
272 | - $query_params[ 'caps' ] = $context; |
|
273 | - if( ! $request->get_header( 'no_rest_headers' ) ) { |
|
274 | - $this->_set_headers_from_query_params( $relation->get_other_model(), $query_params ); |
|
269 | + $query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params()); |
|
270 | + $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id; |
|
271 | + $query_params['default_where_conditions'] = 'none'; |
|
272 | + $query_params['caps'] = $context; |
|
273 | + if ( ! $request->get_header('no_rest_headers')) { |
|
274 | + $this->_set_headers_from_query_params($relation->get_other_model(), $query_params); |
|
275 | 275 | } |
276 | 276 | /** @type array $results */ |
277 | - $results = $relation->get_other_model()->get_all_wpdb_results( $query_params ); |
|
277 | + $results = $relation->get_other_model()->get_all_wpdb_results($query_params); |
|
278 | 278 | $nice_results = array(); |
279 | - foreach( $results as $result ) { |
|
279 | + foreach ($results as $result) { |
|
280 | 280 | $nice_result = $this->create_entity_from_wpdb_result( |
281 | 281 | $relation->get_other_model(), |
282 | 282 | $result, |
283 | 283 | $request |
284 | 284 | ); |
285 | - if( $relation instanceof \EE_HABTM_Relation ) { |
|
285 | + if ($relation instanceof \EE_HABTM_Relation) { |
|
286 | 286 | //put the unusual stuff (properties from the HABTM relation) first, and make sure |
287 | 287 | //if there are conflicts we prefer the properties from the main model |
288 | 288 | $join_model_result = $this->create_entity_from_wpdb_result( |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | $result, |
291 | 291 | $request |
292 | 292 | ); |
293 | - $joined_result = array_merge( $nice_result, $join_model_result ); |
|
293 | + $joined_result = array_merge($nice_result, $join_model_result); |
|
294 | 294 | //but keep the meta stuff from the main model |
295 | - if( isset( $nice_result['meta'] ) ){ |
|
295 | + if (isset($nice_result['meta'])) { |
|
296 | 296 | $joined_result['meta'] = $nice_result['meta']; |
297 | 297 | } |
298 | 298 | $nice_result = $joined_result; |
299 | 299 | } |
300 | 300 | $nice_results[] = $nice_result; |
301 | 301 | } |
302 | - if( $relation instanceof \EE_Belongs_To_Relation ){ |
|
303 | - return array_shift( $nice_results ); |
|
304 | - }else{ |
|
302 | + if ($relation instanceof \EE_Belongs_To_Relation) { |
|
303 | + return array_shift($nice_results); |
|
304 | + } else { |
|
305 | 305 | return $nice_results; |
306 | 306 | } |
307 | 307 | } |
@@ -314,30 +314,30 @@ discard block |
||
314 | 314 | * @param array $query_params |
315 | 315 | * @return void |
316 | 316 | */ |
317 | - protected function _set_headers_from_query_params( $model, $query_params ) { |
|
318 | - $this->_set_debug_info( 'model query params', $query_params ); |
|
319 | - $this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) ); |
|
317 | + protected function _set_headers_from_query_params($model, $query_params) { |
|
318 | + $this->_set_debug_info('model query params', $query_params); |
|
319 | + $this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps'])); |
|
320 | 320 | //normally the limit to a 2-part array, where the 2nd item is the limit |
321 | - if( ! isset( $query_params[ 'limit' ] ) ) { |
|
322 | - $query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
321 | + if ( ! isset($query_params['limit'])) { |
|
322 | + $query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
323 | 323 | } |
324 | - if( is_array( $query_params[ 'limit' ] ) ) { |
|
325 | - $limit_parts = $query_params[ 'limit' ]; |
|
324 | + if (is_array($query_params['limit'])) { |
|
325 | + $limit_parts = $query_params['limit']; |
|
326 | 326 | } else { |
327 | - $limit_parts = explode(',', $query_params[ 'limit' ] ); |
|
328 | - if( count( $limit_parts ) == 1 ){ |
|
329 | - $limit_parts = array(0, $limit_parts[ 0 ] ); |
|
327 | + $limit_parts = explode(',', $query_params['limit']); |
|
328 | + if (count($limit_parts) == 1) { |
|
329 | + $limit_parts = array(0, $limit_parts[0]); |
|
330 | 330 | } |
331 | 331 | } |
332 | 332 | //remove the group by and having parts of the query, as those will |
333 | 333 | //make the sql query return an array of values, instead of just a single value |
334 | - unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] ); |
|
335 | - $count = $model->count( $query_params, null, true ); |
|
334 | + unset($query_params['group_by'], $query_params['having'], $query_params['limit']); |
|
335 | + $count = $model->count($query_params, null, true); |
|
336 | 336 | |
337 | - $pages = $count / $limit_parts[ 1 ]; |
|
338 | - $this->_set_response_header( 'Total', $count, false ); |
|
339 | - $this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false ); |
|
340 | - $this->_set_response_header( 'TotalPages', ceil( $pages ), false ); |
|
337 | + $pages = $count / $limit_parts[1]; |
|
338 | + $this->_set_response_header('Total', $count, false); |
|
339 | + $this->_set_response_header('PageSize', $limit_parts[1], false); |
|
340 | + $this->_set_response_header('TotalPages', ceil($pages), false); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -350,47 +350,47 @@ discard block |
||
350 | 350 | * @param string $deprecated no longer used |
351 | 351 | * @return array ready for being converted into json for sending to client |
352 | 352 | */ |
353 | - public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) { |
|
354 | - if( ! $rest_request instanceof \WP_REST_Request ) { |
|
353 | + public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) { |
|
354 | + if ( ! $rest_request instanceof \WP_REST_Request) { |
|
355 | 355 | //ok so this was called in the old style, where the 3rd arg was |
356 | 356 | //$include, and the 4th arg was $context |
357 | 357 | //now setup the request just to avoid fatal errors, although we won't be able |
358 | 358 | //to truly make use of it because it's kinda devoid of info |
359 | 359 | $rest_request = new \WP_REST_Request(); |
360 | - $rest_request->set_param( 'include', $rest_request ); |
|
361 | - $rest_request->set_param( 'caps', $deprecated ); |
|
360 | + $rest_request->set_param('include', $rest_request); |
|
361 | + $rest_request->set_param('caps', $deprecated); |
|
362 | 362 | } |
363 | - if( $rest_request->get_param( 'caps' ) == null ) { |
|
364 | - $rest_request->set_param( 'caps', \EEM_Base::caps_read ); |
|
363 | + if ($rest_request->get_param('caps') == null) { |
|
364 | + $rest_request->set_param('caps', \EEM_Base::caps_read); |
|
365 | 365 | } |
366 | - $entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row ); |
|
367 | - $entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array ); |
|
368 | - $entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array ); |
|
369 | - $entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request ); |
|
370 | - $entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array ); |
|
366 | + $entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row); |
|
367 | + $entity_array = $this->_add_extra_fields($model, $db_row, $entity_array); |
|
368 | + $entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array); |
|
369 | + $entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request); |
|
370 | + $entity_array = $this->_include_requested_models($model, $rest_request, $entity_array); |
|
371 | 371 | $entity_array = apply_filters( |
372 | 372 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
373 | 373 | $entity_array, |
374 | 374 | $model, |
375 | - $rest_request->get_param( 'caps' ), |
|
375 | + $rest_request->get_param('caps'), |
|
376 | 376 | $rest_request, |
377 | 377 | $this |
378 | 378 | ); |
379 | 379 | $result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields( |
380 | 380 | $entity_array, |
381 | 381 | $model, |
382 | - $rest_request->get_param( 'caps' ), |
|
382 | + $rest_request->get_param('caps'), |
|
383 | 383 | $this->get_model_version_info() |
384 | 384 | ); |
385 | 385 | $this->_set_debug_info( |
386 | 386 | 'inaccessible fields', |
387 | - array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) ) |
|
387 | + array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields)) |
|
388 | 388 | ); |
389 | 389 | return apply_filters( |
390 | 390 | 'FHEE__Read__create_entity_from_wpdb_results__entity_return', |
391 | 391 | $result_without_inaccessible_fields, |
392 | 392 | $model, |
393 | - $rest_request->get_param( 'caps' ) |
|
393 | + $rest_request->get_param('caps') |
|
394 | 394 | ); |
395 | 395 | } |
396 | 396 | |
@@ -402,39 +402,39 @@ discard block |
||
402 | 402 | * @param array $db_row |
403 | 403 | * @return array entity mostly ready for converting to JSON and sending in the response |
404 | 404 | */ |
405 | - protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) { |
|
406 | - $result = $model->deduce_fields_n_values_from_cols_n_values( $db_row ); |
|
407 | - $result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) ); |
|
408 | - foreach( $result as $field_name => $raw_field_value ) { |
|
405 | + protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) { |
|
406 | + $result = $model->deduce_fields_n_values_from_cols_n_values($db_row); |
|
407 | + $result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model)); |
|
408 | + foreach ($result as $field_name => $raw_field_value) { |
|
409 | 409 | $field_obj = $model->field_settings_for($field_name); |
410 | - $field_value = $field_obj->prepare_for_set_from_db( $raw_field_value ); |
|
411 | - if( $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_ignored() ) ){ |
|
412 | - unset( $result[ $field_name ] ); |
|
413 | - }elseif( |
|
414 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() ) |
|
415 | - ){ |
|
416 | - $result[ $field_name ] = array( |
|
417 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
418 | - 'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
410 | + $field_value = $field_obj->prepare_for_set_from_db($raw_field_value); |
|
411 | + if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) { |
|
412 | + unset($result[$field_name]); |
|
413 | + }elseif ( |
|
414 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format()) |
|
415 | + ) { |
|
416 | + $result[$field_name] = array( |
|
417 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
418 | + 'rendered' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
419 | 419 | ); |
420 | - }elseif( |
|
421 | - $this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() ) |
|
422 | - ){ |
|
423 | - $result[ $field_name ] = array( |
|
424 | - 'raw' => $field_obj->prepare_for_get( $field_value ), |
|
425 | - 'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value ) |
|
420 | + }elseif ( |
|
421 | + $this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format()) |
|
422 | + ) { |
|
423 | + $result[$field_name] = array( |
|
424 | + 'raw' => $field_obj->prepare_for_get($field_value), |
|
425 | + 'pretty' => $field_obj->prepare_for_pretty_echoing($field_value) |
|
426 | 426 | ); |
427 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
428 | - if( $field_value instanceof \DateTime ) { |
|
427 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
428 | + if ($field_value instanceof \DateTime) { |
|
429 | 429 | $timezone = $field_value->getTimezone(); |
430 | - $field_value->setTimezone( new \DateTimeZone( 'UTC' ) ); |
|
431 | - $result[ $field_name . '_gmt' ] = Model_Data_Translator::prepare_field_value_for_json( |
|
430 | + $field_value->setTimezone(new \DateTimeZone('UTC')); |
|
431 | + $result[$field_name.'_gmt'] = Model_Data_Translator::prepare_field_value_for_json( |
|
432 | 432 | $field_obj, |
433 | 433 | $field_value, |
434 | 434 | $this->get_model_version_info()->requested_version() |
435 | 435 | ); |
436 | - $field_value->setTimezone( $timezone ); |
|
437 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
436 | + $field_value->setTimezone($timezone); |
|
437 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
438 | 438 | $field_obj, |
439 | 439 | $field_value, |
440 | 440 | $this->get_model_version_info()->requested_version() |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | } else { |
445 | - $result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json( |
|
445 | + $result[$field_name] = Model_Data_Translator::prepare_field_value_for_json( |
|
446 | 446 | $field_obj, |
447 | - $field_obj->prepare_for_get( $field_value ), |
|
447 | + $field_obj->prepare_for_get($field_value), |
|
448 | 448 | $this->get_model_version_info()->requested_version() |
449 | 449 | ); |
450 | 450 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * @param array $entity_array |
460 | 460 | * @return array modified entity |
461 | 461 | */ |
462 | - protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) { |
|
463 | - if( $model instanceof \EEM_CPT_Base ) { |
|
464 | - $entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ); |
|
462 | + protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) { |
|
463 | + if ($model instanceof \EEM_CPT_Base) { |
|
464 | + $entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]); |
|
465 | 465 | } |
466 | 466 | return $entity_array; |
467 | 467 | } |
@@ -475,20 +475,20 @@ discard block |
||
475 | 475 | * @param array $entity_array |
476 | 476 | * @return array the _links item in the entity |
477 | 477 | */ |
478 | - protected function _get_entity_links( $model, $db_row, $entity_array ) { |
|
478 | + protected function _get_entity_links($model, $db_row, $entity_array) { |
|
479 | 479 | //add basic links |
480 | 480 | $links = array( |
481 | 481 | 'self' => array( |
482 | 482 | array( |
483 | 483 | 'href' => $this->get_versioned_link_to( |
484 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] |
|
484 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()] |
|
485 | 485 | ) |
486 | 486 | ) |
487 | 487 | ), |
488 | 488 | 'collection' => array( |
489 | 489 | array( |
490 | 490 | 'href' => $this->get_versioned_link_to( |
491 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) |
|
491 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()) |
|
492 | 492 | ) |
493 | 493 | ) |
494 | 494 | ), |
@@ -496,24 +496,24 @@ discard block |
||
496 | 496 | |
497 | 497 | //add link to the wp core endpoint, if wp api is active |
498 | 498 | global $wp_rest_server; |
499 | - if( $model instanceof \EEM_CPT_Base && |
|
499 | + if ($model instanceof \EEM_CPT_Base && |
|
500 | 500 | $wp_rest_server instanceof \WP_REST_Server && |
501 | - $wp_rest_server->get_route_options( '/wp/v2/posts' ) ) { |
|
502 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array( |
|
501 | + $wp_rest_server->get_route_options('/wp/v2/posts')) { |
|
502 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array( |
|
503 | 503 | array( |
504 | - 'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ), |
|
504 | + 'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]), |
|
505 | 505 | 'single' => true |
506 | 506 | ) |
507 | 507 | ); |
508 | 508 | } |
509 | 509 | |
510 | 510 | //add links to related models |
511 | - foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
512 | - $related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj ); |
|
513 | - $links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array( |
|
511 | + foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) { |
|
512 | + $related_model_part = Read::get_related_entity_name($relation_name, $relation_obj); |
|
513 | + $links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array( |
|
514 | 514 | array( |
515 | 515 | 'href' => $this->get_versioned_link_to( |
516 | - \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part |
|
516 | + \EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part |
|
517 | 517 | ), |
518 | 518 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false |
519 | 519 | ) |
@@ -529,51 +529,51 @@ discard block |
||
529 | 529 | * @param array $entity_array |
530 | 530 | * @return array the modified entity |
531 | 531 | */ |
532 | - protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) { |
|
533 | - $includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' ); |
|
534 | - $includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model ); |
|
532 | + protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) { |
|
533 | + $includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), ''); |
|
534 | + $includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model); |
|
535 | 535 | //if they passed in * or didn't specify any includes, return everything |
536 | - if( ! in_array( '*', $includes_for_this_model ) |
|
537 | - && ! empty( $includes_for_this_model ) ) { |
|
538 | - if( $model->has_primary_key_field() ) { |
|
536 | + if ( ! in_array('*', $includes_for_this_model) |
|
537 | + && ! empty($includes_for_this_model)) { |
|
538 | + if ($model->has_primary_key_field()) { |
|
539 | 539 | //always include the primary key. ya just gotta know that at least |
540 | 540 | $includes_for_this_model[] = $model->primary_key_name(); |
541 | 541 | } |
542 | - if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) { |
|
542 | + if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) { |
|
543 | 543 | $includes_for_this_model[] = '_calculated_fields'; |
544 | 544 | } |
545 | - $entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) ); |
|
545 | + $entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model)); |
|
546 | 546 | } |
547 | - $relation_settings = $this->get_model_version_info()->relation_settings( $model ); |
|
548 | - foreach( $relation_settings as $relation_name => $relation_obj ) { |
|
547 | + $relation_settings = $this->get_model_version_info()->relation_settings($model); |
|
548 | + foreach ($relation_settings as $relation_name => $relation_obj) { |
|
549 | 549 | $related_fields_to_include = $this->explode_and_get_items_prefixed_with( |
550 | - $rest_request->get_param( 'include' ), |
|
550 | + $rest_request->get_param('include'), |
|
551 | 551 | $relation_name |
552 | 552 | ); |
553 | 553 | $related_fields_to_calculate = $this->explode_and_get_items_prefixed_with( |
554 | - $rest_request->get_param( 'calculate' ), |
|
554 | + $rest_request->get_param('calculate'), |
|
555 | 555 | $relation_name |
556 | 556 | ); |
557 | 557 | //did they specify they wanted to include a related model, or |
558 | 558 | //specific fields from a related model? |
559 | 559 | //or did they specify to calculate a field from a related model? |
560 | - if( $related_fields_to_include || $related_fields_to_calculate ) { |
|
560 | + if ($related_fields_to_include || $related_fields_to_calculate) { |
|
561 | 561 | //if so, we should include at least some part of the related model |
562 | 562 | $pretend_related_request = new \WP_REST_Request(); |
563 | 563 | $pretend_related_request->set_query_params( |
564 | 564 | array( |
565 | - 'caps' => $rest_request->get_param( 'caps' ), |
|
565 | + 'caps' => $rest_request->get_param('caps'), |
|
566 | 566 | 'include' => $related_fields_to_include, |
567 | 567 | 'calculate' => $related_fields_to_calculate, |
568 | 568 | ) |
569 | 569 | ); |
570 | - $pretend_related_request->add_header( 'no_rest_headers', true ); |
|
570 | + $pretend_related_request->add_header('no_rest_headers', true); |
|
571 | 571 | $related_results = $this->get_entities_from_relation( |
572 | - $entity_array[ $model->primary_key_name() ], |
|
572 | + $entity_array[$model->primary_key_name()], |
|
573 | 573 | $relation_obj, |
574 | 574 | $pretend_related_request |
575 | 575 | ); |
576 | - $entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error |
|
576 | + $entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error |
|
577 | 577 | ? null |
578 | 578 | : $related_results; |
579 | 579 | } |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | * @param array $arr |
588 | 588 | * @return array |
589 | 589 | */ |
590 | - private function _remove_model_names_from_array( $arr ) { |
|
591 | - return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) ); |
|
590 | + private function _remove_model_names_from_array($arr) { |
|
591 | + return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models)); |
|
592 | 592 | } |
593 | 593 | /** |
594 | 594 | * Gets the calculated fields for the response |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @param \WP_REST_Request $rest_request |
599 | 599 | * @return \stdClass the _calculations item in the entity |
600 | 600 | */ |
601 | - protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) { |
|
601 | + protected function _get_entity_calculations($model, $wpdb_row, $rest_request) { |
|
602 | 602 | $calculated_fields = $this->explode_and_get_items_prefixed_with( |
603 | - $rest_request->get_param( 'calculate' ), |
|
603 | + $rest_request->get_param('calculate'), |
|
604 | 604 | '' |
605 | 605 | ); |
606 | 606 | //note: setting calculate=* doesn't do anything |
607 | 607 | $calculated_fields_to_return = new \stdClass(); |
608 | - foreach( $calculated_fields as $field_to_calculate ) { |
|
609 | - try{ |
|
608 | + foreach ($calculated_fields as $field_to_calculate) { |
|
609 | + try { |
|
610 | 610 | $calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json( |
611 | 611 | null, |
612 | 612 | $this->_fields_calculator->retrieve_calculated_field_value( |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | ), |
619 | 619 | $this->get_model_version_info()->requested_version() |
620 | 620 | ); |
621 | - } catch( Rest_Exception $e ) { |
|
621 | + } catch (Rest_Exception $e) { |
|
622 | 622 | //if we don't have permission to read it, just leave it out. but let devs know about the problem |
623 | 623 | $this->_set_response_header( |
624 | - 'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']', |
|
624 | + 'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']', |
|
625 | 625 | $e->getMessage(), |
626 | 626 | true |
627 | 627 | ); |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | * @param string $link_part_after_version_and_slash eg "events/10/datetimes" |
636 | 636 | * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes" |
637 | 637 | */ |
638 | - public function get_versioned_link_to( $link_part_after_version_and_slash ) { |
|
638 | + public function get_versioned_link_to($link_part_after_version_and_slash) { |
|
639 | 639 | return rest_url( |
640 | 640 | \EED_Core_Rest_Api::ee_api_namespace |
641 | 641 | . $this->get_model_version_info()->requested_version() |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | * @param \EE_Model_Relation_Base $relation_obj |
652 | 652 | * @return string |
653 | 653 | */ |
654 | - public static function get_related_entity_name( $relation_name, $relation_obj ){ |
|
655 | - if( $relation_obj instanceof \EE_Belongs_To_Relation ) { |
|
656 | - return strtolower( $relation_name ); |
|
657 | - }else{ |
|
658 | - return \EEH_Inflector::pluralize_and_lower( $relation_name ); |
|
654 | + public static function get_related_entity_name($relation_name, $relation_obj) { |
|
655 | + if ($relation_obj instanceof \EE_Belongs_To_Relation) { |
|
656 | + return strtolower($relation_name); |
|
657 | + } else { |
|
658 | + return \EEH_Inflector::pluralize_and_lower($relation_name); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
@@ -668,43 +668,43 @@ discard block |
||
668 | 668 | * @param \WP_REST_Request $request |
669 | 669 | * @return array|\WP_Error |
670 | 670 | */ |
671 | - public function get_entity_from_model( $model, $request ) { |
|
672 | - $query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1); |
|
673 | - if( $model instanceof \EEM_Soft_Delete_Base ){ |
|
671 | + public function get_entity_from_model($model, $request) { |
|
672 | + $query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1); |
|
673 | + if ($model instanceof \EEM_Soft_Delete_Base) { |
|
674 | 674 | $query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
675 | 675 | } |
676 | 676 | $restricted_query_params = $query_params; |
677 | - $restricted_query_params[ 'caps' ] = $this->validate_context( $request->get_param( 'caps' ) ); |
|
678 | - $this->_set_debug_info( 'model query params', $restricted_query_params ); |
|
679 | - $model_rows = $model->get_all_wpdb_results( $restricted_query_params ); |
|
680 | - if ( ! empty ( $model_rows ) ) { |
|
677 | + $restricted_query_params['caps'] = $this->validate_context($request->get_param('caps')); |
|
678 | + $this->_set_debug_info('model query params', $restricted_query_params); |
|
679 | + $model_rows = $model->get_all_wpdb_results($restricted_query_params); |
|
680 | + if ( ! empty ($model_rows)) { |
|
681 | 681 | return $this->create_entity_from_wpdb_result( |
682 | 682 | $model, |
683 | - array_shift( $model_rows ), |
|
683 | + array_shift($model_rows), |
|
684 | 684 | $request ); |
685 | 685 | } else { |
686 | 686 | //ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities |
687 | - $lowercase_model_name = strtolower( $model->get_this_model_name() ); |
|
688 | - $model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params ); |
|
689 | - if( ! empty( $model_rows_found_sans_restrictions ) ) { |
|
687 | + $lowercase_model_name = strtolower($model->get_this_model_name()); |
|
688 | + $model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params); |
|
689 | + if ( ! empty($model_rows_found_sans_restrictions)) { |
|
690 | 690 | //you got shafted- it existed but we didn't want to tell you! |
691 | 691 | return new \WP_Error( |
692 | 692 | 'rest_user_cannot_read', |
693 | 693 | sprintf( |
694 | - __( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ), |
|
695 | - strtolower( $model->get_this_model_name() ), |
|
694 | + __('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'), |
|
695 | + strtolower($model->get_this_model_name()), |
|
696 | 696 | Capabilities::get_missing_permissions_string( |
697 | 697 | $model, |
698 | - $this->validate_context( $request->get_param( 'caps' ) ) ) |
|
698 | + $this->validate_context($request->get_param('caps')) ) |
|
699 | 699 | ), |
700 | - array( 'status' => 403 ) |
|
700 | + array('status' => 403) |
|
701 | 701 | ); |
702 | 702 | } else { |
703 | 703 | //it's not you. It just doesn't exist |
704 | 704 | return new \WP_Error( |
705 | - sprintf( 'rest_%s_invalid_id', $lowercase_model_name ), |
|
706 | - sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ), |
|
707 | - array( 'status' => 404 ) |
|
705 | + sprintf('rest_%s_invalid_id', $lowercase_model_name), |
|
706 | + sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name), |
|
707 | + array('status' => 404) |
|
708 | 708 | ); |
709 | 709 | } |
710 | 710 | } |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @param string $context |
718 | 718 | * @return string array key of EEM_Base::cap_contexts_to_cap_action_map() |
719 | 719 | */ |
720 | - public function validate_context( $context ) { |
|
721 | - if( ! $context ) { |
|
720 | + public function validate_context($context) { |
|
721 | + if ( ! $context) { |
|
722 | 722 | $context = \EEM_Base::caps_read; |
723 | 723 | } |
724 | 724 | $valid_contexts = \EEM_Base::valid_cap_contexts(); |
725 | - if( in_array( $context, $valid_contexts ) ){ |
|
725 | + if (in_array($context, $valid_contexts)) { |
|
726 | 726 | return $context; |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | return \EEM_Base::caps_read; |
729 | 729 | } |
730 | 730 | } |
@@ -743,87 +743,87 @@ discard block |
||
743 | 743 | * that absolutely no results should be returned |
744 | 744 | * @throws \EE_Error |
745 | 745 | */ |
746 | - public function create_model_query_params( $model, $query_parameters ) { |
|
746 | + public function create_model_query_params($model, $query_parameters) { |
|
747 | 747 | $model_query_params = array( ); |
748 | - if ( isset( $query_parameters[ 'where' ] ) ) { |
|
749 | - $model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | - $query_parameters[ 'where' ], |
|
748 | + if (isset($query_parameters['where'])) { |
|
749 | + $model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
750 | + $query_parameters['where'], |
|
751 | 751 | $model, |
752 | 752 | $this->get_model_version_info()->requested_version() |
753 | 753 | ); |
754 | 754 | } |
755 | - if ( isset( $query_parameters[ 'order_by' ] ) ) { |
|
756 | - $order_by = $query_parameters[ 'order_by' ]; |
|
757 | - } elseif ( isset( $query_parameters[ 'orderby' ] ) ) { |
|
758 | - $order_by = $query_parameters[ 'orderby' ]; |
|
759 | - }else{ |
|
755 | + if (isset($query_parameters['order_by'])) { |
|
756 | + $order_by = $query_parameters['order_by']; |
|
757 | + } elseif (isset($query_parameters['orderby'])) { |
|
758 | + $order_by = $query_parameters['orderby']; |
|
759 | + } else { |
|
760 | 760 | $order_by = null; |
761 | 761 | } |
762 | - if( $order_by !== null ){ |
|
763 | - if( is_array( $order_by ) ) { |
|
764 | - $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json( $order_by ); |
|
762 | + if ($order_by !== null) { |
|
763 | + if (is_array($order_by)) { |
|
764 | + $order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json($order_by); |
|
765 | 765 | } else { |
766 | 766 | //it's a single item |
767 | - $order_by = Model_Data_Translator::prepare_field_name_from_json( $order_by ); |
|
767 | + $order_by = Model_Data_Translator::prepare_field_name_from_json($order_by); |
|
768 | 768 | } |
769 | - $model_query_params[ 'order_by' ] = $order_by; |
|
769 | + $model_query_params['order_by'] = $order_by; |
|
770 | 770 | } |
771 | - if ( isset( $query_parameters[ 'group_by' ] ) ) { |
|
772 | - $group_by = $query_parameters[ 'group_by' ]; |
|
773 | - } elseif ( isset( $query_parameters[ 'groupby' ] ) ) { |
|
774 | - $group_by = $query_parameters[ 'groupby' ]; |
|
775 | - }else{ |
|
776 | - $group_by = array_keys( $model->get_combined_primary_key_fields() ); |
|
771 | + if (isset($query_parameters['group_by'])) { |
|
772 | + $group_by = $query_parameters['group_by']; |
|
773 | + } elseif (isset($query_parameters['groupby'])) { |
|
774 | + $group_by = $query_parameters['groupby']; |
|
775 | + } else { |
|
776 | + $group_by = array_keys($model->get_combined_primary_key_fields()); |
|
777 | 777 | } |
778 | 778 | //make sure they're all real names |
779 | - if( is_array( $group_by ) ) { |
|
780 | - $group_by = Model_Data_Translator::prepare_field_names_from_json( $group_by ); |
|
779 | + if (is_array($group_by)) { |
|
780 | + $group_by = Model_Data_Translator::prepare_field_names_from_json($group_by); |
|
781 | 781 | } |
782 | - if( $group_by !== null ){ |
|
783 | - $model_query_params[ 'group_by' ] = $group_by; |
|
782 | + if ($group_by !== null) { |
|
783 | + $model_query_params['group_by'] = $group_by; |
|
784 | 784 | } |
785 | - if ( isset( $query_parameters[ 'having' ] ) ) { |
|
786 | - $model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | - $query_parameters[ 'having' ], |
|
785 | + if (isset($query_parameters['having'])) { |
|
786 | + $model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models( |
|
787 | + $query_parameters['having'], |
|
788 | 788 | $model, |
789 | 789 | $this->get_model_version_info()->requested_version() |
790 | 790 | ); |
791 | 791 | } |
792 | - if ( isset( $query_parameters[ 'order' ] ) ) { |
|
793 | - $model_query_params[ 'order' ] = $query_parameters[ 'order' ]; |
|
792 | + if (isset($query_parameters['order'])) { |
|
793 | + $model_query_params['order'] = $query_parameters['order']; |
|
794 | 794 | } |
795 | - if ( isset( $query_parameters[ 'mine' ] ) ){ |
|
796 | - $model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params ); |
|
795 | + if (isset($query_parameters['mine'])) { |
|
796 | + $model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params); |
|
797 | 797 | } |
798 | - if( isset( $query_parameters[ 'limit' ] ) ) { |
|
798 | + if (isset($query_parameters['limit'])) { |
|
799 | 799 | //limit should be either a string like '23' or '23,43', or an array with two items in it |
800 | - if( ! is_array( $query_parameters[ 'limit' ] ) ) { |
|
801 | - $limit_array = explode(',', (string)$query_parameters['limit']); |
|
802 | - }else { |
|
803 | - $limit_array = $query_parameters[ 'limit' ]; |
|
800 | + if ( ! is_array($query_parameters['limit'])) { |
|
801 | + $limit_array = explode(',', (string) $query_parameters['limit']); |
|
802 | + } else { |
|
803 | + $limit_array = $query_parameters['limit']; |
|
804 | 804 | } |
805 | 805 | $sanitized_limit = array(); |
806 | - foreach( $limit_array as $key => $limit_part ) { |
|
807 | - if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) { |
|
806 | + foreach ($limit_array as $key => $limit_part) { |
|
807 | + if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) { |
|
808 | 808 | throw new \EE_Error( |
809 | 809 | sprintf( |
810 | - __( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ), |
|
811 | - json_encode( $query_parameters[ 'limit' ] ) |
|
810 | + __('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'), |
|
811 | + json_encode($query_parameters['limit']) |
|
812 | 812 | ) |
813 | 813 | ); |
814 | 814 | } |
815 | - $sanitized_limit[] = (int)$limit_part; |
|
815 | + $sanitized_limit[] = (int) $limit_part; |
|
816 | 816 | } |
817 | - $model_query_params[ 'limit' ] = implode( ',', $sanitized_limit ); |
|
818 | - }else{ |
|
819 | - $model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
817 | + $model_query_params['limit'] = implode(',', $sanitized_limit); |
|
818 | + } else { |
|
819 | + $model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit(); |
|
820 | 820 | } |
821 | - if( isset( $query_parameters[ 'caps' ] ) ) { |
|
822 | - $model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] ); |
|
823 | - }else{ |
|
824 | - $model_query_params[ 'caps' ] = \EEM_Base::caps_read; |
|
821 | + if (isset($query_parameters['caps'])) { |
|
822 | + $model_query_params['caps'] = $this->validate_context($query_parameters['caps']); |
|
823 | + } else { |
|
824 | + $model_query_params['caps'] = \EEM_Base::caps_read; |
|
825 | 825 | } |
826 | - return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model ); |
|
826 | + return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -835,13 +835,13 @@ discard block |
||
835 | 835 | * @param array $query_params sub-array from @see EEM_Base::get_all() |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - public function prepare_rest_query_params_key_for_models( $model, $query_params ) { |
|
838 | + public function prepare_rest_query_params_key_for_models($model, $query_params) { |
|
839 | 839 | $model_ready_query_params = array(); |
840 | - foreach( $query_params as $key => $value ) { |
|
841 | - if( is_array( $value ) ) { |
|
842 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value ); |
|
843 | - }else{ |
|
844 | - $model_ready_query_params[ $key ] = $value; |
|
840 | + foreach ($query_params as $key => $value) { |
|
841 | + if (is_array($value)) { |
|
842 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value); |
|
843 | + } else { |
|
844 | + $model_ready_query_params[$key] = $value; |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | return $model_ready_query_params; |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | * @param $query_params |
856 | 856 | * @return array |
857 | 857 | */ |
858 | - public function prepare_rest_query_params_values_for_models( $model, $query_params ) { |
|
858 | + public function prepare_rest_query_params_values_for_models($model, $query_params) { |
|
859 | 859 | $model_ready_query_params = array(); |
860 | - foreach( $query_params as $key => $value ) { |
|
861 | - if( is_array( $value ) ) { |
|
862 | - $model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value ); |
|
860 | + foreach ($query_params as $key => $value) { |
|
861 | + if (is_array($value)) { |
|
862 | + $model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value); |
|
863 | 863 | } else { |
864 | - $model_ready_query_params[ $key ] = $value; |
|
864 | + $model_ready_query_params[$key] = $value; |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | return $model_ready_query_params; |
@@ -876,33 +876,33 @@ discard block |
||
876 | 876 | * we only return strings starting with that and a period; if no prefix was specified |
877 | 877 | * we return all items containing NO periods |
878 | 878 | */ |
879 | - public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) { |
|
880 | - if( is_string( $string_to_explode ) ) { |
|
881 | - $exploded_contents = explode( ',', $string_to_explode ); |
|
882 | - } else if( is_array( $string_to_explode ) ) { |
|
879 | + public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) { |
|
880 | + if (is_string($string_to_explode)) { |
|
881 | + $exploded_contents = explode(',', $string_to_explode); |
|
882 | + } else if (is_array($string_to_explode)) { |
|
883 | 883 | $exploded_contents = $string_to_explode; |
884 | 884 | } else { |
885 | 885 | $exploded_contents = array(); |
886 | 886 | } |
887 | 887 | //if the string was empty, we want an empty array |
888 | - $exploded_contents = array_filter( $exploded_contents ); |
|
888 | + $exploded_contents = array_filter($exploded_contents); |
|
889 | 889 | $contents_with_prefix = array(); |
890 | - foreach( $exploded_contents as $item ) { |
|
891 | - $item = trim( $item ); |
|
890 | + foreach ($exploded_contents as $item) { |
|
891 | + $item = trim($item); |
|
892 | 892 | //if no prefix was provided, so we look for items with no "." in them |
893 | - if( ! $prefix ) { |
|
893 | + if ( ! $prefix) { |
|
894 | 894 | //does this item have a period? |
895 | - if( strpos( $item, '.' ) === false ) { |
|
895 | + if (strpos($item, '.') === false) { |
|
896 | 896 | //if not, then its what we're looking for |
897 | 897 | $contents_with_prefix[] = $item; |
898 | 898 | } |
899 | - } else if( strpos( $item, $prefix . '.' ) === 0 ) { |
|
899 | + } else if (strpos($item, $prefix.'.') === 0) { |
|
900 | 900 | //this item has the prefix and a period, grab it |
901 | 901 | $contents_with_prefix[] = substr( |
902 | 902 | $item, |
903 | - strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' ) |
|
903 | + strpos($item, $prefix.'.') + strlen($prefix.'.') |
|
904 | 904 | ); |
905 | - } else if( $item === $prefix ) { |
|
905 | + } else if ($item === $prefix) { |
|
906 | 906 | //this item is JUST the prefix |
907 | 907 | //so let's grab everything after, which is a blank string |
908 | 908 | $contents_with_prefix[] = ''; |
@@ -925,33 +925,33 @@ discard block |
||
925 | 925 | * the fields for that model, with the model's name removed from each. |
926 | 926 | * If $include_string was blank or '*' returns an empty array |
927 | 927 | */ |
928 | - public function extract_includes_for_this_model( $include_string, $model_name = null ) { |
|
929 | - if( is_array( $include_string ) ) { |
|
930 | - $include_string = implode( ',', $include_string ); |
|
928 | + public function extract_includes_for_this_model($include_string, $model_name = null) { |
|
929 | + if (is_array($include_string)) { |
|
930 | + $include_string = implode(',', $include_string); |
|
931 | 931 | } |
932 | - if( $include_string === '*' || $include_string === '' ) { |
|
932 | + if ($include_string === '*' || $include_string === '') { |
|
933 | 933 | return array(); |
934 | 934 | } |
935 | - $includes = explode( ',', $include_string ); |
|
935 | + $includes = explode(',', $include_string); |
|
936 | 936 | $extracted_fields_to_include = array(); |
937 | - if( $model_name ){ |
|
938 | - foreach( $includes as $field_to_include ) { |
|
939 | - $field_to_include = trim( $field_to_include ); |
|
940 | - if( strpos( $field_to_include, $model_name . '.' ) === 0 ) { |
|
937 | + if ($model_name) { |
|
938 | + foreach ($includes as $field_to_include) { |
|
939 | + $field_to_include = trim($field_to_include); |
|
940 | + if (strpos($field_to_include, $model_name.'.') === 0) { |
|
941 | 941 | //found the model name at the exact start |
942 | - $field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include ); |
|
942 | + $field_sans_model_name = str_replace($model_name.'.', '', $field_to_include); |
|
943 | 943 | $extracted_fields_to_include[] = $field_sans_model_name; |
944 | - }elseif( $field_to_include == $model_name ){ |
|
944 | + }elseif ($field_to_include == $model_name) { |
|
945 | 945 | $extracted_fields_to_include[] = '*'; |
946 | 946 | } |
947 | 947 | } |
948 | - }else{ |
|
948 | + } else { |
|
949 | 949 | //look for ones with no period |
950 | - foreach( $includes as $field_to_include ) { |
|
951 | - $field_to_include = trim( $field_to_include ); |
|
950 | + foreach ($includes as $field_to_include) { |
|
951 | + $field_to_include = trim($field_to_include); |
|
952 | 952 | if ( |
953 | - strpos( $field_to_include, '.' ) === false |
|
954 | - && ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include ) |
|
953 | + strpos($field_to_include, '.') === false |
|
954 | + && ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include) |
|
955 | 955 | ) { |
956 | 956 | $extracted_fields_to_include[] = $field_to_include; |
957 | 957 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( |
|
100 | + if ( |
|
101 | 101 | apply_filters( |
102 | 102 | 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
103 | - ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
104 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) |
|
103 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
104 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
105 | 105 | ) |
106 | 106 | ) { |
107 | 107 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | //ok they're using the WP API with Basic Auth |
111 | 111 | $message = sprintf( |
112 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
112 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
113 | 113 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
114 | 114 | '</a>', |
115 | 115 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
116 | 116 | '<br/>' |
117 | 117 | ); |
118 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
119 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
120 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
118 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
119 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
120 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
121 | 121 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
122 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
122 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
123 | 123 | //and send the message to the site admin too |
124 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
125 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
124 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
125 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * appear the same as they always did |
131 | 131 | */ |
132 | 132 | protected static function _set_hooks_for_changes() { |
133 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
134 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
133 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
134 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
135 | 135 | //ignore the base parent class |
136 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
136 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
140 | - if ( class_exists( $full_classname )) { |
|
139 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
140 | + if (class_exists($full_classname)) { |
|
141 | 141 | $instance_of_class = new $full_classname; |
142 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
142 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
143 | 143 | $instance_of_class->set_hooks(); |
144 | 144 | } |
145 | 145 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
153 | 153 | */ |
154 | 154 | public static function register_routes() { |
155 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
156 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
157 | - foreach( $routes as $route ) { |
|
155 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
156 | + foreach ($relative_urls as $endpoint => $routes) { |
|
157 | + foreach ($routes as $route) { |
|
158 | 158 | register_rest_route( |
159 | 159 | $namespace, |
160 | 160 | $endpoint, |
161 | 161 | array( |
162 | - 'callback' => $route[ 'callback' ], |
|
163 | - 'methods' => $route[ 'methods' ], |
|
164 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
162 | + 'callback' => $route['callback'], |
|
163 | + 'methods' => $route['methods'], |
|
164 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
165 | 165 | ) |
166 | 166 | ); |
167 | 167 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * next time the WP API is used |
176 | 176 | */ |
177 | 177 | public static function invalidate_cached_route_data_on_version_change() { |
178 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
178 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
179 | 179 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
180 | 180 | } |
181 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
182 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
181 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
182 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
183 | 183 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
184 | 184 | } |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function invalidate_cached_route_data() { |
192 | 192 | //delete the saved EE REST API routes |
193 | - foreach( EED_Core_Rest_Api::versions_served() as $version => $hidden ){ |
|
194 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names . $version ); |
|
193 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
194 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function get_ee_route_data() { |
207 | 207 | $ee_routes = array(); |
208 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
209 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
208 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
209 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
210 | 210 | } |
211 | 211 | return $ee_routes; |
212 | 212 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @param boolean $hidden_endpoints |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
222 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
223 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
224 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
221 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
222 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
223 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
224 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
225 | 225 | } |
226 | 226 | return $ee_routes; |
227 | 227 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param boolean $hidden_endpoints |
236 | 236 | * @return mixed|null|void |
237 | 237 | */ |
238 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
238 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
239 | 239 | $instance = self::instance(); |
240 | 240 | $routes = apply_filters( |
241 | 241 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
242 | 242 | array_replace_recursive( |
243 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
244 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
245 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
246 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
243 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
244 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
245 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
246 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
247 | 247 | ) |
248 | 248 | ); |
249 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
249 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
250 | 250 | return $routes; |
251 | 251 | } |
252 | 252 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | public static function save_ee_routes() { |
260 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
260 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
261 | 261 | $instance = self::instance(); |
262 | 262 | $routes = apply_filters( |
263 | 263 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $instance->_register_rpc_routes() |
269 | 269 | ) |
270 | 270 | ); |
271 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
271 | + update_option(self::saved_routes_option_names, $routes, true); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | */ |
280 | 280 | protected function _register_model_routes() { |
281 | 281 | $model_routes = array( ); |
282 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
283 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
282 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
283 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
284 | 284 | } |
285 | 285 | return $model_routes; |
286 | 286 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param boolean $hidden_endpoint |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
295 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
294 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
295 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
296 | 296 | $models_to_register = apply_filters( |
297 | 297 | 'FHEE__EED_Core_REST_API___register_model_routes', |
298 | 298 | $model_version_info->models_for_requested_version() |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | unset($models_to_register['Extra_Meta']); |
302 | 302 | unset($models_to_register['Extra_Join']); |
303 | 303 | $model_routes = array(); |
304 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
305 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
304 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
305 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
306 | 306 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
307 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
308 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
309 | - $model_routes[ $plural_model_route ] = array( |
|
307 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
308 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
309 | + $model_routes[$plural_model_route] = array( |
|
310 | 310 | array( |
311 | 311 | 'callback' => array( |
312 | 312 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
313 | 313 | 'handle_request_get_all' ), |
314 | 314 | 'methods' => WP_REST_Server::READABLE, |
315 | 315 | 'hidden_endpoint' => $hidden_endpoint, |
316 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
316 | + 'args' => $this->_get_read_query_params($model, $version), |
|
317 | 317 | '_links' => array( |
318 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
318 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
319 | 319 | ) |
320 | 320 | ), |
321 | 321 | // array( |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | // 'hidden_endpoint' => $hidden_endpoint |
327 | 327 | // ) |
328 | 328 | ); |
329 | - $model_routes[ $singular_model_route ] = array( |
|
329 | + $model_routes[$singular_model_route] = array( |
|
330 | 330 | array( |
331 | 331 | 'callback' => array( |
332 | 332 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
333 | 333 | 'handle_request_get_one' ), |
334 | 334 | 'methods' => WP_REST_Server::READABLE, |
335 | 335 | 'hidden_endpoint' => $hidden_endpoint, |
336 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
336 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
337 | 337 | ), |
338 | 338 | // array( |
339 | 339 | // 'callback' => array( |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | // ), |
345 | 345 | ); |
346 | 346 | //@todo: also handle DELETE for a single item |
347 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
347 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
348 | 348 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
349 | 349 | $relation_name, |
350 | 350 | $relation_obj |
351 | 351 | ); |
352 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
352 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
353 | 353 | array( |
354 | 354 | 'callback' => array( |
355 | 355 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
356 | 356 | 'handle_request_get_related' ), |
357 | 357 | 'methods' => WP_REST_Server::READABLE, |
358 | 358 | 'hidden_endpoint' => $hidden_endpoint, |
359 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
359 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
360 | 360 | ), |
361 | 361 | // array( |
362 | 362 | // 'callback' => array( |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function _register_rpc_routes() { |
381 | 381 | $routes = array(); |
382 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
383 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
382 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
383 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
384 | 384 | } |
385 | 385 | return $routes; |
386 | 386 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param boolean $hidden_endpoint |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
394 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
395 | 395 | $this_versions_routes = array(); |
396 | 396 | //checkin endpoint |
397 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
397 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
398 | 398 | array( |
399 | 399 | 'callback' => array( |
400 | 400 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'force' => array( |
406 | 406 | 'required' => false, |
407 | 407 | 'default' => false, |
408 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
408 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ) |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $version |
425 | 425 | * @return array |
426 | 426 | */ |
427 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
427 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
428 | 428 | return apply_filters( |
429 | 429 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
430 | 430 | array( |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'calculate' => array( |
436 | 436 | 'required' => false, |
437 | 437 | 'default' => '', |
438 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
438 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | $model, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * @return array describing the args acceptable when querying this model |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
456 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
457 | 457 | $default_orderby = array(); |
458 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
459 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
458 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
459 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
460 | 460 | } |
461 | 461 | return array_merge( |
462 | - $this->_get_response_selection_query_params( $model, $version ), |
|
462 | + $this->_get_response_selection_query_params($model, $version), |
|
463 | 463 | array( |
464 | 464 | 'where' => array( |
465 | 465 | 'required' => false, |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function _register_config_routes() { |
498 | 498 | $config_routes = array(); |
499 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
500 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
499 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
500 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
501 | 501 | } |
502 | 502 | return $config_routes; |
503 | 503 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param boolean $hidden_endpoint |
509 | 509 | * @return array |
510 | 510 | */ |
511 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
511 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
512 | 512 | return array( |
513 | 513 | 'config' => array( |
514 | 514 | array( |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function _register_meta_routes() { |
540 | 540 | $meta_routes = array(); |
541 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
542 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
541 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
542 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
543 | 543 | } |
544 | 544 | return $meta_routes; |
545 | 545 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param boolean $hidden_endpoint |
551 | 551 | * @return array |
552 | 552 | */ |
553 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
553 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
554 | 554 | return array( |
555 | 555 | 'resources' => array( |
556 | 556 | array( |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | * @param array $route_data |
573 | 573 | * @return array |
574 | 574 | */ |
575 | - public static function hide_old_endpoints( $route_data ) { |
|
576 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
577 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
578 | - foreach( $routes as $route ) { |
|
579 | - if( $route[ 'hidden_endpoint' ] ) { |
|
580 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
581 | - unset( $route_data[ $full_route ] ); |
|
575 | + public static function hide_old_endpoints($route_data) { |
|
576 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
577 | + foreach ($relative_urls as $endpoint => $routes) { |
|
578 | + foreach ($routes as $route) { |
|
579 | + if ($route['hidden_endpoint']) { |
|
580 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
581 | + unset($route_data[$full_route]); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public static function latest_rest_api_version() { |
619 | 619 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
620 | - $versions_served_keys = array_keys( $versions_served ); |
|
621 | - return end( $versions_served_keys ); |
|
620 | + $versions_served_keys = array_keys($versions_served); |
|
621 | + return end($versions_served_keys); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -632,32 +632,32 @@ discard block |
||
632 | 632 | public static function versions_served() { |
633 | 633 | $versions_served = array(); |
634 | 634 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
635 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
636 | - reset( $possibly_served_versions ); |
|
637 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
638 | - $latest_version = end( $versions_served_historically ); |
|
639 | - reset( $versions_served_historically ); |
|
635 | + $lowest_compatible_version = end($possibly_served_versions); |
|
636 | + reset($possibly_served_versions); |
|
637 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
638 | + $latest_version = end($versions_served_historically); |
|
639 | + reset($versions_served_historically); |
|
640 | 640 | //for each version of core we have ever served: |
641 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
641 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
642 | 642 | //if it's not above the current core version, and it's compatible with the current version of core |
643 | - if( $key_versioned_endpoint == $latest_version ) { |
|
643 | + if ($key_versioned_endpoint == $latest_version) { |
|
644 | 644 | //don't hide the latest version in the index |
645 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
646 | - } else if( |
|
645 | + $versions_served[$key_versioned_endpoint] = false; |
|
646 | + } else if ( |
|
647 | 647 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
648 | 648 | && $key_versioned_endpoint >= $lowest_compatible_version |
649 | 649 | ) { |
650 | 650 | //include, but hide, previous versions which are still supported |
651 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
652 | - } elseif( |
|
651 | + $versions_served[$key_versioned_endpoint] = true; |
|
652 | + } elseif ( |
|
653 | 653 | apply_filters( |
654 | 654 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
655 | 655 | false, |
656 | 656 | $possibly_served_versions |
657 | 657 | ) |
658 | - ){ |
|
658 | + ) { |
|
659 | 659 | //if a version is no longer supported, don't include it in index or list of versions served |
660 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
660 | + $versions_served[$key_versioned_endpoint] = true; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | return $versions_served; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @return string |
671 | 671 | */ |
672 | 672 | public static function core_version() { |
673 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
673 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * @param WP $WP |
696 | 696 | * @return void |
697 | 697 | */ |
698 | - public function run( $WP ) { |
|
698 | + public function run($WP) { |
|
699 | 699 | |
700 | 700 | } |
701 | 701 |
@@ -864,8 +864,8 @@ |
||
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | 866 | if ( isset( $this->_data->reg_obj ) |
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | - && $this->_single_message |
|
867 | + && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | + && $this->_single_message |
|
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * EE_Base_Class_Object |
275 | 275 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
276 | 276 | */ |
277 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
277 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
278 | 278 | |
279 | 279 | |
280 | 280 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @deprecated 4.9.0 |
302 | 302 | * @return int |
303 | 303 | */ |
304 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
304 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
305 | 305 | return 0; |
306 | 306 | } |
307 | 307 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sending. |
331 | 331 | * @since 4.9.0 |
332 | 332 | */ |
333 | - public function do_messenger_hooks( $messenger = null ) { |
|
333 | + public function do_messenger_hooks($messenger = null) { |
|
334 | 334 | $this->_active_messenger = $messenger; |
335 | 335 | $this->_do_messenger_hooks(); |
336 | 336 | } |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
380 | 380 | * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
381 | 381 | */ |
382 | - public function get_data_handler( $data ) { |
|
382 | + public function get_data_handler($data) { |
|
383 | 383 | $this->_data = $data; |
384 | 384 | $this->_set_data_handler(); |
385 | - return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this ); |
|
385 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -419,26 +419,26 @@ discard block |
||
419 | 419 | * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
420 | 420 | * @return string generated url |
421 | 421 | */ |
422 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
422 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
423 | 423 | //validate context |
424 | 424 | //valid context? |
425 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
425 | + if ( ! isset($this->_contexts[$context])) { |
|
426 | 426 | throw new EE_Error( |
427 | 427 | sprintf( |
428 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
428 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
429 | 429 | $context, |
430 | - get_class( $this ) |
|
430 | + get_class($this) |
|
431 | 431 | ) |
432 | 432 | ); |
433 | 433 | } |
434 | 434 | //valid sending_messenger? |
435 | 435 | $not_valid_msgr = false; |
436 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
437 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === false ) { |
|
436 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
437 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
438 | 438 | $not_valid_msgr = true; |
439 | 439 | } |
440 | 440 | } |
441 | - if ( $not_valid_msgr ) { |
|
441 | + if ($not_valid_msgr) { |
|
442 | 442 | throw new EE_Error( |
443 | 443 | sprintf( |
444 | 444 | __( |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | 'event_espresso' |
447 | 447 | ), |
448 | 448 | $sending_messenger, |
449 | - get_class( $this ) |
|
449 | + get_class($this) |
|
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->name, |
458 | 458 | $registration, |
459 | 459 | $this->_GRP_ID, |
460 | - $this->_get_id_for_msg_url( $context, $registration ) |
|
460 | + $this->_get_id_for_msg_url($context, $registration) |
|
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
@@ -476,26 +476,26 @@ discard block |
||
476 | 476 | * EE_Base_Class_Object |
477 | 477 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
478 | 478 | */ |
479 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
479 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
480 | 480 | //valid context? |
481 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
481 | + if ( ! isset($this->_contexts[$context])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $context, |
486 | - get_class( $this ) |
|
486 | + get_class($this) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | //get data and apply global and class specific filters on it. |
491 | 491 | $data = apply_filters( |
492 | 492 | 'FHEE__EE_message_type__get_data_for_context__data', |
493 | - $this->_get_data_for_context( $context, $registration, $id ), |
|
493 | + $this->_get_data_for_context($context, $registration, $id), |
|
494 | 494 | $this |
495 | 495 | ); |
496 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
496 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
497 | 497 | //if empty then something went wrong! |
498 | - if ( empty( $data ) ) { |
|
498 | + if (empty($data)) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __( |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | protected function _set_with_messengers() { |
541 | 541 | $this->_with_messengers = array( |
542 | - 'email' => array( 'html' ), |
|
542 | + 'email' => array('html'), |
|
543 | 543 | ); |
544 | 544 | } |
545 | 545 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function with_messengers() { |
555 | 555 | return apply_filters( |
556 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), |
|
556 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), |
|
557 | 557 | $this->_with_messengers |
558 | 558 | ); |
559 | 559 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $messengers = array() |
581 | 581 | ) { |
582 | 582 | //we can also further refine the context by action (if present). |
583 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
583 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | public function get_master_templates() { |
616 | 616 | //first class specific filter then filter that by the global filter. |
617 | 617 | $master_templates = apply_filters( |
618 | - 'FHEE__' . get_class( $this ) . '__get_master_templates', |
|
618 | + 'FHEE__'.get_class($this).'__get_master_templates', |
|
619 | 619 | $this->_master_templates |
620 | 620 | ); |
621 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
621 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -632,20 +632,20 @@ discard block |
||
632 | 632 | * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
633 | 633 | * that context |
634 | 634 | */ |
635 | - public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) { |
|
635 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') { |
|
636 | 636 | //override _data |
637 | 637 | $this->_data = $data; |
638 | 638 | $addressees = array(); |
639 | 639 | //if incoming context then limit to that context |
640 | - if ( ! empty( $context ) ) { |
|
641 | - $cntxt = ! empty( $this->_contexts[ $context ] ) ? $this->_contexts[ $context ] : ''; |
|
642 | - if ( ! empty( $cntxt ) ) { |
|
640 | + if ( ! empty($context)) { |
|
641 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
642 | + if ( ! empty($cntxt)) { |
|
643 | 643 | $this->_contexts = array(); |
644 | - $this->_contexts[ $context ] = $cntxt; |
|
644 | + $this->_contexts[$context] = $cntxt; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | $this->_set_default_addressee_data(); |
648 | - if ( $this->_process_data() ) { |
|
648 | + if ($this->_process_data()) { |
|
649 | 649 | $addressees = $this->_addressees; |
650 | 650 | } |
651 | 651 | return $addressees; |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | */ |
662 | 662 | protected function _process_data() { |
663 | 663 | //at a minimum, we NEED EE_Attendee objects. |
664 | - if ( empty( $this->_data->attendees ) ) { |
|
665 | - return false; //there's no data to process! |
|
664 | + if (empty($this->_data->attendees)) { |
|
665 | + return false; //there's no data to process! |
|
666 | 666 | } |
667 | 667 | // process addressees for each context. Child classes will have to have methods for |
668 | 668 | // each context defined to handle the processing of the data object within them |
669 | - foreach ( $this->_contexts as $context => $details ) { |
|
670 | - $xpctd_method = '_' . $context . '_addressees'; |
|
671 | - if ( ! method_exists( $this, $xpctd_method ) ) { |
|
669 | + foreach ($this->_contexts as $context => $details) { |
|
670 | + $xpctd_method = '_'.$context.'_addressees'; |
|
671 | + if ( ! method_exists($this, $xpctd_method)) { |
|
672 | 672 | throw new EE_Error( |
673 | 673 | sprintf( |
674 | 674 | __( |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | } |
683 | - $this->_addressees[ $context ] = call_user_func( array( $this, $xpctd_method ) ); |
|
683 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
684 | 684 | } |
685 | 685 | return true; //data was processed successfully. |
686 | 686 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | 'grand_total_line_item' => $this->_data->grand_total_line_item, |
703 | 703 | 'txn' => $this->_data->txn, |
704 | 704 | 'payments' => $this->_data->payments, |
705 | - 'payment' => isset( $this->_data->payment ) && $this->_data->payment instanceof EE_Payment |
|
705 | + 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
706 | 706 | ? $this->_data->payment |
707 | 707 | : null, |
708 | 708 | 'reg_objs' => $this->_data->reg_objs, |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | 'txn_status' => $this->_data->txn_status, |
716 | 716 | 'total_ticket_count' => $this->_data->total_ticket_count, |
717 | 717 | ); |
718 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
718 | + if (is_array($this->_data->primary_attendee_data)) { |
|
719 | 719 | $this->_default_addressee_data = array_merge( |
720 | 720 | $this->_default_addressee_data, |
721 | 721 | $this->_data->primary_attendee_data |
@@ -759,24 +759,24 @@ discard block |
||
759 | 759 | 'messenger', |
760 | 760 | ); |
761 | 761 | $contexts = $this->get_contexts(); |
762 | - foreach ( $contexts as $context => $details ) { |
|
763 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
762 | + foreach ($contexts as $context => $details) { |
|
763 | + $this->_valid_shortcodes[$context] = $all_shortcodes; |
|
764 | 764 | //make sure non admin context does not include the event_author shortcodes |
765 | - if ( $context != 'admin' ) { |
|
766 | - if ( ( $key = array_search( 'event_author', $this->_valid_shortcodes[ $context ] ) ) !== false ) { |
|
767 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
765 | + if ($context != 'admin') { |
|
766 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
767 | + unset($this->_valid_shortcodes[$context][$key]); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | // make sure admin context does not include the recipient_details shortcodes |
772 | 772 | // IF we have admin context hooked in message types might not have that context. |
773 | - if ( ! empty( $this->_valid_shortcodes['admin'] ) ) { |
|
774 | - if ( ( $key = array_search( 'recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
775 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
773 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
774 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
775 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
776 | 776 | } |
777 | 777 | //make sure admin context does not include the recipient_details shortcodes |
778 | - if ( ( $key = array_search( 'recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
779 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
778 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
779 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | * @param array $new_config array of valid shortcodes (by context) |
790 | 790 | * @return void sets valid_shortcodes property |
791 | 791 | */ |
792 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
793 | - foreach ( $new_config as $context => $shortcodes ) { |
|
794 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
792 | + public function reset_valid_shortcodes_config($new_config) { |
|
793 | + foreach ($new_config as $context => $shortcodes) { |
|
794 | + $this->_valid_shortcodes[$context] = $shortcodes; |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | $addressees = array(); |
809 | 809 | // first we need to get the event admin user id for all the events |
810 | 810 | // and setup an addressee object for each unique admin user. |
811 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
812 | - $admin_id = $this->_get_event_admin_id( $event['ID'] ); |
|
811 | + foreach ($this->_data->events as $line_ref => $event) { |
|
812 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
813 | 813 | //make sure we are just including the events that belong to this admin! |
814 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
814 | + $admin_events[$admin_id][$line_ref] = $event; |
|
815 | 815 | } |
816 | 816 | //k now we can loop through the event_admins and setup the addressee data. |
817 | - foreach ( $admin_events as $admin_id => $event_details ) { |
|
817 | + foreach ($admin_events as $admin_id => $event_details) { |
|
818 | 818 | $aee = array( |
819 | 819 | 'user_id' => $admin_id, |
820 | 820 | 'events' => $event_details, |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | 'recipient_id' => $admin_id, |
823 | 823 | 'recipient_type' => 'WP_User', |
824 | 824 | ); |
825 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
826 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
825 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
826 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
827 | 827 | } |
828 | 828 | return $addressees; |
829 | 829 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
844 | 844 | $aee['recipient_type'] = 'Attendee'; |
845 | 845 | //great now we can instantiate the $addressee object and return (as an array); |
846 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
846 | + $add[] = new EE_Messages_Addressee($aee); |
|
847 | 847 | return $add; |
848 | 848 | } |
849 | 849 | |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | //we just have to loop through the attendees. We'll also set the attached events for each attendee. |
861 | 861 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
862 | 862 | $already_processed = array(); |
863 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
863 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | - if ( isset( $this->_data->reg_obj ) |
|
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
866 | + if (isset($this->_data->reg_obj) |
|
867 | + && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
868 | 868 | && $this->_single_message |
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | // is $this->_regs_for_sending present? |
873 | 873 | // If so, let's make sure we ONLY generate addressee for registrations in that array. |
874 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
875 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
876 | - if ( empty( $regs_allowed ) ) { |
|
874 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
875 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
876 | + if (empty($regs_allowed)) { |
|
877 | 877 | continue; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | if ( |
881 | - in_array( $details['attendee_email'], $already_processed ) |
|
881 | + in_array($details['attendee_email'], $already_processed) |
|
882 | 882 | && apply_filters( |
883 | 883 | 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
884 | 884 | true, |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | continue; |
890 | 890 | } |
891 | 891 | $already_processed[] = $details['attendee_email']; |
892 | - foreach ( $details as $item => $value ) { |
|
893 | - $aee[ $item ] = $value; |
|
894 | - if ( $item == 'line_ref' ) { |
|
895 | - foreach ( $value as $event_id ) { |
|
896 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
892 | + foreach ($details as $item => $value) { |
|
893 | + $aee[$item] = $value; |
|
894 | + if ($item == 'line_ref') { |
|
895 | + foreach ($value as $event_id) { |
|
896 | + $aee['events'][$event_id] = $this->_data->events[$event_id]; |
|
897 | 897 | } |
898 | 898 | } |
899 | - if ( $item == 'attendee_email' ) { |
|
899 | + if ($item == 'attendee_email') { |
|
900 | 900 | $aee['attendee_email'] = $value; |
901 | 901 | } |
902 | 902 | /*if ( $item == 'registration_id' ) { |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | } |
906 | 906 | // note the FIRST reg object in this array is the one |
907 | 907 | // we'll use for this attendee as the primary registration for this attendee. |
908 | - $aee['reg_obj'] = reset( $this->_data->attendees[ $att_id ]['reg_objs'] ); |
|
908 | + $aee['reg_obj'] = reset($this->_data->attendees[$att_id]['reg_objs']); |
|
909 | 909 | $aee['attendees'] = $this->_data->attendees; |
910 | 910 | $aee['recipient_id'] = $att_id; |
911 | 911 | $aee['recipient_type'] = 'Attendee'; |
912 | 912 | //merge in the primary attendee data |
913 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
914 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
913 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
914 | + $add[] = new EE_Messages_Addressee($aee); |
|
915 | 915 | } |
916 | 916 | return $add; |
917 | 917 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * @param $event_id |
923 | 923 | * @return int |
924 | 924 | */ |
925 | - protected function _get_event_admin_id( $event_id ) { |
|
926 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
925 | + protected function _get_event_admin_id($event_id) { |
|
926 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
927 | 927 | return $event instanceof EE_Event ? $event->wp_user() : 0; |
928 | 928 | } |
929 | 929 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties |
261 | 261 | * for the object. |
262 | 262 | */ |
263 | - public function __construct( $addressee_data ) { |
|
263 | + public function __construct($addressee_data) { |
|
264 | 264 | $this->_data = $addressee_data; |
265 | 265 | $this->_set_properties(); |
266 | 266 | } |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | * @return void. |
276 | 276 | */ |
277 | 277 | protected function _set_properties() { |
278 | - foreach ( $this->_data as $prop => $value ) { |
|
279 | - if ( property_exists( $this, $prop ) ) { |
|
278 | + foreach ($this->_data as $prop => $value) { |
|
279 | + if (property_exists($this, $prop)) { |
|
280 | 280 | $this->{$prop} = $value; |
281 | 281 | } |
282 | 282 | } |
283 | 283 | //if user_id present we'll use this to set the fname and lname and admin_email. |
284 | - if ( ! empty( $this->user_id ) ) { |
|
284 | + if ( ! empty($this->user_id)) { |
|
285 | 285 | $this->user_id = (int) $this->user_id; |
286 | - $user = get_userdata( $this->user_id ); |
|
286 | + $user = get_userdata($this->user_id); |
|
287 | 287 | $this->fname = $user->user_firstname; |
288 | 288 | $this->lname = $user->user_lastname; |
289 | 289 | $this->admin_email = $user->user_email; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | |
41 | 41 | |
42 | 42 | protected function _init_props() { |
43 | - $this->label = esc_html__( 'Transaction Shortcodes', 'event_espresso' ); |
|
44 | - $this->description = esc_html__( 'All shortcodes specific to transaction related data', 'event_espresso' ); |
|
43 | + $this->label = esc_html__('Transaction Shortcodes', 'event_espresso'); |
|
44 | + $this->description = esc_html__('All shortcodes specific to transaction related data', 'event_espresso'); |
|
45 | 45 | $this->_shortcodes = array( |
46 | - '[TXN_ID]' => esc_html__( 'The transaction id for the purchase.', 'event_espresso' ), |
|
47 | - '[PAYMENT_URL]' => esc_html__( 'This is a link to make a payment for the event', 'event_espresso' ), |
|
48 | - '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso' ) . '<ul>' |
|
49 | - . '<li>' . sprintf( esc_html__( '%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
50 | - . '<li>' . sprintf( esc_html__( '%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
51 | - . '<li>' . sprintf( esc_html__( '%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
46 | + '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
|
47 | + '[PAYMENT_URL]' => esc_html__('This is a link to make a payment for the event', 'event_espresso'), |
|
48 | + '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
49 | + . '<li>'.sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
50 | + . '<li>'.sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
51 | + . '<li>'.sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
52 | 52 | . '</ul>', |
53 | - '[PAYMENT_DUE_DATE_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
53 | + '[PAYMENT_DUE_DATE_*]' => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
54 | 54 | . '<ul>' |
55 | - . '<li>' . sprintf( esc_html__( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
56 | - . '<li>' . sprintf( esc_html__( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
57 | - . '<li>' . sprintf( esc_html__( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
58 | - '[INVOICE_LINK]' => esc_html__( 'This is a full html link to the invoice', 'event_espresso' ), |
|
59 | - '[INVOICE_URL]' => esc_html__( 'This is just the url for the invoice', 'event_espresso' ), |
|
60 | - '[INVOICE_LOGO_URL]' => esc_html__( 'This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso' ), |
|
61 | - '[INVOICE_LOGO]' => esc_html__( 'This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_NAME]' => esc_html__( 'This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_ADDRESS]' => esc_html__( 'This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
64 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__( 'This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
65 | - '[INVOICE_PAYEE_EMAIL]' => esc_html__( 'This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
66 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( esc_html__( 'This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), '<code>', '</code>' ), |
|
67 | - '[TOTAL_COST]' => esc_html__( 'The total cost for the transaction', 'event_espresso' ), |
|
68 | - '[TXN_STATUS]' => esc_html__( 'The transaction status for the transaction.', 'event_espresso' ), |
|
69 | - '[TXN_STATUS_ID]' => esc_html__( 'The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso' ), |
|
70 | - '[PAYMENT_STATUS]' => esc_html__( 'The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso' ), |
|
71 | - '[PAYMENT_GATEWAY]' => esc_html__( 'The payment gateway used for the transaction', 'event_espresso' ), |
|
72 | - '[AMOUNT_PAID]' => esc_html__( 'The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso' ), |
|
73 | - '[LAST_AMOUNT_PAID]' => esc_html__( 'This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso' ), |
|
74 | - '[TOTAL_AMOUNT_PAID]' => esc_html__( 'This parses to the total amount paid over all payments', 'event_espresso' ), |
|
75 | - '[TOTAL_OWING]' => esc_html__( 'The total owing on a transaction with no attributes.', 'event_espresso' ), |
|
76 | - '[TXN_SUBTOTAL]' => esc_html__( 'The subtotal for all txn line items.', 'event_espresso' ), |
|
77 | - '[TXN_TAX_SUBTOTAL]' => esc_html__( 'The subtotal for all tax line items.', 'event_espresso' ), |
|
78 | - '[OWING_STATUS_MESSAGE_*]' => esc_html__( 'A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso' ) . '<p></ul>' . |
|
79 | - '<li><strong>still_owing</strong>:' . esc_html__( 'If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso' ) . sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
80 | - '<li><strong>none_owing</strong>:' . esc_html__( 'If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso' ) . '</li></ul></p>', |
|
81 | - '[TXN_TOTAL_TICKETS]' => esc_html__( 'The total number of all tickets purchased in a transaction', 'event_espresso' ), |
|
82 | - '[TKT_QTY_PURCHASED]' => sprintf( esc_html__( 'The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso' ), '<strong>', '</strong>' ), |
|
83 | - '[TRANSACTION_ADMIN_URL]' => esc_html__( 'The url to the admin page for this transaction', 'event_espresso' ), |
|
84 | - '[RECEIPT_URL]' => esc_html__( 'This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso' ), |
|
85 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso' ), |
|
86 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( esc_html__( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
55 | + . '<li>'.sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
56 | + . '<li>'.sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
57 | + . '<li>'.sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
58 | + '[INVOICE_LINK]' => esc_html__('This is a full html link to the invoice', 'event_espresso'), |
|
59 | + '[INVOICE_URL]' => esc_html__('This is just the url for the invoice', 'event_espresso'), |
|
60 | + '[INVOICE_LOGO_URL]' => esc_html__('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
|
61 | + '[INVOICE_LOGO]' => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_NAME]' => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
64 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
65 | + '[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
66 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will output: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), '<code>', '</code>'), |
|
67 | + '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
|
68 | + '[TXN_STATUS]' => esc_html__('The transaction status for the transaction.', 'event_espresso'), |
|
69 | + '[TXN_STATUS_ID]' => esc_html__('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
|
70 | + '[PAYMENT_STATUS]' => esc_html__('The transaction status for the transaction. This parses to the same value as the [TXN_STATUS] shortcode and still remains here for legacy support.', 'event_espresso'), |
|
71 | + '[PAYMENT_GATEWAY]' => esc_html__('The payment gateway used for the transaction', 'event_espresso'), |
|
72 | + '[AMOUNT_PAID]' => esc_html__('The amount paid or refunded. This will only have a value if there was a payment or refund at the time of generating the message.', 'event_espresso'), |
|
73 | + '[LAST_AMOUNT_PAID]' => esc_html__('This is the last payment or refund made on the transaction related to the message being generated.', 'event_espresso'), |
|
74 | + '[TOTAL_AMOUNT_PAID]' => esc_html__('This parses to the total amount paid over all payments', 'event_espresso'), |
|
75 | + '[TOTAL_OWING]' => esc_html__('The total owing on a transaction with no attributes.', 'event_espresso'), |
|
76 | + '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
|
77 | + '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
|
78 | + '[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total owing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
79 | + '<li><strong>still_owing</strong>:'.esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount owing). The default is:', 'event_espresso').sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
80 | + '<li><strong>none_owing</strong>:'.esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total owing.', 'event_espresso').'</li></ul></p>', |
|
81 | + '[TXN_TOTAL_TICKETS]' => esc_html__('The total number of all tickets purchased in a transaction', 'event_espresso'), |
|
82 | + '[TKT_QTY_PURCHASED]' => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>'), |
|
83 | + '[TRANSACTION_ADMIN_URL]' => esc_html__('The url to the admin page for this transaction', 'event_espresso'), |
|
84 | + '[RECEIPT_URL]' => esc_html__('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
|
85 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
86 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
@@ -94,40 +94,40 @@ discard block |
||
94 | 94 | * @param string $shortcode the shortcode to be parsed. |
95 | 95 | * @return string parsed shortcode |
96 | 96 | */ |
97 | - protected function _parser( $shortcode ) { |
|
97 | + protected function _parser($shortcode) { |
|
98 | 98 | |
99 | 99 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
100 | 100 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
101 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
101 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
102 | 102 | |
103 | 103 | //payment |
104 | 104 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
105 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
105 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
106 | 106 | |
107 | 107 | |
108 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
108 | + if ( ! $transaction instanceof EE_Transaction) { |
|
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | |
112 | - switch ( $shortcode ) { |
|
112 | + switch ($shortcode) { |
|
113 | 113 | case '[TXN_ID]' : |
114 | 114 | return $transaction->ID(); |
115 | 115 | break; |
116 | 116 | |
117 | 117 | case '[PAYMENT_URL]' : |
118 | 118 | $payment_url = $transaction->payment_overview_url(); |
119 | - return empty( $payment_url ) ? esc_html__( 'http://dummypaymenturlforpreview.com', 'event_espresso' ) : $payment_url; |
|
119 | + return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LINK]' : |
123 | 123 | $invoice_url = $transaction->invoice_url(); |
124 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | - return sprintf( esc_html__( '%sClick here for Invoice%s', 'event_espresso' ), '<a href="' . $invoice_url . '">', '</a>' ); |
|
124 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
125 | + return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
126 | 126 | break; /**/ |
127 | 127 | |
128 | 128 | case '[INVOICE_URL]' : |
129 | 129 | $invoice_url = $transaction->invoice_url(); |
130 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
130 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | case '[INVOICE_LOGO_URL]' : |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | break; |
136 | 136 | |
137 | 137 | case '[INVOICE_LOGO]' : |
138 | - return $this->_get_invoice_logo( true ); |
|
138 | + return $this->_get_invoice_logo(true); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case '[INVOICE_PAYEE_NAME]' : |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | |
158 | 158 | case '[TOTAL_COST]' : |
159 | 159 | $total = $transaction->total(); |
160 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
160 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case '[PAYMENT_STATUS]' : |
164 | 164 | $status = $transaction->pretty_status(); |
165 | - return ! empty($status) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
165 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
166 | 166 | break; /**/ |
167 | 167 | |
168 | 168 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
169 | 169 | case '[TXN_STATUS]': |
170 | 170 | $status = $transaction->pretty_status(); |
171 | - return ! empty( $status ) ? $status : esc_html__( 'Unknown', 'event_espresso' ); |
|
171 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
172 | 172 | break; |
173 | 173 | |
174 | 174 | case '[TXN_STATUS_ID]' : |
@@ -176,36 +176,36 @@ discard block |
||
176 | 176 | break; |
177 | 177 | |
178 | 178 | case '[PAYMENT_GATEWAY]' : |
179 | - return $this->_get_payment_gateway( $transaction ); |
|
179 | + return $this->_get_payment_gateway($transaction); |
|
180 | 180 | break; |
181 | 181 | |
182 | 182 | case '[AMOUNT_PAID]' : |
183 | 183 | return $payment instanceof EE_Payment |
184 | - ? EEH_Template::format_currency( $payment->amount() ) |
|
185 | - : EEH_Template::format_currency( 0 ); |
|
184 | + ? EEH_Template::format_currency($payment->amount()) |
|
185 | + : EEH_Template::format_currency(0); |
|
186 | 186 | break; |
187 | 187 | |
188 | 188 | case '[LAST_AMOUNT_PAID]' : |
189 | 189 | $last_payment = $transaction->last_payment(); |
190 | 190 | return $last_payment instanceof EE_Payment |
191 | - ? EEH_Template::format_currency( $last_payment->amount() ) |
|
192 | - : EEH_Template::format_currency( 0 ); |
|
191 | + ? EEH_Template::format_currency($last_payment->amount()) |
|
192 | + : EEH_Template::format_currency(0); |
|
193 | 193 | |
194 | 194 | case '[TOTAL_AMOUNT_PAID]' : |
195 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
195 | + return EEH_Template::format_currency($transaction->paid()); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | case '[TOTAL_OWING]' : |
199 | 199 | $total_owing = $transaction->remaining(); |
200 | - return EEH_Template::format_currency( $total_owing ); |
|
200 | + return EEH_Template::format_currency($total_owing); |
|
201 | 201 | break; |
202 | 202 | |
203 | 203 | case '[TXN_SUBTOTAL]' : |
204 | - return EEH_Template::format_currency( $this->_get_subtotal() ); |
|
204 | + return EEH_Template::format_currency($this->_get_subtotal()); |
|
205 | 205 | break; |
206 | 206 | |
207 | 207 | case '[TXN_TAX_SUBTOTAL]' : |
208 | - return EEH_Template::format_currency( $this->_get_subtotal( true ) ); |
|
208 | + return EEH_Template::format_currency($this->_get_subtotal(true)); |
|
209 | 209 | break; |
210 | 210 | |
211 | 211 | case '[TKT_QTY_PURCHASED]' : |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | break; |
215 | 215 | |
216 | 216 | case '[TRANSACTION_ADMIN_URL]' : |
217 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
218 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
219 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url( 'admin.php' ) ); |
|
217 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
218 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
219 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
220 | 220 | return $url; |
221 | 221 | break; |
222 | 222 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | //get primary_registration |
225 | 225 | $reg = $this->_data->primary_reg_obj; |
226 | 226 | |
227 | - if ( ! $reg instanceof EE_Registration ) { |
|
227 | + if ( ! $reg instanceof EE_Registration) { |
|
228 | 228 | return ''; |
229 | 229 | } |
230 | 230 | return $reg->receipt_url(); |
231 | 231 | break; |
232 | 232 | |
233 | 233 | case '[INVOICE_RECEIPT_SWITCHER_URL]' : |
234 | - return $this->_get_invoice_receipt_switcher( false ); |
|
234 | + return $this->_get_invoice_receipt_switcher(false); |
|
235 | 235 | break; |
236 | 236 | |
237 | 237 | case '[INVOICE_RECEIPT_SWITCHER_BUTTON]' : |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | |
242 | 242 | } |
243 | 243 | |
244 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== false ) { |
|
245 | - return $this->_get_custom_total_owing( $shortcode ); |
|
244 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== false) { |
|
245 | + return $this->_get_custom_total_owing($shortcode); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== false ) { |
|
249 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
248 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== false) { |
|
249 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
250 | 250 | } |
251 | 251 | |
252 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== false ) { |
|
253 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
252 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== false) { |
|
253 | + return $this->_get_payment_link_if_needed($shortcode); |
|
254 | 254 | } |
255 | 255 | |
256 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
257 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
256 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
257 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | return ''; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return string parsed. |
273 | 273 | */ |
274 | - private function _get_custom_total_owing( $shortcode ) { |
|
275 | - $valid_shortcodes = array( 'transaction' ); |
|
276 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
274 | + private function _get_custom_total_owing($shortcode) { |
|
275 | + $valid_shortcodes = array('transaction'); |
|
276 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
277 | 277 | |
278 | 278 | //ensure default is set. |
279 | 279 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
280 | 280 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
281 | 281 | |
282 | - if ( $total_owing > 0 ) { |
|
283 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso' ), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
284 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
282 | + if ($total_owing > 0) { |
|
283 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
284 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
285 | 285 | } else { |
286 | - $owing_content = ! empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
286 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $owing_content; |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param EE_Transaction $transaction |
296 | 296 | * @return string |
297 | 297 | */ |
298 | - private function _get_payment_gateway( $transaction ) { |
|
299 | - $pm = $this->_get_payment_method( $transaction ); |
|
298 | + private function _get_payment_gateway($transaction) { |
|
299 | + $pm = $this->_get_payment_method($transaction); |
|
300 | 300 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
301 | 301 | } |
302 | 302 | |
@@ -311,37 +311,37 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return string url or html |
313 | 313 | */ |
314 | - private function _get_invoice_logo( $img_tags = false ) { |
|
314 | + private function _get_invoice_logo($img_tags = false) { |
|
315 | 315 | //try to get the invoice payment method's logo for this transaction image first |
316 | 316 | $pm = $this->_get_payment_method(); |
317 | - if ( $pm instanceof EE_Payment_Method ){ |
|
318 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', true ); |
|
317 | + if ($pm instanceof EE_Payment_Method) { |
|
318 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', true); |
|
319 | 319 | } else { |
320 | 320 | $invoice_logo_url = null; |
321 | 321 | } |
322 | - if ( empty( $invoice_logo_url ) ){ |
|
322 | + if (empty($invoice_logo_url)) { |
|
323 | 323 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
324 | 324 | } |
325 | 325 | |
326 | - if ( empty( $invoice_logo_url ) ) { |
|
326 | + if (empty($invoice_logo_url)) { |
|
327 | 327 | return ''; |
328 | 328 | } |
329 | 329 | |
330 | - if ( ! $img_tags ) { |
|
330 | + if ( ! $img_tags) { |
|
331 | 331 | return $invoice_logo_url; |
332 | 332 | } |
333 | 333 | |
334 | 334 | //image tags have been requested. |
335 | - $image_size = getimagesize( $invoice_logo_url ); |
|
335 | + $image_size = getimagesize($invoice_logo_url); |
|
336 | 336 | |
337 | 337 | //if image is wider than 200px, set the width to 200 |
338 | - if ( $image_size[0] > 300 ) { |
|
338 | + if ($image_size[0] > 300) { |
|
339 | 339 | $image_width = 300; |
340 | 340 | } else { |
341 | 341 | $image_width = $image_size[0]; |
342 | 342 | } |
343 | 343 | |
344 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
344 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | private function _get_invoice_payee_name() { |
359 | 359 | $payee_name = null; |
360 | 360 | $pm = $this->_get_payment_method(); |
361 | - if ( $pm instanceof EE_Payment_Method ){ |
|
362 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', true ); |
|
361 | + if ($pm instanceof EE_Payment_Method) { |
|
362 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', true); |
|
363 | 363 | } |
364 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
364 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
365 | 365 | return $payee_name; |
366 | 366 | } |
367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param EE_Transaction|null $transaction |
374 | 374 | * @return \EE_Payment_Method|mixed|null|void |
375 | 375 | */ |
376 | - private function _get_payment_method( $transaction = null ){ |
|
377 | - if ( $transaction instanceof EE_Transaction ) { |
|
376 | + private function _get_payment_method($transaction = null) { |
|
377 | + if ($transaction instanceof EE_Transaction) { |
|
378 | 378 | $payment_method = $transaction->payment_method(); |
379 | - if ( empty( $payment_method ) ) { |
|
380 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
379 | + if (empty($payment_method)) { |
|
380 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
381 | 381 | } |
382 | 382 | return $payment_method; |
383 | 383 | } else { |
384 | 384 | //get the first payment method we can find |
385 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ) ); |
|
385 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | private function _get_invoice_payee_email() { |
400 | 400 | $payee_email = null; |
401 | 401 | $pm = $this->_get_payment_method(); |
402 | - if ( $pm instanceof EE_Payment_Method ){ |
|
403 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', true ); |
|
402 | + if ($pm instanceof EE_Payment_Method) { |
|
403 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', true); |
|
404 | 404 | } |
405 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
405 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
406 | 406 | return $payee_email; |
407 | 407 | } |
408 | 408 | |
@@ -418,24 +418,24 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
421 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
422 | 422 | $payee_tax_number = null; |
423 | 423 | $pm = $this->_get_payment_method(); |
424 | - if ( $pm instanceof EE_Payment_Method ){ |
|
425 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', true ); |
|
424 | + if ($pm instanceof EE_Payment_Method) { |
|
425 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', true); |
|
426 | 426 | } |
427 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
427 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
428 | 428 | |
429 | - if ( empty( $payee_tax_number ) ) { |
|
429 | + if (empty($payee_tax_number)) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | 433 | //any attributes? |
434 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
434 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
435 | 435 | |
436 | 436 | //prefix? |
437 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' ); |
|
438 | - return $prefix . $payee_tax_number; |
|
437 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
438 | + return $prefix.$payee_tax_number; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -452,22 +452,22 @@ discard block |
||
452 | 452 | private function _get_invoice_payee_address() { |
453 | 453 | $payee_address = null; |
454 | 454 | $pm = $this->_get_payment_method(); |
455 | - if ( $pm instanceof EE_Payment_Method ){ |
|
456 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', true ); |
|
455 | + if ($pm instanceof EE_Payment_Method) { |
|
456 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', true); |
|
457 | 457 | } |
458 | - if ( empty( $payee_address ) ) { |
|
458 | + if (empty($payee_address)) { |
|
459 | 459 | $organization = EE_Registry::instance()->CFG->organization; |
460 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
461 | - $payee_address .= ! empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
462 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
460 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
461 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
462 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
463 | 463 | |
464 | 464 | //state |
465 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
466 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
465 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
466 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
467 | 467 | |
468 | 468 | //Country |
469 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
470 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
469 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
470 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
471 | 471 | } |
472 | 472 | return $payee_address; |
473 | 473 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | private function _get_invoice_payment_instructions() { |
486 | 486 | $instructions = null; |
487 | 487 | $pm = $this->_get_payment_method(); |
488 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', true ) : ''; |
|
488 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', true) : ''; |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -499,27 +499,27 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - protected function _get_invoice_receipt_switcher( $button = true ) { |
|
502 | + protected function _get_invoice_receipt_switcher($button = true) { |
|
503 | 503 | $reg = $this->_data->primary_reg_obj; |
504 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
505 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
504 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
505 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
506 | 506 | return ''; |
507 | 507 | } |
508 | 508 | |
509 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__( 'View Invoice', 'event_espresso' ) : esc_html__( 'Switch to Invoice', 'event_espresso' ); |
|
511 | - $switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
509 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
510 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
511 | + $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
512 | 512 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
513 | 513 | |
514 | - if ( ! $button ) { |
|
514 | + if ( ! $button) { |
|
515 | 515 | return $switch_to_url; |
516 | 516 | } |
517 | 517 | |
518 | - if ( ! empty( $switch_to_url ) ) { |
|
518 | + if ( ! empty($switch_to_url)) { |
|
519 | 519 | |
520 | 520 | return ' |
521 | - <form method="post" action="' . $switch_to_url . '" > |
|
522 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
521 | + <form method="post" action="' . $switch_to_url.'" > |
|
522 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
523 | 523 | </form> |
524 | 524 | '; |
525 | 525 | } |
@@ -559,10 +559,10 @@ discard block |
||
559 | 559 | * |
560 | 560 | * @return int |
561 | 561 | */ |
562 | - private function _get_subtotal( $tax = false ) { |
|
563 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : null; |
|
562 | + private function _get_subtotal($tax = false) { |
|
563 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : null; |
|
564 | 564 | |
565 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
565 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
566 | 566 | return 0; |
567 | 567 | } |
568 | 568 | |
@@ -581,26 +581,26 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return string parsed. |
583 | 583 | */ |
584 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
585 | - $valid_shortcodes = array( 'transaction' ); |
|
586 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
584 | + private function _get_payment_link_if_needed($shortcode) { |
|
585 | + $valid_shortcodes = array('transaction'); |
|
586 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
587 | 587 | |
588 | 588 | //ensure default is set. |
589 | 589 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
590 | 590 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
591 | 591 | |
592 | - if ( $total_owing > 0 ) { |
|
593 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
594 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
596 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
597 | - $opening_tag .= ! empty( $opening_tag ) && ! empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
598 | - $opening_tag .= ! empty( $opening_tag ) ? '>' : $opening_tag; |
|
599 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
600 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
592 | + if ($total_owing > 0) { |
|
593 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
594 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
595 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
596 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
597 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
598 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
599 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
600 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
601 | 601 | |
602 | 602 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
603 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
603 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
604 | 604 | } else { |
605 | 605 | return ''; |
606 | 606 | } |
@@ -620,31 +620,31 @@ discard block |
||
620 | 620 | * @param EE_Transaction $transaction |
621 | 621 | * @return string |
622 | 622 | */ |
623 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
623 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
624 | 624 | //if transaction is paid in full then we can just return an empty string |
625 | - if ( $transaction->remaining() === 0 ) { |
|
625 | + if ($transaction->remaining() === 0) { |
|
626 | 626 | return ''; |
627 | 627 | } |
628 | 628 | |
629 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
630 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
631 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
632 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' ); |
|
633 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
629 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
630 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
631 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
632 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
633 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
634 | 634 | |
635 | 635 | //setup date due: |
636 | 636 | try { |
637 | - if ( $transaction_created instanceof DateTime ) { |
|
638 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
637 | + if ($transaction_created instanceof DateTime) { |
|
638 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
639 | 639 | } else { |
640 | 640 | throw new Exception(); |
641 | 641 | } |
642 | - } catch( Exception $e ) { |
|
642 | + } catch (Exception $e) { |
|
643 | 643 | //format was likely invalid. |
644 | 644 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
645 | 645 | } |
646 | 646 | |
647 | - return $prefix_text . $date_due; |
|
647 | + return $prefix_text.$date_due; |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | } //end EE_Transaction Shortcodes library |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -160,8 +162,9 @@ discard block |
||
160 | 162 | */ |
161 | 163 | public function __construct( $routing = TRUE ) { |
162 | 164 | |
163 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
164 | - $this->_is_caf = TRUE; |
|
165 | + if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) { |
|
166 | + $this->_is_caf = TRUE; |
|
167 | + } |
|
165 | 168 | |
166 | 169 | $this->_yes_no_values = array( |
167 | 170 | array('id' => TRUE, 'text' => __('Yes', 'event_espresso')), |
@@ -192,8 +195,9 @@ discard block |
||
192 | 195 | $this->_do_other_page_hooks(); |
193 | 196 | |
194 | 197 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
195 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
196 | - $this->_before_page_setup(); |
|
198 | + if ( method_exists( $this, '_before_page_setup' ) ) { |
|
199 | + $this->_before_page_setup(); |
|
200 | + } |
|
197 | 201 | |
198 | 202 | //set up page dependencies |
199 | 203 | $this->_page_setup(); |
@@ -500,7 +504,9 @@ discard block |
||
500 | 504 | global $ee_menu_slugs; |
501 | 505 | $ee_menu_slugs = (array) $ee_menu_slugs; |
502 | 506 | |
503 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
507 | + if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) { |
|
508 | + return FALSE; |
|
509 | + } |
|
504 | 510 | |
505 | 511 | |
506 | 512 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
@@ -535,12 +541,14 @@ discard block |
||
535 | 541 | } |
536 | 542 | |
537 | 543 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
538 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
539 | - $this->_extend_page_config(); |
|
544 | + if ( method_exists( $this, '_extend_page_config' ) ) { |
|
545 | + $this->_extend_page_config(); |
|
546 | + } |
|
540 | 547 | |
541 | 548 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
542 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
543 | - $this->_extend_page_config_for_cpt(); |
|
549 | + if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) { |
|
550 | + $this->_extend_page_config_for_cpt(); |
|
551 | + } |
|
544 | 552 | |
545 | 553 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
546 | 554 | $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
@@ -656,8 +664,9 @@ discard block |
||
656 | 664 | //add screen options - global, page child class, and view specific |
657 | 665 | $this->_add_global_screen_options(); |
658 | 666 | $this->_add_screen_options(); |
659 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
660 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
667 | + if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) { |
|
668 | + call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
669 | + } |
|
661 | 670 | |
662 | 671 | |
663 | 672 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -668,28 +677,32 @@ discard block |
||
668 | 677 | //add feature_pointers - global, page child class, and view specific |
669 | 678 | $this->_add_feature_pointers(); |
670 | 679 | $this->_add_global_feature_pointers(); |
671 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
672 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
680 | + if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) { |
|
681 | + call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
682 | + } |
|
673 | 683 | |
674 | 684 | //enqueue scripts/styles - global, page class, and view specific |
675 | 685 | add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
676 | 686 | add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
677 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
678 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
687 | + if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) { |
|
688 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
689 | + } |
|
679 | 690 | |
680 | 691 | add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
681 | 692 | |
682 | 693 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
683 | 694 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
684 | 695 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
685 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
686 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
696 | + if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) { |
|
697 | + add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
698 | + } |
|
687 | 699 | |
688 | 700 | //admin footer scripts |
689 | 701 | add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
690 | 702 | add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
691 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
692 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
703 | + if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) { |
|
704 | + add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
705 | + } |
|
693 | 706 | |
694 | 707 | |
695 | 708 | do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
@@ -762,7 +775,9 @@ discard block |
||
762 | 775 | protected function _verify_routes() { |
763 | 776 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
764 | 777 | |
765 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
778 | + if ( !$this->_current_page && !defined( 'DOING_AJAX')) { |
|
779 | + return FALSE; |
|
780 | + } |
|
766 | 781 | |
767 | 782 | $this->_route = FALSE; |
768 | 783 | $func = FALSE; |
@@ -872,8 +887,9 @@ discard block |
||
872 | 887 | * @return void |
873 | 888 | */ |
874 | 889 | protected function _route_admin_request() { |
875 | - if ( ! $this->_is_UI_request ) |
|
876 | - $this->_verify_routes(); |
|
890 | + if ( ! $this->_is_UI_request ) { |
|
891 | + $this->_verify_routes(); |
|
892 | + } |
|
877 | 893 | |
878 | 894 | $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
879 | 895 | |
@@ -883,8 +899,9 @@ discard block |
||
883 | 899 | $this->_verify_nonce( $nonce, $this->_req_nonce ); |
884 | 900 | } |
885 | 901 | //set the nav_tabs array but ONLY if this is UI_request |
886 | - if ( $this->_is_UI_request ) |
|
887 | - $this->_set_nav_tabs(); |
|
902 | + if ( $this->_is_UI_request ) { |
|
903 | + $this->_set_nav_tabs(); |
|
904 | + } |
|
888 | 905 | |
889 | 906 | // grab callback function |
890 | 907 | $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
@@ -921,8 +938,9 @@ discard block |
||
921 | 938 | } |
922 | 939 | |
923 | 940 | |
924 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
925 | - throw new EE_Error( $error_msg ); |
|
941 | + if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) { |
|
942 | + throw new EE_Error( $error_msg ); |
|
943 | + } |
|
926 | 944 | } |
927 | 945 | |
928 | 946 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
@@ -1049,8 +1067,9 @@ discard block |
||
1049 | 1067 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
1050 | 1068 | foreach ( $this->_help_tour['tours'] as $tour ) { |
1051 | 1069 | //if this is the end tour then we don't need to setup a button |
1052 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
1053 | - continue; |
|
1070 | + if ( $tour instanceof EE_Help_Tour_final_stop ) { |
|
1071 | + continue; |
|
1072 | + } |
|
1054 | 1073 | $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
1055 | 1074 | } |
1056 | 1075 | $tour_buttons .= implode('<br />', $tb); |
@@ -1060,8 +1079,9 @@ discard block |
||
1060 | 1079 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
1061 | 1080 | if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
1062 | 1081 | //check that the callback given is valid |
1063 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
1064 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1082 | + if ( !method_exists($this, $config['help_sidebar'] ) ) { |
|
1083 | + throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1084 | + } |
|
1065 | 1085 | |
1066 | 1086 | $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
1067 | 1087 | |
@@ -1085,18 +1105,23 @@ discard block |
||
1085 | 1105 | }/**/ |
1086 | 1106 | |
1087 | 1107 | |
1088 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
1108 | + if ( !isset( $config['help_tabs'] ) ) { |
|
1109 | + return; |
|
1110 | + } |
|
1111 | + //no help tabs for this route |
|
1089 | 1112 | |
1090 | 1113 | foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
1091 | 1114 | //we're here so there ARE help tabs! |
1092 | 1115 | |
1093 | 1116 | //make sure we've got what we need |
1094 | - if ( !isset( $cfg['title'] ) ) |
|
1095 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1117 | + if ( !isset( $cfg['title'] ) ) { |
|
1118 | + throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1119 | + } |
|
1096 | 1120 | |
1097 | 1121 | |
1098 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
1099 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1122 | + if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) { |
|
1123 | + throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1124 | + } |
|
1100 | 1125 | |
1101 | 1126 | |
1102 | 1127 | |
@@ -1159,14 +1184,16 @@ discard block |
||
1159 | 1184 | $this->_help_tour = array(); |
1160 | 1185 | |
1161 | 1186 | //exit early if help tours are turned off globally |
1162 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
1163 | - return; |
|
1187 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) { |
|
1188 | + return; |
|
1189 | + } |
|
1164 | 1190 | |
1165 | 1191 | //loop through _page_config to find any help_tour defined |
1166 | 1192 | foreach ( $this->_page_config as $route => $config ) { |
1167 | 1193 | //we're only going to set things up for this route |
1168 | - if ( $route !== $this->_req_action ) |
|
1169 | - continue; |
|
1194 | + if ( $route !== $this->_req_action ) { |
|
1195 | + continue; |
|
1196 | + } |
|
1170 | 1197 | |
1171 | 1198 | if ( isset( $config['help_tour'] ) ) { |
1172 | 1199 | |
@@ -1201,8 +1228,9 @@ discard block |
||
1201 | 1228 | } |
1202 | 1229 | } |
1203 | 1230 | |
1204 | - if ( !empty( $tours ) ) |
|
1205 | - $this->_help_tour['tours'] = $tours; |
|
1231 | + if ( !empty( $tours ) ) { |
|
1232 | + $this->_help_tour['tours'] = $tours; |
|
1233 | + } |
|
1206 | 1234 | |
1207 | 1235 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
1208 | 1236 | } |
@@ -1242,15 +1270,21 @@ discard block |
||
1242 | 1270 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1243 | 1271 | $i = 0; |
1244 | 1272 | foreach ( $this->_page_config as $slug => $config ) { |
1245 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
1246 | - continue; //no nav tab for this config |
|
1273 | + if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) { |
|
1274 | + continue; |
|
1275 | + } |
|
1276 | + //no nav tab for this config |
|
1247 | 1277 | |
1248 | 1278 | //check for persistent flag |
1249 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
1250 | - continue; //nav tab is only to appear when route requested. |
|
1279 | + if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) { |
|
1280 | + continue; |
|
1281 | + } |
|
1282 | + //nav tab is only to appear when route requested. |
|
1251 | 1283 | |
1252 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
1253 | - continue; //no nav tab becasue current user does not have access. |
|
1284 | + if ( ! $this->check_user_access( $slug, TRUE ) ) { |
|
1285 | + continue; |
|
1286 | + } |
|
1287 | + //no nav tab becasue current user does not have access. |
|
1254 | 1288 | |
1255 | 1289 | $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
1256 | 1290 | $this->_nav_tabs[$slug] = array( |
@@ -1486,10 +1520,11 @@ discard block |
||
1486 | 1520 | $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
1487 | 1521 | } |
1488 | 1522 | |
1489 | - if ( $display ) |
|
1490 | - echo $content; |
|
1491 | - else |
|
1492 | - return $content; |
|
1523 | + if ( $display ) { |
|
1524 | + echo $content; |
|
1525 | + } else { |
|
1526 | + return $content; |
|
1527 | + } |
|
1493 | 1528 | } |
1494 | 1529 | |
1495 | 1530 | |
@@ -1506,8 +1541,9 @@ discard block |
||
1506 | 1541 | $method_name = '_help_popup_content_' . $this->_req_action; |
1507 | 1542 | |
1508 | 1543 | //if method doesn't exist let's get out. |
1509 | - if ( !method_exists( $this, $method_name ) ) |
|
1510 | - return array(); |
|
1544 | + if ( !method_exists( $this, $method_name ) ) { |
|
1545 | + return array(); |
|
1546 | + } |
|
1511 | 1547 | |
1512 | 1548 | //k we're good to go let's retrieve the help array |
1513 | 1549 | $help_array = call_user_func( array( $this, $method_name ) ); |
@@ -1538,7 +1574,9 @@ discard block |
||
1538 | 1574 | */ |
1539 | 1575 | protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
1540 | 1576 | |
1541 | - if ( defined('DOING_AJAX') ) return; |
|
1577 | + if ( defined('DOING_AJAX') ) { |
|
1578 | + return; |
|
1579 | + } |
|
1542 | 1580 | |
1543 | 1581 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
1544 | 1582 | $help_array = $this->_get_help_content(); |
@@ -1556,10 +1594,11 @@ discard block |
||
1556 | 1594 | $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
1557 | 1595 | $content = $content . $help_content; |
1558 | 1596 | |
1559 | - if ( $display ) |
|
1560 | - echo $content; |
|
1561 | - else |
|
1562 | - return $content; |
|
1597 | + if ( $display ) { |
|
1598 | + echo $content; |
|
1599 | + } else { |
|
1600 | + return $content; |
|
1601 | + } |
|
1563 | 1602 | } |
1564 | 1603 | |
1565 | 1604 | |
@@ -1785,8 +1824,10 @@ discard block |
||
1785 | 1824 | protected function _set_list_table() { |
1786 | 1825 | |
1787 | 1826 | //first is this a list_table view? |
1788 | - if ( !isset($this->_route_config['list_table']) ) |
|
1789 | - return; //not a list_table view so get out. |
|
1827 | + if ( !isset($this->_route_config['list_table']) ) { |
|
1828 | + return; |
|
1829 | + } |
|
1830 | + //not a list_table view so get out. |
|
1790 | 1831 | |
1791 | 1832 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
1792 | 1833 | |
@@ -2148,8 +2189,9 @@ discard block |
||
2148 | 2189 | protected function _espresso_sponsors_post_box() { |
2149 | 2190 | |
2150 | 2191 | $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
2151 | - if ( $show_sponsors ) |
|
2152 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2192 | + if ( $show_sponsors ) { |
|
2193 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2194 | + } |
|
2153 | 2195 | } |
2154 | 2196 | |
2155 | 2197 | |
@@ -2446,8 +2488,9 @@ discard block |
||
2446 | 2488 | |
2447 | 2489 | $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
2448 | 2490 | |
2449 | - if ( defined('DOING_AJAX' ) ) |
|
2450 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2491 | + if ( defined('DOING_AJAX' ) ) { |
|
2492 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2493 | + } |
|
2451 | 2494 | |
2452 | 2495 | $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
2453 | 2496 | |
@@ -2586,10 +2629,11 @@ discard block |
||
2586 | 2629 | true |
2587 | 2630 | ); |
2588 | 2631 | // the final template wrapper |
2589 | - if ( $sidebar ) |
|
2590 | - $this->display_admin_page_with_sidebar(); |
|
2591 | - else |
|
2592 | - $this->display_admin_page_with_no_sidebar(); |
|
2632 | + if ( $sidebar ) { |
|
2633 | + $this->display_admin_page_with_sidebar(); |
|
2634 | + } else { |
|
2635 | + $this->display_admin_page_with_no_sidebar(); |
|
2636 | + } |
|
2593 | 2637 | } |
2594 | 2638 | |
2595 | 2639 | |
@@ -2657,8 +2701,9 @@ discard block |
||
2657 | 2701 | |
2658 | 2702 | |
2659 | 2703 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2660 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
2661 | - header('Content-Type: application/json; charset=UTF-8'); |
|
2704 | + if ( NULL === error_get_last() || ! headers_sent() ) { |
|
2705 | + header('Content-Type: application/json; charset=UTF-8'); |
|
2706 | + } |
|
2662 | 2707 | if( function_exists( 'wp_json_encode' ) ) { |
2663 | 2708 | echo wp_json_encode( $json ); |
2664 | 2709 | } else { |
@@ -2674,10 +2719,9 @@ discard block |
||
2674 | 2719 | * @return json_obj|EE_Error |
2675 | 2720 | */ |
2676 | 2721 | public function return_json() { |
2677 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
2678 | - $this->_return_json(); |
|
2679 | - |
|
2680 | - else { |
|
2722 | + if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2723 | + $this->_return_json(); |
|
2724 | + } else { |
|
2681 | 2725 | throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
2682 | 2726 | } |
2683 | 2727 | } |
@@ -2824,7 +2868,9 @@ discard block |
||
2824 | 2868 | $id = $this->_current_view . '_' . $ref; |
2825 | 2869 | $name = !empty($actions) ? $actions[$key] : $ref; |
2826 | 2870 | $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
2827 | - if ( !$both ) break; |
|
2871 | + if ( !$both ) { |
|
2872 | + break; |
|
2873 | + } |
|
2828 | 2874 | } |
2829 | 2875 | |
2830 | 2876 | } |
@@ -3163,13 +3209,15 @@ discard block |
||
3163 | 3209 | if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
3164 | 3210 | check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
3165 | 3211 | |
3166 | - if ( !$user = wp_get_current_user() ) |
|
3167 | - return; |
|
3212 | + if ( !$user = wp_get_current_user() ) { |
|
3213 | + return; |
|
3214 | + } |
|
3168 | 3215 | $option = $_POST['wp_screen_options']['option']; |
3169 | 3216 | $value = $_POST['wp_screen_options']['value']; |
3170 | 3217 | |
3171 | - if ( $option != sanitize_key( $option ) ) |
|
3172 | - return; |
|
3218 | + if ( $option != sanitize_key( $option ) ) { |
|
3219 | + return; |
|
3220 | + } |
|
3173 | 3221 | |
3174 | 3222 | $map_option = $option; |
3175 | 3223 | |
@@ -3178,13 +3226,15 @@ discard block |
||
3178 | 3226 | switch ( $map_option ) { |
3179 | 3227 | case $this->_current_page . '_' . $this->_current_view . '_per_page': |
3180 | 3228 | $value = (int) $value; |
3181 | - if ( $value < 1 || $value > 999 ) |
|
3182 | - return; |
|
3229 | + if ( $value < 1 || $value > 999 ) { |
|
3230 | + return; |
|
3231 | + } |
|
3183 | 3232 | break; |
3184 | 3233 | default: |
3185 | 3234 | $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
3186 | - if ( false === $value ) |
|
3187 | - return; |
|
3235 | + if ( false === $value ) { |
|
3236 | + return; |
|
3237 | + } |
|
3188 | 3238 | break; |
3189 | 3239 | } |
3190 | 3240 | |
@@ -3220,8 +3270,9 @@ discard block |
||
3220 | 3270 | protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
3221 | 3271 | $user_id = get_current_user_id(); |
3222 | 3272 | |
3223 | - if ( !$skip_route_verify ) |
|
3224 | - $this->_verify_route($route); |
|
3273 | + if ( !$skip_route_verify ) { |
|
3274 | + $this->_verify_route($route); |
|
3275 | + } |
|
3225 | 3276 | |
3226 | 3277 | |
3227 | 3278 | //now let's set the string for what kind of transient we're setting |
@@ -1311,8 +1311,8 @@ discard block |
||
1311 | 1311 | * verifies user access for this admin page |
1312 | 1312 | * @param string $route_to_check if present then the capability for the route matching this string is checked. |
1313 | 1313 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
1314 | - * @return BOOL|wp_die() |
|
1315 | - */ |
|
1314 | + * @return BOOL|wp_die() |
|
1315 | + */ |
|
1316 | 1316 | public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
1317 | 1317 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1318 | 1318 | $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
@@ -1698,11 +1698,11 @@ discard block |
||
1698 | 1698 | |
1699 | 1699 | |
1700 | 1700 | /** |
1701 | - * admin_footer_scripts_eei18n_js_strings |
|
1702 | - * |
|
1703 | - * @access public |
|
1704 | - * @return void |
|
1705 | - */ |
|
1701 | + * admin_footer_scripts_eei18n_js_strings |
|
1702 | + * |
|
1703 | + * @access public |
|
1704 | + * @return void |
|
1705 | + */ |
|
1706 | 1706 | public function admin_footer_scripts_eei18n_js_strings() { |
1707 | 1707 | |
1708 | 1708 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
@@ -1758,11 +1758,11 @@ discard block |
||
1758 | 1758 | |
1759 | 1759 | |
1760 | 1760 | /** |
1761 | - * load enhanced xdebug styles for ppl with failing eyesight |
|
1762 | - * |
|
1763 | - * @access public |
|
1764 | - * @return void |
|
1765 | - */ |
|
1761 | + * load enhanced xdebug styles for ppl with failing eyesight |
|
1762 | + * |
|
1763 | + * @access public |
|
1764 | + * @return void |
|
1765 | + */ |
|
1766 | 1766 | public function add_xdebug_style() { |
1767 | 1767 | echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
1768 | 1768 | } |
@@ -1819,9 +1819,9 @@ discard block |
||
1819 | 1819 | |
1820 | 1820 | /** |
1821 | 1821 | * set current view for List Table |
1822 | - * @access public |
|
1823 | - * @return array |
|
1824 | - */ |
|
1822 | + * @access public |
|
1823 | + * @return array |
|
1824 | + */ |
|
1825 | 1825 | protected function _set_list_table_view() { |
1826 | 1826 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1827 | 1827 | |
@@ -1910,7 +1910,7 @@ discard block |
||
1910 | 1910 | * @access protected |
1911 | 1911 | * @param int $max_entries total number of rows in the table |
1912 | 1912 | * @return string |
1913 | - */ |
|
1913 | + */ |
|
1914 | 1914 | protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
1915 | 1915 | |
1916 | 1916 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -1955,9 +1955,9 @@ discard block |
||
1955 | 1955 | |
1956 | 1956 | /** |
1957 | 1957 | * _set_search_attributes |
1958 | - * @access protected |
|
1959 | - * @return void |
|
1960 | - */ |
|
1958 | + * @access protected |
|
1959 | + * @return void |
|
1960 | + */ |
|
1961 | 1961 | public function _set_search_attributes() { |
1962 | 1962 | $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
1963 | 1963 | $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
1978 | 1978 | * @access private |
1979 | 1979 | * @return void |
1980 | - */ |
|
1980 | + */ |
|
1981 | 1981 | private function _add_registered_meta_boxes() { |
1982 | 1982 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1983 | 1983 | |
@@ -2209,7 +2209,6 @@ discard block |
||
2209 | 2209 | * Note: currently there is no validation for this. However if you want the delete button, the |
2210 | 2210 | * save, and save and close buttons to work properly, then you will want to include a |
2211 | 2211 | * values for the name and id arguments. |
2212 | - |
|
2213 | 2212 | * |
2214 | 2213 | *@todo Add in validation for name/id arguments. |
2215 | 2214 | * @param string $name key used for the action ID (i.e. event_id) |
@@ -2268,9 +2267,9 @@ discard block |
||
2268 | 2267 | |
2269 | 2268 | /** |
2270 | 2269 | * displays an error message to ppl who have javascript disabled |
2271 | - * @access private |
|
2272 | - * @return string |
|
2273 | - */ |
|
2270 | + * @access private |
|
2271 | + * @return string |
|
2272 | + */ |
|
2274 | 2273 | private function _display_no_javascript_warning() { |
2275 | 2274 | ?> |
2276 | 2275 | <noscript> |
@@ -2293,9 +2292,9 @@ discard block |
||
2293 | 2292 | |
2294 | 2293 | /** |
2295 | 2294 | * displays espresso success and/or error notices |
2296 | - * @access private |
|
2297 | - * @return string |
|
2298 | - */ |
|
2295 | + * @access private |
|
2296 | + * @return string |
|
2297 | + */ |
|
2299 | 2298 | private function _display_espresso_notices() { |
2300 | 2299 | $notices = $this->_get_transient( TRUE ); |
2301 | 2300 | echo stripslashes($notices); |
@@ -2307,10 +2306,10 @@ discard block |
||
2307 | 2306 | |
2308 | 2307 | |
2309 | 2308 | /** |
2310 | - * spinny things pacify the masses |
|
2311 | - * @access private |
|
2312 | - * @return string |
|
2313 | - */ |
|
2309 | + * spinny things pacify the masses |
|
2310 | + * @access private |
|
2311 | + * @return string |
|
2312 | + */ |
|
2314 | 2313 | protected function _add_admin_page_ajax_loading_img() { |
2315 | 2314 | ?> |
2316 | 2315 | <div id="espresso-ajax-loading" class="ajax-loading-grey"> |
@@ -2324,10 +2323,10 @@ discard block |
||
2324 | 2323 | |
2325 | 2324 | |
2326 | 2325 | /** |
2327 | - * add admin page overlay for modal boxes |
|
2328 | - * @access private |
|
2329 | - * @return string |
|
2330 | - */ |
|
2326 | + * add admin page overlay for modal boxes |
|
2327 | + * @access private |
|
2328 | + * @return string |
|
2329 | + */ |
|
2331 | 2330 | protected function _add_admin_page_overlay() { |
2332 | 2331 | ?> |
2333 | 2332 | <div id="espresso-admin-page-overlay-dv" class=""></div> |
@@ -2389,10 +2388,10 @@ discard block |
||
2389 | 2388 | |
2390 | 2389 | |
2391 | 2390 | /** |
2392 | - * generates HTML wrapper for an admin details page |
|
2393 | - * @access public |
|
2394 | - * @return void |
|
2395 | - */ |
|
2391 | + * generates HTML wrapper for an admin details page |
|
2392 | + * @access public |
|
2393 | + * @return void |
|
2394 | + */ |
|
2396 | 2395 | public function display_admin_page_with_sidebar() { |
2397 | 2396 | |
2398 | 2397 | $this->_display_admin_page(TRUE); |
@@ -2402,10 +2401,10 @@ discard block |
||
2402 | 2401 | |
2403 | 2402 | |
2404 | 2403 | /** |
2405 | - * generates HTML wrapper for an admin details page (except no sidebar) |
|
2406 | - * @access public |
|
2407 | - * @return void |
|
2408 | - */ |
|
2404 | + * generates HTML wrapper for an admin details page (except no sidebar) |
|
2405 | + * @access public |
|
2406 | + * @return void |
|
2407 | + */ |
|
2409 | 2408 | public function display_admin_page_with_no_sidebar() { |
2410 | 2409 | $this->_display_admin_page(); |
2411 | 2410 | } |
@@ -2662,11 +2661,11 @@ discard block |
||
2662 | 2661 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2663 | 2662 | if ( NULL === error_get_last() || ! headers_sent() ) |
2664 | 2663 | header('Content-Type: application/json; charset=UTF-8'); |
2665 | - if( function_exists( 'wp_json_encode' ) ) { |
|
2666 | - echo wp_json_encode( $json ); |
|
2667 | - } else { |
|
2668 | - echo json_encode( $json ); |
|
2669 | - } |
|
2664 | + if( function_exists( 'wp_json_encode' ) ) { |
|
2665 | + echo wp_json_encode( $json ); |
|
2666 | + } else { |
|
2667 | + echo json_encode( $json ); |
|
2668 | + } |
|
2670 | 2669 | exit(); |
2671 | 2670 | } |
2672 | 2671 | |
@@ -2705,11 +2704,11 @@ discard block |
||
2705 | 2704 | |
2706 | 2705 | |
2707 | 2706 | /** |
2708 | - * generates HTML wrapper with Tabbed nav for an admin page |
|
2709 | - * @access public |
|
2710 | - * @param boolean $about whether to use the special about page wrapper or default. |
|
2711 | - * @return void |
|
2712 | - */ |
|
2707 | + * generates HTML wrapper with Tabbed nav for an admin page |
|
2708 | + * @access public |
|
2709 | + * @param boolean $about whether to use the special about page wrapper or default. |
|
2710 | + * @return void |
|
2711 | + */ |
|
2713 | 2712 | public function admin_page_wrapper($about = FALSE) { |
2714 | 2713 | |
2715 | 2714 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2766,9 +2765,9 @@ discard block |
||
2766 | 2765 | */ |
2767 | 2766 | private function _sort_nav_tabs( $a, $b ) { |
2768 | 2767 | if ($a['order'] == $b['order']) { |
2769 | - return 0; |
|
2770 | - } |
|
2771 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
2768 | + return 0; |
|
2769 | + } |
|
2770 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
2772 | 2771 | } |
2773 | 2772 | |
2774 | 2773 |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
159 | 159 | * @access public |
160 | 160 | */ |
161 | - public function __construct( $routing = TRUE ) { |
|
161 | + public function __construct($routing = TRUE) { |
|
162 | 162 | |
163 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
163 | + if (strpos($this->_get_dir(), 'caffeinated') !== false) |
|
164 | 164 | $this->_is_caf = TRUE; |
165 | 165 | |
166 | 166 | $this->_yes_no_values = array( |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | |
173 | 173 | //set the _req_data property. |
174 | - $this->_req_data = array_merge( $_GET, $_POST ); |
|
174 | + $this->_req_data = array_merge($_GET, $_POST); |
|
175 | 175 | |
176 | 176 | |
177 | 177 | //routing enabled? |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->_do_other_page_hooks(); |
193 | 193 | |
194 | 194 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
195 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
195 | + if (method_exists($this, '_before_page_setup')) |
|
196 | 196 | $this->_before_page_setup(); |
197 | 197 | |
198 | 198 | //set up page dependencies |
@@ -462,16 +462,16 @@ discard block |
||
462 | 462 | */ |
463 | 463 | protected function _global_ajax_hooks() { |
464 | 464 | //for lazy loading of metabox content |
465 | - add_action( 'wp_ajax_espresso-ajax-content', array( $this, 'ajax_metabox_content'), 10 ); |
|
465 | + add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | |
469 | 469 | |
470 | 470 | public function ajax_metabox_content() { |
471 | - $contentid = isset( $this->_req_data['contentid'] ) ? $this->_req_data['contentid'] : ''; |
|
472 | - $url = isset( $this->_req_data['contenturl'] ) ? $this->_req_data['contenturl'] : ''; |
|
471 | + $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
472 | + $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
473 | 473 | |
474 | - self::cached_rss_display( $contentid, $url ); |
|
474 | + self::cached_rss_display($contentid, $url); |
|
475 | 475 | wp_die(); |
476 | 476 | } |
477 | 477 | |
@@ -490,87 +490,87 @@ discard block |
||
490 | 490 | //requires? |
491 | 491 | |
492 | 492 | //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
493 | - add_action( 'admin_init', array( $this, 'admin_init_global' ), 5 ); |
|
493 | + add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
494 | 494 | |
495 | 495 | |
496 | 496 | //next verify if we need to load anything... |
497 | - $this->_current_page = !empty( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; |
|
498 | - $this->page_folder = strtolower( str_replace( '_Admin_Page', '', str_replace( 'Extend_', '', get_class($this) ) ) ); |
|
497 | + $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
498 | + $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
499 | 499 | |
500 | 500 | global $ee_menu_slugs; |
501 | 501 | $ee_menu_slugs = (array) $ee_menu_slugs; |
502 | 502 | |
503 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
503 | + if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) return FALSE; |
|
504 | 504 | |
505 | 505 | |
506 | 506 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
507 | - if ( isset( $this->_req_data['action2'] ) && $this->_req_data['action'] == -1 ) { |
|
508 | - $this->_req_data['action'] = ! empty( $this->_req_data['action2'] ) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
507 | + if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
508 | + $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
509 | 509 | } |
510 | 510 | // then set blank or -1 action values to 'default' |
511 | - $this->_req_action = isset( $this->_req_data['action'] ) && ! empty( $this->_req_data['action'] ) && $this->_req_data['action'] != -1 ? sanitize_key( $this->_req_data['action'] ) : 'default'; |
|
511 | + $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
512 | 512 | |
513 | 513 | //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
514 | - $this->_req_action = $this->_req_action == 'default' && isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : $this->_req_action; |
|
514 | + $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
515 | 515 | |
516 | 516 | //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
517 | 517 | $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
518 | 518 | |
519 | 519 | $this->_current_view = $this->_req_action; |
520 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
520 | + $this->_req_nonce = $this->_req_action.'_nonce'; |
|
521 | 521 | $this->_define_page_props(); |
522 | 522 | |
523 | - $this->_current_page_view_url = add_query_arg( array( 'page' => $this->_current_page, 'action' => $this->_current_view ), $this->_admin_base_url ); |
|
523 | + $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
524 | 524 | |
525 | 525 | //default things |
526 | - $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box' ); |
|
526 | + $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
527 | 527 | |
528 | 528 | //set page configs |
529 | 529 | $this->_set_page_routes(); |
530 | 530 | $this->_set_page_config(); |
531 | 531 | |
532 | 532 | //let's include any referrer data in our default_query_args for this route for "stickiness". |
533 | - if ( isset( $this->_req_data['wp_referer'] ) ) { |
|
533 | + if (isset($this->_req_data['wp_referer'])) { |
|
534 | 534 | $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
535 | 535 | } |
536 | 536 | |
537 | 537 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
538 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
538 | + if (method_exists($this, '_extend_page_config')) |
|
539 | 539 | $this->_extend_page_config(); |
540 | 540 | |
541 | 541 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
542 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
542 | + if (method_exists($this, '_extend_page_config_for_cpt')) |
|
543 | 543 | $this->_extend_page_config_for_cpt(); |
544 | 544 | |
545 | 545 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
546 | - $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
|
547 | - $this->_page_config = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this ); |
|
546 | + $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this); |
|
547 | + $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this); |
|
548 | 548 | |
549 | 549 | |
550 | 550 | //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
551 | - if ( method_exists( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ) ) { |
|
552 | - add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ), 10, 2 ); |
|
551 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) { |
|
552 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | |
556 | 556 | //next route only if routing enabled |
557 | - if ( $this->_routing && !defined('DOING_AJAX') ) { |
|
557 | + if ($this->_routing && ! defined('DOING_AJAX')) { |
|
558 | 558 | |
559 | 559 | $this->_verify_routes(); |
560 | 560 | |
561 | 561 | //next let's just check user_access and kill if no access |
562 | 562 | $this->check_user_access(); |
563 | 563 | |
564 | - if ( $this->_is_UI_request ) { |
|
564 | + if ($this->_is_UI_request) { |
|
565 | 565 | //admin_init stuff - global, all views for this page class, specific view |
566 | - add_action( 'admin_init', array( $this, 'admin_init' ), 10 ); |
|
567 | - if ( method_exists( $this, 'admin_init_' . $this->_current_view )) { |
|
568 | - add_action( 'admin_init', array( $this, 'admin_init_' . $this->_current_view ), 15 ); |
|
566 | + add_action('admin_init', array($this, 'admin_init'), 10); |
|
567 | + if (method_exists($this, 'admin_init_'.$this->_current_view)) { |
|
568 | + add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | } else { |
572 | 572 | //hijack regular WP loading and route admin request immediately |
573 | - @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
573 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
574 | 574 | $this->route_admin_request(); |
575 | 575 | } |
576 | 576 | } |
@@ -587,18 +587,18 @@ discard block |
||
587 | 587 | * @return void |
588 | 588 | */ |
589 | 589 | private function _do_other_page_hooks() { |
590 | - $registered_pages = apply_filters( 'FHEE_do_other_page_hooks_' . $this->page_slug, array() ); |
|
590 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array()); |
|
591 | 591 | |
592 | - foreach ( $registered_pages as $page ) { |
|
592 | + foreach ($registered_pages as $page) { |
|
593 | 593 | |
594 | 594 | //now let's setup the file name and class that should be present |
595 | 595 | $classname = str_replace('.class.php', '', $page); |
596 | 596 | |
597 | 597 | //autoloaders should take care of loading file |
598 | - if ( !class_exists( $classname ) ) { |
|
599 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s admin hooks page.', 'event_espresso' ), $page); |
|
600 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname ); |
|
601 | - throw new EE_Error( implode( '||', $error_msg )); |
|
598 | + if ( ! class_exists($classname)) { |
|
599 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
600 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname); |
|
601 | + throw new EE_Error(implode('||', $error_msg)); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $a = new ReflectionClass($classname); |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | public function load_page_dependencies() { |
614 | 614 | try { |
615 | 615 | $this->_load_page_dependencies(); |
616 | - } catch ( EE_Error $e ) { |
|
616 | + } catch (EE_Error $e) { |
|
617 | 617 | $e->get_error(); |
618 | 618 | } |
619 | 619 | } |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | $this->_current_screen = get_current_screen(); |
632 | 632 | |
633 | 633 | //load admin_notices - global, page class, and view specific |
634 | - add_action( 'admin_notices', array( $this, 'admin_notices_global'), 5 ); |
|
635 | - add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 ); |
|
636 | - if ( method_exists( $this, 'admin_notices_' . $this->_current_view ) ) { |
|
637 | - add_action( 'admin_notices', array( $this, 'admin_notices_' . $this->_current_view ), 15 ); |
|
634 | + add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
635 | + add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
636 | + if (method_exists($this, 'admin_notices_'.$this->_current_view)) { |
|
637 | + add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | //load network admin_notices - global, page class, and view specific |
641 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_global'), 5 ); |
|
642 | - if ( method_exists( $this, 'network_admin_notices_' . $this->_current_view ) ) { |
|
643 | - add_action( 'network_admin_notices', array( $this, 'network_admin_notices_' . $this->_current_view ) ); |
|
641 | + add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
642 | + if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) { |
|
643 | + add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view)); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | //this will save any per_page screen options if they are present |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | //add screen options - global, page child class, and view specific |
657 | 657 | $this->_add_global_screen_options(); |
658 | 658 | $this->_add_screen_options(); |
659 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
660 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
659 | + if (method_exists($this, '_add_screen_options_'.$this->_current_view)) |
|
660 | + call_user_func(array($this, '_add_screen_options_'.$this->_current_view)); |
|
661 | 661 | |
662 | 662 | |
663 | 663 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -668,33 +668,33 @@ discard block |
||
668 | 668 | //add feature_pointers - global, page child class, and view specific |
669 | 669 | $this->_add_feature_pointers(); |
670 | 670 | $this->_add_global_feature_pointers(); |
671 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
672 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
671 | + if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) |
|
672 | + call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view)); |
|
673 | 673 | |
674 | 674 | //enqueue scripts/styles - global, page class, and view specific |
675 | - add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
|
676 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
|
677 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
678 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
675 | + add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
676 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
677 | + if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) |
|
678 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15); |
|
679 | 679 | |
680 | - add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
|
680 | + add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
681 | 681 | |
682 | 682 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
683 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
|
684 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
|
685 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
686 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
683 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
684 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
685 | + if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) |
|
686 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101); |
|
687 | 687 | |
688 | 688 | //admin footer scripts |
689 | - add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
|
690 | - add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
|
691 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
692 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
689 | + add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
690 | + add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
691 | + if (method_exists($this, 'admin_footer_'.$this->_current_view)) |
|
692 | + add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101); |
|
693 | 693 | |
694 | 694 | |
695 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
|
695 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
696 | 696 | //targeted hook |
697 | - do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action ); |
|
697 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action); |
|
698 | 698 | |
699 | 699 | } |
700 | 700 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | private function _set_defaults() { |
710 | 710 | $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = NULL; |
711 | 711 | |
712 | - $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
712 | + $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
713 | 713 | |
714 | 714 | $this->default_nav_tab_name = 'overview'; |
715 | 715 | |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | public function route_admin_request() { |
737 | 737 | try { |
738 | 738 | $this->_route_admin_request(); |
739 | - } catch ( EE_Error $e ) { |
|
739 | + } catch (EE_Error $e) { |
|
740 | 740 | $e->get_error(); |
741 | 741 | } |
742 | 742 | } |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | $this->_wp_page_slug = $wp_page_slug; |
748 | 748 | |
749 | 749 | //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
750 | - if ( is_network_admin() ) { |
|
750 | + if (is_network_admin()) { |
|
751 | 751 | $this->_wp_page_slug .= '-network'; |
752 | 752 | } |
753 | 753 | } |
@@ -760,53 +760,53 @@ discard block |
||
760 | 760 | * @return void |
761 | 761 | */ |
762 | 762 | protected function _verify_routes() { |
763 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
763 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
764 | 764 | |
765 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
765 | + if ( ! $this->_current_page && ! defined('DOING_AJAX')) return FALSE; |
|
766 | 766 | |
767 | 767 | $this->_route = FALSE; |
768 | 768 | $func = FALSE; |
769 | 769 | $args = array(); |
770 | 770 | |
771 | 771 | // check that the page_routes array is not empty |
772 | - if ( empty( $this->_page_routes )) { |
|
772 | + if (empty($this->_page_routes)) { |
|
773 | 773 | // user error msg |
774 | - $error_msg = sprintf( __('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title ); |
|
774 | + $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
775 | 775 | // developer error msg |
776 | - $error_msg .= '||' . $error_msg . __( ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso' ); |
|
777 | - throw new EE_Error( $error_msg ); |
|
776 | + $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
777 | + throw new EE_Error($error_msg); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | // and that the requested page route exists |
781 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
782 | - $this->_route = $this->_page_routes[ $this->_req_action ]; |
|
781 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
782 | + $this->_route = $this->_page_routes[$this->_req_action]; |
|
783 | 783 | $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
784 | 784 | } else { |
785 | 785 | // user error msg |
786 | - $error_msg = sprintf( __( 'The requested page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
786 | + $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
787 | 787 | // developer error msg |
788 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso' ), $this->_req_action ); |
|
789 | - throw new EE_Error( $error_msg ); |
|
788 | + $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
789 | + throw new EE_Error($error_msg); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | // and that a default route exists |
793 | - if ( ! array_key_exists( 'default', $this->_page_routes )) { |
|
793 | + if ( ! array_key_exists('default', $this->_page_routes)) { |
|
794 | 794 | // user error msg |
795 | - $error_msg = sprintf( __( 'A default page route has not been set for the % admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
795 | + $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
796 | 796 | // developer error msg |
797 | - $error_msg .= '||' . $error_msg . __( ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso' ); |
|
798 | - throw new EE_Error( $error_msg ); |
|
797 | + $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
798 | + throw new EE_Error($error_msg); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | |
802 | 802 | //first lets' catch if the UI request has EVER been set. |
803 | - if ( $this->_is_UI_request === NULL ) { |
|
803 | + if ($this->_is_UI_request === NULL) { |
|
804 | 804 | //lets set if this is a UI request or not. |
805 | - $this->_is_UI_request = ( ! isset( $this->_req_data['noheader'] ) || $this->_req_data['noheader'] !== TRUE ) ? TRUE : FALSE; |
|
805 | + $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== TRUE) ? TRUE : FALSE; |
|
806 | 806 | |
807 | 807 | |
808 | 808 | //wait a minute... we might have a noheader in the route array |
809 | - $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader'] ) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
809 | + $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request; |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | $this->_set_current_labels(); |
@@ -821,15 +821,15 @@ discard block |
||
821 | 821 | * @param string $route the route name we're verifying |
822 | 822 | * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
823 | 823 | */ |
824 | - protected function _verify_route( $route ) { |
|
825 | - if ( array_key_exists( $this->_req_action, $this->_page_routes )) { |
|
824 | + protected function _verify_route($route) { |
|
825 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
826 | 826 | return true; |
827 | 827 | } else { |
828 | 828 | // user error msg |
829 | - $error_msg = sprintf( __( 'The given page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title ); |
|
829 | + $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
830 | 830 | // developer error msg |
831 | - $error_msg .= '||' . $error_msg . sprintf( __( ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso' ), $route ); |
|
832 | - throw new EE_Error( $error_msg ); |
|
831 | + $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
832 | + throw new EE_Error($error_msg); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
@@ -843,18 +843,18 @@ discard block |
||
843 | 843 | * @param string $nonce_ref The nonce reference string (name0) |
844 | 844 | * @return mixed (bool|die) |
845 | 845 | */ |
846 | - protected function _verify_nonce( $nonce, $nonce_ref ) { |
|
846 | + protected function _verify_nonce($nonce, $nonce_ref) { |
|
847 | 847 | // verify nonce against expected value |
848 | - if ( ! wp_verify_nonce( $nonce, $nonce_ref) ) { |
|
848 | + if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
849 | 849 | // these are not the droids you are looking for !!! |
850 | - $msg = sprintf(__('%sNonce Fail.%s' , 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>' ); |
|
851 | - if ( WP_DEBUG ) { |
|
852 | - $msg .= "\n " . sprintf( __('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso' ), __CLASS__ ); |
|
850 | + $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
851 | + if (WP_DEBUG) { |
|
852 | + $msg .= "\n ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
853 | 853 | } |
854 | - if ( ! defined( 'DOING_AJAX' )) { |
|
855 | - wp_die( $msg ); |
|
854 | + if ( ! defined('DOING_AJAX')) { |
|
855 | + wp_die($msg); |
|
856 | 856 | } else { |
857 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
857 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
858 | 858 | $this->_return_json(); |
859 | 859 | } |
860 | 860 | } |
@@ -872,63 +872,63 @@ discard block |
||
872 | 872 | * @return void |
873 | 873 | */ |
874 | 874 | protected function _route_admin_request() { |
875 | - if ( ! $this->_is_UI_request ) |
|
875 | + if ( ! $this->_is_UI_request) |
|
876 | 876 | $this->_verify_routes(); |
877 | 877 | |
878 | - $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
|
878 | + $nonce_check = isset($this->_route_config['require_nonce']) ? $this->_route_config['require_nonce'] : TRUE; |
|
879 | 879 | |
880 | - if ( $this->_req_action != 'default' && $nonce_check ) { |
|
880 | + if ($this->_req_action != 'default' && $nonce_check) { |
|
881 | 881 | // set nonce from post data |
882 | - $nonce = isset($this->_req_data[ $this->_req_nonce ]) ? sanitize_text_field( $this->_req_data[ $this->_req_nonce ] ) : ''; |
|
883 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
882 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
883 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
884 | 884 | } |
885 | 885 | //set the nav_tabs array but ONLY if this is UI_request |
886 | - if ( $this->_is_UI_request ) |
|
886 | + if ($this->_is_UI_request) |
|
887 | 887 | $this->_set_nav_tabs(); |
888 | 888 | |
889 | 889 | // grab callback function |
890 | - $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
|
890 | + $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
891 | 891 | |
892 | 892 | // check if callback has args |
893 | - $args = is_array( $this->_route ) && isset( $this->_route['args'] ) ? $this->_route['args'] : array(); |
|
893 | + $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
894 | 894 | |
895 | 895 | $error_msg = ''; |
896 | 896 | |
897 | 897 | //action right before calling route (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
898 | - if ( !did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
899 | - do_action( 'AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this ); |
|
898 | + if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
899 | + do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | //right before calling the route, let's remove _wp_http_referer from the $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
903 | - $_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
|
903 | + $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
904 | 904 | |
905 | - if ( ! empty( $func )) { |
|
905 | + if ( ! empty($func)) { |
|
906 | 906 | $base_call = $addon_call = FALSE; |
907 | 907 | //try to access page route via this class |
908 | - if ( ! is_array( $func ) && method_exists( $this, $func ) && ( $base_call = call_user_func_array( array( $this, &$func ), $args ) ) === FALSE ) { |
|
908 | + if ( ! is_array($func) && method_exists($this, $func) && ($base_call = call_user_func_array(array($this, &$func), $args)) === FALSE) { |
|
909 | 909 | // user error msg |
910 | - $error_msg = __( 'An error occurred. The requested page route could not be found.', 'event_espresso' ); |
|
910 | + $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
911 | 911 | // developer error msg |
912 | - $error_msg .= '||' . sprintf( __( 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso' ), $func ); |
|
912 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso'), $func); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | //for pluggability by addons first let's see if just the function exists (this will also work in the case where $func is an array indicating class/method) |
916 | 916 | $args['admin_page_object'] = $this; //send along this admin page object for access by addons. |
917 | 917 | |
918 | - if ( $base_call === FALSE && ( $addon_call = call_user_func_array( $func, $args ) )=== FALSE ) { |
|
919 | - $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso' ); |
|
920 | - $error_msg .= '||' . sprintf( __('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func ); |
|
918 | + if ($base_call === FALSE && ($addon_call = call_user_func_array($func, $args)) === FALSE) { |
|
919 | + $error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso'); |
|
920 | + $error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | |
924 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
925 | - throw new EE_Error( $error_msg ); |
|
924 | + if ( ! empty($error_msg) && $base_call === FALSE && $addon_call === FALSE) |
|
925 | + throw new EE_Error($error_msg); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
929 | 929 | //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
930 | - if ( $this->_is_UI_request === FALSE && is_array( $this->_route) && ! empty( $this->_route['headers_sent_route'] ) ) { |
|
931 | - $this->_reset_routing_properties( $this->_route['headers_sent_route'] ); |
|
930 | + if ($this->_is_UI_request === FALSE && is_array($this->_route) && ! empty($this->_route['headers_sent_route'])) { |
|
931 | + $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
932 | 932 | } |
933 | 933 | } |
934 | 934 | |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | * @param string $new_route New (non header) route to redirect to. |
945 | 945 | * @return void |
946 | 946 | */ |
947 | - protected function _reset_routing_properties( $new_route ) { |
|
947 | + protected function _reset_routing_properties($new_route) { |
|
948 | 948 | $this->_is_UI_request = TRUE; |
949 | 949 | //now we set the current route to whatever the headers_sent_route is set at |
950 | 950 | $this->_req_data['action'] = $new_route; |
@@ -990,23 +990,23 @@ discard block |
||
990 | 990 | * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
991 | 991 | * @return string |
992 | 992 | */ |
993 | - public static function add_query_args_and_nonce( $args = array(), $url = false, $sticky = false, $exclude_nonce = false ) { |
|
993 | + public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) { |
|
994 | 994 | |
995 | 995 | //if there is a _wp_http_referer include the values from the request but only if sticky = true |
996 | - if ( $sticky ) { |
|
996 | + if ($sticky) { |
|
997 | 997 | $request = $_REQUEST; |
998 | - unset( $request['_wp_http_referer'] ); |
|
999 | - unset( $request['wp_referer'] ); |
|
1000 | - foreach ( $request as $key => $value ) { |
|
998 | + unset($request['_wp_http_referer']); |
|
999 | + unset($request['wp_referer']); |
|
1000 | + foreach ($request as $key => $value) { |
|
1001 | 1001 | //do not add nonces |
1002 | - if ( strpos( $key, 'nonce' ) !== false ) { |
|
1002 | + if (strpos($key, 'nonce') !== false) { |
|
1003 | 1003 | continue; |
1004 | 1004 | } |
1005 | - $args['wp_referer[' . $key . ']'] = $value; |
|
1005 | + $args['wp_referer['.$key.']'] = $value; |
|
1006 | 1006 | } |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - return EEH_URL::add_query_args_and_nonce( $args, $url, $exclude_nonce ); |
|
1009 | + return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * @uses EEH_Template::get_help_tab_link() |
1023 | 1023 | * @return string generated link |
1024 | 1024 | */ |
1025 | - protected function _get_help_tab_link( $help_tab_id, $icon_style = FALSE, $help_text = FALSE ) { |
|
1026 | - return EEH_Template::get_help_tab_link( $help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text ); |
|
1025 | + protected function _get_help_tab_link($help_tab_id, $icon_style = FALSE, $help_text = FALSE) { |
|
1026 | + return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | |
@@ -1040,30 +1040,30 @@ discard block |
||
1040 | 1040 | */ |
1041 | 1041 | protected function _add_help_tabs() { |
1042 | 1042 | $tour_buttons = ''; |
1043 | - if ( isset( $this->_page_config[$this->_req_action] ) ) { |
|
1043 | + if (isset($this->_page_config[$this->_req_action])) { |
|
1044 | 1044 | $config = $this->_page_config[$this->_req_action]; |
1045 | 1045 | |
1046 | 1046 | //is there a help tour for the current route? if there is let's setup the tour buttons |
1047 | - if ( isset( $this->_help_tour[$this->_req_action]) ) { |
|
1047 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1048 | 1048 | $tb = array(); |
1049 | 1049 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
1050 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
1050 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1051 | 1051 | //if this is the end tour then we don't need to setup a button |
1052 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
1052 | + if ($tour instanceof EE_Help_Tour_final_stop) |
|
1053 | 1053 | continue; |
1054 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
1054 | + $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>'; |
|
1055 | 1055 | } |
1056 | 1056 | $tour_buttons .= implode('<br />', $tb); |
1057 | 1057 | $tour_buttons .= '</div></div>'; |
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
1061 | - if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
|
1061 | + if (is_array($config) && isset($config['help_sidebar'])) { |
|
1062 | 1062 | //check that the callback given is valid |
1063 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
1064 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1063 | + if ( ! method_exists($this, $config['help_sidebar'])) |
|
1064 | + throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
1065 | 1065 | |
1066 | - $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
|
1066 | + $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1067 | 1067 | |
1068 | 1068 | $content .= $tour_buttons; //add help tour buttons. |
1069 | 1069 | |
@@ -1072,49 +1072,49 @@ discard block |
||
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
1075 | - if ( !isset( $config['help_sidebar'] ) && !empty( $tour_buttons ) ) { |
|
1075 | + if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
1076 | 1076 | $this->_current_screen->set_help_sidebar($tour_buttons); |
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
1080 | - if ( !isset( $config['help_tabs'] ) && !empty($tour_buttons) ) { |
|
1080 | + if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
1081 | 1081 | $_ht['id'] = $this->page_slug; |
1082 | 1082 | $_ht['title'] = __('Help Tours', 'event_espresso'); |
1083 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
1083 | + $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>'; |
|
1084 | 1084 | $this->_current_screen->add_help_tab($_ht); |
1085 | 1085 | }/**/ |
1086 | 1086 | |
1087 | 1087 | |
1088 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
1088 | + if ( ! isset($config['help_tabs'])) return; //no help tabs for this route |
|
1089 | 1089 | |
1090 | - foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
|
1090 | + foreach ((array) $config['help_tabs'] as $tab_id => $cfg) { |
|
1091 | 1091 | //we're here so there ARE help tabs! |
1092 | 1092 | |
1093 | 1093 | //make sure we've got what we need |
1094 | - if ( !isset( $cfg['title'] ) ) |
|
1095 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1094 | + if ( ! isset($cfg['title'])) |
|
1095 | + throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
1096 | 1096 | |
1097 | 1097 | |
1098 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
1099 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1098 | + if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) |
|
1099 | + throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso')); |
|
1100 | 1100 | |
1101 | 1101 | |
1102 | 1102 | |
1103 | 1103 | //first priority goes to content. |
1104 | - if ( !empty($cfg['content'] ) ) { |
|
1105 | - $content = !empty($cfg['content']) ? $cfg['content'] : NULL; |
|
1104 | + if ( ! empty($cfg['content'])) { |
|
1105 | + $content = ! empty($cfg['content']) ? $cfg['content'] : NULL; |
|
1106 | 1106 | |
1107 | 1107 | //second priority goes to filename |
1108 | - } else if ( !empty($cfg['filename'] ) ) { |
|
1109 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
1108 | + } else if ( ! empty($cfg['filename'])) { |
|
1109 | + $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php'; |
|
1110 | 1110 | |
1111 | 1111 | |
1112 | 1112 | //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
1113 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
1113 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path; |
|
1114 | 1114 | |
1115 | 1115 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1116 | - if ( !is_readable($file_path) && !isset($cfg['callback']) ) { |
|
1117 | - EE_Error::add_error( sprintf( __('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1116 | + if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
1117 | + EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
1118 | 1118 | return; |
1119 | 1119 | } |
1120 | 1120 | $template_args['admin_page_obj'] = $this; |
@@ -1125,21 +1125,21 @@ discard block |
||
1125 | 1125 | |
1126 | 1126 | |
1127 | 1127 | //check if callback is valid |
1128 | - if ( empty($content) && ( !isset($cfg['callback']) || !method_exists( $this, $cfg['callback'] ) ) ) { |
|
1129 | - EE_Error::add_error( sprintf( __('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title'] ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1128 | + if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
1129 | + EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
1130 | 1130 | return; |
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | //setup config array for help tab method |
1134 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
1134 | + $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id; |
|
1135 | 1135 | $_ht = array( |
1136 | 1136 | 'id' => $id, |
1137 | 1137 | 'title' => $cfg['title'], |
1138 | - 'callback' => isset( $cfg['callback'] ) && empty($content) ? array( $this, $cfg['callback'] ) : NULL, |
|
1138 | + 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : NULL, |
|
1139 | 1139 | 'content' => $content |
1140 | 1140 | ); |
1141 | 1141 | |
1142 | - $this->_current_screen->add_help_tab( $_ht ); |
|
1142 | + $this->_current_screen->add_help_tab($_ht); |
|
1143 | 1143 | } |
1144 | 1144 | } |
1145 | 1145 | } |
@@ -1159,49 +1159,49 @@ discard block |
||
1159 | 1159 | $this->_help_tour = array(); |
1160 | 1160 | |
1161 | 1161 | //exit early if help tours are turned off globally |
1162 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
1162 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) |
|
1163 | 1163 | return; |
1164 | 1164 | |
1165 | 1165 | //loop through _page_config to find any help_tour defined |
1166 | - foreach ( $this->_page_config as $route => $config ) { |
|
1166 | + foreach ($this->_page_config as $route => $config) { |
|
1167 | 1167 | //we're only going to set things up for this route |
1168 | - if ( $route !== $this->_req_action ) |
|
1168 | + if ($route !== $this->_req_action) |
|
1169 | 1169 | continue; |
1170 | 1170 | |
1171 | - if ( isset( $config['help_tour'] ) ) { |
|
1171 | + if (isset($config['help_tour'])) { |
|
1172 | 1172 | |
1173 | - foreach( $config['help_tour'] as $tour ) { |
|
1174 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
1173 | + foreach ($config['help_tour'] as $tour) { |
|
1174 | + $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php'; |
|
1175 | 1175 | //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
1176 | - $file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
1176 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path; |
|
1177 | 1177 | |
1178 | 1178 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1179 | - if ( !is_readable($file_path) ) { |
|
1180 | - EE_Error::add_error( sprintf( __('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1179 | + if ( ! is_readable($file_path)) { |
|
1180 | + EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
1181 | 1181 | return; |
1182 | 1182 | } |
1183 | 1183 | |
1184 | 1184 | require_once $file_path; |
1185 | - if ( !class_exists( $tour ) ) { |
|
1186 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso' ), $tour); |
|
1187 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this) ); |
|
1188 | - throw new EE_Error( implode( '||', $error_msg )); |
|
1185 | + if ( ! class_exists($tour)) { |
|
1186 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
1187 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
1188 | + throw new EE_Error(implode('||', $error_msg)); |
|
1189 | 1189 | } |
1190 | 1190 | $a = new ReflectionClass($tour); |
1191 | 1191 | $tour_obj = $a->newInstance($this->_is_caf); |
1192 | 1192 | |
1193 | 1193 | $tours[] = $tour_obj; |
1194 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $tour_obj ); |
|
1194 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
1198 | 1198 | $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
1199 | 1199 | $tours[] = $end_stop_tour; |
1200 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $end_stop_tour ); |
|
1200 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
1201 | 1201 | } |
1202 | 1202 | } |
1203 | 1203 | |
1204 | - if ( !empty( $tours ) ) |
|
1204 | + if ( ! empty($tours)) |
|
1205 | 1205 | $this->_help_tour['tours'] = $tours; |
1206 | 1206 | |
1207 | 1207 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
@@ -1217,12 +1217,12 @@ discard block |
||
1217 | 1217 | * @return void |
1218 | 1218 | */ |
1219 | 1219 | protected function _add_qtips() { |
1220 | - if ( isset( $this->_route_config['qtips'] ) ) { |
|
1220 | + if (isset($this->_route_config['qtips'])) { |
|
1221 | 1221 | $qtips = (array) $this->_route_config['qtips']; |
1222 | 1222 | //load qtip loader |
1223 | 1223 | $path = array( |
1224 | - $this->_get_dir() . '/qtips/', |
|
1225 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/' |
|
1224 | + $this->_get_dir().'/qtips/', |
|
1225 | + EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/' |
|
1226 | 1226 | ); |
1227 | 1227 | EEH_Qtip_Loader::instance()->register($qtips, $path); |
1228 | 1228 | } |
@@ -1239,41 +1239,41 @@ discard block |
||
1239 | 1239 | * @return void |
1240 | 1240 | */ |
1241 | 1241 | protected function _set_nav_tabs() { |
1242 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1242 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1243 | 1243 | $i = 0; |
1244 | - foreach ( $this->_page_config as $slug => $config ) { |
|
1245 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
1244 | + foreach ($this->_page_config as $slug => $config) { |
|
1245 | + if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) |
|
1246 | 1246 | continue; //no nav tab for this config |
1247 | 1247 | |
1248 | 1248 | //check for persistent flag |
1249 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
1249 | + if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) |
|
1250 | 1250 | continue; //nav tab is only to appear when route requested. |
1251 | 1251 | |
1252 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
1252 | + if ( ! $this->check_user_access($slug, TRUE)) |
|
1253 | 1253 | continue; //no nav tab becasue current user does not have access. |
1254 | 1254 | |
1255 | - $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
|
1255 | + $css_class = isset($config['css_class']) ? $config['css_class'].' ' : ''; |
|
1256 | 1256 | $this->_nav_tabs[$slug] = array( |
1257 | - 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce( array( 'action'=>$slug ), $this->_admin_base_url ), |
|
1258 | - 'link_text' => isset( $config['nav']['label'] ) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug ) ), |
|
1259 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
1260 | - 'order' => isset( $config['nav']['order'] ) ? $config['nav']['order'] : $i |
|
1257 | + 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action'=>$slug), $this->_admin_base_url), |
|
1258 | + 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
1259 | + 'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class, |
|
1260 | + 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i |
|
1261 | 1261 | ); |
1262 | 1262 | $i++; |
1263 | 1263 | } |
1264 | 1264 | |
1265 | 1265 | //if $this->_nav_tabs is empty then lets set the default |
1266 | - if ( empty( $this->_nav_tabs ) ) { |
|
1266 | + if (empty($this->_nav_tabs)) { |
|
1267 | 1267 | $this->_nav_tabs[$this->default_nav_tab_name] = array( |
1268 | 1268 | 'url' => $this->admin_base_url, |
1269 | - 'link_text' => ucwords( str_replace( '_', ' ', $this->default_nav_tab_name ) ), |
|
1269 | + 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
1270 | 1270 | 'css_class' => 'nav-tab-active', |
1271 | 1271 | 'order' => 10 |
1272 | 1272 | ); |
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | //now let's sort the tabs according to order |
1276 | - usort( $this->_nav_tabs, array($this, '_sort_nav_tabs' )); |
|
1276 | + usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
1277 | 1277 | |
1278 | 1278 | } |
1279 | 1279 | |
@@ -1289,10 +1289,10 @@ discard block |
||
1289 | 1289 | * @return void |
1290 | 1290 | */ |
1291 | 1291 | private function _set_current_labels() { |
1292 | - if ( is_array($this->_route_config) && isset($this->_route_config['labels']) ) { |
|
1293 | - foreach ( $this->_route_config['labels'] as $label => $text ) { |
|
1294 | - if ( is_array($text) ) { |
|
1295 | - foreach ( $text as $sublabel => $subtext ) { |
|
1292 | + if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
1293 | + foreach ($this->_route_config['labels'] as $label => $text) { |
|
1294 | + if (is_array($text)) { |
|
1295 | + foreach ($text as $sublabel => $subtext) { |
|
1296 | 1296 | $this->_labels[$label][$sublabel] = $subtext; |
1297 | 1297 | } |
1298 | 1298 | } else { |
@@ -1313,24 +1313,24 @@ discard block |
||
1313 | 1313 | * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
1314 | 1314 | * @return BOOL|wp_die() |
1315 | 1315 | */ |
1316 | - public function check_user_access( $route_to_check = '', $verify_only = FALSE ) { |
|
1317 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1318 | - $route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check; |
|
1319 | - $capability = ! empty( $route_to_check ) && isset( $this->_page_routes[$route_to_check] ) && is_array( $this->_page_routes[$route_to_check] ) && ! empty( $this->_page_routes[$route_to_check]['capability'] ) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
1316 | + public function check_user_access($route_to_check = '', $verify_only = FALSE) { |
|
1317 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1318 | + $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
1319 | + $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) ? $this->_page_routes[$route_to_check]['capability'] : NULL; |
|
1320 | 1320 | |
1321 | - if ( empty( $capability ) && empty( $route_to_check ) ) { |
|
1322 | - $capability = is_array( $this->_route ) && empty( $this->_route['capability'] ) ? 'manage_options' : $this->_route['capability']; |
|
1321 | + if (empty($capability) && empty($route_to_check)) { |
|
1322 | + $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
1323 | 1323 | } else { |
1324 | - $capability = empty( $capability ) ? 'manage_options' : $capability; |
|
1324 | + $capability = empty($capability) ? 'manage_options' : $capability; |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | - $id = is_array( $this->_route ) && ! empty( $this->_route['obj_id'] ) ? $this->_route['obj_id'] : 0; |
|
1327 | + $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
1328 | 1328 | |
1329 | - if (( ! function_exists( 'is_admin' ) || ! EE_Registry::instance()->CAP->current_user_can( $capability, $this->page_slug . '_' . $route_to_check, $id ) ) && ! defined( 'DOING_AJAX')) { |
|
1330 | - if ( $verify_only ) { |
|
1329 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1330 | + if ($verify_only) { |
|
1331 | 1331 | return FALSE; |
1332 | 1332 | } else { |
1333 | - wp_die( __('You do not have access to this route.', 'event_espresso' ) ); |
|
1333 | + wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
1334 | 1334 | } |
1335 | 1335 | } |
1336 | 1336 | return TRUE; |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | $this->_add_admin_page_overlay(); |
1408 | 1408 | |
1409 | 1409 | //if metaboxes are present we need to add the nonce field |
1410 | - if ( ( isset($this->_route_config['metaboxes']) || ( isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'] ) || isset($this->_route_config['list_table']) ) ) { |
|
1410 | + if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
1411 | 1411 | wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
1412 | 1412 | wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
1413 | 1413 | } |
@@ -1426,19 +1426,19 @@ discard block |
||
1426 | 1426 | */ |
1427 | 1427 | public function admin_footer_global() { |
1428 | 1428 | //dialog container for dialog helper |
1429 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
1429 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n"; |
|
1430 | 1430 | $d_cont .= '<div class="ee-notices"></div>'; |
1431 | 1431 | $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
1432 | 1432 | $d_cont .= '</div>'; |
1433 | 1433 | echo $d_cont; |
1434 | 1434 | |
1435 | 1435 | //help tour stuff? |
1436 | - if ( isset( $this->_help_tour[$this->_req_action] ) ) { |
|
1436 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1437 | 1437 | echo implode('<br />', $this->_help_tour[$this->_req_action]); |
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | //current set timezone for timezone js |
1441 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
1441 | + echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>'; |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 | |
@@ -1462,18 +1462,18 @@ discard block |
||
1462 | 1462 | * @access protected |
1463 | 1463 | * @return string content |
1464 | 1464 | */ |
1465 | - protected function _set_help_popup_content( $help_array = array(), $display = FALSE ) { |
|
1465 | + protected function _set_help_popup_content($help_array = array(), $display = FALSE) { |
|
1466 | 1466 | $content = ''; |
1467 | 1467 | |
1468 | - $help_array = empty( $help_array ) ? $this->_get_help_content() : $help_array; |
|
1469 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
1468 | + $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
1469 | + $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php'; |
|
1470 | 1470 | |
1471 | 1471 | |
1472 | 1472 | //loop through the array and setup content |
1473 | - foreach ( $help_array as $trigger => $help ) { |
|
1473 | + foreach ($help_array as $trigger => $help) { |
|
1474 | 1474 | //make sure the array is setup properly |
1475 | - if ( !isset($help['title']) || !isset($help['content'] ) ) { |
|
1476 | - throw new EE_Error( __('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso') ); |
|
1475 | + if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
1476 | + throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso')); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | //we're good so let'd setup the template vars and then assign parsed template content to our content. |
@@ -1483,10 +1483,10 @@ discard block |
||
1483 | 1483 | 'help_popup_content' => $help['content'] |
1484 | 1484 | ); |
1485 | 1485 | |
1486 | - $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
1486 | + $content .= EEH_Template::display_template($template_path, $template_args, TRUE); |
|
1487 | 1487 | } |
1488 | 1488 | |
1489 | - if ( $display ) |
|
1489 | + if ($display) |
|
1490 | 1490 | echo $content; |
1491 | 1491 | else |
1492 | 1492 | return $content; |
@@ -1503,18 +1503,18 @@ discard block |
||
1503 | 1503 | */ |
1504 | 1504 | private function _get_help_content() { |
1505 | 1505 | //what is the method we're looking for? |
1506 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
1506 | + $method_name = '_help_popup_content_'.$this->_req_action; |
|
1507 | 1507 | |
1508 | 1508 | //if method doesn't exist let's get out. |
1509 | - if ( !method_exists( $this, $method_name ) ) |
|
1509 | + if ( ! method_exists($this, $method_name)) |
|
1510 | 1510 | return array(); |
1511 | 1511 | |
1512 | 1512 | //k we're good to go let's retrieve the help array |
1513 | - $help_array = call_user_func( array( $this, $method_name ) ); |
|
1513 | + $help_array = call_user_func(array($this, $method_name)); |
|
1514 | 1514 | |
1515 | 1515 | //make sure we've got an array! |
1516 | - if ( !is_array($help_array) ) { |
|
1517 | - throw new EE_Error( __('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso' ) ); |
|
1516 | + if ( ! is_array($help_array)) { |
|
1517 | + throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | return $help_array; |
@@ -1536,27 +1536,27 @@ discard block |
||
1536 | 1536 | * @param array $dimensions an array of dimensions for the box (array(h,w)) |
1537 | 1537 | * @return string |
1538 | 1538 | */ |
1539 | - protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
|
1539 | + protected function _set_help_trigger($trigger_id, $display = TRUE, $dimensions = array('400', '640')) { |
|
1540 | 1540 | |
1541 | - if ( defined('DOING_AJAX') ) return; |
|
1541 | + if (defined('DOING_AJAX')) return; |
|
1542 | 1542 | |
1543 | 1543 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
1544 | 1544 | $help_array = $this->_get_help_content(); |
1545 | 1545 | $help_content = ''; |
1546 | 1546 | |
1547 | - if ( empty( $help_array ) || !isset( $help_array[$trigger_id] ) ) { |
|
1547 | + if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
1548 | 1548 | $help_array[$trigger_id] = array( |
1549 | 1549 | 'title' => __('Missing Content', 'event_espresso'), |
1550 | 1550 | 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', 'event_espresso') |
1551 | 1551 | ); |
1552 | - $help_content = $this->_set_help_popup_content( $help_array, FALSE ); |
|
1552 | + $help_content = $this->_set_help_popup_content($help_array, FALSE); |
|
1553 | 1553 | } |
1554 | 1554 | |
1555 | 1555 | //let's setup the trigger |
1556 | - $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1557 | - $content = $content . $help_content; |
|
1556 | + $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1557 | + $content = $content.$help_content; |
|
1558 | 1558 | |
1559 | - if ( $display ) |
|
1559 | + if ($display) |
|
1560 | 1560 | echo $content; |
1561 | 1561 | else |
1562 | 1562 | return $content; |
@@ -1613,15 +1613,15 @@ discard block |
||
1613 | 1613 | public function load_global_scripts_styles() { |
1614 | 1614 | /** STYLES **/ |
1615 | 1615 | // add debugging styles |
1616 | - if ( WP_DEBUG ) { |
|
1617 | - add_action('admin_head', array( $this, 'add_xdebug_style' )); |
|
1616 | + if (WP_DEBUG) { |
|
1617 | + add_action('admin_head', array($this, 'add_xdebug_style')); |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | //register all styles |
1621 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(),EVENT_ESPRESSO_VERSION ); |
|
1622 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1621 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1622 | + wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1623 | 1623 | //helpers styles |
1624 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1624 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1625 | 1625 | //enqueue global styles |
1626 | 1626 | wp_enqueue_style('ee-admin-css'); |
1627 | 1627 | |
@@ -1629,66 +1629,66 @@ discard block |
||
1629 | 1629 | /** SCRIPTS **/ |
1630 | 1630 | |
1631 | 1631 | //register all scripts |
1632 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1633 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1634 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array( 'espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true ); |
|
1632 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1633 | + wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1634 | + wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1635 | 1635 | |
1636 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true ); |
|
1636 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1637 | 1637 | // register jQuery Validate - see /includes/functions/wp_hooks.php |
1638 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1638 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
1639 | 1639 | add_filter('FHEE_load_joyride', '__return_true'); |
1640 | 1640 | |
1641 | 1641 | //script for sorting tables |
1642 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1642 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1643 | 1643 | //script for parsing uri's |
1644 | - wp_register_script( 'ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1644 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
1645 | 1645 | //and parsing associative serialized form elements |
1646 | - wp_register_script( 'ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1646 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1647 | 1647 | //helpers scripts |
1648 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1649 | - wp_register_script( 'ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1650 | - wp_register_script( 'ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1651 | - wp_register_script( 'ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon','ee-moment'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1648 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1649 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE); |
|
1650 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1651 | + wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1652 | 1652 | |
1653 | 1653 | //google charts |
1654 | - wp_register_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false ); |
|
1654 | + wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
1655 | 1655 | |
1656 | 1656 | //enqueue global scripts |
1657 | 1657 | |
1658 | 1658 | //taking care of metaboxes |
1659 | - if ( ( isset($this->_route_config['metaboxes'] ) || isset($this->_route_config['has_metaboxes']) ) && empty( $this->_cpt_route) ) { |
|
1659 | + if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
1660 | 1660 | wp_enqueue_script('dashboard'); |
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
1664 | - if ( ! isset( $this->_route_config['has_help_popups']) || ( isset( $this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'] ) ) { |
|
1664 | + if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
1665 | 1665 | wp_enqueue_script('ee_admin_js'); |
1666 | 1666 | wp_enqueue_style('ee-admin-css'); |
1667 | 1667 | } |
1668 | 1668 | |
1669 | 1669 | |
1670 | 1670 | //localize script for ajax lazy loading |
1671 | - $lazy_loader_container_ids = apply_filters( 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content') ); |
|
1672 | - wp_localize_script( 'ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1671 | + $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
1672 | + wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | /** |
1676 | 1676 | * help tour stuff |
1677 | 1677 | */ |
1678 | - if ( !empty( $this->_help_tour ) ) { |
|
1678 | + if ( ! empty($this->_help_tour)) { |
|
1679 | 1679 | |
1680 | 1680 | //register the js for kicking things off |
1681 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1681 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1682 | 1682 | |
1683 | 1683 | //setup tours for the js tour object |
1684 | - foreach ( $this->_help_tour['tours'] as $tour ) { |
|
1684 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1685 | 1685 | $tours[] = array( |
1686 | 1686 | 'id' => $tour->get_slug(), |
1687 | 1687 | 'options' => $tour->get_options() |
1688 | 1688 | ); |
1689 | 1689 | } |
1690 | 1690 | |
1691 | - wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours ) ); |
|
1691 | + wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
1692 | 1692 | |
1693 | 1693 | //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
1694 | 1694 | } |
@@ -1706,52 +1706,52 @@ discard block |
||
1706 | 1706 | public function admin_footer_scripts_eei18n_js_strings() { |
1707 | 1707 | |
1708 | 1708 | EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
1709 | - EE_Registry::$i18n_js_strings['confirm_delete'] = __( 'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso' ); |
|
1710 | - |
|
1711 | - EE_Registry::$i18n_js_strings['January'] = __( 'January', 'event_espresso' ); |
|
1712 | - EE_Registry::$i18n_js_strings['February'] = __( 'February', 'event_espresso' ); |
|
1713 | - EE_Registry::$i18n_js_strings['March'] = __( 'March', 'event_espresso' ); |
|
1714 | - EE_Registry::$i18n_js_strings['April'] = __( 'April', 'event_espresso' ); |
|
1715 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
1716 | - EE_Registry::$i18n_js_strings['June'] = __( 'June', 'event_espresso' ); |
|
1717 | - EE_Registry::$i18n_js_strings['July'] = __( 'July', 'event_espresso' ); |
|
1718 | - EE_Registry::$i18n_js_strings['August'] = __( 'August', 'event_espresso' ); |
|
1719 | - EE_Registry::$i18n_js_strings['September'] = __( 'September', 'event_espresso' ); |
|
1720 | - EE_Registry::$i18n_js_strings['October'] = __( 'October', 'event_espresso' ); |
|
1721 | - EE_Registry::$i18n_js_strings['November'] = __( 'November', 'event_espresso' ); |
|
1722 | - EE_Registry::$i18n_js_strings['December'] = __( 'December', 'event_espresso' ); |
|
1723 | - EE_Registry::$i18n_js_strings['Jan'] = __( 'Jan', 'event_espresso' ); |
|
1724 | - EE_Registry::$i18n_js_strings['Feb'] = __( 'Feb', 'event_espresso' ); |
|
1725 | - EE_Registry::$i18n_js_strings['Mar'] = __( 'Mar', 'event_espresso' ); |
|
1726 | - EE_Registry::$i18n_js_strings['Apr'] = __( 'Apr', 'event_espresso' ); |
|
1727 | - EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' ); |
|
1728 | - EE_Registry::$i18n_js_strings['Jun'] = __( 'Jun', 'event_espresso' ); |
|
1729 | - EE_Registry::$i18n_js_strings['Jul'] = __( 'Jul', 'event_espresso' ); |
|
1730 | - EE_Registry::$i18n_js_strings['Aug'] = __( 'Aug', 'event_espresso' ); |
|
1731 | - EE_Registry::$i18n_js_strings['Sep'] = __( 'Sep', 'event_espresso' ); |
|
1732 | - EE_Registry::$i18n_js_strings['Oct'] = __( 'Oct', 'event_espresso' ); |
|
1733 | - EE_Registry::$i18n_js_strings['Nov'] = __( 'Nov', 'event_espresso' ); |
|
1734 | - EE_Registry::$i18n_js_strings['Dec'] = __( 'Dec', 'event_espresso' ); |
|
1735 | - |
|
1736 | - EE_Registry::$i18n_js_strings['Sunday'] = __( 'Sunday', 'event_espresso' ); |
|
1737 | - EE_Registry::$i18n_js_strings['Monday'] = __( 'Monday', 'event_espresso' ); |
|
1738 | - EE_Registry::$i18n_js_strings['Tuesday'] = __( 'Tuesday', 'event_espresso' ); |
|
1739 | - EE_Registry::$i18n_js_strings['Wednesday'] = __( 'Wednesday', 'event_espresso' ); |
|
1740 | - EE_Registry::$i18n_js_strings['Thursday'] = __( 'Thursday', 'event_espresso' ); |
|
1741 | - EE_Registry::$i18n_js_strings['Friday'] = __( 'Friday', 'event_espresso' ); |
|
1742 | - EE_Registry::$i18n_js_strings['Saturday'] = __( 'Saturday', 'event_espresso' ); |
|
1743 | - EE_Registry::$i18n_js_strings['Sun'] = __( 'Sun', 'event_espresso' ); |
|
1744 | - EE_Registry::$i18n_js_strings['Mon'] = __( 'Mon', 'event_espresso' ); |
|
1745 | - EE_Registry::$i18n_js_strings['Tue'] = __( 'Tue', 'event_espresso' ); |
|
1746 | - EE_Registry::$i18n_js_strings['Wed'] = __( 'Wed', 'event_espresso' ); |
|
1747 | - EE_Registry::$i18n_js_strings['Thu'] = __( 'Thu', 'event_espresso' ); |
|
1748 | - EE_Registry::$i18n_js_strings['Fri'] = __( 'Fri', 'event_espresso' ); |
|
1749 | - EE_Registry::$i18n_js_strings['Sat'] = __( 'Sat', 'event_espresso' ); |
|
1709 | + EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
1710 | + |
|
1711 | + EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
1712 | + EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
1713 | + EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
1714 | + EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
1715 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1716 | + EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
1717 | + EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
1718 | + EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
1719 | + EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
1720 | + EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
1721 | + EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
1722 | + EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
1723 | + EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
1724 | + EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
1725 | + EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
1726 | + EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
1727 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1728 | + EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
1729 | + EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
1730 | + EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
1731 | + EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
1732 | + EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
1733 | + EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
1734 | + EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
1735 | + |
|
1736 | + EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
1737 | + EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
1738 | + EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
1739 | + EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
1740 | + EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
1741 | + EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
1742 | + EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
1743 | + EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
1744 | + EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
1745 | + EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
1746 | + EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
1747 | + EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
1748 | + EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
1749 | + EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
1750 | 1750 | |
1751 | 1751 | //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
1752 | 1752 | //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
1753 | 1753 | //espresso_core is listed as a dependency of ee_admin_js. |
1754 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
1754 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
1755 | 1755 | |
1756 | 1756 | } |
1757 | 1757 | |
@@ -1785,23 +1785,23 @@ discard block |
||
1785 | 1785 | protected function _set_list_table() { |
1786 | 1786 | |
1787 | 1787 | //first is this a list_table view? |
1788 | - if ( !isset($this->_route_config['list_table']) ) |
|
1788 | + if ( ! isset($this->_route_config['list_table'])) |
|
1789 | 1789 | return; //not a list_table view so get out. |
1790 | 1790 | |
1791 | 1791 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
1792 | 1792 | |
1793 | - if ( call_user_func( array( $this, '_set_list_table_views_' . $this->_req_action ) ) === FALSE ) { |
|
1793 | + if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === FALSE) { |
|
1794 | 1794 | //user error msg |
1795 | - $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso' ); |
|
1795 | + $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
1796 | 1796 | //developer error msg |
1797 | - $error_msg .= '||' . sprintf( __('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso' ), $this->_req_action, '_set_list_table_views_' . $this->_req_action ); |
|
1798 | - throw new EE_Error( $error_msg ); |
|
1797 | + $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), $this->_req_action, '_set_list_table_views_'.$this->_req_action); |
|
1798 | + throw new EE_Error($error_msg); |
|
1799 | 1799 | } |
1800 | 1800 | |
1801 | 1801 | //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
1802 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views ); |
|
1803 | - $this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug, $this->_views ); |
|
1804 | - $this->_views = apply_filters( 'FHEE_list_table_views', $this->_views ); |
|
1802 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views); |
|
1803 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views); |
|
1804 | + $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
1805 | 1805 | |
1806 | 1806 | $this->_set_list_table_view(); |
1807 | 1807 | $this->_set_list_table_object(); |
@@ -1823,14 +1823,14 @@ discard block |
||
1823 | 1823 | * @return array |
1824 | 1824 | */ |
1825 | 1825 | protected function _set_list_table_view() { |
1826 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1826 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1827 | 1827 | |
1828 | 1828 | |
1829 | 1829 | // looking at active items or dumpster diving ? |
1830 | - if ( ! isset( $this->_req_data['status'] ) || ! array_key_exists( $this->_req_data['status'], $this->_views )) { |
|
1831 | - $this->_view = isset( $this->_views['in_use'] ) ? 'in_use' : 'all'; |
|
1830 | + if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
1831 | + $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
1832 | 1832 | } else { |
1833 | - $this->_view = sanitize_key( $this->_req_data['status'] ); |
|
1833 | + $this->_view = sanitize_key($this->_req_data['status']); |
|
1834 | 1834 | } |
1835 | 1835 | } |
1836 | 1836 | |
@@ -1843,8 +1843,8 @@ discard block |
||
1843 | 1843 | * @throws \EE_Error |
1844 | 1844 | */ |
1845 | 1845 | protected function _set_list_table_object() { |
1846 | - if ( isset( $this->_route_config['list_table'] ) ) { |
|
1847 | - if ( ! class_exists( $this->_route_config['list_table'] ) ) { |
|
1846 | + if (isset($this->_route_config['list_table'])) { |
|
1847 | + if ( ! class_exists($this->_route_config['list_table'])) { |
|
1848 | 1848 | throw new EE_Error( |
1849 | 1849 | sprintf( |
1850 | 1850 | __( |
@@ -1852,12 +1852,12 @@ discard block |
||
1852 | 1852 | 'event_espresso' |
1853 | 1853 | ), |
1854 | 1854 | $this->_route_config['list_table'], |
1855 | - get_class( $this ) |
|
1855 | + get_class($this) |
|
1856 | 1856 | ) |
1857 | 1857 | ); |
1858 | 1858 | } |
1859 | 1859 | $list_table = $this->_route_config['list_table']; |
1860 | - $this->_list_table_object = new $list_table( $this ); |
|
1860 | + $this->_list_table_object = new $list_table($this); |
|
1861 | 1861 | } |
1862 | 1862 | } |
1863 | 1863 | |
@@ -1874,27 +1874,27 @@ discard block |
||
1874 | 1874 | * |
1875 | 1875 | * @return array |
1876 | 1876 | */ |
1877 | - public function get_list_table_view_RLs( $extra_query_args = array() ) { |
|
1877 | + public function get_list_table_view_RLs($extra_query_args = array()) { |
|
1878 | 1878 | |
1879 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1879 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1880 | 1880 | |
1881 | - if ( empty( $this->_views )) { |
|
1881 | + if (empty($this->_views)) { |
|
1882 | 1882 | $this->_views = array(); |
1883 | 1883 | } |
1884 | 1884 | |
1885 | 1885 | // cycle thru views |
1886 | - foreach ( $this->_views as $key => $view ) { |
|
1886 | + foreach ($this->_views as $key => $view) { |
|
1887 | 1887 | $query_args = array(); |
1888 | 1888 | // check for current view |
1889 | - $this->_views[ $key ]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1889 | + $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1890 | 1890 | $query_args['action'] = $this->_req_action; |
1891 | - $query_args[$this->_req_action.'_nonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
1891 | + $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
1892 | 1892 | $query_args['status'] = $view['slug']; |
1893 | 1893 | //merge any other arguments sent in. |
1894 | - if ( isset( $extra_query_args[$view['slug']] ) ) { |
|
1895 | - $query_args = array_merge( $query_args, $extra_query_args[$view['slug']] ); |
|
1894 | + if (isset($extra_query_args[$view['slug']])) { |
|
1895 | + $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
1896 | 1896 | } |
1897 | - $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1897 | + $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | return $this->_views; |
@@ -1911,15 +1911,15 @@ discard block |
||
1911 | 1911 | * @param int $max_entries total number of rows in the table |
1912 | 1912 | * @return string |
1913 | 1913 | */ |
1914 | - protected function _entries_per_page_dropdown( $max_entries = FALSE ) { |
|
1914 | + protected function _entries_per_page_dropdown($max_entries = FALSE) { |
|
1915 | 1915 | |
1916 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1917 | - $values = array( 10, 25, 50, 100 ); |
|
1918 | - $per_page = ( ! empty( $this->_req_data['per_page'] )) ? absint( $this->_req_data['per_page'] ) : 10; |
|
1916 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1917 | + $values = array(10, 25, 50, 100); |
|
1918 | + $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
1919 | 1919 | |
1920 | - if ( $max_entries ) { |
|
1920 | + if ($max_entries) { |
|
1921 | 1921 | $values[] = $max_entries; |
1922 | - sort( $values ); |
|
1922 | + sort($values); |
|
1923 | 1923 | } |
1924 | 1924 | |
1925 | 1925 | $entries_per_page_dropdown = ' |
@@ -1928,15 +1928,15 @@ discard block |
||
1928 | 1928 | Show |
1929 | 1929 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
1930 | 1930 | |
1931 | - foreach ( $values as $value ) { |
|
1932 | - if ( $value < $max_entries ) { |
|
1933 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1931 | + foreach ($values as $value) { |
|
1932 | + if ($value < $max_entries) { |
|
1933 | + $selected = $value == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1934 | 1934 | $entries_per_page_dropdown .= ' |
1935 | 1935 | <option value="'.$value.'"'.$selected.'>'.$value.' </option>'; |
1936 | 1936 | } |
1937 | 1937 | } |
1938 | 1938 | |
1939 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1939 | + $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1940 | 1940 | $entries_per_page_dropdown .= ' |
1941 | 1941 | <option value="'.$max_entries.'"'.$selected.'>All </option>'; |
1942 | 1942 | |
@@ -1959,8 +1959,8 @@ discard block |
||
1959 | 1959 | * @return void |
1960 | 1960 | */ |
1961 | 1961 | public function _set_search_attributes() { |
1962 | - $this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label ); |
|
1963 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
1962 | + $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
1963 | + $this->_template_args['search']['callback'] = 'search_'.$this->page_slug; |
|
1964 | 1964 | } |
1965 | 1965 | |
1966 | 1966 | /*** END LIST TABLE METHODS **/ |
@@ -1979,10 +1979,10 @@ discard block |
||
1979 | 1979 | * @return void |
1980 | 1980 | */ |
1981 | 1981 | private function _add_registered_meta_boxes() { |
1982 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1982 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1983 | 1983 | |
1984 | 1984 | //we only add meta boxes if the page_route calls for it |
1985 | - if ( is_array( $this->_route_config ) && isset( $this->_route_config['metaboxes'] ) |
|
1985 | + if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
1986 | 1986 | && is_array( |
1987 | 1987 | $this->_route_config['metaboxes'] |
1988 | 1988 | ) |
@@ -1990,27 +1990,27 @@ discard block |
||
1990 | 1990 | // this simply loops through the callbacks provided |
1991 | 1991 | // and checks if there is a corresponding callback registered by the child |
1992 | 1992 | // if there is then we go ahead and process the metabox loader. |
1993 | - foreach ( $this->_route_config['metaboxes'] as $metabox_callback ) { |
|
1993 | + foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
1994 | 1994 | // first check for Closures |
1995 | - if ( is_callable( $metabox_callback ) ) { |
|
1995 | + if (is_callable($metabox_callback)) { |
|
1996 | 1996 | $result = $metabox_callback(); |
1997 | - } else if ( is_array( $metabox_callback ) && isset( $metabox_callback[0], $metabox_callback[1] ) ) { |
|
1998 | - $result = call_user_func( array( $metabox_callback[0], $metabox_callback[1] ) ); |
|
1997 | + } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
1998 | + $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
1999 | 1999 | } else { |
2000 | - $result = call_user_func( array( $this, &$metabox_callback ) ); |
|
2000 | + $result = call_user_func(array($this, &$metabox_callback)); |
|
2001 | 2001 | } |
2002 | - if ( $result === FALSE ) { |
|
2002 | + if ($result === FALSE) { |
|
2003 | 2003 | // user error msg |
2004 | - $error_msg = __( 'An error occurred. The requested metabox could not be found.', 'event_espresso' ); |
|
2004 | + $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
2005 | 2005 | // developer error msg |
2006 | - $error_msg .= '||' . sprintf( |
|
2006 | + $error_msg .= '||'.sprintf( |
|
2007 | 2007 | __( |
2008 | 2008 | 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
2009 | 2009 | 'event_espresso' |
2010 | 2010 | ), |
2011 | 2011 | $metabox_callback |
2012 | 2012 | ); |
2013 | - throw new EE_Error( $error_msg ); |
|
2013 | + throw new EE_Error($error_msg); |
|
2014 | 2014 | } |
2015 | 2015 | } |
2016 | 2016 | } |
@@ -2027,17 +2027,17 @@ discard block |
||
2027 | 2027 | * @return void |
2028 | 2028 | */ |
2029 | 2029 | private function _add_screen_columns() { |
2030 | - if ( is_array($this->_route_config) && isset( $this->_route_config['columns'] ) && is_array($this->_route_config['columns']) && count( $this->_route_config['columns'] == 2 ) ) { |
|
2030 | + if (is_array($this->_route_config) && isset($this->_route_config['columns']) && is_array($this->_route_config['columns']) && count($this->_route_config['columns'] == 2)) { |
|
2031 | 2031 | |
2032 | - add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1] ) ); |
|
2032 | + add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1])); |
|
2033 | 2033 | $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
2034 | 2034 | $screen_id = $this->_current_screen->id; |
2035 | 2035 | $screen_columns = (int) get_user_option("screen_layout_$screen_id"); |
2036 | - $total_columns = !empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
2037 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
2036 | + $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
2037 | + $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns; |
|
2038 | 2038 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2039 | 2039 | $this->_template_args['screen'] = $this->_current_screen; |
2040 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
2040 | + $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php'; |
|
2041 | 2041 | |
2042 | 2042 | //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
2043 | 2043 | $this->_route_config['has_metaboxes'] = TRUE; |
@@ -2054,11 +2054,11 @@ discard block |
||
2054 | 2054 | */ |
2055 | 2055 | |
2056 | 2056 | private function _espresso_news_post_box() { |
2057 | - $news_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __( 'New @ Event Espresso', 'event_espresso' ) ); |
|
2058 | - add_meta_box( 'espresso_news_post_box', $news_box_title, array( |
|
2057 | + $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
2058 | + add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
2059 | 2059 | $this, |
2060 | 2060 | 'espresso_news_post_box' |
2061 | - ), $this->_wp_page_slug, 'side' ); |
|
2061 | + ), $this->_wp_page_slug, 'side'); |
|
2062 | 2062 | } |
2063 | 2063 | |
2064 | 2064 | |
@@ -2066,14 +2066,14 @@ discard block |
||
2066 | 2066 | * Code for setting up espresso ratings request metabox. |
2067 | 2067 | */ |
2068 | 2068 | protected function _espresso_ratings_request() { |
2069 | - if ( ! apply_filters( 'FHEE_show_ratings_request_meta_box', true ) ) { |
|
2069 | + if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
2070 | 2070 | return ''; |
2071 | 2071 | } |
2072 | - $ratings_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso') ); |
|
2073 | - add_meta_box( 'espresso_ratings_request', $ratings_box_title, array( |
|
2072 | + $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
2073 | + add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
2074 | 2074 | $this, |
2075 | 2075 | 'espresso_ratings_request' |
2076 | - ), $this->_wp_page_slug, 'side' ); |
|
2076 | + ), $this->_wp_page_slug, 'side'); |
|
2077 | 2077 | } |
2078 | 2078 | |
2079 | 2079 | |
@@ -2081,34 +2081,34 @@ discard block |
||
2081 | 2081 | * Code for setting up espresso ratings request metabox content. |
2082 | 2082 | */ |
2083 | 2083 | public function espresso_ratings_request() { |
2084 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
2085 | - EEH_Template::display_template( $template_path, array() ); |
|
2084 | + $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php'; |
|
2085 | + EEH_Template::display_template($template_path, array()); |
|
2086 | 2086 | } |
2087 | 2087 | |
2088 | 2088 | |
2089 | 2089 | |
2090 | 2090 | |
2091 | - public static function cached_rss_display( $rss_id, $url ) { |
|
2092 | - $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
|
2093 | - $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
2094 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
2095 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
2096 | - $post = '</div>' . "\n"; |
|
2091 | + public static function cached_rss_display($rss_id, $url) { |
|
2092 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
2093 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
2094 | + $pre = '<div class="espresso-rss-display">'."\n\t"; |
|
2095 | + $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>'; |
|
2096 | + $post = '</div>'."\n"; |
|
2097 | 2097 | |
2098 | - $cache_key = 'ee_rss_' . md5( $rss_id ); |
|
2099 | - if ( FALSE != ( $output = get_transient( $cache_key ) ) ) { |
|
2100 | - echo $pre . $output . $post; |
|
2098 | + $cache_key = 'ee_rss_'.md5($rss_id); |
|
2099 | + if (FALSE != ($output = get_transient($cache_key))) { |
|
2100 | + echo $pre.$output.$post; |
|
2101 | 2101 | return TRUE; |
2102 | 2102 | } |
2103 | 2103 | |
2104 | - if ( ! $doing_ajax ) { |
|
2105 | - echo $pre . $loading . $post; |
|
2104 | + if ( ! $doing_ajax) { |
|
2105 | + echo $pre.$loading.$post; |
|
2106 | 2106 | return FALSE; |
2107 | 2107 | } |
2108 | 2108 | |
2109 | 2109 | ob_start(); |
2110 | - wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5) ); |
|
2111 | - set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); |
|
2110 | + wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
2111 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
2112 | 2112 | return TRUE; |
2113 | 2113 | |
2114 | 2114 | } |
@@ -2120,13 +2120,13 @@ discard block |
||
2120 | 2120 | <div id="espresso_news_post_box_content" class="infolinks"> |
2121 | 2121 | <?php |
2122 | 2122 | // Get RSS Feed(s) |
2123 | - $feed_url = apply_filters( 'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/' ); |
|
2123 | + $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
2124 | 2124 | $url = urlencode($feed_url); |
2125 | - self::cached_rss_display( 'espresso_news_post_box_content', $url ); |
|
2125 | + self::cached_rss_display('espresso_news_post_box_content', $url); |
|
2126 | 2126 | |
2127 | 2127 | ?> |
2128 | 2128 | </div> |
2129 | - <?php do_action( 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
2129 | + <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
|
2130 | 2130 | </div> |
2131 | 2131 | <?php |
2132 | 2132 | } |
@@ -2147,32 +2147,32 @@ discard block |
||
2147 | 2147 | |
2148 | 2148 | protected function _espresso_sponsors_post_box() { |
2149 | 2149 | |
2150 | - $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
|
2151 | - if ( $show_sponsors ) |
|
2152 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2150 | + $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', TRUE); |
|
2151 | + if ($show_sponsors) |
|
2152 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2153 | 2153 | } |
2154 | 2154 | |
2155 | 2155 | |
2156 | 2156 | public function espresso_sponsors_post_box() { |
2157 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2158 | - EEH_Template::display_template( $templatepath ); |
|
2157 | + $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2158 | + EEH_Template::display_template($templatepath); |
|
2159 | 2159 | } |
2160 | 2160 | |
2161 | 2161 | |
2162 | 2162 | |
2163 | 2163 | private function _publish_post_box() { |
2164 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
2164 | + $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview'; |
|
2165 | 2165 | |
2166 | 2166 | //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
2167 | - if ( !empty( $this->_labels['publishbox'] ) ) { |
|
2168 | - $box_label = is_array( $this->_labels['publishbox'] ) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2167 | + if ( ! empty($this->_labels['publishbox'])) { |
|
2168 | + $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2169 | 2169 | } else { |
2170 | 2170 | $box_label = __('Publish', 'event_espresso'); |
2171 | 2171 | } |
2172 | 2172 | |
2173 | - $box_label = apply_filters( 'FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this ); |
|
2173 | + $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
2174 | 2174 | |
2175 | - add_meta_box( $meta_box_ref, $box_label, array( $this, 'editor_overview' ), $this->_current_screen->id, 'side', 'high' ); |
|
2175 | + add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
2176 | 2176 | |
2177 | 2177 | } |
2178 | 2178 | |
@@ -2180,9 +2180,9 @@ discard block |
||
2180 | 2180 | |
2181 | 2181 | public function editor_overview() { |
2182 | 2182 | //if we have extra content set let's add it in if not make sure its empty |
2183 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2184 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
2185 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2183 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2184 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php'; |
|
2185 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2186 | 2186 | } |
2187 | 2187 | |
2188 | 2188 | |
@@ -2198,8 +2198,8 @@ discard block |
||
2198 | 2198 | * @see $this->_set_publish_post_box_vars for param details |
2199 | 2199 | * @since 4.6.0 |
2200 | 2200 | */ |
2201 | - public function set_publish_post_box_vars( $name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true ) { |
|
2202 | - $this->_set_publish_post_box_vars( $name, $id, $delete, $save_close_redirect_URL, $both_btns ); |
|
2201 | + public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) { |
|
2202 | + $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
2203 | 2203 | } |
2204 | 2204 | |
2205 | 2205 | |
@@ -2227,17 +2227,17 @@ discard block |
||
2227 | 2227 | $both_btns = true |
2228 | 2228 | ) { |
2229 | 2229 | // if Save & Close, use a custom redirect URL or default to the main page? |
2230 | - $save_close_redirect_URL = ! empty( $save_close_redirect_URL ) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2230 | + $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2231 | 2231 | // create the Save & Close and Save buttons |
2232 | - $this->_set_save_buttons( $both_btns, array(), array(), $save_close_redirect_URL ); |
|
2232 | + $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
2233 | 2233 | //if we have extra content set let's add it in if not make sure its empty |
2234 | - $this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2234 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2235 | 2235 | |
2236 | 2236 | |
2237 | - if ( $delete && ! empty( $id ) ) { |
|
2237 | + if ($delete && ! empty($id)) { |
|
2238 | 2238 | //make sure we have a default if just true is sent. |
2239 | 2239 | $delete = ! empty($delete) ? $delete : 'delete'; |
2240 | - $delete_link_args = array( $name => $id ); |
|
2240 | + $delete_link_args = array($name => $id); |
|
2241 | 2241 | $delete = $this->get_action_link_or_button( |
2242 | 2242 | $delete, |
2243 | 2243 | $delete, |
@@ -2248,8 +2248,8 @@ discard block |
||
2248 | 2248 | ); |
2249 | 2249 | } |
2250 | 2250 | |
2251 | - $this->_template_args['publish_delete_link'] = !empty( $id ) ? $delete : ''; |
|
2252 | - if ( ! empty( $name ) && ! empty( $id ) ) { |
|
2251 | + $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
2252 | + if ( ! empty($name) && ! empty($id)) { |
|
2253 | 2253 | $hidden_field_arr[$name] = array( |
2254 | 2254 | 'type' => 'hidden', |
2255 | 2255 | 'value' => $id |
@@ -2259,7 +2259,7 @@ discard block |
||
2259 | 2259 | $hf = ''; |
2260 | 2260 | } |
2261 | 2261 | // add hidden field |
2262 | - $this->_template_args['publish_hidden_fields'] = ! empty( $hf ) ? $hf[$name]['field'] : $hf; |
|
2262 | + $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
2263 | 2263 | |
2264 | 2264 | } |
2265 | 2265 | |
@@ -2276,8 +2276,8 @@ discard block |
||
2276 | 2276 | <noscript> |
2277 | 2277 | <div id="no-js-message" class="error"> |
2278 | 2278 | <p style="font-size:1.3em;"> |
2279 | - <span style="color:red;"><?php _e( 'Warning!', 'event_espresso' ); ?></span> |
|
2280 | - <?php _e( 'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso' ); ?> |
|
2279 | + <span style="color:red;"><?php _e('Warning!', 'event_espresso'); ?></span> |
|
2280 | + <?php _e('Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso'); ?> |
|
2281 | 2281 | </p> |
2282 | 2282 | </div> |
2283 | 2283 | </noscript> |
@@ -2297,7 +2297,7 @@ discard block |
||
2297 | 2297 | * @return string |
2298 | 2298 | */ |
2299 | 2299 | private function _display_espresso_notices() { |
2300 | - $notices = $this->_get_transient( TRUE ); |
|
2300 | + $notices = $this->_get_transient(TRUE); |
|
2301 | 2301 | echo stripslashes($notices); |
2302 | 2302 | } |
2303 | 2303 | |
@@ -2349,11 +2349,11 @@ discard block |
||
2349 | 2349 | * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
2350 | 2350 | * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
2351 | 2351 | */ |
2352 | - public function _add_admin_page_meta_box( $action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true ) { |
|
2353 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, $callback ); |
|
2352 | + public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) { |
|
2353 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
2354 | 2354 | |
2355 | 2355 | //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
2356 | - if ( empty( $callback_args ) && $create_func ) { |
|
2356 | + if (empty($callback_args) && $create_func) { |
|
2357 | 2357 | $callback_args = array( |
2358 | 2358 | 'template_path' => $this->_template_path, |
2359 | 2359 | 'template_args' => $this->_template_args, |
@@ -2363,7 +2363,7 @@ discard block |
||
2363 | 2363 | //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
2364 | 2364 | $call_back_func = $create_func ? create_function('$post, $metabox', 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
2365 | 2365 | |
2366 | - add_meta_box( str_replace( '_', '-', $action ) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args ); |
|
2366 | + add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2367 | 2367 | } |
2368 | 2368 | |
2369 | 2369 | |
@@ -2376,7 +2376,7 @@ discard block |
||
2376 | 2376 | */ |
2377 | 2377 | public function display_admin_page_with_metabox_columns() { |
2378 | 2378 | $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
2379 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_column_template_path, $this->_template_args, TRUE); |
|
2379 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, TRUE); |
|
2380 | 2380 | |
2381 | 2381 | //the final wrapper |
2382 | 2382 | $this->admin_page_wrapper(); |
@@ -2419,7 +2419,7 @@ discard block |
||
2419 | 2419 | * @return void |
2420 | 2420 | */ |
2421 | 2421 | public function display_about_admin_page() { |
2422 | - $this->_display_admin_page( FALSE, TRUE ); |
|
2422 | + $this->_display_admin_page(FALSE, TRUE); |
|
2423 | 2423 | } |
2424 | 2424 | |
2425 | 2425 | |
@@ -2435,26 +2435,26 @@ discard block |
||
2435 | 2435 | * @return void |
2436 | 2436 | */ |
2437 | 2437 | private function _display_admin_page($sidebar = false, $about = FALSE) { |
2438 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2438 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2439 | 2439 | |
2440 | 2440 | //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
2441 | - do_action( 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' ); |
|
2441 | + do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
2442 | 2442 | |
2443 | 2443 | // set current wp page slug - looks like: event-espresso_page_event_categories |
2444 | 2444 | // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
2445 | 2445 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2446 | 2446 | |
2447 | - $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
2447 | + $template_path = $sidebar ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php'; |
|
2448 | 2448 | |
2449 | - if ( defined('DOING_AJAX' ) ) |
|
2450 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2449 | + if (defined('DOING_AJAX')) |
|
2450 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2451 | 2451 | |
2452 | - $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2452 | + $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2453 | 2453 | |
2454 | - $this->_template_args['post_body_content'] = isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : ''; |
|
2454 | + $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
2455 | 2455 | $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
2456 | 2456 | $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
2457 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2457 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2458 | 2458 | |
2459 | 2459 | |
2460 | 2460 | // the final template wrapper |
@@ -2472,7 +2472,7 @@ discard block |
||
2472 | 2472 | * @return void |
2473 | 2473 | * @throws \EE_Error |
2474 | 2474 | */ |
2475 | - public function display_admin_caf_preview_page( $utm_campaign_source = '', $display_sidebar = TRUE ) { |
|
2475 | + public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = TRUE) { |
|
2476 | 2476 | //let's generate a default preview action button if there isn't one already present. |
2477 | 2477 | $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso'); |
2478 | 2478 | $buy_now_url = add_query_arg( |
@@ -2485,7 +2485,7 @@ discard block |
||
2485 | 2485 | ), |
2486 | 2486 | 'http://eventespresso.com/pricing/' |
2487 | 2487 | ); |
2488 | - $this->_template_args['preview_action_button'] = ! isset( $this->_template_args['preview_action_button'] ) |
|
2488 | + $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
2489 | 2489 | ? $this->get_action_link_or_button( |
2490 | 2490 | '', |
2491 | 2491 | 'buy_now', |
@@ -2495,13 +2495,13 @@ discard block |
||
2495 | 2495 | true |
2496 | 2496 | ) |
2497 | 2497 | : $this->_template_args['preview_action_button']; |
2498 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
2498 | + $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php'; |
|
2499 | 2499 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2500 | 2500 | $template_path, |
2501 | 2501 | $this->_template_args, |
2502 | 2502 | true |
2503 | 2503 | ); |
2504 | - $this->_display_admin_page( $display_sidebar ); |
|
2504 | + $this->_display_admin_page($display_sidebar); |
|
2505 | 2505 | } |
2506 | 2506 | |
2507 | 2507 | |
@@ -2535,49 +2535,49 @@ discard block |
||
2535 | 2535 | * @param boolean $sidebar whether to display with sidebar or not. |
2536 | 2536 | * @return void |
2537 | 2537 | */ |
2538 | - private function _display_admin_list_table_page( $sidebar = false ) { |
|
2538 | + private function _display_admin_list_table_page($sidebar = false) { |
|
2539 | 2539 | //setup search attributes |
2540 | 2540 | $this->_set_search_attributes(); |
2541 | 2541 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2542 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
2542 | + $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php'; |
|
2543 | 2543 | |
2544 | - $this->_template_args['table_url'] = defined( 'DOING_AJAX') |
|
2545 | - ? add_query_arg( array( 'noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url ) |
|
2546 | - : add_query_arg( array( 'route' => $this->_req_action), $this->_admin_base_url); |
|
2544 | + $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
2545 | + ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
2546 | + : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
2547 | 2547 | $this->_template_args['list_table'] = $this->_list_table_object; |
2548 | 2548 | $this->_template_args['current_route'] = $this->_req_action; |
2549 | - $this->_template_args['list_table_class'] = get_class( $this->_list_table_object ); |
|
2549 | + $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
2550 | 2550 | |
2551 | 2551 | $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
2552 | - if( ! empty( $ajax_sorting_callback )) { |
|
2552 | + if ( ! empty($ajax_sorting_callback)) { |
|
2553 | 2553 | $sortable_list_table_form_fields = wp_nonce_field( |
2554 | - $ajax_sorting_callback . '_nonce', |
|
2555 | - $ajax_sorting_callback . '_nonce', |
|
2554 | + $ajax_sorting_callback.'_nonce', |
|
2555 | + $ajax_sorting_callback.'_nonce', |
|
2556 | 2556 | FALSE, |
2557 | 2557 | FALSE |
2558 | 2558 | ); |
2559 | 2559 | // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
2560 | 2560 | // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
2561 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug .'" />'; |
|
2562 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
2561 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />'; |
|
2562 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />'; |
|
2563 | 2563 | } else { |
2564 | 2564 | $sortable_list_table_form_fields = ''; |
2565 | 2565 | } |
2566 | 2566 | |
2567 | 2567 | $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
2568 | - $hidden_form_fields = isset( $this->_template_args['list_table_hidden_fields'] ) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2569 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
2570 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce( $nonce_ref ) . '">'; |
|
2568 | + $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2569 | + $nonce_ref = $this->_req_action.'_nonce'; |
|
2570 | + $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">'; |
|
2571 | 2571 | $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
2572 | 2572 | |
2573 | 2573 | //display message about search results? |
2574 | 2574 | $this->_template_args['before_list_table'] .= apply_filters( |
2575 | 2575 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
2576 | - ! empty( $this->_req_data['s'] ) |
|
2577 | - ? '<p class="ee-search-results">' . sprintf( |
|
2578 | - __( 'Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso' ), |
|
2579 | - trim( $this->_req_data['s'], '%' ) |
|
2580 | - ) . '</p>' |
|
2576 | + ! empty($this->_req_data['s']) |
|
2577 | + ? '<p class="ee-search-results">'.sprintf( |
|
2578 | + __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), |
|
2579 | + trim($this->_req_data['s'], '%') |
|
2580 | + ).'</p>' |
|
2581 | 2581 | : '', |
2582 | 2582 | $this->page_slug, |
2583 | 2583 | $this->_req_data, |
@@ -2589,7 +2589,7 @@ discard block |
||
2589 | 2589 | true |
2590 | 2590 | ); |
2591 | 2591 | // the final template wrapper |
2592 | - if ( $sidebar ) |
|
2592 | + if ($sidebar) |
|
2593 | 2593 | $this->display_admin_page_with_sidebar(); |
2594 | 2594 | else |
2595 | 2595 | $this->display_admin_page_with_no_sidebar(); |
@@ -2612,9 +2612,9 @@ discard block |
||
2612 | 2612 | * @param array $items see above for format of array |
2613 | 2613 | * @return string html string of legend |
2614 | 2614 | */ |
2615 | - protected function _display_legend( $items ) { |
|
2616 | - $this->_template_args['items'] = apply_filters( 'FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this ); |
|
2617 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
2615 | + protected function _display_legend($items) { |
|
2616 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this); |
|
2617 | + $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php'; |
|
2618 | 2618 | return EEH_Template::display_template($legend_template, $this->_template_args, TRUE); |
2619 | 2619 | } |
2620 | 2620 | |
@@ -2639,33 +2639,33 @@ discard block |
||
2639 | 2639 | * |
2640 | 2640 | * @return void |
2641 | 2641 | */ |
2642 | - protected function _return_json( $sticky_notices = false ) { |
|
2642 | + protected function _return_json($sticky_notices = false) { |
|
2643 | 2643 | |
2644 | 2644 | //make sure any EE_Error notices have been handled. |
2645 | - $this->_process_notices( array(), true, $sticky_notices ); |
|
2645 | + $this->_process_notices(array(), true, $sticky_notices); |
|
2646 | 2646 | |
2647 | 2647 | |
2648 | - $data = isset( $this->_template_args['data'] ) ? $this->_template_args['data'] : array(); |
|
2648 | + $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
2649 | 2649 | unset($this->_template_args['data']); |
2650 | 2650 | $json = array( |
2651 | - 'error' => isset( $this->_template_args['error'] ) ? $this->_template_args['error'] : false, |
|
2652 | - 'success' => isset( $this->_template_args['success'] ) ? $this->_template_args['success'] : false, |
|
2653 | - 'errors' => isset( $this->_template_args['errors'] ) ? $this->_template_args['errors'] : false, |
|
2654 | - 'attention' => isset( $this->_template_args['attention'] ) ? $this->_template_args['attention'] : false, |
|
2651 | + 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
2652 | + 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
2653 | + 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
2654 | + 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
2655 | 2655 | 'notices' => EE_Error::get_notices(), |
2656 | - 'content' => isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : '', |
|
2657 | - 'data' => array_merge( $data, array('template_args' => $this->_template_args ) ), |
|
2656 | + 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
2657 | + 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
2658 | 2658 | 'isEEajax' => TRUE //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
2659 | 2659 | ); |
2660 | 2660 | |
2661 | 2661 | |
2662 | 2662 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2663 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
2663 | + if (NULL === error_get_last() || ! headers_sent()) |
|
2664 | 2664 | header('Content-Type: application/json; charset=UTF-8'); |
2665 | - if( function_exists( 'wp_json_encode' ) ) { |
|
2666 | - echo wp_json_encode( $json ); |
|
2665 | + if (function_exists('wp_json_encode')) { |
|
2666 | + echo wp_json_encode($json); |
|
2667 | 2667 | } else { |
2668 | - echo json_encode( $json ); |
|
2668 | + echo json_encode($json); |
|
2669 | 2669 | } |
2670 | 2670 | exit(); |
2671 | 2671 | } |
@@ -2679,11 +2679,11 @@ discard block |
||
2679 | 2679 | * @throws EE_Error |
2680 | 2680 | */ |
2681 | 2681 | public function return_json() { |
2682 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
2682 | + if (defined('DOING_AJAX') && DOING_AJAX) |
|
2683 | 2683 | $this->_return_json(); |
2684 | 2684 | |
2685 | 2685 | else { |
2686 | - throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
|
2686 | + throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
2687 | 2687 | } |
2688 | 2688 | } |
2689 | 2689 | |
@@ -2696,7 +2696,7 @@ discard block |
||
2696 | 2696 | * |
2697 | 2697 | * @access public |
2698 | 2698 | */ |
2699 | - public function set_hook_object( EE_Admin_Hooks $hook_obj ) { |
|
2699 | + public function set_hook_object(EE_Admin_Hooks $hook_obj) { |
|
2700 | 2700 | $this->_hook_obj = $hook_obj; |
2701 | 2701 | } |
2702 | 2702 | |
@@ -2712,33 +2712,33 @@ discard block |
||
2712 | 2712 | */ |
2713 | 2713 | public function admin_page_wrapper($about = FALSE) { |
2714 | 2714 | |
2715 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2715 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2716 | 2716 | |
2717 | 2717 | $this->_nav_tabs = $this->_get_main_nav_tabs(); |
2718 | 2718 | |
2719 | 2719 | $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
2720 | 2720 | $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
2721 | 2721 | |
2722 | - $this->_template_args['before_admin_page_content'] = apply_filters( 'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['before_admin_page_content'] ) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2723 | - $this->_template_args['after_admin_page_content'] = apply_filters( 'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['after_admin_page_content'] ) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2722 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2723 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2724 | 2724 | |
2725 | 2725 | $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
2726 | 2726 | |
2727 | 2727 | |
2728 | 2728 | |
2729 | 2729 | // load settings page wrapper template |
2730 | - $template_path = !defined( 'DOING_AJAX' ) ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
2730 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php'; |
|
2731 | 2731 | |
2732 | 2732 | //about page? |
2733 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
2733 | + $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path; |
|
2734 | 2734 | |
2735 | 2735 | |
2736 | - if ( defined( 'DOING_AJAX' ) ) { |
|
2737 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2736 | + if (defined('DOING_AJAX')) { |
|
2737 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2738 | 2738 | |
2739 | 2739 | $this->_return_json(); |
2740 | 2740 | } else { |
2741 | - EEH_Template::display_template( $template_path, $this->_template_args ); |
|
2741 | + EEH_Template::display_template($template_path, $this->_template_args); |
|
2742 | 2742 | } |
2743 | 2743 | |
2744 | 2744 | } |
@@ -2764,7 +2764,7 @@ discard block |
||
2764 | 2764 | * @param $b |
2765 | 2765 | * @return int |
2766 | 2766 | */ |
2767 | - private function _sort_nav_tabs( $a, $b ) { |
|
2767 | + private function _sort_nav_tabs($a, $b) { |
|
2768 | 2768 | if ($a['order'] == $b['order']) { |
2769 | 2769 | return 0; |
2770 | 2770 | } |
@@ -2784,7 +2784,7 @@ discard block |
||
2784 | 2784 | * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
2785 | 2785 | * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
2786 | 2786 | */ |
2787 | - protected function _generate_admin_form_fields( $input_vars = array(), $generator = 'string', $id = FALSE ) { |
|
2787 | + protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = FALSE) { |
|
2788 | 2788 | $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
2789 | 2789 | return $content; |
2790 | 2790 | } |
@@ -2806,25 +2806,25 @@ discard block |
||
2806 | 2806 | * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
2807 | 2807 | * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
2808 | 2808 | */ |
2809 | - protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL ) { |
|
2809 | + protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL) { |
|
2810 | 2810 | //make sure $text and $actions are in an array |
2811 | 2811 | $text = (array) $text; |
2812 | 2812 | $actions = (array) $actions; |
2813 | 2813 | $referrer_url = empty($referrer) ? '' : $referrer; |
2814 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] .'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer .'" />'; |
|
2814 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />'; |
|
2815 | 2815 | |
2816 | - $button_text = !empty($text) ? $text : array( __('Save', 'event_espresso'), __('Save and Close', 'event_espresso') ); |
|
2817 | - $default_names = array( 'save', 'save_and_close' ); |
|
2816 | + $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
2817 | + $default_names = array('save', 'save_and_close'); |
|
2818 | 2818 | |
2819 | 2819 | //add in a hidden index for the current page (so save and close redirects properly) |
2820 | 2820 | $this->_template_args['save_buttons'] = $referrer_url; |
2821 | 2821 | |
2822 | - foreach ( $button_text as $key => $button ) { |
|
2822 | + foreach ($button_text as $key => $button) { |
|
2823 | 2823 | $ref = $default_names[$key]; |
2824 | - $id = $this->_current_view . '_' . $ref; |
|
2825 | - $name = !empty($actions) ? $actions[$key] : $ref; |
|
2826 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
2827 | - if ( !$both ) break; |
|
2824 | + $id = $this->_current_view.'_'.$ref; |
|
2825 | + $name = ! empty($actions) ? $actions[$key] : $ref; |
|
2826 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />'; |
|
2827 | + if ( ! $both) break; |
|
2828 | 2828 | } |
2829 | 2829 | |
2830 | 2830 | } |
@@ -2839,8 +2839,8 @@ discard block |
||
2839 | 2839 | * @param string $route |
2840 | 2840 | * @param array $additional_hidden_fields |
2841 | 2841 | */ |
2842 | - public function set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
2843 | - $this->_set_add_edit_form_tags( $route, $additional_hidden_fields ); |
|
2842 | + public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
2843 | + $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
2844 | 2844 | } |
2845 | 2845 | |
2846 | 2846 | |
@@ -2853,30 +2853,30 @@ discard block |
||
2853 | 2853 | * @param array $additional_hidden_fields any additional hidden fields required in the form header |
2854 | 2854 | * @return void |
2855 | 2855 | */ |
2856 | - protected function _set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) { |
|
2856 | + protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) { |
|
2857 | 2857 | |
2858 | - if ( empty( $route )) { |
|
2858 | + if (empty($route)) { |
|
2859 | 2859 | $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
2860 | - $dev_msg = $user_msg . "\n" . sprintf( __('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__ ); |
|
2861 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2860 | + $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2861 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2862 | 2862 | } |
2863 | 2863 | // open form |
2864 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
2864 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >'; |
|
2865 | 2865 | // add nonce |
2866 | - $nonce = wp_nonce_field( $route . '_nonce', $route . '_nonce', FALSE, FALSE ); |
|
2866 | + $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', FALSE, FALSE); |
|
2867 | 2867 | // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
2868 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
2868 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce; |
|
2869 | 2869 | // add REQUIRED form action |
2870 | 2870 | $hidden_fields = array( |
2871 | - 'action' => array( 'type' => 'hidden', 'value' => $route ), |
|
2871 | + 'action' => array('type' => 'hidden', 'value' => $route), |
|
2872 | 2872 | ); |
2873 | 2873 | // merge arrays |
2874 | - $hidden_fields = is_array( $additional_hidden_fields) ? array_merge( $hidden_fields, $additional_hidden_fields ) : $hidden_fields; |
|
2874 | + $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
2875 | 2875 | // generate form fields |
2876 | - $form_fields = $this->_generate_admin_form_fields( $hidden_fields, 'array' ); |
|
2876 | + $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
2877 | 2877 | // add fields to form |
2878 | - foreach ( (array)$form_fields as $field_name => $form_field ) { |
|
2879 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
2878 | + foreach ((array) $form_fields as $field_name => $form_field) { |
|
2879 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field']; |
|
2880 | 2880 | } |
2881 | 2881 | |
2882 | 2882 | // close form |
@@ -2893,8 +2893,8 @@ discard block |
||
2893 | 2893 | * @see EE_Admin_Page::_redirect_after_action() for params. |
2894 | 2894 | * @since 4.5.0 |
2895 | 2895 | */ |
2896 | - public function redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
2897 | - $this->_redirect_after_action( $success, $what, $action_desc, $query_args, $override_overwrite ); |
|
2896 | + public function redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
2897 | + $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
2898 | 2898 | } |
2899 | 2899 | |
2900 | 2900 | |
@@ -2910,38 +2910,38 @@ discard block |
||
2910 | 2910 | * @access protected |
2911 | 2911 | * @return void |
2912 | 2912 | */ |
2913 | - protected function _redirect_after_action( $success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) { |
|
2913 | + protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) { |
|
2914 | 2914 | |
2915 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2915 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2916 | 2916 | |
2917 | 2917 | //class name for actions/filters. |
2918 | 2918 | $classname = get_class($this); |
2919 | 2919 | |
2920 | 2920 | //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
2921 | - $redirect_url = isset( $query_args['page'] ) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2922 | - $notices = EE_Error::get_notices( FALSE ); |
|
2921 | + $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2922 | + $notices = EE_Error::get_notices(FALSE); |
|
2923 | 2923 | |
2924 | 2924 | // overwrite default success messages //BUT ONLY if overwrite not overridden |
2925 | - if ( ! $override_overwrite || ! empty( $notices['errors'] )) { |
|
2925 | + if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
2926 | 2926 | EE_Error::overwrite_success(); |
2927 | 2927 | } |
2928 | - if ( ! empty( $what ) && ! empty( $action_desc ) ) { |
|
2928 | + if ( ! empty($what) && ! empty($action_desc)) { |
|
2929 | 2929 | // how many records affected ? more than one record ? or just one ? |
2930 | - if ( $success > 1 && empty( $notices[ 'errors' ] ) ) { |
|
2930 | + if ($success > 1 && empty($notices['errors'])) { |
|
2931 | 2931 | // set plural msg |
2932 | 2932 | EE_Error::add_success( |
2933 | 2933 | sprintf( |
2934 | - __( 'The "%s" have been successfully %s.', 'event_espresso' ), |
|
2934 | + __('The "%s" have been successfully %s.', 'event_espresso'), |
|
2935 | 2935 | $what, |
2936 | 2936 | $action_desc |
2937 | 2937 | ), |
2938 | 2938 | __FILE__, __FUNCTION__, __LINE__ |
2939 | 2939 | ); |
2940 | - } else if ( $success == 1 && empty( $notices[ 'errors' ] ) ) { |
|
2940 | + } else if ($success == 1 && empty($notices['errors'])) { |
|
2941 | 2941 | // set singular msg |
2942 | 2942 | EE_Error::add_success( |
2943 | 2943 | sprintf( |
2944 | - __( 'The "%s" has been successfully %s.', 'event_espresso' ), |
|
2944 | + __('The "%s" has been successfully %s.', 'event_espresso'), |
|
2945 | 2945 | $what, |
2946 | 2946 | $action_desc |
2947 | 2947 | ), |
@@ -2950,7 +2950,7 @@ discard block |
||
2950 | 2950 | } |
2951 | 2951 | } |
2952 | 2952 | // check that $query_args isn't something crazy |
2953 | - if ( ! is_array( $query_args )) { |
|
2953 | + if ( ! is_array($query_args)) { |
|
2954 | 2954 | $query_args = array(); |
2955 | 2955 | } |
2956 | 2956 | |
@@ -2963,36 +2963,36 @@ discard block |
||
2963 | 2963 | * @param array $query_args The original query_args array coming into the |
2964 | 2964 | * method. |
2965 | 2965 | */ |
2966 | - do_action( 'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args ); |
|
2966 | + do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args); |
|
2967 | 2967 | |
2968 | 2968 | //calculate where we're going (if we have a "save and close" button pushed) |
2969 | - if ( isset($this->_req_data['save_and_close'] ) && isset($this->_req_data['save_and_close_referrer'] ) ) { |
|
2969 | + if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
2970 | 2970 | // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
2971 | - $parsed_url = parse_url( $this->_req_data['save_and_close_referrer'] ); |
|
2971 | + $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
2972 | 2972 | // regenerate query args array from referrer URL |
2973 | - parse_str( $parsed_url['query'], $query_args ); |
|
2973 | + parse_str($parsed_url['query'], $query_args); |
|
2974 | 2974 | // correct page and action will be in the query args now |
2975 | - $redirect_url = admin_url( 'admin.php' ); |
|
2975 | + $redirect_url = admin_url('admin.php'); |
|
2976 | 2976 | } |
2977 | 2977 | |
2978 | 2978 | //merge any default query_args set in _default_route_query_args property |
2979 | - if ( ! empty( $this->_default_route_query_args ) && ! $this->_is_UI_request ) { |
|
2979 | + if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
2980 | 2980 | $args_to_merge = array(); |
2981 | - foreach ( $this->_default_route_query_args as $query_param => $query_value ) { |
|
2981 | + foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
2982 | 2982 | //is there a wp_referer array in our _default_route_query_args property? |
2983 | - if ( $query_param == 'wp_referer' ) { |
|
2983 | + if ($query_param == 'wp_referer') { |
|
2984 | 2984 | $query_value = (array) $query_value; |
2985 | - foreach ( $query_value as $reference => $value ) { |
|
2986 | - if ( strpos( $reference, 'nonce' ) !== false ) { |
|
2985 | + foreach ($query_value as $reference => $value) { |
|
2986 | + if (strpos($reference, 'nonce') !== false) { |
|
2987 | 2987 | continue; |
2988 | 2988 | } |
2989 | 2989 | |
2990 | 2990 | //finally we will override any arguments in the referer with |
2991 | 2991 | //what might be set on the _default_route_query_args array. |
2992 | - if ( isset( $this->_default_route_query_args[$reference] ) ) { |
|
2993 | - $args_to_merge[$reference] = urlencode( $this->_default_route_query_args[$reference] ); |
|
2992 | + if (isset($this->_default_route_query_args[$reference])) { |
|
2993 | + $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
2994 | 2994 | } else { |
2995 | - $args_to_merge[$reference] = urlencode( $value ); |
|
2995 | + $args_to_merge[$reference] = urlencode($value); |
|
2996 | 2996 | } |
2997 | 2997 | } |
2998 | 2998 | continue; |
@@ -3003,7 +3003,7 @@ discard block |
||
3003 | 3003 | |
3004 | 3004 | //now let's merge these arguments but override with what was specifically sent in to the |
3005 | 3005 | //redirect. |
3006 | - $query_args = array_merge( $args_to_merge, $query_args ); |
|
3006 | + $query_args = array_merge($args_to_merge, $query_args); |
|
3007 | 3007 | } |
3008 | 3008 | |
3009 | 3009 | $this->_process_notices($query_args); |
@@ -3012,19 +3012,19 @@ discard block |
||
3012 | 3012 | // generate redirect url |
3013 | 3013 | |
3014 | 3014 | // if redirecting to anything other than the main page, add a nonce |
3015 | - if ( isset( $query_args['action'] )) { |
|
3015 | + if (isset($query_args['action'])) { |
|
3016 | 3016 | // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
3017 | - $query_args['_wpnonce'] = wp_create_nonce( $query_args['action'] . '_nonce' ); |
|
3017 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
3018 | 3018 | } |
3019 | 3019 | |
3020 | 3020 | //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
3021 | - do_action( 'AHEE_redirect_' . $classname . $this->_req_action, $query_args ); |
|
3021 | + do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args); |
|
3022 | 3022 | |
3023 | - $redirect_url = apply_filters( 'FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce( $query_args, $redirect_url ), $query_args ); |
|
3023 | + $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
3024 | 3024 | |
3025 | 3025 | |
3026 | 3026 | // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
3027 | - if ( defined('DOING_AJAX' ) ) { |
|
3027 | + if (defined('DOING_AJAX')) { |
|
3028 | 3028 | $default_data = array( |
3029 | 3029 | 'close' => TRUE, |
3030 | 3030 | 'redirect_url' => $redirect_url, |
@@ -3033,11 +3033,11 @@ discard block |
||
3033 | 3033 | ); |
3034 | 3034 | |
3035 | 3035 | $this->_template_args['success'] = $success; |
3036 | - $this->_template_args['data'] = !empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data'] ): $default_data; |
|
3036 | + $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
3037 | 3037 | $this->_return_json(); |
3038 | 3038 | } |
3039 | 3039 | |
3040 | - wp_safe_redirect( $redirect_url ); |
|
3040 | + wp_safe_redirect($redirect_url); |
|
3041 | 3041 | exit(); |
3042 | 3042 | } |
3043 | 3043 | |
@@ -3053,30 +3053,30 @@ discard block |
||
3053 | 3053 | * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
3054 | 3054 | * @return void |
3055 | 3055 | */ |
3056 | - protected function _process_notices( $query_args = array(), $skip_route_verify = FALSE , $sticky_notices = TRUE ) { |
|
3056 | + protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE) { |
|
3057 | 3057 | |
3058 | 3058 | //first let's set individual error properties if doing_ajax and the properties aren't already set. |
3059 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
3060 | - $notices = EE_Error::get_notices( false ); |
|
3061 | - if ( empty( $this->_template_args['success'] ) ) { |
|
3062 | - $this->_template_args['success'] = isset( $notices['success'] ) ? $notices['success'] : false; |
|
3059 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
3060 | + $notices = EE_Error::get_notices(false); |
|
3061 | + if (empty($this->_template_args['success'])) { |
|
3062 | + $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
3063 | 3063 | } |
3064 | 3064 | |
3065 | - if ( empty( $this->_template_args['errors'] ) ) { |
|
3066 | - $this->_template_args['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : false; |
|
3065 | + if (empty($this->_template_args['errors'])) { |
|
3066 | + $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
3067 | 3067 | } |
3068 | 3068 | |
3069 | - if ( empty( $this->_template_args['attention'] ) ) { |
|
3070 | - $this->_template_args['attention'] = isset( $notices['attention'] ) ? $notices['attention'] : false; |
|
3069 | + if (empty($this->_template_args['attention'])) { |
|
3070 | + $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
3071 | 3071 | } |
3072 | 3072 | } |
3073 | 3073 | |
3074 | 3074 | $this->_template_args['notices'] = EE_Error::get_notices(); |
3075 | 3075 | |
3076 | 3076 | //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
3077 | - if ( ! defined( 'DOING_AJAX' ) || $sticky_notices ) { |
|
3078 | - $route = isset( $query_args['action'] ) ? $query_args['action'] : 'default'; |
|
3079 | - $this->_add_transient( $route, $this->_template_args['notices'], TRUE, $skip_route_verify ); |
|
3077 | + if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
3078 | + $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
3079 | + $this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify); |
|
3080 | 3080 | } |
3081 | 3081 | } |
3082 | 3082 | |
@@ -3106,7 +3106,7 @@ discard block |
||
3106 | 3106 | $exclude_nonce = false |
3107 | 3107 | ) { |
3108 | 3108 | //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
3109 | - if ( empty( $base_url ) && ! isset( $this->_page_routes[ $action ] ) ) { |
|
3109 | + if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
3110 | 3110 | throw new EE_Error( |
3111 | 3111 | sprintf( |
3112 | 3112 | __( |
@@ -3117,7 +3117,7 @@ discard block |
||
3117 | 3117 | ) |
3118 | 3118 | ); |
3119 | 3119 | } |
3120 | - if ( ! isset( $this->_labels['buttons'][ $type ] ) ) { |
|
3120 | + if ( ! isset($this->_labels['buttons'][$type])) { |
|
3121 | 3121 | throw new EE_Error( |
3122 | 3122 | sprintf( |
3123 | 3123 | __( |
@@ -3129,8 +3129,8 @@ discard block |
||
3129 | 3129 | ); |
3130 | 3130 | } |
3131 | 3131 | //finally check user access for this button. |
3132 | - $has_access = $this->check_user_access( $action, true ); |
|
3133 | - if ( ! $has_access ) { |
|
3132 | + $has_access = $this->check_user_access($action, true); |
|
3133 | + if ( ! $has_access) { |
|
3134 | 3134 | return ''; |
3135 | 3135 | } |
3136 | 3136 | $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
@@ -3138,11 +3138,11 @@ discard block |
||
3138 | 3138 | 'action' => $action |
3139 | 3139 | ); |
3140 | 3140 | //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
3141 | - if ( ! empty( $extra_request ) ) { |
|
3142 | - $query_args = array_merge( $extra_request, $query_args ); |
|
3141 | + if ( ! empty($extra_request)) { |
|
3142 | + $query_args = array_merge($extra_request, $query_args); |
|
3143 | 3143 | } |
3144 | - $url = self::add_query_args_and_nonce( $query_args, $_base_url, false, $exclude_nonce ); |
|
3145 | - return EEH_Template::get_button_or_link( $url, $this->_labels['buttons'][ $type ], $class ); |
|
3144 | + $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
3145 | + return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
3146 | 3146 | } |
3147 | 3147 | |
3148 | 3148 | |
@@ -3157,11 +3157,11 @@ discard block |
||
3157 | 3157 | $args = array( |
3158 | 3158 | 'label' => $this->_admin_page_title, |
3159 | 3159 | 'default' => 10, |
3160 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page' |
|
3160 | + 'option' => $this->_current_page.'_'.$this->_current_view.'_per_page' |
|
3161 | 3161 | ); |
3162 | 3162 | //ONLY add the screen option if the user has access to it. |
3163 | - if ( $this->check_user_access( $this->_current_view, true ) ) { |
|
3164 | - add_screen_option( $option, $args ); |
|
3163 | + if ($this->check_user_access($this->_current_view, true)) { |
|
3164 | + add_screen_option($option, $args); |
|
3165 | 3165 | } |
3166 | 3166 | } |
3167 | 3167 | |
@@ -3177,36 +3177,36 @@ discard block |
||
3177 | 3177 | * @return void |
3178 | 3178 | */ |
3179 | 3179 | private function _set_per_page_screen_options() { |
3180 | - if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
|
3181 | - check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
|
3180 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
3181 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
3182 | 3182 | |
3183 | - if ( !$user = wp_get_current_user() ) |
|
3183 | + if ( ! $user = wp_get_current_user()) |
|
3184 | 3184 | return; |
3185 | 3185 | $option = $_POST['wp_screen_options']['option']; |
3186 | 3186 | $value = $_POST['wp_screen_options']['value']; |
3187 | 3187 | |
3188 | - if ( $option != sanitize_key( $option ) ) |
|
3188 | + if ($option != sanitize_key($option)) |
|
3189 | 3189 | return; |
3190 | 3190 | |
3191 | 3191 | $map_option = $option; |
3192 | 3192 | |
3193 | 3193 | $option = str_replace('-', '_', $option); |
3194 | 3194 | |
3195 | - switch ( $map_option ) { |
|
3196 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
3195 | + switch ($map_option) { |
|
3196 | + case $this->_current_page.'_'.$this->_current_view.'_per_page': |
|
3197 | 3197 | $value = (int) $value; |
3198 | - if ( $value < 1 || $value > 999 ) |
|
3198 | + if ($value < 1 || $value > 999) |
|
3199 | 3199 | return; |
3200 | 3200 | break; |
3201 | 3201 | default: |
3202 | - $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
|
3203 | - if ( false === $value ) |
|
3202 | + $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
3203 | + if (false === $value) |
|
3204 | 3204 | return; |
3205 | 3205 | break; |
3206 | 3206 | } |
3207 | 3207 | |
3208 | 3208 | update_user_meta($user->ID, $option, $value); |
3209 | - wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) ); |
|
3209 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
3210 | 3210 | exit; |
3211 | 3211 | } |
3212 | 3212 | } |
@@ -3217,8 +3217,8 @@ discard block |
||
3217 | 3217 | * This just allows for setting the $_template_args property if it needs to be set outside the object |
3218 | 3218 | * @param array $data array that will be assigned to template args. |
3219 | 3219 | */ |
3220 | - public function set_template_args( $data ) { |
|
3221 | - $this->_template_args = array_merge( $this->_template_args, (array) $data ); |
|
3220 | + public function set_template_args($data) { |
|
3221 | + $this->_template_args = array_merge($this->_template_args, (array) $data); |
|
3222 | 3222 | } |
3223 | 3223 | |
3224 | 3224 | |
@@ -3234,26 +3234,26 @@ discard block |
||
3234 | 3234 | * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
3235 | 3235 | * @return void |
3236 | 3236 | */ |
3237 | - protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
|
3237 | + protected function _add_transient($route, $data, $notices = FALSE, $skip_route_verify = FALSE) { |
|
3238 | 3238 | $user_id = get_current_user_id(); |
3239 | 3239 | |
3240 | - if ( !$skip_route_verify ) |
|
3240 | + if ( ! $skip_route_verify) |
|
3241 | 3241 | $this->_verify_route($route); |
3242 | 3242 | |
3243 | 3243 | |
3244 | 3244 | //now let's set the string for what kind of transient we're setting |
3245 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3246 | - $data = $notices ? array( 'notices' => $data ) : $data; |
|
3245 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3246 | + $data = $notices ? array('notices' => $data) : $data; |
|
3247 | 3247 | //is there already a transient for this route? If there is then let's ADD to that transient |
3248 | - $existing = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
3249 | - if ( $existing ) { |
|
3250 | - $data = array_merge( (array) $data, (array) $existing ); |
|
3248 | + $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3249 | + if ($existing) { |
|
3250 | + $data = array_merge((array) $data, (array) $existing); |
|
3251 | 3251 | } |
3252 | 3252 | |
3253 | - if ( is_multisite() && is_network_admin() ) { |
|
3254 | - set_site_transient( $transient, $data, 8 ); |
|
3253 | + if (is_multisite() && is_network_admin()) { |
|
3254 | + set_site_transient($transient, $data, 8); |
|
3255 | 3255 | } else { |
3256 | - set_transient( $transient, $data, 8 ); |
|
3256 | + set_transient($transient, $data, 8); |
|
3257 | 3257 | } |
3258 | 3258 | } |
3259 | 3259 | |
@@ -3265,18 +3265,18 @@ discard block |
||
3265 | 3265 | * @param bool $notices true we get notices transient. False we just return normal route transient |
3266 | 3266 | * @return mixed data |
3267 | 3267 | */ |
3268 | - protected function _get_transient( $notices = FALSE, $route = FALSE ) { |
|
3268 | + protected function _get_transient($notices = FALSE, $route = FALSE) { |
|
3269 | 3269 | $user_id = get_current_user_id(); |
3270 | - $route = !$route ? $this->_req_action : $route; |
|
3271 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3272 | - $data = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient ); |
|
3270 | + $route = ! $route ? $this->_req_action : $route; |
|
3271 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3272 | + $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3273 | 3273 | //delete transient after retrieval (just in case it hasn't expired); |
3274 | - if ( is_multisite() && is_network_admin() ) { |
|
3275 | - delete_site_transient( $transient ); |
|
3274 | + if (is_multisite() && is_network_admin()) { |
|
3275 | + delete_site_transient($transient); |
|
3276 | 3276 | } else { |
3277 | - delete_transient( $transient ); |
|
3277 | + delete_transient($transient); |
|
3278 | 3278 | } |
3279 | - return $notices && isset( $data['notices'] ) ? $data['notices'] : $data; |
|
3279 | + return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
3280 | 3280 | } |
3281 | 3281 | |
3282 | 3282 | |
@@ -3293,12 +3293,12 @@ discard block |
||
3293 | 3293 | |
3294 | 3294 | //retrieve all existing transients |
3295 | 3295 | $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
3296 | - if ( $results = $wpdb->get_results( $query ) ) { |
|
3297 | - foreach ( $results as $result ) { |
|
3298 | - $transient = str_replace( '_transient_', '', $result->option_name ); |
|
3299 | - get_transient( $transient ); |
|
3300 | - if ( is_multisite() && is_network_admin() ) { |
|
3301 | - get_site_transient( $transient ); |
|
3296 | + if ($results = $wpdb->get_results($query)) { |
|
3297 | + foreach ($results as $result) { |
|
3298 | + $transient = str_replace('_transient_', '', $result->option_name); |
|
3299 | + get_transient($transient); |
|
3300 | + if (is_multisite() && is_network_admin()) { |
|
3301 | + get_site_transient($transient); |
|
3302 | 3302 | } |
3303 | 3303 | } |
3304 | 3304 | } |
@@ -3448,23 +3448,23 @@ discard block |
||
3448 | 3448 | * @param string $line line no where error occurred |
3449 | 3449 | * @return boolean |
3450 | 3450 | */ |
3451 | - protected function _update_espresso_configuration( $tab, $config, $file = '', $func = '', $line = '' ) { |
|
3451 | + protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') { |
|
3452 | 3452 | |
3453 | 3453 | //remove any options that are NOT going to be saved with the config settings. |
3454 | - if ( isset( $config->core->ee_ueip_optin ) ) { |
|
3454 | + if (isset($config->core->ee_ueip_optin)) { |
|
3455 | 3455 | $config->core->ee_ueip_has_notified = TRUE; |
3456 | 3456 | // TODO: remove the following two lines and make sure values are migrated from 3.1 |
3457 | - update_option( 'ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3458 | - update_option( 'ee_ueip_has_notified', TRUE ); |
|
3457 | + update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3458 | + update_option('ee_ueip_has_notified', TRUE); |
|
3459 | 3459 | } |
3460 | 3460 | // and save it (note we're also doing the network save here) |
3461 | - $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config( FALSE, FALSE ) : TRUE; |
|
3462 | - $config_saved = EE_Config::instance()->update_espresso_config( FALSE, FALSE ); |
|
3463 | - if ( $config_saved && $net_saved ) { |
|
3464 | - EE_Error::add_success( sprintf( __('"%s" have been successfully updated.', 'event_espresso'), $tab )); |
|
3461 | + $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(FALSE, FALSE) : TRUE; |
|
3462 | + $config_saved = EE_Config::instance()->update_espresso_config(FALSE, FALSE); |
|
3463 | + if ($config_saved && $net_saved) { |
|
3464 | + EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
3465 | 3465 | return TRUE; |
3466 | 3466 | } else { |
3467 | - EE_Error::add_error( sprintf( __('The "%s" were not updated.', 'event_espresso'), $tab ), $file, $func, $line ); |
|
3467 | + EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
3468 | 3468 | return FALSE; |
3469 | 3469 | } |
3470 | 3470 | } |
@@ -3477,7 +3477,7 @@ discard block |
||
3477 | 3477 | * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
3478 | 3478 | * @return array |
3479 | 3479 | */ |
3480 | - public function get_yes_no_values(){ |
|
3480 | + public function get_yes_no_values() { |
|
3481 | 3481 | return $this->_yes_no_values; |
3482 | 3482 | } |
3483 | 3483 | |
@@ -3499,8 +3499,8 @@ discard block |
||
3499 | 3499 | * |
3500 | 3500 | * @return string |
3501 | 3501 | */ |
3502 | - protected function _next_link( $url, $class = 'dashicons dashicons-arrow-right' ) { |
|
3503 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3502 | + protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') { |
|
3503 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3504 | 3504 | } |
3505 | 3505 | |
3506 | 3506 | |
@@ -3514,8 +3514,8 @@ discard block |
||
3514 | 3514 | * |
3515 | 3515 | * @return string |
3516 | 3516 | */ |
3517 | - protected function _previous_link( $url, $class = 'dashicons dashicons-arrow-left' ) { |
|
3518 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3517 | + protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') { |
|
3518 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3519 | 3519 | } |
3520 | 3520 | |
3521 | 3521 | |
@@ -3534,8 +3534,8 @@ discard block |
||
3534 | 3534 | * @return bool success/fail |
3535 | 3535 | */ |
3536 | 3536 | protected function _process_resend_registration() { |
3537 | - $this->_template_args['success'] = EED_Messages::process_resend( $this->_req_data ); |
|
3538 | - do_action( 'AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data ); |
|
3537 | + $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
3538 | + do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
3539 | 3539 | return $this->_template_args['success']; |
3540 | 3540 | } |
3541 | 3541 | |
@@ -3548,11 +3548,11 @@ discard block |
||
3548 | 3548 | * @param \EE_Payment $payment |
3549 | 3549 | * @return bool success/fail |
3550 | 3550 | */ |
3551 | - protected function _process_payment_notification( EE_Payment $payment ) { |
|
3552 | - add_filter( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true' ); |
|
3553 | - do_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', $payment ); |
|
3554 | - $this->_template_args['success'] = apply_filters( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment ); |
|
3555 | - return $this->_template_args[ 'success' ]; |
|
3551 | + protected function _process_payment_notification(EE_Payment $payment) { |
|
3552 | + add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
3553 | + do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
3554 | + $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
3555 | + return $this->_template_args['success']; |
|
3556 | 3556 | } |
3557 | 3557 | |
3558 | 3558 |