Skip to content

Commit 2f3567b

Browse files
authored
Merge pull request #22 from searchcraft-inc/development
1.0.3 Release
2 parents ccc5203 + da7f8fd commit 2f3567b

23 files changed

Lines changed: 211 additions & 35 deletions

admin/class-searchcraft-admin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,9 @@ private function searchcraft_on_layout_settings_config_request( $request ) {
796796
$enable_facets = isset( $request['searchcraft_enable_facets'] ) ? '1' : '0';
797797
update_option( 'searchcraft_enable_facets', $enable_facets );
798798

799+
$hide_uncategorized = isset( $request['searchcraft_hide_uncategorized'] ) ? true : false;
800+
update_option( 'searchcraft_hide_uncategorized', $hide_uncategorized );
801+
799802
// Handle toggle button disabled color.
800803
if ( isset( $request['searchcraft_toggle_button_disabled_color'] ) ) {
801804
$toggle_button_disabled_color = sanitize_text_field( wp_unslash( $request['searchcraft_toggle_button_disabled_color'] ) );

admin/js/searchcraft-admin.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ function toggleFilterPanelOptions() {
144144
}
145145
}
146146

147+
/**
148+
* Toggle facets options visibility
149+
*/
150+
function toggleFacetsOptions() {
151+
const facetsCheckbox = document.getElementById('searchcraft_enable_facets');
152+
const facetsOptions = document.querySelector('.searchcraft-facets-options');
153+
154+
if (facetsCheckbox && facetsOptions) {
155+
if (facetsCheckbox.checked) {
156+
facetsOptions.style.display = '';
157+
} else {
158+
facetsOptions.style.display = 'none';
159+
}
160+
}
161+
}
162+
147163
/**
148164
* Toggle AI summary banner text visibility
149165
*/
@@ -222,6 +238,16 @@ document.addEventListener('DOMContentLoaded', function() {
222238
filterPanelCheckbox.addEventListener('change', toggleFilterPanelOptions);
223239
}
224240

241+
// Facets options toggle
242+
const facetsCheckbox = document.getElementById('searchcraft_enable_facets');
243+
if (facetsCheckbox) {
244+
// Initial state
245+
toggleFacetsOptions();
246+
247+
// Add event listener
248+
facetsCheckbox.addEventListener('change', toggleFacetsOptions);
249+
}
250+
225251
// AI summary banner text toggle
226252
const aiSummaryCheckbox = document.getElementById('searchcraft_enable_ai_summary');
227253
if (aiSummaryCheckbox) {

admin/partials/searchcraft-admin-layout-tab.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
$enable_exact_match_toggle = true;
2727
$enable_date_range = true;
2828
$enable_facets = true;
29+
$hide_uncategorized = false;
2930

3031
if ( $is_configured ) {
3132
$search_experience = get_option( 'searchcraft_search_experience', 'full' );
@@ -35,6 +36,7 @@
3536
$enable_exact_match_toggle = get_option( 'searchcraft_enable_exact_match_toggle', '1' );
3637
$enable_date_range = get_option( 'searchcraft_enable_date_range', '1' );
3738
$enable_facets = get_option( 'searchcraft_enable_facets', '1' );
39+
$hide_uncategorized = get_option( 'searchcraft_hide_uncategorized', false );
3840
}
3941
?>
4042
<div class="searchcraft-layout">
@@ -556,6 +558,22 @@
556558
</p>
557559
</label>
558560

561+
<div class="searchcraft-facets-options" style="<?php echo $enable_facets ? '' : 'display:none;'; ?> padding-left: 2em; margin-bottom: 1em;">
562+
<label for="searchcraft_hide_uncategorized" style="display: block;">
563+
<input
564+
type="checkbox"
565+
name="searchcraft_hide_uncategorized"
566+
id="searchcraft_hide_uncategorized"
567+
value="1"
568+
<?php checked( $hide_uncategorized, true ); ?>
569+
/>
570+
<strong>Hide Uncategorized</strong>
571+
<p class="description" style="margin: 0.25em 0 0 1.5em;">
572+
Hide the "Uncategorized" option from category facets.
573+
</p>
574+
</label>
575+
</div>
576+
559577
<div style="margin-top: 1em;">
560578
<label for="searchcraft_toggle_button_disabled_color" style="display: block; margin-bottom: 0.5em;">
561579
<strong>Toggle Button Disabled State Color</strong>

public/class-searchcraft-public.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public function get_js_config() {
242242
$js_config['enableExactMatchToggle'] = (bool) get_option( 'searchcraft_enable_exact_match_toggle', '1' );
243243
$js_config['enableDateRange'] = (bool) get_option( 'searchcraft_enable_date_range', '1' );
244244
$js_config['enableFacets'] = (bool) get_option( 'searchcraft_enable_facets', '1' );
245+
$js_config['hideUncategorized'] = (bool) get_option( 'searchcraft_hide_uncategorized', false );
245246

246247
// Date slider options.
247248
$admin_instance = new Searchcraft_Admin( 'searchcraft', SEARCHCRAFT_VERSION );
@@ -347,7 +348,7 @@ public function enqueue_sdk_assets() {
347348

348349
wp_enqueue_script(
349350
$this->plugin_name . '-sdk-components',
350-
plugin_dir_url( __FILE__ ) . 'sdk/components/index.js?v=0.12.1',
351+
plugin_dir_url( __FILE__ ) . 'sdk/components/index.js?v=0.12.2',
351352
$script_deps,
352353
$this->version,
353354
true
@@ -386,14 +387,14 @@ public function enqueue_sdk_assets() {
386387
// Add CSS for Searchcraft components.
387388
wp_enqueue_style(
388389
$this->plugin_name . '-sdk-hologram-styles',
389-
plugin_dir_url( __FILE__ ) . 'sdk/themes/hologram.css?v=0.12.1',
390+
plugin_dir_url( __FILE__ ) . 'sdk/themes/hologram.css?v=0.12.2',
390391
$style_deps,
391392
$this->version,
392393
'all'
393394
);
394395
wp_enqueue_style(
395396
$this->plugin_name . '-sdk-styles',
396-
plugin_dir_url( __FILE__ ) . 'css/searchcraft-sdk.css?v=0.12.1',
397+
plugin_dir_url( __FILE__ ) . 'css/searchcraft-sdk.css?v=0.12.2',
397398
$style_deps,
398399
$this->version,
399400
'all'

public/js/searchcraft-sdk-integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
async function loadSearchcraftSDK() {
5151
try {
5252
// Get the SDK script element to determine the module URL
53-
const sdkScript = document.querySelector('script[src*="sdk/components/index.js?v=0.12.1"]');
53+
const sdkScript = document.querySelector('script[src*="sdk/components/index.js?v=0.12.2"]');
5454
if (!sdkScript) {
5555
console.error('Searchcraft: SDK script not found');
5656
showConfigurationError('SDK script not found');

public/js/searchcraft-sdk-settings.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,17 @@
122122
if (searchcraft_config.filterTaxonomies && Array.isArray(searchcraft_config.filterTaxonomies)) {
123123
searchcraft_config.filterTaxonomies.forEach(taxonomy => {
124124
const taxonomyName = taxonomy.name === "category" ? "categories" : taxonomy.name;
125+
const options = {
126+
showSublevel: true,
127+
}
128+
if (taxonomyName === 'categories' && searchcraft_config.hideUncategorized) {
129+
options.exclude = ['/uncategorized']
130+
}
125131
filterPanelItems.push({
126132
type: 'facets',
127133
fieldName: taxonomyName,
128134
label: `${taxonomy.label}`,
129-
options: {
130-
showSublevel: true,
131-
},
135+
options
132136
});
133137
});
134138
}

public/sdk/components/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export interface FacetsFilterItem extends FilterItem {
183183
type: "facets";
184184
options: {
185185
showSublevel: boolean;
186+
exclude?: string[];
186187
};
187188
}
188189
export interface NumericFilterItem extends FilterItem {
@@ -833,6 +834,10 @@ export namespace Components {
833834
* ```
834835
*/
835836
interface SearchcraftFacetList {
837+
/**
838+
* Array of facet values to exclude from rendering.
839+
*/
840+
"exclude"?: string[];
836841
/**
837842
* The name of the field where facets are applied.
838843
*/
@@ -2082,6 +2087,10 @@ declare namespace LocalJSX {
20822087
* ```
20832088
*/
20842089
interface SearchcraftFacetList {
2090+
/**
2091+
* Array of facet values to exclude from rendering.
2092+
*/
2093+
"exclude"?: string[];
20852094
/**
20862095
* The name of the field where facets are applied.
20872096
*/

public/sdk/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ class SearchcraftCore {
17011701
}
17021702

17031703
const name = "@searchcraft/javascript-sdk";
1704-
const version = "0.12.1";
1704+
const version = "0.12.2";
17051705

17061706
/**
17071707
* @fileoverview entry point for your component library

public/sdk/components/p-c8566920.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 37 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)