Skip to content

Commit 96d4822

Browse files
committed
Setup Wizard
1 parent d4b6d62 commit 96d4822

File tree

11 files changed

+1019
-24
lines changed

11 files changed

+1019
-24
lines changed

includes/admin/class-admin.php

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use WebberZone\Knowledge_Base\Util\Cache;
1313
use WebberZone\Knowledge_Base\Util\Hook_Registry;
14+
use WebberZone\Knowledge_Base\Admin\Setup_Wizard;
1415

1516
// If this file is called directly, abort.
1617
if ( ! defined( 'WPINC' ) ) {
@@ -42,6 +43,15 @@ class Admin {
4243
*/
4344
public $activator;
4445

46+
/**
47+
* Setup wizard.
48+
*
49+
* @since 3.0.0
50+
*
51+
* @var Setup_Wizard|null Setup wizard instance.
52+
*/
53+
public ?Setup_Wizard $setup_wizard = null;
54+
4555
/**
4656
* Cache.
4757
*
@@ -83,6 +93,7 @@ public function __construct() {
8393
$this->cache = new Cache();
8494
$this->admin_columns = new Admin_Columns();
8595
$this->product_migrator = new Product_Migrator();
96+
$this->setup_wizard = new Setup_Wizard();
8697
}
8798

8899
/**
@@ -147,16 +158,16 @@ public function admin_enqueue_scripts() {
147158
* @since 2.3.0
148159
*/
149160
public function admin_notices() {
150-
$kb_slug = \wzkb_get_option( 'kb_slug', 'not-set-random-string' );
151-
$product_slug = \wzkb_get_option( 'product_slug', 'not-set-random-string' );
152-
$cat_slug = \wzkb_get_option( 'category_slug', 'not-set-random-string' );
153-
$tag_slug = \wzkb_get_option( 'tag_slug', 'not-set-random-string' );
154-
155161
// Only add the notice if the user is an admin.
156162
if ( ! current_user_can( 'manage_options' ) ) {
157163
return;
158164
}
159165

166+
$kb_slug = \wzkb_get_option( 'kb_slug', 'not-set-random-string' );
167+
$product_slug = \wzkb_get_option( 'product_slug', 'not-set-random-string' );
168+
$cat_slug = \wzkb_get_option( 'category_slug', 'not-set-random-string' );
169+
$tag_slug = \wzkb_get_option( 'tag_slug', 'not-set-random-string' );
170+
160171
// Only add the notice if the settings cannot be found.
161172
if ( 'not-set-random-string' === $kb_slug || 'not-set-random-string' === $product_slug || 'not-set-random-string' === $cat_slug || 'not-set-random-string' === $tag_slug ) {
162173
?>
@@ -165,14 +176,32 @@ public function admin_notices() {
165176
<?php
166177
printf(
167178
/* translators: 1. Link to admin page. */
168-
esc_html__( 'Knowledge Base settings for the slug have not been registered. Please visit the <a href="%s">admin page</a> to update and save the options.', 'knowledgebase' ),
169-
esc_url( admin_url( 'edit.php?post_type=wz_knowledgebase&page=wzkb-settings' ) )
179+
esc_html__( 'Knowledge Base settings for the slug have not been registered. Please visit the %s to update and save the options.', 'knowledgebase' ),
180+
'<a href="' . esc_url( admin_url( 'edit.php?post_type=wz_knowledgebase&page=wzkb-settings' ) ) . '">' . esc_html__( 'admin page', 'knowledgebase' ) . '</a>'
170181
);
171182
?>
172183
</p>
173184
</div>
174185
<?php
175186
}
187+
188+
// Show notice if on Products taxonomy screen and multi-product mode is not enabled.
189+
global $current_screen;
190+
if ( isset( $current_screen ) && 'edit-wzkb_product' === $current_screen->id && 'wzkb_product' === $current_screen->taxonomy ) { // Check for Products taxonomy admin screen.
191+
$multi_product = (int) wzkb_get_option( 'multi_product', 0 );
192+
if ( ! $multi_product ) { // Yoda condition: Only show if not enabled.
193+
// translators: %s: Link to plugin settings page.
194+
$settings_link = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'edit.php?post_type=wz_knowledgebase&page=wzkb-settings' ) ), esc_html__( 'plugin settings', 'knowledgebase' ) );
195+
$message = sprintf(
196+
esc_html__( 'The Products taxonomy is only available in multi-product mode. Please enable multi-product mode in the %s.', 'knowledgebase' ),
197+
$settings_link
198+
);
199+
printf(
200+
'<div class="notice notice-warning"><p>%s</p></div>',
201+
wp_kses_post( $message )
202+
);
203+
}
204+
}
176205
}
177206

178207
/**

includes/admin/class-settings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public static function settings_general() {
385385
'cache' => array(
386386
'id' => 'cache',
387387
'name' => esc_html__( 'Enable cache', 'knowledgebase' ),
388-
'desc' => esc_html__( 'Cache the output of the WP_Query lookups to speed up retrieval of the knowledgebase. Recommended for large knowledge bases', 'knowledgebase' ),
388+
'desc' => esc_html__( 'Cache the output of the queries to speed up retrieval of the knowledgebase. Recommended for large knowledge bases', 'knowledgebase' ),
389389
'type' => 'checkbox',
390390
'options' => false,
391391
),
@@ -478,7 +478,7 @@ public static function settings_output() {
478478
'name' => esc_html__( 'Show article count', 'knowledgebase' ),
479479
'desc' => esc_html__( 'If selected, the number of articles will be displayed in an orange circle next to the header. You can override the color by styling wzkb_section_count', 'knowledgebase' ),
480480
'type' => 'checkbox',
481-
'options' => false,
481+
'options' => true,
482482
),
483483
'show_excerpt' => array(
484484
'id' => 'show_excerpt',

0 commit comments

Comments
 (0)