@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function _parser($shortcode) |
50 | 50 | { |
51 | 51 | // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
52 | - if (! $this->_data instanceof EE_Payment) { |
|
52 | + if ( ! $this->_data instanceof EE_Payment) { |
|
53 | 53 | return ''; |
54 | 54 | } |
55 | 55 |
@@ -16,93 +16,93 @@ |
||
16 | 16 | */ |
17 | 17 | class EE_Payment_Shortcodes extends EE_Shortcodes |
18 | 18 | { |
19 | - protected function _init_props() |
|
20 | - { |
|
21 | - $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
22 | - $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
23 | - $this->_shortcodes = array( |
|
24 | - '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
25 | - 'Outputs the date of the payment (using the default date format).', |
|
26 | - 'event_espresso' |
|
27 | - ), |
|
28 | - '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
29 | - '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
30 | - '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
31 | - '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
32 | - '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
33 | - 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
37 | - '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
38 | - 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
39 | - 'event_espresso' |
|
40 | - ), |
|
41 | - '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
42 | - // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
43 | - ); |
|
44 | - } |
|
19 | + protected function _init_props() |
|
20 | + { |
|
21 | + $this->label = esc_html__('Payment Shortcodes', 'event_espresso'); |
|
22 | + $this->description = esc_html__('All shortcodes specific to payments.', 'event_espresso'); |
|
23 | + $this->_shortcodes = array( |
|
24 | + '[PAYMENT_TIMESTAMP]' => esc_html__( |
|
25 | + 'Outputs the date of the payment (using the default date format).', |
|
26 | + 'event_espresso' |
|
27 | + ), |
|
28 | + '[PAYMENT_METHOD]' => esc_html__('Outputs a the payment method.', 'event_espresso'), |
|
29 | + '[PAYMENT_AMOUNT]' => esc_html__('Outputs the payment amount (with currency symbol).', 'event_espresso'), |
|
30 | + '[PAYMENT_GATEWAY]' => esc_html__('Outputs the gateway used for the payment.', 'event_espresso'), |
|
31 | + '[PAYMENT_GATEWAY_RESPONSE]' => esc_html__('Outputs the payment gateway response.', 'event_espresso'), |
|
32 | + '[PAYMENT_GATEWAY_TXN_ID]' => esc_html__( |
|
33 | + 'This will either be the gateway transaction ID, or the manual ID added with payment applied via the admin.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '[PAYMENT_PO_NUMBER]' => esc_html__('Purchase Order number (if present)', 'event_espresso'), |
|
37 | + '[PAYMENT_EXTRA_ACCOUNTING]' => esc_html__( |
|
38 | + 'Any extra accounting messages. Typically added with payments made via the admin.', |
|
39 | + 'event_espresso' |
|
40 | + ), |
|
41 | + '[PAYMENT_STATUS]' => esc_html__('The status of the payment.', 'event_espresso'), |
|
42 | + // '[PAYMENT_STATUS_WITH_ICONS]' => esc_html__('The status of the payment including icons representing the status.', 'event_espresso') |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - protected function _parser($shortcode) |
|
48 | - { |
|
49 | - // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
50 | - if (! $this->_data instanceof EE_Payment) { |
|
51 | - return ''; |
|
52 | - } |
|
47 | + protected function _parser($shortcode) |
|
48 | + { |
|
49 | + // ensure that the incoming object is an EE_Payment object. If it isn't then bail early. |
|
50 | + if (! $this->_data instanceof EE_Payment) { |
|
51 | + return ''; |
|
52 | + } |
|
53 | 53 | |
54 | - $payment = $this->_data; |
|
54 | + $payment = $this->_data; |
|
55 | 55 | |
56 | - switch ($shortcode) { |
|
57 | - case '[PAYMENT_TIMESTAMP]': |
|
58 | - return $payment->timestamp(); |
|
59 | - break; |
|
56 | + switch ($shortcode) { |
|
57 | + case '[PAYMENT_TIMESTAMP]': |
|
58 | + return $payment->timestamp(); |
|
59 | + break; |
|
60 | 60 | |
61 | - case '[PAYMENT_METHOD]': |
|
62 | - // previously the column 'PAY_source' was known as 'PAY_method' |
|
63 | - return $payment->source(); |
|
64 | - break; |
|
61 | + case '[PAYMENT_METHOD]': |
|
62 | + // previously the column 'PAY_source' was known as 'PAY_method' |
|
63 | + return $payment->source(); |
|
64 | + break; |
|
65 | 65 | |
66 | - case '[PAYMENT_AMOUNT]': |
|
67 | - return $payment->amount_no_code(); |
|
68 | - break; |
|
66 | + case '[PAYMENT_AMOUNT]': |
|
67 | + return $payment->amount_no_code(); |
|
68 | + break; |
|
69 | 69 | |
70 | - case '[PAYMENT_GATEWAY]': |
|
71 | - // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
72 | - if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
73 | - return $payment->payment_method()->name(); |
|
74 | - } else { |
|
75 | - return esc_html__('Unknown', 'event_espresso'); |
|
76 | - } |
|
77 | - break; |
|
70 | + case '[PAYMENT_GATEWAY]': |
|
71 | + // previously teh column 'PMD_ID' was more-or-less 'PAY_gateway' |
|
72 | + if ($payment->payment_method() instanceof EE_Payment_Method) { |
|
73 | + return $payment->payment_method()->name(); |
|
74 | + } else { |
|
75 | + return esc_html__('Unknown', 'event_espresso'); |
|
76 | + } |
|
77 | + break; |
|
78 | 78 | |
79 | - case '[PAYMENT_GATEWAY_RESPONSE]': |
|
80 | - return $payment->gateway_response(); |
|
81 | - break; |
|
79 | + case '[PAYMENT_GATEWAY_RESPONSE]': |
|
80 | + return $payment->gateway_response(); |
|
81 | + break; |
|
82 | 82 | |
83 | - case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | - return $payment->txn_id_chq_nmbr(); |
|
85 | - break; |
|
83 | + case '[PAYMENT_GATEWAY_TXN_ID]': |
|
84 | + return $payment->txn_id_chq_nmbr(); |
|
85 | + break; |
|
86 | 86 | |
87 | - case '[PAYMENT_PO_NUMBER]': |
|
88 | - return $payment->po_number(); |
|
89 | - break; |
|
87 | + case '[PAYMENT_PO_NUMBER]': |
|
88 | + return $payment->po_number(); |
|
89 | + break; |
|
90 | 90 | |
91 | - case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
92 | - return $payment->extra_accntng(); |
|
93 | - break; |
|
91 | + case '[PAYMENT_EXTRA_ACCOUNTING]': |
|
92 | + return $payment->extra_accntng(); |
|
93 | + break; |
|
94 | 94 | |
95 | - case '[PAYMENT_STATUS]': |
|
96 | - return $payment->pretty_status(); |
|
97 | - break; |
|
95 | + case '[PAYMENT_STATUS]': |
|
96 | + return $payment->pretty_status(); |
|
97 | + break; |
|
98 | 98 | |
99 | - case '[PAYMENT_STATUS_WITH_ICONS]': |
|
100 | - return $payment->pretty_status(true); |
|
101 | - break; |
|
99 | + case '[PAYMENT_STATUS_WITH_ICONS]': |
|
100 | + return $payment->pretty_status(true); |
|
101 | + break; |
|
102 | 102 | |
103 | - default: |
|
104 | - return ''; |
|
105 | - break; |
|
106 | - } |
|
107 | - } |
|
103 | + default: |
|
104 | + return ''; |
|
105 | + break; |
|
106 | + } |
|
107 | + } |
|
108 | 108 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
60 | 60 | $event = $this->_data instanceof EE_Event ? $this->_data : null; |
61 | 61 | |
62 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | + if ( ! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
63 | 63 | return ''; |
64 | 64 | } |
65 | 65 | |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | break; |
84 | 84 | |
85 | 85 | case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
86 | - if (! empty($recipient)) { |
|
86 | + if ( ! empty($recipient)) { |
|
87 | 87 | $email = ! empty($recipient->fname) |
88 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | + ? $recipient->fname.' '.$recipient->lname.'<'.$recipient->admin_email.'>' |
|
89 | 89 | : EE_Registry::instance()->CFG->organization->get_pretty( |
90 | 90 | 'name' |
91 | - ) . '<' . $recipient->admin_email . '>'; |
|
91 | + ).'<'.$recipient->admin_email.'>'; |
|
92 | 92 | } else { |
93 | 93 | $email = null; |
94 | 94 | } |
95 | 95 | if (empty($email) && ! empty($event)) { |
96 | 96 | $user = $this->_get_author_for_event($event); |
97 | 97 | $email = ! empty($user->first_name) |
98 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | + ? $user->first_name.' '.$user->last_name.'<'.$user->user_email.'>' |
|
99 | 99 | : EE_Registry::instance()->CFG->organization->get_pretty( |
100 | 100 | 'name' |
101 | - ) . '<' . $user->user_email . '>'; |
|
101 | + ).'<'.$user->user_email.'>'; |
|
102 | 102 | } |
103 | 103 | return $email; |
104 | 104 | break; |
@@ -19,116 +19,116 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_Event_Author_Shortcodes extends EE_Shortcodes |
21 | 21 | { |
22 | - public function __construct() |
|
23 | - { |
|
24 | - parent::__construct(); |
|
25 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + parent::__construct(); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - protected function _init_props() |
|
29 | - { |
|
30 | - $this->label = esc_html__('Event Author Details Shortcodes', 'event_espresso'); |
|
31 | - $this->description = esc_html__('All shortcodes specific to event_author data', 'event_espresso'); |
|
32 | - $this->_shortcodes = array( |
|
33 | - '[EVENT_AUTHOR_FNAME]' => esc_html__('Parses to the first name of the event author.', 'event_espresso'), |
|
34 | - '[EVENT_AUTHOR_LNAME]' => esc_html__('Parses to the last name of the event author.', 'event_espresso'), |
|
35 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => esc_html__( |
|
36 | - 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - '[EVENT_AUTHOR_EMAIL]' => esc_html__( |
|
40 | - 'Parses to the unformatted email address of the event author', |
|
41 | - 'event_espresso' |
|
42 | - ), |
|
43 | - ); |
|
44 | - } |
|
28 | + protected function _init_props() |
|
29 | + { |
|
30 | + $this->label = esc_html__('Event Author Details Shortcodes', 'event_espresso'); |
|
31 | + $this->description = esc_html__('All shortcodes specific to event_author data', 'event_espresso'); |
|
32 | + $this->_shortcodes = array( |
|
33 | + '[EVENT_AUTHOR_FNAME]' => esc_html__('Parses to the first name of the event author.', 'event_espresso'), |
|
34 | + '[EVENT_AUTHOR_LNAME]' => esc_html__('Parses to the last name of the event author.', 'event_espresso'), |
|
35 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => esc_html__( |
|
36 | + 'Parses to a formatted email address of the event author (fname lname <[email protected]>). <strong>NOTE:</strong> If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + '[EVENT_AUTHOR_EMAIL]' => esc_html__( |
|
40 | + 'Parses to the unformatted email address of the event author', |
|
41 | + 'event_espresso' |
|
42 | + ), |
|
43 | + ); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - protected function _parser($shortcode) |
|
48 | - { |
|
49 | - // make sure we end up with a copy of the EE_Messages_Addressee object |
|
50 | - $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
51 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
52 | - $this->_data |
|
53 | - ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
54 | - : $recipient; |
|
55 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
56 | - ? $this->_extra_data['data'] : $recipient; |
|
47 | + protected function _parser($shortcode) |
|
48 | + { |
|
49 | + // make sure we end up with a copy of the EE_Messages_Addressee object |
|
50 | + $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
51 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array( |
|
52 | + $this->_data |
|
53 | + ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] |
|
54 | + : $recipient; |
|
55 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
56 | + ? $this->_extra_data['data'] : $recipient; |
|
57 | 57 | |
58 | - // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
59 | - $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
58 | + // now it's possible that $recipient is not an instance of EE_Messages_Addressee in which case we need to see if $this->_data is an instance of $event. |
|
59 | + $event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
60 | 60 | |
61 | - if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | - return ''; |
|
63 | - } |
|
61 | + if (! $recipient instanceof EE_Messages_Addressee && ! $event instanceof EE_Event) { |
|
62 | + return ''; |
|
63 | + } |
|
64 | 64 | |
65 | - switch ($shortcode) { |
|
66 | - case '[EVENT_AUTHOR_FNAME]': |
|
67 | - $fname = ! empty($recipient) ? $recipient->fname : null; |
|
68 | - if (empty($fname) && ! empty($event)) { |
|
69 | - $user = $this->_get_author_for_event($event); |
|
70 | - $fname = $user->first_name; |
|
71 | - } |
|
72 | - return $fname; |
|
73 | - break; |
|
65 | + switch ($shortcode) { |
|
66 | + case '[EVENT_AUTHOR_FNAME]': |
|
67 | + $fname = ! empty($recipient) ? $recipient->fname : null; |
|
68 | + if (empty($fname) && ! empty($event)) { |
|
69 | + $user = $this->_get_author_for_event($event); |
|
70 | + $fname = $user->first_name; |
|
71 | + } |
|
72 | + return $fname; |
|
73 | + break; |
|
74 | 74 | |
75 | - case '[EVENT_AUTHOR_LNAME]': |
|
76 | - $lname = ! empty($recipient) ? $recipient->lname : null; |
|
77 | - if (empty($lname) && ! empty($event)) { |
|
78 | - $user = $this->_get_author_for_event($event); |
|
79 | - $lname = $user->last_name; |
|
80 | - } |
|
81 | - return $lname; |
|
82 | - break; |
|
75 | + case '[EVENT_AUTHOR_LNAME]': |
|
76 | + $lname = ! empty($recipient) ? $recipient->lname : null; |
|
77 | + if (empty($lname) && ! empty($event)) { |
|
78 | + $user = $this->_get_author_for_event($event); |
|
79 | + $lname = $user->last_name; |
|
80 | + } |
|
81 | + return $lname; |
|
82 | + break; |
|
83 | 83 | |
84 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
85 | - if (! empty($recipient)) { |
|
86 | - $email = ! empty($recipient->fname) |
|
87 | - ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
89 | - 'name' |
|
90 | - ) . '<' . $recipient->admin_email . '>'; |
|
91 | - } else { |
|
92 | - $email = null; |
|
93 | - } |
|
94 | - if (empty($email) && ! empty($event)) { |
|
95 | - $user = $this->_get_author_for_event($event); |
|
96 | - $email = ! empty($user->first_name) |
|
97 | - ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
99 | - 'name' |
|
100 | - ) . '<' . $user->user_email . '>'; |
|
101 | - } |
|
102 | - return $email; |
|
103 | - break; |
|
84 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
85 | + if (! empty($recipient)) { |
|
86 | + $email = ! empty($recipient->fname) |
|
87 | + ? $recipient->fname . ' ' . $recipient->lname . '<' . $recipient->admin_email . '>' |
|
88 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
89 | + 'name' |
|
90 | + ) . '<' . $recipient->admin_email . '>'; |
|
91 | + } else { |
|
92 | + $email = null; |
|
93 | + } |
|
94 | + if (empty($email) && ! empty($event)) { |
|
95 | + $user = $this->_get_author_for_event($event); |
|
96 | + $email = ! empty($user->first_name) |
|
97 | + ? $user->first_name . ' ' . $user->last_name . '<' . $user->user_email . '>' |
|
98 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
99 | + 'name' |
|
100 | + ) . '<' . $user->user_email . '>'; |
|
101 | + } |
|
102 | + return $email; |
|
103 | + break; |
|
104 | 104 | |
105 | - case '[EVENT_AUTHOR_EMAIL]': |
|
106 | - $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
107 | - if (empty($email) && ! empty($event)) { |
|
108 | - $user = $this->_get_author_for_event($event); |
|
109 | - $email = $user->user_email; |
|
110 | - } |
|
111 | - return $email; |
|
112 | - break; |
|
105 | + case '[EVENT_AUTHOR_EMAIL]': |
|
106 | + $email = ! empty($recipient) ? $recipient->admin_email : null; |
|
107 | + if (empty($email) && ! empty($event)) { |
|
108 | + $user = $this->_get_author_for_event($event); |
|
109 | + $email = $user->user_email; |
|
110 | + } |
|
111 | + return $email; |
|
112 | + break; |
|
113 | 113 | |
114 | - default: |
|
115 | - return ''; |
|
116 | - break; |
|
117 | - } |
|
118 | - } |
|
114 | + default: |
|
115 | + return ''; |
|
116 | + break; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Helper method to return the user object for the author of the given EE_Event |
|
123 | - * |
|
124 | - * @param EE_Event $event |
|
125 | - * |
|
126 | - * @return WP_User |
|
127 | - */ |
|
128 | - private function _get_author_for_event(EE_Event $event) |
|
129 | - { |
|
130 | - $author_id = $event->wp_user(); |
|
131 | - $user_data = get_userdata((int) $author_id); |
|
132 | - return $user_data; |
|
133 | - } |
|
121 | + /** |
|
122 | + * Helper method to return the user object for the author of the given EE_Event |
|
123 | + * |
|
124 | + * @param EE_Event $event |
|
125 | + * |
|
126 | + * @return WP_User |
|
127 | + */ |
|
128 | + private function _get_author_for_event(EE_Event $event) |
|
129 | + { |
|
130 | + $author_id = $event->wp_user(); |
|
131 | + $user_data = get_userdata((int) $author_id); |
|
132 | + return $user_data; |
|
133 | + } |
|
134 | 134 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | |
88 | 88 | case '[CO_FORMATTED_EMAIL]': |
89 | 89 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
90 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
91 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <' |
|
91 | + . EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
92 | 92 | break; |
93 | 93 | |
94 | 94 | case '[CO_EMAIL]': |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | private function _get_event_admin_emails($fancy_headers = true) |
119 | 119 | { |
120 | 120 | |
121 | - if (! empty($this->_data->admin_email)) { |
|
122 | - if (! $fancy_headers) { |
|
121 | + if ( ! empty($this->_data->admin_email)) { |
|
122 | + if ( ! $fancy_headers) { |
|
123 | 123 | return $this->_data->admin_email; |
124 | 124 | } |
125 | 125 | return ! empty($this->_data->fname) |
126 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
126 | + ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' |
|
127 | 127 | : EE_Registry::instance()->CFG->organization->get_pretty( |
128 | 128 | 'name' |
129 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
129 | + ).' <'.$this->_data->admin_email.'>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | $cnt = 0; |
147 | 147 | foreach ($events as $event) { |
148 | 148 | $user = get_userdata($event->get('EVT_wp_user')); |
149 | - $admin_details[ $cnt ] = new stdClass(); |
|
150 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
151 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
152 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
149 | + $admin_details[$cnt] = new stdClass(); |
|
150 | + $admin_details[$cnt]->email = $user->user_email; |
|
151 | + $admin_details[$cnt]->first_name = $user->user_firstname; |
|
152 | + $admin_details[$cnt]->last_name = $user->user_lastname; |
|
153 | 153 | $cnt++; |
154 | 154 | } |
155 | 155 | |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
172 | - if (! $fancy_headers) { |
|
172 | + if ( ! $fancy_headers) { |
|
173 | 173 | $admin_email[] = $admin->email; |
174 | 174 | continue; |
175 | 175 | } |
176 | 176 | |
177 | 177 | $admin_email[] = ! empty($admin->first_name) |
178 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
179 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | + ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' |
|
179 | + : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $admin_email = implode(',', $admin_email); |
@@ -17,167 +17,167 @@ |
||
17 | 17 | */ |
18 | 18 | class EE_Email_Shortcodes extends EE_Shortcodes |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - parent::__construct(); |
|
23 | - } |
|
24 | - |
|
25 | - |
|
26 | - protected function _init_props() |
|
27 | - { |
|
28 | - $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
29 | - $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
30 | - $this->_shortcodes = array( |
|
31 | - '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
32 | - 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
36 | - esc_html__( |
|
37 | - 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - '<strong>', |
|
41 | - '</strong>' |
|
42 | - ), |
|
43 | - '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
44 | - esc_html__( |
|
45 | - 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
46 | - 'event_espresso' |
|
47 | - ), |
|
48 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
49 | - ), |
|
50 | - '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
51 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[CO_EMAIL]' => esc_html__( |
|
55 | - 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
59 | - 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
63 | - 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - ); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - protected function _parser($shortcode) |
|
71 | - { |
|
72 | - |
|
73 | - switch ($shortcode) { |
|
74 | - case '[SITE_ADMIN_EMAIL]': |
|
75 | - return $this->_get_site_admin_email(); |
|
76 | - break; |
|
77 | - |
|
78 | - case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
79 | - return $this->_get_event_admin_emails(); |
|
80 | - break; |
|
81 | - |
|
82 | - case '[EVENT_AUTHOR_EMAIL]': |
|
83 | - return $this->_get_event_admin_emails(false); |
|
84 | - break; |
|
85 | - |
|
86 | - case '[CO_FORMATTED_EMAIL]': |
|
87 | - case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
88 | - return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
89 | - . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | - break; |
|
91 | - |
|
92 | - case '[CO_EMAIL]': |
|
93 | - case '[ESPRESSO_ADMIN_EMAIL]': |
|
94 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | - break; |
|
96 | - |
|
97 | - default: |
|
98 | - return ''; |
|
99 | - break; |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
106 | - * |
|
107 | - * @access private |
|
108 | - * @return string email address of site admin |
|
109 | - */ |
|
110 | - private function _get_site_admin_email() |
|
111 | - { |
|
112 | - return get_bloginfo('admin_email'); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - private function _get_event_admin_emails($fancy_headers = true) |
|
117 | - { |
|
118 | - |
|
119 | - if (! empty($this->_data->admin_email)) { |
|
120 | - if (! $fancy_headers) { |
|
121 | - return $this->_data->admin_email; |
|
122 | - } |
|
123 | - return ! empty($this->_data->fname) |
|
124 | - ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
125 | - : EE_Registry::instance()->CFG->organization->get_pretty( |
|
126 | - 'name' |
|
127 | - ) . ' <' . $this->_data->admin_email . '>'; |
|
128 | - } |
|
129 | - |
|
130 | - // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
131 | - |
|
132 | - $admin_email = array(); |
|
133 | - |
|
134 | - // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
135 | - foreach ($this->_data->events as $event) { |
|
136 | - $ids[] = $event['ID']; |
|
137 | - } |
|
138 | - |
|
139 | - // get all the events |
|
140 | - $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
141 | - |
|
142 | - // now loop through each event and setup the details |
|
143 | - $admin_details = array(); |
|
144 | - $cnt = 0; |
|
145 | - foreach ($events as $event) { |
|
146 | - $user = get_userdata($event->get('EVT_wp_user')); |
|
147 | - $admin_details[ $cnt ] = new stdClass(); |
|
148 | - $admin_details[ $cnt ]->email = $user->user_email; |
|
149 | - $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
150 | - $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
151 | - $cnt++; |
|
152 | - } |
|
153 | - |
|
154 | - // results? |
|
155 | - if (empty($admin_details) || ! is_array($admin_details)) { |
|
156 | - $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
157 | - $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
158 | - $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
159 | - $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
160 | - $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
161 | - do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
162 | - } |
|
163 | - |
|
164 | - foreach ($admin_details as $admin) { |
|
165 | - // only add an admin email if it is present. |
|
166 | - if (empty($admin->email) || $admin->email == '') { |
|
167 | - continue; |
|
168 | - } |
|
169 | - |
|
170 | - if (! $fancy_headers) { |
|
171 | - $admin_email[] = $admin->email; |
|
172 | - continue; |
|
173 | - } |
|
174 | - |
|
175 | - $admin_email[] = ! empty($admin->first_name) |
|
176 | - ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
177 | - : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | - } |
|
179 | - |
|
180 | - $admin_email = implode(',', $admin_email); |
|
181 | - return $admin_email; |
|
182 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + parent::__construct(); |
|
23 | + } |
|
24 | + |
|
25 | + |
|
26 | + protected function _init_props() |
|
27 | + { |
|
28 | + $this->label = esc_html__('Email Shortcodes', 'event_espresso'); |
|
29 | + $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
|
30 | + $this->_shortcodes = array( |
|
31 | + '[SITE_ADMIN_EMAIL]' => esc_html__( |
|
32 | + 'Will be replaced with the admin email for the site that Event Espresso is installed on', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( |
|
36 | + esc_html__( |
|
37 | + 'This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + '<strong>', |
|
41 | + '</strong>' |
|
42 | + ), |
|
43 | + '[EVENT_AUTHOR_EMAIL]' => sprintf( |
|
44 | + esc_html__( |
|
45 | + 'This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', |
|
46 | + 'event_espresso' |
|
47 | + ), |
|
48 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' |
|
49 | + ), |
|
50 | + '[CO_FORMATTED_EMAIL]' => esc_html__( |
|
51 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[CO_EMAIL]' => esc_html__( |
|
55 | + 'This will parse to the email address only for the organization set in Your Organization Settings.', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__( |
|
59 | + 'This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + '[ESPRESSO_ADMIN_EMAIL]' => esc_html__( |
|
63 | + 'This parses to the email address only for the organization set in Your Organization Settings page.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + ); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + protected function _parser($shortcode) |
|
71 | + { |
|
72 | + |
|
73 | + switch ($shortcode) { |
|
74 | + case '[SITE_ADMIN_EMAIL]': |
|
75 | + return $this->_get_site_admin_email(); |
|
76 | + break; |
|
77 | + |
|
78 | + case '[EVENT_AUTHOR_FORMATTED_EMAIL]': |
|
79 | + return $this->_get_event_admin_emails(); |
|
80 | + break; |
|
81 | + |
|
82 | + case '[EVENT_AUTHOR_EMAIL]': |
|
83 | + return $this->_get_event_admin_emails(false); |
|
84 | + break; |
|
85 | + |
|
86 | + case '[CO_FORMATTED_EMAIL]': |
|
87 | + case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]': |
|
88 | + return EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' |
|
89 | + . EE_Registry::instance()->CFG->organization->get_pretty('email') . '>'; |
|
90 | + break; |
|
91 | + |
|
92 | + case '[CO_EMAIL]': |
|
93 | + case '[ESPRESSO_ADMIN_EMAIL]': |
|
94 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
95 | + break; |
|
96 | + |
|
97 | + default: |
|
98 | + return ''; |
|
99 | + break; |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * This simply returns the site admin email (result for parsing "[SITE_ADMIN_EMAIL]" shortcode) |
|
106 | + * |
|
107 | + * @access private |
|
108 | + * @return string email address of site admin |
|
109 | + */ |
|
110 | + private function _get_site_admin_email() |
|
111 | + { |
|
112 | + return get_bloginfo('admin_email'); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + private function _get_event_admin_emails($fancy_headers = true) |
|
117 | + { |
|
118 | + |
|
119 | + if (! empty($this->_data->admin_email)) { |
|
120 | + if (! $fancy_headers) { |
|
121 | + return $this->_data->admin_email; |
|
122 | + } |
|
123 | + return ! empty($this->_data->fname) |
|
124 | + ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' |
|
125 | + : EE_Registry::instance()->CFG->organization->get_pretty( |
|
126 | + 'name' |
|
127 | + ) . ' <' . $this->_data->admin_email . '>'; |
|
128 | + } |
|
129 | + |
|
130 | + // k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
|
131 | + |
|
132 | + $admin_email = array(); |
|
133 | + |
|
134 | + // loop through events and set the list of event_ids to retrieve so we can do ONE query. |
|
135 | + foreach ($this->_data->events as $event) { |
|
136 | + $ids[] = $event['ID']; |
|
137 | + } |
|
138 | + |
|
139 | + // get all the events |
|
140 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
141 | + |
|
142 | + // now loop through each event and setup the details |
|
143 | + $admin_details = array(); |
|
144 | + $cnt = 0; |
|
145 | + foreach ($events as $event) { |
|
146 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
147 | + $admin_details[ $cnt ] = new stdClass(); |
|
148 | + $admin_details[ $cnt ]->email = $user->user_email; |
|
149 | + $admin_details[ $cnt ]->first_name = $user->user_firstname; |
|
150 | + $admin_details[ $cnt ]->last_name = $user->user_lastname; |
|
151 | + $cnt++; |
|
152 | + } |
|
153 | + |
|
154 | + // results? |
|
155 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
156 | + $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
|
157 | + $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
158 | + $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, true)); |
|
159 | + $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, true)); |
|
160 | + $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
161 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
162 | + } |
|
163 | + |
|
164 | + foreach ($admin_details as $admin) { |
|
165 | + // only add an admin email if it is present. |
|
166 | + if (empty($admin->email) || $admin->email == '') { |
|
167 | + continue; |
|
168 | + } |
|
169 | + |
|
170 | + if (! $fancy_headers) { |
|
171 | + $admin_email[] = $admin->email; |
|
172 | + continue; |
|
173 | + } |
|
174 | + |
|
175 | + $admin_email[] = ! empty($admin->first_name) |
|
176 | + ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' |
|
177 | + : EE_Registry::instance()->CFG->organization->get_pretty('name') . ' <' . $admin->email . '>'; |
|
178 | + } |
|
179 | + |
|
180 | + $admin_email = implode(',', $admin_email); |
|
181 | + return $admin_email; |
|
182 | + } |
|
183 | 183 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | public function __construct($answer_options, $input_settings = array()) |
22 | 22 | { |
23 | 23 | $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
24 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
24 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)))); |
|
25 | 25 | $this->_multiple_selections = true; |
26 | 26 | parent::__construct($answer_options, $input_settings); |
27 | 27 | } |
@@ -14,15 +14,15 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base |
16 | 16 | { |
17 | - /** |
|
18 | - * @param array $input_settings |
|
19 | - * @param array | EE_Question_Option[] $answer_options |
|
20 | - */ |
|
21 | - public function __construct($answer_options, $input_settings = array()) |
|
22 | - { |
|
23 | - $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
24 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
25 | - $this->_multiple_selections = true; |
|
26 | - parent::__construct($answer_options, $input_settings); |
|
27 | - } |
|
17 | + /** |
|
18 | + * @param array $input_settings |
|
19 | + * @param array | EE_Question_Option[] $answer_options |
|
20 | + */ |
|
21 | + public function __construct($answer_options, $input_settings = array()) |
|
22 | + { |
|
23 | + $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
24 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
25 | + $this->_multiple_selections = true; |
|
26 | + parent::__construct($answer_options, $input_settings); |
|
27 | + } |
|
28 | 28 | } |
@@ -19,10 +19,10 @@ |
||
19 | 19 | $key_begin_range = $january_is_month_1 ? 1 : 0; |
20 | 20 | $key_range = range($key_begin_range, $key_begin_range + 11); |
21 | 21 | if ($leading_zero) { |
22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
22 | + array_walk($key_range, array($this, '_zero_pad')); |
|
23 | 23 | } |
24 | 24 | $value_range = range(1, 12); |
25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
25 | + array_walk($value_range, array($this, '_zero_pad')); |
|
26 | 26 | parent::__construct( |
27 | 27 | array_combine( |
28 | 28 | $key_range, |
@@ -9,36 +9,36 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Month_Input extends EE_Select_Input |
11 | 11 | { |
12 | - /** |
|
13 | - * @param bool $leading_zero |
|
14 | - * @param array $input_settings |
|
15 | - * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
16 | - */ |
|
17 | - public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
18 | - { |
|
19 | - $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
20 | - $key_range = range($key_begin_range, $key_begin_range + 11); |
|
21 | - if ($leading_zero) { |
|
22 | - array_walk($key_range, array( $this, '_zero_pad' )); |
|
23 | - } |
|
24 | - $value_range = range(1, 12); |
|
25 | - array_walk($value_range, array( $this, '_zero_pad' )); |
|
26 | - parent::__construct( |
|
27 | - array_combine( |
|
28 | - $key_range, |
|
29 | - $value_range |
|
30 | - ), |
|
31 | - $input_settings |
|
32 | - ); |
|
33 | - } |
|
12 | + /** |
|
13 | + * @param bool $leading_zero |
|
14 | + * @param array $input_settings |
|
15 | + * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0 |
|
16 | + */ |
|
17 | + public function __construct($leading_zero = false, $input_settings = array(), $january_is_month_1 = true) |
|
18 | + { |
|
19 | + $key_begin_range = $january_is_month_1 ? 1 : 0; |
|
20 | + $key_range = range($key_begin_range, $key_begin_range + 11); |
|
21 | + if ($leading_zero) { |
|
22 | + array_walk($key_range, array( $this, '_zero_pad' )); |
|
23 | + } |
|
24 | + $value_range = range(1, 12); |
|
25 | + array_walk($value_range, array( $this, '_zero_pad' )); |
|
26 | + parent::__construct( |
|
27 | + array_combine( |
|
28 | + $key_range, |
|
29 | + $value_range |
|
30 | + ), |
|
31 | + $input_settings |
|
32 | + ); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Changes int 1 to 01, etc. Useful with array_walk |
|
37 | - * @param int $input |
|
38 | - * @param mixed $key |
|
39 | - */ |
|
40 | - protected function _zero_pad(&$input, $key) |
|
41 | - { |
|
42 | - $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
43 | - } |
|
35 | + /** |
|
36 | + * Changes int 1 to 01, etc. Useful with array_walk |
|
37 | + * @param int $input |
|
38 | + * @param mixed $key |
|
39 | + */ |
|
40 | + protected function _zero_pad(&$input, $key) |
|
41 | + { |
|
42 | + $input = str_pad($input, 2, '0', STR_PAD_LEFT); |
|
43 | + } |
|
44 | 44 | } |
@@ -55,11 +55,11 @@ |
||
55 | 55 | $select_options = array(); |
56 | 56 | foreach ($answer_options as $model_obj) { |
57 | 57 | if ($this->_naming_method) { |
58 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | + $display_value = call_user_func(array($model_obj, $this->_naming_method)); |
|
59 | 59 | } else { |
60 | 60 | $display_value = $model_obj->name(); |
61 | 61 | } |
62 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | + $select_options[$model_obj->ID()] = $display_value; |
|
63 | 63 | } |
64 | 64 | parent::set_select_options($select_options); |
65 | 65 | } |
@@ -11,75 +11,75 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Select_Multi_Model_Input extends EE_Select_Multiple_Input |
13 | 13 | { |
14 | - protected $_naming_method; |
|
14 | + protected $_naming_method; |
|
15 | 15 | |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * |
|
20 | - * @param EE_Base_Class[] $answer_options |
|
21 | - * @param array $input_settings { |
|
22 | - * @var EE_Base_Class[] or array $default |
|
23 | - * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
24 | - * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
25 | - * } |
|
26 | - */ |
|
27 | - public function __construct($answer_options = array(), $input_settings = array()) |
|
28 | - { |
|
29 | - if (isset($input_settings['naming_method'])) { |
|
30 | - $this->set_option_naming_method($input_settings['naming_method']); |
|
31 | - } |
|
32 | - parent::__construct($answer_options, $input_settings); |
|
33 | - } |
|
18 | + /** |
|
19 | + * |
|
20 | + * @param EE_Base_Class[] $answer_options |
|
21 | + * @param array $input_settings { |
|
22 | + * @var EE_Base_Class[] or array $default |
|
23 | + * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
24 | + * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
25 | + * } |
|
26 | + */ |
|
27 | + public function __construct($answer_options = array(), $input_settings = array()) |
|
28 | + { |
|
29 | + if (isset($input_settings['naming_method'])) { |
|
30 | + $this->set_option_naming_method($input_settings['naming_method']); |
|
31 | + } |
|
32 | + parent::__construct($answer_options, $input_settings); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Sets the method name which will be called when outputting the options list |
|
37 | - * @param string $method |
|
38 | - */ |
|
39 | - public function set_option_naming_method($method) |
|
40 | - { |
|
41 | - $this->_naming_method = $method; |
|
42 | - } |
|
35 | + /** |
|
36 | + * Sets the method name which will be called when outputting the options list |
|
37 | + * @param string $method |
|
38 | + */ |
|
39 | + public function set_option_naming_method($method) |
|
40 | + { |
|
41 | + $this->_naming_method = $method; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * You CAN pass an array of model objects instead of simple values for teh options |
|
48 | - * @param EE_Base_Class[] $answer_options |
|
49 | - * @return null|void |
|
50 | - */ |
|
51 | - public function set_select_options($answer_options = array()) |
|
52 | - { |
|
53 | - // convert the model objects to select from into normal select options |
|
54 | - $select_options = array(); |
|
55 | - foreach ($answer_options as $model_obj) { |
|
56 | - if ($this->_naming_method) { |
|
57 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | - } else { |
|
59 | - $display_value = $model_obj->name(); |
|
60 | - } |
|
61 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | - } |
|
63 | - parent::set_select_options($select_options); |
|
64 | - } |
|
46 | + /** |
|
47 | + * You CAN pass an array of model objects instead of simple values for teh options |
|
48 | + * @param EE_Base_Class[] $answer_options |
|
49 | + * @return null|void |
|
50 | + */ |
|
51 | + public function set_select_options($answer_options = array()) |
|
52 | + { |
|
53 | + // convert the model objects to select from into normal select options |
|
54 | + $select_options = array(); |
|
55 | + foreach ($answer_options as $model_obj) { |
|
56 | + if ($this->_naming_method) { |
|
57 | + $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
58 | + } else { |
|
59 | + $display_value = $model_obj->name(); |
|
60 | + } |
|
61 | + $select_options[ $model_obj->ID() ] = $display_value; |
|
62 | + } |
|
63 | + parent::set_select_options($select_options); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * if they passed in an array of model objects for the default, convert it |
|
70 | - * into the format EE_Select_Multiple expects |
|
71 | - * @param EE_Base_Class[]|array $values |
|
72 | - */ |
|
73 | - public function set_default($values) |
|
74 | - { |
|
75 | - $defaults_as_simple_ids = array(); |
|
76 | - foreach ($values as $key => $value) { |
|
77 | - if ($value instanceof EE_Base_Class) { |
|
78 | - $defaults_as_simple_ids[] = $value->ID(); |
|
79 | - } else { |
|
80 | - $defaults_as_simple_ids[] = $value; |
|
81 | - } |
|
82 | - } |
|
83 | - parent::set_default($defaults_as_simple_ids); |
|
84 | - } |
|
68 | + /** |
|
69 | + * if they passed in an array of model objects for the default, convert it |
|
70 | + * into the format EE_Select_Multiple expects |
|
71 | + * @param EE_Base_Class[]|array $values |
|
72 | + */ |
|
73 | + public function set_default($values) |
|
74 | + { |
|
75 | + $defaults_as_simple_ids = array(); |
|
76 | + foreach ($values as $key => $value) { |
|
77 | + if ($value instanceof EE_Base_Class) { |
|
78 | + $defaults_as_simple_ids[] = $value->ID(); |
|
79 | + } else { |
|
80 | + $defaults_as_simple_ids[] = $value; |
|
81 | + } |
|
82 | + } |
|
83 | + parent::set_default($defaults_as_simple_ids); |
|
84 | + } |
|
85 | 85 | } |
@@ -136,17 +136,17 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private function addIframeAssets(array $localized_vars) |
138 | 138 | { |
139 | - if (! $this->useCaptcha()) { |
|
139 | + if ( ! $this->useCaptcha()) { |
|
140 | 140 | return; |
141 | 141 | } |
142 | 142 | add_filter( |
143 | 143 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
144 | - function (array $iframe_assets) { |
|
145 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
144 | + function(array $iframe_assets) { |
|
145 | + $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA] = |
|
146 | 146 | EED_Recaptcha_Invisible::assetsUrl() |
147 | 147 | . 'espresso_invisible_recaptcha.js?ver=' |
148 | 148 | . EVENT_ESPRESSO_VERSION; |
149 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
149 | + $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] = |
|
150 | 150 | add_query_arg( |
151 | 151 | array( |
152 | 152 | 'onload' => 'espressoLoadRecaptcha', |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | ); |
161 | 161 | add_filter( |
162 | 162 | 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
163 | - function (array $iframe_asset_attributes) { |
|
164 | - $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
163 | + function(array $iframe_asset_attributes) { |
|
164 | + $iframe_asset_attributes[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] |
|
165 | 165 | = ' async="async" defer="defer"'; |
166 | 166 | return $iframe_asset_attributes; |
167 | 167 | } |
168 | 168 | ); |
169 | 169 | add_action( |
170 | 170 | 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
171 | - function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
171 | + function(EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
172 | 172 | $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
173 | 173 | } |
174 | 174 | ); |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | */ |
181 | 181 | private function registerScripts() |
182 | 182 | { |
183 | - if (! $this->useCaptcha()) { |
|
183 | + if ( ! $this->useCaptcha()) { |
|
184 | 184 | return; |
185 | 185 | } |
186 | 186 | add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
187 | 187 | wp_register_script( |
188 | 188 | EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
189 | - EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
189 | + EED_Recaptcha_Invisible::assetsUrl().'espresso_invisible_recaptcha.js', |
|
190 | 190 | array('espresso_core'), |
191 | 191 | EVENT_ESPRESSO_VERSION, |
192 | 192 | true |
@@ -14,222 +14,222 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Invisible_Recaptcha_Input extends EE_Form_Input_Base |
16 | 16 | { |
17 | - const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA = 'google_invisible_recaptcha'; |
|
18 | - |
|
19 | - const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha'; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var EE_Registration_Config $config |
|
23 | - */ |
|
24 | - private $config; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var string $recaptcha_id |
|
28 | - */ |
|
29 | - private $recaptcha_id; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string $submit_button_id |
|
33 | - */ |
|
34 | - private $submit_button_id; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param array $input_settings |
|
39 | - * @param EE_Registration_Config $registration_config |
|
40 | - * @throws InvalidArgumentException |
|
41 | - * @throws InvalidDataTypeException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws DomainException |
|
44 | - */ |
|
45 | - public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null) |
|
46 | - { |
|
47 | - $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy()); |
|
48 | - parent::__construct($input_settings); |
|
49 | - $registration_config = $registration_config instanceof EE_Registration_Config |
|
50 | - ? $registration_config |
|
51 | - : EE_Registry::instance()->CFG->registration; |
|
52 | - $this->config = $registration_config; |
|
53 | - $this->recaptcha_id = isset($input_settings['recaptcha_id']) |
|
54 | - ? $input_settings['recaptcha_id'] |
|
55 | - : substr(spl_object_hash($this), 8, 8); |
|
56 | - $this->submit_button_id = isset($input_settings['submit_button_id']) |
|
57 | - ? $input_settings['submit_button_id'] |
|
58 | - : ''; |
|
59 | - if ( |
|
60 | - isset($input_settings['localized_vars']) |
|
61 | - && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN) |
|
62 | - ) { |
|
63 | - $this->addIframeAssets($input_settings['localized_vars']); |
|
64 | - } else { |
|
65 | - $this->registerScripts(); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return bool |
|
72 | - */ |
|
73 | - public function useCaptcha() |
|
74 | - { |
|
75 | - return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function badge() |
|
83 | - { |
|
84 | - return $this->config->recaptcha_badge; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function language() |
|
92 | - { |
|
93 | - return $this->config->recaptcha_language; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function siteKey() |
|
101 | - { |
|
102 | - return $this->config->recaptcha_publickey; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function secretKey() |
|
110 | - { |
|
111 | - return $this->config->recaptcha_privatekey; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function recaptchaId() |
|
119 | - { |
|
120 | - return $this->recaptcha_id; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function submitButtonId() |
|
128 | - { |
|
129 | - return $this->submit_button_id; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @param array $localized_vars |
|
135 | - * @throws DomainException |
|
136 | - */ |
|
137 | - private function addIframeAssets(array $localized_vars) |
|
138 | - { |
|
139 | - if (! $this->useCaptcha()) { |
|
140 | - return; |
|
141 | - } |
|
142 | - add_filter( |
|
143 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
144 | - function (array $iframe_assets) { |
|
145 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
146 | - EED_Recaptcha_Invisible::assetsUrl() |
|
147 | - . 'espresso_invisible_recaptcha.js?ver=' |
|
148 | - . EVENT_ESPRESSO_VERSION; |
|
149 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
150 | - add_query_arg( |
|
151 | - array( |
|
152 | - 'onload' => 'espressoLoadRecaptcha', |
|
153 | - 'render' => 'explicit', |
|
154 | - 'hl' => $this->language(), |
|
155 | - ), |
|
156 | - 'https://www.google.com/recaptcha/api.js?' |
|
157 | - ); |
|
158 | - return $iframe_assets; |
|
159 | - } |
|
160 | - ); |
|
161 | - add_filter( |
|
162 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
163 | - function (array $iframe_asset_attributes) { |
|
164 | - $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
165 | - = ' async="async" defer="defer"'; |
|
166 | - return $iframe_asset_attributes; |
|
167 | - } |
|
168 | - ); |
|
169 | - add_action( |
|
170 | - 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
171 | - function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
172 | - $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
|
173 | - } |
|
174 | - ); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @return void |
|
180 | - */ |
|
181 | - private function registerScripts() |
|
182 | - { |
|
183 | - if (! $this->useCaptcha()) { |
|
184 | - return; |
|
185 | - } |
|
186 | - add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
|
187 | - wp_register_script( |
|
188 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
189 | - EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
190 | - array('espresso_core'), |
|
191 | - EVENT_ESPRESSO_VERSION, |
|
192 | - true |
|
193 | - ); |
|
194 | - wp_register_script( |
|
195 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA, |
|
196 | - add_query_arg( |
|
197 | - array( |
|
198 | - 'onload' => 'espressoLoadRecaptcha', |
|
199 | - 'render' => 'explicit', |
|
200 | - 'hl' => $this->language(), |
|
201 | - ), |
|
202 | - 'https://www.google.com/recaptcha/api.js?' |
|
203 | - ), |
|
204 | - array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA), |
|
205 | - false, |
|
206 | - true |
|
207 | - ); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @param string $tag |
|
213 | - * @param string $handle |
|
214 | - * @return string |
|
215 | - */ |
|
216 | - public function addScriptAttributes($tag, $handle) |
|
217 | - { |
|
218 | - if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) { |
|
219 | - $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag); |
|
220 | - } |
|
221 | - return $tag; |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - /** |
|
226 | - * Gets the HTML for displaying the label for this form input |
|
227 | - * according to the form section's layout strategy |
|
228 | - * |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - public function get_html_for_label() |
|
232 | - { |
|
233 | - return ''; |
|
234 | - } |
|
17 | + const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA = 'google_invisible_recaptcha'; |
|
18 | + |
|
19 | + const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha'; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var EE_Registration_Config $config |
|
23 | + */ |
|
24 | + private $config; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var string $recaptcha_id |
|
28 | + */ |
|
29 | + private $recaptcha_id; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string $submit_button_id |
|
33 | + */ |
|
34 | + private $submit_button_id; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param array $input_settings |
|
39 | + * @param EE_Registration_Config $registration_config |
|
40 | + * @throws InvalidArgumentException |
|
41 | + * @throws InvalidDataTypeException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws DomainException |
|
44 | + */ |
|
45 | + public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null) |
|
46 | + { |
|
47 | + $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy()); |
|
48 | + parent::__construct($input_settings); |
|
49 | + $registration_config = $registration_config instanceof EE_Registration_Config |
|
50 | + ? $registration_config |
|
51 | + : EE_Registry::instance()->CFG->registration; |
|
52 | + $this->config = $registration_config; |
|
53 | + $this->recaptcha_id = isset($input_settings['recaptcha_id']) |
|
54 | + ? $input_settings['recaptcha_id'] |
|
55 | + : substr(spl_object_hash($this), 8, 8); |
|
56 | + $this->submit_button_id = isset($input_settings['submit_button_id']) |
|
57 | + ? $input_settings['submit_button_id'] |
|
58 | + : ''; |
|
59 | + if ( |
|
60 | + isset($input_settings['localized_vars']) |
|
61 | + && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN) |
|
62 | + ) { |
|
63 | + $this->addIframeAssets($input_settings['localized_vars']); |
|
64 | + } else { |
|
65 | + $this->registerScripts(); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return bool |
|
72 | + */ |
|
73 | + public function useCaptcha() |
|
74 | + { |
|
75 | + return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function badge() |
|
83 | + { |
|
84 | + return $this->config->recaptcha_badge; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function language() |
|
92 | + { |
|
93 | + return $this->config->recaptcha_language; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function siteKey() |
|
101 | + { |
|
102 | + return $this->config->recaptcha_publickey; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function secretKey() |
|
110 | + { |
|
111 | + return $this->config->recaptcha_privatekey; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function recaptchaId() |
|
119 | + { |
|
120 | + return $this->recaptcha_id; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function submitButtonId() |
|
128 | + { |
|
129 | + return $this->submit_button_id; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @param array $localized_vars |
|
135 | + * @throws DomainException |
|
136 | + */ |
|
137 | + private function addIframeAssets(array $localized_vars) |
|
138 | + { |
|
139 | + if (! $this->useCaptcha()) { |
|
140 | + return; |
|
141 | + } |
|
142 | + add_filter( |
|
143 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
144 | + function (array $iframe_assets) { |
|
145 | + $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
146 | + EED_Recaptcha_Invisible::assetsUrl() |
|
147 | + . 'espresso_invisible_recaptcha.js?ver=' |
|
148 | + . EVENT_ESPRESSO_VERSION; |
|
149 | + $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
150 | + add_query_arg( |
|
151 | + array( |
|
152 | + 'onload' => 'espressoLoadRecaptcha', |
|
153 | + 'render' => 'explicit', |
|
154 | + 'hl' => $this->language(), |
|
155 | + ), |
|
156 | + 'https://www.google.com/recaptcha/api.js?' |
|
157 | + ); |
|
158 | + return $iframe_assets; |
|
159 | + } |
|
160 | + ); |
|
161 | + add_filter( |
|
162 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
163 | + function (array $iframe_asset_attributes) { |
|
164 | + $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
165 | + = ' async="async" defer="defer"'; |
|
166 | + return $iframe_asset_attributes; |
|
167 | + } |
|
168 | + ); |
|
169 | + add_action( |
|
170 | + 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
171 | + function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
172 | + $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
|
173 | + } |
|
174 | + ); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @return void |
|
180 | + */ |
|
181 | + private function registerScripts() |
|
182 | + { |
|
183 | + if (! $this->useCaptcha()) { |
|
184 | + return; |
|
185 | + } |
|
186 | + add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
|
187 | + wp_register_script( |
|
188 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
189 | + EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
190 | + array('espresso_core'), |
|
191 | + EVENT_ESPRESSO_VERSION, |
|
192 | + true |
|
193 | + ); |
|
194 | + wp_register_script( |
|
195 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA, |
|
196 | + add_query_arg( |
|
197 | + array( |
|
198 | + 'onload' => 'espressoLoadRecaptcha', |
|
199 | + 'render' => 'explicit', |
|
200 | + 'hl' => $this->language(), |
|
201 | + ), |
|
202 | + 'https://www.google.com/recaptcha/api.js?' |
|
203 | + ), |
|
204 | + array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA), |
|
205 | + false, |
|
206 | + true |
|
207 | + ); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @param string $tag |
|
213 | + * @param string $handle |
|
214 | + * @return string |
|
215 | + */ |
|
216 | + public function addScriptAttributes($tag, $handle) |
|
217 | + { |
|
218 | + if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) { |
|
219 | + $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag); |
|
220 | + } |
|
221 | + return $tag; |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + /** |
|
226 | + * Gets the HTML for displaying the label for this form input |
|
227 | + * according to the form section's layout strategy |
|
228 | + * |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + public function get_html_for_label() |
|
232 | + { |
|
233 | + return ''; |
|
234 | + } |
|
235 | 235 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | public function __construct($answer_options, $input_settings = array()) |
17 | 17 | { |
18 | 18 | $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)))); |
|
20 | 20 | $this->_multiple_selections = true; |
21 | 21 | parent::__construct($answer_options, $input_settings); |
22 | 22 | } |
@@ -9,15 +9,15 @@ |
||
9 | 9 | */ |
10 | 10 | class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base |
11 | 11 | { |
12 | - /** |
|
13 | - * @param array | EE_Question_Option[] $answer_options |
|
14 | - * @param array $input_settings |
|
15 | - */ |
|
16 | - public function __construct($answer_options, $input_settings = array()) |
|
17 | - { |
|
18 | - $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
20 | - $this->_multiple_selections = true; |
|
21 | - parent::__construct($answer_options, $input_settings); |
|
22 | - } |
|
12 | + /** |
|
13 | + * @param array | EE_Question_Option[] $answer_options |
|
14 | + * @param array $input_settings |
|
15 | + */ |
|
16 | + public function __construct($answer_options, $input_settings = array()) |
|
17 | + { |
|
18 | + $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
20 | + $this->_multiple_selections = true; |
|
21 | + parent::__construct($answer_options, $input_settings); |
|
22 | + } |
|
23 | 23 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | } |
22 | 22 | $answer_options = array(); |
23 | 23 | for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
24 | - $answer_options[ $start ] = $start; |
|
24 | + $answer_options[$start] = $start; |
|
25 | 25 | } |
26 | 26 | parent::__construct($answer_options, $input_settings); |
27 | 27 | } |
@@ -11,17 +11,17 @@ |
||
11 | 11 | */ |
12 | 12 | class EE_Year_Input extends EE_Select_Input |
13 | 13 | { |
14 | - public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) |
|
15 | - { |
|
16 | - if ($four_digit_year) { |
|
17 | - $current_year_int = intval(date('Y')); |
|
18 | - } else { |
|
19 | - $current_year_int = intval(date('y')); |
|
20 | - } |
|
21 | - $answer_options = array(); |
|
22 | - for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
23 | - $answer_options[ $start ] = $start; |
|
24 | - } |
|
25 | - parent::__construct($answer_options, $input_settings); |
|
26 | - } |
|
14 | + public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) |
|
15 | + { |
|
16 | + if ($four_digit_year) { |
|
17 | + $current_year_int = intval(date('Y')); |
|
18 | + } else { |
|
19 | + $current_year_int = intval(date('y')); |
|
20 | + } |
|
21 | + $answer_options = array(); |
|
22 | + for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
23 | + $answer_options[ $start ] = $start; |
|
24 | + } |
|
25 | + parent::__construct($answer_options, $input_settings); |
|
26 | + } |
|
27 | 27 | } |