@@ -12,87 +12,87 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @return EED_Invoice |
|
17 | - */ |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - return parent::get_instance(__CLASS__); |
|
21 | - } |
|
15 | + /** |
|
16 | + * @return EED_Invoice |
|
17 | + */ |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + return parent::get_instance(__CLASS__); |
|
21 | + } |
|
22 | 22 | |
23 | 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 | - EE_Config::register_route('download_invoice', 'EED_Invoice', 'download_invoice'); |
|
33 | - EE_Config::register_route('launch_invoice', 'EED_Invoice', 'launch_invoice'); |
|
34 | - } |
|
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 | + EE_Config::register_route('download_invoice', 'EED_Invoice', 'download_invoice'); |
|
33 | + EE_Config::register_route('launch_invoice', 'EED_Invoice', 'launch_invoice'); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public static function set_hooks_admin() |
|
44 | - { |
|
45 | - } |
|
37 | + /** |
|
38 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public static function set_hooks_admin() |
|
44 | + { |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * run - initial module setup |
|
50 | - * |
|
51 | - * @access public |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public function run($WP) |
|
55 | - { |
|
56 | - if (is_readable(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php')) { |
|
57 | - require_once(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php'); |
|
58 | - } else { |
|
59 | - $msg = __('The Invoice.class.php file could not be loaded.', 'event_espresso'); |
|
60 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
61 | - } |
|
62 | - } |
|
48 | + /** |
|
49 | + * run - initial module setup |
|
50 | + * |
|
51 | + * @access public |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public function run($WP) |
|
55 | + { |
|
56 | + if (is_readable(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php')) { |
|
57 | + require_once(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php'); |
|
58 | + } else { |
|
59 | + $msg = __('The Invoice.class.php file could not be loaded.', 'event_espresso'); |
|
60 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * invoice_launch |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - public function launch_invoice() |
|
72 | - { |
|
73 | - $this->run(null); |
|
74 | - if (EE_Registry::instance()->REQ->is_set('id')) { |
|
75 | - $id = sanitize_key(EE_Registry::instance()->REQ->get('id')); |
|
76 | - $invoice = new Invoice($id); |
|
77 | - $invoice->send_invoice(); |
|
78 | - } |
|
79 | - } |
|
65 | + /** |
|
66 | + * invoice_launch |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + public function launch_invoice() |
|
72 | + { |
|
73 | + $this->run(null); |
|
74 | + if (EE_Registry::instance()->REQ->is_set('id')) { |
|
75 | + $id = sanitize_key(EE_Registry::instance()->REQ->get('id')); |
|
76 | + $invoice = new Invoice($id); |
|
77 | + $invoice->send_invoice(); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * download_invoice |
|
84 | - * |
|
85 | - * @access public |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - public function download_invoice() |
|
89 | - { |
|
90 | - $this->run(null); |
|
91 | - if (EE_Registry::instance()->REQ->is_set('id')) { |
|
92 | - $id = sanitize_key(EE_Registry::instance()->REQ->get('id')); |
|
93 | - $invoice = new Invoice($_REQUEST['id']); |
|
94 | - // send invoice but force download |
|
95 | - $invoice->send_invoice(true); |
|
96 | - } |
|
97 | - } |
|
82 | + /** |
|
83 | + * download_invoice |
|
84 | + * |
|
85 | + * @access public |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + public function download_invoice() |
|
89 | + { |
|
90 | + $this->run(null); |
|
91 | + if (EE_Registry::instance()->REQ->is_set('id')) { |
|
92 | + $id = sanitize_key(EE_Registry::instance()->REQ->get('id')); |
|
93 | + $invoice = new Invoice($_REQUEST['id']); |
|
94 | + // send invoice but force download |
|
95 | + $invoice->send_invoice(true); |
|
96 | + } |
|
97 | + } |
|
98 | 98 | } |
@@ -53,8 +53,8 @@ |
||
53 | 53 | */ |
54 | 54 | public function run($WP) |
55 | 55 | { |
56 | - if (is_readable(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php')) { |
|
57 | - require_once(EE_MODULES . 'gateways/Invoice/lib/Invoice.class.php'); |
|
56 | + if (is_readable(EE_MODULES.'gateways/Invoice/lib/Invoice.class.php')) { |
|
57 | + require_once(EE_MODULES.'gateways/Invoice/lib/Invoice.class.php'); |
|
58 | 58 | } else { |
59 | 59 | $msg = __('The Invoice.class.php file could not be loaded.', 'event_espresso'); |
60 | 60 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
@@ -29,176 +29,176 @@ |
||
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 (EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
99 | - ->get_selected_template() != 'archive-espresso_venues.php' |
|
100 | - ) { |
|
101 | - EEH_Template::load_espresso_theme_functions(); |
|
102 | - // then add extra event data via hooks |
|
103 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
104 | - // don't know if theme uses the_excerpt |
|
105 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
106 | - // or the_content |
|
107 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
108 | - // don't display entry meta because the existing theme will take care of that |
|
109 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
110 | - } |
|
111 | - return $template; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * the_title |
|
117 | - * |
|
118 | - * @access public |
|
119 | - * @param string $title |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function the_title($title = '') |
|
123 | - { |
|
124 | - return $title; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * venue_details |
|
130 | - * |
|
131 | - * @access public |
|
132 | - * @param string $content |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function venue_details($content) |
|
136 | - { |
|
137 | - global $post; |
|
138 | - if ($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_excerpt', array($this, 'venue_details'), 100); |
|
146 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
147 | - // add filters we want |
|
148 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
149 | - add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
150 | - // now load our template |
|
151 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
152 | - // now add our filter back in, plus some others |
|
153 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
154 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
155 | - // remove other filters we added so they won't get applied to the next post |
|
156 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
157 | - remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
158 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
159 | - } |
|
160 | - return ! empty($template) ? $template : $content; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * venue_location |
|
166 | - * |
|
167 | - * @access public |
|
168 | - * @param string $content |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function venue_location($content) |
|
172 | - { |
|
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * wp_enqueue_scripts |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - public function wp_enqueue_scripts() |
|
184 | - { |
|
185 | - // get some style |
|
186 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
187 | - // first check theme folder |
|
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
189 | - wp_register_style( |
|
190 | - $this->theme, |
|
191 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
192 | - array('dashicons', 'espresso_default') |
|
193 | - ); |
|
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
195 | - wp_register_style( |
|
196 | - $this->theme, |
|
197 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
198 | - array('dashicons', 'espresso_default') |
|
199 | - ); |
|
200 | - } |
|
201 | - wp_enqueue_style($this->theme); |
|
202 | - } |
|
203 | - } |
|
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 (EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
99 | + ->get_selected_template() != 'archive-espresso_venues.php' |
|
100 | + ) { |
|
101 | + EEH_Template::load_espresso_theme_functions(); |
|
102 | + // then add extra event data via hooks |
|
103 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
104 | + // don't know if theme uses the_excerpt |
|
105 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
106 | + // or the_content |
|
107 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
108 | + // don't display entry meta because the existing theme will take care of that |
|
109 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
110 | + } |
|
111 | + return $template; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * the_title |
|
117 | + * |
|
118 | + * @access public |
|
119 | + * @param string $title |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function the_title($title = '') |
|
123 | + { |
|
124 | + return $title; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * venue_details |
|
130 | + * |
|
131 | + * @access public |
|
132 | + * @param string $content |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function venue_details($content) |
|
136 | + { |
|
137 | + global $post; |
|
138 | + if ($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_excerpt', array($this, 'venue_details'), 100); |
|
146 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
147 | + // add filters we want |
|
148 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
149 | + add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
150 | + // now load our template |
|
151 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
152 | + // now add our filter back in, plus some others |
|
153 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
154 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
155 | + // remove other filters we added so they won't get applied to the next post |
|
156 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
157 | + remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
158 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
159 | + } |
|
160 | + return ! empty($template) ? $template : $content; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * venue_location |
|
166 | + * |
|
167 | + * @access public |
|
168 | + * @param string $content |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function venue_location($content) |
|
172 | + { |
|
173 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * wp_enqueue_scripts |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + public function wp_enqueue_scripts() |
|
184 | + { |
|
185 | + // get some style |
|
186 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
187 | + // first check theme folder |
|
188 | + if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
189 | + wp_register_style( |
|
190 | + $this->theme, |
|
191 | + get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
192 | + array('dashicons', 'espresso_default') |
|
193 | + ); |
|
194 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
195 | + wp_register_style( |
|
196 | + $this->theme, |
|
197 | + EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
198 | + array('dashicons', 'espresso_default') |
|
199 | + ); |
|
200 | + } |
|
201 | + wp_enqueue_style($this->theme); |
|
202 | + } |
|
203 | + } |
|
204 | 204 | } |
@@ -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 . DS . 'style.css')) { |
|
188 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
189 | 189 | wp_register_style( |
190 | 190 | $this->theme, |
191 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
191 | + get_stylesheet_directory_uri().$this->theme.DS.'style.css', |
|
192 | 192 | array('dashicons', 'espresso_default') |
193 | 193 | ); |
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
194 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.DS.'style.css')) { |
|
195 | 195 | wp_register_style( |
196 | 196 | $this->theme, |
197 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
197 | + EE_TEMPLATES_URL.$this->theme.DS.'style.css', |
|
198 | 198 | array('dashicons', 'espresso_default') |
199 | 199 | ); |
200 | 200 | } |
@@ -15,340 +15,340 @@ |
||
15 | 15 | { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * @return EED_Bot_Trap|EED_Module |
|
20 | - */ |
|
21 | - public static function instance() |
|
22 | - { |
|
23 | - return parent::get_instance(__CLASS__); |
|
24 | - } |
|
18 | + /** |
|
19 | + * @return EED_Bot_Trap|EED_Module |
|
20 | + */ |
|
21 | + public static function instance() |
|
22 | + { |
|
23 | + return parent::get_instance(__CLASS__); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
29 | - * |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public static function set_hooks() |
|
33 | - { |
|
34 | - if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
35 | - \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
36 | - ) { |
|
37 | - \EED_Bot_Trap::set_trap(); |
|
38 | - // redirect bots to bogus success page |
|
39 | - \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
40 | - } |
|
41 | - } |
|
27 | + /** |
|
28 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
29 | + * |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public static function set_hooks() |
|
33 | + { |
|
34 | + if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
35 | + \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
36 | + ) { |
|
37 | + \EED_Bot_Trap::set_trap(); |
|
38 | + // redirect bots to bogus success page |
|
39 | + \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
46 | - * |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public static function set_trap() |
|
50 | - { |
|
51 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
52 | - add_action( |
|
53 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
54 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
55 | - 10, |
|
56 | - 2 |
|
57 | - ); |
|
58 | - add_action( |
|
59 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | - 1, |
|
62 | - 2 |
|
63 | - ); |
|
64 | - } |
|
44 | + /** |
|
45 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
46 | + * |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public static function set_trap() |
|
50 | + { |
|
51 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
52 | + add_action( |
|
53 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
54 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
55 | + 10, |
|
56 | + 2 |
|
57 | + ); |
|
58 | + add_action( |
|
59 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
60 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
61 | + 1, |
|
62 | + 2 |
|
63 | + ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public static function set_hooks_admin() |
|
73 | - { |
|
74 | - if (defined('DOING_AJAX') |
|
75 | - && DOING_AJAX |
|
76 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
77 | - && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
78 | - ) { |
|
79 | - \EED_Bot_Trap::set_trap(); |
|
80 | - } |
|
81 | - add_action( |
|
82 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
83 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
84 | - 5 |
|
85 | - ); |
|
86 | - add_filter( |
|
87 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
88 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
89 | - 10, |
|
90 | - 1 |
|
91 | - ); |
|
92 | - } |
|
67 | + /** |
|
68 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public static function set_hooks_admin() |
|
73 | + { |
|
74 | + if (defined('DOING_AJAX') |
|
75 | + && DOING_AJAX |
|
76 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
77 | + && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
78 | + ) { |
|
79 | + \EED_Bot_Trap::set_trap(); |
|
80 | + } |
|
81 | + add_action( |
|
82 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
83 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
84 | + 5 |
|
85 | + ); |
|
86 | + add_filter( |
|
87 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
88 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
89 | + 10, |
|
90 | + 1 |
|
91 | + ); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * run - initial module setup |
|
97 | - * |
|
98 | - * @param WP $WP |
|
99 | - * @return void |
|
100 | - */ |
|
101 | - public function run($WP) |
|
102 | - { |
|
103 | - } |
|
95 | + /** |
|
96 | + * run - initial module setup |
|
97 | + * |
|
98 | + * @param WP $WP |
|
99 | + * @return void |
|
100 | + */ |
|
101 | + public function run($WP) |
|
102 | + { |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * generate_bot_trap |
|
108 | - * |
|
109 | - * @return void |
|
110 | - * @throws RuntimeException |
|
111 | - */ |
|
112 | - public static function generate_bot_trap() |
|
113 | - { |
|
114 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
115 | - $time = microtime(true); |
|
116 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
117 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
118 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
119 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
120 | - $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
|
121 | - if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
122 | - EE_Registry::instance()->load_core('EE_Encryption'); |
|
123 | - $html .= EE_Encryption::instance()->encrypt($time); |
|
124 | - } else { |
|
125 | - $html .= $time; |
|
126 | - } |
|
127 | - $html .= '"/>'; |
|
128 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
129 | - echo $html; |
|
130 | - } |
|
106 | + /** |
|
107 | + * generate_bot_trap |
|
108 | + * |
|
109 | + * @return void |
|
110 | + * @throws RuntimeException |
|
111 | + */ |
|
112 | + public static function generate_bot_trap() |
|
113 | + { |
|
114 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
115 | + $time = microtime(true); |
|
116 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
117 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
118 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
119 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
120 | + $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
|
121 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
122 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
123 | + $html .= EE_Encryption::instance()->encrypt($time); |
|
124 | + } else { |
|
125 | + $html .= $time; |
|
126 | + } |
|
127 | + $html .= '"/>'; |
|
128 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
129 | + echo $html; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * process_bot_trap |
|
135 | - * |
|
136 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
137 | - * response if the bot trap is triggered. |
|
138 | - * It should receive one argument: a boolean indicating |
|
139 | - * whether the trap was triggered by suspicious timing or not. |
|
140 | - * @throws RuntimeException |
|
141 | - */ |
|
142 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
143 | - { |
|
144 | - // what's your email address Mr. Bot ? |
|
145 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
146 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
147 | - // get encrypted timestamp for when the form was originally displayed |
|
148 | - $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
149 | - ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
150 | - : ''; |
|
151 | - // decrypt and convert to absolute integer |
|
152 | - if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
153 | - EE_Registry::instance()->load_core('EE_Encryption'); |
|
154 | - $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
155 | - } else { |
|
156 | - $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
157 | - } |
|
158 | - // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
|
159 | - $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS); |
|
160 | - // are we human ? |
|
161 | - if ($empty_trap && ! $suspicious_timing) { |
|
162 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
163 | - return; |
|
164 | - } |
|
165 | - // check the given callback is valid first before executing |
|
166 | - if (! is_callable($triggered_trap_callback)) { |
|
167 | - // invalid callback so lets just sub in our default. |
|
168 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
169 | - } |
|
170 | - call_user_func($triggered_trap_callback, $suspicious_timing); |
|
171 | - } |
|
133 | + /** |
|
134 | + * process_bot_trap |
|
135 | + * |
|
136 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
137 | + * response if the bot trap is triggered. |
|
138 | + * It should receive one argument: a boolean indicating |
|
139 | + * whether the trap was triggered by suspicious timing or not. |
|
140 | + * @throws RuntimeException |
|
141 | + */ |
|
142 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
143 | + { |
|
144 | + // what's your email address Mr. Bot ? |
|
145 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
146 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
147 | + // get encrypted timestamp for when the form was originally displayed |
|
148 | + $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
149 | + ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
150 | + : ''; |
|
151 | + // decrypt and convert to absolute integer |
|
152 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
153 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
154 | + $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
155 | + } else { |
|
156 | + $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
157 | + } |
|
158 | + // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
|
159 | + $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS); |
|
160 | + // are we human ? |
|
161 | + if ($empty_trap && ! $suspicious_timing) { |
|
162 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
163 | + return; |
|
164 | + } |
|
165 | + // check the given callback is valid first before executing |
|
166 | + if (! is_callable($triggered_trap_callback)) { |
|
167 | + // invalid callback so lets just sub in our default. |
|
168 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
169 | + } |
|
170 | + call_user_func($triggered_trap_callback, $suspicious_timing); |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - /** |
|
175 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
176 | - * |
|
177 | - * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
|
178 | - */ |
|
179 | - public static function triggered_trap_response($suspicious_timing) |
|
180 | - { |
|
181 | - // UH OH... |
|
182 | - $redirect_url = add_query_arg( |
|
183 | - array('ee' => 'ticket_selection_received'), |
|
184 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
185 | - ); |
|
186 | - if ($suspicious_timing) { |
|
187 | - $redirect_url = add_query_arg( |
|
188 | - array( |
|
189 | - 'ee-notice' => urlencode( |
|
190 | - esc_html__( |
|
191 | - 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', |
|
192 | - 'event_espresso' |
|
193 | - ) |
|
194 | - ), |
|
195 | - ), |
|
196 | - $redirect_url |
|
197 | - ); |
|
198 | - } |
|
199 | - $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
|
200 | - // if AJAX, return the redirect URL |
|
201 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
202 | - echo wp_json_encode( |
|
203 | - array_merge( |
|
204 | - EE_Error::get_notices(false), |
|
205 | - array( |
|
206 | - 'redirect_url' => $redirect_url, |
|
207 | - ) |
|
208 | - ) |
|
209 | - ); |
|
210 | - exit(); |
|
211 | - } |
|
212 | - wp_safe_redirect($redirect_url); |
|
213 | - exit(); |
|
214 | - } |
|
174 | + /** |
|
175 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
176 | + * |
|
177 | + * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
|
178 | + */ |
|
179 | + public static function triggered_trap_response($suspicious_timing) |
|
180 | + { |
|
181 | + // UH OH... |
|
182 | + $redirect_url = add_query_arg( |
|
183 | + array('ee' => 'ticket_selection_received'), |
|
184 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
185 | + ); |
|
186 | + if ($suspicious_timing) { |
|
187 | + $redirect_url = add_query_arg( |
|
188 | + array( |
|
189 | + 'ee-notice' => urlencode( |
|
190 | + esc_html__( |
|
191 | + 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', |
|
192 | + 'event_espresso' |
|
193 | + ) |
|
194 | + ), |
|
195 | + ), |
|
196 | + $redirect_url |
|
197 | + ); |
|
198 | + } |
|
199 | + $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
|
200 | + // if AJAX, return the redirect URL |
|
201 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
202 | + echo wp_json_encode( |
|
203 | + array_merge( |
|
204 | + EE_Error::get_notices(false), |
|
205 | + array( |
|
206 | + 'redirect_url' => $redirect_url, |
|
207 | + ) |
|
208 | + ) |
|
209 | + ); |
|
210 | + exit(); |
|
211 | + } |
|
212 | + wp_safe_redirect($redirect_url); |
|
213 | + exit(); |
|
214 | + } |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * display_bot_trap_success |
|
219 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
220 | - * think the form was submitted successfully |
|
221 | - * |
|
222 | - * @return void |
|
223 | - */ |
|
224 | - public static function display_bot_trap_success() |
|
225 | - { |
|
226 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
227 | - $bot_notice = esc_html__( |
|
228 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
229 | - 'event_espresso' |
|
230 | - ); |
|
231 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
232 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
233 | - : $bot_notice; |
|
234 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
235 | - } |
|
217 | + /** |
|
218 | + * display_bot_trap_success |
|
219 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
220 | + * think the form was submitted successfully |
|
221 | + * |
|
222 | + * @return void |
|
223 | + */ |
|
224 | + public static function display_bot_trap_success() |
|
225 | + { |
|
226 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
227 | + $bot_notice = esc_html__( |
|
228 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
229 | + 'event_espresso' |
|
230 | + ); |
|
231 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
232 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
233 | + : $bot_notice; |
|
234 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
235 | + } |
|
236 | 236 | |
237 | 237 | |
238 | 238 | |
239 | - /*********************************** ADMIN **********************************/ |
|
239 | + /*********************************** ADMIN **********************************/ |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * bot_trap_settings_form |
|
244 | - * |
|
245 | - * @return void |
|
246 | - * @throws EE_Error |
|
247 | - */ |
|
248 | - public static function bot_trap_settings_form() |
|
249 | - { |
|
250 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
251 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
252 | - } |
|
242 | + /** |
|
243 | + * bot_trap_settings_form |
|
244 | + * |
|
245 | + * @return void |
|
246 | + * @throws EE_Error |
|
247 | + */ |
|
248 | + public static function bot_trap_settings_form() |
|
249 | + { |
|
250 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
251 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | - /** |
|
256 | - * _bot_trap_settings_form |
|
257 | - * |
|
258 | - * @return EE_Form_Section_Proper |
|
259 | - * @throws EE_Error |
|
260 | - */ |
|
261 | - protected static function _bot_trap_settings_form() |
|
262 | - { |
|
263 | - return new EE_Form_Section_Proper( |
|
264 | - array( |
|
265 | - 'name' => 'bot_trap_settings', |
|
266 | - 'html_id' => 'bot_trap_settings', |
|
267 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
268 | - 'subsections' => array( |
|
269 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
270 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
271 | - ), |
|
272 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
273 | - array( |
|
274 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
275 | - 'html_help_text' => esc_html__( |
|
276 | - '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.', |
|
277 | - 'event_espresso' |
|
278 | - ), |
|
279 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
280 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
281 | - : true, |
|
282 | - 'required' => false, |
|
283 | - ) |
|
284 | - ), |
|
285 | - 'use_encryption' => new EE_Yes_No_Input( |
|
286 | - array( |
|
287 | - 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
288 | - 'html_help_text' => esc_html__( |
|
289 | - 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', |
|
290 | - 'event_espresso' |
|
291 | - ), |
|
292 | - 'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null |
|
293 | - ? EE_Registry::instance()->CFG->registration->use_encryption |
|
294 | - : true, |
|
295 | - 'required' => false, |
|
296 | - ) |
|
297 | - ), |
|
298 | - ), |
|
299 | - ) |
|
300 | - ); |
|
301 | - } |
|
255 | + /** |
|
256 | + * _bot_trap_settings_form |
|
257 | + * |
|
258 | + * @return EE_Form_Section_Proper |
|
259 | + * @throws EE_Error |
|
260 | + */ |
|
261 | + protected static function _bot_trap_settings_form() |
|
262 | + { |
|
263 | + return new EE_Form_Section_Proper( |
|
264 | + array( |
|
265 | + 'name' => 'bot_trap_settings', |
|
266 | + 'html_id' => 'bot_trap_settings', |
|
267 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
268 | + 'subsections' => array( |
|
269 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
270 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
271 | + ), |
|
272 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
273 | + array( |
|
274 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
275 | + 'html_help_text' => esc_html__( |
|
276 | + '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.', |
|
277 | + 'event_espresso' |
|
278 | + ), |
|
279 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
280 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
281 | + : true, |
|
282 | + 'required' => false, |
|
283 | + ) |
|
284 | + ), |
|
285 | + 'use_encryption' => new EE_Yes_No_Input( |
|
286 | + array( |
|
287 | + 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
288 | + 'html_help_text' => esc_html__( |
|
289 | + 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', |
|
290 | + 'event_espresso' |
|
291 | + ), |
|
292 | + 'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null |
|
293 | + ? EE_Registry::instance()->CFG->registration->use_encryption |
|
294 | + : true, |
|
295 | + 'required' => false, |
|
296 | + ) |
|
297 | + ), |
|
298 | + ), |
|
299 | + ) |
|
300 | + ); |
|
301 | + } |
|
302 | 302 | |
303 | 303 | |
304 | - /** |
|
305 | - * update_bot_trap_settings_form |
|
306 | - * |
|
307 | - * @param EE_Registration_Config $EE_Registration_Config |
|
308 | - * @return EE_Registration_Config |
|
309 | - * @throws ReflectionException |
|
310 | - * @throws EE_Error |
|
311 | - */ |
|
312 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
313 | - { |
|
314 | - try { |
|
315 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
316 | - // if not displaying a form, then check for form submission |
|
317 | - if ($bot_trap_settings_form->was_submitted()) { |
|
318 | - // capture form data |
|
319 | - $bot_trap_settings_form->receive_form_submission(); |
|
320 | - // validate form data |
|
321 | - if ($bot_trap_settings_form->is_valid()) { |
|
322 | - // grab validated data from form |
|
323 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
324 | - if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
325 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
326 | - $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
327 | - } else { |
|
328 | - EE_Error::add_error( |
|
329 | - esc_html__( |
|
330 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
331 | - 'event_espresso' |
|
332 | - ), |
|
333 | - __FILE__, |
|
334 | - __FUNCTION__, |
|
335 | - __LINE__ |
|
336 | - ); |
|
337 | - } |
|
338 | - } else { |
|
339 | - if ($bot_trap_settings_form->submission_error_message() !== '') { |
|
340 | - EE_Error::add_error( |
|
341 | - $bot_trap_settings_form->submission_error_message(), |
|
342 | - __FILE__, |
|
343 | - __FUNCTION__, |
|
344 | - __LINE__ |
|
345 | - ); |
|
346 | - } |
|
347 | - } |
|
348 | - } |
|
349 | - } catch (EE_Error $e) { |
|
350 | - $e->get_error(); |
|
351 | - } |
|
352 | - return $EE_Registration_Config; |
|
353 | - } |
|
304 | + /** |
|
305 | + * update_bot_trap_settings_form |
|
306 | + * |
|
307 | + * @param EE_Registration_Config $EE_Registration_Config |
|
308 | + * @return EE_Registration_Config |
|
309 | + * @throws ReflectionException |
|
310 | + * @throws EE_Error |
|
311 | + */ |
|
312 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
313 | + { |
|
314 | + try { |
|
315 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
316 | + // if not displaying a form, then check for form submission |
|
317 | + if ($bot_trap_settings_form->was_submitted()) { |
|
318 | + // capture form data |
|
319 | + $bot_trap_settings_form->receive_form_submission(); |
|
320 | + // validate form data |
|
321 | + if ($bot_trap_settings_form->is_valid()) { |
|
322 | + // grab validated data from form |
|
323 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
324 | + if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
325 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
326 | + $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
327 | + } else { |
|
328 | + EE_Error::add_error( |
|
329 | + esc_html__( |
|
330 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
331 | + 'event_espresso' |
|
332 | + ), |
|
333 | + __FILE__, |
|
334 | + __FUNCTION__, |
|
335 | + __LINE__ |
|
336 | + ); |
|
337 | + } |
|
338 | + } else { |
|
339 | + if ($bot_trap_settings_form->submission_error_message() !== '') { |
|
340 | + EE_Error::add_error( |
|
341 | + $bot_trap_settings_form->submission_error_message(), |
|
342 | + __FILE__, |
|
343 | + __FUNCTION__, |
|
344 | + __LINE__ |
|
345 | + ); |
|
346 | + } |
|
347 | + } |
|
348 | + } |
|
349 | + } catch (EE_Error $e) { |
|
350 | + $e->get_error(); |
|
351 | + } |
|
352 | + return $EE_Registration_Config; |
|
353 | + } |
|
354 | 354 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function set_trap() |
50 | 50 | { |
51 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
51 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
52 | 52 | add_action( |
53 | 53 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
54 | 54 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
115 | 115 | $time = microtime(true); |
116 | 116 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
117 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
117 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
118 | 118 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
119 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
119 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
120 | 120 | $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
121 | 121 | if (EE_Registry::instance()->CFG->registration->use_encryption) { |
122 | 122 | EE_Registry::instance()->load_core('EE_Encryption'); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return; |
164 | 164 | } |
165 | 165 | // check the given callback is valid first before executing |
166 | - if (! is_callable($triggered_trap_callback)) { |
|
166 | + if ( ! is_callable($triggered_trap_callback)) { |
|
167 | 167 | // invalid callback so lets just sub in our default. |
168 | 168 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
169 | 169 | } |
@@ -29,171 +29,171 @@ |
||
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 (EE_Registry::instance() |
|
99 | - ->load_core('Front_Controller', array(), false, true) |
|
100 | - ->get_selected_template() != 'single-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 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
106 | - // don't display entry meta because the existing theme will take car of that |
|
107 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
108 | - } |
|
109 | - return $template; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * the_title |
|
115 | - * |
|
116 | - * @access public |
|
117 | - * @param string $title |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function the_title($title = '') |
|
121 | - { |
|
122 | - return $title; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * venue_details |
|
128 | - * |
|
129 | - * @access public |
|
130 | - * @param string $content |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function venue_details($content) |
|
134 | - { |
|
135 | - global $post; |
|
136 | - if ($post->post_type == 'espresso_venues' |
|
137 | - && ! post_password_required() |
|
138 | - ) { |
|
139 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
140 | - // it uses the_content() for displaying the $post->post_content |
|
141 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
142 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
143 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
144 | - // add filters we want |
|
145 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
146 | - // now load our template |
|
147 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
148 | - // remove other filters we added so they won't get applied to the next post |
|
149 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
150 | - } |
|
151 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
152 | - return ! empty($template) ? $template : $content; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * venue_location |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @param string $content |
|
161 | - * @return string |
|
162 | - */ |
|
163 | - public function venue_location($content) |
|
164 | - { |
|
165 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * wp_enqueue_scripts |
|
171 | - * |
|
172 | - * @access public |
|
173 | - * @return void |
|
174 | - */ |
|
175 | - public function wp_enqueue_scripts() |
|
176 | - { |
|
177 | - // get some style |
|
178 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
179 | - // first check theme folder |
|
180 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
181 | - wp_register_style( |
|
182 | - $this->theme, |
|
183 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
184 | - array('dashicons', 'espresso_default') |
|
185 | - ); |
|
186 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
187 | - wp_register_style( |
|
188 | - $this->theme, |
|
189 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
190 | - array('dashicons', 'espresso_default') |
|
191 | - ); |
|
192 | - } |
|
193 | - wp_enqueue_style($this->theme); |
|
194 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
195 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
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 (EE_Registry::instance() |
|
99 | + ->load_core('Front_Controller', array(), false, true) |
|
100 | + ->get_selected_template() != 'single-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 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
106 | + // don't display entry meta because the existing theme will take car of that |
|
107 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
108 | + } |
|
109 | + return $template; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * the_title |
|
115 | + * |
|
116 | + * @access public |
|
117 | + * @param string $title |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function the_title($title = '') |
|
121 | + { |
|
122 | + return $title; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * venue_details |
|
128 | + * |
|
129 | + * @access public |
|
130 | + * @param string $content |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function venue_details($content) |
|
134 | + { |
|
135 | + global $post; |
|
136 | + if ($post->post_type == 'espresso_venues' |
|
137 | + && ! post_password_required() |
|
138 | + ) { |
|
139 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
140 | + // it uses the_content() for displaying the $post->post_content |
|
141 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
142 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
143 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
144 | + // add filters we want |
|
145 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
146 | + // now load our template |
|
147 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
148 | + // remove other filters we added so they won't get applied to the next post |
|
149 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
150 | + } |
|
151 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
152 | + return ! empty($template) ? $template : $content; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * venue_location |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @param string $content |
|
161 | + * @return string |
|
162 | + */ |
|
163 | + public function venue_location($content) |
|
164 | + { |
|
165 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * wp_enqueue_scripts |
|
171 | + * |
|
172 | + * @access public |
|
173 | + * @return void |
|
174 | + */ |
|
175 | + public function wp_enqueue_scripts() |
|
176 | + { |
|
177 | + // get some style |
|
178 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
179 | + // first check theme folder |
|
180 | + if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
181 | + wp_register_style( |
|
182 | + $this->theme, |
|
183 | + get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
184 | + array('dashicons', 'espresso_default') |
|
185 | + ); |
|
186 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
187 | + wp_register_style( |
|
188 | + $this->theme, |
|
189 | + EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
190 | + array('dashicons', 'espresso_default') |
|
191 | + ); |
|
192 | + } |
|
193 | + wp_enqueue_style($this->theme); |
|
194 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
195 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | 199 | } |
@@ -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 . DS . 'style.css')) { |
|
180 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
181 | 181 | wp_register_style( |
182 | 182 | $this->theme, |
183 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
183 | + get_stylesheet_directory_uri().$this->theme.DS.'style.css', |
|
184 | 184 | array('dashicons', 'espresso_default') |
185 | 185 | ); |
186 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . DS . 'style.css')) { |
|
186 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.DS.'style.css')) { |
|
187 | 187 | wp_register_style( |
188 | 188 | $this->theme, |
189 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
189 | + EE_TEMPLATES_URL.$this->theme.DS.'style.css', |
|
190 | 190 | array('dashicons', 'espresso_default') |
191 | 191 | ); |
192 | 192 | } |
@@ -23,336 +23,336 @@ |
||
23 | 23 | class EED_Batch extends EED_Module |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
28 | - * processes data only |
|
29 | - */ |
|
30 | - const batch_job = 'job'; |
|
31 | - /** |
|
32 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
33 | - * produces a file for download |
|
34 | - */ |
|
35 | - const batch_file_job = 'file'; |
|
36 | - /** |
|
37 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
38 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
39 | - * at all |
|
40 | - */ |
|
41 | - const batch_not_job = 'none'; |
|
26 | + /** |
|
27 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
28 | + * processes data only |
|
29 | + */ |
|
30 | + const batch_job = 'job'; |
|
31 | + /** |
|
32 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
33 | + * produces a file for download |
|
34 | + */ |
|
35 | + const batch_file_job = 'file'; |
|
36 | + /** |
|
37 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
38 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
39 | + * at all |
|
40 | + */ |
|
41 | + const batch_not_job = 'none'; |
|
42 | 42 | |
43 | - /** |
|
44 | - * |
|
45 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
46 | - */ |
|
47 | - protected $_batch_request_type = null; |
|
43 | + /** |
|
44 | + * |
|
45 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
46 | + */ |
|
47 | + protected $_batch_request_type = null; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Because we want to use the response in both the localized JS and in the body |
|
51 | - * we need to make this response available between method calls |
|
52 | - * |
|
53 | - * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
54 | - */ |
|
55 | - protected $_job_step_response = null; |
|
49 | + /** |
|
50 | + * Because we want to use the response in both the localized JS and in the body |
|
51 | + * we need to make this response available between method calls |
|
52 | + * |
|
53 | + * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
54 | + */ |
|
55 | + protected $_job_step_response = null; |
|
56 | 56 | |
57 | - /** |
|
58 | - * Gets the batch instance |
|
59 | - * |
|
60 | - * @return EED_Batch |
|
61 | - */ |
|
62 | - public static function instance() |
|
63 | - { |
|
64 | - return self::get_instance(); |
|
65 | - } |
|
57 | + /** |
|
58 | + * Gets the batch instance |
|
59 | + * |
|
60 | + * @return EED_Batch |
|
61 | + */ |
|
62 | + public static function instance() |
|
63 | + { |
|
64 | + return self::get_instance(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
69 | - * because it's an attack vector and there are currently no implementations |
|
70 | - */ |
|
71 | - public static function set_hooks() |
|
72 | - { |
|
73 | - // because this is a possibel attack vector, let's have this disabled until |
|
74 | - // we at least have a real use for it on the frontend |
|
75 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
76 | - add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
77 | - add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
78 | - } |
|
79 | - } |
|
67 | + /** |
|
68 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
69 | + * because it's an attack vector and there are currently no implementations |
|
70 | + */ |
|
71 | + public static function set_hooks() |
|
72 | + { |
|
73 | + // because this is a possibel attack vector, let's have this disabled until |
|
74 | + // we at least have a real use for it on the frontend |
|
75 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
76 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
77 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Initializes some hooks for the admin in order to run batch jobs |
|
83 | - */ |
|
84 | - public static function set_hooks_admin() |
|
85 | - { |
|
86 | - add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
87 | - add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
81 | + /** |
|
82 | + * Initializes some hooks for the admin in order to run batch jobs |
|
83 | + */ |
|
84 | + public static function set_hooks_admin() |
|
85 | + { |
|
86 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
87 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | 88 | |
89 | - // ajax |
|
90 | - add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
91 | - add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
92 | - add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
93 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
94 | - } |
|
89 | + // ajax |
|
90 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
91 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
92 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
93 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
98 | - */ |
|
99 | - public function enqueue_scripts() |
|
100 | - { |
|
101 | - if (isset($_REQUEST['espresso_batch']) |
|
102 | - || |
|
103 | - ( |
|
104 | - isset($_REQUEST['page']) |
|
105 | - && $_REQUEST['page'] == 'espresso_batch' |
|
106 | - ) |
|
107 | - ) { |
|
108 | - switch ($this->batch_request_type()) { |
|
109 | - case self::batch_job: |
|
110 | - $this->enqueue_scripts_styles_batch_create(); |
|
111 | - break; |
|
112 | - case self::batch_file_job: |
|
113 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
114 | - break; |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
96 | + /** |
|
97 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
98 | + */ |
|
99 | + public function enqueue_scripts() |
|
100 | + { |
|
101 | + if (isset($_REQUEST['espresso_batch']) |
|
102 | + || |
|
103 | + ( |
|
104 | + isset($_REQUEST['page']) |
|
105 | + && $_REQUEST['page'] == 'espresso_batch' |
|
106 | + ) |
|
107 | + ) { |
|
108 | + switch ($this->batch_request_type()) { |
|
109 | + case self::batch_job: |
|
110 | + $this->enqueue_scripts_styles_batch_create(); |
|
111 | + break; |
|
112 | + case self::batch_file_job: |
|
113 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
114 | + break; |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
121 | - */ |
|
122 | - public function enqueue_scripts_styles_batch_create() |
|
123 | - { |
|
124 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
125 | - wp_enqueue_script( |
|
126 | - 'batch_runner_init', |
|
127 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
128 | - array('batch_runner'), |
|
129 | - EVENT_ESPRESSO_VERSION, |
|
130 | - true |
|
131 | - ); |
|
132 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
133 | - wp_localize_script( |
|
134 | - 'batch_runner_init', |
|
135 | - 'ee_job_i18n', |
|
136 | - array( |
|
137 | - 'return_url' => $_REQUEST['return_url'], |
|
138 | - ) |
|
139 | - ); |
|
140 | - } |
|
119 | + /** |
|
120 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
121 | + */ |
|
122 | + public function enqueue_scripts_styles_batch_create() |
|
123 | + { |
|
124 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
125 | + wp_enqueue_script( |
|
126 | + 'batch_runner_init', |
|
127 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
128 | + array('batch_runner'), |
|
129 | + EVENT_ESPRESSO_VERSION, |
|
130 | + true |
|
131 | + ); |
|
132 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
133 | + wp_localize_script( |
|
134 | + 'batch_runner_init', |
|
135 | + 'ee_job_i18n', |
|
136 | + array( |
|
137 | + 'return_url' => $_REQUEST['return_url'], |
|
138 | + ) |
|
139 | + ); |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
144 | - */ |
|
145 | - public function enqueue_scripts_styles_batch_file_create() |
|
146 | - { |
|
147 | - // creates a job based on the request variable |
|
148 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
149 | - wp_enqueue_script( |
|
150 | - 'batch_file_runner_init', |
|
151 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
152 | - array('batch_runner'), |
|
153 | - EVENT_ESPRESSO_VERSION, |
|
154 | - true |
|
155 | - ); |
|
156 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
157 | - wp_localize_script( |
|
158 | - 'batch_file_runner_init', |
|
159 | - 'ee_job_i18n', |
|
160 | - array( |
|
161 | - 'download_and_redirecting' => sprintf( |
|
162 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
163 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
164 | - '</a>' |
|
165 | - ), |
|
166 | - 'return_url' => $_REQUEST['return_url'], |
|
167 | - ) |
|
168 | - ); |
|
169 | - } |
|
142 | + /** |
|
143 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
144 | + */ |
|
145 | + public function enqueue_scripts_styles_batch_file_create() |
|
146 | + { |
|
147 | + // creates a job based on the request variable |
|
148 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
149 | + wp_enqueue_script( |
|
150 | + 'batch_file_runner_init', |
|
151 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
152 | + array('batch_runner'), |
|
153 | + EVENT_ESPRESSO_VERSION, |
|
154 | + true |
|
155 | + ); |
|
156 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
157 | + wp_localize_script( |
|
158 | + 'batch_file_runner_init', |
|
159 | + 'ee_job_i18n', |
|
160 | + array( |
|
161 | + 'download_and_redirecting' => sprintf( |
|
162 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
163 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
164 | + '</a>' |
|
165 | + ), |
|
166 | + 'return_url' => $_REQUEST['return_url'], |
|
167 | + ) |
|
168 | + ); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Enqueues scripts and styles common to any batch job, and creates |
|
173 | - * a job from the request data, and stores the response in the |
|
174 | - * $this->_job_step_response property |
|
175 | - * |
|
176 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
177 | - */ |
|
178 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
179 | - { |
|
180 | - wp_register_script( |
|
181 | - 'progress_bar', |
|
182 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
183 | - array('jquery') |
|
184 | - ); |
|
185 | - wp_enqueue_style( |
|
186 | - 'progress_bar', |
|
187 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
188 | - array(), |
|
189 | - EVENT_ESPRESSO_VERSION |
|
190 | - ); |
|
191 | - wp_enqueue_script( |
|
192 | - 'batch_runner', |
|
193 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
194 | - array('progress_bar') |
|
195 | - ); |
|
196 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
197 | - wp_localize_script( |
|
198 | - 'batch_runner', |
|
199 | - 'eei18n', |
|
200 | - array( |
|
201 | - 'ajax_url' => WP_AJAX_URL, |
|
202 | - 'is_admin' => (bool) is_admin(), |
|
203 | - 'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso'), |
|
204 | - ) |
|
205 | - ); |
|
206 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
207 | - $request_data = array_diff_key( |
|
208 | - $_REQUEST, |
|
209 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
210 | - ); |
|
211 | - $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
212 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
213 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
214 | - // remember the response for later. We need it to display the page body |
|
215 | - $this->_job_step_response = $job_response; |
|
216 | - return $job_response; |
|
217 | - } |
|
171 | + /** |
|
172 | + * Enqueues scripts and styles common to any batch job, and creates |
|
173 | + * a job from the request data, and stores the response in the |
|
174 | + * $this->_job_step_response property |
|
175 | + * |
|
176 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
177 | + */ |
|
178 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
179 | + { |
|
180 | + wp_register_script( |
|
181 | + 'progress_bar', |
|
182 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
183 | + array('jquery') |
|
184 | + ); |
|
185 | + wp_enqueue_style( |
|
186 | + 'progress_bar', |
|
187 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
188 | + array(), |
|
189 | + EVENT_ESPRESSO_VERSION |
|
190 | + ); |
|
191 | + wp_enqueue_script( |
|
192 | + 'batch_runner', |
|
193 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
194 | + array('progress_bar') |
|
195 | + ); |
|
196 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
197 | + wp_localize_script( |
|
198 | + 'batch_runner', |
|
199 | + 'eei18n', |
|
200 | + array( |
|
201 | + 'ajax_url' => WP_AJAX_URL, |
|
202 | + 'is_admin' => (bool) is_admin(), |
|
203 | + 'error_message' => esc_html__('An error occurred and the job has been stopped.', 'event_espresso'), |
|
204 | + ) |
|
205 | + ); |
|
206 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
207 | + $request_data = array_diff_key( |
|
208 | + $_REQUEST, |
|
209 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
210 | + ); |
|
211 | + $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
212 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
213 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
214 | + // remember the response for later. We need it to display the page body |
|
215 | + $this->_job_step_response = $job_response; |
|
216 | + return $job_response; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
221 | - * |
|
222 | - * @param string $template |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - public function override_template($template) |
|
226 | - { |
|
227 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
228 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
229 | - } |
|
230 | - return $template; |
|
231 | - } |
|
219 | + /** |
|
220 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
221 | + * |
|
222 | + * @param string $template |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + public function override_template($template) |
|
226 | + { |
|
227 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
228 | + return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
229 | + } |
|
230 | + return $template; |
|
231 | + } |
|
232 | 232 | |
233 | - /** |
|
234 | - * Adds an admin page which doesn't appear in the admin menu |
|
235 | - */ |
|
236 | - public function register_admin_pages() |
|
237 | - { |
|
238 | - add_submenu_page( |
|
239 | - '', // parent slug. we don't want this to actually appear in the menu |
|
240 | - __('Batch Job', 'event_espresso'), // page title |
|
241 | - 'n/a', // menu title |
|
242 | - 'read', // we want this page to actually be accessible to anyone, |
|
243 | - 'espresso_batch', // menu slug |
|
244 | - array(self::instance(), 'show_admin_page') |
|
245 | - ); |
|
246 | - } |
|
233 | + /** |
|
234 | + * Adds an admin page which doesn't appear in the admin menu |
|
235 | + */ |
|
236 | + public function register_admin_pages() |
|
237 | + { |
|
238 | + add_submenu_page( |
|
239 | + '', // parent slug. we don't want this to actually appear in the menu |
|
240 | + __('Batch Job', 'event_espresso'), // page title |
|
241 | + 'n/a', // menu title |
|
242 | + 'read', // we want this page to actually be accessible to anyone, |
|
243 | + 'espresso_batch', // menu slug |
|
244 | + array(self::instance(), 'show_admin_page') |
|
245 | + ); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
250 | - * of creating the job and localizing some data |
|
251 | - */ |
|
252 | - public function show_admin_page() |
|
253 | - { |
|
254 | - echo EEH_Template::locate_template( |
|
255 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
256 | - array('batch_request_type' => $this->batch_request_type()) |
|
257 | - ); |
|
258 | - } |
|
248 | + /** |
|
249 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
250 | + * of creating the job and localizing some data |
|
251 | + */ |
|
252 | + public function show_admin_page() |
|
253 | + { |
|
254 | + echo EEH_Template::locate_template( |
|
255 | + EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
256 | + array('batch_request_type' => $this->batch_request_type()) |
|
257 | + ); |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * Receives ajax calls for continuing a job |
|
262 | - */ |
|
263 | - public function batch_continue() |
|
264 | - { |
|
265 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
266 | - $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
267 | - $response_obj = $batch_runner->continue_job($job_id); |
|
268 | - $this->_return_json($response_obj->to_array()); |
|
269 | - } |
|
260 | + /** |
|
261 | + * Receives ajax calls for continuing a job |
|
262 | + */ |
|
263 | + public function batch_continue() |
|
264 | + { |
|
265 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
266 | + $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
267 | + $response_obj = $batch_runner->continue_job($job_id); |
|
268 | + $this->_return_json($response_obj->to_array()); |
|
269 | + } |
|
270 | 270 | |
271 | - /** |
|
272 | - * Receives the ajax call to cleanup a job |
|
273 | - * |
|
274 | - * @return type |
|
275 | - */ |
|
276 | - public function batch_cleanup() |
|
277 | - { |
|
278 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
279 | - $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
280 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
281 | - $this->_return_json($response_obj->to_array()); |
|
282 | - } |
|
271 | + /** |
|
272 | + * Receives the ajax call to cleanup a job |
|
273 | + * |
|
274 | + * @return type |
|
275 | + */ |
|
276 | + public function batch_cleanup() |
|
277 | + { |
|
278 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
279 | + $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
|
280 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
281 | + $this->_return_json($response_obj->to_array()); |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | - /** |
|
286 | - * Returns a json response |
|
287 | - * |
|
288 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
289 | - * |
|
290 | - * The returned json object is created from an array in the following format: |
|
291 | - * array( |
|
292 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
293 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
294 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
295 | - * args that might be included in here) |
|
296 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
297 | - * ) |
|
298 | - */ |
|
299 | - protected function _return_json($data) |
|
300 | - { |
|
301 | - $json = array( |
|
302 | - 'notices' => EE_Error::get_notices(), |
|
303 | - 'data' => $data, |
|
304 | - 'isEEajax' => true |
|
305 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
306 | - ); |
|
285 | + /** |
|
286 | + * Returns a json response |
|
287 | + * |
|
288 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
289 | + * |
|
290 | + * The returned json object is created from an array in the following format: |
|
291 | + * array( |
|
292 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
293 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
294 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
295 | + * args that might be included in here) |
|
296 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
297 | + * ) |
|
298 | + */ |
|
299 | + protected function _return_json($data) |
|
300 | + { |
|
301 | + $json = array( |
|
302 | + 'notices' => EE_Error::get_notices(), |
|
303 | + 'data' => $data, |
|
304 | + 'isEEajax' => true |
|
305 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
306 | + ); |
|
307 | 307 | |
308 | 308 | |
309 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
310 | - if (null === error_get_last() || ! headers_sent()) { |
|
311 | - header('Content-Type: application/json; charset=UTF-8'); |
|
312 | - } |
|
313 | - echo wp_json_encode($json); |
|
314 | - exit(); |
|
315 | - } |
|
309 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
310 | + if (null === error_get_last() || ! headers_sent()) { |
|
311 | + header('Content-Type: application/json; charset=UTF-8'); |
|
312 | + } |
|
313 | + echo wp_json_encode($json); |
|
314 | + exit(); |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Gets the job step response which was done during the enqueuing of scripts |
|
319 | - * |
|
320 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
321 | - */ |
|
322 | - public function job_step_response() |
|
323 | - { |
|
324 | - return $this->_job_step_response; |
|
325 | - } |
|
317 | + /** |
|
318 | + * Gets the job step response which was done during the enqueuing of scripts |
|
319 | + * |
|
320 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
321 | + */ |
|
322 | + public function job_step_response() |
|
323 | + { |
|
324 | + return $this->_job_step_response; |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * Gets the batch request type indicated in the $_REQUEST |
|
329 | - * |
|
330 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
331 | - */ |
|
332 | - public function batch_request_type() |
|
333 | - { |
|
334 | - if ($this->_batch_request_type === null) { |
|
335 | - if (isset($_GET['batch'])) { |
|
336 | - if ($_GET['batch'] == self::batch_job) { |
|
337 | - $this->_batch_request_type = self::batch_job; |
|
338 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
339 | - $this->_batch_request_type = self::batch_file_job; |
|
340 | - } |
|
341 | - } |
|
342 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
343 | - if ($this->_batch_request_type === null) { |
|
344 | - $this->_batch_request_type = self::batch_not_job; |
|
345 | - } |
|
346 | - } |
|
347 | - return $this->_batch_request_type; |
|
348 | - } |
|
327 | + /** |
|
328 | + * Gets the batch request type indicated in the $_REQUEST |
|
329 | + * |
|
330 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
331 | + */ |
|
332 | + public function batch_request_type() |
|
333 | + { |
|
334 | + if ($this->_batch_request_type === null) { |
|
335 | + if (isset($_GET['batch'])) { |
|
336 | + if ($_GET['batch'] == self::batch_job) { |
|
337 | + $this->_batch_request_type = self::batch_job; |
|
338 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
339 | + $this->_batch_request_type = self::batch_file_job; |
|
340 | + } |
|
341 | + } |
|
342 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
343 | + if ($this->_batch_request_type === null) { |
|
344 | + $this->_batch_request_type = self::batch_not_job; |
|
345 | + } |
|
346 | + } |
|
347 | + return $this->_batch_request_type; |
|
348 | + } |
|
349 | 349 | |
350 | - /** |
|
351 | - * Unnecessary |
|
352 | - * |
|
353 | - * @param type $WP |
|
354 | - */ |
|
355 | - public function run($WP) |
|
356 | - { |
|
357 | - } |
|
350 | + /** |
|
351 | + * Unnecessary |
|
352 | + * |
|
353 | + * @param type $WP |
|
354 | + */ |
|
355 | + public function run($WP) |
|
356 | + { |
|
357 | + } |
|
358 | 358 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
125 | 125 | wp_enqueue_script( |
126 | 126 | 'batch_runner_init', |
127 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
127 | + BATCH_URL.'assets/batch_runner_init.js', |
|
128 | 128 | array('batch_runner'), |
129 | 129 | EVENT_ESPRESSO_VERSION, |
130 | 130 | true |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
149 | 149 | wp_enqueue_script( |
150 | 150 | 'batch_file_runner_init', |
151 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
151 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
152 | 152 | array('batch_runner'), |
153 | 153 | EVENT_ESPRESSO_VERSION, |
154 | 154 | true |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | array( |
161 | 161 | 'download_and_redirecting' => sprintf( |
162 | 162 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
163 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
163 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
164 | 164 | '</a>' |
165 | 165 | ), |
166 | 166 | 'return_url' => $_REQUEST['return_url'], |
@@ -179,18 +179,18 @@ discard block |
||
179 | 179 | { |
180 | 180 | wp_register_script( |
181 | 181 | 'progress_bar', |
182 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
182 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
183 | 183 | array('jquery') |
184 | 184 | ); |
185 | 185 | wp_enqueue_style( |
186 | 186 | 'progress_bar', |
187 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
187 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
188 | 188 | array(), |
189 | 189 | EVENT_ESPRESSO_VERSION |
190 | 190 | ); |
191 | 191 | wp_enqueue_script( |
192 | 192 | 'batch_runner', |
193 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
193 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
194 | 194 | array('progress_bar') |
195 | 195 | ); |
196 | 196 | // just copy the bits of EE admin's eei18n that we need in the JS |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | public function override_template($template) |
226 | 226 | { |
227 | 227 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
228 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
228 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
229 | 229 | } |
230 | 230 | return $template; |
231 | 231 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | public function show_admin_page() |
253 | 253 | { |
254 | 254 | echo EEH_Template::locate_template( |
255 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
255 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
256 | 256 | array('batch_request_type' => $this->batch_request_type()) |
257 | 257 | ); |
258 | 258 | } |
@@ -10,11 +10,11 @@ |
||
10 | 10 | * @ version 4+ |
11 | 11 | */ |
12 | 12 | ?> |
13 | -<p><?php _e('Organizer Name: ', 'event_espresso') . espresso_organization_name($VNU_ID); ?><br/> |
|
14 | - <?php _e('Organizer Email: ', 'event_espresso') . espresso_organization_email($VNU_ID); ?><br/> |
|
15 | - <?php _e('Venue Phone: ', 'event_espresso') . espresso_venue_phone($VNU_ID); ?></p> |
|
16 | -<p><?php _e('Categories: ', 'event_espresso') . espresso_venue_categories($VNU_ID); ?></p> |
|
17 | -<p><?php _e('Address: ', 'event_espresso') . espresso_venue_address($VNU_ID); ?></p> |
|
18 | -<p><?php _e('Website: ', 'event_espresso') . espresso_venue_website($VNU_ID); ?></p> |
|
19 | -<p><?php echo __('Description: ', 'event_espresso') . $venue_description; ?></p><br/> |
|
13 | +<p><?php _e('Organizer Name: ', 'event_espresso').espresso_organization_name($VNU_ID); ?><br/> |
|
14 | + <?php _e('Organizer Email: ', 'event_espresso').espresso_organization_email($VNU_ID); ?><br/> |
|
15 | + <?php _e('Venue Phone: ', 'event_espresso').espresso_venue_phone($VNU_ID); ?></p> |
|
16 | +<p><?php _e('Categories: ', 'event_espresso').espresso_venue_categories($VNU_ID); ?></p> |
|
17 | +<p><?php _e('Address: ', 'event_espresso').espresso_venue_address($VNU_ID); ?></p> |
|
18 | +<p><?php _e('Website: ', 'event_espresso').espresso_venue_website($VNU_ID); ?></p> |
|
19 | +<p><?php echo __('Description: ', 'event_espresso').$venue_description; ?></p><br/> |
|
20 | 20 | |
21 | 21 | \ No newline at end of file |
@@ -10,13 +10,13 @@ |
||
10 | 10 | * @ version 4+ |
11 | 11 | */ |
12 | 12 | ?> |
13 | -<p><?php _e('Event Organizer: ', 'event_espresso') . espresso_organization_name($EVT_ID); ?><br/> |
|
14 | - <?php _e('Organizer Email: ', 'event_espresso') . espresso_organization_email($EVT_ID); ?><br/> |
|
15 | - <?php _e('Event Phone: ', 'event_espresso') . espresso_event_phone($EVT_ID); ?></p> |
|
16 | -<p><?php _e('Event Status: ', 'event_espresso') . espresso_event_status($EVT_ID); ?></p> |
|
17 | -<p><?php _e('Categories: ', 'event_espresso') . espresso_event_categories($EVT_ID); ?></p> |
|
18 | -<?php _e('Dates and Times: ', 'event_espresso') . espresso_list_of_event_dates($EVT_ID); ?> |
|
19 | -<?php _e('Available Tickets: ', 'event_espresso') . espresso_event_tickets_available($EVT_ID); ?> |
|
20 | -<p><?php _e('Event Venue: ', 'event_espresso') . espresso_venue_name(null, false); ?></p> |
|
21 | -<p><?php echo __('Description: ', 'event_espresso') . $event_description; ?></p><br/> |
|
13 | +<p><?php _e('Event Organizer: ', 'event_espresso').espresso_organization_name($EVT_ID); ?><br/> |
|
14 | + <?php _e('Organizer Email: ', 'event_espresso').espresso_organization_email($EVT_ID); ?><br/> |
|
15 | + <?php _e('Event Phone: ', 'event_espresso').espresso_event_phone($EVT_ID); ?></p> |
|
16 | +<p><?php _e('Event Status: ', 'event_espresso').espresso_event_status($EVT_ID); ?></p> |
|
17 | +<p><?php _e('Categories: ', 'event_espresso').espresso_event_categories($EVT_ID); ?></p> |
|
18 | +<?php _e('Dates and Times: ', 'event_espresso').espresso_list_of_event_dates($EVT_ID); ?> |
|
19 | +<?php _e('Available Tickets: ', 'event_espresso').espresso_event_tickets_available($EVT_ID); ?> |
|
20 | +<p><?php _e('Event Venue: ', 'event_espresso').espresso_venue_name(null, false); ?></p> |
|
21 | +<p><?php echo __('Description: ', 'event_espresso').$event_description; ?></p><br/> |
|
22 | 22 | |
23 | 23 | \ No newline at end of file |
@@ -20,208 +20,208 @@ |
||
20 | 20 | class SettingsForm extends EE_Payment_Method_Form |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var string of HTML being the help tab link |
|
25 | - */ |
|
26 | - protected $helpTabLink; |
|
23 | + /** |
|
24 | + * @var string of HTML being the help tab link |
|
25 | + */ |
|
26 | + protected $helpTabLink; |
|
27 | 27 | |
28 | - /** |
|
29 | - * SettingsForm constructor. |
|
30 | - * |
|
31 | - * @param array $options_array |
|
32 | - * @param string $help_tab_link |
|
33 | - */ |
|
34 | - public function __construct(array $options_array = array(), $help_tab_link) |
|
35 | - { |
|
36 | - $this->helpTabLink = $help_tab_link; |
|
37 | - $options_array = array_replace_recursive( |
|
38 | - array( |
|
39 | - 'extra_meta_inputs' => array( |
|
40 | - 'api_username' => new EE_Text_Input( |
|
41 | - array( |
|
42 | - 'html_label_text' => sprintf( |
|
43 | - esc_html__('API Username %s', 'event_espresso'), |
|
44 | - $help_tab_link |
|
45 | - ), |
|
46 | - 'required' => true, |
|
47 | - ) |
|
48 | - ), |
|
49 | - 'api_password' => new EE_Text_Input( |
|
50 | - array( |
|
51 | - 'html_label_text' => sprintf( |
|
52 | - esc_html__('API Password %s', 'event_espresso'), |
|
53 | - $help_tab_link |
|
54 | - ), |
|
55 | - 'required' => true, |
|
56 | - ) |
|
57 | - ), |
|
58 | - 'api_signature' => new EE_Text_Input( |
|
59 | - array( |
|
60 | - 'html_label_text' => sprintf( |
|
61 | - esc_html__('API Signature %s', 'event_espresso'), |
|
62 | - $help_tab_link |
|
63 | - ), |
|
64 | - 'required' => true, |
|
65 | - ) |
|
66 | - ), |
|
67 | - 'request_shipping_addr' => new EE_Yes_No_Input( |
|
68 | - array( |
|
69 | - 'html_label_text' => sprintf( |
|
70 | - esc_html__('Request Shipping Address %s', 'event_espresso'), |
|
71 | - $help_tab_link |
|
72 | - ), |
|
73 | - 'html_help_text' => esc_html__( |
|
74 | - // @codingStandardsIgnoreStart |
|
75 | - 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', |
|
76 | - // @codingStandardsIgnoreEnd |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - 'required' => true, |
|
80 | - 'default' => false, |
|
81 | - ) |
|
82 | - ), |
|
83 | - 'image_url' => new EE_Admin_File_Uploader_Input( |
|
84 | - array( |
|
85 | - 'html_label_text' => sprintf( |
|
86 | - esc_html__('Image URL %s', 'event_espresso'), |
|
87 | - $help_tab_link |
|
88 | - ), |
|
89 | - 'html_help_text' => esc_html__( |
|
90 | - 'Used for your business/personal logo on the PayPal page', |
|
91 | - 'event_espresso' |
|
92 | - ), |
|
93 | - 'required' => false, |
|
94 | - ) |
|
95 | - ), |
|
96 | - ) |
|
97 | - ), |
|
98 | - $options_array |
|
99 | - ); |
|
100 | - parent::__construct($options_array); |
|
101 | - } |
|
28 | + /** |
|
29 | + * SettingsForm constructor. |
|
30 | + * |
|
31 | + * @param array $options_array |
|
32 | + * @param string $help_tab_link |
|
33 | + */ |
|
34 | + public function __construct(array $options_array = array(), $help_tab_link) |
|
35 | + { |
|
36 | + $this->helpTabLink = $help_tab_link; |
|
37 | + $options_array = array_replace_recursive( |
|
38 | + array( |
|
39 | + 'extra_meta_inputs' => array( |
|
40 | + 'api_username' => new EE_Text_Input( |
|
41 | + array( |
|
42 | + 'html_label_text' => sprintf( |
|
43 | + esc_html__('API Username %s', 'event_espresso'), |
|
44 | + $help_tab_link |
|
45 | + ), |
|
46 | + 'required' => true, |
|
47 | + ) |
|
48 | + ), |
|
49 | + 'api_password' => new EE_Text_Input( |
|
50 | + array( |
|
51 | + 'html_label_text' => sprintf( |
|
52 | + esc_html__('API Password %s', 'event_espresso'), |
|
53 | + $help_tab_link |
|
54 | + ), |
|
55 | + 'required' => true, |
|
56 | + ) |
|
57 | + ), |
|
58 | + 'api_signature' => new EE_Text_Input( |
|
59 | + array( |
|
60 | + 'html_label_text' => sprintf( |
|
61 | + esc_html__('API Signature %s', 'event_espresso'), |
|
62 | + $help_tab_link |
|
63 | + ), |
|
64 | + 'required' => true, |
|
65 | + ) |
|
66 | + ), |
|
67 | + 'request_shipping_addr' => new EE_Yes_No_Input( |
|
68 | + array( |
|
69 | + 'html_label_text' => sprintf( |
|
70 | + esc_html__('Request Shipping Address %s', 'event_espresso'), |
|
71 | + $help_tab_link |
|
72 | + ), |
|
73 | + 'html_help_text' => esc_html__( |
|
74 | + // @codingStandardsIgnoreStart |
|
75 | + 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', |
|
76 | + // @codingStandardsIgnoreEnd |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + 'required' => true, |
|
80 | + 'default' => false, |
|
81 | + ) |
|
82 | + ), |
|
83 | + 'image_url' => new EE_Admin_File_Uploader_Input( |
|
84 | + array( |
|
85 | + 'html_label_text' => sprintf( |
|
86 | + esc_html__('Image URL %s', 'event_espresso'), |
|
87 | + $help_tab_link |
|
88 | + ), |
|
89 | + 'html_help_text' => esc_html__( |
|
90 | + 'Used for your business/personal logo on the PayPal page', |
|
91 | + 'event_espresso' |
|
92 | + ), |
|
93 | + 'required' => false, |
|
94 | + ) |
|
95 | + ), |
|
96 | + ) |
|
97 | + ), |
|
98 | + $options_array |
|
99 | + ); |
|
100 | + parent::__construct($options_array); |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * Does the normal validation, but also verifies the PayPal API credentials work. |
|
107 | - * If they don't, sets a validation error on the entire form, and adds validation errors (which are really more tips) |
|
108 | - * on each of the inputs that could be the cause of the problem. |
|
109 | - * @throws EntityNotFoundException |
|
110 | - */ |
|
111 | - public function _validate() |
|
112 | - { |
|
113 | - parent::_validate(); |
|
114 | - if (! $this->_payment_method_type instanceof \EE_PMT_Paypal_Express) { |
|
115 | - throw new EntityNotFoundException('EE_PMT_Paypal_Express', '$this->_payment_method_type'); |
|
116 | - } |
|
117 | - if (! $this->_payment_method_type->get_gateway() instanceof \EEG_Paypal_Express) { |
|
118 | - throw new EntityNotFoundException('EEG_Paypal_Express', '$this->_payment_method_type->get_gateway()'); |
|
119 | - } |
|
120 | - $credentials_message = $this->checkForCredentialsErrors(); |
|
121 | - if ($credentials_message !== '') { |
|
122 | - $this->add_validation_error($credentials_message); |
|
123 | - $this->get_input('PMD_debug_mode')->add_validation_error( |
|
124 | - esc_html__('If you are using PayPal Sandbox (test) credentials, Debug mode should be set to "Yes". Otherwise, if you are using live PayPal credentials, set this to "No".', 'event_espresso') |
|
125 | - ); |
|
126 | - $this->get_input('api_username')->add_validation_error( |
|
127 | - sprintf( |
|
128 | - esc_html__('Are you sure this is your API username, not your login username?%1$s', 'event_espresso'), |
|
129 | - $this->helpTabLink() |
|
130 | - ) |
|
131 | - ); |
|
132 | - $this->get_input('api_password')->add_validation_error( |
|
133 | - sprintf( |
|
134 | - esc_html__('Are you sure this is your API password, not your login password.%1$s', 'event_espresso'), |
|
135 | - $this->helpTabLink() |
|
136 | - ) |
|
137 | - ); |
|
138 | - $this->get_input('api_signature')->add_validation_error( |
|
139 | - sprintf( |
|
140 | - esc_html__('Please verify your API signature is correct.%1$s', 'event_espresso'), |
|
141 | - $this->helpTabLink() |
|
142 | - ) |
|
143 | - ); |
|
144 | - } |
|
145 | - } |
|
105 | + /** |
|
106 | + * Does the normal validation, but also verifies the PayPal API credentials work. |
|
107 | + * If they don't, sets a validation error on the entire form, and adds validation errors (which are really more tips) |
|
108 | + * on each of the inputs that could be the cause of the problem. |
|
109 | + * @throws EntityNotFoundException |
|
110 | + */ |
|
111 | + public function _validate() |
|
112 | + { |
|
113 | + parent::_validate(); |
|
114 | + if (! $this->_payment_method_type instanceof \EE_PMT_Paypal_Express) { |
|
115 | + throw new EntityNotFoundException('EE_PMT_Paypal_Express', '$this->_payment_method_type'); |
|
116 | + } |
|
117 | + if (! $this->_payment_method_type->get_gateway() instanceof \EEG_Paypal_Express) { |
|
118 | + throw new EntityNotFoundException('EEG_Paypal_Express', '$this->_payment_method_type->get_gateway()'); |
|
119 | + } |
|
120 | + $credentials_message = $this->checkForCredentialsErrors(); |
|
121 | + if ($credentials_message !== '') { |
|
122 | + $this->add_validation_error($credentials_message); |
|
123 | + $this->get_input('PMD_debug_mode')->add_validation_error( |
|
124 | + esc_html__('If you are using PayPal Sandbox (test) credentials, Debug mode should be set to "Yes". Otherwise, if you are using live PayPal credentials, set this to "No".', 'event_espresso') |
|
125 | + ); |
|
126 | + $this->get_input('api_username')->add_validation_error( |
|
127 | + sprintf( |
|
128 | + esc_html__('Are you sure this is your API username, not your login username?%1$s', 'event_espresso'), |
|
129 | + $this->helpTabLink() |
|
130 | + ) |
|
131 | + ); |
|
132 | + $this->get_input('api_password')->add_validation_error( |
|
133 | + sprintf( |
|
134 | + esc_html__('Are you sure this is your API password, not your login password.%1$s', 'event_espresso'), |
|
135 | + $this->helpTabLink() |
|
136 | + ) |
|
137 | + ); |
|
138 | + $this->get_input('api_signature')->add_validation_error( |
|
139 | + sprintf( |
|
140 | + esc_html__('Please verify your API signature is correct.%1$s', 'event_espresso'), |
|
141 | + $this->helpTabLink() |
|
142 | + ) |
|
143 | + ); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | 148 | |
149 | - /** |
|
150 | - * Gets the HTML to show the link to the help tab |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - protected function helpTabLink() |
|
154 | - { |
|
155 | - return $this->helpTabLink; |
|
156 | - } |
|
157 | - /** |
|
158 | - * Tests the the PayPal API credentials work ok |
|
159 | - * @return string of an error using the credentials, otherwise, if the credentials work, returns a blank string |
|
160 | - */ |
|
161 | - protected function checkForCredentialsErrors() |
|
162 | - { |
|
163 | - $request_params = array( |
|
164 | - 'METHOD' => 'GetBalance', |
|
165 | - 'VERSION' => '204.0', |
|
166 | - 'USER' => urlencode($this->get_input_value('api_username')), |
|
167 | - 'PWD' => urlencode($this->get_input_value('api_password')), |
|
168 | - 'SIGNATURE' => urlencode($this->get_input_value('api_signature')), |
|
169 | - ); |
|
170 | - $gateway_url = $this->get_input_value('PMD_debug_mode') |
|
171 | - ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
172 | - : 'https://api-3t.paypal.com/nvp'; |
|
173 | - // Request Customer Details. |
|
174 | - $response = wp_remote_post( |
|
175 | - $gateway_url, |
|
176 | - array( |
|
177 | - 'method' => 'POST', |
|
178 | - 'timeout' => 45, |
|
179 | - 'httpversion' => '1.1', |
|
180 | - 'cookies' => array(), |
|
181 | - 'headers' => array(), |
|
182 | - 'body' => http_build_query($request_params, '', '&'), |
|
183 | - ) |
|
184 | - ); |
|
185 | - if (is_wp_error($response) || empty($response['body'])) { |
|
186 | - // If we got here then there was an error in this request. |
|
187 | - // maybe is turned off. We don't know the credentials are invalid |
|
188 | - EE_Error::add_error( |
|
189 | - sprintf( |
|
190 | - esc_html__('Your PayPal credentials could not be verified. There was an error communicating with PayPal, it was %1$s', 'event_espresso'), |
|
191 | - $response->get_error_message() |
|
192 | - ), |
|
193 | - __FILE__, |
|
194 | - __FUNCTION__, |
|
195 | - __LINE__ |
|
196 | - ); |
|
197 | - } |
|
198 | - $response_args = array(); |
|
199 | - parse_str(urldecode($response['body']), $response_args); |
|
149 | + /** |
|
150 | + * Gets the HTML to show the link to the help tab |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + protected function helpTabLink() |
|
154 | + { |
|
155 | + return $this->helpTabLink; |
|
156 | + } |
|
157 | + /** |
|
158 | + * Tests the the PayPal API credentials work ok |
|
159 | + * @return string of an error using the credentials, otherwise, if the credentials work, returns a blank string |
|
160 | + */ |
|
161 | + protected function checkForCredentialsErrors() |
|
162 | + { |
|
163 | + $request_params = array( |
|
164 | + 'METHOD' => 'GetBalance', |
|
165 | + 'VERSION' => '204.0', |
|
166 | + 'USER' => urlencode($this->get_input_value('api_username')), |
|
167 | + 'PWD' => urlencode($this->get_input_value('api_password')), |
|
168 | + 'SIGNATURE' => urlencode($this->get_input_value('api_signature')), |
|
169 | + ); |
|
170 | + $gateway_url = $this->get_input_value('PMD_debug_mode') |
|
171 | + ? 'https://api-3t.sandbox.paypal.com/nvp' |
|
172 | + : 'https://api-3t.paypal.com/nvp'; |
|
173 | + // Request Customer Details. |
|
174 | + $response = wp_remote_post( |
|
175 | + $gateway_url, |
|
176 | + array( |
|
177 | + 'method' => 'POST', |
|
178 | + 'timeout' => 45, |
|
179 | + 'httpversion' => '1.1', |
|
180 | + 'cookies' => array(), |
|
181 | + 'headers' => array(), |
|
182 | + 'body' => http_build_query($request_params, '', '&'), |
|
183 | + ) |
|
184 | + ); |
|
185 | + if (is_wp_error($response) || empty($response['body'])) { |
|
186 | + // If we got here then there was an error in this request. |
|
187 | + // maybe is turned off. We don't know the credentials are invalid |
|
188 | + EE_Error::add_error( |
|
189 | + sprintf( |
|
190 | + esc_html__('Your PayPal credentials could not be verified. There was an error communicating with PayPal, it was %1$s', 'event_espresso'), |
|
191 | + $response->get_error_message() |
|
192 | + ), |
|
193 | + __FILE__, |
|
194 | + __FUNCTION__, |
|
195 | + __LINE__ |
|
196 | + ); |
|
197 | + } |
|
198 | + $response_args = array(); |
|
199 | + parse_str(urldecode($response['body']), $response_args); |
|
200 | 200 | |
201 | - if (empty($response_args['ACK'])) { |
|
202 | - EE_Error::add_error( |
|
203 | - esc_html__('Your PayPal credentials could not be verified. Part of their response was missing.', 'event_espresso'), |
|
204 | - __FILE__, |
|
205 | - __FUNCTION__, |
|
206 | - __LINE__ |
|
207 | - ); |
|
208 | - } |
|
209 | - if (in_array( |
|
210 | - $response_args['ACK'], |
|
211 | - array( |
|
212 | - 'Success', |
|
213 | - 'SuccessWithWarning' |
|
214 | - ), |
|
215 | - true |
|
216 | - ) |
|
217 | - ) { |
|
218 | - return ''; |
|
219 | - } else { |
|
220 | - return sprintf( |
|
221 | - esc_html__('Your PayPal API credentials appear to be invalid. PayPal said "%1$s (%2$s)". Please see tips below.', 'event_espresso'), |
|
222 | - isset($response_args['L_LONGMESSAGE0']) ? $response_args['L_LONGMESSAGE0'] : esc_html__('No error message received from PayPal', 'event_espresso'), |
|
223 | - isset($response_args['L_ERRORCODE0']) ? $response_args['L_ERRORCODE0'] : 0 |
|
224 | - ); |
|
225 | - } |
|
226 | - } |
|
201 | + if (empty($response_args['ACK'])) { |
|
202 | + EE_Error::add_error( |
|
203 | + esc_html__('Your PayPal credentials could not be verified. Part of their response was missing.', 'event_espresso'), |
|
204 | + __FILE__, |
|
205 | + __FUNCTION__, |
|
206 | + __LINE__ |
|
207 | + ); |
|
208 | + } |
|
209 | + if (in_array( |
|
210 | + $response_args['ACK'], |
|
211 | + array( |
|
212 | + 'Success', |
|
213 | + 'SuccessWithWarning' |
|
214 | + ), |
|
215 | + true |
|
216 | + ) |
|
217 | + ) { |
|
218 | + return ''; |
|
219 | + } else { |
|
220 | + return sprintf( |
|
221 | + esc_html__('Your PayPal API credentials appear to be invalid. PayPal said "%1$s (%2$s)". Please see tips below.', 'event_espresso'), |
|
222 | + isset($response_args['L_LONGMESSAGE0']) ? $response_args['L_LONGMESSAGE0'] : esc_html__('No error message received from PayPal', 'event_espresso'), |
|
223 | + isset($response_args['L_ERRORCODE0']) ? $response_args['L_ERRORCODE0'] : 0 |
|
224 | + ); |
|
225 | + } |
|
226 | + } |
|
227 | 227 | } |
@@ -111,10 +111,10 @@ |
||
111 | 111 | public function _validate() |
112 | 112 | { |
113 | 113 | parent::_validate(); |
114 | - if (! $this->_payment_method_type instanceof \EE_PMT_Paypal_Express) { |
|
114 | + if ( ! $this->_payment_method_type instanceof \EE_PMT_Paypal_Express) { |
|
115 | 115 | throw new EntityNotFoundException('EE_PMT_Paypal_Express', '$this->_payment_method_type'); |
116 | 116 | } |
117 | - if (! $this->_payment_method_type->get_gateway() instanceof \EEG_Paypal_Express) { |
|
117 | + if ( ! $this->_payment_method_type->get_gateway() instanceof \EEG_Paypal_Express) { |
|
118 | 118 | throw new EntityNotFoundException('EEG_Paypal_Express', '$this->_payment_method_type->get_gateway()'); |
119 | 119 | } |
120 | 120 | $credentials_message = $this->checkForCredentialsErrors(); |
@@ -15,90 +15,90 @@ |
||
15 | 15 | class EE_PMT_Paypal_Express extends EE_PMT_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * EE_PMT_Paypal_Express constructor. |
|
20 | - */ |
|
21 | - public function __construct($pm_instance = null) |
|
22 | - { |
|
23 | - require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
24 | - $this->_gateway = new EEG_Paypal_Express(); |
|
18 | + /** |
|
19 | + * EE_PMT_Paypal_Express constructor. |
|
20 | + */ |
|
21 | + public function __construct($pm_instance = null) |
|
22 | + { |
|
23 | + require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
24 | + $this->_gateway = new EEG_Paypal_Express(); |
|
25 | 25 | |
26 | - $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
|
27 | - $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
28 | - $this->_default_description = esc_html__( |
|
29 | - // @codingStandardsIgnoreStart |
|
30 | - 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
|
31 | - // @codingStandardsIgnoreEnd |
|
32 | - 'event_espresso' |
|
33 | - ); |
|
34 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo-gold-160.png'; |
|
26 | + $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
|
27 | + $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
28 | + $this->_default_description = esc_html__( |
|
29 | + // @codingStandardsIgnoreStart |
|
30 | + 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
|
31 | + // @codingStandardsIgnoreEnd |
|
32 | + 'event_espresso' |
|
33 | + ); |
|
34 | + $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo-gold-160.png'; |
|
35 | 35 | |
36 | - parent::__construct($pm_instance); |
|
37 | - } |
|
36 | + parent::__construct($pm_instance); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Adds the help tab. |
|
42 | - * |
|
43 | - * @see EE_PMT_Base::help_tabs_config() |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function help_tabs_config() |
|
47 | - { |
|
48 | - return array( |
|
49 | - $this->get_help_tab_name() => array( |
|
50 | - 'title' => esc_html__('PayPal Express Settings', 'event_espresso'), |
|
51 | - 'filename' => 'payment_methods_overview_paypal_express' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
40 | + /** |
|
41 | + * Adds the help tab. |
|
42 | + * |
|
43 | + * @see EE_PMT_Base::help_tabs_config() |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function help_tabs_config() |
|
47 | + { |
|
48 | + return array( |
|
49 | + $this->get_help_tab_name() => array( |
|
50 | + 'title' => esc_html__('PayPal Express Settings', 'event_espresso'), |
|
51 | + 'filename' => 'payment_methods_overview_paypal_express' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Gets the form for all the settings related to this payment method type. |
|
59 | - * |
|
60 | - * @return EE_Payment_Method_Form |
|
61 | - */ |
|
62 | - public function generate_new_settings_form() |
|
63 | - { |
|
64 | - $form = new SettingsForm(array(), $this->get_help_tab_link()); |
|
65 | - return $form; |
|
66 | - } |
|
57 | + /** |
|
58 | + * Gets the form for all the settings related to this payment method type. |
|
59 | + * |
|
60 | + * @return EE_Payment_Method_Form |
|
61 | + */ |
|
62 | + public function generate_new_settings_form() |
|
63 | + { |
|
64 | + $form = new SettingsForm(array(), $this->get_help_tab_link()); |
|
65 | + return $form; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Creates a billing form for this payment method type. |
|
71 | - * |
|
72 | - * @param \EE_Transaction $transaction |
|
73 | - * @return \EE_Billing_Info_Form |
|
74 | - */ |
|
75 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
76 | - { |
|
77 | - if ($this->_pm_instance->debug_mode()) { |
|
78 | - $form = new EE_Billing_Info_Form( |
|
79 | - $this->_pm_instance, |
|
80 | - array( |
|
81 | - 'name' => 'paypal_express_Info_Form', |
|
82 | - 'subsections' => array( |
|
83 | - 'paypal_express_debug_info' => new EE_Form_Section_Proper( |
|
84 | - array( |
|
85 | - 'layout_strategy' => new EE_Template_Layout( |
|
86 | - array( |
|
87 | - 'layout_template_file' => $this->_template_path |
|
88 | - . 'paypal_express_debug_info.template.php', |
|
89 | - 'template_args' => array( |
|
90 | - 'debug_mode' => $this->_pm_instance->debug_mode() |
|
91 | - ) |
|
92 | - ) |
|
93 | - ) |
|
94 | - ) |
|
95 | - ) |
|
96 | - ) |
|
97 | - ) |
|
98 | - ); |
|
99 | - return $form; |
|
100 | - } |
|
69 | + /** |
|
70 | + * Creates a billing form for this payment method type. |
|
71 | + * |
|
72 | + * @param \EE_Transaction $transaction |
|
73 | + * @return \EE_Billing_Info_Form |
|
74 | + */ |
|
75 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
76 | + { |
|
77 | + if ($this->_pm_instance->debug_mode()) { |
|
78 | + $form = new EE_Billing_Info_Form( |
|
79 | + $this->_pm_instance, |
|
80 | + array( |
|
81 | + 'name' => 'paypal_express_Info_Form', |
|
82 | + 'subsections' => array( |
|
83 | + 'paypal_express_debug_info' => new EE_Form_Section_Proper( |
|
84 | + array( |
|
85 | + 'layout_strategy' => new EE_Template_Layout( |
|
86 | + array( |
|
87 | + 'layout_template_file' => $this->_template_path |
|
88 | + . 'paypal_express_debug_info.template.php', |
|
89 | + 'template_args' => array( |
|
90 | + 'debug_mode' => $this->_pm_instance->debug_mode() |
|
91 | + ) |
|
92 | + ) |
|
93 | + ) |
|
94 | + ) |
|
95 | + ) |
|
96 | + ) |
|
97 | + ) |
|
98 | + ); |
|
99 | + return $form; |
|
100 | + } |
|
101 | 101 | |
102 | - return false; |
|
103 | - } |
|
102 | + return false; |
|
103 | + } |
|
104 | 104 | } |
@@ -20,18 +20,18 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct($pm_instance = null) |
22 | 22 | { |
23 | - require_once($this->file_folder() . 'EEG_Paypal_Express.gateway.php'); |
|
23 | + require_once($this->file_folder().'EEG_Paypal_Express.gateway.php'); |
|
24 | 24 | $this->_gateway = new EEG_Paypal_Express(); |
25 | 25 | |
26 | 26 | $this->_pretty_name = esc_html__('PayPal Express', 'event_espresso'); |
27 | - $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
27 | + $this->_template_path = $this->file_folder().'templates'.DS; |
|
28 | 28 | $this->_default_description = esc_html__( |
29 | 29 | // @codingStandardsIgnoreStart |
30 | 30 | 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', |
31 | 31 | // @codingStandardsIgnoreEnd |
32 | 32 | 'event_espresso' |
33 | 33 | ); |
34 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo-gold-160.png'; |
|
34 | + $this->_default_button_url = $this->file_url().'lib'.DS.'paypal-express-checkout-logo-gold-160.png'; |
|
35 | 35 | |
36 | 36 | parent::__construct($pm_instance); |
37 | 37 | } |