From ac11d68a6f53fa2886ea7cfa8f07534ed1d3c377 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 14 Feb 2025 16:19:19 +0200 Subject: [PATCH 1/8] feat: load survey vis internal pages hooks --- functions.php | 1 + inc/Admin.php | 44 +++++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/functions.php b/functions.php index a5a75c2..f939ecc 100644 --- a/functions.php +++ b/functions.php @@ -71,6 +71,7 @@ function define_constants() { define( 'FORK_DEBUG', defined( 'WP_DEBUG' ) && WP_DEBUG === true ); define( 'FORK_DIR', trailingslashit( get_template_directory() ) ); define( 'FORK_URL', trailingslashit( get_template_directory_uri() ) ); + define( 'FORK_PRODUCT_SLUG', basename( FORK_DIR ) ); } /** diff --git a/inc/Admin.php b/inc/Admin.php index cae9848..fcbc1cf 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -33,7 +33,7 @@ public function setup_admin_hooks() { add_action( 'admin_notices', array( $this, 'render_welcome_notice' ), 0 ); add_action( 'wp_ajax_fork_dismiss_welcome_notice', array( $this, 'remove_welcome_notice' ) ); add_action( 'wp_ajax_fork_set_otter_ref', array( $this, 'set_otter_ref' ) ); - add_action( 'admin_print_scripts', array( $this, 'add_nps_form' ) ); + add_action( 'admin_enqueue_scripts', array( $this, 'register_internal_page' ) ); add_action( 'enqueue_block_editor_assets', array( $this, 'add_fse_design_pack_notice' ) ); add_action( 'wp_ajax_fork_dismiss_design_pack_notice', array( $this, 'remove_design_pack_notice' ) ); @@ -307,27 +307,37 @@ private function get_otter_status(): string { } /** - * Add NPS form. + * Register internal pages. * * @return void */ - public function add_nps_form() { + public function register_internal_page() { $screen = get_current_screen(); - - if ( current_user_can( 'manage_options' ) && ( 'dashboard' === $screen->id || 'themes' === $screen->id ) ) { - $website_url = preg_replace( '/[^a-zA-Z0-9]+/', '', get_site_url() ); - - $config = array( - 'environmentId' => 'clr7hsvmjeu0u8up04ydg210b', - 'apiHost' => 'https://app.formbricks.com', - 'userId' => 'fork_' . $website_url, - 'attributes' => array( - 'days_since_install' => self::convert_to_category( round( ( time() - get_option( 'fork_install', time() ) ) / DAY_IN_SECONDS ) ), - ), - ); - - echo ''; + + if ( ! current_user_can( 'manage_options' ) || ( 'dashboard' !== $screen->id && 'themes' !== $screen->id ) ) { + return; } + + add_filter( + 'themeisle-sdk/survey/' . FORK_PRODUCT_SLUG, + function( $data, $page_slug ) { + $install_days_number = intval( ( time() - get_option( 'fork_install', time() ) ) / DAY_IN_SECONDS ); + + $data = array( + 'environmentId' => 'clr7hsvmjeu0u8up04ydg210b', + 'attributes' => array( + 'days_since_install' => self::convert_to_category( $install_days_number ), + 'install_days_number' => $install_days_number, + 'version' => FORK_VERSION, + ), + ); + + return $data; + }, + 10, + 2 + ); + do_action( 'themeisle_internal_page', FORK_PRODUCT_SLUG, $screen->id ); } /** From 0d2066c5f5409fbd30947d8cebc19d2163ef7486 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 14 Feb 2025 16:19:34 +0200 Subject: [PATCH 2/8] fix: update PHP workflow to use Ubuntu 22.04 --- .github/workflows/test-php.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index e465cd8..9f0f463 100644 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -3,17 +3,17 @@ name: Test PHP on: push: branches-ignore: - - 'master' + - "master" jobs: phplint: name: Phplint - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Setup PHP version uses: shivammathur/setup-php@v2 with: - php-version: '7.2' + php-version: "7.2" extensions: simplexml - name: Checkout source code uses: actions/checkout@v2 @@ -34,7 +34,7 @@ jobs: run: composer run lint phpunit: name: Phpunit - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 services: mysql: image: mysql:5.7 @@ -47,7 +47,7 @@ jobs: - name: Setup PHP version uses: shivammathur/setup-php@v2 with: - php-version: '7.2' + php-version: "7.2" extensions: simplexml, mysql tools: phpunit-polyfills - name: Checkout source code @@ -69,4 +69,4 @@ jobs: - name: Install composer run: composer install --prefer-dist --no-progress --no-suggest - name: Run phpunit - run: composer run-script phpunit \ No newline at end of file + run: composer run-script phpunit From 176ccc64ca29c00a446084a63defd120682f4771 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 18 Feb 2025 14:27:48 +0200 Subject: [PATCH 3/8] refactor: remove install category from survey --- inc/Admin.php | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/inc/Admin.php b/inc/Admin.php index fcbc1cf..853d439 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -326,7 +326,6 @@ function( $data, $page_slug ) { $data = array( 'environmentId' => 'clr7hsvmjeu0u8up04ydg210b', 'attributes' => array( - 'days_since_install' => self::convert_to_category( $install_days_number ), 'install_days_number' => $install_days_number, 'version' => FORK_VERSION, ), @@ -339,28 +338,4 @@ function( $data, $page_slug ) { ); do_action( 'themeisle_internal_page', FORK_PRODUCT_SLUG, $screen->id ); } - - /** - * Convert a number to a category. - * - * @param int $number Number to convert. - * @param int $scale Scale. - * - * @return int - */ - public static function convert_to_category( $number, $scale = 1 ) { - $normalized_number = intval( round( $number / $scale ) ); - - if ( 0 === $normalized_number || 1 === $normalized_number ) { - return 0; - } elseif ( $normalized_number > 1 && $normalized_number < 8 ) { - return 7; - } elseif ( $normalized_number >= 8 && $normalized_number < 31 ) { - return 30; - } elseif ( $normalized_number > 30 && $normalized_number < 90 ) { - return 90; - } elseif ( $normalized_number > 90 ) { - return 91; - } - } } From 2df1b4cd0ec9b68aa68f1badf274ebcd9b1959fe Mon Sep 17 00:00:00 2001 From: vytisbulkevicius <36594177+vytisbulkevicius@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:05:55 +0300 Subject: [PATCH 4/8] Update test-js.yml Updated cache version --- .github/workflows/test-js.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml index 622c05f..7e62d6c 100644 --- a/.github/workflows/test-js.yml +++ b/.github/workflows/test-js.yml @@ -22,7 +22,7 @@ jobs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -34,4 +34,4 @@ jobs: - name: Build source run: yarn run build - name: Run lint checks - run: yarn run lint \ No newline at end of file + run: yarn run lint From 14a1154002f14dbbe4dc714398c9492954b1257f Mon Sep 17 00:00:00 2001 From: vytisbulkevicius <36594177+vytisbulkevicius@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:08:42 +0300 Subject: [PATCH 5/8] Update test-php.yml --- .github/workflows/test-php.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index 9f0f463..5acc5d1 100644 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -22,7 +22,7 @@ jobs: run: | echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Setup Composer cache - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -60,7 +60,7 @@ jobs: run: | echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Setup Composer cache - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} From 43e4ab3cee5c3dbb8693bcf8e76ae3a8db8b1c49 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius <36594177+vytisbulkevicius@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:18:23 +0300 Subject: [PATCH 6/8] Update create-build-zip.yml --- .github/workflows/create-build-zip.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-build-zip.yml b/.github/workflows/create-build-zip.yml index 6afd345..3236dd7 100644 --- a/.github/workflows/create-build-zip.yml +++ b/.github/workflows/create-build-zip.yml @@ -25,7 +25,7 @@ jobs: run: | echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Configure Composer cache - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} @@ -103,4 +103,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 }} From b1200466ebda7ff6cf7541b7db48e50c9dafbce5 Mon Sep 17 00:00:00 2001 From: vytisbulkevicius <36594177+vytisbulkevicius@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:18:49 +0300 Subject: [PATCH 7/8] Update deploy-s3-store.yml --- .github/workflows/deploy-s3-store.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-s3-store.yml b/.github/workflows/deploy-s3-store.yml index aaa0da4..c5c01c1 100644 --- a/.github/workflows/deploy-s3-store.yml +++ b/.github/workflows/deploy-s3-store.yml @@ -17,7 +17,7 @@ jobs: - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 + - uses: actions/cache@v4 id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} From 085ad9e2262e5ee4fd678c708fdd32dd767a26b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 07:22:13 +0000 Subject: [PATCH 8/8] chore(deps): bump codeinwp/themeisle-sdk from 3.3.37 to 3.3.44 Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.37 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.37...v3.3.44) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-version: 3.3.44 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 7d30c81..52346a6 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.37", + "version": "3.3.44", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "73e9010fb4e30ad8835f00a0df802733f98c4094" + "reference": "fed444b52ebf1f689ec2434df177926bf8f238c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/73e9010fb4e30ad8835f00a0df802733f98c4094", - "reference": "73e9010fb4e30ad8835f00a0df802733f98c4094", + "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.37" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.44" }, - "time": "2024-11-06T14:44:53+00:00" + "time": "2025-02-18T21:31:30+00:00" } ], "packages-dev": [ @@ -2418,5 +2418,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" }