Skip to content

Commit

Permalink
packaged version 4.9.0 (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladanost committed Mar 19, 2021
1 parent d100587 commit c7eaeca
Show file tree
Hide file tree
Showing 35 changed files with 636 additions and 149 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [4.9.0]

### Added
- Added support for Product Category images
- Added additional error message when attempting to create a channel with an existing name


## [4.8.0]

### Fixed
Expand Down Expand Up @@ -1364,6 +1371,7 @@
in fact, reset postdata, so far as Gutenberg 3.2.0 is concerned.


[4.9.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.8.0...4.9.0
[4.8.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.7.0...4.8.0
[4.7.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.6.0...4.7.0
[4.6.0]: https://github.com/bigcommerce/bigcommerce-for-wordpress/compare/4.5.0...4.6.0
Expand Down
8 changes: 7 additions & 1 deletion assets/css/master.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/master.min.css

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions assets/pcss/content/loop/_products.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@
padding: 0 30px;
}
}

.attachment-bc-category-image {
display: block;
max-width: 100%;
height: auto;
margin: 0.5em 0 1em;
}
2 changes: 1 addition & 1 deletion bigcommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: BigCommerce for WordPress
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.
Author: BigCommerce
Version: 4.8.0
Version: 4.9.0
Author URI: https://www.bigcommerce.com/wordpress
Requires PHP: 7.2.0
Text Domain: bigcommerce
Expand Down
2 changes: 1 addition & 1 deletion build-timestamp.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '5.54.02.05.2021');
define('BIGCOMMERCE_ASSETS_BUILD_TIMESTAMP', '3.59.03.19.2021');
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: bigcommerce, moderntribe, jbrinley, becomevocal, vincentlistrani,
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
Requires at least: 5.2
Tested up to: 5.5
Stable tag: 4.8.0
Stable tag: 4.9.0
Requires PHP: 7.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
18 changes: 12 additions & 6 deletions src/BigCommerce/Assets/Theme/Image_Sizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ class Image_Sizes {
const VERSION = 2;
const STATE_META = 'bigcommerce_sizing';

const BC_THUMB = 'bc-thumb';
const BC_THUMB_LARGE = 'bc-thumb-large';
const BC_SMALL = 'bc-small';
const BC_MEDIUM = 'bc-medium';
const BC_EXTRA_MEDIUM = 'bc-xmedium';
const BC_LARGE = 'bc-large';
const BC_THUMB = 'bc-thumb';
const BC_THUMB_LARGE = 'bc-thumb-large';
const BC_SMALL = 'bc-small';
const BC_MEDIUM = 'bc-medium';
const BC_EXTRA_MEDIUM = 'bc-xmedium';
const BC_LARGE = 'bc-large';
const BC_CATEGORY_IMAGE = 'bc-category-image';

// Increment self::VERSION above when adding/changing this list
private $sizes = [
Expand Down Expand Up @@ -47,6 +48,11 @@ class Image_Sizes {
'height' => 1280,
'crop' => true,
],
self::BC_CATEGORY_IMAGE => [
'width' => 1600,
'height' => 0,
'crop' => false,
],
];

/**
Expand Down
1 change: 1 addition & 0 deletions src/BigCommerce/Import/Importers/Terms/Term_Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected function save_wp_term( \ArrayAccess $bc_term ) {

protected function save_wp_termmeta( \ArrayAccess $bc_term ) {
update_term_meta( $this->term_id, 'bigcommerce_id', $bc_term[ 'id' ] );
update_term_meta( $this->term_id, 'sort_order', $bc_term[ 'sort_order' ] );
}

}
32 changes: 32 additions & 0 deletions src/BigCommerce/Import/Importers/Terms/Term_Saver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace BigCommerce\Import\Importers\Terms;

use BigCommerce\Import\Import_Strategy;
use BigCommerce\Import\Image_Importer;

abstract class Term_Saver implements Import_Strategy {
/** @var \ArrayAccess */
Expand All @@ -29,6 +30,7 @@ public function __construct( \ArrayAccess $bc_term, $taxonomy, $term_id = 0 ) {
public function do_import() {
$this->term_id = $this->save_wp_term( $this->bc_term );
$this->save_wp_termmeta( $this->bc_term );
$this->import_image( $this->bc_term );

return $this->term_id;
}
Expand Down Expand Up @@ -143,4 +145,34 @@ protected function determine_parent_term_id( \ArrayAccess $bc_term ) {

return 0;
}

protected function import_image( \ArrayAccess $bc_term ) {
$image_url = $bc_term[ 'image_url' ];

// find an existing image
$existing = get_posts( [
'post_type' => 'attachment',
'meta_query' => [
[
'key' => Image_Importer::SOURCE_URL,
'value' => $image_url,
'compare' => '=',
],
],
'fields' => 'ids',
'posts_per_page' => 1,
] );

if ( ! empty( $existing ) ) {
$post_id = reset( $existing );
} else {
$importer = new Image_Importer( $image_url );
$post_id = $importer->import();
}
if ( ! empty( $post_id ) ) {
update_term_meta( $this->term_id, 'thumbnail_id', $post_id );
} else {
delete_term_meta( $this->term_id, 'thumbnail_id' );
}
}
}
2 changes: 1 addition & 1 deletion src/BigCommerce/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace BigCommerce;

class Plugin {
const VERSION = '4.8.0';
const VERSION = '4.9.0';

protected static $_instance;

Expand Down
4 changes: 4 additions & 0 deletions src/BigCommerce/Taxonomies/Channel/Channel_Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ private function create_channel( $name ) {
try {
$response = $this->channels->createChannel( $request );
} catch ( ApiException $e ) {
$resp_body = $e->getResponseBody();
if ( ! empty( $resp_body->title ) ) {
add_settings_error( Channel_Select::NEW_CHANNEL, 'api_channel_error', $resp_body->title );
}
do_action( 'bigcommerce/channel/error/could_not_create_channel', $e, $request );

return 0;
Expand Down
47 changes: 36 additions & 11 deletions src/BigCommerce/Templates/Product_Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,38 @@

namespace BigCommerce\Templates;


use BigCommerce\Customizer;
use BigCommerce\Post_Types\Product\Product;
use BigCommerce\Taxonomies\Brand\Brand;
use BigCommerce\Taxonomies\Product_Category\Product_Category;
use BigCommerce\Settings\Sections\Api_Credentials;
use BigCommerce\Assets\Theme\Image_Sizes;

class Product_Archive extends Controller {
const QUERY = 'query';

const POSTS = 'posts';
const NO_RESULTS = 'no_results';
const TITLE = 'title';
const DESCRIPTION = 'description';
const REFINERY = 'refinery';
const PAGINATION = 'pagination';
const COLUMNS = 'columns';
const POSTS = 'posts';
const NO_RESULTS = 'no_results';
const TITLE = 'title';
const DESCRIPTION = 'description';
const THUMBNAIL = 'thumbnail';
const THUMBNAIL_SIZE = 'thumbnail';
const REFINERY = 'refinery';
const PAGINATION = 'pagination';
const COLUMNS = 'columns';

protected $template = 'components/catalog/product-archive.php';

protected function parse_options( array $options ) {
$defaults = [
self::QUERY => null, // \WP_Query
self::COLUMNS => absint( get_option( Customizer\Sections\Product_Archive::GRID_COLUMNS, 4 ) ),
self::QUERY => null, // \WP_Query
self::COLUMNS => absint( get_option( Customizer\Sections\Product_Archive::GRID_COLUMNS, 4 ) ),
/**
* Filter the thumbnail size
*
* @param string $size The image size to use
*/
self::THUMBNAIL_SIZE => apply_filters( 'bigcommerce/template/product_archive/thumbnail_size', Image_Sizes::BC_CATEGORY_IMAGE ),
];

return wp_parse_args( $options, $defaults );
Expand All @@ -40,6 +48,7 @@ public function get_data() {
self::POSTS => $this->get_posts( $query ),
self::TITLE => $this->get_title( $query ),
self::DESCRIPTION => $this->get_description(),
self::THUMBNAIL => $this->get_thumbnail(),
self::REFINERY => $this->get_refinery( $query ),
self::PAGINATION => $this->get_pagination( $query ),
self::COLUMNS => $this->options[ self::COLUMNS ],
Expand Down Expand Up @@ -98,6 +107,22 @@ private function get_description() {
return $description;
}

private function get_thumbnail() {
$term = get_queried_object();

if ( ! is_a( $term, 'WP_Term' ) ) {
return '';
}

$attachment_id = get_term_meta( $term->term_id, 'thumbnail_id', true );

if ( $attachment_id ) {
return wp_get_attachment_image( $attachment_id, $this->options[ self::THUMBNAIL_SIZE ] );
}

return '';
}

private function get_refinery( \WP_Query $query ) {
$component = Refinery::factory( [
Refinery::QUERY => $query,
Expand All @@ -120,4 +145,4 @@ private function get_no_results() {
return $component->render();
}

}
}
2 changes: 2 additions & 0 deletions templates/public/components/catalog/product-archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @var string $no_results
* @var string $title
* @var string $description
* @var string $thumbnail
* @var string $refinery
* @var string $pagination
* @var string $columns
Expand All @@ -16,6 +17,7 @@

<header class="bc-product-archive__header">
<h2 class="bc-product-archive__title"><?php echo esc_html( $title ); ?></h2>
<?php echo wp_kses_post( $thumbnail ); ?>
<div><?php echo wp_kses_post( $description ); ?></div>
</header>

Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitef8b243e8bac21b00e6d48497c7050eb::getLoader();
return ComposerAutoloaderInitf629a677b821c24e4ef358484fa6c69d::getLoader();
3 changes: 2 additions & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@
'Dotenv\\Validator' => $vendorDir . '/vlucas/phpdotenv/src/Validator.php',
'Firebase\\JWT\\BeforeValidException' => $vendorDir . '/firebase/php-jwt/src/BeforeValidException.php',
'Firebase\\JWT\\ExpiredException' => $vendorDir . '/firebase/php-jwt/src/ExpiredException.php',
'Firebase\\JWT\\JWK' => $vendorDir . '/firebase/php-jwt/src/JWK.php',
'Firebase\\JWT\\JWT' => $vendorDir . '/firebase/php-jwt/src/JWT.php',
'Firebase\\JWT\\SignatureInvalidException' => $vendorDir . '/firebase/php-jwt/src/SignatureInvalidException.php',
'Monolog\\ErrorHandler' => $vendorDir . '/monolog/monolog/src/Monolog/ErrorHandler.php',
Expand Down Expand Up @@ -977,7 +978,7 @@
'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php',
'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php',
'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php',
'Psr\\Log\\Test\\DummyTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\DummyTest' => $vendorDir . '/psr/log/Psr/Log/Test/DummyTest.php',
'Psr\\Log\\Test\\LoggerInterfaceTest' => $vendorDir . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\TestLogger' => $vendorDir . '/psr/log/Psr/Log/Test/TestLogger.php',
);
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitef8b243e8bac21b00e6d48497c7050eb
class ComposerAutoloaderInitf629a677b821c24e4ef358484fa6c69d
{
private static $loader;

Expand All @@ -19,15 +19,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitef8b243e8bac21b00e6d48497c7050eb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf629a677b821c24e4ef358484fa6c69d', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitef8b243e8bac21b00e6d48497c7050eb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf629a677b821c24e4ef358484fa6c69d', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -39,19 +39,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireef8b243e8bac21b00e6d48497c7050eb($fileIdentifier, $file);
composerRequiref629a677b821c24e4ef358484fa6c69d($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequireef8b243e8bac21b00e6d48497c7050eb($fileIdentifier, $file)
function composerRequiref629a677b821c24e4ef358484fa6c69d($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
13 changes: 7 additions & 6 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb
class ComposerStaticInitf629a677b821c24e4ef358484fa6c69d
{
public static $files = array (
'5255c38a0faeba867671b61dfda6d864' => __DIR__ . '/..' . '/paragonie/random_compat/lib/random.php',
Expand Down Expand Up @@ -936,6 +936,7 @@ class ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb
'Dotenv\\Validator' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Validator.php',
'Firebase\\JWT\\BeforeValidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/BeforeValidException.php',
'Firebase\\JWT\\ExpiredException' => __DIR__ . '/..' . '/firebase/php-jwt/src/ExpiredException.php',
'Firebase\\JWT\\JWK' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWK.php',
'Firebase\\JWT\\JWT' => __DIR__ . '/..' . '/firebase/php-jwt/src/JWT.php',
'Firebase\\JWT\\SignatureInvalidException' => __DIR__ . '/..' . '/firebase/php-jwt/src/SignatureInvalidException.php',
'Monolog\\ErrorHandler' => __DIR__ . '/..' . '/monolog/monolog/src/Monolog/ErrorHandler.php',
Expand Down Expand Up @@ -1060,18 +1061,18 @@ class ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb
'Psr\\Log\\LoggerInterface' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerInterface.php',
'Psr\\Log\\LoggerTrait' => __DIR__ . '/..' . '/psr/log/Psr/Log/LoggerTrait.php',
'Psr\\Log\\NullLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/NullLogger.php',
'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\DummyTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/DummyTest.php',
'Psr\\Log\\Test\\LoggerInterfaceTest' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/LoggerInterfaceTest.php',
'Psr\\Log\\Test\\TestLogger' => __DIR__ . '/..' . '/psr/log/Psr/Log/Test/TestLogger.php',
);

public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::$prefixesPsr0;
$loader->classMap = ComposerStaticInitef8b243e8bac21b00e6d48497c7050eb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::$prefixesPsr0;
$loader->classMap = ComposerStaticInitf629a677b821c24e4ef358484fa6c69d::$classMap;

}, null, ClassLoader::class);
}
Expand Down
Loading

0 comments on commit c7eaeca

Please sign in to comment.