Skip to content

Commit

Permalink
Merge pull request #286 from Ecwid/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
meteor-ec authored Jul 10, 2024
2 parents 755cec5 + 441bae1 commit 062b2d3
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 153 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
== Changelog ==
= 6.12.15 - Jul 11, 2024 =
- After the last update, the our ecommerce plugin could cause an issue with urls and an issue with loading the admin area. We have fixed these issues.

= 6.12.14 - Jul 2, 2024 =
- Fixed issues with slow loading of storefront pages that were observed in certain scenarios when using our ecommerce plugin.
- Fixed a PHP error message ("Fatal error: Can't use function return value in write context") for PHP versions older 5.5. If your ecommerce site is running on an outdated PHP version, this update might fix a error message for you. Please update your PHP as soon as possible (or ask your hoster to do that for you) — it’s much more secure to use the latest versions of software on your server.
Expand Down
7 changes: 3 additions & 4 deletions ecwid-shopping-cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.14
Version: 6.12.15
Author URI: https://ecwid.to/ecwid-site
License: GPLv2 or later
*/
Expand Down Expand Up @@ -2412,7 +2412,8 @@ function ecwid_get_categories_for_selector() {
}

$query_params = array(
'hidden_categories' => true
'hidden_categories' => true,
'responseFields' => 'total,count,items(id,name,url,enabled,parentId)'
);

if( ecwid_is_demo_store() ) {
Expand Down Expand Up @@ -2447,8 +2448,6 @@ function ecwid_get_categories_for_selector() {
}
}
}

$parents = array();

$result = array();
foreach ( $all_categories as $category ) {
Expand Down
56 changes: 27 additions & 29 deletions includes/class-ecwid-admin-storefront-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static function do_page() {
}

if ( $page_id && ! isset( $page_status ) ) {

$page_data = self::get_page_data( $page_id );
extract( $page_data, EXTR_PREFIX_ALL, 'page' );

Expand Down Expand Up @@ -70,7 +69,7 @@ public static function do_page() {
$categories = ecwid_get_categories_for_selector();

$api = new Ecwid_Api_V3();
$res = $api->get_products( array() );
$res = $api->get_products( array( 'responseFields' => 'total,count,items(id,name)' ) );
if ( $res ) {
$products = $res->items;
$products_total = $res->total;
Expand All @@ -96,13 +95,13 @@ public static function do_page() {

wp_enqueue_script( 'ecwid-admin-storefront-js', ECWID_PLUGIN_URL . 'js/admin-storefront.js', array(), get_option( 'ecwid_plugin_version' ) );

wp_localize_script(
'ecwid-admin-storefront-js',
'EcwidAdminStorefront',
array(
'_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG )
)
);
wp_localize_script(
'ecwid-admin-storefront-js',
'EcwidAdminStorefront',
array(
'_ajax_nonce' => wp_create_nonce( self::NONCE_SLUG ),
)
);

Ecwid_Admin_UI_Framework::print_fix_js();
require_once self::$templates_dir . 'main.php';
Expand Down Expand Up @@ -130,9 +129,9 @@ public static function get_page_data( $page_id ) {
}

public function ajax_set_status() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand Down Expand Up @@ -172,9 +171,9 @@ public function ajax_set_status() {
}

public function ajax_set_store_on_front() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand Down Expand Up @@ -207,9 +206,9 @@ public function ajax_set_store_on_front() {
}

public function ajax_set_mainpage() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand Down Expand Up @@ -244,9 +243,9 @@ public function ajax_set_mainpage() {
}

public function ajax_set_display_cart_icon() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand All @@ -265,9 +264,9 @@ public function ajax_set_display_cart_icon() {
}

public function ajax_set_page_slug() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand Down Expand Up @@ -315,9 +314,9 @@ public function ajax_set_page_slug() {
}

public function ajax_create_page() {
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}
if ( ! check_ajax_referer( self::NONCE_SLUG ) ) {
die();
}

if ( ! current_user_can( Ecwid_Admin::get_capability() ) ) {
die();
Expand Down Expand Up @@ -479,7 +478,6 @@ public static function is_gutenberg_active() {
$version = get_bloginfo( 'version' );

if ( version_compare( $version, '5.0' ) < 0 ) {

if ( is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
return true;
}
Expand Down Expand Up @@ -572,7 +570,7 @@ public static function render_dropdown_list_items( $items ) {
$text = $item['text'];
}

echo sprintf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) );
printf( '<li><a%s>%s</a></li>', wp_kses_post( $attributes ), esc_html( $text ) );
}//end foreach
}

Expand Down
7 changes: 6 additions & 1 deletion includes/class-ecwid-nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,12 @@ public function process_menu_items( $items ) {
if ( ! $posts ) {
$posts = array();
$api = new Ecwid_Api_V3();
$result = $api->get_categories( array( 'parent' => 0 ) );
$result = $api->get_categories(
array(
'parent' => 0,
'responseFields' => 'total,count,items(id,name,url,nameTranslated,orderBy)',
)
);

if ( $result && $result->count > 0 ) {
$categories = $result->items;
Expand Down
3 changes: 2 additions & 1 deletion includes/class-ecwid-seo-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ protected static function _get_pb_preg_pattern() {
}

public function build_rewrite_rules( $rules ) {
$new_rules = array();
$new_rules = array();
$additional_rules = array();

$all_base_urls = $this->_build_all_base_urls();

Expand Down
9 changes: 7 additions & 2 deletions includes/class-ecwid-static-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected static function maybe_fetch_data() {
if ( $is_home_page && $is_css_defined && ! $is_css_already_set ) {
$cached_data->cssFiles = array( $dynamic_css ); //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase

EcwidPlatform::store_in_static_pages_cache( $url, $cached_data );
EcwidPlatform::save_in_static_pages_cache( $url, $cached_data );
}

return $cached_data;
Expand Down Expand Up @@ -221,6 +221,11 @@ protected static function get_static_snapshot( $url, $dynamic_css = '' ) {
$fetched_data->htmlCode = preg_replace( $pattern, '<img $1 decoding="async" loading="lazy">', $fetched_data->htmlCode );
}

EcwidPlatform::encode_fields_with_emoji(
$fetched_data,
array( 'htmlCode', 'metaDescriptionHtml', 'ogTagsHtml', 'jsonLDHtml' )
);

if ( isset( $fetched_data->lastUpdated ) ) {
$last_update = substr( $fetched_data->lastUpdated, 0, -3 );
} else {
Expand All @@ -229,7 +234,7 @@ protected static function get_static_snapshot( $url, $dynamic_css = '' ) {
//phpcs:enable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase

EcwidPlatform::invalidate_static_pages_cache_from( $last_update );
EcwidPlatform::store_in_static_pages_cache( $url, $fetched_data );
EcwidPlatform::save_in_static_pages_cache( $url, $fetched_data );

return $fetched_data;
}//end if
Expand Down
50 changes: 26 additions & 24 deletions includes/gutenberg/class-ecwid-gutenberg-block-store.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,34 +286,36 @@ public function get_attributes_for_editor() {
}
}//end foreach

$categories = ecwid_get_categories_for_selector();
if ( is_admin() ) {
$categories = ecwid_get_categories_for_selector();

if ( $categories ) {
$attributes['default_category_id']['values'] = array(
array(
'value' => '0',
'title' => __( 'Store root category', 'ecwid-shopping-cart' ),
),
);
foreach ( $categories as $category ) {
if ( empty( $category->enabled ) ) {
continue;
}

if ( $categories ) {
$attributes['default_category_id']['values'] = array(
array(
'value' => '0',
'title' => __( 'Store root category', 'ecwid-shopping-cart' ),
),
);
foreach ( $categories as $category ) {
if ( empty( $category->enabled ) ) {
continue;
$attributes['default_category_id']['values'][] = array(
'value' => $category->id,
'title' => $category->name,
);
}

$attributes['default_category_id']['values'][] = array(
'value' => $category->id,
'title' => $category->name,
);
}

$attributes['default_category_id']['default'] = '';
} else {
$api = new Ecwid_Api_V3();
$cats = $api->get_categories( array() );
$attributes['default_category_id']['default'] = '';
} else {
$api = new Ecwid_Api_V3();
$cats = $api->get_categories( array() );

if ( $cats && $cats->total == 0 ) {
unset( $attributes['default_category_id'] );
}
if ( $cats && $cats->total == 0 ) {
unset( $attributes['default_category_id'] );
}
}//end if
}//end if

$attributes['align'] = array(
Expand Down
4 changes: 1 addition & 3 deletions includes/themes/class-ecwid-theme-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ public static function create( $name, $props ) {
}

if ( in_array( 'title', $props, true ) ) {

$store_page_params = Ecwid_Store_Page::get_store_page_params();

if ( @$store_page_params['product_details_show_product_name'] ) {
if ( ! empty( $store_page_params['product_details_show_product_name'] ) ) {
add_filter( 'option_' . Ecwid_Store_Page::OPTION_REPLACE_TITLE, '__return_false' );
}
}
Expand Down Expand Up @@ -125,5 +124,4 @@ protected function add_css( $parent = null ) {
get_option( 'ecwid_plugin_version' )
);
}

}
Loading

0 comments on commit 062b2d3

Please sign in to comment.