@@ -270,19 +270,22 @@ public function enqueue() {
270
270
271
271
$ build_path = get_template_directory_uri () . '/assets/apps/dashboard/build/ ' ;
272
272
$ dependencies = ( include get_template_directory () . '/assets/apps/dashboard/build/dashboard.asset.php ' );
273
+ $ dash_data = apply_filters ( 'neve_dashboard_page_data ' , $ this ->get_localization () );
274
+
275
+ $ this ->register_survey ( $ dash_data );
273
276
274
277
wp_register_style ( 'neve-dash-style ' , $ build_path . 'style-dashboard.css ' , [ 'wp-components ' , 'neve-components ' ], $ dependencies ['version ' ] );
275
278
wp_style_add_data ( 'neve-dash-style ' , 'rtl ' , 'replace ' );
276
279
wp_enqueue_style ( 'neve-dash-style ' );
277
280
wp_register_script ( 'neve-dash-script ' , $ build_path . 'dashboard.js ' , array_merge ( $ dependencies ['dependencies ' ], [ 'updates ' ] ), $ dependencies ['version ' ], true );
278
- wp_localize_script ( 'neve-dash-script ' , 'neveDash ' , apply_filters ( ' neve_dashboard_page_data ' , $ this -> get_localization () ) );
281
+ wp_localize_script ( 'neve-dash-script ' , 'neveDash ' , $ dash_data );
279
282
wp_enqueue_script ( 'neve-dash-script ' );
280
283
281
284
if ( function_exists ( 'wp_set_script_translations ' ) ) {
282
285
wp_set_script_translations ( 'neve-dash-script ' , 'neve ' );
283
286
}
284
287
285
- do_action ( 'themeisle_sdk_dependency_enqueue_script ' , 'survey ' );
288
+ do_action ( 'themeisle_internal_page ' , 'neve ' , ' dashboard ' );
286
289
}
287
290
288
291
/**
@@ -361,8 +364,6 @@ private function get_localization() {
361
364
'canActivatePlugins ' => current_user_can ( 'activate_plugins ' ),
362
365
'deal ' => $ offer ->get_localized_data (),
363
366
'rootUrl ' => get_site_url (),
364
- 'daysSinceInstall ' => round ( ( time () - get_option ( 'neve_install ' , 0 ) ) / DAY_IN_SECONDS ),
365
- 'proPluginVersion ' => defined ( 'NEVE_PRO_VERSION ' ) ? NEVE_PRO_VERSION : '' ,
366
367
];
367
368
368
369
if ( defined ( 'NEVE_PRO_PATH ' ) ) {
@@ -1084,4 +1085,57 @@ public function render_neve_header() {
1084
1085
</div>
1085
1086
<?php
1086
1087
}
1088
+
1089
+ /**
1090
+ * Register the survey.
1091
+ *
1092
+ * @param array $dash_data The dashboard data.
1093
+ *
1094
+ * @return void
1095
+ */
1096
+ public function register_survey ( $ dash_data ) {
1097
+ add_filter (
1098
+ 'themeisle-sdk/survey/neve ' ,
1099
+ function ( $ data , $ page_slug ) use ( $ dash_data ) {
1100
+
1101
+ $ install_category = 0 ;
1102
+ $ install_days_number = intval ( ( time () - get_option ( 'neve_install ' , 0 ) ) / DAY_IN_SECONDS );
1103
+
1104
+ if ( 0 === $ install_days_number || 1 === $ install_days_number ) {
1105
+ $ install_category = 0 ;
1106
+ } elseif ( 1 < $ install_days_number && 8 > $ install_days_number ) {
1107
+ $ install_category = 7 ;
1108
+ } elseif ( 8 <= $ install_days_number && 31 > $ install_days_number ) {
1109
+ $ install_category = 30 ;
1110
+ } elseif ( 30 < $ install_days_number && 90 > $ install_days_number ) {
1111
+ $ install_category = 90 ;
1112
+ } elseif ( 90 <= $ install_days_number ) {
1113
+ $ install_category = 91 ;
1114
+ }
1115
+
1116
+ $ data = array (
1117
+ 'environmentId ' => 'clr0ply35522h8up0bay2de4y ' ,
1118
+ 'attributes ' => array (
1119
+ 'plan ' => isset ( $ dash_data ['license ' ], $ dash_data ['license ' ]['tier ' ] ) ? $ dash_data ['license ' ]['tier ' ] : 0 ,
1120
+ 'license_status ' => isset ( $ dash_data ['license ' ], $ dash_data ['license ' ]['valid ' ] ) ? $ dash_data ['license ' ]['valid ' ] : 'invalid ' ,
1121
+ 'days_since_install ' => $ install_category ,
1122
+ 'install_days_number ' => $ install_days_number ,
1123
+ 'free_version ' => $ dash_data ['version ' ],
1124
+ ),
1125
+ );
1126
+
1127
+ if ( isset ( $ dash_data ['license ' ], $ dash_data ['license ' ]['key ' ] ) ) {
1128
+ $ data ['attributes ' ]['license_key ' ] = apply_filters ( 'themeisle_sdk_secret_masking ' , $ dash_data ['license ' ]['key ' ] );
1129
+ }
1130
+
1131
+ if ( defined ( 'NEVE_PRO_VERSION ' ) ) {
1132
+ $ data ['attributes ' ]['pro_version ' ] = NEVE_PRO_VERSION ;
1133
+ }
1134
+
1135
+ return $ data ;
1136
+ },
1137
+ 10 ,
1138
+ 2
1139
+ );
1140
+ }
1087
1141
}
0 commit comments