diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index e6ed796..39f0dc9 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -26,7 +26,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.0' tools: cs2pr coverage: none @@ -50,4 +50,4 @@ jobs: run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml - name: Show PHPCS results in PR - run: cs2pr --graceful-warnings ./phpcs-report.xml + run: cs2pr --graceful-warnings ./phpcs-report.xml \ No newline at end of file diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 017a66c..ce0e304 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -23,7 +23,7 @@ jobs: matrix: # Notes regarding supported versions in WP: # The base matrix only contains the PHP versions which are supported on all supported WP versions. - php: ['8.0', '7.3', '7.4'] + php: ['8.0', '8.1', '7.4'] wp: ['latest'] experimental: [false] @@ -37,8 +37,8 @@ jobs: - php: '8.2' wp: 'latest' experimental: true - - php: '8.1' - wp: 'latest' + - php: '8.2' + wp: '6.3' experimental: true - php: '8.0' wp: '5.9' @@ -71,23 +71,18 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: phpunit-polyfills + extensions: mysqli, mysql coverage: none - # The PHP 5.6 and 7.0 images don't include mysql[i] by default. - extensions: mysqli - - - name: Set up WordPress - run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }} # On WP 5.2, PHPUnit 5.x, 6.x and 7.x are supported. # On PHP >= 8.0, PHPUnit 7.5+ is needed, no matter what. - name: Determine supported PHPUnit version id: set_phpunit run: | - if [[ "${{ matrix.php }}" > "7.4" ]]; then - echo "PHPUNIT=8.5.*" >> $GITHUB_ENV + if [[ "${{ matrix.php }}" > "8.0" ]]; then + echo "PHPUNIT=9.*" >> $GITHUB_ENV else - echo "PHPUNIT=5.7.*||6.*||7.5.*" >> $GITHUB_ENV + echo "PHPUNIT=5.7.*||6.*||7.5.*||8.5.*" >> $GITHUB_ENV fi - name: 'Composer: set up PHPUnit' @@ -99,30 +94,32 @@ jobs: # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies for PHP < 8.0 if: ${{ matrix.php < 8.0 }} - uses: "ramsey/composer-install@v3" + uses: "ramsey/composer-install@v2" # For the PHP 8.0 and above, we need to install with ignore platform reqs as not all dependencies allow it yet. - name: Install Composer dependencies for PHP >= 8.0 if: ${{ matrix.php >= 8.0 }} - uses: "ramsey/composer-install@v3" + uses: "ramsey/composer-install@v2" with: composer-options: --ignore-platform-reqs - - name: 'Run Composer Update' - run: | - composer update --ignore-platform-reqs + - name: Install Subversion + run: sudo apt-get install subversion + + - name: Set up WordPress + run: phpunit/install.sh wordpress_test root '' 127.0.0.1:3306 ${{ matrix.wp }} - name: Tool versions run: | php --version composer --version - phpunit --version - which phpunit + ./vendor/bin/phpunit --version + which ./vendor/bin/phpunit - name: Run the unit tests - single site - run: vendor/bin/phpunit + run: ./vendor/bin/phpunit - name: Run the unit tests - multisite - run: vendor/bin/phpunit env: WP_MULTISITE: 1 + run: ./vendor/bin/phpunit \ No newline at end of file diff --git a/.github/workflows/zipitup.yml b/.github/workflows/zipitup.yml index ef83cfa..e4b9355 100644 --- a/.github/workflows/zipitup.yml +++ b/.github/workflows/zipitup.yml @@ -29,15 +29,15 @@ jobs: - name: Create artifact uses: montudor/action-zip@v1 with: - args: zip -X -r build/knowledgebase.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml composer.* dev-helpers** build** wporg-assets** phpunit** + args: zip -X -r build/${{ github.event.repository.name }}.zip . -x *.git* node_modules/\* .* "*/\.*" CODE_OF_CONDUCT.md CONTRIBUTING.md ISSUE_TEMPLATE.md PULL_REQUEST_TEMPLATE.md *.dist *.yml *.neon composer.* package.json dev-helpers** build** wporg-assets** phpunit** - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: knowledgebase - path: build/knowledgebase.zip + name: ${{ github.event.repository.name }} + path: build/${{ github.event.repository.name }}.zip - name: Upload to release uses: JasonEtco/upload-to-release@master with: - args: build/knowledgebase.zip application/zip + args: build/${{ github.event.repository.name }}.zip application/zip env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 diff --git a/README.md b/README.md index bb2688e..f2aa951 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ __Requires:__ 6.3 -__Tested up to:__ 6.7 +__Tested up to:__ 6.8 __License:__ [GPL-2.0+](http://www.gnu.org/licenses/gpl-2.0.html) diff --git a/composer.json b/composer.json index bf81ab6..00601eb 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "webberzone/knowledgebase", "description": "Fastest way to create a highly-flexible multi-product knowledge base.", - "version": "2.3.0", "type": "wordpress-plugin", "keywords": [ "knowledge base", @@ -30,12 +29,18 @@ "dealerdirect/phpcodesniffer-composer-installer": "^1", "phpcompatibility/phpcompatibility-wp": "^2", "yoast/phpunit-polyfills": "^3", - "phpunit/phpunit": "^5.7.21 || ^6.5 || ^7.5" + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11 || ^12" }, "config": { "allow-plugins": { "phpstan/extension-installer": true, "dealerdirect/phpcodesniffer-composer-installer": true } + }, + "scripts": { + "phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M", + "phpstan-baseline": "vendor/bin/phpstan analyse --generate-baseline --memory-limit=2048M", + "phpcs": "vendor/bin/phpcs -p -v -s --standard=phpcs.xml.dist $(find . -name '*.php')", + "phpcbf": "vendor/bin/phpcbf -p -v -s --standard=phpcs.xml.dist $(find . -name '*.php')" } } \ No newline at end of file diff --git a/includes/admin/settings/class-settings-api.php b/includes/admin/settings/class-settings-api.php index 0402f7c..2ea3c71 100644 --- a/includes/admin/settings/class-settings-api.php +++ b/includes/admin/settings/class-settings-api.php @@ -252,12 +252,12 @@ public function set_translation_strings( $strings ) { // Args prefixed with an underscore are reserved for internal use. $defaults = array( 'page_header' => '', - 'reset_message' => __( 'Settings have been reset to their default values. Reload this page to view the updated settings.' ), - 'success_message' => __( 'Settings updated.' ), - 'save_changes' => __( 'Save Changes' ), - 'reset_settings' => __( 'Reset all settings' ), - 'reset_button_confirm' => __( 'Do you really want to reset all these settings to their default values?' ), - 'checkbox_modified' => __( 'Modified from default setting' ), + 'reset_message' => 'Settings have been reset to their default values. Reload this page to view the updated settings.', + 'success_message' => 'Settings updated.', + 'save_changes' => 'Save Changes', + 'reset_settings' => 'Reset all settings', + 'reset_button_confirm' => 'Do you really want to reset all these settings to their default values?', + 'checkbox_modified' => 'Modified from default setting', ); $strings = wp_parse_args( $strings, $defaults ); @@ -486,7 +486,7 @@ public function admin_enqueue_scripts( $hook ) { ); wp_register_script( 'wz-codemirror-js', - plugins_url( 'js/apply-codemirror' . $minimize . '.js', __FILE__ ), + plugins_url( 'js/apply-cm' . $minimize . '.js', __FILE__ ), array( 'jquery' ), self::VERSION, true diff --git a/includes/admin/settings/class-settings-form.php b/includes/admin/settings/class-settings-form.php index 35ddff1..e66a5f2 100644 --- a/includes/admin/settings/class-settings-form.php +++ b/includes/admin/settings/class-settings-form.php @@ -115,7 +115,7 @@ public function get_option( $option, $default_value = '' ) { */ public function callback_missing( $args ) { /* translators: 1: Code. */ - printf( esc_html__( 'The callback function used for the %1$s setting is missing.' ), '' . esc_attr( $args['id'] ) . '' ); + printf( 'The callback function used for the %1$s setting is missing.', '' . esc_attr( $args['id'] ) . '' ); } /** @@ -478,7 +478,7 @@ public function callback_thumbsizes( $args ) { $name, (int) $option['width'], (int) $option['height'], - (bool) $option['crop'] ? ' ' . __( 'cropped' ) : '' + (bool) $option['crop'] ? ' cropped' : '' ); } @@ -704,7 +704,7 @@ public function callback_file( $args ) { $value = isset( $args['value'] ) ? $args['value'] : $this->get_option( $args['id'], $args['options'] ); $size = sanitize_html_class( isset( $args['size'] ) ? $args['size'] : 'regular' ); $class = sanitize_html_class( $args['field_class'] ); - $label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : __( 'Choose File' ); + $label = isset( $args['options']['button_label'] ) ? $args['options']['button_label'] : 'Choose File'; $html = sprintf( '', diff --git a/includes/admin/settings/js/apply-codemirror.js b/includes/admin/settings/js/apply-cm.js similarity index 100% rename from includes/admin/settings/js/apply-codemirror.js rename to includes/admin/settings/js/apply-cm.js diff --git a/includes/admin/settings/js/apply-codemirror.min.js b/includes/admin/settings/js/apply-cm.min.js similarity index 100% rename from includes/admin/settings/js/apply-codemirror.min.js rename to includes/admin/settings/js/apply-cm.min.js diff --git a/includes/frontend/class-breadcrumbs.php b/includes/frontend/class-breadcrumbs.php index b330070..0955dfb 100644 --- a/includes/frontend/class-breadcrumbs.php +++ b/includes/frontend/class-breadcrumbs.php @@ -7,6 +7,8 @@ namespace WebberZone\Knowledge_Base\Frontend; +use WebberZone\Knowledge_Base\Util\Helpers; + if ( ! defined( 'WPINC' ) ) { die; } @@ -50,6 +52,7 @@ public static function get_breadcrumb( $args = array() ) { // Parse incoming $args into an array and merge it with $defaults. $args = wp_parse_args( $args, $defaults ); + $args = Helpers::sanitize_args( $args ); // Convert Unicode sequence if provided. if ( strpos( $args['separator'], '\\' ) === 0 ) { @@ -139,6 +142,7 @@ private static function get_hierarchical_term_trail( \WP_Term $taxonomy, $args = ); $args = wp_parse_args( $args, $defaults ); + $args = Helpers::sanitize_args( $args ); $output = '
diff --git a/includes/widgets/index.php b/includes/widgets/index.php old mode 100644 new mode 100755 diff --git a/index.php b/index.php old mode 100644 new mode 100755 diff --git a/knowledgebase.php b/knowledgebase.php old mode 100644 new mode 100755 index 25857d1..6c81526 --- a/knowledgebase.php +++ b/knowledgebase.php @@ -13,7 +13,7 @@ * Plugin Name: WebberZone Knowledge Base * Plugin URI: https://github.com/WebberZone/knowledgebase * Description: Create a multi-product knowledge base on your WordPress site. - * Version: 2.3.0 + * Version: 2.3.1 * Author: WebberZone * Author URI: https://webberzone.com * License: GPL-2.0+ @@ -37,7 +37,7 @@ * * @var string $wzkb_version Plugin version */ - define( 'WZKB_VERSION', '2.3.0' ); + define( 'WZKB_VERSION', '2.3.1' ); } if ( ! defined( 'WZKB_PLUGIN_DIR' ) ) { diff --git a/languages/index.php b/languages/index.php old mode 100644 new mode 100755 diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index bf54b88..8bafd6c 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -1,14 +1,8 @@