@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | { |
66 | 66 | // make sure autoloaders are set (fail-safe) |
67 | 67 | EED_Messages::set_autoloaders(); |
68 | - $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type'; |
|
69 | - $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : ''; |
|
68 | + $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages/message_type'; |
|
69 | + $folder .= $folder[strlen($folder) - 1] != '/' ? '/' : ''; |
|
70 | 70 | // get all the files in that folder that end in ".class.php |
71 | 71 | $filepaths = apply_filters( |
72 | 72 | 'FHEE__EE_messages__get_installed__messagetype_files', |
73 | - glob($folder . '*.class.php') |
|
73 | + glob($folder.'*.class.php') |
|
74 | 74 | ); |
75 | 75 | if (empty($filepaths)) { |
76 | 76 | return; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | |
89 | - if (! class_exists($message_type_class_name)) { |
|
89 | + if ( ! class_exists($message_type_class_name)) { |
|
90 | 90 | throw new EE_Error( |
91 | 91 | sprintf( |
92 | 92 | __('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'), |
@@ -15,105 +15,105 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @type EE_Message_Type_Collection $_message_type_collection |
|
20 | - */ |
|
21 | - protected $_message_type_collection = null; |
|
22 | - |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * EE_Message_Type_Collection_Loader constructor. |
|
27 | - * |
|
28 | - * @param EE_Message_Type_Collection $message_types |
|
29 | - */ |
|
30 | - public function __construct(EE_Message_Type_Collection $message_types) |
|
31 | - { |
|
32 | - $this->set_message_type_collection($message_types); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @return EE_Message_Type_Collection |
|
39 | - */ |
|
40 | - public function message_type_collection() |
|
41 | - { |
|
42 | - return $this->_message_type_collection; |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @param mixed $message_types |
|
49 | - */ |
|
50 | - public function set_message_type_collection(EE_Message_Type_Collection $message_types) |
|
51 | - { |
|
52 | - $this->_message_type_collection = $message_types; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * load_message_types |
|
59 | - * globs the supplied filepath and adds any found |
|
60 | - * |
|
61 | - * @param string $folder |
|
62 | - * @throws \EE_Error |
|
63 | - */ |
|
64 | - public function load_message_types_from_folder($folder = '') |
|
65 | - { |
|
66 | - // make sure autoloaders are set (fail-safe) |
|
67 | - EED_Messages::set_autoloaders(); |
|
68 | - $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type'; |
|
69 | - $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : ''; |
|
70 | - // get all the files in that folder that end in ".class.php |
|
71 | - $filepaths = apply_filters( |
|
72 | - 'FHEE__EE_messages__get_installed__messagetype_files', |
|
73 | - glob($folder . '*.class.php') |
|
74 | - ); |
|
75 | - if (empty($filepaths)) { |
|
76 | - return; |
|
77 | - } |
|
78 | - foreach ((array) $filepaths as $file_path) { |
|
79 | - // extract filename from path |
|
80 | - $file_path = basename($file_path); |
|
81 | - // now remove any file extensions |
|
82 | - $message_type_class_name = substr($file_path, 0, strpos($file_path, '.')); |
|
83 | - |
|
84 | - // if this class name doesn't represent a message type class, then we just skip. |
|
85 | - if (strpos(strtolower($message_type_class_name), 'message_type') === false) { |
|
86 | - continue; |
|
87 | - } |
|
88 | - |
|
89 | - if (! class_exists($message_type_class_name)) { |
|
90 | - throw new EE_Error( |
|
91 | - sprintf( |
|
92 | - __('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'), |
|
93 | - $message_type_class_name, |
|
94 | - $file_path |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - $this->_load_message_type(new $message_type_class_name()); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * Loads the given message type into the message type collection if it doesn't already exist. |
|
106 | - * @param EE_message_type $message_type |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - protected function _load_message_type(EE_message_type $message_type) |
|
110 | - { |
|
111 | - if ($this->message_type_collection()->has_by_name($message_type->name)) { |
|
112 | - return true; |
|
113 | - } |
|
114 | - return $this->message_type_collection()->add( |
|
115 | - $message_type, |
|
116 | - $message_type->name |
|
117 | - ); |
|
118 | - } |
|
18 | + /** |
|
19 | + * @type EE_Message_Type_Collection $_message_type_collection |
|
20 | + */ |
|
21 | + protected $_message_type_collection = null; |
|
22 | + |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * EE_Message_Type_Collection_Loader constructor. |
|
27 | + * |
|
28 | + * @param EE_Message_Type_Collection $message_types |
|
29 | + */ |
|
30 | + public function __construct(EE_Message_Type_Collection $message_types) |
|
31 | + { |
|
32 | + $this->set_message_type_collection($message_types); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @return EE_Message_Type_Collection |
|
39 | + */ |
|
40 | + public function message_type_collection() |
|
41 | + { |
|
42 | + return $this->_message_type_collection; |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @param mixed $message_types |
|
49 | + */ |
|
50 | + public function set_message_type_collection(EE_Message_Type_Collection $message_types) |
|
51 | + { |
|
52 | + $this->_message_type_collection = $message_types; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * load_message_types |
|
59 | + * globs the supplied filepath and adds any found |
|
60 | + * |
|
61 | + * @param string $folder |
|
62 | + * @throws \EE_Error |
|
63 | + */ |
|
64 | + public function load_message_types_from_folder($folder = '') |
|
65 | + { |
|
66 | + // make sure autoloaders are set (fail-safe) |
|
67 | + EED_Messages::set_autoloaders(); |
|
68 | + $folder = ! empty($folder) ? $folder : EE_LIBRARIES . 'messages/message_type'; |
|
69 | + $folder .= $folder[ strlen($folder) - 1 ] != '/' ? '/' : ''; |
|
70 | + // get all the files in that folder that end in ".class.php |
|
71 | + $filepaths = apply_filters( |
|
72 | + 'FHEE__EE_messages__get_installed__messagetype_files', |
|
73 | + glob($folder . '*.class.php') |
|
74 | + ); |
|
75 | + if (empty($filepaths)) { |
|
76 | + return; |
|
77 | + } |
|
78 | + foreach ((array) $filepaths as $file_path) { |
|
79 | + // extract filename from path |
|
80 | + $file_path = basename($file_path); |
|
81 | + // now remove any file extensions |
|
82 | + $message_type_class_name = substr($file_path, 0, strpos($file_path, '.')); |
|
83 | + |
|
84 | + // if this class name doesn't represent a message type class, then we just skip. |
|
85 | + if (strpos(strtolower($message_type_class_name), 'message_type') === false) { |
|
86 | + continue; |
|
87 | + } |
|
88 | + |
|
89 | + if (! class_exists($message_type_class_name)) { |
|
90 | + throw new EE_Error( |
|
91 | + sprintf( |
|
92 | + __('The "%1$s" message type class can\'t be loaded from %2$s. Likely there is a typo in the class name or the file name.', 'event_espresso'), |
|
93 | + $message_type_class_name, |
|
94 | + $file_path |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + $this->_load_message_type(new $message_type_class_name()); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * Loads the given message type into the message type collection if it doesn't already exist. |
|
106 | + * @param EE_message_type $message_type |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + protected function _load_message_type(EE_message_type $message_type) |
|
110 | + { |
|
111 | + if ($this->message_type_collection()->has_by_name($message_type->name)) { |
|
112 | + return true; |
|
113 | + } |
|
114 | + return $this->message_type_collection()->add( |
|
115 | + $message_type, |
|
116 | + $message_type->name |
|
117 | + ); |
|
118 | + } |
|
119 | 119 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function __construct($title, $content) |
84 | 84 | { |
85 | 85 | global $wp_version; |
86 | - if (! defined('EE_IFRAME_DIR_URL')) { |
|
86 | + if ( ! defined('EE_IFRAME_DIR_URL')) { |
|
87 | 87 | define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__)); |
88 | 88 | } |
89 | 89 | $this->setContent($content); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
94 | 94 | array( |
95 | 95 | 'site_theme' => get_stylesheet_directory_uri() |
96 | - . '/style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
97 | - 'dashicons' => includes_url('css/dashicons.min.css?ver=' . $wp_version), |
|
96 | + . '/style.css?ver='.EVENT_ESPRESSO_VERSION, |
|
97 | + 'dashicons' => includes_url('css/dashicons.min.css?ver='.$wp_version), |
|
98 | 98 | 'espresso_default' => EE_GLOBAL_ASSETS_URL |
99 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
99 | + . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION, |
|
100 | 100 | ), |
101 | 101 | $this |
102 | 102 | ) |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | apply_filters( |
106 | 106 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
107 | 107 | array( |
108 | - 'jquery' => includes_url('js/jquery/jquery.js?ver=' . $wp_version), |
|
108 | + 'jquery' => includes_url('js/jquery/jquery.js?ver='.$wp_version), |
|
109 | 109 | 'espresso_core' => EE_GLOBAL_ASSETS_URL |
110 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
110 | + . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
111 | 111 | ), |
112 | 112 | $this |
113 | 113 | ) |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | ); |
182 | 182 | } |
183 | 183 | foreach ($stylesheets as $handle => $stylesheet) { |
184 | - $this->css[ $handle ] = $stylesheet; |
|
184 | + $this->css[$handle] = $stylesheet; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | } |
204 | 204 | foreach ($scripts as $handle => $script) { |
205 | 205 | if ($add_to_header) { |
206 | - $this->header_js[ $handle ] = $script; |
|
206 | + $this->header_js[$handle] = $script; |
|
207 | 207 | } else { |
208 | - $this->footer_js[ $handle ] = $script; |
|
208 | + $this->footer_js[$handle] = $script; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | } |
229 | 229 | foreach ($script_attributes as $handle => $script_attribute) { |
230 | 230 | if ($add_to_header) { |
231 | - $this->header_js_attributes[ $handle ] = $script_attribute; |
|
231 | + $this->header_js_attributes[$handle] = $script_attribute; |
|
232 | 232 | } else { |
233 | - $this->footer_js_attributes[ $handle ] = $script_attribute; |
|
233 | + $this->footer_js_attributes[$handle] = $script_attribute; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -253,14 +253,14 @@ discard block |
||
253 | 253 | } |
254 | 254 | foreach ($vars as $handle => $var) { |
255 | 255 | if ($var_name === 'eei18n') { |
256 | - EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
256 | + EE_Registry::$i18n_js_strings[$handle] = $var; |
|
257 | 257 | } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') { |
258 | - $this->localized_vars[ $var_name ] = $var; |
|
258 | + $this->localized_vars[$var_name] = $var; |
|
259 | 259 | } else { |
260 | - if (! isset($this->localized_vars[ $var_name ])) { |
|
261 | - $this->localized_vars[ $var_name ] = array(); |
|
260 | + if ( ! isset($this->localized_vars[$var_name])) { |
|
261 | + $this->localized_vars[$var_name] = array(); |
|
262 | 262 | } |
263 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
263 | + $this->localized_vars[$var_name][$handle] = $var; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | public function getTemplate() |
291 | 291 | { |
292 | 292 | return EEH_Template::display_template( |
293 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
293 | + __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php', |
|
294 | 294 | array( |
295 | 295 | 'title' => apply_filters( |
296 | 296 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | ), |
335 | 335 | 'eei18n' => apply_filters( |
336 | 336 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
337 | - EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
337 | + EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(), |
|
338 | 338 | $this |
339 | 339 | ), |
340 | 340 | 'notices' => EEH_Template::display_template( |
341 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
341 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
342 | 342 | array(), |
343 | 343 | true |
344 | 344 | ), |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | { |
359 | 359 | $JSON = ''; |
360 | 360 | foreach ((array) $this->localized_vars as $var_name => $vars) { |
361 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars); |
|
361 | + $this->localized_vars[$var_name] = $this->encodeJsonVars($vars); |
|
362 | 362 | $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
363 | - $JSON .= wp_json_encode($this->localized_vars[ $var_name ]); |
|
363 | + $JSON .= wp_json_encode($this->localized_vars[$var_name]); |
|
364 | 364 | $JSON .= '; /* ]]> */'; |
365 | 365 | } |
366 | 366 | return $JSON; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | if (is_array($var)) { |
377 | 377 | $localized_vars = array(); |
378 | 378 | foreach ((array) $var as $key => $value) { |
379 | - $localized_vars[ $key ] = $this->encodeJsonVars($value); |
|
379 | + $localized_vars[$key] = $this->encodeJsonVars($value); |
|
380 | 380 | } |
381 | 381 | return $localized_vars; |
382 | 382 | } |
@@ -18,373 +18,373 @@ |
||
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 additional attributes to be added to <script> tags for header JS |
53 | 53 | * @var array $footer_js |
54 | 54 | */ |
55 | - protected $header_js_attributes = array(); |
|
55 | + protected $header_js_attributes = array(); |
|
56 | 56 | |
57 | - /* |
|
57 | + /* |
|
58 | 58 | * an array of JS URLs to be displayed before the HTML </body> tag |
59 | 59 | * @var array $footer_js |
60 | 60 | */ |
61 | - protected $footer_js = array(); |
|
61 | + protected $footer_js = array(); |
|
62 | 62 | |
63 | - /* |
|
63 | + /* |
|
64 | 64 | * an array of additional attributes to be added to <script> tags for footer JS |
65 | 65 | * @var array $footer_js_attributes |
66 | 66 | */ |
67 | - protected $footer_js_attributes = array(); |
|
67 | + protected $footer_js_attributes = array(); |
|
68 | 68 | |
69 | - /* |
|
69 | + /* |
|
70 | 70 | * an array of JSON vars to be set in the HTML header. |
71 | 71 | * @var array $localized_vars |
72 | 72 | */ |
73 | - protected $localized_vars = array(); |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Iframe constructor |
|
78 | - * |
|
79 | - * @param string $title |
|
80 | - * @param string $content |
|
81 | - * @throws DomainException |
|
82 | - */ |
|
83 | - public function __construct($title, $content) |
|
84 | - { |
|
85 | - global $wp_version; |
|
86 | - if (! defined('EE_IFRAME_DIR_URL')) { |
|
87 | - define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__)); |
|
88 | - } |
|
89 | - $this->setContent($content); |
|
90 | - $this->setTitle($title); |
|
91 | - $this->addStylesheets( |
|
92 | - apply_filters( |
|
93 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
94 | - array( |
|
95 | - 'site_theme' => get_stylesheet_directory_uri() |
|
96 | - . '/style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
97 | - 'dashicons' => includes_url('css/dashicons.min.css?ver=' . $wp_version), |
|
98 | - 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
99 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
100 | - ), |
|
101 | - $this |
|
102 | - ) |
|
103 | - ); |
|
104 | - $this->addScripts( |
|
105 | - apply_filters( |
|
106 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
107 | - array( |
|
108 | - 'jquery' => includes_url('js/jquery/jquery.js?ver=' . $wp_version), |
|
109 | - 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
110 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
111 | - ), |
|
112 | - $this |
|
113 | - ) |
|
114 | - ); |
|
115 | - if ( |
|
116 | - apply_filters( |
|
117 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
118 | - false |
|
119 | - ) |
|
120 | - ) { |
|
121 | - $this->addStylesheets( |
|
122 | - apply_filters( |
|
123 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
124 | - array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
125 | - $this |
|
126 | - ) |
|
127 | - ); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * @param string $title |
|
134 | - * @throws DomainException |
|
135 | - */ |
|
136 | - public function setTitle($title) |
|
137 | - { |
|
138 | - if (empty($title)) { |
|
139 | - throw new DomainException( |
|
140 | - esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso') |
|
141 | - ); |
|
142 | - } |
|
143 | - $this->title = $title; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @param string $content |
|
149 | - * @throws DomainException |
|
150 | - */ |
|
151 | - public function setContent($content) |
|
152 | - { |
|
153 | - if (empty($content)) { |
|
154 | - throw new DomainException( |
|
155 | - esc_html__('You must provide content in order to create an iframe.', 'event_espresso') |
|
156 | - ); |
|
157 | - } |
|
158 | - $this->content = $content; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param boolean $enqueue_wp_assets |
|
164 | - */ |
|
165 | - public function setEnqueueWpAssets($enqueue_wp_assets) |
|
166 | - { |
|
167 | - $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param array $stylesheets |
|
173 | - * @throws DomainException |
|
174 | - */ |
|
175 | - public function addStylesheets(array $stylesheets) |
|
176 | - { |
|
177 | - if (empty($stylesheets)) { |
|
178 | - throw new DomainException( |
|
179 | - esc_html__( |
|
180 | - 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
181 | - 'event_espresso' |
|
182 | - ) |
|
183 | - ); |
|
184 | - } |
|
185 | - foreach ($stylesheets as $handle => $stylesheet) { |
|
186 | - $this->css[ $handle ] = $stylesheet; |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param array $scripts |
|
193 | - * @param bool $add_to_header |
|
194 | - * @throws DomainException |
|
195 | - */ |
|
196 | - public function addScripts(array $scripts, $add_to_header = false) |
|
197 | - { |
|
198 | - if (empty($scripts)) { |
|
199 | - throw new DomainException( |
|
200 | - esc_html__( |
|
201 | - 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
202 | - 'event_espresso' |
|
203 | - ) |
|
204 | - ); |
|
205 | - } |
|
206 | - foreach ($scripts as $handle => $script) { |
|
207 | - if ($add_to_header) { |
|
208 | - $this->header_js[ $handle ] = $script; |
|
209 | - } else { |
|
210 | - $this->footer_js[ $handle ] = $script; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * @param array $script_attributes |
|
218 | - * @param bool $add_to_header |
|
219 | - * @throws DomainException |
|
220 | - */ |
|
221 | - public function addScriptAttributes(array $script_attributes, $add_to_header = false) |
|
222 | - { |
|
223 | - if (empty($script_attributes)) { |
|
224 | - throw new DomainException( |
|
225 | - esc_html__( |
|
226 | - 'A non-empty array of strings, is required to add attributes to iframe Javascript.', |
|
227 | - 'event_espresso' |
|
228 | - ) |
|
229 | - ); |
|
230 | - } |
|
231 | - foreach ($script_attributes as $handle => $script_attribute) { |
|
232 | - if ($add_to_header) { |
|
233 | - $this->header_js_attributes[ $handle ] = $script_attribute; |
|
234 | - } else { |
|
235 | - $this->footer_js_attributes[ $handle ] = $script_attribute; |
|
236 | - } |
|
237 | - } |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * @param array $vars |
|
243 | - * @param string $var_name |
|
244 | - * @throws DomainException |
|
245 | - */ |
|
246 | - public function addLocalizedVars(array $vars, $var_name = 'eei18n') |
|
247 | - { |
|
248 | - if (empty($vars)) { |
|
249 | - throw new DomainException( |
|
250 | - esc_html__( |
|
251 | - 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
252 | - 'event_espresso' |
|
253 | - ) |
|
254 | - ); |
|
255 | - } |
|
256 | - foreach ($vars as $handle => $var) { |
|
257 | - if ($var_name === 'eei18n') { |
|
258 | - EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
259 | - } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') { |
|
260 | - $this->localized_vars[ $var_name ] = $var; |
|
261 | - } else { |
|
262 | - if (! isset($this->localized_vars[ $var_name ])) { |
|
263 | - $this->localized_vars[ $var_name ] = array(); |
|
264 | - } |
|
265 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
266 | - } |
|
267 | - } |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * @param string $utm_content |
|
273 | - * @throws DomainException |
|
274 | - */ |
|
275 | - public function display($utm_content = '') |
|
276 | - { |
|
277 | - $this->content .= EEH_Template::powered_by_event_espresso( |
|
278 | - '', |
|
279 | - '', |
|
280 | - ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
281 | - ); |
|
282 | - EE_System::do_not_cache(); |
|
283 | - echo $this->getTemplate(); |
|
284 | - exit; |
|
285 | - } |
|
286 | - |
|
287 | - |
|
288 | - /** |
|
289 | - * @return string |
|
290 | - * @throws DomainException |
|
291 | - */ |
|
292 | - public function getTemplate() |
|
293 | - { |
|
294 | - return EEH_Template::display_template( |
|
295 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
296 | - array( |
|
297 | - 'title' => apply_filters( |
|
298 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
299 | - $this->title, |
|
300 | - $this |
|
301 | - ), |
|
302 | - 'content' => apply_filters( |
|
303 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
304 | - $this->content, |
|
305 | - $this |
|
306 | - ), |
|
307 | - 'enqueue_wp_assets' => apply_filters( |
|
308 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
309 | - $this->enqueue_wp_assets, |
|
310 | - $this |
|
311 | - ), |
|
312 | - 'css' => (array) apply_filters( |
|
313 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
314 | - $this->css, |
|
315 | - $this |
|
316 | - ), |
|
317 | - 'header_js' => (array) apply_filters( |
|
318 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
319 | - $this->header_js, |
|
320 | - $this |
|
321 | - ), |
|
322 | - 'header_js_attributes' => (array) apply_filters( |
|
323 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes', |
|
324 | - $this->header_js_attributes, |
|
325 | - $this |
|
326 | - ), |
|
327 | - 'footer_js' => (array) apply_filters( |
|
328 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
329 | - $this->footer_js, |
|
330 | - $this |
|
331 | - ), |
|
332 | - 'footer_js_attributes' => (array) apply_filters( |
|
333 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes', |
|
334 | - $this->footer_js_attributes, |
|
335 | - $this |
|
336 | - ), |
|
337 | - 'eei18n' => apply_filters( |
|
338 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
339 | - EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
340 | - $this |
|
341 | - ), |
|
342 | - 'notices' => EEH_Template::display_template( |
|
343 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
344 | - array(), |
|
345 | - true |
|
346 | - ), |
|
347 | - ), |
|
348 | - true, |
|
349 | - true |
|
350 | - ); |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * localizeJsonVars |
|
356 | - * |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - public function localizeJsonVars() |
|
360 | - { |
|
361 | - $JSON = ''; |
|
362 | - foreach ((array) $this->localized_vars as $var_name => $vars) { |
|
363 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars); |
|
364 | - $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
365 | - $JSON .= wp_json_encode($this->localized_vars[ $var_name ]); |
|
366 | - $JSON .= '; /* ]]> */'; |
|
367 | - } |
|
368 | - return $JSON; |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * @param bool|int|float|string|array $var |
|
374 | - * @return array |
|
375 | - */ |
|
376 | - public function encodeJsonVars($var) |
|
377 | - { |
|
378 | - if (is_array($var)) { |
|
379 | - $localized_vars = array(); |
|
380 | - foreach ((array) $var as $key => $value) { |
|
381 | - $localized_vars[ $key ] = $this->encodeJsonVars($value); |
|
382 | - } |
|
383 | - return $localized_vars; |
|
384 | - } |
|
385 | - if (is_scalar($var)) { |
|
386 | - return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8'); |
|
387 | - } |
|
388 | - return null; |
|
389 | - } |
|
73 | + protected $localized_vars = array(); |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Iframe constructor |
|
78 | + * |
|
79 | + * @param string $title |
|
80 | + * @param string $content |
|
81 | + * @throws DomainException |
|
82 | + */ |
|
83 | + public function __construct($title, $content) |
|
84 | + { |
|
85 | + global $wp_version; |
|
86 | + if (! defined('EE_IFRAME_DIR_URL')) { |
|
87 | + define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__)); |
|
88 | + } |
|
89 | + $this->setContent($content); |
|
90 | + $this->setTitle($title); |
|
91 | + $this->addStylesheets( |
|
92 | + apply_filters( |
|
93 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
94 | + array( |
|
95 | + 'site_theme' => get_stylesheet_directory_uri() |
|
96 | + . '/style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
97 | + 'dashicons' => includes_url('css/dashicons.min.css?ver=' . $wp_version), |
|
98 | + 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
99 | + . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
100 | + ), |
|
101 | + $this |
|
102 | + ) |
|
103 | + ); |
|
104 | + $this->addScripts( |
|
105 | + apply_filters( |
|
106 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
107 | + array( |
|
108 | + 'jquery' => includes_url('js/jquery/jquery.js?ver=' . $wp_version), |
|
109 | + 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
110 | + . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
111 | + ), |
|
112 | + $this |
|
113 | + ) |
|
114 | + ); |
|
115 | + if ( |
|
116 | + apply_filters( |
|
117 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
118 | + false |
|
119 | + ) |
|
120 | + ) { |
|
121 | + $this->addStylesheets( |
|
122 | + apply_filters( |
|
123 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
124 | + array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
125 | + $this |
|
126 | + ) |
|
127 | + ); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * @param string $title |
|
134 | + * @throws DomainException |
|
135 | + */ |
|
136 | + public function setTitle($title) |
|
137 | + { |
|
138 | + if (empty($title)) { |
|
139 | + throw new DomainException( |
|
140 | + esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso') |
|
141 | + ); |
|
142 | + } |
|
143 | + $this->title = $title; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @param string $content |
|
149 | + * @throws DomainException |
|
150 | + */ |
|
151 | + public function setContent($content) |
|
152 | + { |
|
153 | + if (empty($content)) { |
|
154 | + throw new DomainException( |
|
155 | + esc_html__('You must provide content in order to create an iframe.', 'event_espresso') |
|
156 | + ); |
|
157 | + } |
|
158 | + $this->content = $content; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param boolean $enqueue_wp_assets |
|
164 | + */ |
|
165 | + public function setEnqueueWpAssets($enqueue_wp_assets) |
|
166 | + { |
|
167 | + $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param array $stylesheets |
|
173 | + * @throws DomainException |
|
174 | + */ |
|
175 | + public function addStylesheets(array $stylesheets) |
|
176 | + { |
|
177 | + if (empty($stylesheets)) { |
|
178 | + throw new DomainException( |
|
179 | + esc_html__( |
|
180 | + 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
181 | + 'event_espresso' |
|
182 | + ) |
|
183 | + ); |
|
184 | + } |
|
185 | + foreach ($stylesheets as $handle => $stylesheet) { |
|
186 | + $this->css[ $handle ] = $stylesheet; |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param array $scripts |
|
193 | + * @param bool $add_to_header |
|
194 | + * @throws DomainException |
|
195 | + */ |
|
196 | + public function addScripts(array $scripts, $add_to_header = false) |
|
197 | + { |
|
198 | + if (empty($scripts)) { |
|
199 | + throw new DomainException( |
|
200 | + esc_html__( |
|
201 | + 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
202 | + 'event_espresso' |
|
203 | + ) |
|
204 | + ); |
|
205 | + } |
|
206 | + foreach ($scripts as $handle => $script) { |
|
207 | + if ($add_to_header) { |
|
208 | + $this->header_js[ $handle ] = $script; |
|
209 | + } else { |
|
210 | + $this->footer_js[ $handle ] = $script; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * @param array $script_attributes |
|
218 | + * @param bool $add_to_header |
|
219 | + * @throws DomainException |
|
220 | + */ |
|
221 | + public function addScriptAttributes(array $script_attributes, $add_to_header = false) |
|
222 | + { |
|
223 | + if (empty($script_attributes)) { |
|
224 | + throw new DomainException( |
|
225 | + esc_html__( |
|
226 | + 'A non-empty array of strings, is required to add attributes to iframe Javascript.', |
|
227 | + 'event_espresso' |
|
228 | + ) |
|
229 | + ); |
|
230 | + } |
|
231 | + foreach ($script_attributes as $handle => $script_attribute) { |
|
232 | + if ($add_to_header) { |
|
233 | + $this->header_js_attributes[ $handle ] = $script_attribute; |
|
234 | + } else { |
|
235 | + $this->footer_js_attributes[ $handle ] = $script_attribute; |
|
236 | + } |
|
237 | + } |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * @param array $vars |
|
243 | + * @param string $var_name |
|
244 | + * @throws DomainException |
|
245 | + */ |
|
246 | + public function addLocalizedVars(array $vars, $var_name = 'eei18n') |
|
247 | + { |
|
248 | + if (empty($vars)) { |
|
249 | + throw new DomainException( |
|
250 | + esc_html__( |
|
251 | + 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
252 | + 'event_espresso' |
|
253 | + ) |
|
254 | + ); |
|
255 | + } |
|
256 | + foreach ($vars as $handle => $var) { |
|
257 | + if ($var_name === 'eei18n') { |
|
258 | + EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
259 | + } elseif ($var_name === 'eeCAL' && $handle === 'espresso_calendar') { |
|
260 | + $this->localized_vars[ $var_name ] = $var; |
|
261 | + } else { |
|
262 | + if (! isset($this->localized_vars[ $var_name ])) { |
|
263 | + $this->localized_vars[ $var_name ] = array(); |
|
264 | + } |
|
265 | + $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
266 | + } |
|
267 | + } |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * @param string $utm_content |
|
273 | + * @throws DomainException |
|
274 | + */ |
|
275 | + public function display($utm_content = '') |
|
276 | + { |
|
277 | + $this->content .= EEH_Template::powered_by_event_espresso( |
|
278 | + '', |
|
279 | + '', |
|
280 | + ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
281 | + ); |
|
282 | + EE_System::do_not_cache(); |
|
283 | + echo $this->getTemplate(); |
|
284 | + exit; |
|
285 | + } |
|
286 | + |
|
287 | + |
|
288 | + /** |
|
289 | + * @return string |
|
290 | + * @throws DomainException |
|
291 | + */ |
|
292 | + public function getTemplate() |
|
293 | + { |
|
294 | + return EEH_Template::display_template( |
|
295 | + __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
296 | + array( |
|
297 | + 'title' => apply_filters( |
|
298 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
299 | + $this->title, |
|
300 | + $this |
|
301 | + ), |
|
302 | + 'content' => apply_filters( |
|
303 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
304 | + $this->content, |
|
305 | + $this |
|
306 | + ), |
|
307 | + 'enqueue_wp_assets' => apply_filters( |
|
308 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
309 | + $this->enqueue_wp_assets, |
|
310 | + $this |
|
311 | + ), |
|
312 | + 'css' => (array) apply_filters( |
|
313 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
314 | + $this->css, |
|
315 | + $this |
|
316 | + ), |
|
317 | + 'header_js' => (array) apply_filters( |
|
318 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
319 | + $this->header_js, |
|
320 | + $this |
|
321 | + ), |
|
322 | + 'header_js_attributes' => (array) apply_filters( |
|
323 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_attributes', |
|
324 | + $this->header_js_attributes, |
|
325 | + $this |
|
326 | + ), |
|
327 | + 'footer_js' => (array) apply_filters( |
|
328 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
329 | + $this->footer_js, |
|
330 | + $this |
|
331 | + ), |
|
332 | + 'footer_js_attributes' => (array) apply_filters( |
|
333 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_attributes', |
|
334 | + $this->footer_js_attributes, |
|
335 | + $this |
|
336 | + ), |
|
337 | + 'eei18n' => apply_filters( |
|
338 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
339 | + EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
340 | + $this |
|
341 | + ), |
|
342 | + 'notices' => EEH_Template::display_template( |
|
343 | + EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
344 | + array(), |
|
345 | + true |
|
346 | + ), |
|
347 | + ), |
|
348 | + true, |
|
349 | + true |
|
350 | + ); |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * localizeJsonVars |
|
356 | + * |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + public function localizeJsonVars() |
|
360 | + { |
|
361 | + $JSON = ''; |
|
362 | + foreach ((array) $this->localized_vars as $var_name => $vars) { |
|
363 | + $this->localized_vars[ $var_name ] = $this->encodeJsonVars($vars); |
|
364 | + $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
365 | + $JSON .= wp_json_encode($this->localized_vars[ $var_name ]); |
|
366 | + $JSON .= '; /* ]]> */'; |
|
367 | + } |
|
368 | + return $JSON; |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * @param bool|int|float|string|array $var |
|
374 | + * @return array |
|
375 | + */ |
|
376 | + public function encodeJsonVars($var) |
|
377 | + { |
|
378 | + if (is_array($var)) { |
|
379 | + $localized_vars = array(); |
|
380 | + foreach ((array) $var as $key => $value) { |
|
381 | + $localized_vars[ $key ] = $this->encodeJsonVars($value); |
|
382 | + } |
|
383 | + return $localized_vars; |
|
384 | + } |
|
385 | + if (is_scalar($var)) { |
|
386 | + return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8'); |
|
387 | + } |
|
388 | + return null; |
|
389 | + } |
|
390 | 390 | } |
@@ -17,135 +17,135 @@ |
||
17 | 17 | */ |
18 | 18 | abstract class JobHandlerFile extends JobHandler |
19 | 19 | { |
20 | - // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
21 | - const temp_folder_name = 'batch_temp_folder'; |
|
20 | + // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
21 | + const temp_folder_name = 'batch_temp_folder'; |
|
22 | 22 | |
23 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
24 | - /** |
|
25 | - * @var \EEHI_File |
|
26 | - */ |
|
27 | - protected $_file_helper = null; |
|
23 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
24 | + /** |
|
25 | + * @var \EEHI_File |
|
26 | + */ |
|
27 | + protected $_file_helper = null; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * JobHandlerFile constructor. |
|
32 | - * |
|
33 | - * @param \EEHI_File|null $file_helper |
|
34 | - */ |
|
35 | - public function __construct(\EEHI_File $file_helper = null) |
|
36 | - { |
|
37 | - if (! $file_helper) { |
|
38 | - $this->_file_helper = new EEH_File(); |
|
39 | - } |
|
40 | - } |
|
30 | + /** |
|
31 | + * JobHandlerFile constructor. |
|
32 | + * |
|
33 | + * @param \EEHI_File|null $file_helper |
|
34 | + */ |
|
35 | + public function __construct(\EEHI_File $file_helper = null) |
|
36 | + { |
|
37 | + if (! $file_helper) { |
|
38 | + $this->_file_helper = new EEH_File(); |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | - /** |
|
44 | - * Creates a file |
|
45 | - * |
|
46 | - * @param string $job_id |
|
47 | - * @param string $filename |
|
48 | - * @param string $filetype |
|
49 | - * @param string $bom initial content to place in the file. |
|
50 | - * @return string |
|
51 | - * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
52 | - */ |
|
53 | - public function create_file_from_job_with_name( |
|
54 | - $job_id, |
|
55 | - $filename, |
|
56 | - $filetype = 'application/ms-excel', |
|
57 | - $bom = "\xEF\xBB\xBF" |
|
58 | - ) { |
|
59 | - $filepath = ''; |
|
60 | - try { |
|
61 | - $base_folder = $this->get_base_folder(); |
|
62 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
63 | - $base_folder . JobHandlerFile::temp_folder_name |
|
64 | - ); |
|
65 | - if ($success) { |
|
66 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
67 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
68 | - ); |
|
69 | - } |
|
70 | - if ($success) { |
|
71 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
72 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
73 | - } |
|
74 | - // let's add the .htaccess file so safari will open the file properly |
|
75 | - if ($success) { |
|
76 | - $extension = EEH_File::get_file_extension($filepath); |
|
77 | - EEH_File::write_to_file( |
|
78 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
79 | - 'AddType ' . $filetype . ' ' . $extension, |
|
80 | - '.htaccess' |
|
81 | - ); |
|
82 | - } |
|
83 | - /** |
|
84 | - * Filters what initial content will be added to the file. |
|
85 | - * @param string $return_value. By default it's whatever was pased into |
|
86 | - * JobHandlerFile::create_file_from_job_with_name() |
|
87 | - * @param string $filename |
|
88 | - * @param string $filetype default 'application/ms-excel' |
|
89 | - * @param string $filepath |
|
90 | - */ |
|
91 | - EEH_File::write_to_file( |
|
92 | - $filepath, |
|
93 | - apply_filters( |
|
94 | - 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
95 | - $bom, |
|
96 | - $filename, |
|
97 | - $filetype, |
|
98 | - $filepath |
|
99 | - ) |
|
100 | - ); |
|
101 | - // those methods normally fail with an exception, but if not, let's do it |
|
102 | - if (! $success) { |
|
103 | - throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
104 | - } |
|
105 | - } catch (\EE_Error $e) { |
|
106 | - throw new BatchRequestException( |
|
107 | - sprintf( |
|
108 | - // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
109 | - __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
110 | - $job_id, |
|
111 | - $e->getMessage() |
|
112 | - ), |
|
113 | - 500, |
|
114 | - $e |
|
115 | - ); |
|
116 | - } |
|
117 | - return $filepath; |
|
118 | - } |
|
42 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | + /** |
|
44 | + * Creates a file |
|
45 | + * |
|
46 | + * @param string $job_id |
|
47 | + * @param string $filename |
|
48 | + * @param string $filetype |
|
49 | + * @param string $bom initial content to place in the file. |
|
50 | + * @return string |
|
51 | + * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
52 | + */ |
|
53 | + public function create_file_from_job_with_name( |
|
54 | + $job_id, |
|
55 | + $filename, |
|
56 | + $filetype = 'application/ms-excel', |
|
57 | + $bom = "\xEF\xBB\xBF" |
|
58 | + ) { |
|
59 | + $filepath = ''; |
|
60 | + try { |
|
61 | + $base_folder = $this->get_base_folder(); |
|
62 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
63 | + $base_folder . JobHandlerFile::temp_folder_name |
|
64 | + ); |
|
65 | + if ($success) { |
|
66 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
67 | + $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
68 | + ); |
|
69 | + } |
|
70 | + if ($success) { |
|
71 | + $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
72 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
73 | + } |
|
74 | + // let's add the .htaccess file so safari will open the file properly |
|
75 | + if ($success) { |
|
76 | + $extension = EEH_File::get_file_extension($filepath); |
|
77 | + EEH_File::write_to_file( |
|
78 | + $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
79 | + 'AddType ' . $filetype . ' ' . $extension, |
|
80 | + '.htaccess' |
|
81 | + ); |
|
82 | + } |
|
83 | + /** |
|
84 | + * Filters what initial content will be added to the file. |
|
85 | + * @param string $return_value. By default it's whatever was pased into |
|
86 | + * JobHandlerFile::create_file_from_job_with_name() |
|
87 | + * @param string $filename |
|
88 | + * @param string $filetype default 'application/ms-excel' |
|
89 | + * @param string $filepath |
|
90 | + */ |
|
91 | + EEH_File::write_to_file( |
|
92 | + $filepath, |
|
93 | + apply_filters( |
|
94 | + 'FHEE__EE_CSV__begin_sending_csv__start_writing', |
|
95 | + $bom, |
|
96 | + $filename, |
|
97 | + $filetype, |
|
98 | + $filepath |
|
99 | + ) |
|
100 | + ); |
|
101 | + // those methods normally fail with an exception, but if not, let's do it |
|
102 | + if (! $success) { |
|
103 | + throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
104 | + } |
|
105 | + } catch (\EE_Error $e) { |
|
106 | + throw new BatchRequestException( |
|
107 | + sprintf( |
|
108 | + // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment |
|
109 | + __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
110 | + $job_id, |
|
111 | + $e->getMessage() |
|
112 | + ), |
|
113 | + 500, |
|
114 | + $e |
|
115 | + ); |
|
116 | + } |
|
117 | + return $filepath; |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Gets the URL to download the file |
|
122 | - * |
|
123 | - * @param string $filepath |
|
124 | - * @return string url to file |
|
125 | - */ |
|
126 | - public function get_url_to_file($filepath) |
|
127 | - { |
|
128 | - return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
129 | - } |
|
120 | + /** |
|
121 | + * Gets the URL to download the file |
|
122 | + * |
|
123 | + * @param string $filepath |
|
124 | + * @return string url to file |
|
125 | + */ |
|
126 | + public function get_url_to_file($filepath) |
|
127 | + { |
|
128 | + return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Gets the folder which will contain the "batch_temp_folder" |
|
133 | - * |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function get_base_folder() |
|
137 | - { |
|
138 | - return apply_filters( |
|
139 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
140 | - EVENT_ESPRESSO_UPLOAD_DIR |
|
141 | - ); |
|
142 | - } |
|
131 | + /** |
|
132 | + * Gets the folder which will contain the "batch_temp_folder" |
|
133 | + * |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function get_base_folder() |
|
137 | + { |
|
138 | + return apply_filters( |
|
139 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
140 | + EVENT_ESPRESSO_UPLOAD_DIR |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | |
144 | - public function get_base_url() |
|
145 | - { |
|
146 | - return apply_filters( |
|
147 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
148 | - EVENT_ESPRESSO_UPLOAD_URL |
|
149 | - ); |
|
150 | - } |
|
144 | + public function get_base_url() |
|
145 | + { |
|
146 | + return apply_filters( |
|
147 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
148 | + EVENT_ESPRESSO_UPLOAD_URL |
|
149 | + ); |
|
150 | + } |
|
151 | 151 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function __construct(\EEHI_File $file_helper = null) |
36 | 36 | { |
37 | - if (! $file_helper) { |
|
37 | + if ( ! $file_helper) { |
|
38 | 38 | $this->_file_helper = new EEH_File(); |
39 | 39 | } |
40 | 40 | } |
@@ -60,23 +60,23 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $base_folder = $this->get_base_folder(); |
62 | 62 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
63 | - $base_folder . JobHandlerFile::temp_folder_name |
|
63 | + $base_folder.JobHandlerFile::temp_folder_name |
|
64 | 64 | ); |
65 | 65 | if ($success) { |
66 | 66 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
67 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id |
|
67 | + $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | if ($success) { |
71 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/' . $filename; |
|
71 | + $filepath = $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id.'/'.$filename; |
|
72 | 72 | $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
73 | 73 | } |
74 | 74 | // let's add the .htaccess file so safari will open the file properly |
75 | 75 | if ($success) { |
76 | 76 | $extension = EEH_File::get_file_extension($filepath); |
77 | 77 | EEH_File::write_to_file( |
78 | - $base_folder . JobHandlerFile::temp_folder_name . '/' . $job_id . '/.htaccess', |
|
79 | - 'AddType ' . $filetype . ' ' . $extension, |
|
78 | + $base_folder.JobHandlerFile::temp_folder_name.'/'.$job_id.'/.htaccess', |
|
79 | + 'AddType '.$filetype.' '.$extension, |
|
80 | 80 | '.htaccess' |
81 | 81 | ); |
82 | 82 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ) |
100 | 100 | ); |
101 | 101 | // those methods normally fail with an exception, but if not, let's do it |
102 | - if (! $success) { |
|
102 | + if ( ! $success) { |
|
103 | 103 | throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
104 | 104 | } |
105 | 105 | } catch (\EE_Error $e) { |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public static function set_definitions() |
128 | 128 | { |
129 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
129 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
130 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | return $this->_current_txn; |
143 | 143 | } |
144 | 144 | $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
145 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
145 | + if ( ! $TXN_model instanceof EEM_Transaction) { |
|
146 | 146 | EE_Error::add_error( |
147 | 147 | __('The transaction model could not be established.', 'event_espresso'), |
148 | 148 | __FILE__, |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function get_txn_payments($since = 0) |
181 | 181 | { |
182 | - if (! $this->get_txn()) { |
|
182 | + if ( ! $this->get_txn()) { |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function _get_reg_url_link() |
211 | 211 | { |
212 | - if (! empty($this->_reg_url_link)) { |
|
212 | + if ( ! empty($this->_reg_url_link)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | // only do thank you page stuff if we have a REG_url_link in the url |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | { |
322 | 322 | wp_register_script( |
323 | 323 | 'thank_you_page', |
324 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
324 | + THANK_YOU_ASSETS_URL.'thank_you_page.js', |
|
325 | 325 | array('espresso_core', 'heartbeat'), |
326 | 326 | EVENT_ESPRESSO_VERSION, |
327 | 327 | true |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | public function init() |
341 | 341 | { |
342 | 342 | $this->_get_reg_url_link(); |
343 | - if (! $this->get_txn()) { |
|
343 | + if ( ! $this->get_txn()) { |
|
344 | 344 | echo EEH_HTML::div( |
345 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
345 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', ''). |
|
346 | 346 | sprintf( |
347 | 347 | __( |
348 | 348 | 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | public function thank_you_page_results() |
433 | 433 | { |
434 | 434 | $this->init(); |
435 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
435 | + if ( ! $this->_current_txn instanceof EE_Transaction) { |
|
436 | 436 | return EE_Error::get_notices(); |
437 | 437 | } |
438 | 438 | // link to receipt |
439 | 439 | $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
440 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
440 | + if ( ! empty($template_args['TXN_receipt_url'])) { |
|
441 | 441 | $template_args['order_conf_desc'] = __( |
442 | 442 | '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
443 | 443 | 'event_espresso' |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
456 | 456 | } |
457 | 457 | return EEH_Template::locate_template( |
458 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
458 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php', |
|
459 | 459 | $template_args, |
460 | 460 | true, |
461 | 461 | true |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | '$SPCO_attendee_information_url' |
508 | 508 | ); |
509 | 509 | echo EEH_Template::locate_template( |
510 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
510 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php', |
|
511 | 511 | $template_args, |
512 | 512 | true, |
513 | 513 | true |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function get_ajax_content() |
582 | 582 | { |
583 | - if (! $this->get_txn()) { |
|
583 | + if ( ! $this->get_txn()) { |
|
584 | 584 | return; |
585 | 585 | } |
586 | 586 | // first determine which event(s) require pre-approval or not |
@@ -591,9 +591,9 @@ discard block |
||
591 | 591 | $event = $registration->event(); |
592 | 592 | if ($event instanceof EE_Event) { |
593 | 593 | if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
594 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
594 | + $events_requiring_pre_approval[$event->ID()] = $event; |
|
595 | 595 | } else { |
596 | - $events[ $event->ID() ] = $event; |
|
596 | + $events[$event->ID()] = $event; |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function display_details_for_events($events = array()) |
613 | 613 | { |
614 | - if (! empty($events)) { |
|
614 | + if ( ! empty($events)) { |
|
615 | 615 | ?> |
616 | 616 | <div id="espresso-thank-you-page-ajax-content-dv"> |
617 | 617 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | 'event_espresso' |
625 | 625 | ); ?></span> |
626 | 626 | </div> |
627 | - <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
627 | + <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
|
628 | 628 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
629 | 629 | <?php echo apply_filters( |
630 | 630 | 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | */ |
656 | 656 | public function display_details_for_events_requiring_pre_approval($events = array()) |
657 | 657 | { |
658 | - if (! empty($events)) { |
|
658 | + if ( ! empty($events)) { |
|
659 | 659 | ?> |
660 | 660 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
661 | 661 | <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | '$SPCO_payment_options_url' |
713 | 713 | ); |
714 | 714 | return EEH_Template::locate_template( |
715 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
715 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php', |
|
716 | 716 | $template_args, |
717 | 717 | true, |
718 | 718 | true |
@@ -741,25 +741,25 @@ discard block |
||
741 | 741 | $payment->set_status(EEM_Payment::status_id_pending); |
742 | 742 | } |
743 | 743 | $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
744 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
744 | + ? '<br /><span class="small-text">'.$payment->gateway_response().'</span>' |
|
745 | 745 | : ''; |
746 | 746 | $html .= ' |
747 | 747 | <tr> |
748 | 748 | <td> |
749 | - ' . $payment->timestamp() . ' |
|
749 | + ' . $payment->timestamp().' |
|
750 | 750 | </td> |
751 | 751 | <td> |
752 | 752 | ' . ( |
753 | 753 | $payment->payment_method() instanceof EE_Payment_Method |
754 | 754 | ? $payment->payment_method()->name() |
755 | 755 | : __('Unknown', 'event_espresso') |
756 | - ) . ' |
|
756 | + ).' |
|
757 | 757 | </td> |
758 | 758 | <td class="jst-rght"> |
759 | - ' . EEH_Template::format_currency($payment->amount()) . ' |
|
759 | + ' . EEH_Template::format_currency($payment->amount()).' |
|
760 | 760 | </td> |
761 | 761 | <td class="jst-rght" style="line-height:1;"> |
762 | - ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
|
762 | + ' . $payment->pretty_status(true).$payment_declined_msg.' |
|
763 | 763 | </td> |
764 | 764 | </tr>'; |
765 | 765 | do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | '$SPCO_payment_options_url' |
818 | 818 | ); |
819 | 819 | return EEH_Template::locate_template( |
820 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
820 | + THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php', |
|
821 | 821 | $template_args, |
822 | 822 | true, |
823 | 823 | true |
@@ -10,611 +10,611 @@ discard block |
||
10 | 10 | class EED_Thank_You_Page extends EED_Module |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
15 | - */ |
|
16 | - const IPN_wait_time = 1200; |
|
17 | - |
|
18 | - /** |
|
19 | - * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
20 | - * |
|
21 | - * @var EE_Transaction $_current_txn |
|
22 | - */ |
|
23 | - private $_current_txn; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var EE_Registration $_primary_registrant |
|
27 | - */ |
|
28 | - private $_primary_registrant; |
|
29 | - |
|
30 | - /** |
|
31 | - * The reg_url_link passed from the Request, or from the Session |
|
32 | - * |
|
33 | - * @var string $_reg_url_link |
|
34 | - */ |
|
35 | - private $_reg_url_link; |
|
36 | - |
|
37 | - /** |
|
38 | - * whether the incoming reg_url_link is for the primary registrant or not |
|
39 | - * |
|
40 | - * @var boolean $_is_primary |
|
41 | - */ |
|
42 | - private $_is_primary; |
|
43 | - |
|
44 | - /** |
|
45 | - * The URL for revisiting the SPCO attendee information step |
|
46 | - * |
|
47 | - * @var string $_SPCO_attendee_information_url |
|
48 | - */ |
|
49 | - private $_SPCO_attendee_information_url; |
|
50 | - |
|
51 | - /** |
|
52 | - * The URL for revisiting the SPCO payment options step |
|
53 | - * |
|
54 | - * @var string $_SPCO_payment_options_url |
|
55 | - */ |
|
56 | - private $_SPCO_payment_options_url; |
|
57 | - |
|
58 | - /** |
|
59 | - * whether to display the Payment Options link |
|
60 | - * |
|
61 | - * @var boolean $_show_try_pay_again_link |
|
62 | - */ |
|
63 | - private $_show_try_pay_again_link = false; |
|
64 | - |
|
65 | - /** |
|
66 | - * whether payments are allowed at this time |
|
67 | - * |
|
68 | - * @var boolean $_payments_closed |
|
69 | - */ |
|
70 | - private $_payments_closed = false; |
|
71 | - |
|
72 | - /** |
|
73 | - * whether the selected payment method is Bank, Check , Invoice, etc |
|
74 | - * |
|
75 | - * @var boolean $_is_offline_payment_method |
|
76 | - */ |
|
77 | - private $_is_offline_payment_method = true; |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return EED_Module|EED_Thank_You_Page |
|
82 | - */ |
|
83 | - public static function instance() |
|
84 | - { |
|
85 | - return parent::get_instance(__CLASS__); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * set_hooks - for hooking into EE Core, modules, etc |
|
91 | - * |
|
92 | - * @return void |
|
93 | - */ |
|
94 | - public static function set_hooks() |
|
95 | - { |
|
96 | - add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
102 | - * |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public static function set_hooks_admin() |
|
106 | - { |
|
107 | - add_action( |
|
108 | - 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
109 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
110 | - 10, |
|
111 | - 2 |
|
112 | - ); |
|
113 | - add_action( |
|
114 | - 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
115 | - array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
116 | - 10, |
|
117 | - 2 |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * set_definitions |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public static function set_definitions() |
|
128 | - { |
|
129 | - define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | - define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * get_txn |
|
136 | - * |
|
137 | - * @return EE_Transaction |
|
138 | - */ |
|
139 | - public function get_txn() |
|
140 | - { |
|
141 | - if ($this->_current_txn instanceof EE_Transaction) { |
|
142 | - return $this->_current_txn; |
|
143 | - } |
|
144 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
145 | - if (! $TXN_model instanceof EEM_Transaction) { |
|
146 | - EE_Error::add_error( |
|
147 | - __('The transaction model could not be established.', 'event_espresso'), |
|
148 | - __FILE__, |
|
149 | - __FUNCTION__, |
|
150 | - __LINE__ |
|
151 | - ); |
|
152 | - return null; |
|
153 | - } |
|
154 | - // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
155 | - $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
156 | - // verify TXN |
|
157 | - if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
158 | - EE_Error::add_error( |
|
159 | - __( |
|
160 | - 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
161 | - 'event_espresso' |
|
162 | - ), |
|
163 | - __FILE__, |
|
164 | - __FUNCTION__, |
|
165 | - __LINE__ |
|
166 | - ); |
|
167 | - return null; |
|
168 | - } |
|
169 | - return $this->_current_txn; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * get_txn_payments |
|
175 | - * |
|
176 | - * @param int $since |
|
177 | - * @return mixed array of EE_Payment || FALSE |
|
178 | - * @throws \EE_Error |
|
179 | - */ |
|
180 | - public function get_txn_payments($since = 0) |
|
181 | - { |
|
182 | - if (! $this->get_txn()) { |
|
183 | - return false; |
|
184 | - } |
|
185 | - $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
186 | - if ($since > 0) { |
|
187 | - $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
188 | - } |
|
189 | - // get array of payments with most recent first |
|
190 | - return $this->_current_txn->payments($args); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * @return bool |
|
196 | - */ |
|
197 | - public function isOfflinePaymentMethod() |
|
198 | - { |
|
199 | - return $this->_is_offline_payment_method; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * get_reg_url_link |
|
207 | - * |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - private function _get_reg_url_link() |
|
211 | - { |
|
212 | - if (! empty($this->_reg_url_link)) { |
|
213 | - return; |
|
214 | - } |
|
215 | - // only do thank you page stuff if we have a REG_url_link in the url |
|
216 | - if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
217 | - EE_Error::add_error( |
|
218 | - __( |
|
219 | - 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - __FILE__, |
|
223 | - __FUNCTION__, |
|
224 | - __LINE__ |
|
225 | - ); |
|
226 | - return; |
|
227 | - } |
|
228 | - // check for reg_url_link |
|
229 | - $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * set_reg_url_link |
|
235 | - * |
|
236 | - * @param string $reg_url_link |
|
237 | - */ |
|
238 | - public function set_reg_url_link($reg_url_link = null) |
|
239 | - { |
|
240 | - $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * run - initial module setup |
|
246 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
247 | - * |
|
248 | - * @param WP $WP |
|
249 | - * @return void |
|
250 | - * @throws \EE_Error |
|
251 | - */ |
|
252 | - public function run($WP) |
|
253 | - { |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * load_resources |
|
259 | - * |
|
260 | - * @return void |
|
261 | - * @throws \EE_Error |
|
262 | - */ |
|
263 | - public function load_resources() |
|
264 | - { |
|
265 | - $this->_get_reg_url_link(); |
|
266 | - // resend_reg_confirmation_email ? |
|
267 | - if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
268 | - EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
269 | - } |
|
270 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
271 | - $this->_translate_strings(); |
|
272 | - // load assets |
|
273 | - add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * load_js |
|
279 | - * |
|
280 | - * @return void |
|
281 | - */ |
|
282 | - protected function _translate_strings() |
|
283 | - { |
|
284 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
285 | - EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
286 | - EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
287 | - EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
288 | - EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
289 | - EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
290 | - 'checking for new payments...', |
|
291 | - 'event_espresso' |
|
292 | - ); |
|
293 | - EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
294 | - 'loading payment information...', |
|
295 | - 'event_espresso' |
|
296 | - ); |
|
297 | - EE_Registry::$i18n_js_strings['server_error'] = __( |
|
298 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
299 | - 'event_espresso' |
|
300 | - ); |
|
301 | - EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
302 | - 'EED_Thank_You_Page__load_js__slow_IPN', |
|
303 | - sprintf( |
|
304 | - __( |
|
305 | - '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
306 | - 'event_espresso' |
|
307 | - ), |
|
308 | - '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
309 | - '</div>' |
|
310 | - ) |
|
311 | - ); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * load_js |
|
317 | - * |
|
318 | - * @return void |
|
319 | - */ |
|
320 | - public function load_js() |
|
321 | - { |
|
322 | - wp_register_script( |
|
323 | - 'thank_you_page', |
|
324 | - THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
325 | - array('espresso_core', 'heartbeat'), |
|
326 | - EVENT_ESPRESSO_VERSION, |
|
327 | - true |
|
328 | - ); |
|
329 | - wp_enqueue_script('thank_you_page'); |
|
330 | - wp_enqueue_style('espresso_default'); |
|
331 | - } |
|
332 | - |
|
333 | - |
|
334 | - /** |
|
335 | - * init |
|
336 | - * |
|
337 | - * @return void |
|
338 | - * @throws \EE_Error |
|
339 | - */ |
|
340 | - public function init() |
|
341 | - { |
|
342 | - $this->_get_reg_url_link(); |
|
343 | - if (! $this->get_txn()) { |
|
344 | - echo EEH_HTML::div( |
|
345 | - EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
346 | - sprintf( |
|
347 | - __( |
|
348 | - 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
349 | - 'event_espresso' |
|
350 | - ), |
|
351 | - '<br/>' |
|
352 | - ), |
|
353 | - '', |
|
354 | - 'ee-attention' |
|
355 | - ); |
|
356 | - return null; |
|
357 | - } |
|
358 | - // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
359 | - if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
360 | - $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
361 | - $this->_current_txn->save(); |
|
362 | - } |
|
363 | - $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
364 | - ? $this->_current_txn->primary_registration() |
|
365 | - : null; |
|
366 | - $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
367 | - $show_try_pay_again_link_default = apply_filters( |
|
368 | - 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
369 | - true |
|
370 | - ); |
|
371 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
372 | - // txn status ? |
|
373 | - if ($this->_current_txn->is_completed()) { |
|
374 | - $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
375 | - } elseif ( |
|
376 | - $this->_current_txn->is_incomplete() |
|
377 | - && ($this->_primary_registrant->is_approved() |
|
378 | - || $this->_primary_registrant->is_pending_payment()) |
|
379 | - ) { |
|
380 | - $this->_show_try_pay_again_link = true; |
|
381 | - } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
382 | - // its pending |
|
383 | - $this->_show_try_pay_again_link = isset( |
|
384 | - EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
385 | - ) |
|
386 | - && EE_Registry::instance()->CFG |
|
387 | - ->registration->show_pending_payment_options |
|
388 | - ? true |
|
389 | - : $show_try_pay_again_link_default; |
|
390 | - } |
|
391 | - $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
392 | - ? true |
|
393 | - : false; |
|
394 | - $this->_is_offline_payment_method = false; |
|
395 | - if ( |
|
13 | + /** |
|
14 | + * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes ) |
|
15 | + */ |
|
16 | + const IPN_wait_time = 1200; |
|
17 | + |
|
18 | + /** |
|
19 | + * The transaction specified by the reg_url_link passed from the Request, or from the Session |
|
20 | + * |
|
21 | + * @var EE_Transaction $_current_txn |
|
22 | + */ |
|
23 | + private $_current_txn; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var EE_Registration $_primary_registrant |
|
27 | + */ |
|
28 | + private $_primary_registrant; |
|
29 | + |
|
30 | + /** |
|
31 | + * The reg_url_link passed from the Request, or from the Session |
|
32 | + * |
|
33 | + * @var string $_reg_url_link |
|
34 | + */ |
|
35 | + private $_reg_url_link; |
|
36 | + |
|
37 | + /** |
|
38 | + * whether the incoming reg_url_link is for the primary registrant or not |
|
39 | + * |
|
40 | + * @var boolean $_is_primary |
|
41 | + */ |
|
42 | + private $_is_primary; |
|
43 | + |
|
44 | + /** |
|
45 | + * The URL for revisiting the SPCO attendee information step |
|
46 | + * |
|
47 | + * @var string $_SPCO_attendee_information_url |
|
48 | + */ |
|
49 | + private $_SPCO_attendee_information_url; |
|
50 | + |
|
51 | + /** |
|
52 | + * The URL for revisiting the SPCO payment options step |
|
53 | + * |
|
54 | + * @var string $_SPCO_payment_options_url |
|
55 | + */ |
|
56 | + private $_SPCO_payment_options_url; |
|
57 | + |
|
58 | + /** |
|
59 | + * whether to display the Payment Options link |
|
60 | + * |
|
61 | + * @var boolean $_show_try_pay_again_link |
|
62 | + */ |
|
63 | + private $_show_try_pay_again_link = false; |
|
64 | + |
|
65 | + /** |
|
66 | + * whether payments are allowed at this time |
|
67 | + * |
|
68 | + * @var boolean $_payments_closed |
|
69 | + */ |
|
70 | + private $_payments_closed = false; |
|
71 | + |
|
72 | + /** |
|
73 | + * whether the selected payment method is Bank, Check , Invoice, etc |
|
74 | + * |
|
75 | + * @var boolean $_is_offline_payment_method |
|
76 | + */ |
|
77 | + private $_is_offline_payment_method = true; |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return EED_Module|EED_Thank_You_Page |
|
82 | + */ |
|
83 | + public static function instance() |
|
84 | + { |
|
85 | + return parent::get_instance(__CLASS__); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * set_hooks - for hooking into EE Core, modules, etc |
|
91 | + * |
|
92 | + * @return void |
|
93 | + */ |
|
94 | + public static function set_hooks() |
|
95 | + { |
|
96 | + add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
102 | + * |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public static function set_hooks_admin() |
|
106 | + { |
|
107 | + add_action( |
|
108 | + 'wp_ajax_espresso_resend_reg_confirmation_email', |
|
109 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
110 | + 10, |
|
111 | + 2 |
|
112 | + ); |
|
113 | + add_action( |
|
114 | + 'wp_ajax_nopriv_espresso_resend_reg_confirmation_email', |
|
115 | + array('EED_Thank_You_Page', 'resend_reg_confirmation_email'), |
|
116 | + 10, |
|
117 | + 2 |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * set_definitions |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public static function set_definitions() |
|
128 | + { |
|
129 | + define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
130 | + define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * get_txn |
|
136 | + * |
|
137 | + * @return EE_Transaction |
|
138 | + */ |
|
139 | + public function get_txn() |
|
140 | + { |
|
141 | + if ($this->_current_txn instanceof EE_Transaction) { |
|
142 | + return $this->_current_txn; |
|
143 | + } |
|
144 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
145 | + if (! $TXN_model instanceof EEM_Transaction) { |
|
146 | + EE_Error::add_error( |
|
147 | + __('The transaction model could not be established.', 'event_espresso'), |
|
148 | + __FILE__, |
|
149 | + __FUNCTION__, |
|
150 | + __LINE__ |
|
151 | + ); |
|
152 | + return null; |
|
153 | + } |
|
154 | + // get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request |
|
155 | + $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link); |
|
156 | + // verify TXN |
|
157 | + if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) { |
|
158 | + EE_Error::add_error( |
|
159 | + __( |
|
160 | + 'No transaction information could be retrieved or the transaction data is not of the correct type.', |
|
161 | + 'event_espresso' |
|
162 | + ), |
|
163 | + __FILE__, |
|
164 | + __FUNCTION__, |
|
165 | + __LINE__ |
|
166 | + ); |
|
167 | + return null; |
|
168 | + } |
|
169 | + return $this->_current_txn; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * get_txn_payments |
|
175 | + * |
|
176 | + * @param int $since |
|
177 | + * @return mixed array of EE_Payment || FALSE |
|
178 | + * @throws \EE_Error |
|
179 | + */ |
|
180 | + public function get_txn_payments($since = 0) |
|
181 | + { |
|
182 | + if (! $this->get_txn()) { |
|
183 | + return false; |
|
184 | + } |
|
185 | + $args = array('order_by' => array('PAY_timestamp' => 'ASC')); |
|
186 | + if ($since > 0) { |
|
187 | + $args[0] = array('PAY_timestamp' => array('>', $since)); |
|
188 | + } |
|
189 | + // get array of payments with most recent first |
|
190 | + return $this->_current_txn->payments($args); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * @return bool |
|
196 | + */ |
|
197 | + public function isOfflinePaymentMethod() |
|
198 | + { |
|
199 | + return $this->_is_offline_payment_method; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * get_reg_url_link |
|
207 | + * |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + private function _get_reg_url_link() |
|
211 | + { |
|
212 | + if (! empty($this->_reg_url_link)) { |
|
213 | + return; |
|
214 | + } |
|
215 | + // only do thank you page stuff if we have a REG_url_link in the url |
|
216 | + if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
217 | + EE_Error::add_error( |
|
218 | + __( |
|
219 | + 'No transaction information could be retrieved because the registration URL link is missing or invalid.', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + __FILE__, |
|
223 | + __FUNCTION__, |
|
224 | + __LINE__ |
|
225 | + ); |
|
226 | + return; |
|
227 | + } |
|
228 | + // check for reg_url_link |
|
229 | + $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link'); |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * set_reg_url_link |
|
235 | + * |
|
236 | + * @param string $reg_url_link |
|
237 | + */ |
|
238 | + public function set_reg_url_link($reg_url_link = null) |
|
239 | + { |
|
240 | + $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * run - initial module setup |
|
246 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
247 | + * |
|
248 | + * @param WP $WP |
|
249 | + * @return void |
|
250 | + * @throws \EE_Error |
|
251 | + */ |
|
252 | + public function run($WP) |
|
253 | + { |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * load_resources |
|
259 | + * |
|
260 | + * @return void |
|
261 | + * @throws \EE_Error |
|
262 | + */ |
|
263 | + public function load_resources() |
|
264 | + { |
|
265 | + $this->_get_reg_url_link(); |
|
266 | + // resend_reg_confirmation_email ? |
|
267 | + if (EE_Registry::instance()->REQ->is_set('resend')) { |
|
268 | + EED_Thank_You_Page::resend_reg_confirmation_email(); |
|
269 | + } |
|
270 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
271 | + $this->_translate_strings(); |
|
272 | + // load assets |
|
273 | + add_action('wp_enqueue_scripts', array($this, 'load_js'), 10); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * load_js |
|
279 | + * |
|
280 | + * @return void |
|
281 | + */ |
|
282 | + protected function _translate_strings() |
|
283 | + { |
|
284 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link; |
|
285 | + EE_Registry::$i18n_js_strings['initial_access'] = time(); |
|
286 | + EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time; |
|
287 | + EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code; |
|
288 | + EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code; |
|
289 | + EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __( |
|
290 | + 'checking for new payments...', |
|
291 | + 'event_espresso' |
|
292 | + ); |
|
293 | + EE_Registry::$i18n_js_strings['loading_payment_info'] = __( |
|
294 | + 'loading payment information...', |
|
295 | + 'event_espresso' |
|
296 | + ); |
|
297 | + EE_Registry::$i18n_js_strings['server_error'] = __( |
|
298 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.', |
|
299 | + 'event_espresso' |
|
300 | + ); |
|
301 | + EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters( |
|
302 | + 'EED_Thank_You_Page__load_js__slow_IPN', |
|
303 | + sprintf( |
|
304 | + __( |
|
305 | + '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s', |
|
306 | + 'event_espresso' |
|
307 | + ), |
|
308 | + '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">', |
|
309 | + '</div>' |
|
310 | + ) |
|
311 | + ); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * load_js |
|
317 | + * |
|
318 | + * @return void |
|
319 | + */ |
|
320 | + public function load_js() |
|
321 | + { |
|
322 | + wp_register_script( |
|
323 | + 'thank_you_page', |
|
324 | + THANK_YOU_ASSETS_URL . 'thank_you_page.js', |
|
325 | + array('espresso_core', 'heartbeat'), |
|
326 | + EVENT_ESPRESSO_VERSION, |
|
327 | + true |
|
328 | + ); |
|
329 | + wp_enqueue_script('thank_you_page'); |
|
330 | + wp_enqueue_style('espresso_default'); |
|
331 | + } |
|
332 | + |
|
333 | + |
|
334 | + /** |
|
335 | + * init |
|
336 | + * |
|
337 | + * @return void |
|
338 | + * @throws \EE_Error |
|
339 | + */ |
|
340 | + public function init() |
|
341 | + { |
|
342 | + $this->_get_reg_url_link(); |
|
343 | + if (! $this->get_txn()) { |
|
344 | + echo EEH_HTML::div( |
|
345 | + EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') . |
|
346 | + sprintf( |
|
347 | + __( |
|
348 | + 'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s', |
|
349 | + 'event_espresso' |
|
350 | + ), |
|
351 | + '<br/>' |
|
352 | + ), |
|
353 | + '', |
|
354 | + 'ee-attention' |
|
355 | + ); |
|
356 | + return null; |
|
357 | + } |
|
358 | + // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete" |
|
359 | + if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) { |
|
360 | + $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code); |
|
361 | + $this->_current_txn->save(); |
|
362 | + } |
|
363 | + $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration |
|
364 | + ? $this->_current_txn->primary_registration() |
|
365 | + : null; |
|
366 | + $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false; |
|
367 | + $show_try_pay_again_link_default = apply_filters( |
|
368 | + 'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default', |
|
369 | + true |
|
370 | + ); |
|
371 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
372 | + // txn status ? |
|
373 | + if ($this->_current_txn->is_completed()) { |
|
374 | + $this->_show_try_pay_again_link = $show_try_pay_again_link_default; |
|
375 | + } elseif ( |
|
376 | + $this->_current_txn->is_incomplete() |
|
377 | + && ($this->_primary_registrant->is_approved() |
|
378 | + || $this->_primary_registrant->is_pending_payment()) |
|
379 | + ) { |
|
380 | + $this->_show_try_pay_again_link = true; |
|
381 | + } elseif ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) { |
|
382 | + // its pending |
|
383 | + $this->_show_try_pay_again_link = isset( |
|
384 | + EE_Registry::instance()->CFG->registration->show_pending_payment_options |
|
385 | + ) |
|
386 | + && EE_Registry::instance()->CFG |
|
387 | + ->registration->show_pending_payment_options |
|
388 | + ? true |
|
389 | + : $show_try_pay_again_link_default; |
|
390 | + } |
|
391 | + $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
392 | + ? true |
|
393 | + : false; |
|
394 | + $this->_is_offline_payment_method = false; |
|
395 | + if ( |
|
396 | 396 | // if payment method is unknown |
397 | - ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
398 | - || ( |
|
399 | - // or is an offline payment method |
|
400 | - $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
401 | - && $this->_current_txn->payment_method()->is_off_line() |
|
402 | - ) |
|
403 | - ) { |
|
404 | - $this->_is_offline_payment_method = true; |
|
405 | - } |
|
406 | - // link to SPCO |
|
407 | - $revisit_spco_url = add_query_arg( |
|
408 | - array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
409 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
410 | - ); |
|
411 | - // link to SPCO payment_options |
|
412 | - $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
413 | - ? $this->_primary_registrant->payment_overview_url() |
|
414 | - : add_query_arg( |
|
415 | - array('step' => 'payment_options'), |
|
416 | - $revisit_spco_url |
|
417 | - ); |
|
418 | - // link to SPCO attendee_information |
|
419 | - $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
420 | - ? $this->_primary_registrant->edit_attendee_information_url() |
|
421 | - : false; |
|
422 | - do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
423 | - // set no cache headers and constants |
|
424 | - EE_System::do_not_cache(); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * display_thank_you_page_results |
|
430 | - * |
|
431 | - * @return string |
|
432 | - * @throws \EE_Error |
|
433 | - */ |
|
434 | - public function thank_you_page_results() |
|
435 | - { |
|
436 | - $this->init(); |
|
437 | - if (! $this->_current_txn instanceof EE_Transaction) { |
|
438 | - return EE_Error::get_notices(); |
|
439 | - } |
|
440 | - // link to receipt |
|
441 | - $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
442 | - if (! empty($template_args['TXN_receipt_url'])) { |
|
443 | - $template_args['order_conf_desc'] = __( |
|
444 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
445 | - 'event_espresso' |
|
446 | - ); |
|
447 | - } else { |
|
448 | - $template_args['order_conf_desc'] = __( |
|
449 | - '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
450 | - 'event_espresso' |
|
451 | - ); |
|
452 | - } |
|
453 | - $template_args['transaction'] = $this->_current_txn; |
|
454 | - $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
455 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
456 | - if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
457 | - add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
458 | - } |
|
459 | - return EEH_Template::locate_template( |
|
460 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
461 | - $template_args, |
|
462 | - true, |
|
463 | - true |
|
464 | - ); |
|
465 | - } |
|
466 | - |
|
467 | - |
|
468 | - |
|
469 | - /** |
|
470 | - * _update_server_wait_time |
|
471 | - * |
|
472 | - * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
473 | - * @return array |
|
474 | - * @throws \EE_Error |
|
475 | - */ |
|
476 | - private function _update_server_wait_time($thank_you_page_data = array()) |
|
477 | - { |
|
478 | - $response['espresso_thank_you_page'] = array( |
|
479 | - 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
480 | - ? time() - $thank_you_page_data['initial_access'] |
|
481 | - : 0, |
|
482 | - 'txn_status' => $this->_current_txn->status_ID(), |
|
483 | - ); |
|
484 | - return $response; |
|
485 | - } |
|
486 | - |
|
487 | - |
|
488 | - /** |
|
489 | - * get_registration_details |
|
490 | - * |
|
491 | - * @throws \EE_Error |
|
492 | - */ |
|
493 | - public function get_registration_details() |
|
494 | - { |
|
495 | - // prepare variables for displaying |
|
496 | - $template_args = array(); |
|
497 | - $template_args['transaction'] = $this->_current_txn; |
|
498 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
499 | - $template_args['is_primary'] = $this->_is_primary; |
|
500 | - $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
501 | - $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
502 | - array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
503 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
504 | - ); |
|
505 | - // verify template arguments |
|
506 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
507 | - EEH_Template_Validator::verify_isnt_null( |
|
508 | - $template_args['SPCO_attendee_information_url'], |
|
509 | - '$SPCO_attendee_information_url' |
|
510 | - ); |
|
511 | - echo EEH_Template::locate_template( |
|
512 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
513 | - $template_args, |
|
514 | - true, |
|
515 | - true |
|
516 | - ); |
|
517 | - } |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * resend_reg_confirmation_email |
|
522 | - * |
|
523 | - * @throws \EE_Error |
|
524 | - */ |
|
525 | - public static function resend_reg_confirmation_email() |
|
526 | - { |
|
527 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
528 | - $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
529 | - // was a REG_ID passed ? |
|
530 | - if ($reg_url_link) { |
|
531 | - $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
532 | - array(array('REG_url_link' => $reg_url_link)) |
|
533 | - ); |
|
534 | - if ($registration instanceof EE_Registration) { |
|
535 | - // resend email |
|
536 | - EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
537 | - } else { |
|
538 | - EE_Error::add_error( |
|
539 | - __( |
|
540 | - 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
541 | - 'event_espresso' |
|
542 | - ), |
|
543 | - __FILE__, |
|
544 | - __FUNCTION__, |
|
545 | - __LINE__ |
|
546 | - ); |
|
547 | - } |
|
548 | - } else { |
|
549 | - EE_Error::add_error( |
|
550 | - __( |
|
551 | - 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
552 | - 'event_espresso' |
|
553 | - ), |
|
554 | - __FILE__, |
|
555 | - __FUNCTION__, |
|
556 | - __LINE__ |
|
557 | - ); |
|
558 | - } |
|
559 | - // request sent via AJAX ? |
|
560 | - if (EE_FRONT_AJAX) { |
|
561 | - echo wp_json_encode(EE_Error::get_notices(false)); |
|
562 | - die(); |
|
563 | - // or was JS disabled ? |
|
564 | - } else { |
|
565 | - // save errors so that they get picked up on the next request |
|
566 | - EE_Error::get_notices(true, true); |
|
567 | - wp_safe_redirect( |
|
568 | - add_query_arg( |
|
569 | - array('e_reg_url_link' => $reg_url_link), |
|
570 | - EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
571 | - ) |
|
572 | - ); |
|
573 | - } |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * get_ajax_content |
|
579 | - * |
|
580 | - * @return void |
|
581 | - * @throws \EE_Error |
|
582 | - */ |
|
583 | - public function get_ajax_content() |
|
584 | - { |
|
585 | - if (! $this->get_txn()) { |
|
586 | - return; |
|
587 | - } |
|
588 | - // first determine which event(s) require pre-approval or not |
|
589 | - $events = array(); |
|
590 | - $events_requiring_pre_approval = array(); |
|
591 | - foreach ($this->_current_txn->registrations() as $registration) { |
|
592 | - if ($registration instanceof EE_Registration) { |
|
593 | - $event = $registration->event(); |
|
594 | - if ($event instanceof EE_Event) { |
|
595 | - if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
596 | - $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
597 | - } else { |
|
598 | - $events[ $event->ID() ] = $event; |
|
599 | - } |
|
600 | - } |
|
601 | - } |
|
602 | - } |
|
603 | - $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
604 | - $this->display_details_for_events($events); |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - /** |
|
609 | - * display_details_for_events |
|
610 | - * |
|
611 | - * @param EE_Event[] $events |
|
612 | - * @return void |
|
613 | - */ |
|
614 | - public function display_details_for_events($events = array()) |
|
615 | - { |
|
616 | - if (! empty($events)) { |
|
617 | - ?> |
|
397 | + ! $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
398 | + || ( |
|
399 | + // or is an offline payment method |
|
400 | + $this->_current_txn->payment_method() instanceof EE_Payment_Method |
|
401 | + && $this->_current_txn->payment_method()->is_off_line() |
|
402 | + ) |
|
403 | + ) { |
|
404 | + $this->_is_offline_payment_method = true; |
|
405 | + } |
|
406 | + // link to SPCO |
|
407 | + $revisit_spco_url = add_query_arg( |
|
408 | + array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link), |
|
409 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
410 | + ); |
|
411 | + // link to SPCO payment_options |
|
412 | + $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration |
|
413 | + ? $this->_primary_registrant->payment_overview_url() |
|
414 | + : add_query_arg( |
|
415 | + array('step' => 'payment_options'), |
|
416 | + $revisit_spco_url |
|
417 | + ); |
|
418 | + // link to SPCO attendee_information |
|
419 | + $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration |
|
420 | + ? $this->_primary_registrant->edit_attendee_information_url() |
|
421 | + : false; |
|
422 | + do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn); |
|
423 | + // set no cache headers and constants |
|
424 | + EE_System::do_not_cache(); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * display_thank_you_page_results |
|
430 | + * |
|
431 | + * @return string |
|
432 | + * @throws \EE_Error |
|
433 | + */ |
|
434 | + public function thank_you_page_results() |
|
435 | + { |
|
436 | + $this->init(); |
|
437 | + if (! $this->_current_txn instanceof EE_Transaction) { |
|
438 | + return EE_Error::get_notices(); |
|
439 | + } |
|
440 | + // link to receipt |
|
441 | + $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html'); |
|
442 | + if (! empty($template_args['TXN_receipt_url'])) { |
|
443 | + $template_args['order_conf_desc'] = __( |
|
444 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.', |
|
445 | + 'event_espresso' |
|
446 | + ); |
|
447 | + } else { |
|
448 | + $template_args['order_conf_desc'] = __( |
|
449 | + '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.', |
|
450 | + 'event_espresso' |
|
451 | + ); |
|
452 | + } |
|
453 | + $template_args['transaction'] = $this->_current_txn; |
|
454 | + $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false); |
|
455 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details')); |
|
456 | + if ($this->_is_primary && ! $this->_current_txn->is_free()) { |
|
457 | + add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content')); |
|
458 | + } |
|
459 | + return EEH_Template::locate_template( |
|
460 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php', |
|
461 | + $template_args, |
|
462 | + true, |
|
463 | + true |
|
464 | + ); |
|
465 | + } |
|
466 | + |
|
467 | + |
|
468 | + |
|
469 | + /** |
|
470 | + * _update_server_wait_time |
|
471 | + * |
|
472 | + * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data |
|
473 | + * @return array |
|
474 | + * @throws \EE_Error |
|
475 | + */ |
|
476 | + private function _update_server_wait_time($thank_you_page_data = array()) |
|
477 | + { |
|
478 | + $response['espresso_thank_you_page'] = array( |
|
479 | + 'still_waiting' => isset($thank_you_page_data['initial_access']) |
|
480 | + ? time() - $thank_you_page_data['initial_access'] |
|
481 | + : 0, |
|
482 | + 'txn_status' => $this->_current_txn->status_ID(), |
|
483 | + ); |
|
484 | + return $response; |
|
485 | + } |
|
486 | + |
|
487 | + |
|
488 | + /** |
|
489 | + * get_registration_details |
|
490 | + * |
|
491 | + * @throws \EE_Error |
|
492 | + */ |
|
493 | + public function get_registration_details() |
|
494 | + { |
|
495 | + // prepare variables for displaying |
|
496 | + $template_args = array(); |
|
497 | + $template_args['transaction'] = $this->_current_txn; |
|
498 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
499 | + $template_args['is_primary'] = $this->_is_primary; |
|
500 | + $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url; |
|
501 | + $template_args['resend_reg_confirmation_url'] = add_query_arg( |
|
502 | + array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'), |
|
503 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
504 | + ); |
|
505 | + // verify template arguments |
|
506 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
507 | + EEH_Template_Validator::verify_isnt_null( |
|
508 | + $template_args['SPCO_attendee_information_url'], |
|
509 | + '$SPCO_attendee_information_url' |
|
510 | + ); |
|
511 | + echo EEH_Template::locate_template( |
|
512 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php', |
|
513 | + $template_args, |
|
514 | + true, |
|
515 | + true |
|
516 | + ); |
|
517 | + } |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * resend_reg_confirmation_email |
|
522 | + * |
|
523 | + * @throws \EE_Error |
|
524 | + */ |
|
525 | + public static function resend_reg_confirmation_email() |
|
526 | + { |
|
527 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
528 | + $reg_url_link = EE_Registry::instance()->REQ->get('token'); |
|
529 | + // was a REG_ID passed ? |
|
530 | + if ($reg_url_link) { |
|
531 | + $registration = EE_Registry::instance()->load_model('Registration')->get_one( |
|
532 | + array(array('REG_url_link' => $reg_url_link)) |
|
533 | + ); |
|
534 | + if ($registration instanceof EE_Registration) { |
|
535 | + // resend email |
|
536 | + EED_Messages::process_resend(array('_REG_ID' => $registration->ID())); |
|
537 | + } else { |
|
538 | + EE_Error::add_error( |
|
539 | + __( |
|
540 | + 'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.', |
|
541 | + 'event_espresso' |
|
542 | + ), |
|
543 | + __FILE__, |
|
544 | + __FUNCTION__, |
|
545 | + __LINE__ |
|
546 | + ); |
|
547 | + } |
|
548 | + } else { |
|
549 | + EE_Error::add_error( |
|
550 | + __( |
|
551 | + 'The Registration Confirmation email could not be sent because a registration token is missing or invalid.', |
|
552 | + 'event_espresso' |
|
553 | + ), |
|
554 | + __FILE__, |
|
555 | + __FUNCTION__, |
|
556 | + __LINE__ |
|
557 | + ); |
|
558 | + } |
|
559 | + // request sent via AJAX ? |
|
560 | + if (EE_FRONT_AJAX) { |
|
561 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
562 | + die(); |
|
563 | + // or was JS disabled ? |
|
564 | + } else { |
|
565 | + // save errors so that they get picked up on the next request |
|
566 | + EE_Error::get_notices(true, true); |
|
567 | + wp_safe_redirect( |
|
568 | + add_query_arg( |
|
569 | + array('e_reg_url_link' => $reg_url_link), |
|
570 | + EE_Registry::instance()->CFG->core->thank_you_page_url() |
|
571 | + ) |
|
572 | + ); |
|
573 | + } |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * get_ajax_content |
|
579 | + * |
|
580 | + * @return void |
|
581 | + * @throws \EE_Error |
|
582 | + */ |
|
583 | + public function get_ajax_content() |
|
584 | + { |
|
585 | + if (! $this->get_txn()) { |
|
586 | + return; |
|
587 | + } |
|
588 | + // first determine which event(s) require pre-approval or not |
|
589 | + $events = array(); |
|
590 | + $events_requiring_pre_approval = array(); |
|
591 | + foreach ($this->_current_txn->registrations() as $registration) { |
|
592 | + if ($registration instanceof EE_Registration) { |
|
593 | + $event = $registration->event(); |
|
594 | + if ($event instanceof EE_Event) { |
|
595 | + if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) { |
|
596 | + $events_requiring_pre_approval[ $event->ID() ] = $event; |
|
597 | + } else { |
|
598 | + $events[ $event->ID() ] = $event; |
|
599 | + } |
|
600 | + } |
|
601 | + } |
|
602 | + } |
|
603 | + $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval); |
|
604 | + $this->display_details_for_events($events); |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + /** |
|
609 | + * display_details_for_events |
|
610 | + * |
|
611 | + * @param EE_Event[] $events |
|
612 | + * @return void |
|
613 | + */ |
|
614 | + public function display_details_for_events($events = array()) |
|
615 | + { |
|
616 | + if (! empty($events)) { |
|
617 | + ?> |
|
618 | 618 | <div id="espresso-thank-you-page-ajax-content-dv"> |
619 | 619 | <div id="espresso-thank-you-page-ajax-transaction-dv"></div> |
620 | 620 | <div id="espresso-thank-you-page-ajax-payment-dv"></div> |
@@ -622,19 +622,19 @@ discard block |
||
622 | 622 | <div id="ee-ajax-loading-dv" class="float-left lt-blue-text"> |
623 | 623 | <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"> |
624 | 624 | <?php _e( |
625 | - 'loading transaction and payment information...', |
|
626 | - 'event_espresso' |
|
627 | - ); ?></span> |
|
625 | + 'loading transaction and payment information...', |
|
626 | + 'event_espresso' |
|
627 | + ); ?></span> |
|
628 | 628 | </div> |
629 | 629 | <?php if (! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?> |
630 | 630 | <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear"> |
631 | 631 | <?php echo apply_filters( |
632 | - 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
633 | - __( |
|
634 | - 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
635 | - 'event_espresso' |
|
636 | - ) |
|
637 | - ); ?> |
|
632 | + 'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg', |
|
633 | + __( |
|
634 | + 'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.', |
|
635 | + 'event_espresso' |
|
636 | + ) |
|
637 | + ); ?> |
|
638 | 638 | <br/> |
639 | 639 | <span class="jst-rght ee-block small-text lt-grey-text"> |
640 | 640 | <?php _e('current wait time ', 'event_espresso'); ?> |
@@ -645,118 +645,118 @@ discard block |
||
645 | 645 | <div class="clear"></div> |
646 | 646 | </div> |
647 | 647 | <?php |
648 | - } |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - /** |
|
653 | - * display_details_for_events_requiring_pre_approval |
|
654 | - * |
|
655 | - * @param EE_Event[] $events |
|
656 | - * @return void |
|
657 | - */ |
|
658 | - public function display_details_for_events_requiring_pre_approval($events = array()) |
|
659 | - { |
|
660 | - if (! empty($events)) { |
|
661 | - ?> |
|
648 | + } |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + /** |
|
653 | + * display_details_for_events_requiring_pre_approval |
|
654 | + * |
|
655 | + * @param EE_Event[] $events |
|
656 | + * @return void |
|
657 | + */ |
|
658 | + public function display_details_for_events_requiring_pre_approval($events = array()) |
|
659 | + { |
|
660 | + if (! empty($events)) { |
|
661 | + ?> |
|
662 | 662 | <div id="espresso-thank-you-page-not-approved-message-dv"> |
663 | 663 | <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4> |
664 | 664 | <p id="events-requiring-pre-approval-pg" class="small-text"> |
665 | 665 | <?php echo apply_filters( |
666 | - 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
667 | - __( |
|
668 | - 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
669 | - 'event_espresso' |
|
670 | - ) |
|
671 | - ); ?> |
|
666 | + 'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message', |
|
667 | + __( |
|
668 | + 'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', |
|
669 | + 'event_espresso' |
|
670 | + ) |
|
671 | + ); ?> |
|
672 | 672 | </p> |
673 | 673 | <ul class="events-requiring-pre-approval-ul"> |
674 | 674 | <?php |
675 | - foreach ($events as $event) { |
|
676 | - if ($event instanceof EE_Event) { |
|
677 | - echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
678 | - $event->name(), |
|
679 | - '</li>'; |
|
680 | - } |
|
681 | - } ?> |
|
675 | + foreach ($events as $event) { |
|
676 | + if ($event instanceof EE_Event) { |
|
677 | + echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>', |
|
678 | + $event->name(), |
|
679 | + '</li>'; |
|
680 | + } |
|
681 | + } ?> |
|
682 | 682 | </ul> |
683 | 683 | <div class="clear"></div> |
684 | 684 | </div> |
685 | 685 | <?php |
686 | - } |
|
687 | - } |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * get_transaction_details |
|
692 | - * |
|
693 | - * @return string |
|
694 | - * @throws \EE_Error |
|
695 | - */ |
|
696 | - public function get_transaction_details() |
|
697 | - { |
|
698 | - // prepare variables for displaying |
|
699 | - $template_args = array(); |
|
700 | - $template_args['transaction'] = $this->_current_txn; |
|
701 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
702 | - $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
703 | - // link to SPCO payment_options |
|
704 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
705 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
706 | - // verify template arguments |
|
707 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
708 | - EEH_Template_Validator::verify_isnt_null( |
|
709 | - $template_args['show_try_pay_again_link'], |
|
710 | - '$show_try_pay_again_link' |
|
711 | - ); |
|
712 | - EEH_Template_Validator::verify_isnt_null( |
|
713 | - $template_args['SPCO_payment_options_url'], |
|
714 | - '$SPCO_payment_options_url' |
|
715 | - ); |
|
716 | - return EEH_Template::locate_template( |
|
717 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
718 | - $template_args, |
|
719 | - true, |
|
720 | - true |
|
721 | - ); |
|
722 | - } |
|
723 | - |
|
724 | - |
|
725 | - /** |
|
726 | - * get_payment_row_html |
|
727 | - * |
|
728 | - * @param EE_Payment $payment |
|
729 | - * @return string |
|
730 | - * @throws \EE_Error |
|
731 | - */ |
|
732 | - public function get_payment_row_html($payment = null) |
|
733 | - { |
|
734 | - $html = ''; |
|
735 | - if ($payment instanceof EE_Payment) { |
|
736 | - if ( |
|
737 | - $payment->payment_method() instanceof EE_Payment_Method |
|
738 | - && $payment->status() === EEM_Payment::status_id_failed |
|
739 | - && $payment->payment_method()->is_off_site() |
|
740 | - ) { |
|
741 | - // considering the registrant has made it to the Thank You page, |
|
742 | - // any failed payments may actually be pending and the IPN is just slow |
|
743 | - // so let's |
|
744 | - $payment->set_status(EEM_Payment::status_id_pending); |
|
745 | - } |
|
746 | - $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
747 | - ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
748 | - : ''; |
|
749 | - $html .= ' |
|
686 | + } |
|
687 | + } |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * get_transaction_details |
|
692 | + * |
|
693 | + * @return string |
|
694 | + * @throws \EE_Error |
|
695 | + */ |
|
696 | + public function get_transaction_details() |
|
697 | + { |
|
698 | + // prepare variables for displaying |
|
699 | + $template_args = array(); |
|
700 | + $template_args['transaction'] = $this->_current_txn; |
|
701 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
702 | + $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true); |
|
703 | + // link to SPCO payment_options |
|
704 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
705 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
706 | + // verify template arguments |
|
707 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
708 | + EEH_Template_Validator::verify_isnt_null( |
|
709 | + $template_args['show_try_pay_again_link'], |
|
710 | + '$show_try_pay_again_link' |
|
711 | + ); |
|
712 | + EEH_Template_Validator::verify_isnt_null( |
|
713 | + $template_args['SPCO_payment_options_url'], |
|
714 | + '$SPCO_payment_options_url' |
|
715 | + ); |
|
716 | + return EEH_Template::locate_template( |
|
717 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php', |
|
718 | + $template_args, |
|
719 | + true, |
|
720 | + true |
|
721 | + ); |
|
722 | + } |
|
723 | + |
|
724 | + |
|
725 | + /** |
|
726 | + * get_payment_row_html |
|
727 | + * |
|
728 | + * @param EE_Payment $payment |
|
729 | + * @return string |
|
730 | + * @throws \EE_Error |
|
731 | + */ |
|
732 | + public function get_payment_row_html($payment = null) |
|
733 | + { |
|
734 | + $html = ''; |
|
735 | + if ($payment instanceof EE_Payment) { |
|
736 | + if ( |
|
737 | + $payment->payment_method() instanceof EE_Payment_Method |
|
738 | + && $payment->status() === EEM_Payment::status_id_failed |
|
739 | + && $payment->payment_method()->is_off_site() |
|
740 | + ) { |
|
741 | + // considering the registrant has made it to the Thank You page, |
|
742 | + // any failed payments may actually be pending and the IPN is just slow |
|
743 | + // so let's |
|
744 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
745 | + } |
|
746 | + $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined |
|
747 | + ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>' |
|
748 | + : ''; |
|
749 | + $html .= ' |
|
750 | 750 | <tr> |
751 | 751 | <td> |
752 | 752 | ' . $payment->timestamp() . ' |
753 | 753 | </td> |
754 | 754 | <td> |
755 | 755 | ' . ( |
756 | - $payment->payment_method() instanceof EE_Payment_Method |
|
757 | - ? $payment->payment_method()->name() |
|
758 | - : __('Unknown', 'event_espresso') |
|
759 | - ) . ' |
|
756 | + $payment->payment_method() instanceof EE_Payment_Method |
|
757 | + ? $payment->payment_method()->name() |
|
758 | + : __('Unknown', 'event_espresso') |
|
759 | + ) . ' |
|
760 | 760 | </td> |
761 | 761 | <td class="jst-rght"> |
762 | 762 | ' . EEH_Template::format_currency($payment->amount()) . ' |
@@ -765,83 +765,83 @@ discard block |
||
765 | 765 | ' . $payment->pretty_status(true) . $payment_declined_msg . ' |
766 | 766 | </td> |
767 | 767 | </tr>'; |
768 | - do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
769 | - } |
|
770 | - return $html; |
|
771 | - } |
|
772 | - |
|
773 | - |
|
774 | - /** |
|
775 | - * get_payment_details |
|
776 | - * |
|
777 | - * @param array $payments |
|
778 | - * @return string |
|
779 | - * @throws \EE_Error |
|
780 | - */ |
|
781 | - public function get_payment_details($payments = array()) |
|
782 | - { |
|
783 | - // prepare variables for displaying |
|
784 | - $template_args = array(); |
|
785 | - $template_args['transaction'] = $this->_current_txn; |
|
786 | - $template_args['reg_url_link'] = $this->_reg_url_link; |
|
787 | - $template_args['payments'] = array(); |
|
788 | - foreach ($payments as $payment) { |
|
789 | - $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
790 | - } |
|
791 | - // create a hacky payment object, but dont save it |
|
792 | - $payment = EE_Payment::new_instance( |
|
793 | - array( |
|
794 | - 'TXN_ID' => $this->_current_txn->ID(), |
|
795 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
796 | - 'PAY_timestamp' => time(), |
|
797 | - 'PAY_amount' => $this->_current_txn->total(), |
|
798 | - 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
799 | - ) |
|
800 | - ); |
|
801 | - $payment_method = $this->_current_txn->payment_method(); |
|
802 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
803 | - $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
804 | - } else { |
|
805 | - $template_args['gateway_content'] = ''; |
|
806 | - } |
|
807 | - // link to SPCO payment_options |
|
808 | - $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
809 | - $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
810 | - // verify template arguments |
|
811 | - EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
812 | - EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
813 | - EEH_Template_Validator::verify_isnt_null( |
|
814 | - $template_args['show_try_pay_again_link'], |
|
815 | - '$show_try_pay_again_link' |
|
816 | - ); |
|
817 | - EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
818 | - EEH_Template_Validator::verify_isnt_null( |
|
819 | - $template_args['SPCO_payment_options_url'], |
|
820 | - '$SPCO_payment_options_url' |
|
821 | - ); |
|
822 | - return EEH_Template::locate_template( |
|
823 | - THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
824 | - $template_args, |
|
825 | - true, |
|
826 | - true |
|
827 | - ); |
|
828 | - } |
|
829 | - |
|
830 | - |
|
831 | - /** |
|
832 | - * get_payment_details |
|
833 | - * |
|
834 | - * @param array $payments |
|
835 | - * @return string |
|
836 | - * @throws \EE_Error |
|
837 | - */ |
|
838 | - public function get_new_payments($payments = array()) |
|
839 | - { |
|
840 | - $payments_html = ''; |
|
841 | - // prepare variables for displaying |
|
842 | - foreach ($payments as $payment) { |
|
843 | - $payments_html .= $this->get_payment_row_html($payment); |
|
844 | - } |
|
845 | - return $payments_html; |
|
846 | - } |
|
768 | + do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment); |
|
769 | + } |
|
770 | + return $html; |
|
771 | + } |
|
772 | + |
|
773 | + |
|
774 | + /** |
|
775 | + * get_payment_details |
|
776 | + * |
|
777 | + * @param array $payments |
|
778 | + * @return string |
|
779 | + * @throws \EE_Error |
|
780 | + */ |
|
781 | + public function get_payment_details($payments = array()) |
|
782 | + { |
|
783 | + // prepare variables for displaying |
|
784 | + $template_args = array(); |
|
785 | + $template_args['transaction'] = $this->_current_txn; |
|
786 | + $template_args['reg_url_link'] = $this->_reg_url_link; |
|
787 | + $template_args['payments'] = array(); |
|
788 | + foreach ($payments as $payment) { |
|
789 | + $template_args['payments'][] = $this->get_payment_row_html($payment); |
|
790 | + } |
|
791 | + // create a hacky payment object, but dont save it |
|
792 | + $payment = EE_Payment::new_instance( |
|
793 | + array( |
|
794 | + 'TXN_ID' => $this->_current_txn->ID(), |
|
795 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
796 | + 'PAY_timestamp' => time(), |
|
797 | + 'PAY_amount' => $this->_current_txn->total(), |
|
798 | + 'PMD_ID' => $this->_current_txn->payment_method_ID(), |
|
799 | + ) |
|
800 | + ); |
|
801 | + $payment_method = $this->_current_txn->payment_method(); |
|
802 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
803 | + $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment); |
|
804 | + } else { |
|
805 | + $template_args['gateway_content'] = ''; |
|
806 | + } |
|
807 | + // link to SPCO payment_options |
|
808 | + $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link; |
|
809 | + $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url; |
|
810 | + // verify template arguments |
|
811 | + EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction'); |
|
812 | + EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments'); |
|
813 | + EEH_Template_Validator::verify_isnt_null( |
|
814 | + $template_args['show_try_pay_again_link'], |
|
815 | + '$show_try_pay_again_link' |
|
816 | + ); |
|
817 | + EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content'); |
|
818 | + EEH_Template_Validator::verify_isnt_null( |
|
819 | + $template_args['SPCO_payment_options_url'], |
|
820 | + '$SPCO_payment_options_url' |
|
821 | + ); |
|
822 | + return EEH_Template::locate_template( |
|
823 | + THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php', |
|
824 | + $template_args, |
|
825 | + true, |
|
826 | + true |
|
827 | + ); |
|
828 | + } |
|
829 | + |
|
830 | + |
|
831 | + /** |
|
832 | + * get_payment_details |
|
833 | + * |
|
834 | + * @param array $payments |
|
835 | + * @return string |
|
836 | + * @throws \EE_Error |
|
837 | + */ |
|
838 | + public function get_new_payments($payments = array()) |
|
839 | + { |
|
840 | + $payments_html = ''; |
|
841 | + // prepare variables for displaying |
|
842 | + foreach ($payments as $payment) { |
|
843 | + $payments_html .= $this->get_payment_row_html($payment); |
|
844 | + } |
|
845 | + return $payments_html; |
|
846 | + } |
|
847 | 847 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function venue_location($content) |
164 | 164 | { |
165 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
165 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | // get some style |
178 | 178 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
179 | 179 | // first check theme folder |
180 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
180 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
181 | 181 | wp_register_style( |
182 | 182 | $this->theme, |
183 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
183 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
184 | 184 | array('dashicons', 'espresso_default') |
185 | 185 | ); |
186 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
186 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
187 | 187 | wp_register_style( |
188 | 188 | $this->theme, |
189 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
189 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
190 | 190 | array('dashicons', 'espresso_default') |
191 | 191 | ); |
192 | 192 | } |
@@ -29,173 +29,173 @@ |
||
29 | 29 | class EED_Venue_Single extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @return EED_Venue_Single |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types['espresso_venues']['singular_slug'], |
|
58 | - 'Venue_Single', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance() |
|
100 | - ->load_core('Front_Controller', array(), false, true) |
|
101 | - ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | - ) { |
|
103 | - EEH_Template::load_espresso_theme_functions(); |
|
104 | - // then add extra event data via hooks |
|
105 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | - // don't display entry meta because the existing theme will take car of that |
|
108 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | - } |
|
110 | - return $template; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * the_title |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @param string $title |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function the_title($title = '') |
|
122 | - { |
|
123 | - return $title; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * venue_details |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @param string $content |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function venue_details($content) |
|
135 | - { |
|
136 | - global $post; |
|
137 | - if ( |
|
138 | - $post->post_type == 'espresso_venues' |
|
139 | - && ! post_password_required() |
|
140 | - ) { |
|
141 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | - // it uses the_content() for displaying the $post->post_content |
|
143 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | - // add filters we want |
|
147 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | - // now load our template |
|
149 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | - // remove other filters we added so they won't get applied to the next post |
|
151 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | - } |
|
153 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | - return ! empty($template) ? $template : $content; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * venue_location |
|
160 | - * |
|
161 | - * @access public |
|
162 | - * @param string $content |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function venue_location($content) |
|
166 | - { |
|
167 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * wp_enqueue_scripts |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function wp_enqueue_scripts() |
|
178 | - { |
|
179 | - // get some style |
|
180 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | - // first check theme folder |
|
182 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | - wp_register_style( |
|
184 | - $this->theme, |
|
185 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | - array('dashicons', 'espresso_default') |
|
187 | - ); |
|
188 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | - wp_register_style( |
|
190 | - $this->theme, |
|
191 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | - array('dashicons', 'espresso_default') |
|
193 | - ); |
|
194 | - } |
|
195 | - wp_enqueue_style($this->theme); |
|
196 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venue_Single |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types['espresso_venues']['singular_slug'], |
|
58 | + 'Venue_Single', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance() |
|
100 | + ->load_core('Front_Controller', array(), false, true) |
|
101 | + ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | + ) { |
|
103 | + EEH_Template::load_espresso_theme_functions(); |
|
104 | + // then add extra event data via hooks |
|
105 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | + // don't display entry meta because the existing theme will take car of that |
|
108 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | + } |
|
110 | + return $template; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * the_title |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @param string $title |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function the_title($title = '') |
|
122 | + { |
|
123 | + return $title; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * venue_details |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @param string $content |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function venue_details($content) |
|
135 | + { |
|
136 | + global $post; |
|
137 | + if ( |
|
138 | + $post->post_type == 'espresso_venues' |
|
139 | + && ! post_password_required() |
|
140 | + ) { |
|
141 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | + // it uses the_content() for displaying the $post->post_content |
|
143 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | + // add filters we want |
|
147 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | + // now load our template |
|
149 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | + // remove other filters we added so they won't get applied to the next post |
|
151 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | + } |
|
153 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | + return ! empty($template) ? $template : $content; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * venue_location |
|
160 | + * |
|
161 | + * @access public |
|
162 | + * @param string $content |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function venue_location($content) |
|
166 | + { |
|
167 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * wp_enqueue_scripts |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function wp_enqueue_scripts() |
|
178 | + { |
|
179 | + // get some style |
|
180 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | + // first check theme folder |
|
182 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | + wp_register_style( |
|
184 | + $this->theme, |
|
185 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | + array('dashicons', 'espresso_default') |
|
187 | + ); |
|
188 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | + wp_register_style( |
|
190 | + $this->theme, |
|
191 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | + array('dashicons', 'espresso_default') |
|
193 | + ); |
|
194 | + } |
|
195 | + wp_enqueue_style($this->theme); |
|
196 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public static function set_trap() |
55 | 55 | { |
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/'); |
|
57 | 57 | add_action( |
58 | 58 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
59 | 59 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
120 | 120 | $time = microtime(true); |
121 | 121 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
123 | 123 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
124 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | 125 | $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
126 | 126 | echo $html; |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | // check the given callback is valid first before executing |
150 | - if (! is_callable($triggered_trap_callback)) { |
|
150 | + if ( ! is_callable($triggered_trap_callback)) { |
|
151 | 151 | // invalid callback so lets just sub in our default. |
152 | 152 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
153 | 153 | } |
@@ -16,306 +16,306 @@ |
||
16 | 16 | class EED_Bot_Trap extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EED_Bot_Trap|EED_Module |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return EED_Bot_Trap|EED_Module |
|
21 | + */ |
|
22 | + public static function instance() |
|
23 | + { |
|
24 | + return parent::get_instance(__CLASS__); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function set_hooks() |
|
34 | - { |
|
35 | - if ( |
|
36 | - apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
37 | - EE_Registry::instance()->CFG->registration->use_bot_trap |
|
38 | - ) { |
|
39 | - EED_Bot_Trap::set_trap(); |
|
40 | - // redirect bots to bogus success page |
|
41 | - EE_Config::register_route( |
|
42 | - 'ticket_selection_received', |
|
43 | - 'EED_Bot_Trap', |
|
44 | - 'display_bot_trap_success' |
|
45 | - ); |
|
46 | - } |
|
47 | - } |
|
28 | + /** |
|
29 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function set_hooks() |
|
34 | + { |
|
35 | + if ( |
|
36 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
37 | + EE_Registry::instance()->CFG->registration->use_bot_trap |
|
38 | + ) { |
|
39 | + EED_Bot_Trap::set_trap(); |
|
40 | + // redirect bots to bogus success page |
|
41 | + EE_Config::register_route( |
|
42 | + 'ticket_selection_received', |
|
43 | + 'EED_Bot_Trap', |
|
44 | + 'display_bot_trap_success' |
|
45 | + ); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public static function set_trap() |
|
56 | - { |
|
57 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
58 | - add_action( |
|
59 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
60 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
61 | - 10, |
|
62 | - 2 |
|
63 | - ); |
|
64 | - add_action( |
|
65 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
66 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
67 | - 1, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - } |
|
50 | + /** |
|
51 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public static function set_trap() |
|
56 | + { |
|
57 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
58 | + add_action( |
|
59 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
60 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
61 | + 10, |
|
62 | + 2 |
|
63 | + ); |
|
64 | + add_action( |
|
65 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
66 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
67 | + 1, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
75 | - * |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public static function set_hooks_admin() |
|
79 | - { |
|
80 | - if ( |
|
81 | - defined('DOING_AJAX') |
|
82 | - && DOING_AJAX |
|
83 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
84 | - && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
85 | - ) { |
|
86 | - EED_Bot_Trap::set_trap(); |
|
87 | - } |
|
88 | - add_action( |
|
89 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
90 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
91 | - 5 |
|
92 | - ); |
|
93 | - add_filter( |
|
94 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
95 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
96 | - 10, |
|
97 | - 1 |
|
98 | - ); |
|
99 | - } |
|
73 | + /** |
|
74 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
75 | + * |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public static function set_hooks_admin() |
|
79 | + { |
|
80 | + if ( |
|
81 | + defined('DOING_AJAX') |
|
82 | + && DOING_AJAX |
|
83 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
84 | + && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
85 | + ) { |
|
86 | + EED_Bot_Trap::set_trap(); |
|
87 | + } |
|
88 | + add_action( |
|
89 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
90 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
91 | + 5 |
|
92 | + ); |
|
93 | + add_filter( |
|
94 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
95 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
96 | + 10, |
|
97 | + 1 |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - /** |
|
103 | - * run - initial module setup |
|
104 | - * |
|
105 | - * @param WP $WP |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public function run($WP) |
|
109 | - { |
|
110 | - } |
|
102 | + /** |
|
103 | + * run - initial module setup |
|
104 | + * |
|
105 | + * @param WP $WP |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public function run($WP) |
|
109 | + { |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * generate_bot_trap |
|
115 | - * |
|
116 | - * @return void |
|
117 | - * @throws RuntimeException |
|
118 | - */ |
|
119 | - public static function generate_bot_trap() |
|
120 | - { |
|
121 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
122 | - $time = microtime(true); |
|
123 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
124 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
125 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
126 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
127 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
128 | - echo $html; |
|
129 | - } |
|
113 | + /** |
|
114 | + * generate_bot_trap |
|
115 | + * |
|
116 | + * @return void |
|
117 | + * @throws RuntimeException |
|
118 | + */ |
|
119 | + public static function generate_bot_trap() |
|
120 | + { |
|
121 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
122 | + $time = microtime(true); |
|
123 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
124 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
125 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
126 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
127 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
128 | + echo $html; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | |
132 | - /** |
|
133 | - * process_bot_trap |
|
134 | - * |
|
135 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | - * response if the bot trap is triggered. |
|
137 | - * It should receive one argument: a boolean indicating |
|
138 | - * whether the trap was triggered by suspicious timing or not. |
|
139 | - * @throws RuntimeException |
|
140 | - */ |
|
141 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
142 | - { |
|
143 | - // what's your email address Mr. Bot ? |
|
144 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
145 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
146 | - // are we human ? |
|
147 | - if ($empty_trap) { |
|
148 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
149 | - return; |
|
150 | - } |
|
151 | - // check the given callback is valid first before executing |
|
152 | - if (! is_callable($triggered_trap_callback)) { |
|
153 | - // invalid callback so lets just sub in our default. |
|
154 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
155 | - } |
|
156 | - call_user_func($triggered_trap_callback); |
|
157 | - } |
|
132 | + /** |
|
133 | + * process_bot_trap |
|
134 | + * |
|
135 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
136 | + * response if the bot trap is triggered. |
|
137 | + * It should receive one argument: a boolean indicating |
|
138 | + * whether the trap was triggered by suspicious timing or not. |
|
139 | + * @throws RuntimeException |
|
140 | + */ |
|
141 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
142 | + { |
|
143 | + // what's your email address Mr. Bot ? |
|
144 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
145 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
146 | + // are we human ? |
|
147 | + if ($empty_trap) { |
|
148 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
149 | + return; |
|
150 | + } |
|
151 | + // check the given callback is valid first before executing |
|
152 | + if (! is_callable($triggered_trap_callback)) { |
|
153 | + // invalid callback so lets just sub in our default. |
|
154 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
155 | + } |
|
156 | + call_user_func($triggered_trap_callback); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
162 | - * |
|
163 | - * @throws InvalidArgumentException |
|
164 | - * @throws InvalidDataTypeException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - */ |
|
167 | - public static function triggered_trap_response() |
|
168 | - { |
|
169 | - // UH OH... |
|
170 | - $redirect_url = apply_filters( |
|
171 | - 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
172 | - add_query_arg( |
|
173 | - array('ee' => 'ticket_selection_received'), |
|
174 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
175 | - ) |
|
176 | - ); |
|
177 | - // if AJAX, return the redirect URL |
|
178 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
179 | - echo wp_json_encode( |
|
180 | - array_merge( |
|
181 | - EE_Error::get_notices(false), |
|
182 | - array( |
|
183 | - 'redirect_url' => $redirect_url, |
|
184 | - ) |
|
185 | - ) |
|
186 | - ); |
|
187 | - exit(); |
|
188 | - } |
|
189 | - wp_safe_redirect($redirect_url); |
|
190 | - exit(); |
|
191 | - } |
|
160 | + /** |
|
161 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
162 | + * |
|
163 | + * @throws InvalidArgumentException |
|
164 | + * @throws InvalidDataTypeException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + */ |
|
167 | + public static function triggered_trap_response() |
|
168 | + { |
|
169 | + // UH OH... |
|
170 | + $redirect_url = apply_filters( |
|
171 | + 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
172 | + add_query_arg( |
|
173 | + array('ee' => 'ticket_selection_received'), |
|
174 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
175 | + ) |
|
176 | + ); |
|
177 | + // if AJAX, return the redirect URL |
|
178 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
179 | + echo wp_json_encode( |
|
180 | + array_merge( |
|
181 | + EE_Error::get_notices(false), |
|
182 | + array( |
|
183 | + 'redirect_url' => $redirect_url, |
|
184 | + ) |
|
185 | + ) |
|
186 | + ); |
|
187 | + exit(); |
|
188 | + } |
|
189 | + wp_safe_redirect($redirect_url); |
|
190 | + exit(); |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * display_bot_trap_success |
|
196 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
197 | - * think the form was submitted successfully |
|
198 | - * |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - public static function display_bot_trap_success() |
|
202 | - { |
|
203 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
204 | - $bot_notice = esc_html__( |
|
205 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
206 | - 'event_espresso' |
|
207 | - ); |
|
208 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
209 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
210 | - : $bot_notice; |
|
211 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
212 | - } |
|
194 | + /** |
|
195 | + * display_bot_trap_success |
|
196 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
197 | + * think the form was submitted successfully |
|
198 | + * |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + public static function display_bot_trap_success() |
|
202 | + { |
|
203 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
204 | + $bot_notice = esc_html__( |
|
205 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
206 | + 'event_espresso' |
|
207 | + ); |
|
208 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
209 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
210 | + : $bot_notice; |
|
211 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - /*********************************** ADMIN **********************************/ |
|
216 | + /*********************************** ADMIN **********************************/ |
|
217 | 217 | |
218 | 218 | |
219 | - /** |
|
220 | - * bot_trap_settings_form |
|
221 | - * |
|
222 | - * @return void |
|
223 | - * @throws EE_Error |
|
224 | - * @throws InvalidArgumentException |
|
225 | - * @throws InvalidDataTypeException |
|
226 | - * @throws InvalidInterfaceException |
|
227 | - */ |
|
228 | - public static function bot_trap_settings_form() |
|
229 | - { |
|
230 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
231 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
232 | - } |
|
219 | + /** |
|
220 | + * bot_trap_settings_form |
|
221 | + * |
|
222 | + * @return void |
|
223 | + * @throws EE_Error |
|
224 | + * @throws InvalidArgumentException |
|
225 | + * @throws InvalidDataTypeException |
|
226 | + * @throws InvalidInterfaceException |
|
227 | + */ |
|
228 | + public static function bot_trap_settings_form() |
|
229 | + { |
|
230 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
231 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - /** |
|
236 | - * _bot_trap_settings_form |
|
237 | - * |
|
238 | - * @return EE_Form_Section_Proper |
|
239 | - * @throws EE_Error |
|
240 | - */ |
|
241 | - protected static function _bot_trap_settings_form() |
|
242 | - { |
|
243 | - return new EE_Form_Section_Proper( |
|
244 | - array( |
|
245 | - 'name' => 'bot_trap_settings', |
|
246 | - 'html_id' => 'bot_trap_settings', |
|
247 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
248 | - 'subsections' => array( |
|
249 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
250 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
251 | - ), |
|
252 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
253 | - array( |
|
254 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
255 | - 'html_help_text' => esc_html__( |
|
256 | - 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
257 | - 'event_espresso' |
|
258 | - ), |
|
259 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
260 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
261 | - : true, |
|
262 | - 'required' => false, |
|
263 | - ) |
|
264 | - ), |
|
265 | - ), |
|
266 | - ) |
|
267 | - ); |
|
268 | - } |
|
235 | + /** |
|
236 | + * _bot_trap_settings_form |
|
237 | + * |
|
238 | + * @return EE_Form_Section_Proper |
|
239 | + * @throws EE_Error |
|
240 | + */ |
|
241 | + protected static function _bot_trap_settings_form() |
|
242 | + { |
|
243 | + return new EE_Form_Section_Proper( |
|
244 | + array( |
|
245 | + 'name' => 'bot_trap_settings', |
|
246 | + 'html_id' => 'bot_trap_settings', |
|
247 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
248 | + 'subsections' => array( |
|
249 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
250 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
251 | + ), |
|
252 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
253 | + array( |
|
254 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
255 | + 'html_help_text' => esc_html__( |
|
256 | + 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
257 | + 'event_espresso' |
|
258 | + ), |
|
259 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
260 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
261 | + : true, |
|
262 | + 'required' => false, |
|
263 | + ) |
|
264 | + ), |
|
265 | + ), |
|
266 | + ) |
|
267 | + ); |
|
268 | + } |
|
269 | 269 | |
270 | 270 | |
271 | - /** |
|
272 | - * update_bot_trap_settings_form |
|
273 | - * |
|
274 | - * @param EE_Registration_Config $EE_Registration_Config |
|
275 | - * @return EE_Registration_Config |
|
276 | - * @throws EE_Error |
|
277 | - * @throws InvalidArgumentException |
|
278 | - * @throws ReflectionException |
|
279 | - * @throws InvalidDataTypeException |
|
280 | - * @throws InvalidInterfaceException |
|
281 | - */ |
|
282 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
283 | - { |
|
284 | - try { |
|
285 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
286 | - // if not displaying a form, then check for form submission |
|
287 | - if ($bot_trap_settings_form->was_submitted()) { |
|
288 | - // capture form data |
|
289 | - $bot_trap_settings_form->receive_form_submission(); |
|
290 | - // validate form data |
|
291 | - if ($bot_trap_settings_form->is_valid()) { |
|
292 | - // grab validated data from form |
|
293 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
294 | - if (isset($valid_data['use_bot_trap'])) { |
|
295 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
296 | - } else { |
|
297 | - EE_Error::add_error( |
|
298 | - esc_html__( |
|
299 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
300 | - 'event_espresso' |
|
301 | - ), |
|
302 | - __FILE__, |
|
303 | - __FUNCTION__, |
|
304 | - __LINE__ |
|
305 | - ); |
|
306 | - } |
|
307 | - } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
308 | - EE_Error::add_error( |
|
309 | - $bot_trap_settings_form->submission_error_message(), |
|
310 | - __FILE__, |
|
311 | - __FUNCTION__, |
|
312 | - __LINE__ |
|
313 | - ); |
|
314 | - } |
|
315 | - } |
|
316 | - } catch (EE_Error $e) { |
|
317 | - $e->get_error(); |
|
318 | - } |
|
319 | - return $EE_Registration_Config; |
|
320 | - } |
|
271 | + /** |
|
272 | + * update_bot_trap_settings_form |
|
273 | + * |
|
274 | + * @param EE_Registration_Config $EE_Registration_Config |
|
275 | + * @return EE_Registration_Config |
|
276 | + * @throws EE_Error |
|
277 | + * @throws InvalidArgumentException |
|
278 | + * @throws ReflectionException |
|
279 | + * @throws InvalidDataTypeException |
|
280 | + * @throws InvalidInterfaceException |
|
281 | + */ |
|
282 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
283 | + { |
|
284 | + try { |
|
285 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
286 | + // if not displaying a form, then check for form submission |
|
287 | + if ($bot_trap_settings_form->was_submitted()) { |
|
288 | + // capture form data |
|
289 | + $bot_trap_settings_form->receive_form_submission(); |
|
290 | + // validate form data |
|
291 | + if ($bot_trap_settings_form->is_valid()) { |
|
292 | + // grab validated data from form |
|
293 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
294 | + if (isset($valid_data['use_bot_trap'])) { |
|
295 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
296 | + } else { |
|
297 | + EE_Error::add_error( |
|
298 | + esc_html__( |
|
299 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
300 | + 'event_espresso' |
|
301 | + ), |
|
302 | + __FILE__, |
|
303 | + __FUNCTION__, |
|
304 | + __LINE__ |
|
305 | + ); |
|
306 | + } |
|
307 | + } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
308 | + EE_Error::add_error( |
|
309 | + $bot_trap_settings_form->submission_error_message(), |
|
310 | + __FILE__, |
|
311 | + __FUNCTION__, |
|
312 | + __LINE__ |
|
313 | + ); |
|
314 | + } |
|
315 | + } |
|
316 | + } catch (EE_Error $e) { |
|
317 | + $e->get_error(); |
|
318 | + } |
|
319 | + return $EE_Registration_Config; |
|
320 | + } |
|
321 | 321 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function getLoader() |
115 | 115 | { |
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
116 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
117 | 117 | $this->loader = LoaderFactory::getLoader(); |
118 | 118 | } |
119 | 119 | return $this->loader; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | && $_REQUEST['page'] == 'espresso_batch' |
132 | 132 | ) |
133 | 133 | ) { |
134 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
134 | + if ( ! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
135 | 135 | wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
136 | 136 | } |
137 | 137 | switch ($this->batch_request_type()) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
154 | 154 | wp_enqueue_script( |
155 | 155 | 'batch_runner_init', |
156 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
156 | + BATCH_URL.'assets/batch_runner_init.js', |
|
157 | 157 | array('batch_runner'), |
158 | 158 | EVENT_ESPRESSO_VERSION, |
159 | 159 | true |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
178 | 178 | wp_enqueue_script( |
179 | 179 | 'batch_file_runner_init', |
180 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
180 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
181 | 181 | array('batch_runner'), |
182 | 182 | EVENT_ESPRESSO_VERSION, |
183 | 183 | true |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | array( |
190 | 190 | 'download_and_redirecting' => sprintf( |
191 | 191 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
192 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
192 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
193 | 193 | '</a>' |
194 | 194 | ), |
195 | 195 | 'return_url' => $_REQUEST['return_url'], |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
208 | 208 | { |
209 | 209 | // just copy the bits of EE admin's eei18n that we need in the JS |
210 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
210 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
211 | 211 | 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
212 | 212 | 'event_espresso' |
213 | 213 | ); |
214 | 214 | wp_register_script( |
215 | 215 | 'progress_bar', |
216 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
216 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
217 | 217 | array('jquery'), |
218 | 218 | EVENT_ESPRESSO_VERSION, |
219 | 219 | true |
220 | 220 | ); |
221 | 221 | wp_enqueue_style( |
222 | 222 | 'progress_bar', |
223 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
223 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
224 | 224 | array(), |
225 | 225 | EVENT_ESPRESSO_VERSION |
226 | 226 | ); |
227 | 227 | wp_enqueue_script( |
228 | 228 | 'batch_runner', |
229 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
229 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
230 | 230 | array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
231 | 231 | EVENT_ESPRESSO_VERSION, |
232 | 232 | true |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function override_template($template) |
254 | 254 | { |
255 | 255 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
256 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
256 | + return EE_MODULES.'batch/templates/batch_frontend_wrapper.template.html'; |
|
257 | 257 | } |
258 | 258 | return $template; |
259 | 259 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public function show_admin_page() |
281 | 281 | { |
282 | 282 | echo EEH_Template::locate_template( |
283 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
283 | + EE_MODULES.'batch/templates/batch_wrapper.template.html', |
|
284 | 284 | array('batch_request_type' => $this->batch_request_type()) |
285 | 285 | ); |
286 | 286 | } |
@@ -29,359 +29,359 @@ |
||
29 | 29 | class EED_Batch extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | - * processes data only |
|
35 | - */ |
|
36 | - const batch_job = 'job'; |
|
37 | - /** |
|
38 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | - * produces a file for download |
|
40 | - */ |
|
41 | - const batch_file_job = 'file'; |
|
42 | - /** |
|
43 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | - * at all |
|
46 | - */ |
|
47 | - const batch_not_job = 'none'; |
|
32 | + /** |
|
33 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | + * processes data only |
|
35 | + */ |
|
36 | + const batch_job = 'job'; |
|
37 | + /** |
|
38 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | + * produces a file for download |
|
40 | + */ |
|
41 | + const batch_file_job = 'file'; |
|
42 | + /** |
|
43 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | + * at all |
|
46 | + */ |
|
47 | + const batch_not_job = 'none'; |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | - */ |
|
53 | - protected $_batch_request_type = null; |
|
49 | + /** |
|
50 | + * |
|
51 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | + */ |
|
53 | + protected $_batch_request_type = null; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Because we want to use the response in both the localized JS and in the body |
|
57 | - * we need to make this response available between method calls |
|
58 | - * |
|
59 | - * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | - */ |
|
61 | - protected $_job_step_response = null; |
|
55 | + /** |
|
56 | + * Because we want to use the response in both the localized JS and in the body |
|
57 | + * we need to make this response available between method calls |
|
58 | + * |
|
59 | + * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | + */ |
|
61 | + protected $_job_step_response = null; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var LoaderInterface |
|
65 | - */ |
|
66 | - protected $loader; |
|
63 | + /** |
|
64 | + * @var LoaderInterface |
|
65 | + */ |
|
66 | + protected $loader; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gets the batch instance |
|
70 | - * |
|
71 | - * @return EED_Batch |
|
72 | - */ |
|
73 | - public static function instance() |
|
74 | - { |
|
75 | - return self::get_instance(); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Gets the batch instance |
|
70 | + * |
|
71 | + * @return EED_Batch |
|
72 | + */ |
|
73 | + public static function instance() |
|
74 | + { |
|
75 | + return self::get_instance(); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | - * because it's an attack vector and there are currently no implementations |
|
81 | - */ |
|
82 | - public static function set_hooks() |
|
83 | - { |
|
84 | - // because this is a possibel attack vector, let's have this disabled until |
|
85 | - // we at least have a real use for it on the frontend |
|
86 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | - add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | - add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | + * because it's an attack vector and there are currently no implementations |
|
81 | + */ |
|
82 | + public static function set_hooks() |
|
83 | + { |
|
84 | + // because this is a possibel attack vector, let's have this disabled until |
|
85 | + // we at least have a real use for it on the frontend |
|
86 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Initializes some hooks for the admin in order to run batch jobs |
|
94 | - */ |
|
95 | - public static function set_hooks_admin() |
|
96 | - { |
|
97 | - add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | - add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
92 | + /** |
|
93 | + * Initializes some hooks for the admin in order to run batch jobs |
|
94 | + */ |
|
95 | + public static function set_hooks_admin() |
|
96 | + { |
|
97 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
99 | 99 | |
100 | - // ajax |
|
101 | - add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | - add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | - add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | - } |
|
100 | + // ajax |
|
101 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @since 4.9.80.p |
|
109 | - * @return LoaderInterface |
|
110 | - * @throws InvalidArgumentException |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - */ |
|
114 | - protected function getLoader() |
|
115 | - { |
|
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
117 | - $this->loader = LoaderFactory::getLoader(); |
|
118 | - } |
|
119 | - return $this->loader; |
|
120 | - } |
|
107 | + /** |
|
108 | + * @since 4.9.80.p |
|
109 | + * @return LoaderInterface |
|
110 | + * @throws InvalidArgumentException |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + */ |
|
114 | + protected function getLoader() |
|
115 | + { |
|
116 | + if (!$this->loader instanceof LoaderInterface) { |
|
117 | + $this->loader = LoaderFactory::getLoader(); |
|
118 | + } |
|
119 | + return $this->loader; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | - */ |
|
125 | - public function enqueue_scripts() |
|
126 | - { |
|
127 | - if ( |
|
128 | - isset($_REQUEST['espresso_batch']) |
|
129 | - || |
|
130 | - ( |
|
131 | - isset($_REQUEST['page']) |
|
132 | - && $_REQUEST['page'] == 'espresso_batch' |
|
133 | - ) |
|
134 | - ) { |
|
135 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
136 | - wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
137 | - } |
|
138 | - switch ($this->batch_request_type()) { |
|
139 | - case self::batch_job: |
|
140 | - $this->enqueue_scripts_styles_batch_create(); |
|
141 | - break; |
|
142 | - case self::batch_file_job: |
|
143 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
144 | - break; |
|
145 | - } |
|
146 | - } |
|
147 | - } |
|
122 | + /** |
|
123 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | + */ |
|
125 | + public function enqueue_scripts() |
|
126 | + { |
|
127 | + if ( |
|
128 | + isset($_REQUEST['espresso_batch']) |
|
129 | + || |
|
130 | + ( |
|
131 | + isset($_REQUEST['page']) |
|
132 | + && $_REQUEST['page'] == 'espresso_batch' |
|
133 | + ) |
|
134 | + ) { |
|
135 | + if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
136 | + wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
137 | + } |
|
138 | + switch ($this->batch_request_type()) { |
|
139 | + case self::batch_job: |
|
140 | + $this->enqueue_scripts_styles_batch_create(); |
|
141 | + break; |
|
142 | + case self::batch_file_job: |
|
143 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
144 | + break; |
|
145 | + } |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
151 | - */ |
|
152 | - public function enqueue_scripts_styles_batch_create() |
|
153 | - { |
|
154 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
155 | - wp_enqueue_script( |
|
156 | - 'batch_runner_init', |
|
157 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
158 | - array('batch_runner'), |
|
159 | - EVENT_ESPRESSO_VERSION, |
|
160 | - true |
|
161 | - ); |
|
162 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
163 | - wp_localize_script( |
|
164 | - 'batch_runner_init', |
|
165 | - 'ee_job_i18n', |
|
166 | - array( |
|
167 | - 'return_url' => $_REQUEST['return_url'], |
|
168 | - ) |
|
169 | - ); |
|
170 | - } |
|
149 | + /** |
|
150 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
151 | + */ |
|
152 | + public function enqueue_scripts_styles_batch_create() |
|
153 | + { |
|
154 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
155 | + wp_enqueue_script( |
|
156 | + 'batch_runner_init', |
|
157 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
158 | + array('batch_runner'), |
|
159 | + EVENT_ESPRESSO_VERSION, |
|
160 | + true |
|
161 | + ); |
|
162 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
163 | + wp_localize_script( |
|
164 | + 'batch_runner_init', |
|
165 | + 'ee_job_i18n', |
|
166 | + array( |
|
167 | + 'return_url' => $_REQUEST['return_url'], |
|
168 | + ) |
|
169 | + ); |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
174 | - */ |
|
175 | - public function enqueue_scripts_styles_batch_file_create() |
|
176 | - { |
|
177 | - // creates a job based on the request variable |
|
178 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
179 | - wp_enqueue_script( |
|
180 | - 'batch_file_runner_init', |
|
181 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
182 | - array('batch_runner'), |
|
183 | - EVENT_ESPRESSO_VERSION, |
|
184 | - true |
|
185 | - ); |
|
186 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
187 | - wp_localize_script( |
|
188 | - 'batch_file_runner_init', |
|
189 | - 'ee_job_i18n', |
|
190 | - array( |
|
191 | - 'download_and_redirecting' => sprintf( |
|
192 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
193 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
194 | - '</a>' |
|
195 | - ), |
|
196 | - 'return_url' => $_REQUEST['return_url'], |
|
197 | - ) |
|
198 | - ); |
|
199 | - } |
|
172 | + /** |
|
173 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
174 | + */ |
|
175 | + public function enqueue_scripts_styles_batch_file_create() |
|
176 | + { |
|
177 | + // creates a job based on the request variable |
|
178 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
179 | + wp_enqueue_script( |
|
180 | + 'batch_file_runner_init', |
|
181 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
182 | + array('batch_runner'), |
|
183 | + EVENT_ESPRESSO_VERSION, |
|
184 | + true |
|
185 | + ); |
|
186 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
187 | + wp_localize_script( |
|
188 | + 'batch_file_runner_init', |
|
189 | + 'ee_job_i18n', |
|
190 | + array( |
|
191 | + 'download_and_redirecting' => sprintf( |
|
192 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
193 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
194 | + '</a>' |
|
195 | + ), |
|
196 | + 'return_url' => $_REQUEST['return_url'], |
|
197 | + ) |
|
198 | + ); |
|
199 | + } |
|
200 | 200 | |
201 | - /** |
|
202 | - * Enqueues scripts and styles common to any batch job, and creates |
|
203 | - * a job from the request data, and stores the response in the |
|
204 | - * $this->_job_step_response property |
|
205 | - * |
|
206 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
207 | - */ |
|
208 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
209 | - { |
|
210 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
211 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
212 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
213 | - 'event_espresso' |
|
214 | - ); |
|
215 | - wp_register_script( |
|
216 | - 'progress_bar', |
|
217 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
218 | - array('jquery'), |
|
219 | - EVENT_ESPRESSO_VERSION, |
|
220 | - true |
|
221 | - ); |
|
222 | - wp_enqueue_style( |
|
223 | - 'progress_bar', |
|
224 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
225 | - array(), |
|
226 | - EVENT_ESPRESSO_VERSION |
|
227 | - ); |
|
228 | - wp_enqueue_script( |
|
229 | - 'batch_runner', |
|
230 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
231 | - array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
232 | - EVENT_ESPRESSO_VERSION, |
|
233 | - true |
|
234 | - ); |
|
235 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
236 | - $request_data = array_diff_key( |
|
237 | - $_REQUEST, |
|
238 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
239 | - ); |
|
240 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
241 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
242 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
243 | - // remember the response for later. We need it to display the page body |
|
244 | - $this->_job_step_response = $job_response; |
|
245 | - return $job_response; |
|
246 | - } |
|
201 | + /** |
|
202 | + * Enqueues scripts and styles common to any batch job, and creates |
|
203 | + * a job from the request data, and stores the response in the |
|
204 | + * $this->_job_step_response property |
|
205 | + * |
|
206 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
207 | + */ |
|
208 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
209 | + { |
|
210 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
211 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
212 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
213 | + 'event_espresso' |
|
214 | + ); |
|
215 | + wp_register_script( |
|
216 | + 'progress_bar', |
|
217 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
218 | + array('jquery'), |
|
219 | + EVENT_ESPRESSO_VERSION, |
|
220 | + true |
|
221 | + ); |
|
222 | + wp_enqueue_style( |
|
223 | + 'progress_bar', |
|
224 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
225 | + array(), |
|
226 | + EVENT_ESPRESSO_VERSION |
|
227 | + ); |
|
228 | + wp_enqueue_script( |
|
229 | + 'batch_runner', |
|
230 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
231 | + array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
232 | + EVENT_ESPRESSO_VERSION, |
|
233 | + true |
|
234 | + ); |
|
235 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
236 | + $request_data = array_diff_key( |
|
237 | + $_REQUEST, |
|
238 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
239 | + ); |
|
240 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
241 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
242 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
243 | + // remember the response for later. We need it to display the page body |
|
244 | + $this->_job_step_response = $job_response; |
|
245 | + return $job_response; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
250 | - * |
|
251 | - * @param string $template |
|
252 | - * @return string |
|
253 | - */ |
|
254 | - public function override_template($template) |
|
255 | - { |
|
256 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
257 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
258 | - } |
|
259 | - return $template; |
|
260 | - } |
|
248 | + /** |
|
249 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
250 | + * |
|
251 | + * @param string $template |
|
252 | + * @return string |
|
253 | + */ |
|
254 | + public function override_template($template) |
|
255 | + { |
|
256 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
257 | + return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
258 | + } |
|
259 | + return $template; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * Adds an admin page which doesn't appear in the admin menu |
|
264 | - */ |
|
265 | - public function register_admin_pages() |
|
266 | - { |
|
267 | - add_submenu_page( |
|
268 | - '', // parent slug. we don't want this to actually appear in the menu |
|
269 | - __('Batch Job', 'event_espresso'), // page title |
|
270 | - 'n/a', // menu title |
|
271 | - 'read', // we want this page to actually be accessible to anyone, |
|
272 | - 'espresso_batch', // menu slug |
|
273 | - array(self::instance(), 'show_admin_page') |
|
274 | - ); |
|
275 | - } |
|
262 | + /** |
|
263 | + * Adds an admin page which doesn't appear in the admin menu |
|
264 | + */ |
|
265 | + public function register_admin_pages() |
|
266 | + { |
|
267 | + add_submenu_page( |
|
268 | + '', // parent slug. we don't want this to actually appear in the menu |
|
269 | + __('Batch Job', 'event_espresso'), // page title |
|
270 | + 'n/a', // menu title |
|
271 | + 'read', // we want this page to actually be accessible to anyone, |
|
272 | + 'espresso_batch', // menu slug |
|
273 | + array(self::instance(), 'show_admin_page') |
|
274 | + ); |
|
275 | + } |
|
276 | 276 | |
277 | - /** |
|
278 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
279 | - * of creating the job and localizing some data |
|
280 | - */ |
|
281 | - public function show_admin_page() |
|
282 | - { |
|
283 | - echo EEH_Template::locate_template( |
|
284 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
285 | - array('batch_request_type' => $this->batch_request_type()) |
|
286 | - ); |
|
287 | - } |
|
277 | + /** |
|
278 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
279 | + * of creating the job and localizing some data |
|
280 | + */ |
|
281 | + public function show_admin_page() |
|
282 | + { |
|
283 | + echo EEH_Template::locate_template( |
|
284 | + EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
285 | + array('batch_request_type' => $this->batch_request_type()) |
|
286 | + ); |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * Receives ajax calls for continuing a job |
|
291 | - */ |
|
292 | - public function batch_continue() |
|
293 | - { |
|
294 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
295 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
296 | - $response_obj = $batch_runner->continue_job($job_id); |
|
297 | - $this->_return_json($response_obj->to_array()); |
|
298 | - } |
|
289 | + /** |
|
290 | + * Receives ajax calls for continuing a job |
|
291 | + */ |
|
292 | + public function batch_continue() |
|
293 | + { |
|
294 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
295 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
296 | + $response_obj = $batch_runner->continue_job($job_id); |
|
297 | + $this->_return_json($response_obj->to_array()); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Receives the ajax call to cleanup a job |
|
302 | - * |
|
303 | - * @return type |
|
304 | - */ |
|
305 | - public function batch_cleanup() |
|
306 | - { |
|
307 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
308 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
309 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
310 | - $this->_return_json($response_obj->to_array()); |
|
311 | - } |
|
300 | + /** |
|
301 | + * Receives the ajax call to cleanup a job |
|
302 | + * |
|
303 | + * @return type |
|
304 | + */ |
|
305 | + public function batch_cleanup() |
|
306 | + { |
|
307 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
308 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
309 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
310 | + $this->_return_json($response_obj->to_array()); |
|
311 | + } |
|
312 | 312 | |
313 | 313 | |
314 | - /** |
|
315 | - * Returns a json response |
|
316 | - * |
|
317 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
318 | - * |
|
319 | - * The returned json object is created from an array in the following format: |
|
320 | - * array( |
|
321 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
322 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
323 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
324 | - * args that might be included in here) |
|
325 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
326 | - * ) |
|
327 | - */ |
|
328 | - protected function _return_json($data) |
|
329 | - { |
|
330 | - $json = array( |
|
331 | - 'notices' => EE_Error::get_notices(), |
|
332 | - 'data' => $data, |
|
333 | - 'isEEajax' => true |
|
334 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
335 | - ); |
|
314 | + /** |
|
315 | + * Returns a json response |
|
316 | + * |
|
317 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
318 | + * |
|
319 | + * The returned json object is created from an array in the following format: |
|
320 | + * array( |
|
321 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
322 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
323 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
324 | + * args that might be included in here) |
|
325 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
326 | + * ) |
|
327 | + */ |
|
328 | + protected function _return_json($data) |
|
329 | + { |
|
330 | + $json = array( |
|
331 | + 'notices' => EE_Error::get_notices(), |
|
332 | + 'data' => $data, |
|
333 | + 'isEEajax' => true |
|
334 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
335 | + ); |
|
336 | 336 | |
337 | 337 | |
338 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
339 | - if (null === error_get_last() || ! headers_sent()) { |
|
340 | - header('Content-Type: application/json; charset=UTF-8'); |
|
341 | - } |
|
342 | - echo wp_json_encode($json); |
|
343 | - exit(); |
|
344 | - } |
|
338 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
339 | + if (null === error_get_last() || ! headers_sent()) { |
|
340 | + header('Content-Type: application/json; charset=UTF-8'); |
|
341 | + } |
|
342 | + echo wp_json_encode($json); |
|
343 | + exit(); |
|
344 | + } |
|
345 | 345 | |
346 | - /** |
|
347 | - * Gets the job step response which was done during the enqueuing of scripts |
|
348 | - * |
|
349 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
350 | - */ |
|
351 | - public function job_step_response() |
|
352 | - { |
|
353 | - return $this->_job_step_response; |
|
354 | - } |
|
346 | + /** |
|
347 | + * Gets the job step response which was done during the enqueuing of scripts |
|
348 | + * |
|
349 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
350 | + */ |
|
351 | + public function job_step_response() |
|
352 | + { |
|
353 | + return $this->_job_step_response; |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * Gets the batch request type indicated in the $_REQUEST |
|
358 | - * |
|
359 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
360 | - */ |
|
361 | - public function batch_request_type() |
|
362 | - { |
|
363 | - if ($this->_batch_request_type === null) { |
|
364 | - if (isset($_GET['batch'])) { |
|
365 | - if ($_GET['batch'] == self::batch_job) { |
|
366 | - $this->_batch_request_type = self::batch_job; |
|
367 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
368 | - $this->_batch_request_type = self::batch_file_job; |
|
369 | - } |
|
370 | - } |
|
371 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
372 | - if ($this->_batch_request_type === null) { |
|
373 | - $this->_batch_request_type = self::batch_not_job; |
|
374 | - } |
|
375 | - } |
|
376 | - return $this->_batch_request_type; |
|
377 | - } |
|
356 | + /** |
|
357 | + * Gets the batch request type indicated in the $_REQUEST |
|
358 | + * |
|
359 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
360 | + */ |
|
361 | + public function batch_request_type() |
|
362 | + { |
|
363 | + if ($this->_batch_request_type === null) { |
|
364 | + if (isset($_GET['batch'])) { |
|
365 | + if ($_GET['batch'] == self::batch_job) { |
|
366 | + $this->_batch_request_type = self::batch_job; |
|
367 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
368 | + $this->_batch_request_type = self::batch_file_job; |
|
369 | + } |
|
370 | + } |
|
371 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
372 | + if ($this->_batch_request_type === null) { |
|
373 | + $this->_batch_request_type = self::batch_not_job; |
|
374 | + } |
|
375 | + } |
|
376 | + return $this->_batch_request_type; |
|
377 | + } |
|
378 | 378 | |
379 | - /** |
|
380 | - * Unnecessary |
|
381 | - * |
|
382 | - * @param type $WP |
|
383 | - */ |
|
384 | - public function run($WP) |
|
385 | - { |
|
386 | - } |
|
379 | + /** |
|
380 | + * Unnecessary |
|
381 | + * |
|
382 | + * @param type $WP |
|
383 | + */ |
|
384 | + public function run($WP) |
|
385 | + { |
|
386 | + } |
|
387 | 387 | } |
@@ -12,217 +12,217 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @return EED_Feeds |
|
17 | - */ |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - return parent::get_instance(__CLASS__); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public static function set_hooks() |
|
31 | - { |
|
32 | - add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | - add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | - add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | - add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function set_hooks_admin() |
|
45 | - { |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * run - initial module setup |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function run($WP) |
|
56 | - { |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * default_feed |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param type rss2, atom, rss, rdf, rssjs |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function default_feed($type = 'rss2') |
|
68 | - { |
|
69 | - // rss2, atom, rss, rdf, rssjs |
|
70 | - $type = 'rss2'; |
|
71 | - return $type; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * parse_request |
|
77 | - * |
|
78 | - * @access public |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function parse_request() |
|
82 | - { |
|
83 | - if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | - // define path to templates |
|
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | - // what kinda post_type are we dealing with ? |
|
87 | - switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | - case 'espresso_events': |
|
89 | - // for rss2, atom, rss, rdf |
|
90 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | - add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | - // for json ( also uses the above filter ) |
|
93 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | - break; |
|
95 | - case 'espresso_venues': |
|
96 | - // for rss2, atom, rss, rdf |
|
97 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | - add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | - // for json ( also uses the above filter ) |
|
100 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | - break; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | - * espresso_attendees post_type |
|
112 | - * |
|
113 | - * @access public |
|
114 | - * @param string $SQL the JOIN clause for the comment feed query |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public static function comment_feed_join($SQL) |
|
118 | - { |
|
119 | - global $wpdb; |
|
120 | - // check for wp_posts table in JOIN clause |
|
121 | - if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | - add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | - } |
|
124 | - return $SQL; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | - * espresso_attendees post_type |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @param string $SQL the WHERE clause for the comment feed query |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public static function comment_feed_where($SQL) |
|
139 | - { |
|
140 | - global $wp_query, $wpdb; |
|
141 | - if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | - $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | - } |
|
144 | - return $SQL; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * the_event_feed |
|
150 | - * |
|
151 | - * @access public |
|
152 | - * @param string $content |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public static function the_event_feed($content) |
|
156 | - { |
|
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | - global $post; |
|
159 | - $template_args = array( |
|
160 | - 'EVT_ID' => $post->ID, |
|
161 | - 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | - ); |
|
163 | - $content = EEH_Template::display_template( |
|
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | - $template_args, |
|
166 | - true |
|
167 | - ); |
|
168 | - } |
|
169 | - return $content; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * the_event_rssjs_feed |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * @param object $item |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - public static function the_event_rssjs_feed($item) |
|
181 | - { |
|
182 | - if (is_feed() && isset($item->description)) { |
|
183 | - $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | - } |
|
185 | - return $item; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * the_venue_feed |
|
191 | - * |
|
192 | - * @access public |
|
193 | - * @param string $content |
|
194 | - * @return void |
|
195 | - */ |
|
196 | - public static function the_venue_feed($content) |
|
197 | - { |
|
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | - global $post; |
|
200 | - $template_args = array( |
|
201 | - 'VNU_ID' => $post->ID, |
|
202 | - 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | - ); |
|
204 | - $content = EEH_Template::display_template( |
|
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | - $template_args, |
|
207 | - true |
|
208 | - ); |
|
209 | - } |
|
210 | - return $content; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * the_venue_rssjs_feed |
|
216 | - * |
|
217 | - * @access public |
|
218 | - * @param object $item |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - public static function the_venue_rssjs_feed($item) |
|
222 | - { |
|
223 | - if (is_feed() && isset($item->description)) { |
|
224 | - $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | - } |
|
226 | - return $item; |
|
227 | - } |
|
15 | + /** |
|
16 | + * @return EED_Feeds |
|
17 | + */ |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + return parent::get_instance(__CLASS__); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks() |
|
31 | + { |
|
32 | + add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | + add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | + add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | + add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function set_hooks_admin() |
|
45 | + { |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * run - initial module setup |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function run($WP) |
|
56 | + { |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * default_feed |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param type rss2, atom, rss, rdf, rssjs |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function default_feed($type = 'rss2') |
|
68 | + { |
|
69 | + // rss2, atom, rss, rdf, rssjs |
|
70 | + $type = 'rss2'; |
|
71 | + return $type; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * parse_request |
|
77 | + * |
|
78 | + * @access public |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function parse_request() |
|
82 | + { |
|
83 | + if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | + // define path to templates |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | + // what kinda post_type are we dealing with ? |
|
87 | + switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | + case 'espresso_events': |
|
89 | + // for rss2, atom, rss, rdf |
|
90 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | + add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | + // for json ( also uses the above filter ) |
|
93 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | + break; |
|
95 | + case 'espresso_venues': |
|
96 | + // for rss2, atom, rss, rdf |
|
97 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | + add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | + // for json ( also uses the above filter ) |
|
100 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | + break; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | + * espresso_attendees post_type |
|
112 | + * |
|
113 | + * @access public |
|
114 | + * @param string $SQL the JOIN clause for the comment feed query |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public static function comment_feed_join($SQL) |
|
118 | + { |
|
119 | + global $wpdb; |
|
120 | + // check for wp_posts table in JOIN clause |
|
121 | + if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | + add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | + } |
|
124 | + return $SQL; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | + * espresso_attendees post_type |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @param string $SQL the WHERE clause for the comment feed query |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public static function comment_feed_where($SQL) |
|
139 | + { |
|
140 | + global $wp_query, $wpdb; |
|
141 | + if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | + $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | + } |
|
144 | + return $SQL; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * the_event_feed |
|
150 | + * |
|
151 | + * @access public |
|
152 | + * @param string $content |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public static function the_event_feed($content) |
|
156 | + { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | + global $post; |
|
159 | + $template_args = array( |
|
160 | + 'EVT_ID' => $post->ID, |
|
161 | + 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | + ); |
|
163 | + $content = EEH_Template::display_template( |
|
164 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | + $template_args, |
|
166 | + true |
|
167 | + ); |
|
168 | + } |
|
169 | + return $content; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * the_event_rssjs_feed |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * @param object $item |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + public static function the_event_rssjs_feed($item) |
|
181 | + { |
|
182 | + if (is_feed() && isset($item->description)) { |
|
183 | + $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | + } |
|
185 | + return $item; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * the_venue_feed |
|
191 | + * |
|
192 | + * @access public |
|
193 | + * @param string $content |
|
194 | + * @return void |
|
195 | + */ |
|
196 | + public static function the_venue_feed($content) |
|
197 | + { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | + global $post; |
|
200 | + $template_args = array( |
|
201 | + 'VNU_ID' => $post->ID, |
|
202 | + 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | + ); |
|
204 | + $content = EEH_Template::display_template( |
|
205 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | + $template_args, |
|
207 | + true |
|
208 | + ); |
|
209 | + } |
|
210 | + return $content; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * the_venue_rssjs_feed |
|
216 | + * |
|
217 | + * @access public |
|
218 | + * @param object $item |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + public static function the_venue_rssjs_feed($item) |
|
222 | + { |
|
223 | + if (is_feed() && isset($item->description)) { |
|
224 | + $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | + } |
|
226 | + return $item; |
|
227 | + } |
|
228 | 228 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | if (EE_Registry::instance()->REQ->is_set('post_type')) { |
84 | 84 | // define path to templates |
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
86 | 86 | // what kinda post_type are we dealing with ? |
87 | 87 | switch (EE_Registry::instance()->REQ->get('post_type')) { |
88 | 88 | case 'espresso_events': |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public static function the_event_feed($content) |
156 | 156 | { |
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) { |
|
158 | 158 | global $post; |
159 | 159 | $template_args = array( |
160 | 160 | 'EVT_ID' => $post->ID, |
161 | 161 | 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
162 | 162 | ); |
163 | 163 | $content = EEH_Template::display_template( |
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
164 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php', |
|
165 | 165 | $template_args, |
166 | 166 | true |
167 | 167 | ); |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public static function the_venue_feed($content) |
197 | 197 | { |
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) { |
|
199 | 199 | global $post; |
200 | 200 | $template_args = array( |
201 | 201 | 'VNU_ID' => $post->ID, |
202 | 202 | 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
203 | 203 | ); |
204 | 204 | $content = EEH_Template::display_template( |
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
205 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php', |
|
206 | 206 | $template_args, |
207 | 207 | true |
208 | 208 | ); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function venue_location($content) |
172 | 172 | { |
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
173 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | // get some style |
186 | 186 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
187 | 187 | // first check theme folder |
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
188 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
189 | 189 | wp_register_style( |
190 | 190 | $this->theme, |
191 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
191 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
192 | 192 | array('dashicons', 'espresso_default') |
193 | 193 | ); |
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
194 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
195 | 195 | wp_register_style( |
196 | 196 | $this->theme, |
197 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
197 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
198 | 198 | array('dashicons', 'espresso_default') |
199 | 199 | ); |
200 | 200 | } |
@@ -29,178 +29,178 @@ |
||
29 | 29 | class EED_Venues_Archive extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @return EED_Venues_Archive |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | - 'Venues_Archive', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | - ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | - ) { |
|
102 | - EEH_Template::load_espresso_theme_functions(); |
|
103 | - // then add extra event data via hooks |
|
104 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | - // don't know if theme uses the_excerpt |
|
106 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | - // or the_content |
|
108 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | - // don't display entry meta because the existing theme will take care of that |
|
110 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | - } |
|
112 | - return $template; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * the_title |
|
118 | - * |
|
119 | - * @access public |
|
120 | - * @param string $title |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function the_title($title = '') |
|
124 | - { |
|
125 | - return $title; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * venue_details |
|
131 | - * |
|
132 | - * @access public |
|
133 | - * @param string $content |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function venue_details($content) |
|
137 | - { |
|
138 | - global $post; |
|
139 | - if ( |
|
140 | - $post->post_type == 'espresso_venues' |
|
141 | - && ! post_password_required() |
|
142 | - ) { |
|
143 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | - // it uses the_content() for displaying the $post->post_content |
|
145 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | - remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | - // add filters we want |
|
150 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | - add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | - // now load our template |
|
153 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | - // now add our filter back in, plus some others |
|
155 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | - // remove other filters we added so they won't get applied to the next post |
|
158 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | - remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | - } |
|
162 | - return ! empty($template) ? $template : $content; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * venue_location |
|
168 | - * |
|
169 | - * @access public |
|
170 | - * @param string $content |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function venue_location($content) |
|
174 | - { |
|
175 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * wp_enqueue_scripts |
|
181 | - * |
|
182 | - * @access public |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function wp_enqueue_scripts() |
|
186 | - { |
|
187 | - // get some style |
|
188 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | - // first check theme folder |
|
190 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | - wp_register_style( |
|
192 | - $this->theme, |
|
193 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | - array('dashicons', 'espresso_default') |
|
195 | - ); |
|
196 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | - wp_register_style( |
|
198 | - $this->theme, |
|
199 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | - array('dashicons', 'espresso_default') |
|
201 | - ); |
|
202 | - } |
|
203 | - wp_enqueue_style($this->theme); |
|
204 | - } |
|
205 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venues_Archive |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | + 'Venues_Archive', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | + ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | + ) { |
|
102 | + EEH_Template::load_espresso_theme_functions(); |
|
103 | + // then add extra event data via hooks |
|
104 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | + // don't know if theme uses the_excerpt |
|
106 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | + // or the_content |
|
108 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | + // don't display entry meta because the existing theme will take care of that |
|
110 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | + } |
|
112 | + return $template; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * the_title |
|
118 | + * |
|
119 | + * @access public |
|
120 | + * @param string $title |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function the_title($title = '') |
|
124 | + { |
|
125 | + return $title; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * venue_details |
|
131 | + * |
|
132 | + * @access public |
|
133 | + * @param string $content |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function venue_details($content) |
|
137 | + { |
|
138 | + global $post; |
|
139 | + if ( |
|
140 | + $post->post_type == 'espresso_venues' |
|
141 | + && ! post_password_required() |
|
142 | + ) { |
|
143 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | + // it uses the_content() for displaying the $post->post_content |
|
145 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | + remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | + // add filters we want |
|
150 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | + add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | + // now load our template |
|
153 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | + // now add our filter back in, plus some others |
|
155 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | + // remove other filters we added so they won't get applied to the next post |
|
158 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | + remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | + } |
|
162 | + return ! empty($template) ? $template : $content; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * venue_location |
|
168 | + * |
|
169 | + * @access public |
|
170 | + * @param string $content |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function venue_location($content) |
|
174 | + { |
|
175 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * wp_enqueue_scripts |
|
181 | + * |
|
182 | + * @access public |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function wp_enqueue_scripts() |
|
186 | + { |
|
187 | + // get some style |
|
188 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | + // first check theme folder |
|
190 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | + wp_register_style( |
|
192 | + $this->theme, |
|
193 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | + array('dashicons', 'espresso_default') |
|
195 | + ); |
|
196 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | + wp_register_style( |
|
198 | + $this->theme, |
|
199 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | + array('dashicons', 'espresso_default') |
|
201 | + ); |
|
202 | + } |
|
203 | + wp_enqueue_style($this->theme); |
|
204 | + } |
|
205 | + } |
|
206 | 206 | } |