Skip to content

Commit a680d60

Browse files
refactor: use filters for getting license data in survey
1 parent fb3743f commit a680d60

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

classes/Visualizer/Module/Admin.php

+14-7
Original file line numberDiff line numberDiff line change
@@ -1233,19 +1233,23 @@ public static function checkChartStatus( $type ) {
12331233

12341234
/**
12351235
* Get the survey metadata.
1236-
*
1237-
* @param array $data The data for survey in Formbricks format.
1236+
*
1237+
* @param array $data The data for survey in Formbricks format.
12381238
* @param string $page_slug The slug of the loaded page.
12391239
*
12401240
* @return array The survey metadata.
12411241
*/
12421242
public function get_survey_metadata( $data, $page_slug ) {
12431243
$install_date = get_option( 'visualizer_install', time() );
1244-
12451244
$install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS );
12461245

1246+
$license_status = apply_filters( 'product_visualizer_license_status', 'invalid' );
1247+
$license_plan = apply_filters( 'product_visualizer_license_plan', false );
1248+
$license_key = apply_filters( 'product_visualizer_license_key', false );
1249+
12471250
$plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
12481251
$plugin_version = '';
1252+
12491253
if ( ! empty( $plugin_data['Version'] ) ) {
12501254
$plugin_version = $plugin_data['Version'];
12511255
}
@@ -1255,14 +1259,17 @@ public function get_survey_metadata( $data, $page_slug ) {
12551259
'attributes' => array(
12561260
'free_version' => $plugin_version,
12571261
'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1258-
'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ),
1262+
'license_status' => $license_status,
12591263
'install_days_number' => $install_days_number,
12601264
),
12611265
);
12621266

1263-
$license_data = get_option( 'visualizer_pro_license_data', false );
1264-
if ( isset( $license_data->key ) ) {
1265-
$data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_data->key );
1267+
if ( ! empty( $license_plan ) ) {
1268+
$data['attributes']['plan'] = $license_plan;
1269+
}
1270+
1271+
if ( ! empty( $license_key ) ) {
1272+
$data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
12661273
}
12671274

12681275
return $data;

0 commit comments

Comments
 (0)