diff --git a/.github/workflows/diff-translations.yml b/.github/workflows/diff-translations.yml new file mode 100644 index 0000000..8745525 --- /dev/null +++ b/.github/workflows/diff-translations.yml @@ -0,0 +1,74 @@ +name: Translations Diff + +on: + pull_request_review: + pull_request: + types: [opened, edited, synchronize, ready_for_review] + branches: + - 'development' + +jobs: + translation: + runs-on: ubuntu-latest + steps: + - name: Checkout Ref Base + uses: actions/checkout@v2 + with: + path: jaxon-head + - name: Setup node 14 + uses: actions/setup-node@v1 + with: + node-version: 14.x + - name: FRESH Makepot BASE + run: | + cd jaxon-head + ls languages/ + composer install --no-dev --prefer-dist --no-progress --no-suggest + yarn install --frozen-lockfile + yarn run build + ls languages/ + - name: Checkout Ref Head + uses: actions/checkout@v2 + with: + ref: development + path: jaxon-base + - name: FRESH Makepot HEAD + run: | + cd jaxon-base + ls languages/ + composer install --no-dev --prefer-dist --no-progress --no-suggest + yarn install --frozen-lockfile + yarn run build + ls languages/ + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: find_coomment + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'pirate-bot' + body-includes: PR has POT difference + - name: Install PODiff + run: | + curl -o podiff.gz ftp://download.gnu.org.ua/pub/releases/podiff/podiff-1.3.tar.gz + tar -xf podiff.gz + cd podiff-1.3 + make + mkdir -p $GITHUB_WORKSPACE/bin + mv ./podiff $GITHUB_WORKSPACE/bin + echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH + cd .. + - name: Run Podiff + id: translation_status + run: | + ${GITHUB_WORKSPACE}/jaxon-head/bin/pot-diff.sh ./jaxon-base/languages/jaxon.pot ./jaxon-head/languages/jaxon.pot $PERCENT_TRESHOLD + - name: Step require review + if: steps.translation_status.outputs.has_pot_diff != 'success' + uses: Automattic/action-required-review@v3 + with: + requirements: | + - name: Everything else + paths: unmatched + teams: + - "sbs" + status: Has translation changes, a review from SBS team is required + token: ${{ secrets.BOT_TOKEN }} diff --git a/bin/pot-diff.sh b/bin/pot-diff.sh new file mode 100755 index 0000000..4aea2ad --- /dev/null +++ b/bin/pot-diff.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Set Arguments +file1="$1" +file2="$2" + +## Striping headers for file1 and file2. + +sed '/^"/d' $file1 > $file1.edited +mv $file1.edited $file1 +sed '/^"/d' ${file2} > ${file2}.edited +mv ${file2}.edited ${file2} + +if [[ $(podiff $file1 $file2) ]]; then + podiff $file1 $file2 + echo "has_pot_diff=failure" >> $GITHUB_OUTPUT +else + echo "has_pot_diff=success" >> $GITHUB_OUTPUT + echo "No differences found" +fi diff --git a/composer.json b/composer.json index c9b08d4..aa07e6b 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "wp-coding-standards/wpcs": "^2.3", "squizlabs/php_codesniffer": "^3.7", "phpcompatibility/php-compatibility": "^9.3", - "yoast/phpunit-polyfills": "^1.0" + "yoast/phpunit-polyfills": "^2.0" }, "scripts": { "format-fix-exit": "\"vendor/bin/phpcbf-fix-exit-0\" --standard=phpcs.xml --report-summary --report-source -s --runtime-set testVersion 7.0- ", diff --git a/composer.lock b/composer.lock index c787c64..2bc7501 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "80fe500fc7b976af9a0bb956e33e7e72", + "content-hash": "a0359fc838f49c5af45ab4825e4dd42b", "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.0", + "version": "3.3.13", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "68dc5d11c1d7a20a13f3ae730183f61ff309d574" + "reference": "2209cdf402e8f97def8d699bb8447dc67585cc95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/68dc5d11c1d7a20a13f3ae730183f61ff309d574", - "reference": "68dc5d11c1d7a20a13f3ae730183f61ff309d574", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/2209cdf402e8f97def8d699bb8447dc67585cc95", + "reference": "2209cdf402e8f97def8d699bb8447dc67585cc95", "shasum": "" }, "require-dev": { @@ -42,36 +42,36 @@ ], "support": { "issues": "https://github.com/Codeinwp/themeisle-sdk/issues", - "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.0" + "source": "https://github.com/Codeinwp/themeisle-sdk/tree/v3.3.13" }, - "time": "2023-05-30T08:55:06+00:00" + "time": "2024-02-01T14:10:46+00:00" } ], "packages-dev": [ { "name": "automattic/vipwpcs", - "version": "2.3.3", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/Automattic/VIP-Coding-Standards.git", - "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b" + "reference": "b8610e3837f49c5f2fcc4b663b6c0a7c9b3509b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", - "reference": "6cd0a6a82bc0ac988dbf9d6a7c2e293dc8ac640b", + "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/b8610e3837f49c5f2fcc4b663b6c0a7c9b3509b6", + "reference": "b8610e3837f49c5f2fcc4b663b6c0a7c9b3509b6", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "sirbrillig/phpcs-variable-analysis": "^2.11.1", - "squizlabs/php_codesniffer": "^3.5.5", + "sirbrillig/phpcs-variable-analysis": "^2.11.17", + "squizlabs/php_codesniffer": "^3.7.1", "wp-coding-standards/wpcs": "^2.3" }, "require-dev": { - "php-parallel-lint/php-console-highlighter": "^0.5", - "php-parallel-lint/php-parallel-lint": "^1.0", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9", "phpcsstandards/phpcsdevtools": "^1.0", "phpunit/phpunit": "^4 || ^5 || ^6 || ^7" @@ -91,6 +91,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -98,7 +99,7 @@ "source": "https://github.com/Automattic/VIP-Coding-Standards", "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" }, - "time": "2021-09-29T16:20:23+00:00" + "time": "2023-08-24T15:11:13+00:00" }, { "name": "codeinwp/phpcs-ruleset", @@ -264,8 +265,22 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/master" + "source": "https://github.com/doctrine/instantiator/tree/1.0.5" }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], "time": "2015-06-14T21:17:01+00:00" }, { @@ -1889,16 +1904,16 @@ }, { "name": "sirbrillig/phpcs-variable-analysis", - "version": "v2.11.9", + "version": "v2.11.17", "source": { "type": "git", "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", - "reference": "62730888d225d55a613854b6a76fb1f9f57d1618" + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/62730888d225d55a613854b6a76fb1f9f57d1618", - "reference": "62730888d225d55a613854b6a76fb1f9f57d1618", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/3b71162a6bf0cde2bff1752e40a1788d8273d049", + "reference": "3b71162a6bf0cde2bff1752e40a1788d8273d049", "shasum": "" }, "require": { @@ -1906,7 +1921,7 @@ "squizlabs/php_codesniffer": "^3.5.6" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", "phpcsstandards/phpcsdevcs": "^1.1", "phpstan/phpstan": "^1.7", "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0", @@ -1943,20 +1958,20 @@ "source": "https://github.com/sirbrillig/phpcs-variable-analysis", "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" }, - "time": "2022-10-05T23:31:46+00:00" + "time": "2023-08-05T23:46:11+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.8.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", "shasum": "" }, "require": { @@ -1966,11 +1981,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -1985,21 +2000,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-01-11T20:47:48+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2304,30 +2343,29 @@ }, { "name": "yoast/phpunit-polyfills", - "version": "1.0.4", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", - "reference": "3c621ff5429d2b1ff96dc5808ad6cde99d31ea4c" + "reference": "c758753e8f9dac251fed396a73c8305af3f17922" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/3c621ff5429d2b1ff96dc5808ad6cde99d31ea4c", - "reference": "3c621ff5429d2b1ff96dc5808ad6cde99d31ea4c", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/c758753e8f9dac251fed396a73c8305af3f17922", + "reference": "c758753e8f9dac251fed396a73c8305af3f17922", "shasum": "" }, "require": { - "php": ">=5.4", - "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0" + "php": ">=5.6", + "phpunit/phpunit": "^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0" }, "require-dev": { - "yoast/yoastcs": "^2.2.1" + "yoast/yoastcs": "^2.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.x-dev", - "dev-develop": "1.x-dev" + "dev-main": "2.x-dev" } }, "autoload": { @@ -2361,7 +2399,7 @@ "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues", "source": "https://github.com/Yoast/PHPUnit-Polyfills" }, - "time": "2022-11-16T09:07:52+00:00" + "time": "2023-06-06T20:28:24+00:00" } ], "aliases": [], @@ -2376,5 +2414,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/inc/Admin.php b/inc/Admin.php index 9742eb9..3b34f01 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -20,19 +20,20 @@ class Admin { * Admin constructor. */ public function __construct() { - $this->setup_otter_notice(); + $this->setup_admin_hooks(); } /** - * Setup the Otter Blocks notice. + * Setup admin hooks. * * @return void */ - public function setup_otter_notice() { + public function setup_admin_hooks() { add_action( 'admin_notices', array( $this, 'render_welcome_notice' ), 0 ); add_action( 'wp_ajax_jaxon_dismiss_welcome_notice', array( $this, 'remove_welcome_notice' ) ); add_action( 'wp_ajax_jaxon_set_otter_ref', array( $this, 'set_otter_ref' ) ); + add_action( 'admin_print_scripts', array( $this, 'add_nps_form' ) ); } /** @@ -230,4 +231,52 @@ private function get_otter_status(): string { return $status; } + + /** + * Add NPS form. + * + * @return void + */ + public function add_nps_form() { + $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' => 'clr7jjqypey8v8up0bg5lk2nw', + 'apiHost' => 'https://app.formbricks.com', + 'userId' => 'jaxon_' . $website_url, + 'attributes' => array( + 'days_since_install' => self::convert_to_category( round( ( time() - get_option( 'jaxon_install', 0 ) ) / DAY_IN_SECONDS ) ), + ), + ); + + echo ''; + } + } + + /** + * 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; + } + } } diff --git a/readme.md b/readme.md index ad7f24a..129e6ff 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ **Contributors:** [themeisle](https://profiles.wordpress.org/themeisle/) **Tags:** block-patterns **Requires at least:** 5.5 -**Tested up to:** 6.1 +**Tested up to:** 6.4 **Stable tag:** trunk **Requires PHP:** 7.0 **License:** GPLv2 or later diff --git a/readme.txt b/readme.txt index fbcdd05..49e4694 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: themeisle Tags: block-patterns Requires at least: 5.5 -Tested up to: 6.1 +Tested up to: 6.4 Stable tag: trunk Requires PHP: 7.0 License: GPLv2 or later