Ecwid Ecommerce Shopping Cart - Version 5.0.5

Version Description

  • Fixed a a bug causing 404 errors on the store page when SEO friendly URLs are enabled. The issue appeared on the sites where store is placed on the site home page. Now the clean SEO URLs option should work fine regardless of whether you add Ecwid store to your site home page or any other page.

  • Minor fixes and improvements.

Download this release

Release Info

Developer Ecwid
Plugin Icon 128x128 Ecwid Ecommerce Shopping Cart
Version 5.0.5
Comparing to
See all releases

Code changes from version 5.0.4 to 5.0.5

ecwid-shopping-cart.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.ecwid.com?source=wporg
5
  Description: Ecwid 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.
6
  Text Domain: ecwid-shopping-cart
7
  Author: Ecwid Team
8
- Version: 5.0.4
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
@@ -855,12 +855,25 @@ function ecwid_page_has_productbrowser($post_id = null)
855
  }
856
  }
857
 
 
858
  return $results[$post_id];
859
  }
860
 
861
  function ecwid_ajax_crawling_fragment() {
862
- if (ecwid_is_api_enabled() && !isset($_GET['_escaped_fragment_']) && ecwid_page_has_productbrowser())
863
- echo '<meta name="fragment" content="!">' . PHP_EOL;
 
 
 
 
 
 
 
 
 
 
 
 
864
  }
865
 
866
  function ecwid_meta() {
5
  Description: Ecwid 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.
6
  Text Domain: ecwid-shopping-cart
7
  Author: Ecwid Team
8
+ Version: 5.0.5
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
855
  }
856
  }
857
 
858
+
859
  return $results[$post_id];
860
  }
861
 
862
  function ecwid_ajax_crawling_fragment() {
863
+
864
+ if ( !ecwid_is_api_enabled() ) return;
865
+
866
+ if ( isset( $_GET['_escaped_fragment_'] ) ) return;
867
+
868
+ if ( ! ecwid_page_has_productbrowser() ) return;
869
+
870
+ global $wp, $ecwid_seo_links;
871
+
872
+ $slug = ltrim( strrchr( $wp->request, '/' ), '/' );
873
+
874
+ if ( Ecwid_Seo_Links::is_enabled() && $ecwid_seo_links->slug_matches_seo_pattern( $slug ) ) return;
875
+
876
+ echo '<meta name="fragment" content="!">' . PHP_EOL;
877
  }
878
 
879
  function ecwid_meta() {
includes/class-ecwid-seo-links.php CHANGED
@@ -17,6 +17,10 @@ class Ecwid_Seo_Links {
17
  add_action( 'template_redirect', array( $this, 'redirect_escaped_fragment' ) );
18
 
19
  add_action( 'ecwid_print_inline_js_config', array( $this, 'add_js_config') );
 
 
 
 
20
  }
21
  }
22
 
@@ -28,6 +32,10 @@ class Ecwid_Seo_Links {
28
  return false;
29
  }
30
 
 
 
 
 
31
  return $redir;
32
  }
33
 
@@ -51,6 +59,60 @@ class Ecwid_Seo_Links {
51
  }
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  public function add_js_config() {
55
 
56
  global $wp_query;
@@ -76,6 +138,13 @@ JS;
76
 
77
  $page_id = get_option( 'ecwid_store_page_id' );
78
 
 
 
 
 
 
 
 
79
  if ( ecwid_page_has_productbrowser( $page_id ) ) {
80
  $link = get_page_uri( $page_id );
81
 
17
  add_action( 'template_redirect', array( $this, 'redirect_escaped_fragment' ) );
18
 
19
  add_action( 'ecwid_print_inline_js_config', array( $this, 'add_js_config') );
20
+
21
+ add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', array( $this, 'is_post_slug_bad'), 10, 4 );
22
+ add_filter( 'wp_unique_post_slug_is_bad_flat_slug', array( $this, 'is_post_slug_bad' ), 10, 2 );
23
+ add_filter( 'wp_unique_post_slug_is_bad_attachment_slug', array( $this, 'is_post_slug_bad' ), 10, 2 );
24
  }
25
  }
26
 
32
  return false;
33
  }
34
 
35
+ if ($this->is_store_on_home_page() && get_queried_object_id() == get_option('page_on_front')) {
36
+ return false;
37
+ }
38
+
39
  return $redir;
40
  }
41
 
59
  }
60
  }
61
 
62
+ public function is_post_slug_bad( $value, $slug, $type = '', $parent = '' ) {
63
+
64
+ if ( !$this->is_store_on_home_page() ) {
65
+ return $value;
66
+ }
67
+
68
+ if ( $this->slug_matches_seo_pattern( $slug ) ) {
69
+ return true;
70
+ }
71
+
72
+ return $value;
73
+ }
74
+ public function slug_matches_seo_pattern($slug) {
75
+ static $pattern = '';
76
+
77
+ if ( !$pattern ) {
78
+ $patterns = $this->get_seo_links_patterns();
79
+
80
+ $pattern = '!(^' . implode('$|^', $patterns) . '$)!';
81
+ }
82
+
83
+ return preg_match($pattern, $slug);
84
+ }
85
+
86
+ protected function get_seo_links_patterns() {
87
+ return array(
88
+ '[^/]+-p[0-9]+',
89
+ '[^/]+-c[0-9]+',
90
+ 'cart',
91
+ 'checkout',
92
+ 'checkout\/shipping',
93
+ 'checkout\/payment',
94
+ 'checkout\/place-order',
95
+ 'checkout\/order-confirmation',
96
+ 'account',
97
+ 'account\/settings',
98
+ 'account\/orders',
99
+ 'account\/address-book',
100
+ 'account\/favorites',
101
+ 'search',
102
+ 'search\?.*'
103
+ );
104
+ }
105
+
106
+ public function is_store_on_home_page() {
107
+ $front_page = get_option( 'page_on_front' );
108
+
109
+ if ( Ecwid_Store_Page::is_store_page( $front_page ) ) {
110
+ return true;
111
+ }
112
+
113
+ return false;
114
+ }
115
+
116
  public function add_js_config() {
117
 
118
  global $wp_query;
138
 
139
  $page_id = get_option( 'ecwid_store_page_id' );
140
 
141
+ if ( $this->is_store_on_home_page() ) {
142
+ $patterns = $this->get_seo_links_patterns();
143
+ foreach ($patterns as $pattern) {
144
+ $rules['^' . $pattern . '$'] = 'index.php?page_id=' . get_option( 'page_on_front' );
145
+ }
146
+ }
147
+
148
  if ( ecwid_page_has_productbrowser( $page_id ) ) {
149
  $link = get_page_uri( $page_id );
150
 
includes/class-ecwid-store-page.php CHANGED
@@ -115,4 +115,8 @@ class Ecwid_Store_Page {
115
  return $page_id;
116
  }
117
 
 
 
 
 
118
  }
115
  return $page_id;
116
  }
117
 
118
+ public static function is_store_page( $page_id ) {
119
+ return get_option( 'ecwid_store_page_id' ) == $page_id || get_option( 'ecwid_store_page_id_auto' ) == $page_id;
120
+ }
121
+
122
  }
js/product-popup.js CHANGED
@@ -506,8 +506,9 @@ jQuery(document).ready(function() {
506
 
507
  ecwidRenderCheckboxOption = function(data) {
508
 
509
- if (!this.template) {
510
- this.template = wp.template( 'checkbox-option' );
 
511
  }
512
 
513
  if (data.section == 'display-options') {
@@ -522,12 +523,12 @@ ecwidRenderCheckboxOption = function(data) {
522
  }
523
 
524
 
525
- if (!this.nextTarget || this.nextTarget == 'right') {
526
- this.nextTarget = 'left';
527
  } else {
528
- this.nextTarget = 'right';
529
  }
530
 
531
- jQuery('#ecwid-product-popup-content .widget-settings.' + data.section + ' .widget-settings__' + this.nextTarget)
532
- .append(this.template(data));
533
  }
506
 
507
  ecwidRenderCheckboxOption = function(data) {
508
 
509
+ var that = ecwidRenderCheckboxOption;
510
+ if (!that.template) {
511
+ that.template = wp.template( 'checkbox-option' );
512
  }
513
 
514
  if (data.section == 'display-options') {
523
  }
524
 
525
 
526
+ if (!that.nextTarget || that.nextTarget == 'right') {
527
+ that.nextTarget = 'left';
528
  } else {
529
+ that.nextTarget = 'right';
530
  }
531
 
532
+ jQuery('#ecwid-product-popup-content .widget-settings.' + data.section + ' .widget-settings__' + that.nextTarget)
533
+ .append(that.template(data));
534
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Ecwid
3
  Tags: ecommerce, downloadable products, Facebook ecommerce, online store, paypal, product catalog, shop, shopping cart, store
4
  Requires at least: 3.5
5
  Tested up to: 4.7
6
- Stable tag: 5.0.4
7
 
8
  Powerful, easy to use ecommerce shopping cart. Bank level PCI DSS Level 1 security. iPhone & Android apps. Superb support. Free plan available.
9
 
@@ -149,6 +149,11 @@ You can use Ecwid’s built-in import tools to copy your store products from any
149
  * [Ecwid eCommerce Forums](https://www.ecwid.com/forums/forumdisplay.php?f=19)
150
 
151
  == Changelog ==
 
 
 
 
 
152
  = 5.0.4 =
153
  - Minor fixes for the new SEO friendly clean URLs feature.
154
 
3
  Tags: ecommerce, downloadable products, Facebook ecommerce, online store, paypal, product catalog, shop, shopping cart, store
4
  Requires at least: 3.5
5
  Tested up to: 4.7
6
+ Stable tag: 5.0.5
7
 
8
  Powerful, easy to use ecommerce shopping cart. Bank level PCI DSS Level 1 security. iPhone & Android apps. Superb support. Free plan available.
9
 
149
  * [Ecwid eCommerce Forums](https://www.ecwid.com/forums/forumdisplay.php?f=19)
150
 
151
  == Changelog ==
152
+ = 5.0.5 =
153
+ - **Fixed a a bug causing 404 errors on the store page when SEO friendly URLs are enabled.** The issue appeared on the sites where store is placed on the site home page. Now the clean SEO URLs option should work fine regardless of whether you add Ecwid store to your site home page or any other page.
154
+
155
+ - Minor fixes and improvements.
156
+
157
  = 5.0.4 =
158
  - Minor fixes for the new SEO friendly clean URLs feature.
159