diff --git a/.github/workflows/create-build-zip.yml b/.github/workflows/create-build-zip.yml index 70f5fa7..dab6ce1 100644 --- a/.github/workflows/create-build-zip.yml +++ b/.github/workflows/create-build-zip.yml @@ -2,7 +2,7 @@ name: Build and publish the ZIP build file on: pull_request: - types: [ opened, synchronize, ready_for_review ] + types: [opened, synchronize, ready_for_review] branches-ignore: - "update_dependencies" jobs: @@ -16,20 +16,10 @@ jobs: steps: - uses: actions/checkout@master - name: Setup node 14 - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - - 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 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- + cache: "yarn" - name: Install composer deps run: composer install --no-dev --prefer-dist --no-progress --no-suggest - name: Install yarn deps @@ -102,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 659d416..783f743 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -19,16 +19,7 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + cache: "yarn" - name: Release new version id: release run: | @@ -53,4 +44,4 @@ jobs: steps: - name: Meep run: | - echo "Nothing to do" \ No newline at end of file + echo "Nothing to do" diff --git a/.github/workflows/deploy-s3-store.yml b/.github/workflows/deploy-s3-store.yml index 88c6d4a..2d807a6 100644 --- a/.github/workflows/deploy-s3-store.yml +++ b/.github/workflows/deploy-s3-store.yml @@ -11,19 +11,10 @@ jobs: steps: - uses: actions/checkout@master - name: Setup node 14 - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + cache: "yarn" - name: Build & create dist/artifact run: | yarn install --frozen-lockfile @@ -43,8 +34,8 @@ jobs: AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DOWNLOADS }} AWS_ACCESS_KEY_ID: ${{ secrets.S3_DOWNLOADS_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DOWNLOADS_AWS_SECRET_ACCESS_KEY }} - AWS_REGION: 'us-west-1' # optional: defaults to us-east-1 - SOURCE_DIR: 'artifact' # optional: defaults to entire repository + AWS_REGION: "us-west-1" # optional: defaults to us-east-1 + SOURCE_DIR: "artifact" # optional: defaults to entire repository DEST_DIR: ${{ secrets.S3_AWS_PRODUCTS_FOLDER }}/$BUILD_NAME/latest - name: Upload Tagged Version to S3 uses: jakejarvis/s3-sync-action@master @@ -54,8 +45,8 @@ jobs: AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DOWNLOADS }} AWS_ACCESS_KEY_ID: ${{ secrets.S3_DOWNLOADS_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DOWNLOADS_AWS_SECRET_ACCESS_KEY }} - AWS_REGION: 'us-west-1' # optional: defaults to us-east-1 - SOURCE_DIR: 'artifact' # optional: defaults to entire repository + AWS_REGION: "us-west-1" # optional: defaults to us-east-1 + SOURCE_DIR: "artifact" # optional: defaults to entire repository DEST_DIR: ${{ secrets.S3_AWS_PRODUCTS_FOLDER }}/$BUILD_NAME/$BUILD_VERSION - name: Send update to the store env: @@ -64,4 +55,4 @@ jobs: STORE_URL: ${{ secrets.THEMEISLE_STORE_URL }} GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} BUILD_VERSION: ${{ env.BUILD_VERSION }} - uses: Codeinwp/action-store-release@main \ No newline at end of file + uses: Codeinwp/action-store-release@main diff --git a/.github/workflows/diff-translations.yml b/.github/workflows/diff-translations.yml index e2ed749..0fea7df 100644 --- a/.github/workflows/diff-translations.yml +++ b/.github/workflows/diff-translations.yml @@ -5,18 +5,18 @@ on: pull_request: types: [opened, edited, synchronize, ready_for_review] branches: - - 'development' + - "development" jobs: translation: runs-on: ubuntu-latest steps: - name: Checkout Ref Base - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: raft-head - name: Setup node 14 - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: 14.x - name: FRESH Makepot BASE @@ -28,7 +28,7 @@ jobs: yarn run build ls languages/ - name: Checkout Ref Head - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: development path: raft-base @@ -45,7 +45,7 @@ jobs: id: find_coomment with: issue-number: ${{ github.event.pull_request.number }} - comment-author: 'pirate-bot' + comment-author: "pirate-bot" body-includes: PR has POT difference - name: Install PODiff run: | @@ -71,4 +71,4 @@ jobs: teams: - "sbs" status: Has translation changes, a review from SBS team is required - token: ${{ secrets.BOT_TOKEN }} + token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml index 622c05f..d32d774 100644 --- a/.github/workflows/test-js.yml +++ b/.github/workflows/test-js.yml @@ -3,7 +3,7 @@ name: Test JS on: push: branches-ignore: - - 'master' + - "master" jobs: jslint: @@ -16,22 +16,13 @@ jobs: - name: Checkout source code uses: actions/checkout@master - name: Setup node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v2 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + cache: "yarn" - name: Install Dependencies run: yarn install --frozen-lockfile - 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 diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml index e465cd8..a95f7d2 100644 --- a/.github/workflows/test-php.yml +++ b/.github/workflows/test-php.yml @@ -3,38 +3,27 @@ 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 - - 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 --no-suggest - name: Run PHPCS run: composer run lint phpunit: name: Phpunit - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 services: mysql: image: mysql:5.7 @@ -47,26 +36,15 @@ 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 - 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-suggest - name: Run phpunit - run: composer run-script phpunit \ No newline at end of file + run: composer run-script phpunit diff --git a/composer.lock b/composer.lock index 7252a0d..2854bae 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": [ @@ -2413,5 +2413,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/functions.php b/functions.php index 4badfd3..b7035e7 100644 --- a/functions.php +++ b/functions.php @@ -71,6 +71,7 @@ function define_constants() { define( 'RAFT_DEBUG', defined( 'WP_DEBUG' ) && WP_DEBUG === true ); define( 'RAFT_DIR', trailingslashit( get_template_directory() ) ); define( 'RAFT_URL', trailingslashit( get_template_directory_uri() ) ); + define( 'RAFT_PRODUCT_SLUG', basename( RAFT_DIR ) ); } /** diff --git a/inc/Admin.php b/inc/Admin.php index b333757..e8332cc 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -33,7 +33,7 @@ public function setup_admin_hooks() { add_action( 'wp_ajax_raft_dismiss_welcome_notice', array( $this, 'remove_welcome_notice' ) ); add_action( 'wp_ajax_raft_set_otter_ref', array( $this, 'set_otter_ref' ) ); add_action( 'activated_plugin', array( $this, 'after_otter_activation' ) ); - 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_raft_dismiss_design_pack_notice', array( $this, 'remove_design_pack_notice' ) ); @@ -380,50 +380,35 @@ public function after_otter_activation( $plugin ) { } /** - * 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' => 'clp9hp3j71oqndl2ietgq8nej', - 'apiHost' => 'https://app.formbricks.com', - 'userId' => 'raft_' . $website_url, - 'attributes' => array( - 'days_since_install' => self::convert_to_category( round( ( time() - get_option( 'raft_install', time() ) ) / DAY_IN_SECONDS ) ), - ), - ); - - echo ''; + + if ( ! current_user_can( 'manage_options' ) || ( 'dashboard' !== $screen->id && 'themes' !== $screen->id ) ) { + return; } - } + + add_filter( + 'themeisle-sdk/survey/' . RAFT_PRODUCT_SLUG, + function( $data, $page_slug ) { + $install_days_number = intval( ( time() - get_option( 'raft_install', time() ) ) / DAY_IN_SECONDS ); + + $data = array( + 'environmentId' => 'clp9hp3j71oqndl2ietgq8nej', + 'attributes' => array( + 'install_days_number' => $install_days_number, + 'version' => RAFT_VERSION, + ), + ); - /** - * 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; - } + return $data; + }, + 10, + 2 + ); + do_action( 'themeisle_internal_page', RAFT_PRODUCT_SLUG, $screen->id ); } }