@@ -15,141 +15,141 @@ |
||
15 | 15 | abstract class EED_Module extends EE_Configurable implements ResettableInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * rendered output to be returned to WP |
|
20 | - * |
|
21 | - * @var string $output |
|
22 | - */ |
|
23 | - protected $output = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * the current active espresso template theme |
|
27 | - * |
|
28 | - * @var string $theme |
|
29 | - */ |
|
30 | - protected $theme = ''; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function reset() |
|
37 | - { |
|
38 | - $module_name = get_called_class(); |
|
39 | - new $module_name(); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public static function set_hooks_admin() |
|
61 | - { |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * run - initial module setup |
|
67 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @var WP $WP |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - abstract public function run($WP); |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * EED_Module constructor. |
|
78 | - */ |
|
79 | - final public function __construct() |
|
80 | - { |
|
81 | - $this->theme = EE_Config::get_current_theme(); |
|
82 | - $module_name = $this->module_name(); |
|
83 | - EE_Registry::instance()->modules->{$module_name} = $this; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * @param string $module_name |
|
89 | - * @return EED_Module|mixed |
|
90 | - * @throws EE_Error |
|
91 | - * @throws ReflectionException |
|
92 | - */ |
|
93 | - protected static function get_instance($module_name = '') |
|
94 | - { |
|
95 | - $module_name = ! empty($module_name) |
|
96 | - ? $module_name |
|
97 | - : get_called_class(); |
|
98 | - if ( |
|
99 | - ! isset(EE_Registry::instance()->modules->{$module_name}) |
|
100 | - || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
101 | - ) { |
|
102 | - EE_Registry::instance()->add_module($module_name); |
|
103 | - } |
|
104 | - return EE_Registry::instance()->get_module($module_name); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * module_name |
|
110 | - * |
|
111 | - * @access public |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function module_name() |
|
115 | - { |
|
116 | - return get_class($this); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function theme() |
|
124 | - { |
|
125 | - return $this->theme; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @return RequestInterface |
|
131 | - * @since 4.10.14.p |
|
132 | - */ |
|
133 | - protected static function getRequest() |
|
134 | - { |
|
135 | - static $request; |
|
136 | - if (! $request instanceof RequestInterface) { |
|
137 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
138 | - } |
|
139 | - return $request; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return ResponseInterface |
|
145 | - * @since 4.10.14.p |
|
146 | - */ |
|
147 | - protected static function getResponse() |
|
148 | - { |
|
149 | - static $response; |
|
150 | - if (! $response instanceof RequestInterface) { |
|
151 | - $response = LoaderFactory::getLoader()->getShared(ResponseInterface::class); |
|
152 | - } |
|
153 | - return $response; |
|
154 | - } |
|
18 | + /** |
|
19 | + * rendered output to be returned to WP |
|
20 | + * |
|
21 | + * @var string $output |
|
22 | + */ |
|
23 | + protected $output = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * the current active espresso template theme |
|
27 | + * |
|
28 | + * @var string $theme |
|
29 | + */ |
|
30 | + protected $theme = ''; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function reset() |
|
37 | + { |
|
38 | + $module_name = get_called_class(); |
|
39 | + new $module_name(); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public static function set_hooks_admin() |
|
61 | + { |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * run - initial module setup |
|
67 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @var WP $WP |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + abstract public function run($WP); |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * EED_Module constructor. |
|
78 | + */ |
|
79 | + final public function __construct() |
|
80 | + { |
|
81 | + $this->theme = EE_Config::get_current_theme(); |
|
82 | + $module_name = $this->module_name(); |
|
83 | + EE_Registry::instance()->modules->{$module_name} = $this; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * @param string $module_name |
|
89 | + * @return EED_Module|mixed |
|
90 | + * @throws EE_Error |
|
91 | + * @throws ReflectionException |
|
92 | + */ |
|
93 | + protected static function get_instance($module_name = '') |
|
94 | + { |
|
95 | + $module_name = ! empty($module_name) |
|
96 | + ? $module_name |
|
97 | + : get_called_class(); |
|
98 | + if ( |
|
99 | + ! isset(EE_Registry::instance()->modules->{$module_name}) |
|
100 | + || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module |
|
101 | + ) { |
|
102 | + EE_Registry::instance()->add_module($module_name); |
|
103 | + } |
|
104 | + return EE_Registry::instance()->get_module($module_name); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * module_name |
|
110 | + * |
|
111 | + * @access public |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function module_name() |
|
115 | + { |
|
116 | + return get_class($this); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function theme() |
|
124 | + { |
|
125 | + return $this->theme; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @return RequestInterface |
|
131 | + * @since 4.10.14.p |
|
132 | + */ |
|
133 | + protected static function getRequest() |
|
134 | + { |
|
135 | + static $request; |
|
136 | + if (! $request instanceof RequestInterface) { |
|
137 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
138 | + } |
|
139 | + return $request; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return ResponseInterface |
|
145 | + * @since 4.10.14.p |
|
146 | + */ |
|
147 | + protected static function getResponse() |
|
148 | + { |
|
149 | + static $response; |
|
150 | + if (! $response instanceof RequestInterface) { |
|
151 | + $response = LoaderFactory::getLoader()->getShared(ResponseInterface::class); |
|
152 | + } |
|
153 | + return $response; |
|
154 | + } |
|
155 | 155 | } |
@@ -17,1047 +17,1047 @@ discard block |
||
17 | 17 | class EED_Events_Archive extends EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - const EVENT_DETAILS_PRIORITY = 100; |
|
21 | - |
|
22 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
23 | - |
|
24 | - const EVENT_TICKETS_PRIORITY = 120; |
|
25 | - |
|
26 | - const EVENT_VENUES_PRIORITY = 130; |
|
27 | - |
|
28 | - |
|
29 | - public static $espresso_event_list_ID = 0; |
|
30 | - |
|
31 | - public static $espresso_grid_event_lists = []; |
|
32 | - |
|
33 | - /** |
|
34 | - * @type bool $using_get_the_excerpt |
|
35 | - */ |
|
36 | - protected static $using_get_the_excerpt = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * Used to flag when the event list is being called from an external iframe. |
|
40 | - * |
|
41 | - * @var bool $iframe |
|
42 | - */ |
|
43 | - protected static $iframe = false; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var EventListIframeEmbedButton $_iframe_embed_button |
|
47 | - */ |
|
48 | - private static $_iframe_embed_button; |
|
49 | - |
|
50 | - /** |
|
51 | - * @type EE_Template_Part_Manager $template_parts |
|
52 | - */ |
|
53 | - protected $template_parts; |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return EED_Events_Archive |
|
58 | - * @throws EE_Error |
|
59 | - * @throws ReflectionException |
|
60 | - */ |
|
61 | - public static function instance() |
|
62 | - { |
|
63 | - return parent::get_instance(__CLASS__); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * for hooking into EE Core, other modules, etc |
|
69 | - * |
|
70 | - * @return void |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - */ |
|
75 | - public static function set_hooks() |
|
76 | - { |
|
77 | - /** @var CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
78 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(CustomPostTypeDefinitions::class); |
|
79 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
80 | - EE_Config::register_route( |
|
81 | - $custom_post_types['espresso_events']['plural_slug'], |
|
82 | - 'Events_Archive', |
|
83 | - 'run' |
|
84 | - ); |
|
85 | - EE_Config::register_route( |
|
86 | - 'event_list', |
|
87 | - 'Events_Archive', |
|
88 | - 'event_list' |
|
89 | - ); |
|
90 | - EE_Config::register_route( |
|
91 | - 'iframe', |
|
92 | - 'Events_Archive', |
|
93 | - 'event_list_iframe', |
|
94 | - 'event_list' |
|
95 | - ); |
|
96 | - add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * for hooking into EE Admin Core, other modules, etc |
|
102 | - * |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public static function set_hooks_admin() |
|
106 | - { |
|
107 | - add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2); |
|
108 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
109 | - // to load assets for "espresso_events" page on the "default" route (action) |
|
110 | - add_action( |
|
111 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
112 | - ['EED_Events_Archive', 'event_list_iframe_embed_button'], |
|
113 | - 10 |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - public static function set_definitions() |
|
122 | - { |
|
123 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
124 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * set up EE_Events_Archive_Config |
|
130 | - */ |
|
131 | - protected function set_config() |
|
132 | - { |
|
133 | - $this->set_config_section('template_settings'); |
|
134 | - $this->set_config_class('EE_Events_Archive_Config'); |
|
135 | - $this->set_config_name('EED_Events_Archive'); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @return EventListIframeEmbedButton |
|
141 | - */ |
|
142 | - public static function get_iframe_embed_button() |
|
143 | - { |
|
144 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
145 | - self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
146 | - } |
|
147 | - return self::$_iframe_embed_button; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @return void |
|
153 | - */ |
|
154 | - public static function event_list_iframe_embed_button() |
|
155 | - { |
|
156 | - $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button(); |
|
157 | - $iframe_embed_button->addEmbedButton(); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param EE_Events_Archive_Config|null $config |
|
163 | - * @return EE_Template_Part_Manager |
|
164 | - * @throws EE_Error |
|
165 | - */ |
|
166 | - public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
167 | - { |
|
168 | - $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
169 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
170 | - $template_parts = new EE_Template_Part_Manager(); |
|
171 | - $template_parts->add_template_part( |
|
172 | - 'tickets', |
|
173 | - esc_html__('Ticket Selector', 'event_espresso'), |
|
174 | - 'content-espresso_events-tickets.php', |
|
175 | - $config->display_order_tickets |
|
176 | - ); |
|
177 | - $template_parts->add_template_part( |
|
178 | - 'datetimes', |
|
179 | - esc_html__('Dates and Times', 'event_espresso'), |
|
180 | - 'content-espresso_events-datetimes.php', |
|
181 | - $config->display_order_datetimes |
|
182 | - ); |
|
183 | - $template_parts->add_template_part( |
|
184 | - 'event', |
|
185 | - esc_html__('Event Description', 'event_espresso'), |
|
186 | - 'content-espresso_events-details.php', |
|
187 | - $config->display_order_event |
|
188 | - ); |
|
189 | - $template_parts->add_template_part( |
|
190 | - 'venue', |
|
191 | - esc_html__('Venue Information', 'event_espresso'), |
|
192 | - 'content-espresso_events-venues.php', |
|
193 | - $config->display_order_venue |
|
194 | - ); |
|
195 | - do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
196 | - return $template_parts; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * initial module setup |
|
202 | - * this gets called by the EE_Front_Controller if the module route is found in the incoming request |
|
203 | - * |
|
204 | - * @param WP $WP |
|
205 | - * @return void |
|
206 | - */ |
|
207 | - public function run($WP) |
|
208 | - { |
|
209 | - do_action('AHEE__EED_Events_Archive__before_run'); |
|
210 | - // ensure valid EE_Events_Archive_Config() object exists |
|
211 | - $this->set_config(); |
|
212 | - /** @type EE_Events_Archive_Config $config */ |
|
213 | - $config = $this->config(); |
|
214 | - // load other required components |
|
215 | - $this->load_event_list_assets(); |
|
216 | - // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
217 | - // add query filters |
|
218 | - EEH_Event_Query::add_query_filters(); |
|
219 | - // set params that will get used by the filters |
|
220 | - EEH_Event_Query::set_query_params( |
|
221 | - '', // month |
|
222 | - '', // category |
|
223 | - $config->display_expired_events // show_expired |
|
224 | - ); |
|
225 | - // check what template is loaded |
|
226 | - add_filter('template_include', [$this, 'template_include'], 999, 1); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
232 | - * |
|
233 | - * @return void |
|
234 | - */ |
|
235 | - public function event_list() |
|
236 | - { |
|
237 | - // ensure valid EE_Events_Archive_Config() object exists |
|
238 | - $this->set_config(); |
|
239 | - // load other required components |
|
240 | - $this->load_event_list_assets(); |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @return void |
|
246 | - * @throws EE_Error |
|
247 | - * @throws ReflectionException |
|
248 | - */ |
|
249 | - public function event_list_iframe() |
|
250 | - { |
|
251 | - EED_Events_Archive::$iframe = true; |
|
252 | - $event_list_iframe = new EventsArchiveIframe($this); |
|
253 | - $event_list_iframe->display(); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * @return bool |
|
259 | - */ |
|
260 | - public static function is_iframe() |
|
261 | - { |
|
262 | - return EED_Events_Archive::$iframe; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public static function link_target() |
|
270 | - { |
|
271 | - return EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * @param string $template |
|
277 | - * @return string |
|
278 | - * @throws EE_Error |
|
279 | - * @throws ReflectionException |
|
280 | - */ |
|
281 | - public function template_include($template = '') |
|
282 | - { |
|
283 | - // don't add content filter for dedicated EE child themes or private posts |
|
284 | - if (! EEH_Template::is_espresso_theme()) { |
|
285 | - /** @type EE_Events_Archive_Config $config */ |
|
286 | - $config = $this->config(); |
|
287 | - // add status banner ? |
|
288 | - if ($config->display_status_banner) { |
|
289 | - add_filter('the_title', ['EED_Events_Archive', 'the_title'], 100, 2); |
|
290 | - } |
|
291 | - // if NOT a custom template |
|
292 | - if ( |
|
293 | - apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
294 | - || EE_Registry::instance() |
|
295 | - ->load_core('Front_Controller') |
|
296 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
297 | - ) { |
|
298 | - add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
299 | - // load functions.php file for the theme (loaded by WP if using child theme) |
|
300 | - EEH_Template::load_espresso_theme_functions(); |
|
301 | - EED_Events_Archive::addEventDetailsFilters(); |
|
302 | - // don't display entry meta because the existing theme will take care of that |
|
303 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
304 | - } |
|
305 | - } |
|
306 | - return $template; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
312 | - * then we need to remove our filters on the_content() |
|
313 | - * |
|
314 | - * @param string $excerpt |
|
315 | - * @return string |
|
316 | - * @throws EE_Error |
|
317 | - * @throws ReflectionException |
|
318 | - */ |
|
319 | - public static function get_the_excerpt($excerpt = '') |
|
320 | - { |
|
321 | - if (post_password_required()) { |
|
322 | - return $excerpt; |
|
323 | - } |
|
324 | - if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
325 | - EED_Events_Archive::removeEventDetailsFilters(false); |
|
326 | - $excerpt = EED_Events_Archive::event_details($excerpt); |
|
327 | - } else { |
|
328 | - EED_Events_Archive::$using_get_the_excerpt = true; |
|
329 | - add_filter('wp_trim_excerpt', ['EED_Events_Archive', 'end_get_the_excerpt'], 999, 1); |
|
330 | - } |
|
331 | - return $excerpt; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * @param string $text |
|
337 | - * @return string |
|
338 | - */ |
|
339 | - public static function end_get_the_excerpt($text = '') |
|
340 | - { |
|
341 | - EED_Events_Archive::$using_get_the_excerpt = false; |
|
342 | - return $text; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @param string $title |
|
348 | - * @param string $id |
|
349 | - * @return string |
|
350 | - * @throws EE_Error |
|
351 | - * @throws ReflectionException |
|
352 | - */ |
|
353 | - public static function the_title($title = '', $id = '') |
|
354 | - { |
|
355 | - global $post; |
|
356 | - if ($post instanceof WP_Post) { |
|
357 | - return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id |
|
358 | - ? espresso_event_status_banner($post->ID) . $title |
|
359 | - : $title; |
|
360 | - } |
|
361 | - return $title; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * @param string $content |
|
367 | - * @return string |
|
368 | - * @throws EE_Error |
|
369 | - * @throws ReflectionException |
|
370 | - */ |
|
371 | - public static function event_details($content) |
|
372 | - { |
|
373 | - global $post; |
|
374 | - static $current_post_ID = 0; |
|
375 | - if ( |
|
376 | - $current_post_ID !== $post->ID |
|
377 | - && $post->post_type === 'espresso_events' |
|
378 | - && ! EED_Events_Archive::$using_get_the_excerpt |
|
379 | - && ! post_password_required() |
|
380 | - && ( |
|
381 | - apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
382 | - || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
383 | - ) |
|
384 | - ) { |
|
385 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
386 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
387 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
388 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
389 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
390 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
391 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
392 | - if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
393 | - $content = EED_Events_Archive::use_sortable_display_order(); |
|
394 | - } else { |
|
395 | - $content = EED_Events_Archive::use_filterable_display_order(); |
|
396 | - } |
|
397 | - } |
|
398 | - return $content; |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * @return string |
|
404 | - * @throws EE_Error |
|
405 | - * @throws ReflectionException |
|
406 | - */ |
|
407 | - protected static function use_sortable_display_order() |
|
408 | - { |
|
409 | - // no further password checks required atm |
|
410 | - add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
411 | - // remove this callback from being applied to the_content() |
|
412 | - EED_Events_Archive::removeEventDetailsFilters(); |
|
413 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
414 | - EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
415 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
416 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
417 | - // re-add our main filters (or else the next event won't have them) |
|
418 | - EED_Events_Archive::addEventDetailsFilters(); |
|
419 | - remove_filter( |
|
420 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
421 | - '__return_true' |
|
422 | - ); |
|
423 | - return $content; |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - protected static function use_filterable_display_order() |
|
431 | - { |
|
432 | - // remove this callback from being applied to the_content() |
|
433 | - EED_Events_Archive::removeEventDetailsFilters(); |
|
434 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
435 | - EED_Events_Archive::_add_additional_excerpt_filters(); |
|
436 | - EED_Events_Archive::_add_additional_content_filters(); |
|
437 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
438 | - // now load our template |
|
439 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
440 | - // re-add our main filters (or else the next event won't have them) |
|
441 | - EED_Events_Archive::addEventDetailsFilters(); |
|
442 | - // but remove the other filters so that they don't get applied to the next post |
|
443 | - EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
444 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
445 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
446 | - // return ! empty( $template ) ? $template : $content; |
|
447 | - return $content; |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - /** |
|
452 | - * adds datetimes ABOVE content |
|
453 | - * |
|
454 | - * @param string $content |
|
455 | - * @return string |
|
456 | - */ |
|
457 | - public static function event_datetimes($content) |
|
458 | - { |
|
459 | - if (post_password_required()) { |
|
460 | - return $content; |
|
461 | - } |
|
462 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
463 | - } |
|
464 | - |
|
465 | - |
|
466 | - /** |
|
467 | - * adds tickets ABOVE content (which includes datetimes) |
|
468 | - * |
|
469 | - * @param string $content |
|
470 | - * @return string |
|
471 | - */ |
|
472 | - public static function event_tickets($content) |
|
473 | - { |
|
474 | - if (post_password_required()) { |
|
475 | - return $content; |
|
476 | - } |
|
477 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * adds venues BELOW content |
|
483 | - * |
|
484 | - * @param string $content |
|
485 | - * @return string |
|
486 | - */ |
|
487 | - public static function event_venue($content) |
|
488 | - { |
|
489 | - return EED_Events_Archive::event_venues($content); |
|
490 | - } |
|
491 | - |
|
492 | - |
|
493 | - /** |
|
494 | - * adds venues BELOW content |
|
495 | - * |
|
496 | - * @param string $content |
|
497 | - * @return string |
|
498 | - */ |
|
499 | - public static function event_venues($content) |
|
500 | - { |
|
501 | - if (post_password_required()) { |
|
502 | - return $content; |
|
503 | - } |
|
504 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * @return bool |
|
510 | - * @since $VID:$ |
|
511 | - */ |
|
512 | - public static function isBlockTheme() |
|
513 | - { |
|
514 | - return function_exists('wp_is_block_theme') && wp_is_block_theme(); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * @return string |
|
520 | - * @since $VID:$ |
|
521 | - */ |
|
522 | - public static function getExcerptFilter() |
|
523 | - { |
|
524 | - static $excerpt_filter = null; |
|
525 | - if ($excerpt_filter === null) { |
|
526 | - $excerpt_filter = EED_Events_Archive::isBlockTheme() ? 'get_the_excerpt' : 'the_excerpt'; |
|
527 | - } |
|
528 | - return $excerpt_filter; |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * @since $VID:$ |
|
534 | - */ |
|
535 | - protected static function addEventDetailsFilters() |
|
536 | - { |
|
537 | - add_filter( |
|
538 | - 'the_content', |
|
539 | - ['EED_Events_Archive', 'event_details'], |
|
540 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
541 | - ); |
|
542 | - // but because we don't know if the theme is using the_excerpt() |
|
543 | - add_filter( |
|
544 | - EED_Events_Archive::getExcerptFilter(), |
|
545 | - ['EED_Events_Archive', 'event_details'], |
|
546 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
547 | - ); |
|
548 | - // and just in case they are running get_the_excerpt() which DESTROYS things |
|
549 | - add_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1, 1); |
|
550 | - } |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * @param bool $and_get_the_excerpt |
|
555 | - * @since $VID:$ |
|
556 | - */ |
|
557 | - protected static function removeEventDetailsFilters($and_get_the_excerpt = true) |
|
558 | - { |
|
559 | - // we need to first remove all callbacks from being applied to the_content() |
|
560 | - // (otherwise it will recurse and blow up the interweb) |
|
561 | - remove_filter( |
|
562 | - 'the_content', |
|
563 | - ['EED_Events_Archive', 'event_details'], |
|
564 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
565 | - ); |
|
566 | - remove_filter( |
|
567 | - EED_Events_Archive::getExcerptFilter(), |
|
568 | - ['EED_Events_Archive', 'event_details'], |
|
569 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
570 | - ); |
|
571 | - if ($and_get_the_excerpt) { |
|
572 | - remove_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1); |
|
573 | - } |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * @return void |
|
579 | - */ |
|
580 | - private static function _add_additional_excerpt_filters() |
|
581 | - { |
|
582 | - add_filter( |
|
583 | - EED_Events_Archive::getExcerptFilter(), |
|
584 | - ['EED_Events_Archive', 'event_datetimes'], |
|
585 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
586 | - ); |
|
587 | - add_filter( |
|
588 | - EED_Events_Archive::getExcerptFilter(), |
|
589 | - ['EED_Events_Archive', 'event_tickets'], |
|
590 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
591 | - ); |
|
592 | - add_filter( |
|
593 | - EED_Events_Archive::getExcerptFilter(), |
|
594 | - ['EED_Events_Archive', 'event_venues'], |
|
595 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
596 | - ); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - /** |
|
601 | - * @return void |
|
602 | - */ |
|
603 | - private static function _add_additional_content_filters() |
|
604 | - { |
|
605 | - add_filter( |
|
606 | - 'the_content', |
|
607 | - ['EED_Events_Archive', 'event_datetimes'], |
|
608 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
609 | - ); |
|
610 | - add_filter( |
|
611 | - 'the_content', |
|
612 | - ['EED_Events_Archive', 'event_tickets'], |
|
613 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
614 | - ); |
|
615 | - add_filter( |
|
616 | - 'the_content', |
|
617 | - ['EED_Events_Archive', 'event_venues'], |
|
618 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
619 | - ); |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * @return void |
|
625 | - */ |
|
626 | - private static function _remove_additional_events_archive_filters() |
|
627 | - { |
|
628 | - remove_filter( |
|
629 | - EED_Events_Archive::getExcerptFilter(), |
|
630 | - ['EED_Events_Archive', 'event_datetimes'], |
|
631 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
632 | - ); |
|
633 | - remove_filter( |
|
634 | - EED_Events_Archive::getExcerptFilter(), |
|
635 | - ['EED_Events_Archive', 'event_tickets'], |
|
636 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
637 | - ); |
|
638 | - remove_filter( |
|
639 | - EED_Events_Archive::getExcerptFilter(), |
|
640 | - ['EED_Events_Archive', 'event_venues'], |
|
641 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
642 | - ); |
|
643 | - remove_filter( |
|
644 | - 'the_content', |
|
645 | - ['EED_Events_Archive', 'event_datetimes'], |
|
646 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
647 | - ); |
|
648 | - remove_filter( |
|
649 | - 'the_content', |
|
650 | - ['EED_Events_Archive', 'event_tickets'], |
|
651 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
652 | - ); |
|
653 | - remove_filter( |
|
654 | - 'the_content', |
|
655 | - ['EED_Events_Archive', 'event_venues'], |
|
656 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
657 | - ); |
|
658 | - } |
|
659 | - |
|
660 | - |
|
661 | - /** |
|
662 | - * @return void |
|
663 | - */ |
|
664 | - public static function remove_all_events_archive_filters() |
|
665 | - { |
|
666 | - // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
667 | - remove_filter('the_title', ['EED_Events_Archive', 'the_title'], 1); |
|
668 | - remove_filter( |
|
669 | - EED_Events_Archive::getExcerptFilter(), |
|
670 | - ['EED_Events_Archive', 'event_details'], |
|
671 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
672 | - ); |
|
673 | - remove_filter( |
|
674 | - EED_Events_Archive::getExcerptFilter(), |
|
675 | - ['EED_Events_Archive', 'event_datetimes'], |
|
676 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
677 | - ); |
|
678 | - remove_filter( |
|
679 | - EED_Events_Archive::getExcerptFilter(), |
|
680 | - ['EED_Events_Archive', 'event_tickets'], |
|
681 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
682 | - ); |
|
683 | - remove_filter( |
|
684 | - EED_Events_Archive::getExcerptFilter(), |
|
685 | - ['EED_Events_Archive', 'event_venues'], |
|
686 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
687 | - ); |
|
688 | - remove_filter( |
|
689 | - 'the_content', |
|
690 | - ['EED_Events_Archive', 'event_details'], |
|
691 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
692 | - ); |
|
693 | - remove_filter( |
|
694 | - 'the_content', |
|
695 | - ['EED_Events_Archive', 'event_datetimes'], |
|
696 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
697 | - ); |
|
698 | - remove_filter( |
|
699 | - 'the_content', |
|
700 | - ['EED_Events_Archive', 'event_tickets'], |
|
701 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
702 | - ); |
|
703 | - remove_filter( |
|
704 | - 'the_content', |
|
705 | - ['EED_Events_Archive', 'event_venues'], |
|
706 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
707 | - ); |
|
708 | - // don't display entry meta because the existing theme will take care of that |
|
709 | - remove_filter( |
|
710 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
711 | - '__return_false' |
|
712 | - ); |
|
713 | - } |
|
714 | - |
|
715 | - |
|
716 | - /** |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - public function load_event_list_assets() |
|
720 | - { |
|
721 | - do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
722 | - add_filter('FHEE_load_EE_Session', '__return_true'); |
|
723 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
724 | - add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts'], 10); |
|
725 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
726 | - add_action('wp_enqueue_scripts', ['EEH_Maps', 'espresso_google_map_js'], 11); |
|
727 | - } |
|
728 | - } |
|
729 | - |
|
730 | - |
|
731 | - /** |
|
732 | - * @return void |
|
733 | - * @throws EE_Error |
|
734 | - */ |
|
735 | - public function wp_enqueue_scripts() |
|
736 | - { |
|
737 | - // get some style |
|
738 | - if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
739 | - // first check uploads folder |
|
740 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
741 | - wp_register_style( |
|
742 | - $this->theme, |
|
743 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
744 | - ['dashicons', 'espresso_default'] |
|
745 | - ); |
|
746 | - } |
|
747 | - wp_enqueue_style($this->theme); |
|
748 | - } |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * @static |
|
754 | - * @return void |
|
755 | - */ |
|
756 | - public static function template_settings_form() |
|
757 | - { |
|
758 | - $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
759 | - $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
760 | - ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
761 | - $template_settings->EED_Events_Archive = apply_filters( |
|
762 | - 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
763 | - $template_settings->EED_Events_Archive |
|
764 | - ); |
|
765 | - $events_archive_settings = [ |
|
766 | - 'display_status_banner' => 0, |
|
767 | - 'display_description' => 1, |
|
768 | - 'display_ticket_selector' => 0, |
|
769 | - 'display_datetimes' => 1, |
|
770 | - 'display_venue' => 0, |
|
771 | - 'display_expired_events' => 0, |
|
772 | - ]; |
|
773 | - $events_archive_settings = array_merge( |
|
774 | - $events_archive_settings, |
|
775 | - (array) $template_settings->EED_Events_Archive |
|
776 | - ); |
|
777 | - EEH_Template::display_template( |
|
778 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
779 | - $events_archive_settings |
|
780 | - ); |
|
781 | - } |
|
782 | - |
|
783 | - |
|
784 | - /** |
|
785 | - * @param EE_Template_Config $CFG |
|
786 | - * @param array $REQ |
|
787 | - * @return EE_Template_Config |
|
788 | - */ |
|
789 | - public static function update_template_settings($CFG, $REQ) |
|
790 | - { |
|
791 | - $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
792 | - // unless we are resetting the config... |
|
793 | - if ( |
|
794 | - ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
795 | - || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
796 | - ) { |
|
797 | - $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
798 | - ? absint($REQ['EED_Events_Archive_display_status_banner']) |
|
799 | - : 0; |
|
800 | - $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
801 | - ? absint($REQ['EED_Events_Archive_display_description']) |
|
802 | - : 1; |
|
803 | - $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
804 | - ? absint($REQ['EED_Events_Archive_display_ticket_selector']) |
|
805 | - : 0; |
|
806 | - $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) |
|
807 | - ? absint($REQ['EED_Events_Archive_display_datetimes']) |
|
808 | - : 1; |
|
809 | - $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) |
|
810 | - ? absint($REQ['EED_Events_Archive_display_venue']) |
|
811 | - : 0; |
|
812 | - $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
813 | - ? absint($REQ['EED_Events_Archive_display_expired_events']) |
|
814 | - : 0; |
|
815 | - } |
|
816 | - return $CFG; |
|
817 | - } |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * @param string $extra_class |
|
822 | - * @return string |
|
823 | - */ |
|
824 | - public static function event_list_css($extra_class = '') |
|
825 | - { |
|
826 | - $event_list_css = ! empty($extra_class) ? [$extra_class] : []; |
|
827 | - $event_list_css[] = 'espresso-event-list-event'; |
|
828 | - return implode(' ', $event_list_css); |
|
829 | - } |
|
830 | - |
|
831 | - |
|
832 | - /** |
|
833 | - * @return array |
|
834 | - * @throws EE_Error |
|
835 | - * @throws ReflectionException |
|
836 | - */ |
|
837 | - public static function event_categories() |
|
838 | - { |
|
839 | - return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
840 | - } |
|
841 | - |
|
842 | - |
|
843 | - /** |
|
844 | - * @param $value |
|
845 | - * @return bool |
|
846 | - */ |
|
847 | - public static function display_description($value) |
|
848 | - { |
|
849 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
850 | - $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
851 | - return $display_description === $value; |
|
852 | - } |
|
853 | - |
|
854 | - |
|
855 | - /** |
|
856 | - * @return bool |
|
857 | - */ |
|
858 | - public static function display_ticket_selector() |
|
859 | - { |
|
860 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
861 | - return isset($config->display_ticket_selector) && $config->display_ticket_selector; |
|
862 | - } |
|
863 | - |
|
864 | - |
|
865 | - /** |
|
866 | - * @return bool |
|
867 | - * @throws EE_Error |
|
868 | - * @throws ReflectionException |
|
869 | - */ |
|
870 | - public static function display_venue() |
|
871 | - { |
|
872 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
873 | - return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name(); |
|
874 | - } |
|
875 | - |
|
876 | - |
|
877 | - /** |
|
878 | - * @return bool |
|
879 | - */ |
|
880 | - public static function display_datetimes() |
|
881 | - { |
|
882 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
883 | - return isset($config->display_datetimes) && $config->display_datetimes; |
|
884 | - } |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * @return string |
|
889 | - */ |
|
890 | - public static function event_list_title() |
|
891 | - { |
|
892 | - return apply_filters( |
|
893 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
894 | - esc_html__('Upcoming Events', 'event_espresso') |
|
895 | - ); |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - // GRAVEYARD |
|
900 | - |
|
901 | - |
|
902 | - /** |
|
903 | - * @since 4.4.0 |
|
904 | - */ |
|
905 | - public static function _doing_it_wrong_notice($function = '') |
|
906 | - { |
|
907 | - EE_Error::doing_it_wrong( |
|
908 | - __FUNCTION__, |
|
909 | - sprintf( |
|
910 | - esc_html__( |
|
911 | - 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
912 | - 'event_espresso' |
|
913 | - ), |
|
914 | - $function, |
|
915 | - '<br />', |
|
916 | - '4.6.0' |
|
917 | - ), |
|
918 | - '4.4.0' |
|
919 | - ); |
|
920 | - } |
|
921 | - |
|
922 | - |
|
923 | - /** |
|
924 | - * @deprecated |
|
925 | - * @since 4.4.0 |
|
926 | - */ |
|
927 | - public function get_post_data() |
|
928 | - { |
|
929 | - EEH_Event_Query::set_query_params(); |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - /** |
|
934 | - * @throws EE_Error |
|
935 | - * @since 4.4.0 |
|
936 | - * @deprecated |
|
937 | - */ |
|
938 | - public function posts_fields($SQL, WP_Query $wp_query) |
|
939 | - { |
|
940 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
941 | - return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
942 | - } |
|
943 | - |
|
944 | - |
|
945 | - /** |
|
946 | - * @throws EE_Error |
|
947 | - * @since 4.4.0 |
|
948 | - * @deprecated |
|
949 | - */ |
|
950 | - public static function posts_fields_sql_for_orderby($orderby_params = []) |
|
951 | - { |
|
952 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
953 | - return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
954 | - } |
|
955 | - |
|
956 | - |
|
957 | - /** |
|
958 | - * @throws EE_Error |
|
959 | - * @since 4.4.0 |
|
960 | - * @deprecated |
|
961 | - */ |
|
962 | - public function posts_join($SQL, WP_Query $wp_query) |
|
963 | - { |
|
964 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
965 | - return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
966 | - } |
|
967 | - |
|
968 | - |
|
969 | - /** |
|
970 | - * @deprecated |
|
971 | - * @since 4.4.0 |
|
972 | - */ |
|
973 | - public static function posts_join_sql_for_terms($join_terms = null) |
|
974 | - { |
|
975 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
976 | - return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
977 | - } |
|
978 | - |
|
979 | - |
|
980 | - /** |
|
981 | - * @throws EE_Error |
|
982 | - * @since 4.4.0 |
|
983 | - * @deprecated |
|
984 | - */ |
|
985 | - public static function posts_join_for_orderby($orderby_params = []) |
|
986 | - { |
|
987 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
988 | - return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
989 | - } |
|
990 | - |
|
991 | - |
|
992 | - /** |
|
993 | - * @throws EE_Error |
|
994 | - * @since 4.4.0 |
|
995 | - * @deprecated |
|
996 | - */ |
|
997 | - public function posts_where($SQL, WP_Query $wp_query) |
|
998 | - { |
|
999 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1000 | - return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1001 | - } |
|
1002 | - |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * @throws EE_Error |
|
1006 | - * @since 4.4.0 |
|
1007 | - * @deprecated |
|
1008 | - */ |
|
1009 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1010 | - { |
|
1011 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1012 | - return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * @deprecated |
|
1018 | - * @since 4.4.0 |
|
1019 | - */ |
|
1020 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1021 | - { |
|
1022 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1023 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1024 | - } |
|
1025 | - |
|
1026 | - |
|
1027 | - /** |
|
1028 | - * @throws EE_Error |
|
1029 | - * @since 4.4.0 |
|
1030 | - * @deprecated |
|
1031 | - */ |
|
1032 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
1033 | - { |
|
1034 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1035 | - return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1036 | - } |
|
1037 | - |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * @throws EE_Error |
|
1041 | - * @since 4.4.0 |
|
1042 | - * @deprecated |
|
1043 | - */ |
|
1044 | - public function posts_orderby($SQL, WP_Query $wp_query) |
|
1045 | - { |
|
1046 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1047 | - return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1048 | - } |
|
1049 | - |
|
1050 | - |
|
1051 | - /** |
|
1052 | - * @throws EE_Error |
|
1053 | - * @since 4.4.0 |
|
1054 | - * @deprecated |
|
1055 | - */ |
|
1056 | - public static function posts_orderby_sql($orderby_params = [], $sort = 'ASC') |
|
1057 | - { |
|
1058 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1059 | - return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1060 | - } |
|
20 | + const EVENT_DETAILS_PRIORITY = 100; |
|
21 | + |
|
22 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
23 | + |
|
24 | + const EVENT_TICKETS_PRIORITY = 120; |
|
25 | + |
|
26 | + const EVENT_VENUES_PRIORITY = 130; |
|
27 | + |
|
28 | + |
|
29 | + public static $espresso_event_list_ID = 0; |
|
30 | + |
|
31 | + public static $espresso_grid_event_lists = []; |
|
32 | + |
|
33 | + /** |
|
34 | + * @type bool $using_get_the_excerpt |
|
35 | + */ |
|
36 | + protected static $using_get_the_excerpt = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * Used to flag when the event list is being called from an external iframe. |
|
40 | + * |
|
41 | + * @var bool $iframe |
|
42 | + */ |
|
43 | + protected static $iframe = false; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var EventListIframeEmbedButton $_iframe_embed_button |
|
47 | + */ |
|
48 | + private static $_iframe_embed_button; |
|
49 | + |
|
50 | + /** |
|
51 | + * @type EE_Template_Part_Manager $template_parts |
|
52 | + */ |
|
53 | + protected $template_parts; |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return EED_Events_Archive |
|
58 | + * @throws EE_Error |
|
59 | + * @throws ReflectionException |
|
60 | + */ |
|
61 | + public static function instance() |
|
62 | + { |
|
63 | + return parent::get_instance(__CLASS__); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * for hooking into EE Core, other modules, etc |
|
69 | + * |
|
70 | + * @return void |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + */ |
|
75 | + public static function set_hooks() |
|
76 | + { |
|
77 | + /** @var CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
78 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared(CustomPostTypeDefinitions::class); |
|
79 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
80 | + EE_Config::register_route( |
|
81 | + $custom_post_types['espresso_events']['plural_slug'], |
|
82 | + 'Events_Archive', |
|
83 | + 'run' |
|
84 | + ); |
|
85 | + EE_Config::register_route( |
|
86 | + 'event_list', |
|
87 | + 'Events_Archive', |
|
88 | + 'event_list' |
|
89 | + ); |
|
90 | + EE_Config::register_route( |
|
91 | + 'iframe', |
|
92 | + 'Events_Archive', |
|
93 | + 'event_list_iframe', |
|
94 | + 'event_list' |
|
95 | + ); |
|
96 | + add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * for hooking into EE Admin Core, other modules, etc |
|
102 | + * |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public static function set_hooks_admin() |
|
106 | + { |
|
107 | + add_action('wp_loaded', ['EED_Events_Archive', 'set_definitions'], 2); |
|
108 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
109 | + // to load assets for "espresso_events" page on the "default" route (action) |
|
110 | + add_action( |
|
111 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
112 | + ['EED_Events_Archive', 'event_list_iframe_embed_button'], |
|
113 | + 10 |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + public static function set_definitions() |
|
122 | + { |
|
123 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
124 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * set up EE_Events_Archive_Config |
|
130 | + */ |
|
131 | + protected function set_config() |
|
132 | + { |
|
133 | + $this->set_config_section('template_settings'); |
|
134 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
135 | + $this->set_config_name('EED_Events_Archive'); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @return EventListIframeEmbedButton |
|
141 | + */ |
|
142 | + public static function get_iframe_embed_button() |
|
143 | + { |
|
144 | + if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
145 | + self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
146 | + } |
|
147 | + return self::$_iframe_embed_button; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @return void |
|
153 | + */ |
|
154 | + public static function event_list_iframe_embed_button() |
|
155 | + { |
|
156 | + $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button(); |
|
157 | + $iframe_embed_button->addEmbedButton(); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param EE_Events_Archive_Config|null $config |
|
163 | + * @return EE_Template_Part_Manager |
|
164 | + * @throws EE_Error |
|
165 | + */ |
|
166 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
167 | + { |
|
168 | + $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
169 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
170 | + $template_parts = new EE_Template_Part_Manager(); |
|
171 | + $template_parts->add_template_part( |
|
172 | + 'tickets', |
|
173 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
174 | + 'content-espresso_events-tickets.php', |
|
175 | + $config->display_order_tickets |
|
176 | + ); |
|
177 | + $template_parts->add_template_part( |
|
178 | + 'datetimes', |
|
179 | + esc_html__('Dates and Times', 'event_espresso'), |
|
180 | + 'content-espresso_events-datetimes.php', |
|
181 | + $config->display_order_datetimes |
|
182 | + ); |
|
183 | + $template_parts->add_template_part( |
|
184 | + 'event', |
|
185 | + esc_html__('Event Description', 'event_espresso'), |
|
186 | + 'content-espresso_events-details.php', |
|
187 | + $config->display_order_event |
|
188 | + ); |
|
189 | + $template_parts->add_template_part( |
|
190 | + 'venue', |
|
191 | + esc_html__('Venue Information', 'event_espresso'), |
|
192 | + 'content-espresso_events-venues.php', |
|
193 | + $config->display_order_venue |
|
194 | + ); |
|
195 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
196 | + return $template_parts; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * initial module setup |
|
202 | + * this gets called by the EE_Front_Controller if the module route is found in the incoming request |
|
203 | + * |
|
204 | + * @param WP $WP |
|
205 | + * @return void |
|
206 | + */ |
|
207 | + public function run($WP) |
|
208 | + { |
|
209 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
210 | + // ensure valid EE_Events_Archive_Config() object exists |
|
211 | + $this->set_config(); |
|
212 | + /** @type EE_Events_Archive_Config $config */ |
|
213 | + $config = $this->config(); |
|
214 | + // load other required components |
|
215 | + $this->load_event_list_assets(); |
|
216 | + // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
217 | + // add query filters |
|
218 | + EEH_Event_Query::add_query_filters(); |
|
219 | + // set params that will get used by the filters |
|
220 | + EEH_Event_Query::set_query_params( |
|
221 | + '', // month |
|
222 | + '', // category |
|
223 | + $config->display_expired_events // show_expired |
|
224 | + ); |
|
225 | + // check what template is loaded |
|
226 | + add_filter('template_include', [$this, 'template_include'], 999, 1); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
232 | + * |
|
233 | + * @return void |
|
234 | + */ |
|
235 | + public function event_list() |
|
236 | + { |
|
237 | + // ensure valid EE_Events_Archive_Config() object exists |
|
238 | + $this->set_config(); |
|
239 | + // load other required components |
|
240 | + $this->load_event_list_assets(); |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @return void |
|
246 | + * @throws EE_Error |
|
247 | + * @throws ReflectionException |
|
248 | + */ |
|
249 | + public function event_list_iframe() |
|
250 | + { |
|
251 | + EED_Events_Archive::$iframe = true; |
|
252 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
253 | + $event_list_iframe->display(); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * @return bool |
|
259 | + */ |
|
260 | + public static function is_iframe() |
|
261 | + { |
|
262 | + return EED_Events_Archive::$iframe; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @return string |
|
268 | + */ |
|
269 | + public static function link_target() |
|
270 | + { |
|
271 | + return EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * @param string $template |
|
277 | + * @return string |
|
278 | + * @throws EE_Error |
|
279 | + * @throws ReflectionException |
|
280 | + */ |
|
281 | + public function template_include($template = '') |
|
282 | + { |
|
283 | + // don't add content filter for dedicated EE child themes or private posts |
|
284 | + if (! EEH_Template::is_espresso_theme()) { |
|
285 | + /** @type EE_Events_Archive_Config $config */ |
|
286 | + $config = $this->config(); |
|
287 | + // add status banner ? |
|
288 | + if ($config->display_status_banner) { |
|
289 | + add_filter('the_title', ['EED_Events_Archive', 'the_title'], 100, 2); |
|
290 | + } |
|
291 | + // if NOT a custom template |
|
292 | + if ( |
|
293 | + apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
294 | + || EE_Registry::instance() |
|
295 | + ->load_core('Front_Controller') |
|
296 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
297 | + ) { |
|
298 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
299 | + // load functions.php file for the theme (loaded by WP if using child theme) |
|
300 | + EEH_Template::load_espresso_theme_functions(); |
|
301 | + EED_Events_Archive::addEventDetailsFilters(); |
|
302 | + // don't display entry meta because the existing theme will take care of that |
|
303 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
304 | + } |
|
305 | + } |
|
306 | + return $template; |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
312 | + * then we need to remove our filters on the_content() |
|
313 | + * |
|
314 | + * @param string $excerpt |
|
315 | + * @return string |
|
316 | + * @throws EE_Error |
|
317 | + * @throws ReflectionException |
|
318 | + */ |
|
319 | + public static function get_the_excerpt($excerpt = '') |
|
320 | + { |
|
321 | + if (post_password_required()) { |
|
322 | + return $excerpt; |
|
323 | + } |
|
324 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
325 | + EED_Events_Archive::removeEventDetailsFilters(false); |
|
326 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
327 | + } else { |
|
328 | + EED_Events_Archive::$using_get_the_excerpt = true; |
|
329 | + add_filter('wp_trim_excerpt', ['EED_Events_Archive', 'end_get_the_excerpt'], 999, 1); |
|
330 | + } |
|
331 | + return $excerpt; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * @param string $text |
|
337 | + * @return string |
|
338 | + */ |
|
339 | + public static function end_get_the_excerpt($text = '') |
|
340 | + { |
|
341 | + EED_Events_Archive::$using_get_the_excerpt = false; |
|
342 | + return $text; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @param string $title |
|
348 | + * @param string $id |
|
349 | + * @return string |
|
350 | + * @throws EE_Error |
|
351 | + * @throws ReflectionException |
|
352 | + */ |
|
353 | + public static function the_title($title = '', $id = '') |
|
354 | + { |
|
355 | + global $post; |
|
356 | + if ($post instanceof WP_Post) { |
|
357 | + return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id |
|
358 | + ? espresso_event_status_banner($post->ID) . $title |
|
359 | + : $title; |
|
360 | + } |
|
361 | + return $title; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * @param string $content |
|
367 | + * @return string |
|
368 | + * @throws EE_Error |
|
369 | + * @throws ReflectionException |
|
370 | + */ |
|
371 | + public static function event_details($content) |
|
372 | + { |
|
373 | + global $post; |
|
374 | + static $current_post_ID = 0; |
|
375 | + if ( |
|
376 | + $current_post_ID !== $post->ID |
|
377 | + && $post->post_type === 'espresso_events' |
|
378 | + && ! EED_Events_Archive::$using_get_the_excerpt |
|
379 | + && ! post_password_required() |
|
380 | + && ( |
|
381 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
382 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
383 | + ) |
|
384 | + ) { |
|
385 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
386 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
387 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
388 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
389 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
390 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
391 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
392 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
393 | + $content = EED_Events_Archive::use_sortable_display_order(); |
|
394 | + } else { |
|
395 | + $content = EED_Events_Archive::use_filterable_display_order(); |
|
396 | + } |
|
397 | + } |
|
398 | + return $content; |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * @return string |
|
404 | + * @throws EE_Error |
|
405 | + * @throws ReflectionException |
|
406 | + */ |
|
407 | + protected static function use_sortable_display_order() |
|
408 | + { |
|
409 | + // no further password checks required atm |
|
410 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
411 | + // remove this callback from being applied to the_content() |
|
412 | + EED_Events_Archive::removeEventDetailsFilters(); |
|
413 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
414 | + EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
415 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
416 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
417 | + // re-add our main filters (or else the next event won't have them) |
|
418 | + EED_Events_Archive::addEventDetailsFilters(); |
|
419 | + remove_filter( |
|
420 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
421 | + '__return_true' |
|
422 | + ); |
|
423 | + return $content; |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + protected static function use_filterable_display_order() |
|
431 | + { |
|
432 | + // remove this callback from being applied to the_content() |
|
433 | + EED_Events_Archive::removeEventDetailsFilters(); |
|
434 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
435 | + EED_Events_Archive::_add_additional_excerpt_filters(); |
|
436 | + EED_Events_Archive::_add_additional_content_filters(); |
|
437 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
438 | + // now load our template |
|
439 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
440 | + // re-add our main filters (or else the next event won't have them) |
|
441 | + EED_Events_Archive::addEventDetailsFilters(); |
|
442 | + // but remove the other filters so that they don't get applied to the next post |
|
443 | + EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
444 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
445 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
446 | + // return ! empty( $template ) ? $template : $content; |
|
447 | + return $content; |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + /** |
|
452 | + * adds datetimes ABOVE content |
|
453 | + * |
|
454 | + * @param string $content |
|
455 | + * @return string |
|
456 | + */ |
|
457 | + public static function event_datetimes($content) |
|
458 | + { |
|
459 | + if (post_password_required()) { |
|
460 | + return $content; |
|
461 | + } |
|
462 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
463 | + } |
|
464 | + |
|
465 | + |
|
466 | + /** |
|
467 | + * adds tickets ABOVE content (which includes datetimes) |
|
468 | + * |
|
469 | + * @param string $content |
|
470 | + * @return string |
|
471 | + */ |
|
472 | + public static function event_tickets($content) |
|
473 | + { |
|
474 | + if (post_password_required()) { |
|
475 | + return $content; |
|
476 | + } |
|
477 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * adds venues BELOW content |
|
483 | + * |
|
484 | + * @param string $content |
|
485 | + * @return string |
|
486 | + */ |
|
487 | + public static function event_venue($content) |
|
488 | + { |
|
489 | + return EED_Events_Archive::event_venues($content); |
|
490 | + } |
|
491 | + |
|
492 | + |
|
493 | + /** |
|
494 | + * adds venues BELOW content |
|
495 | + * |
|
496 | + * @param string $content |
|
497 | + * @return string |
|
498 | + */ |
|
499 | + public static function event_venues($content) |
|
500 | + { |
|
501 | + if (post_password_required()) { |
|
502 | + return $content; |
|
503 | + } |
|
504 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * @return bool |
|
510 | + * @since $VID:$ |
|
511 | + */ |
|
512 | + public static function isBlockTheme() |
|
513 | + { |
|
514 | + return function_exists('wp_is_block_theme') && wp_is_block_theme(); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * @return string |
|
520 | + * @since $VID:$ |
|
521 | + */ |
|
522 | + public static function getExcerptFilter() |
|
523 | + { |
|
524 | + static $excerpt_filter = null; |
|
525 | + if ($excerpt_filter === null) { |
|
526 | + $excerpt_filter = EED_Events_Archive::isBlockTheme() ? 'get_the_excerpt' : 'the_excerpt'; |
|
527 | + } |
|
528 | + return $excerpt_filter; |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * @since $VID:$ |
|
534 | + */ |
|
535 | + protected static function addEventDetailsFilters() |
|
536 | + { |
|
537 | + add_filter( |
|
538 | + 'the_content', |
|
539 | + ['EED_Events_Archive', 'event_details'], |
|
540 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
541 | + ); |
|
542 | + // but because we don't know if the theme is using the_excerpt() |
|
543 | + add_filter( |
|
544 | + EED_Events_Archive::getExcerptFilter(), |
|
545 | + ['EED_Events_Archive', 'event_details'], |
|
546 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
547 | + ); |
|
548 | + // and just in case they are running get_the_excerpt() which DESTROYS things |
|
549 | + add_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1, 1); |
|
550 | + } |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * @param bool $and_get_the_excerpt |
|
555 | + * @since $VID:$ |
|
556 | + */ |
|
557 | + protected static function removeEventDetailsFilters($and_get_the_excerpt = true) |
|
558 | + { |
|
559 | + // we need to first remove all callbacks from being applied to the_content() |
|
560 | + // (otherwise it will recurse and blow up the interweb) |
|
561 | + remove_filter( |
|
562 | + 'the_content', |
|
563 | + ['EED_Events_Archive', 'event_details'], |
|
564 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
565 | + ); |
|
566 | + remove_filter( |
|
567 | + EED_Events_Archive::getExcerptFilter(), |
|
568 | + ['EED_Events_Archive', 'event_details'], |
|
569 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
570 | + ); |
|
571 | + if ($and_get_the_excerpt) { |
|
572 | + remove_filter('get_the_excerpt', ['EED_Events_Archive', 'get_the_excerpt'], 1); |
|
573 | + } |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * @return void |
|
579 | + */ |
|
580 | + private static function _add_additional_excerpt_filters() |
|
581 | + { |
|
582 | + add_filter( |
|
583 | + EED_Events_Archive::getExcerptFilter(), |
|
584 | + ['EED_Events_Archive', 'event_datetimes'], |
|
585 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
586 | + ); |
|
587 | + add_filter( |
|
588 | + EED_Events_Archive::getExcerptFilter(), |
|
589 | + ['EED_Events_Archive', 'event_tickets'], |
|
590 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
591 | + ); |
|
592 | + add_filter( |
|
593 | + EED_Events_Archive::getExcerptFilter(), |
|
594 | + ['EED_Events_Archive', 'event_venues'], |
|
595 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
596 | + ); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + /** |
|
601 | + * @return void |
|
602 | + */ |
|
603 | + private static function _add_additional_content_filters() |
|
604 | + { |
|
605 | + add_filter( |
|
606 | + 'the_content', |
|
607 | + ['EED_Events_Archive', 'event_datetimes'], |
|
608 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
609 | + ); |
|
610 | + add_filter( |
|
611 | + 'the_content', |
|
612 | + ['EED_Events_Archive', 'event_tickets'], |
|
613 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
614 | + ); |
|
615 | + add_filter( |
|
616 | + 'the_content', |
|
617 | + ['EED_Events_Archive', 'event_venues'], |
|
618 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
619 | + ); |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + /** |
|
624 | + * @return void |
|
625 | + */ |
|
626 | + private static function _remove_additional_events_archive_filters() |
|
627 | + { |
|
628 | + remove_filter( |
|
629 | + EED_Events_Archive::getExcerptFilter(), |
|
630 | + ['EED_Events_Archive', 'event_datetimes'], |
|
631 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
632 | + ); |
|
633 | + remove_filter( |
|
634 | + EED_Events_Archive::getExcerptFilter(), |
|
635 | + ['EED_Events_Archive', 'event_tickets'], |
|
636 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
637 | + ); |
|
638 | + remove_filter( |
|
639 | + EED_Events_Archive::getExcerptFilter(), |
|
640 | + ['EED_Events_Archive', 'event_venues'], |
|
641 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
642 | + ); |
|
643 | + remove_filter( |
|
644 | + 'the_content', |
|
645 | + ['EED_Events_Archive', 'event_datetimes'], |
|
646 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
647 | + ); |
|
648 | + remove_filter( |
|
649 | + 'the_content', |
|
650 | + ['EED_Events_Archive', 'event_tickets'], |
|
651 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
652 | + ); |
|
653 | + remove_filter( |
|
654 | + 'the_content', |
|
655 | + ['EED_Events_Archive', 'event_venues'], |
|
656 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
657 | + ); |
|
658 | + } |
|
659 | + |
|
660 | + |
|
661 | + /** |
|
662 | + * @return void |
|
663 | + */ |
|
664 | + public static function remove_all_events_archive_filters() |
|
665 | + { |
|
666 | + // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
667 | + remove_filter('the_title', ['EED_Events_Archive', 'the_title'], 1); |
|
668 | + remove_filter( |
|
669 | + EED_Events_Archive::getExcerptFilter(), |
|
670 | + ['EED_Events_Archive', 'event_details'], |
|
671 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
672 | + ); |
|
673 | + remove_filter( |
|
674 | + EED_Events_Archive::getExcerptFilter(), |
|
675 | + ['EED_Events_Archive', 'event_datetimes'], |
|
676 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
677 | + ); |
|
678 | + remove_filter( |
|
679 | + EED_Events_Archive::getExcerptFilter(), |
|
680 | + ['EED_Events_Archive', 'event_tickets'], |
|
681 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
682 | + ); |
|
683 | + remove_filter( |
|
684 | + EED_Events_Archive::getExcerptFilter(), |
|
685 | + ['EED_Events_Archive', 'event_venues'], |
|
686 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
687 | + ); |
|
688 | + remove_filter( |
|
689 | + 'the_content', |
|
690 | + ['EED_Events_Archive', 'event_details'], |
|
691 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
692 | + ); |
|
693 | + remove_filter( |
|
694 | + 'the_content', |
|
695 | + ['EED_Events_Archive', 'event_datetimes'], |
|
696 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
697 | + ); |
|
698 | + remove_filter( |
|
699 | + 'the_content', |
|
700 | + ['EED_Events_Archive', 'event_tickets'], |
|
701 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
702 | + ); |
|
703 | + remove_filter( |
|
704 | + 'the_content', |
|
705 | + ['EED_Events_Archive', 'event_venues'], |
|
706 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
707 | + ); |
|
708 | + // don't display entry meta because the existing theme will take care of that |
|
709 | + remove_filter( |
|
710 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
711 | + '__return_false' |
|
712 | + ); |
|
713 | + } |
|
714 | + |
|
715 | + |
|
716 | + /** |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + public function load_event_list_assets() |
|
720 | + { |
|
721 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
722 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
723 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
724 | + add_action('wp_enqueue_scripts', [$this, 'wp_enqueue_scripts'], 10); |
|
725 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
726 | + add_action('wp_enqueue_scripts', ['EEH_Maps', 'espresso_google_map_js'], 11); |
|
727 | + } |
|
728 | + } |
|
729 | + |
|
730 | + |
|
731 | + /** |
|
732 | + * @return void |
|
733 | + * @throws EE_Error |
|
734 | + */ |
|
735 | + public function wp_enqueue_scripts() |
|
736 | + { |
|
737 | + // get some style |
|
738 | + if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
739 | + // first check uploads folder |
|
740 | + if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
741 | + wp_register_style( |
|
742 | + $this->theme, |
|
743 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
744 | + ['dashicons', 'espresso_default'] |
|
745 | + ); |
|
746 | + } |
|
747 | + wp_enqueue_style($this->theme); |
|
748 | + } |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * @static |
|
754 | + * @return void |
|
755 | + */ |
|
756 | + public static function template_settings_form() |
|
757 | + { |
|
758 | + $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
759 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
760 | + ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
761 | + $template_settings->EED_Events_Archive = apply_filters( |
|
762 | + 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
763 | + $template_settings->EED_Events_Archive |
|
764 | + ); |
|
765 | + $events_archive_settings = [ |
|
766 | + 'display_status_banner' => 0, |
|
767 | + 'display_description' => 1, |
|
768 | + 'display_ticket_selector' => 0, |
|
769 | + 'display_datetimes' => 1, |
|
770 | + 'display_venue' => 0, |
|
771 | + 'display_expired_events' => 0, |
|
772 | + ]; |
|
773 | + $events_archive_settings = array_merge( |
|
774 | + $events_archive_settings, |
|
775 | + (array) $template_settings->EED_Events_Archive |
|
776 | + ); |
|
777 | + EEH_Template::display_template( |
|
778 | + EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
779 | + $events_archive_settings |
|
780 | + ); |
|
781 | + } |
|
782 | + |
|
783 | + |
|
784 | + /** |
|
785 | + * @param EE_Template_Config $CFG |
|
786 | + * @param array $REQ |
|
787 | + * @return EE_Template_Config |
|
788 | + */ |
|
789 | + public static function update_template_settings($CFG, $REQ) |
|
790 | + { |
|
791 | + $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
792 | + // unless we are resetting the config... |
|
793 | + if ( |
|
794 | + ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
795 | + || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
796 | + ) { |
|
797 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
798 | + ? absint($REQ['EED_Events_Archive_display_status_banner']) |
|
799 | + : 0; |
|
800 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
801 | + ? absint($REQ['EED_Events_Archive_display_description']) |
|
802 | + : 1; |
|
803 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
804 | + ? absint($REQ['EED_Events_Archive_display_ticket_selector']) |
|
805 | + : 0; |
|
806 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) |
|
807 | + ? absint($REQ['EED_Events_Archive_display_datetimes']) |
|
808 | + : 1; |
|
809 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) |
|
810 | + ? absint($REQ['EED_Events_Archive_display_venue']) |
|
811 | + : 0; |
|
812 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
813 | + ? absint($REQ['EED_Events_Archive_display_expired_events']) |
|
814 | + : 0; |
|
815 | + } |
|
816 | + return $CFG; |
|
817 | + } |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * @param string $extra_class |
|
822 | + * @return string |
|
823 | + */ |
|
824 | + public static function event_list_css($extra_class = '') |
|
825 | + { |
|
826 | + $event_list_css = ! empty($extra_class) ? [$extra_class] : []; |
|
827 | + $event_list_css[] = 'espresso-event-list-event'; |
|
828 | + return implode(' ', $event_list_css); |
|
829 | + } |
|
830 | + |
|
831 | + |
|
832 | + /** |
|
833 | + * @return array |
|
834 | + * @throws EE_Error |
|
835 | + * @throws ReflectionException |
|
836 | + */ |
|
837 | + public static function event_categories() |
|
838 | + { |
|
839 | + return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
840 | + } |
|
841 | + |
|
842 | + |
|
843 | + /** |
|
844 | + * @param $value |
|
845 | + * @return bool |
|
846 | + */ |
|
847 | + public static function display_description($value) |
|
848 | + { |
|
849 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
850 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
851 | + return $display_description === $value; |
|
852 | + } |
|
853 | + |
|
854 | + |
|
855 | + /** |
|
856 | + * @return bool |
|
857 | + */ |
|
858 | + public static function display_ticket_selector() |
|
859 | + { |
|
860 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
861 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector; |
|
862 | + } |
|
863 | + |
|
864 | + |
|
865 | + /** |
|
866 | + * @return bool |
|
867 | + * @throws EE_Error |
|
868 | + * @throws ReflectionException |
|
869 | + */ |
|
870 | + public static function display_venue() |
|
871 | + { |
|
872 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
873 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name(); |
|
874 | + } |
|
875 | + |
|
876 | + |
|
877 | + /** |
|
878 | + * @return bool |
|
879 | + */ |
|
880 | + public static function display_datetimes() |
|
881 | + { |
|
882 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
883 | + return isset($config->display_datetimes) && $config->display_datetimes; |
|
884 | + } |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * @return string |
|
889 | + */ |
|
890 | + public static function event_list_title() |
|
891 | + { |
|
892 | + return apply_filters( |
|
893 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
894 | + esc_html__('Upcoming Events', 'event_espresso') |
|
895 | + ); |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + // GRAVEYARD |
|
900 | + |
|
901 | + |
|
902 | + /** |
|
903 | + * @since 4.4.0 |
|
904 | + */ |
|
905 | + public static function _doing_it_wrong_notice($function = '') |
|
906 | + { |
|
907 | + EE_Error::doing_it_wrong( |
|
908 | + __FUNCTION__, |
|
909 | + sprintf( |
|
910 | + esc_html__( |
|
911 | + 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
912 | + 'event_espresso' |
|
913 | + ), |
|
914 | + $function, |
|
915 | + '<br />', |
|
916 | + '4.6.0' |
|
917 | + ), |
|
918 | + '4.4.0' |
|
919 | + ); |
|
920 | + } |
|
921 | + |
|
922 | + |
|
923 | + /** |
|
924 | + * @deprecated |
|
925 | + * @since 4.4.0 |
|
926 | + */ |
|
927 | + public function get_post_data() |
|
928 | + { |
|
929 | + EEH_Event_Query::set_query_params(); |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + /** |
|
934 | + * @throws EE_Error |
|
935 | + * @since 4.4.0 |
|
936 | + * @deprecated |
|
937 | + */ |
|
938 | + public function posts_fields($SQL, WP_Query $wp_query) |
|
939 | + { |
|
940 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
941 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
942 | + } |
|
943 | + |
|
944 | + |
|
945 | + /** |
|
946 | + * @throws EE_Error |
|
947 | + * @since 4.4.0 |
|
948 | + * @deprecated |
|
949 | + */ |
|
950 | + public static function posts_fields_sql_for_orderby($orderby_params = []) |
|
951 | + { |
|
952 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
953 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
954 | + } |
|
955 | + |
|
956 | + |
|
957 | + /** |
|
958 | + * @throws EE_Error |
|
959 | + * @since 4.4.0 |
|
960 | + * @deprecated |
|
961 | + */ |
|
962 | + public function posts_join($SQL, WP_Query $wp_query) |
|
963 | + { |
|
964 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
965 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
966 | + } |
|
967 | + |
|
968 | + |
|
969 | + /** |
|
970 | + * @deprecated |
|
971 | + * @since 4.4.0 |
|
972 | + */ |
|
973 | + public static function posts_join_sql_for_terms($join_terms = null) |
|
974 | + { |
|
975 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
976 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
977 | + } |
|
978 | + |
|
979 | + |
|
980 | + /** |
|
981 | + * @throws EE_Error |
|
982 | + * @since 4.4.0 |
|
983 | + * @deprecated |
|
984 | + */ |
|
985 | + public static function posts_join_for_orderby($orderby_params = []) |
|
986 | + { |
|
987 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
988 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
989 | + } |
|
990 | + |
|
991 | + |
|
992 | + /** |
|
993 | + * @throws EE_Error |
|
994 | + * @since 4.4.0 |
|
995 | + * @deprecated |
|
996 | + */ |
|
997 | + public function posts_where($SQL, WP_Query $wp_query) |
|
998 | + { |
|
999 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1000 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1001 | + } |
|
1002 | + |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * @throws EE_Error |
|
1006 | + * @since 4.4.0 |
|
1007 | + * @deprecated |
|
1008 | + */ |
|
1009 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1010 | + { |
|
1011 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1012 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * @deprecated |
|
1018 | + * @since 4.4.0 |
|
1019 | + */ |
|
1020 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1021 | + { |
|
1022 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1023 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1024 | + } |
|
1025 | + |
|
1026 | + |
|
1027 | + /** |
|
1028 | + * @throws EE_Error |
|
1029 | + * @since 4.4.0 |
|
1030 | + * @deprecated |
|
1031 | + */ |
|
1032 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
1033 | + { |
|
1034 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1035 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1036 | + } |
|
1037 | + |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * @throws EE_Error |
|
1041 | + * @since 4.4.0 |
|
1042 | + * @deprecated |
|
1043 | + */ |
|
1044 | + public function posts_orderby($SQL, WP_Query $wp_query) |
|
1045 | + { |
|
1046 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1047 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1048 | + } |
|
1049 | + |
|
1050 | + |
|
1051 | + /** |
|
1052 | + * @throws EE_Error |
|
1053 | + * @since 4.4.0 |
|
1054 | + * @deprecated |
|
1055 | + */ |
|
1056 | + public static function posts_orderby_sql($orderby_params = [], $sort = 'ASC') |
|
1057 | + { |
|
1058 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1059 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1060 | + } |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | |
@@ -1066,9 +1066,9 @@ discard block |
||
1066 | 1066 | */ |
1067 | 1067 | function espresso_get_event_list_ID() |
1068 | 1068 | { |
1069 | - EED_Events_Archive::$espresso_event_list_ID++; |
|
1070 | - EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1071 | - return EED_Events_Archive::$espresso_event_list_ID; |
|
1069 | + EED_Events_Archive::$espresso_event_list_ID++; |
|
1070 | + EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1071 | + return EED_Events_Archive::$espresso_event_list_ID; |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | */ |
1078 | 1078 | function espresso_event_list_title() |
1079 | 1079 | { |
1080 | - return EED_Events_Archive::event_list_title(); |
|
1080 | + return EED_Events_Archive::event_list_title(); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | */ |
1088 | 1088 | function espresso_event_list_css($extra_class = '') |
1089 | 1089 | { |
1090 | - return EED_Events_Archive::event_list_css($extra_class); |
|
1090 | + return EED_Events_Archive::event_list_css($extra_class); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | */ |
1099 | 1099 | function espresso_get_event_categories() |
1100 | 1100 | { |
1101 | - return EED_Events_Archive::event_categories(); |
|
1101 | + return EED_Events_Archive::event_categories(); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | function espresso_display_full_description_in_event_list() |
1109 | 1109 | { |
1110 | - return EED_Events_Archive::display_description(2); |
|
1110 | + return EED_Events_Archive::display_description(2); |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | |
@@ -1116,7 +1116,7 @@ discard block |
||
1116 | 1116 | */ |
1117 | 1117 | function espresso_display_excerpt_in_event_list() |
1118 | 1118 | { |
1119 | - return EED_Events_Archive::display_description(1); |
|
1119 | + return EED_Events_Archive::display_description(1); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | function espresso_display_ticket_selector_in_event_list() |
1127 | 1127 | { |
1128 | - return EED_Events_Archive::display_ticket_selector(); |
|
1128 | + return EED_Events_Archive::display_ticket_selector(); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | */ |
1137 | 1137 | function espresso_display_venue_in_event_list() |
1138 | 1138 | { |
1139 | - return EED_Events_Archive::display_venue(); |
|
1139 | + return EED_Events_Archive::display_venue(); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | |
@@ -1145,5 +1145,5 @@ discard block |
||
1145 | 1145 | */ |
1146 | 1146 | function espresso_display_datetimes_in_event_list() |
1147 | 1147 | { |
1148 | - return EED_Events_Archive::display_datetimes(); |
|
1148 | + return EED_Events_Archive::display_datetimes(); |
|
1149 | 1149 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public static function set_definitions() |
122 | 122 | { |
123 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
124 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
123 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
124 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function get_iframe_embed_button() |
143 | 143 | { |
144 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
144 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
145 | 145 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
146 | 146 | } |
147 | 147 | return self::$_iframe_embed_button; |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | EEH_Event_Query::add_query_filters(); |
219 | 219 | // set params that will get used by the filters |
220 | 220 | EEH_Event_Query::set_query_params( |
221 | - '', // month |
|
222 | - '', // category |
|
221 | + '', // month |
|
222 | + '', // category |
|
223 | 223 | $config->display_expired_events // show_expired |
224 | 224 | ); |
225 | 225 | // check what template is loaded |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | public function template_include($template = '') |
282 | 282 | { |
283 | 283 | // don't add content filter for dedicated EE child themes or private posts |
284 | - if (! EEH_Template::is_espresso_theme()) { |
|
284 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
285 | 285 | /** @type EE_Events_Archive_Config $config */ |
286 | 286 | $config = $this->config(); |
287 | 287 | // add status banner ? |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | global $post; |
356 | 356 | if ($post instanceof WP_Post) { |
357 | 357 | return (EED_Events_Archive::isBlockTheme() || in_the_loop()) && $post->ID == $id |
358 | - ? espresso_event_status_banner($post->ID) . $title |
|
358 | + ? espresso_event_status_banner($post->ID).$title |
|
359 | 359 | : $title; |
360 | 360 | } |
361 | 361 | return $title; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | if (post_password_required()) { |
460 | 460 | return $content; |
461 | 461 | } |
462 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
462 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | if (post_password_required()) { |
475 | 475 | return $content; |
476 | 476 | } |
477 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
477 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | if (post_password_required()) { |
502 | 502 | return $content; |
503 | 503 | } |
504 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
504 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | // get some style |
738 | 738 | if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
739 | 739 | // first check uploads folder |
740 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
740 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
741 | 741 | wp_register_style( |
742 | 742 | $this->theme, |
743 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
743 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
744 | 744 | ['dashicons', 'espresso_default'] |
745 | 745 | ); |
746 | 746 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
763 | 763 | $template_settings->EED_Events_Archive |
764 | 764 | ); |
765 | - $events_archive_settings = [ |
|
765 | + $events_archive_settings = [ |
|
766 | 766 | 'display_status_banner' => 0, |
767 | 767 | 'display_description' => 1, |
768 | 768 | 'display_ticket_selector' => 0, |
@@ -770,12 +770,12 @@ discard block |
||
770 | 770 | 'display_venue' => 0, |
771 | 771 | 'display_expired_events' => 0, |
772 | 772 | ]; |
773 | - $events_archive_settings = array_merge( |
|
773 | + $events_archive_settings = array_merge( |
|
774 | 774 | $events_archive_settings, |
775 | 775 | (array) $template_settings->EED_Events_Archive |
776 | 776 | ); |
777 | 777 | EEH_Template::display_template( |
778 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
778 | + EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', |
|
779 | 779 | $events_archive_settings |
780 | 780 | ); |
781 | 781 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.33.rc.011'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.33.rc.011'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | \ No newline at end of file |