Version Description
- Major improvement in the speed of loading storefront. The plugin now renders ecommerce pages and loads store widgets much more quicker both for your visitors and search engines.
- SEO improvements for product and categories pages when SEO friendly URLs are enabled. Now a special plain version of the product page content is generated and loaded in background along with a regular product/category page. This new version is formatted to provide product and category information in a clear and understandable format for crawl robots that cannot parse JavaScript this makes your store indexable by other search engines besides Google (e.g. Yandex). This special version is not visible in a browser, so your customers will as usually get the full store version. Please do not forget to enable new SEO friendly clean URLs to get this working on your site.
Download this release
Release Info
Developer | Ecwid |
Plugin | Ecwid Ecommerce Shopping Cart |
Version | 5.2 |
Comparing to | |
See all releases |
Code changes from version 5.1.1 to 5.2
- ecwid-shopping-cart.php +54 -7
- includes/class-ecwid-product-popup.php +19 -16
- includes/class-ecwid-seo-links.php +39 -2
- includes/class-ecwid-store-page.php +8 -3
- includes/shortcodes/class-ecwid-shortcode-productbrowser.php +57 -37
- lib/ecwid_api_v3.php +43 -22
- lib/ecwid_catalog.php +2 -0
- lib/ecwid_platform.php +63 -0
- lib/ecwid_product_api.php +40 -28
- readme.txt +5 -1
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.
|
9 |
Author URI: http://www.ecwid.com?source=wporg
|
10 |
*/
|
11 |
|
@@ -69,6 +69,7 @@ if ( is_admin() ){
|
|
69 |
add_action('admin_post_ecwid_connect', 'ecwid_admin_post_connect');
|
70 |
add_filter('tiny_mce_before_init', 'ecwid_tinymce_init');
|
71 |
add_action('admin_post_ecwid_get_debug', 'ecwid_get_debug_file');
|
|
|
72 |
} else {
|
73 |
add_shortcode('ecwid_script', 'ecwid_script_shortcode');
|
74 |
add_action('init', 'ecwid_backward_compatibility');
|
@@ -93,6 +94,7 @@ if ( is_admin() ){
|
|
93 |
add_filter('the_content', 'ecwid_content_started', 0);
|
94 |
add_filter('body_class', 'ecwid_body_class');
|
95 |
add_action('redirect_canonical', 'ecwid_redirect_canonical', 10, 2 );
|
|
|
96 |
$ecwid_seo_title = '';
|
97 |
}
|
98 |
add_action('admin_bar_menu', 'add_ecwid_admin_bar_node', 1000);
|
@@ -750,6 +752,43 @@ function ecwid_seo_compatibility_restore()
|
|
750 |
ecwid_override_option('aiosp_rewrite_titles');
|
751 |
}
|
752 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
753 |
function add_ecwid_admin_bar_node() {
|
754 |
global $wp_admin_bar;
|
755 |
|
@@ -940,11 +979,16 @@ function ecwid_is_applicable_escaped_fragment() {
|
|
940 |
|
941 |
function ecwid_meta_description() {
|
942 |
|
943 |
-
|
944 |
-
|
|
|
|
|
|
|
|
|
945 |
}
|
946 |
|
947 |
-
|
|
|
948 |
$api = ecwid_new_product_api();
|
949 |
if ($params['mode'] == 'product') {
|
950 |
$product = $api->get_product($params['id']);
|
@@ -1058,12 +1102,15 @@ function ecwid_seo_title_parts($parts)
|
|
1058 |
|
1059 |
function _ecwid_get_seo_title()
|
1060 |
{
|
|
|
1061 |
|
1062 |
-
if (
|
1063 |
-
|
|
|
|
|
1064 |
}
|
1065 |
|
1066 |
-
|
1067 |
|
1068 |
$ecwid_seo_title = '';
|
1069 |
|
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.2
|
9 |
Author URI: http://www.ecwid.com?source=wporg
|
10 |
*/
|
11 |
|
69 |
add_action('admin_post_ecwid_connect', 'ecwid_admin_post_connect');
|
70 |
add_filter('tiny_mce_before_init', 'ecwid_tinymce_init');
|
71 |
add_action('admin_post_ecwid_get_debug', 'ecwid_get_debug_file');
|
72 |
+
add_action('admin_init', 'ecwid_admin_check_api_cache');
|
73 |
} else {
|
74 |
add_shortcode('ecwid_script', 'ecwid_script_shortcode');
|
75 |
add_action('init', 'ecwid_backward_compatibility');
|
94 |
add_filter('the_content', 'ecwid_content_started', 0);
|
95 |
add_filter('body_class', 'ecwid_body_class');
|
96 |
add_action('redirect_canonical', 'ecwid_redirect_canonical', 10, 2 );
|
97 |
+
add_action('init', 'ecwid_check_api_cache');
|
98 |
$ecwid_seo_title = '';
|
99 |
}
|
100 |
add_action('admin_bar_menu', 'add_ecwid_admin_bar_node', 1000);
|
752 |
ecwid_override_option('aiosp_rewrite_titles');
|
753 |
}
|
754 |
|
755 |
+
function ecwid_check_api_cache()
|
756 |
+
{
|
757 |
+
$last_cache = get_option('ecwid_last_api_cache_check');
|
758 |
+
|
759 |
+
if (time() - $last_cache > HOUR_IN_SECONDS ) {
|
760 |
+
ecwid_invalidate_cache();
|
761 |
+
}
|
762 |
+
|
763 |
+
update_option('ecwid_last_api_cache_check', time());
|
764 |
+
}
|
765 |
+
|
766 |
+
function ecwid_admin_check_api_cache()
|
767 |
+
{
|
768 |
+
$last_cache = get_option('ecwid_last_api_cache_check');
|
769 |
+
|
770 |
+
if (time() - $last_cache > MINUTE_IN_SECONDS * 5 ) {
|
771 |
+
ecwid_invalidate_cache();
|
772 |
+
}
|
773 |
+
|
774 |
+
update_option('ecwid_last_api_cache_check', time());
|
775 |
+
}
|
776 |
+
|
777 |
+
function ecwid_invalidate_cache()
|
778 |
+
{
|
779 |
+
$api = new Ecwid_Api_V3();
|
780 |
+
|
781 |
+
if ($api->is_available()) {
|
782 |
+
$stats = $api->get_store_update_stats();
|
783 |
+
|
784 |
+
if ($stats) {
|
785 |
+
EcwidPlatform::invalidate_products_cache_from(strtotime($stats->productsUpdated));
|
786 |
+
EcwidPlatform::invalidate_categories_cache_from(strtotime($stats->categoriesUpdated));
|
787 |
+
}
|
788 |
+
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
function add_ecwid_admin_bar_node() {
|
793 |
global $wp_admin_bar;
|
794 |
|
979 |
|
980 |
function ecwid_meta_description() {
|
981 |
|
982 |
+
$params = array();
|
983 |
+
|
984 |
+
if ( ecwid_is_applicable_escaped_fragment() ) {
|
985 |
+
$params = ecwid_parse_escaped_fragment( $_GET['_escaped_fragment_'] );
|
986 |
+
} else if ( Ecwid_Seo_Links::is_product_browser_url() ) {
|
987 |
+
$params = Ecwid_Seo_Links::maybe_extract_html_catalog_params();
|
988 |
}
|
989 |
|
990 |
+
if ( empty( $params ) ) return;
|
991 |
+
|
992 |
$api = ecwid_new_product_api();
|
993 |
if ($params['mode'] == 'product') {
|
994 |
$product = $api->get_product($params['id']);
|
1102 |
|
1103 |
function _ecwid_get_seo_title()
|
1104 |
{
|
1105 |
+
$params = array();
|
1106 |
|
1107 |
+
if ( ecwid_is_applicable_escaped_fragment() ) {
|
1108 |
+
$params = ecwid_parse_escaped_fragment( $_GET['_escaped_fragment_'] );
|
1109 |
+
} else if ( Ecwid_Seo_Links::is_product_browser_url() ) {
|
1110 |
+
$params = Ecwid_Seo_Links::maybe_extract_html_catalog_params();
|
1111 |
}
|
1112 |
|
1113 |
+
if ( empty( $params ) ) return;
|
1114 |
|
1115 |
$ecwid_seo_title = '';
|
1116 |
|
includes/class-ecwid-product-popup.php
CHANGED
@@ -64,25 +64,28 @@ class Ecwid_Product_Popup {
|
|
64 |
|
65 |
$result = $api->search_products( $params );
|
66 |
|
67 |
-
$
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
foreach ($result->items as $product) {
|
76 |
-
$output['items'][] = array(
|
77 |
-
'id' => $product->id,
|
78 |
-
'name' => $product->name,
|
79 |
-
'thumb' => $product->smallThumbnailUrl,
|
80 |
-
'sku' => $product->sku
|
81 |
-
);
|
82 |
}
|
83 |
|
84 |
-
echo json_encode($output);
|
85 |
-
|
86 |
wp_die();
|
87 |
}
|
88 |
|
64 |
|
65 |
$result = $api->search_products( $params );
|
66 |
|
67 |
+
if ( $result && $result->count > 0 ) {
|
68 |
+
|
69 |
+
$output = array(
|
70 |
+
'total' => $result->total,
|
71 |
+
'count' => $result->count,
|
72 |
+
'offset' => $result->offset,
|
73 |
+
'limit' => $params['limit'],
|
74 |
+
'items' => array()
|
75 |
+
);
|
76 |
+
|
77 |
+
foreach ($result->items as $product) {
|
78 |
+
$output['items'][] = array(
|
79 |
+
'id' => $product->id,
|
80 |
+
'name' => $product->name,
|
81 |
+
'thumb' => $product->smallThumbnailUrl,
|
82 |
+
'sku' => $product->sku
|
83 |
+
);
|
84 |
+
}
|
85 |
+
echo json_encode($output);
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
|
|
|
|
89 |
wp_die();
|
90 |
}
|
91 |
|
includes/class-ecwid-seo-links.php
CHANGED
@@ -21,6 +21,7 @@ class Ecwid_Seo_Links {
|
|
21 |
|
22 |
add_filter( 'redirect_canonical', array( $this, 'redirect_canonical' ), 10, 2 );
|
23 |
add_action( 'template_redirect', array( $this, 'redirect_escaped_fragment' ) );
|
|
|
24 |
|
25 |
add_action( 'ecwid_print_inline_js_config', array( $this, 'add_js_config') );
|
26 |
|
@@ -67,6 +68,14 @@ class Ecwid_Seo_Links {
|
|
67 |
}
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
public function is_post_slug_bad( $value, $slug, $type = '', $parent = '' ) {
|
71 |
|
72 |
if ( !$this->is_store_on_home_page() ) {
|
@@ -93,8 +102,8 @@ class Ecwid_Seo_Links {
|
|
93 |
|
94 |
protected function get_seo_links_patterns() {
|
95 |
return array(
|
96 |
-
'[^/]
|
97 |
-
'[^/]
|
98 |
'cart',
|
99 |
'checkout',
|
100 |
'checkout\/shipping',
|
@@ -139,6 +148,34 @@ class Ecwid_Seo_Links {
|
|
139 |
JS;
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
public function build_rewrite_rules( $original_rules ) {
|
143 |
|
144 |
if ( !self::is_enabled() ) return $original_rules;
|
21 |
|
22 |
add_filter( 'redirect_canonical', array( $this, 'redirect_canonical' ), 10, 2 );
|
23 |
add_action( 'template_redirect', array( $this, 'redirect_escaped_fragment' ) );
|
24 |
+
add_filter( 'get_shortlink', array( $this, 'get_shortlink' ) );
|
25 |
|
26 |
add_action( 'ecwid_print_inline_js_config', array( $this, 'add_js_config') );
|
27 |
|
68 |
}
|
69 |
}
|
70 |
|
71 |
+
public function get_shortlink( $shortlink ) {
|
72 |
+
if ( self::is_product_browser_url() ) {
|
73 |
+
return '';
|
74 |
+
}
|
75 |
+
|
76 |
+
return $shortlink;
|
77 |
+
}
|
78 |
+
|
79 |
public function is_post_slug_bad( $value, $slug, $type = '', $parent = '' ) {
|
80 |
|
81 |
if ( !$this->is_store_on_home_page() ) {
|
102 |
|
103 |
protected function get_seo_links_patterns() {
|
104 |
return array(
|
105 |
+
'[^/]*-p[0-9]+',
|
106 |
+
'[^/]*-c[0-9]+',
|
107 |
'cart',
|
108 |
'checkout',
|
109 |
'checkout\/shipping',
|
148 |
JS;
|
149 |
}
|
150 |
|
151 |
+
public static function maybe_extract_html_catalog_params() {
|
152 |
+
|
153 |
+
$current_url = add_query_arg( null, null );
|
154 |
+
$matches = array();
|
155 |
+
if ( !preg_match( self::_get_pb_preg_pattern(), $current_url, $matches ) ) {
|
156 |
+
return array();
|
157 |
+
}
|
158 |
+
|
159 |
+
$modes = array(
|
160 |
+
'p' => 'product',
|
161 |
+
'c' => 'category'
|
162 |
+
);
|
163 |
+
|
164 |
+
return array( 'mode' => $modes[$matches[1]], 'id' => $matches[2] );
|
165 |
+
}
|
166 |
+
|
167 |
+
public static function is_product_browser_url( $url = '' ) {
|
168 |
+
if (!$url) {
|
169 |
+
$url = add_query_arg( null, null );
|
170 |
+
}
|
171 |
+
|
172 |
+
return preg_match( self::_get_pb_preg_pattern(), $url );
|
173 |
+
}
|
174 |
+
|
175 |
+
protected static function _get_pb_preg_pattern() {
|
176 |
+
return $pattern = '!.*-(p|c)([0-9]*)!';
|
177 |
+
}
|
178 |
+
|
179 |
public function build_rewrite_rules( $original_rules ) {
|
180 |
|
181 |
if ( !self::is_enabled() ) return $original_rules;
|
includes/class-ecwid-store-page.php
CHANGED
@@ -111,7 +111,7 @@ class Ecwid_Store_Page {
|
|
111 |
if ( $id ) {
|
112 |
$status = get_post_status( $id );
|
113 |
|
114 |
-
if (
|
115 |
$page_id = $id;
|
116 |
}
|
117 |
}
|
@@ -250,7 +250,7 @@ class Ecwid_Store_Page {
|
|
250 |
|
251 |
if ( self::is_store_page( $post_id ) ) {
|
252 |
|
253 |
-
$is_disabled = !in_array( get_post_status( $post_id ),
|
254 |
|
255 |
|
256 |
if ( $is_disabled || !$has_pb ) {
|
@@ -258,13 +258,18 @@ class Ecwid_Store_Page {
|
|
258 |
}
|
259 |
}
|
260 |
|
261 |
-
if ( $has_pb && in_array( get_post_status( $post_id ),
|
262 |
self::add_store_page( $post_id );
|
263 |
} else if ( get_option( self::OPTION_MAIN_STORE_PAGE_ID ) == $post_id ) {
|
264 |
update_option( self::OPTION_MAIN_STORE_PAGE_ID, '' );
|
265 |
}
|
266 |
}
|
267 |
|
|
|
|
|
|
|
|
|
|
|
268 |
public static function on_frontend_rendered() {}
|
269 |
}
|
270 |
|
111 |
if ( $id ) {
|
112 |
$status = get_post_status( $id );
|
113 |
|
114 |
+
if (in_array($status, self::_get_allowed_post_statuses())) {
|
115 |
$page_id = $id;
|
116 |
}
|
117 |
}
|
250 |
|
251 |
if ( self::is_store_page( $post_id ) ) {
|
252 |
|
253 |
+
$is_disabled = !in_array( get_post_status( $post_id ), self::_get_allowed_post_statuses() );
|
254 |
|
255 |
|
256 |
if ( $is_disabled || !$has_pb ) {
|
258 |
}
|
259 |
}
|
260 |
|
261 |
+
if ( $has_pb && in_array( get_post_status( $post_id ), self::_get_allowed_post_statuses() ) ) {
|
262 |
self::add_store_page( $post_id );
|
263 |
} else if ( get_option( self::OPTION_MAIN_STORE_PAGE_ID ) == $post_id ) {
|
264 |
update_option( self::OPTION_MAIN_STORE_PAGE_ID, '' );
|
265 |
}
|
266 |
}
|
267 |
|
268 |
+
protected static function _get_allowed_post_statuses()
|
269 |
+
{
|
270 |
+
return array('publish', 'private', 'draft');
|
271 |
+
}
|
272 |
+
|
273 |
public static function on_frontend_rendered() {}
|
274 |
}
|
275 |
|
includes/shortcodes/class-ecwid-shortcode-productbrowser.php
CHANGED
@@ -32,55 +32,75 @@ class Ecwid_Shortcode_ProductBrowser extends Ecwid_Shortcode_Base {
|
|
32 |
|
33 |
$plain_content = '';
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
|
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
if ($params['mode'] == 'product') {
|
48 |
-
$plain_content = $catalog->get_product($params['id']);
|
49 |
-
$url = Ecwid_Store_Page::get_product_url( $params['id'] );
|
50 |
-
} elseif ($params['mode'] == 'category') {
|
51 |
-
$plain_content = $catalog->get_category( $params['id'] );
|
52 |
-
$url = Ecwid_Store_Page::get_category_url( $params[ 'id' ] );
|
53 |
-
}
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
-
|
66 |
-
$parsed = parse_url($url);
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
73 |
}
|
74 |
}
|
75 |
|
76 |
-
$
|
77 |
-
|
78 |
-
<div id="ecwid-store-$store_id" class="ecwid-shopping-cart-$classname">
|
79 |
-
{$plain_content}
|
80 |
-
</div>
|
81 |
-
HTML;
|
82 |
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
protected function _process_params( $shortcode_params = array() ) {
|
32 |
|
33 |
$plain_content = '';
|
34 |
|
35 |
+
$html_catalog_params = false;
|
36 |
+
if ( ecwid_can_display_html_catalog() ) {
|
37 |
+
$html_catalog_params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
|
38 |
+
} elseif ( Ecwid_Seo_Links::is_enabled() && Ecwid_Store_Page::is_store_page() ) {
|
39 |
+
$html_catalog_params = Ecwid_Seo_Links::maybe_extract_html_catalog_params();
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( $html_catalog_params !== false ) {
|
43 |
+
$plain_content = $this->_build_html_catalog( $store_id, $html_catalog_params );
|
44 |
+
}
|
45 |
|
46 |
+
$classname = $this->_get_html_class_name();
|
47 |
+
$result = <<<HTML
|
48 |
+
<div id="ecwid-store-$store_id" class="ecwid-shopping-cart-$classname">
|
49 |
+
{$plain_content}
|
50 |
+
</div>
|
51 |
+
HTML;
|
52 |
|
53 |
+
return $result;
|
54 |
+
}
|
55 |
|
56 |
+
/**
|
57 |
+
* @param $store_id
|
58 |
+
* @param $params
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function _build_html_catalog($store_id, $params)
|
62 |
+
{
|
63 |
+
include_once ECWID_PLUGIN_DIR . 'lib/ecwid_product_api.php';
|
64 |
+
include_once ECWID_PLUGIN_DIR . 'lib/ecwid_catalog.php';
|
65 |
|
66 |
+
$page_url = get_page_link();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
+
$catalog = new EcwidCatalog($store_id, $page_url);
|
69 |
+
|
70 |
+
$url = false;
|
71 |
+
|
72 |
+
if (isset($params['mode']) && !empty($params['mode'])) {
|
73 |
+
if ($params['mode'] == 'product') {
|
74 |
+
$plain_content = $catalog->get_product($params['id']);
|
75 |
+
$url = Ecwid_Store_Page::get_product_url($params['id']);
|
76 |
+
} elseif ($params['mode'] == 'category') {
|
77 |
+
$plain_content = $catalog->get_category($params['id']);
|
78 |
+
$url = Ecwid_Store_Page::get_category_url($params['id']);
|
79 |
}
|
80 |
|
81 |
+
} else {
|
|
|
82 |
|
83 |
+
$id = intval( $this->_get_param_default_category_id( $params ) );
|
84 |
+
$plain_content = $catalog->get_category($id);
|
85 |
+
if ( empty( $plain_content ) || !isset( $params['id'] ) ) {
|
86 |
+
$plain_content = $catalog->get_category(0);
|
87 |
+
} else {
|
88 |
+
$url = Ecwid_Store_Page::get_category_url( $params['id'] );
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
if ( $url && !Ecwid_Seo_Links::is_product_browser_url() ) {
|
93 |
+
$parsed = parse_url($url);
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
if ($parsed['fragment']) {
|
96 |
+
$plain_content .= '<script data-cfasync="false" type="text/javascript"> if (!document.location.hash) document.location.hash = "' . $parsed['fragment'] . '";</script>';
|
97 |
+
return $plain_content;
|
98 |
+
} else {
|
99 |
+
$plain_content .= '<script data-cfasync="false" type="text/javascript"> document.location = "' . esc_js($url) . '";</script>';
|
100 |
+
return $plain_content;
|
101 |
+
}
|
102 |
+
}
|
103 |
+
return $plain_content;
|
104 |
}
|
105 |
|
106 |
protected function _process_params( $shortcode_params = array() ) {
|
lib/ecwid_api_v3.php
CHANGED
@@ -62,18 +62,23 @@ class Ecwid_Api_V3
|
|
62 |
$params['cleanUrls'] = 'true';
|
63 |
}
|
64 |
|
65 |
-
$
|
66 |
-
$this->
|
67 |
-
|
68 |
-
$params
|
69 |
-
)
|
70 |
);
|
71 |
|
|
|
|
|
|
|
|
|
|
|
72 |
if ($result['code'] != '200') {
|
73 |
return false;
|
74 |
}
|
75 |
|
76 |
-
$
|
|
|
|
|
77 |
|
78 |
return $result;
|
79 |
}
|
@@ -95,18 +100,23 @@ class Ecwid_Api_V3
|
|
95 |
$params['cleanUrls'] = 'true';
|
96 |
}
|
97 |
|
98 |
-
$
|
99 |
-
$this->
|
100 |
-
|
101 |
-
$params
|
102 |
-
)
|
103 |
);
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
if ($result['code'] != '200') {
|
106 |
return false;
|
107 |
}
|
108 |
|
109 |
-
$
|
|
|
|
|
110 |
|
111 |
return $result;
|
112 |
}
|
@@ -122,18 +132,23 @@ class Ecwid_Api_V3
|
|
122 |
$params['cleanUrls'] = 'true';
|
123 |
}
|
124 |
|
125 |
-
$
|
126 |
-
$this->
|
127 |
-
|
128 |
-
$params
|
129 |
-
)
|
130 |
);
|
131 |
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
if ($result['code'] != '200') {
|
134 |
return false;
|
135 |
}
|
136 |
|
|
|
|
|
137 |
$result = json_decode($result['data']);
|
138 |
|
139 |
return $result;
|
@@ -156,16 +171,22 @@ class Ecwid_Api_V3
|
|
156 |
$params['cleanUrls'] = 'true';
|
157 |
}
|
158 |
|
159 |
-
$
|
160 |
-
$this->
|
161 |
-
|
162 |
-
$params
|
163 |
-
)
|
164 |
);
|
165 |
|
|
|
|
|
|
|
|
|
|
|
166 |
if ($result['code'] != '200') {
|
167 |
return false;
|
168 |
}
|
|
|
|
|
|
|
169 |
$result = json_decode($result['data']);
|
170 |
return $result;
|
171 |
}
|
62 |
$params['cleanUrls'] = 'true';
|
63 |
}
|
64 |
|
65 |
+
$url = $this->build_request_url(
|
66 |
+
$this->_categories_api_url,
|
67 |
+
$params
|
|
|
|
|
68 |
);
|
69 |
|
70 |
+
$result = EcwidPlatform::get_from_categories_cache($url);
|
71 |
+
if ( !$result ) {
|
72 |
+
$result = EcwidPlatform::fetch_url( $url );
|
73 |
+
}
|
74 |
+
|
75 |
if ($result['code'] != '200') {
|
76 |
return false;
|
77 |
}
|
78 |
|
79 |
+
EcwidPlatform::store_in_categories_cache( $url, $result );
|
80 |
+
|
81 |
+
$result = json_decode( $result['data'] );
|
82 |
|
83 |
return $result;
|
84 |
}
|
100 |
$params['cleanUrls'] = 'true';
|
101 |
}
|
102 |
|
103 |
+
$url = $this->build_request_url(
|
104 |
+
$this->_categories_api_url . '/' . $categoryId,
|
105 |
+
$params
|
|
|
|
|
106 |
);
|
107 |
+
$result = EcwidPlatform::get_from_categories_cache( $url );
|
108 |
+
|
109 |
+
if ( !$result ) {
|
110 |
+
$result = EcwidPlatform::fetch_url( $url );
|
111 |
+
}
|
112 |
|
113 |
if ($result['code'] != '200') {
|
114 |
return false;
|
115 |
}
|
116 |
|
117 |
+
EcwidPlatform::store_in_categories_cache( $url, $result );
|
118 |
+
|
119 |
+
$result = json_decode( $result['data'] );
|
120 |
|
121 |
return $result;
|
122 |
}
|
132 |
$params['cleanUrls'] = 'true';
|
133 |
}
|
134 |
|
135 |
+
$url = $this->build_request_url(
|
136 |
+
$this->_products_api_url . '/' . $product_id,
|
137 |
+
$params
|
|
|
|
|
138 |
);
|
139 |
|
140 |
+
$result = EcwidPlatform::get_from_products_cache( $url );
|
141 |
+
|
142 |
+
if (!$result) {
|
143 |
+
$result = EcwidPlatform::fetch_url( $url );
|
144 |
+
}
|
145 |
|
146 |
if ($result['code'] != '200') {
|
147 |
return false;
|
148 |
}
|
149 |
|
150 |
+
EcwidPlatform::store_in_products_cache( $url, $result );
|
151 |
+
|
152 |
$result = json_decode($result['data']);
|
153 |
|
154 |
return $result;
|
171 |
$params['cleanUrls'] = 'true';
|
172 |
}
|
173 |
|
174 |
+
$url = $this->build_request_url(
|
175 |
+
$this->_products_api_url,
|
176 |
+
$params
|
|
|
|
|
177 |
);
|
178 |
|
179 |
+
$result = EcwidPlatform::get_from_products_cache( $url );
|
180 |
+
if (!$result ) {
|
181 |
+
$result = EcwidPlatform::fetch_url( $url );
|
182 |
+
}
|
183 |
+
|
184 |
if ($result['code'] != '200') {
|
185 |
return false;
|
186 |
}
|
187 |
+
|
188 |
+
EcwidPlatform::store_in_products_cache( $url, $result );
|
189 |
+
|
190 |
$result = json_decode($result['data']);
|
191 |
return $result;
|
192 |
}
|
lib/ecwid_catalog.php
CHANGED
@@ -15,6 +15,7 @@ class EcwidCatalog
|
|
15 |
|
16 |
public function get_product($id)
|
17 |
{
|
|
|
18 |
$params = array
|
19 |
(
|
20 |
array("alias" => "p", "action" => "product", "params" => array("id" => $id)),
|
@@ -22,6 +23,7 @@ class EcwidCatalog
|
|
22 |
);
|
23 |
|
24 |
$batch_result = $this->ecwid_api->get_batch_request($params);
|
|
|
25 |
$product = $batch_result["p"];
|
26 |
$profile = $batch_result["pf"];
|
27 |
|
15 |
|
16 |
public function get_product($id)
|
17 |
{
|
18 |
+
|
19 |
$params = array
|
20 |
(
|
21 |
array("alias" => "p", "action" => "product", "params" => array("id" => $id)),
|
23 |
);
|
24 |
|
25 |
$batch_result = $this->ecwid_api->get_batch_request($params);
|
26 |
+
|
27 |
$product = $batch_result["p"];
|
28 |
$profile = $batch_result["pf"];
|
29 |
|
lib/ecwid_platform.php
CHANGED
@@ -8,6 +8,9 @@ class EcwidPlatform {
|
|
8 |
|
9 |
static protected $crypt = null;
|
10 |
|
|
|
|
|
|
|
11 |
static public function get_store_id()
|
12 |
{
|
13 |
return get_ecwid_store_id();
|
@@ -249,6 +252,66 @@ class EcwidPlatform {
|
|
249 |
&& strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) == false
|
250 |
&& ! ini_get( 'safe_mode' );
|
251 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
|
254 |
add_filter('http_api_transports', array('EcwidPlatform', 'http_api_transports'));
|
8 |
|
9 |
static protected $crypt = null;
|
10 |
|
11 |
+
const CATEGORIES_CACHE_VALID_FROM = 'categories_cache_valid_from';
|
12 |
+
const PRODUCTS_CACHE_VALID_FROM = 'products_cache_valid_from';
|
13 |
+
|
14 |
static public function get_store_id()
|
15 |
{
|
16 |
return get_ecwid_store_id();
|
252 |
&& strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) == false
|
253 |
&& ! ini_get( 'safe_mode' );
|
254 |
}
|
255 |
+
|
256 |
+
|
257 |
+
static public function store_in_products_cache( $url, $data ) {
|
258 |
+
self::_store_in_cache($url, 'products', $data);
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
static public function store_in_categories_cache( $url, $data ) {
|
263 |
+
self::_store_in_cache($url, 'categories', $data);
|
264 |
+
}
|
265 |
+
|
266 |
+
static protected function _store_in_cache( $url, $type, $data ) {
|
267 |
+
$name = self::_build_cache_name( $url, $type );
|
268 |
+
|
269 |
+
$to_store = array(
|
270 |
+
'time' => time(),
|
271 |
+
'data' => $data
|
272 |
+
);
|
273 |
+
|
274 |
+
self::cache_set( $name, $to_store, MONTH_IN_SECONDS );
|
275 |
+
}
|
276 |
+
|
277 |
+
static public function get_from_categories_cache( $url )
|
278 |
+
{
|
279 |
+
$cache_name = self::_build_cache_name( $url, 'categories' );
|
280 |
+
|
281 |
+
$result = self::cache_get( $cache_name );
|
282 |
+
if ( $result['time'] > EcwidPlatform::get( self::CATEGORIES_CACHE_VALID_FROM ) ) {
|
283 |
+
return $result['data'];
|
284 |
+
}
|
285 |
+
|
286 |
+
return false;
|
287 |
+
}
|
288 |
+
|
289 |
+
static public function get_from_products_cache( $url )
|
290 |
+
{
|
291 |
+
$cache_name = self::_build_cache_name( $url, 'products' );
|
292 |
+
|
293 |
+
$result = self::cache_get( $cache_name );
|
294 |
+
|
295 |
+
if ( $result['time'] > EcwidPlatform::get( self::PRODUCTS_CACHE_VALID_FROM ) ) {
|
296 |
+
return $result['data'];
|
297 |
+
}
|
298 |
+
|
299 |
+
return false;
|
300 |
+
}
|
301 |
+
|
302 |
+
static protected function _build_cache_name( $url, $type ) {
|
303 |
+
return $type . '_' . md5($url);
|
304 |
+
}
|
305 |
+
|
306 |
+
static public function invalidate_products_cache_from( $time )
|
307 |
+
{
|
308 |
+
EcwidPlatform::set( self::PRODUCTS_CACHE_VALID_FROM, $time );
|
309 |
+
}
|
310 |
+
|
311 |
+
static public function invalidate_categories_cache_from( $time )
|
312 |
+
{
|
313 |
+
EcwidPlatform::set( self::CATEGORIES_CACHE_VALID_FROM, $time );
|
314 |
+
}
|
315 |
}
|
316 |
|
317 |
add_filter('http_api_transports', array('EcwidPlatform', 'http_api_transports'));
|
lib/ecwid_product_api.php
CHANGED
@@ -85,59 +85,66 @@ class EcwidProductApi {
|
|
85 |
|
86 |
$category_id = intval($category_id);
|
87 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products?category=" . $category_id;
|
88 |
-
$products = $this->process_request($api_url);
|
89 |
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
function get_product($product_id) {
|
94 |
|
95 |
-
static $cached;
|
96 |
-
|
97 |
$product_id = intval($product_id);
|
98 |
|
99 |
-
if (isset($cached[$product_id])) {
|
100 |
-
return $cached[$product_id];
|
101 |
-
}
|
102 |
-
|
103 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/product?id=" . $product_id;
|
104 |
-
$cached[$product_id] = $this->process_request($api_url);
|
105 |
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
|
109 |
function get_product_https($product_id) {
|
110 |
|
111 |
-
static $cached;
|
112 |
-
|
113 |
$product_id = intval($product_id);
|
114 |
|
115 |
-
if (isset($cached[$product_id])) {
|
116 |
-
return $cached[$product_id];
|
117 |
-
}
|
118 |
-
|
119 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT_HTTPS . "/" . $this->store_id . "/product?id=" . $product_id;
|
120 |
-
$cached[$product_id] = $this->process_request($api_url);
|
121 |
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
|
126 |
function get_category($category_id) {
|
127 |
|
128 |
-
static $cached = array();
|
129 |
-
|
130 |
$category_id = intval($category_id);
|
131 |
|
132 |
-
if (isset($cached[$category_id])) {
|
133 |
-
return $cached[$category_id];
|
134 |
-
}
|
135 |
-
|
136 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
|
137 |
-
|
138 |
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
function get_batch_request($params) {
|
143 |
|
@@ -180,7 +187,12 @@ class EcwidProductApi {
|
|
180 |
}
|
181 |
|
182 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/batch?". $api_url;
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
return $data;
|
186 |
}
|
85 |
|
86 |
$category_id = intval($category_id);
|
87 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products?category=" . $category_id;
|
|
|
88 |
|
89 |
+
$result = EcwidPlatform::get_from_products_cache($api_url);
|
90 |
+
if (!$result) {
|
91 |
+
|
92 |
+
$result = $this->process_request($api_url);
|
93 |
+
EcwidPlatform::store_in_products_cache($api_url, $result);
|
94 |
+
}
|
95 |
+
|
96 |
+
return $result;
|
97 |
}
|
98 |
|
99 |
function get_product($product_id) {
|
100 |
|
|
|
|
|
101 |
$product_id = intval($product_id);
|
102 |
|
|
|
|
|
|
|
|
|
103 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/product?id=" . $product_id;
|
|
|
104 |
|
105 |
+
$result = EcwidPlatform::get_from_products_cache($api_url);
|
106 |
+
if (!$result) {
|
107 |
+
|
108 |
+
$result = $this->process_request($api_url);
|
109 |
+
EcwidPlatform::store_in_products_cache($api_url, $result);
|
110 |
+
}
|
111 |
+
|
112 |
+
return $result;
|
113 |
}
|
114 |
|
115 |
function get_product_https($product_id) {
|
116 |
|
|
|
|
|
117 |
$product_id = intval($product_id);
|
118 |
|
|
|
|
|
|
|
|
|
119 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT_HTTPS . "/" . $this->store_id . "/product?id=" . $product_id;
|
|
|
120 |
|
121 |
+
$result = EcwidPlatform::get_from_products_cache($api_url);
|
122 |
+
if (!$result) {
|
123 |
+
|
124 |
+
$result = $this->process_request($api_url);
|
125 |
+
EcwidPlatform::store_in_products_cache($api_url, $result);
|
126 |
+
}
|
127 |
+
|
128 |
+
return $result;
|
129 |
}
|
130 |
|
131 |
|
132 |
function get_category($category_id) {
|
133 |
|
|
|
|
|
134 |
$category_id = intval($category_id);
|
135 |
|
|
|
|
|
|
|
|
|
136 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
|
137 |
+
;
|
138 |
|
139 |
+
|
140 |
+
$result = EcwidPlatform::get_from_categories_cache($api_url);
|
141 |
+
if (!$result) {
|
142 |
+
$result = $this->process_request($api_url);
|
143 |
+
EcwidPlatform::store_in_categories_cache($api_url, $result);
|
144 |
+
}
|
145 |
+
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
|
149 |
function get_batch_request($params) {
|
150 |
|
187 |
}
|
188 |
|
189 |
$api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/batch?". $api_url;
|
190 |
+
|
191 |
+
$data = EcwidPlatform::get_from_products_cache($api_url);
|
192 |
+
if (!$data) {
|
193 |
+
$data = $this->process_request($api_url);
|
194 |
+
EcwidPlatform::store_in_products_cache($api_url, $data);
|
195 |
+
}
|
196 |
|
197 |
return $data;
|
198 |
}
|
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.
|
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,10 @@ 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.1.1 =
|
153 |
- **Fixed the “Strict code standards” notices** appearing on some sites with Ecwid plugin enabled. The messages didn’t affect the product catalog and checkout, but looked confusing for the site visitors. We fixed that. The notices should disappear now.
|
154 |
- Minor improvement for the SEO friendly clean URLs function.
|
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.2
|
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.2 =
|
153 |
+
- **Major improvement in the speed of loading storefront.** The plugin now renders ecommerce pages and loads store widgets much more quicker both for your visitors and search engines.
|
154 |
+
- **SEO improvements for product and categories pages when SEO friendly URLs are enabled.** Now a special plain version of the product page content is generated and loaded in background along with a regular product/category page. This new version is formatted to provide product and category information in a clear and understandable format for crawl robots that cannot parse JavaScript — this makes your store indexable by other search engines besides Google (e.g. Yandex). This special version is not visible in a browser, so your customers will as usually get the full store version. Please do not forget to enable new SEO friendly clean URLs to get this working on your site.
|
155 |
+
|
156 |
= 5.1.1 =
|
157 |
- **Fixed the “Strict code standards” notices** appearing on some sites with Ecwid plugin enabled. The messages didn’t affect the product catalog and checkout, but looked confusing for the site visitors. We fixed that. The notices should disappear now.
|
158 |
- Minor improvement for the SEO friendly clean URLs function.
|