PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.5.13
GiveWP – Donation Plugin and Fundraising Platform v2.5.13
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / filters.php
give / includes Last commit date
admin 6 years ago api 6 years ago database 6 years ago deprecated 6 years ago donors 6 years ago emails 6 years ago forms 6 years ago frontend 7 years ago gateways 6 years ago libraries 7 years ago payments 6 years ago actions.php 6 years ago ajax-functions.php 6 years ago class-give-async-process.php 7 years ago class-give-background-updater.php 6 years ago class-give-cache-setting.php 6 years ago class-give-cache.php 6 years ago class-give-cli-commands.php 6 years ago class-give-comment.php 7 years ago class-give-cron.php 6 years ago class-give-donate-form.php 6 years ago class-give-donor-wall-widget.php 6 years ago class-give-donor.php 6 years ago class-give-email-access.php 7 years ago class-give-license-handler.php 6 years ago class-give-logging.php 7 years ago class-give-readme-parser.php 7 years ago class-give-roles.php 6 years ago class-give-scripts.php 6 years ago class-give-session.php 6 years ago class-give-stats.php 7 years ago class-give-template-loader.php 8 years ago class-give-tooltips.php 7 years ago class-give-translation.php 8 years ago class-notices.php 6 years ago country-functions.php 6 years ago currencies-list.php 6 years ago currency-functions.php 6 years ago error-tracking.php 7 years ago filters.php 7 years ago formatting.php 6 years ago install.php 6 years ago login-register.php 7 years ago misc-functions.php 6 years ago plugin-compatibility.php 6 years ago post-types.php 6 years ago price-functions.php 7 years ago process-donation.php 6 years ago setting-functions.php 6 years ago shortcodes.php 6 years ago template-functions.php 6 years ago user-functions.php 6 years ago
filters.php
271 lines
1 <?php
2 /**
3 * Front-end Filters
4 *
5 * @package Give
6 * @subpackage Functions
7 * @copyright Copyright (c) 2016, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17
18 /**
19 * Add backward compatibility for settings who has disable_ as name prefix.
20 * TODO: Remove this backward compatibility when do not need.
21 *
22 * @since 1.8
23 *
24 * @param array $old_settings Array of settings.
25 * @param array $settings Array of settings.
26 *
27 * @return void
28 */
29 function give_set_settings_with_disable_prefix( $old_settings, $settings ) {
30 // Bailout.
31 if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) {
32 return;
33 }
34
35 // Get old setting names.
36 $old_settings = array_flip( give_v18_renamed_core_settings() );
37 $update_setting = false;
38
39 foreach ( $settings as $key => $value ) {
40
41 // Check 1. Check if new option is really updated or not.
42 // Check 2. Continue if key is not renamed.
43 if ( ! isset( $old_settings[ $key ] ) ) {
44 continue;
45 }
46
47 // Set old setting.
48 $settings[ $old_settings[ $key ] ] = 'on';
49
50 // Do not need to set old setting if new setting is not set.
51 if (
52 ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) )
53 || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) )
54
55 ) {
56 unset( $settings[ $old_settings[ $key ] ] );
57 }
58
59 // Tell bot to update setting.
60 $update_setting = true;
61 }
62
63 // Update setting if any old setting set.
64 if ( $update_setting ) {
65 update_option( 'give_settings', $settings, false );
66 }
67 }
68
69 add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );
70
71 /**
72 * Check spam through Akismet.
73 *
74 * It will build Akismet query string and call Akismet API.
75 * Akismet response return 'true' for spam donation.
76 *
77 * @since 1.8.14
78 *
79 * @param $spam
80 *
81 * @return bool|mixed
82 */
83 function give_akismet( $spam ) {
84
85 // Bail out, If spam.
86 if ( $spam ) {
87 return $spam;
88 }
89
90 // Bail out, if Akismet key not exist.
91 if ( ! give_check_akismet_key() ) {
92 return false;
93 }
94
95 // Build args array.
96 $args = array();
97
98 $args['comment_author'] = isset( $_POST['give_first'] ) ? give_clean( $_POST['give_first'] ) : '';
99 $args['comment_author_email'] = isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : false;
100 $args['blog'] = get_option( 'home' );
101 $args['blog_lang'] = get_locale();
102 $args['blog_charset'] = get_option( 'blog_charset' );
103 $args['user_ip'] = $_SERVER['REMOTE_ADDR'];
104 $args['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
105 $args['referrer'] = $_SERVER['HTTP_REFERER'];
106 $args['comment_type'] = 'contact-form';
107
108 $form_id = isset( $_POST['give-form-id'] ) ? absint( $_POST['give-form-id'] ) : 0;
109
110 // Pass Donor comment if enabled.
111 if ( give_is_donor_comment_field_enabled( $form_id ) ) {
112 $give_comment = isset( $_POST['give_comment'] ) ? give_clean( $_POST['give_comment'] ) : '';
113
114 $args['comment_content'] = $give_comment;
115 }
116
117 $ignore = array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' );
118
119 foreach ( $_SERVER as $key => $value ) {
120 if ( ! in_array( $key, (array) $ignore ) ) {
121 $args["$key"] = $value;
122 }
123 }
124
125 // It will return Akismet spam detect API response.
126 return give_akismet_spam_check( $args );
127
128 }
129
130 add_filter( 'give_spam', 'give_akismet' );
131
132 /**
133 * Check Akismet API Key.
134 *
135 * @since 1.8.14
136 *
137 * @return bool
138 */
139 function give_check_akismet_key() {
140 if ( is_callable( array( 'Akismet', 'get_api_key' ) ) ) { // Akismet v3.0+
141 return (bool) Akismet::get_api_key();
142 }
143
144 if ( function_exists( 'akismet_get_key' ) ) {
145 return (bool) akismet_get_key();
146 }
147
148 return false;
149 }
150
151 /**
152 * Detect spam through Akismet Comment API.
153 *
154 * @since 1.8.14
155 *
156 * @param array $args
157 *
158 * @return bool|mixed
159 */
160 function give_akismet_spam_check( $args ) {
161 global $akismet_api_host, $akismet_api_port;
162
163 $spam = false;
164 $query_string = http_build_query( $args );
165
166 if ( is_callable( array( 'Akismet', 'http_post' ) ) ) { // Akismet v3.0+
167 $response = Akismet::http_post( $query_string, 'comment-check' );
168 } else {
169 $response = akismet_http_post( $query_string, $akismet_api_host,
170 '/1.1/comment-check', $akismet_api_port );
171 }
172
173 // It's spam if response status is true.
174 if ( 'true' === $response[1] ) {
175 $spam = true;
176 }
177
178 // Allow developer to modified Akismet spam detection response.
179 return apply_filters( 'give_akismet_spam_check', $spam, $args );
180 }
181
182 /**
183 * Add support of RIAL code for backward compatibility.
184 * Note: for internal use only
185 *
186 * @since 1.8.17
187 *
188 * @param array $currencies
189 *
190 * @return array
191 */
192 function give_bc_v1817_iranian_currency_code( $currencies ) {
193 $currencies['RIAL'] = $currencies['IRR'];
194
195 return $currencies;
196 }
197
198 if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) {
199 add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 );
200 }
201
202
203 /**
204 * Format right to left supported currency amount.
205 *
206 * @since 1.8.17
207 *
208 * @param $formatted_amount
209 * @param $currency_args
210 * @param $price
211 *
212 * @return string
213 */
214 function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) {
215 if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) {
216 return $formatted_amount;
217 }
218
219 $formatted_amount = (
220 'before' === (string) $currency_args['position'] ?
221 '&#x202B;' . $price . $currency_args['symbol'] . '&#x202C;' :
222 '&#x202A;' . $price . $currency_args['symbol'] . '&#x202C;'
223 );
224
225 $formatted_amount = $currency_args['decode_currency'] ?
226 html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) :
227 $formatted_amount;
228
229 return $formatted_amount;
230 }
231
232 add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 );
233
234 /**
235 * Validate active gateway value before returning result.
236 *
237 * @since 2.1.0
238 *
239 * @param $value
240 *
241 * @return array
242 */
243 function __give_validate_active_gateways( $value ) {
244 $gateways = array_keys( give_get_payment_gateways() );
245 $active_gateways = is_array( $value ) ? array_keys( $value ) : array();
246
247 // Remove deactivated payment gateways.
248 if( ! empty( $active_gateways ) ) {
249 foreach ( $active_gateways as $index => $gateway_id ) {
250 if( ! in_array( $gateway_id, $gateways ) ) {
251 unset( $value[$gateway_id] );
252 }
253 }
254 }
255
256 if ( empty( $value ) ) {
257 /**
258 * Filter the default active gateway
259 *
260 * @since 2.1.0
261 */
262 $value = apply_filters( 'give_default_active_gateways', array(
263 'manual' => 1,
264 ) );
265 }
266
267 return $value;
268 }
269
270 add_filter( 'give_get_option_gateways', '__give_validate_active_gateways', 10, 1 );
271