@@ -15,249 +15,249 @@ |
||
15 | 15 | */ |
16 | 16 | class EED_Mijireh_Slurper extends EED_Module |
17 | 17 | { |
18 | - const slurp_started_transient_name = 'ee_mijireh_slurp_started'; |
|
19 | - const mijireh_slurper_shortcode = '{{mj-checkout-form}}'; |
|
18 | + const slurp_started_transient_name = 'ee_mijireh_slurp_started'; |
|
19 | + const mijireh_slurper_shortcode = '{{mj-checkout-form}}'; |
|
20 | 20 | |
21 | - /** |
|
22 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | - * |
|
24 | - * @access public |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public static function set_hooks() |
|
28 | - { |
|
29 | - } |
|
21 | + /** |
|
22 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
23 | + * |
|
24 | + * @access public |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public static function set_hooks() |
|
28 | + { |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
33 | - * MIjireh Slurper module mostly just detects a special request on the EE payment methods page |
|
34 | - * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
35 | - * initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special |
|
36 | - * shortcode is present |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public static function set_hooks_admin() |
|
42 | - { |
|
43 | - define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules' . DS . 'mijireh_slurper' . DS); |
|
44 | - add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
|
45 | - add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
|
46 | - add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
|
47 | - } |
|
31 | + /** |
|
32 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
33 | + * MIjireh Slurper module mostly just detects a special request on the EE payment methods page |
|
34 | + * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
35 | + * initiate slurping into mijireh; and adds a metabox to the post.php editing page when mijireh's special |
|
36 | + * shortcode is present |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public static function set_hooks_admin() |
|
42 | + { |
|
43 | + define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules' . DS . 'mijireh_slurper' . DS); |
|
44 | + add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
|
45 | + add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
|
46 | + add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php |
|
51 | - */ |
|
52 | - public static function set_edit_post_page_hooks() |
|
53 | - { |
|
54 | - add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox')); |
|
55 | - add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not')); |
|
56 | - if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) { |
|
57 | - add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice')); |
|
58 | - delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * Merely used to avoid even bothering to add these hooks on pages besides admin's post.php |
|
51 | + */ |
|
52 | + public static function set_edit_post_page_hooks() |
|
53 | + { |
|
54 | + add_action('add_meta_boxes', array('EED_Mijireh_Slurper', 'add_slurp_page_metabox')); |
|
55 | + add_action('posts_selection', array('EED_Mijireh_Slurper', 'slurp_or_not')); |
|
56 | + if (get_transient(EED_Mijireh_Slurper::slurp_started_transient_name)) { |
|
57 | + add_action('admin_notices', array('EED_Mijireh_Slurper', 'slurping_in_progress_notice')); |
|
58 | + delete_transient(EED_Mijireh_Slurper::slurp_started_transient_name); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in |
|
64 | - * the module's code (because the gateway works fine independent of this module) |
|
65 | - */ |
|
66 | - public static function add_slurp_link_to_gateway($existing_content) |
|
67 | - { |
|
68 | - echo EEH_Template::display_template( |
|
69 | - EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
70 | - array(), |
|
71 | - true |
|
72 | - ) . $existing_content; |
|
73 | - } |
|
62 | + /** |
|
63 | + * Adds the slurping content to the gateway's settings page, because I thought this was best suited to remain in |
|
64 | + * the module's code (because the gateway works fine independent of this module) |
|
65 | + */ |
|
66 | + public static function add_slurp_link_to_gateway($existing_content) |
|
67 | + { |
|
68 | + echo EEH_Template::display_template( |
|
69 | + EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
70 | + array(), |
|
71 | + true |
|
72 | + ) . $existing_content; |
|
73 | + } |
|
74 | 74 | |
75 | - public static function slurping_in_progress_notice() |
|
76 | - { |
|
77 | - EEH_Template::display_template( |
|
78 | - EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
79 | - array() |
|
80 | - ); |
|
81 | - } |
|
75 | + public static function slurping_in_progress_notice() |
|
76 | + { |
|
77 | + EEH_Template::display_template( |
|
78 | + EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
79 | + array() |
|
80 | + ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page |
|
85 | - * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page |
|
86 | - * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user |
|
87 | - * to the slurp page's edit page |
|
88 | - * |
|
89 | - * @return void |
|
90 | - */ |
|
91 | - public static function check_for_edit_slurp_page() |
|
92 | - { |
|
93 | - if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
|
94 | - // check if we already have a slurping page |
|
95 | - if (! $slurp_page_id = self::find_slurp_page()) { |
|
96 | - // if no slurp page yet, make one |
|
97 | - $slurp_page_id = wp_insert_post( |
|
98 | - array( |
|
99 | - 'post_title' => __("Mijireh Slurping Page", 'event_espresso'), |
|
100 | - 'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode, |
|
101 | - 'post_type' => 'page', |
|
102 | - ) |
|
103 | - ); |
|
104 | - } |
|
105 | - wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php'))); |
|
106 | - } |
|
107 | - } |
|
83 | + /** |
|
84 | + * Inspects the request's querystring for a special arg indicating to forward the user onto the mijireh slurp page |
|
85 | + * (we do it this way, instead of just directly putting a link to the page in the anchor tag, because the page |
|
86 | + * might not exist yet, in whcih case we need to first make it). If the special arg is present, redirects the user |
|
87 | + * to the slurp page's edit page |
|
88 | + * |
|
89 | + * @return void |
|
90 | + */ |
|
91 | + public static function check_for_edit_slurp_page() |
|
92 | + { |
|
93 | + if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
|
94 | + // check if we already have a slurping page |
|
95 | + if (! $slurp_page_id = self::find_slurp_page()) { |
|
96 | + // if no slurp page yet, make one |
|
97 | + $slurp_page_id = wp_insert_post( |
|
98 | + array( |
|
99 | + 'post_title' => __("Mijireh Slurping Page", 'event_espresso'), |
|
100 | + 'post_content' => EED_Mijireh_Slurper::mijireh_slurper_shortcode, |
|
101 | + 'post_type' => 'page', |
|
102 | + ) |
|
103 | + ); |
|
104 | + } |
|
105 | + wp_redirect(add_query_arg(array('post' => $slurp_page_id, 'action' => 'edit'), admin_url('post.php'))); |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - public static function find_slurp_page() |
|
115 | - { |
|
116 | - global $wpdb; |
|
117 | - return $wpdb->get_var( |
|
118 | - "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
119 | - ); |
|
120 | - } |
|
109 | + /** |
|
110 | + * Gets the post id which has the {{mj-checkout-form}} "shortcode" in it, otherwise null |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + public static function find_slurp_page() |
|
115 | + { |
|
116 | + global $wpdb; |
|
117 | + return $wpdb->get_var( |
|
118 | + "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
119 | + ); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Return true if the current page is the mijireh checkout page, otherwise return false. |
|
124 | - * |
|
125 | - * @return boolean |
|
126 | - */ |
|
127 | - public static function is_slurp_page() |
|
128 | - { |
|
129 | - global $post; |
|
130 | - $isSlurp = false; |
|
131 | - if (isset($post) && is_object($post)) { |
|
132 | - $content = $post->post_content; |
|
133 | - if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) { |
|
134 | - $isSlurp = true; |
|
135 | - } |
|
136 | - } else { |
|
137 | - // echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1); |
|
138 | - } |
|
139 | - return $isSlurp; |
|
140 | - } |
|
122 | + /** |
|
123 | + * Return true if the current page is the mijireh checkout page, otherwise return false. |
|
124 | + * |
|
125 | + * @return boolean |
|
126 | + */ |
|
127 | + public static function is_slurp_page() |
|
128 | + { |
|
129 | + global $post; |
|
130 | + $isSlurp = false; |
|
131 | + if (isset($post) && is_object($post)) { |
|
132 | + $content = $post->post_content; |
|
133 | + if (strpos($content, EED_Mijireh_Slurper::mijireh_slurper_shortcode) !== false) { |
|
134 | + $isSlurp = true; |
|
135 | + } |
|
136 | + } else { |
|
137 | + // echo '[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Check Slurp Page Failed: " . print_r($post, 1); |
|
138 | + } |
|
139 | + return $isSlurp; |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the |
|
144 | - * {{mj-checkout-form}} "shortcode" |
|
145 | - * |
|
146 | - * @return void |
|
147 | - */ |
|
148 | - public static function add_slurp_page_metabox() |
|
149 | - { |
|
150 | - if (self::is_slurp_page() |
|
151 | - && EEM_Payment_Method::instance()->get_one_active( |
|
152 | - EEM_Payment_Method::scope_cart, |
|
153 | - array(array('PMD_type' => 'Mijireh')) |
|
154 | - )) { |
|
155 | - add_meta_box( |
|
156 | - 'slurp_meta_box', // $id |
|
157 | - 'Mijireh Page Slurp', // $title |
|
158 | - array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback |
|
159 | - 'page', // $page |
|
160 | - 'normal', // $context |
|
161 | - 'high' |
|
162 | - ); // $priority |
|
163 | - } |
|
164 | - } |
|
142 | + /** |
|
143 | + * adds the callback to adding the slurp page metabox, which shoudl only appear on a page with the |
|
144 | + * {{mj-checkout-form}} "shortcode" |
|
145 | + * |
|
146 | + * @return void |
|
147 | + */ |
|
148 | + public static function add_slurp_page_metabox() |
|
149 | + { |
|
150 | + if (self::is_slurp_page() |
|
151 | + && EEM_Payment_Method::instance()->get_one_active( |
|
152 | + EEM_Payment_Method::scope_cart, |
|
153 | + array(array('PMD_type' => 'Mijireh')) |
|
154 | + )) { |
|
155 | + add_meta_box( |
|
156 | + 'slurp_meta_box', // $id |
|
157 | + 'Mijireh Page Slurp', // $title |
|
158 | + array('EED_Mijireh_Slurper', 'slurp_page_metabox'), // $callback |
|
159 | + 'page', // $page |
|
160 | + 'normal', // $context |
|
161 | + 'high' |
|
162 | + ); // $priority |
|
163 | + } |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * outputs HTML for displaying the slurping metabox |
|
168 | - * |
|
169 | - * @param WP_Post $post |
|
170 | - * @return void echoes out html |
|
171 | - */ |
|
172 | - public static function slurp_page_metabox($post) |
|
173 | - { |
|
174 | - global $wp; |
|
175 | - $mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
176 | - if ($mijireh_payment_method) { |
|
177 | - $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
|
178 | - EEH_Template::display_template( |
|
179 | - EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | - array( |
|
181 | - 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
|
182 | - 'access_key' => $access_key, |
|
183 | - 'slurp_action_link' => esc_url_raw( |
|
184 | - add_query_arg( |
|
185 | - 'mijireh_slurp_now', |
|
186 | - 'true', |
|
187 | - add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
188 | - ) |
|
189 | - ), |
|
190 | - ) |
|
191 | - ); |
|
192 | - } |
|
193 | - } |
|
166 | + /** |
|
167 | + * outputs HTML for displaying the slurping metabox |
|
168 | + * |
|
169 | + * @param WP_Post $post |
|
170 | + * @return void echoes out html |
|
171 | + */ |
|
172 | + public static function slurp_page_metabox($post) |
|
173 | + { |
|
174 | + global $wp; |
|
175 | + $mijireh_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
176 | + if ($mijireh_payment_method) { |
|
177 | + $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
|
178 | + EEH_Template::display_template( |
|
179 | + EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | + array( |
|
181 | + 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
|
182 | + 'access_key' => $access_key, |
|
183 | + 'slurp_action_link' => esc_url_raw( |
|
184 | + add_query_arg( |
|
185 | + 'mijireh_slurp_now', |
|
186 | + 'true', |
|
187 | + add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
188 | + ) |
|
189 | + ), |
|
190 | + ) |
|
191 | + ); |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * decides whether to slurp the post indicated by the $post global or not, based entirely |
|
197 | - * on a special arg being in the querystring |
|
198 | - * |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - public static function slurp_or_not() |
|
202 | - { |
|
203 | - // check if this page has the right mijire 'shortcode' and if they've specified to slurp it |
|
204 | - if (isset($_GET['mijireh_slurp_now']) |
|
205 | - && $_GET['mijireh_slurp_now'] == 'true' |
|
206 | - && EED_Mijireh_Slurper::is_slurp_page() |
|
207 | - ) { |
|
208 | - EED_Mijireh_Slurper::slurp_now(); |
|
209 | - } |
|
210 | - } |
|
195 | + /** |
|
196 | + * decides whether to slurp the post indicated by the $post global or not, based entirely |
|
197 | + * on a special arg being in the querystring |
|
198 | + * |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + public static function slurp_or_not() |
|
202 | + { |
|
203 | + // check if this page has the right mijire 'shortcode' and if they've specified to slurp it |
|
204 | + if (isset($_GET['mijireh_slurp_now']) |
|
205 | + && $_GET['mijireh_slurp_now'] == 'true' |
|
206 | + && EED_Mijireh_Slurper::is_slurp_page() |
|
207 | + ) { |
|
208 | + EED_Mijireh_Slurper::slurp_now(); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page |
|
214 | - * without the special querystring arg indicating to slurp. Also, should temporarily make the current post |
|
215 | - * published, then revert it to its previous status |
|
216 | - */ |
|
217 | - public static function slurp_now() |
|
218 | - { |
|
219 | - global $post; |
|
220 | - if ($post->post_status != 'publish') { |
|
221 | - // make sure the post is published at least while slurping |
|
222 | - $post->post_status = 'publish'; |
|
223 | - wp_update_post($post); |
|
224 | - } |
|
225 | - $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
226 | - $access_key = $mijireh_gateway->get_extra_meta('access_key', true); |
|
227 | - // 'slurp_url'=>get_permalink($post), |
|
228 | - // 'page_id'=>$post->ID, |
|
229 | - // 'return_url'=>$return_url |
|
230 | - $url = 'https://secure.mijireh.com/api/1/slurps'; |
|
231 | - $args = array( |
|
232 | - 'headers' => array( |
|
233 | - 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
234 | - 'Accept' => 'application/json', |
|
235 | - ), |
|
236 | - 'body' => wp_json_encode( |
|
237 | - array( |
|
238 | - 'url' => get_permalink($post->ID), |
|
239 | - 'page_id' => $post->ID, |
|
240 | - 'return_url' => '', |
|
241 | - ) |
|
242 | - ), |
|
243 | - ); |
|
244 | - $response = wp_remote_post($url, $args); |
|
245 | - // now redirect the user back to the same page |
|
246 | - $redirect_args = $_GET; |
|
247 | - unset($redirect_args['mijireh_slurp_now']); |
|
248 | - $url = add_query_arg($redirect_args, admin_url('post.php')); |
|
249 | - set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true); |
|
250 | - // echo "redirect to $url"; |
|
251 | - wp_redirect($url); |
|
252 | - } |
|
212 | + /** |
|
213 | + * Sends a request to mijireh to slurp the current $post, and then redirects the user back to the current page |
|
214 | + * without the special querystring arg indicating to slurp. Also, should temporarily make the current post |
|
215 | + * published, then revert it to its previous status |
|
216 | + */ |
|
217 | + public static function slurp_now() |
|
218 | + { |
|
219 | + global $post; |
|
220 | + if ($post->post_status != 'publish') { |
|
221 | + // make sure the post is published at least while slurping |
|
222 | + $post->post_status = 'publish'; |
|
223 | + wp_update_post($post); |
|
224 | + } |
|
225 | + $mijireh_gateway = EEM_Payment_Method::instance()->get_one_of_type('Mijireh'); |
|
226 | + $access_key = $mijireh_gateway->get_extra_meta('access_key', true); |
|
227 | + // 'slurp_url'=>get_permalink($post), |
|
228 | + // 'page_id'=>$post->ID, |
|
229 | + // 'return_url'=>$return_url |
|
230 | + $url = 'https://secure.mijireh.com/api/1/slurps'; |
|
231 | + $args = array( |
|
232 | + 'headers' => array( |
|
233 | + 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
234 | + 'Accept' => 'application/json', |
|
235 | + ), |
|
236 | + 'body' => wp_json_encode( |
|
237 | + array( |
|
238 | + 'url' => get_permalink($post->ID), |
|
239 | + 'page_id' => $post->ID, |
|
240 | + 'return_url' => '', |
|
241 | + ) |
|
242 | + ), |
|
243 | + ); |
|
244 | + $response = wp_remote_post($url, $args); |
|
245 | + // now redirect the user back to the same page |
|
246 | + $redirect_args = $_GET; |
|
247 | + unset($redirect_args['mijireh_slurp_now']); |
|
248 | + $url = add_query_arg($redirect_args, admin_url('post.php')); |
|
249 | + set_transient(EED_Mijireh_Slurper::slurp_started_transient_name, true); |
|
250 | + // echo "redirect to $url"; |
|
251 | + wp_redirect($url); |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * run - initial module setup |
|
256 | - * |
|
257 | - * @access public |
|
258 | - * @return void |
|
259 | - */ |
|
260 | - public function run($WP) |
|
261 | - { |
|
262 | - } |
|
254 | + /** |
|
255 | + * run - initial module setup |
|
256 | + * |
|
257 | + * @access public |
|
258 | + * @return void |
|
259 | + */ |
|
260 | + public function run($WP) |
|
261 | + { |
|
262 | + } |
|
263 | 263 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function set_hooks_admin() |
42 | 42 | { |
43 | - define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH . 'modules' . DS . 'mijireh_slurper' . DS); |
|
43 | + define('EED_MIJIREH_SLURPER_PATH', EE_CAFF_PATH.'modules'.DS.'mijireh_slurper'.DS); |
|
44 | 44 | add_action('load-post.php', array('EED_Mijireh_Slurper', 'set_edit_post_page_hooks')); |
45 | 45 | add_action('load-admin.php', array('EED_Mijireh_Slurper', 'check_for_edit_slurp_page')); |
46 | 46 | add_action('AHEE__EE_Mijireh__settings_end', array('EED_Mijireh_Slurper', 'add_slurp_link_to_gateway')); |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | public static function add_slurp_link_to_gateway($existing_content) |
67 | 67 | { |
68 | 68 | echo EEH_Template::display_template( |
69 | - EED_MIJIREH_SLURPER_PATH . 'templates/additional_content_on_gateway.template.php', |
|
69 | + EED_MIJIREH_SLURPER_PATH.'templates/additional_content_on_gateway.template.php', |
|
70 | 70 | array(), |
71 | 71 | true |
72 | - ) . $existing_content; |
|
72 | + ).$existing_content; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function slurping_in_progress_notice() |
76 | 76 | { |
77 | 77 | EEH_Template::display_template( |
78 | - EED_MIJIREH_SLURPER_PATH . 'templates/slurping_in_progress_notice.template.php', |
|
78 | + EED_MIJIREH_SLURPER_PATH.'templates/slurping_in_progress_notice.template.php', |
|
79 | 79 | array() |
80 | 80 | ); |
81 | 81 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | if (isset($_GET['mijireh_edit_slurp_page']) && $_GET['mijireh_edit_slurp_page'] == 'true') { |
94 | 94 | // check if we already have a slurping page |
95 | - if (! $slurp_page_id = self::find_slurp_page()) { |
|
95 | + if ( ! $slurp_page_id = self::find_slurp_page()) { |
|
96 | 96 | // if no slurp page yet, make one |
97 | 97 | $slurp_page_id = wp_insert_post( |
98 | 98 | array( |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | global $wpdb; |
117 | 117 | return $wpdb->get_var( |
118 | - "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%" . EED_Mijireh_Slurper::mijireh_slurper_shortcode . "%'" |
|
118 | + "SELECT id FROM {$wpdb->posts} WHERE post_content LIKE '%".EED_Mijireh_Slurper::mijireh_slurper_shortcode."%'" |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if ($mijireh_payment_method) { |
177 | 177 | $access_key = $mijireh_payment_method->get_extra_meta('access_key', true); |
178 | 178 | EEH_Template::display_template( |
179 | - EED_MIJIREH_SLURPER_PATH . 'templates/mijireh_slurp_page_metabox.template.php', |
|
179 | + EED_MIJIREH_SLURPER_PATH.'templates/mijireh_slurp_page_metabox.template.php', |
|
180 | 180 | array( |
181 | 181 | 'mijireh_image_url' => $mijireh_payment_method->button_url(), |
182 | 182 | 'access_key' => $access_key, |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | add_query_arg( |
185 | 185 | 'mijireh_slurp_now', |
186 | 186 | 'true', |
187 | - add_query_arg($wp->query_string, '', '?' . $_SERVER['QUERY_STRING']) |
|
187 | + add_query_arg($wp->query_string, '', '?'.$_SERVER['QUERY_STRING']) |
|
188 | 188 | ) |
189 | 189 | ), |
190 | 190 | ) |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $url = 'https://secure.mijireh.com/api/1/slurps'; |
231 | 231 | $args = array( |
232 | 232 | 'headers' => array( |
233 | - 'Authorization' => 'Basic ' . base64_encode($access_key . ':'), |
|
233 | + 'Authorization' => 'Basic '.base64_encode($access_key.':'), |
|
234 | 234 | 'Accept' => 'application/json', |
235 | 235 | ), |
236 | 236 | 'body' => wp_json_encode( |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <tr> |
2 | 2 | <th><?php _e("Mijireh Checkout Page Design", 'event_espresso'); ?><?php |
3 | - echo EEH_Template::get_help_tab_link( |
|
4 | - 'ee_mijireh_help_tab' |
|
5 | - ); ?></th> |
|
3 | + echo EEH_Template::get_help_tab_link( |
|
4 | + 'ee_mijireh_help_tab' |
|
5 | + ); ?></th> |
|
6 | 6 | <td> |
7 | 7 | <a href="?mijireh_edit_slurp_page=true"><?php _e("Edit Slurp Page", 'event_espresso'); ?></a> |
8 | 8 | </td> |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <div class="updated"> |
2 | 2 | <p><?php |
3 | - _e( |
|
4 | - "Mijireh is currently slurping your content. This will usually take a few minutes. Please login to Mijireh to see the slurp's progress", |
|
5 | - 'event_espresso' |
|
6 | - ); ?></p> |
|
3 | + _e( |
|
4 | + "Mijireh is currently slurping your content. This will usually take a few minutes. Please login to Mijireh to see the slurp's progress", |
|
5 | + 'event_espresso' |
|
6 | + ); ?></p> |
|
7 | 7 | </div> |
8 | 8 | \ No newline at end of file |
@@ -5,14 +5,14 @@ |
||
5 | 5 | <div class='mijireh-blurb'> |
6 | 6 | <h2><?php _e("Slurp Into Mijireh", 'event_espresso'); ?></h2> |
7 | 7 | <p><?php |
8 | - printf( |
|
9 | - __( |
|
10 | - "Design the page how you want, and be sure to include the special text {{mj-checkout-form}} to indicate where to place Mijireh's Checkout Form. You may want to read %s Mijireh's instructions on slurping%s.", |
|
11 | - 'event_espresso' |
|
12 | - ), |
|
13 | - "<a href='http://www.mijireh.com/docs/what-is-page-slurp/'>", |
|
14 | - "</a>" |
|
15 | - ); ?> |
|
8 | + printf( |
|
9 | + __( |
|
10 | + "Design the page how you want, and be sure to include the special text {{mj-checkout-form}} to indicate where to place Mijireh's Checkout Form. You may want to read %s Mijireh's instructions on slurping%s.", |
|
11 | + 'event_espresso' |
|
12 | + ), |
|
13 | + "<a href='http://www.mijireh.com/docs/what-is-page-slurp/'>", |
|
14 | + "</a>" |
|
15 | + ); ?> |
|
16 | 16 | |
17 | 17 | <p class='aligncenter'><a href='<?php echo $slurp_action_link ?>' id='page_slurp' class='button-primary'>Slurp |
18 | 18 | This Page!</a></p> |
@@ -18,380 +18,380 @@ |
||
18 | 18 | class EED_Recaptcha extends EED_Module |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var EE_Registration_Config $config |
|
23 | - */ |
|
24 | - private static $config; |
|
25 | - |
|
26 | - /** |
|
27 | - * @type bool $_not_a_robot |
|
28 | - */ |
|
29 | - private static $_not_a_robot; |
|
30 | - |
|
31 | - /** |
|
32 | - * @type string $_recaptcha_response |
|
33 | - */ |
|
34 | - private static $_recaptcha_response; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @return EED_Module|EED_Recaptcha |
|
39 | - */ |
|
40 | - public static function instance() |
|
41 | - { |
|
42 | - return parent::get_instance(__CLASS__); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
48 | - * |
|
49 | - * @return void |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws InvalidInterfaceException |
|
52 | - * @throws InvalidDataTypeException |
|
53 | - */ |
|
54 | - public static function set_hooks() |
|
55 | - { |
|
56 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
57 | - // use_captcha ? |
|
58 | - if (EED_Recaptcha::useRecaptcha() |
|
59 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | - ) { |
|
61 | - EED_Recaptcha::set_definitions(); |
|
62 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | - add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | - add_action( |
|
65 | - 'AHEE__before_spco_whats_next_buttons', |
|
66 | - array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | - 10, |
|
68 | - 0 |
|
69 | - ); |
|
70 | - add_filter( |
|
71 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | - array('EED_Recaptcha', 'not_a_robot') |
|
73 | - ); |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | - array('EED_Recaptcha', 'not_a_robot') |
|
77 | - ); |
|
78 | - add_filter( |
|
79 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | - array('EED_Recaptcha', 'recaptcha_response') |
|
81 | - ); |
|
82 | - add_filter( |
|
83 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | - array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | - ); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | - * |
|
93 | - * @return void |
|
94 | - * @throws InvalidArgumentException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - */ |
|
98 | - public static function set_hooks_admin() |
|
99 | - { |
|
100 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | - EED_Recaptcha::set_definitions(); |
|
102 | - // use_captcha ? |
|
103 | - if (EED_Recaptcha::useRecaptcha() |
|
104 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
105 | - && EE_Registry::instance()->REQ->get('step', '') !== '' |
|
106 | - ) { |
|
107 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
108 | - add_filter( |
|
109 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
110 | - array('EED_Recaptcha', 'not_a_robot') |
|
111 | - ); |
|
112 | - add_filter( |
|
113 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
114 | - array('EED_Recaptcha', 'not_a_robot') |
|
115 | - ); |
|
116 | - add_filter( |
|
117 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
118 | - array('EED_Recaptcha', 'recaptcha_response') |
|
119 | - ); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return void |
|
126 | - */ |
|
127 | - public static function set_definitions() |
|
128 | - { |
|
129 | - if (is_user_logged_in()) { |
|
130 | - EED_Recaptcha::$_not_a_robot = true; |
|
131 | - } |
|
132 | - define( |
|
133 | - 'RECAPTCHA_BASE_PATH', |
|
134 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
135 | - ); |
|
136 | - define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return void |
|
142 | - */ |
|
143 | - public static function set_late_hooks() |
|
144 | - { |
|
145 | - add_filter( |
|
146 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
147 | - array('EED_Recaptcha', 'not_a_robot') |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @return boolean |
|
154 | - */ |
|
155 | - public static function useRecaptcha() |
|
156 | - { |
|
157 | - return EED_Recaptcha::$config->use_captcha |
|
158 | - && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @return boolean |
|
164 | - * @throws InvalidArgumentException |
|
165 | - * @throws InvalidInterfaceException |
|
166 | - * @throws InvalidDataTypeException |
|
167 | - */ |
|
168 | - public static function notPaymentOptionsRevisit() |
|
169 | - { |
|
170 | - return ! ( |
|
171 | - EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
172 | - && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
173 | - ); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @return void |
|
179 | - * @throws InvalidArgumentException |
|
180 | - * @throws InvalidInterfaceException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - */ |
|
183 | - public static function enqueue_styles_and_scripts() |
|
184 | - { |
|
185 | - wp_register_script( |
|
186 | - 'espresso_recaptcha', |
|
187 | - RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', |
|
188 | - array('single_page_checkout'), |
|
189 | - EVENT_ESPRESSO_VERSION, |
|
190 | - true |
|
191 | - ); |
|
192 | - wp_register_script( |
|
193 | - 'google_recaptcha', |
|
194 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
195 | - array('espresso_recaptcha'), |
|
196 | - EVENT_ESPRESSO_VERSION, |
|
197 | - true |
|
198 | - ); |
|
199 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
200 | - 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
201 | - 'event_espresso' |
|
202 | - ); |
|
203 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
204 | - 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
205 | - 'event_espresso' |
|
206 | - ); |
|
207 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
208 | - 'Please complete the anti-spam test before proceeding.', |
|
209 | - 'event_espresso' |
|
210 | - ); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * @param \WP $WP |
|
216 | - */ |
|
217 | - public function run($WP) |
|
218 | - { |
|
219 | - } |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * @return boolean |
|
224 | - * @throws InvalidArgumentException |
|
225 | - * @throws InvalidInterfaceException |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - */ |
|
228 | - public static function not_a_robot() |
|
229 | - { |
|
230 | - $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) |
|
231 | - ? EED_Recaptcha::$_not_a_robot |
|
232 | - : EED_Recaptcha::recaptcha_passed(); |
|
233 | - return $not_a_robot; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * @return void |
|
239 | - * @throws DomainException |
|
240 | - * @throws InvalidArgumentException |
|
241 | - * @throws InvalidInterfaceException |
|
242 | - * @throws InvalidDataTypeException |
|
243 | - */ |
|
244 | - public static function display_recaptcha() |
|
245 | - { |
|
246 | - // logged in means you have already passed a turing test of sorts |
|
247 | - if (is_user_logged_in()) { |
|
248 | - return; |
|
249 | - } |
|
250 | - // don't display if not using recaptcha or user is logged in |
|
251 | - if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
252 | - // only display if they have NOT passed the test yet |
|
253 | - EEH_Template::display_template( |
|
254 | - RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
255 | - array( |
|
256 | - 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
257 | - 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
258 | - 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
259 | - ) |
|
260 | - ); |
|
261 | - wp_enqueue_script('google_recaptcha'); |
|
262 | - } |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * @return array |
|
268 | - * @throws InvalidArgumentException |
|
269 | - * @throws InvalidInterfaceException |
|
270 | - * @throws InvalidDataTypeException |
|
271 | - */ |
|
272 | - public static function bypass_recaptcha_for_spco_load_payment_method() |
|
273 | - { |
|
274 | - return array( |
|
275 | - 'EESID' => EE_Registry::instance()->SSN->id(), |
|
276 | - 'step' => 'payment_options', |
|
277 | - 'action' => 'switch_spco_billing_form', |
|
278 | - ); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * @return boolean |
|
284 | - * @throws InvalidArgumentException |
|
285 | - * @throws InvalidInterfaceException |
|
286 | - * @throws InvalidDataTypeException |
|
287 | - */ |
|
288 | - public static function recaptcha_passed() |
|
289 | - { |
|
290 | - // logged in means you have already passed a turing test of sorts |
|
291 | - if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
292 | - return true; |
|
293 | - } |
|
294 | - // was test already passed? |
|
295 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
296 | - $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
297 | - // verify recaptcha |
|
298 | - EED_Recaptcha::_get_recaptcha_response(); |
|
299 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | - $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
301 | - EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
302 | - } |
|
303 | - EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
304 | - return $recaptcha_passed; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * @param array $recaptcha_response |
|
310 | - * @return array |
|
311 | - */ |
|
312 | - public static function recaptcha_response($recaptcha_response = array()) |
|
313 | - { |
|
314 | - if (EED_Recaptcha::_bypass_recaptcha()) { |
|
315 | - $recaptcha_response['bypass_recaptcha'] = true; |
|
316 | - $recaptcha_response['recaptcha_passed'] = true; |
|
317 | - } else { |
|
318 | - $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
319 | - } |
|
320 | - return $recaptcha_response; |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * @return boolean |
|
326 | - */ |
|
327 | - private static function _bypass_recaptcha() |
|
328 | - { |
|
329 | - // an array of key value pairs that must match exactly with the incoming request, |
|
330 | - // in order to bypass recaptcha for the current request ONLY |
|
331 | - $bypass_request_params_array = (array) apply_filters( |
|
332 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
333 | - array() |
|
334 | - ); |
|
335 | - // does $bypass_request_params_array have any values ? |
|
336 | - if (empty($bypass_request_params_array)) { |
|
337 | - return false; |
|
338 | - } |
|
339 | - // initially set bypass to TRUE |
|
340 | - $bypass_recaptcha = true; |
|
341 | - foreach ($bypass_request_params_array as $key => $value) { |
|
342 | - // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
343 | - // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
344 | - $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
345 | - ? $bypass_recaptcha |
|
346 | - : false; |
|
347 | - } |
|
348 | - return $bypass_recaptcha; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @return void |
|
354 | - * @throws InvalidArgumentException |
|
355 | - * @throws InvalidInterfaceException |
|
356 | - * @throws InvalidDataTypeException |
|
357 | - */ |
|
358 | - private static function _get_recaptcha_response() |
|
359 | - { |
|
360 | - EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( |
|
361 | - 'g-recaptcha-response', |
|
362 | - false |
|
363 | - ); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @return boolean |
|
369 | - * @throws InvalidArgumentException |
|
370 | - * @throws InvalidInterfaceException |
|
371 | - * @throws InvalidDataTypeException |
|
372 | - */ |
|
373 | - private static function _process_recaptcha_response() |
|
374 | - { |
|
375 | - // verify library is loaded |
|
376 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | - require_once RECAPTCHA_BASE_PATH . DS . 'autoload.php'; |
|
378 | - } |
|
379 | - // The response from reCAPTCHA |
|
380 | - EED_Recaptcha::_get_recaptcha_response(); |
|
381 | - $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
382 | - // Was there a reCAPTCHA response? |
|
383 | - if ($recaptcha_response) { |
|
384 | - // if allow_url_fopen is Off, then set a different request method |
|
385 | - $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
386 | - $recaptcha = new ReCaptcha( |
|
387 | - EED_Recaptcha::$config->recaptcha_privatekey, |
|
388 | - $request_method |
|
389 | - ); |
|
390 | - $recaptcha_response = $recaptcha->verify( |
|
391 | - EED_Recaptcha::$_recaptcha_response, |
|
392 | - $_SERVER['REMOTE_ADDR'] |
|
393 | - ); |
|
394 | - } |
|
395 | - return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
396 | - } |
|
21 | + /** |
|
22 | + * @var EE_Registration_Config $config |
|
23 | + */ |
|
24 | + private static $config; |
|
25 | + |
|
26 | + /** |
|
27 | + * @type bool $_not_a_robot |
|
28 | + */ |
|
29 | + private static $_not_a_robot; |
|
30 | + |
|
31 | + /** |
|
32 | + * @type string $_recaptcha_response |
|
33 | + */ |
|
34 | + private static $_recaptcha_response; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @return EED_Module|EED_Recaptcha |
|
39 | + */ |
|
40 | + public static function instance() |
|
41 | + { |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
48 | + * |
|
49 | + * @return void |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws InvalidInterfaceException |
|
52 | + * @throws InvalidDataTypeException |
|
53 | + */ |
|
54 | + public static function set_hooks() |
|
55 | + { |
|
56 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
57 | + // use_captcha ? |
|
58 | + if (EED_Recaptcha::useRecaptcha() |
|
59 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | + ) { |
|
61 | + EED_Recaptcha::set_definitions(); |
|
62 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | + add_action( |
|
65 | + 'AHEE__before_spco_whats_next_buttons', |
|
66 | + array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | + 10, |
|
68 | + 0 |
|
69 | + ); |
|
70 | + add_filter( |
|
71 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | + array('EED_Recaptcha', 'not_a_robot') |
|
73 | + ); |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | + array('EED_Recaptcha', 'not_a_robot') |
|
77 | + ); |
|
78 | + add_filter( |
|
79 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | + array('EED_Recaptcha', 'recaptcha_response') |
|
81 | + ); |
|
82 | + add_filter( |
|
83 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | + ); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | + * |
|
93 | + * @return void |
|
94 | + * @throws InvalidArgumentException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + */ |
|
98 | + public static function set_hooks_admin() |
|
99 | + { |
|
100 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | + EED_Recaptcha::set_definitions(); |
|
102 | + // use_captcha ? |
|
103 | + if (EED_Recaptcha::useRecaptcha() |
|
104 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
105 | + && EE_Registry::instance()->REQ->get('step', '') !== '' |
|
106 | + ) { |
|
107 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
108 | + add_filter( |
|
109 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
110 | + array('EED_Recaptcha', 'not_a_robot') |
|
111 | + ); |
|
112 | + add_filter( |
|
113 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
114 | + array('EED_Recaptcha', 'not_a_robot') |
|
115 | + ); |
|
116 | + add_filter( |
|
117 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
118 | + array('EED_Recaptcha', 'recaptcha_response') |
|
119 | + ); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return void |
|
126 | + */ |
|
127 | + public static function set_definitions() |
|
128 | + { |
|
129 | + if (is_user_logged_in()) { |
|
130 | + EED_Recaptcha::$_not_a_robot = true; |
|
131 | + } |
|
132 | + define( |
|
133 | + 'RECAPTCHA_BASE_PATH', |
|
134 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
135 | + ); |
|
136 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return void |
|
142 | + */ |
|
143 | + public static function set_late_hooks() |
|
144 | + { |
|
145 | + add_filter( |
|
146 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
147 | + array('EED_Recaptcha', 'not_a_robot') |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @return boolean |
|
154 | + */ |
|
155 | + public static function useRecaptcha() |
|
156 | + { |
|
157 | + return EED_Recaptcha::$config->use_captcha |
|
158 | + && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @return boolean |
|
164 | + * @throws InvalidArgumentException |
|
165 | + * @throws InvalidInterfaceException |
|
166 | + * @throws InvalidDataTypeException |
|
167 | + */ |
|
168 | + public static function notPaymentOptionsRevisit() |
|
169 | + { |
|
170 | + return ! ( |
|
171 | + EE_Registry::instance()->REQ->get('step', '') === 'payment_options' |
|
172 | + && (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true |
|
173 | + ); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @return void |
|
179 | + * @throws InvalidArgumentException |
|
180 | + * @throws InvalidInterfaceException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + */ |
|
183 | + public static function enqueue_styles_and_scripts() |
|
184 | + { |
|
185 | + wp_register_script( |
|
186 | + 'espresso_recaptcha', |
|
187 | + RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', |
|
188 | + array('single_page_checkout'), |
|
189 | + EVENT_ESPRESSO_VERSION, |
|
190 | + true |
|
191 | + ); |
|
192 | + wp_register_script( |
|
193 | + 'google_recaptcha', |
|
194 | + 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
195 | + array('espresso_recaptcha'), |
|
196 | + EVENT_ESPRESSO_VERSION, |
|
197 | + true |
|
198 | + ); |
|
199 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
200 | + 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
201 | + 'event_espresso' |
|
202 | + ); |
|
203 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
204 | + 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
205 | + 'event_espresso' |
|
206 | + ); |
|
207 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
208 | + 'Please complete the anti-spam test before proceeding.', |
|
209 | + 'event_espresso' |
|
210 | + ); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * @param \WP $WP |
|
216 | + */ |
|
217 | + public function run($WP) |
|
218 | + { |
|
219 | + } |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * @return boolean |
|
224 | + * @throws InvalidArgumentException |
|
225 | + * @throws InvalidInterfaceException |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + */ |
|
228 | + public static function not_a_robot() |
|
229 | + { |
|
230 | + $not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) |
|
231 | + ? EED_Recaptcha::$_not_a_robot |
|
232 | + : EED_Recaptcha::recaptcha_passed(); |
|
233 | + return $not_a_robot; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * @return void |
|
239 | + * @throws DomainException |
|
240 | + * @throws InvalidArgumentException |
|
241 | + * @throws InvalidInterfaceException |
|
242 | + * @throws InvalidDataTypeException |
|
243 | + */ |
|
244 | + public static function display_recaptcha() |
|
245 | + { |
|
246 | + // logged in means you have already passed a turing test of sorts |
|
247 | + if (is_user_logged_in()) { |
|
248 | + return; |
|
249 | + } |
|
250 | + // don't display if not using recaptcha or user is logged in |
|
251 | + if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
252 | + // only display if they have NOT passed the test yet |
|
253 | + EEH_Template::display_template( |
|
254 | + RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
255 | + array( |
|
256 | + 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
257 | + 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
258 | + 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
259 | + ) |
|
260 | + ); |
|
261 | + wp_enqueue_script('google_recaptcha'); |
|
262 | + } |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * @return array |
|
268 | + * @throws InvalidArgumentException |
|
269 | + * @throws InvalidInterfaceException |
|
270 | + * @throws InvalidDataTypeException |
|
271 | + */ |
|
272 | + public static function bypass_recaptcha_for_spco_load_payment_method() |
|
273 | + { |
|
274 | + return array( |
|
275 | + 'EESID' => EE_Registry::instance()->SSN->id(), |
|
276 | + 'step' => 'payment_options', |
|
277 | + 'action' => 'switch_spco_billing_form', |
|
278 | + ); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * @return boolean |
|
284 | + * @throws InvalidArgumentException |
|
285 | + * @throws InvalidInterfaceException |
|
286 | + * @throws InvalidDataTypeException |
|
287 | + */ |
|
288 | + public static function recaptcha_passed() |
|
289 | + { |
|
290 | + // logged in means you have already passed a turing test of sorts |
|
291 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
292 | + return true; |
|
293 | + } |
|
294 | + // was test already passed? |
|
295 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
296 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
297 | + // verify recaptcha |
|
298 | + EED_Recaptcha::_get_recaptcha_response(); |
|
299 | + if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | + $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
301 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
302 | + } |
|
303 | + EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
304 | + return $recaptcha_passed; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * @param array $recaptcha_response |
|
310 | + * @return array |
|
311 | + */ |
|
312 | + public static function recaptcha_response($recaptcha_response = array()) |
|
313 | + { |
|
314 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
315 | + $recaptcha_response['bypass_recaptcha'] = true; |
|
316 | + $recaptcha_response['recaptcha_passed'] = true; |
|
317 | + } else { |
|
318 | + $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
319 | + } |
|
320 | + return $recaptcha_response; |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * @return boolean |
|
326 | + */ |
|
327 | + private static function _bypass_recaptcha() |
|
328 | + { |
|
329 | + // an array of key value pairs that must match exactly with the incoming request, |
|
330 | + // in order to bypass recaptcha for the current request ONLY |
|
331 | + $bypass_request_params_array = (array) apply_filters( |
|
332 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
333 | + array() |
|
334 | + ); |
|
335 | + // does $bypass_request_params_array have any values ? |
|
336 | + if (empty($bypass_request_params_array)) { |
|
337 | + return false; |
|
338 | + } |
|
339 | + // initially set bypass to TRUE |
|
340 | + $bypass_recaptcha = true; |
|
341 | + foreach ($bypass_request_params_array as $key => $value) { |
|
342 | + // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
343 | + // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
344 | + $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
345 | + ? $bypass_recaptcha |
|
346 | + : false; |
|
347 | + } |
|
348 | + return $bypass_recaptcha; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @return void |
|
354 | + * @throws InvalidArgumentException |
|
355 | + * @throws InvalidInterfaceException |
|
356 | + * @throws InvalidDataTypeException |
|
357 | + */ |
|
358 | + private static function _get_recaptcha_response() |
|
359 | + { |
|
360 | + EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( |
|
361 | + 'g-recaptcha-response', |
|
362 | + false |
|
363 | + ); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @return boolean |
|
369 | + * @throws InvalidArgumentException |
|
370 | + * @throws InvalidInterfaceException |
|
371 | + * @throws InvalidDataTypeException |
|
372 | + */ |
|
373 | + private static function _process_recaptcha_response() |
|
374 | + { |
|
375 | + // verify library is loaded |
|
376 | + if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | + require_once RECAPTCHA_BASE_PATH . DS . 'autoload.php'; |
|
378 | + } |
|
379 | + // The response from reCAPTCHA |
|
380 | + EED_Recaptcha::_get_recaptcha_response(); |
|
381 | + $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
382 | + // Was there a reCAPTCHA response? |
|
383 | + if ($recaptcha_response) { |
|
384 | + // if allow_url_fopen is Off, then set a different request method |
|
385 | + $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
386 | + $recaptcha = new ReCaptcha( |
|
387 | + EED_Recaptcha::$config->recaptcha_privatekey, |
|
388 | + $request_method |
|
389 | + ); |
|
390 | + $recaptcha_response = $recaptcha->verify( |
|
391 | + EED_Recaptcha::$_recaptcha_response, |
|
392 | + $_SERVER['REMOTE_ADDR'] |
|
393 | + ); |
|
394 | + } |
|
395 | + return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
396 | + } |
|
397 | 397 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | } |
132 | 132 | define( |
133 | 133 | 'RECAPTCHA_BASE_PATH', |
134 | - rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS |
|
134 | + rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS |
|
135 | 135 | ); |
136 | 136 | define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
137 | 137 | } |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | { |
185 | 185 | wp_register_script( |
186 | 186 | 'espresso_recaptcha', |
187 | - RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', |
|
187 | + RECAPTCHA_BASE_URL.'scripts'.DS.'espresso_recaptcha.js', |
|
188 | 188 | array('single_page_checkout'), |
189 | 189 | EVENT_ESPRESSO_VERSION, |
190 | 190 | true |
191 | 191 | ); |
192 | 192 | wp_register_script( |
193 | 193 | 'google_recaptcha', |
194 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
194 | + 'https://www.google.com/recaptcha/api.js?hl='.EED_Recaptcha::$config->recaptcha_language, |
|
195 | 195 | array('espresso_recaptcha'), |
196 | 196 | EVENT_ESPRESSO_VERSION, |
197 | 197 | true |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
252 | 252 | // only display if they have NOT passed the test yet |
253 | 253 | EEH_Template::display_template( |
254 | - RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
|
254 | + RECAPTCHA_BASE_PATH.DS.'templates'.DS.'recaptcha.template.php', |
|
255 | 255 | array( |
256 | 256 | 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
257 | 257 | 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
297 | 297 | // verify recaptcha |
298 | 298 | EED_Recaptcha::_get_recaptcha_response(); |
299 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
299 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
300 | 300 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
301 | 301 | EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
302 | 302 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | foreach ($bypass_request_params_array as $key => $value) { |
342 | 342 | // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
343 | 343 | // otherwise carry over it's value. This way, one missed setting results in no bypass |
344 | - $bypass_recaptcha = isset($_REQUEST[ $key ]) && $_REQUEST[ $key ] === $value |
|
344 | + $bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value |
|
345 | 345 | ? $bypass_recaptcha |
346 | 346 | : false; |
347 | 347 | } |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | private static function _process_recaptcha_response() |
374 | 374 | { |
375 | 375 | // verify library is loaded |
376 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | - require_once RECAPTCHA_BASE_PATH . DS . 'autoload.php'; |
|
376 | + if ( ! class_exists('\ReCaptcha\ReCaptcha')) { |
|
377 | + require_once RECAPTCHA_BASE_PATH.DS.'autoload.php'; |
|
378 | 378 | } |
379 | 379 | // The response from reCAPTCHA |
380 | 380 | EED_Recaptcha::_get_recaptcha_response(); |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('No direct script access allowed'); |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** @type string $recaptcha_language */ |
6 | 6 | /** @type string $recaptcha_publickey */ |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** @type string $recaptcha_language */ |
@@ -19,98 +19,98 @@ |
||
19 | 19 | class EED_Mijireh_Payment_Checker extends EED_Module |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @return void |
|
27 | - */ |
|
28 | - public static function set_hooks() |
|
29 | - { |
|
30 | - } |
|
22 | + /** |
|
23 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @return void |
|
27 | + */ |
|
28 | + public static function set_hooks() |
|
29 | + { |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
34 | - * Mijireh Slurper module mostly just detects a special request on the EE payment methods page |
|
35 | - * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
36 | - * initiate slurping into Mijireh; and adds a metabox to the post.php editing page when Mijireh's special |
|
37 | - * shortcode is present |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public static function set_hooks_admin() |
|
43 | - { |
|
44 | - add_action( |
|
45 | - 'AHEE__Transactions_Admin_Page__transaction_details__start', |
|
46 | - array('EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction'), |
|
47 | - 10, |
|
48 | - 1 |
|
49 | - ); |
|
50 | - } |
|
32 | + /** |
|
33 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
34 | + * Mijireh Slurper module mostly just detects a special request on the EE payment methods page |
|
35 | + * to perform a redirect to a slurping page; detects a special request on the post.php editing page to |
|
36 | + * initiate slurping into Mijireh; and adds a metabox to the post.php editing page when Mijireh's special |
|
37 | + * shortcode is present |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public static function set_hooks_admin() |
|
43 | + { |
|
44 | + add_action( |
|
45 | + 'AHEE__Transactions_Admin_Page__transaction_details__start', |
|
46 | + array('EED_Mijireh_Payment_Checker', 'check_for_payment_update_on_transaction'), |
|
47 | + 10, |
|
48 | + 1 |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * If the transaction has pending mijireh payments, we check with mijireh to see if they've been completed. |
|
55 | - * |
|
56 | - * @param EE_Transaction $transaction |
|
57 | - * @throws EE_Error if a model is misconfigured |
|
58 | - */ |
|
59 | - public static function check_for_payment_update_on_transaction($transaction) |
|
60 | - { |
|
61 | - if ($transaction instanceof EE_Transaction) { |
|
62 | - // are there pending Mijireh payments on this transaction? |
|
63 | - $a_mijireh_payment = EEM_Payment::instance()->get_one( |
|
64 | - array( |
|
65 | - array( |
|
66 | - 'TXN_ID' => $transaction->ID(), |
|
67 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
68 | - 'Payment_Method.PMD_type' => 'Mijireh', |
|
69 | - ), |
|
70 | - ) |
|
71 | - ); |
|
72 | - if ($a_mijireh_payment instanceof EE_Payment) { |
|
73 | - add_action( |
|
74 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
75 | - array('EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn'), |
|
76 | - 5, |
|
77 | - 2 |
|
78 | - ); |
|
79 | - EE_Payment_Processor::instance()->process_ipn( |
|
80 | - array(), |
|
81 | - $transaction, |
|
82 | - $a_mijireh_payment->payment_method() |
|
83 | - ); |
|
84 | - } |
|
85 | - } |
|
86 | - } |
|
53 | + /** |
|
54 | + * If the transaction has pending mijireh payments, we check with mijireh to see if they've been completed. |
|
55 | + * |
|
56 | + * @param EE_Transaction $transaction |
|
57 | + * @throws EE_Error if a model is misconfigured |
|
58 | + */ |
|
59 | + public static function check_for_payment_update_on_transaction($transaction) |
|
60 | + { |
|
61 | + if ($transaction instanceof EE_Transaction) { |
|
62 | + // are there pending Mijireh payments on this transaction? |
|
63 | + $a_mijireh_payment = EEM_Payment::instance()->get_one( |
|
64 | + array( |
|
65 | + array( |
|
66 | + 'TXN_ID' => $transaction->ID(), |
|
67 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
68 | + 'Payment_Method.PMD_type' => 'Mijireh', |
|
69 | + ), |
|
70 | + ) |
|
71 | + ); |
|
72 | + if ($a_mijireh_payment instanceof EE_Payment) { |
|
73 | + add_action( |
|
74 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
75 | + array('EED_Mijireh_Payment_Checker', 'send_notifications_after_mijireh_ipn'), |
|
76 | + 5, |
|
77 | + 2 |
|
78 | + ); |
|
79 | + EE_Payment_Processor::instance()->process_ipn( |
|
80 | + array(), |
|
81 | + $transaction, |
|
82 | + $a_mijireh_payment->payment_method() |
|
83 | + ); |
|
84 | + } |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * send_notifications_after_mijireh_ipn |
|
91 | - * |
|
92 | - * checks if the payment processed in the IPN was approved and if not, blocks messages from being sent. |
|
93 | - * |
|
94 | - * @access public |
|
95 | - * @param EE_Registration $registration |
|
96 | - * @param array $additional_details |
|
97 | - */ |
|
98 | - public static function send_notifications_after_mijireh_ipn($registration, $additional_details) |
|
99 | - { |
|
100 | - $last_payment = isset($additional_details['last_payment']) ? $additional_details['last_payment'] : null; |
|
101 | - if (! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) { |
|
102 | - add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
103 | - } |
|
104 | - } |
|
89 | + /** |
|
90 | + * send_notifications_after_mijireh_ipn |
|
91 | + * |
|
92 | + * checks if the payment processed in the IPN was approved and if not, blocks messages from being sent. |
|
93 | + * |
|
94 | + * @access public |
|
95 | + * @param EE_Registration $registration |
|
96 | + * @param array $additional_details |
|
97 | + */ |
|
98 | + public static function send_notifications_after_mijireh_ipn($registration, $additional_details) |
|
99 | + { |
|
100 | + $last_payment = isset($additional_details['last_payment']) ? $additional_details['last_payment'] : null; |
|
101 | + if (! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) { |
|
102 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * run - initial module setup |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param WP_Query $WP_Query |
|
112 | - */ |
|
113 | - public function run($WP_Query = null) |
|
114 | - { |
|
115 | - } |
|
107 | + /** |
|
108 | + * run - initial module setup |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param WP_Query $WP_Query |
|
112 | + */ |
|
113 | + public function run($WP_Query = null) |
|
114 | + { |
|
115 | + } |
|
116 | 116 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | public static function send_notifications_after_mijireh_ipn($registration, $additional_details) |
99 | 99 | { |
100 | 100 | $last_payment = isset($additional_details['last_payment']) ? $additional_details['last_payment'] : null; |
101 | - if (! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) { |
|
101 | + if ( ! $last_payment instanceof EE_Payment || $last_payment->status() != EEM_Payment::status_id_approved) { |
|
102 | 102 | add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
103 | 103 | } |
104 | 104 | } |
@@ -14,309 +14,309 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * @return EED_Ticket_Selector_Caff |
|
19 | - */ |
|
20 | - public static function instance() |
|
21 | - { |
|
22 | - return parent::get_instance(__CLASS__); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @return EED_Ticket_Selector_Caff |
|
19 | + */ |
|
20 | + public static function instance() |
|
21 | + { |
|
22 | + return parent::get_instance(__CLASS__); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
28 | - * |
|
29 | - * @access public |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public static function set_hooks() |
|
33 | - { |
|
34 | - add_action( |
|
35 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
36 | - array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
37 | - 10, |
|
38 | - 3 |
|
39 | - ); |
|
40 | - } |
|
26 | + /** |
|
27 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
28 | + * |
|
29 | + * @access public |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public static function set_hooks() |
|
33 | + { |
|
34 | + add_action( |
|
35 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
36 | + array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
37 | + 10, |
|
38 | + 3 |
|
39 | + ); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
44 | - * |
|
45 | - * @access public |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - public static function set_hooks_admin() |
|
49 | - { |
|
50 | - define( |
|
51 | - 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
52 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
53 | - ); |
|
54 | - add_action( |
|
55 | - 'AHEE__template_settings__template__before_settings_form', |
|
56 | - array('EED_Ticket_Selector_Caff', 'template_settings_form'), |
|
57 | - 10 |
|
58 | - ); |
|
59 | - add_filter( |
|
60 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
61 | - array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
62 | - 10, |
|
63 | - 2 |
|
64 | - ); |
|
65 | - } |
|
42 | + /** |
|
43 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
44 | + * |
|
45 | + * @access public |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + public static function set_hooks_admin() |
|
49 | + { |
|
50 | + define( |
|
51 | + 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
|
52 | + str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
53 | + ); |
|
54 | + add_action( |
|
55 | + 'AHEE__template_settings__template__before_settings_form', |
|
56 | + array('EED_Ticket_Selector_Caff', 'template_settings_form'), |
|
57 | + 10 |
|
58 | + ); |
|
59 | + add_filter( |
|
60 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
61 | + array('EED_Ticket_Selector_Caff', 'update_template_settings'), |
|
62 | + 10, |
|
63 | + 2 |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @param \WP $WP |
|
70 | - */ |
|
71 | - public function run($WP) |
|
72 | - { |
|
73 | - $this->set_config(); |
|
74 | - } |
|
68 | + /** |
|
69 | + * @param \WP $WP |
|
70 | + */ |
|
71 | + public function run($WP) |
|
72 | + { |
|
73 | + $this->set_config(); |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - protected function set_config() |
|
78 | - { |
|
79 | - $this->set_config_section('template_settings'); |
|
80 | - $this->set_config_class('EE_Ticket_Selector_Config'); |
|
81 | - $this->set_config_name('EED_Ticket_Selector'); |
|
82 | - } |
|
77 | + protected function set_config() |
|
78 | + { |
|
79 | + $this->set_config_section('template_settings'); |
|
80 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
81 | + $this->set_config_name('EED_Ticket_Selector'); |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * template_settings_form |
|
87 | - * |
|
88 | - * @access public |
|
89 | - * @static |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public static function template_settings_form() |
|
93 | - { |
|
94 | - echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
95 | - } |
|
85 | + /** |
|
86 | + * template_settings_form |
|
87 | + * |
|
88 | + * @access public |
|
89 | + * @static |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public static function template_settings_form() |
|
93 | + { |
|
94 | + echo EED_Ticket_Selector_Caff::_ticket_selector_settings_form()->get_html(); |
|
95 | + } |
|
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return \EE_Form_Section_Proper |
|
100 | - * @throws \EE_Error |
|
101 | - */ |
|
102 | - public static function _ticket_selector_settings_form() |
|
103 | - { |
|
98 | + /** |
|
99 | + * @return \EE_Form_Section_Proper |
|
100 | + * @throws \EE_Error |
|
101 | + */ |
|
102 | + public static function _ticket_selector_settings_form() |
|
103 | + { |
|
104 | 104 | |
105 | - return new EE_Form_Section_Proper( |
|
106 | - array( |
|
107 | - 'name' => 'ticket_selector_settings_form', |
|
108 | - 'html_id' => 'ticket_selector_settings_form', |
|
109 | - 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
110 | - 'subsections' => apply_filters( |
|
111 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
112 | - array( |
|
113 | - 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
114 | - EEH_HTML::br(2) . |
|
115 | - EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
116 | - ), |
|
117 | - 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
118 | - ) |
|
119 | - ), |
|
120 | - ) |
|
121 | - ); |
|
122 | - } |
|
105 | + return new EE_Form_Section_Proper( |
|
106 | + array( |
|
107 | + 'name' => 'ticket_selector_settings_form', |
|
108 | + 'html_id' => 'ticket_selector_settings_form', |
|
109 | + 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
|
110 | + 'subsections' => apply_filters( |
|
111 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
|
112 | + array( |
|
113 | + 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
|
114 | + EEH_HTML::br(2) . |
|
115 | + EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
116 | + ), |
|
117 | + 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
|
118 | + ) |
|
119 | + ), |
|
120 | + ) |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * @return \EE_Form_Section_Proper |
|
127 | - * @throws \EE_Error |
|
128 | - */ |
|
129 | - public static function _ticket_selector_appearance_settings() |
|
130 | - { |
|
131 | - if (! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
132 | - ) { |
|
133 | - \EED_Ticket_Selector::instance()->set_config(); |
|
134 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance( |
|
135 | - )->config(); |
|
136 | - } |
|
137 | - // get option for whether to show datetime selector in TS |
|
138 | - $show_datetime_selector = \EE_Registry::instance() |
|
139 | - ->CFG |
|
140 | - ->template_settings |
|
141 | - ->EED_Ticket_Selector |
|
142 | - ->getShowDatetimeSelector(); |
|
143 | - // and option for how may datetimes must exist if display is conditional |
|
144 | - $datetime_selector_threshold = \EE_Registry::instance() |
|
145 | - ->CFG |
|
146 | - ->template_settings |
|
147 | - ->EED_Ticket_Selector |
|
148 | - ->getDatetimeSelectorThreshold(); |
|
125 | + /** |
|
126 | + * @return \EE_Form_Section_Proper |
|
127 | + * @throws \EE_Error |
|
128 | + */ |
|
129 | + public static function _ticket_selector_appearance_settings() |
|
130 | + { |
|
131 | + if (! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
132 | + ) { |
|
133 | + \EED_Ticket_Selector::instance()->set_config(); |
|
134 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance( |
|
135 | + )->config(); |
|
136 | + } |
|
137 | + // get option for whether to show datetime selector in TS |
|
138 | + $show_datetime_selector = \EE_Registry::instance() |
|
139 | + ->CFG |
|
140 | + ->template_settings |
|
141 | + ->EED_Ticket_Selector |
|
142 | + ->getShowDatetimeSelector(); |
|
143 | + // and option for how may datetimes must exist if display is conditional |
|
144 | + $datetime_selector_threshold = \EE_Registry::instance() |
|
145 | + ->CFG |
|
146 | + ->template_settings |
|
147 | + ->EED_Ticket_Selector |
|
148 | + ->getDatetimeSelectorThreshold(); |
|
149 | 149 | |
150 | - return new EE_Form_Section_Proper( |
|
151 | - array( |
|
152 | - 'name' => 'ticket_selector_settings_tbl', |
|
153 | - 'html_id' => 'ticket_selector_settings_tbl', |
|
154 | - 'html_class' => 'form-table', |
|
155 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
156 | - 'subsections' => apply_filters( |
|
157 | - 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
158 | - array( |
|
159 | - 'show_ticket_details' => new EE_Yes_No_Input( |
|
160 | - array( |
|
161 | - 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso'), |
|
162 | - 'html_help_text' => esc_html__( |
|
163 | - 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
164 | - 'event_espresso' |
|
165 | - ), |
|
166 | - 'default' => isset( |
|
167 | - EE_Registry::instance( |
|
168 | - )->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
|
169 | - ) |
|
170 | - ? EE_Registry::instance( |
|
171 | - )->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
|
172 | - : true, |
|
173 | - 'display_html_label_text' => false, |
|
174 | - ) |
|
175 | - ), |
|
176 | - 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
177 | - array( |
|
178 | - 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso'), |
|
179 | - 'html_help_text' => esc_html__( |
|
180 | - 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
181 | - 'event_espresso' |
|
182 | - ), |
|
183 | - 'default' => isset( |
|
184 | - EE_Registry::instance( |
|
185 | - )->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
|
186 | - ) |
|
187 | - ? EE_Registry::instance( |
|
188 | - )->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
|
189 | - : true, |
|
190 | - 'display_html_label_text' => false, |
|
191 | - ) |
|
192 | - ), |
|
193 | - 'show_expired_tickets' => new EE_Yes_No_Input( |
|
194 | - array( |
|
195 | - 'html_label_text' => esc_html__('Show Expired Tickets?', 'event_espresso'), |
|
196 | - 'html_help_text' => esc_html__( |
|
197 | - 'Indicate whether to show expired tickets in the ticket selector', |
|
198 | - 'event_espresso' |
|
199 | - ), |
|
200 | - 'default' => isset( |
|
201 | - EE_Registry::instance( |
|
202 | - )->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
|
203 | - ) |
|
204 | - ? EE_Registry::instance( |
|
205 | - )->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
|
206 | - : true, |
|
207 | - 'display_html_label_text' => false, |
|
208 | - ) |
|
209 | - ), |
|
210 | - 'show_datetime_selector' => new EE_Select_Input( |
|
211 | - \EE_Registry::instance( |
|
212 | - )->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
213 | - array( |
|
214 | - 'html_label_text' => esc_html__('Show Date & Time Filter?', 'event_espresso'), |
|
215 | - 'html_help_text' => sprintf( |
|
216 | - esc_html__( |
|
217 | - 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
218 | - 'event_espresso' |
|
219 | - ), |
|
220 | - '<br>', |
|
221 | - '<strong>', |
|
222 | - '</strong>' |
|
223 | - ), |
|
224 | - 'default' => ! empty($show_datetime_selector) |
|
225 | - ? $show_datetime_selector |
|
226 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
227 | - 'display_html_label_text' => false, |
|
228 | - ) |
|
229 | - ), |
|
230 | - 'datetime_selector_threshold' => new EE_Select_Input( |
|
231 | - array_combine($r = range(1, 10), $r), |
|
232 | - array( |
|
233 | - 'html_label_text' => esc_html__( |
|
234 | - 'Date & Time Filter Threshold', |
|
235 | - 'event_espresso' |
|
236 | - ), |
|
237 | - 'html_help_text' => esc_html__( |
|
238 | - 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
239 | - 'event_espresso' |
|
240 | - ), |
|
241 | - 'default' => ! empty($datetime_selector_threshold) |
|
242 | - ? $datetime_selector_threshold |
|
243 | - : 3, |
|
244 | - 'display_html_label_text' => false, |
|
245 | - ) |
|
246 | - ), |
|
247 | - ) |
|
248 | - ), |
|
249 | - ) |
|
250 | - ); |
|
251 | - } |
|
150 | + return new EE_Form_Section_Proper( |
|
151 | + array( |
|
152 | + 'name' => 'ticket_selector_settings_tbl', |
|
153 | + 'html_id' => 'ticket_selector_settings_tbl', |
|
154 | + 'html_class' => 'form-table', |
|
155 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
156 | + 'subsections' => apply_filters( |
|
157 | + 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_appearance_settings__form_subsections', |
|
158 | + array( |
|
159 | + 'show_ticket_details' => new EE_Yes_No_Input( |
|
160 | + array( |
|
161 | + 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso'), |
|
162 | + 'html_help_text' => esc_html__( |
|
163 | + 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', |
|
164 | + 'event_espresso' |
|
165 | + ), |
|
166 | + 'default' => isset( |
|
167 | + EE_Registry::instance( |
|
168 | + )->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
|
169 | + ) |
|
170 | + ? EE_Registry::instance( |
|
171 | + )->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
|
172 | + : true, |
|
173 | + 'display_html_label_text' => false, |
|
174 | + ) |
|
175 | + ), |
|
176 | + 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
|
177 | + array( |
|
178 | + 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso'), |
|
179 | + 'html_help_text' => esc_html__( |
|
180 | + 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', |
|
181 | + 'event_espresso' |
|
182 | + ), |
|
183 | + 'default' => isset( |
|
184 | + EE_Registry::instance( |
|
185 | + )->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
|
186 | + ) |
|
187 | + ? EE_Registry::instance( |
|
188 | + )->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
|
189 | + : true, |
|
190 | + 'display_html_label_text' => false, |
|
191 | + ) |
|
192 | + ), |
|
193 | + 'show_expired_tickets' => new EE_Yes_No_Input( |
|
194 | + array( |
|
195 | + 'html_label_text' => esc_html__('Show Expired Tickets?', 'event_espresso'), |
|
196 | + 'html_help_text' => esc_html__( |
|
197 | + 'Indicate whether to show expired tickets in the ticket selector', |
|
198 | + 'event_espresso' |
|
199 | + ), |
|
200 | + 'default' => isset( |
|
201 | + EE_Registry::instance( |
|
202 | + )->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
|
203 | + ) |
|
204 | + ? EE_Registry::instance( |
|
205 | + )->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
|
206 | + : true, |
|
207 | + 'display_html_label_text' => false, |
|
208 | + ) |
|
209 | + ), |
|
210 | + 'show_datetime_selector' => new EE_Select_Input( |
|
211 | + \EE_Registry::instance( |
|
212 | + )->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
213 | + array( |
|
214 | + 'html_label_text' => esc_html__('Show Date & Time Filter?', 'event_espresso'), |
|
215 | + 'html_help_text' => sprintf( |
|
216 | + esc_html__( |
|
217 | + 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
218 | + 'event_espresso' |
|
219 | + ), |
|
220 | + '<br>', |
|
221 | + '<strong>', |
|
222 | + '</strong>' |
|
223 | + ), |
|
224 | + 'default' => ! empty($show_datetime_selector) |
|
225 | + ? $show_datetime_selector |
|
226 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
227 | + 'display_html_label_text' => false, |
|
228 | + ) |
|
229 | + ), |
|
230 | + 'datetime_selector_threshold' => new EE_Select_Input( |
|
231 | + array_combine($r = range(1, 10), $r), |
|
232 | + array( |
|
233 | + 'html_label_text' => esc_html__( |
|
234 | + 'Date & Time Filter Threshold', |
|
235 | + 'event_espresso' |
|
236 | + ), |
|
237 | + 'html_help_text' => esc_html__( |
|
238 | + 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
239 | + 'event_espresso' |
|
240 | + ), |
|
241 | + 'default' => ! empty($datetime_selector_threshold) |
|
242 | + ? $datetime_selector_threshold |
|
243 | + : 3, |
|
244 | + 'display_html_label_text' => false, |
|
245 | + ) |
|
246 | + ), |
|
247 | + ) |
|
248 | + ), |
|
249 | + ) |
|
250 | + ); |
|
251 | + } |
|
252 | 252 | |
253 | 253 | |
254 | - /** |
|
255 | - * callback for updating template settings |
|
256 | - * |
|
257 | - * @since 4.6.18.rc.006 |
|
258 | - * @param EE_Template_Config $CFG |
|
259 | - * @param array $REQ incoming request |
|
260 | - * @return EE_Template_Config |
|
261 | - */ |
|
262 | - public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
263 | - { |
|
264 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
265 | - \EED_Ticket_Selector::instance()->set_config(); |
|
266 | - $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
267 | - } |
|
268 | - try { |
|
269 | - $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
254 | + /** |
|
255 | + * callback for updating template settings |
|
256 | + * |
|
257 | + * @since 4.6.18.rc.006 |
|
258 | + * @param EE_Template_Config $CFG |
|
259 | + * @param array $REQ incoming request |
|
260 | + * @return EE_Template_Config |
|
261 | + */ |
|
262 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
|
263 | + { |
|
264 | + if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
265 | + \EED_Ticket_Selector::instance()->set_config(); |
|
266 | + $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
267 | + } |
|
268 | + try { |
|
269 | + $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
|
270 | 270 | |
271 | - // check for form submission |
|
272 | - if ($ticket_selector_form->was_submitted()) { |
|
273 | - // capture form data |
|
274 | - $ticket_selector_form->receive_form_submission(); |
|
271 | + // check for form submission |
|
272 | + if ($ticket_selector_form->was_submitted()) { |
|
273 | + // capture form data |
|
274 | + $ticket_selector_form->receive_form_submission(); |
|
275 | 275 | |
276 | - // validate form data |
|
277 | - if ($ticket_selector_form->is_valid()) { |
|
278 | - // grab validated data from form |
|
279 | - $valid_data = $ticket_selector_form->valid_data(); |
|
276 | + // validate form data |
|
277 | + if ($ticket_selector_form->is_valid()) { |
|
278 | + // grab validated data from form |
|
279 | + $valid_data = $ticket_selector_form->valid_data(); |
|
280 | 280 | |
281 | - // set data on config |
|
282 | - $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
283 | - $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
284 | - $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
285 | - $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
286 | - $valid_data['appearance_settings']['show_datetime_selector'] |
|
287 | - ); |
|
288 | - $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
289 | - $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
290 | - ); |
|
291 | - } else { |
|
292 | - if ($ticket_selector_form->submission_error_message() !== '') { |
|
293 | - EE_Error::add_error( |
|
294 | - $ticket_selector_form->submission_error_message(), |
|
295 | - __FILE__, |
|
296 | - __FUNCTION__, |
|
297 | - __LINE__ |
|
298 | - ); |
|
299 | - } |
|
300 | - } |
|
301 | - } |
|
302 | - } catch (EE_Error $e) { |
|
303 | - $e->get_error(); |
|
304 | - } |
|
281 | + // set data on config |
|
282 | + $CFG->EED_Ticket_Selector->show_ticket_sale_columns = $valid_data['appearance_settings']['show_ticket_sale_columns']; |
|
283 | + $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
|
284 | + $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
|
285 | + $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
|
286 | + $valid_data['appearance_settings']['show_datetime_selector'] |
|
287 | + ); |
|
288 | + $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
|
289 | + $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
290 | + ); |
|
291 | + } else { |
|
292 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
293 | + EE_Error::add_error( |
|
294 | + $ticket_selector_form->submission_error_message(), |
|
295 | + __FILE__, |
|
296 | + __FUNCTION__, |
|
297 | + __LINE__ |
|
298 | + ); |
|
299 | + } |
|
300 | + } |
|
301 | + } |
|
302 | + } catch (EE_Error $e) { |
|
303 | + $e->get_error(); |
|
304 | + } |
|
305 | 305 | |
306 | - return $CFG; |
|
307 | - } |
|
306 | + return $CFG; |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | - /** |
|
311 | - * @param \EE_Ticket $ticket |
|
312 | - * @param int $ticket_price |
|
313 | - * @param bool $display_ticket_price |
|
314 | - */ |
|
315 | - public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
316 | - { |
|
317 | - require( |
|
318 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) |
|
319 | - . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
320 | - ); |
|
321 | - } |
|
310 | + /** |
|
311 | + * @param \EE_Ticket $ticket |
|
312 | + * @param int $ticket_price |
|
313 | + * @param bool $display_ticket_price |
|
314 | + */ |
|
315 | + public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
316 | + { |
|
317 | + require( |
|
318 | + str_replace('\\', DS, plugin_dir_path(__FILE__)) |
|
319 | + . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
320 | + ); |
|
321 | + } |
|
322 | 322 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | define( |
51 | 51 | 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', |
52 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS |
|
52 | + str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS |
|
53 | 53 | ); |
54 | 54 | add_action( |
55 | 55 | 'AHEE__template_settings__template__before_settings_form', |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
112 | 112 | array( |
113 | 113 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
114 | - EEH_HTML::br(2) . |
|
114 | + EEH_HTML::br(2). |
|
115 | 115 | EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
116 | 116 | ), |
117 | 117 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings(), |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public static function _ticket_selector_appearance_settings() |
130 | 130 | { |
131 | - if (! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
131 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
132 | 132 | ) { |
133 | 133 | \EED_Ticket_Selector::instance()->set_config(); |
134 | 134 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public static function update_template_settings(EE_Template_Config $CFG, $REQ) |
263 | 263 | { |
264 | - if (! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
264 | + if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
265 | 265 | \EED_Ticket_Selector::instance()->set_config(); |
266 | 266 | $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
267 | 267 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | require( |
318 | 318 | str_replace('\\', DS, plugin_dir_path(__FILE__)) |
319 | - . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
319 | + . 'templates'.DS.'ticket_selector_price_details.template.php' |
|
320 | 320 | ); |
321 | 321 | } |
322 | 322 | } |
@@ -7,39 +7,39 @@ discard block |
||
7 | 7 | if ($display_ticket_price) { ?> |
8 | 8 | <section class="tckt-slctr-tkt-price-sctn"> |
9 | 9 | <h5><?php |
10 | - echo apply_filters( |
|
11 | - 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
12 | - esc_html__('Price', 'event_espresso') |
|
13 | - ); ?></h5> |
|
10 | + echo apply_filters( |
|
11 | + 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
|
12 | + esc_html__('Price', 'event_espresso') |
|
13 | + ); ?></h5> |
|
14 | 14 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
15 | 15 | <table class="tckt-slctr-tkt-details-tbl"> |
16 | 16 | <thead> |
17 | 17 | <tr> |
18 | 18 | <th class="ee-third-width"><span class="small-text"> |
19 | 19 | <?php |
20 | - esc_html_e( |
|
21 | - 'Name', |
|
22 | - 'event_espresso' |
|
23 | - ); ?></span> |
|
20 | + esc_html_e( |
|
21 | + 'Name', |
|
22 | + 'event_espresso' |
|
23 | + ); ?></span> |
|
24 | 24 | </th> |
25 | 25 | <th class="jst-cntr"><span class="small-text"> |
26 | 26 | <?php |
27 | - esc_html_e( |
|
28 | - 'Description', |
|
29 | - 'event_espresso' |
|
30 | - ); ?></span> |
|
27 | + esc_html_e( |
|
28 | + 'Description', |
|
29 | + 'event_espresso' |
|
30 | + ); ?></span> |
|
31 | 31 | </th> |
32 | 32 | <th class="ee-fourth-width jst-rght"><span class="small-text"> |
33 | 33 | <?php |
34 | - esc_html_e( |
|
35 | - 'Amount', |
|
36 | - 'event_espresso' |
|
37 | - ); ?></span></th> |
|
34 | + esc_html_e( |
|
35 | + 'Amount', |
|
36 | + 'event_espresso' |
|
37 | + ); ?></span></th> |
|
38 | 38 | </tr> |
39 | 39 | </thead> |
40 | 40 | <tbody> |
41 | 41 | <?php |
42 | - if ($ticket->base_price() instanceof EE_Price) { ?> |
|
42 | + if ($ticket->base_price() instanceof EE_Price) { ?> |
|
43 | 43 | <tr> |
44 | 44 | <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>" class="small-text"> |
45 | 45 | <b><?php echo $ticket->base_price()->name(); ?></b></td> |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
50 | 50 | </tr> |
51 | 51 | <?php |
52 | - $running_total = $ticket->base_price()->amount(); |
|
53 | - } else { |
|
54 | - $running_total = 0; |
|
55 | - } |
|
56 | - // now add price modifiers |
|
57 | - foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
52 | + $running_total = $ticket->base_price()->amount(); |
|
53 | + } else { |
|
54 | + $running_total = 0; |
|
55 | + } |
|
56 | + // now add price modifiers |
|
57 | + foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
58 | 58 | <tr> |
59 | 59 | <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>" |
60 | 60 | class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
@@ -64,23 +64,23 @@ discard block |
||
64 | 64 | % |
65 | 65 | </td> |
66 | 66 | <?php |
67 | - $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
68 | - $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
|
69 | - ?> |
|
67 | + $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
68 | + $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
|
69 | + ?> |
|
70 | 70 | <?php } else { ?> |
71 | 71 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 |
72 | - : $price_mod->amount(); ?> |
|
72 | + : $price_mod->amount(); ?> |
|
73 | 73 | <td data-th="<?php esc_html_e('Description', 'event_espresso'); ?>" |
74 | 74 | class="small-text"><?php echo $price_mod->desc(); ?></td> |
75 | 75 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 |
76 | - : $price_mod->amount(); ?> |
|
76 | + : $price_mod->amount(); ?> |
|
77 | 77 | <?php } ?> |
78 | 78 | <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>" |
79 | 79 | class="jst-rght small-text"> |
80 | 80 | <?php |
81 | - echo EEH_Template::format_currency( |
|
82 | - $new_sub_total |
|
83 | - ); ?></td> |
|
81 | + echo EEH_Template::format_currency( |
|
82 | + $new_sub_total |
|
83 | + ); ?></td> |
|
84 | 84 | <?php $running_total += $new_sub_total; ?> |
85 | 85 | </tr> |
86 | 86 | <?php } ?> |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | <tr> |
90 | 90 | <td colspan="2" class="jst-rght small-text sbttl"><b> |
91 | 91 | <?php |
92 | - esc_html_e( |
|
93 | - 'subtotal', |
|
94 | - 'event_espresso' |
|
95 | - ); ?></b></td> |
|
92 | + esc_html_e( |
|
93 | + 'subtotal', |
|
94 | + 'event_espresso' |
|
95 | + ); ?></b></td> |
|
96 | 96 | <td data-th="<?php esc_html_e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"> |
97 | 97 | <b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
98 | 98 | </tr> |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>" |
109 | 109 | class="jst-rght small-text"> |
110 | 110 | <?php |
111 | - echo EEH_Template::format_currency( |
|
112 | - $tax_amount |
|
113 | - ); ?></td> |
|
111 | + echo EEH_Template::format_currency( |
|
112 | + $tax_amount |
|
113 | + ); ?></td> |
|
114 | 114 | <?php $running_total += $tax_amount; ?> |
115 | 115 | </tr> |
116 | 116 | <?php } ?> |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | <tr> |
119 | 119 | <td colspan="2" class="jst-rght small-text ttl-lbl-td"> |
120 | 120 | <b><?php |
121 | - echo apply_filters( |
|
122 | - 'FHEE__ticket_selector_chart_template__ticket_details_total_price', |
|
123 | - esc_html__('Total', 'event_espresso') |
|
124 | - ); ?></b></td> |
|
121 | + echo apply_filters( |
|
122 | + 'FHEE__ticket_selector_chart_template__ticket_details_total_price', |
|
123 | + esc_html__('Total', 'event_espresso') |
|
124 | + ); ?></b></td> |
|
125 | 125 | <td data-th="<?php |
126 | - echo apply_filters( |
|
127 | - 'FHEE__ticket_selector_chart_template__ticket_details_total_price', |
|
128 | - esc_html__('Total', 'event_espresso') |
|
129 | - ); ?>" class="jst-rght small-text"> |
|
126 | + echo apply_filters( |
|
127 | + 'FHEE__ticket_selector_chart_template__ticket_details_total_price', |
|
128 | + esc_html__('Total', 'event_espresso') |
|
129 | + ); ?>" class="jst-rght small-text"> |
|
130 | 130 | <b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
131 | 131 | </tr> |
132 | 132 | </tbody> |