Skip to content

Commit 5a12b81

Browse files
authored
packaged version 4.22.0 (#323)
Co-authored-by: Mykhailo Los <[email protected]>
1 parent da43470 commit 5a12b81

30 files changed

+379
-81
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [4.22.0]
4+
5+
### Added
6+
- Added ability to enable or disable sub-categories in navigation menu. The option can be changed in Customizer > BigCommerce > Product Category > Menus. Sub categories are hidden from menu by default
7+
- Added ability to abort import process. In order to do that go to Bigcommerce > Settings > Diagnostics and click on the "Abort Product Import" button
8+
9+
### Fixed
10+
- Fixed 500 issue on the REST API endpoint for the product review
11+
- Fixed PHP notice appearance when get_terms return boolean result during category fetching
12+
- Added an error handling for situation when import task is missing
13+
314
## [4.21.0]
415

516
### Changed
@@ -1668,6 +1679,7 @@
16681679
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.
16691680

16701681

1682+
[4.22.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.21.1...4.22.0
16711683
[4.21.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.20.1...4.21.0
16721684
[4.20.1]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.20.0...4.20.1
16731685
[4.20.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.19.1...4.20.0

assets/css/bc-admin.css

+9-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/bc-admin.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/scripts.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/dist/admin/scripts.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/admin/settings/product-sync.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const state = {
1919
syncCompleted: false,
2020
syncError: false,
2121
pollingDelay: 1000,
22+
isAborted: false,
2223
};
2324

2425
/**
@@ -48,7 +49,13 @@ const importSuccess = (node, icon, response = '') => {
4849
messageWrapper.innerHTML = importCloseButton;
4950
tools.removeClass(icon, 'icon-bc-sync');
5051
tools.addClass(icon, 'icon-bc-check');
51-
tools.addClass(el.container, 'bigcommerce-notice__import-status--success');
52+
53+
if (!state.isAborted) {
54+
tools.addClass(el.container, 'bigcommerce-notice__import-status--success');
55+
} else {
56+
tools.addClass(el.container, 'bigcommerce-notice__import-status--warning');
57+
}
58+
5259
node.textContent = response;
5360
};
5461

@@ -221,6 +228,7 @@ const pollProductSyncWatcher = () => {
221228
} else if (data.status === 'not_started') {
222229
// The import is done.
223230
state.syncCompleted = true;
231+
state.isAborted = !!data.aborted;
224232
if (data.previous !== 'failed') {
225233
// The sync has not failed and still contains a status response.
226234
handleStatusMessage(data.products.status);

assets/pcss/admin/pages/settings/_plugin-notices.pcss

+6
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ p.bigcommerce-notice__refresh {
8383
align-items: center;
8484
}
8585

86+
&.bigcommerce-notice__import-status--warning {
87+
background-color: var(--color-bc-red);
88+
align-content: center;
89+
align-items: center;
90+
}
91+
8692
&.bigcommerce-notice__import-status--error {
8793
border: 1px solid var(--color-bc-red);
8894
background-color: var(--color-white);

bigcommerce.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: BigCommerce for WordPress
44
Description: Scale your ecommerce business with WordPress on the front-end and BigCommerce on the back end. Free up server resources from things like catalog management, processing payments, and managing fulfillment logistics.
55
Author: BigCommerce
6-
Version: 4.21.0
6+
Version: 4.22.0
77
Author URI: https://www.bigcommerce.com/wordpress
88
Requires PHP: 7.4.0
99
Text Domain: bigcommerce

build-timestamp.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?php
2-
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.30.11.29.2021');
2+
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '4.45.12.17.2021');

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: bigcommerce, moderntribe, jbrinley, becomevocal, vincentlistrani,
33
Tags: ecommerce, online store, sell online, storefront, retail, online shop, bigcommerce, big commerce, e-commerce, physical products, buy buttons, commerce, shopping cart, checkout, cart, shop, headless commerce, shipping, payments, fulfillment
44
Requires at least: 5.2
55
Tested up to: 5.8.1
6-
Stable tag: 4.21.0
6+
Stable tag: 4.22.0
77
Requires PHP: 7.4.0
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html

src/BigCommerce/Container/Rest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use BigCommerce\Rest\Shortcode_Controller;
1414
use BigCommerce\Rest\Shipping_Controller;
1515
use BigCommerce\Rest\Coupon_Code_Controller;
16+
use BigCommerce\Reviews\Review_Fetcher;
1617
use Pimple\Container;
1718

1819
class Rest extends Provider {
@@ -142,7 +143,7 @@ public function register( Container $container ) {
142143
};
143144

144145
$container[ self::REVIEW_LIST ] = function ( Container $container ) {
145-
return new Reviews_Listing_Controller( $container[ self::NAMESPACE_BASE ], $container[ self::VERSION ], $container[ self::REVIEW_LIST_BASE ], $container[ Api::FACTORY ]->catalog() );
146+
return new Reviews_Listing_Controller( $container[ self::NAMESPACE_BASE ], $container[ self::VERSION ], $container[ self::REVIEW_LIST_BASE ], $container[ Reviews::FETCHER ] );
146147
};
147148

148149
$container[ self::PRICING_BASE ] = function ( Container $container ) {

src/BigCommerce/Container/Settings.php

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use BigCommerce\Merchant\Onboarding_Api;
99
use BigCommerce\Nav_Menu\Nav_Items_Meta_Box;
1010
use BigCommerce\Post_Types\Product\Product;
11+
use BigCommerce\Settings\Abort_Import;
1112
use BigCommerce\Settings\Connection_Status;
1213
use BigCommerce\Settings\Import_Now;
1314
use BigCommerce\Settings\Import_Status;
@@ -78,6 +79,7 @@ class Settings extends Provider {
7879
const START_OVER = 'settings.start_over';
7980
const ONBOARDING_PROGRESS = 'settings.onboarding.progress_bar';
8081
const SITE_URL_SYNC = 'settings.site_url_sync';
82+
const ABORT_IMPORT = 'settings.abort_product_import';
8183

8284
const CONFIG_STATUS = 'settings.configuration_status';
8385
const CONFIG_DISPLAY_MENUS = 'settings.configuration_display_menus';
@@ -648,6 +650,10 @@ private function diagnostics( Container $container ) {
648650
return new Site_URL_Sync( $container[ Taxonomies::ROUTES ] , $container[ self::SETTINGS_SCREEN ] );
649651
};
650652

653+
$container[ self::ABORT_IMPORT ] = function ( Container $container ) {
654+
return new Abort_Import( $container[ self::SETTINGS_SCREEN ] );
655+
};
656+
651657
add_action( 'bigcommerce/settings/register/screen=' . Settings_Screen::NAME, $this->create_callback( 'diagnostics_settings_register', function () use ( $container ) {
652658
$container[ self::DIAGNOSTICS_SECTION ]->register_settings_section();
653659
} ), 90, 0 );
@@ -663,6 +669,10 @@ private function diagnostics( Container $container ) {
663669
add_action( 'admin_post_' . Troubleshooting_Diagnostics::SYNC_SITE_URL, $this->create_callback( 'diagnostics_settings_sync_site_url_action', function () use ( $container ) {
664670
$container[ self::SITE_URL_SYNC ]->sync();
665671
} ), 10, 0 );
672+
673+
add_action( 'admin_post_' . Troubleshooting_Diagnostics::ABORT_NAME, $this->create_callback( 'diagnostics_settings_abort_import_action', function () use ( $container ) {
674+
$container[ self::ABORT_IMPORT ]->abort( $container['import.cleanup'] );
675+
} ), 10, 0 );
666676
}
667677

668678
private function resources( Container $container ) {

src/BigCommerce/Container/Theme_Customizer.php

+16-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
use Pimple\Container;
1111

1212
class Theme_Customizer extends Provider {
13-
const PANEL_PRIMARY = 'customizer.panel.primary';
14-
const SECTION_BUTTONS = 'customizer.section.buttons';
15-
const SECTION_COLORS = 'customizer.section.colors';
16-
const SECTION_PRODUCT_SINGLE = 'customizer.section.product_single';
17-
const SECTION_PRODUCT_ARCHIVE = 'customizer.section.product_archive';
18-
const SECTION_CART = 'customizer.section.cart';
19-
const SECTION_CHECKOUT = 'customizer.section.checkout';
20-
const SECTION_BANNERS = 'customizer.section.banners';
21-
const STYLES = 'customizer.styles';
13+
const PANEL_PRIMARY = 'customizer.panel.primary';
14+
const SECTION_BUTTONS = 'customizer.section.buttons';
15+
const SECTION_COLORS = 'customizer.section.colors';
16+
const SECTION_PRODUCT_SINGLE = 'customizer.section.product_single';
17+
const SECTION_PRODUCT_ARCHIVE = 'customizer.section.product_archive';
18+
const SECTION_PRODUCT_CATEGORIES = 'customizer.section.product_categories';
19+
const SECTION_CART = 'customizer.section.cart';
20+
const SECTION_CHECKOUT = 'customizer.section.checkout';
21+
const SECTION_BANNERS = 'customizer.section.banners';
22+
const STYLES = 'customizer.styles';
2223

2324
public function register( Container $container ) {
2425
$container[ self::PANEL_PRIMARY ] = function ( Container $container ) {
@@ -41,14 +42,18 @@ public function register( Container $container ) {
4142
return new Sections\Product_Archive();
4243
};
4344

45+
$container[ self::SECTION_PRODUCT_CATEGORIES ] = function ( Container $container ) {
46+
return new Sections\Product_Category();
47+
};
48+
4449
$container[ self::SECTION_CART ] = function ( Container $container ) {
4550
return new Sections\Cart();
4651
};
4752

4853
$container[ self::SECTION_CHECKOUT ] = function ( Container $container ) {
4954
return new Sections\Checkout();
5055
};
51-
56+
5257
$container[ self::SECTION_BANNERS ] = function ( Container $container ) {
5358
return new Sections\Banners();
5459
};
@@ -65,6 +70,7 @@ public function register( Container $container ) {
6570
$container[ self::SECTION_COLORS ]->register( $wp_customize );
6671
$container[ self::SECTION_PRODUCT_SINGLE ]->register( $wp_customize );
6772
$container[ self::SECTION_PRODUCT_ARCHIVE ]->register( $wp_customize );
73+
$container[ self::SECTION_PRODUCT_CATEGORIES ]->register( $wp_customize );
6874
$container[ self::SECTION_BANNERS ]->register( $wp_customize );
6975

7076
if ( get_option( \BigCommerce\Settings\Sections\Cart::OPTION_ENABLE_CART, true ) ) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace BigCommerce\Customizer\Sections;
4+
5+
use BigCommerce\Customizer\Panels;
6+
7+
/**
8+
* Class Product_Category
9+
*
10+
* @package BigCommerce\Customizer\Sections
11+
*/
12+
class Product_Category {
13+
14+
const NAME = 'bigcommerce_product_categories';
15+
const CHILD_ITEM_SHOW = 'bigcommerce_show_child_items';
16+
17+
/**
18+
* Register Product Category customize section and related controls
19+
*
20+
* @param \WP_Customize_Manager $wp_customize
21+
*
22+
* @return void
23+
*/
24+
public function register( $wp_customize ) {
25+
$wp_customize->add_section( new \WP_Customize_Section( $wp_customize, self::NAME, [
26+
'title' => __( 'Product Category', 'bigcommerce' ),
27+
'panel' => Panels\Primary::NAME,
28+
] ) );
29+
30+
$wp_customize->add_setting( new \WP_Customize_Setting( $wp_customize, self::CHILD_ITEM_SHOW, [
31+
'type' => 'option',
32+
'default' => 'no',
33+
'transport' => 'refresh',
34+
] ) );
35+
36+
$wp_customize->add_control(self::CHILD_ITEM_SHOW, [
37+
'section' => self::NAME,
38+
'type' => 'radio',
39+
'label' => __( 'Menus Sub-Categories', 'bigcommerce' ),
40+
'choices' => [
41+
'yes' => __( 'Show Product Sub-Categories in Menu', 'bigcommerce' ),
42+
'no' => __( 'Hide Product Sub-Categories in Menu', 'bigcommerce' ),
43+
],
44+
'description' => __( 'Toggle the ability to displaying Sub-Categories in menu', 'bigcommerce' ),
45+
] );
46+
}
47+
}

src/BigCommerce/Import/Processors/Cleanup.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct( $batch = 100 ) {
2525
$this->batch = $batch;
2626
}
2727

28-
public function run() {
28+
public function run( $abort = false ) {
2929
$status = new Status();
3030
$status->set_status( Status::CLEANING );
3131

@@ -49,7 +49,12 @@ public function run() {
4949
delete_option( Product_Data_Fetcher::FILTERED_LISTING_MAP );
5050
delete_option( Import_Type::IMPORT_TYPE );
5151

52-
$status->set_status( Status::COMPLETED );
52+
if ( $abort ) {
53+
$status->set_status( Status::ABORTED );
54+
} else {
55+
$status->set_status( Status::COMPLETED );
56+
}
57+
5358

5459
$this->clean_customer_group_transients();
5560

src/BigCommerce/Import/Runner/Status.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Status {
1111

1212
const NOT_STARTED = 'not_started';
1313
const STARTED = 'started';
14+
const ABORTED = 'aborted';
1415
const FETCHING_LISTINGS = 'fetching_listings';
1516
const FETCHED_LISTINGS = 'fetched_listings';
1617
const INITIALIZING_CHANNEL = 'initializing_channel';

src/BigCommerce/Nav_Menu/Dynamic_Menu_Items.php

+67-23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace BigCommerce\Nav_Menu;
55

6+
use BigCommerce\Customizer\Sections\Product_Category as Customizer;
67
use BigCommerce\Post_Types\Product\Product;
78

89
class Dynamic_Menu_Items {
@@ -60,7 +61,7 @@ public function insert_dynamic_menu_items( $items, $menu, $args ) {
6061

6162
/**
6263
* Get the top-level terms from the taxonomy as menu items
63-
*
64+
*
6465
* @param object $item
6566
*
6667
* @return array
@@ -70,30 +71,73 @@ private function get_menu_item_children( $item ) {
7071
if ( ! $taxonomy ) {
7172
return [];
7273
}
73-
$terms = get_terms( [
74-
'taxonomy' => $taxonomy->name,
75-
'hide_empty' => true,
76-
'hierarchical' => true,
77-
'parent' => 0,
78-
'meta_query' => [
79-
[
80-
'key' => 'sort_order',
81-
'type' => 'NUMERIC',
82-
]
83-
],
84-
'orderby' => 'sort_order',
85-
'order' => 'ASC',
86-
] );
87-
$index = 1;
88-
$items = array_map( function ( $term ) use ( $item, &$index ) {
89-
$term = wp_setup_nav_menu_item( $term );
9074

91-
$term->menu_item_parent = $item->ID;
92-
$term->post_status = 'publish';
75+
$terms = $this->get_terms_items( $taxonomy );
76+
$should_retrieve_child_items = get_option( Customizer::CHILD_ITEM_SHOW, 'no' ) === 'yes';
77+
$items = [];
78+
79+
if ( ! empty( $terms ) ) {
80+
foreach ( $terms as $term ) {
81+
$term_taxonomy = $term->taxonomy;
82+
$term_id = $term->term_id;
83+
84+
$term = wp_setup_nav_menu_item( $term );
85+
$term->menu_item_parent = $item->ID;
86+
$term->post_status = 'publish';
87+
88+
$items[] = $term;
9389

94-
return $term;
95-
}, $terms );
90+
if ( ! $should_retrieve_child_items ) {
91+
continue;
92+
}
93+
94+
// Get term children to level 1.
95+
$term_children = $this->get_terms_items( $term_taxonomy, $term_id );
96+
97+
if ( empty( $term_children ) ) {
98+
continue;
99+
}
100+
101+
foreach ( $term_children as $child ) {
102+
$term_child = wp_setup_nav_menu_item( $child );
103+
$term_child->title = ' - ' . $term_child->title;
104+
$term_child->menu_item_parent = $item->ID;
105+
$term_child->post_status = 'publish';
106+
107+
$items[] = $term_child;
108+
}
109+
}
110+
}
96111

97112
return $items;
98113
}
99-
}
114+
115+
/**
116+
* @param $taxonomy
117+
* @param int $parent
118+
*
119+
* @return array|int[]|string|string[]|\WP_Error|\WP_Term[]
120+
*/
121+
private function get_terms_items( $taxonomy, int $parent = 0 ) {
122+
$terms = get_terms( [
123+
'taxonomy' => is_object( $taxonomy ) ? $taxonomy->name : $taxonomy,
124+
'hide_empty' => true,
125+
'hierarchical' => true,
126+
'parent' => $parent,
127+
'meta_query' => [
128+
[
129+
'key' => 'sort_order',
130+
'type' => 'NUMERIC',
131+
],
132+
],
133+
'orderby' => 'sort_order',
134+
'order' => 'ASC',
135+
] );
136+
137+
if ( empty( $terms ) || is_wp_error( $terms ) ) {
138+
return [];
139+
}
140+
141+
return $terms;
142+
}
143+
}

0 commit comments

Comments
 (0)