From 0c72fe7181f73b11fbf22b274223b1cb00fecf14 Mon Sep 17 00:00:00 2001 From: James Rosado Date: Mon, 9 Jan 2023 10:55:20 -0500 Subject: [PATCH 1/3] do not display theme categories --- assets/js/boldgrid-inspirations.js | 59 ++++++++++++++++++++--- pages/templates/boldgrid-inspirations.php | 17 +++++-- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/assets/js/boldgrid-inspirations.js b/assets/js/boldgrid-inspirations.js index d08f10c..a172e47 100644 --- a/assets/js/boldgrid-inspirations.js +++ b/assets/js/boldgrid-inspirations.js @@ -1357,7 +1357,10 @@ IMHWPB.InspirationsDesignFirst = function( $, configs ) { * @since 1.2.3 */ this.initCategories = function() { - var failureMessage, failAction, success_action; + var template = wp.template( 'init-categories' ), + failureMessage, + failAction, + success_action; // Show a loading message to the user that we're fetching categories. self.$categories.html( Inspiration.fetchingCategories + ' ' ); @@ -1418,12 +1421,49 @@ IMHWPB.InspirationsDesignFirst = function( $, configs ) { } }; - self.ajax.ajaxCall( - { inspirations_mode: 'standard' }, - 'get_categories', - success_action, - failAction - ); + /** + * We are now only going to display the 'default' category on the stable release channel. + * + * Rather than remove the code that fetches categories, we will just hide the categories + * in case we need to revert back to the old behavior, or if we need to display categories + * for development / test releases. This method easily allows for them to be displayed if the + * user has selected a non-stable release channel. + * + * Adding this logic here, rather than inside the 'success_action' callback, also prevents making + * an unnecessary API call to fetch the categories list. + */ + if ( 'stable' === self.themeReleaseChannel ) { + template = wp.template( 'init-categories' ); + self.categories = {}; + self.categories.default = { + subcategories: [ + { + displayOrder: 1, + name: 'Default', + id: 'default' + } + ] + }; + + console.log( { releaseChannel: self.themeReleaseChannel, categories: self.categories } ); + + self.$categories.html( template( self.categories ) ); + + self.sortCategories( 'data-display-order' ); + + self.initThemes(); + + $( '#screen-design #categories.left' ).hide(); + $( '#screen-design #categories.left .sub-category.active' ).hide(); + $( '#screen-design .right.theme-browser' ).css( 'width', '100%' ); + } else { + self.ajax.ajaxCall( + { inspirations_mode: 'standard' }, + 'get_categories', + success_action, + failAction + ); + } }; /** @@ -1618,6 +1658,11 @@ IMHWPB.InspirationsDesignFirst = function( $, configs ) { build.isDefault = false; } + // On the stable release channel, we only display 'default' themes category. + if ( 'stable' === self.themeReleaseChannel ) { + return; + } + /** * If, however, the theme's category is hidden from the sidebar, we do not want * to have it printed twice, since the user does not need to be able to select that diff --git a/pages/templates/boldgrid-inspirations.php b/pages/templates/boldgrid-inspirations.php index 6abb28e..d8c960f 100644 --- a/pages/templates/boldgrid-inspirations.php +++ b/pages/templates/boldgrid-inspirations.php @@ -1,17 +1,24 @@