From c1b1d978b6ccf7e01643297a21ae56444fc2730c Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 20 Feb 2025 14:19:28 +0200 Subject: [PATCH 1/8] chore: update Github Actions versions --- .github/workflows/build-dev-artifacts.yml | 17 ++++-------- .github/workflows/create-tag.yml | 5 ++-- .github/workflows/test-e2e.yml | 14 +++------- .github/workflows/test-php.yml | 32 ++++------------------- 4 files changed, 16 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-dev-artifacts.yml b/.github/workflows/build-dev-artifacts.yml index 9997bce1..b13dae1b 100755 --- a/.github/workflows/build-dev-artifacts.yml +++ b/.github/workflows/build-dev-artifacts.yml @@ -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 }} @@ -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 }} \ No newline at end of file + body: ${{ steps.get-comment-body.outputs.body }} diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index e2cec0db..af53b54f 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -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: | @@ -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 }} \ No newline at end of file + GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }} diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index a50a3364..c44e03ab 100755 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -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 diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index 595a1850..fc7ffecd 100755 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -3,7 +3,7 @@ name: PHP Tests on: push: branches-ignore: - - 'master' + - "master" jobs: phplint: @@ -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 @@ -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 From a209ba3c4a0dc142216732b05ffae06e457f8118 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:20:57 +0000 Subject: [PATCH 2/8] chore(deps): bump codeinwp/themeisle-sdk from 3.3.41 to 3.3.44 Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.41 to 3.3.44. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Changelog](https://github.com/Codeinwp/themeisle-sdk/blob/v3.3.44/CHANGELOG.md) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.41...v3.3.44) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 142f29d1..8546d89e 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.41", + "version": "3.3.44", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "b194c872933882f4e5780eae56c59698d01623fc" + "reference": "fed444b52ebf1f689ec2434df177926bf8f238c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/b194c872933882f4e5780eae56c59698d01623fc", - "reference": "b194c872933882f4e5780eae56c59698d01623fc", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/fed444b52ebf1f689ec2434df177926bf8f238c4", + "reference": "fed444b52ebf1f689ec2434df177926bf8f238c4", "shasum": "" }, "require-dev": { @@ -43,9 +43,9 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.41" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.44" }, - "time": "2025-02-05T10:30:34+00:00" + "time": "2025-02-18T21:31:30+00:00" }, { "name": "neitanod/forceutf8", From db679e5405567bd9886be1aed10514a39e2fcee2 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 13 Feb 2025 14:34:30 +0200 Subject: [PATCH 3/8] feat: load survey via internal pages --- classes/Visualizer/Module/Admin.php | 89 ++++++++++++----------------- index.php | 1 + js/survey.js | 12 ---- 3 files changed, 38 insertions(+), 64 deletions(-) delete mode 100644 js/survey.js diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index 2bc81b5c..0a623645 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -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_PRODUCT_SLUG, 'get_survey_metadata', 10, 2 ); + } + if ( defined( 'TI_CYPRESS_TESTING' ) ) { $this->load_cypress_hooks(); } @@ -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_PRODUCT_SLUG, 'support' ); include_once VISUALIZER_ABSPATH . '/templates/support.php'; } @@ -1091,7 +1095,7 @@ public function renderLibraryPage() { ) ); - $this->load_survey(); + do_action( 'themeisle_internal_page', VISUALIZER_PRODUCT_SLUG, 'library' ); if ( ! apply_filters( 'visualizer_is_business', false ) ) { do_action( 'themeisle_sdk_load_banner', 'visualizer' ); @@ -1229,28 +1233,30 @@ 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_category = 0; + + $install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS ); + + if ( 0 === $install_days_number || 1 === $install_days_number ) { + $install_category = 0; + } elseif ( 1 < $install_days_number && 8 > $install_days_number ) { + $install_category = 7; + } elseif ( 8 <= $install_days_number && 31 > $install_days_number ) { + $install_category = 30; + } elseif ( 30 < $install_days_number && 90 > $install_days_number ) { + $install_category = 90; + } elseif ( 90 <= $install_days_number ) { + $install_category = 91; } + $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false ); $plugin_version = ''; @@ -1258,43 +1264,22 @@ private function get_survey_metadata() { $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. - - $license_data = get_option( 'visualizer_pro_license_data', false ); - if ( false !== $license_data && isset( $license_data->key ) ) { - $user_id = 'visualizer_' . $license_data->key; - } - - 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' ), + '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' ), + 'install_days_number' => $install_days_number, ), ); - } - /** - * Load the survey. - */ - private function load_survey() { - - if ( defined( 'TI_CYPRESS_TESTING' ) ) { - return; - } - - $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' ); - - if ( empty( $survey_handler ) ) { - return; + $license_data = get_option( 'visualizer_pro_license_data', false ); + if ( isset( $license_data->key ) ) { + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_data->key ); } - $metadata = $this->get_survey_metadata(); - - 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 ); + return $data; } } diff --git a/index.php b/index.php index b5cdea88..9f8fa65a 100644 --- a/index.php +++ b/index.php @@ -69,6 +69,7 @@ function visualizer_launch() { define( 'VISUALIZER_ABSPATH', dirname( __FILE__ ) ); define( 'VISUALIZER_DIRNAME', basename( VISUALIZER_ABSPATH ) ); define( 'VISUALIZER_REST_VERSION', 1 ); + define( 'VISUALIZER_PRODUCT_SLUG', VISUALIZER_DIRNAME ); // if the below is true, then the js/customization.js in the plugin folder will be used instead of the one in the uploads folder (if it exists). // this is also used in Block.php if ( ! defined( 'VISUALIZER_TEST_JS_CUSTOMIZATION' ) ) { diff --git a/js/survey.js b/js/survey.js deleted file mode 100644 index 6e29d56b..00000000 --- a/js/survey.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Initialize the formbricks survey. - * - * @see https://github.com/formbricks/setup-examples/tree/main/html - */ -window.addEventListener('themeisle:survey:loaded', function () { - window?.tsdk_formbricks?.init?.({ - environmentId: "cltef8cut1s7wyyfxy3rlxzs5", - apiHost: "https://app.formbricks.com", - ...(window?.visualizerSurveyData ?? {}), - }); -}); \ No newline at end of file From 000ab63d227726924277299e7bedac391e8ae838 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 18 Feb 2025 14:53:07 +0200 Subject: [PATCH 4/8] refactor: remove install category from survey --- classes/Visualizer/Module/Admin.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index 0a623645..3a90e548 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1241,23 +1241,9 @@ public static function checkChartStatus( $type ) { */ public function get_survey_metadata( $data, $page_slug ) { $install_date = get_option( 'visualizer_install', time() ); - $install_category = 0; $install_days_number = intval( ( time() - $install_date ) / DAY_IN_SECONDS ); - if ( 0 === $install_days_number || 1 === $install_days_number ) { - $install_category = 0; - } elseif ( 1 < $install_days_number && 8 > $install_days_number ) { - $install_category = 7; - } elseif ( 8 <= $install_days_number && 31 > $install_days_number ) { - $install_category = 30; - } elseif ( 30 < $install_days_number && 90 > $install_days_number ) { - $install_category = 90; - } elseif ( 90 <= $install_days_number ) { - $install_category = 91; - } - - $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false ); $plugin_version = ''; if ( ! empty( $plugin_data['Version'] ) ) { @@ -1267,7 +1253,6 @@ public function get_survey_metadata( $data, $page_slug ) { $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' ), From c78363864c4bd93aaf05a4614851b825c68a20b7 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 20 Feb 2025 14:13:19 +0200 Subject: [PATCH 5/8] refactor: use filters for getting license data in survey --- classes/Visualizer/Module/Admin.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index 3a90e548..5d0cea2e 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1233,19 +1233,23 @@ public static function checkChartStatus( $type ) { /** * Get the survey metadata. - * - * @param array $data The data for survey in Formbricks format. + * + * @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. */ 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']; } @@ -1255,14 +1259,17 @@ public function get_survey_metadata( $data, $page_slug ) { 'attributes' => array( 'free_version' => $plugin_version, 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '', - 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ), + 'license_status' => $license_status, 'install_days_number' => $install_days_number, ), ); - $license_data = get_option( 'visualizer_pro_license_data', false ); - if ( isset( $license_data->key ) ) { - $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_data->key ); + if ( ! empty( $license_plan ) ) { + $data['attributes']['plan'] = $license_plan; + } + + if ( ! empty( $license_key ) ) { + $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', $license_key ); } return $data; From e33357594f38d68db27962803bd549e40b07c72c Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 20 Feb 2025 14:15:23 +0200 Subject: [PATCH 6/8] refactor: use VISUALIZER_DIRNAME for internal pages --- classes/Visualizer/Module/Admin.php | 6 +++--- index.php | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index 5d0cea2e..e1f45694 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -80,7 +80,7 @@ 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_PRODUCT_SLUG, 'get_survey_metadata', 10, 2 ); + $this->_addFilter( 'themeisle-sdk/survey/' . VISUALIZER_DIRNAME, 'get_survey_metadata', 10, 2 ); } if ( defined( 'TI_CYPRESS_TESTING' ) ) { @@ -938,7 +938,7 @@ private function getQuery() { */ public function renderSupportPage() { wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION ); - do_action( 'themeisle_internal_page', VISUALIZER_PRODUCT_SLUG, 'support' ); + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' ); include_once VISUALIZER_ABSPATH . '/templates/support.php'; } @@ -1095,7 +1095,7 @@ public function renderLibraryPage() { ) ); - do_action( 'themeisle_internal_page', VISUALIZER_PRODUCT_SLUG, 'library' ); + do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' ); if ( ! apply_filters( 'visualizer_is_business', false ) ) { do_action( 'themeisle_sdk_load_banner', 'visualizer' ); diff --git a/index.php b/index.php index 9f8fa65a..b5cdea88 100644 --- a/index.php +++ b/index.php @@ -69,7 +69,6 @@ function visualizer_launch() { define( 'VISUALIZER_ABSPATH', dirname( __FILE__ ) ); define( 'VISUALIZER_DIRNAME', basename( VISUALIZER_ABSPATH ) ); define( 'VISUALIZER_REST_VERSION', 1 ); - define( 'VISUALIZER_PRODUCT_SLUG', VISUALIZER_DIRNAME ); // if the below is true, then the js/customization.js in the plugin folder will be used instead of the one in the uploads folder (if it exists). // this is also used in Block.php if ( ! defined( 'VISUALIZER_TEST_JS_CUSTOMIZATION' ) ) { From 7635c8dc64044c0b68afaff885614c849d770c5c Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 21 Feb 2025 10:54:59 +0200 Subject: [PATCH 7/8] feat: add created charts number to survey metadata --- classes/Visualizer/Module/Admin.php | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e1f45694..d2b62f74 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -1254,6 +1254,16 @@ public function get_survey_metadata( $data, $page_slug ) { $plugin_version = $plugin_data['Version']; } + $count_charts_cache_key = 'visualizer_count_charts'; + $charts_number = get_transient( $count_charts_cache_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 ); + } + $data = array( 'environmentId' => 'cltef8cut1s7wyyfxy3rlxzs5', 'attributes' => array( @@ -1261,6 +1271,7 @@ public function get_survey_metadata( $data, $page_slug ) { 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '', 'license_status' => $license_status, 'install_days_number' => $install_days_number, + 'charts_number' => $charts_number, ), ); @@ -1274,4 +1285,23 @@ public function get_survey_metadata( $data, $page_slug ) { 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', + ); + + $query = new WP_Query( $args); + return $query->post_count; + } } From e372a12a416ebce70764db9bc70356180c23aacd Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 4 Mar 2025 12:45:49 +0530 Subject: [PATCH 8/8] fix: special characters rendering issue --- classes/Visualizer/Source.php | 2 +- classes/Visualizer/Source/Csv.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Visualizer/Source.php b/classes/Visualizer/Source.php index 03e7c99a..7b3d6b59 100644 --- a/classes/Visualizer/Source.php +++ b/classes/Visualizer/Source.php @@ -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 ], ); } diff --git a/classes/Visualizer/Source/Csv.php b/classes/Visualizer/Source/Csv.php index 461fd8db..79665864 100644 --- a/classes/Visualizer/Source/Csv.php +++ b/classes/Visualizer/Source/Csv.php @@ -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, ); }