| 1 |
<?php |
| 2 |
namespace Elementor\App\Modules\Onboarding; |
| 3 |
|
| 4 |
use Elementor\Includes\EditorAssetsAPI; |
| 5 |
|
| 6 |
class API { |
| 7 |
protected EditorAssetsAPI $editor_assets_api; |
| 8 |
|
| 9 |
public function __construct( EditorAssetsAPI $editor_assets_api ) { |
| 10 |
$this->editor_assets_api = $editor_assets_api; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_ab_testing_data( $force_request = false ): array { |
| 14 |
$assets_data = $this->editor_assets_api->get_assets_data( $force_request ); |
| 15 |
|
| 16 |
return $this->extract_ab_testing_config( $assets_data ); |
| 17 |
} |
| 18 |
|
| 19 |
private function extract_ab_testing_config( array $json_data ): array { |
| 20 |
if ( empty( $json_data ) || ! is_array( $json_data ) ) { |
| 21 |
return []; |
| 22 |
} |
| 23 |
|
| 24 |
return $json_data[0] ?? []; |
| 25 |
} |
| 26 |
|
| 27 |
public function is_theme_selection_experiment_enabled( $force_request = false ): bool { |
| 28 |
$ab_testing_data = $this->get_ab_testing_data( $force_request ); |
| 29 |
|
| 30 |
return $ab_testing_data['coreOnboardingThemeSelection'] ?? false; |
| 31 |
} |
| 32 |
|
| 33 |
public function is_good_to_go_experiment_enabled( $force_request = false ): bool { |
| 34 |
$ab_testing_data = $this->get_ab_testing_data( $force_request ); |
| 35 |
|
| 36 |
return $ab_testing_data['coreOnboardingGoodToGo'] ?? false; |
| 37 |
} |
| 38 |
} |
| 39 |
|