Skip to content

Commit d1b6b71

Browse files
release: fixes
- Fixed special characters not rendering correctly in Legend labels - Updated dependencies
2 parents 72b6b57 + 2d8dcd9 commit d1b6b71

File tree

9 files changed

+78
-119
lines changed

9 files changed

+78
-119
lines changed

.github/workflows/build-dev-artifacts.yml

+5-12
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,11 @@ jobs:
1717
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}
1818
steps:
1919
- name: Check out source files
20-
uses: actions/checkout@v2
21-
- name: Get Composer Cache Directory
22-
id: composer-cache
23-
run: |
24-
echo "::set-output name=dir::$(composer config cache-files-dir)"
25-
- name: Configure Composer cache
26-
uses: actions/cache@v1
20+
uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
2722
with:
28-
path: ${{ steps.composer-cache.outputs.dir }}
29-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
30-
restore-keys: |
31-
${{ runner.os }}-composer-
23+
node-version: 18
24+
cache: "npm"
3225
- name: Install composer deps
3326
env:
3427
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
@@ -99,4 +92,4 @@ jobs:
9992
comment-id: ${{ steps.find-comment.outputs.comment-id }}
10093
token: ${{ secrets.BOT_TOKEN }}
10194
edit-mode: replace
102-
body: ${{ steps.get-comment-body.outputs.body }}
95+
body: ${{ steps.get-comment-body.outputs.body }}

.github/workflows/create-tag.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ jobs:
1515
with:
1616
persist-credentials: false
1717
- name: Build files using ${{ matrix.node-version }}
18-
uses: actions/setup-node@v1
18+
uses: actions/setup-node@v4
1919
with:
2020
node-version: ${{ matrix.node-version }}
21+
cache: "npm"
2122
- name: Release new version
2223
id: release
2324
run: |
@@ -31,4 +32,4 @@ jobs:
3132
SEMANTIC_RELEASE_PACKAGE: Visualizer(free)
3233
GIT_AUTHOR_EMAIL: ${{ secrets.BOT_EMAIL }}
3334
GIT_COMMITTER_NAME: themeisle[bot]
34-
GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }}
35+
GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }}

.github/workflows/test-e2e.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,11 @@ jobs:
1616
fail-fast: false
1717
runs-on: ubuntu-22.04
1818
steps:
19-
- uses: actions/checkout@v2
20-
- uses: actions/setup-node@v2
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
2121
with:
2222
node-version: "18"
23-
- uses: actions/cache@v2
24-
id: npm-and-build-cache
25-
with:
26-
path: |
27-
~/.cache/Cypress
28-
node_modules
29-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
30-
restore-keys: |
31-
${{ runner.os }}-node-
23+
cache: "npm"
3224
- name: Install npm deps
3325
run: |
3426
npm ci

.github/workflows/test-php.yml

+5-27
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: PHP Tests
33
on:
44
push:
55
branches-ignore:
6-
- 'master'
6+
- "master"
77

88
jobs:
99
phplint:
@@ -13,21 +13,10 @@ jobs:
1313
- name: Setup PHP version
1414
uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: '7.4'
16+
php-version: "7.4"
1717
extensions: simplexml
1818
- name: Checkout source code
19-
uses: actions/checkout@v2
20-
- name: Get Composer Cache Directory
21-
id: composer-cache
22-
run: |
23-
echo "::set-output name=dir::$(composer config cache-files-dir)"
24-
- name: Setup Composer cache
25-
uses: actions/cache@v1
26-
with:
27-
path: ${{ steps.composer-cache.outputs.dir }}
28-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
29-
restore-keys: |
30-
${{ runner.os }}-composer-
19+
uses: actions/checkout@v4
3120
- name: Install composer
3221
run: |
3322
composer install --prefer-dist --no-progress
@@ -49,25 +38,14 @@ jobs:
4938
- name: Setup PHP version
5039
uses: shivammathur/setup-php@v2
5140
with:
52-
php-version: '7.4'
41+
php-version: "7.4"
5342
extensions: simplexml, mysql
5443
tools: phpunit-polyfills
5544
- name: Checkout source code
56-
uses: actions/checkout@v2
45+
uses: actions/checkout@v4
5746
- name: Install WordPress Test Suite
5847
run: |
5948
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
60-
- name: Get Composer Cache Directory
61-
id: composer-cache
62-
run: |
63-
echo "::set-output name=dir::$(composer config cache-files-dir)"
64-
- name: Setup Composer cache
65-
uses: actions/cache@v1
66-
with:
67-
path: ${{ steps.composer-cache.outputs.dir }}
68-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
69-
restore-keys: |
70-
${{ runner.os }}-composer-
7149
- name: Install composer
7250
run: |
7351
composer install --prefer-dist --no-progress --no-dev

classes/Visualizer/Module/Admin.php

+54-47
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public function __construct( Visualizer_Plugin $plugin ) {
7979

8080
$this->_addFilter( 'admin_footer_text', 'render_review_notice' );
8181

82+
if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
83+
$this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
84+
}
85+
8286
if ( defined( 'TI_CYPRESS_TESTING' ) ) {
8387
$this->load_cypress_hooks();
8488
}
@@ -934,7 +938,7 @@ private function getQuery() {
934938
*/
935939
public function renderSupportPage() {
936940
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' );
938942
include_once VISUALIZER_ABSPATH . '/templates/support.php';
939943
}
940944

@@ -1091,7 +1095,7 @@ public function renderLibraryPage() {
10911095
)
10921096
);
10931097

1094-
$this->load_survey();
1098+
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
10951099

10961100
if ( ! apply_filters( 'visualizer_is_business', false ) ) {
10971101
do_action( 'themeisle_sdk_load_banner', 'visualizer' );
@@ -1230,71 +1234,74 @@ public static function checkChartStatus( $type ) {
12301234
/**
12311235
* Get the survey metadata.
12321236
*
1237+
* @param array $data The data for survey in Formbricks format.
1238+
* @param string $page_slug The slug of the loaded page.
1239+
*
12331240
* @return array The survey metadata.
12341241
*/
1235-
private function get_survey_metadata() {
1236-
$install_date = get_option( 'visualizer_install', false );
1237-
$install_category = 0;
1238-
1239-
if ( false !== $install_date ) {
1240-
$days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );
1241-
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-
}
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 );
1245+
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 );
12541249

12551250
$plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
12561251
$plugin_version = '';
1252+
12571253
if ( ! empty( $plugin_data['Version'] ) ) {
12581254
$plugin_version = $plugin_data['Version'];
12591255
}
12601256

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 );
12621259

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 );
12661265
}
12671266

1268-
return array(
1269-
'userId' => $user_id,
1267+
$data = array(
1268+
'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
12701269
'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,
12751275
),
12761276
);
1277-
}
1278-
1279-
/**
1280-
* Load the survey.
1281-
*/
1282-
private function load_survey() {
12831277

1284-
if ( defined( 'TI_CYPRESS_TESTING' ) ) {
1285-
return;
1278+
if ( ! empty( $license_plan ) ) {
1279+
$data['attributes']['plan'] = $license_plan;
12861280
}
12871281

1288-
$survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );
1289-
1290-
if ( empty( $survey_handler ) ) {
1291-
return;
1282+
if ( ! empty( $license_key ) ) {
1283+
$data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
12921284
}
12931285

1294-
$metadata = $this->get_survey_metadata();
1286+
return $data;
1287+
}
1288+
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+
);
12951303

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;
12991306
}
13001307
}

classes/Visualizer/Source.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ private function _fetchSeriesFromEditableTable() {
429429
foreach ( $headers as $header ) {
430430
if ( ! empty( $types[ $header ] ) ) {
431431
$this->_series[] = array(
432-
'label' => esc_html( wp_strip_all_tags( $header ) ),
432+
'label' => sanitize_text_field( wp_strip_all_tags( $header ) ),
433433
'type' => $types[ $header ],
434434
);
435435
}

classes/Visualizer/Source/Csv.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function _fetchSeries( &$handle ) {
9797
$labels[ $i ] = $this->toUTF8( $labels[ $i ] );
9898

9999
$this->_series[] = array(
100-
'label' => esc_html( wp_strip_all_tags( $labels[ $i ] ) ),
100+
'label' => sanitize_text_field( wp_strip_all_tags( $labels[ $i ] ) ),
101101
'type' => isset( $types[ $i ] ) ? $types[ $i ] : $default_type,
102102
);
103103
}

composer.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/survey.js

-12
This file was deleted.

0 commit comments

Comments
 (0)