PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | classes/Visualizer/Module/Admin.php +53 -46 3.11.93.11.10 View file →
@@ -78,8 +78,12 @@
78 78 $this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' );
79 79
80 80 $this->_addFilter( 'admin_footer_text', 'render_review_notice' );
81 81
82 + if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
83 + $this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
84 + }
85 +
82 86 if ( defined( 'TI_CYPRESS_TESTING' ) ) {
83 87 $this->load_cypress_hooks();
84 88 }
85 89
@@ -933,9 +937,9 @@
933 937 * @access public
934 938 */
935 939 public function renderSupportPage() {
936 940 wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
937 - $this->load_survey();
941 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
938 942 include_once VISUALIZER_ABSPATH . '/templates/support.php';
939 943 }
940 944
941 945 /**
@@ -1090,9 +1094,9 @@
1090 1094 'type' => 'array',
1091 1095 )
1092 1096 );
1093 1097
1094 - $this->load_survey();
1098 + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
1095 1099
1096 1100 if ( ! apply_filters( 'visualizer_is_business', false ) ) {
1097 1101 do_action( 'themeisle_sdk_load_banner', 'visualizer' );
1098 1102 }
@@ -1229,72 +1233,75 @@
1229 1233
1230 1234 /**
1231 1235 * Get the survey metadata.
1232 1236 *
1237 + * @param array $data The data for survey in Formbricks format.
1238 + * @param string $page_slug The slug of the loaded page.
1239 + *
1233 1240 * @return array The survey metadata.
1234 1241 */
1235 - private function get_survey_metadata() {
1236 - $install_date = get_option( 'visualizer_install', false );
1237 - $install_category = 0;
1242 + public function get_survey_metadata( $data, $page_slug ) {
1243 + $install_date = get_option( 'visualizer_install', time() );
1244 + $install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS );
1238 1245
1239 - if ( false !== $install_date ) {
1240 - $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );
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 );
1241 1249
1242 - if ( 0 === $days_since_install || 1 === $days_since_install ) {
1243 - $install_category = 0;
1244 - } elseif ( 1 < $days_since_install && 8 > $days_since_install ) {
1245 - $install_category = 7;
1246 - } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) {
1247 - $install_category = 30;
1248 - } elseif ( 30 < $days_since_install && 90 > $days_since_install ) {
1249 - $install_category = 90;
1250 - } elseif ( 90 <= $days_since_install ) {
1251 - $install_category = 91;
1252 - }
1253 - }
1254 -
1255 1250 $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
1256 1251 $plugin_version = '';
1252 +
1257 1253 if ( ! empty( $plugin_data['Version'] ) ) {
1258 1254 $plugin_version = $plugin_data['Version'];
1259 1255 }
1260 1256
1261 - $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID.
1257 + $count_charts_cache_key = 'visualizer_count_charts';
1258 + $charts_number = get_transient( $count_charts_cache_key );
1262 1259
1263 - $license_data = get_option( 'visualizer_pro_license_data', false );
1264 - if ( false !== $license_data && isset( $license_data->key ) ) {
1265 - $user_id = 'visualizer_' . $license_data->key;
1260 + if ( false === $charts_number ) {
1261 + $charts_number = $this->count_charts( 100 );
1262 + set_transient( $count_charts_cache_key, $charts_number, 100 === $charts_number ? WEEK_IN_SECONDS : 6 * HOUR_IN_SECONDS );
1263 + } else {
1264 + $charts_number = strval( $charts_number );
1266 1265 }
1267 1266
1268 - return array(
1269 - 'userId' => $user_id,
1267 + $data = array(
1268 + 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
1270 1269 'attributes' => array(
1271 - 'days_since_install' => strval( $install_category ),
1272 - 'free_version' => $plugin_version,
1273 - 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1274 - 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ),
1270 + 'free_version' => $plugin_version,
1271 + 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
1272 + 'license_status' => $license_status,
1273 + 'install_days_number' => $install_days_number,
1274 + 'charts_number' => $charts_number,
1275 1275 ),
1276 1276 );
1277 - }
1278 1277
1279 - /**
1280 - * Load the survey.
1281 - */
1282 - private function load_survey() {
1278 + if ( ! empty( $license_plan ) ) {
1279 + $data['attributes']['plan'] = $license_plan;
1280 + }
1283 1281
1284 - if ( defined( 'TI_CYPRESS_TESTING' ) ) {
1285 - return;
1282 + if ( ! empty( $license_key ) ) {
1283 + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
1286 1284 }
1287 1285
1288 - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
1286 + return $data;
1287 + }
1289 1288
1290 - if ( empty( $survey_handler ) ) {
1291 - return;
1292 - }
1289 + /**
1290 + * Count the charts.
1291 + *
1292 + * @param int $limit The count limit (optional).
1293 + *
1294 + * @return int The number of charts.
1295 + */
1296 + public function count_charts( $limit = -1 ) {
1297 + $args = array(
1298 + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
1299 + 'post_status' => 'publish',
1300 + 'posts_per_page' => $limit,
1301 + 'fields' => 'ids',
1302 + );
1293 1303
1294 - $metadata = $this->get_survey_metadata();
1295 -
1296 - do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
1297 - wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true );
1298 - wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata );
1304 + $query = new WP_Query( $args);
1305 + return $query->post_count;
1299 1306 }
1300 1307 }