??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/renovaid.co.uk/wp-content/plugins/elementor/core/utils/ab-test.php
⬅ Kembali
<?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 );
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
📁 api
dir
—
2026-06-23 10:10
📁 import-export
dir
—
2026-06-23 10:10
📁 promotions
dir
—
2026-06-23 10:10
📁 svg
dir
—
2026-06-23 10:10
🐘 ab-test.php
php
2.4 KB
2025-09-15 14:10
🐘 assets-config-provider.php
php
1.5 KB
2023-08-23 17:47
🐘 assets-translation-loader.php
php
2.5 KB
2025-10-21 16:51
🐘 collection.php
php
10.1 KB
2025-12-22 17:25
🐘 exceptions.php
php
709 B
2025-03-17 17:28
🐘 force-locale.php
php
3.6 KB
2023-04-23 15:22
🐘 hints.php
php
14.7 KB
2026-03-30 13:49
🐘 http.php
php
981 B
2023-04-23 15:22
🐘 plugins-manager.php
php
2.8 KB
2025-04-28 11:15
🐘 static-collection.php
php
1.1 KB
2025-10-21 16:51
🐘 str.php
php
1001 B
2025-03-17 17:28
🐘 template-library-element-iterator.php
php
766 B
2026-03-30 13:49
🐘 template-library-import-export-utils.php
php
7.2 KB
2026-03-30 13:49
🐘 template-library-snapshot-processor.php
php
6.8 KB
2026-05-20 16:19
🐘 version.php
php
3.8 KB
2025-10-21 16:51