Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
39 changes: 18 additions & 21 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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
10 changes: 5 additions & 5 deletions .github/workflows/zipitup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Empty file modified LICENSE.txt
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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')"
}
}
14 changes: 7 additions & 7 deletions includes/admin/settings/class-settings-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions includes/admin/settings/class-settings-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' ), '<strong>' . esc_attr( $args['id'] ) . '</strong>' );
printf( 'The callback function used for the %1$s setting is missing.', '<strong>' . esc_attr( $args['id'] ) . '</strong>' );
}

/**
Expand Down Expand Up @@ -478,7 +478,7 @@ public function callback_thumbsizes( $args ) {
$name,
(int) $option['width'],
(int) $option['height'],
(bool) $option['crop'] ? ' ' . __( 'cropped' ) : ''
(bool) $option['crop'] ? ' cropped' : ''
);
}

Expand Down Expand Up @@ -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(
'<input type="text" class="%1$s" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>',
Expand Down
4 changes: 4 additions & 0 deletions includes/frontend/class-breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace WebberZone\Knowledge_Base\Frontend;

use WebberZone\Knowledge_Base\Util\Helpers;

if ( ! defined( 'WPINC' ) ) {
die;
}
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 = '<li class="wzkb_breadcrumb-item" data-separator="' . esc_attr( $args['separator'] ) . '" itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">';
$output .= '<a href="' . esc_url( get_term_link( $taxonomy ) ) . '" itemprop="item" title="' . esc_attr( $taxonomy->name ) . '">';
Expand Down
3 changes: 3 additions & 0 deletions includes/frontend/class-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace WebberZone\Knowledge_Base\Frontend;

use WebberZone\Knowledge_Base\Util\Cache;
use WebberZone\Knowledge_Base\Util\Helpers;

if ( ! defined( 'WPINC' ) ) {
die;
Expand Down Expand Up @@ -64,6 +65,7 @@ public static function get_knowledge_base( $args = array() ) {
);

$args = wp_parse_args( $args, $defaults );
$args = Helpers::sanitize_args( $args );

// Set defaults if variables are empty.
$args['limit'] = ( ! empty( absint( $args['limit'] ) ) ) ? absint( $args['limit'] ) : \wzkb_get_option( 'limit' );
Expand Down Expand Up @@ -379,6 +381,7 @@ public static function get_categories_list( $term_id, $level = 0, $args = array(
);

$args = wp_parse_args( $args, $defaults );
$args = Helpers::sanitize_args( $args );

// Get Knowledge Base Sections.
$sections = get_terms(
Expand Down
4 changes: 1 addition & 3 deletions includes/frontend/templates/archive-wz_knowledgebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// If no content, include the "No posts found" template.
else :
esc_html_e( 'No results found', 'wzkb' );
esc_html_e( 'No results found', 'knowledgebase' );

endif;
?>
Expand All @@ -50,5 +50,3 @@

<?php
get_footer();


6 changes: 5 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use WebberZone\Knowledge_Base\Frontend\Media_Handler;
use WebberZone\Knowledge_Base\Frontend\Related;
use WebberZone\Knowledge_Base\Util\Helpers;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
Expand Down Expand Up @@ -102,8 +103,9 @@ function wzkb_get_alert( $args = array(), $content = '' ) {

// Parse incomming $args into an array and merge it with $defaults.
$args = wp_parse_args( $args, $defaults );
$args = Helpers::sanitize_args( $args );

$type = 'wzkb-alert-' . $args['type'];
$type = 'wzkb-alert-' . sanitize_html_class( $args['type'] );

$class = implode( ' ', explode( ',', $args['class'] ) );
$class = $type . ' ' . $class;
Expand Down Expand Up @@ -161,6 +163,7 @@ function wzkb_get_the_post_thumbnail( $args = array() ) {

// Parse incomming $args into an array and merge it with $defaults.
$args = wp_parse_args( $args, $defaults );
$args = Helpers::sanitize_args( $args );

return Media_Handler::get_the_post_thumbnail( $args );
}
Expand All @@ -180,6 +183,7 @@ function wzkb_related_articles( $args = array() ) {
);

$args = wp_parse_args( $args, $defaults );
$args = Helpers::sanitize_args( $args );

$related = Related::get_related_articles( $args );

Expand Down
2 changes: 1 addition & 1 deletion includes/options-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function wz_tag_search() {

$s = isset( $_REQUEST['q'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['q'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended

$comma = _x( ',', 'tag delimiter' );
$comma = _x( ',', 'tag delimiter', 'knowledgebase' );
if ( ',' !== $comma ) {
$s = str_replace( $comma, ',', $s );
}
Expand Down
28 changes: 28 additions & 0 deletions includes/util/class-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,32 @@ public static function get_credit_link() {

return $output;
}

/**
* Sanitize args.
*
* @since 2.3.1
*
* @param array $args Array of arguments.
* @return array Sanitized array of arguments.
*/
public static function sanitize_args( $args ): array {
foreach ( $args as $key => $value ) {
if ( is_string( $value ) ) {
switch ( $key ) {
case 'class':
case 'className':
case 'extra_class':
$classes = explode( ' ', $value );
$sanitized_classes = array_map( 'sanitize_html_class', $classes );
$args[ $key ] = implode( ' ', $sanitized_classes );
break;
default:
$args[ $key ] = wp_kses_post( $value );
break;
}
}
}
return $args;
}
}
4 changes: 2 additions & 2 deletions includes/widgets/class-articles-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public function form( $instance ) {
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>">
<?php esc_html_e( 'No. of posts', 'contextual-related-posts' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" />
<?php esc_html_e( 'No. of posts', 'knowledgebase' ); ?>: <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" type="text" value="<?php echo esc_attr( $limit ); ?>" />
</label>
</p>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>">
<input id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox" <?php checked( true, $show_excerpt, true ); ?> /> <?php esc_html_e( ' Show excerpt?', 'contextual-related-posts' ); ?>
<input id="<?php echo esc_attr( $this->get_field_id( 'show_excerpt' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_excerpt' ) ); ?>" type="checkbox" <?php checked( true, $show_excerpt, true ); ?> /> <?php esc_html_e( ' Show excerpt?', 'knowledgebase' ); ?>
</label>
</p>

Expand Down
Empty file modified includes/widgets/index.php
100644 → 100755
Empty file.
Empty file modified index.php
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions knowledgebase.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -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' ) ) {
Expand Down
Empty file modified languages/index.php
100644 → 100755
Empty file.
Loading