Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not display theme categories #167

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions assets/js/boldgrid-inspirations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ' <span class="spinner inline"></span>' );
Expand Down Expand Up @@ -1418,12 +1421,47 @@ 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'
}
]
};

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
);
}
};

/**
Expand Down Expand Up @@ -1618,6 +1656,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
Expand Down
20 changes: 13 additions & 7 deletions pages/templates/boldgrid-inspirations.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<script type="text/html" id="tmpl-init-categories">
<div class="category-filter" ><?php echo __( 'Categories', 'boldgrid-inspirations' ); ?></div>

<div class="sub-category active" data-display-order="0" >
<input type="radio" name="sub-category" checked data-sub-category-id="0" >
<div class="sub-category" data-display-order="0" >
<input type="radio" name="sub-category" data-sub-category-id="0" >
<span class="sub-category-name"><?php echo __( 'All', 'boldgrid-inspirations' ); ?></span>
</div>

<# _.each( data, function( category ) { #>
<# _.each( category.subcategories, function( sub_category ) { #>
<# if ( ! sub_category.isHiddenFromSidebar ) { #>
<div class="sub-category" data-display-order="{{sub_category.displayOrder}}" >
<input type="radio" name="sub-category" data-sub-category-id="{{sub_category.id}}"> <span class="sub-category-name">{{sub_category.name}}</span>
</div>
<# if ( 'default' === sub_category.id ) { #>
<div class="sub-category active" data-display-order="{{sub_category.displayOrder}}" >
<input type="radio" name="sub-category" checked data-sub-category-id="{{sub_category.id}}">
<span class="sub-category-name">{{sub_category.name}}</span>
</div>
<# } else {#>
<div class="sub-category" data-display-order="{{sub_category.displayOrder}}" >
<input type="radio" name="sub-category" data-sub-category-id="{{sub_category.id}}"> <span class="sub-category-name">{{sub_category.name}}</span>
</div>
<# } #>
<# } #>
<# }); #>
<# }); #>
Expand Down Expand Up @@ -53,8 +60,7 @@
<div class="theme-id-container">

<h2 class="theme-name" >
<span class="sub-category-name">{{data.build.SubCategoryName}} - </span>
<span class="name">{{data.build.ThemeName}}</span>
<span class="sub-category-name">{{data.build.SubCategoryName}}</span>
</h2>

<div class="theme-actions">
Expand Down