$73 GRAYBYTE WORDPRESS FILE MANAGER $69

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.43.35 | ADMIN IP 216.73.216.157
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravrvjk/itiministry.org/wp-content/plugins/give/includes/

HOME
Current File : /home/bravrvjk/itiministry.org/wp-content/plugins/give/includes//filters.php
<?php

use Give\Log\Log;
use Give\Framework\Database\DB;
use Give\Log\ValueObjects\LogType;
/**
 * Front-end Filters
 *
 * @package     Give
 * @subpackage  Functions
 * @copyright   Copyright (c) 2016, GiveWP
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
 * @since       1.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}


/**
 * Add backward compatibility for settings who has disable_ as name prefix.
 * TODO: Remove this backward compatibility when do not need.
 *
 * @since  1.8
 *
 * @param  array $old_settings Array of settings.
 * @param  array $settings     Array of settings.
 *
 * @return void
 */
function give_set_settings_with_disable_prefix( $old_settings, $settings ) {
	// Bailout.
	if ( ! function_exists( 'give_v18_renamed_core_settings' ) ) {
		return;
	}

	// Get old setting names.
	$old_settings   = array_flip( give_v18_renamed_core_settings() );
	$update_setting = false;

	foreach ( $settings as $key => $value ) {

		// Check 1. Check if new option is really updated or not.
		// Check 2. Continue if key is not renamed.
		if ( ! isset( $old_settings[ $key ] ) ) {
			continue;
		}

		// Set old setting.
		$settings[ $old_settings[ $key ] ] = 'on';

		// Do not need to set old setting if new setting is not set.
		if (
			( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) )
			|| ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) )

		) {
			unset( $settings[ $old_settings[ $key ] ] );
		}

		// Tell bot to update setting.
		$update_setting = true;
	}

	// Update setting if any old setting set.
	if ( $update_setting ) {
		update_option( 'give_settings', $settings, false );
	}
}

add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );

/**
 * Check spam through Akismet.
 *
 * It will build Akismet query string and call Akismet API.
 * Akismet response return 'true' for spam donation.
 *
 * @since 1.8.14
 *
 * @param $spam
 *
 * @return bool|mixed
 */
function give_akismet( $spam ) {
	// Build args array.
	$args = [];

	// Bail out, If spam.
	if ( $spam || ! give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) ) {
		return $spam;
	}

	// Bail out, if Akismet key not exist.
	if ( ! give_check_akismet_key() ) {
		return false;
	}

	$args['comment_author_email'] = isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : false;

	/**
	 * Filter list of whitelisted emails
	 *
	 * @since 2.5.14
	 *
	 * @param array
	 */
	$whitelist_emails = apply_filters( 'give_akismet_whitelist_emails', give_akismet_get_whitelisted_emails() );

	// Whitelist emails.
	if ( in_array( $args['comment_author_email'], (array) $whitelist_emails, true ) ) {
		return false;
	}

	$args['comment_author'] = isset( $_POST['give_first'] ) ? give_clean( $_POST['give_first'] ) : '';
	$args['blog']           = get_option( 'home' );
	$args['blog_lang']      = get_locale();
	$args['blog_charset']   = get_option( 'blog_charset' );
	$args['user_ip']        = $_SERVER['REMOTE_ADDR'];
	$args['user_agent']     = $_SERVER['HTTP_USER_AGENT'];
	$args['referrer']       = $_SERVER['HTTP_REFERER'];
	$args['comment_type']   = 'contact-form';

	$form_id         = isset( $_POST['give-form-id'] ) ? absint( $_POST['give-form-id'] ) : 0;
	$donor_last_name = ! empty( $_POST['give_last'] ) ? ' ' . give_clean( $_POST['give_last'] ) : '';

	// Pass Donor comment if enabled.
	if ( give_is_donor_comment_field_enabled( $form_id ) ) {
		$give_comment = isset( $_POST['give_comment'] ) ? give_clean( $_POST['give_comment'] ) : '';

		$args['comment_content'] = $give_comment;
	}

	$ignore = [ 'HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW' ];

	foreach ( $_SERVER as $key => $value ) {
		if ( ! in_array( $key, $ignore, true ) ) {
			$args[ $key ] = $value;
		}
	}

	$response = give_akismet_spam_check_post( $args );
	$spam     = 'true' === $response[1];

	// Log spam information.
	if ( $spam && ! give_akismet_is_email_logged( $args['comment_author_email'] ) ) {

		$title = sprintf(
			'This donor\'s email (%1$s%2$s - %3$s) has been flagged as SPAM',
			$args['comment_author'],
			$donor_last_name,
			$args['comment_author_email']
		);

		$message = sprintf(
			'<p><strong>%1$s</strong><pre>%2$s</pre></p><strong>%3$s</strong><pre>%4$s</pre><p>',
			__( 'Request', 'give' ),
			print_r( $args, true ),
			__( 'Response', 'give' ),
			print_r( $response, true )
		);

		$context = [
			'donor_email' => $args['comment_author_email'],
			'filter'      => 'akismet',
			'message'     => $message,
		];

		Log::spam( $title, $context );
	}

	// It will return Akismet spam detect API response.
	return $spam;

}

add_filter( 'give_spam', 'give_akismet' );

/**
 * Check Akismet API Key.
 *
 * @since 1.8.14
 *
 * @return bool
 */
function give_check_akismet_key() {
	if ( is_callable( [ 'Akismet', 'get_api_key' ] ) ) { // Akismet v3.0+
		return (bool) Akismet::get_api_key();
	}

	if ( function_exists( 'akismet_get_key' ) ) {
		return (bool) akismet_get_key();
	}

	return false;
}

/**
 * Detect spam through Akismet Comment API.
 *
 * @param array $args
 *
 * @return bool|mixed
 * @since 1.8.14
 * @since 2.3.15 Refactor function to use give_akismet_spam_check_post
 */
function give_akismet_spam_check( $args ) {
	$response = give_akismet_spam_check_post( $args );

	// It's spam if response status is true.
	$spam = 'true' === $response[1];

	// Allow developer to modified Akismet spam detection response.
	return apply_filters( 'give_akismet_spam_check', $spam, $args );
}

/**
 * Detect spam through Akismet Comment API.
 *
 * @since 2.5.13
 *
 * @param array $args
 *
 * @return array
 */
function give_akismet_spam_check_post( $args ) {
	global $akismet_api_host, $akismet_api_port;

	$query_string = http_build_query( $args );

	if ( is_callable( [ 'Akismet', 'http_post' ] ) ) { // Akismet v3.0+
		$response = Akismet::http_post( $query_string, 'comment-check' );
	} else {
		$response = akismet_http_post(
			$query_string,
			$akismet_api_host,
			'/1.1/comment-check',
			$akismet_api_port
		);
	}

	return $response;
}


/**
 * Check if email already logged or not
 *
 * @param $email
 *
 * @return bool
 * @since 2.5.13
 */
function give_akismet_is_email_logged( $email ) {
	global $wpdb;

	return (bool) DB::get_var(
		DB::prepare(
            "SELECT COUNT(id) FROM {$wpdb->give_log} WHERE log_type = %s AND data LIKE '%s';",
            LogType::SPAM,
            '%' . esc_sql( $email ) . '%'
        )
	);
}

/**
 * Get list of whitelisted emails.
 *
 * @return array
 * @since 2.5.13
 */
function give_akismet_get_whitelisted_emails() {
	return give_get_option(
		'akismet_whitelisted_email_addresses',
		get_bloginfo( 'admin_email' )
	);
}

/**
 * Add support of RIAL code for backward compatibility.
 * Note: for internal use only
 *
 * @since 1.8.17
 *
 * @param array $currencies
 *
 * @return array
 */
function give_bc_v1817_iranian_currency_code( $currencies ) {
	$currencies['RIAL'] = $currencies['IRR'];

	return $currencies;
}

if ( ! give_has_upgrade_completed( 'v1817_update_donation_iranian_currency_code' ) ) {
	add_filter( 'give_currencies', 'give_bc_v1817_iranian_currency_code', 0 );
}


/**
 * Format right to left supported currency amount.
 *
 * @since 1.8.17
 *
 * @param $formatted_amount
 * @param $currency_args
 * @param $price
 *
 * @return string
 */
function give_format_price_for_right_to_left_supported_currency( $formatted_amount, $currency_args, $price ) {
	if ( ! give_is_right_to_left_supported_currency( $currency_args['currency_code'] ) ) {
		return $formatted_amount;
	}

	$formatted_amount = (
	'before' === (string) $currency_args['position'] ?
		'&#x202B;' . $price . $currency_args['symbol'] . '&#x202C;' :
		'&#x202A;' . $price . $currency_args['symbol'] . '&#x202C;'
	);

	$formatted_amount = $currency_args['decode_currency'] ?
		html_entity_decode( $formatted_amount, ENT_COMPAT, 'UTF-8' ) :
		$formatted_amount;

	return $formatted_amount;
}

add_filter( 'give_currency_filter', 'give_format_price_for_right_to_left_supported_currency', 10, 3 );

/**
 * Validate active gateway value before returning result.
 *
 * @since 4.9.0 rename function - PHP 8 compatibility
 * @since 2.1.0
 *
 * @param $value
 *
 * @return array
 */
function give_validate_active_gateways( $value ) {
	$gateways        = array_keys( give_get_payment_gateways() );
	$active_gateways = is_array( $value ) ? array_keys( $value ) : [];

	// Remove deactivated payment gateways.
	if ( ! empty( $active_gateways ) ) {
		foreach ( $active_gateways as $index => $gateway_id ) {
			if ( ! in_array( $gateway_id, $gateways ) ) {
				unset( $value[ $gateway_id ] );
			}
		}
	}

	if ( empty( $value ) ) {
		/**
		 * Filter the default active gateway
		 *
		 * @since 2.1.0
		 */
		$value = apply_filters(
			'give_default_active_gateways',
			[
				'manual' => 1,
			]
		);
	}

	return $value;
}

add_filter( 'give_get_option_gateways', 'give_validate_active_gateways', 10, 1 );


Current_dir [ WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
admin
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
api
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
database
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
deprecated
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
donors
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
emails
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
forms
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
frontend
--
7 Apr 2026 5.25 AM
bravrvjk / bravrvjk
0755
gateways
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
libraries
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
payments
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
actions.php
10.004 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
ajax-functions.php
21.116 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-async-process.php
1.332 KB
14 Aug 2024 11.11 PM
bravrvjk / bravrvjk
0644
class-give-background-updater.php
15.351 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-cache-setting.php
6.059 KB
22 May 2025 12.18 AM
bravrvjk / bravrvjk
0644
class-give-cache.php
17.805 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-cli-commands.php
32.395 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
class-give-comment.php
17.029 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-cron.php
5.212 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-donate-form.php
24.154 KB
18 Jul 2024 12.34 AM
bravrvjk / bravrvjk
0644
class-give-donor.php
40.059 KB
11 Jan 2024 12.22 AM
bravrvjk / bravrvjk
0644
class-give-email-access.php
8.304 KB
23 Mar 2021 1.24 AM
bravrvjk / bravrvjk
0644
class-give-license-handler.php
34.26 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
class-give-logging.php
7.414 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-readme-parser.php
1.376 KB
17 Jun 2022 4.03 AM
bravrvjk / bravrvjk
0644
class-give-roles.php
11.103 KB
28 Jan 2026 8.00 PM
bravrvjk / bravrvjk
0644
class-give-scripts.php
26 KB
16 Oct 2025 6.10 PM
bravrvjk / bravrvjk
0644
class-give-session.php
14.961 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
class-give-stats.php
11.767 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
class-give-template-loader.php
3.553 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
class-give-tooltips.php
4.561 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
class-give-translation.php
8.268 KB
20 Jan 2022 11.45 AM
bravrvjk / bravrvjk
0644
class-notices.php
19.3 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
country-functions.php
76.284 KB
18 Nov 2025 7.37 PM
bravrvjk / bravrvjk
0644
currencies-list.php
52.224 KB
18 Nov 2025 7.37 PM
bravrvjk / bravrvjk
0644
currency-functions.php
11.573 KB
8 Jul 2022 3.27 AM
bravrvjk / bravrvjk
0644
error-tracking.php
2.926 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
filters.php
8.836 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
formatting.php
28.439 KB
1 Oct 2025 3.37 PM
bravrvjk / bravrvjk
0644
install.php
17.08 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
login-register.php
10.33 KB
10 Apr 2024 9.54 PM
bravrvjk / bravrvjk
0644
misc-functions.php
113.723 KB
17 Sep 2025 8.52 PM
bravrvjk / bravrvjk
0644
plugin-compatibility.php
3.171 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
post-types.php
17.825 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
price-functions.php
2.827 KB
31 Mar 2020 4.14 AM
bravrvjk / bravrvjk
0644
process-donation.php
49.202 KB
6 Nov 2024 11.55 PM
bravrvjk / bravrvjk
0644
setting-functions.php
4.356 KB
11 Jul 2019 8.38 AM
bravrvjk / bravrvjk
0644
shortcodes.php
33.278 KB
22 May 2025 12.18 AM
bravrvjk / bravrvjk
0644
template-functions.php
13.151 KB
31 Mar 2025 11.17 PM
bravrvjk / bravrvjk
0644
user-functions.php
15.768 KB
18 Aug 2022 10.28 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF