@@ -1,9 +1,9 @@ |
||
1 | 1 | <div id="espresso-ajax-loading" style="display:none;"> |
2 | 2 | <span class="ee-spinner ee-spin"></span><span style="display:none;"> |
3 | 3 | <?php _e( |
4 | - 'loading...', |
|
5 | - 'event_espresso' |
|
6 | - ); ?></span> |
|
4 | + 'loading...', |
|
5 | + 'event_espresso' |
|
6 | + ); ?></span> |
|
7 | 7 | </div> |
8 | 8 | |
9 | 9 | <div id="espresso-ajax-notices"> |
@@ -14,78 +14,78 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * load_espresso_addons |
|
19 | - * runs during the WP 'plugins_loaded' action at priority 1 |
|
20 | - * and is the initial loading phase for EE addons |
|
21 | - * no other logic should be performed at this point |
|
22 | - */ |
|
23 | - public static function load_espresso_addons() |
|
24 | - { |
|
25 | - do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
26 | - } |
|
17 | + /** |
|
18 | + * load_espresso_addons |
|
19 | + * runs during the WP 'plugins_loaded' action at priority 1 |
|
20 | + * and is the initial loading phase for EE addons |
|
21 | + * no other logic should be performed at this point |
|
22 | + */ |
|
23 | + public static function load_espresso_addons() |
|
24 | + { |
|
25 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * detect_activations_or_upgrades |
|
31 | - * runs during the WP 'plugins_loaded' action at priority 3 |
|
32 | - * Now that all of the addons have been loaded, |
|
33 | - * we can determine if anything needs activating or upgrading |
|
34 | - */ |
|
35 | - public static function detect_activations_or_upgrades() |
|
36 | - { |
|
37 | - do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
38 | - } |
|
29 | + /** |
|
30 | + * detect_activations_or_upgrades |
|
31 | + * runs during the WP 'plugins_loaded' action at priority 3 |
|
32 | + * Now that all of the addons have been loaded, |
|
33 | + * we can determine if anything needs activating or upgrading |
|
34 | + */ |
|
35 | + public static function detect_activations_or_upgrades() |
|
36 | + { |
|
37 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * load_core_configuration |
|
43 | - * runs during the WP 'plugins_loaded' action at priority 5 |
|
44 | - * Now that the database is assumed to be at the correct version |
|
45 | - * we can load and set all of the system configurations |
|
46 | - */ |
|
47 | - public static function load_core_configuration() |
|
48 | - { |
|
49 | - do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
50 | - } |
|
41 | + /** |
|
42 | + * load_core_configuration |
|
43 | + * runs during the WP 'plugins_loaded' action at priority 5 |
|
44 | + * Now that the database is assumed to be at the correct version |
|
45 | + * we can load and set all of the system configurations |
|
46 | + */ |
|
47 | + public static function load_core_configuration() |
|
48 | + { |
|
49 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * register_shortcodes_modules_and_widgets |
|
55 | - * runs during the WP 'plugins_loaded' action at priority 7 |
|
56 | - * and handles registering all o four shortcodes, modules and widgets |
|
57 | - * so that they are ready to be used throughout the system |
|
58 | - */ |
|
59 | - public static function register_shortcodes_modules_and_widgets() |
|
60 | - { |
|
61 | - do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
62 | - } |
|
53 | + /** |
|
54 | + * register_shortcodes_modules_and_widgets |
|
55 | + * runs during the WP 'plugins_loaded' action at priority 7 |
|
56 | + * and handles registering all o four shortcodes, modules and widgets |
|
57 | + * so that they are ready to be used throughout the system |
|
58 | + */ |
|
59 | + public static function register_shortcodes_modules_and_widgets() |
|
60 | + { |
|
61 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * brew_espresso |
|
67 | - * runs during the WP 'plugins_loaded' action at priority 9 |
|
68 | - * bootstrapping is considered complete at this point, |
|
69 | - * so let the fun begin... |
|
70 | - */ |
|
71 | - public static function brew_espresso() |
|
72 | - { |
|
73 | - do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
74 | - } |
|
65 | + /** |
|
66 | + * brew_espresso |
|
67 | + * runs during the WP 'plugins_loaded' action at priority 9 |
|
68 | + * bootstrapping is considered complete at this point, |
|
69 | + * so let the fun begin... |
|
70 | + */ |
|
71 | + public static function brew_espresso() |
|
72 | + { |
|
73 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @deprecated 4.9.53 |
|
79 | - */ |
|
80 | - public function run_request_stack() |
|
81 | - { |
|
82 | - } |
|
77 | + /** |
|
78 | + * @deprecated 4.9.53 |
|
79 | + */ |
|
80 | + public function run_request_stack() |
|
81 | + { |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @deprecated 4.9.53 |
|
87 | - */ |
|
88 | - public function build_request_stack() |
|
89 | - { |
|
90 | - } |
|
85 | + /** |
|
86 | + * @deprecated 4.9.53 |
|
87 | + */ |
|
88 | + public function build_request_stack() |
|
89 | + { |
|
90 | + } |
|
91 | 91 | } |
@@ -13,268 +13,268 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * holds the template |
|
18 | - * |
|
19 | - * @access private |
|
20 | - * @var mixed (string|array) |
|
21 | - */ |
|
22 | - private $_template; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * holds the incoming data object |
|
27 | - * |
|
28 | - * @access private |
|
29 | - * @var object |
|
30 | - */ |
|
31 | - private $_data; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * will hold an array of EE_Shortcodes library objects. |
|
36 | - * |
|
37 | - * @access private |
|
38 | - * @var EE_Shortcodes[] |
|
39 | - */ |
|
40 | - private $_shortcode_objs = array(); |
|
41 | - |
|
42 | - |
|
43 | - public function __construct() |
|
44 | - { |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * This kicks off the parsing of shortcodes in message templates |
|
50 | - * |
|
51 | - * @param string $template This is the incoming string to be parsed |
|
52 | - * @param EE_Messages_Addressee $data This is the incoming data object |
|
53 | - * @param array $valid_shortcodes An array of strings that correspond to EE_Shortcode libraries |
|
54 | - * @param EE_message_type $message_type The message type that called the parser |
|
55 | - * @param EE_messenger $messenger The active messenger for this parsing session. |
|
56 | - * @param EE_Message $message |
|
57 | - * @return string The parsed template string |
|
58 | - */ |
|
59 | - public function parse_message_template( |
|
60 | - $template, |
|
61 | - EE_Messages_Addressee $data, |
|
62 | - $valid_shortcodes, |
|
63 | - EE_message_type $message_type, |
|
64 | - EE_messenger $messenger, |
|
65 | - EE_Message $message |
|
66 | - ) { |
|
67 | - $extra_data = array( |
|
68 | - 'messenger' => $messenger, |
|
69 | - 'message_type' => $message_type, |
|
70 | - 'message' => $message, |
|
71 | - ); |
|
72 | - $this->_init_data($template, $data, $valid_shortcodes, $extra_data); |
|
73 | - $this->_template = is_array($template) ? $template['main'] : $template; |
|
74 | - return $this->_parse_message_template(); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - public function parse_attendee_list_template( |
|
79 | - $template, |
|
80 | - EE_Registration $registration, |
|
81 | - $valid_shortcodes, |
|
82 | - $extra_data = array() |
|
83 | - ) { |
|
84 | - $this->_init_data($template, $registration, $valid_shortcodes, $extra_data); |
|
85 | - $this->_template = is_array($template) ? $template['attendee_list'] : $template; |
|
86 | - return $this->_parse_message_template(); |
|
87 | - } |
|
88 | - |
|
89 | - public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) |
|
90 | - { |
|
91 | - $this->_init_data($template, $event, $valid_shortcodes, $extra_data); |
|
92 | - $this->_template = is_array($template) ? $template['event_list'] : $template; |
|
93 | - return $this->_parse_message_template(); |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) |
|
98 | - { |
|
99 | - $this->_init_data($template, $ticket, $valid_shortcodes, $extra_data); |
|
100 | - $this->_template = is_array($template) ? $template['ticket_list'] : $template; |
|
101 | - return $this->_parse_message_template(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - public function parse_line_item_list_template( |
|
106 | - $template, |
|
107 | - EE_Line_Item $line_item, |
|
108 | - $valid_shortcodes, |
|
109 | - $extra_data = array() |
|
110 | - ) { |
|
111 | - $this->_init_data($template, $line_item, $valid_shortcodes, $extra_data); |
|
112 | - $this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template; |
|
113 | - return $this->_parse_message_template(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - public function parse_payment_list_template( |
|
118 | - $template, |
|
119 | - EE_Payment $payment_item, |
|
120 | - $valid_shortcodes, |
|
121 | - $extra_data = array() |
|
122 | - ) { |
|
123 | - $this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data); |
|
124 | - $this->_template = is_array($template) ? $template['payment_list'] : $template; |
|
125 | - return $this->_parse_message_template(); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - public function parse_datetime_list_template( |
|
130 | - $template, |
|
131 | - EE_Datetime $datetime, |
|
132 | - $valid_shortcodes, |
|
133 | - $extra_data = array() |
|
134 | - ) { |
|
135 | - $this->_init_data($template, $datetime, $valid_shortcodes, $extra_data); |
|
136 | - $this->_template = is_array($template) ? $template['datetime_list'] : $template; |
|
137 | - return $this->_parse_message_template(); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) |
|
142 | - { |
|
143 | - $this->_init_data($template, $answer, $valid_shortcodes, $extra_data); |
|
144 | - $this->_template = is_array($template) ? $template['question_list'] : $template; |
|
145 | - return $this->_parse_message_template(); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) |
|
150 | - { |
|
151 | - $this->_reset_props(); |
|
152 | - $this->_data['template'] = $template; |
|
153 | - $this->_data['data'] = $data; |
|
154 | - $this->_data['extra_data'] = $extra_data; |
|
155 | - $this->_set_shortcodes($valid_shortcodes); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - private function _reset_props() |
|
160 | - { |
|
161 | - $this->_template = $this->_data = null; |
|
162 | - $this->_shortcode_objs = array(); |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * takes the given template and parses it with the $_shortcodes property |
|
168 | - * |
|
169 | - * @access private |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - private function _parse_message_template() |
|
173 | - { |
|
174 | - // now let's get a list of shortcodes that are found in the given template |
|
175 | - preg_match_all('/(\[.+?\])/', $this->_template, $matches); |
|
176 | - $shortcodes = (array) $matches[0]; // this should be an array of shortcodes in the template string. |
|
177 | - |
|
178 | - $matched_code = array(); |
|
179 | - $sc_values = array(); |
|
180 | - |
|
181 | - $list_type_shortcodes = array( |
|
182 | - '[ATTENDEE_LIST]', |
|
183 | - '[EVENT_LIST]', |
|
184 | - '[TICKET_LIST]', |
|
185 | - '[DATETIME_LIST]', |
|
186 | - '[QUESTION_LIST]', |
|
187 | - '[RECIPIENT_QUESTION_LIST]', |
|
188 | - '[PRIMARY_REGISTRANT_QUESTION_LIST]', |
|
189 | - '[RECIPIENT_TICKET_LIST]', |
|
190 | - '[PRIMARY_REGISTRANT_TICKET_LIST]', |
|
191 | - '[RECIPIENT_DATETIME_LIST]', |
|
192 | - '[PRIMARY_REGISTRANT_DATETIME_LIST]', |
|
193 | - '[TICKET_LINE_ITEM_LIST]', |
|
194 | - '[TAX_LINE_ITEM_LIST]', |
|
195 | - '[ADDITIONAL_LINE_ITEM_LIST]', |
|
196 | - '[PRICE_MODIFIER_LINE_ITEM_LIST]', |
|
197 | - '[PAYMENT_LIST_*]', |
|
198 | - ); |
|
199 | - |
|
200 | - $list_type_shortcodes = apply_filters( |
|
201 | - 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
202 | - $list_type_shortcodes |
|
203 | - ); |
|
204 | - |
|
205 | - // now lets go ahead and loop through our parsers for each shortcode and setup the values |
|
206 | - foreach ($shortcodes as $shortcode) { |
|
207 | - foreach ($this->_shortcode_objs as $sc_obj) { |
|
208 | - if ($sc_obj instanceof EE_Shortcodes) { |
|
209 | - // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
|
210 | - preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
211 | - $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
212 | - |
|
213 | - if (! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
214 | - continue; // the given shortcode isn't in this object |
|
215 | - } |
|
216 | - |
|
217 | - // if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
|
218 | - if (! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
219 | - $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
220 | - } else { |
|
221 | - $data_send = $this->_data; |
|
222 | - } |
|
223 | - |
|
224 | - // is this a conditional type shortcode? If it is then we actually parse the template here. |
|
225 | - if ($this->_is_conditional_shortcode($shortcode)) { |
|
226 | - // most shortcode parsers are not going to have a match for this shortcode and will return an |
|
227 | - // empty string so we need to make sure that we're only replacing the template when there is a non empty string. |
|
228 | - $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
229 | - if ($parsed) { |
|
230 | - $this->_template = $parsed; |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
235 | - |
|
236 | - $matched_code[] = $shortcode; |
|
237 | - $sc_values[] = $parsed; |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - // now we've got parsed values for all the shortcodes in the template so we can go ahead and swap the shortcodes out. |
|
243 | - $parsed = str_replace(array_values($matched_code), array_values($sc_values), $this->_template); |
|
244 | - return $parsed; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * Simply returns whether the given shortcode matches the structure for a conditional shortcode. |
|
250 | - * |
|
251 | - * Does it match this format: `[IF_` |
|
252 | - * |
|
253 | - * @param $shortcode |
|
254 | - */ |
|
255 | - protected function _is_conditional_shortcode($shortcode) |
|
256 | - { |
|
257 | - return strpos($shortcode, '[IF_') === 0; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * This sets the shortcodes property from the incoming array of valid shortcodes that corresponds to names of |
|
263 | - * various EE_Shortcode library objects |
|
264 | - * |
|
265 | - * @access private |
|
266 | - * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects |
|
267 | - * @return void |
|
268 | - */ |
|
269 | - private function _set_shortcodes($valid_shortcodes) |
|
270 | - { |
|
271 | - foreach ($valid_shortcodes as $shortcode_ref) { |
|
272 | - $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
|
273 | - $ref = str_replace(' ', '_', $ref); |
|
274 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
275 | - if (class_exists($classname)) { |
|
276 | - $this->_shortcode_objs[] = new $classname; |
|
277 | - } |
|
278 | - } |
|
279 | - } |
|
16 | + /** |
|
17 | + * holds the template |
|
18 | + * |
|
19 | + * @access private |
|
20 | + * @var mixed (string|array) |
|
21 | + */ |
|
22 | + private $_template; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * holds the incoming data object |
|
27 | + * |
|
28 | + * @access private |
|
29 | + * @var object |
|
30 | + */ |
|
31 | + private $_data; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * will hold an array of EE_Shortcodes library objects. |
|
36 | + * |
|
37 | + * @access private |
|
38 | + * @var EE_Shortcodes[] |
|
39 | + */ |
|
40 | + private $_shortcode_objs = array(); |
|
41 | + |
|
42 | + |
|
43 | + public function __construct() |
|
44 | + { |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * This kicks off the parsing of shortcodes in message templates |
|
50 | + * |
|
51 | + * @param string $template This is the incoming string to be parsed |
|
52 | + * @param EE_Messages_Addressee $data This is the incoming data object |
|
53 | + * @param array $valid_shortcodes An array of strings that correspond to EE_Shortcode libraries |
|
54 | + * @param EE_message_type $message_type The message type that called the parser |
|
55 | + * @param EE_messenger $messenger The active messenger for this parsing session. |
|
56 | + * @param EE_Message $message |
|
57 | + * @return string The parsed template string |
|
58 | + */ |
|
59 | + public function parse_message_template( |
|
60 | + $template, |
|
61 | + EE_Messages_Addressee $data, |
|
62 | + $valid_shortcodes, |
|
63 | + EE_message_type $message_type, |
|
64 | + EE_messenger $messenger, |
|
65 | + EE_Message $message |
|
66 | + ) { |
|
67 | + $extra_data = array( |
|
68 | + 'messenger' => $messenger, |
|
69 | + 'message_type' => $message_type, |
|
70 | + 'message' => $message, |
|
71 | + ); |
|
72 | + $this->_init_data($template, $data, $valid_shortcodes, $extra_data); |
|
73 | + $this->_template = is_array($template) ? $template['main'] : $template; |
|
74 | + return $this->_parse_message_template(); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + public function parse_attendee_list_template( |
|
79 | + $template, |
|
80 | + EE_Registration $registration, |
|
81 | + $valid_shortcodes, |
|
82 | + $extra_data = array() |
|
83 | + ) { |
|
84 | + $this->_init_data($template, $registration, $valid_shortcodes, $extra_data); |
|
85 | + $this->_template = is_array($template) ? $template['attendee_list'] : $template; |
|
86 | + return $this->_parse_message_template(); |
|
87 | + } |
|
88 | + |
|
89 | + public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) |
|
90 | + { |
|
91 | + $this->_init_data($template, $event, $valid_shortcodes, $extra_data); |
|
92 | + $this->_template = is_array($template) ? $template['event_list'] : $template; |
|
93 | + return $this->_parse_message_template(); |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) |
|
98 | + { |
|
99 | + $this->_init_data($template, $ticket, $valid_shortcodes, $extra_data); |
|
100 | + $this->_template = is_array($template) ? $template['ticket_list'] : $template; |
|
101 | + return $this->_parse_message_template(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + public function parse_line_item_list_template( |
|
106 | + $template, |
|
107 | + EE_Line_Item $line_item, |
|
108 | + $valid_shortcodes, |
|
109 | + $extra_data = array() |
|
110 | + ) { |
|
111 | + $this->_init_data($template, $line_item, $valid_shortcodes, $extra_data); |
|
112 | + $this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template; |
|
113 | + return $this->_parse_message_template(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + public function parse_payment_list_template( |
|
118 | + $template, |
|
119 | + EE_Payment $payment_item, |
|
120 | + $valid_shortcodes, |
|
121 | + $extra_data = array() |
|
122 | + ) { |
|
123 | + $this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data); |
|
124 | + $this->_template = is_array($template) ? $template['payment_list'] : $template; |
|
125 | + return $this->_parse_message_template(); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + public function parse_datetime_list_template( |
|
130 | + $template, |
|
131 | + EE_Datetime $datetime, |
|
132 | + $valid_shortcodes, |
|
133 | + $extra_data = array() |
|
134 | + ) { |
|
135 | + $this->_init_data($template, $datetime, $valid_shortcodes, $extra_data); |
|
136 | + $this->_template = is_array($template) ? $template['datetime_list'] : $template; |
|
137 | + return $this->_parse_message_template(); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) |
|
142 | + { |
|
143 | + $this->_init_data($template, $answer, $valid_shortcodes, $extra_data); |
|
144 | + $this->_template = is_array($template) ? $template['question_list'] : $template; |
|
145 | + return $this->_parse_message_template(); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) |
|
150 | + { |
|
151 | + $this->_reset_props(); |
|
152 | + $this->_data['template'] = $template; |
|
153 | + $this->_data['data'] = $data; |
|
154 | + $this->_data['extra_data'] = $extra_data; |
|
155 | + $this->_set_shortcodes($valid_shortcodes); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + private function _reset_props() |
|
160 | + { |
|
161 | + $this->_template = $this->_data = null; |
|
162 | + $this->_shortcode_objs = array(); |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * takes the given template and parses it with the $_shortcodes property |
|
168 | + * |
|
169 | + * @access private |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + private function _parse_message_template() |
|
173 | + { |
|
174 | + // now let's get a list of shortcodes that are found in the given template |
|
175 | + preg_match_all('/(\[.+?\])/', $this->_template, $matches); |
|
176 | + $shortcodes = (array) $matches[0]; // this should be an array of shortcodes in the template string. |
|
177 | + |
|
178 | + $matched_code = array(); |
|
179 | + $sc_values = array(); |
|
180 | + |
|
181 | + $list_type_shortcodes = array( |
|
182 | + '[ATTENDEE_LIST]', |
|
183 | + '[EVENT_LIST]', |
|
184 | + '[TICKET_LIST]', |
|
185 | + '[DATETIME_LIST]', |
|
186 | + '[QUESTION_LIST]', |
|
187 | + '[RECIPIENT_QUESTION_LIST]', |
|
188 | + '[PRIMARY_REGISTRANT_QUESTION_LIST]', |
|
189 | + '[RECIPIENT_TICKET_LIST]', |
|
190 | + '[PRIMARY_REGISTRANT_TICKET_LIST]', |
|
191 | + '[RECIPIENT_DATETIME_LIST]', |
|
192 | + '[PRIMARY_REGISTRANT_DATETIME_LIST]', |
|
193 | + '[TICKET_LINE_ITEM_LIST]', |
|
194 | + '[TAX_LINE_ITEM_LIST]', |
|
195 | + '[ADDITIONAL_LINE_ITEM_LIST]', |
|
196 | + '[PRICE_MODIFIER_LINE_ITEM_LIST]', |
|
197 | + '[PAYMENT_LIST_*]', |
|
198 | + ); |
|
199 | + |
|
200 | + $list_type_shortcodes = apply_filters( |
|
201 | + 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
202 | + $list_type_shortcodes |
|
203 | + ); |
|
204 | + |
|
205 | + // now lets go ahead and loop through our parsers for each shortcode and setup the values |
|
206 | + foreach ($shortcodes as $shortcode) { |
|
207 | + foreach ($this->_shortcode_objs as $sc_obj) { |
|
208 | + if ($sc_obj instanceof EE_Shortcodes) { |
|
209 | + // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
|
210 | + preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
211 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
212 | + |
|
213 | + if (! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
214 | + continue; // the given shortcode isn't in this object |
|
215 | + } |
|
216 | + |
|
217 | + // if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
|
218 | + if (! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
219 | + $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
|
220 | + } else { |
|
221 | + $data_send = $this->_data; |
|
222 | + } |
|
223 | + |
|
224 | + // is this a conditional type shortcode? If it is then we actually parse the template here. |
|
225 | + if ($this->_is_conditional_shortcode($shortcode)) { |
|
226 | + // most shortcode parsers are not going to have a match for this shortcode and will return an |
|
227 | + // empty string so we need to make sure that we're only replacing the template when there is a non empty string. |
|
228 | + $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
229 | + if ($parsed) { |
|
230 | + $this->_template = $parsed; |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + $parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']); |
|
235 | + |
|
236 | + $matched_code[] = $shortcode; |
|
237 | + $sc_values[] = $parsed; |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + // now we've got parsed values for all the shortcodes in the template so we can go ahead and swap the shortcodes out. |
|
243 | + $parsed = str_replace(array_values($matched_code), array_values($sc_values), $this->_template); |
|
244 | + return $parsed; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * Simply returns whether the given shortcode matches the structure for a conditional shortcode. |
|
250 | + * |
|
251 | + * Does it match this format: `[IF_` |
|
252 | + * |
|
253 | + * @param $shortcode |
|
254 | + */ |
|
255 | + protected function _is_conditional_shortcode($shortcode) |
|
256 | + { |
|
257 | + return strpos($shortcode, '[IF_') === 0; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * This sets the shortcodes property from the incoming array of valid shortcodes that corresponds to names of |
|
263 | + * various EE_Shortcode library objects |
|
264 | + * |
|
265 | + * @access private |
|
266 | + * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects |
|
267 | + * @return void |
|
268 | + */ |
|
269 | + private function _set_shortcodes($valid_shortcodes) |
|
270 | + { |
|
271 | + foreach ($valid_shortcodes as $shortcode_ref) { |
|
272 | + $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
|
273 | + $ref = str_replace(' ', '_', $ref); |
|
274 | + $classname = 'EE_' . $ref . '_Shortcodes'; |
|
275 | + if (class_exists($classname)) { |
|
276 | + $this->_shortcode_objs[] = new $classname; |
|
277 | + } |
|
278 | + } |
|
279 | + } |
|
280 | 280 | } |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | if ($sc_obj instanceof EE_Shortcodes) { |
209 | 209 | // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
210 | 210 | preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
211 | - $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
211 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
212 | 212 | |
213 | - if (! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
213 | + if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) { |
|
214 | 214 | continue; // the given shortcode isn't in this object |
215 | 215 | } |
216 | 216 | |
217 | 217 | // if this isn't a "list" type shortcode then we'll send along the data vanilla instead of in an array. |
218 | - if (! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
218 | + if ( ! in_array($sc_to_verify, $list_type_shortcodes)) { |
|
219 | 219 | $data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data; |
220 | 220 | } else { |
221 | 221 | $data_send = $this->_data; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | foreach ($valid_shortcodes as $shortcode_ref) { |
272 | 272 | $ref = ucwords(str_replace('_', ' ', $shortcode_ref)); |
273 | 273 | $ref = str_replace(' ', '_', $ref); |
274 | - $classname = 'EE_' . $ref . '_Shortcodes'; |
|
274 | + $classname = 'EE_'.$ref.'_Shortcodes'; |
|
275 | 275 | if (class_exists($classname)) { |
276 | 276 | $this->_shortcode_objs[] = new $classname; |
277 | 277 | } |
@@ -13,124 +13,124 @@ |
||
13 | 13 | |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * format - output formatted EE object address information |
|
18 | - * |
|
19 | - * @access public |
|
20 | - * @param object EEI_Address $obj_with_address |
|
21 | - * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
22 | - * @param boolean $use_schema whether to apply schema.org formatting to the address |
|
23 | - * @param bool $add_wrapper |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public static function format( |
|
27 | - $obj_with_address = null, |
|
28 | - $type = 'multiline', |
|
29 | - $use_schema = true, |
|
30 | - $add_wrapper = true |
|
31 | - ) { |
|
32 | - // check that incoming object implements the EEI_Address interface |
|
33 | - if (! $obj_with_address instanceof EEI_Address) { |
|
34 | - $msg = __('The address could not be formatted.', 'event_espresso'); |
|
35 | - $dev_msg = __( |
|
36 | - 'The Address Formatter requires passed objects to implement the EEI_Address interface.', |
|
37 | - 'event_espresso' |
|
38 | - ); |
|
39 | - EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
40 | - return null; |
|
41 | - } |
|
42 | - // obtain an address formatter |
|
43 | - $formatter = EEH_Address::_get_formatter($type); |
|
44 | - // apply schema.org formatting ? |
|
45 | - $use_schema = ! is_admin() ? $use_schema : false; |
|
46 | - $formatted_address = $use_schema |
|
47 | - ? EEH_Address::_schema_formatting($formatter, $obj_with_address) |
|
48 | - : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); |
|
49 | - $formatted_address = $add_wrapper && ! $use_schema |
|
50 | - ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' |
|
51 | - : $formatted_address; |
|
52 | - // return the formatted address |
|
53 | - return $formatted_address; |
|
54 | - } |
|
16 | + /** |
|
17 | + * format - output formatted EE object address information |
|
18 | + * |
|
19 | + * @access public |
|
20 | + * @param object EEI_Address $obj_with_address |
|
21 | + * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
22 | + * @param boolean $use_schema whether to apply schema.org formatting to the address |
|
23 | + * @param bool $add_wrapper |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public static function format( |
|
27 | + $obj_with_address = null, |
|
28 | + $type = 'multiline', |
|
29 | + $use_schema = true, |
|
30 | + $add_wrapper = true |
|
31 | + ) { |
|
32 | + // check that incoming object implements the EEI_Address interface |
|
33 | + if (! $obj_with_address instanceof EEI_Address) { |
|
34 | + $msg = __('The address could not be formatted.', 'event_espresso'); |
|
35 | + $dev_msg = __( |
|
36 | + 'The Address Formatter requires passed objects to implement the EEI_Address interface.', |
|
37 | + 'event_espresso' |
|
38 | + ); |
|
39 | + EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
40 | + return null; |
|
41 | + } |
|
42 | + // obtain an address formatter |
|
43 | + $formatter = EEH_Address::_get_formatter($type); |
|
44 | + // apply schema.org formatting ? |
|
45 | + $use_schema = ! is_admin() ? $use_schema : false; |
|
46 | + $formatted_address = $use_schema |
|
47 | + ? EEH_Address::_schema_formatting($formatter, $obj_with_address) |
|
48 | + : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); |
|
49 | + $formatted_address = $add_wrapper && ! $use_schema |
|
50 | + ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' |
|
51 | + : $formatted_address; |
|
52 | + // return the formatted address |
|
53 | + return $formatted_address; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * _get_formatter - obtain the requester formatter class |
|
60 | - * |
|
61 | - * @access private |
|
62 | - * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
63 | - * @return EEI_Address_Formatter |
|
64 | - */ |
|
65 | - private static function _get_formatter($type) |
|
66 | - { |
|
67 | - switch ($type) { |
|
68 | - case 'multiline': |
|
69 | - return new EventEspresso\core\services\address\formatters\MultiLineAddressFormatter(); |
|
70 | - case 'inline': |
|
71 | - return new EventEspresso\core\services\address\formatters\InlineAddressFormatter(); |
|
72 | - default: |
|
73 | - return new EventEspresso\core\services\address\formatters\NullAddressFormatter(); |
|
74 | - } |
|
75 | - } |
|
58 | + /** |
|
59 | + * _get_formatter - obtain the requester formatter class |
|
60 | + * |
|
61 | + * @access private |
|
62 | + * @param string $type how the address is formatted. for example: 'multiline' or 'inline' |
|
63 | + * @return EEI_Address_Formatter |
|
64 | + */ |
|
65 | + private static function _get_formatter($type) |
|
66 | + { |
|
67 | + switch ($type) { |
|
68 | + case 'multiline': |
|
69 | + return new EventEspresso\core\services\address\formatters\MultiLineAddressFormatter(); |
|
70 | + case 'inline': |
|
71 | + return new EventEspresso\core\services\address\formatters\InlineAddressFormatter(); |
|
72 | + default: |
|
73 | + return new EventEspresso\core\services\address\formatters\NullAddressFormatter(); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * _regular_formatting |
|
81 | - * adds formatting to an address |
|
82 | - * |
|
83 | - * @access private |
|
84 | - * @param object EEI_Address_Formatter $formatter |
|
85 | - * @param object EEI_Address $obj_with_address |
|
86 | - * @param bool $add_wrapper |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - private static function _regular_formatting( |
|
90 | - EEI_Address_Formatter $formatter, |
|
91 | - EEI_Address $obj_with_address, |
|
92 | - $add_wrapper = true |
|
93 | - ) { |
|
94 | - $formatted_address = $add_wrapper ? '<div>' : ''; |
|
95 | - $formatted_address .= $formatter->format( |
|
96 | - $obj_with_address->address(), |
|
97 | - $obj_with_address->address2(), |
|
98 | - $obj_with_address->city(), |
|
99 | - $obj_with_address->state_name(), |
|
100 | - $obj_with_address->zip(), |
|
101 | - $obj_with_address->country_name(), |
|
102 | - $obj_with_address->country_ID() |
|
103 | - ); |
|
104 | - $formatted_address .= $add_wrapper ? '</div>' : ''; |
|
105 | - // return the formatted address |
|
106 | - return $formatted_address; |
|
107 | - } |
|
79 | + /** |
|
80 | + * _regular_formatting |
|
81 | + * adds formatting to an address |
|
82 | + * |
|
83 | + * @access private |
|
84 | + * @param object EEI_Address_Formatter $formatter |
|
85 | + * @param object EEI_Address $obj_with_address |
|
86 | + * @param bool $add_wrapper |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + private static function _regular_formatting( |
|
90 | + EEI_Address_Formatter $formatter, |
|
91 | + EEI_Address $obj_with_address, |
|
92 | + $add_wrapper = true |
|
93 | + ) { |
|
94 | + $formatted_address = $add_wrapper ? '<div>' : ''; |
|
95 | + $formatted_address .= $formatter->format( |
|
96 | + $obj_with_address->address(), |
|
97 | + $obj_with_address->address2(), |
|
98 | + $obj_with_address->city(), |
|
99 | + $obj_with_address->state_name(), |
|
100 | + $obj_with_address->zip(), |
|
101 | + $obj_with_address->country_name(), |
|
102 | + $obj_with_address->country_ID() |
|
103 | + ); |
|
104 | + $formatted_address .= $add_wrapper ? '</div>' : ''; |
|
105 | + // return the formatted address |
|
106 | + return $formatted_address; |
|
107 | + } |
|
108 | 108 | |
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * _schema_formatting |
|
113 | - * adds schema.org formatting to an address |
|
114 | - * |
|
115 | - * @access private |
|
116 | - * @param object EEI_Address_Formatter $formatter |
|
117 | - * @param object EEI_Address $obj_with_address |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) |
|
121 | - { |
|
122 | - $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; |
|
123 | - $formatted_address .= $formatter->format( |
|
124 | - EEH_Schema::streetAddress($obj_with_address), |
|
125 | - EEH_Schema::postOfficeBoxNumber($obj_with_address), |
|
126 | - EEH_Schema::addressLocality($obj_with_address), |
|
127 | - EEH_Schema::addressRegion($obj_with_address), |
|
128 | - EEH_Schema::postalCode($obj_with_address), |
|
129 | - EEH_Schema::addressCountry($obj_with_address), |
|
130 | - $obj_with_address->country_ID() |
|
131 | - ); |
|
132 | - $formatted_address .= '</div>'; |
|
133 | - // return the formatted address |
|
134 | - return $formatted_address; |
|
135 | - } |
|
111 | + /** |
|
112 | + * _schema_formatting |
|
113 | + * adds schema.org formatting to an address |
|
114 | + * |
|
115 | + * @access private |
|
116 | + * @param object EEI_Address_Formatter $formatter |
|
117 | + * @param object EEI_Address $obj_with_address |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) |
|
121 | + { |
|
122 | + $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">'; |
|
123 | + $formatted_address .= $formatter->format( |
|
124 | + EEH_Schema::streetAddress($obj_with_address), |
|
125 | + EEH_Schema::postOfficeBoxNumber($obj_with_address), |
|
126 | + EEH_Schema::addressLocality($obj_with_address), |
|
127 | + EEH_Schema::addressRegion($obj_with_address), |
|
128 | + EEH_Schema::postalCode($obj_with_address), |
|
129 | + EEH_Schema::addressCountry($obj_with_address), |
|
130 | + $obj_with_address->country_ID() |
|
131 | + ); |
|
132 | + $formatted_address .= '</div>'; |
|
133 | + // return the formatted address |
|
134 | + return $formatted_address; |
|
135 | + } |
|
136 | 136 | } |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | $add_wrapper = true |
31 | 31 | ) { |
32 | 32 | // check that incoming object implements the EEI_Address interface |
33 | - if (! $obj_with_address instanceof EEI_Address) { |
|
33 | + if ( ! $obj_with_address instanceof EEI_Address) { |
|
34 | 34 | $msg = __('The address could not be formatted.', 'event_espresso'); |
35 | 35 | $dev_msg = __( |
36 | 36 | 'The Address Formatter requires passed objects to implement the EEI_Address interface.', |
37 | 37 | 'event_espresso' |
38 | 38 | ); |
39 | - EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
39 | + EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
40 | 40 | return null; |
41 | 41 | } |
42 | 42 | // obtain an address formatter |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | ? EEH_Address::_schema_formatting($formatter, $obj_with_address) |
48 | 48 | : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper); |
49 | 49 | $formatted_address = $add_wrapper && ! $use_schema |
50 | - ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' |
|
50 | + ? '<div class="espresso-address-dv">'.$formatted_address.'</div>' |
|
51 | 51 | : $formatted_address; |
52 | 52 | // return the formatted address |
53 | 53 | return $formatted_address; |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | // the post already contains the related EE_Venue object AND one of the following is TRUE: |
59 | 59 | // the requested Venue ID matches the post ID OR... |
60 | 60 | // there was no specific Venue ID requested |
61 | - if (isset($post->EE_Venue) && ( $VNU_ID == $post->ID || ! $VNU_ID )) { |
|
61 | + if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) { |
|
62 | 62 | // use existing related EE_Venue object |
63 | - EEH_Venue_View::$_venue = $post->EE_Venue; |
|
63 | + EEH_Venue_View::$_venue = $post->EE_Venue; |
|
64 | 64 | } elseif ($VNU_ID) { |
65 | 65 | // there WAS a specific Venue ID requested, but it's NOT the current post object |
66 | 66 | EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
102 | - if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
102 | + if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
103 | 103 | // sigh... pull it from the db |
104 | 104 | EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
105 | 105 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public static function is_venue_private($VNU_ID = false) |
172 | 172 | { |
173 | 173 | $venue = EEH_Venue_View::get_venue($VNU_ID, true, true); |
174 | - if (! $venue instanceof EE_Venue) { |
|
174 | + if ( ! $venue instanceof EE_Venue) { |
|
175 | 175 | return null; |
176 | 176 | } |
177 | 177 | |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | $venue = EEH_Venue_View::get_venue($VNU_ID); |
251 | 251 | if ($venue instanceof EE_Venue) { |
252 | 252 | $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
253 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso') . '…'); |
|
254 | - return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
253 | + $venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'…'); |
|
254 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : ''; |
|
255 | 255 | } |
256 | 256 | return ''; |
257 | 257 | } |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | // loop thru terms and create links |
277 | 277 | foreach ($venue_categories as $term) { |
278 | 278 | $url = get_term_link($term, 'espresso_venue_categories'); |
279 | - if (! is_wp_error($url) && (( $hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized )) { |
|
280 | - $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
279 | + if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) { |
|
280 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> '; |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | $venue_name = apply_filters( |
342 | 342 | 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
343 | 343 | EEH_Venue_View::is_venue_private() |
344 | - ? EEH_Venue_View::$_venue->name() . " " . __('(Private)', 'event_espresso') |
|
344 | + ? EEH_Venue_View::$_venue->name()." ".__('(Private)', 'event_espresso') |
|
345 | 345 | : EEH_Venue_View::$_venue->name(), |
346 | 346 | EEH_Venue_View::$_venue |
347 | 347 | ); |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
451 | 451 | $details_page = is_single(); |
452 | 452 | $options = array(); |
453 | - $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
453 | + $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
454 | 454 | |
455 | 455 | $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
456 | 456 | |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | ; |
469 | 469 | |
470 | 470 | $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size; |
471 | - $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size'])? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
471 | + $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
472 | 472 | |
473 | 473 | $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type; |
474 | - $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control'])? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
474 | + $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
475 | 475 | |
476 | 476 | $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align; |
477 | - $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align'])? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
477 | + $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
478 | 478 | |
479 | - $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
479 | + $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
480 | 480 | |
481 | 481 | return EEH_Maps::google_map($options); |
482 | 482 | } |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | // generate nonce |
536 | 536 | $nonce = wp_create_nonce('edit_nonce'); |
537 | 537 | // generate url to venue editor for this venue |
538 | - $url = add_query_arg(array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url('admin.php')); |
|
538 | + $url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php')); |
|
539 | 539 | // get edit CPT text |
540 | 540 | $post_type_obj = get_post_type_object('espresso_venues'); |
541 | 541 | // build final link html |
542 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr($post_type_obj->labels->edit_item) . '">' . $link . '</a>'; |
|
542 | + $link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>'; |
|
543 | 543 | // put it all together |
544 | - return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
544 | + return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after; |
|
545 | 545 | } |
546 | 546 | } |
547 | 547 | return ''; |
@@ -11,539 +11,538 @@ |
||
11 | 11 | class EEH_Venue_View extends EEH_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @access private |
|
16 | - * @var EE_Venue |
|
17 | - */ |
|
18 | - private static $_venue = null; |
|
19 | - |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * get_venue |
|
24 | - * attempts to retrieve an EE_Venue object any way it can |
|
25 | - * |
|
26 | - * @access public |
|
27 | - * @param int $VNU_ID |
|
28 | - * @param bool $look_in_event |
|
29 | - * @param bool $privacy_check Defaults to true. |
|
30 | - * When false, means even if the venue is private we return it regardless of access. |
|
31 | - * @param bool $password_check |
|
32 | - * @return \EE_Venue|null |
|
33 | - */ |
|
34 | - public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true) |
|
35 | - { |
|
36 | - $VNU_ID = absint($VNU_ID); |
|
37 | - // do we already have the Venue you are looking for? |
|
38 | - if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
39 | - // If the Venue ID matches $VNU_ID, return the venue. |
|
40 | - if (EEH_Venue_View::$_venue->ID() === $VNU_ID) { |
|
41 | - return EEH_Venue_View::_get_venue($privacy_check); |
|
42 | - } |
|
43 | - // If the Venue ID does not match, try pulling a venue using $VNU_ID. |
|
44 | - $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
45 | - if ($venue instanceof EE_Venue) { |
|
46 | - EEH_Venue_View::$_venue = $venue; |
|
47 | - return EEH_Venue_View::_get_venue($privacy_check); |
|
48 | - } |
|
49 | - } |
|
50 | - // international newspaper? |
|
51 | - global $post; |
|
52 | - if ($post instanceof WP_Post) { |
|
53 | - switch ($post->post_type) { |
|
54 | - // if this is being called from an EE_Venue post, |
|
55 | - // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
|
56 | - // then we can try to just grab the attached EE_Venue object |
|
57 | - case 'espresso_venues': |
|
58 | - // the post already contains the related EE_Venue object AND one of the following is TRUE: |
|
59 | - // the requested Venue ID matches the post ID OR... |
|
60 | - // there was no specific Venue ID requested |
|
61 | - if (isset($post->EE_Venue) && ( $VNU_ID == $post->ID || ! $VNU_ID )) { |
|
62 | - // use existing related EE_Venue object |
|
63 | - EEH_Venue_View::$_venue = $post->EE_Venue; |
|
64 | - } elseif ($VNU_ID) { |
|
65 | - // there WAS a specific Venue ID requested, but it's NOT the current post object |
|
66 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
67 | - } else { |
|
68 | - // no specific Venue ID requested, so use post ID to generate EE_Venue object |
|
69 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
70 | - } |
|
71 | - break; |
|
72 | - |
|
73 | - case 'espresso_events': |
|
74 | - if ($look_in_event) { |
|
75 | - // grab the events related venues |
|
76 | - $venues = EEH_Venue_View::get_event_venues(); |
|
77 | - // make sure the result is an array |
|
78 | - $venues = is_array($venues) ? $venues : array(); |
|
79 | - // do we have an ID for a specific venue? |
|
80 | - if ($VNU_ID) { |
|
81 | - // loop thru the related venues |
|
82 | - foreach ($venues as $venue) { |
|
83 | - if ($venue instanceof EE_Venue) { |
|
84 | - // until we find the venue we're looking for |
|
85 | - if ($venue->ID() == $VNU_ID) { |
|
86 | - EEH_Venue_View::$_venue = $venue; |
|
87 | - break; |
|
88 | - } |
|
89 | - } |
|
90 | - } |
|
91 | - // no venue ID ? |
|
92 | - // then the global post is an events post and this function was called with no argument |
|
93 | - } else { |
|
94 | - // just grab the first related event venue |
|
95 | - EEH_Venue_View::$_venue = reset($venues); |
|
96 | - } |
|
97 | - } |
|
98 | - break; |
|
99 | - } |
|
100 | - } |
|
101 | - // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
|
102 | - if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
103 | - // sigh... pull it from the db |
|
104 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
105 | - } |
|
106 | - return EEH_Venue_View::_get_venue($privacy_check, $password_check); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * return a single venue |
|
113 | - * |
|
114 | - * @param bool $privacy_check Defaults to true. |
|
115 | - * When false, means even if the venue is private we return it regardless of access. |
|
116 | - * @param bool $password_check |
|
117 | - * @return EE_Venue |
|
118 | - */ |
|
119 | - protected static function _get_venue($privacy_check = true, $password_check = true) |
|
120 | - { |
|
121 | - // check for private venues. |
|
122 | - if (EEH_Venue_View::$_venue instanceof EE_Venue |
|
123 | - && EEH_Venue_View::$_venue->status() == 'private' |
|
124 | - && $privacy_check |
|
125 | - && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues') |
|
126 | - ) { |
|
127 | - return null; |
|
128 | - } |
|
129 | - // check for password protected venues |
|
130 | - if (EEH_Venue_View::$_venue instanceof EE_Venue |
|
131 | - && $password_check |
|
132 | - && post_password_required(EEH_Venue_View::$_venue->ID()) |
|
133 | - ) { |
|
134 | - return null; |
|
135 | - } |
|
136 | - return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * get_event_venues |
|
143 | - * |
|
144 | - * @access public |
|
145 | - * @return EE_Venue[] |
|
146 | - */ |
|
147 | - public static function get_event_venues() |
|
148 | - { |
|
149 | - global $post; |
|
150 | - if ($post->post_type == 'espresso_events') { |
|
151 | - if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
152 | - return $post->EE_Event->venues(); |
|
153 | - } |
|
154 | - } |
|
155 | - return array(); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * Simply checks whether a venue for the given ID (or the internally derived venue is private). |
|
163 | - * |
|
164 | - * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but is not |
|
165 | - * private. So it is important to do explicit boolean checks when using this conditional. |
|
166 | - * |
|
167 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
168 | - * |
|
169 | - * @return bool|null |
|
170 | - */ |
|
171 | - public static function is_venue_private($VNU_ID = false) |
|
172 | - { |
|
173 | - $venue = EEH_Venue_View::get_venue($VNU_ID, true, true); |
|
174 | - if (! $venue instanceof EE_Venue) { |
|
175 | - return null; |
|
176 | - } |
|
177 | - |
|
178 | - return $venue->status() == 'private' ? true : false; |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * returns true or false if a venue is password protected or not |
|
186 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
187 | - * @return bool |
|
188 | - */ |
|
189 | - public static function is_venue_password_protected($VNU_ID = false) |
|
190 | - { |
|
191 | - $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
192 | - if ($venue instanceof EE_Venue |
|
193 | - && post_password_required($venue->ID()) |
|
194 | - ) { |
|
195 | - return true; |
|
196 | - } |
|
197 | - return false; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * If a venue is password protected, this will return the password form for gaining access |
|
204 | - * returns an empty string otherwise |
|
205 | - |
|
206 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
207 | - * |
|
208 | - * @return string |
|
209 | - */ |
|
210 | - public static function password_protected_venue_form($VNU_ID = false) |
|
211 | - { |
|
212 | - $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
213 | - if ($venue instanceof EE_Venue |
|
214 | - && post_password_required($venue->ID()) |
|
215 | - ) { |
|
216 | - return get_the_password_form($venue->ID()); |
|
217 | - } |
|
218 | - return ''; |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * venue_description |
|
225 | - * |
|
226 | - * @access public |
|
227 | - * @param int $VNU_ID |
|
228 | - * @return string |
|
229 | - */ |
|
230 | - public static function venue_description($VNU_ID = 0) |
|
231 | - { |
|
232 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
233 | - if ($venue instanceof EE_Venue) { |
|
234 | - return $venue->get_pretty('VNU_desc'); |
|
235 | - } |
|
236 | - return ''; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * venue_excerpt |
|
243 | - * |
|
244 | - * @access public |
|
245 | - * @param int $VNU_ID |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public static function venue_excerpt($VNU_ID = 0) |
|
249 | - { |
|
250 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
251 | - if ($venue instanceof EE_Venue) { |
|
252 | - $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
|
253 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso') . '…'); |
|
254 | - return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
255 | - } |
|
256 | - return ''; |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * venue_categories |
|
263 | - * |
|
264 | - * @access public |
|
265 | - * @param int $VNU_ID |
|
266 | - * @param bool $hide_uncategorized |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true) |
|
270 | - { |
|
271 | - $category_links = array(); |
|
272 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
273 | - if ($venue instanceof EE_Venue) { |
|
274 | - // get category terms |
|
275 | - if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
276 | - // loop thru terms and create links |
|
277 | - foreach ($venue_categories as $term) { |
|
278 | - $url = get_term_link($term, 'espresso_venue_categories'); |
|
279 | - if (! is_wp_error($url) && (( $hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized )) { |
|
280 | - $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
281 | - } |
|
282 | - } |
|
283 | - } |
|
284 | - } |
|
285 | - return implode(', ', $category_links); |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * venue_address |
|
292 | - * |
|
293 | - * @access public |
|
294 | - * @param string $type |
|
295 | - * @param int $VNU_ID |
|
296 | - * @param bool $use_schema |
|
297 | - * @param bool $add_wrapper |
|
298 | - * @return string |
|
299 | - */ |
|
300 | - public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) |
|
301 | - { |
|
302 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
303 | - if ($venue instanceof EE_Venue) { |
|
304 | - return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
305 | - } |
|
306 | - return ''; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * venue_has_address |
|
313 | - * |
|
314 | - * @access public |
|
315 | - * @param int $VNU_ID |
|
316 | - * @return bool|string |
|
317 | - */ |
|
318 | - public static function venue_has_address($VNU_ID = 0) |
|
319 | - { |
|
320 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
321 | - if ($venue instanceof EE_Venue) { |
|
322 | - return EEH_Address::format($venue, 'inline', false, false); |
|
323 | - } |
|
324 | - return false; |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * venue_name |
|
331 | - * |
|
332 | - * @access public |
|
333 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
334 | - * @param int $VNU_ID |
|
335 | - * @return string |
|
336 | - */ |
|
337 | - public static function venue_name($link_to = 'details', $VNU_ID = 0) |
|
338 | - { |
|
339 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
340 | - if ($venue instanceof EE_Venue) { |
|
341 | - $venue_name = apply_filters( |
|
342 | - 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
|
343 | - EEH_Venue_View::is_venue_private() |
|
344 | - ? EEH_Venue_View::$_venue->name() . " " . __('(Private)', 'event_espresso') |
|
345 | - : EEH_Venue_View::$_venue->name(), |
|
346 | - EEH_Venue_View::$_venue |
|
347 | - ); |
|
348 | - $venue_name = EEH_Schema::name($venue_name); |
|
349 | - |
|
350 | - // if venue is trashed then ignore the "link to" setting because the venue is trashed. |
|
351 | - if ($venue->get('status') == 'trash') { |
|
352 | - $link_to = ''; |
|
353 | - } |
|
354 | - switch ($link_to) { |
|
355 | - case 'details': |
|
356 | - return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
357 | - break; |
|
358 | - |
|
359 | - case 'website': |
|
360 | - return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
361 | - break; |
|
362 | - |
|
363 | - default: |
|
364 | - return $venue_name; |
|
365 | - } |
|
366 | - } |
|
367 | - return ''; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * venue_details_link |
|
374 | - * |
|
375 | - * @access public |
|
376 | - * @param int $VNU_ID |
|
377 | - * @param string $text |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public static function venue_details_link($VNU_ID = 0, $text = '') |
|
381 | - { |
|
382 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
383 | - if ($venue instanceof EE_Venue) { |
|
384 | - return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
385 | - } |
|
386 | - return ''; |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * venue_website_link |
|
393 | - * |
|
394 | - * @access public |
|
395 | - * @param int $VNU_ID |
|
396 | - * @param string $text |
|
397 | - * @return string |
|
398 | - */ |
|
399 | - public static function venue_website_link($VNU_ID = 0, $text = '') |
|
400 | - { |
|
401 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
402 | - if ($venue instanceof EE_Venue) { |
|
403 | - $url = $venue->venue_url(); |
|
404 | - $text = ! empty($text) ? $text : $url; |
|
405 | - return ! empty($url) ? EEH_Schema::url($url, $text) : ''; |
|
406 | - } |
|
407 | - return ''; |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * venue_phone |
|
414 | - * |
|
415 | - * @access public |
|
416 | - * @param int $VNU_ID |
|
417 | - * @return string |
|
418 | - */ |
|
419 | - public static function venue_phone($VNU_ID = 0) |
|
420 | - { |
|
421 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
422 | - if ($venue instanceof EE_Venue) { |
|
423 | - return EEH_Schema::telephone($venue->phone()); |
|
424 | - } |
|
425 | - return ''; |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * venue_gmap |
|
432 | - * |
|
433 | - * @access public |
|
434 | - * @param int $VNU_ID |
|
435 | - * @param bool|string $map_ID a unique identifier for this map |
|
436 | - * @param array $gmap map options |
|
437 | - * @return string |
|
438 | - */ |
|
439 | - public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = array()) |
|
440 | - { |
|
441 | - |
|
442 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
443 | - if ($venue instanceof EE_Venue) { |
|
444 | - // check for global espresso_events post and use it's ID if no map_ID is set |
|
445 | - global $post; |
|
446 | - $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
447 | - // grab map settings |
|
448 | - $map_cfg = EE_Registry::instance()->CFG->map_settings; |
|
449 | - // are maps enabled ? |
|
450 | - if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
451 | - $details_page = is_single(); |
|
452 | - $options = array(); |
|
453 | - $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
454 | - |
|
455 | - $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
|
456 | - |
|
457 | - $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width; |
|
458 | - $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
459 | - |
|
460 | - $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height; |
|
461 | - $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
462 | - |
|
463 | - $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom; |
|
464 | - $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
465 | - |
|
466 | - $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav; |
|
467 | - $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; |
|
468 | - ; |
|
469 | - |
|
470 | - $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size; |
|
471 | - $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size'])? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
472 | - |
|
473 | - $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type; |
|
474 | - $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control'])? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
475 | - |
|
476 | - $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align; |
|
477 | - $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align'])? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
478 | - |
|
479 | - $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
480 | - |
|
481 | - return EEH_Maps::google_map($options); |
|
482 | - } |
|
483 | - } |
|
484 | - |
|
485 | - return ''; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * Gets the HTML to display a static map of the venue |
|
490 | - * @param EE_Venue $venue |
|
491 | - * @param array $atts like EEH_Maps::google_map_link |
|
492 | - * @return string |
|
493 | - */ |
|
494 | - public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) |
|
495 | - { |
|
496 | - $state = $venue->state_obj(); |
|
497 | - $country = $venue->country_obj(); |
|
498 | - $atts = shortcode_atts( |
|
499 | - array( |
|
500 | - 'id' => $venue->ID(), |
|
501 | - 'address' => $venue->get('VNU_address'), |
|
502 | - 'city' => $venue->get('VNU_city'), |
|
503 | - 'state' => $state instanceof EE_State ? $state->name() : '', |
|
504 | - 'zip' => $venue->get('VNU_zip'), |
|
505 | - 'country' => $country instanceof EE_Country ? $country->name() : '', |
|
506 | - 'type' => 'map', |
|
507 | - 'map_w' => 200, |
|
508 | - 'map_h' => 200 |
|
509 | - ), |
|
510 | - $atts |
|
511 | - ); |
|
512 | - return EEH_Maps::google_map_link($atts); |
|
513 | - } |
|
514 | - |
|
515 | - |
|
516 | - |
|
517 | - /** |
|
518 | - * edit_venue_link |
|
519 | - * |
|
520 | - * @access public |
|
521 | - * @param int $VNU_ID |
|
522 | - * @param string $link |
|
523 | - * @param string $before |
|
524 | - * @param string $after |
|
525 | - * @return string |
|
526 | - */ |
|
527 | - public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') |
|
528 | - { |
|
529 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
530 | - if ($venue instanceof EE_Venue) { |
|
531 | - // can the user edit this post ? |
|
532 | - if (current_user_can('edit_post', $venue->ID())) { |
|
533 | - // set link text |
|
534 | - $link = ! empty($link) ? $link : __('edit this venue', 'event_espresso'); |
|
535 | - // generate nonce |
|
536 | - $nonce = wp_create_nonce('edit_nonce'); |
|
537 | - // generate url to venue editor for this venue |
|
538 | - $url = add_query_arg(array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url('admin.php')); |
|
539 | - // get edit CPT text |
|
540 | - $post_type_obj = get_post_type_object('espresso_venues'); |
|
541 | - // build final link html |
|
542 | - $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr($post_type_obj->labels->edit_item) . '">' . $link . '</a>'; |
|
543 | - // put it all together |
|
544 | - return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
545 | - } |
|
546 | - } |
|
547 | - return ''; |
|
548 | - } |
|
14 | + /** |
|
15 | + * @access private |
|
16 | + * @var EE_Venue |
|
17 | + */ |
|
18 | + private static $_venue = null; |
|
19 | + |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * get_venue |
|
24 | + * attempts to retrieve an EE_Venue object any way it can |
|
25 | + * |
|
26 | + * @access public |
|
27 | + * @param int $VNU_ID |
|
28 | + * @param bool $look_in_event |
|
29 | + * @param bool $privacy_check Defaults to true. |
|
30 | + * When false, means even if the venue is private we return it regardless of access. |
|
31 | + * @param bool $password_check |
|
32 | + * @return \EE_Venue|null |
|
33 | + */ |
|
34 | + public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true) |
|
35 | + { |
|
36 | + $VNU_ID = absint($VNU_ID); |
|
37 | + // do we already have the Venue you are looking for? |
|
38 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
39 | + // If the Venue ID matches $VNU_ID, return the venue. |
|
40 | + if (EEH_Venue_View::$_venue->ID() === $VNU_ID) { |
|
41 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
42 | + } |
|
43 | + // If the Venue ID does not match, try pulling a venue using $VNU_ID. |
|
44 | + $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
45 | + if ($venue instanceof EE_Venue) { |
|
46 | + EEH_Venue_View::$_venue = $venue; |
|
47 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
48 | + } |
|
49 | + } |
|
50 | + // international newspaper? |
|
51 | + global $post; |
|
52 | + if ($post instanceof WP_Post) { |
|
53 | + switch ($post->post_type) { |
|
54 | + // if this is being called from an EE_Venue post, |
|
55 | + // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
|
56 | + // then we can try to just grab the attached EE_Venue object |
|
57 | + case 'espresso_venues': |
|
58 | + // the post already contains the related EE_Venue object AND one of the following is TRUE: |
|
59 | + // the requested Venue ID matches the post ID OR... |
|
60 | + // there was no specific Venue ID requested |
|
61 | + if (isset($post->EE_Venue) && ( $VNU_ID == $post->ID || ! $VNU_ID )) { |
|
62 | + // use existing related EE_Venue object |
|
63 | + EEH_Venue_View::$_venue = $post->EE_Venue; |
|
64 | + } elseif ($VNU_ID) { |
|
65 | + // there WAS a specific Venue ID requested, but it's NOT the current post object |
|
66 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
67 | + } else { |
|
68 | + // no specific Venue ID requested, so use post ID to generate EE_Venue object |
|
69 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
70 | + } |
|
71 | + break; |
|
72 | + |
|
73 | + case 'espresso_events': |
|
74 | + if ($look_in_event) { |
|
75 | + // grab the events related venues |
|
76 | + $venues = EEH_Venue_View::get_event_venues(); |
|
77 | + // make sure the result is an array |
|
78 | + $venues = is_array($venues) ? $venues : array(); |
|
79 | + // do we have an ID for a specific venue? |
|
80 | + if ($VNU_ID) { |
|
81 | + // loop thru the related venues |
|
82 | + foreach ($venues as $venue) { |
|
83 | + if ($venue instanceof EE_Venue) { |
|
84 | + // until we find the venue we're looking for |
|
85 | + if ($venue->ID() == $VNU_ID) { |
|
86 | + EEH_Venue_View::$_venue = $venue; |
|
87 | + break; |
|
88 | + } |
|
89 | + } |
|
90 | + } |
|
91 | + // no venue ID ? |
|
92 | + // then the global post is an events post and this function was called with no argument |
|
93 | + } else { |
|
94 | + // just grab the first related event venue |
|
95 | + EEH_Venue_View::$_venue = reset($venues); |
|
96 | + } |
|
97 | + } |
|
98 | + break; |
|
99 | + } |
|
100 | + } |
|
101 | + // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
|
102 | + if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
103 | + // sigh... pull it from the db |
|
104 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
105 | + } |
|
106 | + return EEH_Venue_View::_get_venue($privacy_check, $password_check); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * return a single venue |
|
113 | + * |
|
114 | + * @param bool $privacy_check Defaults to true. |
|
115 | + * When false, means even if the venue is private we return it regardless of access. |
|
116 | + * @param bool $password_check |
|
117 | + * @return EE_Venue |
|
118 | + */ |
|
119 | + protected static function _get_venue($privacy_check = true, $password_check = true) |
|
120 | + { |
|
121 | + // check for private venues. |
|
122 | + if (EEH_Venue_View::$_venue instanceof EE_Venue |
|
123 | + && EEH_Venue_View::$_venue->status() == 'private' |
|
124 | + && $privacy_check |
|
125 | + && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues') |
|
126 | + ) { |
|
127 | + return null; |
|
128 | + } |
|
129 | + // check for password protected venues |
|
130 | + if (EEH_Venue_View::$_venue instanceof EE_Venue |
|
131 | + && $password_check |
|
132 | + && post_password_required(EEH_Venue_View::$_venue->ID()) |
|
133 | + ) { |
|
134 | + return null; |
|
135 | + } |
|
136 | + return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * get_event_venues |
|
143 | + * |
|
144 | + * @access public |
|
145 | + * @return EE_Venue[] |
|
146 | + */ |
|
147 | + public static function get_event_venues() |
|
148 | + { |
|
149 | + global $post; |
|
150 | + if ($post->post_type == 'espresso_events') { |
|
151 | + if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
152 | + return $post->EE_Event->venues(); |
|
153 | + } |
|
154 | + } |
|
155 | + return array(); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * Simply checks whether a venue for the given ID (or the internally derived venue is private). |
|
163 | + * |
|
164 | + * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but is not |
|
165 | + * private. So it is important to do explicit boolean checks when using this conditional. |
|
166 | + * |
|
167 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
168 | + * |
|
169 | + * @return bool|null |
|
170 | + */ |
|
171 | + public static function is_venue_private($VNU_ID = false) |
|
172 | + { |
|
173 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true); |
|
174 | + if (! $venue instanceof EE_Venue) { |
|
175 | + return null; |
|
176 | + } |
|
177 | + |
|
178 | + return $venue->status() == 'private' ? true : false; |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * returns true or false if a venue is password protected or not |
|
186 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
187 | + * @return bool |
|
188 | + */ |
|
189 | + public static function is_venue_password_protected($VNU_ID = false) |
|
190 | + { |
|
191 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
192 | + if ($venue instanceof EE_Venue |
|
193 | + && post_password_required($venue->ID()) |
|
194 | + ) { |
|
195 | + return true; |
|
196 | + } |
|
197 | + return false; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * If a venue is password protected, this will return the password form for gaining access |
|
204 | + * returns an empty string otherwise |
|
205 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
206 | + * |
|
207 | + * @return string |
|
208 | + */ |
|
209 | + public static function password_protected_venue_form($VNU_ID = false) |
|
210 | + { |
|
211 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
212 | + if ($venue instanceof EE_Venue |
|
213 | + && post_password_required($venue->ID()) |
|
214 | + ) { |
|
215 | + return get_the_password_form($venue->ID()); |
|
216 | + } |
|
217 | + return ''; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * venue_description |
|
224 | + * |
|
225 | + * @access public |
|
226 | + * @param int $VNU_ID |
|
227 | + * @return string |
|
228 | + */ |
|
229 | + public static function venue_description($VNU_ID = 0) |
|
230 | + { |
|
231 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
232 | + if ($venue instanceof EE_Venue) { |
|
233 | + return $venue->get_pretty('VNU_desc'); |
|
234 | + } |
|
235 | + return ''; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * venue_excerpt |
|
242 | + * |
|
243 | + * @access public |
|
244 | + * @param int $VNU_ID |
|
245 | + * @return string |
|
246 | + */ |
|
247 | + public static function venue_excerpt($VNU_ID = 0) |
|
248 | + { |
|
249 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
250 | + if ($venue instanceof EE_Venue) { |
|
251 | + $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
|
252 | + $venue_link = ' ' . EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso') . '…'); |
|
253 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
254 | + } |
|
255 | + return ''; |
|
256 | + } |
|
257 | + |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * venue_categories |
|
262 | + * |
|
263 | + * @access public |
|
264 | + * @param int $VNU_ID |
|
265 | + * @param bool $hide_uncategorized |
|
266 | + * @return string |
|
267 | + */ |
|
268 | + public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true) |
|
269 | + { |
|
270 | + $category_links = array(); |
|
271 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
272 | + if ($venue instanceof EE_Venue) { |
|
273 | + // get category terms |
|
274 | + if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
275 | + // loop thru terms and create links |
|
276 | + foreach ($venue_categories as $term) { |
|
277 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
278 | + if (! is_wp_error($url) && (( $hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized )) { |
|
279 | + $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + } |
|
284 | + return implode(', ', $category_links); |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * venue_address |
|
291 | + * |
|
292 | + * @access public |
|
293 | + * @param string $type |
|
294 | + * @param int $VNU_ID |
|
295 | + * @param bool $use_schema |
|
296 | + * @param bool $add_wrapper |
|
297 | + * @return string |
|
298 | + */ |
|
299 | + public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) |
|
300 | + { |
|
301 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
302 | + if ($venue instanceof EE_Venue) { |
|
303 | + return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
304 | + } |
|
305 | + return ''; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * venue_has_address |
|
312 | + * |
|
313 | + * @access public |
|
314 | + * @param int $VNU_ID |
|
315 | + * @return bool|string |
|
316 | + */ |
|
317 | + public static function venue_has_address($VNU_ID = 0) |
|
318 | + { |
|
319 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
320 | + if ($venue instanceof EE_Venue) { |
|
321 | + return EEH_Address::format($venue, 'inline', false, false); |
|
322 | + } |
|
323 | + return false; |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + |
|
328 | + /** |
|
329 | + * venue_name |
|
330 | + * |
|
331 | + * @access public |
|
332 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
333 | + * @param int $VNU_ID |
|
334 | + * @return string |
|
335 | + */ |
|
336 | + public static function venue_name($link_to = 'details', $VNU_ID = 0) |
|
337 | + { |
|
338 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
339 | + if ($venue instanceof EE_Venue) { |
|
340 | + $venue_name = apply_filters( |
|
341 | + 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
|
342 | + EEH_Venue_View::is_venue_private() |
|
343 | + ? EEH_Venue_View::$_venue->name() . " " . __('(Private)', 'event_espresso') |
|
344 | + : EEH_Venue_View::$_venue->name(), |
|
345 | + EEH_Venue_View::$_venue |
|
346 | + ); |
|
347 | + $venue_name = EEH_Schema::name($venue_name); |
|
348 | + |
|
349 | + // if venue is trashed then ignore the "link to" setting because the venue is trashed. |
|
350 | + if ($venue->get('status') == 'trash') { |
|
351 | + $link_to = ''; |
|
352 | + } |
|
353 | + switch ($link_to) { |
|
354 | + case 'details': |
|
355 | + return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
356 | + break; |
|
357 | + |
|
358 | + case 'website': |
|
359 | + return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
360 | + break; |
|
361 | + |
|
362 | + default: |
|
363 | + return $venue_name; |
|
364 | + } |
|
365 | + } |
|
366 | + return ''; |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * venue_details_link |
|
373 | + * |
|
374 | + * @access public |
|
375 | + * @param int $VNU_ID |
|
376 | + * @param string $text |
|
377 | + * @return string |
|
378 | + */ |
|
379 | + public static function venue_details_link($VNU_ID = 0, $text = '') |
|
380 | + { |
|
381 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
382 | + if ($venue instanceof EE_Venue) { |
|
383 | + return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
384 | + } |
|
385 | + return ''; |
|
386 | + } |
|
387 | + |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * venue_website_link |
|
392 | + * |
|
393 | + * @access public |
|
394 | + * @param int $VNU_ID |
|
395 | + * @param string $text |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + public static function venue_website_link($VNU_ID = 0, $text = '') |
|
399 | + { |
|
400 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
401 | + if ($venue instanceof EE_Venue) { |
|
402 | + $url = $venue->venue_url(); |
|
403 | + $text = ! empty($text) ? $text : $url; |
|
404 | + return ! empty($url) ? EEH_Schema::url($url, $text) : ''; |
|
405 | + } |
|
406 | + return ''; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * venue_phone |
|
413 | + * |
|
414 | + * @access public |
|
415 | + * @param int $VNU_ID |
|
416 | + * @return string |
|
417 | + */ |
|
418 | + public static function venue_phone($VNU_ID = 0) |
|
419 | + { |
|
420 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
421 | + if ($venue instanceof EE_Venue) { |
|
422 | + return EEH_Schema::telephone($venue->phone()); |
|
423 | + } |
|
424 | + return ''; |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * venue_gmap |
|
431 | + * |
|
432 | + * @access public |
|
433 | + * @param int $VNU_ID |
|
434 | + * @param bool|string $map_ID a unique identifier for this map |
|
435 | + * @param array $gmap map options |
|
436 | + * @return string |
|
437 | + */ |
|
438 | + public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = array()) |
|
439 | + { |
|
440 | + |
|
441 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
442 | + if ($venue instanceof EE_Venue) { |
|
443 | + // check for global espresso_events post and use it's ID if no map_ID is set |
|
444 | + global $post; |
|
445 | + $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
446 | + // grab map settings |
|
447 | + $map_cfg = EE_Registry::instance()->CFG->map_settings; |
|
448 | + // are maps enabled ? |
|
449 | + if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
450 | + $details_page = is_single(); |
|
451 | + $options = array(); |
|
452 | + $options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/; |
|
453 | + |
|
454 | + $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
|
455 | + |
|
456 | + $options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width; |
|
457 | + $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width']; |
|
458 | + |
|
459 | + $options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height; |
|
460 | + $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height']; |
|
461 | + |
|
462 | + $options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom; |
|
463 | + $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom']; |
|
464 | + |
|
465 | + $options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav; |
|
466 | + $options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; |
|
467 | + ; |
|
468 | + |
|
469 | + $options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size; |
|
470 | + $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size'])? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size']; |
|
471 | + |
|
472 | + $options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type; |
|
473 | + $options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control'])? $gmap['ee_map_type_control'] : $options['ee_map_type_control']; |
|
474 | + |
|
475 | + $options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align; |
|
476 | + $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align'])? $gmap['ee_map_align'] : $options['ee_map_align']; |
|
477 | + |
|
478 | + $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link(); |
|
479 | + |
|
480 | + return EEH_Maps::google_map($options); |
|
481 | + } |
|
482 | + } |
|
483 | + |
|
484 | + return ''; |
|
485 | + } |
|
486 | + |
|
487 | + /** |
|
488 | + * Gets the HTML to display a static map of the venue |
|
489 | + * @param EE_Venue $venue |
|
490 | + * @param array $atts like EEH_Maps::google_map_link |
|
491 | + * @return string |
|
492 | + */ |
|
493 | + public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) |
|
494 | + { |
|
495 | + $state = $venue->state_obj(); |
|
496 | + $country = $venue->country_obj(); |
|
497 | + $atts = shortcode_atts( |
|
498 | + array( |
|
499 | + 'id' => $venue->ID(), |
|
500 | + 'address' => $venue->get('VNU_address'), |
|
501 | + 'city' => $venue->get('VNU_city'), |
|
502 | + 'state' => $state instanceof EE_State ? $state->name() : '', |
|
503 | + 'zip' => $venue->get('VNU_zip'), |
|
504 | + 'country' => $country instanceof EE_Country ? $country->name() : '', |
|
505 | + 'type' => 'map', |
|
506 | + 'map_w' => 200, |
|
507 | + 'map_h' => 200 |
|
508 | + ), |
|
509 | + $atts |
|
510 | + ); |
|
511 | + return EEH_Maps::google_map_link($atts); |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + |
|
516 | + /** |
|
517 | + * edit_venue_link |
|
518 | + * |
|
519 | + * @access public |
|
520 | + * @param int $VNU_ID |
|
521 | + * @param string $link |
|
522 | + * @param string $before |
|
523 | + * @param string $after |
|
524 | + * @return string |
|
525 | + */ |
|
526 | + public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') |
|
527 | + { |
|
528 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
529 | + if ($venue instanceof EE_Venue) { |
|
530 | + // can the user edit this post ? |
|
531 | + if (current_user_can('edit_post', $venue->ID())) { |
|
532 | + // set link text |
|
533 | + $link = ! empty($link) ? $link : __('edit this venue', 'event_espresso'); |
|
534 | + // generate nonce |
|
535 | + $nonce = wp_create_nonce('edit_nonce'); |
|
536 | + // generate url to venue editor for this venue |
|
537 | + $url = add_query_arg(array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url('admin.php')); |
|
538 | + // get edit CPT text |
|
539 | + $post_type_obj = get_post_type_object('espresso_venues'); |
|
540 | + // build final link html |
|
541 | + $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr($post_type_obj->labels->edit_item) . '">' . $link . '</a>'; |
|
542 | + // put it all together |
|
543 | + return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
544 | + } |
|
545 | + } |
|
546 | + return ''; |
|
547 | + } |
|
549 | 548 | } |
@@ -11,42 +11,42 @@ |
||
11 | 11 | class EEH_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @var array $uri_segment_array URL segments |
|
16 | - * @access private |
|
17 | - */ |
|
14 | + /** |
|
15 | + * @var array $uri_segment_array URL segments |
|
16 | + * @access private |
|
17 | + */ |
|
18 | 18 | // final private function __construct() {} |
19 | 19 | |
20 | - /** |
|
21 | - * @ override magic methods |
|
22 | - * @ return void |
|
23 | - */ |
|
24 | - public function __set($a, $b) |
|
25 | - { |
|
26 | - return false; |
|
27 | - } |
|
28 | - public function __get($a) |
|
29 | - { |
|
30 | - return false; |
|
31 | - } |
|
32 | - public function __isset($a) |
|
33 | - { |
|
34 | - return false; |
|
35 | - } |
|
36 | - public function __unset($a) |
|
37 | - { |
|
38 | - return false; |
|
39 | - } |
|
40 | - public function __clone() |
|
41 | - { |
|
42 | - return false; |
|
43 | - } |
|
44 | - public function __wakeup() |
|
45 | - { |
|
46 | - return false; |
|
47 | - } |
|
48 | - public function __destruct() |
|
49 | - { |
|
50 | - return false; |
|
51 | - } |
|
20 | + /** |
|
21 | + * @ override magic methods |
|
22 | + * @ return void |
|
23 | + */ |
|
24 | + public function __set($a, $b) |
|
25 | + { |
|
26 | + return false; |
|
27 | + } |
|
28 | + public function __get($a) |
|
29 | + { |
|
30 | + return false; |
|
31 | + } |
|
32 | + public function __isset($a) |
|
33 | + { |
|
34 | + return false; |
|
35 | + } |
|
36 | + public function __unset($a) |
|
37 | + { |
|
38 | + return false; |
|
39 | + } |
|
40 | + public function __clone() |
|
41 | + { |
|
42 | + return false; |
|
43 | + } |
|
44 | + public function __wakeup() |
|
45 | + { |
|
46 | + return false; |
|
47 | + } |
|
48 | + public function __destruct() |
|
49 | + { |
|
50 | + return false; |
|
51 | + } |
|
52 | 52 | } |
@@ -13,203 +13,203 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays |
|
18 | - * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects |
|
19 | - * |
|
20 | - * @uses array_udiff core php function for setting up our own array comparison |
|
21 | - * @uses self::_compare_objects as the custom method for array_udiff |
|
22 | - * @param array $array1 an array of objects |
|
23 | - * @param array $array2 an array of objects |
|
24 | - * @return array an array of objects found in array 1 that aren't found in array 2. |
|
25 | - */ |
|
26 | - public static function object_array_diff($array1, $array2) |
|
27 | - { |
|
28 | - return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed |
|
33 | - * |
|
34 | - * @param array $array |
|
35 | - * @return boolean |
|
36 | - */ |
|
37 | - public static function is_associative_array(array $array) |
|
38 | - { |
|
39 | - return array_keys($array) !== range(0, count($array) - 1); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Gets an item from the array and leave the array intact. Use in place of end() |
|
44 | - * when you don't want to change the array |
|
45 | - * |
|
46 | - * @param array $arr |
|
47 | - * @return mixed what ever is in the array |
|
48 | - */ |
|
49 | - public static function get_one_item_from_array($arr) |
|
50 | - { |
|
51 | - $item = end($arr); |
|
52 | - reset($arr); |
|
53 | - return $item; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Detects if this is a multi-dimensional array (meaning that the top-level |
|
58 | - * values are themselves array. Eg array(array(...),...) |
|
59 | - * |
|
60 | - * @param mixed $arr |
|
61 | - * @return boolean |
|
62 | - */ |
|
63 | - public static function is_multi_dimensional_array($arr) |
|
64 | - { |
|
65 | - if (is_array($arr)) { |
|
66 | - $first_item = reset($arr); |
|
67 | - if (is_array($first_item)) { |
|
68 | - return true;// yep, there's at least 2 levels to this array |
|
69 | - } else { |
|
70 | - return false;// nope, only 1 level |
|
71 | - } |
|
72 | - } else { |
|
73 | - return false;// its not an array at all! |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default |
|
79 | - * |
|
80 | - * @param array $arr |
|
81 | - * @param mixed $index |
|
82 | - * @param mixed $default |
|
83 | - * @return mixed |
|
84 | - */ |
|
85 | - public static function is_set($arr, $index, $default) |
|
86 | - { |
|
87 | - return isset($arr[ $index ]) ? $arr[ $index ] : $default; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118 |
|
92 | - * |
|
93 | - * @param mixed $value usually a string, but could be an array or object |
|
94 | - * @return mixed the UN-serialized data |
|
95 | - */ |
|
96 | - public static function maybe_unserialize($value) |
|
97 | - { |
|
98 | - $data = maybe_unserialize($value); |
|
99 | - // it's possible that this still has serialized data if its the session. WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically. |
|
100 | - $token = 'C'; |
|
101 | - $data = is_string($data) ? trim($data) : $data; |
|
102 | - if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
103 | - return unserialize($data); |
|
104 | - } else { |
|
105 | - return $data; |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * insert_into_array |
|
112 | - * |
|
113 | - * @param array $target_array the array to insert new data into |
|
114 | - * @param array $array_to_insert the new data to be inserted |
|
115 | - * @param int | string $offset a known key within $target_array where new data will be inserted |
|
116 | - * @param bool $add_before whether to add new data before or after the offset key |
|
117 | - * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - public static function insert_into_array( |
|
121 | - $target_array = array(), |
|
122 | - $array_to_insert = array(), |
|
123 | - $offset = null, |
|
124 | - $add_before = true, |
|
125 | - $preserve_keys = true |
|
126 | - ) { |
|
127 | - // ensure incoming arrays are actually arrays |
|
128 | - $target_array = (array) $target_array; |
|
129 | - $array_to_insert = (array) $array_to_insert; |
|
130 | - // if no offset key was supplied |
|
131 | - if (empty($offset)) { |
|
132 | - // use start or end of $target_array based on whether we are adding before or not |
|
133 | - $offset = $add_before ? 0 : count($target_array); |
|
134 | - } |
|
135 | - // if offset key is a string, then find the corresponding numeric location for that element |
|
136 | - $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
137 | - // add one to the offset if adding after |
|
138 | - $offset = $add_before ? $offset : $offset + 1; |
|
139 | - // but ensure offset does not exceed the length of the array |
|
140 | - $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
141 | - // reindex array ??? |
|
142 | - if ($preserve_keys) { |
|
143 | - // take a slice of the target array from the beginning till the offset, |
|
144 | - // then add the new data |
|
145 | - // then add another slice that starts at the offset and goes till the end |
|
146 | - return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice( |
|
147 | - $target_array, |
|
148 | - $offset, |
|
149 | - null, |
|
150 | - true |
|
151 | - ); |
|
152 | - } else { |
|
153 | - // since we don't want to preserve keys, we can use array_splice |
|
154 | - array_splice($target_array, $offset, 0, $array_to_insert); |
|
155 | - return $target_array; |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - |
|
160 | - /** |
|
161 | - * array_merge() is slow and should never be used while looping over data |
|
162 | - * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster |
|
163 | - * so really this acts more like array_replace( $array1, $array2 ) |
|
164 | - * or a union with the arrays flipped ( $array2 + $array1 ) |
|
165 | - * this saves a few lines of code and improves readability |
|
166 | - * |
|
167 | - * @param array $array1 |
|
168 | - * @param array $array2 |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) |
|
172 | - { |
|
173 | - foreach ($array2 as $key => $value) { |
|
174 | - $array1[ $key ] = $value; |
|
175 | - } |
|
176 | - return $array1; |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * given a flat array like $array = array('A', 'B', 'C') |
|
182 | - * will convert into a multidimensional array like $array[A][B][C] |
|
183 | - * if $final_value is provided and is anything other than null, |
|
184 | - * then that will be set as the value for the innermost array key |
|
185 | - * like so: $array[A][B][C] = $final_value |
|
186 | - * |
|
187 | - * @param array $flat_array |
|
188 | - * @param mixed $final_value |
|
189 | - * @return array |
|
190 | - */ |
|
191 | - public static function convert_array_values_to_keys(array $flat_array, $final_value = null) |
|
192 | - { |
|
193 | - $multidimensional = array(); |
|
194 | - $reference = &$multidimensional; |
|
195 | - foreach ($flat_array as $key) { |
|
196 | - $reference[ $key ] = array(); |
|
197 | - $reference = &$reference[ $key ]; |
|
198 | - } |
|
199 | - if ($final_value !== null) { |
|
200 | - $reference = $final_value; |
|
201 | - } |
|
202 | - return $multidimensional; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential |
|
208 | - * @param array $array |
|
209 | - * @return bool |
|
210 | - */ |
|
211 | - public static function is_array_numerically_and_sequentially_indexed(array $array) |
|
212 | - { |
|
213 | - return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
214 | - } |
|
16 | + /** |
|
17 | + * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays |
|
18 | + * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects |
|
19 | + * |
|
20 | + * @uses array_udiff core php function for setting up our own array comparison |
|
21 | + * @uses self::_compare_objects as the custom method for array_udiff |
|
22 | + * @param array $array1 an array of objects |
|
23 | + * @param array $array2 an array of objects |
|
24 | + * @return array an array of objects found in array 1 that aren't found in array 2. |
|
25 | + */ |
|
26 | + public static function object_array_diff($array1, $array2) |
|
27 | + { |
|
28 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed |
|
33 | + * |
|
34 | + * @param array $array |
|
35 | + * @return boolean |
|
36 | + */ |
|
37 | + public static function is_associative_array(array $array) |
|
38 | + { |
|
39 | + return array_keys($array) !== range(0, count($array) - 1); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Gets an item from the array and leave the array intact. Use in place of end() |
|
44 | + * when you don't want to change the array |
|
45 | + * |
|
46 | + * @param array $arr |
|
47 | + * @return mixed what ever is in the array |
|
48 | + */ |
|
49 | + public static function get_one_item_from_array($arr) |
|
50 | + { |
|
51 | + $item = end($arr); |
|
52 | + reset($arr); |
|
53 | + return $item; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Detects if this is a multi-dimensional array (meaning that the top-level |
|
58 | + * values are themselves array. Eg array(array(...),...) |
|
59 | + * |
|
60 | + * @param mixed $arr |
|
61 | + * @return boolean |
|
62 | + */ |
|
63 | + public static function is_multi_dimensional_array($arr) |
|
64 | + { |
|
65 | + if (is_array($arr)) { |
|
66 | + $first_item = reset($arr); |
|
67 | + if (is_array($first_item)) { |
|
68 | + return true;// yep, there's at least 2 levels to this array |
|
69 | + } else { |
|
70 | + return false;// nope, only 1 level |
|
71 | + } |
|
72 | + } else { |
|
73 | + return false;// its not an array at all! |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default |
|
79 | + * |
|
80 | + * @param array $arr |
|
81 | + * @param mixed $index |
|
82 | + * @param mixed $default |
|
83 | + * @return mixed |
|
84 | + */ |
|
85 | + public static function is_set($arr, $index, $default) |
|
86 | + { |
|
87 | + return isset($arr[ $index ]) ? $arr[ $index ] : $default; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118 |
|
92 | + * |
|
93 | + * @param mixed $value usually a string, but could be an array or object |
|
94 | + * @return mixed the UN-serialized data |
|
95 | + */ |
|
96 | + public static function maybe_unserialize($value) |
|
97 | + { |
|
98 | + $data = maybe_unserialize($value); |
|
99 | + // it's possible that this still has serialized data if its the session. WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically. |
|
100 | + $token = 'C'; |
|
101 | + $data = is_string($data) ? trim($data) : $data; |
|
102 | + if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) { |
|
103 | + return unserialize($data); |
|
104 | + } else { |
|
105 | + return $data; |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * insert_into_array |
|
112 | + * |
|
113 | + * @param array $target_array the array to insert new data into |
|
114 | + * @param array $array_to_insert the new data to be inserted |
|
115 | + * @param int | string $offset a known key within $target_array where new data will be inserted |
|
116 | + * @param bool $add_before whether to add new data before or after the offset key |
|
117 | + * @param bool $preserve_keys whether or not to reset numerically indexed arrays |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + public static function insert_into_array( |
|
121 | + $target_array = array(), |
|
122 | + $array_to_insert = array(), |
|
123 | + $offset = null, |
|
124 | + $add_before = true, |
|
125 | + $preserve_keys = true |
|
126 | + ) { |
|
127 | + // ensure incoming arrays are actually arrays |
|
128 | + $target_array = (array) $target_array; |
|
129 | + $array_to_insert = (array) $array_to_insert; |
|
130 | + // if no offset key was supplied |
|
131 | + if (empty($offset)) { |
|
132 | + // use start or end of $target_array based on whether we are adding before or not |
|
133 | + $offset = $add_before ? 0 : count($target_array); |
|
134 | + } |
|
135 | + // if offset key is a string, then find the corresponding numeric location for that element |
|
136 | + $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array)); |
|
137 | + // add one to the offset if adding after |
|
138 | + $offset = $add_before ? $offset : $offset + 1; |
|
139 | + // but ensure offset does not exceed the length of the array |
|
140 | + $offset = $offset > count($target_array) ? count($target_array) : $offset; |
|
141 | + // reindex array ??? |
|
142 | + if ($preserve_keys) { |
|
143 | + // take a slice of the target array from the beginning till the offset, |
|
144 | + // then add the new data |
|
145 | + // then add another slice that starts at the offset and goes till the end |
|
146 | + return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice( |
|
147 | + $target_array, |
|
148 | + $offset, |
|
149 | + null, |
|
150 | + true |
|
151 | + ); |
|
152 | + } else { |
|
153 | + // since we don't want to preserve keys, we can use array_splice |
|
154 | + array_splice($target_array, $offset, 0, $array_to_insert); |
|
155 | + return $target_array; |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + |
|
160 | + /** |
|
161 | + * array_merge() is slow and should never be used while looping over data |
|
162 | + * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster |
|
163 | + * so really this acts more like array_replace( $array1, $array2 ) |
|
164 | + * or a union with the arrays flipped ( $array2 + $array1 ) |
|
165 | + * this saves a few lines of code and improves readability |
|
166 | + * |
|
167 | + * @param array $array1 |
|
168 | + * @param array $array2 |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) |
|
172 | + { |
|
173 | + foreach ($array2 as $key => $value) { |
|
174 | + $array1[ $key ] = $value; |
|
175 | + } |
|
176 | + return $array1; |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * given a flat array like $array = array('A', 'B', 'C') |
|
182 | + * will convert into a multidimensional array like $array[A][B][C] |
|
183 | + * if $final_value is provided and is anything other than null, |
|
184 | + * then that will be set as the value for the innermost array key |
|
185 | + * like so: $array[A][B][C] = $final_value |
|
186 | + * |
|
187 | + * @param array $flat_array |
|
188 | + * @param mixed $final_value |
|
189 | + * @return array |
|
190 | + */ |
|
191 | + public static function convert_array_values_to_keys(array $flat_array, $final_value = null) |
|
192 | + { |
|
193 | + $multidimensional = array(); |
|
194 | + $reference = &$multidimensional; |
|
195 | + foreach ($flat_array as $key) { |
|
196 | + $reference[ $key ] = array(); |
|
197 | + $reference = &$reference[ $key ]; |
|
198 | + } |
|
199 | + if ($final_value !== null) { |
|
200 | + $reference = $final_value; |
|
201 | + } |
|
202 | + return $multidimensional; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential |
|
208 | + * @param array $array |
|
209 | + * @return bool |
|
210 | + */ |
|
211 | + public static function is_array_numerically_and_sequentially_indexed(array $array) |
|
212 | + { |
|
213 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
214 | + } |
|
215 | 215 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | if (is_array($arr)) { |
66 | 66 | $first_item = reset($arr); |
67 | 67 | if (is_array($first_item)) { |
68 | - return true;// yep, there's at least 2 levels to this array |
|
68 | + return true; // yep, there's at least 2 levels to this array |
|
69 | 69 | } else { |
70 | - return false;// nope, only 1 level |
|
70 | + return false; // nope, only 1 level |
|
71 | 71 | } |
72 | 72 | } else { |
73 | - return false;// its not an array at all! |
|
73 | + return false; // its not an array at all! |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function is_set($arr, $index, $default) |
86 | 86 | { |
87 | - return isset($arr[ $index ]) ? $arr[ $index ] : $default; |
|
87 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | public static function merge_arrays_and_overwrite_keys(array $array1, array $array2) |
172 | 172 | { |
173 | 173 | foreach ($array2 as $key => $value) { |
174 | - $array1[ $key ] = $value; |
|
174 | + $array1[$key] = $value; |
|
175 | 175 | } |
176 | 176 | return $array1; |
177 | 177 | } |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | $multidimensional = array(); |
194 | 194 | $reference = &$multidimensional; |
195 | 195 | foreach ($flat_array as $key) { |
196 | - $reference[ $key ] = array(); |
|
197 | - $reference = &$reference[ $key ]; |
|
196 | + $reference[$key] = array(); |
|
197 | + $reference = &$reference[$key]; |
|
198 | 198 | } |
199 | 199 | if ($final_value !== null) { |
200 | 200 | $reference = $final_value; |
@@ -15,673 +15,673 @@ |
||
15 | 15 | class EEH_Event_Query |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Start Date |
|
20 | - * |
|
21 | - * @var $_event_query_month |
|
22 | - */ |
|
23 | - protected static $_event_query_month; |
|
24 | - |
|
25 | - /** |
|
26 | - * Category |
|
27 | - * |
|
28 | - * @var $_event_query_category |
|
29 | - */ |
|
30 | - protected static $_event_query_category; |
|
31 | - |
|
32 | - /** |
|
33 | - * whether to display expired events in the event list |
|
34 | - * |
|
35 | - * @var bool $_show_expired |
|
36 | - */ |
|
37 | - protected static $_event_query_show_expired = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * list of params for controlling how the query results are ordered |
|
41 | - * |
|
42 | - * @var array $_event_query_orderby |
|
43 | - */ |
|
44 | - protected static $_event_query_orderby = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * direction list is sorted |
|
48 | - * |
|
49 | - * @var string $_event_query_sort |
|
50 | - */ |
|
51 | - protected static $_event_query_sort; |
|
52 | - |
|
53 | - /** |
|
54 | - * list of params used to build the query's various clauses |
|
55 | - * |
|
56 | - * @var $_query_params |
|
57 | - */ |
|
58 | - protected static $_query_params = array(); |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public static function add_query_filters() |
|
66 | - { |
|
67 | - // add query filters |
|
68 | - add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param WP_Query $WP_Query |
|
75 | - * @return bool |
|
76 | - */ |
|
77 | - public static function apply_query_filters(WP_Query $WP_Query) |
|
78 | - { |
|
79 | - return ( |
|
80 | - isset($WP_Query->query['post_type']) |
|
81 | - && $WP_Query->query['post_type'] === 'espresso_events' |
|
82 | - ) |
|
83 | - || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param WP_Query $WP_Query |
|
89 | - */ |
|
90 | - public static function filter_query_parts(WP_Query $WP_Query) |
|
91 | - { |
|
92 | - // ONLY add our filters if this isn't the main wp_query, |
|
93 | - // because if this is the main wp_query we already have |
|
94 | - // our cpt strategies take care of adding things in. |
|
95 | - if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
96 | - // build event list query |
|
97 | - add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
98 | - add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
99 | - add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
100 | - add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
101 | - add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $month |
|
109 | - * @param string $category |
|
110 | - * @param bool $show_expired |
|
111 | - * @param string $orderby |
|
112 | - * @param string $sort |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - */ |
|
117 | - public static function set_query_params( |
|
118 | - $month = '', |
|
119 | - $category = '', |
|
120 | - $show_expired = false, |
|
121 | - $orderby = 'start_date', |
|
122 | - $sort = 'ASC' |
|
123 | - ) { |
|
124 | - self::$_query_params = array(); |
|
125 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
126 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
127 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
128 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
129 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * what month should the event list display events for? |
|
136 | - * |
|
137 | - * @param string $month |
|
138 | - * @return string |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - */ |
|
143 | - private static function _display_month($month = '') |
|
144 | - { |
|
145 | - return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month)); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @param string $category |
|
152 | - * @return string |
|
153 | - * @throws InvalidArgumentException |
|
154 | - * @throws InvalidDataTypeException |
|
155 | - * @throws InvalidInterfaceException |
|
156 | - */ |
|
157 | - private static function _event_category_slug($category = '') |
|
158 | - { |
|
159 | - return sanitize_title_with_dashes(EE_Registry::instance()->REQ->get('event_query_category', $category)); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param bool $show_expired |
|
166 | - * @return bool |
|
167 | - * @throws InvalidArgumentException |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - * @throws InvalidInterfaceException |
|
170 | - */ |
|
171 | - private static function _show_expired($show_expired = false) |
|
172 | - { |
|
173 | - // override default expired option if set via filter |
|
174 | - return filter_var( |
|
175 | - EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired), |
|
176 | - FILTER_VALIDATE_BOOLEAN |
|
177 | - ); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @param string $orderby |
|
184 | - * @return array |
|
185 | - * @throws InvalidArgumentException |
|
186 | - * @throws InvalidDataTypeException |
|
187 | - * @throws InvalidInterfaceException |
|
188 | - */ |
|
189 | - private static function _orderby($orderby = 'start_date') |
|
190 | - { |
|
191 | - $event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby); |
|
192 | - $event_query_orderby = is_array($event_query_orderby) |
|
193 | - ? $event_query_orderby |
|
194 | - : explode(',', $event_query_orderby); |
|
195 | - $event_query_orderby = array_map('trim', $event_query_orderby); |
|
196 | - $event_query_orderby = array_map('sanitize_text_field', $event_query_orderby); |
|
197 | - return $event_query_orderby; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @param string $sort |
|
204 | - * @return string |
|
205 | - * @throws InvalidArgumentException |
|
206 | - * @throws InvalidDataTypeException |
|
207 | - * @throws InvalidInterfaceException |
|
208 | - */ |
|
209 | - private static function _sort($sort = 'ASC') |
|
210 | - { |
|
211 | - $sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort); |
|
212 | - return in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
213 | - ? strtoupper($sort) |
|
214 | - : 'ASC'; |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * Filters the clauses for the WP_Query object |
|
221 | - * |
|
222 | - * @param array $clauses array of clauses |
|
223 | - * @param WP_Query $wp_query |
|
224 | - * @return array array of clauses |
|
225 | - */ |
|
226 | - public static function posts_clauses($clauses, WP_Query $wp_query) |
|
227 | - { |
|
228 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
229 | - global $wpdb; |
|
230 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
231 | - } |
|
232 | - return $clauses; |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * @param string $SQL |
|
239 | - * @param WP_Query $wp_query |
|
240 | - * @return string |
|
241 | - * @throws EE_Error |
|
242 | - * @throws InvalidArgumentException |
|
243 | - * @throws InvalidDataTypeException |
|
244 | - * @throws InvalidInterfaceException |
|
245 | - */ |
|
246 | - public static function posts_fields($SQL, WP_Query $wp_query) |
|
247 | - { |
|
248 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
249 | - // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
|
250 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
251 | - } |
|
252 | - return $SQL; |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * @param array $orderby_params |
|
259 | - * @return string |
|
260 | - * @throws EE_Error |
|
261 | - * @throws InvalidArgumentException |
|
262 | - * @throws InvalidDataTypeException |
|
263 | - * @throws InvalidInterfaceException |
|
264 | - */ |
|
265 | - public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
|
266 | - { |
|
267 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
268 | - foreach ($orderby_params as $orderby) { |
|
269 | - switch ($orderby) { |
|
270 | - case 'ticket_start': |
|
271 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
272 | - break; |
|
273 | - case 'ticket_end': |
|
274 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
275 | - break; |
|
276 | - case 'venue_title': |
|
277 | - $SQL .= ', Venue.post_title AS venue_title'; |
|
278 | - break; |
|
279 | - case 'city': |
|
280 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
281 | - break; |
|
282 | - case 'state': |
|
283 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
284 | - break; |
|
285 | - } |
|
286 | - } |
|
287 | - return $SQL; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * @param string $SQL |
|
294 | - * @param WP_Query $wp_query |
|
295 | - * @return string |
|
296 | - * @throws EE_Error |
|
297 | - * @throws InvalidArgumentException |
|
298 | - * @throws InvalidDataTypeException |
|
299 | - * @throws InvalidInterfaceException |
|
300 | - */ |
|
301 | - public static function posts_join($SQL = '', WP_Query $wp_query) |
|
302 | - { |
|
303 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
304 | - // Category |
|
305 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
306 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
307 | - $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
308 | - } |
|
309 | - return $SQL; |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * @param string $SQL |
|
316 | - * @param boolean $show_expired if TRUE, then displayed past events |
|
317 | - * @return string |
|
318 | - * @throws EE_Error |
|
319 | - * @throws InvalidArgumentException |
|
320 | - * @throws InvalidDataTypeException |
|
321 | - * @throws InvalidInterfaceException |
|
322 | - */ |
|
323 | - public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
|
324 | - { |
|
325 | - if (! $show_expired) { |
|
326 | - $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | - $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
328 | - // don't add if this is already in the SQL |
|
329 | - if (strpos($SQL, $join) === false) { |
|
330 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
331 | - } |
|
332 | - } |
|
333 | - return $SQL; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @param string $SQL |
|
340 | - * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get |
|
341 | - * used for anything yet |
|
342 | - * @return string |
|
343 | - */ |
|
344 | - public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
|
345 | - { |
|
346 | - if (! empty($join_terms)) { |
|
347 | - global $wpdb; |
|
348 | - $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
349 | - $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
350 | - $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
351 | - } |
|
352 | - return $SQL; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * usage: $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
359 | - * |
|
360 | - * @param string $SQL |
|
361 | - * @param array $orderby_params |
|
362 | - * @return string |
|
363 | - * @throws EE_Error |
|
364 | - * @throws InvalidArgumentException |
|
365 | - * @throws InvalidDataTypeException |
|
366 | - * @throws InvalidInterfaceException |
|
367 | - */ |
|
368 | - public static function posts_join_for_orderby($SQL = '', array $orderby_params = array()) |
|
369 | - { |
|
370 | - foreach ($orderby_params as $orderby) { |
|
371 | - switch ($orderby) { |
|
372 | - case 'ticket_start': |
|
373 | - case 'ticket_end': |
|
374 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
|
375 | - $SQL, |
|
376 | - EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
377 | - ); |
|
378 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
379 | - $SQL .= ' ON ('; |
|
380 | - $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
381 | - $SQL .= ' = '; |
|
382 | - $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
383 | - $SQL .= ' )'; |
|
384 | - break; |
|
385 | - case 'venue_title': |
|
386 | - case 'city': |
|
387 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
388 | - break; |
|
389 | - case 'state': |
|
390 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
391 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
392 | - break; |
|
393 | - case 'start_date': |
|
394 | - default: |
|
395 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
396 | - break; |
|
397 | - } |
|
398 | - } |
|
399 | - return $SQL; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * @param string $SQL |
|
406 | - * @param string $join |
|
407 | - * @return string |
|
408 | - * @throws EE_Error |
|
409 | - * @throws InvalidArgumentException |
|
410 | - * @throws InvalidDataTypeException |
|
411 | - * @throws InvalidInterfaceException |
|
412 | - */ |
|
413 | - protected static function _posts_join_for_datetime($SQL = '', $join = '') |
|
414 | - { |
|
415 | - if (! empty($join)) { |
|
416 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
417 | - if (strpos($SQL, $join) === false) { |
|
418 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
419 | - } |
|
420 | - } |
|
421 | - return ''; |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * @param string $SQL |
|
428 | - * @return string |
|
429 | - * @throws EE_Error |
|
430 | - * @throws InvalidArgumentException |
|
431 | - * @throws InvalidDataTypeException |
|
432 | - * @throws InvalidInterfaceException |
|
433 | - */ |
|
434 | - protected static function _posts_join_for_event_venue($SQL = '') |
|
435 | - { |
|
436 | - // Event Venue table name |
|
437 | - $event_venue_table = EEM_Event_Venue::instance()->table(); |
|
438 | - // generate conditions for: Event <=> Event Venue JOIN clause |
|
439 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = '; |
|
440 | - $event_to_event_venue_join .= $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
441 | - // don't add joins if they have already been added |
|
442 | - if (strpos($SQL, $event_to_event_venue_join) === false) { |
|
443 | - // Venue table name |
|
444 | - $venue_table = EEM_Venue::instance()->table(); |
|
445 | - // Venue table pk |
|
446 | - $venue_table_pk = EEM_Venue::instance()->primary_key_name(); |
|
447 | - // Venue Meta table name |
|
448 | - $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
449 | - // generate JOIN clause for: Event <=> Event Venue |
|
450 | - $venue_SQL = " LEFT JOIN $event_venue_table ON ( $event_to_event_venue_join )"; |
|
451 | - // generate JOIN clause for: Event Venue <=> Venue |
|
452 | - $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
|
453 | - // generate JOIN clause for: Venue <=> Venue Meta |
|
454 | - $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
|
455 | - unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
456 | - return $venue_SQL; |
|
457 | - } |
|
458 | - unset($event_venue_table, $event_to_event_venue_join); |
|
459 | - return ''; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * @param string $SQL |
|
466 | - * @return string |
|
467 | - * @throws EE_Error |
|
468 | - * @throws InvalidArgumentException |
|
469 | - * @throws InvalidDataTypeException |
|
470 | - * @throws InvalidInterfaceException |
|
471 | - */ |
|
472 | - protected static function _posts_join_for_venue_state($SQL = '') |
|
473 | - { |
|
474 | - // Venue Meta table name |
|
475 | - $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
476 | - // State table name |
|
477 | - $state_table = EEM_State::instance()->table(); |
|
478 | - // State table pk |
|
479 | - $state_table_pk = EEM_State::instance()->primary_key_name(); |
|
480 | - // verify vars |
|
481 | - if ($venue_meta_table && $state_table && $state_table_pk) { |
|
482 | - // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
|
483 | - $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
|
484 | - // don't add join if it has already been added |
|
485 | - if (strpos($SQL, $join) === false) { |
|
486 | - unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
487 | - return " LEFT JOIN $state_table ON ( $join )"; |
|
488 | - } |
|
489 | - } |
|
490 | - unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
491 | - return ''; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * @param string $SQL |
|
498 | - * @param WP_Query $wp_query |
|
499 | - * @return string |
|
500 | - * @throws EE_Error |
|
501 | - * @throws InvalidArgumentException |
|
502 | - * @throws InvalidDataTypeException |
|
503 | - * @throws InvalidInterfaceException |
|
504 | - */ |
|
505 | - public static function posts_where($SQL = '', WP_Query $wp_query) |
|
506 | - { |
|
507 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
508 | - // Show Expired ? |
|
509 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
510 | - // Category |
|
511 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
512 | - // Start Date |
|
513 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
514 | - } |
|
515 | - return $SQL; |
|
516 | - } |
|
517 | - |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * @param boolean $show_expired if TRUE, then displayed past events |
|
522 | - * @return string |
|
523 | - * @throws EE_Error |
|
524 | - * @throws InvalidArgumentException |
|
525 | - * @throws InvalidDataTypeException |
|
526 | - * @throws InvalidInterfaceException |
|
527 | - */ |
|
528 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
529 | - { |
|
530 | - return ! $show_expired |
|
531 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
532 | - : ''; |
|
533 | - } |
|
534 | - |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * @param boolean $event_category_slug |
|
539 | - * @return string |
|
540 | - */ |
|
541 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
542 | - { |
|
543 | - global $wpdb; |
|
544 | - return ! empty($event_category_slug) |
|
545 | - ? $wpdb->prepare(" AND {$wpdb->terms}.slug = %s ", $event_category_slug) |
|
546 | - : ''; |
|
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - |
|
551 | - /** |
|
552 | - * @param boolean $month |
|
553 | - * @return string |
|
554 | - * @throws EE_Error |
|
555 | - * @throws InvalidArgumentException |
|
556 | - * @throws InvalidDataTypeException |
|
557 | - * @throws InvalidInterfaceException |
|
558 | - */ |
|
559 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
560 | - { |
|
561 | - $SQL = ''; |
|
562 | - if (! empty($month)) { |
|
563 | - $datetime_table = EEM_Datetime::instance()->table(); |
|
564 | - // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
565 | - $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
|
566 | - $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
567 | - // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
568 | - $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
|
569 | - $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
570 | - } |
|
571 | - return $SQL; |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * @param string $SQL |
|
578 | - * @param WP_Query $wp_query |
|
579 | - * @return string |
|
580 | - * @throws EE_Error |
|
581 | - * @throws InvalidArgumentException |
|
582 | - * @throws InvalidDataTypeException |
|
583 | - * @throws InvalidInterfaceException |
|
584 | - */ |
|
585 | - public static function posts_orderby($SQL = '', WP_Query $wp_query) |
|
586 | - { |
|
587 | - if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
588 | - $SQL = EEH_Event_Query::posts_orderby_sql( |
|
589 | - EEH_Event_Query::$_event_query_orderby, |
|
590 | - EEH_Event_Query::$_event_query_sort |
|
591 | - ); |
|
592 | - } |
|
593 | - return $SQL; |
|
594 | - } |
|
595 | - |
|
596 | - |
|
597 | - |
|
598 | - /** |
|
599 | - * posts_orderby_sql |
|
600 | - * possible parameters: |
|
601 | - * ID |
|
602 | - * start_date |
|
603 | - * end_date |
|
604 | - * event_name |
|
605 | - * category_slug |
|
606 | - * ticket_start |
|
607 | - * ticket_end |
|
608 | - * venue_title |
|
609 | - * city |
|
610 | - * state |
|
611 | - * **IMPORTANT** |
|
612 | - * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
613 | - * or else some of the table references below will result in MySQL errors |
|
614 | - * |
|
615 | - * @param array $orderby_params |
|
616 | - * @param string $sort |
|
617 | - * @return string |
|
618 | - * @throws EE_Error |
|
619 | - * @throws InvalidArgumentException |
|
620 | - * @throws InvalidDataTypeException |
|
621 | - * @throws InvalidInterfaceException |
|
622 | - */ |
|
623 | - public static function posts_orderby_sql(array $orderby_params = array(), $sort = 'ASC') |
|
624 | - { |
|
625 | - global $wpdb; |
|
626 | - $SQL = ''; |
|
627 | - $counter = 0; |
|
628 | - $sort = in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
629 | - ? strtoupper($sort) |
|
630 | - : 'ASC'; |
|
631 | - // make sure 'orderby' is set in query params |
|
632 | - if (! isset(self::$_query_params['orderby'])) { |
|
633 | - self::$_query_params['orderby'] = array(); |
|
634 | - } |
|
635 | - // loop thru $orderby_params (type cast as array) |
|
636 | - foreach ($orderby_params as $orderby) { |
|
637 | - // check if we have already added this param |
|
638 | - if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
639 | - // if so then remove from the $orderby_params so that the count() method below is accurate |
|
640 | - unset($orderby_params[ $orderby ]); |
|
641 | - // then bump ahead to the next param |
|
642 | - continue; |
|
643 | - } |
|
644 | - // this will ad a comma depending on whether this is the first or last param |
|
645 | - $glue = $counter === 0 || $counter === count($orderby_params) ? ' ' : ', '; |
|
646 | - // ok what's we dealing with? |
|
647 | - switch ($orderby) { |
|
648 | - case 'id': |
|
649 | - case 'ID': |
|
650 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
651 | - break; |
|
652 | - case 'end_date': |
|
653 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
654 | - break; |
|
655 | - case 'event_name': |
|
656 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
657 | - break; |
|
658 | - case 'category_slug': |
|
659 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
660 | - break; |
|
661 | - case 'ticket_start': |
|
662 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
663 | - break; |
|
664 | - case 'ticket_end': |
|
665 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
666 | - break; |
|
667 | - case 'venue_title': |
|
668 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
669 | - break; |
|
670 | - case 'city': |
|
671 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
672 | - break; |
|
673 | - case 'state': |
|
674 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
675 | - break; |
|
676 | - case 'start_date': |
|
677 | - default: |
|
678 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
679 | - break; |
|
680 | - } |
|
681 | - // add to array of orderby params that have been added |
|
682 | - self::$_query_params['orderby'][ $orderby ] = true; |
|
683 | - $counter++; |
|
684 | - } |
|
685 | - return $SQL; |
|
686 | - } |
|
18 | + /** |
|
19 | + * Start Date |
|
20 | + * |
|
21 | + * @var $_event_query_month |
|
22 | + */ |
|
23 | + protected static $_event_query_month; |
|
24 | + |
|
25 | + /** |
|
26 | + * Category |
|
27 | + * |
|
28 | + * @var $_event_query_category |
|
29 | + */ |
|
30 | + protected static $_event_query_category; |
|
31 | + |
|
32 | + /** |
|
33 | + * whether to display expired events in the event list |
|
34 | + * |
|
35 | + * @var bool $_show_expired |
|
36 | + */ |
|
37 | + protected static $_event_query_show_expired = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * list of params for controlling how the query results are ordered |
|
41 | + * |
|
42 | + * @var array $_event_query_orderby |
|
43 | + */ |
|
44 | + protected static $_event_query_orderby = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * direction list is sorted |
|
48 | + * |
|
49 | + * @var string $_event_query_sort |
|
50 | + */ |
|
51 | + protected static $_event_query_sort; |
|
52 | + |
|
53 | + /** |
|
54 | + * list of params used to build the query's various clauses |
|
55 | + * |
|
56 | + * @var $_query_params |
|
57 | + */ |
|
58 | + protected static $_query_params = array(); |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public static function add_query_filters() |
|
66 | + { |
|
67 | + // add query filters |
|
68 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param WP_Query $WP_Query |
|
75 | + * @return bool |
|
76 | + */ |
|
77 | + public static function apply_query_filters(WP_Query $WP_Query) |
|
78 | + { |
|
79 | + return ( |
|
80 | + isset($WP_Query->query['post_type']) |
|
81 | + && $WP_Query->query['post_type'] === 'espresso_events' |
|
82 | + ) |
|
83 | + || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param WP_Query $WP_Query |
|
89 | + */ |
|
90 | + public static function filter_query_parts(WP_Query $WP_Query) |
|
91 | + { |
|
92 | + // ONLY add our filters if this isn't the main wp_query, |
|
93 | + // because if this is the main wp_query we already have |
|
94 | + // our cpt strategies take care of adding things in. |
|
95 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
96 | + // build event list query |
|
97 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
98 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
99 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
100 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
101 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $month |
|
109 | + * @param string $category |
|
110 | + * @param bool $show_expired |
|
111 | + * @param string $orderby |
|
112 | + * @param string $sort |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + */ |
|
117 | + public static function set_query_params( |
|
118 | + $month = '', |
|
119 | + $category = '', |
|
120 | + $show_expired = false, |
|
121 | + $orderby = 'start_date', |
|
122 | + $sort = 'ASC' |
|
123 | + ) { |
|
124 | + self::$_query_params = array(); |
|
125 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
126 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
127 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
128 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
129 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * what month should the event list display events for? |
|
136 | + * |
|
137 | + * @param string $month |
|
138 | + * @return string |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + */ |
|
143 | + private static function _display_month($month = '') |
|
144 | + { |
|
145 | + return sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month', $month)); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @param string $category |
|
152 | + * @return string |
|
153 | + * @throws InvalidArgumentException |
|
154 | + * @throws InvalidDataTypeException |
|
155 | + * @throws InvalidInterfaceException |
|
156 | + */ |
|
157 | + private static function _event_category_slug($category = '') |
|
158 | + { |
|
159 | + return sanitize_title_with_dashes(EE_Registry::instance()->REQ->get('event_query_category', $category)); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param bool $show_expired |
|
166 | + * @return bool |
|
167 | + * @throws InvalidArgumentException |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + * @throws InvalidInterfaceException |
|
170 | + */ |
|
171 | + private static function _show_expired($show_expired = false) |
|
172 | + { |
|
173 | + // override default expired option if set via filter |
|
174 | + return filter_var( |
|
175 | + EE_Registry::instance()->REQ->get('event_query_show_expired', $show_expired), |
|
176 | + FILTER_VALIDATE_BOOLEAN |
|
177 | + ); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @param string $orderby |
|
184 | + * @return array |
|
185 | + * @throws InvalidArgumentException |
|
186 | + * @throws InvalidDataTypeException |
|
187 | + * @throws InvalidInterfaceException |
|
188 | + */ |
|
189 | + private static function _orderby($orderby = 'start_date') |
|
190 | + { |
|
191 | + $event_query_orderby = EE_Registry::instance()->REQ->get('event_query_orderby', $orderby); |
|
192 | + $event_query_orderby = is_array($event_query_orderby) |
|
193 | + ? $event_query_orderby |
|
194 | + : explode(',', $event_query_orderby); |
|
195 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
196 | + $event_query_orderby = array_map('sanitize_text_field', $event_query_orderby); |
|
197 | + return $event_query_orderby; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @param string $sort |
|
204 | + * @return string |
|
205 | + * @throws InvalidArgumentException |
|
206 | + * @throws InvalidDataTypeException |
|
207 | + * @throws InvalidInterfaceException |
|
208 | + */ |
|
209 | + private static function _sort($sort = 'ASC') |
|
210 | + { |
|
211 | + $sort = EE_Registry::instance()->REQ->get('event_query_sort', $sort); |
|
212 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
213 | + ? strtoupper($sort) |
|
214 | + : 'ASC'; |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * Filters the clauses for the WP_Query object |
|
221 | + * |
|
222 | + * @param array $clauses array of clauses |
|
223 | + * @param WP_Query $wp_query |
|
224 | + * @return array array of clauses |
|
225 | + */ |
|
226 | + public static function posts_clauses($clauses, WP_Query $wp_query) |
|
227 | + { |
|
228 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
229 | + global $wpdb; |
|
230 | + $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
231 | + } |
|
232 | + return $clauses; |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * @param string $SQL |
|
239 | + * @param WP_Query $wp_query |
|
240 | + * @return string |
|
241 | + * @throws EE_Error |
|
242 | + * @throws InvalidArgumentException |
|
243 | + * @throws InvalidDataTypeException |
|
244 | + * @throws InvalidInterfaceException |
|
245 | + */ |
|
246 | + public static function posts_fields($SQL, WP_Query $wp_query) |
|
247 | + { |
|
248 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
249 | + // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
|
250 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
251 | + } |
|
252 | + return $SQL; |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * @param array $orderby_params |
|
259 | + * @return string |
|
260 | + * @throws EE_Error |
|
261 | + * @throws InvalidArgumentException |
|
262 | + * @throws InvalidDataTypeException |
|
263 | + * @throws InvalidInterfaceException |
|
264 | + */ |
|
265 | + public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
|
266 | + { |
|
267 | + $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
268 | + foreach ($orderby_params as $orderby) { |
|
269 | + switch ($orderby) { |
|
270 | + case 'ticket_start': |
|
271 | + $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
272 | + break; |
|
273 | + case 'ticket_end': |
|
274 | + $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
275 | + break; |
|
276 | + case 'venue_title': |
|
277 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
278 | + break; |
|
279 | + case 'city': |
|
280 | + $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
281 | + break; |
|
282 | + case 'state': |
|
283 | + $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
284 | + break; |
|
285 | + } |
|
286 | + } |
|
287 | + return $SQL; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * @param string $SQL |
|
294 | + * @param WP_Query $wp_query |
|
295 | + * @return string |
|
296 | + * @throws EE_Error |
|
297 | + * @throws InvalidArgumentException |
|
298 | + * @throws InvalidDataTypeException |
|
299 | + * @throws InvalidInterfaceException |
|
300 | + */ |
|
301 | + public static function posts_join($SQL = '', WP_Query $wp_query) |
|
302 | + { |
|
303 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
304 | + // Category |
|
305 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
306 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
307 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
308 | + } |
|
309 | + return $SQL; |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * @param string $SQL |
|
316 | + * @param boolean $show_expired if TRUE, then displayed past events |
|
317 | + * @return string |
|
318 | + * @throws EE_Error |
|
319 | + * @throws InvalidArgumentException |
|
320 | + * @throws InvalidDataTypeException |
|
321 | + * @throws InvalidInterfaceException |
|
322 | + */ |
|
323 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
|
324 | + { |
|
325 | + if (! $show_expired) { |
|
326 | + $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | + $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
328 | + // don't add if this is already in the SQL |
|
329 | + if (strpos($SQL, $join) === false) { |
|
330 | + $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
331 | + } |
|
332 | + } |
|
333 | + return $SQL; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @param string $SQL |
|
340 | + * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get |
|
341 | + * used for anything yet |
|
342 | + * @return string |
|
343 | + */ |
|
344 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
|
345 | + { |
|
346 | + if (! empty($join_terms)) { |
|
347 | + global $wpdb; |
|
348 | + $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
|
349 | + $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
|
350 | + $SQL .= " LEFT JOIN $wpdb->terms ON ($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id) "; |
|
351 | + } |
|
352 | + return $SQL; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * usage: $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
359 | + * |
|
360 | + * @param string $SQL |
|
361 | + * @param array $orderby_params |
|
362 | + * @return string |
|
363 | + * @throws EE_Error |
|
364 | + * @throws InvalidArgumentException |
|
365 | + * @throws InvalidDataTypeException |
|
366 | + * @throws InvalidInterfaceException |
|
367 | + */ |
|
368 | + public static function posts_join_for_orderby($SQL = '', array $orderby_params = array()) |
|
369 | + { |
|
370 | + foreach ($orderby_params as $orderby) { |
|
371 | + switch ($orderby) { |
|
372 | + case 'ticket_start': |
|
373 | + case 'ticket_end': |
|
374 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
|
375 | + $SQL, |
|
376 | + EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
377 | + ); |
|
378 | + $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
379 | + $SQL .= ' ON ('; |
|
380 | + $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
381 | + $SQL .= ' = '; |
|
382 | + $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
383 | + $SQL .= ' )'; |
|
384 | + break; |
|
385 | + case 'venue_title': |
|
386 | + case 'city': |
|
387 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
388 | + break; |
|
389 | + case 'state': |
|
390 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
391 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
392 | + break; |
|
393 | + case 'start_date': |
|
394 | + default: |
|
395 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
396 | + break; |
|
397 | + } |
|
398 | + } |
|
399 | + return $SQL; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * @param string $SQL |
|
406 | + * @param string $join |
|
407 | + * @return string |
|
408 | + * @throws EE_Error |
|
409 | + * @throws InvalidArgumentException |
|
410 | + * @throws InvalidDataTypeException |
|
411 | + * @throws InvalidInterfaceException |
|
412 | + */ |
|
413 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') |
|
414 | + { |
|
415 | + if (! empty($join)) { |
|
416 | + $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
417 | + if (strpos($SQL, $join) === false) { |
|
418 | + return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
419 | + } |
|
420 | + } |
|
421 | + return ''; |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * @param string $SQL |
|
428 | + * @return string |
|
429 | + * @throws EE_Error |
|
430 | + * @throws InvalidArgumentException |
|
431 | + * @throws InvalidDataTypeException |
|
432 | + * @throws InvalidInterfaceException |
|
433 | + */ |
|
434 | + protected static function _posts_join_for_event_venue($SQL = '') |
|
435 | + { |
|
436 | + // Event Venue table name |
|
437 | + $event_venue_table = EEM_Event_Venue::instance()->table(); |
|
438 | + // generate conditions for: Event <=> Event Venue JOIN clause |
|
439 | + $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = '; |
|
440 | + $event_to_event_venue_join .= $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
441 | + // don't add joins if they have already been added |
|
442 | + if (strpos($SQL, $event_to_event_venue_join) === false) { |
|
443 | + // Venue table name |
|
444 | + $venue_table = EEM_Venue::instance()->table(); |
|
445 | + // Venue table pk |
|
446 | + $venue_table_pk = EEM_Venue::instance()->primary_key_name(); |
|
447 | + // Venue Meta table name |
|
448 | + $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
449 | + // generate JOIN clause for: Event <=> Event Venue |
|
450 | + $venue_SQL = " LEFT JOIN $event_venue_table ON ( $event_to_event_venue_join )"; |
|
451 | + // generate JOIN clause for: Event Venue <=> Venue |
|
452 | + $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
|
453 | + // generate JOIN clause for: Venue <=> Venue Meta |
|
454 | + $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
|
455 | + unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
456 | + return $venue_SQL; |
|
457 | + } |
|
458 | + unset($event_venue_table, $event_to_event_venue_join); |
|
459 | + return ''; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * @param string $SQL |
|
466 | + * @return string |
|
467 | + * @throws EE_Error |
|
468 | + * @throws InvalidArgumentException |
|
469 | + * @throws InvalidDataTypeException |
|
470 | + * @throws InvalidInterfaceException |
|
471 | + */ |
|
472 | + protected static function _posts_join_for_venue_state($SQL = '') |
|
473 | + { |
|
474 | + // Venue Meta table name |
|
475 | + $venue_meta_table = EEM_Venue::instance()->second_table(); |
|
476 | + // State table name |
|
477 | + $state_table = EEM_State::instance()->table(); |
|
478 | + // State table pk |
|
479 | + $state_table_pk = EEM_State::instance()->primary_key_name(); |
|
480 | + // verify vars |
|
481 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
482 | + // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
|
483 | + $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
|
484 | + // don't add join if it has already been added |
|
485 | + if (strpos($SQL, $join) === false) { |
|
486 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
487 | + return " LEFT JOIN $state_table ON ( $join )"; |
|
488 | + } |
|
489 | + } |
|
490 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
491 | + return ''; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * @param string $SQL |
|
498 | + * @param WP_Query $wp_query |
|
499 | + * @return string |
|
500 | + * @throws EE_Error |
|
501 | + * @throws InvalidArgumentException |
|
502 | + * @throws InvalidDataTypeException |
|
503 | + * @throws InvalidInterfaceException |
|
504 | + */ |
|
505 | + public static function posts_where($SQL = '', WP_Query $wp_query) |
|
506 | + { |
|
507 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
508 | + // Show Expired ? |
|
509 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
510 | + // Category |
|
511 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
512 | + // Start Date |
|
513 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
514 | + } |
|
515 | + return $SQL; |
|
516 | + } |
|
517 | + |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * @param boolean $show_expired if TRUE, then displayed past events |
|
522 | + * @return string |
|
523 | + * @throws EE_Error |
|
524 | + * @throws InvalidArgumentException |
|
525 | + * @throws InvalidDataTypeException |
|
526 | + * @throws InvalidInterfaceException |
|
527 | + */ |
|
528 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
529 | + { |
|
530 | + return ! $show_expired |
|
531 | + ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
532 | + : ''; |
|
533 | + } |
|
534 | + |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * @param boolean $event_category_slug |
|
539 | + * @return string |
|
540 | + */ |
|
541 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
542 | + { |
|
543 | + global $wpdb; |
|
544 | + return ! empty($event_category_slug) |
|
545 | + ? $wpdb->prepare(" AND {$wpdb->terms}.slug = %s ", $event_category_slug) |
|
546 | + : ''; |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + |
|
551 | + /** |
|
552 | + * @param boolean $month |
|
553 | + * @return string |
|
554 | + * @throws EE_Error |
|
555 | + * @throws InvalidArgumentException |
|
556 | + * @throws InvalidDataTypeException |
|
557 | + * @throws InvalidInterfaceException |
|
558 | + */ |
|
559 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
560 | + { |
|
561 | + $SQL = ''; |
|
562 | + if (! empty($month)) { |
|
563 | + $datetime_table = EEM_Datetime::instance()->table(); |
|
564 | + // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
|
565 | + $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
|
566 | + $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
567 | + // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
|
568 | + $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
|
569 | + $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
570 | + } |
|
571 | + return $SQL; |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * @param string $SQL |
|
578 | + * @param WP_Query $wp_query |
|
579 | + * @return string |
|
580 | + * @throws EE_Error |
|
581 | + * @throws InvalidArgumentException |
|
582 | + * @throws InvalidDataTypeException |
|
583 | + * @throws InvalidInterfaceException |
|
584 | + */ |
|
585 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) |
|
586 | + { |
|
587 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
588 | + $SQL = EEH_Event_Query::posts_orderby_sql( |
|
589 | + EEH_Event_Query::$_event_query_orderby, |
|
590 | + EEH_Event_Query::$_event_query_sort |
|
591 | + ); |
|
592 | + } |
|
593 | + return $SQL; |
|
594 | + } |
|
595 | + |
|
596 | + |
|
597 | + |
|
598 | + /** |
|
599 | + * posts_orderby_sql |
|
600 | + * possible parameters: |
|
601 | + * ID |
|
602 | + * start_date |
|
603 | + * end_date |
|
604 | + * event_name |
|
605 | + * category_slug |
|
606 | + * ticket_start |
|
607 | + * ticket_end |
|
608 | + * venue_title |
|
609 | + * city |
|
610 | + * state |
|
611 | + * **IMPORTANT** |
|
612 | + * make sure to also send the $orderby_params array to the posts_join_for_orderby() method |
|
613 | + * or else some of the table references below will result in MySQL errors |
|
614 | + * |
|
615 | + * @param array $orderby_params |
|
616 | + * @param string $sort |
|
617 | + * @return string |
|
618 | + * @throws EE_Error |
|
619 | + * @throws InvalidArgumentException |
|
620 | + * @throws InvalidDataTypeException |
|
621 | + * @throws InvalidInterfaceException |
|
622 | + */ |
|
623 | + public static function posts_orderby_sql(array $orderby_params = array(), $sort = 'ASC') |
|
624 | + { |
|
625 | + global $wpdb; |
|
626 | + $SQL = ''; |
|
627 | + $counter = 0; |
|
628 | + $sort = in_array($sort, array('ASC', 'asc', 'DESC', 'desc'), true) |
|
629 | + ? strtoupper($sort) |
|
630 | + : 'ASC'; |
|
631 | + // make sure 'orderby' is set in query params |
|
632 | + if (! isset(self::$_query_params['orderby'])) { |
|
633 | + self::$_query_params['orderby'] = array(); |
|
634 | + } |
|
635 | + // loop thru $orderby_params (type cast as array) |
|
636 | + foreach ($orderby_params as $orderby) { |
|
637 | + // check if we have already added this param |
|
638 | + if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
639 | + // if so then remove from the $orderby_params so that the count() method below is accurate |
|
640 | + unset($orderby_params[ $orderby ]); |
|
641 | + // then bump ahead to the next param |
|
642 | + continue; |
|
643 | + } |
|
644 | + // this will ad a comma depending on whether this is the first or last param |
|
645 | + $glue = $counter === 0 || $counter === count($orderby_params) ? ' ' : ', '; |
|
646 | + // ok what's we dealing with? |
|
647 | + switch ($orderby) { |
|
648 | + case 'id': |
|
649 | + case 'ID': |
|
650 | + $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
651 | + break; |
|
652 | + case 'end_date': |
|
653 | + $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
654 | + break; |
|
655 | + case 'event_name': |
|
656 | + $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
657 | + break; |
|
658 | + case 'category_slug': |
|
659 | + $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
660 | + break; |
|
661 | + case 'ticket_start': |
|
662 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
663 | + break; |
|
664 | + case 'ticket_end': |
|
665 | + $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
666 | + break; |
|
667 | + case 'venue_title': |
|
668 | + $SQL .= $glue . 'venue_title ' . $sort; |
|
669 | + break; |
|
670 | + case 'city': |
|
671 | + $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
672 | + break; |
|
673 | + case 'state': |
|
674 | + $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
675 | + break; |
|
676 | + case 'start_date': |
|
677 | + default: |
|
678 | + $SQL .= $glue . ' event_start_date ' . $sort; |
|
679 | + break; |
|
680 | + } |
|
681 | + // add to array of orderby params that have been added |
|
682 | + self::$_query_params['orderby'][ $orderby ] = true; |
|
683 | + $counter++; |
|
684 | + } |
|
685 | + return $SQL; |
|
686 | + } |
|
687 | 687 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | if (EEH_Event_Query::apply_query_filters($wp_query)) { |
229 | 229 | global $wpdb; |
230 | - $clauses['groupby'] = $wpdb->posts . '.ID '; |
|
230 | + $clauses['groupby'] = $wpdb->posts.'.ID '; |
|
231 | 231 | } |
232 | 232 | return $clauses; |
233 | 233 | } |
@@ -264,23 +264,23 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public static function posts_fields_sql_for_orderby(array $orderby_params = array()) |
266 | 266 | { |
267 | - $SQL = ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date '; |
|
267 | + $SQL = ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date '; |
|
268 | 268 | foreach ($orderby_params as $orderby) { |
269 | 269 | switch ($orderby) { |
270 | 270 | case 'ticket_start': |
271 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date'; |
|
271 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
272 | 272 | break; |
273 | 273 | case 'ticket_end': |
274 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date'; |
|
274 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
275 | 275 | break; |
276 | 276 | case 'venue_title': |
277 | 277 | $SQL .= ', Venue.post_title AS venue_title'; |
278 | 278 | break; |
279 | 279 | case 'city': |
280 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city'; |
|
280 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
281 | 281 | break; |
282 | 282 | case 'state': |
283 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name'; |
|
283 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
284 | 284 | break; |
285 | 285 | } |
286 | 286 | } |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = false) |
324 | 324 | { |
325 | - if (! $show_expired) { |
|
326 | - $join = EEM_Event::instance()->table() . '.ID = '; |
|
327 | - $join .= EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
325 | + if ( ! $show_expired) { |
|
326 | + $join = EEM_Event::instance()->table().'.ID = '; |
|
327 | + $join .= EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
328 | 328 | // don't add if this is already in the SQL |
329 | 329 | if (strpos($SQL, $join) === false) { |
330 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
330 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | return $SQL; |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') |
345 | 345 | { |
346 | - if (! empty($join_terms)) { |
|
346 | + if ( ! empty($join_terms)) { |
|
347 | 347 | global $wpdb; |
348 | 348 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
349 | 349 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | case 'ticket_end': |
374 | 374 | $SQL .= EEH_Event_Query::_posts_join_for_datetime( |
375 | 375 | $SQL, |
376 | - EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() |
|
376 | + EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name() |
|
377 | 377 | ); |
378 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table(); |
|
378 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table(); |
|
379 | 379 | $SQL .= ' ON ('; |
380 | - $SQL .= EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
380 | + $SQL .= EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name(); |
|
381 | 381 | $SQL .= ' = '; |
382 | - $SQL .= EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name(); |
|
382 | + $SQL .= EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name(); |
|
383 | 383 | $SQL .= ' )'; |
384 | 384 | break; |
385 | 385 | case 'venue_title': |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | break; |
393 | 393 | case 'start_date': |
394 | 394 | default: |
395 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID'); |
|
395 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
396 | 396 | break; |
397 | 397 | } |
398 | 398 | } |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | protected static function _posts_join_for_datetime($SQL = '', $join = '') |
414 | 414 | { |
415 | - if (! empty($join)) { |
|
416 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
415 | + if ( ! empty($join)) { |
|
416 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
417 | 417 | if (strpos($SQL, $join) === false) { |
418 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
418 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | return ''; |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | // Event Venue table name |
437 | 437 | $event_venue_table = EEM_Event_Venue::instance()->table(); |
438 | 438 | // generate conditions for: Event <=> Event Venue JOIN clause |
439 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = '; |
|
440 | - $event_to_event_venue_join .= $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
439 | + $event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '; |
|
440 | + $event_to_event_venue_join .= $event_venue_table.'.'.EEM_Event::instance()->primary_key_name(); |
|
441 | 441 | // don't add joins if they have already been added |
442 | 442 | if (strpos($SQL, $event_to_event_venue_join) === false) { |
443 | 443 | // Venue table name |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | public static function posts_where_sql_for_show_expired($show_expired = false) |
529 | 529 | { |
530 | 530 | return ! $show_expired |
531 | - ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > \'' . current_time('mysql', true) . '\' ' |
|
531 | + ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > \''.current_time('mysql', true).'\' ' |
|
532 | 532 | : ''; |
533 | 533 | } |
534 | 534 | |
@@ -559,14 +559,14 @@ discard block |
||
559 | 559 | public static function posts_where_sql_for_event_list_month($month = null) |
560 | 560 | { |
561 | 561 | $SQL = ''; |
562 | - if (! empty($month)) { |
|
562 | + if ( ! empty($month)) { |
|
563 | 563 | $datetime_table = EEM_Datetime::instance()->table(); |
564 | 564 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
565 | 565 | $SQL = " AND {$datetime_table}.DTT_EVT_start <= '"; |
566 | - $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "'"; |
|
566 | + $SQL .= date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month))."'"; |
|
567 | 567 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
568 | 568 | $SQL .= " AND {$datetime_table}.DTT_EVT_end >= '"; |
569 | - $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . "' "; |
|
569 | + $SQL .= date('Y-m-01 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month))."' "; |
|
570 | 570 | } |
571 | 571 | return $SQL; |
572 | 572 | } |
@@ -629,15 +629,15 @@ discard block |
||
629 | 629 | ? strtoupper($sort) |
630 | 630 | : 'ASC'; |
631 | 631 | // make sure 'orderby' is set in query params |
632 | - if (! isset(self::$_query_params['orderby'])) { |
|
632 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
633 | 633 | self::$_query_params['orderby'] = array(); |
634 | 634 | } |
635 | 635 | // loop thru $orderby_params (type cast as array) |
636 | 636 | foreach ($orderby_params as $orderby) { |
637 | 637 | // check if we have already added this param |
638 | - if (isset(self::$_query_params['orderby'][ $orderby ])) { |
|
638 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
639 | 639 | // if so then remove from the $orderby_params so that the count() method below is accurate |
640 | - unset($orderby_params[ $orderby ]); |
|
640 | + unset($orderby_params[$orderby]); |
|
641 | 641 | // then bump ahead to the next param |
642 | 642 | continue; |
643 | 643 | } |
@@ -647,39 +647,39 @@ discard block |
||
647 | 647 | switch ($orderby) { |
648 | 648 | case 'id': |
649 | 649 | case 'ID': |
650 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
650 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
651 | 651 | break; |
652 | 652 | case 'end_date': |
653 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
653 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
654 | 654 | break; |
655 | 655 | case 'event_name': |
656 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
656 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
657 | 657 | break; |
658 | 658 | case 'category_slug': |
659 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
659 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
660 | 660 | break; |
661 | 661 | case 'ticket_start': |
662 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
662 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
663 | 663 | break; |
664 | 664 | case 'ticket_end': |
665 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
665 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
666 | 666 | break; |
667 | 667 | case 'venue_title': |
668 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
668 | + $SQL .= $glue.'venue_title '.$sort; |
|
669 | 669 | break; |
670 | 670 | case 'city': |
671 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
671 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
672 | 672 | break; |
673 | 673 | case 'state': |
674 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
674 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
675 | 675 | break; |
676 | 676 | case 'start_date': |
677 | 677 | default: |
678 | - $SQL .= $glue . ' event_start_date ' . $sort; |
|
678 | + $SQL .= $glue.' event_start_date '.$sort; |
|
679 | 679 | break; |
680 | 680 | } |
681 | 681 | // add to array of orderby params that have been added |
682 | - self::$_query_params['orderby'][ $orderby ] = true; |
|
682 | + self::$_query_params['orderby'][$orderby] = true; |
|
683 | 683 | $counter++; |
684 | 684 | } |
685 | 685 | return $SQL; |
@@ -11,131 +11,131 @@ |
||
11 | 11 | class EEH_Class_Tools |
12 | 12 | { |
13 | 13 | |
14 | - public static $i = 0; |
|
15 | - public static $file_line = null; |
|
14 | + public static $i = 0; |
|
15 | + public static $file_line = null; |
|
16 | 16 | |
17 | - /** |
|
18 | - * get_called_class - for PHP versions < 5.3 |
|
19 | - * |
|
20 | - * @access public |
|
21 | - * @author origins: http://stackoverflow.com/a/1542045 |
|
22 | - * return string |
|
23 | - */ |
|
24 | - public static function get_called_class() |
|
25 | - { |
|
26 | - $backtrace = debug_backtrace(); |
|
27 | - if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) { |
|
28 | - return $backtrace[2]['class']; |
|
29 | - } elseif (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
|
30 | - return $backtrace[3]['class']; |
|
31 | - } elseif (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
|
32 | - if (self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line']) { |
|
33 | - self::$i++; |
|
34 | - } else { |
|
35 | - self::$i = 0; |
|
36 | - self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
37 | - } |
|
38 | - // was class method called via call_user_func ? |
|
39 | - if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
|
40 | - if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) { |
|
41 | - $called_class = $backtrace[2]['args'][0][0]; |
|
42 | - // is it an EE function ? |
|
43 | - if (strpos($called_class, 'EE') === 0) { |
|
44 | - $prefix_chars = strpos($called_class, '_') + 1; |
|
45 | - $prefix = substr($called_class, 0, $prefix_chars); |
|
46 | - $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
|
47 | - $classname = $prefix . str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
48 | - return $classname; |
|
49 | - } |
|
50 | - } |
|
51 | - } else { |
|
52 | - $lines = file($backtrace[2]['file']); |
|
53 | - preg_match_all('/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[ $backtrace[2]['line']-1 ], $matches); |
|
54 | - if (isset($matches[1]) && isset($matches[1][ self::$i ])) { |
|
55 | - return $matches[1][ self::$i ]; |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
59 | - return false; |
|
60 | - } |
|
17 | + /** |
|
18 | + * get_called_class - for PHP versions < 5.3 |
|
19 | + * |
|
20 | + * @access public |
|
21 | + * @author origins: http://stackoverflow.com/a/1542045 |
|
22 | + * return string |
|
23 | + */ |
|
24 | + public static function get_called_class() |
|
25 | + { |
|
26 | + $backtrace = debug_backtrace(); |
|
27 | + if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) { |
|
28 | + return $backtrace[2]['class']; |
|
29 | + } elseif (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
|
30 | + return $backtrace[3]['class']; |
|
31 | + } elseif (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
|
32 | + if (self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line']) { |
|
33 | + self::$i++; |
|
34 | + } else { |
|
35 | + self::$i = 0; |
|
36 | + self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
37 | + } |
|
38 | + // was class method called via call_user_func ? |
|
39 | + if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
|
40 | + if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) { |
|
41 | + $called_class = $backtrace[2]['args'][0][0]; |
|
42 | + // is it an EE function ? |
|
43 | + if (strpos($called_class, 'EE') === 0) { |
|
44 | + $prefix_chars = strpos($called_class, '_') + 1; |
|
45 | + $prefix = substr($called_class, 0, $prefix_chars); |
|
46 | + $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
|
47 | + $classname = $prefix . str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
48 | + return $classname; |
|
49 | + } |
|
50 | + } |
|
51 | + } else { |
|
52 | + $lines = file($backtrace[2]['file']); |
|
53 | + preg_match_all('/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[ $backtrace[2]['line']-1 ], $matches); |
|
54 | + if (isset($matches[1]) && isset($matches[1][ self::$i ])) { |
|
55 | + return $matches[1][ self::$i ]; |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * get_class_names_for_all_callbacks_on_hook |
|
67 | - * returns an array of names for all classes that have methods registered as callbacks for the given action or filter hook |
|
68 | - * @access public |
|
69 | - * @param string $hook |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public static function get_class_names_for_all_callbacks_on_hook($hook = null) |
|
73 | - { |
|
74 | - global $wp_filter; |
|
75 | - $class_names = array(); |
|
76 | - // are any callbacks registered for this hook ? |
|
77 | - if (isset($wp_filter[ $hook ])) { |
|
78 | - // loop thru all of the callbacks attached to the deprecated hookpoint |
|
79 | - foreach ($wp_filter[ $hook ] as $priority) { |
|
80 | - foreach ($priority as $callback) { |
|
81 | - // is the callback a non-static class method ? |
|
82 | - if (isset($callback['function']) && is_array($callback['function'])) { |
|
83 | - if (isset($callback['function'][0]) && is_object($callback['function'][0])) { |
|
84 | - $class_names[] = get_class($callback['function'][0]); |
|
85 | - } |
|
86 | - // test for static method |
|
87 | - } elseif (strpos($callback['function'], '::') !== false) { |
|
88 | - $class = explode('::', $callback['function']); |
|
89 | - $class_names[] = $class[0]; |
|
90 | - } else { |
|
91 | - // just a function |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
96 | - return $class_names; |
|
97 | - } |
|
65 | + /** |
|
66 | + * get_class_names_for_all_callbacks_on_hook |
|
67 | + * returns an array of names for all classes that have methods registered as callbacks for the given action or filter hook |
|
68 | + * @access public |
|
69 | + * @param string $hook |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public static function get_class_names_for_all_callbacks_on_hook($hook = null) |
|
73 | + { |
|
74 | + global $wp_filter; |
|
75 | + $class_names = array(); |
|
76 | + // are any callbacks registered for this hook ? |
|
77 | + if (isset($wp_filter[ $hook ])) { |
|
78 | + // loop thru all of the callbacks attached to the deprecated hookpoint |
|
79 | + foreach ($wp_filter[ $hook ] as $priority) { |
|
80 | + foreach ($priority as $callback) { |
|
81 | + // is the callback a non-static class method ? |
|
82 | + if (isset($callback['function']) && is_array($callback['function'])) { |
|
83 | + if (isset($callback['function'][0]) && is_object($callback['function'][0])) { |
|
84 | + $class_names[] = get_class($callback['function'][0]); |
|
85 | + } |
|
86 | + // test for static method |
|
87 | + } elseif (strpos($callback['function'], '::') !== false) { |
|
88 | + $class = explode('::', $callback['function']); |
|
89 | + $class_names[] = $class[0]; |
|
90 | + } else { |
|
91 | + // just a function |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | + return $class_names; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * property_exists() with fallback for PHP versions < 5.3 |
|
104 | - * @access public |
|
105 | - * @param mixed object | string $class |
|
106 | - * @param string $property |
|
107 | - * @return boolean |
|
108 | - */ |
|
109 | - public static function has_property($class = null, $property = null) |
|
110 | - { |
|
111 | - // if $class or $property don't exist, then get out, cuz that would be like... fatal dude |
|
112 | - if (empty($class) || empty($property)) { |
|
113 | - return false; |
|
114 | - } |
|
115 | - // if your hosting company doesn't cut the mustard |
|
116 | - if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
117 | - // just in case $class is an actual instantiated object |
|
118 | - if (is_object($class)) { |
|
119 | - return isset($class->{$property}) ? true : false; |
|
120 | - } else { |
|
121 | - // use reflection for < PHP 5.3 to get details using just the class name |
|
122 | - $reflector = new ReflectionClass($class); |
|
123 | - return $reflector->hasProperty($property); |
|
124 | - } |
|
125 | - } else { |
|
126 | - // or try regular property exists method which works as expected in PHP 5.3+ |
|
127 | - return property_exists($class, $property); |
|
128 | - } |
|
129 | - } |
|
102 | + /** |
|
103 | + * property_exists() with fallback for PHP versions < 5.3 |
|
104 | + * @access public |
|
105 | + * @param mixed object | string $class |
|
106 | + * @param string $property |
|
107 | + * @return boolean |
|
108 | + */ |
|
109 | + public static function has_property($class = null, $property = null) |
|
110 | + { |
|
111 | + // if $class or $property don't exist, then get out, cuz that would be like... fatal dude |
|
112 | + if (empty($class) || empty($property)) { |
|
113 | + return false; |
|
114 | + } |
|
115 | + // if your hosting company doesn't cut the mustard |
|
116 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
117 | + // just in case $class is an actual instantiated object |
|
118 | + if (is_object($class)) { |
|
119 | + return isset($class->{$property}) ? true : false; |
|
120 | + } else { |
|
121 | + // use reflection for < PHP 5.3 to get details using just the class name |
|
122 | + $reflector = new ReflectionClass($class); |
|
123 | + return $reflector->hasProperty($property); |
|
124 | + } |
|
125 | + } else { |
|
126 | + // or try regular property exists method which works as expected in PHP 5.3+ |
|
127 | + return property_exists($class, $property); |
|
128 | + } |
|
129 | + } |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // if PHP version < 5.3 |
133 | 133 | if (! function_exists('get_called_class')) { |
134 | - /** |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - function get_called_class() |
|
138 | - { |
|
139 | - return EEH_Class_Tools::get_called_class(); |
|
140 | - } |
|
134 | + /** |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + function get_called_class() |
|
138 | + { |
|
139 | + return EEH_Class_Tools::get_called_class(); |
|
140 | + } |
|
141 | 141 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | } elseif (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
30 | 30 | return $backtrace[3]['class']; |
31 | 31 | } elseif (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
32 | - if (self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line']) { |
|
32 | + if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) { |
|
33 | 33 | self::$i++; |
34 | 34 | } else { |
35 | 35 | self::$i = 0; |
36 | - self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
36 | + self::$file_line = $backtrace[2]['file'].$backtrace[2]['line']; |
|
37 | 37 | } |
38 | 38 | // was class method called via call_user_func ? |
39 | 39 | if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | $prefix_chars = strpos($called_class, '_') + 1; |
45 | 45 | $prefix = substr($called_class, 0, $prefix_chars); |
46 | 46 | $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
47 | - $classname = $prefix . str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
47 | + $classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
48 | 48 | return $classname; |
49 | 49 | } |
50 | 50 | } |
51 | 51 | } else { |
52 | 52 | $lines = file($backtrace[2]['file']); |
53 | - preg_match_all('/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[ $backtrace[2]['line']-1 ], $matches); |
|
54 | - if (isset($matches[1]) && isset($matches[1][ self::$i ])) { |
|
55 | - return $matches[1][ self::$i ]; |
|
53 | + preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches); |
|
54 | + if (isset($matches[1]) && isset($matches[1][self::$i])) { |
|
55 | + return $matches[1][self::$i]; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | global $wp_filter; |
75 | 75 | $class_names = array(); |
76 | 76 | // are any callbacks registered for this hook ? |
77 | - if (isset($wp_filter[ $hook ])) { |
|
77 | + if (isset($wp_filter[$hook])) { |
|
78 | 78 | // loop thru all of the callbacks attached to the deprecated hookpoint |
79 | - foreach ($wp_filter[ $hook ] as $priority) { |
|
79 | + foreach ($wp_filter[$hook] as $priority) { |
|
80 | 80 | foreach ($priority as $callback) { |
81 | 81 | // is the callback a non-static class method ? |
82 | 82 | if (isset($callback['function']) && is_array($callback['function'])) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // if PHP version < 5.3 |
133 | -if (! function_exists('get_called_class')) { |
|
133 | +if ( ! function_exists('get_called_class')) { |
|
134 | 134 | /** |
135 | 135 | * @return string |
136 | 136 | */ |