diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index def0228a..70dc9124 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,4 +1,9 @@
== Changelog ==
+= 6.12.20 - Oct 3, 2024 =
+- In the "Only featured products" mode, the "Store Home Page" ecommerce block was displayed incorrectly. We've fixed this.
+- Fixed an issue with the "Manage access to store control panel" feature where in some cases users couldn't have access to embedded store control panel.
+- Internal improvements and optimizations.
+
= 6.12.19 - Sep 11, 2024 =
- Fixed an issue with processing some store pages links.
- Internal improvements and optimizations.
diff --git a/ecwid-shopping-cart.php b/ecwid-shopping-cart.php
index 582f573d..4680bf4b 100644
--- a/ecwid-shopping-cart.php
+++ b/ecwid-shopping-cart.php
@@ -5,7 +5,7 @@
Description: Ecwid by Lightspeed is a free full-featured shopping cart. It can be easily integrated with any Wordpress blog and takes less than 5 minutes to set up.
Text Domain: ecwid-shopping-cart
Author: Ecwid Ecommerce
-Version: 6.12.19
+Version: 6.12.20
Author URI: https://ecwid.to/ecwid-site
License: GPLv2 or later
*/
@@ -108,11 +108,11 @@
require_once ECWID_PLUGIN_DIR . 'lib/ecwid_api_v3.php';
require_once ECWID_PLUGIN_DIR . 'includes/themes.php';
-require_once ECWID_PLUGIN_DIR . 'includes/oembed.php';
require_once ECWID_PLUGIN_DIR . 'includes/widgets.php';
require_once ECWID_PLUGIN_DIR . 'includes/shortcodes.php';
require_once ECWID_PLUGIN_DIR . 'includes/kliken.php';
+require_once ECWID_PLUGIN_DIR . 'includes/class-ec-store-oembed.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-message-manager.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-store-editor.php';
require_once ECWID_PLUGIN_DIR . 'includes/class-ecwid-product-popup.php';
@@ -1638,10 +1638,11 @@ function ecwid_plugin_activation_redirect( $plugin ) {
&& count($_POST['checked']) > 1;
$is_cli_running = Ecwid_Config::is_cli_running();
+ $is_wp_playground = Ecwid_Config::is_wp_playground_running();
$is_newbie = ecwid_is_demo_store();
- if( !$is_cli_running && !$is_bulk_activation && $is_newbie && $plugin == plugin_basename( __FILE__ ) ) {
+ if( !$is_cli_running && $is_wp_playground && !$is_bulk_activation && $is_newbie && $plugin == plugin_basename( __FILE__ ) ) {
wp_safe_redirect( Ecwid_Admin::get_dashboard_url() );
exit();
}
@@ -2987,6 +2988,7 @@ function ecwid_update_store_id( $new_store_id ) {
function ecwid_is_paid_account()
{
+ return false;
if ( Ecwid_Api_V3::is_available() ) {
$api = new Ecwid_Api_V3();
diff --git a/includes/class-ec-store-admin-access.php b/includes/class-ec-store-admin-access.php
index a12b2d60..d14144a4 100644
--- a/includes/class-ec-store-admin-access.php
+++ b/includes/class-ec-store-admin-access.php
@@ -41,10 +41,13 @@ public function save_custom_user_profile_fields( $user_id ) {
}
public static function get_users_with_manage_access() {
+ global $wpdb;
+ $table_prefix = $wpdb->prefix;
+
$args = array(
'meta_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
- 'key' => 'wp_capabilities',
+ 'key' => $table_prefix . 'capabilities',
'value' => self::CAP_MANAGE_CONTROL_PANEL . '";b:1',
'compare' => 'LIKE',
),
diff --git a/includes/class-ec-store-oembed.php b/includes/class-ec-store-oembed.php
new file mode 100644
index 00000000..27d532ce
--- /dev/null
+++ b/includes/class-ec-store-oembed.php
@@ -0,0 +1,100 @@
+post_content;
+ $shortcodes = array();
+
+ foreach ( Ecwid_Shortcode_Base::get_store_shortcode_names() as $shortcode_name ) {
+ $shortcodes = ecwid_find_shortcodes( $post_content, $shortcode_name );
+ if ( $shortcodes ) {
+ break;
+ }
+ }
+
+ if ( ! $shortcodes || ! isset( $shortcodes[0] ) || ! isset( $shortcodes[0][3] ) ) {
+ return;
+ }
+
+ $attributes = $shortcodes[0][3];
+ if ( ! preg_match( '/default_category_id=.([\\d]*)./', $attributes, $matches ) ) {
+ return;
+ }
+
+ $root_category_id = intval( $matches[1] ) <= 0 ? 0 : $matches[1];
+
+ $api = new Ecwid_Api_V3();
+
+ $categories = $api->get_categories( array( 'parent' => $root_category_id ) );
+
+ $max_items = 5;
+
+ $items = array();
+
+ $see_more = false;
+ $result = '';
+ if ( ! empty( $categories->items ) ) {
+ foreach ( $categories->items as $category ) {
+ $category = Ecwid_Category::get_by_id( $category->id );
+ $items[ $category->link ] = $category->name;
+ if ( count( $items ) >= $max_items ) {
+ $see_more = true;
+ break;
+ }
+ }
+ }
+
+ $api = new Ecwid_Api_V3();
+
+ $category = $api->get_category( $root_category_id );
+
+ if ( $category ) {
+ $trimmed = ecwid_trim_description( $category->description );
+ $result .= '
' . ecwid_trim_description( $category->description );
+
+ $descr_length = function_exists( 'mb_strlen' ) ? mb_strlen( $category->description ) : strlen( $category->description );
+ $trimmed_length = function_exists( 'mb_strlen' ) ? mb_strlen( $trimmed ) : strlen( $trimmed );
+
+ if ( $trimmed_length < $descr_length && $trimmed_length == ECWID_TRIMMED_DESCRIPTION_LENGTH ) {
+ $result .= '...
' . __( 'See more', 'ecwid-shopping-cart' ) . ' ';
+ }
+ $result .= '
';
+ }
+
+ if ( ! $see_more ) {
+ $products = $api->search_products( array( 'category' => $root_category_id ) );
+
+ if ( $products->items ) {
+ foreach ( $products->items as $product ) {
+ $product = Ecwid_Product::get_by_id( $product->id );
+ $items[ $product->link ] = $product->name;
+ if ( count( $items ) >= $max_items ) {
+ $see_more = true;
+ break;
+ }
+ }
+ }
+ }
+
+ $result .= '';
+
+ return $result;
+ }
+}
+
+add_filter( 'embed_content', 'Ec_Store_Oembed::print_content', 10, 1 );
diff --git a/includes/class-ecwid-config.php b/includes/class-ecwid-config.php
index 4b26c8cb..3b4ee4a2 100644
--- a/includes/class-ecwid-config.php
+++ b/includes/class-ecwid-config.php
@@ -130,6 +130,10 @@ public static function is_cli_running() {
return defined( 'WP_CLI' ) && WP_CLI;
}
+ public static function is_wp_playground_running() {
+ return defined( 'IS_PLAYGROUND_PREVIEW' ) && IS_PLAYGROUND_PREVIEW;
+ }
+
public static function load_from_cli( $config ) {
if ( ! $config ) {
diff --git a/includes/class-ecwid-product-browser.php b/includes/class-ecwid-product-browser.php
index 96afbf62..32c5e32d 100644
--- a/includes/class-ecwid-product-browser.php
+++ b/includes/class-ecwid-product-browser.php
@@ -428,7 +428,6 @@ public static function get_attributes() {
}
if ( $api->is_store_feature_available( Ecwid_Api_V3::FEATURE_PRODUCT_SUBTITLES ) ) {
-
$attributes['product_list_subtitles_behavior'] = array(
'name' => 'product_list_subtitles_behavior',
'title' => __( 'Product subtitles', 'ecwid-shopping-cart' ),
@@ -447,7 +446,6 @@ public static function get_attributes() {
}
return $attributes;
-
}
protected static function _get_behaviors() {
diff --git a/includes/class-ecwid-static-page.php b/includes/class-ecwid-static-page.php
index e33f4dc4..5d8110c1 100644
--- a/includes/class-ecwid-static-page.php
+++ b/includes/class-ecwid-static-page.php
@@ -124,7 +124,7 @@ protected static function maybe_fetch_data() {
$pb_attribures[ $param ] = array(
'name' => $param,
'is_storefront_api' => true,
- 'type' => true,
+ 'type' => 'boolean',
);
}
}
diff --git a/includes/class-ecwid-store-page.php b/includes/class-ecwid-store-page.php
index 0f1af37e..570d220c 100644
--- a/includes/class-ecwid-store-page.php
+++ b/includes/class-ecwid-store-page.php
@@ -7,7 +7,6 @@ class Ecwid_Store_Page {
const OPTION_LAST_STORE_PAGE_ID = 'ecwid_last_store_page_id';
const OPTION_FLUSH_REWRITES = 'ecwid_flush_rewrites';
const OPTION_REPLACE_TITLE = 'ecwid_replace_title';
- const WARMUP_ACTION = 'ecwid_warmup_store';
const META_STORE_DATA = 'ecwid_store';
@@ -398,45 +397,6 @@ protected static function _get_allowed_post_statuses() {
return array( 'publish', 'private', 'draft' );
}
- public static function warmup_store() {
- $store_page = get_post( self::get_current_store_page_id() );
-
- if ( ! $store_page ) {
- return;
- }
-
- $shortcodes = array();
- foreach ( Ecwid_Shortcode_Base::get_store_shortcode_names() as $shortcode_name ) {
- $shortcodes[] = ecwid_find_shortcodes( $store_page->post_content, $shortcode_name );
- }
-
- if ( count( $shortcodes ) === 0 ) {
- return;
- }
-
- $shortcode_data = $shortcodes[0];
-
- $category = 0;
-
- if ( isset( $shortcode_data[3] ) ) {
- $attributes = shortcode_parse_atts( $shortcode_data[3] );
-
- if ( ! $attributes ) {
- return;
- }
-
- $category = $attributes['default_category_id'];
- }
-
- $page_url = get_permalink( $store_page );
-
- include_once ECWID_PLUGIN_DIR . 'lib/ecwid_catalog.php';
-
- $catalog = new EcwidCatalog( get_ecwid_store_id(), $page_url );
-
- $catalog->warmup_store_page( intval( $category ) );
- }
-
public static $main_page_title = '';
// If you figure out a better place to put this the_title functionality, go ahead, move it =)
@@ -631,7 +591,6 @@ public static function delete_page_from_nav_menus() {
add_action( 'init', array( 'Ecwid_Store_Page', 'flush_rewrites' ) );
add_action( 'save_post', array( 'Ecwid_Store_Page', 'on_save_post' ) );
-add_action( 'wp_ajax_' . Ecwid_Store_Page::WARMUP_ACTION, array( 'Ecwid_Store_Page', 'warmup_store' ) );
add_action( 'update_option_page_on_front', array( 'Ecwid_Store_Page', 'schedule_flush_rewrites' ) );
add_action( 'display_post_states', array( 'Ecwid_Store_Page', 'display_post_states' ), 10, 2 );
diff --git a/includes/oembed.php b/includes/oembed.php
deleted file mode 100644
index 4e343fda..00000000
--- a/includes/oembed.php
+++ /dev/null
@@ -1,123 +0,0 @@
-post_content;
- $shortcodes = array();
-
- foreach ( Ecwid_Shortcode_Base::get_store_shortcode_names() as $shortcode_name ) {
- $shortcodes = ecwid_find_shortcodes( $post_content, $shortcode_name );
- if ( $shortcodes ) {
- break;
- }
- }
-
- if ( ! $shortcodes || ! isset( $shortcodes[0] ) || ! isset( $shortcodes[0][3] ) ) {
- return;
- }
-
- $attributes = $shortcodes[0][3];
- if ( ! preg_match( '/default_category_id=.([\\d]*)./', $attributes, $matches ) ) {
- return;
- }
-
- $root_category_id = 0;
- if ( ! is_numeric( $matches[1] ) ) {
- return;
- } elseif ( isset( $matches[1] ) ) {
- $root_category_id = $matches[1];
- }
-
- $api = new Ecwid_Api_V3();
-
- $categories = $api->get_categories( array( 'parent' => $root_category_id ) );
-
- $max_items = 5;
-
- $items = array();
-
- $see_more = false;
- $result = '';
- if ( ! empty( $categories->items ) ) {
- foreach ( $categories->items as $category ) {
- $category = Ecwid_Category::get_by_id( $category->id );
- $items[ $category->link ] = $category->name;
- if ( count( $items ) >= $max_items ) {
- $see_more = true;
- break;
- }
- }
- }
-
- if ( ecwid_is_paid_account() ) {
- $api = new Ecwid_Api_V3();
-
- $category = $api->get_category( $root_category_id );
-
- if ( $category ) {
- $trimmed = ecwid_trim_description( $category->description );
- $result .= '' . ecwid_trim_description( $category->description );
-
- $descr_length = function_exists( 'mb_strlen' ) ? mb_strlen( $category->description ) : strlen( $category->description );
- $trimmed_length = function_exists( 'mb_strlen' ) ? mb_strlen( $trimmed ) : strlen( $trimmed );
-
- if ( $trimmed_length < $descr_length && $trimmed_length == ECWID_TRIMMED_DESCRIPTION_LENGTH ) {
- $result .= '...
' . __( 'See more', 'ecwid-shopping-cart' ) . ' ';
- }
- $result .= '
';
- }
-
- if ( ! $see_more ) {
- $products = $api->search_products( array( 'category' => $root_category_id ) );
-
- if ( $products->items ) {
- foreach ( $products->items as $product ) {
- $product = Ecwid_Product::get_by_id( $product->id );
- $items[ $product->link ] = $product->name;
- if ( count( $items ) >= $max_items ) {
- $see_more = true;
- break;
- }
- }
- }
- }
- }//end if
-
- $result .= '';
- return $result;
-}
-
-function _ecwid_find_category_in_horizontal_categories_tree( $categories, $root_id ) {
- foreach ( $categories as $category ) {
- if ( $category->id == $root_id ) {
- return $category->sub;
- }
-
- if ( ! is_null( $category->sub ) ) {
- $result = _ecwid_find_category_in_horizontal_categories_tree( $category->sub, $root_id );
- if ( $result !== false ) {
- return $result;
- }
- }
- }
- return false;
-}
diff --git a/includes/shortcodes/class-ecwid-shortcode-stub.php b/includes/shortcodes/class-ecwid-shortcode-stub.php
deleted file mode 100644
index 12a95eb6..00000000
--- a/includes/shortcodes/class-ecwid-shortcode-stub.php
+++ /dev/null
@@ -1,27 +0,0 @@
-_get_html_class_name();
- $id = $this->get_html_id();
- return '';
- }
-}
diff --git a/lib/ecwid_catalog.php b/lib/ecwid_catalog.php
deleted file mode 100755
index e50e0405..00000000
--- a/lib/ecwid_catalog.php
+++ /dev/null
@@ -1,141 +0,0 @@
-store_id = intval( $store_id );
- $this->store_base_url = $store_base_url;
- }
-
- public function warmup_store_page( $category_id ) {
- $this->_get_data_for_category( $category_id, null );
- }
-
- public function get_product( $id ) {
- $result = $this->_get_data_for_product( $id );
-
- if ( ! $result ) {
- return '';
- }
-
- ob_start();
- $product = $result->product;
- $formats = $result->formats;
- require __DIR__ . '/html-catalog-templates/product.php';
-
- $return = ob_get_contents();
- ob_end_clean();
-
- return $return;
- }
-
- public function get_category( $id ) {
- $offset = ( isset( $_GET['offset'] ) ) ? intval( $_GET['offset'] ) : 0;
- $data = $this->_get_data_for_category( $id, $offset );
-
- if ( ! $data ) {
- return '';
- }
-
- $main_category = null;
- if ( $id > 0 ) {
- $main_category = $data->main_category;
- }
- $categories = $data->categories;
- $products = $data->products;
- $formats = $data->formats;
-
- ob_start();
- require __DIR__ . '/html-catalog-templates/category.php';
-
- $return = ob_get_contents();
- ob_end_clean();
-
- return $return;
- }
-
- protected function _get_data_for_product( $id ) {
- if ( Ecwid_Api_V3::is_available() ) {
- $api = new Ecwid_Api_V3();
-
- $product = Ecwid_Product::get_by_id( $id );
-
- $profile = $api->get_store_profile();
-
- if ( ! $profile ) {
- return null;
- }
-
- return (object) array(
- 'product' => $product,
- 'formats' => @$profile->formatsAndUnits,
- );
- }
-
- return null;
- }
-
- protected function _get_data_for_category( $id, $offset = 0 ) {
- if ( Ecwid_Api_V3::is_available() ) {
- $api = new Ecwid_Api_V3();
-
- $main_category = null;
- if ( $id > 0 ) {
- $main_category = $api->get_category( $id );
- }
-
- $get_categories_params = array(
- 'parent' => $id,
- );
- if ( $offset && $offset > 0 ) {
- $get_categories_params['offset'] = $offset;
- }
- $categories = $api->get_categories( $get_categories_params );
-
- $get_products_params = array(
- 'category' => $id,
- );
- if ( $offset ) {
- $get_products_params['offset'] = $offset;
- }
- $products = $api->search_products( $get_products_params );
-
- $profile = $api->get_store_profile();
-
- if ( is_null( $profile ) || ! isset( $categories->items ) || ! isset( $products->items ) ) {
- return null;
- }
-
- return (object) array(
- 'main_category' => $main_category,
- 'categories' => $categories->items,
- 'products' => $products->items,
- 'formats' => @$profile->formatsAndUnits,
- );
- }//end if
-
- return null;
- }
-
- public function parse_escaped_fragment( $escaped_fragment ) {
- $fragment = urldecode( $escaped_fragment );
- $return = array();
-
- if ( preg_match( '/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches ) ) {
- parse_str( $matches[3], $return );
- $return['mode'] = $matches[2];
- } elseif ( preg_match( '!.*/(p|c)/([0-9]*)!', $fragment, $matches ) ) {
- if ( count( $matches ) == 3 && in_array( $matches[1], array( 'p', 'c' ) ) ) {
- $return = array(
- 'mode' => 'p' == $matches[1] ? 'product' : 'category',
- 'id' => $matches[2],
- );
- }
- }
-
- return $return;
- }
-}
diff --git a/lib/html-catalog-templates/category.php b/lib/html-catalog-templates/category.php
deleted file mode 100644
index 156ff2df..00000000
--- a/lib/html-catalog-templates/category.php
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-name ); ?>
-description ): ?>
-description ); ?>
-
-
-
-
-
-
-
-
-
-
-id); ?>
-
-
-
- name ); ?>
-
-
-
- defaultDisplayedPrice . ' ' . $formats->currency ); ?>
-
-
-
-
diff --git a/lib/html-catalog-templates/product.php b/lib/html-catalog-templates/product.php
deleted file mode 100644
index b65ead17..00000000
--- a/lib/html-catalog-templates/product.php
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
name ); ?>
-
sku ); ?>
-
-
seoDescription )&& !empty( $product->seoDescription ) ? wp_kses_post( $product->seoDescription ) : wp_kses_post( $product->description ); ?>
-
- currencyPrefix . $product->defaultDisplayedPrice . $formats->currencySuffix
- );
- ?>
-
- quantity) || $product->quantity > 0): ?> In stock
-
-
- attributes ) && is_array( $product->attributes ) && !empty( $product->attributes) ): ?>
-
- attributes as $attribute ):
- ?>
name ) . ':';
- if ( isset( $attribute->internalName ) && $attribute->internalName == 'Brand'
- ||
- isset( $attribute->type ) && $attribute->type == 'BRAND'
- ):
- ?>value ); ?> value );
- endif;
- ?>
-
-
- options) && is_array( $product->options ) && !empty( $product->options ) ): ?>
- options as $option ): ?>
-
- name ); ?>
- type == 'TEXTAREA' ):
- ?>
-
- type == 'SELECT' ): ?>
- choices as $param ): ?>
- text );
- echo ' ';
- echo esc_html( $param->priceModifier );
- ?>
- type == 'RADIO' ):
- foreach ( $option->choices as $param ): ?>
- %s (%s)',
- esc_attr( $option->name ),
- esc_attr( $param->text ),
- esc_html( $param->text ),
- esc_html( $param->priceModifier )
- ); ?>
-
- type == 'CHECKBOX'): foreach ( $option->choices as $param ): ?>
- %s (%s)',
- esc_attr( $option->name ),
- esc_attr( $param->text ),
- esc_html( $param->text ),
- esc_html( $param->priceModifier )
- ); ?>
-
-
-
-
-
-
- galleryImages ) foreach ( $product->galleryImages as $image):
- ?>
-
-
\ No newline at end of file
diff --git a/readme.txt b/readme.txt
index 1d37e06a..13216cd7 100644
--- a/readme.txt
+++ b/readme.txt
@@ -5,7 +5,7 @@ License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Requires at least: 4.4
Tested up to: 6.6
-Stable tag: 6.12.19
+Stable tag: 6.12.20
Powerful, easy to use ecommerce shopping cart for WordPress. Sell on Facebook and Instagram. iPhone & Android apps. Superb support. Free plan available.
@@ -153,6 +153,11 @@ You can use Ecwid’s built-in import tools to copy your store products from any
* [Ecwid Help Center](http://help.ecwid.com "Ecwid Help")
== Changelog ==
+= 6.12.20 - Oct 3, 2024 =
+- In the "Only featured products" mode, the "Store Home Page" ecommerce block was displayed incorrectly. We've fixed this.
+- Fixed an issue with the "Manage access to store control panel" feature where in some cases users couldn't have access to embedded store control panel.
+- Internal improvements and optimizations.
+
= 6.12.19 - Sep 11, 2024 =
- Fixed an issue with processing some store pages links.
- Internal improvements and optimizations.
diff --git a/templates/ecwid-admin.php b/templates/ecwid-admin.php
index bc757df0..b498620e 100644
--- a/templates/ecwid-admin.php
+++ b/templates/ecwid-admin.php
@@ -4,10 +4,6 @@
jQuery(document).ready(function() {
jQuery('#ecwid-frame').attr('src', '');
ecwidSetPopupCentering('#ecwid-frame');
-
- jQuery.ajax({
- url: ajaxurl + '?action='
- });
});
//]]>