@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
5 | - exit( 'No direct script access allowed' ); |
|
5 | + exit( 'No direct script access allowed' ); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -18,338 +18,338 @@ discard block |
||
18 | 18 | class Iframe |
19 | 19 | { |
20 | 20 | |
21 | - /* |
|
21 | + /* |
|
22 | 22 | * HTML for notices and ajax gif |
23 | 23 | * @var string $title |
24 | 24 | */ |
25 | - protected $title = ''; |
|
25 | + protected $title = ''; |
|
26 | 26 | |
27 | - /* |
|
27 | + /* |
|
28 | 28 | * HTML for the content being displayed |
29 | 29 | * @var string $content |
30 | 30 | */ |
31 | - protected $content = ''; |
|
31 | + protected $content = ''; |
|
32 | 32 | |
33 | - /* |
|
33 | + /* |
|
34 | 34 | * whether or not to call wp_head() and wp_footer() |
35 | 35 | * @var boolean $enqueue_wp_assets |
36 | 36 | */ |
37 | - protected $enqueue_wp_assets = false; |
|
37 | + protected $enqueue_wp_assets = false; |
|
38 | 38 | |
39 | - /* |
|
39 | + /* |
|
40 | 40 | * an array of CSS URLs |
41 | 41 | * @var array $css |
42 | 42 | */ |
43 | - protected $css = array(); |
|
43 | + protected $css = array(); |
|
44 | 44 | |
45 | - /* |
|
45 | + /* |
|
46 | 46 | * an array of JS URLs to be set in the HTML header. |
47 | 47 | * @var array $header_js |
48 | 48 | */ |
49 | - protected $header_js = array(); |
|
49 | + protected $header_js = array(); |
|
50 | 50 | |
51 | - /* |
|
51 | + /* |
|
52 | 52 | * an array of JS URLs to be displayed before the HTML </body> tag |
53 | 53 | * @var array $footer_js |
54 | 54 | */ |
55 | - protected $footer_js = array(); |
|
55 | + protected $footer_js = array(); |
|
56 | 56 | |
57 | - /* |
|
57 | + /* |
|
58 | 58 | * an array of JSON vars to be set in the HTML header. |
59 | 59 | * @var array $localized_vars |
60 | 60 | */ |
61 | - protected $localized_vars = array(); |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Iframe constructor |
|
67 | - * |
|
68 | - * @param string $title |
|
69 | - * @param string $content |
|
70 | - * @throws \DomainException |
|
71 | - */ |
|
72 | - public function __construct( $title, $content ) |
|
73 | - { |
|
74 | - global $wp_version; |
|
75 | - if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
76 | - define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
77 | - } |
|
78 | - $this->setContent( $content ); |
|
79 | - $this->setTitle( $title ); |
|
80 | - $this->addStylesheets( |
|
81 | - apply_filters( |
|
82 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
83 | - array( |
|
84 | - 'site_theme' => get_stylesheet_directory_uri() . DS |
|
85 | - . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
86 | - 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
87 | - 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
88 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
89 | - ), |
|
90 | - $this |
|
91 | - ) |
|
92 | - ); |
|
93 | - $this->addScripts( |
|
94 | - apply_filters( |
|
95 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
96 | - array( |
|
97 | - 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
98 | - 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
99 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
100 | - ), |
|
101 | - $this |
|
102 | - ) |
|
103 | - ); |
|
104 | - if ( |
|
105 | - apply_filters( |
|
106 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
107 | - false |
|
108 | - ) |
|
109 | - ) { |
|
110 | - $this->addStylesheets( |
|
111 | - apply_filters( |
|
112 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
113 | - array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
114 | - $this |
|
115 | - ) |
|
116 | - ); |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $title |
|
124 | - * @throws \DomainException |
|
125 | - */ |
|
126 | - public function setTitle( $title ) |
|
127 | - { |
|
128 | - if ( empty( $title ) ) { |
|
129 | - throw new \DomainException( |
|
130 | - esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
131 | - ); |
|
132 | - } |
|
133 | - $this->title = $title; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @param string $content |
|
140 | - * @throws \DomainException |
|
141 | - */ |
|
142 | - public function setContent( $content ) |
|
143 | - { |
|
144 | - if ( empty( $content ) ) { |
|
145 | - throw new \DomainException( |
|
146 | - esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
147 | - ); |
|
148 | - } |
|
149 | - $this->content = $content; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @param boolean $enqueue_wp_assets |
|
156 | - */ |
|
157 | - public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
158 | - { |
|
159 | - $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param array $stylesheets |
|
166 | - * @throws \DomainException |
|
167 | - */ |
|
168 | - public function addStylesheets( array $stylesheets ) |
|
169 | - { |
|
170 | - if ( empty( $stylesheets ) ) { |
|
171 | - throw new \DomainException( |
|
172 | - esc_html__( |
|
173 | - 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
174 | - 'event_espresso' |
|
175 | - ) |
|
176 | - ); |
|
177 | - } |
|
178 | - foreach ( $stylesheets as $handle => $stylesheet ) { |
|
179 | - $this->css[ $handle ] = $stylesheet; |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * @param array $scripts |
|
187 | - * @param bool $add_to_header |
|
188 | - * @throws \DomainException |
|
189 | - */ |
|
190 | - public function addScripts( array $scripts, $add_to_header = false ) |
|
191 | - { |
|
192 | - if ( empty( $scripts ) ) { |
|
193 | - throw new \DomainException( |
|
194 | - esc_html__( |
|
195 | - 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
196 | - 'event_espresso' |
|
197 | - ) |
|
198 | - ); |
|
199 | - } |
|
200 | - foreach ( $scripts as $handle => $script ) { |
|
201 | - if ( $add_to_header ) { |
|
202 | - $this->header_js[ $handle ] = $script; |
|
203 | - } else { |
|
204 | - $this->footer_js[ $handle ] = $script; |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @param array $vars |
|
213 | - * @param string $var_name |
|
214 | - * @throws \DomainException |
|
215 | - */ |
|
216 | - public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
217 | - { |
|
218 | - if ( empty( $vars ) ) { |
|
219 | - throw new \DomainException( |
|
220 | - esc_html__( |
|
221 | - 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
222 | - 'event_espresso' |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
226 | - foreach ( $vars as $handle => $var ) { |
|
227 | - if ( $var_name === 'eei18n' ) { |
|
228 | - \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
229 | - } else { |
|
230 | - if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
231 | - $this->localized_vars[ $var_name ] = array(); |
|
232 | - } |
|
233 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
234 | - } |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $utm_content |
|
242 | - * @throws \DomainException |
|
243 | - */ |
|
244 | - public function display($utm_content = '') |
|
245 | - { |
|
246 | - $this->content .= \EEH_Template::powered_by_event_espresso( |
|
247 | - '', |
|
248 | - '', |
|
249 | - ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
250 | - ); |
|
251 | - \EE_System::do_not_cache(); |
|
252 | - echo $this->getTemplate(); |
|
253 | - exit; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * @return string |
|
260 | - * @throws \DomainException |
|
261 | - */ |
|
262 | - public function getTemplate() |
|
263 | - { |
|
264 | - return \EEH_Template::display_template( |
|
265 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
266 | - array( |
|
267 | - 'title' => apply_filters( |
|
268 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
269 | - $this->title, |
|
270 | - $this |
|
271 | - ), |
|
272 | - 'content' => apply_filters( |
|
273 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
274 | - $this->content, |
|
275 | - $this |
|
276 | - ), |
|
277 | - 'enqueue_wp_assets' => apply_filters( |
|
278 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
279 | - $this->enqueue_wp_assets, |
|
280 | - $this |
|
281 | - ), |
|
282 | - 'css' => (array)apply_filters( |
|
283 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
284 | - $this->css, |
|
285 | - $this |
|
286 | - ), |
|
287 | - 'header_js' => (array)apply_filters( |
|
288 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
289 | - $this->header_js, |
|
290 | - $this |
|
291 | - ), |
|
292 | - 'footer_js' => (array)apply_filters( |
|
293 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
294 | - $this->footer_js, |
|
295 | - $this |
|
296 | - ), |
|
297 | - 'eei18n' => apply_filters( |
|
298 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
299 | - \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
300 | - $this |
|
301 | - ), |
|
302 | - 'notices' => \EEH_Template::display_template( |
|
303 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
304 | - array(), |
|
305 | - true |
|
306 | - ), |
|
307 | - ), |
|
308 | - true, |
|
309 | - true |
|
310 | - ); |
|
311 | - } |
|
312 | - |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * localizeJsonVars |
|
317 | - * |
|
318 | - * @return string |
|
319 | - */ |
|
320 | - public function localizeJsonVars() |
|
321 | - { |
|
322 | - $JSON = ''; |
|
323 | - foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
324 | - foreach ( (array)$vars as $key => $value ) { |
|
325 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
326 | - } |
|
327 | - $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
328 | - $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
329 | - $JSON .= '; /* ]]> */'; |
|
330 | - } |
|
331 | - return $JSON; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @param bool|int|float|string|array $var |
|
338 | - * @return array |
|
339 | - */ |
|
340 | - public function encodeJsonVars( $var ) |
|
341 | - { |
|
342 | - if ( is_array( $var ) ) { |
|
343 | - $localized_vars = array(); |
|
344 | - foreach ( (array)$var as $key => $value ) { |
|
345 | - $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
346 | - } |
|
347 | - return $localized_vars; |
|
348 | - } else if ( is_scalar( $var ) ) { |
|
349 | - return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
350 | - } |
|
351 | - return null; |
|
352 | - } |
|
61 | + protected $localized_vars = array(); |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Iframe constructor |
|
67 | + * |
|
68 | + * @param string $title |
|
69 | + * @param string $content |
|
70 | + * @throws \DomainException |
|
71 | + */ |
|
72 | + public function __construct( $title, $content ) |
|
73 | + { |
|
74 | + global $wp_version; |
|
75 | + if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
76 | + define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
77 | + } |
|
78 | + $this->setContent( $content ); |
|
79 | + $this->setTitle( $title ); |
|
80 | + $this->addStylesheets( |
|
81 | + apply_filters( |
|
82 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
83 | + array( |
|
84 | + 'site_theme' => get_stylesheet_directory_uri() . DS |
|
85 | + . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
86 | + 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
87 | + 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
88 | + . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
89 | + ), |
|
90 | + $this |
|
91 | + ) |
|
92 | + ); |
|
93 | + $this->addScripts( |
|
94 | + apply_filters( |
|
95 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
96 | + array( |
|
97 | + 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
98 | + 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
99 | + . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
100 | + ), |
|
101 | + $this |
|
102 | + ) |
|
103 | + ); |
|
104 | + if ( |
|
105 | + apply_filters( |
|
106 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
107 | + false |
|
108 | + ) |
|
109 | + ) { |
|
110 | + $this->addStylesheets( |
|
111 | + apply_filters( |
|
112 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
113 | + array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
114 | + $this |
|
115 | + ) |
|
116 | + ); |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $title |
|
124 | + * @throws \DomainException |
|
125 | + */ |
|
126 | + public function setTitle( $title ) |
|
127 | + { |
|
128 | + if ( empty( $title ) ) { |
|
129 | + throw new \DomainException( |
|
130 | + esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
131 | + ); |
|
132 | + } |
|
133 | + $this->title = $title; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @param string $content |
|
140 | + * @throws \DomainException |
|
141 | + */ |
|
142 | + public function setContent( $content ) |
|
143 | + { |
|
144 | + if ( empty( $content ) ) { |
|
145 | + throw new \DomainException( |
|
146 | + esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
147 | + ); |
|
148 | + } |
|
149 | + $this->content = $content; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @param boolean $enqueue_wp_assets |
|
156 | + */ |
|
157 | + public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
158 | + { |
|
159 | + $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param array $stylesheets |
|
166 | + * @throws \DomainException |
|
167 | + */ |
|
168 | + public function addStylesheets( array $stylesheets ) |
|
169 | + { |
|
170 | + if ( empty( $stylesheets ) ) { |
|
171 | + throw new \DomainException( |
|
172 | + esc_html__( |
|
173 | + 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
174 | + 'event_espresso' |
|
175 | + ) |
|
176 | + ); |
|
177 | + } |
|
178 | + foreach ( $stylesheets as $handle => $stylesheet ) { |
|
179 | + $this->css[ $handle ] = $stylesheet; |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * @param array $scripts |
|
187 | + * @param bool $add_to_header |
|
188 | + * @throws \DomainException |
|
189 | + */ |
|
190 | + public function addScripts( array $scripts, $add_to_header = false ) |
|
191 | + { |
|
192 | + if ( empty( $scripts ) ) { |
|
193 | + throw new \DomainException( |
|
194 | + esc_html__( |
|
195 | + 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
196 | + 'event_espresso' |
|
197 | + ) |
|
198 | + ); |
|
199 | + } |
|
200 | + foreach ( $scripts as $handle => $script ) { |
|
201 | + if ( $add_to_header ) { |
|
202 | + $this->header_js[ $handle ] = $script; |
|
203 | + } else { |
|
204 | + $this->footer_js[ $handle ] = $script; |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @param array $vars |
|
213 | + * @param string $var_name |
|
214 | + * @throws \DomainException |
|
215 | + */ |
|
216 | + public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
217 | + { |
|
218 | + if ( empty( $vars ) ) { |
|
219 | + throw new \DomainException( |
|
220 | + esc_html__( |
|
221 | + 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
222 | + 'event_espresso' |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | + foreach ( $vars as $handle => $var ) { |
|
227 | + if ( $var_name === 'eei18n' ) { |
|
228 | + \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
229 | + } else { |
|
230 | + if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
231 | + $this->localized_vars[ $var_name ] = array(); |
|
232 | + } |
|
233 | + $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
234 | + } |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $utm_content |
|
242 | + * @throws \DomainException |
|
243 | + */ |
|
244 | + public function display($utm_content = '') |
|
245 | + { |
|
246 | + $this->content .= \EEH_Template::powered_by_event_espresso( |
|
247 | + '', |
|
248 | + '', |
|
249 | + ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
250 | + ); |
|
251 | + \EE_System::do_not_cache(); |
|
252 | + echo $this->getTemplate(); |
|
253 | + exit; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * @return string |
|
260 | + * @throws \DomainException |
|
261 | + */ |
|
262 | + public function getTemplate() |
|
263 | + { |
|
264 | + return \EEH_Template::display_template( |
|
265 | + __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
266 | + array( |
|
267 | + 'title' => apply_filters( |
|
268 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
269 | + $this->title, |
|
270 | + $this |
|
271 | + ), |
|
272 | + 'content' => apply_filters( |
|
273 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
274 | + $this->content, |
|
275 | + $this |
|
276 | + ), |
|
277 | + 'enqueue_wp_assets' => apply_filters( |
|
278 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
279 | + $this->enqueue_wp_assets, |
|
280 | + $this |
|
281 | + ), |
|
282 | + 'css' => (array)apply_filters( |
|
283 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
284 | + $this->css, |
|
285 | + $this |
|
286 | + ), |
|
287 | + 'header_js' => (array)apply_filters( |
|
288 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
289 | + $this->header_js, |
|
290 | + $this |
|
291 | + ), |
|
292 | + 'footer_js' => (array)apply_filters( |
|
293 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
294 | + $this->footer_js, |
|
295 | + $this |
|
296 | + ), |
|
297 | + 'eei18n' => apply_filters( |
|
298 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
299 | + \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
300 | + $this |
|
301 | + ), |
|
302 | + 'notices' => \EEH_Template::display_template( |
|
303 | + EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
304 | + array(), |
|
305 | + true |
|
306 | + ), |
|
307 | + ), |
|
308 | + true, |
|
309 | + true |
|
310 | + ); |
|
311 | + } |
|
312 | + |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * localizeJsonVars |
|
317 | + * |
|
318 | + * @return string |
|
319 | + */ |
|
320 | + public function localizeJsonVars() |
|
321 | + { |
|
322 | + $JSON = ''; |
|
323 | + foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
324 | + foreach ( (array)$vars as $key => $value ) { |
|
325 | + $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
326 | + } |
|
327 | + $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
328 | + $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
329 | + $JSON .= '; /* ]]> */'; |
|
330 | + } |
|
331 | + return $JSON; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @param bool|int|float|string|array $var |
|
338 | + * @return array |
|
339 | + */ |
|
340 | + public function encodeJsonVars( $var ) |
|
341 | + { |
|
342 | + if ( is_array( $var ) ) { |
|
343 | + $localized_vars = array(); |
|
344 | + foreach ( (array)$var as $key => $value ) { |
|
345 | + $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
346 | + } |
|
347 | + return $localized_vars; |
|
348 | + } else if ( is_scalar( $var ) ) { |
|
349 | + return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
350 | + } |
|
351 | + return null; |
|
352 | + } |
|
353 | 353 | |
354 | 354 | |
355 | 355 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | * @param string $content |
70 | 70 | * @throws \DomainException |
71 | 71 | */ |
72 | - public function __construct( $title, $content ) |
|
72 | + public function __construct($title, $content) |
|
73 | 73 | { |
74 | 74 | global $wp_version; |
75 | - if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
76 | - define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
75 | + if ( ! defined('EE_IFRAME_DIR_URL')) { |
|
76 | + define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__)); |
|
77 | 77 | } |
78 | - $this->setContent( $content ); |
|
79 | - $this->setTitle( $title ); |
|
78 | + $this->setContent($content); |
|
79 | + $this->setTitle($title); |
|
80 | 80 | $this->addStylesheets( |
81 | 81 | apply_filters( |
82 | 82 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
83 | 83 | array( |
84 | - 'site_theme' => get_stylesheet_directory_uri() . DS |
|
85 | - . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
86 | - 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
84 | + 'site_theme' => get_stylesheet_directory_uri().DS |
|
85 | + . 'style.css?ver='.EVENT_ESPRESSO_VERSION, |
|
86 | + 'dashicons' => includes_url('css/dashicons.min.css?ver='.$wp_version), |
|
87 | 87 | 'espresso_default' => EE_GLOBAL_ASSETS_URL |
88 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
88 | + . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION, |
|
89 | 89 | ), |
90 | 90 | $this |
91 | 91 | ) |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | apply_filters( |
95 | 95 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
96 | 96 | array( |
97 | - 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
97 | + 'jquery' => includes_url('js/jquery/jquery.js?ver='.$wp_version), |
|
98 | 98 | 'espresso_core' => EE_GLOBAL_ASSETS_URL |
99 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
99 | + . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
100 | 100 | ), |
101 | 101 | $this |
102 | 102 | ) |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | * @param string $title |
124 | 124 | * @throws \DomainException |
125 | 125 | */ |
126 | - public function setTitle( $title ) |
|
126 | + public function setTitle($title) |
|
127 | 127 | { |
128 | - if ( empty( $title ) ) { |
|
128 | + if (empty($title)) { |
|
129 | 129 | throw new \DomainException( |
130 | - esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
130 | + esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso') |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | $this->title = $title; |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * @param string $content |
140 | 140 | * @throws \DomainException |
141 | 141 | */ |
142 | - public function setContent( $content ) |
|
142 | + public function setContent($content) |
|
143 | 143 | { |
144 | - if ( empty( $content ) ) { |
|
144 | + if (empty($content)) { |
|
145 | 145 | throw new \DomainException( |
146 | - esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
146 | + esc_html__('You must provide content in order to create an iframe.', 'event_espresso') |
|
147 | 147 | ); |
148 | 148 | } |
149 | 149 | $this->content = $content; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param boolean $enqueue_wp_assets |
156 | 156 | */ |
157 | - public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
157 | + public function setEnqueueWpAssets($enqueue_wp_assets) |
|
158 | 158 | { |
159 | - $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
159 | + $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param array $stylesheets |
166 | 166 | * @throws \DomainException |
167 | 167 | */ |
168 | - public function addStylesheets( array $stylesheets ) |
|
168 | + public function addStylesheets(array $stylesheets) |
|
169 | 169 | { |
170 | - if ( empty( $stylesheets ) ) { |
|
170 | + if (empty($stylesheets)) { |
|
171 | 171 | throw new \DomainException( |
172 | 172 | esc_html__( |
173 | 173 | 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | } |
178 | - foreach ( $stylesheets as $handle => $stylesheet ) { |
|
179 | - $this->css[ $handle ] = $stylesheet; |
|
178 | + foreach ($stylesheets as $handle => $stylesheet) { |
|
179 | + $this->css[$handle] = $stylesheet; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param bool $add_to_header |
188 | 188 | * @throws \DomainException |
189 | 189 | */ |
190 | - public function addScripts( array $scripts, $add_to_header = false ) |
|
190 | + public function addScripts(array $scripts, $add_to_header = false) |
|
191 | 191 | { |
192 | - if ( empty( $scripts ) ) { |
|
192 | + if (empty($scripts)) { |
|
193 | 193 | throw new \DomainException( |
194 | 194 | esc_html__( |
195 | 195 | 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | ) |
198 | 198 | ); |
199 | 199 | } |
200 | - foreach ( $scripts as $handle => $script ) { |
|
201 | - if ( $add_to_header ) { |
|
202 | - $this->header_js[ $handle ] = $script; |
|
200 | + foreach ($scripts as $handle => $script) { |
|
201 | + if ($add_to_header) { |
|
202 | + $this->header_js[$handle] = $script; |
|
203 | 203 | } else { |
204 | - $this->footer_js[ $handle ] = $script; |
|
204 | + $this->footer_js[$handle] = $script; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | * @param string $var_name |
214 | 214 | * @throws \DomainException |
215 | 215 | */ |
216 | - public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
216 | + public function addLocalizedVars(array $vars, $var_name = 'eei18n') |
|
217 | 217 | { |
218 | - if ( empty( $vars ) ) { |
|
218 | + if (empty($vars)) { |
|
219 | 219 | throw new \DomainException( |
220 | 220 | esc_html__( |
221 | 221 | 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | ) |
224 | 224 | ); |
225 | 225 | } |
226 | - foreach ( $vars as $handle => $var ) { |
|
227 | - if ( $var_name === 'eei18n' ) { |
|
228 | - \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
226 | + foreach ($vars as $handle => $var) { |
|
227 | + if ($var_name === 'eei18n') { |
|
228 | + \EE_Registry::$i18n_js_strings[$handle] = $var; |
|
229 | 229 | } else { |
230 | - if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
231 | - $this->localized_vars[ $var_name ] = array(); |
|
230 | + if ( ! isset($this->localized_vars[$var_name])) { |
|
231 | + $this->localized_vars[$var_name] = array(); |
|
232 | 232 | } |
233 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
233 | + $this->localized_vars[$var_name][$handle] = $var; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | public function getTemplate() |
263 | 263 | { |
264 | 264 | return \EEH_Template::display_template( |
265 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
265 | + __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php', |
|
266 | 266 | array( |
267 | 267 | 'title' => apply_filters( |
268 | 268 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
@@ -279,28 +279,28 @@ discard block |
||
279 | 279 | $this->enqueue_wp_assets, |
280 | 280 | $this |
281 | 281 | ), |
282 | - 'css' => (array)apply_filters( |
|
282 | + 'css' => (array) apply_filters( |
|
283 | 283 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
284 | 284 | $this->css, |
285 | 285 | $this |
286 | 286 | ), |
287 | - 'header_js' => (array)apply_filters( |
|
287 | + 'header_js' => (array) apply_filters( |
|
288 | 288 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
289 | 289 | $this->header_js, |
290 | 290 | $this |
291 | 291 | ), |
292 | - 'footer_js' => (array)apply_filters( |
|
292 | + 'footer_js' => (array) apply_filters( |
|
293 | 293 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
294 | 294 | $this->footer_js, |
295 | 295 | $this |
296 | 296 | ), |
297 | 297 | 'eei18n' => apply_filters( |
298 | 298 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
299 | - \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
299 | + \EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(), |
|
300 | 300 | $this |
301 | 301 | ), |
302 | 302 | 'notices' => \EEH_Template::display_template( |
303 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
303 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
304 | 304 | array(), |
305 | 305 | true |
306 | 306 | ), |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | public function localizeJsonVars() |
321 | 321 | { |
322 | 322 | $JSON = ''; |
323 | - foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
324 | - foreach ( (array)$vars as $key => $value ) { |
|
325 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
323 | + foreach ((array) $this->localized_vars as $var_name => $vars) { |
|
324 | + foreach ((array) $vars as $key => $value) { |
|
325 | + $this->localized_vars[$var_name] = $this->encodeJsonVars($value); |
|
326 | 326 | } |
327 | 327 | $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
328 | - $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
328 | + $JSON .= wp_json_encode($this->localized_vars[$var_name]); |
|
329 | 329 | $JSON .= '; /* ]]> */'; |
330 | 330 | } |
331 | 331 | return $JSON; |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | * @param bool|int|float|string|array $var |
338 | 338 | * @return array |
339 | 339 | */ |
340 | - public function encodeJsonVars( $var ) |
|
340 | + public function encodeJsonVars($var) |
|
341 | 341 | { |
342 | - if ( is_array( $var ) ) { |
|
342 | + if (is_array($var)) { |
|
343 | 343 | $localized_vars = array(); |
344 | - foreach ( (array)$var as $key => $value ) { |
|
345 | - $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
344 | + foreach ((array) $var as $key => $value) { |
|
345 | + $localized_vars[$key] = $this->encodeJsonVars($value); |
|
346 | 346 | } |
347 | 347 | return $localized_vars; |
348 | - } else if ( is_scalar( $var ) ) { |
|
349 | - return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
348 | + } else if (is_scalar($var)) { |
|
349 | + return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8'); |
|
350 | 350 | } |
351 | 351 | return null; |
352 | 352 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,65 +17,65 @@ discard block |
||
17 | 17 | class EE_Checkbox_Dropdown_Selector_Input extends EE_Form_Input_With_Options_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string text to display on the select button itself |
|
22 | - */ |
|
23 | - protected $_select_button_text; |
|
20 | + /** |
|
21 | + * @var string text to display on the select button itself |
|
22 | + */ |
|
23 | + protected $_select_button_text; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param array $answer_options |
|
27 | - * @param array $input_settings |
|
28 | - */ |
|
29 | - public function __construct($answer_options, $input_settings = array()) |
|
30 | - { |
|
31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
32 | - esc_html__('Select', 'event_espresso')); |
|
33 | - $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
34 | - $this->_set_display_strategy($display_strategy); |
|
35 | - $this->load_iframe_assets($display_strategy); |
|
36 | - $this->_add_validation_strategy( |
|
37 | - new EE_Many_Valued_Validation_Strategy( |
|
38 | - array( |
|
39 | - new EE_Enum_Validation_Strategy( |
|
40 | - isset($input_settings['validation_error_message']) |
|
41 | - ? $input_settings['validation_error_message'] |
|
42 | - : null |
|
43 | - ), |
|
44 | - ) |
|
45 | - ) |
|
46 | - ); |
|
47 | - $this->_multiple_selections = true; |
|
48 | - parent::__construct($answer_options, $input_settings); |
|
49 | - } |
|
25 | + /** |
|
26 | + * @param array $answer_options |
|
27 | + * @param array $input_settings |
|
28 | + */ |
|
29 | + public function __construct($answer_options, $input_settings = array()) |
|
30 | + { |
|
31 | + $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
32 | + esc_html__('Select', 'event_espresso')); |
|
33 | + $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
34 | + $this->_set_display_strategy($display_strategy); |
|
35 | + $this->load_iframe_assets($display_strategy); |
|
36 | + $this->_add_validation_strategy( |
|
37 | + new EE_Many_Valued_Validation_Strategy( |
|
38 | + array( |
|
39 | + new EE_Enum_Validation_Strategy( |
|
40 | + isset($input_settings['validation_error_message']) |
|
41 | + ? $input_settings['validation_error_message'] |
|
42 | + : null |
|
43 | + ), |
|
44 | + ) |
|
45 | + ) |
|
46 | + ); |
|
47 | + $this->_multiple_selections = true; |
|
48 | + parent::__construct($answer_options, $input_settings); |
|
49 | + } |
|
50 | 50 | |
51 | - /* |
|
51 | + /* |
|
52 | 52 | * Returns the text to display in the select button |
53 | 53 | */ |
54 | - public function select_button_text(){ |
|
55 | - return $this->_select_button_text; |
|
56 | - } |
|
54 | + public function select_button_text(){ |
|
55 | + return $this->_select_button_text; |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | * add css and js for iframes |
60 | 60 | */ |
61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
62 | - add_filter( |
|
63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
64 | - array($display_strategy, 'iframe_css') |
|
65 | - ); |
|
66 | - add_filter( |
|
67 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
68 | - array($display_strategy, 'iframe_js') |
|
69 | - ); |
|
70 | - add_filter( |
|
71 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
72 | - array($display_strategy, 'iframe_css') |
|
73 | - ); |
|
74 | - add_filter( |
|
75 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
76 | - array($display_strategy, 'iframe_js') |
|
77 | - ); |
|
78 | - } |
|
61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
62 | + add_filter( |
|
63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
64 | + array($display_strategy, 'iframe_css') |
|
65 | + ); |
|
66 | + add_filter( |
|
67 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
68 | + array($display_strategy, 'iframe_js') |
|
69 | + ); |
|
70 | + add_filter( |
|
71 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
72 | + array($display_strategy, 'iframe_css') |
|
73 | + ); |
|
74 | + add_filter( |
|
75 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
76 | + array($display_strategy, 'iframe_js') |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct($answer_options, $input_settings = array()) |
30 | 30 | { |
31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
31 | + $this->_select_button_text = EEH_Array::is_set($input_settings, 'select_button_text', |
|
32 | 32 | esc_html__('Select', 'event_espresso')); |
33 | 33 | $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
34 | 34 | $this->_set_display_strategy($display_strategy); |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | /* |
52 | 52 | * Returns the text to display in the select button |
53 | 53 | */ |
54 | - public function select_button_text(){ |
|
54 | + public function select_button_text() { |
|
55 | 55 | return $this->_select_button_text; |
56 | 56 | } |
57 | 57 | |
58 | 58 | /* |
59 | 59 | * add css and js for iframes |
60 | 60 | */ |
61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy) { |
|
62 | 62 | add_filter( |
63 | 63 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
64 | 64 | array($display_strategy, 'iframe_css') |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @param string $name |
492 | 492 | * @param string $config_class |
493 | 493 | * @param EE_Config_Base $config_obj |
494 | - * @param array $tests_to_run |
|
494 | + * @param integer[] $tests_to_run |
|
495 | 495 | * @param bool $display_errors |
496 | 496 | * @return bool TRUE on success, FALSE on fail |
497 | 497 | */ |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | |
1795 | 1795 | |
1796 | 1796 | /** |
1797 | - * @return array |
|
1797 | + * @return integer[] |
|
1798 | 1798 | */ |
1799 | 1799 | public function get_critical_pages_array() |
1800 | 1800 | { |
@@ -1808,7 +1808,7 @@ discard block |
||
1808 | 1808 | |
1809 | 1809 | |
1810 | 1810 | /** |
1811 | - * @return array |
|
1811 | + * @return string[] |
|
1812 | 1812 | */ |
1813 | 1813 | public function get_critical_pages_shortcodes_array() |
1814 | 1814 | { |
@@ -3088,7 +3088,7 @@ discard block |
||
3088 | 3088 | * according to max_input_vars |
3089 | 3089 | * |
3090 | 3090 | * @param int $input_count the count of input vars. |
3091 | - * @return array { |
|
3091 | + * @return string { |
|
3092 | 3092 | * An array that represents whether available space and if no available space the error |
3093 | 3093 | * message. |
3094 | 3094 | * @type bool $has_space whether more inputs can be added. |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,2504 +14,2504 @@ discard block |
||
14 | 14 | final class EE_Config |
15 | 15 | { |
16 | 16 | |
17 | - const OPTION_NAME = 'ee_config'; |
|
17 | + const OPTION_NAME = 'ee_config'; |
|
18 | + |
|
19 | + const LOG_NAME = 'ee_config_log'; |
|
20 | + |
|
21 | + const LOG_LENGTH = 100; |
|
22 | + |
|
23 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * instance of the EE_Config object |
|
28 | + * |
|
29 | + * @var EE_Config $_instance |
|
30 | + * @access private |
|
31 | + */ |
|
32 | + private static $_instance; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $_logging_enabled |
|
36 | + */ |
|
37 | + private static $_logging_enabled = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * An StdClass whose property names are addon slugs, |
|
41 | + * and values are their config classes |
|
42 | + * |
|
43 | + * @var StdClass |
|
44 | + */ |
|
45 | + public $addons; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Admin_Config |
|
49 | + */ |
|
50 | + public $admin; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var EE_Core_Config |
|
54 | + */ |
|
55 | + public $core; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var EE_Currency_Config |
|
59 | + */ |
|
60 | + public $currency; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var EE_Organization_Config |
|
64 | + */ |
|
65 | + public $organization; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var EE_Registration_Config |
|
69 | + */ |
|
70 | + public $registration; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var EE_Template_Config |
|
74 | + */ |
|
75 | + public $template_settings; |
|
76 | + |
|
77 | + /** |
|
78 | + * Holds EE environment values. |
|
79 | + * |
|
80 | + * @var EE_Environment_Config |
|
81 | + */ |
|
82 | + public $environment; |
|
83 | + |
|
84 | + /** |
|
85 | + * settings pertaining to Google maps |
|
86 | + * |
|
87 | + * @var EE_Map_Config |
|
88 | + */ |
|
89 | + public $map_settings; |
|
90 | + |
|
91 | + /** |
|
92 | + * settings pertaining to Taxes |
|
93 | + * |
|
94 | + * @var EE_Tax_Config |
|
95 | + */ |
|
96 | + public $tax_settings; |
|
97 | + |
|
98 | + /** |
|
99 | + * @deprecated |
|
100 | + * @var EE_Gateway_Config |
|
101 | + */ |
|
102 | + public $gateway; |
|
103 | + |
|
104 | + /** |
|
105 | + * @var array $_addon_option_names |
|
106 | + * @access private |
|
107 | + */ |
|
108 | + private $_addon_option_names = array(); |
|
109 | + |
|
110 | + /** |
|
111 | + * @var array $_module_route_map |
|
112 | + * @access private |
|
113 | + */ |
|
114 | + private static $_module_route_map = array(); |
|
115 | + |
|
116 | + /** |
|
117 | + * @var array $_module_forward_map |
|
118 | + * @access private |
|
119 | + */ |
|
120 | + private static $_module_forward_map = array(); |
|
121 | + |
|
122 | + /** |
|
123 | + * @var array $_module_view_map |
|
124 | + * @access private |
|
125 | + */ |
|
126 | + private static $_module_view_map = array(); |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @singleton method used to instantiate class object |
|
132 | + * @access public |
|
133 | + * @return EE_Config instance |
|
134 | + */ |
|
135 | + public static function instance() |
|
136 | + { |
|
137 | + // check if class object is instantiated, and instantiated properly |
|
138 | + if ( ! self::$_instance instanceof EE_Config) { |
|
139 | + self::$_instance = new self(); |
|
140 | + } |
|
141 | + return self::$_instance; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Resets the config |
|
148 | + * |
|
149 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
150 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
151 | + * reflect its state in the database |
|
152 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
153 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
154 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
155 | + * site was put into maintenance mode) |
|
156 | + * @return EE_Config |
|
157 | + */ |
|
158 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
159 | + { |
|
160 | + if (self::$_instance instanceof EE_Config) { |
|
161 | + if ($hard_reset) { |
|
162 | + self::$_instance->_addon_option_names = array(); |
|
163 | + self::$_instance->_initialize_config(); |
|
164 | + self::$_instance->update_espresso_config(); |
|
165 | + } |
|
166 | + self::$_instance->update_addon_option_names(); |
|
167 | + } |
|
168 | + self::$_instance = null; |
|
169 | + //we don't need to reset the static properties imo because those should |
|
170 | + //only change when a module is added or removed. Currently we don't |
|
171 | + //support removing a module during a request when it previously existed |
|
172 | + if ($reinstantiate) { |
|
173 | + return self::instance(); |
|
174 | + } else { |
|
175 | + return null; |
|
176 | + } |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * class constructor |
|
183 | + * |
|
184 | + * @access private |
|
185 | + */ |
|
186 | + private function __construct() |
|
187 | + { |
|
188 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
189 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
190 | + // setup empty config classes |
|
191 | + $this->_initialize_config(); |
|
192 | + // load existing EE site settings |
|
193 | + $this->_load_core_config(); |
|
194 | + // confirm everything loaded correctly and set filtered defaults if not |
|
195 | + $this->_verify_config(); |
|
196 | + // register shortcodes and modules |
|
197 | + add_action( |
|
198 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
199 | + array($this, 'register_shortcodes_and_modules'), |
|
200 | + 999 |
|
201 | + ); |
|
202 | + // initialize shortcodes and modules |
|
203 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
204 | + // register widgets |
|
205 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
206 | + // shutdown |
|
207 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
208 | + // construct__end hook |
|
209 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
210 | + // hardcoded hack |
|
211 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * @return boolean |
|
218 | + */ |
|
219 | + public static function logging_enabled() |
|
220 | + { |
|
221 | + return self::$_logging_enabled; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * use to get the current theme if needed from static context |
|
228 | + * |
|
229 | + * @return string current theme set. |
|
230 | + */ |
|
231 | + public static function get_current_theme() |
|
232 | + { |
|
233 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
234 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * _initialize_config |
|
241 | + * |
|
242 | + * @access private |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + private function _initialize_config() |
|
246 | + { |
|
247 | + EE_Config::trim_log(); |
|
248 | + //set defaults |
|
249 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
250 | + $this->addons = new stdClass(); |
|
251 | + // set _module_route_map |
|
252 | + EE_Config::$_module_route_map = array(); |
|
253 | + // set _module_forward_map |
|
254 | + EE_Config::$_module_forward_map = array(); |
|
255 | + // set _module_view_map |
|
256 | + EE_Config::$_module_view_map = array(); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * load core plugin configuration |
|
263 | + * |
|
264 | + * @access private |
|
265 | + * @return void |
|
266 | + */ |
|
267 | + private function _load_core_config() |
|
268 | + { |
|
269 | + // load_core_config__start hook |
|
270 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
271 | + $espresso_config = $this->get_espresso_config(); |
|
272 | + foreach ($espresso_config as $config => $settings) { |
|
273 | + // load_core_config__start hook |
|
274 | + $settings = apply_filters( |
|
275 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
276 | + $settings, |
|
277 | + $config, |
|
278 | + $this |
|
279 | + ); |
|
280 | + if (is_object($settings) && property_exists($this, $config)) { |
|
281 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
282 | + //call configs populate method to ensure any defaults are set for empty values. |
|
283 | + if (method_exists($settings, 'populate')) { |
|
284 | + $this->{$config}->populate(); |
|
285 | + } |
|
286 | + if (method_exists($settings, 'do_hooks')) { |
|
287 | + $this->{$config}->do_hooks(); |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
292 | + $this->update_espresso_config(); |
|
293 | + } |
|
294 | + // load_core_config__end hook |
|
295 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * _verify_config |
|
302 | + * |
|
303 | + * @access protected |
|
304 | + * @return void |
|
305 | + */ |
|
306 | + protected function _verify_config() |
|
307 | + { |
|
308 | + $this->core = $this->core instanceof EE_Core_Config |
|
309 | + ? $this->core |
|
310 | + : new EE_Core_Config(); |
|
311 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
312 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
313 | + ? $this->organization |
|
314 | + : new EE_Organization_Config(); |
|
315 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', |
|
316 | + $this->organization); |
|
317 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
318 | + ? $this->currency |
|
319 | + : new EE_Currency_Config(); |
|
320 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
321 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
322 | + ? $this->registration |
|
323 | + : new EE_Registration_Config(); |
|
324 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', |
|
325 | + $this->registration); |
|
326 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
327 | + ? $this->admin |
|
328 | + : new EE_Admin_Config(); |
|
329 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
330 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
331 | + ? $this->template_settings |
|
332 | + : new EE_Template_Config(); |
|
333 | + $this->template_settings = apply_filters( |
|
334 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
335 | + $this->template_settings |
|
336 | + ); |
|
337 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
338 | + ? $this->map_settings |
|
339 | + : new EE_Map_Config(); |
|
340 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
341 | + $this->map_settings); |
|
342 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
343 | + ? $this->environment |
|
344 | + : new EE_Environment_Config(); |
|
345 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
346 | + $this->environment); |
|
347 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
348 | + ? $this->tax_settings |
|
349 | + : new EE_Tax_Config(); |
|
350 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
351 | + $this->tax_settings); |
|
352 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
353 | + ? $this->gateway |
|
354 | + : new EE_Gateway_Config(); |
|
355 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * get_espresso_config |
|
362 | + * |
|
363 | + * @access public |
|
364 | + * @return array of espresso config stuff |
|
365 | + */ |
|
366 | + public function get_espresso_config() |
|
367 | + { |
|
368 | + // grab espresso configuration |
|
369 | + return apply_filters( |
|
370 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
371 | + get_option(EE_Config::OPTION_NAME, array()) |
|
372 | + ); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * double_check_config_comparison |
|
379 | + * |
|
380 | + * @access public |
|
381 | + * @param string $option |
|
382 | + * @param $old_value |
|
383 | + * @param $value |
|
384 | + */ |
|
385 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
386 | + { |
|
387 | + // make sure we're checking the ee config |
|
388 | + if ($option === EE_Config::OPTION_NAME) { |
|
389 | + // run a loose comparison of the old value against the new value for type and properties, |
|
390 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
391 | + if ($value != $old_value) { |
|
392 | + // if they are NOT the same, then remove the hook, |
|
393 | + // which means the subsequent update results will be based solely on the update query results |
|
394 | + // the reason we do this is because, as stated above, |
|
395 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
396 | + // this happens PRIOR to serialization and any subsequent update. |
|
397 | + // If values are found to match their previous old value, |
|
398 | + // then WP bails before performing any update. |
|
399 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
400 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
401 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
402 | + // MySQL MAY ALSO NOT perform the update because |
|
403 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
404 | + // This results in the query returning an "affected rows" value of ZERO, |
|
405 | + // which gets returned immediately by WP update_option and looks like an error. |
|
406 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
407 | + } |
|
408 | + } |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * update_espresso_config |
|
415 | + * |
|
416 | + * @access public |
|
417 | + */ |
|
418 | + protected function _reset_espresso_addon_config() |
|
419 | + { |
|
420 | + $this->_addon_option_names = array(); |
|
421 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
422 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
423 | + $config_class = get_class($addon_config_obj); |
|
424 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
425 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
426 | + } |
|
427 | + $this->addons->{$addon_name} = null; |
|
428 | + } |
|
429 | + } |
|
430 | + |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * update_espresso_config |
|
435 | + * |
|
436 | + * @access public |
|
437 | + * @param bool $add_success |
|
438 | + * @param bool $add_error |
|
439 | + * @return bool |
|
440 | + */ |
|
441 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
442 | + { |
|
443 | + // don't allow config updates during WP heartbeats |
|
444 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
445 | + return false; |
|
446 | + } |
|
447 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
448 | + //$clone = clone( self::$_instance ); |
|
449 | + //self::$_instance = NULL; |
|
450 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
451 | + $this->_reset_espresso_addon_config(); |
|
452 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
453 | + // but BEFORE the actual update occurs |
|
454 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
455 | + // now update "ee_config" |
|
456 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
457 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
458 | + // if not saved... check if the hook we just added still exists; |
|
459 | + // if it does, it means one of two things: |
|
460 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
461 | + // or... |
|
462 | + // the db update query returned 0 rows affected |
|
463 | + // (probably because the data value was the same from it's perspective) |
|
464 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
465 | + // but just means no update occurred, so don't display an error to the user. |
|
466 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
467 | + // then it means that something truly went wrong |
|
468 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
469 | + // remove our action since we don't want it in the system anymore |
|
470 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
471 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
472 | + //self::$_instance = $clone; |
|
473 | + //unset( $clone ); |
|
474 | + // if config remains the same or was updated successfully |
|
475 | + if ($saved) { |
|
476 | + if ($add_success) { |
|
477 | + EE_Error::add_success( |
|
478 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
479 | + __FILE__, |
|
480 | + __FUNCTION__, |
|
481 | + __LINE__ |
|
482 | + ); |
|
483 | + } |
|
484 | + return true; |
|
485 | + } else { |
|
486 | + if ($add_error) { |
|
487 | + EE_Error::add_error( |
|
488 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
489 | + __FILE__, |
|
490 | + __FUNCTION__, |
|
491 | + __LINE__ |
|
492 | + ); |
|
493 | + } |
|
494 | + return false; |
|
495 | + } |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * _verify_config_params |
|
502 | + * |
|
503 | + * @access private |
|
504 | + * @param string $section |
|
505 | + * @param string $name |
|
506 | + * @param string $config_class |
|
507 | + * @param EE_Config_Base $config_obj |
|
508 | + * @param array $tests_to_run |
|
509 | + * @param bool $display_errors |
|
510 | + * @return bool TRUE on success, FALSE on fail |
|
511 | + */ |
|
512 | + private function _verify_config_params( |
|
513 | + $section = '', |
|
514 | + $name = '', |
|
515 | + $config_class = '', |
|
516 | + $config_obj = null, |
|
517 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
518 | + $display_errors = true |
|
519 | + ) { |
|
520 | + try { |
|
521 | + foreach ($tests_to_run as $test) { |
|
522 | + switch ($test) { |
|
523 | + // TEST #1 : check that section was set |
|
524 | + case 1 : |
|
525 | + if (empty($section)) { |
|
526 | + if ($display_errors) { |
|
527 | + throw new EE_Error( |
|
528 | + sprintf( |
|
529 | + __( |
|
530 | + 'No configuration section has been provided while attempting to save "%s".', |
|
531 | + 'event_espresso' |
|
532 | + ), |
|
533 | + $config_class |
|
534 | + ) |
|
535 | + ); |
|
536 | + } |
|
537 | + return false; |
|
538 | + } |
|
539 | + break; |
|
540 | + // TEST #2 : check that settings section exists |
|
541 | + case 2 : |
|
542 | + if ( ! isset($this->{$section})) { |
|
543 | + if ($display_errors) { |
|
544 | + throw new EE_Error( |
|
545 | + sprintf( |
|
546 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
547 | + $section |
|
548 | + ) |
|
549 | + ); |
|
550 | + } |
|
551 | + return false; |
|
552 | + } |
|
553 | + break; |
|
554 | + // TEST #3 : check that section is the proper format |
|
555 | + case 3 : |
|
556 | + if ( |
|
557 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
558 | + ) { |
|
559 | + if ($display_errors) { |
|
560 | + throw new EE_Error( |
|
561 | + sprintf( |
|
562 | + __( |
|
563 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
564 | + 'event_espresso' |
|
565 | + ), |
|
566 | + $section |
|
567 | + ) |
|
568 | + ); |
|
569 | + } |
|
570 | + return false; |
|
571 | + } |
|
572 | + break; |
|
573 | + // TEST #4 : check that config section name has been set |
|
574 | + case 4 : |
|
575 | + if (empty($name)) { |
|
576 | + if ($display_errors) { |
|
577 | + throw new EE_Error( |
|
578 | + __( |
|
579 | + 'No name has been provided for the specific configuration section.', |
|
580 | + 'event_espresso' |
|
581 | + ) |
|
582 | + ); |
|
583 | + } |
|
584 | + return false; |
|
585 | + } |
|
586 | + break; |
|
587 | + // TEST #5 : check that a config class name has been set |
|
588 | + case 5 : |
|
589 | + if (empty($config_class)) { |
|
590 | + if ($display_errors) { |
|
591 | + throw new EE_Error( |
|
592 | + __( |
|
593 | + 'No class name has been provided for the specific configuration section.', |
|
594 | + 'event_espresso' |
|
595 | + ) |
|
596 | + ); |
|
597 | + } |
|
598 | + return false; |
|
599 | + } |
|
600 | + break; |
|
601 | + // TEST #6 : verify config class is accessible |
|
602 | + case 6 : |
|
603 | + if ( ! class_exists($config_class)) { |
|
604 | + if ($display_errors) { |
|
605 | + throw new EE_Error( |
|
606 | + sprintf( |
|
607 | + __( |
|
608 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
609 | + 'event_espresso' |
|
610 | + ), |
|
611 | + $config_class |
|
612 | + ) |
|
613 | + ); |
|
614 | + } |
|
615 | + return false; |
|
616 | + } |
|
617 | + break; |
|
618 | + // TEST #7 : check that config has even been set |
|
619 | + case 7 : |
|
620 | + if ( ! isset($this->{$section}->{$name})) { |
|
621 | + if ($display_errors) { |
|
622 | + throw new EE_Error( |
|
623 | + sprintf( |
|
624 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
625 | + $section, |
|
626 | + $name |
|
627 | + ) |
|
628 | + ); |
|
629 | + } |
|
630 | + return false; |
|
631 | + } else { |
|
632 | + // and make sure it's not serialized |
|
633 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
634 | + } |
|
635 | + break; |
|
636 | + // TEST #8 : check that config is the requested type |
|
637 | + case 8 : |
|
638 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
639 | + if ($display_errors) { |
|
640 | + throw new EE_Error( |
|
641 | + sprintf( |
|
642 | + __( |
|
643 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
644 | + 'event_espresso' |
|
645 | + ), |
|
646 | + $section, |
|
647 | + $name, |
|
648 | + $config_class |
|
649 | + ) |
|
650 | + ); |
|
651 | + } |
|
652 | + return false; |
|
653 | + } |
|
654 | + break; |
|
655 | + // TEST #9 : verify config object |
|
656 | + case 9 : |
|
657 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
658 | + if ($display_errors) { |
|
659 | + throw new EE_Error( |
|
660 | + sprintf( |
|
661 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
662 | + print_r($config_obj, true) |
|
663 | + ) |
|
664 | + ); |
|
665 | + } |
|
666 | + return false; |
|
667 | + } |
|
668 | + break; |
|
669 | + } |
|
670 | + } |
|
671 | + } catch (EE_Error $e) { |
|
672 | + $e->get_error(); |
|
673 | + } |
|
674 | + // you have successfully run the gauntlet |
|
675 | + return true; |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + |
|
680 | + /** |
|
681 | + * _generate_config_option_name |
|
682 | + * |
|
683 | + * @access protected |
|
684 | + * @param string $section |
|
685 | + * @param string $name |
|
686 | + * @return string |
|
687 | + */ |
|
688 | + private function _generate_config_option_name($section = '', $name = '') |
|
689 | + { |
|
690 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + |
|
695 | + /** |
|
696 | + * _set_config_class |
|
697 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
698 | + * |
|
699 | + * @access private |
|
700 | + * @param string $config_class |
|
701 | + * @param string $name |
|
702 | + * @return string |
|
703 | + */ |
|
704 | + private function _set_config_class($config_class = '', $name = '') |
|
705 | + { |
|
706 | + return ! empty($config_class) |
|
707 | + ? $config_class |
|
708 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * set_config |
|
715 | + * |
|
716 | + * @access protected |
|
717 | + * @param string $section |
|
718 | + * @param string $name |
|
719 | + * @param string $config_class |
|
720 | + * @param EE_Config_Base $config_obj |
|
721 | + * @return EE_Config_Base |
|
722 | + */ |
|
723 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
724 | + { |
|
725 | + // ensure config class is set to something |
|
726 | + $config_class = $this->_set_config_class($config_class, $name); |
|
727 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
728 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
729 | + return null; |
|
730 | + } |
|
731 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
732 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
733 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
734 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
735 | + $this->update_addon_option_names(); |
|
736 | + } |
|
737 | + // verify the incoming config object but suppress errors |
|
738 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
739 | + $config_obj = new $config_class(); |
|
740 | + } |
|
741 | + if (get_option($config_option_name)) { |
|
742 | + EE_Config::log($config_option_name); |
|
743 | + update_option($config_option_name, $config_obj); |
|
744 | + $this->{$section}->{$name} = $config_obj; |
|
745 | + return $this->{$section}->{$name}; |
|
746 | + } else { |
|
747 | + // create a wp-option for this config |
|
748 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
749 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
750 | + return $this->{$section}->{$name}; |
|
751 | + } else { |
|
752 | + EE_Error::add_error( |
|
753 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
754 | + __FILE__, |
|
755 | + __FUNCTION__, |
|
756 | + __LINE__ |
|
757 | + ); |
|
758 | + return null; |
|
759 | + } |
|
760 | + } |
|
761 | + } |
|
762 | + |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * update_config |
|
767 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
768 | + * |
|
769 | + * @access public |
|
770 | + * @param string $section |
|
771 | + * @param string $name |
|
772 | + * @param EE_Config_Base|string $config_obj |
|
773 | + * @param bool $throw_errors |
|
774 | + * @return bool |
|
775 | + */ |
|
776 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
777 | + { |
|
778 | + // don't allow config updates during WP heartbeats |
|
779 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
780 | + return false; |
|
781 | + } |
|
782 | + $config_obj = maybe_unserialize($config_obj); |
|
783 | + // get class name of the incoming object |
|
784 | + $config_class = get_class($config_obj); |
|
785 | + // run tests 1-5 and 9 to verify config |
|
786 | + if ( ! $this->_verify_config_params( |
|
787 | + $section, |
|
788 | + $name, |
|
789 | + $config_class, |
|
790 | + $config_obj, |
|
791 | + array(1, 2, 3, 4, 7, 9) |
|
792 | + ) |
|
793 | + ) { |
|
794 | + return false; |
|
795 | + } |
|
796 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
797 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
798 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
799 | + // save new config to db |
|
800 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
801 | + return true; |
|
802 | + } |
|
803 | + } else { |
|
804 | + // first check if the record already exists |
|
805 | + $existing_config = get_option($config_option_name); |
|
806 | + $config_obj = serialize($config_obj); |
|
807 | + // just return if db record is already up to date (NOT type safe comparison) |
|
808 | + if ($existing_config == $config_obj) { |
|
809 | + $this->{$section}->{$name} = $config_obj; |
|
810 | + return true; |
|
811 | + } else if (update_option($config_option_name, $config_obj)) { |
|
812 | + EE_Config::log($config_option_name); |
|
813 | + // update wp-option for this config class |
|
814 | + $this->{$section}->{$name} = $config_obj; |
|
815 | + return true; |
|
816 | + } elseif ($throw_errors) { |
|
817 | + EE_Error::add_error( |
|
818 | + sprintf( |
|
819 | + __( |
|
820 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
821 | + 'event_espresso' |
|
822 | + ), |
|
823 | + $config_class, |
|
824 | + 'EE_Config->' . $section . '->' . $name |
|
825 | + ), |
|
826 | + __FILE__, |
|
827 | + __FUNCTION__, |
|
828 | + __LINE__ |
|
829 | + ); |
|
830 | + } |
|
831 | + } |
|
832 | + return false; |
|
833 | + } |
|
834 | + |
|
835 | + |
|
836 | + |
|
837 | + /** |
|
838 | + * get_config |
|
839 | + * |
|
840 | + * @access public |
|
841 | + * @param string $section |
|
842 | + * @param string $name |
|
843 | + * @param string $config_class |
|
844 | + * @return mixed EE_Config_Base | NULL |
|
845 | + */ |
|
846 | + public function get_config($section = '', $name = '', $config_class = '') |
|
847 | + { |
|
848 | + // ensure config class is set to something |
|
849 | + $config_class = $this->_set_config_class($config_class, $name); |
|
850 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
851 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
852 | + return null; |
|
853 | + } |
|
854 | + // now test if the requested config object exists, but suppress errors |
|
855 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
856 | + // config already exists, so pass it back |
|
857 | + return $this->{$section}->{$name}; |
|
858 | + } |
|
859 | + // load config option from db if it exists |
|
860 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
861 | + // verify the newly retrieved config object, but suppress errors |
|
862 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
863 | + // config is good, so set it and pass it back |
|
864 | + $this->{$section}->{$name} = $config_obj; |
|
865 | + return $this->{$section}->{$name}; |
|
866 | + } |
|
867 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
868 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
869 | + // verify the newly created config object |
|
870 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
871 | + return $this->{$section}->{$name}; |
|
872 | + } else { |
|
873 | + EE_Error::add_error( |
|
874 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
875 | + __FILE__, |
|
876 | + __FUNCTION__, |
|
877 | + __LINE__ |
|
878 | + ); |
|
879 | + } |
|
880 | + return null; |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + |
|
885 | + /** |
|
886 | + * get_config_option |
|
887 | + * |
|
888 | + * @access public |
|
889 | + * @param string $config_option_name |
|
890 | + * @return mixed EE_Config_Base | FALSE |
|
891 | + */ |
|
892 | + public function get_config_option($config_option_name = '') |
|
893 | + { |
|
894 | + // retrieve the wp-option for this config class. |
|
895 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
896 | + if (empty($config_option)) { |
|
897 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
898 | + } |
|
899 | + return $config_option; |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * log |
|
906 | + * |
|
907 | + * @param string $config_option_name |
|
908 | + */ |
|
909 | + public static function log($config_option_name = '') |
|
910 | + { |
|
911 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
912 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
913 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
914 | + $_request = $_REQUEST; |
|
915 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
916 | + $config_log[(string)microtime(true)] = array( |
|
917 | + 'config_name' => $config_option_name, |
|
918 | + 'request' => $_request, |
|
919 | + ); |
|
920 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
921 | + } |
|
922 | + } |
|
923 | + |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * trim_log |
|
928 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
929 | + */ |
|
930 | + public static function trim_log() |
|
931 | + { |
|
932 | + if ( ! EE_Config::logging_enabled()) { |
|
933 | + return; |
|
934 | + } |
|
935 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
936 | + $log_length = count($config_log); |
|
937 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
938 | + ksort($config_log); |
|
939 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
940 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
941 | + } |
|
942 | + } |
|
943 | + |
|
944 | + |
|
945 | + |
|
946 | + /** |
|
947 | + * get_page_for_posts |
|
948 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
949 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
950 | + * |
|
951 | + * @access public |
|
952 | + * @return string |
|
953 | + */ |
|
954 | + public static function get_page_for_posts() |
|
955 | + { |
|
956 | + $page_for_posts = get_option('page_for_posts'); |
|
957 | + if ( ! $page_for_posts) { |
|
958 | + return 'posts'; |
|
959 | + } |
|
960 | + /** @type WPDB $wpdb */ |
|
961 | + global $wpdb; |
|
962 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
963 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
964 | + } |
|
965 | + |
|
966 | + |
|
967 | + |
|
968 | + /** |
|
969 | + * register_shortcodes_and_modules. |
|
970 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
971 | + * In fact, this is where we give modules a chance to let core know they exist |
|
972 | + * so they can help trigger maintenance mode if it's needed |
|
973 | + * |
|
974 | + * @access public |
|
975 | + * @return void |
|
976 | + */ |
|
977 | + public function register_shortcodes_and_modules() |
|
978 | + { |
|
979 | + // allow shortcodes to register with WP and to set hooks for the rest of the system |
|
980 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
981 | + // allow modules to set hooks for the rest of the system |
|
982 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
983 | + } |
|
984 | + |
|
985 | + |
|
986 | + |
|
987 | + /** |
|
988 | + * initialize_shortcodes_and_modules |
|
989 | + * meaning they can start adding their hooks to get stuff done |
|
990 | + * |
|
991 | + * @access public |
|
992 | + * @return void |
|
993 | + */ |
|
994 | + public function initialize_shortcodes_and_modules() |
|
995 | + { |
|
996 | + // allow shortcodes to set hooks for the rest of the system |
|
997 | + $this->_initialize_shortcodes(); |
|
998 | + // allow modules to set hooks for the rest of the system |
|
999 | + $this->_initialize_modules(); |
|
1000 | + } |
|
1001 | + |
|
1002 | + |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * widgets_init |
|
1006 | + * |
|
1007 | + * @access private |
|
1008 | + * @return void |
|
1009 | + */ |
|
1010 | + public function widgets_init() |
|
1011 | + { |
|
1012 | + //only init widgets on admin pages when not in complete maintenance, and |
|
1013 | + //on frontend when not in any maintenance mode |
|
1014 | + if ( |
|
1015 | + ! EE_Maintenance_Mode::instance()->level() |
|
1016 | + || ( |
|
1017 | + is_admin() |
|
1018 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | + ) |
|
1020 | + ) { |
|
1021 | + // grab list of installed widgets |
|
1022 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | + // filter list of modules to register |
|
1024 | + $widgets_to_register = apply_filters( |
|
1025 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | + $widgets_to_register |
|
1027 | + ); |
|
1028 | + if ( ! empty($widgets_to_register)) { |
|
1029 | + // cycle thru widget folders |
|
1030 | + foreach ($widgets_to_register as $widget_path) { |
|
1031 | + // add to list of installed widget modules |
|
1032 | + EE_Config::register_ee_widget($widget_path); |
|
1033 | + } |
|
1034 | + } |
|
1035 | + // filter list of installed modules |
|
1036 | + EE_Registry::instance()->widgets = apply_filters( |
|
1037 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | + EE_Registry::instance()->widgets |
|
1039 | + ); |
|
1040 | + } |
|
1041 | + } |
|
1042 | + |
|
1043 | + |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * register_ee_widget - makes core aware of this widget |
|
1047 | + * |
|
1048 | + * @access public |
|
1049 | + * @param string $widget_path - full path up to and including widget folder |
|
1050 | + * @return void |
|
1051 | + */ |
|
1052 | + public static function register_ee_widget($widget_path = null) |
|
1053 | + { |
|
1054 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1055 | + $widget_ext = '.widget.php'; |
|
1056 | + // make all separators match |
|
1057 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1058 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1059 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1060 | + // grab and shortcode file name from directory name and break apart at dots |
|
1061 | + $file_name = explode('.', basename($widget_path)); |
|
1062 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1063 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1064 | + // sanitize shortcode directory name |
|
1065 | + $widget = sanitize_key($widget); |
|
1066 | + // now we need to rebuild the shortcode path |
|
1067 | + $widget_path = explode(DS, $widget_path); |
|
1068 | + // remove last segment |
|
1069 | + array_pop($widget_path); |
|
1070 | + // glue it back together |
|
1071 | + $widget_path = implode(DS, $widget_path); |
|
1072 | + } else { |
|
1073 | + // grab and sanitize widget directory name |
|
1074 | + $widget = sanitize_key(basename($widget_path)); |
|
1075 | + } |
|
1076 | + // create classname from widget directory name |
|
1077 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1078 | + // add class prefix |
|
1079 | + $widget_class = 'EEW_' . $widget; |
|
1080 | + // does the widget exist ? |
|
1081 | + if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1082 | + $msg = sprintf( |
|
1083 | + __( |
|
1084 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1085 | + 'event_espresso' |
|
1086 | + ), |
|
1087 | + $widget_class, |
|
1088 | + $widget_path . DS . $widget_class . $widget_ext |
|
1089 | + ); |
|
1090 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1091 | + return; |
|
1092 | + } |
|
1093 | + // load the widget class file |
|
1094 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1095 | + // verify that class exists |
|
1096 | + if ( ! class_exists($widget_class)) { |
|
1097 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1098 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1099 | + return; |
|
1100 | + } |
|
1101 | + register_widget($widget_class); |
|
1102 | + // add to array of registered widgets |
|
1103 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1104 | + } |
|
1105 | + |
|
1106 | + |
|
1107 | + |
|
1108 | + /** |
|
1109 | + * _register_shortcodes |
|
1110 | + * |
|
1111 | + * @access private |
|
1112 | + * @return array |
|
1113 | + */ |
|
1114 | + private function _register_shortcodes() |
|
1115 | + { |
|
1116 | + // grab list of installed shortcodes |
|
1117 | + $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
1118 | + // filter list of modules to register |
|
1119 | + $shortcodes_to_register = apply_filters( |
|
1120 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
1121 | + $shortcodes_to_register |
|
1122 | + ); |
|
1123 | + if ( ! empty($shortcodes_to_register)) { |
|
1124 | + // cycle thru shortcode folders |
|
1125 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
1126 | + // add to list of installed shortcode modules |
|
1127 | + EE_Config::register_shortcode($shortcode_path); |
|
1128 | + } |
|
1129 | + } |
|
1130 | + // filter list of installed modules |
|
1131 | + return apply_filters( |
|
1132 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
1133 | + EE_Registry::instance()->shortcodes |
|
1134 | + ); |
|
1135 | + } |
|
1136 | + |
|
1137 | + |
|
1138 | + |
|
1139 | + /** |
|
1140 | + * register_shortcode - makes core aware of this shortcode |
|
1141 | + * |
|
1142 | + * @access public |
|
1143 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
1144 | + * @return bool |
|
1145 | + */ |
|
1146 | + public static function register_shortcode($shortcode_path = null) |
|
1147 | + { |
|
1148 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1149 | + $shortcode_ext = '.shortcode.php'; |
|
1150 | + // make all separators match |
|
1151 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1152 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1153 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
1154 | + // grab shortcode file name from directory name and break apart at dots |
|
1155 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
1156 | + // take first segment from file name pieces and remove class prefix if it exists |
|
1157 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
1158 | + ? substr($shortcode_file[0], 4) |
|
1159 | + : $shortcode_file[0]; |
|
1160 | + // sanitize shortcode directory name |
|
1161 | + $shortcode = sanitize_key($shortcode); |
|
1162 | + // now we need to rebuild the shortcode path |
|
1163 | + $shortcode_path = explode(DS, $shortcode_path); |
|
1164 | + // remove last segment |
|
1165 | + array_pop($shortcode_path); |
|
1166 | + // glue it back together |
|
1167 | + $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
1168 | + } else { |
|
1169 | + // we need to generate the filename based off of the folder name |
|
1170 | + // grab and sanitize shortcode directory name |
|
1171 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
1172 | + $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
1173 | + } |
|
1174 | + // create classname from shortcode directory or file name |
|
1175 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1176 | + // add class prefix |
|
1177 | + $shortcode_class = 'EES_' . $shortcode; |
|
1178 | + // does the shortcode exist ? |
|
1179 | + if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
1180 | + $msg = sprintf( |
|
1181 | + __( |
|
1182 | + 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
1183 | + 'event_espresso' |
|
1184 | + ), |
|
1185 | + $shortcode_class, |
|
1186 | + $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1187 | + ); |
|
1188 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1189 | + return false; |
|
1190 | + } |
|
1191 | + // load the shortcode class file |
|
1192 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
1193 | + // verify that class exists |
|
1194 | + if ( ! class_exists($shortcode_class)) { |
|
1195 | + $msg = sprintf( |
|
1196 | + __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
1197 | + $shortcode_class |
|
1198 | + ); |
|
1199 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1200 | + return false; |
|
1201 | + } |
|
1202 | + $shortcode = strtoupper($shortcode); |
|
1203 | + // add to array of registered shortcodes |
|
1204 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1205 | + return true; |
|
1206 | + } |
|
1207 | + |
|
1208 | + |
|
1209 | + |
|
1210 | + /** |
|
1211 | + * _register_modules |
|
1212 | + * |
|
1213 | + * @access private |
|
1214 | + * @return array |
|
1215 | + */ |
|
1216 | + private function _register_modules() |
|
1217 | + { |
|
1218 | + // grab list of installed modules |
|
1219 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1220 | + // filter list of modules to register |
|
1221 | + $modules_to_register = apply_filters( |
|
1222 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1223 | + $modules_to_register |
|
1224 | + ); |
|
1225 | + if ( ! empty($modules_to_register)) { |
|
1226 | + // loop through folders |
|
1227 | + foreach ($modules_to_register as $module_path) { |
|
1228 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1229 | + if ( |
|
1230 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1231 | + && $module_path !== EE_MODULES . 'gateways' |
|
1232 | + ) { |
|
1233 | + // add to list of installed modules |
|
1234 | + EE_Config::register_module($module_path); |
|
1235 | + } |
|
1236 | + } |
|
1237 | + } |
|
1238 | + // filter list of installed modules |
|
1239 | + return apply_filters( |
|
1240 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
1241 | + EE_Registry::instance()->modules |
|
1242 | + ); |
|
1243 | + } |
|
1244 | + |
|
1245 | + |
|
1246 | + |
|
1247 | + /** |
|
1248 | + * register_module - makes core aware of this module |
|
1249 | + * |
|
1250 | + * @access public |
|
1251 | + * @param string $module_path - full path up to and including module folder |
|
1252 | + * @return bool |
|
1253 | + */ |
|
1254 | + public static function register_module($module_path = null) |
|
1255 | + { |
|
1256 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1257 | + $module_ext = '.module.php'; |
|
1258 | + // make all separators match |
|
1259 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1260 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
1261 | + if (strpos($module_path, $module_ext) !== false) { |
|
1262 | + // grab and shortcode file name from directory name and break apart at dots |
|
1263 | + $module_file = explode('.', basename($module_path)); |
|
1264 | + // now we need to rebuild the shortcode path |
|
1265 | + $module_path = explode(DS, $module_path); |
|
1266 | + // remove last segment |
|
1267 | + array_pop($module_path); |
|
1268 | + // glue it back together |
|
1269 | + $module_path = implode(DS, $module_path) . DS; |
|
1270 | + // take first segment from file name pieces and sanitize it |
|
1271 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1272 | + // ensure class prefix is added |
|
1273 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1274 | + } else { |
|
1275 | + // we need to generate the filename based off of the folder name |
|
1276 | + // grab and sanitize module name |
|
1277 | + $module = strtolower(basename($module_path)); |
|
1278 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1279 | + // like trailingslashit() |
|
1280 | + $module_path = rtrim($module_path, DS) . DS; |
|
1281 | + // create classname from module directory name |
|
1282 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1283 | + // add class prefix |
|
1284 | + $module_class = 'EED_' . $module; |
|
1285 | + } |
|
1286 | + // does the module exist ? |
|
1287 | + if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1288 | + $msg = sprintf( |
|
1289 | + __( |
|
1290 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1291 | + 'event_espresso' |
|
1292 | + ), |
|
1293 | + $module |
|
1294 | + ); |
|
1295 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1296 | + return false; |
|
1297 | + } |
|
1298 | + // load the module class file |
|
1299 | + require_once($module_path . $module_class . $module_ext); |
|
1300 | + // verify that class exists |
|
1301 | + if ( ! class_exists($module_class)) { |
|
1302 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1303 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1304 | + return false; |
|
1305 | + } |
|
1306 | + // add to array of registered modules |
|
1307 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1308 | + do_action( |
|
1309 | + 'AHEE__EE_Config__register_module__complete', |
|
1310 | + $module_class, |
|
1311 | + EE_Registry::instance()->modules->{$module_class} |
|
1312 | + ); |
|
1313 | + return true; |
|
1314 | + } |
|
1315 | + |
|
1316 | + |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * _initialize_shortcodes |
|
1320 | + * allow shortcodes to set hooks for the rest of the system |
|
1321 | + * |
|
1322 | + * @access private |
|
1323 | + * @return void |
|
1324 | + */ |
|
1325 | + private function _initialize_shortcodes() |
|
1326 | + { |
|
1327 | + // cycle thru shortcode folders |
|
1328 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1329 | + // add class prefix |
|
1330 | + $shortcode_class = 'EES_' . $shortcode; |
|
1331 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1332 | + // which set hooks ? |
|
1333 | + if (is_admin()) { |
|
1334 | + // fire immediately |
|
1335 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1336 | + } else { |
|
1337 | + // delay until other systems are online |
|
1338 | + add_action( |
|
1339 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1340 | + array($shortcode_class, 'set_hooks') |
|
1341 | + ); |
|
1342 | + // convert classname to UPPERCASE and create WP shortcode. |
|
1343 | + $shortcode_tag = strtoupper($shortcode); |
|
1344 | + // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
|
1345 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1346 | + // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
|
1347 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1348 | + } |
|
1349 | + } |
|
1350 | + } |
|
1351 | + } |
|
1352 | + |
|
1353 | + |
|
1354 | + |
|
1355 | + /** |
|
1356 | + * _initialize_modules |
|
1357 | + * allow modules to set hooks for the rest of the system |
|
1358 | + * |
|
1359 | + * @access private |
|
1360 | + * @return void |
|
1361 | + */ |
|
1362 | + private function _initialize_modules() |
|
1363 | + { |
|
1364 | + // cycle thru shortcode folders |
|
1365 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1366 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1367 | + // which set hooks ? |
|
1368 | + if (is_admin()) { |
|
1369 | + // fire immediately |
|
1370 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1371 | + } else { |
|
1372 | + // delay until other systems are online |
|
1373 | + add_action( |
|
1374 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1375 | + array($module_class, 'set_hooks') |
|
1376 | + ); |
|
1377 | + } |
|
1378 | + } |
|
1379 | + } |
|
1380 | + |
|
1381 | + |
|
1382 | + |
|
1383 | + /** |
|
1384 | + * register_route - adds module method routes to route_map |
|
1385 | + * |
|
1386 | + * @access public |
|
1387 | + * @param string $route - "pretty" public alias for module method |
|
1388 | + * @param string $module - module name (classname without EED_ prefix) |
|
1389 | + * @param string $method_name - the actual module method to be routed to |
|
1390 | + * @param string $key - url param key indicating a route is being called |
|
1391 | + * @return bool |
|
1392 | + */ |
|
1393 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1394 | + { |
|
1395 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1396 | + $module = str_replace('EED_', '', $module); |
|
1397 | + $module_class = 'EED_' . $module; |
|
1398 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1399 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1400 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1401 | + return false; |
|
1402 | + } |
|
1403 | + if (empty($route)) { |
|
1404 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1405 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1406 | + return false; |
|
1407 | + } |
|
1408 | + if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1409 | + $msg = sprintf( |
|
1410 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1411 | + $route |
|
1412 | + ); |
|
1413 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1414 | + return false; |
|
1415 | + } |
|
1416 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1417 | + return true; |
|
1418 | + } |
|
1419 | + |
|
1420 | + |
|
1421 | + |
|
1422 | + /** |
|
1423 | + * get_route - get module method route |
|
1424 | + * |
|
1425 | + * @access public |
|
1426 | + * @param string $route - "pretty" public alias for module method |
|
1427 | + * @param string $key - url param key indicating a route is being called |
|
1428 | + * @return string |
|
1429 | + */ |
|
1430 | + public static function get_route($route = null, $key = 'ee') |
|
1431 | + { |
|
1432 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1433 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1434 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1435 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1436 | + } |
|
1437 | + return null; |
|
1438 | + } |
|
1439 | + |
|
1440 | + |
|
1441 | + |
|
1442 | + /** |
|
1443 | + * get_routes - get ALL module method routes |
|
1444 | + * |
|
1445 | + * @access public |
|
1446 | + * @return array |
|
1447 | + */ |
|
1448 | + public static function get_routes() |
|
1449 | + { |
|
1450 | + return EE_Config::$_module_route_map; |
|
1451 | + } |
|
1452 | + |
|
1453 | + |
|
1454 | + |
|
1455 | + /** |
|
1456 | + * register_forward - allows modules to forward request to another module for further processing |
|
1457 | + * |
|
1458 | + * @access public |
|
1459 | + * @param string $route - "pretty" public alias for module method |
|
1460 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1461 | + * class, allows different forwards to be served based on status |
|
1462 | + * @param array|string $forward - function name or array( class, method ) |
|
1463 | + * @param string $key - url param key indicating a route is being called |
|
1464 | + * @return bool |
|
1465 | + */ |
|
1466 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1467 | + { |
|
1468 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1469 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1470 | + $msg = sprintf( |
|
1471 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1472 | + $route |
|
1473 | + ); |
|
1474 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1475 | + return false; |
|
1476 | + } |
|
1477 | + if (empty($forward)) { |
|
1478 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1479 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1480 | + return false; |
|
1481 | + } |
|
1482 | + if (is_array($forward)) { |
|
1483 | + if ( ! isset($forward[1])) { |
|
1484 | + $msg = sprintf( |
|
1485 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1486 | + $route |
|
1487 | + ); |
|
1488 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1489 | + return false; |
|
1490 | + } |
|
1491 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1492 | + $msg = sprintf( |
|
1493 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1494 | + $forward[1], |
|
1495 | + $route |
|
1496 | + ); |
|
1497 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1498 | + return false; |
|
1499 | + } |
|
1500 | + } else if ( ! function_exists($forward)) { |
|
1501 | + $msg = sprintf( |
|
1502 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1503 | + $forward, |
|
1504 | + $route |
|
1505 | + ); |
|
1506 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1507 | + return false; |
|
1508 | + } |
|
1509 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1510 | + return true; |
|
1511 | + } |
|
1512 | + |
|
1513 | + |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * get_forward - get forwarding route |
|
1517 | + * |
|
1518 | + * @access public |
|
1519 | + * @param string $route - "pretty" public alias for module method |
|
1520 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1521 | + * allows different forwards to be served based on status |
|
1522 | + * @param string $key - url param key indicating a route is being called |
|
1523 | + * @return string |
|
1524 | + */ |
|
1525 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1526 | + { |
|
1527 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1528 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1529 | + return apply_filters( |
|
1530 | + 'FHEE__EE_Config__get_forward', |
|
1531 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1532 | + $route, |
|
1533 | + $status |
|
1534 | + ); |
|
1535 | + } |
|
1536 | + return null; |
|
1537 | + } |
|
1538 | + |
|
1539 | + |
|
1540 | + |
|
1541 | + /** |
|
1542 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
1543 | + * results |
|
1544 | + * |
|
1545 | + * @access public |
|
1546 | + * @param string $route - "pretty" public alias for module method |
|
1547 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1548 | + * allows different views to be served based on status |
|
1549 | + * @param string $view |
|
1550 | + * @param string $key - url param key indicating a route is being called |
|
1551 | + * @return bool |
|
1552 | + */ |
|
1553 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1554 | + { |
|
1555 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1556 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1557 | + $msg = sprintf( |
|
1558 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1559 | + $route |
|
1560 | + ); |
|
1561 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1562 | + return false; |
|
1563 | + } |
|
1564 | + if ( ! is_readable($view)) { |
|
1565 | + $msg = sprintf( |
|
1566 | + __( |
|
1567 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
1568 | + 'event_espresso' |
|
1569 | + ), |
|
1570 | + $view |
|
1571 | + ); |
|
1572 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1573 | + return false; |
|
1574 | + } |
|
1575 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1576 | + return true; |
|
1577 | + } |
|
1578 | + |
|
1579 | + |
|
1580 | + |
|
1581 | + /** |
|
1582 | + * get_view - get view for route and status |
|
1583 | + * |
|
1584 | + * @access public |
|
1585 | + * @param string $route - "pretty" public alias for module method |
|
1586 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1587 | + * allows different views to be served based on status |
|
1588 | + * @param string $key - url param key indicating a route is being called |
|
1589 | + * @return string |
|
1590 | + */ |
|
1591 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1592 | + { |
|
1593 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1594 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1595 | + return apply_filters( |
|
1596 | + 'FHEE__EE_Config__get_view', |
|
1597 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1598 | + $route, |
|
1599 | + $status |
|
1600 | + ); |
|
1601 | + } |
|
1602 | + return null; |
|
1603 | + } |
|
1604 | + |
|
1605 | + |
|
1606 | + |
|
1607 | + public function update_addon_option_names() |
|
1608 | + { |
|
1609 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1610 | + } |
|
1611 | + |
|
1612 | + |
|
1613 | + |
|
1614 | + public function shutdown() |
|
1615 | + { |
|
1616 | + $this->update_addon_option_names(); |
|
1617 | + } |
|
18 | 1618 | |
19 | - const LOG_NAME = 'ee_config_log'; |
|
20 | 1619 | |
21 | - const LOG_LENGTH = 100; |
|
22 | - |
|
23 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * instance of the EE_Config object |
|
28 | - * |
|
29 | - * @var EE_Config $_instance |
|
30 | - * @access private |
|
31 | - */ |
|
32 | - private static $_instance; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $_logging_enabled |
|
36 | - */ |
|
37 | - private static $_logging_enabled = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * An StdClass whose property names are addon slugs, |
|
41 | - * and values are their config classes |
|
42 | - * |
|
43 | - * @var StdClass |
|
44 | - */ |
|
45 | - public $addons; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Admin_Config |
|
49 | - */ |
|
50 | - public $admin; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var EE_Core_Config |
|
54 | - */ |
|
55 | - public $core; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var EE_Currency_Config |
|
59 | - */ |
|
60 | - public $currency; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var EE_Organization_Config |
|
64 | - */ |
|
65 | - public $organization; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var EE_Registration_Config |
|
69 | - */ |
|
70 | - public $registration; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var EE_Template_Config |
|
74 | - */ |
|
75 | - public $template_settings; |
|
76 | - |
|
77 | - /** |
|
78 | - * Holds EE environment values. |
|
79 | - * |
|
80 | - * @var EE_Environment_Config |
|
81 | - */ |
|
82 | - public $environment; |
|
83 | - |
|
84 | - /** |
|
85 | - * settings pertaining to Google maps |
|
86 | - * |
|
87 | - * @var EE_Map_Config |
|
88 | - */ |
|
89 | - public $map_settings; |
|
90 | - |
|
91 | - /** |
|
92 | - * settings pertaining to Taxes |
|
93 | - * |
|
94 | - * @var EE_Tax_Config |
|
95 | - */ |
|
96 | - public $tax_settings; |
|
97 | - |
|
98 | - /** |
|
99 | - * @deprecated |
|
100 | - * @var EE_Gateway_Config |
|
101 | - */ |
|
102 | - public $gateway; |
|
103 | - |
|
104 | - /** |
|
105 | - * @var array $_addon_option_names |
|
106 | - * @access private |
|
107 | - */ |
|
108 | - private $_addon_option_names = array(); |
|
109 | - |
|
110 | - /** |
|
111 | - * @var array $_module_route_map |
|
112 | - * @access private |
|
113 | - */ |
|
114 | - private static $_module_route_map = array(); |
|
115 | - |
|
116 | - /** |
|
117 | - * @var array $_module_forward_map |
|
118 | - * @access private |
|
119 | - */ |
|
120 | - private static $_module_forward_map = array(); |
|
121 | - |
|
122 | - /** |
|
123 | - * @var array $_module_view_map |
|
124 | - * @access private |
|
125 | - */ |
|
126 | - private static $_module_view_map = array(); |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @singleton method used to instantiate class object |
|
132 | - * @access public |
|
133 | - * @return EE_Config instance |
|
134 | - */ |
|
135 | - public static function instance() |
|
136 | - { |
|
137 | - // check if class object is instantiated, and instantiated properly |
|
138 | - if ( ! self::$_instance instanceof EE_Config) { |
|
139 | - self::$_instance = new self(); |
|
140 | - } |
|
141 | - return self::$_instance; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Resets the config |
|
148 | - * |
|
149 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
150 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
151 | - * reflect its state in the database |
|
152 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
153 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
154 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
155 | - * site was put into maintenance mode) |
|
156 | - * @return EE_Config |
|
157 | - */ |
|
158 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
159 | - { |
|
160 | - if (self::$_instance instanceof EE_Config) { |
|
161 | - if ($hard_reset) { |
|
162 | - self::$_instance->_addon_option_names = array(); |
|
163 | - self::$_instance->_initialize_config(); |
|
164 | - self::$_instance->update_espresso_config(); |
|
165 | - } |
|
166 | - self::$_instance->update_addon_option_names(); |
|
167 | - } |
|
168 | - self::$_instance = null; |
|
169 | - //we don't need to reset the static properties imo because those should |
|
170 | - //only change when a module is added or removed. Currently we don't |
|
171 | - //support removing a module during a request when it previously existed |
|
172 | - if ($reinstantiate) { |
|
173 | - return self::instance(); |
|
174 | - } else { |
|
175 | - return null; |
|
176 | - } |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * class constructor |
|
183 | - * |
|
184 | - * @access private |
|
185 | - */ |
|
186 | - private function __construct() |
|
187 | - { |
|
188 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
189 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
190 | - // setup empty config classes |
|
191 | - $this->_initialize_config(); |
|
192 | - // load existing EE site settings |
|
193 | - $this->_load_core_config(); |
|
194 | - // confirm everything loaded correctly and set filtered defaults if not |
|
195 | - $this->_verify_config(); |
|
196 | - // register shortcodes and modules |
|
197 | - add_action( |
|
198 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
199 | - array($this, 'register_shortcodes_and_modules'), |
|
200 | - 999 |
|
201 | - ); |
|
202 | - // initialize shortcodes and modules |
|
203 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
204 | - // register widgets |
|
205 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
206 | - // shutdown |
|
207 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
208 | - // construct__end hook |
|
209 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
210 | - // hardcoded hack |
|
211 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * @return boolean |
|
218 | - */ |
|
219 | - public static function logging_enabled() |
|
220 | - { |
|
221 | - return self::$_logging_enabled; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * use to get the current theme if needed from static context |
|
228 | - * |
|
229 | - * @return string current theme set. |
|
230 | - */ |
|
231 | - public static function get_current_theme() |
|
232 | - { |
|
233 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
234 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * _initialize_config |
|
241 | - * |
|
242 | - * @access private |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - private function _initialize_config() |
|
246 | - { |
|
247 | - EE_Config::trim_log(); |
|
248 | - //set defaults |
|
249 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
250 | - $this->addons = new stdClass(); |
|
251 | - // set _module_route_map |
|
252 | - EE_Config::$_module_route_map = array(); |
|
253 | - // set _module_forward_map |
|
254 | - EE_Config::$_module_forward_map = array(); |
|
255 | - // set _module_view_map |
|
256 | - EE_Config::$_module_view_map = array(); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * load core plugin configuration |
|
263 | - * |
|
264 | - * @access private |
|
265 | - * @return void |
|
266 | - */ |
|
267 | - private function _load_core_config() |
|
268 | - { |
|
269 | - // load_core_config__start hook |
|
270 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
271 | - $espresso_config = $this->get_espresso_config(); |
|
272 | - foreach ($espresso_config as $config => $settings) { |
|
273 | - // load_core_config__start hook |
|
274 | - $settings = apply_filters( |
|
275 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
276 | - $settings, |
|
277 | - $config, |
|
278 | - $this |
|
279 | - ); |
|
280 | - if (is_object($settings) && property_exists($this, $config)) { |
|
281 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
282 | - //call configs populate method to ensure any defaults are set for empty values. |
|
283 | - if (method_exists($settings, 'populate')) { |
|
284 | - $this->{$config}->populate(); |
|
285 | - } |
|
286 | - if (method_exists($settings, 'do_hooks')) { |
|
287 | - $this->{$config}->do_hooks(); |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
292 | - $this->update_espresso_config(); |
|
293 | - } |
|
294 | - // load_core_config__end hook |
|
295 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * _verify_config |
|
302 | - * |
|
303 | - * @access protected |
|
304 | - * @return void |
|
305 | - */ |
|
306 | - protected function _verify_config() |
|
307 | - { |
|
308 | - $this->core = $this->core instanceof EE_Core_Config |
|
309 | - ? $this->core |
|
310 | - : new EE_Core_Config(); |
|
311 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
312 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
313 | - ? $this->organization |
|
314 | - : new EE_Organization_Config(); |
|
315 | - $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', |
|
316 | - $this->organization); |
|
317 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
318 | - ? $this->currency |
|
319 | - : new EE_Currency_Config(); |
|
320 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
321 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
322 | - ? $this->registration |
|
323 | - : new EE_Registration_Config(); |
|
324 | - $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', |
|
325 | - $this->registration); |
|
326 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
327 | - ? $this->admin |
|
328 | - : new EE_Admin_Config(); |
|
329 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
330 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
331 | - ? $this->template_settings |
|
332 | - : new EE_Template_Config(); |
|
333 | - $this->template_settings = apply_filters( |
|
334 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
335 | - $this->template_settings |
|
336 | - ); |
|
337 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
338 | - ? $this->map_settings |
|
339 | - : new EE_Map_Config(); |
|
340 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
341 | - $this->map_settings); |
|
342 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
343 | - ? $this->environment |
|
344 | - : new EE_Environment_Config(); |
|
345 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
346 | - $this->environment); |
|
347 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
348 | - ? $this->tax_settings |
|
349 | - : new EE_Tax_Config(); |
|
350 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
351 | - $this->tax_settings); |
|
352 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
353 | - ? $this->gateway |
|
354 | - : new EE_Gateway_Config(); |
|
355 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * get_espresso_config |
|
362 | - * |
|
363 | - * @access public |
|
364 | - * @return array of espresso config stuff |
|
365 | - */ |
|
366 | - public function get_espresso_config() |
|
367 | - { |
|
368 | - // grab espresso configuration |
|
369 | - return apply_filters( |
|
370 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
371 | - get_option(EE_Config::OPTION_NAME, array()) |
|
372 | - ); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * double_check_config_comparison |
|
379 | - * |
|
380 | - * @access public |
|
381 | - * @param string $option |
|
382 | - * @param $old_value |
|
383 | - * @param $value |
|
384 | - */ |
|
385 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
386 | - { |
|
387 | - // make sure we're checking the ee config |
|
388 | - if ($option === EE_Config::OPTION_NAME) { |
|
389 | - // run a loose comparison of the old value against the new value for type and properties, |
|
390 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
391 | - if ($value != $old_value) { |
|
392 | - // if they are NOT the same, then remove the hook, |
|
393 | - // which means the subsequent update results will be based solely on the update query results |
|
394 | - // the reason we do this is because, as stated above, |
|
395 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
396 | - // this happens PRIOR to serialization and any subsequent update. |
|
397 | - // If values are found to match their previous old value, |
|
398 | - // then WP bails before performing any update. |
|
399 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
400 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
401 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
402 | - // MySQL MAY ALSO NOT perform the update because |
|
403 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
404 | - // This results in the query returning an "affected rows" value of ZERO, |
|
405 | - // which gets returned immediately by WP update_option and looks like an error. |
|
406 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
407 | - } |
|
408 | - } |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * update_espresso_config |
|
415 | - * |
|
416 | - * @access public |
|
417 | - */ |
|
418 | - protected function _reset_espresso_addon_config() |
|
419 | - { |
|
420 | - $this->_addon_option_names = array(); |
|
421 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
422 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
423 | - $config_class = get_class($addon_config_obj); |
|
424 | - if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
425 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
426 | - } |
|
427 | - $this->addons->{$addon_name} = null; |
|
428 | - } |
|
429 | - } |
|
430 | - |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * update_espresso_config |
|
435 | - * |
|
436 | - * @access public |
|
437 | - * @param bool $add_success |
|
438 | - * @param bool $add_error |
|
439 | - * @return bool |
|
440 | - */ |
|
441 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
442 | - { |
|
443 | - // don't allow config updates during WP heartbeats |
|
444 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
445 | - return false; |
|
446 | - } |
|
447 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
448 | - //$clone = clone( self::$_instance ); |
|
449 | - //self::$_instance = NULL; |
|
450 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
451 | - $this->_reset_espresso_addon_config(); |
|
452 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
453 | - // but BEFORE the actual update occurs |
|
454 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
455 | - // now update "ee_config" |
|
456 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
457 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
458 | - // if not saved... check if the hook we just added still exists; |
|
459 | - // if it does, it means one of two things: |
|
460 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
461 | - // or... |
|
462 | - // the db update query returned 0 rows affected |
|
463 | - // (probably because the data value was the same from it's perspective) |
|
464 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
465 | - // but just means no update occurred, so don't display an error to the user. |
|
466 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
467 | - // then it means that something truly went wrong |
|
468 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
469 | - // remove our action since we don't want it in the system anymore |
|
470 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
471 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
472 | - //self::$_instance = $clone; |
|
473 | - //unset( $clone ); |
|
474 | - // if config remains the same or was updated successfully |
|
475 | - if ($saved) { |
|
476 | - if ($add_success) { |
|
477 | - EE_Error::add_success( |
|
478 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
479 | - __FILE__, |
|
480 | - __FUNCTION__, |
|
481 | - __LINE__ |
|
482 | - ); |
|
483 | - } |
|
484 | - return true; |
|
485 | - } else { |
|
486 | - if ($add_error) { |
|
487 | - EE_Error::add_error( |
|
488 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
489 | - __FILE__, |
|
490 | - __FUNCTION__, |
|
491 | - __LINE__ |
|
492 | - ); |
|
493 | - } |
|
494 | - return false; |
|
495 | - } |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * _verify_config_params |
|
502 | - * |
|
503 | - * @access private |
|
504 | - * @param string $section |
|
505 | - * @param string $name |
|
506 | - * @param string $config_class |
|
507 | - * @param EE_Config_Base $config_obj |
|
508 | - * @param array $tests_to_run |
|
509 | - * @param bool $display_errors |
|
510 | - * @return bool TRUE on success, FALSE on fail |
|
511 | - */ |
|
512 | - private function _verify_config_params( |
|
513 | - $section = '', |
|
514 | - $name = '', |
|
515 | - $config_class = '', |
|
516 | - $config_obj = null, |
|
517 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
518 | - $display_errors = true |
|
519 | - ) { |
|
520 | - try { |
|
521 | - foreach ($tests_to_run as $test) { |
|
522 | - switch ($test) { |
|
523 | - // TEST #1 : check that section was set |
|
524 | - case 1 : |
|
525 | - if (empty($section)) { |
|
526 | - if ($display_errors) { |
|
527 | - throw new EE_Error( |
|
528 | - sprintf( |
|
529 | - __( |
|
530 | - 'No configuration section has been provided while attempting to save "%s".', |
|
531 | - 'event_espresso' |
|
532 | - ), |
|
533 | - $config_class |
|
534 | - ) |
|
535 | - ); |
|
536 | - } |
|
537 | - return false; |
|
538 | - } |
|
539 | - break; |
|
540 | - // TEST #2 : check that settings section exists |
|
541 | - case 2 : |
|
542 | - if ( ! isset($this->{$section})) { |
|
543 | - if ($display_errors) { |
|
544 | - throw new EE_Error( |
|
545 | - sprintf( |
|
546 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
547 | - $section |
|
548 | - ) |
|
549 | - ); |
|
550 | - } |
|
551 | - return false; |
|
552 | - } |
|
553 | - break; |
|
554 | - // TEST #3 : check that section is the proper format |
|
555 | - case 3 : |
|
556 | - if ( |
|
557 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
558 | - ) { |
|
559 | - if ($display_errors) { |
|
560 | - throw new EE_Error( |
|
561 | - sprintf( |
|
562 | - __( |
|
563 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
564 | - 'event_espresso' |
|
565 | - ), |
|
566 | - $section |
|
567 | - ) |
|
568 | - ); |
|
569 | - } |
|
570 | - return false; |
|
571 | - } |
|
572 | - break; |
|
573 | - // TEST #4 : check that config section name has been set |
|
574 | - case 4 : |
|
575 | - if (empty($name)) { |
|
576 | - if ($display_errors) { |
|
577 | - throw new EE_Error( |
|
578 | - __( |
|
579 | - 'No name has been provided for the specific configuration section.', |
|
580 | - 'event_espresso' |
|
581 | - ) |
|
582 | - ); |
|
583 | - } |
|
584 | - return false; |
|
585 | - } |
|
586 | - break; |
|
587 | - // TEST #5 : check that a config class name has been set |
|
588 | - case 5 : |
|
589 | - if (empty($config_class)) { |
|
590 | - if ($display_errors) { |
|
591 | - throw new EE_Error( |
|
592 | - __( |
|
593 | - 'No class name has been provided for the specific configuration section.', |
|
594 | - 'event_espresso' |
|
595 | - ) |
|
596 | - ); |
|
597 | - } |
|
598 | - return false; |
|
599 | - } |
|
600 | - break; |
|
601 | - // TEST #6 : verify config class is accessible |
|
602 | - case 6 : |
|
603 | - if ( ! class_exists($config_class)) { |
|
604 | - if ($display_errors) { |
|
605 | - throw new EE_Error( |
|
606 | - sprintf( |
|
607 | - __( |
|
608 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
609 | - 'event_espresso' |
|
610 | - ), |
|
611 | - $config_class |
|
612 | - ) |
|
613 | - ); |
|
614 | - } |
|
615 | - return false; |
|
616 | - } |
|
617 | - break; |
|
618 | - // TEST #7 : check that config has even been set |
|
619 | - case 7 : |
|
620 | - if ( ! isset($this->{$section}->{$name})) { |
|
621 | - if ($display_errors) { |
|
622 | - throw new EE_Error( |
|
623 | - sprintf( |
|
624 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
625 | - $section, |
|
626 | - $name |
|
627 | - ) |
|
628 | - ); |
|
629 | - } |
|
630 | - return false; |
|
631 | - } else { |
|
632 | - // and make sure it's not serialized |
|
633 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
634 | - } |
|
635 | - break; |
|
636 | - // TEST #8 : check that config is the requested type |
|
637 | - case 8 : |
|
638 | - if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
639 | - if ($display_errors) { |
|
640 | - throw new EE_Error( |
|
641 | - sprintf( |
|
642 | - __( |
|
643 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
644 | - 'event_espresso' |
|
645 | - ), |
|
646 | - $section, |
|
647 | - $name, |
|
648 | - $config_class |
|
649 | - ) |
|
650 | - ); |
|
651 | - } |
|
652 | - return false; |
|
653 | - } |
|
654 | - break; |
|
655 | - // TEST #9 : verify config object |
|
656 | - case 9 : |
|
657 | - if ( ! $config_obj instanceof EE_Config_Base) { |
|
658 | - if ($display_errors) { |
|
659 | - throw new EE_Error( |
|
660 | - sprintf( |
|
661 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
662 | - print_r($config_obj, true) |
|
663 | - ) |
|
664 | - ); |
|
665 | - } |
|
666 | - return false; |
|
667 | - } |
|
668 | - break; |
|
669 | - } |
|
670 | - } |
|
671 | - } catch (EE_Error $e) { |
|
672 | - $e->get_error(); |
|
673 | - } |
|
674 | - // you have successfully run the gauntlet |
|
675 | - return true; |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - |
|
680 | - /** |
|
681 | - * _generate_config_option_name |
|
682 | - * |
|
683 | - * @access protected |
|
684 | - * @param string $section |
|
685 | - * @param string $name |
|
686 | - * @return string |
|
687 | - */ |
|
688 | - private function _generate_config_option_name($section = '', $name = '') |
|
689 | - { |
|
690 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - |
|
695 | - /** |
|
696 | - * _set_config_class |
|
697 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
698 | - * |
|
699 | - * @access private |
|
700 | - * @param string $config_class |
|
701 | - * @param string $name |
|
702 | - * @return string |
|
703 | - */ |
|
704 | - private function _set_config_class($config_class = '', $name = '') |
|
705 | - { |
|
706 | - return ! empty($config_class) |
|
707 | - ? $config_class |
|
708 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * set_config |
|
715 | - * |
|
716 | - * @access protected |
|
717 | - * @param string $section |
|
718 | - * @param string $name |
|
719 | - * @param string $config_class |
|
720 | - * @param EE_Config_Base $config_obj |
|
721 | - * @return EE_Config_Base |
|
722 | - */ |
|
723 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
724 | - { |
|
725 | - // ensure config class is set to something |
|
726 | - $config_class = $this->_set_config_class($config_class, $name); |
|
727 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
728 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
729 | - return null; |
|
730 | - } |
|
731 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
732 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
733 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
734 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
735 | - $this->update_addon_option_names(); |
|
736 | - } |
|
737 | - // verify the incoming config object but suppress errors |
|
738 | - if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
739 | - $config_obj = new $config_class(); |
|
740 | - } |
|
741 | - if (get_option($config_option_name)) { |
|
742 | - EE_Config::log($config_option_name); |
|
743 | - update_option($config_option_name, $config_obj); |
|
744 | - $this->{$section}->{$name} = $config_obj; |
|
745 | - return $this->{$section}->{$name}; |
|
746 | - } else { |
|
747 | - // create a wp-option for this config |
|
748 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
749 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
750 | - return $this->{$section}->{$name}; |
|
751 | - } else { |
|
752 | - EE_Error::add_error( |
|
753 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
754 | - __FILE__, |
|
755 | - __FUNCTION__, |
|
756 | - __LINE__ |
|
757 | - ); |
|
758 | - return null; |
|
759 | - } |
|
760 | - } |
|
761 | - } |
|
762 | - |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * update_config |
|
767 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
768 | - * |
|
769 | - * @access public |
|
770 | - * @param string $section |
|
771 | - * @param string $name |
|
772 | - * @param EE_Config_Base|string $config_obj |
|
773 | - * @param bool $throw_errors |
|
774 | - * @return bool |
|
775 | - */ |
|
776 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
777 | - { |
|
778 | - // don't allow config updates during WP heartbeats |
|
779 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
780 | - return false; |
|
781 | - } |
|
782 | - $config_obj = maybe_unserialize($config_obj); |
|
783 | - // get class name of the incoming object |
|
784 | - $config_class = get_class($config_obj); |
|
785 | - // run tests 1-5 and 9 to verify config |
|
786 | - if ( ! $this->_verify_config_params( |
|
787 | - $section, |
|
788 | - $name, |
|
789 | - $config_class, |
|
790 | - $config_obj, |
|
791 | - array(1, 2, 3, 4, 7, 9) |
|
792 | - ) |
|
793 | - ) { |
|
794 | - return false; |
|
795 | - } |
|
796 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
797 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
798 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
799 | - // save new config to db |
|
800 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
801 | - return true; |
|
802 | - } |
|
803 | - } else { |
|
804 | - // first check if the record already exists |
|
805 | - $existing_config = get_option($config_option_name); |
|
806 | - $config_obj = serialize($config_obj); |
|
807 | - // just return if db record is already up to date (NOT type safe comparison) |
|
808 | - if ($existing_config == $config_obj) { |
|
809 | - $this->{$section}->{$name} = $config_obj; |
|
810 | - return true; |
|
811 | - } else if (update_option($config_option_name, $config_obj)) { |
|
812 | - EE_Config::log($config_option_name); |
|
813 | - // update wp-option for this config class |
|
814 | - $this->{$section}->{$name} = $config_obj; |
|
815 | - return true; |
|
816 | - } elseif ($throw_errors) { |
|
817 | - EE_Error::add_error( |
|
818 | - sprintf( |
|
819 | - __( |
|
820 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
821 | - 'event_espresso' |
|
822 | - ), |
|
823 | - $config_class, |
|
824 | - 'EE_Config->' . $section . '->' . $name |
|
825 | - ), |
|
826 | - __FILE__, |
|
827 | - __FUNCTION__, |
|
828 | - __LINE__ |
|
829 | - ); |
|
830 | - } |
|
831 | - } |
|
832 | - return false; |
|
833 | - } |
|
834 | - |
|
835 | - |
|
836 | - |
|
837 | - /** |
|
838 | - * get_config |
|
839 | - * |
|
840 | - * @access public |
|
841 | - * @param string $section |
|
842 | - * @param string $name |
|
843 | - * @param string $config_class |
|
844 | - * @return mixed EE_Config_Base | NULL |
|
845 | - */ |
|
846 | - public function get_config($section = '', $name = '', $config_class = '') |
|
847 | - { |
|
848 | - // ensure config class is set to something |
|
849 | - $config_class = $this->_set_config_class($config_class, $name); |
|
850 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
851 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
852 | - return null; |
|
853 | - } |
|
854 | - // now test if the requested config object exists, but suppress errors |
|
855 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
856 | - // config already exists, so pass it back |
|
857 | - return $this->{$section}->{$name}; |
|
858 | - } |
|
859 | - // load config option from db if it exists |
|
860 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
861 | - // verify the newly retrieved config object, but suppress errors |
|
862 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
863 | - // config is good, so set it and pass it back |
|
864 | - $this->{$section}->{$name} = $config_obj; |
|
865 | - return $this->{$section}->{$name}; |
|
866 | - } |
|
867 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
868 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
869 | - // verify the newly created config object |
|
870 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
871 | - return $this->{$section}->{$name}; |
|
872 | - } else { |
|
873 | - EE_Error::add_error( |
|
874 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
875 | - __FILE__, |
|
876 | - __FUNCTION__, |
|
877 | - __LINE__ |
|
878 | - ); |
|
879 | - } |
|
880 | - return null; |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - |
|
885 | - /** |
|
886 | - * get_config_option |
|
887 | - * |
|
888 | - * @access public |
|
889 | - * @param string $config_option_name |
|
890 | - * @return mixed EE_Config_Base | FALSE |
|
891 | - */ |
|
892 | - public function get_config_option($config_option_name = '') |
|
893 | - { |
|
894 | - // retrieve the wp-option for this config class. |
|
895 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
896 | - if (empty($config_option)) { |
|
897 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
898 | - } |
|
899 | - return $config_option; |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * log |
|
906 | - * |
|
907 | - * @param string $config_option_name |
|
908 | - */ |
|
909 | - public static function log($config_option_name = '') |
|
910 | - { |
|
911 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
912 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
913 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
914 | - $_request = $_REQUEST; |
|
915 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
916 | - $config_log[(string)microtime(true)] = array( |
|
917 | - 'config_name' => $config_option_name, |
|
918 | - 'request' => $_request, |
|
919 | - ); |
|
920 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
921 | - } |
|
922 | - } |
|
923 | - |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * trim_log |
|
928 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
929 | - */ |
|
930 | - public static function trim_log() |
|
931 | - { |
|
932 | - if ( ! EE_Config::logging_enabled()) { |
|
933 | - return; |
|
934 | - } |
|
935 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
936 | - $log_length = count($config_log); |
|
937 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
938 | - ksort($config_log); |
|
939 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
940 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
941 | - } |
|
942 | - } |
|
943 | - |
|
944 | - |
|
945 | - |
|
946 | - /** |
|
947 | - * get_page_for_posts |
|
948 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
949 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
950 | - * |
|
951 | - * @access public |
|
952 | - * @return string |
|
953 | - */ |
|
954 | - public static function get_page_for_posts() |
|
955 | - { |
|
956 | - $page_for_posts = get_option('page_for_posts'); |
|
957 | - if ( ! $page_for_posts) { |
|
958 | - return 'posts'; |
|
959 | - } |
|
960 | - /** @type WPDB $wpdb */ |
|
961 | - global $wpdb; |
|
962 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
963 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
964 | - } |
|
965 | - |
|
966 | - |
|
967 | - |
|
968 | - /** |
|
969 | - * register_shortcodes_and_modules. |
|
970 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
971 | - * In fact, this is where we give modules a chance to let core know they exist |
|
972 | - * so they can help trigger maintenance mode if it's needed |
|
973 | - * |
|
974 | - * @access public |
|
975 | - * @return void |
|
976 | - */ |
|
977 | - public function register_shortcodes_and_modules() |
|
978 | - { |
|
979 | - // allow shortcodes to register with WP and to set hooks for the rest of the system |
|
980 | - EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
981 | - // allow modules to set hooks for the rest of the system |
|
982 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
983 | - } |
|
984 | - |
|
985 | - |
|
986 | - |
|
987 | - /** |
|
988 | - * initialize_shortcodes_and_modules |
|
989 | - * meaning they can start adding their hooks to get stuff done |
|
990 | - * |
|
991 | - * @access public |
|
992 | - * @return void |
|
993 | - */ |
|
994 | - public function initialize_shortcodes_and_modules() |
|
995 | - { |
|
996 | - // allow shortcodes to set hooks for the rest of the system |
|
997 | - $this->_initialize_shortcodes(); |
|
998 | - // allow modules to set hooks for the rest of the system |
|
999 | - $this->_initialize_modules(); |
|
1000 | - } |
|
1001 | - |
|
1002 | - |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * widgets_init |
|
1006 | - * |
|
1007 | - * @access private |
|
1008 | - * @return void |
|
1009 | - */ |
|
1010 | - public function widgets_init() |
|
1011 | - { |
|
1012 | - //only init widgets on admin pages when not in complete maintenance, and |
|
1013 | - //on frontend when not in any maintenance mode |
|
1014 | - if ( |
|
1015 | - ! EE_Maintenance_Mode::instance()->level() |
|
1016 | - || ( |
|
1017 | - is_admin() |
|
1018 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
1019 | - ) |
|
1020 | - ) { |
|
1021 | - // grab list of installed widgets |
|
1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1023 | - // filter list of modules to register |
|
1024 | - $widgets_to_register = apply_filters( |
|
1025 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
1026 | - $widgets_to_register |
|
1027 | - ); |
|
1028 | - if ( ! empty($widgets_to_register)) { |
|
1029 | - // cycle thru widget folders |
|
1030 | - foreach ($widgets_to_register as $widget_path) { |
|
1031 | - // add to list of installed widget modules |
|
1032 | - EE_Config::register_ee_widget($widget_path); |
|
1033 | - } |
|
1034 | - } |
|
1035 | - // filter list of installed modules |
|
1036 | - EE_Registry::instance()->widgets = apply_filters( |
|
1037 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
1038 | - EE_Registry::instance()->widgets |
|
1039 | - ); |
|
1040 | - } |
|
1041 | - } |
|
1042 | - |
|
1043 | - |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * register_ee_widget - makes core aware of this widget |
|
1047 | - * |
|
1048 | - * @access public |
|
1049 | - * @param string $widget_path - full path up to and including widget folder |
|
1050 | - * @return void |
|
1051 | - */ |
|
1052 | - public static function register_ee_widget($widget_path = null) |
|
1053 | - { |
|
1054 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
1055 | - $widget_ext = '.widget.php'; |
|
1056 | - // make all separators match |
|
1057 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
1058 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1059 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
1060 | - // grab and shortcode file name from directory name and break apart at dots |
|
1061 | - $file_name = explode('.', basename($widget_path)); |
|
1062 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1063 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1064 | - // sanitize shortcode directory name |
|
1065 | - $widget = sanitize_key($widget); |
|
1066 | - // now we need to rebuild the shortcode path |
|
1067 | - $widget_path = explode(DS, $widget_path); |
|
1068 | - // remove last segment |
|
1069 | - array_pop($widget_path); |
|
1070 | - // glue it back together |
|
1071 | - $widget_path = implode(DS, $widget_path); |
|
1072 | - } else { |
|
1073 | - // grab and sanitize widget directory name |
|
1074 | - $widget = sanitize_key(basename($widget_path)); |
|
1075 | - } |
|
1076 | - // create classname from widget directory name |
|
1077 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1078 | - // add class prefix |
|
1079 | - $widget_class = 'EEW_' . $widget; |
|
1080 | - // does the widget exist ? |
|
1081 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1082 | - $msg = sprintf( |
|
1083 | - __( |
|
1084 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
1085 | - 'event_espresso' |
|
1086 | - ), |
|
1087 | - $widget_class, |
|
1088 | - $widget_path . DS . $widget_class . $widget_ext |
|
1089 | - ); |
|
1090 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1091 | - return; |
|
1092 | - } |
|
1093 | - // load the widget class file |
|
1094 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1095 | - // verify that class exists |
|
1096 | - if ( ! class_exists($widget_class)) { |
|
1097 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1098 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1099 | - return; |
|
1100 | - } |
|
1101 | - register_widget($widget_class); |
|
1102 | - // add to array of registered widgets |
|
1103 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1104 | - } |
|
1105 | - |
|
1106 | - |
|
1107 | - |
|
1108 | - /** |
|
1109 | - * _register_shortcodes |
|
1110 | - * |
|
1111 | - * @access private |
|
1112 | - * @return array |
|
1113 | - */ |
|
1114 | - private function _register_shortcodes() |
|
1115 | - { |
|
1116 | - // grab list of installed shortcodes |
|
1117 | - $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
1118 | - // filter list of modules to register |
|
1119 | - $shortcodes_to_register = apply_filters( |
|
1120 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
1121 | - $shortcodes_to_register |
|
1122 | - ); |
|
1123 | - if ( ! empty($shortcodes_to_register)) { |
|
1124 | - // cycle thru shortcode folders |
|
1125 | - foreach ($shortcodes_to_register as $shortcode_path) { |
|
1126 | - // add to list of installed shortcode modules |
|
1127 | - EE_Config::register_shortcode($shortcode_path); |
|
1128 | - } |
|
1129 | - } |
|
1130 | - // filter list of installed modules |
|
1131 | - return apply_filters( |
|
1132 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
1133 | - EE_Registry::instance()->shortcodes |
|
1134 | - ); |
|
1135 | - } |
|
1136 | - |
|
1137 | - |
|
1138 | - |
|
1139 | - /** |
|
1140 | - * register_shortcode - makes core aware of this shortcode |
|
1141 | - * |
|
1142 | - * @access public |
|
1143 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
1144 | - * @return bool |
|
1145 | - */ |
|
1146 | - public static function register_shortcode($shortcode_path = null) |
|
1147 | - { |
|
1148 | - do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1149 | - $shortcode_ext = '.shortcode.php'; |
|
1150 | - // make all separators match |
|
1151 | - $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1152 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1153 | - if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
1154 | - // grab shortcode file name from directory name and break apart at dots |
|
1155 | - $shortcode_file = explode('.', basename($shortcode_path)); |
|
1156 | - // take first segment from file name pieces and remove class prefix if it exists |
|
1157 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
1158 | - ? substr($shortcode_file[0], 4) |
|
1159 | - : $shortcode_file[0]; |
|
1160 | - // sanitize shortcode directory name |
|
1161 | - $shortcode = sanitize_key($shortcode); |
|
1162 | - // now we need to rebuild the shortcode path |
|
1163 | - $shortcode_path = explode(DS, $shortcode_path); |
|
1164 | - // remove last segment |
|
1165 | - array_pop($shortcode_path); |
|
1166 | - // glue it back together |
|
1167 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
1168 | - } else { |
|
1169 | - // we need to generate the filename based off of the folder name |
|
1170 | - // grab and sanitize shortcode directory name |
|
1171 | - $shortcode = sanitize_key(basename($shortcode_path)); |
|
1172 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
1173 | - } |
|
1174 | - // create classname from shortcode directory or file name |
|
1175 | - $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1176 | - // add class prefix |
|
1177 | - $shortcode_class = 'EES_' . $shortcode; |
|
1178 | - // does the shortcode exist ? |
|
1179 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
1180 | - $msg = sprintf( |
|
1181 | - __( |
|
1182 | - 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
1183 | - 'event_espresso' |
|
1184 | - ), |
|
1185 | - $shortcode_class, |
|
1186 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1187 | - ); |
|
1188 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1189 | - return false; |
|
1190 | - } |
|
1191 | - // load the shortcode class file |
|
1192 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
1193 | - // verify that class exists |
|
1194 | - if ( ! class_exists($shortcode_class)) { |
|
1195 | - $msg = sprintf( |
|
1196 | - __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
1197 | - $shortcode_class |
|
1198 | - ); |
|
1199 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1200 | - return false; |
|
1201 | - } |
|
1202 | - $shortcode = strtoupper($shortcode); |
|
1203 | - // add to array of registered shortcodes |
|
1204 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1205 | - return true; |
|
1206 | - } |
|
1207 | - |
|
1208 | - |
|
1209 | - |
|
1210 | - /** |
|
1211 | - * _register_modules |
|
1212 | - * |
|
1213 | - * @access private |
|
1214 | - * @return array |
|
1215 | - */ |
|
1216 | - private function _register_modules() |
|
1217 | - { |
|
1218 | - // grab list of installed modules |
|
1219 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1220 | - // filter list of modules to register |
|
1221 | - $modules_to_register = apply_filters( |
|
1222 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
1223 | - $modules_to_register |
|
1224 | - ); |
|
1225 | - if ( ! empty($modules_to_register)) { |
|
1226 | - // loop through folders |
|
1227 | - foreach ($modules_to_register as $module_path) { |
|
1228 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
1229 | - if ( |
|
1230 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1231 | - && $module_path !== EE_MODULES . 'gateways' |
|
1232 | - ) { |
|
1233 | - // add to list of installed modules |
|
1234 | - EE_Config::register_module($module_path); |
|
1235 | - } |
|
1236 | - } |
|
1237 | - } |
|
1238 | - // filter list of installed modules |
|
1239 | - return apply_filters( |
|
1240 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
1241 | - EE_Registry::instance()->modules |
|
1242 | - ); |
|
1243 | - } |
|
1244 | - |
|
1245 | - |
|
1246 | - |
|
1247 | - /** |
|
1248 | - * register_module - makes core aware of this module |
|
1249 | - * |
|
1250 | - * @access public |
|
1251 | - * @param string $module_path - full path up to and including module folder |
|
1252 | - * @return bool |
|
1253 | - */ |
|
1254 | - public static function register_module($module_path = null) |
|
1255 | - { |
|
1256 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1257 | - $module_ext = '.module.php'; |
|
1258 | - // make all separators match |
|
1259 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1260 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
1261 | - if (strpos($module_path, $module_ext) !== false) { |
|
1262 | - // grab and shortcode file name from directory name and break apart at dots |
|
1263 | - $module_file = explode('.', basename($module_path)); |
|
1264 | - // now we need to rebuild the shortcode path |
|
1265 | - $module_path = explode(DS, $module_path); |
|
1266 | - // remove last segment |
|
1267 | - array_pop($module_path); |
|
1268 | - // glue it back together |
|
1269 | - $module_path = implode(DS, $module_path) . DS; |
|
1270 | - // take first segment from file name pieces and sanitize it |
|
1271 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1272 | - // ensure class prefix is added |
|
1273 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1274 | - } else { |
|
1275 | - // we need to generate the filename based off of the folder name |
|
1276 | - // grab and sanitize module name |
|
1277 | - $module = strtolower(basename($module_path)); |
|
1278 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1279 | - // like trailingslashit() |
|
1280 | - $module_path = rtrim($module_path, DS) . DS; |
|
1281 | - // create classname from module directory name |
|
1282 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1283 | - // add class prefix |
|
1284 | - $module_class = 'EED_' . $module; |
|
1285 | - } |
|
1286 | - // does the module exist ? |
|
1287 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1288 | - $msg = sprintf( |
|
1289 | - __( |
|
1290 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
1291 | - 'event_espresso' |
|
1292 | - ), |
|
1293 | - $module |
|
1294 | - ); |
|
1295 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1296 | - return false; |
|
1297 | - } |
|
1298 | - // load the module class file |
|
1299 | - require_once($module_path . $module_class . $module_ext); |
|
1300 | - // verify that class exists |
|
1301 | - if ( ! class_exists($module_class)) { |
|
1302 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1303 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1304 | - return false; |
|
1305 | - } |
|
1306 | - // add to array of registered modules |
|
1307 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1308 | - do_action( |
|
1309 | - 'AHEE__EE_Config__register_module__complete', |
|
1310 | - $module_class, |
|
1311 | - EE_Registry::instance()->modules->{$module_class} |
|
1312 | - ); |
|
1313 | - return true; |
|
1314 | - } |
|
1315 | - |
|
1316 | - |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * _initialize_shortcodes |
|
1320 | - * allow shortcodes to set hooks for the rest of the system |
|
1321 | - * |
|
1322 | - * @access private |
|
1323 | - * @return void |
|
1324 | - */ |
|
1325 | - private function _initialize_shortcodes() |
|
1326 | - { |
|
1327 | - // cycle thru shortcode folders |
|
1328 | - foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1329 | - // add class prefix |
|
1330 | - $shortcode_class = 'EES_' . $shortcode; |
|
1331 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1332 | - // which set hooks ? |
|
1333 | - if (is_admin()) { |
|
1334 | - // fire immediately |
|
1335 | - call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1336 | - } else { |
|
1337 | - // delay until other systems are online |
|
1338 | - add_action( |
|
1339 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1340 | - array($shortcode_class, 'set_hooks') |
|
1341 | - ); |
|
1342 | - // convert classname to UPPERCASE and create WP shortcode. |
|
1343 | - $shortcode_tag = strtoupper($shortcode); |
|
1344 | - // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
|
1345 | - if ( ! shortcode_exists($shortcode_tag)) { |
|
1346 | - // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
|
1347 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1348 | - } |
|
1349 | - } |
|
1350 | - } |
|
1351 | - } |
|
1352 | - |
|
1353 | - |
|
1354 | - |
|
1355 | - /** |
|
1356 | - * _initialize_modules |
|
1357 | - * allow modules to set hooks for the rest of the system |
|
1358 | - * |
|
1359 | - * @access private |
|
1360 | - * @return void |
|
1361 | - */ |
|
1362 | - private function _initialize_modules() |
|
1363 | - { |
|
1364 | - // cycle thru shortcode folders |
|
1365 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1366 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
1367 | - // which set hooks ? |
|
1368 | - if (is_admin()) { |
|
1369 | - // fire immediately |
|
1370 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
1371 | - } else { |
|
1372 | - // delay until other systems are online |
|
1373 | - add_action( |
|
1374 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
1375 | - array($module_class, 'set_hooks') |
|
1376 | - ); |
|
1377 | - } |
|
1378 | - } |
|
1379 | - } |
|
1380 | - |
|
1381 | - |
|
1382 | - |
|
1383 | - /** |
|
1384 | - * register_route - adds module method routes to route_map |
|
1385 | - * |
|
1386 | - * @access public |
|
1387 | - * @param string $route - "pretty" public alias for module method |
|
1388 | - * @param string $module - module name (classname without EED_ prefix) |
|
1389 | - * @param string $method_name - the actual module method to be routed to |
|
1390 | - * @param string $key - url param key indicating a route is being called |
|
1391 | - * @return bool |
|
1392 | - */ |
|
1393 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
1394 | - { |
|
1395 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1396 | - $module = str_replace('EED_', '', $module); |
|
1397 | - $module_class = 'EED_' . $module; |
|
1398 | - if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
1399 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1400 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1401 | - return false; |
|
1402 | - } |
|
1403 | - if (empty($route)) { |
|
1404 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1405 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1406 | - return false; |
|
1407 | - } |
|
1408 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1409 | - $msg = sprintf( |
|
1410 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1411 | - $route |
|
1412 | - ); |
|
1413 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1414 | - return false; |
|
1415 | - } |
|
1416 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1417 | - return true; |
|
1418 | - } |
|
1419 | - |
|
1420 | - |
|
1421 | - |
|
1422 | - /** |
|
1423 | - * get_route - get module method route |
|
1424 | - * |
|
1425 | - * @access public |
|
1426 | - * @param string $route - "pretty" public alias for module method |
|
1427 | - * @param string $key - url param key indicating a route is being called |
|
1428 | - * @return string |
|
1429 | - */ |
|
1430 | - public static function get_route($route = null, $key = 'ee') |
|
1431 | - { |
|
1432 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1433 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1434 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1435 | - return EE_Config::$_module_route_map[$key][$route]; |
|
1436 | - } |
|
1437 | - return null; |
|
1438 | - } |
|
1439 | - |
|
1440 | - |
|
1441 | - |
|
1442 | - /** |
|
1443 | - * get_routes - get ALL module method routes |
|
1444 | - * |
|
1445 | - * @access public |
|
1446 | - * @return array |
|
1447 | - */ |
|
1448 | - public static function get_routes() |
|
1449 | - { |
|
1450 | - return EE_Config::$_module_route_map; |
|
1451 | - } |
|
1452 | - |
|
1453 | - |
|
1454 | - |
|
1455 | - /** |
|
1456 | - * register_forward - allows modules to forward request to another module for further processing |
|
1457 | - * |
|
1458 | - * @access public |
|
1459 | - * @param string $route - "pretty" public alias for module method |
|
1460 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
1461 | - * class, allows different forwards to be served based on status |
|
1462 | - * @param array|string $forward - function name or array( class, method ) |
|
1463 | - * @param string $key - url param key indicating a route is being called |
|
1464 | - * @return bool |
|
1465 | - */ |
|
1466 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
1467 | - { |
|
1468 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1469 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1470 | - $msg = sprintf( |
|
1471 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1472 | - $route |
|
1473 | - ); |
|
1474 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1475 | - return false; |
|
1476 | - } |
|
1477 | - if (empty($forward)) { |
|
1478 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1479 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1480 | - return false; |
|
1481 | - } |
|
1482 | - if (is_array($forward)) { |
|
1483 | - if ( ! isset($forward[1])) { |
|
1484 | - $msg = sprintf( |
|
1485 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1486 | - $route |
|
1487 | - ); |
|
1488 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1489 | - return false; |
|
1490 | - } |
|
1491 | - if ( ! method_exists($forward[0], $forward[1])) { |
|
1492 | - $msg = sprintf( |
|
1493 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1494 | - $forward[1], |
|
1495 | - $route |
|
1496 | - ); |
|
1497 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1498 | - return false; |
|
1499 | - } |
|
1500 | - } else if ( ! function_exists($forward)) { |
|
1501 | - $msg = sprintf( |
|
1502 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1503 | - $forward, |
|
1504 | - $route |
|
1505 | - ); |
|
1506 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1507 | - return false; |
|
1508 | - } |
|
1509 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1510 | - return true; |
|
1511 | - } |
|
1512 | - |
|
1513 | - |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * get_forward - get forwarding route |
|
1517 | - * |
|
1518 | - * @access public |
|
1519 | - * @param string $route - "pretty" public alias for module method |
|
1520 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1521 | - * allows different forwards to be served based on status |
|
1522 | - * @param string $key - url param key indicating a route is being called |
|
1523 | - * @return string |
|
1524 | - */ |
|
1525 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
1526 | - { |
|
1527 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1528 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1529 | - return apply_filters( |
|
1530 | - 'FHEE__EE_Config__get_forward', |
|
1531 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
1532 | - $route, |
|
1533 | - $status |
|
1534 | - ); |
|
1535 | - } |
|
1536 | - return null; |
|
1537 | - } |
|
1538 | - |
|
1539 | - |
|
1540 | - |
|
1541 | - /** |
|
1542 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
1543 | - * results |
|
1544 | - * |
|
1545 | - * @access public |
|
1546 | - * @param string $route - "pretty" public alias for module method |
|
1547 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1548 | - * allows different views to be served based on status |
|
1549 | - * @param string $view |
|
1550 | - * @param string $key - url param key indicating a route is being called |
|
1551 | - * @return bool |
|
1552 | - */ |
|
1553 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
1554 | - { |
|
1555 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1556 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1557 | - $msg = sprintf( |
|
1558 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1559 | - $route |
|
1560 | - ); |
|
1561 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1562 | - return false; |
|
1563 | - } |
|
1564 | - if ( ! is_readable($view)) { |
|
1565 | - $msg = sprintf( |
|
1566 | - __( |
|
1567 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
1568 | - 'event_espresso' |
|
1569 | - ), |
|
1570 | - $view |
|
1571 | - ); |
|
1572 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1573 | - return false; |
|
1574 | - } |
|
1575 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1576 | - return true; |
|
1577 | - } |
|
1578 | - |
|
1579 | - |
|
1580 | - |
|
1581 | - /** |
|
1582 | - * get_view - get view for route and status |
|
1583 | - * |
|
1584 | - * @access public |
|
1585 | - * @param string $route - "pretty" public alias for module method |
|
1586 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
1587 | - * allows different views to be served based on status |
|
1588 | - * @param string $key - url param key indicating a route is being called |
|
1589 | - * @return string |
|
1590 | - */ |
|
1591 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
1592 | - { |
|
1593 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1594 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1595 | - return apply_filters( |
|
1596 | - 'FHEE__EE_Config__get_view', |
|
1597 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
1598 | - $route, |
|
1599 | - $status |
|
1600 | - ); |
|
1601 | - } |
|
1602 | - return null; |
|
1603 | - } |
|
1604 | - |
|
1605 | - |
|
1606 | - |
|
1607 | - public function update_addon_option_names() |
|
1608 | - { |
|
1609 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1610 | - } |
|
1611 | - |
|
1612 | - |
|
1613 | - |
|
1614 | - public function shutdown() |
|
1615 | - { |
|
1616 | - $this->update_addon_option_names(); |
|
1617 | - } |
|
1618 | - |
|
1619 | - |
|
1620 | -} |
|
1621 | - |
|
1622 | - |
|
1623 | - |
|
1624 | -/** |
|
1625 | - * Base class used for config classes. These classes should generally not have |
|
1626 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1627 | - * basically, they should just be well-defined stdClasses |
|
1628 | - */ |
|
1629 | -class EE_Config_Base |
|
1630 | -{ |
|
1631 | - |
|
1632 | - /** |
|
1633 | - * Utility function for escaping the value of a property and returning. |
|
1634 | - * |
|
1635 | - * @param string $property property name (checks to see if exists). |
|
1636 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1637 | - * @throws \EE_Error |
|
1638 | - */ |
|
1639 | - public function get_pretty($property) |
|
1640 | - { |
|
1641 | - if ( ! property_exists($this, $property)) { |
|
1642 | - throw new EE_Error( |
|
1643 | - sprintf( |
|
1644 | - __( |
|
1645 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1646 | - 'event_espresso' |
|
1647 | - ), |
|
1648 | - get_class($this), |
|
1649 | - $property |
|
1650 | - ) |
|
1651 | - ); |
|
1652 | - } |
|
1653 | - //just handling escaping of strings for now. |
|
1654 | - if (is_string($this->{$property})) { |
|
1655 | - return stripslashes($this->{$property}); |
|
1656 | - } |
|
1657 | - return $this->{$property}; |
|
1658 | - } |
|
1659 | - |
|
1660 | - |
|
1661 | - |
|
1662 | - public function populate() |
|
1663 | - { |
|
1664 | - //grab defaults via a new instance of this class. |
|
1665 | - $class_name = get_class($this); |
|
1666 | - $defaults = new $class_name; |
|
1667 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1668 | - //default from our $defaults object. |
|
1669 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
1670 | - if ($this->{$property} === null) { |
|
1671 | - $this->{$property} = $value; |
|
1672 | - } |
|
1673 | - } |
|
1674 | - //cleanup |
|
1675 | - unset($defaults); |
|
1676 | - } |
|
1677 | - |
|
1678 | - |
|
1679 | - /** |
|
1680 | - * @ override magic methods |
|
1681 | - * @ return void |
|
1682 | - */ |
|
1683 | - // public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); } |
|
1684 | - // public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); } |
|
1685 | - /** |
|
1686 | - * __isset |
|
1687 | - * |
|
1688 | - * @param $a |
|
1689 | - * @return bool |
|
1690 | - */ |
|
1691 | - public function __isset($a) |
|
1692 | - { |
|
1693 | - return false; |
|
1694 | - } |
|
1695 | - |
|
1696 | - |
|
1697 | - |
|
1698 | - /** |
|
1699 | - * __unset |
|
1700 | - * |
|
1701 | - * @param $a |
|
1702 | - * @return bool |
|
1703 | - */ |
|
1704 | - public function __unset($a) |
|
1705 | - { |
|
1706 | - return false; |
|
1707 | - } |
|
1708 | - |
|
1709 | - |
|
1710 | - |
|
1711 | - /** |
|
1712 | - * __clone |
|
1713 | - */ |
|
1714 | - public function __clone() |
|
1715 | - { |
|
1716 | - } |
|
1717 | - |
|
1718 | - |
|
1719 | - |
|
1720 | - /** |
|
1721 | - * __wakeup |
|
1722 | - */ |
|
1723 | - public function __wakeup() |
|
1724 | - { |
|
1725 | - } |
|
1726 | - |
|
1727 | - |
|
1728 | - |
|
1729 | - /** |
|
1730 | - * __destruct |
|
1731 | - */ |
|
1732 | - public function __destruct() |
|
1733 | - { |
|
1734 | - } |
|
1735 | -} |
|
1736 | - |
|
1737 | - |
|
1738 | - |
|
1739 | -/** |
|
1740 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1741 | - */ |
|
1742 | -class EE_Core_Config extends EE_Config_Base |
|
1743 | -{ |
|
1744 | - |
|
1745 | - public $current_blog_id; |
|
1746 | - |
|
1747 | - public $ee_ueip_optin; |
|
1748 | - |
|
1749 | - public $ee_ueip_has_notified; |
|
1750 | - |
|
1751 | - /** |
|
1752 | - * Not to be confused with the 4 critical page variables (See |
|
1753 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1754 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1755 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1756 | - * |
|
1757 | - * @var array |
|
1758 | - */ |
|
1759 | - public $post_shortcodes; |
|
1760 | - |
|
1761 | - public $module_route_map; |
|
1762 | - |
|
1763 | - public $module_forward_map; |
|
1764 | - |
|
1765 | - public $module_view_map; |
|
1766 | - |
|
1767 | - /** |
|
1768 | - * The next 4 vars are the IDs of critical EE pages. |
|
1769 | - * |
|
1770 | - * @var int |
|
1771 | - */ |
|
1772 | - public $reg_page_id; |
|
1773 | - |
|
1774 | - public $txn_page_id; |
|
1775 | - |
|
1776 | - public $thank_you_page_id; |
|
1777 | - |
|
1778 | - public $cancel_page_id; |
|
1779 | - |
|
1780 | - /** |
|
1781 | - * The next 4 vars are the URLs of critical EE pages. |
|
1782 | - * |
|
1783 | - * @var int |
|
1784 | - */ |
|
1785 | - public $reg_page_url; |
|
1786 | - |
|
1787 | - public $txn_page_url; |
|
1788 | - |
|
1789 | - public $thank_you_page_url; |
|
1790 | - |
|
1791 | - public $cancel_page_url; |
|
1792 | - |
|
1793 | - /** |
|
1794 | - * The next vars relate to the custom slugs for EE CPT routes |
|
1795 | - */ |
|
1796 | - public $event_cpt_slug; |
|
1797 | - |
|
1798 | - |
|
1799 | - /** |
|
1800 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
1801 | - * request across blog switches in a multisite context. |
|
1802 | - * Avoids extra queries to the db for this option. |
|
1803 | - * |
|
1804 | - * @var bool |
|
1805 | - */ |
|
1806 | - public static $ee_ueip_option; |
|
1807 | - |
|
1808 | - |
|
1809 | - |
|
1810 | - /** |
|
1811 | - * class constructor |
|
1812 | - * |
|
1813 | - * @access public |
|
1814 | - */ |
|
1815 | - public function __construct() |
|
1816 | - { |
|
1817 | - // set default organization settings |
|
1818 | - $this->current_blog_id = get_current_blog_id(); |
|
1819 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1820 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1821 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1822 | - $this->post_shortcodes = array(); |
|
1823 | - $this->module_route_map = array(); |
|
1824 | - $this->module_forward_map = array(); |
|
1825 | - $this->module_view_map = array(); |
|
1826 | - // critical EE page IDs |
|
1827 | - $this->reg_page_id = 0; |
|
1828 | - $this->txn_page_id = 0; |
|
1829 | - $this->thank_you_page_id = 0; |
|
1830 | - $this->cancel_page_id = 0; |
|
1831 | - // critical EE page URLs |
|
1832 | - $this->reg_page_url = ''; |
|
1833 | - $this->txn_page_url = ''; |
|
1834 | - $this->thank_you_page_url = ''; |
|
1835 | - $this->cancel_page_url = ''; |
|
1836 | - //cpt slugs |
|
1837 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1838 | - //ueip constant check |
|
1839 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1840 | - $this->ee_ueip_optin = false; |
|
1841 | - $this->ee_ueip_has_notified = true; |
|
1842 | - } |
|
1843 | - } |
|
1844 | - |
|
1845 | - |
|
1846 | - |
|
1847 | - /** |
|
1848 | - * @return array |
|
1849 | - */ |
|
1850 | - public function get_critical_pages_array() |
|
1851 | - { |
|
1852 | - return array( |
|
1853 | - $this->reg_page_id, |
|
1854 | - $this->txn_page_id, |
|
1855 | - $this->thank_you_page_id, |
|
1856 | - $this->cancel_page_id, |
|
1857 | - ); |
|
1858 | - } |
|
1859 | - |
|
1860 | - |
|
1861 | - |
|
1862 | - /** |
|
1863 | - * @return array |
|
1864 | - */ |
|
1865 | - public function get_critical_pages_shortcodes_array() |
|
1866 | - { |
|
1867 | - return array( |
|
1868 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1869 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1870 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1871 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1872 | - ); |
|
1873 | - } |
|
1874 | - |
|
1875 | - |
|
1876 | - |
|
1877 | - /** |
|
1878 | - * gets/returns URL for EE reg_page |
|
1879 | - * |
|
1880 | - * @access public |
|
1881 | - * @return string |
|
1882 | - */ |
|
1883 | - public function reg_page_url() |
|
1884 | - { |
|
1885 | - if ( ! $this->reg_page_url) { |
|
1886 | - $this->reg_page_url = add_query_arg( |
|
1887 | - array('uts' => time()), |
|
1888 | - get_permalink($this->reg_page_id) |
|
1889 | - ) . '#checkout'; |
|
1890 | - } |
|
1891 | - return $this->reg_page_url; |
|
1892 | - } |
|
1893 | - |
|
1894 | - |
|
1895 | - |
|
1896 | - /** |
|
1897 | - * gets/returns URL for EE txn_page |
|
1898 | - * |
|
1899 | - * @param array $query_args like what gets passed to |
|
1900 | - * add_query_arg() as the first argument |
|
1901 | - * @access public |
|
1902 | - * @return string |
|
1903 | - */ |
|
1904 | - public function txn_page_url($query_args = array()) |
|
1905 | - { |
|
1906 | - if ( ! $this->txn_page_url) { |
|
1907 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1908 | - } |
|
1909 | - if ($query_args) { |
|
1910 | - return add_query_arg($query_args, $this->txn_page_url); |
|
1911 | - } else { |
|
1912 | - return $this->txn_page_url; |
|
1913 | - } |
|
1914 | - } |
|
1915 | - |
|
1916 | - |
|
1917 | - |
|
1918 | - /** |
|
1919 | - * gets/returns URL for EE thank_you_page |
|
1920 | - * |
|
1921 | - * @param array $query_args like what gets passed to |
|
1922 | - * add_query_arg() as the first argument |
|
1923 | - * @access public |
|
1924 | - * @return string |
|
1925 | - */ |
|
1926 | - public function thank_you_page_url($query_args = array()) |
|
1927 | - { |
|
1928 | - if ( ! $this->thank_you_page_url) { |
|
1929 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1930 | - } |
|
1931 | - if ($query_args) { |
|
1932 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
1933 | - } else { |
|
1934 | - return $this->thank_you_page_url; |
|
1935 | - } |
|
1936 | - } |
|
1937 | - |
|
1938 | - |
|
1939 | - |
|
1940 | - /** |
|
1941 | - * gets/returns URL for EE cancel_page |
|
1942 | - * |
|
1943 | - * @access public |
|
1944 | - * @return string |
|
1945 | - */ |
|
1946 | - public function cancel_page_url() |
|
1947 | - { |
|
1948 | - if ( ! $this->cancel_page_url) { |
|
1949 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1950 | - } |
|
1951 | - return $this->cancel_page_url; |
|
1952 | - } |
|
1953 | - |
|
1954 | - |
|
1955 | - |
|
1956 | - /** |
|
1957 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1958 | - * |
|
1959 | - * @since 4.7.5 |
|
1960 | - */ |
|
1961 | - protected function _reset_urls() |
|
1962 | - { |
|
1963 | - $this->reg_page_url = ''; |
|
1964 | - $this->txn_page_url = ''; |
|
1965 | - $this->cancel_page_url = ''; |
|
1966 | - $this->thank_you_page_url = ''; |
|
1967 | - } |
|
1968 | - |
|
1969 | - |
|
1970 | - |
|
1971 | - /** |
|
1972 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
1973 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1974 | - * on the main site only. |
|
1975 | - * |
|
1976 | - * @return mixed|void |
|
1977 | - */ |
|
1978 | - protected function _get_main_ee_ueip_optin() |
|
1979 | - { |
|
1980 | - //if this is the main site then we can just bypass our direct query. |
|
1981 | - if (is_main_site()) { |
|
1982 | - return get_option('ee_ueip_optin', false); |
|
1983 | - } |
|
1984 | - //is this already cached for this request? If so use it. |
|
1985 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1986 | - return EE_Core_Config::$ee_ueip_option; |
|
1987 | - } |
|
1988 | - global $wpdb; |
|
1989 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1990 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1991 | - $option = 'ee_ueip_optin'; |
|
1992 | - //set correct table for query |
|
1993 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1994 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1995 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1996 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1997 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1998 | - //for the purpose of caching. |
|
1999 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
2000 | - if (false !== $pre) { |
|
2001 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
2002 | - return EE_Core_Config::$ee_ueip_option; |
|
2003 | - } |
|
2004 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
2005 | - $option)); |
|
2006 | - if (is_object($row)) { |
|
2007 | - $value = $row->option_value; |
|
2008 | - } else { //option does not exist so use default. |
|
2009 | - return apply_filters('default_option_' . $option, false, $option); |
|
2010 | - } |
|
2011 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
2012 | - return EE_Core_Config::$ee_ueip_option; |
|
2013 | - } |
|
2014 | - |
|
2015 | - |
|
2016 | - |
|
2017 | - /** |
|
2018 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
2019 | - * on the object. |
|
2020 | - * |
|
2021 | - * @return array |
|
2022 | - */ |
|
2023 | - public function __sleep() |
|
2024 | - { |
|
2025 | - //reset all url properties |
|
2026 | - $this->_reset_urls(); |
|
2027 | - //return what to save to db |
|
2028 | - return array_keys(get_object_vars($this)); |
|
2029 | - } |
|
2030 | - |
|
2031 | -} |
|
2032 | - |
|
2033 | - |
|
2034 | - |
|
2035 | -/** |
|
2036 | - * Config class for storing info on the Organization |
|
2037 | - */ |
|
2038 | -class EE_Organization_Config extends EE_Config_Base |
|
2039 | -{ |
|
2040 | - |
|
2041 | - /** |
|
2042 | - * @var string $name |
|
2043 | - * eg EE4.1 |
|
2044 | - */ |
|
2045 | - public $name; |
|
2046 | - |
|
2047 | - /** |
|
2048 | - * @var string $address_1 |
|
2049 | - * eg 123 Onna Road |
|
2050 | - */ |
|
2051 | - public $address_1; |
|
2052 | - |
|
2053 | - /** |
|
2054 | - * @var string $address_2 |
|
2055 | - * eg PO Box 123 |
|
2056 | - */ |
|
2057 | - public $address_2; |
|
2058 | - |
|
2059 | - /** |
|
2060 | - * @var string $city |
|
2061 | - * eg Inna City |
|
2062 | - */ |
|
2063 | - public $city; |
|
2064 | - |
|
2065 | - /** |
|
2066 | - * @var int $STA_ID |
|
2067 | - * eg 4 |
|
2068 | - */ |
|
2069 | - public $STA_ID; |
|
2070 | - |
|
2071 | - /** |
|
2072 | - * @var string $CNT_ISO |
|
2073 | - * eg US |
|
2074 | - */ |
|
2075 | - public $CNT_ISO; |
|
2076 | - |
|
2077 | - /** |
|
2078 | - * @var string $zip |
|
2079 | - * eg 12345 or V1A 2B3 |
|
2080 | - */ |
|
2081 | - public $zip; |
|
2082 | - |
|
2083 | - /** |
|
2084 | - * @var string $email |
|
2085 | - * eg [email protected] |
|
2086 | - */ |
|
2087 | - public $email; |
|
2088 | - |
|
2089 | - |
|
2090 | - /** |
|
2091 | - * @var string $phone |
|
2092 | - * eg. 111-111-1111 |
|
2093 | - */ |
|
2094 | - public $phone; |
|
2095 | - |
|
2096 | - |
|
2097 | - /** |
|
2098 | - * @var string $vat |
|
2099 | - * VAT/Tax Number |
|
2100 | - */ |
|
2101 | - public $vat; |
|
2102 | - |
|
2103 | - /** |
|
2104 | - * @var string $logo_url |
|
2105 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2106 | - */ |
|
2107 | - public $logo_url; |
|
2108 | - |
|
2109 | - |
|
2110 | - /** |
|
2111 | - * The below are all various properties for holding links to organization social network profiles |
|
2112 | - * |
|
2113 | - * @var string |
|
2114 | - */ |
|
2115 | - /** |
|
2116 | - * facebook (facebook.com/profile.name) |
|
2117 | - * |
|
2118 | - * @var string |
|
2119 | - */ |
|
2120 | - public $facebook; |
|
2121 | - |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * twitter (twitter.com/twitter_handle) |
|
2125 | - * |
|
2126 | - * @var string |
|
2127 | - */ |
|
2128 | - public $twitter; |
|
2129 | - |
|
2130 | - |
|
2131 | - /** |
|
2132 | - * linkedin (linkedin.com/in/profile_name) |
|
2133 | - * |
|
2134 | - * @var string |
|
2135 | - */ |
|
2136 | - public $linkedin; |
|
2137 | - |
|
2138 | - |
|
2139 | - /** |
|
2140 | - * pinterest (www.pinterest.com/profile_name) |
|
2141 | - * |
|
2142 | - * @var string |
|
2143 | - */ |
|
2144 | - public $pinterest; |
|
2145 | - |
|
2146 | - |
|
2147 | - /** |
|
2148 | - * google+ (google.com/+profileName) |
|
2149 | - * |
|
2150 | - * @var string |
|
2151 | - */ |
|
2152 | - public $google; |
|
2153 | - |
|
2154 | - |
|
2155 | - /** |
|
2156 | - * instagram (instagram.com/handle) |
|
2157 | - * |
|
2158 | - * @var string |
|
2159 | - */ |
|
2160 | - public $instagram; |
|
2161 | - |
|
2162 | - |
|
2163 | - |
|
2164 | - /** |
|
2165 | - * class constructor |
|
2166 | - * |
|
2167 | - * @access public |
|
2168 | - */ |
|
2169 | - public function __construct() |
|
2170 | - { |
|
2171 | - // set default organization settings |
|
2172 | - $this->name = get_bloginfo('name'); |
|
2173 | - $this->address_1 = '123 Onna Road'; |
|
2174 | - $this->address_2 = 'PO Box 123'; |
|
2175 | - $this->city = 'Inna City'; |
|
2176 | - $this->STA_ID = 4; |
|
2177 | - $this->CNT_ISO = 'US'; |
|
2178 | - $this->zip = '12345'; |
|
2179 | - $this->email = get_bloginfo('admin_email'); |
|
2180 | - $this->phone = ''; |
|
2181 | - $this->vat = '123456789'; |
|
2182 | - $this->logo_url = ''; |
|
2183 | - $this->facebook = ''; |
|
2184 | - $this->twitter = ''; |
|
2185 | - $this->linkedin = ''; |
|
2186 | - $this->pinterest = ''; |
|
2187 | - $this->google = ''; |
|
2188 | - $this->instagram = ''; |
|
2189 | - } |
|
2190 | - |
|
2191 | -} |
|
2192 | - |
|
2193 | - |
|
2194 | - |
|
2195 | -/** |
|
2196 | - * Class for defining what's in the EE_Config relating to currency |
|
2197 | - */ |
|
2198 | -class EE_Currency_Config extends EE_Config_Base |
|
2199 | -{ |
|
2200 | - |
|
2201 | - /** |
|
2202 | - * @var string $code |
|
2203 | - * eg 'US' |
|
2204 | - */ |
|
2205 | - public $code; |
|
2206 | - |
|
2207 | - /** |
|
2208 | - * @var string $name |
|
2209 | - * eg 'Dollar' |
|
2210 | - */ |
|
2211 | - public $name; |
|
2212 | - |
|
2213 | - /** |
|
2214 | - * plural name |
|
2215 | - * |
|
2216 | - * @var string $plural |
|
2217 | - * eg 'Dollars' |
|
2218 | - */ |
|
2219 | - public $plural; |
|
2220 | - |
|
2221 | - /** |
|
2222 | - * currency sign |
|
2223 | - * |
|
2224 | - * @var string $sign |
|
2225 | - * eg '$' |
|
2226 | - */ |
|
2227 | - public $sign; |
|
2228 | - |
|
2229 | - /** |
|
2230 | - * Whether the currency sign should come before the number or not |
|
2231 | - * |
|
2232 | - * @var boolean $sign_b4 |
|
2233 | - */ |
|
2234 | - public $sign_b4; |
|
2235 | - |
|
2236 | - /** |
|
2237 | - * How many digits should come after the decimal place |
|
2238 | - * |
|
2239 | - * @var int $dec_plc |
|
2240 | - */ |
|
2241 | - public $dec_plc; |
|
2242 | - |
|
2243 | - /** |
|
2244 | - * Symbol to use for decimal mark |
|
2245 | - * |
|
2246 | - * @var string $dec_mrk |
|
2247 | - * eg '.' |
|
2248 | - */ |
|
2249 | - public $dec_mrk; |
|
2250 | - |
|
2251 | - /** |
|
2252 | - * Symbol to use for thousands |
|
2253 | - * |
|
2254 | - * @var string $thsnds |
|
2255 | - * eg ',' |
|
2256 | - */ |
|
2257 | - public $thsnds; |
|
2258 | - |
|
2259 | - |
|
2260 | - |
|
2261 | - /** |
|
2262 | - * class constructor |
|
2263 | - * |
|
2264 | - * @access public |
|
2265 | - * @param string $CNT_ISO |
|
2266 | - * @throws \EE_Error |
|
2267 | - */ |
|
2268 | - public function __construct($CNT_ISO = '') |
|
2269 | - { |
|
2270 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2271 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2272 | - // get country code from organization settings or use default |
|
2273 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2274 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2275 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2276 | - : ''; |
|
2277 | - // but override if requested |
|
2278 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2279 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2280 | - if ( |
|
2281 | - ! empty($CNT_ISO) |
|
2282 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
2283 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2284 | - ) { |
|
2285 | - // retrieve the country settings from the db, just in case they have been customized |
|
2286 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2287 | - if ($country instanceof EE_Country) { |
|
2288 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2289 | - $this->name = $country->currency_name_single(); // Dollar |
|
2290 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2291 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2292 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2293 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2294 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2295 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2296 | - } |
|
2297 | - } |
|
2298 | - // fallback to hardcoded defaults, in case the above failed |
|
2299 | - if (empty($this->code)) { |
|
2300 | - // set default currency settings |
|
2301 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2302 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2303 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2304 | - $this->sign = '$'; // currency sign: $ |
|
2305 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2306 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2307 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2308 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2309 | - } |
|
2310 | - } |
|
2311 | 1620 | } |
2312 | 1621 | |
2313 | 1622 | |
2314 | 1623 | |
2315 | 1624 | /** |
2316 | - * Class for defining what's in the EE_Config relating to registration settings |
|
1625 | + * Base class used for config classes. These classes should generally not have |
|
1626 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
1627 | + * basically, they should just be well-defined stdClasses |
|
2317 | 1628 | */ |
2318 | -class EE_Registration_Config extends EE_Config_Base |
|
1629 | +class EE_Config_Base |
|
2319 | 1630 | { |
2320 | 1631 | |
2321 | - /** |
|
2322 | - * Default registration status |
|
2323 | - * |
|
2324 | - * @var string $default_STS_ID |
|
2325 | - * eg 'RPP' |
|
2326 | - */ |
|
2327 | - public $default_STS_ID; |
|
2328 | - |
|
2329 | - /** |
|
2330 | - * level of validation to apply to email addresses |
|
2331 | - * |
|
2332 | - * @var string $email_validation_level |
|
2333 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2334 | - */ |
|
2335 | - public $email_validation_level; |
|
2336 | - |
|
2337 | - /** |
|
2338 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2339 | - * |
|
2340 | - * @var boolean $show_pending_payment_options |
|
2341 | - */ |
|
2342 | - public $show_pending_payment_options; |
|
2343 | - |
|
2344 | - /** |
|
2345 | - * Whether to skip the registration confirmation page |
|
2346 | - * |
|
2347 | - * @var boolean $skip_reg_confirmation |
|
2348 | - */ |
|
2349 | - public $skip_reg_confirmation; |
|
2350 | - |
|
2351 | - /** |
|
2352 | - * an array of SPCO reg steps where: |
|
2353 | - * the keys denotes the reg step order |
|
2354 | - * each element consists of an array with the following elements: |
|
2355 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2356 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2357 | - * "slug" => the URL param used to trigger the reg step |
|
2358 | - * |
|
2359 | - * @var array $reg_steps |
|
2360 | - */ |
|
2361 | - public $reg_steps; |
|
2362 | - |
|
2363 | - /** |
|
2364 | - * Whether registration confirmation should be the last page of SPCO |
|
2365 | - * |
|
2366 | - * @var boolean $reg_confirmation_last |
|
2367 | - */ |
|
2368 | - public $reg_confirmation_last; |
|
2369 | - |
|
2370 | - /** |
|
2371 | - * Whether or not to enable the EE Bot Trap |
|
2372 | - * |
|
2373 | - * @var boolean $use_bot_trap |
|
2374 | - */ |
|
2375 | - public $use_bot_trap; |
|
2376 | - |
|
2377 | - /** |
|
2378 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2379 | - * |
|
2380 | - * @var boolean $use_encryption |
|
2381 | - */ |
|
2382 | - public $use_encryption; |
|
2383 | - |
|
2384 | - /** |
|
2385 | - * Whether or not to use ReCaptcha |
|
2386 | - * |
|
2387 | - * @var boolean $use_captcha |
|
2388 | - */ |
|
2389 | - public $use_captcha; |
|
2390 | - |
|
2391 | - /** |
|
2392 | - * ReCaptcha Theme |
|
2393 | - * |
|
2394 | - * @var string $recaptcha_theme |
|
2395 | - * options: 'dark ', 'light' |
|
2396 | - */ |
|
2397 | - public $recaptcha_theme; |
|
1632 | + /** |
|
1633 | + * Utility function for escaping the value of a property and returning. |
|
1634 | + * |
|
1635 | + * @param string $property property name (checks to see if exists). |
|
1636 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
1637 | + * @throws \EE_Error |
|
1638 | + */ |
|
1639 | + public function get_pretty($property) |
|
1640 | + { |
|
1641 | + if ( ! property_exists($this, $property)) { |
|
1642 | + throw new EE_Error( |
|
1643 | + sprintf( |
|
1644 | + __( |
|
1645 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
1646 | + 'event_espresso' |
|
1647 | + ), |
|
1648 | + get_class($this), |
|
1649 | + $property |
|
1650 | + ) |
|
1651 | + ); |
|
1652 | + } |
|
1653 | + //just handling escaping of strings for now. |
|
1654 | + if (is_string($this->{$property})) { |
|
1655 | + return stripslashes($this->{$property}); |
|
1656 | + } |
|
1657 | + return $this->{$property}; |
|
1658 | + } |
|
1659 | + |
|
1660 | + |
|
1661 | + |
|
1662 | + public function populate() |
|
1663 | + { |
|
1664 | + //grab defaults via a new instance of this class. |
|
1665 | + $class_name = get_class($this); |
|
1666 | + $defaults = new $class_name; |
|
1667 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
1668 | + //default from our $defaults object. |
|
1669 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1670 | + if ($this->{$property} === null) { |
|
1671 | + $this->{$property} = $value; |
|
1672 | + } |
|
1673 | + } |
|
1674 | + //cleanup |
|
1675 | + unset($defaults); |
|
1676 | + } |
|
1677 | + |
|
1678 | + |
|
1679 | + /** |
|
1680 | + * @ override magic methods |
|
1681 | + * @ return void |
|
1682 | + */ |
|
1683 | + // public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); } |
|
1684 | + // public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); } |
|
1685 | + /** |
|
1686 | + * __isset |
|
1687 | + * |
|
1688 | + * @param $a |
|
1689 | + * @return bool |
|
1690 | + */ |
|
1691 | + public function __isset($a) |
|
1692 | + { |
|
1693 | + return false; |
|
1694 | + } |
|
1695 | + |
|
1696 | + |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * __unset |
|
1700 | + * |
|
1701 | + * @param $a |
|
1702 | + * @return bool |
|
1703 | + */ |
|
1704 | + public function __unset($a) |
|
1705 | + { |
|
1706 | + return false; |
|
1707 | + } |
|
1708 | + |
|
1709 | + |
|
1710 | + |
|
1711 | + /** |
|
1712 | + * __clone |
|
1713 | + */ |
|
1714 | + public function __clone() |
|
1715 | + { |
|
1716 | + } |
|
1717 | + |
|
1718 | + |
|
1719 | + |
|
1720 | + /** |
|
1721 | + * __wakeup |
|
1722 | + */ |
|
1723 | + public function __wakeup() |
|
1724 | + { |
|
1725 | + } |
|
1726 | + |
|
1727 | + |
|
1728 | + |
|
1729 | + /** |
|
1730 | + * __destruct |
|
1731 | + */ |
|
1732 | + public function __destruct() |
|
1733 | + { |
|
1734 | + } |
|
1735 | +} |
|
2398 | 1736 | |
2399 | - /** |
|
2400 | - * ReCaptcha Type |
|
2401 | - * |
|
2402 | - * @var string $recaptcha_type |
|
2403 | - * options: 'audio', 'image' |
|
2404 | - */ |
|
2405 | - public $recaptcha_type; |
|
2406 | 1737 | |
2407 | - /** |
|
2408 | - * ReCaptcha language |
|
2409 | - * |
|
2410 | - * @var string $recaptcha_language |
|
2411 | - * eg 'en' |
|
2412 | - */ |
|
2413 | - public $recaptcha_language; |
|
2414 | 1738 | |
2415 | - /** |
|
2416 | - * ReCaptcha public key |
|
2417 | - * |
|
2418 | - * @var string $recaptcha_publickey |
|
2419 | - */ |
|
2420 | - public $recaptcha_publickey; |
|
1739 | +/** |
|
1740 | + * Class for defining what's in the EE_Config relating to registration settings |
|
1741 | + */ |
|
1742 | +class EE_Core_Config extends EE_Config_Base |
|
1743 | +{ |
|
2421 | 1744 | |
2422 | - /** |
|
2423 | - * ReCaptcha private key |
|
2424 | - * |
|
2425 | - * @var string $recaptcha_privatekey |
|
2426 | - */ |
|
2427 | - public $recaptcha_privatekey; |
|
1745 | + public $current_blog_id; |
|
1746 | + |
|
1747 | + public $ee_ueip_optin; |
|
1748 | + |
|
1749 | + public $ee_ueip_has_notified; |
|
1750 | + |
|
1751 | + /** |
|
1752 | + * Not to be confused with the 4 critical page variables (See |
|
1753 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
1754 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
1755 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
1756 | + * |
|
1757 | + * @var array |
|
1758 | + */ |
|
1759 | + public $post_shortcodes; |
|
1760 | + |
|
1761 | + public $module_route_map; |
|
1762 | + |
|
1763 | + public $module_forward_map; |
|
1764 | + |
|
1765 | + public $module_view_map; |
|
1766 | + |
|
1767 | + /** |
|
1768 | + * The next 4 vars are the IDs of critical EE pages. |
|
1769 | + * |
|
1770 | + * @var int |
|
1771 | + */ |
|
1772 | + public $reg_page_id; |
|
1773 | + |
|
1774 | + public $txn_page_id; |
|
1775 | + |
|
1776 | + public $thank_you_page_id; |
|
1777 | + |
|
1778 | + public $cancel_page_id; |
|
1779 | + |
|
1780 | + /** |
|
1781 | + * The next 4 vars are the URLs of critical EE pages. |
|
1782 | + * |
|
1783 | + * @var int |
|
1784 | + */ |
|
1785 | + public $reg_page_url; |
|
1786 | + |
|
1787 | + public $txn_page_url; |
|
1788 | + |
|
1789 | + public $thank_you_page_url; |
|
1790 | + |
|
1791 | + public $cancel_page_url; |
|
1792 | + |
|
1793 | + /** |
|
1794 | + * The next vars relate to the custom slugs for EE CPT routes |
|
1795 | + */ |
|
1796 | + public $event_cpt_slug; |
|
1797 | + |
|
1798 | + |
|
1799 | + /** |
|
1800 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
1801 | + * request across blog switches in a multisite context. |
|
1802 | + * Avoids extra queries to the db for this option. |
|
1803 | + * |
|
1804 | + * @var bool |
|
1805 | + */ |
|
1806 | + public static $ee_ueip_option; |
|
1807 | + |
|
1808 | + |
|
1809 | + |
|
1810 | + /** |
|
1811 | + * class constructor |
|
1812 | + * |
|
1813 | + * @access public |
|
1814 | + */ |
|
1815 | + public function __construct() |
|
1816 | + { |
|
1817 | + // set default organization settings |
|
1818 | + $this->current_blog_id = get_current_blog_id(); |
|
1819 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
1820 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
1821 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1822 | + $this->post_shortcodes = array(); |
|
1823 | + $this->module_route_map = array(); |
|
1824 | + $this->module_forward_map = array(); |
|
1825 | + $this->module_view_map = array(); |
|
1826 | + // critical EE page IDs |
|
1827 | + $this->reg_page_id = 0; |
|
1828 | + $this->txn_page_id = 0; |
|
1829 | + $this->thank_you_page_id = 0; |
|
1830 | + $this->cancel_page_id = 0; |
|
1831 | + // critical EE page URLs |
|
1832 | + $this->reg_page_url = ''; |
|
1833 | + $this->txn_page_url = ''; |
|
1834 | + $this->thank_you_page_url = ''; |
|
1835 | + $this->cancel_page_url = ''; |
|
1836 | + //cpt slugs |
|
1837 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1838 | + //ueip constant check |
|
1839 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1840 | + $this->ee_ueip_optin = false; |
|
1841 | + $this->ee_ueip_has_notified = true; |
|
1842 | + } |
|
1843 | + } |
|
1844 | + |
|
1845 | + |
|
1846 | + |
|
1847 | + /** |
|
1848 | + * @return array |
|
1849 | + */ |
|
1850 | + public function get_critical_pages_array() |
|
1851 | + { |
|
1852 | + return array( |
|
1853 | + $this->reg_page_id, |
|
1854 | + $this->txn_page_id, |
|
1855 | + $this->thank_you_page_id, |
|
1856 | + $this->cancel_page_id, |
|
1857 | + ); |
|
1858 | + } |
|
1859 | + |
|
1860 | + |
|
1861 | + |
|
1862 | + /** |
|
1863 | + * @return array |
|
1864 | + */ |
|
1865 | + public function get_critical_pages_shortcodes_array() |
|
1866 | + { |
|
1867 | + return array( |
|
1868 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
1869 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
1870 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
1871 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
1872 | + ); |
|
1873 | + } |
|
1874 | + |
|
1875 | + |
|
1876 | + |
|
1877 | + /** |
|
1878 | + * gets/returns URL for EE reg_page |
|
1879 | + * |
|
1880 | + * @access public |
|
1881 | + * @return string |
|
1882 | + */ |
|
1883 | + public function reg_page_url() |
|
1884 | + { |
|
1885 | + if ( ! $this->reg_page_url) { |
|
1886 | + $this->reg_page_url = add_query_arg( |
|
1887 | + array('uts' => time()), |
|
1888 | + get_permalink($this->reg_page_id) |
|
1889 | + ) . '#checkout'; |
|
1890 | + } |
|
1891 | + return $this->reg_page_url; |
|
1892 | + } |
|
1893 | + |
|
1894 | + |
|
1895 | + |
|
1896 | + /** |
|
1897 | + * gets/returns URL for EE txn_page |
|
1898 | + * |
|
1899 | + * @param array $query_args like what gets passed to |
|
1900 | + * add_query_arg() as the first argument |
|
1901 | + * @access public |
|
1902 | + * @return string |
|
1903 | + */ |
|
1904 | + public function txn_page_url($query_args = array()) |
|
1905 | + { |
|
1906 | + if ( ! $this->txn_page_url) { |
|
1907 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1908 | + } |
|
1909 | + if ($query_args) { |
|
1910 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1911 | + } else { |
|
1912 | + return $this->txn_page_url; |
|
1913 | + } |
|
1914 | + } |
|
1915 | + |
|
1916 | + |
|
1917 | + |
|
1918 | + /** |
|
1919 | + * gets/returns URL for EE thank_you_page |
|
1920 | + * |
|
1921 | + * @param array $query_args like what gets passed to |
|
1922 | + * add_query_arg() as the first argument |
|
1923 | + * @access public |
|
1924 | + * @return string |
|
1925 | + */ |
|
1926 | + public function thank_you_page_url($query_args = array()) |
|
1927 | + { |
|
1928 | + if ( ! $this->thank_you_page_url) { |
|
1929 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1930 | + } |
|
1931 | + if ($query_args) { |
|
1932 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1933 | + } else { |
|
1934 | + return $this->thank_you_page_url; |
|
1935 | + } |
|
1936 | + } |
|
1937 | + |
|
1938 | + |
|
1939 | + |
|
1940 | + /** |
|
1941 | + * gets/returns URL for EE cancel_page |
|
1942 | + * |
|
1943 | + * @access public |
|
1944 | + * @return string |
|
1945 | + */ |
|
1946 | + public function cancel_page_url() |
|
1947 | + { |
|
1948 | + if ( ! $this->cancel_page_url) { |
|
1949 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1950 | + } |
|
1951 | + return $this->cancel_page_url; |
|
1952 | + } |
|
1953 | + |
|
1954 | + |
|
1955 | + |
|
1956 | + /** |
|
1957 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
1958 | + * |
|
1959 | + * @since 4.7.5 |
|
1960 | + */ |
|
1961 | + protected function _reset_urls() |
|
1962 | + { |
|
1963 | + $this->reg_page_url = ''; |
|
1964 | + $this->txn_page_url = ''; |
|
1965 | + $this->cancel_page_url = ''; |
|
1966 | + $this->thank_you_page_url = ''; |
|
1967 | + } |
|
1968 | + |
|
1969 | + |
|
1970 | + |
|
1971 | + /** |
|
1972 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
1973 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
1974 | + * on the main site only. |
|
1975 | + * |
|
1976 | + * @return mixed|void |
|
1977 | + */ |
|
1978 | + protected function _get_main_ee_ueip_optin() |
|
1979 | + { |
|
1980 | + //if this is the main site then we can just bypass our direct query. |
|
1981 | + if (is_main_site()) { |
|
1982 | + return get_option('ee_ueip_optin', false); |
|
1983 | + } |
|
1984 | + //is this already cached for this request? If so use it. |
|
1985 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1986 | + return EE_Core_Config::$ee_ueip_option; |
|
1987 | + } |
|
1988 | + global $wpdb; |
|
1989 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
1990 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1991 | + $option = 'ee_ueip_optin'; |
|
1992 | + //set correct table for query |
|
1993 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1994 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
1995 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
1996 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
1997 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
1998 | + //for the purpose of caching. |
|
1999 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
2000 | + if (false !== $pre) { |
|
2001 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
2002 | + return EE_Core_Config::$ee_ueip_option; |
|
2003 | + } |
|
2004 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
2005 | + $option)); |
|
2006 | + if (is_object($row)) { |
|
2007 | + $value = $row->option_value; |
|
2008 | + } else { //option does not exist so use default. |
|
2009 | + return apply_filters('default_option_' . $option, false, $option); |
|
2010 | + } |
|
2011 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
2012 | + return EE_Core_Config::$ee_ueip_option; |
|
2013 | + } |
|
2014 | + |
|
2015 | + |
|
2016 | + |
|
2017 | + /** |
|
2018 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
2019 | + * on the object. |
|
2020 | + * |
|
2021 | + * @return array |
|
2022 | + */ |
|
2023 | + public function __sleep() |
|
2024 | + { |
|
2025 | + //reset all url properties |
|
2026 | + $this->_reset_urls(); |
|
2027 | + //return what to save to db |
|
2028 | + return array_keys(get_object_vars($this)); |
|
2029 | + } |
|
2428 | 2030 | |
2429 | - /** |
|
2430 | - * ReCaptcha width |
|
2431 | - * |
|
2432 | - * @var int $recaptcha_width |
|
2433 | - * @deprecated |
|
2434 | - */ |
|
2435 | - public $recaptcha_width; |
|
2031 | +} |
|
2436 | 2032 | |
2437 | - /** |
|
2438 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2439 | - * |
|
2440 | - * @var boolean $track_invalid_checkout_access |
|
2441 | - */ |
|
2442 | - protected $track_invalid_checkout_access = true; |
|
2443 | 2033 | |
2444 | 2034 | |
2035 | +/** |
|
2036 | + * Config class for storing info on the Organization |
|
2037 | + */ |
|
2038 | +class EE_Organization_Config extends EE_Config_Base |
|
2039 | +{ |
|
2445 | 2040 | |
2446 | - /** |
|
2447 | - * class constructor |
|
2448 | - * |
|
2449 | - * @access public |
|
2450 | - */ |
|
2451 | - public function __construct() |
|
2452 | - { |
|
2453 | - // set default registration settings |
|
2454 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2455 | - $this->email_validation_level = 'wp_default'; |
|
2456 | - $this->show_pending_payment_options = true; |
|
2457 | - $this->skip_reg_confirmation = false; |
|
2458 | - $this->reg_steps = array(); |
|
2459 | - $this->reg_confirmation_last = false; |
|
2460 | - $this->use_bot_trap = true; |
|
2461 | - $this->use_encryption = true; |
|
2462 | - $this->use_captcha = false; |
|
2463 | - $this->recaptcha_theme = 'light'; |
|
2464 | - $this->recaptcha_type = 'image'; |
|
2465 | - $this->recaptcha_language = 'en'; |
|
2466 | - $this->recaptcha_publickey = null; |
|
2467 | - $this->recaptcha_privatekey = null; |
|
2468 | - $this->recaptcha_width = 500; |
|
2469 | - } |
|
2470 | - |
|
2471 | - |
|
2472 | - |
|
2473 | - /** |
|
2474 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2475 | - * |
|
2476 | - * @since 4.8.8.rc.019 |
|
2477 | - */ |
|
2478 | - public function do_hooks() |
|
2479 | - { |
|
2480 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2481 | - } |
|
2041 | + /** |
|
2042 | + * @var string $name |
|
2043 | + * eg EE4.1 |
|
2044 | + */ |
|
2045 | + public $name; |
|
2046 | + |
|
2047 | + /** |
|
2048 | + * @var string $address_1 |
|
2049 | + * eg 123 Onna Road |
|
2050 | + */ |
|
2051 | + public $address_1; |
|
2052 | + |
|
2053 | + /** |
|
2054 | + * @var string $address_2 |
|
2055 | + * eg PO Box 123 |
|
2056 | + */ |
|
2057 | + public $address_2; |
|
2058 | + |
|
2059 | + /** |
|
2060 | + * @var string $city |
|
2061 | + * eg Inna City |
|
2062 | + */ |
|
2063 | + public $city; |
|
2064 | + |
|
2065 | + /** |
|
2066 | + * @var int $STA_ID |
|
2067 | + * eg 4 |
|
2068 | + */ |
|
2069 | + public $STA_ID; |
|
2070 | + |
|
2071 | + /** |
|
2072 | + * @var string $CNT_ISO |
|
2073 | + * eg US |
|
2074 | + */ |
|
2075 | + public $CNT_ISO; |
|
2076 | + |
|
2077 | + /** |
|
2078 | + * @var string $zip |
|
2079 | + * eg 12345 or V1A 2B3 |
|
2080 | + */ |
|
2081 | + public $zip; |
|
2082 | + |
|
2083 | + /** |
|
2084 | + * @var string $email |
|
2085 | + * eg [email protected] |
|
2086 | + */ |
|
2087 | + public $email; |
|
2088 | + |
|
2089 | + |
|
2090 | + /** |
|
2091 | + * @var string $phone |
|
2092 | + * eg. 111-111-1111 |
|
2093 | + */ |
|
2094 | + public $phone; |
|
2095 | + |
|
2096 | + |
|
2097 | + /** |
|
2098 | + * @var string $vat |
|
2099 | + * VAT/Tax Number |
|
2100 | + */ |
|
2101 | + public $vat; |
|
2102 | + |
|
2103 | + /** |
|
2104 | + * @var string $logo_url |
|
2105 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
2106 | + */ |
|
2107 | + public $logo_url; |
|
2108 | + |
|
2109 | + |
|
2110 | + /** |
|
2111 | + * The below are all various properties for holding links to organization social network profiles |
|
2112 | + * |
|
2113 | + * @var string |
|
2114 | + */ |
|
2115 | + /** |
|
2116 | + * facebook (facebook.com/profile.name) |
|
2117 | + * |
|
2118 | + * @var string |
|
2119 | + */ |
|
2120 | + public $facebook; |
|
2121 | + |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * twitter (twitter.com/twitter_handle) |
|
2125 | + * |
|
2126 | + * @var string |
|
2127 | + */ |
|
2128 | + public $twitter; |
|
2129 | + |
|
2130 | + |
|
2131 | + /** |
|
2132 | + * linkedin (linkedin.com/in/profile_name) |
|
2133 | + * |
|
2134 | + * @var string |
|
2135 | + */ |
|
2136 | + public $linkedin; |
|
2137 | + |
|
2138 | + |
|
2139 | + /** |
|
2140 | + * pinterest (www.pinterest.com/profile_name) |
|
2141 | + * |
|
2142 | + * @var string |
|
2143 | + */ |
|
2144 | + public $pinterest; |
|
2145 | + |
|
2146 | + |
|
2147 | + /** |
|
2148 | + * google+ (google.com/+profileName) |
|
2149 | + * |
|
2150 | + * @var string |
|
2151 | + */ |
|
2152 | + public $google; |
|
2153 | + |
|
2154 | + |
|
2155 | + /** |
|
2156 | + * instagram (instagram.com/handle) |
|
2157 | + * |
|
2158 | + * @var string |
|
2159 | + */ |
|
2160 | + public $instagram; |
|
2161 | + |
|
2162 | + |
|
2163 | + |
|
2164 | + /** |
|
2165 | + * class constructor |
|
2166 | + * |
|
2167 | + * @access public |
|
2168 | + */ |
|
2169 | + public function __construct() |
|
2170 | + { |
|
2171 | + // set default organization settings |
|
2172 | + $this->name = get_bloginfo('name'); |
|
2173 | + $this->address_1 = '123 Onna Road'; |
|
2174 | + $this->address_2 = 'PO Box 123'; |
|
2175 | + $this->city = 'Inna City'; |
|
2176 | + $this->STA_ID = 4; |
|
2177 | + $this->CNT_ISO = 'US'; |
|
2178 | + $this->zip = '12345'; |
|
2179 | + $this->email = get_bloginfo('admin_email'); |
|
2180 | + $this->phone = ''; |
|
2181 | + $this->vat = '123456789'; |
|
2182 | + $this->logo_url = ''; |
|
2183 | + $this->facebook = ''; |
|
2184 | + $this->twitter = ''; |
|
2185 | + $this->linkedin = ''; |
|
2186 | + $this->pinterest = ''; |
|
2187 | + $this->google = ''; |
|
2188 | + $this->instagram = ''; |
|
2189 | + } |
|
2482 | 2190 | |
2191 | +} |
|
2483 | 2192 | |
2484 | 2193 | |
2485 | - /** |
|
2486 | - * @return void |
|
2487 | - */ |
|
2488 | - public function set_default_reg_status_on_EEM_Event() |
|
2489 | - { |
|
2490 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2491 | - } |
|
2492 | 2194 | |
2195 | +/** |
|
2196 | + * Class for defining what's in the EE_Config relating to currency |
|
2197 | + */ |
|
2198 | +class EE_Currency_Config extends EE_Config_Base |
|
2199 | +{ |
|
2493 | 2200 | |
2201 | + /** |
|
2202 | + * @var string $code |
|
2203 | + * eg 'US' |
|
2204 | + */ |
|
2205 | + public $code; |
|
2206 | + |
|
2207 | + /** |
|
2208 | + * @var string $name |
|
2209 | + * eg 'Dollar' |
|
2210 | + */ |
|
2211 | + public $name; |
|
2212 | + |
|
2213 | + /** |
|
2214 | + * plural name |
|
2215 | + * |
|
2216 | + * @var string $plural |
|
2217 | + * eg 'Dollars' |
|
2218 | + */ |
|
2219 | + public $plural; |
|
2220 | + |
|
2221 | + /** |
|
2222 | + * currency sign |
|
2223 | + * |
|
2224 | + * @var string $sign |
|
2225 | + * eg '$' |
|
2226 | + */ |
|
2227 | + public $sign; |
|
2228 | + |
|
2229 | + /** |
|
2230 | + * Whether the currency sign should come before the number or not |
|
2231 | + * |
|
2232 | + * @var boolean $sign_b4 |
|
2233 | + */ |
|
2234 | + public $sign_b4; |
|
2235 | + |
|
2236 | + /** |
|
2237 | + * How many digits should come after the decimal place |
|
2238 | + * |
|
2239 | + * @var int $dec_plc |
|
2240 | + */ |
|
2241 | + public $dec_plc; |
|
2242 | + |
|
2243 | + /** |
|
2244 | + * Symbol to use for decimal mark |
|
2245 | + * |
|
2246 | + * @var string $dec_mrk |
|
2247 | + * eg '.' |
|
2248 | + */ |
|
2249 | + public $dec_mrk; |
|
2250 | + |
|
2251 | + /** |
|
2252 | + * Symbol to use for thousands |
|
2253 | + * |
|
2254 | + * @var string $thsnds |
|
2255 | + * eg ',' |
|
2256 | + */ |
|
2257 | + public $thsnds; |
|
2258 | + |
|
2259 | + |
|
2260 | + |
|
2261 | + /** |
|
2262 | + * class constructor |
|
2263 | + * |
|
2264 | + * @access public |
|
2265 | + * @param string $CNT_ISO |
|
2266 | + * @throws \EE_Error |
|
2267 | + */ |
|
2268 | + public function __construct($CNT_ISO = '') |
|
2269 | + { |
|
2270 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
2271 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
2272 | + // get country code from organization settings or use default |
|
2273 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2274 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2275 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
2276 | + : ''; |
|
2277 | + // but override if requested |
|
2278 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2279 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
2280 | + if ( |
|
2281 | + ! empty($CNT_ISO) |
|
2282 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
2283 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
2284 | + ) { |
|
2285 | + // retrieve the country settings from the db, just in case they have been customized |
|
2286 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2287 | + if ($country instanceof EE_Country) { |
|
2288 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2289 | + $this->name = $country->currency_name_single(); // Dollar |
|
2290 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2291 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2292 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2293 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2294 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2295 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2296 | + } |
|
2297 | + } |
|
2298 | + // fallback to hardcoded defaults, in case the above failed |
|
2299 | + if (empty($this->code)) { |
|
2300 | + // set default currency settings |
|
2301 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2302 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2303 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2304 | + $this->sign = '$'; // currency sign: $ |
|
2305 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2306 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2307 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2308 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2309 | + } |
|
2310 | + } |
|
2311 | +} |
|
2494 | 2312 | |
2495 | - /** |
|
2496 | - * @return boolean |
|
2497 | - */ |
|
2498 | - public function track_invalid_checkout_access() |
|
2499 | - { |
|
2500 | - return $this->track_invalid_checkout_access; |
|
2501 | - } |
|
2502 | 2313 | |
2503 | 2314 | |
2315 | +/** |
|
2316 | + * Class for defining what's in the EE_Config relating to registration settings |
|
2317 | + */ |
|
2318 | +class EE_Registration_Config extends EE_Config_Base |
|
2319 | +{ |
|
2504 | 2320 | |
2505 | - /** |
|
2506 | - * @param boolean $track_invalid_checkout_access |
|
2507 | - */ |
|
2508 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2509 | - { |
|
2510 | - $this->track_invalid_checkout_access = filter_var( |
|
2511 | - $track_invalid_checkout_access, |
|
2512 | - FILTER_VALIDATE_BOOLEAN |
|
2513 | - ); |
|
2514 | - } |
|
2321 | + /** |
|
2322 | + * Default registration status |
|
2323 | + * |
|
2324 | + * @var string $default_STS_ID |
|
2325 | + * eg 'RPP' |
|
2326 | + */ |
|
2327 | + public $default_STS_ID; |
|
2328 | + |
|
2329 | + /** |
|
2330 | + * level of validation to apply to email addresses |
|
2331 | + * |
|
2332 | + * @var string $email_validation_level |
|
2333 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
2334 | + */ |
|
2335 | + public $email_validation_level; |
|
2336 | + |
|
2337 | + /** |
|
2338 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
2339 | + * |
|
2340 | + * @var boolean $show_pending_payment_options |
|
2341 | + */ |
|
2342 | + public $show_pending_payment_options; |
|
2343 | + |
|
2344 | + /** |
|
2345 | + * Whether to skip the registration confirmation page |
|
2346 | + * |
|
2347 | + * @var boolean $skip_reg_confirmation |
|
2348 | + */ |
|
2349 | + public $skip_reg_confirmation; |
|
2350 | + |
|
2351 | + /** |
|
2352 | + * an array of SPCO reg steps where: |
|
2353 | + * the keys denotes the reg step order |
|
2354 | + * each element consists of an array with the following elements: |
|
2355 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
2356 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
2357 | + * "slug" => the URL param used to trigger the reg step |
|
2358 | + * |
|
2359 | + * @var array $reg_steps |
|
2360 | + */ |
|
2361 | + public $reg_steps; |
|
2362 | + |
|
2363 | + /** |
|
2364 | + * Whether registration confirmation should be the last page of SPCO |
|
2365 | + * |
|
2366 | + * @var boolean $reg_confirmation_last |
|
2367 | + */ |
|
2368 | + public $reg_confirmation_last; |
|
2369 | + |
|
2370 | + /** |
|
2371 | + * Whether or not to enable the EE Bot Trap |
|
2372 | + * |
|
2373 | + * @var boolean $use_bot_trap |
|
2374 | + */ |
|
2375 | + public $use_bot_trap; |
|
2376 | + |
|
2377 | + /** |
|
2378 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
2379 | + * |
|
2380 | + * @var boolean $use_encryption |
|
2381 | + */ |
|
2382 | + public $use_encryption; |
|
2383 | + |
|
2384 | + /** |
|
2385 | + * Whether or not to use ReCaptcha |
|
2386 | + * |
|
2387 | + * @var boolean $use_captcha |
|
2388 | + */ |
|
2389 | + public $use_captcha; |
|
2390 | + |
|
2391 | + /** |
|
2392 | + * ReCaptcha Theme |
|
2393 | + * |
|
2394 | + * @var string $recaptcha_theme |
|
2395 | + * options: 'dark ', 'light' |
|
2396 | + */ |
|
2397 | + public $recaptcha_theme; |
|
2398 | + |
|
2399 | + /** |
|
2400 | + * ReCaptcha Type |
|
2401 | + * |
|
2402 | + * @var string $recaptcha_type |
|
2403 | + * options: 'audio', 'image' |
|
2404 | + */ |
|
2405 | + public $recaptcha_type; |
|
2406 | + |
|
2407 | + /** |
|
2408 | + * ReCaptcha language |
|
2409 | + * |
|
2410 | + * @var string $recaptcha_language |
|
2411 | + * eg 'en' |
|
2412 | + */ |
|
2413 | + public $recaptcha_language; |
|
2414 | + |
|
2415 | + /** |
|
2416 | + * ReCaptcha public key |
|
2417 | + * |
|
2418 | + * @var string $recaptcha_publickey |
|
2419 | + */ |
|
2420 | + public $recaptcha_publickey; |
|
2421 | + |
|
2422 | + /** |
|
2423 | + * ReCaptcha private key |
|
2424 | + * |
|
2425 | + * @var string $recaptcha_privatekey |
|
2426 | + */ |
|
2427 | + public $recaptcha_privatekey; |
|
2428 | + |
|
2429 | + /** |
|
2430 | + * ReCaptcha width |
|
2431 | + * |
|
2432 | + * @var int $recaptcha_width |
|
2433 | + * @deprecated |
|
2434 | + */ |
|
2435 | + public $recaptcha_width; |
|
2436 | + |
|
2437 | + /** |
|
2438 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
2439 | + * |
|
2440 | + * @var boolean $track_invalid_checkout_access |
|
2441 | + */ |
|
2442 | + protected $track_invalid_checkout_access = true; |
|
2443 | + |
|
2444 | + |
|
2445 | + |
|
2446 | + /** |
|
2447 | + * class constructor |
|
2448 | + * |
|
2449 | + * @access public |
|
2450 | + */ |
|
2451 | + public function __construct() |
|
2452 | + { |
|
2453 | + // set default registration settings |
|
2454 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
2455 | + $this->email_validation_level = 'wp_default'; |
|
2456 | + $this->show_pending_payment_options = true; |
|
2457 | + $this->skip_reg_confirmation = false; |
|
2458 | + $this->reg_steps = array(); |
|
2459 | + $this->reg_confirmation_last = false; |
|
2460 | + $this->use_bot_trap = true; |
|
2461 | + $this->use_encryption = true; |
|
2462 | + $this->use_captcha = false; |
|
2463 | + $this->recaptcha_theme = 'light'; |
|
2464 | + $this->recaptcha_type = 'image'; |
|
2465 | + $this->recaptcha_language = 'en'; |
|
2466 | + $this->recaptcha_publickey = null; |
|
2467 | + $this->recaptcha_privatekey = null; |
|
2468 | + $this->recaptcha_width = 500; |
|
2469 | + } |
|
2470 | + |
|
2471 | + |
|
2472 | + |
|
2473 | + /** |
|
2474 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
2475 | + * |
|
2476 | + * @since 4.8.8.rc.019 |
|
2477 | + */ |
|
2478 | + public function do_hooks() |
|
2479 | + { |
|
2480 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2481 | + } |
|
2482 | + |
|
2483 | + |
|
2484 | + |
|
2485 | + /** |
|
2486 | + * @return void |
|
2487 | + */ |
|
2488 | + public function set_default_reg_status_on_EEM_Event() |
|
2489 | + { |
|
2490 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2491 | + } |
|
2492 | + |
|
2493 | + |
|
2494 | + |
|
2495 | + /** |
|
2496 | + * @return boolean |
|
2497 | + */ |
|
2498 | + public function track_invalid_checkout_access() |
|
2499 | + { |
|
2500 | + return $this->track_invalid_checkout_access; |
|
2501 | + } |
|
2502 | + |
|
2503 | + |
|
2504 | + |
|
2505 | + /** |
|
2506 | + * @param boolean $track_invalid_checkout_access |
|
2507 | + */ |
|
2508 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
2509 | + { |
|
2510 | + $this->track_invalid_checkout_access = filter_var( |
|
2511 | + $track_invalid_checkout_access, |
|
2512 | + FILTER_VALIDATE_BOOLEAN |
|
2513 | + ); |
|
2514 | + } |
|
2515 | 2515 | |
2516 | 2516 | |
2517 | 2517 | } |
@@ -2524,160 +2524,160 @@ discard block |
||
2524 | 2524 | class EE_Admin_Config extends EE_Config_Base |
2525 | 2525 | { |
2526 | 2526 | |
2527 | - /** |
|
2528 | - * @var boolean $use_personnel_manager |
|
2529 | - */ |
|
2530 | - public $use_personnel_manager; |
|
2531 | - |
|
2532 | - /** |
|
2533 | - * @var boolean $use_dashboard_widget |
|
2534 | - */ |
|
2535 | - public $use_dashboard_widget; |
|
2536 | - |
|
2537 | - /** |
|
2538 | - * @var int $events_in_dashboard |
|
2539 | - */ |
|
2540 | - public $events_in_dashboard; |
|
2541 | - |
|
2542 | - /** |
|
2543 | - * @var boolean $use_event_timezones |
|
2544 | - */ |
|
2545 | - public $use_event_timezones; |
|
2546 | - |
|
2547 | - /** |
|
2548 | - * @var boolean $use_full_logging |
|
2549 | - */ |
|
2550 | - public $use_full_logging; |
|
2551 | - |
|
2552 | - /** |
|
2553 | - * @var string $log_file_name |
|
2554 | - */ |
|
2555 | - public $log_file_name; |
|
2556 | - |
|
2557 | - /** |
|
2558 | - * @var string $debug_file_name |
|
2559 | - */ |
|
2560 | - public $debug_file_name; |
|
2561 | - |
|
2562 | - /** |
|
2563 | - * @var boolean $use_remote_logging |
|
2564 | - */ |
|
2565 | - public $use_remote_logging; |
|
2566 | - |
|
2567 | - /** |
|
2568 | - * @var string $remote_logging_url |
|
2569 | - */ |
|
2570 | - public $remote_logging_url; |
|
2571 | - |
|
2572 | - /** |
|
2573 | - * @var boolean $show_reg_footer |
|
2574 | - */ |
|
2575 | - public $show_reg_footer; |
|
2576 | - |
|
2577 | - /** |
|
2578 | - * @var string $affiliate_id |
|
2579 | - */ |
|
2580 | - public $affiliate_id; |
|
2581 | - |
|
2582 | - /** |
|
2583 | - * help tours on or off (global setting) |
|
2584 | - * |
|
2585 | - * @var boolean |
|
2586 | - */ |
|
2587 | - public $help_tour_activation; |
|
2588 | - |
|
2589 | - /** |
|
2590 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2591 | - * but is incompatible with some server configuration errors |
|
2592 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2593 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2594 | - * |
|
2595 | - * @var boolean $encode_session_data |
|
2596 | - */ |
|
2597 | - private $encode_session_data = false; |
|
2598 | - |
|
2599 | - |
|
2600 | - |
|
2601 | - /** |
|
2602 | - * class constructor |
|
2603 | - * |
|
2604 | - * @access public |
|
2605 | - */ |
|
2606 | - public function __construct() |
|
2607 | - { |
|
2608 | - // set default general admin settings |
|
2609 | - $this->use_personnel_manager = true; |
|
2610 | - $this->use_dashboard_widget = true; |
|
2611 | - $this->events_in_dashboard = 30; |
|
2612 | - $this->use_event_timezones = false; |
|
2613 | - $this->use_full_logging = false; |
|
2614 | - $this->use_remote_logging = false; |
|
2615 | - $this->remote_logging_url = null; |
|
2616 | - $this->show_reg_footer = true; |
|
2617 | - $this->affiliate_id = 'default'; |
|
2618 | - $this->help_tour_activation = true; |
|
2619 | - $this->encode_session_data = false; |
|
2620 | - } |
|
2621 | - |
|
2622 | - |
|
2623 | - |
|
2624 | - /** |
|
2625 | - * @param bool $reset |
|
2626 | - * @return string |
|
2627 | - */ |
|
2628 | - public function log_file_name($reset = false) |
|
2629 | - { |
|
2630 | - if (empty($this->log_file_name) || $reset) { |
|
2631 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2632 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2633 | - } |
|
2634 | - return $this->log_file_name; |
|
2635 | - } |
|
2636 | - |
|
2637 | - |
|
2638 | - |
|
2639 | - /** |
|
2640 | - * @param bool $reset |
|
2641 | - * @return string |
|
2642 | - */ |
|
2643 | - public function debug_file_name($reset = false) |
|
2644 | - { |
|
2645 | - if (empty($this->debug_file_name) || $reset) { |
|
2646 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2647 | - EE_Config::instance()->update_espresso_config(false, false); |
|
2648 | - } |
|
2649 | - return $this->debug_file_name; |
|
2650 | - } |
|
2651 | - |
|
2652 | - |
|
2653 | - |
|
2654 | - /** |
|
2655 | - * @return string |
|
2656 | - */ |
|
2657 | - public function affiliate_id() |
|
2658 | - { |
|
2659 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2660 | - } |
|
2661 | - |
|
2662 | - |
|
2663 | - |
|
2664 | - /** |
|
2665 | - * @return boolean |
|
2666 | - */ |
|
2667 | - public function encode_session_data() |
|
2668 | - { |
|
2669 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2670 | - } |
|
2671 | - |
|
2672 | - |
|
2673 | - |
|
2674 | - /** |
|
2675 | - * @param boolean $encode_session_data |
|
2676 | - */ |
|
2677 | - public function set_encode_session_data($encode_session_data) |
|
2678 | - { |
|
2679 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2680 | - } |
|
2527 | + /** |
|
2528 | + * @var boolean $use_personnel_manager |
|
2529 | + */ |
|
2530 | + public $use_personnel_manager; |
|
2531 | + |
|
2532 | + /** |
|
2533 | + * @var boolean $use_dashboard_widget |
|
2534 | + */ |
|
2535 | + public $use_dashboard_widget; |
|
2536 | + |
|
2537 | + /** |
|
2538 | + * @var int $events_in_dashboard |
|
2539 | + */ |
|
2540 | + public $events_in_dashboard; |
|
2541 | + |
|
2542 | + /** |
|
2543 | + * @var boolean $use_event_timezones |
|
2544 | + */ |
|
2545 | + public $use_event_timezones; |
|
2546 | + |
|
2547 | + /** |
|
2548 | + * @var boolean $use_full_logging |
|
2549 | + */ |
|
2550 | + public $use_full_logging; |
|
2551 | + |
|
2552 | + /** |
|
2553 | + * @var string $log_file_name |
|
2554 | + */ |
|
2555 | + public $log_file_name; |
|
2556 | + |
|
2557 | + /** |
|
2558 | + * @var string $debug_file_name |
|
2559 | + */ |
|
2560 | + public $debug_file_name; |
|
2561 | + |
|
2562 | + /** |
|
2563 | + * @var boolean $use_remote_logging |
|
2564 | + */ |
|
2565 | + public $use_remote_logging; |
|
2566 | + |
|
2567 | + /** |
|
2568 | + * @var string $remote_logging_url |
|
2569 | + */ |
|
2570 | + public $remote_logging_url; |
|
2571 | + |
|
2572 | + /** |
|
2573 | + * @var boolean $show_reg_footer |
|
2574 | + */ |
|
2575 | + public $show_reg_footer; |
|
2576 | + |
|
2577 | + /** |
|
2578 | + * @var string $affiliate_id |
|
2579 | + */ |
|
2580 | + public $affiliate_id; |
|
2581 | + |
|
2582 | + /** |
|
2583 | + * help tours on or off (global setting) |
|
2584 | + * |
|
2585 | + * @var boolean |
|
2586 | + */ |
|
2587 | + public $help_tour_activation; |
|
2588 | + |
|
2589 | + /** |
|
2590 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2591 | + * but is incompatible with some server configuration errors |
|
2592 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2593 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2594 | + * |
|
2595 | + * @var boolean $encode_session_data |
|
2596 | + */ |
|
2597 | + private $encode_session_data = false; |
|
2598 | + |
|
2599 | + |
|
2600 | + |
|
2601 | + /** |
|
2602 | + * class constructor |
|
2603 | + * |
|
2604 | + * @access public |
|
2605 | + */ |
|
2606 | + public function __construct() |
|
2607 | + { |
|
2608 | + // set default general admin settings |
|
2609 | + $this->use_personnel_manager = true; |
|
2610 | + $this->use_dashboard_widget = true; |
|
2611 | + $this->events_in_dashboard = 30; |
|
2612 | + $this->use_event_timezones = false; |
|
2613 | + $this->use_full_logging = false; |
|
2614 | + $this->use_remote_logging = false; |
|
2615 | + $this->remote_logging_url = null; |
|
2616 | + $this->show_reg_footer = true; |
|
2617 | + $this->affiliate_id = 'default'; |
|
2618 | + $this->help_tour_activation = true; |
|
2619 | + $this->encode_session_data = false; |
|
2620 | + } |
|
2621 | + |
|
2622 | + |
|
2623 | + |
|
2624 | + /** |
|
2625 | + * @param bool $reset |
|
2626 | + * @return string |
|
2627 | + */ |
|
2628 | + public function log_file_name($reset = false) |
|
2629 | + { |
|
2630 | + if (empty($this->log_file_name) || $reset) { |
|
2631 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2632 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2633 | + } |
|
2634 | + return $this->log_file_name; |
|
2635 | + } |
|
2636 | + |
|
2637 | + |
|
2638 | + |
|
2639 | + /** |
|
2640 | + * @param bool $reset |
|
2641 | + * @return string |
|
2642 | + */ |
|
2643 | + public function debug_file_name($reset = false) |
|
2644 | + { |
|
2645 | + if (empty($this->debug_file_name) || $reset) { |
|
2646 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2647 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2648 | + } |
|
2649 | + return $this->debug_file_name; |
|
2650 | + } |
|
2651 | + |
|
2652 | + |
|
2653 | + |
|
2654 | + /** |
|
2655 | + * @return string |
|
2656 | + */ |
|
2657 | + public function affiliate_id() |
|
2658 | + { |
|
2659 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
2660 | + } |
|
2661 | + |
|
2662 | + |
|
2663 | + |
|
2664 | + /** |
|
2665 | + * @return boolean |
|
2666 | + */ |
|
2667 | + public function encode_session_data() |
|
2668 | + { |
|
2669 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2670 | + } |
|
2671 | + |
|
2672 | + |
|
2673 | + |
|
2674 | + /** |
|
2675 | + * @param boolean $encode_session_data |
|
2676 | + */ |
|
2677 | + public function set_encode_session_data($encode_session_data) |
|
2678 | + { |
|
2679 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
2680 | + } |
|
2681 | 2681 | |
2682 | 2682 | |
2683 | 2683 | } |
@@ -2690,71 +2690,71 @@ discard block |
||
2690 | 2690 | class EE_Template_Config extends EE_Config_Base |
2691 | 2691 | { |
2692 | 2692 | |
2693 | - /** |
|
2694 | - * @var boolean $enable_default_style |
|
2695 | - */ |
|
2696 | - public $enable_default_style; |
|
2697 | - |
|
2698 | - /** |
|
2699 | - * @var string $custom_style_sheet |
|
2700 | - */ |
|
2701 | - public $custom_style_sheet; |
|
2702 | - |
|
2703 | - /** |
|
2704 | - * @var boolean $display_address_in_regform |
|
2705 | - */ |
|
2706 | - public $display_address_in_regform; |
|
2707 | - |
|
2708 | - /** |
|
2709 | - * @var int $display_description_on_multi_reg_page |
|
2710 | - */ |
|
2711 | - public $display_description_on_multi_reg_page; |
|
2712 | - |
|
2713 | - /** |
|
2714 | - * @var boolean $use_custom_templates |
|
2715 | - */ |
|
2716 | - public $use_custom_templates; |
|
2717 | - |
|
2718 | - /** |
|
2719 | - * @var string $current_espresso_theme |
|
2720 | - */ |
|
2721 | - public $current_espresso_theme; |
|
2722 | - |
|
2723 | - /** |
|
2724 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2725 | - */ |
|
2726 | - public $EED_Ticket_Selector; |
|
2727 | - |
|
2728 | - /** |
|
2729 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2730 | - */ |
|
2731 | - public $EED_Event_Single; |
|
2732 | - |
|
2733 | - /** |
|
2734 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2735 | - */ |
|
2736 | - public $EED_Events_Archive; |
|
2737 | - |
|
2738 | - |
|
2739 | - |
|
2740 | - /** |
|
2741 | - * class constructor |
|
2742 | - * |
|
2743 | - * @access public |
|
2744 | - */ |
|
2745 | - public function __construct() |
|
2746 | - { |
|
2747 | - // set default template settings |
|
2748 | - $this->enable_default_style = true; |
|
2749 | - $this->custom_style_sheet = null; |
|
2750 | - $this->display_address_in_regform = true; |
|
2751 | - $this->display_description_on_multi_reg_page = false; |
|
2752 | - $this->use_custom_templates = false; |
|
2753 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2754 | - $this->EED_Event_Single = null; |
|
2755 | - $this->EED_Events_Archive = null; |
|
2756 | - $this->EED_Ticket_Selector = null; |
|
2757 | - } |
|
2693 | + /** |
|
2694 | + * @var boolean $enable_default_style |
|
2695 | + */ |
|
2696 | + public $enable_default_style; |
|
2697 | + |
|
2698 | + /** |
|
2699 | + * @var string $custom_style_sheet |
|
2700 | + */ |
|
2701 | + public $custom_style_sheet; |
|
2702 | + |
|
2703 | + /** |
|
2704 | + * @var boolean $display_address_in_regform |
|
2705 | + */ |
|
2706 | + public $display_address_in_regform; |
|
2707 | + |
|
2708 | + /** |
|
2709 | + * @var int $display_description_on_multi_reg_page |
|
2710 | + */ |
|
2711 | + public $display_description_on_multi_reg_page; |
|
2712 | + |
|
2713 | + /** |
|
2714 | + * @var boolean $use_custom_templates |
|
2715 | + */ |
|
2716 | + public $use_custom_templates; |
|
2717 | + |
|
2718 | + /** |
|
2719 | + * @var string $current_espresso_theme |
|
2720 | + */ |
|
2721 | + public $current_espresso_theme; |
|
2722 | + |
|
2723 | + /** |
|
2724 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2725 | + */ |
|
2726 | + public $EED_Ticket_Selector; |
|
2727 | + |
|
2728 | + /** |
|
2729 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2730 | + */ |
|
2731 | + public $EED_Event_Single; |
|
2732 | + |
|
2733 | + /** |
|
2734 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
2735 | + */ |
|
2736 | + public $EED_Events_Archive; |
|
2737 | + |
|
2738 | + |
|
2739 | + |
|
2740 | + /** |
|
2741 | + * class constructor |
|
2742 | + * |
|
2743 | + * @access public |
|
2744 | + */ |
|
2745 | + public function __construct() |
|
2746 | + { |
|
2747 | + // set default template settings |
|
2748 | + $this->enable_default_style = true; |
|
2749 | + $this->custom_style_sheet = null; |
|
2750 | + $this->display_address_in_regform = true; |
|
2751 | + $this->display_description_on_multi_reg_page = false; |
|
2752 | + $this->use_custom_templates = false; |
|
2753 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
2754 | + $this->EED_Event_Single = null; |
|
2755 | + $this->EED_Events_Archive = null; |
|
2756 | + $this->EED_Ticket_Selector = null; |
|
2757 | + } |
|
2758 | 2758 | |
2759 | 2759 | } |
2760 | 2760 | |
@@ -2766,115 +2766,115 @@ discard block |
||
2766 | 2766 | class EE_Map_Config extends EE_Config_Base |
2767 | 2767 | { |
2768 | 2768 | |
2769 | - /** |
|
2770 | - * @var boolean $use_google_maps |
|
2771 | - */ |
|
2772 | - public $use_google_maps; |
|
2773 | - |
|
2774 | - /** |
|
2775 | - * @var string $api_key |
|
2776 | - */ |
|
2777 | - public $google_map_api_key; |
|
2778 | - |
|
2779 | - /** |
|
2780 | - * @var int $event_details_map_width |
|
2781 | - */ |
|
2782 | - public $event_details_map_width; |
|
2783 | - |
|
2784 | - /** |
|
2785 | - * @var int $event_details_map_height |
|
2786 | - */ |
|
2787 | - public $event_details_map_height; |
|
2788 | - |
|
2789 | - /** |
|
2790 | - * @var int $event_details_map_zoom |
|
2791 | - */ |
|
2792 | - public $event_details_map_zoom; |
|
2793 | - |
|
2794 | - /** |
|
2795 | - * @var boolean $event_details_display_nav |
|
2796 | - */ |
|
2797 | - public $event_details_display_nav; |
|
2798 | - |
|
2799 | - /** |
|
2800 | - * @var boolean $event_details_nav_size |
|
2801 | - */ |
|
2802 | - public $event_details_nav_size; |
|
2803 | - |
|
2804 | - /** |
|
2805 | - * @var string $event_details_control_type |
|
2806 | - */ |
|
2807 | - public $event_details_control_type; |
|
2808 | - |
|
2809 | - /** |
|
2810 | - * @var string $event_details_map_align |
|
2811 | - */ |
|
2812 | - public $event_details_map_align; |
|
2813 | - |
|
2814 | - /** |
|
2815 | - * @var int $event_list_map_width |
|
2816 | - */ |
|
2817 | - public $event_list_map_width; |
|
2818 | - |
|
2819 | - /** |
|
2820 | - * @var int $event_list_map_height |
|
2821 | - */ |
|
2822 | - public $event_list_map_height; |
|
2823 | - |
|
2824 | - /** |
|
2825 | - * @var int $event_list_map_zoom |
|
2826 | - */ |
|
2827 | - public $event_list_map_zoom; |
|
2828 | - |
|
2829 | - /** |
|
2830 | - * @var boolean $event_list_display_nav |
|
2831 | - */ |
|
2832 | - public $event_list_display_nav; |
|
2833 | - |
|
2834 | - /** |
|
2835 | - * @var boolean $event_list_nav_size |
|
2836 | - */ |
|
2837 | - public $event_list_nav_size; |
|
2838 | - |
|
2839 | - /** |
|
2840 | - * @var string $event_list_control_type |
|
2841 | - */ |
|
2842 | - public $event_list_control_type; |
|
2843 | - |
|
2844 | - /** |
|
2845 | - * @var string $event_list_map_align |
|
2846 | - */ |
|
2847 | - public $event_list_map_align; |
|
2848 | - |
|
2849 | - |
|
2850 | - |
|
2851 | - /** |
|
2852 | - * class constructor |
|
2853 | - * |
|
2854 | - * @access public |
|
2855 | - */ |
|
2856 | - public function __construct() |
|
2857 | - { |
|
2858 | - // set default map settings |
|
2859 | - $this->use_google_maps = true; |
|
2860 | - $this->google_map_api_key = ''; |
|
2861 | - // for event details pages (reg page) |
|
2862 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2863 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2864 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2865 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2866 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2867 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2868 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2869 | - // for event list pages |
|
2870 | - $this->event_list_map_width = 300; // ee_map_width |
|
2871 | - $this->event_list_map_height = 185; // ee_map_height |
|
2872 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2873 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2874 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2875 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2876 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2877 | - } |
|
2769 | + /** |
|
2770 | + * @var boolean $use_google_maps |
|
2771 | + */ |
|
2772 | + public $use_google_maps; |
|
2773 | + |
|
2774 | + /** |
|
2775 | + * @var string $api_key |
|
2776 | + */ |
|
2777 | + public $google_map_api_key; |
|
2778 | + |
|
2779 | + /** |
|
2780 | + * @var int $event_details_map_width |
|
2781 | + */ |
|
2782 | + public $event_details_map_width; |
|
2783 | + |
|
2784 | + /** |
|
2785 | + * @var int $event_details_map_height |
|
2786 | + */ |
|
2787 | + public $event_details_map_height; |
|
2788 | + |
|
2789 | + /** |
|
2790 | + * @var int $event_details_map_zoom |
|
2791 | + */ |
|
2792 | + public $event_details_map_zoom; |
|
2793 | + |
|
2794 | + /** |
|
2795 | + * @var boolean $event_details_display_nav |
|
2796 | + */ |
|
2797 | + public $event_details_display_nav; |
|
2798 | + |
|
2799 | + /** |
|
2800 | + * @var boolean $event_details_nav_size |
|
2801 | + */ |
|
2802 | + public $event_details_nav_size; |
|
2803 | + |
|
2804 | + /** |
|
2805 | + * @var string $event_details_control_type |
|
2806 | + */ |
|
2807 | + public $event_details_control_type; |
|
2808 | + |
|
2809 | + /** |
|
2810 | + * @var string $event_details_map_align |
|
2811 | + */ |
|
2812 | + public $event_details_map_align; |
|
2813 | + |
|
2814 | + /** |
|
2815 | + * @var int $event_list_map_width |
|
2816 | + */ |
|
2817 | + public $event_list_map_width; |
|
2818 | + |
|
2819 | + /** |
|
2820 | + * @var int $event_list_map_height |
|
2821 | + */ |
|
2822 | + public $event_list_map_height; |
|
2823 | + |
|
2824 | + /** |
|
2825 | + * @var int $event_list_map_zoom |
|
2826 | + */ |
|
2827 | + public $event_list_map_zoom; |
|
2828 | + |
|
2829 | + /** |
|
2830 | + * @var boolean $event_list_display_nav |
|
2831 | + */ |
|
2832 | + public $event_list_display_nav; |
|
2833 | + |
|
2834 | + /** |
|
2835 | + * @var boolean $event_list_nav_size |
|
2836 | + */ |
|
2837 | + public $event_list_nav_size; |
|
2838 | + |
|
2839 | + /** |
|
2840 | + * @var string $event_list_control_type |
|
2841 | + */ |
|
2842 | + public $event_list_control_type; |
|
2843 | + |
|
2844 | + /** |
|
2845 | + * @var string $event_list_map_align |
|
2846 | + */ |
|
2847 | + public $event_list_map_align; |
|
2848 | + |
|
2849 | + |
|
2850 | + |
|
2851 | + /** |
|
2852 | + * class constructor |
|
2853 | + * |
|
2854 | + * @access public |
|
2855 | + */ |
|
2856 | + public function __construct() |
|
2857 | + { |
|
2858 | + // set default map settings |
|
2859 | + $this->use_google_maps = true; |
|
2860 | + $this->google_map_api_key = ''; |
|
2861 | + // for event details pages (reg page) |
|
2862 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2863 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2864 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2865 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2866 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2867 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2868 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2869 | + // for event list pages |
|
2870 | + $this->event_list_map_width = 300; // ee_map_width |
|
2871 | + $this->event_list_map_height = 185; // ee_map_height |
|
2872 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2873 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2874 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2875 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2876 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2877 | + } |
|
2878 | 2878 | |
2879 | 2879 | } |
2880 | 2880 | |
@@ -2886,47 +2886,47 @@ discard block |
||
2886 | 2886 | class EE_Events_Archive_Config extends EE_Config_Base |
2887 | 2887 | { |
2888 | 2888 | |
2889 | - public $display_status_banner; |
|
2889 | + public $display_status_banner; |
|
2890 | 2890 | |
2891 | - public $display_description; |
|
2891 | + public $display_description; |
|
2892 | 2892 | |
2893 | - public $display_ticket_selector; |
|
2893 | + public $display_ticket_selector; |
|
2894 | 2894 | |
2895 | - public $display_datetimes; |
|
2895 | + public $display_datetimes; |
|
2896 | 2896 | |
2897 | - public $display_venue; |
|
2897 | + public $display_venue; |
|
2898 | 2898 | |
2899 | - public $display_expired_events; |
|
2899 | + public $display_expired_events; |
|
2900 | 2900 | |
2901 | - public $use_sortable_display_order; |
|
2901 | + public $use_sortable_display_order; |
|
2902 | 2902 | |
2903 | - public $display_order_tickets; |
|
2903 | + public $display_order_tickets; |
|
2904 | 2904 | |
2905 | - public $display_order_datetimes; |
|
2905 | + public $display_order_datetimes; |
|
2906 | 2906 | |
2907 | - public $display_order_event; |
|
2907 | + public $display_order_event; |
|
2908 | 2908 | |
2909 | - public $display_order_venue; |
|
2909 | + public $display_order_venue; |
|
2910 | 2910 | |
2911 | 2911 | |
2912 | 2912 | |
2913 | - /** |
|
2914 | - * class constructor |
|
2915 | - */ |
|
2916 | - public function __construct() |
|
2917 | - { |
|
2918 | - $this->display_status_banner = 0; |
|
2919 | - $this->display_description = 1; |
|
2920 | - $this->display_ticket_selector = 0; |
|
2921 | - $this->display_datetimes = 1; |
|
2922 | - $this->display_venue = 0; |
|
2923 | - $this->display_expired_events = 0; |
|
2924 | - $this->use_sortable_display_order = false; |
|
2925 | - $this->display_order_tickets = 100; |
|
2926 | - $this->display_order_datetimes = 110; |
|
2927 | - $this->display_order_event = 120; |
|
2928 | - $this->display_order_venue = 130; |
|
2929 | - } |
|
2913 | + /** |
|
2914 | + * class constructor |
|
2915 | + */ |
|
2916 | + public function __construct() |
|
2917 | + { |
|
2918 | + $this->display_status_banner = 0; |
|
2919 | + $this->display_description = 1; |
|
2920 | + $this->display_ticket_selector = 0; |
|
2921 | + $this->display_datetimes = 1; |
|
2922 | + $this->display_venue = 0; |
|
2923 | + $this->display_expired_events = 0; |
|
2924 | + $this->use_sortable_display_order = false; |
|
2925 | + $this->display_order_tickets = 100; |
|
2926 | + $this->display_order_datetimes = 110; |
|
2927 | + $this->display_order_event = 120; |
|
2928 | + $this->display_order_venue = 130; |
|
2929 | + } |
|
2930 | 2930 | } |
2931 | 2931 | |
2932 | 2932 | |
@@ -2937,35 +2937,35 @@ discard block |
||
2937 | 2937 | class EE_Event_Single_Config extends EE_Config_Base |
2938 | 2938 | { |
2939 | 2939 | |
2940 | - public $display_status_banner_single; |
|
2940 | + public $display_status_banner_single; |
|
2941 | 2941 | |
2942 | - public $display_venue; |
|
2942 | + public $display_venue; |
|
2943 | 2943 | |
2944 | - public $use_sortable_display_order; |
|
2944 | + public $use_sortable_display_order; |
|
2945 | 2945 | |
2946 | - public $display_order_tickets; |
|
2946 | + public $display_order_tickets; |
|
2947 | 2947 | |
2948 | - public $display_order_datetimes; |
|
2948 | + public $display_order_datetimes; |
|
2949 | 2949 | |
2950 | - public $display_order_event; |
|
2950 | + public $display_order_event; |
|
2951 | 2951 | |
2952 | - public $display_order_venue; |
|
2952 | + public $display_order_venue; |
|
2953 | 2953 | |
2954 | 2954 | |
2955 | 2955 | |
2956 | - /** |
|
2957 | - * class constructor |
|
2958 | - */ |
|
2959 | - public function __construct() |
|
2960 | - { |
|
2961 | - $this->display_status_banner_single = 0; |
|
2962 | - $this->display_venue = 1; |
|
2963 | - $this->use_sortable_display_order = false; |
|
2964 | - $this->display_order_tickets = 100; |
|
2965 | - $this->display_order_datetimes = 110; |
|
2966 | - $this->display_order_event = 120; |
|
2967 | - $this->display_order_venue = 130; |
|
2968 | - } |
|
2956 | + /** |
|
2957 | + * class constructor |
|
2958 | + */ |
|
2959 | + public function __construct() |
|
2960 | + { |
|
2961 | + $this->display_status_banner_single = 0; |
|
2962 | + $this->display_venue = 1; |
|
2963 | + $this->use_sortable_display_order = false; |
|
2964 | + $this->display_order_tickets = 100; |
|
2965 | + $this->display_order_datetimes = 110; |
|
2966 | + $this->display_order_event = 120; |
|
2967 | + $this->display_order_venue = 130; |
|
2968 | + } |
|
2969 | 2969 | } |
2970 | 2970 | |
2971 | 2971 | |
@@ -2976,151 +2976,151 @@ discard block |
||
2976 | 2976 | class EE_Ticket_Selector_Config extends EE_Config_Base |
2977 | 2977 | { |
2978 | 2978 | |
2979 | - /** |
|
2980 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2981 | - */ |
|
2982 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2983 | - |
|
2984 | - /** |
|
2985 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2986 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2987 | - */ |
|
2988 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2989 | - |
|
2990 | - /** |
|
2991 | - * @var boolean $show_ticket_sale_columns |
|
2992 | - */ |
|
2993 | - public $show_ticket_sale_columns; |
|
2994 | - |
|
2995 | - /** |
|
2996 | - * @var boolean $show_ticket_details |
|
2997 | - */ |
|
2998 | - public $show_ticket_details; |
|
2999 | - |
|
3000 | - /** |
|
3001 | - * @var boolean $show_expired_tickets |
|
3002 | - */ |
|
3003 | - public $show_expired_tickets; |
|
3004 | - |
|
3005 | - /** |
|
3006 | - * whether or not to display a dropdown box populated with event datetimes |
|
3007 | - * that toggles which tickets are displayed for a ticket selector. |
|
3008 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
3009 | - * |
|
3010 | - * @var string $show_datetime_selector |
|
3011 | - */ |
|
3012 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
3013 | - |
|
3014 | - /** |
|
3015 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
3016 | - * |
|
3017 | - * @var int $datetime_selector_threshold |
|
3018 | - */ |
|
3019 | - private $datetime_selector_threshold = 3; |
|
3020 | - |
|
3021 | - |
|
3022 | - |
|
3023 | - /** |
|
3024 | - * class constructor |
|
3025 | - */ |
|
3026 | - public function __construct() |
|
3027 | - { |
|
3028 | - $this->show_ticket_sale_columns = true; |
|
3029 | - $this->show_ticket_details = true; |
|
3030 | - $this->show_expired_tickets = true; |
|
3031 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3032 | - $this->datetime_selector_threshold = 3; |
|
3033 | - } |
|
3034 | - |
|
3035 | - |
|
3036 | - |
|
3037 | - /** |
|
3038 | - * returns true if a datetime selector should be displayed |
|
3039 | - * |
|
3040 | - * @param array $datetimes |
|
3041 | - * @return bool |
|
3042 | - */ |
|
3043 | - public function showDatetimeSelector(array $datetimes) |
|
3044 | - { |
|
3045 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
3046 | - return ! ( |
|
3047 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
3048 | - || ( |
|
3049 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
3050 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
3051 | - ) |
|
3052 | - ); |
|
3053 | - } |
|
3054 | - |
|
3055 | - |
|
3056 | - |
|
3057 | - /** |
|
3058 | - * @return string |
|
3059 | - */ |
|
3060 | - public function getShowDatetimeSelector() |
|
3061 | - { |
|
3062 | - return $this->show_datetime_selector; |
|
3063 | - } |
|
3064 | - |
|
3065 | - |
|
3066 | - |
|
3067 | - /** |
|
3068 | - * @param bool $keys_only |
|
3069 | - * @return array |
|
3070 | - */ |
|
3071 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
3072 | - { |
|
3073 | - return $keys_only |
|
3074 | - ? array( |
|
3075 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
3076 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
3077 | - ) |
|
3078 | - : array( |
|
3079 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3080 | - 'Do not show date & time filter', 'event_espresso' |
|
3081 | - ), |
|
3082 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3083 | - 'Maybe show date & time filter', 'event_espresso' |
|
3084 | - ), |
|
3085 | - ); |
|
3086 | - } |
|
3087 | - |
|
3088 | - |
|
3089 | - |
|
3090 | - /** |
|
3091 | - * @param string $show_datetime_selector |
|
3092 | - */ |
|
3093 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
3094 | - { |
|
3095 | - $this->show_datetime_selector = in_array( |
|
3096 | - $show_datetime_selector, |
|
3097 | - $this->getShowDatetimeSelectorOptions(), |
|
3098 | - true |
|
3099 | - ) |
|
3100 | - ? $show_datetime_selector |
|
3101 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3102 | - } |
|
3103 | - |
|
3104 | - |
|
3105 | - |
|
3106 | - /** |
|
3107 | - * @return int |
|
3108 | - */ |
|
3109 | - public function getDatetimeSelectorThreshold() |
|
3110 | - { |
|
3111 | - return $this->datetime_selector_threshold; |
|
3112 | - } |
|
3113 | - |
|
3114 | - |
|
3115 | - |
|
3116 | - /** |
|
3117 | - * @param int $datetime_selector_threshold |
|
3118 | - */ |
|
3119 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3120 | - { |
|
3121 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3122 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3123 | - } |
|
2979 | + /** |
|
2980 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2981 | + */ |
|
2982 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2983 | + |
|
2984 | + /** |
|
2985 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2986 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2987 | + */ |
|
2988 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2989 | + |
|
2990 | + /** |
|
2991 | + * @var boolean $show_ticket_sale_columns |
|
2992 | + */ |
|
2993 | + public $show_ticket_sale_columns; |
|
2994 | + |
|
2995 | + /** |
|
2996 | + * @var boolean $show_ticket_details |
|
2997 | + */ |
|
2998 | + public $show_ticket_details; |
|
2999 | + |
|
3000 | + /** |
|
3001 | + * @var boolean $show_expired_tickets |
|
3002 | + */ |
|
3003 | + public $show_expired_tickets; |
|
3004 | + |
|
3005 | + /** |
|
3006 | + * whether or not to display a dropdown box populated with event datetimes |
|
3007 | + * that toggles which tickets are displayed for a ticket selector. |
|
3008 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
3009 | + * |
|
3010 | + * @var string $show_datetime_selector |
|
3011 | + */ |
|
3012 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
3013 | + |
|
3014 | + /** |
|
3015 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
3016 | + * |
|
3017 | + * @var int $datetime_selector_threshold |
|
3018 | + */ |
|
3019 | + private $datetime_selector_threshold = 3; |
|
3020 | + |
|
3021 | + |
|
3022 | + |
|
3023 | + /** |
|
3024 | + * class constructor |
|
3025 | + */ |
|
3026 | + public function __construct() |
|
3027 | + { |
|
3028 | + $this->show_ticket_sale_columns = true; |
|
3029 | + $this->show_ticket_details = true; |
|
3030 | + $this->show_expired_tickets = true; |
|
3031 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3032 | + $this->datetime_selector_threshold = 3; |
|
3033 | + } |
|
3034 | + |
|
3035 | + |
|
3036 | + |
|
3037 | + /** |
|
3038 | + * returns true if a datetime selector should be displayed |
|
3039 | + * |
|
3040 | + * @param array $datetimes |
|
3041 | + * @return bool |
|
3042 | + */ |
|
3043 | + public function showDatetimeSelector(array $datetimes) |
|
3044 | + { |
|
3045 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
3046 | + return ! ( |
|
3047 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
3048 | + || ( |
|
3049 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
3050 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
3051 | + ) |
|
3052 | + ); |
|
3053 | + } |
|
3054 | + |
|
3055 | + |
|
3056 | + |
|
3057 | + /** |
|
3058 | + * @return string |
|
3059 | + */ |
|
3060 | + public function getShowDatetimeSelector() |
|
3061 | + { |
|
3062 | + return $this->show_datetime_selector; |
|
3063 | + } |
|
3064 | + |
|
3065 | + |
|
3066 | + |
|
3067 | + /** |
|
3068 | + * @param bool $keys_only |
|
3069 | + * @return array |
|
3070 | + */ |
|
3071 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
3072 | + { |
|
3073 | + return $keys_only |
|
3074 | + ? array( |
|
3075 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
3076 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
3077 | + ) |
|
3078 | + : array( |
|
3079 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3080 | + 'Do not show date & time filter', 'event_espresso' |
|
3081 | + ), |
|
3082 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3083 | + 'Maybe show date & time filter', 'event_espresso' |
|
3084 | + ), |
|
3085 | + ); |
|
3086 | + } |
|
3087 | + |
|
3088 | + |
|
3089 | + |
|
3090 | + /** |
|
3091 | + * @param string $show_datetime_selector |
|
3092 | + */ |
|
3093 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
3094 | + { |
|
3095 | + $this->show_datetime_selector = in_array( |
|
3096 | + $show_datetime_selector, |
|
3097 | + $this->getShowDatetimeSelectorOptions(), |
|
3098 | + true |
|
3099 | + ) |
|
3100 | + ? $show_datetime_selector |
|
3101 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3102 | + } |
|
3103 | + |
|
3104 | + |
|
3105 | + |
|
3106 | + /** |
|
3107 | + * @return int |
|
3108 | + */ |
|
3109 | + public function getDatetimeSelectorThreshold() |
|
3110 | + { |
|
3111 | + return $this->datetime_selector_threshold; |
|
3112 | + } |
|
3113 | + |
|
3114 | + |
|
3115 | + |
|
3116 | + /** |
|
3117 | + * @param int $datetime_selector_threshold |
|
3118 | + */ |
|
3119 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3120 | + { |
|
3121 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3122 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3123 | + } |
|
3124 | 3124 | |
3125 | 3125 | |
3126 | 3126 | } |
@@ -3137,85 +3137,85 @@ discard block |
||
3137 | 3137 | class EE_Environment_Config extends EE_Config_Base |
3138 | 3138 | { |
3139 | 3139 | |
3140 | - /** |
|
3141 | - * Hold any php environment variables that we want to track. |
|
3142 | - * |
|
3143 | - * @var stdClass; |
|
3144 | - */ |
|
3145 | - public $php; |
|
3146 | - |
|
3147 | - |
|
3148 | - |
|
3149 | - /** |
|
3150 | - * constructor |
|
3151 | - */ |
|
3152 | - public function __construct() |
|
3153 | - { |
|
3154 | - $this->php = new stdClass(); |
|
3155 | - $this->_set_php_values(); |
|
3156 | - } |
|
3157 | - |
|
3158 | - |
|
3159 | - |
|
3160 | - /** |
|
3161 | - * This sets the php environment variables. |
|
3162 | - * |
|
3163 | - * @since 4.4.0 |
|
3164 | - * @return void |
|
3165 | - */ |
|
3166 | - protected function _set_php_values() |
|
3167 | - { |
|
3168 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3169 | - $this->php->version = phpversion(); |
|
3170 | - } |
|
3171 | - |
|
3172 | - |
|
3173 | - |
|
3174 | - /** |
|
3175 | - * helper method for determining whether input_count is |
|
3176 | - * reaching the potential maximum the server can handle |
|
3177 | - * according to max_input_vars |
|
3178 | - * |
|
3179 | - * @param int $input_count the count of input vars. |
|
3180 | - * @return array { |
|
3181 | - * An array that represents whether available space and if no available space the error |
|
3182 | - * message. |
|
3183 | - * @type bool $has_space whether more inputs can be added. |
|
3184 | - * @type string $msg Any message to be displayed. |
|
3185 | - * } |
|
3186 | - */ |
|
3187 | - public function max_input_vars_limit_check($input_count = 0) |
|
3188 | - { |
|
3189 | - if ( ! empty($this->php->max_input_vars) |
|
3190 | - && ($input_count >= $this->php->max_input_vars) |
|
3191 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3192 | - ) { |
|
3193 | - return sprintf( |
|
3194 | - __( |
|
3195 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3196 | - 'event_espresso' |
|
3197 | - ), |
|
3198 | - '<br>', |
|
3199 | - $input_count, |
|
3200 | - $this->php->max_input_vars |
|
3201 | - ); |
|
3202 | - } else { |
|
3203 | - return ''; |
|
3204 | - } |
|
3205 | - } |
|
3206 | - |
|
3207 | - |
|
3208 | - |
|
3209 | - /** |
|
3210 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3211 | - * |
|
3212 | - * @since 4.4.1 |
|
3213 | - * @return void |
|
3214 | - */ |
|
3215 | - public function recheck_values() |
|
3216 | - { |
|
3217 | - $this->_set_php_values(); |
|
3218 | - } |
|
3140 | + /** |
|
3141 | + * Hold any php environment variables that we want to track. |
|
3142 | + * |
|
3143 | + * @var stdClass; |
|
3144 | + */ |
|
3145 | + public $php; |
|
3146 | + |
|
3147 | + |
|
3148 | + |
|
3149 | + /** |
|
3150 | + * constructor |
|
3151 | + */ |
|
3152 | + public function __construct() |
|
3153 | + { |
|
3154 | + $this->php = new stdClass(); |
|
3155 | + $this->_set_php_values(); |
|
3156 | + } |
|
3157 | + |
|
3158 | + |
|
3159 | + |
|
3160 | + /** |
|
3161 | + * This sets the php environment variables. |
|
3162 | + * |
|
3163 | + * @since 4.4.0 |
|
3164 | + * @return void |
|
3165 | + */ |
|
3166 | + protected function _set_php_values() |
|
3167 | + { |
|
3168 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
3169 | + $this->php->version = phpversion(); |
|
3170 | + } |
|
3171 | + |
|
3172 | + |
|
3173 | + |
|
3174 | + /** |
|
3175 | + * helper method for determining whether input_count is |
|
3176 | + * reaching the potential maximum the server can handle |
|
3177 | + * according to max_input_vars |
|
3178 | + * |
|
3179 | + * @param int $input_count the count of input vars. |
|
3180 | + * @return array { |
|
3181 | + * An array that represents whether available space and if no available space the error |
|
3182 | + * message. |
|
3183 | + * @type bool $has_space whether more inputs can be added. |
|
3184 | + * @type string $msg Any message to be displayed. |
|
3185 | + * } |
|
3186 | + */ |
|
3187 | + public function max_input_vars_limit_check($input_count = 0) |
|
3188 | + { |
|
3189 | + if ( ! empty($this->php->max_input_vars) |
|
3190 | + && ($input_count >= $this->php->max_input_vars) |
|
3191 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
3192 | + ) { |
|
3193 | + return sprintf( |
|
3194 | + __( |
|
3195 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
3196 | + 'event_espresso' |
|
3197 | + ), |
|
3198 | + '<br>', |
|
3199 | + $input_count, |
|
3200 | + $this->php->max_input_vars |
|
3201 | + ); |
|
3202 | + } else { |
|
3203 | + return ''; |
|
3204 | + } |
|
3205 | + } |
|
3206 | + |
|
3207 | + |
|
3208 | + |
|
3209 | + /** |
|
3210 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
3211 | + * |
|
3212 | + * @since 4.4.1 |
|
3213 | + * @return void |
|
3214 | + */ |
|
3215 | + public function recheck_values() |
|
3216 | + { |
|
3217 | + $this->_set_php_values(); |
|
3218 | + } |
|
3219 | 3219 | |
3220 | 3220 | |
3221 | 3221 | } |
@@ -3232,22 +3232,22 @@ discard block |
||
3232 | 3232 | class EE_Tax_Config extends EE_Config_Base |
3233 | 3233 | { |
3234 | 3234 | |
3235 | - /* |
|
3235 | + /* |
|
3236 | 3236 | * flag to indicate whether or not to display ticket prices with the taxes included |
3237 | 3237 | * |
3238 | 3238 | * @var boolean $prices_displayed_including_taxes |
3239 | 3239 | */ |
3240 | - public $prices_displayed_including_taxes; |
|
3240 | + public $prices_displayed_including_taxes; |
|
3241 | 3241 | |
3242 | 3242 | |
3243 | 3243 | |
3244 | - /** |
|
3245 | - * class constructor |
|
3246 | - */ |
|
3247 | - public function __construct() |
|
3248 | - { |
|
3249 | - $this->prices_displayed_including_taxes = true; |
|
3250 | - } |
|
3244 | + /** |
|
3245 | + * class constructor |
|
3246 | + */ |
|
3247 | + public function __construct() |
|
3248 | + { |
|
3249 | + $this->prices_displayed_including_taxes = true; |
|
3250 | + } |
|
3251 | 3251 | } |
3252 | 3252 | |
3253 | 3253 | |
@@ -3260,34 +3260,34 @@ discard block |
||
3260 | 3260 | class EE_Gateway_Config extends EE_Config_Base |
3261 | 3261 | { |
3262 | 3262 | |
3263 | - /** |
|
3264 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
3265 | - * with any config info the gateway wants to store |
|
3266 | - * |
|
3267 | - * @var array |
|
3268 | - */ |
|
3269 | - public $payment_settings; |
|
3270 | - |
|
3271 | - /** |
|
3272 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3273 | - * the gateway is stored in the uploads directory |
|
3274 | - * |
|
3275 | - * @var array |
|
3276 | - */ |
|
3277 | - public $active_gateways; |
|
3278 | - |
|
3279 | - |
|
3280 | - |
|
3281 | - /** |
|
3282 | - * class constructor |
|
3283 | - * |
|
3284 | - * @deprecated |
|
3285 | - */ |
|
3286 | - public function __construct() |
|
3287 | - { |
|
3288 | - $this->payment_settings = array(); |
|
3289 | - $this->active_gateways = array('Invoice' => false); |
|
3290 | - } |
|
3263 | + /** |
|
3264 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
3265 | + * with any config info the gateway wants to store |
|
3266 | + * |
|
3267 | + * @var array |
|
3268 | + */ |
|
3269 | + public $payment_settings; |
|
3270 | + |
|
3271 | + /** |
|
3272 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
3273 | + * the gateway is stored in the uploads directory |
|
3274 | + * |
|
3275 | + * @var array |
|
3276 | + */ |
|
3277 | + public $active_gateways; |
|
3278 | + |
|
3279 | + |
|
3280 | + |
|
3281 | + /** |
|
3282 | + * class constructor |
|
3283 | + * |
|
3284 | + * @deprecated |
|
3285 | + */ |
|
3286 | + public function __construct() |
|
3287 | + { |
|
3288 | + $this->payment_settings = array(); |
|
3289 | + $this->active_gateways = array('Invoice' => false); |
|
3290 | + } |
|
3291 | 3291 | } |
3292 | 3292 | |
3293 | 3293 | // End of file EE_Config.core.php |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $this |
279 | 279 | ); |
280 | 280 | if (is_object($settings) && property_exists($this, $config)) { |
281 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
281 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
282 | 282 | //call configs populate method to ensure any defaults are set for empty values. |
283 | 283 | if (method_exists($settings, 'populate')) { |
284 | 284 | $this->{$config}->populate(); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | */ |
688 | 688 | private function _generate_config_option_name($section = '', $name = '') |
689 | 689 | { |
690 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
690 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | { |
706 | 706 | return ! empty($config_class) |
707 | 707 | ? $config_class |
708 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
708 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | 'event_espresso' |
822 | 822 | ), |
823 | 823 | $config_class, |
824 | - 'EE_Config->' . $section . '->' . $name |
|
824 | + 'EE_Config->'.$section.'->'.$name |
|
825 | 825 | ), |
826 | 826 | __FILE__, |
827 | 827 | __FUNCTION__, |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | // retrieve the wp-option for this config class. |
895 | 895 | $config_option = maybe_unserialize(get_option($config_option_name, array())); |
896 | 896 | if (empty($config_option)) { |
897 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
897 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
898 | 898 | } |
899 | 899 | return $config_option; |
900 | 900 | } |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | //copy incoming $_REQUEST and sanitize it so we can save it |
914 | 914 | $_request = $_REQUEST; |
915 | 915 | array_walk_recursive($_request, 'sanitize_text_field'); |
916 | - $config_log[(string)microtime(true)] = array( |
|
916 | + $config_log[(string) microtime(true)] = array( |
|
917 | 917 | 'config_name' => $config_option_name, |
918 | 918 | 'request' => $_request, |
919 | 919 | ); |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | ) |
1020 | 1020 | ) { |
1021 | 1021 | // grab list of installed widgets |
1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
1022 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
1023 | 1023 | // filter list of modules to register |
1024 | 1024 | $widgets_to_register = apply_filters( |
1025 | 1025 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
@@ -1076,31 +1076,31 @@ discard block |
||
1076 | 1076 | // create classname from widget directory name |
1077 | 1077 | $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
1078 | 1078 | // add class prefix |
1079 | - $widget_class = 'EEW_' . $widget; |
|
1079 | + $widget_class = 'EEW_'.$widget; |
|
1080 | 1080 | // does the widget exist ? |
1081 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
1081 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
1082 | 1082 | $msg = sprintf( |
1083 | 1083 | __( |
1084 | 1084 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
1085 | 1085 | 'event_espresso' |
1086 | 1086 | ), |
1087 | 1087 | $widget_class, |
1088 | - $widget_path . DS . $widget_class . $widget_ext |
|
1088 | + $widget_path.DS.$widget_class.$widget_ext |
|
1089 | 1089 | ); |
1090 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1090 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1091 | 1091 | return; |
1092 | 1092 | } |
1093 | 1093 | // load the widget class file |
1094 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
1094 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
1095 | 1095 | // verify that class exists |
1096 | 1096 | if ( ! class_exists($widget_class)) { |
1097 | 1097 | $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
1098 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1098 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1099 | 1099 | return; |
1100 | 1100 | } |
1101 | 1101 | register_widget($widget_class); |
1102 | 1102 | // add to array of registered widgets |
1103 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1103 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | private function _register_shortcodes() |
1115 | 1115 | { |
1116 | 1116 | // grab list of installed shortcodes |
1117 | - $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
1117 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
1118 | 1118 | // filter list of modules to register |
1119 | 1119 | $shortcodes_to_register = apply_filters( |
1120 | 1120 | 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
@@ -1164,44 +1164,44 @@ discard block |
||
1164 | 1164 | // remove last segment |
1165 | 1165 | array_pop($shortcode_path); |
1166 | 1166 | // glue it back together |
1167 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
1167 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
1168 | 1168 | } else { |
1169 | 1169 | // we need to generate the filename based off of the folder name |
1170 | 1170 | // grab and sanitize shortcode directory name |
1171 | 1171 | $shortcode = sanitize_key(basename($shortcode_path)); |
1172 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
1172 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
1173 | 1173 | } |
1174 | 1174 | // create classname from shortcode directory or file name |
1175 | 1175 | $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
1176 | 1176 | // add class prefix |
1177 | - $shortcode_class = 'EES_' . $shortcode; |
|
1177 | + $shortcode_class = 'EES_'.$shortcode; |
|
1178 | 1178 | // does the shortcode exist ? |
1179 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
1179 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1180 | 1180 | $msg = sprintf( |
1181 | 1181 | __( |
1182 | 1182 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
1183 | 1183 | 'event_espresso' |
1184 | 1184 | ), |
1185 | 1185 | $shortcode_class, |
1186 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1186 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1187 | 1187 | ); |
1188 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1188 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1189 | 1189 | return false; |
1190 | 1190 | } |
1191 | 1191 | // load the shortcode class file |
1192 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
1192 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1193 | 1193 | // verify that class exists |
1194 | 1194 | if ( ! class_exists($shortcode_class)) { |
1195 | 1195 | $msg = sprintf( |
1196 | 1196 | __('The requested %s shortcode class does not exist.', 'event_espresso'), |
1197 | 1197 | $shortcode_class |
1198 | 1198 | ); |
1199 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1199 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1200 | 1200 | return false; |
1201 | 1201 | } |
1202 | 1202 | $shortcode = strtoupper($shortcode); |
1203 | 1203 | // add to array of registered shortcodes |
1204 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1204 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1205 | 1205 | return true; |
1206 | 1206 | } |
1207 | 1207 | |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | private function _register_modules() |
1217 | 1217 | { |
1218 | 1218 | // grab list of installed modules |
1219 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
1219 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1220 | 1220 | // filter list of modules to register |
1221 | 1221 | $modules_to_register = apply_filters( |
1222 | 1222 | 'FHEE__EE_Config__register_modules__modules_to_register', |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | foreach ($modules_to_register as $module_path) { |
1228 | 1228 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1229 | 1229 | if ( |
1230 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1231 | - && $module_path !== EE_MODULES . 'gateways' |
|
1230 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
1231 | + && $module_path !== EE_MODULES.'gateways' |
|
1232 | 1232 | ) { |
1233 | 1233 | // add to list of installed modules |
1234 | 1234 | EE_Config::register_module($module_path); |
@@ -1266,25 +1266,25 @@ discard block |
||
1266 | 1266 | // remove last segment |
1267 | 1267 | array_pop($module_path); |
1268 | 1268 | // glue it back together |
1269 | - $module_path = implode(DS, $module_path) . DS; |
|
1269 | + $module_path = implode(DS, $module_path).DS; |
|
1270 | 1270 | // take first segment from file name pieces and sanitize it |
1271 | 1271 | $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
1272 | 1272 | // ensure class prefix is added |
1273 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
1273 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1274 | 1274 | } else { |
1275 | 1275 | // we need to generate the filename based off of the folder name |
1276 | 1276 | // grab and sanitize module name |
1277 | 1277 | $module = strtolower(basename($module_path)); |
1278 | 1278 | $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
1279 | 1279 | // like trailingslashit() |
1280 | - $module_path = rtrim($module_path, DS) . DS; |
|
1280 | + $module_path = rtrim($module_path, DS).DS; |
|
1281 | 1281 | // create classname from module directory name |
1282 | 1282 | $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
1283 | 1283 | // add class prefix |
1284 | - $module_class = 'EED_' . $module; |
|
1284 | + $module_class = 'EED_'.$module; |
|
1285 | 1285 | } |
1286 | 1286 | // does the module exist ? |
1287 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
1287 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1288 | 1288 | $msg = sprintf( |
1289 | 1289 | __( |
1290 | 1290 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1292,19 +1292,19 @@ discard block |
||
1292 | 1292 | ), |
1293 | 1293 | $module |
1294 | 1294 | ); |
1295 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1295 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | 1298 | // load the module class file |
1299 | - require_once($module_path . $module_class . $module_ext); |
|
1299 | + require_once($module_path.$module_class.$module_ext); |
|
1300 | 1300 | // verify that class exists |
1301 | 1301 | if ( ! class_exists($module_class)) { |
1302 | 1302 | $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
1303 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1303 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1304 | 1304 | return false; |
1305 | 1305 | } |
1306 | 1306 | // add to array of registered modules |
1307 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1307 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1308 | 1308 | do_action( |
1309 | 1309 | 'AHEE__EE_Config__register_module__complete', |
1310 | 1310 | $module_class, |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | // cycle thru shortcode folders |
1328 | 1328 | foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
1329 | 1329 | // add class prefix |
1330 | - $shortcode_class = 'EES_' . $shortcode; |
|
1330 | + $shortcode_class = 'EES_'.$shortcode; |
|
1331 | 1331 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1332 | 1332 | // which set hooks ? |
1333 | 1333 | if (is_admin()) { |
@@ -1394,26 +1394,26 @@ discard block |
||
1394 | 1394 | { |
1395 | 1395 | do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
1396 | 1396 | $module = str_replace('EED_', '', $module); |
1397 | - $module_class = 'EED_' . $module; |
|
1397 | + $module_class = 'EED_'.$module; |
|
1398 | 1398 | if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
1399 | 1399 | $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
1400 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1400 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1401 | 1401 | return false; |
1402 | 1402 | } |
1403 | 1403 | if (empty($route)) { |
1404 | 1404 | $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
1405 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1405 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1406 | 1406 | return false; |
1407 | 1407 | } |
1408 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
1408 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1409 | 1409 | $msg = sprintf( |
1410 | 1410 | __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
1411 | 1411 | $route |
1412 | 1412 | ); |
1413 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1413 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1414 | 1414 | return false; |
1415 | 1415 | } |
1416 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
1416 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1417 | 1417 | return true; |
1418 | 1418 | } |
1419 | 1419 | |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | public static function get_route($route = null, $key = 'ee') |
1431 | 1431 | { |
1432 | 1432 | do_action('AHEE__EE_Config__get_route__begin', $route); |
1433 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
1433 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1434 | 1434 | if (isset(EE_Config::$_module_route_map[$key][$route])) { |
1435 | 1435 | return EE_Config::$_module_route_map[$key][$route]; |
1436 | 1436 | } |
@@ -1471,12 +1471,12 @@ discard block |
||
1471 | 1471 | __('The module route %s for this forward has not been registered.', 'event_espresso'), |
1472 | 1472 | $route |
1473 | 1473 | ); |
1474 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1474 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1475 | 1475 | return false; |
1476 | 1476 | } |
1477 | 1477 | if (empty($forward)) { |
1478 | 1478 | $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
1479 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1479 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1480 | 1480 | return false; |
1481 | 1481 | } |
1482 | 1482 | if (is_array($forward)) { |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
1486 | 1486 | $route |
1487 | 1487 | ); |
1488 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1488 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1489 | 1489 | return false; |
1490 | 1490 | } |
1491 | 1491 | if ( ! method_exists($forward[0], $forward[1])) { |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | $forward[1], |
1495 | 1495 | $route |
1496 | 1496 | ); |
1497 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1497 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1498 | 1498 | return false; |
1499 | 1499 | } |
1500 | 1500 | } else if ( ! function_exists($forward)) { |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | $forward, |
1504 | 1504 | $route |
1505 | 1505 | ); |
1506 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1506 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1507 | 1507 | return false; |
1508 | 1508 | } |
1509 | 1509 | EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
@@ -1558,7 +1558,7 @@ discard block |
||
1558 | 1558 | __('The module route %s for this view has not been registered.', 'event_espresso'), |
1559 | 1559 | $route |
1560 | 1560 | ); |
1561 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1561 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1562 | 1562 | return false; |
1563 | 1563 | } |
1564 | 1564 | if ( ! is_readable($view)) { |
@@ -1569,7 +1569,7 @@ discard block |
||
1569 | 1569 | ), |
1570 | 1570 | $view |
1571 | 1571 | ); |
1572 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
1572 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1573 | 1573 | return false; |
1574 | 1574 | } |
1575 | 1575 | EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
@@ -1886,7 +1886,7 @@ discard block |
||
1886 | 1886 | $this->reg_page_url = add_query_arg( |
1887 | 1887 | array('uts' => time()), |
1888 | 1888 | get_permalink($this->reg_page_id) |
1889 | - ) . '#checkout'; |
|
1889 | + ).'#checkout'; |
|
1890 | 1890 | } |
1891 | 1891 | return $this->reg_page_url; |
1892 | 1892 | } |
@@ -1990,13 +1990,13 @@ discard block |
||
1990 | 1990 | $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
1991 | 1991 | $option = 'ee_ueip_optin'; |
1992 | 1992 | //set correct table for query |
1993 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
1993 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
1994 | 1994 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
1995 | 1995 | //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
1996 | 1996 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
1997 | 1997 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
1998 | 1998 | //for the purpose of caching. |
1999 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
1999 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
2000 | 2000 | if (false !== $pre) { |
2001 | 2001 | EE_Core_Config::$ee_ueip_option = $pre; |
2002 | 2002 | return EE_Core_Config::$ee_ueip_option; |
@@ -2006,9 +2006,9 @@ discard block |
||
2006 | 2006 | if (is_object($row)) { |
2007 | 2007 | $value = $row->option_value; |
2008 | 2008 | } else { //option does not exist so use default. |
2009 | - return apply_filters('default_option_' . $option, false, $option); |
|
2009 | + return apply_filters('default_option_'.$option, false, $option); |
|
2010 | 2010 | } |
2011 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
2011 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
2012 | 2012 | return EE_Core_Config::$ee_ueip_option; |
2013 | 2013 | } |
2014 | 2014 | |
@@ -2285,27 +2285,27 @@ discard block |
||
2285 | 2285 | // retrieve the country settings from the db, just in case they have been customized |
2286 | 2286 | $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
2287 | 2287 | if ($country instanceof EE_Country) { |
2288 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2289 | - $this->name = $country->currency_name_single(); // Dollar |
|
2290 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2291 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2292 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2293 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2294 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2295 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2288 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2289 | + $this->name = $country->currency_name_single(); // Dollar |
|
2290 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2291 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2292 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2293 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2294 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2295 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2296 | 2296 | } |
2297 | 2297 | } |
2298 | 2298 | // fallback to hardcoded defaults, in case the above failed |
2299 | 2299 | if (empty($this->code)) { |
2300 | 2300 | // set default currency settings |
2301 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2302 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2303 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2304 | - $this->sign = '$'; // currency sign: $ |
|
2305 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2306 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2307 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2308 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2301 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2302 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2303 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2304 | + $this->sign = '$'; // currency sign: $ |
|
2305 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2306 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2307 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2308 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2309 | 2309 | } |
2310 | 2310 | } |
2311 | 2311 | } |
@@ -2628,7 +2628,7 @@ discard block |
||
2628 | 2628 | public function log_file_name($reset = false) |
2629 | 2629 | { |
2630 | 2630 | if (empty($this->log_file_name) || $reset) { |
2631 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
2631 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
2632 | 2632 | EE_Config::instance()->update_espresso_config(false, false); |
2633 | 2633 | } |
2634 | 2634 | return $this->log_file_name; |
@@ -2643,7 +2643,7 @@ discard block |
||
2643 | 2643 | public function debug_file_name($reset = false) |
2644 | 2644 | { |
2645 | 2645 | if (empty($this->debug_file_name) || $reset) { |
2646 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
2646 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
2647 | 2647 | EE_Config::instance()->update_espresso_config(false, false); |
2648 | 2648 | } |
2649 | 2649 | return $this->debug_file_name; |
@@ -2859,21 +2859,21 @@ discard block |
||
2859 | 2859 | $this->use_google_maps = true; |
2860 | 2860 | $this->google_map_api_key = ''; |
2861 | 2861 | // for event details pages (reg page) |
2862 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2863 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2864 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2865 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2866 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2867 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2868 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2862 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2863 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2864 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2865 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2866 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2867 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2868 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2869 | 2869 | // for event list pages |
2870 | - $this->event_list_map_width = 300; // ee_map_width |
|
2871 | - $this->event_list_map_height = 185; // ee_map_height |
|
2872 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2873 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2874 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2875 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2876 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2870 | + $this->event_list_map_width = 300; // ee_map_width |
|
2871 | + $this->event_list_map_height = 185; // ee_map_height |
|
2872 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2873 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2874 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2875 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2876 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2877 | 2877 | } |
2878 | 2878 | |
2879 | 2879 | } |
@@ -16,282 +16,282 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $iframe_name |
|
21 | - */ |
|
22 | - private $iframe_name; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $route_name |
|
26 | - */ |
|
27 | - private $route_name; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $slug |
|
31 | - */ |
|
32 | - private $slug; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $append_filterable_content |
|
36 | - */ |
|
37 | - private $append_filterable_content; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * IframeEmbedButton constructor. |
|
43 | - * |
|
44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | - * @param string $route_name the name of the registered route |
|
46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | - * will most likely be "event" since that's the only usage atm |
|
48 | - */ |
|
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | - { |
|
51 | - $this->iframe_name = $iframe_name; |
|
52 | - $this->route_name = $route_name; |
|
53 | - $this->slug = $slug; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Adds an iframe embed code button to the Event editor. |
|
60 | - */ |
|
61 | - public function addEventEditorIframeEmbedButtonFilter() |
|
62 | - { |
|
63 | - // add button for iframe code to event editor. |
|
64 | - add_filter( |
|
65 | - 'get_sample_permalink_html', |
|
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | - 10, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - add_action( |
|
71 | - 'admin_enqueue_scripts', |
|
72 | - array( $this, 'embedButtonAssets' ), |
|
73 | - 10 |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param $permalink_string |
|
81 | - * @param $id |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | - { |
|
86 | - return $this->eventEditorIframeEmbedButton( |
|
87 | - $permalink_string, |
|
88 | - $id |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * iframe embed code button to the Event editor. |
|
96 | - * |
|
97 | - * @param string $permalink_string |
|
98 | - * @param int $id |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function eventEditorIframeEmbedButton( |
|
102 | - $permalink_string, |
|
103 | - $id |
|
104 | - ) { |
|
105 | - //make sure this is ONLY when editing and the event id has been set. |
|
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
108 | - //if NOT event then let's get out. |
|
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
110 | - return $permalink_string; |
|
111 | - } |
|
112 | - $permalink_string .= $this->embedButtonHtml( |
|
113 | - array( $this->slug => $id ), |
|
114 | - 'button-small' |
|
115 | - ); |
|
116 | - } |
|
117 | - return $permalink_string; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | - * |
|
125 | - * @param string $action name of the WP do_action() to hook into |
|
126 | - */ |
|
127 | - public function addActionIframeEmbedButton( $action ) |
|
128 | - { |
|
129 | - // add button for iframe code to event editor. |
|
130 | - add_action( |
|
131 | - $action, |
|
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | - 10, 2 |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public function addActionIframeEmbedButtonCallback() |
|
143 | - { |
|
144 | - echo $this->embedButtonHtml(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | - * |
|
152 | - * @param string $filter name of the WP apply_filters() to hook into |
|
153 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | - * else if false, will add to the beginning of the content |
|
155 | - */ |
|
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | - { |
|
158 | - $this->append_filterable_content = $append; |
|
159 | - // add button for iframe code to event editor. |
|
160 | - add_filter( |
|
161 | - $filter, |
|
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | - 10 |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param array|string $filterable_content |
|
171 | - * @return array|string |
|
172 | - */ |
|
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | - { |
|
175 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | - if ( is_array( $filterable_content ) ) { |
|
177 | - $filterable_content = $this->append_filterable_content |
|
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | - } else { |
|
181 | - $filterable_content = $this->append_filterable_content |
|
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
184 | - } |
|
185 | - return $filterable_content; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * iframe_embed_html |
|
192 | - * |
|
193 | - * @param array $query_args |
|
194 | - * @param string $button_class |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | - { |
|
199 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
202 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | - $query_args |
|
204 | - ); |
|
205 | - // add this route to our localized vars |
|
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | - : array(); |
|
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | - $iframe_embed_html = \EEH_HTML::link( |
|
212 | - '#', |
|
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | - sprintf( |
|
215 | - esc_html__( |
|
216 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | - 'event_espresso' |
|
218 | - ), |
|
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | - ), |
|
221 | - "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | - '', |
|
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | - ); |
|
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
228 | - $iframe_embed_html .= esc_html( |
|
229 | - \EEH_HTML::div( |
|
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | - '', |
|
232 | - '', |
|
233 | - 'width:100%; height: 500px;' |
|
234 | - ) |
|
235 | - ); |
|
236 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | - return $iframe_embed_html; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * enqueue iframe button js |
|
244 | - */ |
|
245 | - public function embedButtonAssets() |
|
246 | - { |
|
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | - 'event_espresso' |
|
250 | - ); |
|
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | - 'click anywhere outside of this window to close it.', |
|
253 | - 'event_espresso' |
|
254 | - ); |
|
255 | - wp_register_script( |
|
256 | - 'iframe_embed_button', |
|
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
259 | - EVENT_ESPRESSO_VERSION, |
|
260 | - true |
|
261 | - ); |
|
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * generates embed button sections for admin pages |
|
269 | - * |
|
270 | - * @param array $embed_buttons |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | - { |
|
275 | - $embed_buttons = (array)apply_filters( |
|
276 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | - $embed_buttons |
|
278 | - ); |
|
279 | - if ( empty($embed_buttons)) { |
|
280 | - return ''; |
|
281 | - } |
|
282 | - // add button for iframe code to event editor. |
|
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | - $html .= \EEH_HTML::p( |
|
286 | - esc_html__( |
|
287 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | - 'event_espresso' |
|
289 | - ) |
|
290 | - ); |
|
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
293 | - return $html; |
|
294 | - } |
|
19 | + /** |
|
20 | + * @var string $iframe_name |
|
21 | + */ |
|
22 | + private $iframe_name; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $route_name |
|
26 | + */ |
|
27 | + private $route_name; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $slug |
|
31 | + */ |
|
32 | + private $slug; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $append_filterable_content |
|
36 | + */ |
|
37 | + private $append_filterable_content; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * IframeEmbedButton constructor. |
|
43 | + * |
|
44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | + * @param string $route_name the name of the registered route |
|
46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | + * will most likely be "event" since that's the only usage atm |
|
48 | + */ |
|
49 | + public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | + { |
|
51 | + $this->iframe_name = $iframe_name; |
|
52 | + $this->route_name = $route_name; |
|
53 | + $this->slug = $slug; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Adds an iframe embed code button to the Event editor. |
|
60 | + */ |
|
61 | + public function addEventEditorIframeEmbedButtonFilter() |
|
62 | + { |
|
63 | + // add button for iframe code to event editor. |
|
64 | + add_filter( |
|
65 | + 'get_sample_permalink_html', |
|
66 | + array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | + 10, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + add_action( |
|
71 | + 'admin_enqueue_scripts', |
|
72 | + array( $this, 'embedButtonAssets' ), |
|
73 | + 10 |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param $permalink_string |
|
81 | + * @param $id |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | + { |
|
86 | + return $this->eventEditorIframeEmbedButton( |
|
87 | + $permalink_string, |
|
88 | + $id |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * iframe embed code button to the Event editor. |
|
96 | + * |
|
97 | + * @param string $permalink_string |
|
98 | + * @param int $id |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function eventEditorIframeEmbedButton( |
|
102 | + $permalink_string, |
|
103 | + $id |
|
104 | + ) { |
|
105 | + //make sure this is ONLY when editing and the event id has been set. |
|
106 | + if ( ! empty( $id ) ) { |
|
107 | + $post = get_post( $id ); |
|
108 | + //if NOT event then let's get out. |
|
109 | + if ( $post->post_type !== 'espresso_events' ) { |
|
110 | + return $permalink_string; |
|
111 | + } |
|
112 | + $permalink_string .= $this->embedButtonHtml( |
|
113 | + array( $this->slug => $id ), |
|
114 | + 'button-small' |
|
115 | + ); |
|
116 | + } |
|
117 | + return $permalink_string; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | + * |
|
125 | + * @param string $action name of the WP do_action() to hook into |
|
126 | + */ |
|
127 | + public function addActionIframeEmbedButton( $action ) |
|
128 | + { |
|
129 | + // add button for iframe code to event editor. |
|
130 | + add_action( |
|
131 | + $action, |
|
132 | + array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | + 10, 2 |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public function addActionIframeEmbedButtonCallback() |
|
143 | + { |
|
144 | + echo $this->embedButtonHtml(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | + * |
|
152 | + * @param string $filter name of the WP apply_filters() to hook into |
|
153 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | + * else if false, will add to the beginning of the content |
|
155 | + */ |
|
156 | + public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | + { |
|
158 | + $this->append_filterable_content = $append; |
|
159 | + // add button for iframe code to event editor. |
|
160 | + add_filter( |
|
161 | + $filter, |
|
162 | + array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | + 10 |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param array|string $filterable_content |
|
171 | + * @return array|string |
|
172 | + */ |
|
173 | + public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | + { |
|
175 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | + if ( is_array( $filterable_content ) ) { |
|
177 | + $filterable_content = $this->append_filterable_content |
|
178 | + ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | + : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | + } else { |
|
181 | + $filterable_content = $this->append_filterable_content |
|
182 | + ? $filterable_content . $embedButtonHtml |
|
183 | + : $embedButtonHtml . $filterable_content; |
|
184 | + } |
|
185 | + return $filterable_content; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * iframe_embed_html |
|
192 | + * |
|
193 | + * @param array $query_args |
|
194 | + * @param string $button_class |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | + { |
|
199 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | + $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | + $query_args = (array)apply_filters( |
|
202 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | + $query_args |
|
204 | + ); |
|
205 | + // add this route to our localized vars |
|
206 | + $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | + ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | + : array(); |
|
209 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | + $iframe_embed_html = \EEH_HTML::link( |
|
212 | + '#', |
|
213 | + sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | + sprintf( |
|
215 | + esc_html__( |
|
216 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | + 'event_espresso' |
|
218 | + ), |
|
219 | + \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | + ), |
|
221 | + "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | + 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | + '', |
|
224 | + ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | + ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;' ); |
|
228 | + $iframe_embed_html .= esc_html( |
|
229 | + \EEH_HTML::div( |
|
230 | + '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | + '', |
|
232 | + '', |
|
233 | + 'width:100%; height: 500px;' |
|
234 | + ) |
|
235 | + ); |
|
236 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | + return $iframe_embed_html; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * enqueue iframe button js |
|
244 | + */ |
|
245 | + public function embedButtonAssets() |
|
246 | + { |
|
247 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | + 'event_espresso' |
|
250 | + ); |
|
251 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | + 'click anywhere outside of this window to close it.', |
|
253 | + 'event_espresso' |
|
254 | + ); |
|
255 | + wp_register_script( |
|
256 | + 'iframe_embed_button', |
|
257 | + plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | + array( 'ee-dialog' ), |
|
259 | + EVENT_ESPRESSO_VERSION, |
|
260 | + true |
|
261 | + ); |
|
262 | + wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * generates embed button sections for admin pages |
|
269 | + * |
|
270 | + * @param array $embed_buttons |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | + { |
|
275 | + $embed_buttons = (array)apply_filters( |
|
276 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | + $embed_buttons |
|
278 | + ); |
|
279 | + if ( empty($embed_buttons)) { |
|
280 | + return ''; |
|
281 | + } |
|
282 | + // add button for iframe code to event editor. |
|
283 | + $html = \EEH_HTML::br( 2 ); |
|
284 | + $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | + $html .= \EEH_HTML::p( |
|
286 | + esc_html__( |
|
287 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | + 'event_espresso' |
|
289 | + ) |
|
290 | + ); |
|
291 | + $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | + $html .= \EEH_HTML::br( 2 ); |
|
293 | + return $html; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | 297 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
47 | 47 | * will most likely be "event" since that's the only usage atm |
48 | 48 | */ |
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | 50 | { |
51 | 51 | $this->iframe_name = $iframe_name; |
52 | 52 | $this->route_name = $route_name; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | // add button for iframe code to event editor. |
64 | 64 | add_filter( |
65 | 65 | 'get_sample_permalink_html', |
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
66 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
67 | 67 | 10, |
68 | 68 | 2 |
69 | 69 | ); |
70 | 70 | add_action( |
71 | 71 | 'admin_enqueue_scripts', |
72 | - array( $this, 'embedButtonAssets' ), |
|
72 | + array($this, 'embedButtonAssets'), |
|
73 | 73 | 10 |
74 | 74 | ); |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param $id |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
85 | 85 | { |
86 | 86 | return $this->eventEditorIframeEmbedButton( |
87 | 87 | $permalink_string, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | $id |
104 | 104 | ) { |
105 | 105 | //make sure this is ONLY when editing and the event id has been set. |
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
106 | + if ( ! empty($id)) { |
|
107 | + $post = get_post($id); |
|
108 | 108 | //if NOT event then let's get out. |
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
109 | + if ($post->post_type !== 'espresso_events') { |
|
110 | 110 | return $permalink_string; |
111 | 111 | } |
112 | 112 | $permalink_string .= $this->embedButtonHtml( |
113 | - array( $this->slug => $id ), |
|
113 | + array($this->slug => $id), |
|
114 | 114 | 'button-small' |
115 | 115 | ); |
116 | 116 | } |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $action name of the WP do_action() to hook into |
126 | 126 | */ |
127 | - public function addActionIframeEmbedButton( $action ) |
|
127 | + public function addActionIframeEmbedButton($action) |
|
128 | 128 | { |
129 | 129 | // add button for iframe code to event editor. |
130 | 130 | add_action( |
131 | 131 | $action, |
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
132 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
133 | 133 | 10, 2 |
134 | 134 | ); |
135 | 135 | } |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @param bool $append if true, will add iframe embed button to end of content, |
154 | 154 | * else if false, will add to the beginning of the content |
155 | 155 | */ |
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
156 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
157 | 157 | { |
158 | 158 | $this->append_filterable_content = $append; |
159 | 159 | // add button for iframe code to event editor. |
160 | 160 | add_filter( |
161 | 161 | $filter, |
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
162 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
163 | 163 | 10 |
164 | 164 | ); |
165 | 165 | } |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | * @param array|string $filterable_content |
171 | 171 | * @return array|string |
172 | 172 | */ |
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
173 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
174 | 174 | { |
175 | 175 | $embedButtonHtml = $this->embedButtonHtml(); |
176 | - if ( is_array( $filterable_content ) ) { |
|
176 | + if (is_array($filterable_content)) { |
|
177 | 177 | $filterable_content = $this->append_filterable_content |
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
178 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
179 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
180 | 180 | } else { |
181 | 181 | $filterable_content = $this->append_filterable_content |
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
182 | + ? $filterable_content.$embedButtonHtml |
|
183 | + : $embedButtonHtml.$filterable_content; |
|
184 | 184 | } |
185 | 185 | return $filterable_content; |
186 | 186 | } |
@@ -194,40 +194,40 @@ discard block |
||
194 | 194 | * @param string $button_class |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
197 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
198 | 198 | { |
199 | 199 | // incoming args will replace the defaults listed here in the second array (union preserves first array) |
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
200 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
201 | + $query_args = (array) apply_filters( |
|
202 | 202 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
203 | 203 | $query_args |
204 | 204 | ); |
205 | 205 | // add this route to our localized vars |
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
206 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
207 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
208 | 208 | : array(); |
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
209 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
211 | 211 | $iframe_embed_html = \EEH_HTML::link( |
212 | 212 | '#', |
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
213 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
214 | 214 | sprintf( |
215 | 215 | esc_html__( |
216 | 216 | 'click here to generate code for embedding %1$s iframe into another site.', |
217 | 217 | 'event_espresso' |
218 | 218 | ), |
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
219 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
220 | 220 | ), |
221 | 221 | "{$this->route_name}-iframe-embed-trigger-js", |
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
222 | + 'iframe-embed-trigger-js button '.$button_class, |
|
223 | 223 | '', |
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
224 | + ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"' |
|
225 | 225 | ); |
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;'); |
|
228 | 228 | $iframe_embed_html .= esc_html( |
229 | 229 | \EEH_HTML::div( |
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
230 | + '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>', |
|
231 | 231 | '', |
232 | 232 | '', |
233 | 233 | 'width:100%; height: 500px;' |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function embedButtonAssets() |
246 | 246 | { |
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
247 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
248 | 248 | 'copy and paste the following into any other site\'s content to display this event:', |
249 | 249 | 'event_espresso' |
250 | 250 | ); |
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
251 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
252 | 252 | 'click anywhere outside of this window to close it.', |
253 | 253 | 'event_espresso' |
254 | 254 | ); |
255 | 255 | wp_register_script( |
256 | 256 | 'iframe_embed_button', |
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
257 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
258 | + array('ee-dialog'), |
|
259 | 259 | EVENT_ESPRESSO_VERSION, |
260 | 260 | true |
261 | 261 | ); |
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
262 | + wp_enqueue_script('iframe_embed_button'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -270,26 +270,26 @@ discard block |
||
270 | 270 | * @param array $embed_buttons |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
273 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
274 | 274 | { |
275 | - $embed_buttons = (array)apply_filters( |
|
275 | + $embed_buttons = (array) apply_filters( |
|
276 | 276 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
277 | 277 | $embed_buttons |
278 | 278 | ); |
279 | - if ( empty($embed_buttons)) { |
|
279 | + if (empty($embed_buttons)) { |
|
280 | 280 | return ''; |
281 | 281 | } |
282 | 282 | // add button for iframe code to event editor. |
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
283 | + $html = \EEH_HTML::br(2); |
|
284 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
285 | 285 | $html .= \EEH_HTML::p( |
286 | 286 | esc_html__( |
287 | 287 | 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
288 | 288 | 'event_espresso' |
289 | 289 | ) |
290 | 290 | ); |
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
291 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
292 | + $html .= \EEH_HTML::br(2); |
|
293 | 293 | return $html; |
294 | 294 | } |
295 | 295 |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | class EventListIframeEmbedButton extends IframeEmbedButton |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * EventListIframeEmbedButton constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
25 | - 'event_list' |
|
26 | - ); |
|
27 | - } |
|
18 | + /** |
|
19 | + * EventListIframeEmbedButton constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + esc_html__( 'Event List', 'event_espresso' ), |
|
25 | + 'event_list' |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | public function addEmbedButton() { |
32 | - add_filter( |
|
32 | + add_filter( |
|
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | 34 | array( $this, 'addEventListIframeEmbedButtonSection' ) |
35 | 35 | ); |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | - { |
|
54 | - return \EEH_Array::insert_into_array( |
|
55 | - $after_list_table, |
|
56 | - array( |
|
57 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | - array() |
|
59 | - // array( 'event_list' => $this->embedButtonHtml() ) |
|
60 | - ) |
|
61 | - ), |
|
62 | - 'legend' |
|
63 | - ); |
|
64 | - } |
|
52 | + public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | + { |
|
54 | + return \EEH_Array::insert_into_array( |
|
55 | + $after_list_table, |
|
56 | + array( |
|
57 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | + array() |
|
59 | + // array( 'event_list' => $this->embedButtonHtml() ) |
|
60 | + ) |
|
61 | + ), |
|
62 | + 'legend' |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct() |
22 | 22 | { |
23 | 23 | parent::__construct( |
24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
24 | + esc_html__('Event List', 'event_espresso'), |
|
25 | 25 | 'event_list' |
26 | 26 | ); |
27 | 27 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | public function addEmbedButton() { |
32 | 32 | add_filter( |
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | - array( $this, 'addEventListIframeEmbedButtonSection' ) |
|
34 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
35 | 35 | ); |
36 | 36 | add_action( |
37 | 37 | 'admin_enqueue_scripts', |
38 | - array( $this, 'embedButtonAssets' ), |
|
38 | + array($this, 'embedButtonAssets'), |
|
39 | 39 | 10 |
40 | 40 | ); |
41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
52 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
53 | 53 | { |
54 | 54 | return \EEH_Array::insert_into_array( |
55 | 55 | $after_list_table, |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -13,168 +13,168 @@ discard block |
||
13 | 13 | class EE_Messages_Scheduler extends EE_Base |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Number of seconds between batch sends/generates on the cron job. |
|
18 | - * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | - * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | - * |
|
21 | - * @type int |
|
22 | - */ |
|
23 | - const message_cron_schedule = 300; |
|
24 | - |
|
25 | - /** |
|
26 | - * Constructor |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - //register tasks (and make sure only registered once). |
|
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | - add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | - } |
|
34 | - |
|
35 | - //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | - array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | - ) { |
|
39 | - add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | - add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | - } |
|
42 | - |
|
43 | - //add custom schedules |
|
44 | - add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Add custom schedules for wp_cron |
|
50 | - * |
|
51 | - * @param $schedules |
|
52 | - */ |
|
53 | - public function custom_schedules($schedules) |
|
54 | - { |
|
55 | - $schedules['ee_message_cron'] = array( |
|
56 | - 'interval' => self::message_cron_schedule, |
|
57 | - 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | - 'event_espresso'), |
|
59 | - ); |
|
60 | - return $schedules; |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | - * remove. |
|
67 | - * |
|
68 | - * @param array $tasks already existing scheduled tasks |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - public function register_scheduled_tasks($tasks) |
|
72 | - { |
|
73 | - $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | - $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | - return $tasks; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | - * Note: The EED_Messages module has the handlers for these requests. |
|
82 | - * |
|
83 | - * @param string $task The task the request is being generated for. |
|
84 | - */ |
|
85 | - public static function initiate_scheduled_non_blocking_request($task) |
|
86 | - { |
|
87 | - if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | - true)) { |
|
89 | - $request_url = add_query_arg( |
|
90 | - array_merge( |
|
91 | - array('ee' => 'msg_cron_trigger'), |
|
92 | - EE_Messages_Scheduler::get_request_params($task) |
|
93 | - ), |
|
94 | - site_url() |
|
95 | - ); |
|
96 | - $request_args = array( |
|
97 | - 'timeout' => 300, |
|
98 | - 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | - 'sslverify' => false, |
|
100 | - 'redirection' => 10, |
|
101 | - ); |
|
102 | - $response = wp_remote_get($request_url, $request_args); |
|
103 | - if (is_wp_error($response)) { |
|
104 | - trigger_error($response->get_error_message()); |
|
105 | - } |
|
106 | - } else { |
|
107 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * This returns |
|
114 | - * the request params used for a scheduled message task request. |
|
115 | - * |
|
116 | - * @param string $task The task the request is for. |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - public static function get_request_params($task) |
|
120 | - { |
|
121 | - //transient is used for flood control on msg_cron_trigger requests |
|
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | - set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | - return array( |
|
125 | - 'type' => $task, |
|
126 | - 'key' => $transient_key, |
|
127 | - ); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | - * |
|
134 | - * @param string $task The task the request is being generated for. |
|
135 | - */ |
|
136 | - public static function initiate_immediate_request_on_cron($task) |
|
137 | - { |
|
138 | - $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | - //set those request args in the request so it gets picked up |
|
140 | - foreach ($request_args as $request_key => $request_value) { |
|
141 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | - } |
|
143 | - EED_Messages::instance()->run_cron(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | - */ |
|
150 | - public static function batch_generation() |
|
151 | - { |
|
152 | - /** |
|
153 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | - */ |
|
155 | - if ( |
|
156 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | - ) { |
|
159 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | - */ |
|
167 | - public static function batch_sending() |
|
168 | - { |
|
169 | - /** |
|
170 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | - */ |
|
172 | - if ( |
|
173 | - ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | - ) { |
|
176 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | - } |
|
178 | - } |
|
16 | + /** |
|
17 | + * Number of seconds between batch sends/generates on the cron job. |
|
18 | + * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
19 | + * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
20 | + * |
|
21 | + * @type int |
|
22 | + */ |
|
23 | + const message_cron_schedule = 300; |
|
24 | + |
|
25 | + /** |
|
26 | + * Constructor |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + //register tasks (and make sure only registered once). |
|
31 | + if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
33 | + } |
|
34 | + |
|
35 | + //register callbacks for scheduled events (but make sure they are set only once). |
|
36 | + if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | + array('EE_Messages_Scheduler', 'batch_generation')) |
|
38 | + ) { |
|
39 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | + } |
|
42 | + |
|
43 | + //add custom schedules |
|
44 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Add custom schedules for wp_cron |
|
50 | + * |
|
51 | + * @param $schedules |
|
52 | + */ |
|
53 | + public function custom_schedules($schedules) |
|
54 | + { |
|
55 | + $schedules['ee_message_cron'] = array( |
|
56 | + 'interval' => self::message_cron_schedule, |
|
57 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
58 | + 'event_espresso'), |
|
59 | + ); |
|
60 | + return $schedules; |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
66 | + * remove. |
|
67 | + * |
|
68 | + * @param array $tasks already existing scheduled tasks |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + public function register_scheduled_tasks($tasks) |
|
72 | + { |
|
73 | + $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
74 | + $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
75 | + return $tasks; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * This initiates a non-blocking separate request to execute on a scheduled task. |
|
81 | + * Note: The EED_Messages module has the handlers for these requests. |
|
82 | + * |
|
83 | + * @param string $task The task the request is being generated for. |
|
84 | + */ |
|
85 | + public static function initiate_scheduled_non_blocking_request($task) |
|
86 | + { |
|
87 | + if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
88 | + true)) { |
|
89 | + $request_url = add_query_arg( |
|
90 | + array_merge( |
|
91 | + array('ee' => 'msg_cron_trigger'), |
|
92 | + EE_Messages_Scheduler::get_request_params($task) |
|
93 | + ), |
|
94 | + site_url() |
|
95 | + ); |
|
96 | + $request_args = array( |
|
97 | + 'timeout' => 300, |
|
98 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
99 | + 'sslverify' => false, |
|
100 | + 'redirection' => 10, |
|
101 | + ); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | + if (is_wp_error($response)) { |
|
104 | + trigger_error($response->get_error_message()); |
|
105 | + } |
|
106 | + } else { |
|
107 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * This returns |
|
114 | + * the request params used for a scheduled message task request. |
|
115 | + * |
|
116 | + * @param string $task The task the request is for. |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + public static function get_request_params($task) |
|
120 | + { |
|
121 | + //transient is used for flood control on msg_cron_trigger requests |
|
122 | + $transient_key = 'ee_trans_' . uniqid($task); |
|
123 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
124 | + return array( |
|
125 | + 'type' => $task, |
|
126 | + 'key' => $transient_key, |
|
127 | + ); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
133 | + * |
|
134 | + * @param string $task The task the request is being generated for. |
|
135 | + */ |
|
136 | + public static function initiate_immediate_request_on_cron($task) |
|
137 | + { |
|
138 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
139 | + //set those request args in the request so it gets picked up |
|
140 | + foreach ($request_args as $request_key => $request_value) { |
|
141 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
142 | + } |
|
143 | + EED_Messages::instance()->run_cron(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
149 | + */ |
|
150 | + public static function batch_generation() |
|
151 | + { |
|
152 | + /** |
|
153 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
154 | + */ |
|
155 | + if ( |
|
156 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
157 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
158 | + ) { |
|
159 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
166 | + */ |
|
167 | + public static function batch_sending() |
|
168 | + { |
|
169 | + /** |
|
170 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
171 | + */ |
|
172 | + if ( |
|
173 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
174 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
175 | + ) { |
|
176 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
177 | + } |
|
178 | + } |
|
179 | 179 | |
180 | 180 | } //end EE_Messages_Scheduler |
181 | 181 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | public function __construct() |
29 | 29 | { |
30 | 30 | //register tasks (and make sure only registered once). |
31 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
32 | 32 | add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
33 | 33 | } |
34 | 34 | |
35 | 35 | //register callbacks for scheduled events (but make sure they are set only once). |
36 | - if (! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
36 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', |
|
37 | 37 | array('EE_Messages_Scheduler', 'batch_generation')) |
38 | 38 | ) { |
39 | 39 | add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | { |
87 | 87 | if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
88 | 88 | true)) { |
89 | - $request_url = add_query_arg( |
|
89 | + $request_url = add_query_arg( |
|
90 | 90 | array_merge( |
91 | 91 | array('ee' => 'msg_cron_trigger'), |
92 | 92 | EE_Messages_Scheduler::get_request_params($task) |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | 'sslverify' => false, |
100 | 100 | 'redirection' => 10, |
101 | 101 | ); |
102 | - $response = wp_remote_get($request_url, $request_args); |
|
102 | + $response = wp_remote_get($request_url, $request_args); |
|
103 | 103 | if (is_wp_error($response)) { |
104 | 104 | trigger_error($response->get_error_message()); |
105 | 105 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public static function get_request_params($task) |
120 | 120 | { |
121 | 121 | //transient is used for flood control on msg_cron_trigger requests |
122 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
122 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
123 | 123 | set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
124 | 124 | return array( |
125 | 125 | 'type' => $task, |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | 6 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
7 | - exit( 'No direct script access allowed' ); |
|
7 | + exit( 'No direct script access allowed' ); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -21,64 +21,64 @@ discard block |
||
21 | 21 | class TicketSelectorIframe extends Iframe |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * TicketSelectorIframe constructor. |
|
26 | - * |
|
27 | - * @throws \DomainException |
|
28 | - * @throws \EE_Error |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | - /** @type \EEM_Event $EEM_Event */ |
|
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | - $event = $EEM_Event->get_one_by_ID( |
|
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | - ); |
|
38 | - $ticket_selector = new DisplayTicketSelector(); |
|
39 | - $ticket_selector->setIframe( true ); |
|
40 | - parent::__construct( |
|
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
43 | - ); |
|
44 | - $this->addStylesheets( |
|
45 | - apply_filters( |
|
46 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | - array( |
|
48 | - 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | - . 'ticket_selector_embed.css?ver=' |
|
50 | - . EVENT_ESPRESSO_VERSION, |
|
51 | - 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | - . 'ticket_selector.css?ver=' |
|
53 | - . EVENT_ESPRESSO_VERSION, |
|
54 | - ), |
|
55 | - $this |
|
56 | - ) |
|
57 | - ); |
|
58 | - if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | - } |
|
61 | - $this->addScripts( |
|
62 | - apply_filters( |
|
63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | - array( |
|
65 | - 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | - . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | - . EVENT_ESPRESSO_VERSION, |
|
68 | - ), |
|
69 | - $this |
|
70 | - ) |
|
71 | - ); |
|
72 | - $this->addLocalizedVars( |
|
73 | - array( |
|
74 | - 'ticket_selector_iframe' => true, |
|
75 | - 'EEDTicketSelectorMsg' => __( |
|
76 | - 'Please choose at least one ticket before continuing.', |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - ) |
|
80 | - ); |
|
81 | - } |
|
24 | + /** |
|
25 | + * TicketSelectorIframe constructor. |
|
26 | + * |
|
27 | + * @throws \DomainException |
|
28 | + * @throws \EE_Error |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
33 | + /** @type \EEM_Event $EEM_Event */ |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
35 | + $event = $EEM_Event->get_one_by_ID( |
|
36 | + \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
37 | + ); |
|
38 | + $ticket_selector = new DisplayTicketSelector(); |
|
39 | + $ticket_selector->setIframe( true ); |
|
40 | + parent::__construct( |
|
41 | + esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | + $ticket_selector->display( $event ) |
|
43 | + ); |
|
44 | + $this->addStylesheets( |
|
45 | + apply_filters( |
|
46 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
47 | + array( |
|
48 | + 'ticket_selector_embed' => TICKET_SELECTOR_ASSETS_URL |
|
49 | + . 'ticket_selector_embed.css?ver=' |
|
50 | + . EVENT_ESPRESSO_VERSION, |
|
51 | + 'ticket_selector' => TICKET_SELECTOR_ASSETS_URL |
|
52 | + . 'ticket_selector.css?ver=' |
|
53 | + . EVENT_ESPRESSO_VERSION, |
|
54 | + ), |
|
55 | + $this |
|
56 | + ) |
|
57 | + ); |
|
58 | + if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
|
59 | + $this->addStylesheets( array('site_theme' => '' ) ); |
|
60 | + } |
|
61 | + $this->addScripts( |
|
62 | + apply_filters( |
|
63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
64 | + array( |
|
65 | + 'ticket_selector_iframe_embed' => TICKET_SELECTOR_ASSETS_URL |
|
66 | + . 'ticket_selector_iframe_embed.js?ver=' |
|
67 | + . EVENT_ESPRESSO_VERSION, |
|
68 | + ), |
|
69 | + $this |
|
70 | + ) |
|
71 | + ); |
|
72 | + $this->addLocalizedVars( |
|
73 | + array( |
|
74 | + 'ticket_selector_iframe' => true, |
|
75 | + 'EEDTicketSelectorMsg' => __( |
|
76 | + 'Please choose at least one ticket before continuing.', |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + ) |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | // End of file TicketSelectorIframe.php |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\libraries\iframe_display\Iframe; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - \EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
32 | + \EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | 33 | /** @type \EEM_Event $EEM_Event */ |
34 | - $EEM_Event = \EE_Registry::instance()->load_model( 'Event' ); |
|
34 | + $EEM_Event = \EE_Registry::instance()->load_model('Event'); |
|
35 | 35 | $event = $EEM_Event->get_one_by_ID( |
36 | - \EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
36 | + \EE_Registry::instance()->REQ->get('event', 0) |
|
37 | 37 | ); |
38 | 38 | $ticket_selector = new DisplayTicketSelector(); |
39 | - $ticket_selector->setIframe( true ); |
|
39 | + $ticket_selector->setIframe(true); |
|
40 | 40 | parent::__construct( |
41 | - esc_html__( 'Ticket Selector', 'event_espresso' ), |
|
42 | - $ticket_selector->display( $event ) |
|
41 | + esc_html__('Ticket Selector', 'event_espresso'), |
|
42 | + $ticket_selector->display($event) |
|
43 | 43 | ); |
44 | 44 | $this->addStylesheets( |
45 | 45 | apply_filters( |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | ) |
57 | 57 | ); |
58 | 58 | if ( ! apply_filters('FHEE__EED_Ticket_Selector__ticket_selector_iframe__load_theme_css', false, $this)) { |
59 | - $this->addStylesheets( array('site_theme' => '' ) ); |
|
59 | + $this->addStylesheets(array('site_theme' => '')); |
|
60 | 60 | } |
61 | 61 | $this->addScripts( |
62 | 62 | apply_filters( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,151 +17,151 @@ discard block |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * enqueues css and js, so that this can be called statically |
|
22 | - */ |
|
23 | - public static function enqueue_styles_and_scripts() |
|
24 | - { |
|
25 | - wp_register_style( |
|
26 | - 'checkbox_dropdown_selector', |
|
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | - array('espresso_default'), |
|
29 | - EVENT_ESPRESSO_VERSION |
|
30 | - ); |
|
31 | - wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | - wp_register_script( |
|
33 | - 'checkbox_dropdown_selector', |
|
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | - array('jquery'), |
|
36 | - EVENT_ESPRESSO_VERSION, |
|
37 | - true |
|
38 | - ); |
|
39 | - wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | - */ |
|
47 | - public function enqueue_js(){ |
|
48 | - EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * callback for Iframe::addStylesheets() child class methods |
|
55 | - * |
|
56 | - * @param array $iframe_css |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | - return $iframe_css; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * callback for Iframe::addScripts() child class methods |
|
68 | - * |
|
69 | - * @param array $iframe_js |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | - return $iframe_js; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @throws EE_Error |
|
80 | - * @return string of html to display the field |
|
81 | - */ |
|
82 | - public function display() |
|
83 | - { |
|
84 | - $input = $this->get_input(); |
|
85 | - $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | - // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | - $input->set_label_sizes(); |
|
88 | - $label_size_class = $input->get_label_size_class(); |
|
89 | - if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | - EE_Error::doing_it_wrong( |
|
91 | - 'EE_Checkbox_Display_Strategy::display()', |
|
92 | - sprintf( |
|
93 | - esc_html__( |
|
94 | - 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - $input->html_id(), |
|
98 | - var_export($input->raw_value(), true), |
|
99 | - $input->html_name() . '[]' |
|
100 | - ), |
|
101 | - '4.8.1' |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | - // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | - $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | - $html .= $select_button_text; |
|
115 | - $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | - $html .= '</button>'; |
|
117 | - $html .= EEH_HTML::div( |
|
118 | - '', |
|
119 | - $input->html_id() . '-options-dv', |
|
120 | - 'checkbox-dropdown-selector' |
|
121 | - ); |
|
122 | - $html .= EEH_HTML::link( |
|
123 | - '', |
|
124 | - '<span class="dashicons dashicons-no"></span>', |
|
125 | - esc_html__('close datetime selector', 'event_espresso'), |
|
126 | - '', |
|
127 | - 'close-espresso-notice' |
|
128 | - ); |
|
129 | - $html .= EEH_HTML::ul(); |
|
130 | - $input_raw_value = (array)$input->raw_value(); |
|
131 | - foreach ($input->options() as $value => $display_text) { |
|
132 | - $html .= EEH_HTML::li(); |
|
133 | - $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | - $html_id = $this->get_sub_input_id($value); |
|
135 | - $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | - $html .= '<label for="' |
|
137 | - . $html_id |
|
138 | - . '" id="' |
|
139 | - . $html_id |
|
140 | - . '-lbl" class="ee-checkbox-label-after' |
|
141 | - . $label_size_class |
|
142 | - . '">'; |
|
143 | - $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | - $html .= '<input type="checkbox"'; |
|
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | - $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | - ? ' checked="checked"' |
|
152 | - : ''; |
|
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | - $html .= '>'; |
|
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | - $html .= EEH_HTML::lix(); |
|
158 | - } |
|
159 | - $html .= EEH_HTML::ulx(); |
|
160 | - $html .= EEH_HTML::divx(); |
|
161 | - $html .= EEH_HTML::divx(); |
|
162 | - $html .= \EEH_HTML::br(); |
|
163 | - return $html; |
|
164 | - } |
|
20 | + /** |
|
21 | + * enqueues css and js, so that this can be called statically |
|
22 | + */ |
|
23 | + public static function enqueue_styles_and_scripts() |
|
24 | + { |
|
25 | + wp_register_style( |
|
26 | + 'checkbox_dropdown_selector', |
|
27 | + EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
28 | + array('espresso_default'), |
|
29 | + EVENT_ESPRESSO_VERSION |
|
30 | + ); |
|
31 | + wp_enqueue_style('checkbox_dropdown_selector'); |
|
32 | + wp_register_script( |
|
33 | + 'checkbox_dropdown_selector', |
|
34 | + EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
35 | + array('jquery'), |
|
36 | + EVENT_ESPRESSO_VERSION, |
|
37 | + true |
|
38 | + ); |
|
39 | + wp_enqueue_script('checkbox_dropdown_selector'); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
46 | + */ |
|
47 | + public function enqueue_js(){ |
|
48 | + EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * callback for Iframe::addStylesheets() child class methods |
|
55 | + * |
|
56 | + * @param array $iframe_css |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function iframe_css(array $iframe_css){ |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
61 | + return $iframe_css; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * callback for Iframe::addScripts() child class methods |
|
68 | + * |
|
69 | + * @param array $iframe_js |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + public function iframe_js(array $iframe_js){ |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
74 | + return $iframe_js; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @throws EE_Error |
|
80 | + * @return string of html to display the field |
|
81 | + */ |
|
82 | + public function display() |
|
83 | + { |
|
84 | + $input = $this->get_input(); |
|
85 | + $select_button_text = $input instanceof EE_Checkbox_Dropdown_Selector_Input ? $input->select_button_text() : ''; |
|
86 | + // $multi = count( $input->options() ) > 1 ? TRUE : FALSE; |
|
87 | + $input->set_label_sizes(); |
|
88 | + $label_size_class = $input->get_label_size_class(); |
|
89 | + if ( ! is_array($input->raw_value()) && $input->raw_value() !== null) { |
|
90 | + EE_Error::doing_it_wrong( |
|
91 | + 'EE_Checkbox_Display_Strategy::display()', |
|
92 | + sprintf( |
|
93 | + esc_html__( |
|
94 | + 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + $input->html_id(), |
|
98 | + var_export($input->raw_value(), true), |
|
99 | + $input->html_name() . '[]' |
|
100 | + ), |
|
101 | + '4.8.1' |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
|
107 | + $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
108 | + // $html .= ' name="' . $input->html_name() . '"'; |
|
109 | + $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="' . $input->html_style() . '"'; |
|
111 | + $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | + $html .= ' ' . $input->html_other_attributes() . '>'; |
|
113 | + $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
|
114 | + $html .= $select_button_text; |
|
115 | + $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
|
116 | + $html .= '</button>'; |
|
117 | + $html .= EEH_HTML::div( |
|
118 | + '', |
|
119 | + $input->html_id() . '-options-dv', |
|
120 | + 'checkbox-dropdown-selector' |
|
121 | + ); |
|
122 | + $html .= EEH_HTML::link( |
|
123 | + '', |
|
124 | + '<span class="dashicons dashicons-no"></span>', |
|
125 | + esc_html__('close datetime selector', 'event_espresso'), |
|
126 | + '', |
|
127 | + 'close-espresso-notice' |
|
128 | + ); |
|
129 | + $html .= EEH_HTML::ul(); |
|
130 | + $input_raw_value = (array)$input->raw_value(); |
|
131 | + foreach ($input->options() as $value => $display_text) { |
|
132 | + $html .= EEH_HTML::li(); |
|
133 | + $value = $input->get_normalization_strategy()->unnormalize_one($value); |
|
134 | + $html_id = $this->get_sub_input_id($value); |
|
135 | + $html .= EEH_HTML::nl(0, 'checkbox'); |
|
136 | + $html .= '<label for="' |
|
137 | + . $html_id |
|
138 | + . '" id="' |
|
139 | + . $html_id |
|
140 | + . '-lbl" class="ee-checkbox-label-after' |
|
141 | + . $label_size_class |
|
142 | + . '">'; |
|
143 | + $html .= EEH_HTML::nl(1, 'checkbox'); |
|
144 | + $html .= '<input type="checkbox"'; |
|
145 | + $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | + $html .= ' id="' . $html_id . '"'; |
|
147 | + $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | + $html .= ' style="' . $input->html_style() . '"'; |
|
149 | + $html .= ' value="' . esc_attr($value) . '"'; |
|
150 | + $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
|
151 | + ? ' checked="checked"' |
|
152 | + : ''; |
|
153 | + $html .= ' ' . $this->_input->other_html_attributes(); |
|
154 | + $html .= '>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
157 | + $html .= EEH_HTML::lix(); |
|
158 | + } |
|
159 | + $html .= EEH_HTML::ulx(); |
|
160 | + $html .= EEH_HTML::divx(); |
|
161 | + $html .= EEH_HTML::divx(); |
|
162 | + $html .= \EEH_HTML::br(); |
|
163 | + return $html; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | 167 |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | wp_register_style( |
26 | 26 | 'checkbox_dropdown_selector', |
27 | - EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css', |
|
27 | + EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css', |
|
28 | 28 | array('espresso_default'), |
29 | 29 | EVENT_ESPRESSO_VERSION |
30 | 30 | ); |
31 | 31 | wp_enqueue_style('checkbox_dropdown_selector'); |
32 | 32 | wp_register_script( |
33 | 33 | 'checkbox_dropdown_selector', |
34 | - EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js', |
|
34 | + EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js', |
|
35 | 35 | array('jquery'), |
36 | 36 | EVENT_ESPRESSO_VERSION, |
37 | 37 | true |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * Informs the rest of the forms system what CSS and JS is needed to display the input |
46 | 46 | */ |
47 | - public function enqueue_js(){ |
|
47 | + public function enqueue_js() { |
|
48 | 48 | EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
49 | 49 | } |
50 | 50 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param array $iframe_css |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function iframe_css(array $iframe_css){ |
|
60 | - $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'css/checkbox_dropdown_selector.css'; |
|
59 | + public function iframe_css(array $iframe_css) { |
|
60 | + $iframe_css['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'css/checkbox_dropdown_selector.css'; |
|
61 | 61 | return $iframe_css; |
62 | 62 | } |
63 | 63 | |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @param array $iframe_js |
70 | 70 | * @return array |
71 | 71 | */ |
72 | - public function iframe_js(array $iframe_js){ |
|
73 | - $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL . 'scripts/checkbox_dropdown_selector.js'; |
|
72 | + public function iframe_js(array $iframe_js) { |
|
73 | + $iframe_js['checkbox_dropdown_selector'] = EE_GLOBAL_ASSETS_URL.'scripts/checkbox_dropdown_selector.js'; |
|
74 | 74 | return $iframe_js; |
75 | 75 | } |
76 | 76 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ), |
97 | 97 | $input->html_id(), |
98 | 98 | var_export($input->raw_value(), true), |
99 | - $input->html_name() . '[]' |
|
99 | + $input->html_name().'[]' |
|
100 | 100 | ), |
101 | 101 | '4.8.1' |
102 | 102 | ); |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | |
105 | 105 | |
106 | 106 | $html = \EEH_HTML::div('', '', 'checkbox-dropdown-selector-wrap-dv'); |
107 | - $html .= '<button id="' . $input->html_id() . '-btn"'; |
|
107 | + $html .= '<button id="'.$input->html_id().'-btn"'; |
|
108 | 108 | // $html .= ' name="' . $input->html_name() . '"'; |
109 | - $html .= ' class="' . $input->html_class() . ' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | - $html .= ' style="' . $input->html_style() . '"'; |
|
111 | - $html .= ' data-target="' . $input->html_id() . '-options-dv"'; |
|
112 | - $html .= ' ' . $input->html_other_attributes() . '>'; |
|
109 | + $html .= ' class="'.$input->html_class().' checkbox-dropdown-selector-btn button-secondary button"'; |
|
110 | + $html .= ' style="'.$input->html_style().'"'; |
|
111 | + $html .= ' data-target="'.$input->html_id().'-options-dv"'; |
|
112 | + $html .= ' '.$input->html_other_attributes().'>'; |
|
113 | 113 | $html .= '<span class="checkbox-dropdown-selector-selected-spn">'; |
114 | 114 | $html .= $select_button_text; |
115 | 115 | $html .= '</span> <span class="dashicons dashicons-arrow-down"></span>'; |
116 | 116 | $html .= '</button>'; |
117 | 117 | $html .= EEH_HTML::div( |
118 | 118 | '', |
119 | - $input->html_id() . '-options-dv', |
|
119 | + $input->html_id().'-options-dv', |
|
120 | 120 | 'checkbox-dropdown-selector' |
121 | 121 | ); |
122 | 122 | $html .= EEH_HTML::link( |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'close-espresso-notice' |
128 | 128 | ); |
129 | 129 | $html .= EEH_HTML::ul(); |
130 | - $input_raw_value = (array)$input->raw_value(); |
|
130 | + $input_raw_value = (array) $input->raw_value(); |
|
131 | 131 | foreach ($input->options() as $value => $display_text) { |
132 | 132 | $html .= EEH_HTML::li(); |
133 | 133 | $value = $input->get_normalization_strategy()->unnormalize_one($value); |
@@ -142,18 +142,18 @@ discard block |
||
142 | 142 | . '">'; |
143 | 143 | $html .= EEH_HTML::nl(1, 'checkbox'); |
144 | 144 | $html .= '<input type="checkbox"'; |
145 | - $html .= ' name="' . $input->html_name() . '[]"'; |
|
146 | - $html .= ' id="' . $html_id . '"'; |
|
147 | - $html .= ' class="' . $input->html_class() . '-option"'; |
|
148 | - $html .= ' style="' . $input->html_style() . '"'; |
|
149 | - $html .= ' value="' . esc_attr($value) . '"'; |
|
145 | + $html .= ' name="'.$input->html_name().'[]"'; |
|
146 | + $html .= ' id="'.$html_id.'"'; |
|
147 | + $html .= ' class="'.$input->html_class().'-option"'; |
|
148 | + $html .= ' style="'.$input->html_style().'"'; |
|
149 | + $html .= ' value="'.esc_attr($value).'"'; |
|
150 | 150 | $html .= ! empty($input_raw_value) && in_array($value, $input_raw_value, true) |
151 | 151 | ? ' checked="checked"' |
152 | 152 | : ''; |
153 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
153 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
154 | 154 | $html .= '>'; |
155 | - $html .= '<span class="datetime-selector-option-text-spn">' . $display_text . '</span>'; |
|
156 | - $html .= EEH_HTML::nl(-1, 'checkbox') . '</label>'; |
|
155 | + $html .= '<span class="datetime-selector-option-text-spn">'.$display_text.'</span>'; |
|
156 | + $html .= EEH_HTML::nl(-1, 'checkbox').'</label>'; |
|
157 | 157 | $html .= EEH_HTML::lix(); |
158 | 158 | } |
159 | 159 | $html .= EEH_HTML::ulx(); |
@@ -17,127 +17,127 @@ |
||
17 | 17 | class TicketSelectorStandard extends TicketSelector |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string $date_format |
|
22 | - */ |
|
23 | - protected $date_format; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string $time_format |
|
27 | - */ |
|
28 | - protected $time_format; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | - */ |
|
33 | - protected $ticket_selector_config; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \EE_Tax_Config $tax_config |
|
37 | - */ |
|
38 | - protected $tax_config; |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * TicketSelectorSimple constructor. |
|
44 | - * |
|
45 | - * @param \EE_Event $event |
|
46 | - * @param \EE_Ticket[] $tickets |
|
47 | - * @param int $max_attendees |
|
48 | - * @param array $template_args |
|
49 | - * @param string $date_format |
|
50 | - * @param string $time_format |
|
51 | - * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | - * @param \EE_Tax_Config $tax_config |
|
53 | - */ |
|
54 | - public function __construct( |
|
55 | - \EE_Event $event, |
|
56 | - array $tickets, |
|
57 | - $max_attendees, |
|
58 | - array $template_args, |
|
59 | - $date_format = 'Y-m-d', |
|
60 | - $time_format = 'g:i a', |
|
61 | - \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | - \EE_Tax_Config $tax_config = null |
|
63 | - ) { |
|
64 | - $this->date_format = $date_format; |
|
65 | - $this->time_format = $time_format; |
|
66 | - // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | - $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | - ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | - : new \EE_Ticket_Selector_Config(); |
|
70 | - // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | - // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | - // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | - $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | - ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | - : new \EE_Tax_Config(); |
|
76 | - parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * sets any and all template args that are required for this Ticket Selector |
|
83 | - * |
|
84 | - * @return void |
|
85 | - * @throws \EE_Error |
|
86 | - */ |
|
87 | - protected function addTemplateArgs() |
|
88 | - { |
|
89 | - $row = 1; |
|
90 | - $ticket_row_html = ''; |
|
91 | - $required_ticket_sold_out = false; |
|
92 | - // flag to indicate that at least one taxable ticket has been encountered |
|
93 | - $taxable_tickets = false; |
|
94 | - $datetime_selector = null; |
|
95 | - $this->template_args['datetime_selector'] = ''; |
|
96 | - if ( |
|
97 | - $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | - !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | - ) { |
|
100 | - $datetime_selector = new DatetimeSelector( |
|
101 | - $this->event, |
|
102 | - $this->tickets, |
|
103 | - $this->ticket_selector_config, |
|
104 | - $this->date_format, |
|
105 | - $this->time_format |
|
106 | - ); |
|
107 | - $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | - } |
|
109 | - // loop through tickets |
|
110 | - foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | - if ($ticket instanceof \EE_Ticket) { |
|
112 | - $cols = 2; |
|
113 | - $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | - $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | - $ticket, |
|
116 | - new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | - $this->ticket_selector_config, |
|
118 | - $this->tax_config, |
|
119 | - $this->max_attendees, |
|
120 | - $row, |
|
121 | - $cols, |
|
122 | - $required_ticket_sold_out, |
|
123 | - $this->template_args['event_status'], |
|
124 | - $this->template_args['date_format'], |
|
125 | - $datetime_selector instanceof DatetimeSelector |
|
126 | - ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | - : '' |
|
128 | - ); |
|
129 | - $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | - $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | - $row++; |
|
132 | - } |
|
133 | - } |
|
134 | - $this->template_args['row'] = $row; |
|
135 | - $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | - $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | - $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | - remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | - } |
|
20 | + /** |
|
21 | + * @var string $date_format |
|
22 | + */ |
|
23 | + protected $date_format; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string $time_format |
|
27 | + */ |
|
28 | + protected $time_format; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var \EE_Ticket_Selector_Config $ticket_selector_config |
|
32 | + */ |
|
33 | + protected $ticket_selector_config; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \EE_Tax_Config $tax_config |
|
37 | + */ |
|
38 | + protected $tax_config; |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * TicketSelectorSimple constructor. |
|
44 | + * |
|
45 | + * @param \EE_Event $event |
|
46 | + * @param \EE_Ticket[] $tickets |
|
47 | + * @param int $max_attendees |
|
48 | + * @param array $template_args |
|
49 | + * @param string $date_format |
|
50 | + * @param string $time_format |
|
51 | + * @param \EE_Ticket_Selector_Config $ticket_selector_config |
|
52 | + * @param \EE_Tax_Config $tax_config |
|
53 | + */ |
|
54 | + public function __construct( |
|
55 | + \EE_Event $event, |
|
56 | + array $tickets, |
|
57 | + $max_attendees, |
|
58 | + array $template_args, |
|
59 | + $date_format = 'Y-m-d', |
|
60 | + $time_format = 'g:i a', |
|
61 | + \EE_Ticket_Selector_Config $ticket_selector_config = null, |
|
62 | + \EE_Tax_Config $tax_config = null |
|
63 | + ) { |
|
64 | + $this->date_format = $date_format; |
|
65 | + $this->time_format = $time_format; |
|
66 | + // get EE_Ticket_Selector_Config and TicketDetails |
|
67 | + $this->ticket_selector_config = isset (\EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) |
|
68 | + ? \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector |
|
69 | + : new \EE_Ticket_Selector_Config(); |
|
70 | + // $template_settings->setDatetimeSelectorThreshold(2); |
|
71 | + // \EEH_Debug_Tools::printr($template_settings->getShowDatetimeSelector(), 'getShowDatetimeSelector', __FILE__, __LINE__); |
|
72 | + // \EEH_Debug_Tools::printr($template_settings->getDatetimeSelectorThreshold(), 'getDatetimeSelectorThreshold', __FILE__, __LINE__); |
|
73 | + $this->tax_config = isset (\EE_Registry::instance()->CFG->tax_settings) |
|
74 | + ? \EE_Registry::instance()->CFG->tax_settings |
|
75 | + : new \EE_Tax_Config(); |
|
76 | + parent::__construct($event, $tickets, $max_attendees, $template_args); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * sets any and all template args that are required for this Ticket Selector |
|
83 | + * |
|
84 | + * @return void |
|
85 | + * @throws \EE_Error |
|
86 | + */ |
|
87 | + protected function addTemplateArgs() |
|
88 | + { |
|
89 | + $row = 1; |
|
90 | + $ticket_row_html = ''; |
|
91 | + $required_ticket_sold_out = false; |
|
92 | + // flag to indicate that at least one taxable ticket has been encountered |
|
93 | + $taxable_tickets = false; |
|
94 | + $datetime_selector = null; |
|
95 | + $this->template_args['datetime_selector'] = ''; |
|
96 | + if ( |
|
97 | + $this->ticket_selector_config->getShowDatetimeSelector() |
|
98 | + !== \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
99 | + ) { |
|
100 | + $datetime_selector = new DatetimeSelector( |
|
101 | + $this->event, |
|
102 | + $this->tickets, |
|
103 | + $this->ticket_selector_config, |
|
104 | + $this->date_format, |
|
105 | + $this->time_format |
|
106 | + ); |
|
107 | + $this->template_args['datetime_selector'] = $datetime_selector->getDatetimeSelector(); |
|
108 | + } |
|
109 | + // loop through tickets |
|
110 | + foreach ($this->tickets as $TKT_ID => $ticket) { |
|
111 | + if ($ticket instanceof \EE_Ticket) { |
|
112 | + $cols = 2; |
|
113 | + $taxable_tickets = $ticket->taxable() ? true : $taxable_tickets; |
|
114 | + $ticket_selector_row = new TicketSelectorRowStandard( |
|
115 | + $ticket, |
|
116 | + new TicketDetails($ticket, $this->ticket_selector_config, $this->template_args), |
|
117 | + $this->ticket_selector_config, |
|
118 | + $this->tax_config, |
|
119 | + $this->max_attendees, |
|
120 | + $row, |
|
121 | + $cols, |
|
122 | + $required_ticket_sold_out, |
|
123 | + $this->template_args['event_status'], |
|
124 | + $this->template_args['date_format'], |
|
125 | + $datetime_selector instanceof DatetimeSelector |
|
126 | + ? $datetime_selector->getTicketDatetimeClasses($ticket) |
|
127 | + : '' |
|
128 | + ); |
|
129 | + $ticket_row_html .= $ticket_selector_row->getHtml(); |
|
130 | + $required_ticket_sold_out = $ticket_selector_row->getRequiredTicketSoldOut(); |
|
131 | + $row++; |
|
132 | + } |
|
133 | + } |
|
134 | + $this->template_args['row'] = $row; |
|
135 | + $this->template_args['ticket_row_html'] = $ticket_row_html; |
|
136 | + $this->template_args['taxable_tickets'] = $taxable_tickets; |
|
137 | + $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
139 | + remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | 143 |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $this->template_args['ticket_row_html'] = $ticket_row_html; |
136 | 136 | $this->template_args['taxable_tickets'] = $taxable_tickets; |
137 | 137 | $this->template_args['prices_displayed_including_taxes'] = $this->tax_config->prices_displayed_including_taxes; |
138 | - $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH . 'standard_ticket_selector.template.php'; |
|
138 | + $this->template_args['template_path'] = TICKET_SELECTOR_TEMPLATES_PATH.'standard_ticket_selector.template.php'; |
|
139 | 139 | remove_all_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector'); |
140 | 140 | } |
141 | 141 |