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
7 changes: 5 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ env:

jobs:
test:
name: PHP 8.5
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
matrix:
php: ['8.3', '8.5']
services:
mysql:
image: mysql:8.4
Expand All @@ -40,7 +43,7 @@ jobs:
- uses: actions/checkout@v6
- uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
php-version: ${{ matrix.php }}
extensions: gd, exif, intl, mbstring, mysqli, xml, zip
tools: composer
coverage: none
Expand Down
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ WebberZone Knowledge Base, namespace `WebberZone\Knowledge_Base`, is a WordPress

## Build & Development Commands

Cross-release plans and agent notes live in `dev-helpers/plans/` (excluded from `build-zip.sh`; not shipped). Product docs for customers stay in `docs/`.

### PHP

```bash
Expand Down
2 changes: 2 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ WebberZone Knowledge Base, namespace `WebberZone\Knowledge_Base`, is a WordPress

## Build & Development Commands

Cross-release plans and agent notes live in `dev-helpers/plans/` (excluded from `build-zip.sh`; not shipped). Product docs for customers stay in `docs/`.

### PHP

```bash
Expand Down
1 change: 1 addition & 0 deletions build-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dev-tools/
wporg-assets/
test-tools/
docs/
dev-helpers/
includes/frontend/blocks/src/
includes/pro/blocks/src/
build-assets.js
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2048M",
"phpunit": "vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite core",
"phpunit:all": "vendor/bin/phpunit --configuration phpunit.xml.dist",
"phpunit:ci": "vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite core",
"phpunit:release": "vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite core --exclude-group slow",
"phpunit:ai": "vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite ai",
"phpunit:ai-smoke": "vendor/bin/phpunit --configuration phpunit.xml.dist --testsuite ai --group ai-smoke",
"test:security": "vendor/bin/phpunit --configuration phpunit.xml.dist --filter 'Rendering_Security|Media_Security|REST_Password_Protection|Password_Renderers'",
Expand Down
1 change: 0 additions & 1 deletion includes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ private function get_admin_banner_config(): array {
'nav_label' => esc_html__( 'Knowledge Base admin shortcuts', 'knowledgebase' ),
'eyebrow' => esc_html__( 'WebberZone Knowledge Base', 'knowledgebase' ),
'title' => esc_html__( 'Shape a helpful support hub your users will love.', 'knowledgebase' ),
'text' => esc_html__( 'Jump to your most-used Knowledge Base tools, manage content faster, and explore more WebberZone plugins.', 'knowledgebase' ),
),
'sections' => array(
'archive' => array(
Expand Down
32 changes: 20 additions & 12 deletions includes/admin/class-import-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Import_Export {
*/
public function __construct() {
Hook_Registry::add_action( 'admin_init', array( $this, 'process_export' ) );
Hook_Registry::add_action( 'admin_init', array( $this, 'process_import' ), 9 );
// After Settings_API::admin_init() (priority 10) registers the sanitize callback that update_option() applies.
Hook_Registry::add_action( 'admin_init', array( $this, 'process_import' ), 11 );
Hook_Registry::add_action( 'wzkb_tools_page_content', array( $this, 'render_card' ), 5 );
}

Expand Down Expand Up @@ -102,9 +103,21 @@ public function process_import(): void {
return;
}

if ( ! has_filter( 'sanitize_option_wzkb_settings' ) ) {
wp_die( esc_html__( 'Settings can only be imported from the Tools page.', 'knowledgebase' ) );
}

$existing = get_option( 'wzkb_settings', array() );
$existing = is_array( $existing ) ? $existing : array();

update_option( 'wzkb_settings', self::merge_imported_settings( is_array( $existing ) ? $existing : array(), $imported ) );
// The sanitizer would re-encrypt stored ciphertext, so secrets are restored after it runs.
$restore_secrets = static function ( $output ) use ( $existing ) {
return is_array( $output ) ? self::merge_imported_settings( $existing, $output ) : $output;
};

add_filter( 'wzkb_settings_sanitize', $restore_secrets, PHP_INT_MAX );
update_option( 'wzkb_settings', self::merge_imported_settings( $existing, $imported ) );
remove_filter( 'wzkb_settings_sanitize', $restore_secrets, PHP_INT_MAX );

add_settings_error(
'wzkb-notices',
Expand Down Expand Up @@ -154,14 +167,8 @@ protected function read_uploaded_settings(): ?array {
$raw = file_get_contents( $tmp ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$imported = json_decode( $raw, true );

if ( ! is_array( $imported ) ) {
add_settings_error(
'wzkb-notices',
'wzkb_import_invalid_json',
esc_html__( 'Import failed: the file does not contain valid JSON settings.', 'knowledgebase' ),
'error'
);
return null;
if ( empty( $imported ) || ! is_array( $imported ) ) {
wp_die( esc_html__( 'Import failed: the file does not contain valid JSON settings.', 'knowledgebase' ) );
}

return $imported;
Expand Down Expand Up @@ -216,7 +223,8 @@ protected static function restore_repeater_secrets( array $rows, array $existing
}

foreach ( $rows as $idx => $row ) {
if ( ! is_array( $row ) ) {
if ( ! is_array( $row ) || ( isset( $row['row_id'] ) && ! is_scalar( $row['row_id'] ) ) ) {
unset( $rows[ $idx ] );
continue;
}

Expand All @@ -234,7 +242,7 @@ protected static function restore_repeater_secrets( array $rows, array $existing
}
}

return $rows;
return array_values( $rows );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public static function get_defaults() {
'product_archive_layout' => 'sections',
'show_term_thumbnail' => 1,
'include_styles' => 1,
'kb_style' => 'classic',
'kb_style' => 'vibrant',
'docs_mode' => 0,
'columns' => '2',
'custom_css' => '',
Expand Down
8 changes: 8 additions & 0 deletions includes/admin/settings/class-settings-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,12 @@ public function show_navigation() {

}

$html .= sprintf(
'<li class="wz-settings-nav-save"><button type="submit" class="button button-primary" name="submit" form="%1$s">%2$s</button></li>',
esc_attr( "{$this->prefix}-settings-form" ),
esc_html( $this->translation_strings['save_changes'] )
);

$html .= '</ul>';

$allowed_html = wp_kses_allowed_html( 'post' );
Expand All @@ -1089,6 +1095,8 @@ public function show_navigation() {
$allowed_html['button'] = array(
'type' => true,
'class' => true,
'name' => true,
'form' => true,
'aria-label' => true,
'hidden' => true,
);
Expand Down
12 changes: 12 additions & 0 deletions includes/admin/settings/css/admin-style-rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@
list-style: none;
}

.wz-vertical-tabs > ul.nav-tab-wrapper li.wz-settings-nav-save {
margin-top: 12px;
}

.wz-vertical-tabs > ul.nav-tab-wrapper .wz-settings-nav-save .button {
width: 100%;
}

.wz-vertical-tabs > ul.nav-tab-wrapper .nav-tab {
display: block;
float: none;
Expand Down Expand Up @@ -485,6 +493,10 @@
.wz-vertical-tabs > ul.nav-tab-wrapper .wz-settings-search-wrap {
flex: 1 1 100%;
}

.wz-vertical-tabs > ul.nav-tab-wrapper li.wz-settings-nav-save {
flex: 1 1 100%;
}
}

/* Settings search. */
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/settings/css/admin-style-rtl.min.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions includes/admin/settings/css/admin-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@
list-style: none;
}

.wz-vertical-tabs > ul.nav-tab-wrapper li.wz-settings-nav-save {
margin-top: 12px;
}

.wz-vertical-tabs > ul.nav-tab-wrapper .wz-settings-nav-save .button {
width: 100%;
}

.wz-vertical-tabs > ul.nav-tab-wrapper .nav-tab {
display: block;
float: none;
Expand Down Expand Up @@ -483,6 +491,10 @@
.wz-vertical-tabs > ul.nav-tab-wrapper .wz-settings-search-wrap {
flex: 1 1 100%;
}

.wz-vertical-tabs > ul.nav-tab-wrapper li.wz-settings-nav-save {
flex: 1 1 100%;
}
}

/* Settings search. */
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/settings/css/admin-style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/frontend/class-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ public static function get_article_header( $term, int $level, array $args = arra
if ( ! empty( $args['clickable_section'] ) ) {
$output .= '<a href="' . esc_url( get_term_link( $term ) ) . '" title="' . esc_attr( $term->name ) . '">' . esc_html( $term->name ) . '</a>';
} else {
$output .= esc_html( $term->name );
$output .= '<span class="wzkb-section-title-text">' . esc_html( $term->name ) . '</span>';
}

if ( ! empty( $args['show_article_count'] ) ) {
Expand Down
29 changes: 24 additions & 5 deletions includes/frontend/class-styles-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function register_block_styles() {
private function get_style_context() {
$rtl_suffix = is_rtl() ? '-rtl' : '';
$min_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$kb_style = wzkb_get_option( 'kb_style', 'classic' );
$kb_style = wzkb_get_option( 'kb_style', 'vibrant' );
$deps = ( 'classic' === $kb_style ) ? array( 'dashicons' ) : array();

$style_url = $this->get_style_url( $kb_style, $rtl_suffix, $min_suffix );
Expand All @@ -151,8 +151,27 @@ private function add_common_inline_styles( $handle ) {
wp_add_inline_style( $handle, esc_html( $custom_css ) );
}

$columns = absint( wzkb_get_option( 'columns', 2 ) );
$columns_css = '.wzkb { --wzkb-columns: ' . $columns . '; }';
$columns = absint( wzkb_get_option( 'columns', 2 ) );
if ( $columns < 1 ) {
$columns = 1;
} elseif ( $columns > 4 ) {
$columns = 4;
}

// User column count on :root so preset @media rules can override .wzkb on small screens.
// Setting --wzkb-columns directly on .wzkb here previously beat every mobile breakpoint in the stylesheets.
$columns_css = sprintf(
':root { --wzkb-columns-user: %1$d; }' . PHP_EOL .
'.wzkb, .wzkb-product-grid { --wzkb-columns: var(--wzkb-columns-user, %1$d); }' . PHP_EOL .
'@media (max-width: 1024px) {' . PHP_EOL .
' body.wzkb-sidebar-enabled .wzkb,' . PHP_EOL .
' body.wzkb-sidebar-enabled .wzkb-product-grid { --wzkb-columns: 1; }' . PHP_EOL .
'}' . PHP_EOL .
'@media (max-width: 782px) {' . PHP_EOL .
' .wzkb, .wzkb-product-grid { --wzkb-columns: 1; }' . PHP_EOL .
'}',
$columns
);
wp_add_inline_style( $handle, $columns_css );
}

Expand All @@ -165,11 +184,11 @@ private function add_common_inline_styles( $handle ) {
* @return array Modified array of body classes.
*/
public function add_style_body_class( $classes ) {
$kb_style = wzkb_get_option( 'kb_style', 'classic' );
$kb_style = wzkb_get_option( 'kb_style', 'vibrant' );
$classes[] = 'wzkb-style-' . sanitize_html_class( $kb_style );

// Add sidebar class if enabled.
if ( wzkb_get_option( 'show_sidebar' ) ) {
if ( wzkb_should_show_sidebar() ) {
$classes[] = 'wzkb-sidebar-enabled';
}

Expand Down
Loading
Loading