Skip to content

Commit 1348893

Browse files
committed
Update settings API and wizard styles
1 parent 10e3dc2 commit 1348893

9 files changed

Lines changed: 42 additions & 14 deletions

includes/admin/settings/class-settings-api.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ public function plugin_settings() {
978978
* Shows all the settings section labels as tab
979979
*/
980980
public function show_navigation() {
981-
$active_tab = isset( $_GET['tab'] ) && array_key_exists( sanitize_key( wp_unslash( $_GET['tab'] ) ), $this->settings_sections ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'general'; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
981+
$active_tab = isset( $_GET['tab'] ) && array_key_exists( sanitize_key( wp_unslash( $_GET['tab'] ) ), $this->settings_sections ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : $this->default_tab; // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
982982

983983
$html = '<ul class="nav-tab-wrapper" style="padding:0">';
984984

@@ -993,9 +993,13 @@ public function show_navigation() {
993993

994994
$active = $active_tab === $tab_id ? ' ' : '';
995995

996-
$html .= '<li style="padding:0; border:0; margin:0;"><a href="#' . esc_attr( $tab_id ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . sanitize_html_class( $active ) . '">';
997-
$html .= esc_html( $tab_name );
998-
$html .= '</a></li>';
996+
$html .= sprintf(
997+
'<li style="padding:0; border:0; margin:0;"><a href="#%s" title="%s" class="nav-tab %s">%s</a></li>',
998+
esc_attr( $tab_id ),
999+
esc_attr( $tab_name ),
1000+
sanitize_html_class( $active ),
1001+
esc_html( $tab_name )
1002+
);
9991003

10001004
}
10011005

includes/admin/settings/css/admin-style-rtl.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* Tabs */
2+
#post-body-content .ui-tabs-nav {
3+
border-bottom: 1px solid #c3c4c7;
4+
}
5+
16
/* General styles for the repeater wrapper */
27
.wz-repeater-wrapper {
38
position: relative;

includes/admin/settings/css/admin-style-rtl.min.css

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

includes/admin/settings/css/admin-style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/* Tabs */
2+
#post-body-content .ui-tabs-nav {
3+
border-bottom: 1px solid #c3c4c7;
4+
}
5+
16
/* General styles for the repeater wrapper */
27
.wz-repeater-wrapper {
38
position: relative;

includes/admin/settings/css/admin-style.min.css

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

includes/admin/settings/css/wizard.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/**
22
* Settings Wizard Styles
3-
*
4-
* @package Knowledge_Base
5-
* @since 4.2.0
63
*/
74

85
/* Wizard Container */

includes/admin/settings/js/settings-admin-scripts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ jQuery(document).ready(function ($) {
7373
// Reset default thumbnail - uses plugin-specific localized data.
7474
$('.reset-default-thumb').on('click', function () {
7575
var settingsKey = WZSettingsAdmin.settings_key || '';
76-
var thumbDefault = (typeof window[WZSettingsAdmin.prefix + '_admin'] !== 'undefined')
77-
? window[WZSettingsAdmin.prefix + '_admin'].thumb_default
76+
var thumbDefault = (typeof window[WZSettingsAdmin.prefix + '_admin'] !== 'undefined')
77+
? window[WZSettingsAdmin.prefix + '_admin'].thumb_default
7878
: '';
7979
$('#' + settingsKey + '\\[thumb_default\\]').val(thumbDefault);
8080
});

includes/admin/settings/js/tom-select-init.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,23 @@
5252
formattedOptions.push(...allOptions);
5353
}
5454

55+
// For non-taxonomy endpoints, add saved values as options so Tom Select can display them.
56+
if (!(endpoint === 'category' || endpoint === 'post_tag' || endpoint.includes('tax')) && savedIds.length > 0) {
57+
savedIds.forEach(savedValue => {
58+
if (!formattedOptions.some(opt => opt.value === savedValue)) {
59+
formattedOptions.push({ value: savedValue, text: savedValue });
60+
}
61+
});
62+
}
63+
5564
// Get any custom config from data attributes
5665
let customConfig = {};
5766
const configAttr = element.getAttribute('data-ts-config');
5867

5968
if (configAttr) {
6069
try {
6170
customConfig = JSON.parse(configAttr);
62-
console.log('Parsed custom config:', customConfig); // Debug log
71+
// console.log('Parsed custom config:', customConfig); // Debug log
6372
} catch (e) {
6473
console.error('Error parsing custom config:', configAttr, e);
6574
}
@@ -83,13 +92,21 @@
8392
if (endpoint === 'category' || endpoint === 'post_tag' || endpoint.includes('tax')) {
8493
return `<div>${escape(data.value)}</div>`;
8594
}
95+
// Avoid showing "value (value)" when value and text are identical.
96+
if (data.text === data.value) {
97+
return `<div>${escape(data.value)}</div>`;
98+
}
8699
return `<div>${escape(data.text)} (${escape(data.value)})</div>`;
87100
},
88101
item: (data, escape) => {
89102
// For taxonomy endpoints, display only the formatted value to avoid duplication
90103
if (endpoint === 'category' || endpoint === 'post_tag' || endpoint.includes('tax')) {
91104
return `<div>${escape(data.value)}</div>`;
92105
}
106+
// Avoid showing "value (value)" when value and text are identical.
107+
if (data.text === data.value) {
108+
return `<div>${escape(data.value)}</div>`;
109+
}
93110
return `<div>${escape(data.text)} (${escape(data.value)})</div>`;
94111
}
95112
},
@@ -125,7 +142,7 @@
125142

126143
// Merge default config with custom config
127144
const finalConfig = { ...defaultConfig, ...customConfig };
128-
console.log('Final config:', finalConfig); // Debug log
145+
// console.log('Final config:', finalConfig); // Debug log
129146

130147
// Initialize Tom Select with merged config
131148
try {

0 commit comments

Comments
 (0)