Skip to content

Commit acdfe9d

Browse files
committed
feat: enhance setup wizard UI with Pro features and improved navigation
1 parent fe5ca73 commit acdfe9d

File tree

7 files changed

+153
-39
lines changed

7 files changed

+153
-39
lines changed

includes/admin/class-settings.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -357,32 +357,36 @@ public static function settings_general() {
357357
'type' => 'header',
358358
),
359359
'kb_slug' => array(
360-
'id' => 'kb_slug',
361-
'name' => esc_html__( 'Knowledge Base slug', 'knowledgebase' ),
362-
'desc' => esc_html__( 'This will set the opening path of the URL of the knowledge base and is set when registering the custom post type', 'knowledgebase' ),
363-
'type' => 'text',
364-
'default' => 'knowledgebase',
360+
'id' => 'kb_slug',
361+
'name' => esc_html__( 'Knowledge Base slug', 'knowledgebase' ),
362+
'desc' => esc_html__( 'This will set the opening path of the URL of the knowledge base and is set when registering the custom post type', 'knowledgebase' ),
363+
'type' => 'text',
364+
'default' => 'knowledgebase',
365+
'field_class' => 'large-text',
365366
),
366367
'product_slug' => array(
367-
'id' => 'product_slug',
368-
'name' => esc_html__( 'Product slug', 'knowledgebase' ),
369-
'desc' => esc_html__( 'This slug forms part of the URL for product pages when Multi-Product Mode is enabled. The value is used when registering the custom taxonomy.', 'knowledgebase' ),
370-
'type' => 'text',
371-
'default' => 'kb/product',
368+
'id' => 'product_slug',
369+
'name' => esc_html__( 'Product slug', 'knowledgebase' ),
370+
'desc' => esc_html__( 'This slug forms part of the URL for product pages when Multi-Product Mode is enabled. The value is used when registering the custom taxonomy.', 'knowledgebase' ),
371+
'type' => 'text',
372+
'default' => 'kb/product',
373+
'field_class' => 'large-text',
372374
),
373375
'category_slug' => array(
374-
'id' => 'category_slug',
375-
'name' => esc_html__( 'Section slug', 'knowledgebase' ),
376-
'desc' => esc_html__( 'Each section is a section of the knowledge base. This setting is used when registering the custom section and forms a part of the URL when browsing section archives', 'knowledgebase' ),
377-
'type' => 'text',
378-
'default' => 'kb/section',
376+
'id' => 'category_slug',
377+
'name' => esc_html__( 'Section slug', 'knowledgebase' ),
378+
'desc' => esc_html__( 'Each section is a section of the knowledge base. This setting is used when registering the custom section and forms a part of the URL when browsing section archives', 'knowledgebase' ),
379+
'type' => 'text',
380+
'default' => 'kb/section',
381+
'field_class' => 'large-text',
379382
),
380383
'tag_slug' => array(
381-
'id' => 'tag_slug',
382-
'name' => esc_html__( 'Tags slug', 'knowledgebase' ),
383-
'desc' => esc_html__( 'Each article can have multiple tags. This setting is used when registering the custom tag and forms a part of the URL when browsing tag archives', 'knowledgebase' ),
384-
'type' => 'text',
385-
'default' => 'kb/tags',
384+
'id' => 'tag_slug',
385+
'name' => esc_html__( 'Tags slug', 'knowledgebase' ),
386+
'desc' => esc_html__( 'Each article can have multiple tags. This setting is used when registering the custom tag and forms a part of the URL when browsing tag archives', 'knowledgebase' ),
387+
'type' => 'text',
388+
'default' => 'kb/tags',
389+
'field_class' => 'large-text',
386390
),
387391
'article_permalink' => array(
388392
'id' => 'article_permalink',
@@ -391,7 +395,6 @@ public static function settings_general() {
391395
'type' => 'text',
392396
'default' => '%postname%',
393397
'field_class' => 'large-text',
394-
'pro' => true,
395398
),
396399
'performance_header' => array(
397400
'id' => 'performance_header',

includes/admin/class-setup-wizard.php

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ public function mode_step() {
299299
</table>
300300
<p class="wzkb-setup-actions step">
301301
<?php wp_nonce_field( 'wzkb-setup' ); ?>
302+
<a href="<?php echo esc_url( $this->get_previous_step_link() ); ?>" class="button button-large"><?php esc_html_e( 'Previous', 'knowledgebase' ); ?></a>
302303
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'knowledgebase' ); ?>" name="wzkb_save_step" />
303-
<a href="<?php echo esc_url( add_query_arg( 'wzkb_nonce', wp_create_nonce( 'wzkb-setup' ), $this->get_next_step_link() ) ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'knowledgebase' ); ?></a>
304304
</p>
305305
</form>
306306
<?php
@@ -351,16 +351,46 @@ public function structure_step() {
351351
);
352352
?>
353353
</p>
354+
<?php if ( class_exists( 'WebberZone\\Knowledge_Base\\Pro\\Pro' ) ) : ?>
355+
<p class="wzkb-setup-pro-enabled">
356+
<span class="dashicons dashicons-yes-alt"></span>
357+
<span>
358+
<?php
359+
printf(
360+
/* translators: %s is wrapped in <code> */
361+
wp_kses_post( __( '<strong>Pro active:</strong> You can use nested structures and advanced placeholders like %s for complete control over your URLs.', 'knowledgebase' ) ),
362+
'<code>%product_name%</code>, <code>%section_name%</code>, <code>%postname%</code>'
363+
);
364+
?>
365+
</span>
366+
</p>
367+
<?php else : ?>
354368
<p class="wzkb-setup-warning">
355-
<?php
369+
<?php
356370
printf(
357-
/* translators: %1$s, %2$s, and %3$s are wrapped in <code> */
358-
esc_html__( 'All the below slugs must be unique and not nested within each other. e.g. %1$s (Knowledge Base) and %2$s (Product) are NOT valid as the product slug is nested below the knowledgebase slug. This also applies to Sections and Tags.', 'knowledgebase' ),
371+
/* translators: %1$s, %2$s are wrapped in <code> */
372+
esc_html__( 'All the below slugs must be unique and not nested within each other. e.g. %1$s and %2$s are NOT valid as the product slug is nested below the KB slug.', 'knowledgebase' ),
359373
'<code>kb</code>',
360374
'<code>kb/product</code>'
361375
);
362-
?>
376+
?>
363377
</p>
378+
<p class="wzkb-setup-pro-tip">
379+
<span class="dashicons dashicons-star-filled"></span>
380+
<span class="wzkb-pro-tip-content">
381+
<span>
382+
<?php
383+
printf(
384+
/* translators: %s is the product name */
385+
esc_html__( 'Want advanced permalink flexibility? Upgrade to %s for nested structures, intelligent routing, custom placeholders, and automatic conflict resolution. %s', 'knowledgebase' ),
386+
'<strong>' . esc_html__( 'Knowledge Base Pro', 'knowledgebase' ) . '</strong>',
387+
'<a href="https://webberzone.com/plugins/knowledgebase/pro/" target="_blank" class="button button-secondary button-small">' . esc_html__( 'Learn More', 'knowledgebase' ) . '</a>'
388+
);
389+
?>
390+
</span>
391+
</span>
392+
</p>
393+
<?php endif; ?>
364394
<form method="post">
365395
<table class="form-table">
366396
<tr>
@@ -406,8 +436,8 @@ public function structure_step() {
406436
</table>
407437
<p class="wzkb-setup-actions step">
408438
<?php wp_nonce_field( 'wzkb-setup' ); ?>
439+
<a href="<?php echo esc_url( $this->get_previous_step_link() ); ?>" class="button button-large"><?php esc_html_e( 'Previous', 'knowledgebase' ); ?></a>
409440
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'knowledgebase' ); ?>" name="wzkb_save_step" />
410-
<a href="<?php echo esc_url( add_query_arg( 'wzkb_nonce', wp_create_nonce( 'wzkb-setup' ), $this->get_next_step_link() ) ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'knowledgebase' ); ?></a>
411441
</p>
412442
</form>
413443
<?php
@@ -568,8 +598,8 @@ public function display_step() {
568598

569599
<p class="wzkb-setup-actions step">
570600
<?php wp_nonce_field( 'wzkb-setup' ); ?>
601+
<a href="<?php echo esc_url( $this->get_previous_step_link() ); ?>" class="button button-large"><?php esc_html_e( 'Previous', 'knowledgebase' ); ?></a>
571602
<input type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'knowledgebase' ); ?>" name="wzkb_save_step" />
572-
<a href="<?php echo esc_url( add_query_arg( 'wzkb_nonce', wp_create_nonce( 'wzkb-setup' ), $this->get_next_step_link() ) ); ?>" class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'knowledgebase' ); ?></a>
573603
</p>
574604
</form>
575605
<?php
@@ -685,6 +715,31 @@ public function get_next_step_link( $step = '' ) {
685715
return add_query_arg( 'step', $keys[ $step_index + 1 ], remove_query_arg( 'activate_error' ) );
686716
}
687717

718+
/**
719+
* Get the previous step link.
720+
*
721+
* @since 3.0.0
722+
*
723+
* @param string $step Optional. Current step slug.
724+
* @return string Previous step URL.
725+
* Empty string if it's the first step or on failure.
726+
*/
727+
public function get_previous_step_link( $step = '' ) {
728+
if ( empty( $step ) ) {
729+
$step = $this->current_step;
730+
}
731+
732+
$keys = array_keys( $this->steps );
733+
$step_index = array_search( $step, $keys, true );
734+
735+
// Return empty if first step or not found.
736+
if ( false === $step_index || 0 === $step_index ) {
737+
return '';
738+
}
739+
740+
return add_query_arg( 'step', $keys[ $step_index - 1 ], remove_query_arg( 'activate_error' ) );
741+
}
742+
688743
/**
689744
* Enqueue scripts and styles.
690745
*
@@ -697,17 +752,19 @@ public function enqueue_scripts() {
697752
return;
698753
}
699754

755+
$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
756+
700757
wp_register_style(
701758
'wzkb-wizard',
702-
plugins_url( 'css/wizard.css', __FILE__ ),
759+
plugins_url( "css/wizard{$min}.css", __FILE__ ),
703760
array( 'dashicons' ),
704761
WZKB_VERSION
705762
);
706763
wp_enqueue_style( 'wzkb-wizard' );
707764

708765
wp_register_script(
709766
'wzkb-wizard',
710-
plugins_url( 'js/wizard.js', __FILE__ ),
767+
plugins_url( "js/wizard{$min}.js", __FILE__ ),
711768
array( 'jquery' ),
712769
WZKB_VERSION,
713770
true

includes/admin/css/wizard.css

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@
120120
margin: 20px 0 0;
121121
padding-top: 10px;
122122
border-top: 1px solid #f0f0f1;
123-
text-align: right;
123+
display: flex;
124+
justify-content: space-between;
125+
align-items: center;
126+
gap: 10px;
127+
}
128+
129+
.wzkb-setup .wzkb-setup-actions .button-next {
130+
margin-left: auto;
124131
}
125132

126133
.wzkb-return-to-dashboard {
@@ -158,10 +165,52 @@
158165
}
159166

160167
.wzkb-setup-warning {
161-
background-color: #fff599;
162-
padding: 10px;
163-
border: 1px solid #f7dc6f;
164-
border-radius: 5px;
165-
margin-bottom: 20px;
166-
color: #0a0a0a;
168+
background: #fff3cd;
169+
border-left: 4px solid #dc9814;
170+
padding: 15px 20px;
171+
margin: 15px 0;
172+
border-radius: 4px;
173+
}
174+
175+
/* Pro Tip and Pro Enabled Messages */
176+
.wzkb-setup-pro-tip {
177+
background: #fff9e6;
178+
border-left: 4px solid #996800;
179+
padding: 15px 20px;
180+
margin: 15px 0;
181+
border-radius: 4px;
182+
display: flex;
183+
align-items: center;
184+
gap: 10px;
185+
}
186+
187+
.wzkb-setup-pro-tip .dashicons {
188+
color: #996800;
189+
font-size: 20px;
190+
width: 20px;
191+
height: 20px;
192+
flex-shrink: 0;
193+
}
194+
195+
.wzkb-setup-pro-tip strong {
196+
color: #996800;
197+
}
198+
199+
.wzkb-setup-pro-enabled {
200+
background: #f0fff0;
201+
border-left: 4px solid #46b450;
202+
padding: 15px 20px;
203+
margin: 15px 0;
204+
border-radius: 4px;
205+
display: flex;
206+
align-items: center;
207+
gap: 10px;
208+
}
209+
210+
.wzkb-setup-pro-enabled .dashicons {
211+
color: #46b450;
212+
font-size: 20px;
213+
width: 20px;
214+
height: 20px;
215+
flex-shrink: 0;
167216
}

includes/admin/css/wizard.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/admin/js/wizard.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

knowledgebase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Plugin Name: WebberZone Knowledge Base
1414
* Plugin URI: https://github.com/WebberZone/knowledgebase
1515
* Description: Create a multi-product knowledge base on your WordPress site.
16-
* Version: 3.0.0-beta1
16+
* Version: 3.0.0-beta2
1717
* Author: WebberZone
1818
* Author URI: https://webberzone.com
1919
* License: GPL-2.0+
@@ -37,7 +37,7 @@
3737
*
3838
* @var string $wzkb_version Plugin version
3939
*/
40-
define( 'WZKB_VERSION', '3.0.0-beta1' );
40+
define( 'WZKB_VERSION', '3.0.0-beta2' );
4141
}
4242

4343
if ( ! defined( 'WZKB_PLUGIN_DIR' ) ) {

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ Fixed security issue where Knowledge Base slug in settings was not sanitized.
135135
* Admin UI enhancements for managing products, sections, and migration.
136136
* Setup Wizard to guide users through the initial setup process.
137137
* New Product widget to display the Sections for a specific Product.
138+
* (Pro) Custom Permalinks for Products, Sections, Tags and Articles.
139+
* (Pro) Added Clear cache button and Cache expiry option in the settings page.
138140

139141
* Modifications:
140142
* Standardized CSS class names to use consistent hyphenation (e.g., `wzkb_section` is now `wzkb-section`). If you have custom CSS targeting the old class names, you'll need to update your stylesheets.
141143
* New Hooks_Registry class added to handle hooks in a more organized way and prevents accidental duplicate hooks.
144+
* Upgraded WebberZone Settings API.
142145

143146
* Breaking Changes:
144147
* CSS classes have been renamed for consistency:

0 commit comments

Comments
 (0)