Ecwid Ecommerce Shopping Cart - Version 1.2

Version Description

  • [+] A lot of changes in Ecwid shopping cart: http://www.ecwid.com/blog/new-releases/
  • [+] Support of the Googles AJAX Crawling API for native indexing of AJAX applications has been added. This will significantly improve the indexation of Ecwid stores and is a successor of the Inline SEO Catalog feature. More details at https://developers.google.com/webmasters/ajax-crawling/ (This feature requires a paid Ecwid subscription)
  • [+] Auto-generated meta descriptions and titles for product pages.
  • [+] Support of microformats to get rich snippets in search engine results pages.
  • [+] New Ecwid section has been added to the admin menu.
Download this release

Release Info

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

Code changes from version 1.1.2 to 1.2

ecwid-shopping-cart.php CHANGED
@@ -4,14 +4,14 @@ Plugin Name: Ecwid Shopping Cart
4
  Plugin URI: http://www.ecwid.com/
5
  Description: Ecwid is a free full-featured shopping cart. It can be easily integreted with any Wordpress blog and takes less than 5 minutes to set up.
6
  Author: Ecwid Team
7
- Version: 1.1
8
  Author URI: http://www.ecwid.com/
9
  */
10
 
11
  register_activation_hook( __FILE__, 'ecwid_store_activate' );
12
  register_deactivation_hook( __FILE__, 'ecwid_store_deactivate' );
13
 
14
- if (!empty($_GET['ecwid_product_id']) || !empty($_GET['ecwid_category_id'])) {
15
  remove_action( 'wp_head','rel_canonical');
16
  }
17
  define("APP_ECWID_COM","app.ecwid.com");
@@ -27,22 +27,99 @@ if ( is_admin() ){
27
  add_shortcode('ecwid_searchbox', 'ecwid_searchbox_shortcode');
28
  add_shortcode('ecwid_categories', 'ecwid_categories_shortcode');
29
  add_shortcode('ecwid_productbrowser', 'ecwid_productbrowser_shortcode');
30
- add_filter('wp_title', 'ecwid_seo_title', 0 );
31
- $ecwid_seo_product_title = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
  function ecwid_seo_title($content) {
35
- $ecwid_noscript_seo_catalog = get_option('ecwid_noscript_seo_catalog');
36
- if (!empty($_GET['ecwid_product_id']) && !empty($ecwid_noscript_seo_catalog)) {
37
- $ecwid_seo_product_title = '';
38
- include_once "lib/ecwid_product_api.php";
39
- $ecwid_store_id = intval(get_ecwid_store_id());
40
- $api = new EcwidProductApi($ecwid_store_id);
41
- $ecwid_product = $api->get_product($_GET['ecwid_product_id']);
42
- $ecwid_seo_product_title = $ecwid_product['name'];
43
- return $ecwid_seo_product_title." | ";
44
- }
45
- else {
 
 
 
 
 
 
 
 
 
 
46
  return $content;
47
  }
48
  }
@@ -101,6 +178,17 @@ EOT;
101
  }
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
104
  function ecwid_productbrowser_shortcode() {
105
  global $ecwid_seo_product_title;
106
  $store_id = get_ecwid_store_id();
@@ -117,8 +205,6 @@ function ecwid_productbrowser_shortcode() {
117
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
118
  $ecwid_default_category_id = get_option('ecwid_default_category_id');
119
 
120
- $ecwid_noscript_seo_catalog = get_option('ecwid_noscript_seo_catalog');
121
-
122
  if (empty($ecwid_pb_categoriesperrow)) {
123
  $ecwid_pb_categoriesperrow = 3;
124
  }
@@ -152,36 +238,40 @@ function ecwid_productbrowser_shortcode() {
152
  $ecwid_default_category_str = ',"defaultCategoryId='. $ecwid_default_category_id .'"';
153
  }
154
 
155
-
156
  $ecwid_open_product = '';
157
- if (!empty($ecwid_noscript_seo_catalog)) {
158
-
159
- if (!empty($_GET['ecwid_product_id'])) {
160
- $ecwid_open_product = '<script type="text/javascript"> if (!document.location.hash) document.location.hash = "ecwid:category=0&mode=product&product='. intval($_GET['ecwid_product_id']) .'";</script>';
161
- } elseif (!empty($_GET['ecwid_category_id'])) {
162
- $ecwid_default_category_str = ',"defaultCategoryId='. intval($_GET['ecwid_category_id']) .'"';
163
- }
164
- include_once(ABSPATH . 'wp-content/plugins/ecwid-shopping-cart/lib/ecwid_catalog.php');
165
-
166
- $noscript_str = '<div id="ecwid-inline-catalog">'. show_ecwid_catalog($store_id) . '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  } else {
168
- $noscript_str = "<div id=\"ecwid-inline-catalog\">Your browser does not support JavaScript.<a href=\"{$ecwid_mobile_catalog_link}\">HTML version of this store</a></div>";
169
  }
170
-
171
- $s = <<<EOT
172
- {$noscript_str}
173
- <script type="text/javascript">
174
- xProductBrowser(
175
- "categoriesPerRow=$ecwid_pb_categoriesperrow",
176
- "views=grid($ecwid_pb_productspercolumn_grid,$ecwid_pb_productsperrow_grid) list($ecwid_pb_productsperpage_list) table($ecwid_pb_productsperpage_table)",
177
- "categoryView=$ecwid_pb_defaultview",
178
- "searchView=$ecwid_pb_searchview",
179
- "id=ecwid-inline-catalog",
180
- "style="$ecwid_default_category_str);
181
- </script>
182
- $ecwid_open_product
183
  EOT;
184
- return $s;
185
  }
186
 
187
 
@@ -213,8 +303,9 @@ EOT;
213
 
214
  add_option("ecwid_mobile_catalog_link", '', '', 'yes');
215
  add_option("ecwid_default_category_id", '', '', 'yes');
216
-
217
- add_option("ecwid_noscript_seo_catalog", '', '', 'yes');
 
218
 
219
  add_option("ecwid_sso_secret_key", '', '', 'yes');
220
 
@@ -290,10 +381,13 @@ function ecwid_settings_api_init() {
290
 
291
  register_setting('ecwid_options_page', 'ecwid_mobile_catalog_link');
292
  register_setting('ecwid_options_page', 'ecwid_default_category_id');
293
-
294
- register_setting('ecwid_options_page', 'ecwid_noscript_seo_catalog');
295
 
296
- register_setting('ecwid_options_page', 'ecwid_sso_secret_key');
 
 
 
 
 
297
  }
298
 
299
  function ecwid_options_add_page() {
@@ -316,7 +410,6 @@ function ecwid_options_do_page() {
316
 
317
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
318
  $ecwid_default_category_id = get_option('ecwid_default_category_id');
319
- $ecwid_noscript_seo_catalog = get_option('ecwid_noscript_seo_catalog');
320
  $ecwid_enable_ssl = get_option('ecwid_enable_ssl');
321
  $ecwid_page_id = get_option("ecwid_store_page_id");
322
 
@@ -325,55 +418,7 @@ function ecwid_options_do_page() {
325
  $ecwid_noscript_seo_catalog_disabled = false;
326
  $ecwid_noscript_seo_catalog_message = '<a href="http://kb.ecwid.com/Inline-SEO-Catalog" target="_blank">How it works</a>';
327
  $ecwid_settings_message = false;
328
-
329
- if ($store_id == 1003) {
330
- $ecwid_noscript_seo_catalog_disabled = true;
331
- $ecwid_noscript_seo_catalog_message = 'This option requires using Ecwid Product API. In order to enable it, please set up your Store ID first. Please note, that API is available for the <a href="http://www.ecwid.com/compare-plans.html" target="_blank">paid Ecwid accounts</a> only.';
332
- if (!empty($ecwid_noscript_seo_catalog)) {
333
- update_option('ecwid_noscript_seo_catalog', '');
334
- $ecwid_noscript_seo_catalog = '';
335
- }
336
- } # demo store id
337
-
338
- else if ($store_id != 1003 && empty($ecwid_noscript_seo_catalog)) {
339
- $ecwid_noscript_seo_catalog_message = '<a href="http://kb.ecwid.com/Inline-SEO-Catalog" target="_blank">How Inline Seo Catalog works</a>. This option requires using Ecwid API which is available for the <a href="http://www.ecwid.com/compare-plans.html" target="_blank">paid accounts</a> only.';
340
- }
341
- else if ($store_id != 1003 && !empty($ecwid_noscript_seo_catalog)) {
342
-
343
- include_once(ABSPATH . 'wp-content/plugins/ecwid-shopping-cart/lib/ecwid_product_api.php');
344
- $api = new EcwidProductApi($store_id);
345
- if (!empty($api)) {
346
- $store_profile = $api->get_profile();
347
-
348
- if ($api->error_code == 403) {
349
- #free account, consider upgrade
350
- $ecwid_noscript_seo_catalog_disabled = true;
351
- $ecwid_noscript_seo_catalog_message = 'This option requires using Ecwid API which is available for the <a href="http://www.ecwid.com/compare-plans.html" target="_blank">paid accounts</a> only. Please consider upgrading your account to use it.';
352
- update_option('ecwid_noscript_seo_catalog', '');
353
- $ecwid_noscript_seo_catalog = '';
354
- $ecwid_settings_message = 'The "Inline HTML catalog" option requires using Ecwid API which is available for the <a href="http://www.ecwid.com/compare-plans.html" target="_blank">paid accounts</a> only. Please consider upgrading your account to use it.';
355
-
356
- }
357
- else if ($api->error_code == 404) {
358
- $ecwid_noscript_seo_catalog_message = 'We cannot connect to Ecwid servers using your Store ID. Is it correct?';
359
- $ecwid_settings_message = 'We cannot connect to Ecwid servers using your Store ID. Is it correct?';
360
-
361
- }
362
-
363
- else if($api->error_code != '') {
364
- $ecwid_noscript_seo_catalog_message = 'Connection to Ecwid servers failed. Error code: '. $api->error_code;
365
- $ecwid_settings_message = 'Connection to Ecwid servers failed. Error code: '. $api->error_code;
366
- if ($api->error_code == 0) {
367
- $ecwid_noscript_seo_catalog_message .= '&nbsp;'. $api->error;
368
- $ecwid_settings_message .= '&nbsp;'. $api->error;
369
- }
370
- }
371
- } # no $api
372
- else {
373
- $ecwid_settings_message = 'We cannot include some essential files of Ecwid Shopping Cart module. It looks like it\'s corrupted. Try to re-install the module and contact Ecwid Team if it doesn\'t help.';
374
- }
375
- }
376
-
377
  $_tmp_page = null;
378
  $disabled = false;
379
  if (!empty($ecwid_page_id) and ($ecwid_page_id > 0)) {
@@ -477,21 +522,12 @@ function ecwid_options_do_page() {
477
 
478
  <tr><th colspan="2" style="padding:0px;margin:0px;"><h3 style="padding:0px;margin:0px;">SEO</h3></th></tr>
479
 
480
- <tr><th scope="row"><label for="ecwid_noscript_seo_catalog">
481
- Enable the inline plain-HTML catalog(better SEO)</label>
482
- </th>
483
- <td><input id="ecwid_noscript_seo_catalog" type="checkbox" name="ecwid_noscript_seo_catalog" <?php if (!empty($ecwid_noscript_seo_catalog)) echo "checked=\"checked\""; if(!empty($ecwid_noscript_seo_catalog_disabled)) echo "disabled=\"disabled\""; ?> />
484
- &nbsp;&nbsp;&nbsp;&nbsp;<img src="//www.ecwid.com/wp-content/uploads/ecwid_wp_attention.gif" alt="">&nbsp; <?php echo $ecwid_noscript_seo_catalog_message; ?>
485
-
486
- </td> </tr>
487
- <tr><th scope="row"><label for="ecwid_mobile_catalog_link">
488
- Full link to your mobile catalog</label>
489
- </th>
490
- <td><input id="ecwid_mobile_catalog_link" type="text" name="ecwid_mobile_catalog_link" value="<?php echo $ecwid_mobile_catalog_link; ?>" />
491
- &nbsp;&nbsp;&nbsp;&nbsp;<img src="//www.ecwid.com/wp-content/uploads/ecwid_wp_attention.gif" alt="">&nbsp;For example <em>http://mdemo.ecwid.com</em>.&nbsp;<a href="http://kb.ecwid.com/Mobile-Catalog" target="_blank">Information about Ecwid and mobile catalogs.</a>
492
-
493
- </td> </tr>
494
-
495
  <tr><th colspan="2" style="padding:0px;margin:0px;"><h3 style="padding:0px;margin:0px;">Advanced</h3></th></tr>
496
 
497
  <tr><th scope="row"><label for="ecwid_enable_ssl">
@@ -910,4 +946,32 @@ function ecwid_hmacsha1($data, $key) {
910
  }
911
  }
912
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913
  ?>
4
  Plugin URI: http://www.ecwid.com/
5
  Description: Ecwid is a free full-featured shopping cart. It can be easily integreted with any Wordpress blog and takes less than 5 minutes to set up.
6
  Author: Ecwid Team
7
+ Version: 1.2
8
  Author URI: http://www.ecwid.com/
9
  */
10
 
11
  register_activation_hook( __FILE__, 'ecwid_store_activate' );
12
  register_deactivation_hook( __FILE__, 'ecwid_store_deactivate' );
13
 
14
+ if (!empty($_GET['_escaped_fragment_'])) {
15
  remove_action( 'wp_head','rel_canonical');
16
  }
17
  define("APP_ECWID_COM","app.ecwid.com");
27
  add_shortcode('ecwid_searchbox', 'ecwid_searchbox_shortcode');
28
  add_shortcode('ecwid_categories', 'ecwid_categories_shortcode');
29
  add_shortcode('ecwid_productbrowser', 'ecwid_productbrowser_shortcode');
30
+ add_filter('wp_title', 'ecwid_seo_title', 0);
31
+ add_action('wp_head', 'ecwid_ajax_crawling_fragment');
32
+ add_action('wp_head', 'ecwid_meta');
33
+ $ecwid_seo_title = '';
34
+ }
35
+ add_action('admin_bar_menu', 'add_ecwid_admin_bar_node', 1000);
36
+
37
+
38
+ function add_ecwid_admin_bar_node() {
39
+ global $wp_admin_bar;
40
+ if ( !is_super_admin() || !is_admin_bar_showing() )
41
+ return;
42
+ //add parent menu node
43
+ $wp_admin_bar->add_menu( array(
44
+ 'id' => 'ecwid_main',
45
+ 'title' => '<img src="'.plugins_url().'/ecwid-shopping-cart/ecwid_menu_icon.png" style="width: 22px;height: 22px;margin-top: 3px;"/>',
46
+ ));
47
+ //add ecwid home page
48
+ $wp_admin_bar->add_menu(array(
49
+ "id" => "ecwid_home",
50
+ "title" => "Ecwid Site",
51
+ "parent" => "ecwid_main",
52
+ 'href' => 'http://www.ecwid.com/'
53
+ )
54
+ );
55
+ //add store page link
56
+ $wp_admin_bar->add_menu(array(
57
+ "id" => "ecwid_go_to_page",
58
+ "title" => "My Ecwid Store",
59
+ "parent" => "ecwid_main",
60
+ 'href' => get_page_link(get_option("ecwid_store_page_id"))
61
+ )
62
+ );
63
+ //add settings page link
64
+ $wp_admin_bar->add_menu(array(
65
+ "id" => "ecwid_settings",
66
+ "title" => "Settings page",
67
+ "parent" => "ecwid_main",
68
+ 'href' => admin_url('options-general.php?page=ecwid_options_page' )
69
+ )
70
+ );
71
+ $wp_admin_bar->add_menu(array(
72
+ "id" => "ecwid_fb_app",
73
+ "title" => "→ Sell on Facebook",
74
+ "parent" => "ecwid_main",
75
+ 'href' => 'http://apps.facebook.com/ecwid-shop/?fb_source=wp'
76
+ )
77
+ );
78
+ }
79
+
80
+ function ecwid_ajax_crawling_fragment() {
81
+ $ecwid_page_id = get_option("ecwid_store_page_id");
82
+ if (ecwid_is_api_enabled() && !isset($_GET['_escaped_fragment_']) && get_the_ID() == $ecwid_page_id)
83
+ echo '<meta name="fragment" content="!">' . PHP_EOL;
84
+ }
85
+
86
+ function ecwid_meta() {
87
+ echo '<link rel="dns-prefetch" href="//images-cdn.ecwid.com/">' . PHP_EOL;
88
+ echo '<link rel="dns-prefetch" href="//images.ecwid.com/">' . PHP_EOL;
89
+ echo '<link rel="dns-prefetch" href="//app.ecwid.com/">' . PHP_EOL;
90
+
91
+ $ecwid_page_id = get_option("ecwid_store_page_id");
92
+
93
+ if (get_the_ID() != $ecwid_page_id) {
94
+ $page_url = get_page_link($ecwid_page_id);
95
+ echo '<link rel="prefetch" href="' . $page_url . '" />' . PHP_EOL;
96
+ echo '<link rel="prerender" href="' . $page_url . '" />' . PHP_EOL;
97
+ }
98
+
99
  }
100
 
101
  function ecwid_seo_title($content) {
102
+ if (isset($_GET['_escaped_fragment_']) && ecwid_is_api_enabled()) {
103
+ $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
104
+ $ecwid_seo_title = '';
105
+
106
+ $api = ecwid_new_product_api();
107
+
108
+ if (isset($params['mode']) && !empty($params['mode'])) {
109
+ if ($params['mode'] == 'product') {
110
+ $ecwid_product = $api->get_product($params['id']);
111
+ $ecwid_seo_title = $ecwid_product['name'];
112
+ } elseif ($params['mode'] == 'category') {
113
+ // define category's title. no API for that QQ
114
+ }
115
+ }
116
+
117
+ if (!empty($ecwid_seo_title))
118
+ return $ecwid_seo_title . " | " . $content;
119
+ else
120
+ return $content;
121
+
122
+ } else {
123
  return $content;
124
  }
125
  }
178
  }
179
  }
180
 
181
+ function ecwid_parse_escaped_fragment($escaped_fragment) {
182
+ $fragment = urldecode($escaped_fragment);
183
+ $return = array();
184
+
185
+ if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) {
186
+ parse_str($matches[3], $return);
187
+ $return['mode'] = $matches[2];
188
+ }
189
+ return $return;
190
+ }
191
+
192
  function ecwid_productbrowser_shortcode() {
193
  global $ecwid_seo_product_title;
194
  $store_id = get_ecwid_store_id();
205
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
206
  $ecwid_default_category_id = get_option('ecwid_default_category_id');
207
 
 
 
208
  if (empty($ecwid_pb_categoriesperrow)) {
209
  $ecwid_pb_categoriesperrow = 3;
210
  }
238
  $ecwid_default_category_str = ',"defaultCategoryId='. $ecwid_default_category_id .'"';
239
  }
240
 
 
241
  $ecwid_open_product = '';
242
+ $plain_content = '';
243
+
244
+ if (ecwid_is_api_enabled()) {
245
+ if (isset($_GET['_escaped_fragment_'])) {
246
+ $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
247
+ include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/EcwidCatalog.php';
248
+
249
+ $ecwid_page_id = get_option("ecwid_store_page_id");
250
+ $page_url = get_page_link($ecwid_page_id);
251
+
252
+ $catalog = new EcwidCatalog($store_id, $page_url);
253
+
254
+ if (isset($params['mode']) && !empty($params['mode'])) {
255
+ if ($params['mode'] == 'product') {
256
+ $plain_content = $catalog->get_product($params['id']);
257
+ $plain_content .= '<script type="text/javascript"> if (!document.location.hash) document.location.hash = "!/~/product/id='. intval($params['id']) .'";</script>';
258
+ } elseif ($params['mode'] == 'category') {
259
+ $plain_content = $catalog->get_category($params['id']);
260
+ $ecwid_default_category_str = ',"defaultCategoryId=' . $params['id'] . '"';
261
+ }
262
+ } else {
263
+ $plain_content = $catalog->get_category(0);
264
+ }
265
+ }
266
  } else {
267
+ $plain_content = '<noscript>Your browser does not support JavaScript.<a href="' . $ecwid_mobile_catalog_link .'">HTML version of this store</a></noscript>';
268
  }
269
+
270
+ $s = <<<EOT
271
+ <div> <script type="text/javascript"> xProductBrowser("categoriesPerRow=$ecwid_pb_categoriesperrow","views=grid($ecwid_pb_productspercolumn_grid,$ecwid_pb_productsperrow_grid) list($ecwid_pb_productsperpage_list) table($ecwid_pb_productsperpage_table)","categoryView=$ecwid_pb_defaultview","searchView=$ecwid_pb_searchview","style="$ecwid_default_category_str);</script></div>
272
+ {$plain_content}
 
 
 
 
 
 
 
 
 
273
  EOT;
274
+ return $s;
275
  }
276
 
277
 
303
 
304
  add_option("ecwid_mobile_catalog_link", '', '', 'yes');
305
  add_option("ecwid_default_category_id", '', '', 'yes');
306
+
307
+ add_option('ecwid_is_api_enabled', 'on', '', 'yes');
308
+ add_option('ecwid_api_check_time', 0, '', 'yes');
309
 
310
  add_option("ecwid_sso_secret_key", '', '', 'yes');
311
 
381
 
382
  register_setting('ecwid_options_page', 'ecwid_mobile_catalog_link');
383
  register_setting('ecwid_options_page', 'ecwid_default_category_id');
 
 
384
 
385
+ register_setting('ecwid_options_page', 'ecwid_sso_secret_key');
386
+
387
+ if (isset($_POST['ecwid_store_id'])) {
388
+ update_option('ecwid_is_api_enabled', 'off');
389
+ update_option('ecwid_api_check_time', 0);
390
+ }
391
  }
392
 
393
  function ecwid_options_add_page() {
410
 
411
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
412
  $ecwid_default_category_id = get_option('ecwid_default_category_id');
 
413
  $ecwid_enable_ssl = get_option('ecwid_enable_ssl');
414
  $ecwid_page_id = get_option("ecwid_store_page_id");
415
 
418
  $ecwid_noscript_seo_catalog_disabled = false;
419
  $ecwid_noscript_seo_catalog_message = '<a href="http://kb.ecwid.com/Inline-SEO-Catalog" target="_blank">How it works</a>';
420
  $ecwid_settings_message = false;
421
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  $_tmp_page = null;
423
  $disabled = false;
424
  if (!empty($ecwid_page_id) and ($ecwid_page_id > 0)) {
522
 
523
  <tr><th colspan="2" style="padding:0px;margin:0px;"><h3 style="padding:0px;margin:0px;">SEO</h3></th></tr>
524
 
525
+ <tr>
526
+ <th scope="row"><label for="ecwid_mobile_catalog_link">Full link to your mobile catalog</label></th>
527
+ <td><input id="ecwid_mobile_catalog_link" type="text" name="ecwid_mobile_catalog_link" value="<?php echo $ecwid_mobile_catalog_link; ?>" />
528
+ &nbsp;&nbsp;&nbsp;&nbsp;<img src="//www.ecwid.com/wp-content/uploads/ecwid_wp_attention.gif" alt="">&nbsp;For example <em>http://mdemo.ecwid.com</em>.&nbsp;<a href="http://kb.ecwid.com/Mobile-Catalog" target="_blank">Information about Ecwid and mobile catalogs.</a></td>
529
+ </tr>
530
+
 
 
 
 
 
 
 
 
 
531
  <tr><th colspan="2" style="padding:0px;margin:0px;"><h3 style="padding:0px;margin:0px;">Advanced</h3></th></tr>
532
 
533
  <tr><th scope="row"><label for="ecwid_enable_ssl">
946
  }
947
  }
948
 
949
+ function ecwid_is_api_enabled()
950
+ {
951
+ $ecwid_is_api_enabled = get_option('ecwid_is_api_enabled');
952
+ $ecwid_api_check_time = get_option('ecwid_api_check_time');
953
+ $now = time();
954
+
955
+ if ($now > ($ecwid_api_check_time + 60 * 60 * 3)) {
956
+ // check whether API is available once in 3 hours
957
+ $ecwid = ecwid_new_product_api();
958
+ $ecwid_is_api_enabled = ($ecwid->is_api_enabled() ? 'on' : 'off');
959
+ update_option('ecwid_is_api_enabled', $ecwid_is_api_enabled);
960
+ update_option('ecwid_api_check_time', $now);
961
+ }
962
+
963
+ if ('on' == $ecwid_is_api_enabled)
964
+ return true;
965
+ else
966
+ return false;
967
+ }
968
+
969
+ function ecwid_new_product_api()
970
+ {
971
+ include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/ecwid_product_api.php';
972
+ $ecwid_store_id = intval(get_ecwid_store_id());
973
+ $api = new EcwidProductApi($ecwid_store_id);
974
+
975
+ return $api;
976
+ }
977
  ?>
ecwid_menu_icon.png ADDED
Binary file
lib/EcwidCatalog.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EcwidCatalog
4
+ {
5
+ var $store_id = 0;
6
+ var $store_base_url = '';
7
+ var $ecwid_api = null;
8
+
9
+ function __construct($store_id, $store_base_url)
10
+ {
11
+ $this->store_id = intval($store_id);
12
+ $this->store_base_url = $store_base_url;
13
+ $this->ecwid_api = new EcwidProductApi($this->store_id);
14
+ }
15
+
16
+ function EcwidCatalog($store_id)
17
+ {
18
+ if(version_compare(PHP_VERSION,"5.0.0","<"))
19
+ $this->__construct($store_id);
20
+ }
21
+
22
+ function get_product($id)
23
+ {
24
+ $params = array
25
+ (
26
+ array("alias" => "p", "action" => "product", "params" => array("id" => $id)),
27
+ array("alias" => "pf", "action" => "profile")
28
+ );
29
+
30
+ $batch_result = $this->ecwid_api->get_batch_request($params);
31
+ $product = $batch_result["p"];
32
+ $profile = $batch_result["pf"];
33
+
34
+ $return = '';
35
+
36
+ if (is_array($product))
37
+ {
38
+
39
+ $return = "<div itemscope itemtype=\"http://schema.org/Product\">";
40
+ $return .= "<h1 class='ecwid_catalog_product_name' itemprop=\"name\">" . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "</h1>";
41
+
42
+ if (!empty($product["thumbnailUrl"]))
43
+ $return .= "<div class='ecwid_catalog_product_image'><img itemprop=\"image\" src='" . $product["thumbnailUrl"] . "' alt='" . htmlentities($product["sku"], ENT_COMPAT, 'UTF-8') . " " . htmlentities($product["name"], ENT_COMPAT, 'UTF-8') . "'/></div>";
44
+
45
+ $return .= "<div class='ecwid_catalog_product_price' itemprop=\"offers\" itemscope itemtype=\"http://schema.org/Offer\">Price: <span itemprop=\"price\">" . $product["price"] . "</span>&nbsp;<span itemprop=\"priceCurrency\">" . $profile["currency"] . "</span>";
46
+
47
+ if (!isset($product['quantity']) || (isset($product['quantity']) && $product['quantity'] > 0))
48
+ $return .= "<link itemprop=\"availability\" href=\"http://schema.org/InStock\" />";
49
+
50
+ $return .= "</div>";
51
+ $return .= "<div class='ecwid_catalog_product_description' itemprop=\"description\">" . $product["description"] . "</div>";
52
+
53
+ if (is_array($product["galleryImages"])) {
54
+ foreach ($product["galleryImages"] as $galleryimage) {
55
+ if (empty($galleryimage["alt"])) $galleryimage["alt"] = htmlspecialchars($product["name"]);
56
+ $return .= "<img src='" . $galleryimage["url"] . "' alt='" . htmlspecialchars($galleryimage["alt"]) ."' title='" . htmlspecialchars($galleryimage["alt"]) ."'><br />";
57
+ }
58
+ }
59
+
60
+ $return .= "</div>" . PHP_EOL;
61
+ }
62
+
63
+ return $return;
64
+ }
65
+
66
+ function get_category($id)
67
+ {
68
+ $params = array
69
+ (
70
+ array("alias" => "c", "action" => "categories", "params" => array("parent" => $id)),
71
+ array("alias" => "p", "action" => "products", "params" => array("category" => $id)),
72
+ array("alias" => "pf", "action" => "profile")
73
+ );
74
+
75
+ $batch_result = $this->ecwid_api->get_batch_request($params);
76
+
77
+ $categories = $batch_result["c"];
78
+ $products = $batch_result["p"];
79
+ $profile = $batch_result["pf"];
80
+
81
+ $return = '';
82
+
83
+ if (is_array($categories))
84
+ {
85
+ foreach ($categories as $category)
86
+ {
87
+ $category_url = $this->build_url($category["url"]);
88
+ $category_name = $category["name"];
89
+ $return .= "<div class='ecwid_catalog_category_name'><a href='" . htmlspecialchars($category_url) . "&offset=0&sort=nameAsc'>" . $category_name . "</a><br /></div>" . PHP_EOL;
90
+ }
91
+ }
92
+
93
+ if (is_array($products))
94
+ {
95
+ foreach ($products as $product)
96
+ {
97
+ $product_url = $this->store_base_url . "#!/~/product/category=" . $id . "&id=" . $product["id"];
98
+ $this->build_url($product["url"]);
99
+ $product_name = $product["name"];
100
+ $product_price = $product["price"] . "&nbsp;" . $profile["currency"];
101
+ $return .= "<div>";
102
+ $return .= "<span class='ecwid_product_name'><a href='" . htmlspecialchars($product_url) . "'>" . $product_name . "</a></span>";
103
+ $return .= "&nbsp;&nbsp;<span class='ecwid_product_price'>" . $product_price . "</span>";
104
+ $return .= "</div>" . PHP_EOL;
105
+ }
106
+ }
107
+
108
+ return $return;
109
+ }
110
+
111
+ function build_url($url_from_ecwid)
112
+ {
113
+ if (preg_match('/(.*)(#!)(.*)/', $url_from_ecwid, $matches))
114
+ return $this->store_base_url . $matches[2] . $matches[3];
115
+ else
116
+ return '';
117
+ }
118
+ }
lib/ecwid_product_api.php CHANGED
@@ -8,7 +8,7 @@ class EcwidProductApi {
8
  var $error_code = '';
9
 
10
  var $ECWID_PRODUCT_API_ENDPOINT = "http://app.ecwid.com/api/v1";
11
-
12
  function __construct($store_id) {
13
  $this->store_id = intval($store_id);
14
  }
@@ -29,8 +29,7 @@ class EcwidProductApi {
29
  }
30
 
31
  function internal_fetch_url_libcurl($url) {
32
- if (intval($timeout) <= 0)
33
- $timeout = 90;
34
  if (!function_exists('curl_init'))
35
  return array("code"=>"0","data"=>"The libcurl module isn't installed on your server. Please contact your hosting or server administrator to have it installed.");
36
  $headers[] = "Content-Type: application/x-www-form-urlencoded";
@@ -56,6 +55,7 @@ class EcwidProductApi {
56
  }
57
 
58
  function process_request($url) {
 
59
  $result = $this->internal_fetch_url_libcurl($url);
60
  if ($result['code'] == 200) {
61
  $this->error = '';
@@ -112,7 +112,10 @@ class EcwidProductApi {
112
  foreach ($params as $param) {
113
  $alias = $param["alias"];
114
  $action = $param["action"];
115
- $action_params = $param["params"];
 
 
 
116
  if (!empty($api_url))
117
  $api_url .= "&";
118
 
8
  var $error_code = '';
9
 
10
  var $ECWID_PRODUCT_API_ENDPOINT = "http://app.ecwid.com/api/v1";
11
+
12
  function __construct($store_id) {
13
  $this->store_id = intval($store_id);
14
  }
29
  }
30
 
31
  function internal_fetch_url_libcurl($url) {
32
+ $timeout = 90;
 
33
  if (!function_exists('curl_init'))
34
  return array("code"=>"0","data"=>"The libcurl module isn't installed on your server. Please contact your hosting or server administrator to have it installed.");
35
  $headers[] = "Content-Type: application/x-www-form-urlencoded";
55
  }
56
 
57
  function process_request($url) {
58
+
59
  $result = $this->internal_fetch_url_libcurl($url);
60
  if ($result['code'] == 200) {
61
  $this->error = '';
112
  foreach ($params as $param) {
113
  $alias = $param["alias"];
114
  $action = $param["action"];
115
+
116
+ if (isset($param['params']))
117
+ $action_params = $param["params"];
118
+
119
  if (!empty($api_url))
120
  $api_url .= "&";
121
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Ecwid Team
3
  Tags: shopping cart, ecommerce, e-commerce, paypal, google checkout, 2checkout, store, shop, product catalog, inventory
4
  Requires at least: 2.8
5
  Tested up to: 3.4
6
- Stable tag: 1.1.2
7
 
8
  Ecwid is a free full-featured shopping cart that can easily be added to any blog
9
  and takes less than 5 minutes to set up.
@@ -77,6 +77,12 @@ http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
77
  - Knowledge Base: [http://kb.ecwid.com](http://kb.ecwid.com)
78
 
79
  == Changelog ==
 
 
 
 
 
 
80
  = 1.1.2 =
81
  - [!] Issue with the way how widgets are embedded into the page for the free users was fixed.
82
  = 1.1.1 =
3
  Tags: shopping cart, ecommerce, e-commerce, paypal, google checkout, 2checkout, store, shop, product catalog, inventory
4
  Requires at least: 2.8
5
  Tested up to: 3.4
6
+ Stable tag: 1.2
7
 
8
  Ecwid is a free full-featured shopping cart that can easily be added to any blog
9
  and takes less than 5 minutes to set up.
77
  - Knowledge Base: [http://kb.ecwid.com](http://kb.ecwid.com)
78
 
79
  == Changelog ==
80
+ = 1.2 =
81
+ - [+] A lot of changes in Ecwid shopping cart: http://www.ecwid.com/blog/new-releases/
82
+ - [+] Support of the Google’s “AJAX Crawling” API for native indexing of AJAX applications has been added. This will significantly improve the indexation of Ecwid stores and is a successor of the Inline SEO Catalog feature. More details at https://developers.google.com/webmasters/ajax-crawling/ (This feature requires a paid Ecwid subscription)
83
+ - [+] Auto-generated meta descriptions and titles for product pages.
84
+ - [+] Support of microformats to get rich snippets in search engine results pages.
85
+ - [+] New Ecwid section has been added to the admin menu.
86
  = 1.1.2 =
87
  - [!] Issue with the way how widgets are embedded into the page for the free users was fixed.
88
  = 1.1.1 =