Skip to content

Release #1208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 16, 2025
Merged

Release #1208

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions .github/workflows/build-dev-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@ jobs:
git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }}
steps:
- name: Check out source files
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/cache@v1
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
node-version: 18
cache: "npm"
- name: Install composer deps
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
Expand Down Expand Up @@ -99,4 +92,4 @@ jobs:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
token: ${{ secrets.BOT_TOKEN }}
edit-mode: replace
body: ${{ steps.get-comment-body.outputs.body }}
body: ${{ steps.get-comment-body.outputs.body }}
5 changes: 3 additions & 2 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
with:
persist-credentials: false
- name: Build files using ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Release new version
id: release
run: |
Expand All @@ -31,4 +32,4 @@ jobs:
SEMANTIC_RELEASE_PACKAGE: Visualizer(free)
GIT_AUTHOR_EMAIL: ${{ secrets.BOT_EMAIL }}
GIT_COMMITTER_NAME: themeisle[bot]
GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }}
GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }}
14 changes: 3 additions & 11 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ jobs:
fail-fast: false
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "18"
- uses: actions/cache@v2
id: npm-and-build-cache
with:
path: |
~/.cache/Cypress
node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
cache: "npm"
- name: Install npm deps
run: |
npm ci
Expand Down
32 changes: 5 additions & 27 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: PHP Tests
on:
push:
branches-ignore:
- 'master'
- "master"

jobs:
phplint:
Expand All @@ -13,21 +13,10 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"
extensions: simplexml
- name: Checkout source code
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
uses: actions/checkout@v4
- name: Install composer
run: |
composer install --prefer-dist --no-progress
Expand All @@ -49,25 +38,14 @@ jobs:
- name: Setup PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: "7.4"
extensions: simplexml, mysql
tools: phpunit-polyfills
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install WordPress Test Suite
run: |
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Setup Composer cache
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install composer
run: |
composer install --prefer-dist --no-progress --no-dev
Expand Down
101 changes: 54 additions & 47 deletions classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function __construct( Visualizer_Plugin $plugin ) {

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

if ( ! defined( 'TI_CYPRESS_TESTING' ) ) {
$this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 );
}

if ( defined( 'TI_CYPRESS_TESTING' ) ) {
$this->load_cypress_hooks();
}
Expand Down Expand Up @@ -934,7 +938,7 @@ private function getQuery() {
*/
public function renderSupportPage() {
wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
$this->load_survey();
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
include_once VISUALIZER_ABSPATH . '/templates/support.php';
}

Expand Down Expand Up @@ -1091,7 +1095,7 @@ public function renderLibraryPage() {
)
);

$this->load_survey();
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );

if ( ! apply_filters( 'visualizer_is_business', false ) ) {
do_action( 'themeisle_sdk_load_banner', 'visualizer' );
Expand Down Expand Up @@ -1230,71 +1234,74 @@ public static function checkChartStatus( $type ) {
/**
* Get the survey metadata.
*
* @param array $data The data for survey in Formbricks format.
* @param string $page_slug The slug of the loaded page.
*
* @return array The survey metadata.
*/
private function get_survey_metadata() {
$install_date = get_option( 'visualizer_install', false );
$install_category = 0;

if ( false !== $install_date ) {
$days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS );

if ( 0 === $days_since_install || 1 === $days_since_install ) {
$install_category = 0;
} elseif ( 1 < $days_since_install && 8 > $days_since_install ) {
$install_category = 7;
} elseif ( 8 <= $days_since_install && 31 > $days_since_install ) {
$install_category = 30;
} elseif ( 30 < $days_since_install && 90 > $days_since_install ) {
$install_category = 90;
} elseif ( 90 <= $days_since_install ) {
$install_category = 91;
}
}
public function get_survey_metadata( $data, $page_slug ) {
$install_date = get_option( 'visualizer_install', time() );
$install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS );

$license_status = apply_filters( 'product_visualizer_license_status', 'invalid' );
$license_plan = apply_filters( 'product_visualizer_license_plan', false );
$license_key = apply_filters( 'product_visualizer_license_key', false );

$plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false );
$plugin_version = '';

if ( ! empty( $plugin_data['Version'] ) ) {
$plugin_version = $plugin_data['Version'];
}

$user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID.
$count_charts_cache_key = 'visualizer_count_charts';
$charts_number = get_transient( $count_charts_cache_key );

$license_data = get_option( 'visualizer_pro_license_data', false );
if ( false !== $license_data && isset( $license_data->key ) ) {
$user_id = 'visualizer_' . $license_data->key;
if ( false === $charts_number ) {
$charts_number = $this->count_charts( 100 );
set_transient( $count_charts_cache_key, $charts_number, 100 === $charts_number ? WEEK_IN_SECONDS : 6 * HOUR_IN_SECONDS );
} else {
$charts_number = strval( $charts_number );
}

return array(
'userId' => $user_id,
$data = array(
'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5',
'attributes' => array(
'days_since_install' => strval( $install_category ),
'free_version' => $plugin_version,
'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ),
'free_version' => $plugin_version,
'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '',
'license_status' => $license_status,
'install_days_number' => $install_days_number,
'charts_number' => $charts_number,
),
);
}

/**
* Load the survey.
*/
private function load_survey() {

if ( defined( 'TI_CYPRESS_TESTING' ) ) {
return;
if ( ! empty( $license_plan ) ) {
$data['attributes']['plan'] = $license_plan;
}

$survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' );

if ( empty( $survey_handler ) ) {
return;
if ( ! empty( $license_key ) ) {
$data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key );
}

$metadata = $this->get_survey_metadata();
return $data;
}

/**
* Count the charts.
*
* @param int $limit The count limit (optional).
*
* @return int The number of charts.
*/
public function count_charts( $limit = -1 ) {
$args = array(
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
'post_status' => 'publish',
'posts_per_page' => $limit,
'fields' => 'ids',
);

do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' );
wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true );
wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata );
$query = new WP_Query( $args);
return $query->post_count;
}
}
2 changes: 1 addition & 1 deletion classes/Visualizer/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private function _fetchSeriesFromEditableTable() {
foreach ( $headers as $header ) {
if ( ! empty( $types[ $header ] ) ) {
$this->_series[] = array(
'label' => esc_html( wp_strip_all_tags( $header ) ),
'label' => sanitize_text_field( wp_strip_all_tags( $header ) ),
'type' => $types[ $header ],
);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Source/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function _fetchSeries( &$handle ) {
$labels[ $i ] = $this->toUTF8( $labels[ $i ] );

$this->_series[] = array(
'label' => esc_html( wp_strip_all_tags( $labels[ $i ] ) ),
'label' => sanitize_text_field( wp_strip_all_tags( $labels[ $i ] ) ),
'type' => isset( $types[ $i ] ) ? $types[ $i ] : $default_type,
);
}
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions js/survey.js

This file was deleted.