$62 GRAYBYTE WORDPRESS FILE MANAGER $83

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

/home/bravrvjk/solidactfoundation.org/wp-content/plugins/elementor/core/utils/

HOME
Current File : /home/bravrvjk/solidactfoundation.org/wp-content/plugins/elementor/core/utils//ab-test.php
<?php

namespace Elementor\Core\Utils;

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

/**
 * Core A/B Testing utility class
 *
 * Provides A/B testing functionality for Core features.
 * Uses WordPress transients for caching and user-specific variation assignment.
 */
class Ab_Test {

	const PREFIX_CACHE_KEY = '_elementor_ab_test_';
	const CACHE_TTL = 90 * DAY_IN_SECONDS;

	/**
	 * Get variation for a specific test
	 *
	 * @param string $test_name The name of the A/B test
	 * @param int    $user_id Optional user ID, defaults to current user
	 * @return int Returns 1 or 2 for variation assignment
	 */
	public static function get_variation( $test_name, $user_id = null ): int {
		if ( null === $user_id ) {
			$user_id = get_current_user_id();
		}

		$variation_id = self::get_variation_id_from_cache( $test_name, $user_id );

		if ( false === $variation_id ) {
			$variation_id = self::get_random_variation();
			self::set_variation_id_from_cache( $test_name, $user_id, $variation_id );
		}

		return absint( $variation_id );
	}

	/**
	 * Check if user should see the feature (50% probability)
	 *
	 * @param string $test_name The name of the A/B test
	 * @param int    $user_id Optional user ID, defaults to current user
	 * @return bool True if user should see the feature
	 */
	public static function should_show_feature( $test_name, $user_id = null ): bool {
		$variation = self::get_variation( $test_name, $user_id );
		return 1 === $variation; // Only variation 1 sees the feature
	}

	/**
	 * Get variation ID from cache
	 *
	 * @param string $test_name The name of the A/B test
	 * @param int    $user_id User ID
	 * @return int|false Variation ID or false if not cached
	 */
	private static function get_variation_id_from_cache( $test_name, $user_id ) {
		$cache_key = self::PREFIX_CACHE_KEY . $test_name . '_' . $user_id;
		return get_transient( $cache_key );
	}

	/**
	 * Set variation ID in cache
	 *
	 * @param string $test_name The name of the A/B test
	 * @param int    $user_id User ID
	 * @param int    $variation_id Variation ID to cache
	 */
	private static function set_variation_id_from_cache( $test_name, $user_id, $variation_id ): void {
		$cache_key = self::PREFIX_CACHE_KEY . $test_name . '_' . $user_id;
		set_transient( $cache_key, $variation_id, self::CACHE_TTL );
	}

	/**
	 * Generate random variation (1 or 2)
	 *
	 * @return int Random variation ID
	 */
	private static function get_random_variation(): int {
		return mt_rand( 1, 2 );
	}
}


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
api
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
import-export
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
promotions
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
svg
--
4 Apr 2026 1.57 AM
bravrvjk / bravrvjk
0755
ab-test.php
2.446 KB
15 Sep 2025 2.10 PM
bravrvjk / bravrvjk
0644
assets-config-provider.php
1.486 KB
23 Aug 2023 5.47 PM
bravrvjk / bravrvjk
0644
assets-translation-loader.php
2.508 KB
21 Oct 2025 4.51 PM
bravrvjk / bravrvjk
0644
collection.php
10.133 KB
22 Dec 2025 5.25 PM
bravrvjk / bravrvjk
0644
error_log
0.349 KB
4 Apr 2026 5.26 AM
bravrvjk / bravrvjk
0644
exceptions.php
0.692 KB
17 Mar 2025 5.28 PM
bravrvjk / bravrvjk
0644
force-locale.php
3.555 KB
23 Apr 2023 3.22 PM
bravrvjk / bravrvjk
0644
hints.php
14.66 KB
30 Mar 2026 1.49 PM
bravrvjk / bravrvjk
0644
http.php
0.958 KB
23 Apr 2023 3.22 PM
bravrvjk / bravrvjk
0644
plugins-manager.php
2.84 KB
28 Apr 2025 11.15 AM
bravrvjk / bravrvjk
0644
static-collection.php
1.086 KB
21 Oct 2025 4.51 PM
bravrvjk / bravrvjk
0644
str.php
0.978 KB
17 Mar 2025 5.28 PM
bravrvjk / bravrvjk
0644
template-library-element-iterator.php
0.748 KB
30 Mar 2026 1.49 PM
bravrvjk / bravrvjk
0644
template-library-import-export-utils.php
7.196 KB
30 Mar 2026 1.49 PM
bravrvjk / bravrvjk
0644
template-library-snapshot-processor.php
6.241 KB
30 Mar 2026 1.49 PM
bravrvjk / bravrvjk
0644
version.php
3.778 KB
21 Oct 2025 4.51 PM
bravrvjk / bravrvjk
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF