Ecwid Ecommerce Shopping Cart - Version 4.1.1

Version Description

  • Layout improvements for the Accesspress-mag theme. Accesspress-mag theme users might notice slight glitches in the store buttons. We fixed those.
  • Added the page default category dropdown for free users. When you add a store on your site page, you can set the store category to be displayed on that page. This "default category" tool was previously just a text input where you were supposed to put the category ID, if you're on free Ecwid plan. Now it's a dropdown menu so you can easily select a store category for each page. It's very useful if you want to display different categories on different pages of your site.
  • Minor bug fixes and improvements
Download this release

Release Info

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

Code changes from version 4.0.7 to 4.1.1

css/admin.3.8.css CHANGED
@@ -1,5 +1,5 @@
1
  #adminmenu #toplevel_page_ecwid div.wp-menu-image:before {
2
- font-family: 'ecwid-icons' !important;
3
  content: "\e603";
4
  -webkit-font-smoothing: antialiased;
5
  -moz-osx-font-smoothing: grayscale;
1
  #adminmenu #toplevel_page_ecwid div.wp-menu-image:before {
2
+ font-family: 'ecwid-plugin-icons' !important;
3
  content: "\e603";
4
  -webkit-font-smoothing: antialiased;
5
  -moz-osx-font-smoothing: grayscale;
css/admin.css CHANGED
@@ -127,7 +127,7 @@ div.ecwid-message {
127
 
128
  .ecwid-message .ecwid-message-hide:before {
129
  content: "\e606";
130
- font-family: ecwid-icons;
131
  font-size: 16px;
132
  position: relative;
133
  left: 1px;
@@ -214,7 +214,7 @@ body[class*="_page_ecwid"] .ecwid-message {
214
  left: 16px;
215
  margin-right: -4px;
216
  line-height: 10px;
217
- font-family: 'ecwid-icons';
218
  speak: none;
219
  font-style: normal;
220
  font-weight: normal;
@@ -359,12 +359,17 @@ body[class*="_page_ecwid"] .ecwid-message {
359
  }
360
 
361
  .ecwid-admin-superwrap #wrap {
362
- position:absolute;
363
- left:-20px;
364
- right: 0px;
365
  height: 600px;
366
  background: white;
 
 
 
367
  }
 
 
 
 
 
368
  /* ---------------------- */
369
 
370
  @media screen and (max-width:1023px) {
127
 
128
  .ecwid-message .ecwid-message-hide:before {
129
  content: "\e606";
130
+ font-family: ecwid-plugin-icons;
131
  font-size: 16px;
132
  position: relative;
133
  left: 1px;
214
  left: 16px;
215
  margin-right: -4px;
216
  line-height: 10px;
217
+ font-family: 'ecwid-plugin-icons';
218
  speak: none;
219
  font-style: normal;
220
  font-weight: normal;
359
  }
360
 
361
  .ecwid-admin-superwrap #wrap {
 
 
 
362
  height: 600px;
363
  background: white;
364
+
365
+ width:100%;
366
+ max-width:1440px;
367
  }
368
+
369
+ .ecwid-no-padding #wpcontent {
370
+ padding-left: 0px;
371
+ }
372
+
373
  /* ---------------------- */
374
 
375
  @media screen and (max-width:1023px) {
css/fonts.css CHANGED
@@ -1,5 +1,5 @@
1
  @font-face {
2
- font-family: 'ecwid-icons';
3
  src:url('../fonts/ecwid-icons.eot?-b8sbws');
4
  src:url('../fonts/ecwid-icons.eot?#iefix-b8sbws') format('embedded-opentype'),
5
  url('../fonts/ecwid-icons.woff?-b8sbws') format('woff'),
@@ -10,7 +10,7 @@
10
  }
11
 
12
  [class^="icon-"], [class*=" icon-"] {
13
- font-family: 'ecwid-icons';
14
  speak: none;
15
  font-style: normal;
16
  font-weight: normal;
@@ -24,7 +24,7 @@
24
  }
25
 
26
  #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon.ecwid-top-menu-item {
27
- font: 400 20px/1 'ecwid-icons' !important;
28
  -webkit-font-smoothing: antialiased;
29
  -moz-osx-font-smoothing: grayscale;
30
  background-image: none;
@@ -42,7 +42,7 @@
42
 
43
  @media screen and (max-width: 782px) {
44
  #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon.ecwid-top-menu-item {
45
- font: 400 32px/46px 'ecwid-icons' !important;
46
  width: 46px;
47
  padding: 0px 2px;
48
  text-align: center;
1
  @font-face {
2
+ font-family: 'ecwid-plugin-icons';
3
  src:url('../fonts/ecwid-icons.eot?-b8sbws');
4
  src:url('../fonts/ecwid-icons.eot?#iefix-b8sbws') format('embedded-opentype'),
5
  url('../fonts/ecwid-icons.woff?-b8sbws') format('woff'),
10
  }
11
 
12
  [class^="icon-"], [class*=" icon-"] {
13
+ font-family: 'ecwid-plugin-icons';
14
  speak: none;
15
  font-style: normal;
16
  font-weight: normal;
24
  }
25
 
26
  #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon.ecwid-top-menu-item {
27
+ font: 400 20px/1 'ecwid-plugin-icons' !important;
28
  -webkit-font-smoothing: antialiased;
29
  -moz-osx-font-smoothing: grayscale;
30
  background-image: none;
42
 
43
  @media screen and (max-width: 782px) {
44
  #wpadminbar>#wp-toolbar>#wp-admin-bar-root-default .ab-icon.ecwid-top-menu-item {
45
+ font: 400 32px/46px 'ecwid-plugin-icons' !important;
46
  width: 46px;
47
  padding: 0px 2px;
48
  text-align: center;
css/settings.css CHANGED
@@ -321,6 +321,9 @@ display: none;
321
  }
322
 
323
  /* Common main */
 
 
 
324
  .ecwid-admin .box {
325
  position: relative;
326
  margin-top: 25px;
@@ -721,7 +724,7 @@ display: none;
721
 
722
  .ecwid-popup h3 span.close:before {
723
  content: "\e606";
724
- font-family: ecwid-icons;
725
  font-size: 36px;
726
  }
727
 
@@ -740,3 +743,7 @@ display: none;
740
  bottom: 0px;
741
  }
742
  }
 
 
 
 
321
  }
322
 
323
  /* Common main */
324
+ .ecwid-admin {
325
+ margin-left: 20px;
326
+ }
327
  .ecwid-admin .box {
328
  position: relative;
329
  margin-top: 25px;
724
 
725
  .ecwid-popup h3 span.close:before {
726
  content: "\e606";
727
+ font-family: ecwid-plugin-icons;
728
  font-size: 36px;
729
  }
730
 
743
  bottom: 0px;
744
  }
745
  }
746
+
747
+ .ecwid-admin-footer {
748
+ padding: 0 20px;
749
+ }
css/themes/accesspress-mag.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ html#ecwid_html body#ecwid_body .ecwid .ecwid-btn--secondary,
2
+ html#ecwid_html body#ecwid_body .ecwid-SearchPanel-button {
3
+ color: #333 !important;
4
+ }
5
+ html#ecwid_html body#ecwid_body .ecwid .ecwid-btn--secondary:hover {
6
+ color: #fff !important;
7
+ }
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: 4.0.7
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
@@ -16,6 +16,8 @@ register_uninstall_hook( __FILE__, 'ecwid_uninstall' );
16
  define("APP_ECWID_COM", 'app.ecwid.com');
17
  define("ECWID_DEMO_STORE_ID", 1003);
18
 
 
 
19
 
20
  if ( ! defined( 'ECWID_PLUGIN_DIR' ) ) {
21
  define( 'ECWID_PLUGIN_DIR', plugin_dir_path( realpath(__FILE__) ) );
@@ -43,7 +45,7 @@ if ( is_admin() ){
43
  add_action('admin_init', 'ecwid_settings_api_init');
44
  add_action('admin_init', 'ecwid_check_version');
45
  add_action('admin_init', 'ecwid_process_oauth_params');
46
- add_filter( 'admin_init', 'ecwid_add_meta_boxes' );
47
  add_action('admin_notices', 'ecwid_show_admin_messages');
48
  add_action('admin_menu', 'ecwid_build_menu');
49
  add_action('wp_dashboard_setup', 'ecwid_add_dashboard_widgets' );
@@ -61,7 +63,8 @@ if ( is_admin() ){
61
  add_action('init', 'ecwid_apply_theme');
62
  add_action('get_footer', 'ecwid_admin_get_footer');
63
  add_action('admin_post_ecwid_connect', 'ecwid_admin_post_connect');
64
- add_filter('tiny_mce_before_init', 'ecwid_tinymce_init' );
 
65
  } else {
66
  add_shortcode('ecwid_script', 'ecwid_script_shortcode');
67
  add_shortcode('ecwid_minicart', 'ecwid_minicart_shortcode');
@@ -99,12 +102,14 @@ if (get_option('ecwid_last_oauth_fail_time') > 0) {
99
  $ecwid_script_rendered = false; // controls single script.js on page
100
 
101
  require_once ECWID_PLUGIN_DIR . '/includes/themes.php';
 
102
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-message-manager.php';
103
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-store-editor.php';
104
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-oauth.php';
105
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-kissmetrics.php';
106
 
107
  require_once ECWID_PLUGIN_DIR . '/lib/ecwid_platform.php';
 
108
 
109
 
110
  function ecwid_init_integrations()
@@ -131,56 +136,6 @@ function ecwid_add_breadcrumbs_navxt($trail)
131
  $trail->add($breadcrumb);
132
  }
133
 
134
- /*
135
- add_filter('wpseo_sitemap_index', 'ecwid_wpseo_do_sitemap_index');
136
-
137
- function ecwid_wpseo_do_sitemap_index($params)
138
- {
139
- $now = date('Y-m-dTH:i:sP', time());
140
- $sitemap_url = wpseo_xml_sitemaps_base_url('ecwid-sitemap.xml');
141
- return <<<XML
142
- <sitemap>
143
- <loc>$sitemap_url</loc>
144
- <lastmod>$now</lastmod>
145
- </sitemap>
146
- XML;
147
-
148
- // should return index string
149
- }
150
-
151
- add_action('wpseo_do_sitemap_ecwid', 'ecwid_wpseo_do_sitemap');
152
-
153
- add_action('wpseo_do_sitemap_ecwid_content', 'ecwid_wpseo_do_sitemap');
154
-
155
- function ecwid_wpseo_build_sitemap_callback($loc, $priority, $freq)
156
- {
157
- global $ecwid_wpseo_sitemap;
158
-
159
- $ecwid_wpseo_sitemap .= <<<XML
160
- <url>
161
- <loc>$loc</loc>
162
- <changefreq>$freq</changefreq>
163
- <priority>$priority</priority>
164
- </url>
165
-
166
- XML;
167
- }
168
-
169
-
170
- function ecwid_wpseo_do_sitemap($params)
171
- {
172
- global $ecwid_wpseo_sitemap;
173
-
174
- $ecwid_wpseo_sitemap = <<<XML
175
- <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
176
- XML;
177
-
178
- ecwid_build_sitemap('ecwid_wpseo_build_sitemap_callback');
179
-
180
- $ecwid_wpseo_sitemap .= '</urlset>';
181
- $GLOBALS['wpseo_sitemaps']->set_sitemap($ecwid_wpseo_sitemap);
182
- }
183
- */
184
  function ecwid_add_breadcrumb_links_wpseo($links)
185
  {
186
  return array_merge((array)$links, array(
@@ -666,60 +621,48 @@ TEXT;
666
  $body = __($body, 'ecwid-shopping-cart');
667
  $body = sprintf($body, $theme, $store_url);
668
 
 
 
 
 
 
 
669
  $wp_admin_bar->add_menu(array(
670
- 'id' => 'ecwid-report-problem',
671
- 'title' => __( 'Report a problem with the store', 'ecwid-shopping-cart' ),
672
- 'parent' => 'ecwid-main',
673
- 'href' => 'mailto:wordpress@ecwid.com?subject=' . rawurlencode($subject) . '&body=' . rawurlencode($body),
674
- 'meta' => array(
675
- 'target' => '_blank'
676
  )
677
- ));
 
 
 
 
 
 
 
 
678
 
679
- $wp_admin_bar->add_menu( array(
680
- 'id' => 'ecwid-main',
681
- 'title' => '<span class="ab-icon ecwid-top-menu-item"></span>',
682
- 'href' => 'admin.php?page=ecwid',
683
- ));
684
  $wp_admin_bar->add_menu(array(
685
  "id" => "ecwid-help",
686
- "title" => __("Get help", 'ecwid-shopping-cart'),
687
  "parent" => "ecwid-main",
688
- 'href' => __('https://help.ecwid.com', 'ecwid-shopping-cart'),
689
  'meta' => array(
690
  'target' => '_blank'
691
  )
692
  )
693
  );
694
- $wp_admin_bar->add_menu(array(
695
- "id" => "ecwid-home",
696
- "title" => __("Go to Ecwid site", 'ecwid-shopping-cart'),
697
- "parent" => "ecwid-main",
698
- 'href' => 'http://www.ecwid.com?source=wporg'
699
- )
700
- );
701
- $wp_admin_bar->add_menu(array(
702
- "id" => "ecwid-go-to-page",
703
- "title" => __("Visit storefront", 'ecwid-shopping-cart'),
704
- "parent" => "ecwid-main",
705
- 'href' => ecwid_get_store_page_url()
706
- )
707
- );
708
- $wp_admin_bar->add_menu(array(
709
- "id" => "ecwid-control-panel",
710
- "title" => __("Manage my store", 'ecwid-shopping-cart'),
711
- "parent" => "ecwid-main",
712
- 'href' => admin_url('admin.php?page=ecwid')
713
- )
714
- );
715
- $wp_admin_bar->add_menu(array(
716
- "id" => "ecwid-fb-app",
717
- "title" => __("→ Sell on Facebook", 'ecwid-shopping-cart'),
718
- "parent" => "ecwid-main",
719
- 'href' => 'http://apps.facebook.com/ecwid-shop/?fb_source=wp'
720
- )
721
- );
722
 
 
 
 
 
 
 
 
 
 
723
  }
724
 
725
  function ecwid_content_has_productbrowser($content) {
@@ -831,21 +774,33 @@ function ecwid_meta_description() {
831
  $description = $category['description'];
832
  } else return;
833
 
834
- $description = strip_tags($description);
835
- $description = html_entity_decode($description, ENT_NOQUOTES, 'UTF-8');
 
 
 
 
 
 
 
 
 
836
 
837
  $description = preg_replace('![\p{Z}\s]{1,}!u', ' ', $description);
838
  $description = trim($description, " \t\xA0\n\r"); // Space, tab, non-breaking space, newline, carriage return
839
- $description = mb_substr($description, 0, 160, 'UTF-8');
840
  $description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8');
841
 
842
- echo <<<HTML
843
- <meta name="description" content="$description" />
844
- HTML;
845
  }
846
 
 
847
  function ecwid_ajax_hide_message($params)
848
  {
 
 
 
 
849
  if (Ecwid_Message_Manager::disable_message($_GET['message'])) {
850
  wp_send_json(array('status' => 'success'));
851
  }
@@ -924,6 +879,7 @@ function ecwid_seo_title_parts($parts)
924
  function ecwid_ajax_seo_title()
925
  {
926
  $title = _ecwid_get_seo_title();
 
927
  $template = $_GET['title_template'];
928
 
929
  $result = str_replace('ECWID_SEO_TITLE', $title, $template);
@@ -1010,10 +966,10 @@ function ecwid_content_started($content)
1010
 
1011
  function ecwid_wrap_shortcode_content($content, $name, $attrs)
1012
  {
1013
- return "<!-- Ecwid shopping cart plugin v 4.0.7 --><!-- noptimize -->"
1014
  . ecwid_get_scriptjs_code(@$attrs['lang'])
1015
  . "<div class=\"ecwid-shopping-cart-$name\">$content</div>"
1016
- . "<!-- /noptimize --><!-- END Ecwid Shopping Cart v 4.0.7 -->";
1017
  }
1018
 
1019
  function ecwid_get_scriptjs_code($force_lang = null) {
@@ -1134,7 +1090,7 @@ function ecwid_categories_shortcode($attributes) {
1134
  $ver = get_option('ecwid_plugin_version');
1135
  $result = <<<HTML
1136
  <div id="horizontal-menu" data-storeid="$store_id"></div>
1137
- <script src="https://djqizrxa6f10j.cloudfront.net/horizontal-category-widget/v1.1/horizontal-widget.js?ver=$ver"></script>
1138
  HTML;
1139
  } else {
1140
  $result = <<<EOT
@@ -1638,14 +1594,8 @@ function ecwid_add_meta_boxes()
1638
  add_meta_box( 'ecwid_nav_links', __( 'Store', 'ecwid-shopping-cart' ), 'ecwid_nav_menu_links', 'nav-menus', 'side' );
1639
  }
1640
 
1641
- function ecwid_nav_menu_items($items)
1642
- {
1643
-
1644
- if (is_admin()) {
1645
- return $items;
1646
- }
1647
-
1648
- $categories = wp_cache_get('all_categories', 'ecwid');
1649
 
1650
  if ( false == $categories ) {
1651
  $callback = 'ecwidcatscallback';
@@ -1658,9 +1608,21 @@ function ecwid_nav_menu_items($items)
1658
 
1659
  $categories = json_decode($result);
1660
 
1661
- $result = wp_cache_set('all_categories', $categories, 'ecwid', time() + 60 * 60 * 12);
 
 
 
 
 
 
 
 
 
 
1662
  }
1663
 
 
 
1664
  $counter = 0;
1665
  foreach ($items as $key => $item) {
1666
 
@@ -1704,6 +1666,10 @@ function ecwid_nav_menu_items($items)
1704
 
1705
  function ecwid_reset_categories_cache()
1706
  {
 
 
 
 
1707
  wp_cache_delete('all_categories', 'ecwid');
1708
  }
1709
 
@@ -1795,6 +1761,9 @@ function ecwid_register_admin_styles($hook_suffix) {
1795
  if (get_option('ecwid_store_id') == ECWID_DEMO_STORE_ID) {
1796
  // Open dashboard for the first time, ecwid store id is set to demo => need landing styles/scripts
1797
  wp_enqueue_script('ecwid-landing-js', plugins_url('ecwid-shopping-cart/js/landing.js'), array(), get_option('ecwid_plugin_version'));
 
 
 
1798
  wp_enqueue_style('ecwid-landing-css', plugins_url('ecwid-shopping-cart/css/landing.css'), array(), get_option('ecwid_plugin_version'), 'all');
1799
  wp_enqueue_style('ecwid-landing-fonts', 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300', array(), get_option('ecwid_plugin_version'));
1800
  } else {
@@ -1884,12 +1853,22 @@ function ecwid_common_admin_scripts() {
1884
  $screen = get_current_screen();
1885
 
1886
  if ($screen->base == 'nav-menus') {
 
 
 
 
 
 
 
 
 
1887
  wp_enqueue_script('ecwid-admin-menu-js', plugins_url('ecwid-shopping-cart/js/nav-menu.js'), array(), get_option('ecwid_plugin_version'));
1888
- wp_localize_script('ecwid-admin-menu-js', 'ecwid_l10n', array(
1889
  'store_page' => __('Store Page', 'ecwid-shopping-cart'),
1890
  'reset_cats_cache' => __('Refresh categories list', 'ecwid-shopping-cart'),
1891
  'cache_updated' => __('Done', 'ecwid-shopping-cart'),
1892
- 'reset_cache_message' => __('The store top-level categories are automatically added to this drop-down menu', 'ecwid-shopping-cart')
 
1893
  ));
1894
  }
1895
 
@@ -1937,9 +1916,7 @@ function ecwid_get_register_link()
1937
  }
1938
 
1939
  function ecwid_general_settings_do_page() {
1940
-
1941
- //Ecwid_Kissmetrics::record('wpPluginDeactivated');
1942
-
1943
  $store_id = get_option( 'ecwid_store_id' );
1944
 
1945
  $connection_error = isset( $_GET['connection_error'] );
@@ -1982,9 +1959,9 @@ function ecwid_general_settings_do_page() {
1982
  $iframe_src = sprintf(
1983
  'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&place=%s&inline&lang=%s',
1984
  get_ecwid_store_id(),
1985
- $ecwid_oauth->get_oauth_token(),
1986
  $time,
1987
- hash( 'sha256', get_ecwid_store_id() . $ecwid_oauth->get_oauth_token() . $time . Ecwid_OAuth::OAUTH_CLIENT_SECRET ),
1988
  $page,
1989
  substr( get_bloginfo( 'language' ), 0, 2 )
1990
  );
@@ -2014,9 +1991,9 @@ function ecwid_admin_do_page( $page ) {
2014
  $iframe_src = sprintf(
2015
  'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&place=%s&inline&lang=%s',
2016
  get_ecwid_store_id(),
2017
- $ecwid_oauth->get_oauth_token(),
2018
  $time,
2019
- hash('sha256', get_ecwid_store_id() . $ecwid_oauth->get_oauth_token(). $time . Ecwid_OAuth::OAUTH_CLIENT_SECRET),
2020
  $page,
2021
  substr(get_bloginfo('language'), 0, 2)
2022
  );
@@ -2111,6 +2088,10 @@ function ecwid_process_oauth_params() {
2111
 
2112
  function ecwid_admin_post_connect()
2113
  {
 
 
 
 
2114
  if (isset($_GET['force_store_id'])) {
2115
  update_option('ecwid_store_id', $_GET['force_store_id']);
2116
  update_option('ecwid_is_api_enabled', 'off');
@@ -2153,48 +2134,26 @@ function ecwid_test_oauth($force = false)
2153
  }
2154
 
2155
  function ecwid_get_categories_for_selector() {
2156
- $categories = false;
2157
- if (ecwid_is_paid_account()) {
2158
- $api = ecwid_new_product_api();
2159
- $categories = $api->get_all_categories();
2160
- $by_id = array();
2161
 
2162
- if (empty($categories)) return array();
2163
-
2164
- if (is_array($categories)) {
2165
- foreach ($categories as $key => $category) {
2166
- $by_id[$category['id']] = $category;
2167
- }
2168
- }
2169
- unset($categories);
2170
-
2171
- foreach ($by_id as $id => $category) {
2172
- $name_path = array($category['name']);
2173
- while (is_array($category) && isset($category['parentId'])) {
2174
- $name = '';
2175
- if (isset($by_id[$category['parentId']])) {
2176
- $name = $by_id[$category['parentId']]['name'];
2177
- } else {
2178
- $name = __('Hidden category', 'ecwid-shopping-cart');
2179
- }
2180
- $name_path[] = $name;
2181
- $category = isset($by_id[$category['parentId']]) ? $by_id[$category['parentId']] : false;
2182
- }
2183
-
2184
- $by_id[$id]['path'] = array_reverse($name_path);
2185
- $by_id[$id]['path_str'] = implode(" > ", $by_id[$id]['path']);
2186
  }
 
2187
 
2188
- function sort_by_path($a, $b) {
2189
- return strcmp($a['path_str'], $b['path_str']);
 
 
 
2190
  }
2191
 
2192
- uasort($by_id, 'sort_by_path');
2193
-
2194
- $categories = $by_id;
2195
  }
2196
 
2197
- return $categories;
 
 
2198
  }
2199
 
2200
  function ecwid_advanced_settings_do_page() {
@@ -2229,13 +2188,24 @@ function ecwid_debug_do_page() {
2229
  if (ecwid_is_api_enabled()) {
2230
  $remote_get_results = wp_remote_get( 'http://app.ecwid.com/api/v1/' . get_ecwid_store_id() . '/profile' );
2231
 
2232
- global $ecwid_oauth;
2233
- $api_v3_profile_results = wp_remote_get( 'https://app.ecwid.com/api/v3/' . get_ecwid_store_id() . '/profile?token=' . $ecwid_oauth->get_oauth_token() );
2234
  }
2235
 
2236
  require_once ECWID_PLUGIN_DIR . 'templates/debug.php';
2237
  }
2238
 
 
 
 
 
 
 
 
 
 
 
 
 
2239
  function get_ecwid_store_id() {
2240
  static $store_id = null;
2241
  if (is_null($store_id)) {
@@ -2248,7 +2218,9 @@ function get_ecwid_store_id() {
2248
  }
2249
 
2250
  function ecwid_dashboard_widget_function() {
2251
- require_once ECWID_PLUGIN_DIR . 'templates/wp-dashboard-widget.php';
 
 
2252
  }
2253
 
2254
  function ecwid_add_dashboard_widgets() {
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: 4.1.1
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
16
  define("APP_ECWID_COM", 'app.ecwid.com');
17
  define("ECWID_DEMO_STORE_ID", 1003);
18
 
19
+ define ('ECWID_TRIMMED_DESCRIPTION_LENGTH', 160);
20
+
21
 
22
  if ( ! defined( 'ECWID_PLUGIN_DIR' ) ) {
23
  define( 'ECWID_PLUGIN_DIR', plugin_dir_path( realpath(__FILE__) ) );
45
  add_action('admin_init', 'ecwid_settings_api_init');
46
  add_action('admin_init', 'ecwid_check_version');
47
  add_action('admin_init', 'ecwid_process_oauth_params');
48
+ add_filter('admin_init', 'ecwid_add_meta_boxes' );
49
  add_action('admin_notices', 'ecwid_show_admin_messages');
50
  add_action('admin_menu', 'ecwid_build_menu');
51
  add_action('wp_dashboard_setup', 'ecwid_add_dashboard_widgets' );
63
  add_action('init', 'ecwid_apply_theme');
64
  add_action('get_footer', 'ecwid_admin_get_footer');
65
  add_action('admin_post_ecwid_connect', 'ecwid_admin_post_connect');
66
+ add_filter('tiny_mce_before_init', 'ecwid_tinymce_init');
67
+ add_action('admin_post_ecwid_get_debug', 'ecwid_get_debug_file');
68
  } else {
69
  add_shortcode('ecwid_script', 'ecwid_script_shortcode');
70
  add_shortcode('ecwid_minicart', 'ecwid_minicart_shortcode');
102
  $ecwid_script_rendered = false; // controls single script.js on page
103
 
104
  require_once ECWID_PLUGIN_DIR . '/includes/themes.php';
105
+ require_once ECWID_PLUGIN_DIR . '/includes/oembed.php';
106
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-message-manager.php';
107
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-store-editor.php';
108
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-oauth.php';
109
  require_once ECWID_PLUGIN_DIR . '/includes/class-ecwid-kissmetrics.php';
110
 
111
  require_once ECWID_PLUGIN_DIR . '/lib/ecwid_platform.php';
112
+ require_once ECWID_PLUGIN_DIR . '/lib/ecwid_api_v3.php';
113
 
114
 
115
  function ecwid_init_integrations()
136
  $trail->add($breadcrumb);
137
  }
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  function ecwid_add_breadcrumb_links_wpseo($links)
140
  {
141
  return array_merge((array)$links, array(
621
  $body = __($body, 'ecwid-shopping-cart');
622
  $body = sprintf($body, $theme, $store_url);
623
 
624
+ $wp_admin_bar->add_menu( array(
625
+ 'id' => 'ecwid-main',
626
+ 'title' => '<span class="ab-icon ecwid-top-menu-item"></span>',
627
+ 'href' => 'admin.php?page=ecwid',
628
+ ));
629
+
630
  $wp_admin_bar->add_menu(array(
631
+ "id" => "ecwid-go-to-page",
632
+ "title" => __("Visit storefront", 'ecwid-shopping-cart'),
633
+ "parent" => "ecwid-main",
634
+ 'href' => ecwid_get_store_page_url()
 
 
635
  )
636
+ );
637
+
638
+ $wp_admin_bar->add_menu(array(
639
+ "id" => "ecwid-control-panel",
640
+ "title" => __("Manage my store", 'ecwid-shopping-cart'),
641
+ "parent" => "ecwid-main",
642
+ 'href' => admin_url('admin.php?page=ecwid')
643
+ )
644
+ );
645
 
 
 
 
 
 
646
  $wp_admin_bar->add_menu(array(
647
  "id" => "ecwid-help",
648
+ "title" => __("Read FAQ", 'ecwid-shopping-cart'),
649
  "parent" => "ecwid-main",
650
+ 'href' => __('https://help.ecwid.com/customer/portal/articles/1085017-wordpress-downloadable', 'ecwid-shopping-cart'),
651
  'meta' => array(
652
  'target' => '_blank'
653
  )
654
  )
655
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
 
657
+ $wp_admin_bar->add_menu(array(
658
+ 'id' => 'ecwid-report-problem',
659
+ 'title' => __( 'Report a problem with the store', 'ecwid-shopping-cart' ),
660
+ 'parent' => 'ecwid-main',
661
+ 'href' => 'mailto:wordpress@ecwid.com?subject=' . rawurlencode($subject) . '&body=' . rawurlencode($body),
662
+ 'meta' => array(
663
+ 'target' => '_blank'
664
+ )
665
+ ));
666
  }
667
 
668
  function ecwid_content_has_productbrowser($content) {
774
  $description = $category['description'];
775
  } else return;
776
 
777
+ $description = ecwid_trim_description($description);
778
+
779
+ echo <<<HTML
780
+ <meta name="description" content="$description" />
781
+ HTML;
782
+ }
783
+
784
+ function ecwid_trim_description($description)
785
+ {
786
+ $description = strip_tags($description);
787
+ $description = html_entity_decode($description, ENT_NOQUOTES, 'UTF-8');
788
 
789
  $description = preg_replace('![\p{Z}\s]{1,}!u', ' ', $description);
790
  $description = trim($description, " \t\xA0\n\r"); // Space, tab, non-breaking space, newline, carriage return
791
+ $description = mb_substr($description, 0, ECWID_TRIMMED_DESCRIPTION_LENGTH, 'UTF-8');
792
  $description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8');
793
 
794
+ return $description;
 
 
795
  }
796
 
797
+
798
  function ecwid_ajax_hide_message($params)
799
  {
800
+ if (!current_user_can('administrator')) {
801
+ return;
802
+ }
803
+
804
  if (Ecwid_Message_Manager::disable_message($_GET['message'])) {
805
  wp_send_json(array('status' => 'success'));
806
  }
879
  function ecwid_ajax_seo_title()
880
  {
881
  $title = _ecwid_get_seo_title();
882
+ echo $title;
883
  $template = $_GET['title_template'];
884
 
885
  $result = str_replace('ECWID_SEO_TITLE', $title, $template);
966
 
967
  function ecwid_wrap_shortcode_content($content, $name, $attrs)
968
  {
969
+ return "<!-- Ecwid shopping cart plugin v 4.1.1 --><!-- noptimize -->"
970
  . ecwid_get_scriptjs_code(@$attrs['lang'])
971
  . "<div class=\"ecwid-shopping-cart-$name\">$content</div>"
972
+ . "<!-- /noptimize --><!-- END Ecwid Shopping Cart v 4.1.1 -->";
973
  }
974
 
975
  function ecwid_get_scriptjs_code($force_lang = null) {
1090
  $ver = get_option('ecwid_plugin_version');
1091
  $result = <<<HTML
1092
  <div id="horizontal-menu" data-storeid="$store_id"></div>
1093
+ <script src="https://djqizrxa6f10j.cloudfront.net/horizontal-category-widget/v1.2/horizontal-widget.js?ver=$ver"></script>
1094
  HTML;
1095
  } else {
1096
  $result = <<<EOT
1594
  add_meta_box( 'ecwid_nav_links', __( 'Store', 'ecwid-shopping-cart' ), 'ecwid_nav_menu_links', 'nav-menus', 'side' );
1595
  }
1596
 
1597
+ function ecwid_get_categories() {
1598
+ $categories = EcwidPlatform::cache_get('all_categories');
 
 
 
 
 
 
1599
 
1600
  if ( false == $categories ) {
1601
  $callback = 'ecwidcatscallback';
1608
 
1609
  $categories = json_decode($result);
1610
 
1611
+ $result = EcwidPlatform::cache_set('all_categories', $categories, 60 * 60 * 12);
1612
+ }
1613
+
1614
+ return $categories;
1615
+ }
1616
+
1617
+ function ecwid_nav_menu_items($items)
1618
+ {
1619
+
1620
+ if (is_admin()) {
1621
+ return $items;
1622
  }
1623
 
1624
+ $categories = ecwid_get_categories();
1625
+
1626
  $counter = 0;
1627
  foreach ($items as $key => $item) {
1628
 
1666
 
1667
  function ecwid_reset_categories_cache()
1668
  {
1669
+ if (!current_user_can('administrator')) {
1670
+ return;
1671
+ }
1672
+
1673
  wp_cache_delete('all_categories', 'ecwid');
1674
  }
1675
 
1761
  if (get_option('ecwid_store_id') == ECWID_DEMO_STORE_ID) {
1762
  // Open dashboard for the first time, ecwid store id is set to demo => need landing styles/scripts
1763
  wp_enqueue_script('ecwid-landing-js', plugins_url('ecwid-shopping-cart/js/landing.js'), array(), get_option('ecwid_plugin_version'));
1764
+ wp_localize_script('ecwid-landing-js', 'ecwidParams', array(
1765
+ 'register_link' => ecwid_get_register_link()
1766
+ ));
1767
  wp_enqueue_style('ecwid-landing-css', plugins_url('ecwid-shopping-cart/css/landing.css'), array(), get_option('ecwid_plugin_version'), 'all');
1768
  wp_enqueue_style('ecwid-landing-fonts', 'http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300', array(), get_option('ecwid_plugin_version'));
1769
  } else {
1853
  $screen = get_current_screen();
1854
 
1855
  if ($screen->base == 'nav-menus') {
1856
+ EcwidPlatform::set('nav-menus-opened-once', null);
1857
+
1858
+ $first_run = false;
1859
+ // It opens the page twice on the very first run of that page
1860
+ if (EcwidPlatform::get('nav-menus-opened-once', false) < 2) {
1861
+ EcwidPlatform::set('nav-menus-opened-once', EcwidPlatform::get('nav-menus-opened-once') + 1);
1862
+ $first_run = EcwidPlatform::get('nav-menus-opened-once') <= 2;
1863
+ }
1864
+
1865
  wp_enqueue_script('ecwid-admin-menu-js', plugins_url('ecwid-shopping-cart/js/nav-menu.js'), array(), get_option('ecwid_plugin_version'));
1866
+ wp_localize_script('ecwid-admin-menu-js', 'ecwid_params', array(
1867
  'store_page' => __('Store Page', 'ecwid-shopping-cart'),
1868
  'reset_cats_cache' => __('Refresh categories list', 'ecwid-shopping-cart'),
1869
  'cache_updated' => __('Done', 'ecwid-shopping-cart'),
1870
+ 'reset_cache_message' => __('The store top-level categories are automatically added to this drop-down menu', 'ecwid-shopping-cart'),
1871
+ 'first_run' => $first_run
1872
  ));
1873
  }
1874
 
1916
  }
1917
 
1918
  function ecwid_general_settings_do_page() {
1919
+
 
 
1920
  $store_id = get_option( 'ecwid_store_id' );
1921
 
1922
  $connection_error = isset( $_GET['connection_error'] );
1959
  $iframe_src = sprintf(
1960
  'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&place=%s&inline&lang=%s',
1961
  get_ecwid_store_id(),
1962
+ Ecwid_Api_V3::get_token(),
1963
  $time,
1964
+ hash( 'sha256', get_ecwid_store_id() . Ecwid_Api_V3::get_token() . $time . Ecwid_Api_V3::CLIENT_SECRET ),
1965
  $page,
1966
  substr( get_bloginfo( 'language' ), 0, 2 )
1967
  );
1991
  $iframe_src = sprintf(
1992
  'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&place=%s&inline&lang=%s',
1993
  get_ecwid_store_id(),
1994
+ Ecwid_Api_V3::get_token(),
1995
  $time,
1996
+ hash('sha256', get_ecwid_store_id() . Ecwid_Api_V3::get_token() . $time . Ecwid_Api_V3::CLIENT_SECRET),
1997
  $page,
1998
  substr(get_bloginfo('language'), 0, 2)
1999
  );
2088
 
2089
  function ecwid_admin_post_connect()
2090
  {
2091
+ if (!current_user_can('administrator')) {
2092
+ return;
2093
+ }
2094
+
2095
  if (isset($_GET['force_store_id'])) {
2096
  update_option('ecwid_store_id', $_GET['force_store_id']);
2097
  update_option('ecwid_is_api_enabled', 'off');
2134
  }
2135
 
2136
  function ecwid_get_categories_for_selector() {
 
 
 
 
 
2137
 
2138
+ function walk_through_categories($categories, $parent_prefix) {
2139
+ if (empty($categories)) {
2140
+ return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2141
  }
2142
+ $result = array();
2143
 
2144
+ foreach ($categories as $category) {
2145
+ $result[$category->id] = $category;
2146
+ $result[$category->id]->path = $parent_prefix . $category->name;
2147
+ $result = array_merge($result, walk_through_categories($category->sub, $category->name . ' > '));
2148
+ unset($result[$category->id]->sub);
2149
  }
2150
 
2151
+ return $result;
 
 
2152
  }
2153
 
2154
+ $result = walk_through_categories(ecwid_get_categories(), "");
2155
+
2156
+ return $result;
2157
  }
2158
 
2159
  function ecwid_advanced_settings_do_page() {
2188
  if (ecwid_is_api_enabled()) {
2189
  $remote_get_results = wp_remote_get( 'http://app.ecwid.com/api/v1/' . get_ecwid_store_id() . '/profile' );
2190
 
2191
+ $api_v3_profile_results = wp_remote_get( 'https://app.ecwid.com/api/v3/' . get_ecwid_store_id() . '/profile?token=' . Ecwid_Api_V3::get_token() );
 
2192
  }
2193
 
2194
  require_once ECWID_PLUGIN_DIR . 'templates/debug.php';
2195
  }
2196
 
2197
+ function ecwid_get_debug_file() {
2198
+ if (!current_user_can('administrator')) {
2199
+ return;
2200
+ }
2201
+
2202
+ header('Content-Disposition: attachment;filename=ecwid-plugin-log.html');
2203
+
2204
+
2205
+ ecwid_debug_do_page();
2206
+ wp_die();
2207
+ }
2208
+
2209
  function get_ecwid_store_id() {
2210
  static $store_id = null;
2211
  if (is_null($store_id)) {
2218
  }
2219
 
2220
  function ecwid_dashboard_widget_function() {
2221
+ if (!is_ssl()) {
2222
+ require_once ECWID_PLUGIN_DIR . 'templates/wp-dashboard-widget.php';
2223
+ }
2224
  }
2225
 
2226
  function ecwid_add_dashboard_widgets() {
includes/class-ecwid-integration-wpseo.php CHANGED
@@ -63,7 +63,7 @@ XML;
63
  {
64
 
65
  $this->sitemap = <<<XML
66
- <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
67
  XML;
68
 
69
 
@@ -78,14 +78,28 @@ XML;
78
  }
79
 
80
  // A callback for the streaming sitemap builder
81
- public function sitemap_callback($url, $priority, $frequency)
82
  {
83
  $url = htmlspecialchars($url);
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  $this->sitemap .= <<<XML
85
  <url>
86
  <loc>$url</loc>
87
  <changefreq>$frequency</changefreq>
88
  <priority>$priority</priority>
 
89
  </url>
90
 
91
  XML;
63
  {
64
 
65
  $this->sitemap = <<<XML
66
+ <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
67
  XML;
68
 
69
 
78
  }
79
 
80
  // A callback for the streaming sitemap builder
81
+ public function sitemap_callback($url, $priority, $frequency, $obj)
82
  {
83
  $url = htmlspecialchars($url);
84
+ $imageCode = '';
85
+ $image = @$obj['originalImageUrl'];
86
+ if ($image) {
87
+ $image = htmlspecialchars($image);
88
+ $title = htmlspecialchars($obj['name']);
89
+ $imageCode = <<<XML
90
+ <image:image>
91
+ <image:title>$title</image:title>
92
+ <image:loc>$image</image:loc>
93
+
94
+ </image:image>
95
+ XML;
96
+ }
97
  $this->sitemap .= <<<XML
98
  <url>
99
  <loc>$url</loc>
100
  <changefreq>$frequency</changefreq>
101
  <priority>$priority</priority>
102
+ $imageCode
103
  </url>
104
 
105
  XML;
includes/class-ecwid-kissmetrics.php CHANGED
@@ -31,7 +31,8 @@ class Ecwid_Kissmetrics {
31
  wp_enqueue_script('ecwid-kissmetrics-events', ECWID_PLUGIN_URL . 'js/kissmetrics.js', array( 'ecwid-kissmetrics' ) );
32
 
33
  $kissmetrics = array(
34
- 'events' => $this->_get_pending_events()
 
35
  );
36
 
37
  $this->_flush_events();
31
  wp_enqueue_script('ecwid-kissmetrics-events', ECWID_PLUGIN_URL . 'js/kissmetrics.js', array( 'ecwid-kissmetrics' ) );
32
 
33
  $kissmetrics = array(
34
+ 'events' => $this->_get_pending_events(),
35
+ 'key' => self::API_KEY
36
  );
37
 
38
  $this->_flush_events();
includes/class-ecwid-oauth.php CHANGED
@@ -1,21 +1,17 @@
1
  <?php
2
 
3
  include ECWID_PLUGIN_DIR . "lib/phpseclib/AES.php";
 
4
 
5
  class Ecwid_OAuth {
6
 
7
- const OAUTH_CLIENT_ID = 'RD4o2KQimiGUrFZc';
8
- const OAUTH_CLIENT_SECRET = 'jEPVdcA3KbzKVrG8FZDgNnsY3wKHDTF8';
9
-
10
- const TOKEN_OPTION_NAME = 'ecwid_oauth_token';
11
-
12
  const MODE_CONNECT = 'connect';
13
  const MODE_RECONNECT = 'reconnect';
14
 
15
- protected $crypt = null;
16
-
17
  protected $state;
18
 
 
 
19
  public function __construct()
20
  {
21
  add_action('admin_post_ecwid_oauth', array($this, 'process_authorization'));
@@ -23,10 +19,9 @@ class Ecwid_OAuth {
23
  add_action('admin_post_ecwid_disconnect', array($this, 'disconnect_store'));
24
  add_action('admin_post_ecwid_show_reconnect', array($this, 'show_reconnect'));
25
 
26
- $this->crypt = new Ecwid_Crypt_AES();
27
- $this->_init_crypt();
28
-
29
  $this->_load_state();
 
 
30
  }
31
 
32
  public function show_reconnect()
@@ -57,31 +52,10 @@ class Ecwid_OAuth {
57
 
58
  $redirect_uri = 'admin-post.php?action=' . $action;
59
 
60
- $params = array(
61
- 'scopes' => implode(' ', $this->_get_scope()),
62
- 'redirect_uri' => admin_url( $redirect_uri )
63
  );
64
-
65
- if ( !is_array( $params )
66
- || empty( $params['scopes'] )
67
- ) {
68
- return false;
69
- }
70
-
71
- $url = 'https://my.ecwid.com/api/oauth/authorize';
72
-
73
- $query = array();
74
-
75
- $query['source'] = 'wporg';
76
- $query['client_id'] = self::OAUTH_CLIENT_ID;
77
- $query['redirect_uri'] = $params['redirect_uri'];
78
- $query['response_type'] = 'code';
79
- $query['scope'] = $params['scopes'];
80
- foreach ($query as $key => $value) {
81
- $query[$key] = urlencode($value);
82
- }
83
-
84
- return $url . '?' . build_query( $query );
85
  }
86
 
87
  public function process_authorization()
@@ -102,8 +76,8 @@ class Ecwid_OAuth {
102
  $base_admin_url = 'admin-post.php?action=ecwid_oauth' . ($reconnect ? '_reconnect' : '');
103
 
104
  $params['code'] = $_REQUEST['code'];
105
- $params['client_id'] = self::OAUTH_CLIENT_ID;
106
- $params['client_secret'] = self::OAUTH_CLIENT_SECRET;
107
  $params['redirect_uri'] = admin_url( $base_admin_url );
108
 
109
  $params['grant_type'] = 'authorization_code';
@@ -128,8 +102,7 @@ class Ecwid_OAuth {
128
  Ecwid_Kissmetrics::record( $reconnect ? 'accountReconnected' : 'accountConnected' );
129
  update_option( 'ecwid_store_id', $result->store_id );
130
  update_option( 'ecwid_oauth_scope', $result->scope );
131
- $this->_init_crypt();
132
- $this->_save_token($result->access_token);
133
 
134
  // Reset "Create store cookie" set previously to display the landing page
135
  //in "Connect" mode rather than "Create" mode
@@ -152,7 +125,7 @@ class Ecwid_OAuth {
152
  public function disconnect_store()
153
  {
154
  update_option( 'ecwid_store_id', ECWID_DEMO_STORE_ID );
155
- update_option( 'ecwid_oauth_token', '' );
156
  update_option( 'ecwid_is_api_enabled', 'off' );
157
  update_option( 'ecwid_api_check_time', 0 );
158
 
@@ -225,15 +198,6 @@ class Ecwid_OAuth {
225
  exit;
226
  }
227
 
228
- public function get_oauth_token()
229
- {
230
- if ($this->is_initialized()) {
231
- return $this->_load_token();
232
- }
233
-
234
- return null;
235
- }
236
-
237
  protected function _get_scope() {
238
  $default = $this->_get_default_scopes_array();
239
 
@@ -249,46 +213,15 @@ class Ecwid_OAuth {
249
  return $scopes;
250
  }
251
 
252
- public function is_initialized()
253
- {
254
- return get_option( self::TOKEN_OPTION_NAME );
255
- }
256
-
257
- protected function _save_token($token)
258
- {
259
- $value = base64_encode($this->crypt->encrypt($token));
260
-
261
- update_option(self::TOKEN_OPTION_NAME, $value);
262
- }
263
-
264
- protected function _load_token()
265
- {
266
-
267
- $db_value = get_option(self::TOKEN_OPTION_NAME);
268
- if (empty($db_value)) return false;
269
-
270
- if (strlen($db_value) == 64) {
271
- $encrypted = base64_decode($db_value);
272
- if (empty($encrypted)) return false;
273
-
274
- $token = $this->crypt->decrypt($encrypted);
275
- } else {
276
- $token = $db_value;
277
- }
278
-
279
- return $token;
280
- }
281
-
282
-
283
  public function get_sso_admin_link() {
284
  $url = 'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&inline=true';
285
 
286
  $store_id = get_ecwid_store_id();
287
 
288
- $token = $this->get_oauth_token();
289
 
290
  $timestamp = time();
291
- $signature = hash('sha256', $store_id . $token . $timestamp . self::OAUTH_CLIENT_SECRET);
292
 
293
  $url = sprintf(
294
  $url,
@@ -301,11 +234,6 @@ class Ecwid_OAuth {
301
  return $url;
302
  }
303
 
304
- public function _init_crypt() {
305
- $this->crypt->setIV( substr( md5( SECURE_AUTH_SALT . get_option('ecwid_store_id') ), 0, 16 ) );
306
- $this->crypt->setKey( SECURE_AUTH_KEY );
307
- }
308
-
309
  protected function _load_state() {
310
  if (isset($_COOKIE['ecwid_oauth_state'])) {
311
  $this->state = @unserialize( $_COOKIE['ecwid_oauth_state'] );
1
  <?php
2
 
3
  include ECWID_PLUGIN_DIR . "lib/phpseclib/AES.php";
4
+ require_once ECWID_PLUGIN_DIR . 'lib/ecwid_api_v3.php';
5
 
6
  class Ecwid_OAuth {
7
 
 
 
 
 
 
8
  const MODE_CONNECT = 'connect';
9
  const MODE_RECONNECT = 'reconnect';
10
 
 
 
11
  protected $state;
12
 
13
+ protected $api;
14
+
15
  public function __construct()
16
  {
17
  add_action('admin_post_ecwid_oauth', array($this, 'process_authorization'));
19
  add_action('admin_post_ecwid_disconnect', array($this, 'disconnect_store'));
20
  add_action('admin_post_ecwid_show_reconnect', array($this, 'show_reconnect'));
21
 
 
 
 
22
  $this->_load_state();
23
+
24
+ $this->api = new Ecwid_Api_V3(get_ecwid_store_id());
25
  }
26
 
27
  public function show_reconnect()
52
 
53
  $redirect_uri = 'admin-post.php?action=' . $action;
54
 
55
+ return $this->api->get_oauth_dialog_url(
56
+ admin_url( $redirect_uri ),
57
+ implode(' ', $this->_get_scope() )
58
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
 
61
  public function process_authorization()
76
  $base_admin_url = 'admin-post.php?action=ecwid_oauth' . ($reconnect ? '_reconnect' : '');
77
 
78
  $params['code'] = $_REQUEST['code'];
79
+ $params['client_id'] = Ecwid_Api_V3::CLIENT_ID;
80
+ $params['client_secret'] = Ecwid_Api_V3::CLIENT_SECRET;
81
  $params['redirect_uri'] = admin_url( $base_admin_url );
82
 
83
  $params['grant_type'] = 'authorization_code';
102
  Ecwid_Kissmetrics::record( $reconnect ? 'accountReconnected' : 'accountConnected' );
103
  update_option( 'ecwid_store_id', $result->store_id );
104
  update_option( 'ecwid_oauth_scope', $result->scope );
105
+ $this->api->save_token($result->access_token);
 
106
 
107
  // Reset "Create store cookie" set previously to display the landing page
108
  //in "Connect" mode rather than "Create" mode
125
  public function disconnect_store()
126
  {
127
  update_option( 'ecwid_store_id', ECWID_DEMO_STORE_ID );
128
+ $this->api->save_token( '' );
129
  update_option( 'ecwid_is_api_enabled', 'off' );
130
  update_option( 'ecwid_api_check_time', 0 );
131
 
198
  exit;
199
  }
200
 
 
 
 
 
 
 
 
 
 
201
  protected function _get_scope() {
202
  $default = $this->_get_default_scopes_array();
203
 
213
  return $scopes;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  public function get_sso_admin_link() {
217
  $url = 'https://my.ecwid.com/api/v3/%s/sso?token=%s&timestamp=%s&signature=%s&inline=true';
218
 
219
  $store_id = get_ecwid_store_id();
220
 
221
+ $token = $this->api->get_token();
222
 
223
  $timestamp = time();
224
+ $signature = hash('sha256', $store_id . $token . $timestamp . Ecwid_Api_V3::CLIENT_SECRET);
225
 
226
  $url = sprintf(
227
  $url,
234
  return $url;
235
  }
236
 
 
 
 
 
 
237
  protected function _load_state() {
238
  if (isset($_COOKIE['ecwid_oauth_state'])) {
239
  $this->state = @unserialize( $_COOKIE['ecwid_oauth_state'] );
includes/class-ecwid-sitemap-builder.php CHANGED
@@ -63,7 +63,8 @@ class EcwidSitemapBuilder implements JsonStreamingParser_Listener {
63
  $callback,
64
  ecwid_get_entity_url($obj, $this->type == 'products' ? 'p' : 'c'),
65
  $this->type == 'products' ? 0.6 : 0.5,
66
- 'weekly'
 
67
  );
68
  }
69
  }
@@ -79,8 +80,10 @@ class EcwidSitemapBuilder implements JsonStreamingParser_Listener {
79
  }
80
 
81
  public function value($value) {
82
- if ($this->_key == 'url') {
83
- $this->_stack[0]['url'] = $value;
 
 
84
  }
85
  }
86
  }
63
  $callback,
64
  ecwid_get_entity_url($obj, $this->type == 'products' ? 'p' : 'c'),
65
  $this->type == 'products' ? 0.6 : 0.5,
66
+ 'weekly',
67
+ $obj
68
  );
69
  }
70
  }
80
  }
81
 
82
  public function value($value) {
83
+ $params = array('url', 'originalImageUrl', 'name');
84
+
85
+ if (in_array($this->_key, $params)) {
86
+ $this->_stack[0][$this->_key] = $value;
87
  }
88
  }
89
  }
includes/oembed.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ add_filter('embed_content', 'ecwid_oembed_content', 10, 1);
4
+
5
+ function ecwid_oembed_content($data)
6
+ {
7
+ echo ecwid_get_embed_content();
8
+ }
9
+
10
+ function ecwid_get_embed_content()
11
+ {
12
+
13
+ $html = '';
14
+ $root_category_id = 0;
15
+
16
+ $post_content = get_post(get_the_ID())->post_content;
17
+ $shortcodes = ecwid_find_shortcodes($post_content, 'ecwid');
18
+
19
+ if (!$shortcodes || !isset($shortcodes[0]) || !isset($shortcodes[0][3])) {
20
+ return;
21
+ }
22
+
23
+ $attributes = $shortcodes[0][3];
24
+ if (!preg_match('/default_category_id=.([\\d]*)./', $attributes, $matches)) {
25
+ return;
26
+ }
27
+
28
+ $root_category_id = 0;
29
+ if (!is_numeric($matches[1])) {
30
+ return;
31
+ } else if (isset($matches[1])) {
32
+ $root_category_id = $matches[1];
33
+ }
34
+
35
+ $categories = ecwid_get_categories();
36
+
37
+ if ($root_category_id != 0) {
38
+ $categories = _ecwid_find_category_in_horizontal_categories_tree($categories, $root_category_id);
39
+ }
40
+
41
+ $max_items = 5;
42
+
43
+ $items = array();
44
+
45
+ $see_more = false;
46
+ $result = '';
47
+ if (!empty($categories)) {
48
+ foreach ($categories as $category) {
49
+ $url = ecwid_get_category_url(array('id' => $category->id, 'url' => $category->link));
50
+ $items[$url] = $category->name;
51
+ if (count($items) >= $max_items) {
52
+ $see_more = true;
53
+ break;
54
+ }
55
+ }
56
+ }
57
+
58
+ if (ecwid_is_paid_account()) {
59
+ $api = new Ecwid_Api_V3(get_ecwid_store_id());
60
+
61
+ $category = $api->get_category($root_category_id);
62
+
63
+ if ($category) {
64
+ $trimmed = ecwid_trim_description($category->description);
65
+ $result .= '<div>' . ecwid_trim_description($category->description);
66
+
67
+ if (mb_strlen($trimmed) < mb_strlen($category->description) && mb_strlen($trimmed) == ECWID_TRIMMED_DESCRIPTION_LENGTH) {
68
+ $result .= '... <a class="wp-embed-more" href="' . get_page_link(get_post(get_the_ID())) . '">' . __('See more', 'ecwid-shopping-cart') . '</a>';
69
+ }
70
+ $result .= '</div>';
71
+ }
72
+
73
+ if (!$see_more) {
74
+ $products = $api->get_products(array( 'category' => $root_category_id ));
75
+
76
+ if ($products) {
77
+ foreach ($products as $product) {
78
+ $url = ecwid_get_product_url(array( 'id' => $product->id, 'url' => $product->url ));
79
+ $items[$url] = $product->name;
80
+ if (count($items) >= $max_items) {
81
+ $see_more = TRUE;
82
+ break;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+
89
+ $result .= '<ul>';
90
+ if ($items) {
91
+ foreach ($items as $url => $title) {
92
+ $result .= '<li><a href="' . esc_attr($url) . '">' . esc_html($title) . '</a></li>';
93
+ }
94
+ }
95
+
96
+ if ($see_more) {
97
+ $result .= '<li><a class="wp-embed-more" href="' . get_page_link(get_post(get_the_ID())) . '">' . __('See more', 'ecwid-shopping-cart') . '</a></li>';
98
+ }
99
+
100
+ $result .= '</ul>';
101
+ return $result;
102
+ }
103
+
104
+ function _ecwid_find_category_in_horizontal_categories_tree($categories, $root_id) {
105
+ foreach($categories as $category) {
106
+ if ($category->id == $root_id) {
107
+ return $category->sub;
108
+ }
109
+
110
+ if (!is_null($category->sub)) {
111
+ $result = _ecwid_find_category_in_horizontal_categories_tree($category->sub, $root_id);
112
+ if ($result !== false) {
113
+ return $result;
114
+ }
115
+ }
116
+ }
117
+ return false;
118
+ }
119
+
includes/themes.php CHANGED
@@ -50,7 +50,9 @@ function ecwid_apply_theme($theme_name = null)
50
  'mantra',
51
  'attitude',
52
  'responsiveboat',
53
- 'central'
 
 
54
  );
55
 
56
 
50
  'mantra',
51
  'attitude',
52
  'responsiveboat',
53
+ 'central',
54
+ 'edin',
55
+ 'accesspress-mag'
56
  );
57
 
58
 
includes/themes/class-ecwid-theme-accesspress-mag.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_AccessPressMag extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'AccessPress Mag';
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+
13
+ wp_enqueue_style( 'ecwid-theme-fixes' , plugins_url( 'ecwid-shopping-cart/css/themes/accesspress-mag.css' ), array('accesspress-mag-style'), get_option('ecwid_plugin_version'), 'all' );
14
+ }
15
+ }
16
+
17
+ $ecwid_current_theme = new Ecwid_Theme_AccessPressMag();
includes/themes/class-ecwid-theme-edin.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_Edin extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'Edin';
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+
13
+ if (ecwid_page_has_productbrowser()) {
14
+ wp_enqueue_script( 'ecwid-theme', plugins_url( 'ecwid-shopping-cart/js/themes/edin.js' ), array( 'jquery' ), get_option('ecwid_plugin_version') );
15
+ }
16
+ }
17
+ }
18
+
19
+ $ecwid_current_theme = new Ecwid_Theme_Edin();
js/admin.js CHANGED
@@ -136,4 +136,8 @@
136
  });
137
  }
138
  }
 
 
 
 
139
  });
136
  });
137
  }
138
  }
139
+
140
+ jQuery('#wp-admin-bar-ecwid-main-default a').click(function() {
141
+ ecwid_kissmetrics_record('Top Menu Clicked');
142
+ });
143
  });
js/kissmetrics.js CHANGED
@@ -2,17 +2,37 @@ if ( typeof ecwid_kissmetrics.store_id != 'undefined' ) {
2
  _kmq.push([ 'identify', ecwid_kissmetrics.store_id ] );
3
  }
4
 
5
- for (var i = 0; i < ecwid_kissmetrics.events.length; i++) {
6
- _kmq.push( [ 'record', ecwid_kissmetrics.events[i].event ] );
7
- }
8
 
9
  function ecwid_kissmetrics_record(event) {
10
- if (typeof this.fired == 'undefined') {
11
- this.fired = [];
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- if (this.fired.indexOf(event) != -1) return;
15
 
16
- _kmq.push( [ 'record', 'wp-plugin ' + event ] );
17
- this.fired.push(event);
18
- }
 
 
 
2
  _kmq.push([ 'identify', ecwid_kissmetrics.store_id ] );
3
  }
4
 
 
 
 
5
 
6
  function ecwid_kissmetrics_record(event) {
7
+ if (typeof this.fired == 'undefined') {
8
+ this.fired = [];
9
+ }
10
+
11
+ if (this.fired.indexOf(event) != -1) return;
12
+
13
+ ecwid_kissmetrics.events.push({event: event});
14
+ this.fired.push(event);
15
+
16
+ ecwid_kissmetrics_flush();
17
+ }
18
+
19
+ function ecwid_kissmetrics_flush() {
20
+ if (typeof _kmq == 'undefined') {
21
+ return;
22
+ }
23
+
24
+ for (var i = 0; i < ecwid_kissmetrics.events.length; i++) {
25
+ _kmq.push( [ 'record', ecwid_kissmetrics.events[i].event ] );
26
+ }
27
+
28
+ ecwid_kissmetrics.events = [];
29
+ }
30
 
31
+ jQuery(document).ready(function() {
32
 
33
+ jQuery.getScript('https://i.kissmetrics.com/i.js', function() {
34
+ jQuery.getScript('https://scripts.kissmetrics.com/' + ecwid_kissmetrics.key + '.2.js', function() {
35
+ ecwid_kissmetrics_flush();
36
+ })
37
+ });
38
+ });
js/nav-menu.js CHANGED
@@ -7,6 +7,10 @@ jQuery(document).ready(function() {
7
  'ecwid-store-with-categories': 'storeWithCategories'
8
  };
9
 
 
 
 
 
10
  processEcwidLinks = function(element) {
11
 
12
  var ecwidLink = findEcwidLink(element);
@@ -15,24 +19,24 @@ jQuery(document).ready(function() {
15
  if (jQuery(element).hasClass('ecwid-link')) return;
16
 
17
  jQuery(element).addClass('ecwid-link');
18
- jQuery(element).find('.item-type').text(ecwid_l10n.store_page);
19
 
20
  if (isStoreWithCategories(element)) {
21
 
22
  var $message = jQuery('<p>')
23
  .addClass('ecwid-store-with-cats-message')
24
- .text(ecwid_l10n.reset_cache_message)
25
  .insertAfter(jQuery('.field-move', element));
26
 
27
  $target = jQuery('<p class="ecwid-store-with-cats-reset-cache">').insertAfter($message);
28
 
29
  jQuery('<span>')
30
- .text(ecwid_l10n.cache_updated)
31
  .addClass('ecwid-reset-categories-cache-updated')
32
  .appendTo($target);
33
 
34
  jQuery('<a>')
35
- .text(ecwid_l10n.reset_cats_cache)
36
  .attr('href', 'javascript:void(0);')
37
  .addClass('ecwid-reset-categories-cache')
38
  .appendTo($target)
7
  'ecwid-store-with-categories': 'storeWithCategories'
8
  };
9
 
10
+ if (ecwid_params.first_run && jQuery('#ecwid_nav_links-hide:checked').length == 0) {
11
+ jQuery('#ecwid_nav_links-hide').click();
12
+ }
13
+
14
  processEcwidLinks = function(element) {
15
 
16
  var ecwidLink = findEcwidLink(element);
19
  if (jQuery(element).hasClass('ecwid-link')) return;
20
 
21
  jQuery(element).addClass('ecwid-link');
22
+ jQuery(element).find('.item-type').text(ecwid_params.store_page);
23
 
24
  if (isStoreWithCategories(element)) {
25
 
26
  var $message = jQuery('<p>')
27
  .addClass('ecwid-store-with-cats-message')
28
+ .text(ecwid_params.reset_cache_message)
29
  .insertAfter(jQuery('.field-move', element));
30
 
31
  $target = jQuery('<p class="ecwid-store-with-cats-reset-cache">').insertAfter($message);
32
 
33
  jQuery('<span>')
34
+ .text(ecwid_params.cache_updated)
35
  .addClass('ecwid-reset-categories-cache-updated')
36
  .appendTo($target);
37
 
38
  jQuery('<a>')
39
+ .text(ecwid_params.reset_cats_cache)
40
  .attr('href', 'javascript:void(0);')
41
  .addClass('ecwid-reset-categories-cache')
42
  .appendTo($target)
js/themes/edin.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+
3
+ jQuery('.ecwid-store-with-categories a').click(function() {
4
+ jQuery('button.menu-toggle.open').click()
5
+ })
6
+
7
+ });
languages/ecwid-shopping-cart-ru_RU.mo CHANGED
Binary file
languages/ecwid-shopping-cart-ru_RU.po CHANGED
@@ -214,8 +214,8 @@ msgstr "Секретный ключ системы единой авториза
214
  msgid "Single Sign-On Secret Key is an option that allows your customers access to your WordPress site as well as the Ecwid shopping cart. When customers log in to your site, they will automatically be logged in to your Ecwid store as well. It makes sense to enable this feature if your visitors actually create accounts in your WordPress website."
215
  msgstr "Эта функция позволяет включить систему единой авторизации: когда покупатели вошли в свой аккаунт на вашем сайте, они автоматически входят в свой Эквид-аккаунт, даже если раньше у них его не было. Эта функция может быть полезна в случае, если ваши посетители создают свои аккаунты на вашем сайте."
216
 
217
- msgid "In order to enable this feature, opt to use a secret key. You will find this key in your Ecwid control panel, at \"System Settings > Apps > Legacy API Keys > Single Sign-On Secret Key\" page. This feature is available for <a href=\"http://www.ecwid.com/compare-plans.html\" target=\"_blank\">paid users</a> only."
218
- msgstr "Чтобы включить эту функцию, вам необходимо ввести секретный ключ. Его можно найти в панели управления Эквида в секции \"Настройки > Apps > Legacy API Keys > Секретный ключ SSO\". Эта функция доступна только пользователям с <a href=\"http://www.ecwid.com/compare-plans.html\" target=\"_blank\">платным аккаунтом</a>."
219
 
220
  msgid "Save changes"
221
  msgstr "Сохранить изменения"
@@ -527,4 +527,16 @@ msgid "Report a problem with the store"
527
  msgstr "Сообщить о проблеме"
528
 
529
  msgid "https://help.ecwid.com"
530
- msgstr "https://help.ecwid.com/customer/ru/portal/articles"
 
 
 
 
 
 
 
 
 
 
 
 
214
  msgid "Single Sign-On Secret Key is an option that allows your customers access to your WordPress site as well as the Ecwid shopping cart. When customers log in to your site, they will automatically be logged in to your Ecwid store as well. It makes sense to enable this feature if your visitors actually create accounts in your WordPress website."
215
  msgstr "Эта функция позволяет включить систему единой авторизации: когда покупатели вошли в свой аккаунт на вашем сайте, они автоматически входят в свой Эквид-аккаунт, даже если раньше у них его не было. Эта функция может быть полезна в случае, если ваши посетители создают свои аккаунты на вашем сайте."
216
 
217
+ msgid "To enable this feature, copy the Single Sign On Secret key from the store control panel to the input above. You can find the key on the \"<a href=\"https://my.ecwid.com/cp/CP.html#legacy_api\" target=\"_blank\">Legacy API Keys</a>\" page. This feature is available for <a href=\"https://www.ecwid.com/pricing\" target=\"_blank\">paid users</a> only."
218
+ msgstr "Чтобы включить эту функцию, скопируйте секретный ключ из панели управления магазином в текстовое поле выше. Ключ можно найти на странице \"<a href=\"https://my.ecwid.com/cp/CP.html#legacy_api\" target=\"_blank\">Ключи для предыдущей версии API</a>\". Эта функция доступна только пользователям с <a href=\"https://www.ecwid.com/pricing\" target=\"_blank\">платным аккаунтом</a>."
219
 
220
  msgid "Save changes"
221
  msgstr "Сохранить изменения"
527
  msgstr "Сообщить о проблеме"
528
 
529
  msgid "https://help.ecwid.com"
530
+ msgstr "https://help.ecwid.com/customer/ru/portal/articles"
531
+
532
+ msgid "Download log file"
533
+ msgstr "Скачать лог-файл"
534
+
535
+ msgid "See more"
536
+ msgstr "Посмотреть все"
537
+
538
+ msgid "Read FAQ"
539
+ msgstr "Посмотреть FAQ"
540
+
541
+ msgid "https://help.ecwid.com/customer/portal/articles/1085017-wordpress-downloadable"
542
+ msgstr "https://help.ecwid.com/customer/ru/portal/articles/1085017-wordpress-org"
lib/ecwid_api_v3.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . '/ecwid_platform.php';
4
+
5
+ class Ecwid_Api_V3
6
+ {
7
+ const CLIENT_ID = 'RD4o2KQimiGUrFZc';
8
+ const CLIENT_SECRET = 'jEPVdcA3KbzKVrG8FZDgNnsY3wKHDTF8';
9
+
10
+ const TOKEN_OPTION_NAME = 'ecwid_oauth_token';
11
+
12
+ public $store_id = null;
13
+
14
+ public function __construct($store_id) {
15
+
16
+ $this->store_id = $store_id;
17
+ $this->_api_url = ' https://app.ecwid.com/api/v3/';
18
+ $this->_stores_api_url = $this->_api_url . 'stores';
19
+
20
+ $this->_categories_api_url = $this->_api_url . $this->store_id . '/categories';
21
+ $this->_products_api_url = $this->_api_url . $this->store_id . '/products';
22
+ }
23
+
24
+ public function is_api_available()
25
+ {
26
+ $token = $this->_load_token();
27
+ if ( $token ) {
28
+ return true;
29
+ }
30
+ }
31
+
32
+ public static function save_token($token)
33
+ {
34
+ EcwidPlatform::init_crypt(true);
35
+
36
+ $value = base64_encode(EcwidPlatform::encrypt($token));
37
+
38
+ update_option(self::TOKEN_OPTION_NAME, $value);
39
+ }
40
+
41
+ public function get_categories($input_params)
42
+ {
43
+ $params = array('token');
44
+ if (array_key_exists('parent', $input_params)) {
45
+ $params['parent'] = $input_params['parent'];
46
+ }
47
+
48
+ $result = EcwidPlatform::fetch_url(
49
+ $this->build_request_url(
50
+ $this->_categories_api_url,
51
+ $params
52
+ )
53
+ );
54
+
55
+ if ($result['code'] != '200') {
56
+ return false;
57
+ }
58
+
59
+ $result = json_decode($result['data']);
60
+
61
+ return $result->items;
62
+ }
63
+
64
+ public function get_category($categoryId)
65
+ {
66
+ if (!isset($categoryId)) {
67
+ return false;
68
+ }
69
+
70
+ $params = array('token');
71
+
72
+ $result = EcwidPlatform::fetch_url(
73
+ $this->build_request_url(
74
+ $this->_categories_api_url . '/' . $categoryId,
75
+ $params
76
+ )
77
+ );
78
+
79
+ if ($result['code'] != '200') {
80
+ return false;
81
+ }
82
+
83
+ $result = json_decode($result['data']);
84
+
85
+ return $result;
86
+ }
87
+
88
+ public function get_products($input_params)
89
+ {
90
+ $params = array('token');
91
+ if (array_key_exists('category', $input_params)) {
92
+ $params['category'] = $input_params['category'];
93
+ }
94
+
95
+ $result = EcwidPlatform::fetch_url(
96
+ $this->build_request_url(
97
+ $this->_products_api_url,
98
+ $params
99
+ )
100
+ );
101
+
102
+ if ($result['code'] != '200') {
103
+ return false;
104
+ }
105
+
106
+ $result = json_decode($result['data']);
107
+
108
+ return $result->items;
109
+ }
110
+
111
+ protected static function _load_token()
112
+ {
113
+ $db_value = get_option(self::TOKEN_OPTION_NAME);
114
+ if (empty($db_value)) return false;
115
+
116
+ if (strlen($db_value) == 64) {
117
+ $encrypted = base64_decode($db_value);
118
+ if (empty($encrypted)) return false;
119
+
120
+ $token = EcwidPlatform::decrypt($encrypted);
121
+ } else {
122
+ $token = $db_value;
123
+ }
124
+
125
+ return $token;
126
+ }
127
+
128
+ public static function get_token()
129
+ {
130
+ return self::_load_token();
131
+ }
132
+
133
+ public function get_oauth_dialog_url($redirect_uri, $scope)
134
+ {
135
+ if ( !$scope || !$redirect_uri ) {
136
+ return null;
137
+ }
138
+
139
+ $url = 'https://my.ecwid.com/api/oauth/authorize';
140
+
141
+ $query = array();
142
+
143
+ $query['source'] = 'wporg';
144
+ $query['client_id'] = self::CLIENT_ID;
145
+ $query['redirect_uri'] = $redirect_uri;
146
+ $query['response_type'] = 'code';
147
+ $query['scope'] = $scope;
148
+
149
+ foreach ($query as $key => $value) {
150
+ $query[$key] = urlencode($value);
151
+ }
152
+
153
+ return $url . '?' . build_query( $query );
154
+ }
155
+
156
+ public function does_store_exist($email)
157
+ {
158
+ $params = array(
159
+ 'appClientId',
160
+ 'appSecretKey',
161
+ 'email' => $email
162
+ );
163
+
164
+ $url = $this->build_request_url($this->_stores_api_url, $params);
165
+
166
+ $result = EcwidPlatform::fetch_url($url);
167
+
168
+ return @$result['code'] == 200;
169
+ }
170
+
171
+ public function create_store($params)
172
+ {
173
+ $request_params = array(
174
+ 'appClientId',
175
+ 'appSecretKey',
176
+ 'returnApiToken' => 'true'
177
+ );
178
+ $url = $this->build_request_url($this->_stores_api_url, $request_params);
179
+
180
+ return $url;
181
+
182
+ $result = EcwidPlatform::http_post_request($url, $params);
183
+
184
+ return $result;
185
+ }
186
+
187
+ protected function build_request_url($url, $params)
188
+ {
189
+ foreach ($params as $key => $param) {
190
+ if ( $param == 'appClientId' ) {
191
+ unset($params[$key]);
192
+ $params['appClientId'] = self::CLIENT_ID;
193
+ } elseif ( $param == 'appSecretKey' ) {
194
+ unset($params[$key]);
195
+ $params['appSecretKey'] = self::CLIENT_SECRET;
196
+ } elseif ($param == 'token') {
197
+ unset($params[$key]);
198
+ $params['token'] = self::get_token();
199
+ } else {
200
+ $params[$key] = urlencode($param);
201
+ }
202
+ }
203
+
204
+ return $url . '?' . build_query($params);
205
+ }
206
+ }
lib/ecwid_platform.php CHANGED
@@ -4,6 +4,36 @@ class EcwidPlatform {
4
 
5
  static protected $http_use_streams = false;
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  static public function esc_attr($value)
8
  {
9
  return esc_attr($value);
@@ -19,6 +49,21 @@ class EcwidPlatform {
19
  return __('Price', 'ecwid-shopping-cart');
20
  }
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  static public function fetch_url($url)
23
  {
24
  $use_file_get_contents = get_option('ecwid_fetch_url_use_file_get_contents', false);
@@ -100,6 +145,29 @@ class EcwidPlatform {
100
  return $result;
101
  }
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  static public function http_api_transports($transports)
104
  {
105
  if (self::$http_use_streams) {
@@ -108,6 +176,7 @@ class EcwidPlatform {
108
 
109
  return $transports;
110
  }
 
111
  }
112
 
113
  add_filter('http_api_transports', array('EcwidPlatform', 'http_api_transports'));
4
 
5
  static protected $http_use_streams = false;
6
 
7
+ static protected $crypt = null;
8
+
9
+ static public function init_crypt($force = false)
10
+ {
11
+ if ( $force || is_null(self::$crypt) ) {
12
+ self::$crypt = new Ecwid_Crypt_AES();
13
+ self::_init_crypt();
14
+ }
15
+ }
16
+
17
+ static protected function _init_crypt()
18
+ {
19
+ self::$crypt->setIV( substr( md5( SECURE_AUTH_SALT . get_option('ecwid_store_id') ), 0, 16 ) );
20
+ self::$crypt->setKey( SECURE_AUTH_KEY );
21
+ }
22
+
23
+ static public function encrypt($what)
24
+ {
25
+ self::init_crypt();
26
+
27
+ return self::$crypt->encrypt($what);
28
+ }
29
+
30
+ static public function decrypt($what)
31
+ {
32
+ self::init_crypt();
33
+
34
+ return self::$crypt->decrypt($what);
35
+ }
36
+
37
  static public function esc_attr($value)
38
  {
39
  return esc_attr($value);
49
  return __('Price', 'ecwid-shopping-cart');
50
  }
51
 
52
+ static public function cache_get($name)
53
+ {
54
+ get_transient('ecwid_' . $name);
55
+ }
56
+
57
+ static public function cache_set($name, $value, $expires_after)
58
+ {
59
+ set_transient('ecwid_' . $name, $value, $expires_after);
60
+ }
61
+
62
+ static public function parse_args($args, $defaults)
63
+ {
64
+ return wp_parse_args($args, $defaults);
65
+ }
66
+
67
  static public function fetch_url($url)
68
  {
69
  $use_file_get_contents = get_option('ecwid_fetch_url_use_file_get_contents', false);
145
  return $result;
146
  }
147
 
148
+ static public function get( $name, $default = null )
149
+ {
150
+ $options = get_option( 'ecwid_plugin_data' );
151
+
152
+ if ( is_array( $options ) && array_key_exists( $name, $options ) ) {
153
+ return $options[$name];
154
+ }
155
+
156
+ return $default;
157
+ }
158
+
159
+ static public function set( $name, $value ) {
160
+ $options = get_option( 'ecwid_plugin_data' );
161
+
162
+ if ( !is_array( $options ) ) {
163
+ $options = array();
164
+ }
165
+
166
+ $options[$name] = $value;
167
+
168
+ update_option( 'ecwid_plugin_data', $options );
169
+ }
170
+
171
  static public function http_api_transports($transports)
172
  {
173
  if (self::$http_use_streams) {
176
 
177
  return $transports;
178
  }
179
+
180
  }
181
 
182
  add_filter('http_api_transports', array('EcwidPlatform', 'http_api_transports'));
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Ecwid Shopping Cart ===
2
  Contributors: ecwid
3
- Tags: ecwid, shopping cart, ecommerce, paypal, e-commerce, online store, store, shop, cart, digital goods, downloadable products, product catalog, facebook
4
  Requires at least: 3.5
5
  Tested up to: 4.4
6
- Stable tag: 4.1
7
 
8
  Ecwid is a full-featured shopping cart that can be added to any Wordpress site in less than 5 minutes. Start using Ecwid for free today.
9
 
@@ -104,6 +104,17 @@ http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
104
  * [Ecwid site](http://www.ecwid.com/?source=wporg-plugin-site "Ecwid Site")
105
 
106
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
107
  = 4.0.7 =
108
  - **Fixed a problem with connecting to the Ecwid API on the servers with misconfigured or outdated CURL.** Some servers couldn't connect to Ecwid from to display the Ecwid Control Panel inside Wordpress backend. That caused a "Connection problem" error message, which some of Ecwid users saw in their Wordpress admin section. We added a fix that should resolve this problem and make the Ecwid Control Panel inside Wordpress work OK for those users.
109
  - Improvements for the new drop-down categories store menu added in the version 4 of the plugin. If you haven't tried it yet, go check it out in the Appearance -> Menus settings of your site.
1
  === Ecwid Shopping Cart ===
2
  Contributors: ecwid
3
+ Tags: ecwid, shopping cart, ecommerce, wordpress ecommerce, wp e-commerce, paypal, e-commerce, online store, store, shop, cart, online shop, shopping, digital goods, downloadable products, product catalog, ecomerce, products, facebook, f-commerce
4
  Requires at least: 3.5
5
  Tested up to: 4.4
6
+ Stable tag: 4.1.1
7
 
8
  Ecwid is a full-featured shopping cart that can be added to any Wordpress site in less than 5 minutes. Start using Ecwid for free today.
9
 
104
  * [Ecwid site](http://www.ecwid.com/?source=wporg-plugin-site "Ecwid Site")
105
 
106
  == Changelog ==
107
+ = 4.1.1 =
108
+ - **Layout improvements for the Accesspress-mag theme.** Accesspress-mag theme users might notice slight glitches in the store buttons. We fixed those.
109
+ - **Added the page default category dropdown for free users.** When you add a store on your site page, you can set the store category to be displayed on that page. This "default category" tool was previously just a text input where you were supposed to put the category ID, if you're on free Ecwid plan. Now it's a dropdown menu so you can easily select a store category for each page. It's very useful if you want to display different categories on different pages of your site.
110
+ - Minor bug fixes and improvements
111
+
112
+ = 4.1 =
113
+ - **Product images are included in the sitemap generated by the Yoast SEO plugin.** Ecwid is integrated with popular SEO plugins: Yoast SEO and Google XML Sitemaps, which allows merchants to generate a sitemap containing the links to their products and categories. Now, the sitemaps generated by Yoast SEO will also automatically include links to the product images. This will make Google better index your products pictures and list them in the search results.
114
+ - **Ecwid plugin now supports oEmbed discovery.** As of version 4.4, WordPress supports oEmbed. In short, that's a tool which makes a link to a post or a page of your site looks nice when pasted on another site supporting this. Ecwid now supports it too, so if you paste a link to your store page on any other oEmbed-empowered site (e.g. another Wordpress site), it will automatically displays a nice widget with the page title and a list of your store categories.
115
+ - Fixes and improvements for the storefront widgets and for the plugins admin pages.
116
+
117
+
118
  = 4.0.7 =
119
  - **Fixed a problem with connecting to the Ecwid API on the servers with misconfigured or outdated CURL.** Some servers couldn't connect to Ecwid from to display the Ecwid Control Panel inside Wordpress backend. That caused a "Connection problem" error message, which some of Ecwid users saw in their Wordpress admin section. We added a fix that should resolve this problem and make the Ecwid Control Panel inside Wordpress work OK for those users.
120
  - Improvements for the new drop-down categories store menu added in the version 4 of the plugin. If you haven't tried it yet, go check it out in the Appearance -> Menus settings of your site.
templates/admin-footer.php CHANGED
@@ -1,8 +1,10 @@
 
1
  <?php if (@$show_reconnect): ?>
2
 
3
- <p><?php echo sprintf(__('If you want to connect another Ecwid store, you can re-connect on <a %s>this page</a>', 'ecwid-shopping-cart'), 'href=admin.php?page=ecwid&reconnect'); ?></p>
4
 
5
  <?php endif; ?>
6
 
7
  <p><?php echo sprintf(__('Questions? <a %s>Read FAQ</a> or contact support at <a %s>wordpress@ecwid.com</a>', 'ecwid-shopping-cart'), 'target="_blank" href="https://help.ecwid.com/customer/portal/articles/1085017-wordpress-downloadable#FAQ"', 'href="mailto:wordpress@ecwid.com"'); ?></p>
8
 
 
1
+ <div class="ecwid-admin-footer">
2
  <?php if (@$show_reconnect): ?>
3
 
4
+ <p><?php echo sprintf(__('If you want to connect another Ecwid store, you can re-connect on <a %s>this page</a>', 'ecwid-shopping-cart'), 'href="admin.php?page=ecwid&reconnect"'); ?></p>
5
 
6
  <?php endif; ?>
7
 
8
  <p><?php echo sprintf(__('Questions? <a %s>Read FAQ</a> or contact support at <a %s>wordpress@ecwid.com</a>', 'ecwid-shopping-cart'), 'target="_blank" href="https://help.ecwid.com/customer/portal/articles/1085017-wordpress-downloadable#FAQ"', 'href="mailto:wordpress@ecwid.com"'); ?></p>
9
 
10
+ </div>
templates/advanced-settings.php CHANGED
@@ -79,7 +79,7 @@
79
  <?php _e('Single Sign-On Secret Key is an option that allows your customers access to your WordPress site as well as the Ecwid shopping cart. When customers log in to your site, they will automatically be logged in to your Ecwid store as well. It makes sense to enable this feature if your visitors actually create accounts in your WordPress website.', 'ecwid-shopping-cart'); ?>
80
  </div>
81
  <div class="note grayed-links">
82
- <?php _e('In order to enable this feature, opt to use a secret key. You will find this key in your Ecwid control panel, at "System Settings > Apps > Legacy API Keys > Single Sign-On Secret Key" page. This feature is available for <a href="http://www.ecwid.com/compare-plans.html" target="_blank">paid users</a> only.', 'ecwid-shopping-cart'); ?>
83
  </div>
84
  </div>
85
 
79
  <?php _e('Single Sign-On Secret Key is an option that allows your customers access to your WordPress site as well as the Ecwid shopping cart. When customers log in to your site, they will automatically be logged in to your Ecwid store as well. It makes sense to enable this feature if your visitors actually create accounts in your WordPress website.', 'ecwid-shopping-cart'); ?>
80
  </div>
81
  <div class="note grayed-links">
82
+ <?php _e('To enable this feature, copy the Single Sign On Secret key from the store control panel to the input above. You can find the key on the "<a href="https://my.ecwid.com/cp/CP.html#legacy_api" target="_blank">Legacy API Keys</a>" page. This feature is available for <a href="https://www.ecwid.com/pricing" target="_blank">paid users</a> only.', 'ecwid-shopping-cart'); ?>
83
  </div>
84
  </div>
85
 
templates/appearance-settings.php CHANGED
@@ -222,5 +222,5 @@
222
  </div>
223
 
224
  <script type="text/javascript">
225
- ecwid_kissmetrics_record('Advanced Page Viewed');
226
  </script>
222
  </div>
223
 
224
  <script type="text/javascript">
225
+ ecwid_kissmetrics_record('Appearance Page Viewed');
226
  </script>
templates/debug.php CHANGED
@@ -11,6 +11,8 @@
11
  $all_options = wp_load_alloptions();
12
  ?>
13
 
 
 
14
  <h2>Active plugins</h2>
15
 
16
  <div>
11
  $all_options = wp_load_alloptions();
12
  ?>
13
 
14
+ <a class="button button-primary" href="admin-post.php?action=ecwid_get_debug" style="margin-top:10px"><?php _e('Download log file', 'ecwid-shopping-cart'); ?></a>
15
+
16
  <h2>Active plugins</h2>
17
 
18
  <div>
templates/ecwid-admin.php CHANGED
@@ -1,5 +1,7 @@
1
  <script type='text/javascript'>//<![CDATA[
2
- window.onload=function(){
 
 
3
  $ = jQuery;
4
  // Create IE + others compatible event handler
5
  var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
@@ -12,11 +14,9 @@
12
  $('#superwrap').css('height', (e.data.height) + 'px');
13
  },false);
14
 
15
- $(document).ready(function(){
16
- $('#ecwid-frame').attr('src', '<?php echo $iframe_src; ?>');
17
- });
18
-
19
- }//]]>
20
 
21
  </script>
22
 
1
  <script type='text/javascript'>//<![CDATA[
2
+ document.body.className += ' ecwid-no-padding';
3
+
4
+ jQuery(document).ready(function(){
5
  $ = jQuery;
6
  // Create IE + others compatible event handler
7
  var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
14
  $('#superwrap').css('height', (e.data.height) + 'px');
15
  },false);
16
 
17
+ $('#ecwid-frame').attr('src', '<?php echo $iframe_src; ?>');
18
+ });
19
+ //]]>
 
 
20
 
21
  </script>
22
 
templates/landing.php CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  <div class="ecwid-landing <?php echo $register ? 'register' : 'connect'; echo $connection_error ? ' conn-error': ''; ?>">
2
  <div class="ecwid-thank">
3
  <h1 class="on-register">
1
+ <script type='text/javascript'>//<![CDATA[
2
+ document.body.className += ' ecwid-no-padding';
3
+ //]]>
4
+ </script>
5
  <div class="ecwid-landing <?php echo $register ? 'register' : 'connect'; echo $connection_error ? ' conn-error': ''; ?>">
6
  <div class="ecwid-thank">
7
  <h1 class="on-register">
templates/store-popup.php CHANGED
@@ -149,46 +149,30 @@
149
 
150
  <div class="pure-control-group params-list default-category-id">
151
 
152
- <?php if (ecwid_is_paid_account()): ?>
153
- <?php if ($categories): ?>
154
- <label for="ecwid_default_category_id">
155
- <?php _e('Category shown by default', 'ecwid-shopping-cart'); ?>
156
- </label>
157
-
158
-
159
- <div class="value">
160
-
161
- <select name="default_category_id" id="ecwid_default_category_id">
162
- <option value=""><?php _e('Store root category', 'ecwid-shopping-cart'); ?></option>
163
- <?php foreach ($categories as $category): ?>
164
- <option
165
- value="<?php echo esc_attr($category['id']); ?>"
166
- <?php if ($category['id'] == get_option('ecwid_default_category_id')): ?>
167
- selected="selected"
168
- <?php endif; ?>
169
- >
170
- <?php echo esc_html($category['path_str']); ?>
171
- </option>
172
- <?php endforeach; ?>
173
- </select>
174
- </div>
175
-
176
- <?php endif; ?>
177
- <?php else: ?>
178
-
179
- <label for="ecwid_default_category_id">
180
- <?php _e('Default category ID', 'ecwid-shopping-cart'); ?>
181
- </label>
182
-
183
- <input
184
- id="ecwid_default_category_id"
185
- name="ecwid_default_category_id"
186
- type="text"
187
- placeholder="<?php _e('Default category ID', 'ecwid-shopping-cart'); ?>"
188
- value="<?php echo esc_attr(get_option('ecwid_default_category_id')) ?>"
189
- />
190
- <?php endif; ?>
191
 
 
192
  </div>
193
 
194
  <div class="pure-control-group params-list">
149
 
150
  <div class="pure-control-group params-list default-category-id">
151
 
152
+ <?php if ($categories): ?>
153
+ <label for="ecwid_default_category_id">
154
+ <?php _e('Category shown by default', 'ecwid-shopping-cart'); ?>
155
+ </label>
156
+
157
+
158
+ <div class="value">
159
+
160
+ <select name="default_category_id" id="ecwid_default_category_id">
161
+ <option value=""><?php _e('Store root category', 'ecwid-shopping-cart'); ?></option>
162
+ <?php foreach ($categories as $category): ?>
163
+ <option
164
+ value="<?php echo esc_attr($category->id); ?>"
165
+ <?php if ($category->id == get_option('ecwid_default_category_id')): ?>
166
+ selected="selected"
167
+ <?php endif; ?>
168
+ >
169
+ <?php echo esc_html($category->path); ?>
170
+ </option>
171
+ <?php endforeach; ?>
172
+ </select>
173
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
+ <?php endif; ?>
176
  </div>
177
 
178
  <div class="pure-control-group params-list">