Ecwid Ecommerce Shopping Cart - Version 2.7

Version Description

  • A brand new 'Add store' tool in WordPress editor toolbar. Ecwid is now integrated with WordPress WYSIWYG editor: click the 'Add Store' button in the page editor toolbar, chose widgets to show, adjust the appearance and place your store on any page of your site. Now you can decide what store widgets to show and configure store appearance right in the page editor.
  • New "[ecwid]" shortcode. The new shortcode allows you to control every aspect of your store appearance by means of tweaking the shortcode parameters right in the store page code. Display/hide the search widget, choose the minicart layout you like, display different store categories on different site pages and so on. This shortcode serves the "Add Store" button mentioned above and almost every tweak is available in the new "Add Store" window so you don't have to edit any code in most cases. Still, an advanced Wordpress user may consider using shortcodes for more flexible and quick integration.
  • Improved behavior of single product widgets. If you put a single product widget on your site using the [ecwid_product] shortcode, you might notice that it opens a popup with the customer cart when a customer purchases the product. Now single product widgets are smarter: when the customer decides to buy a product and opens a cart page, the main store page on your site will be opened providing the customer with the built-in cart&checkout functionality. The checkout layout will fit better your site design and provide better buying experience when it's embedded into a page rather than in a popup-like window.
  • Fix for the Envision theme. The Envision theme didn't display Ecwid widgets properly because of a custom page content generation it uses. We issued a workaround from our side to let all Envision users install and use Ecwid plugin on their sites. If you use Envision theme and want to set up an online store on your site, go ahead and install Ecwid plugin, it will work OK for you.
  • Fixes of PHP notices. Some of Ecwid users discovered a few PHP notices (warnings) on their site referring to the Ecwid plugin. Although those didn't break anything, they could be quite annoying. We cleaned up the plugin code to get rid of those warning messages, now the plugin should work without any odd message.
Download this release

Release Info

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

Code changes from version 2.6 to 2.7

css/admin.css CHANGED
@@ -106,6 +106,9 @@ div.ecwid-message {
106
  width: 100%;
107
  }
108
 
 
 
 
109
 
110
  .ecwid-message .ecwid-message-hide:not(:hover) {
111
  color: #bbb;
@@ -142,4 +145,4 @@ div.ecwid-message {
142
 
143
  .ecwid-message.dev .ecwid-message-hide {
144
  letter-spacing: -0.22px;
145
- }
106
  width: 100%;
107
  }
108
 
109
+ .ecwid-message .ecwid-message-buttons > div a{
110
+ text-decoration: none;
111
+ }
112
 
113
  .ecwid-message .ecwid-message-hide:not(:hover) {
114
  color: #bbb;
145
 
146
  .ecwid-message.dev .ecwid-message-hide {
147
  letter-spacing: -0.22px;
148
+ }
css/page-editor.css ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mce-content-body img.ecwid-store-editor,
2
+ .mceContentBody img.ecwid-store-editor
3
+ {
4
+ padding-top: 30px;
5
+ background: #F1F1F1;
6
+ border: 1px solid #E7E7E7;
7
+ height: 200px;
8
+ width: 100%;
9
+ display: block;
10
+ }
11
+
12
+ .mce-content-body .ecwid-store-editor[data-ecwid-store-select="1"],
13
+ .mceContentBody .ecwid-store-editor[data-ecwid-store-select="1"]
14
+ {
15
+ outline: 1px solid #777;
16
+ }
17
+
18
+ #ecwid-store-toolbar {
19
+ position: absolute;
20
+ }
21
+
22
+ #ecwid-store-toolbar div {
23
+ margin-top: 7px;
24
+ margin-left: 7px;
25
+ padding: 2px;
26
+ width: 30px;
27
+ height: 30px;
28
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
29
+ background-color: #000;
30
+ background-color: rgba(0, 0, 0, 0.9);
31
+ cursor: pointer;
32
+ color: #FFF;
33
+ font-size: 30px;
34
+ }
35
+
36
+
37
+
38
+ #ecwid-edit-store-button {
39
+ padding: 0 12px 2px;
40
+ height: 30px;
41
+ line-height: 28px;
42
+
43
+ font-size: 12px;
44
+
45
+ background: #2EA2CC;
46
+ color: #FFF;
47
+
48
+ border: 1px solid #0074A2;
49
+ border-radius: 3px;
50
+ box-shadow: inset 0 1px 0 rgba(120, 200, 230, 0.5), 0 1px 0 rgba(0, 0, 0, 0.15);
51
+
52
+ cursor: pointer;
53
+ }
54
+
55
+
56
+ #ecwid-edit-store-button:hover {
57
+ background: #1E8CBE;
58
+ }
css/store-popup.css ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ecwid-store-icon {
2
+ padding-right: 3px;
3
+ position: relative;
4
+ display: inline-block;
5
+ width: 16px;
6
+ top: 3px;
7
+ height: 16px;
8
+ max-height: 16px;
9
+ }
10
+
11
+ .ecwid-store-icon svg * {
12
+ fill: #888;
13
+ }
14
+
15
+ #ecwid-store-popup-content {
16
+ display: none;
17
+ }
18
+
19
+ #ecwid-store-popup-content a {
20
+ text-decoration: none;
21
+ }
22
+
23
+ #ecwid-store-popup-content .media-frame-content {
24
+ }
25
+
26
+ #ecwid-store-popup-content.open {
27
+ display: block;
28
+ }
29
+
30
+ .wp-media-buttons:not(.has-ecwid) .update-ecwid {
31
+ display: none;
32
+ }
33
+
34
+ .wp-media-buttons.has-ecwid .add-ecwid {
35
+ display: none;
36
+ }
37
+
38
+ #ecwid-store-popup-content .media-modal-close:hover {
39
+ text-decoration: none;
40
+ }
41
+
42
+ /*
43
+ * Menu items visibility
44
+ */
45
+ #ecwid-store-popup-content .media-modal-content .media-menu a {
46
+ display: none
47
+ }
48
+
49
+ #ecwid-store-popup-content .media-modal-content[data-mode=store-settings] .media-menu a[data-content=store-settings],
50
+ #ecwid-store-popup-content .media-modal-content[data-mode=add-store] .media-menu a[data-content=add-store],
51
+ #ecwid-store-popup-content .media-modal-content .media-menu a[data-content=appearance]
52
+ {
53
+ display: inherit;
54
+ }
55
+
56
+ body[class*=branch-3] #ecwid-store-popup-content .media-frame-title span.dashicons {
57
+ display: none;
58
+ }
59
+ /*
60
+ * Content area visibility
61
+ */
62
+ #ecwid-store-popup-content .media-modal-content .media-frame-title,
63
+ #ecwid-store-popup-content .media-modal-content .media-frame-content,
64
+ #ecwid-store-popup-content .media-modal-content .media-toolbar-primary
65
+ {
66
+ display: none;
67
+ }
68
+
69
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=add-store] .media-frame-title.add-store,
70
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=add-store] .media-frame-content.store-settings,
71
+
72
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=store-settings] .media-frame-title.store-settings,
73
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=store-settings] .media-frame-content.store-settings,
74
+
75
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=appearance] .media-frame-title.appearance,
76
+ #ecwid-store-popup-content .media-modal-content[data-active-dialog=appearance] .media-frame-content.appearance,
77
+
78
+ #ecwid-store-popup-content .media-modal-content[data-mode=add-store] .media-frame-toolbar .media-toolbar-primary.add-store,
79
+ #ecwid-store-popup-content .media-modal-content[data-mode=store-settings] .media-frame-toolbar .media-toolbar-primary.store-settings
80
+ {
81
+ display: inherit;
82
+ }
83
+
84
+ /*
85
+ * Size and centering
86
+ */
87
+
88
+ @media only screen and (min-width: 960px) and (min-height: 660px) {
89
+
90
+ html:not(.ie8) #ecwid-store-popup-content .media-modal-content {
91
+ position: absolute;
92
+ width: 900px;
93
+ height: 650px;
94
+ top: 50%;
95
+ left: 50%;
96
+ right: inherit;
97
+ bottom: inherit;
98
+ transform: translate(-50%,-50%);
99
+ -moz-transform: translate(-50%,-50%);
100
+ -ms-transform: translate(-50%,-50%);
101
+ -webkit-transform: translate(-50%,-50%);
102
+ }
103
+ }
104
+
105
+ @media only screen and (min-width: 960px) and (min-height: 400px) and (max-height: 660px) {
106
+
107
+ html:not(.ie8) #ecwid-store-popup-content .media-modal-content {
108
+ position: absolute;
109
+ width: 900px;
110
+ left: 50%;
111
+ right: inherit;
112
+ transform: translate(-50%,0%);
113
+ -moz-transform: translate(-50%,0%);
114
+ -ms-transform: translate(-50%,0%);
115
+ -webkit-transform: translate(-50%,0%);
116
+ }
117
+ }
118
+
119
+ @media only screen and (min-width: 640px) and (max-width: 960px) and (min-height: 660px) {
120
+
121
+ html:not(.ie8) #ecwid-store-popup-content .media-modal-content {
122
+ position: absolute;
123
+ height: 650px;
124
+ top: 50%;
125
+ bottom: inherit;
126
+ transform: translate(0%,-50%);
127
+ -moz-transform: translate(0%,-50%);
128
+ -ms-transform: translate(0%,-50%);
129
+ -webkit-transform: translate(0%,-50%);
130
+ }
131
+ }
132
+
133
+ @media only screen and (max-width: 750px) {
134
+ #ecwid-store-popup-content .store-settings-preview {
135
+ display: none !important;
136
+ }
137
+
138
+ #ecwid-store-popup-content .store-settings-wrapper {
139
+ padding-left: 0px;
140
+ }
141
+ }
142
+
143
+ html:not(.ie8) #ecwid-store-popup-content .store-settings-wrapper {
144
+ position: absolute;
145
+ top: 50%;
146
+ transform: translate(0%,-50%);
147
+ -moz-transform: translate(0%,-50%);
148
+ -ms-transform: translate(0%,-50%);
149
+ -webkit-transform: translate(0%,-50%);
150
+ }
151
+ /*
152
+ *
153
+ */
154
+ .ecwid-store-editor {
155
+ padding: 13px 19px;
156
+ }
157
+
158
+ #ecwid-store-popup-content .pure-control-group {
159
+ margin: 10px 0px;
160
+ }
161
+
162
+ #ecwid-store-popup-content label {
163
+ font-size: 14px;
164
+ font-weight: 400;
165
+ display: inline-block;
166
+ width: 270px;
167
+ }
168
+
169
+ #ecwid-store-popup-content .products-per-page-label {
170
+ display: block;
171
+ }
172
+
173
+ #ecwid-store-popup-content .ecwid-pb-view-size {
174
+ margin-left: 15px;
175
+ margin-right: 30px;
176
+ margin-top: 15px;
177
+ }
178
+
179
+ #ecwid-store-popup-content .ecwid-pb-view-size:nth-child(4) {
180
+ margin-right: 0px;
181
+ }
182
+
183
+
184
+ #ecwid-store-popup-content .ecwid-pb-view-size .title {
185
+ font-size: 14px;
186
+ }
187
+
188
+ #ecwid-store-popup-content .ecwid-pb-view-size .ruler {
189
+ z-index: 0;
190
+ }
191
+
192
+ #ecwid-store-popup-content input {
193
+ position: relative;
194
+ font-size: 13px;
195
+ }
196
+
197
+ #ecwid-store-popup-content input.number {
198
+ border-radius: 4px;
199
+ width: 27px;
200
+ padding: 3px;
201
+ text-align: center;
202
+ }
203
+
204
+ #ecwid-store-popup-content .note.pb-note {
205
+ max-width: 595px;
206
+ font-size: 11px;
207
+ margin: 8px 5px;
208
+ line-height: 16px;
209
+ }
210
+
211
+ #ecwid-store-popup-content hr.after-pb {
212
+ margin-bottom: 25px;
213
+ }
214
+
215
+ #ecwid-store-popup-content .media-toolbar-secondary {
216
+ font-size: 14px;
217
+ margin-left:5px;
218
+ }
219
+
220
+ #ecwid-store-popup-content .media-toolbar-secondary .store-id {
221
+ margin-top: 10px;
222
+ font-weight: bold;
223
+ }
224
+
225
+
226
+ #ecwid-store-popup-content .ecwid-store-editor.add-store {
227
+ padding-top: 125px;
228
+ }
229
+
230
+ #ecwid-store-popup-content .store-settings-preview {
231
+ display: inline-block;
232
+ width: 162px;
233
+ height: 200px;
234
+ }
235
+
236
+ #ecwid-store-popup-content .store-settings,
237
+ #ecwid-store-popup-content .store-settings-preview
238
+ {
239
+ vertical-align: top;
240
+ display: inline-block;
241
+ }
242
+
243
+ #ecwid-store-popup-content .store-settings h3 {
244
+ font-size: 20px;
245
+ margin-bottom: 5px;
246
+ }
247
+
248
+ #ecwid-store-popup-content .store-settings-preview {
249
+ width: 145px;
250
+ margin-top: 17px;
251
+ position: relative;
252
+ }
253
+
254
+ #ecwid-store-popup-content .store-settings-preview label {
255
+ position: absolute;
256
+ background: transparent;
257
+ cursor: pointer;
258
+ display: inline-block;
259
+ }
260
+
261
+ #ecwid-store-popup-content .store-settings .note {
262
+ margin-right: 30px;
263
+ }
264
+
265
+ #ecwid-store-popup-content .note {
266
+ color: #BBBBBB;
267
+ }
268
+
269
+ #ecwid-store-popup-content .store-settings-preview .ecwid-search {
270
+ top: 0px;
271
+ width: 45px;
272
+ height: 45px;
273
+ }
274
+
275
+ #ecwid-store-popup-content .store-settings-preview .ecwid-minicart {
276
+ top: 0px;
277
+ right: 0px;
278
+ width: 45px;
279
+ height: 45px;
280
+ }
281
+
282
+ #ecwid-store-popup-content .store-settings-preview .ecwid-categories {
283
+ top: 45px;
284
+ width: 100%;
285
+ height: 20px;
286
+ }
287
+
288
+ #ecwid-store-popup-content .store-settings-wrapper path {
289
+ fill: #d1ecf5;
290
+ }
291
+
292
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=categories] path.categories,
293
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=minicart] path.minicart,
294
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=search] path.search,
295
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-categories[data-ecwid-widget-hover=categories] path.categories,
296
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-minicart[data-ecwid-widget-hover=minicart] path.minicart,
297
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-search[data-ecwid-widget-hover=search] path.search
298
+ {
299
+ fill: #56d5ff;
300
+ }
301
+
302
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-categories path.categories,
303
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-minicart path.minicart,
304
+ #ecwid-store-popup-content .store-settings-wrapper.ecwid-search path.search,
305
+ #ecwid-store-popup-content .store-settings-wrapper path.productbrowser
306
+ {
307
+ fill: #298cba;
308
+ }
309
+
310
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=categories] label[data-ecwid-widget=categories],
311
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=minicart] label[data-ecwid-widget=minicart],
312
+ #ecwid-store-popup-content .store-settings-wrapper[data-ecwid-widget-hover=search] label[data-ecwid-widget=search]
313
+ {
314
+ color: #40c1ec;
315
+ }
316
+
317
+ #ecwid-store-popup-content .media-frame-content.store-settings {
318
+ padding-left: 43px;
319
+ }
320
+
321
+ #ecwid-store-popup-content .media-frame-content .store-settings-wrapper .store-settings {
322
+ padding-left: 43px;
323
+ }
324
+
325
+ #ecwid-store-popup-content .store-settings .pure-control-group {
326
+ margin: 20px 0px;
327
+ }
328
+
329
+ #ecwid-store-popup-content .store-settings .pure-control-group label {
330
+ font-size: 16px;
331
+ color: black;
332
+ font-weight: 400;
333
+ }
334
+
335
+ #ecwid-store-popup-content .appearance label {
336
+ font-weight: 600;
337
+ }
338
+
339
+ #ecwid-store-popup-content .pure-control-group.default-category-id {
340
+ display: table;
341
+ }
342
+
343
+ #ecwid-store-popup-content .pure-control-group.default-category-id label {
344
+ width: 270px;
345
+ min-width: 270px;
346
+ max-width: 270px;
347
+ display: table-cell;
348
+ }
349
+
350
+ #ecwid-store-popup-content .pure-control-group.default-category-id .value {
351
+ display: table-cell;
352
+ }
353
+
354
+ #ecwid-store-popup-content .pure-control-group.default-category-id .value select,
355
+ #ecwid-store-popup-content .pure-control-group.default-category-id .value input {
356
+ width:100%;
357
+ }
358
+
359
+
360
+ @media only screen and (max-width: 440px) {
361
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list {
362
+ margin: 35px 0px;
363
+ position: relative;
364
+ }
365
+
366
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list select,
367
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list input {
368
+ width: 100%;
369
+ }
370
+
371
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list label,
372
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list .value {
373
+ display: inline-block;
374
+ width: 100%;
375
+ }
376
+
377
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list input#ecwid_pb_categoriesperrow {
378
+ width: 27px;
379
+ position: absolute;
380
+ right: 0px;
381
+ }
382
+
383
+ #ecwid-store-popup-content .media-frame-content .store-settings-wrapper .store-settings {
384
+ padding-left: 0px;
385
+ }
386
+
387
+
388
+ #ecwid-store-popup-content .appearance .pure-control-group.params-list label {
389
+ width: auto;
390
+ min-width: inherit;
391
+ max-width: inherit;
392
+ }
393
+ }
394
+
395
+ #ecwid-store-popup-content .store-settings .pure-control-group input[type=checkbox] {
396
+ margin-right: 15px;
397
+ }
398
+
399
+ @media only screen and (max-width: 640px) {
400
+ #ecwid-store-popup-content .note.pb-note {
401
+ width: auto;
402
+ text-align: left;
403
+ }
404
+
405
+ #ecwid-store-popup-content .pb-views {
406
+ text-align: center;
407
+ }
408
+
409
+
410
+ #ecwid-store-popup-content .appearance input.number {
411
+ margin-left: inherit;
412
+ }
413
+
414
+ #ecwid-store-popup-content .ecwid-pb-view-size {
415
+ margin-left: 25px;
416
+ margin-right: 25px;
417
+ }
418
+
419
+ #ecwid-store-popup-content .media-frame-content .store-settings-wrapper {
420
+ padding-left: 0px;
421
+ }
422
+ }
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: 2.6
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
@@ -47,12 +47,14 @@ if ( is_admin() ){
47
  add_action('admin_head', 'ecwid_send_stats');
48
  add_action('save_post', 'ecwid_save_post');
49
  add_action('init', 'ecwid_apply_theme');
 
50
  } else {
51
  add_shortcode('ecwid_script', 'ecwid_script_shortcode');
52
  add_shortcode('ecwid_minicart', 'ecwid_minicart_shortcode');
53
  add_shortcode('ecwid_searchbox', 'ecwid_searchbox_shortcode');
54
  add_shortcode('ecwid_categories', 'ecwid_categories_shortcode');
55
  add_shortcode('ecwid_product', 'ecwid_product_shortcode');
 
56
  add_action('init', 'ecwid_backward_compatibility');
57
  add_action('send_headers', 'ecwid_503_on_store_closed');
58
  add_action('template_redirect', 'ecwid_seo_compatibility_template_redirect');
@@ -77,8 +79,10 @@ add_action('admin_bar_menu', 'add_ecwid_admin_bar_node', 1000);
77
 
78
  $ecwid_script_rendered = false; // controls single script.js on page
79
 
80
- require_once plugin_dir_path(__FILE__) . '/lib/themes.php';
81
- require_once plugin_dir_path(__FILE__) . '/lib/class-ecwid-message-manager.php';
 
 
82
 
83
  $version = get_bloginfo('version');
84
 
@@ -242,7 +246,7 @@ function ecwid_build_sitemap_pages()
242
  $page_id = ecwid_get_current_store_page_id();
243
 
244
  if (get_post_status($page_id) == 'publish') {
245
- include ECWID_PLUGIN_DIR . '/lib/EcwidSitemapBuilder.php';
246
 
247
  $sitemap = new EcwidSitemapBuilder(ecwid_get_store_page_url(), 'build_sitemap_callback', ecwid_new_product_api());
248
 
@@ -417,19 +421,41 @@ function add_ecwid_admin_bar_node() {
417
  );
418
  }
419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  function ecwid_page_has_productbrowser($post_id = null)
421
  {
422
- static $results = null;
423
 
424
  if (is_null($post_id)) {
425
  $post_id = get_the_ID();
426
  }
427
 
428
- if (is_null($results[$post_id])) {
429
- $post_content = get_post($post_id)->post_content;
430
- $results[$post_id] = has_shortcode($post_content, 'ecwid_productbrowser');
431
 
432
- $results[$post_id] = apply_filters( 'ecwid_page_has_productbrowser', $results[$post_id] );
 
433
  }
434
 
435
  return $results[$post_id];
@@ -620,10 +646,10 @@ function ecwid_content_started($content)
620
 
621
  function ecwid_wrap_shortcode_content($content, $name)
622
  {
623
- return "<!-- Ecwid shopping cart plugin v 2.6 -->"
624
  . ecwid_get_scriptjs_code()
625
  . "<div class=\"ecwid-shopping-cart-$name\">$content</div>"
626
- . "<!-- END Ecwid Shopping Cart v 2.6 -->";
627
  }
628
 
629
  function ecwid_get_scriptjs_code($force_lang = null) {
@@ -657,17 +683,36 @@ function ecwid_script_shortcode($params) {
657
  return ecwid_wrap_shortcode_content($content, 'script');
658
  }
659
 
660
- function ecwid_minicart_shortcode($params) {
 
 
 
 
 
 
 
 
 
 
 
 
661
 
662
- $ecwid_enable_minicart = get_option('ecwid_enable_minicart');
663
- $ecwid_show_categories = get_option('ecwid_show_categories');
 
 
 
 
 
 
664
 
665
  $result = '';
666
- if (!empty($ecwid_enable_minicart) && !empty($ecwid_show_categories)) {
667
- $result = <<<EOT
668
- <script type="text/javascript"> xMinicart("style=","layout=attachToCategories"); </script>
 
669
  EOT;
670
- }
671
 
672
  $result = apply_filters('ecwid_minicart_shortcode_content', $result);
673
 
@@ -678,14 +723,22 @@ EOT;
678
  return $result;
679
  }
680
 
681
- function ecwid_searchbox_shortcode() {
 
 
 
 
 
 
 
 
682
 
683
- $ecwid_show_search_box = get_option('ecwid_show_search_box');
684
- if (!empty($ecwid_show_search_box)) {
685
- $result = <<<EOT
686
  <script type="text/javascript"> xSearchPanel("style="); </script>
687
  EOT;
688
- }
689
 
690
  $result = apply_filters('ecwid_search_shortcode_content', $result);
691
 
@@ -696,16 +749,22 @@ EOT;
696
  return $result;
697
  }
698
 
699
- function ecwid_categories_shortcode() {
 
 
 
 
 
 
700
 
701
- $ecwid_show_categories = get_option('ecwid_show_categories');
702
 
703
  $result = '';
704
- if (!empty($ecwid_show_categories)) {
705
- $result = <<<EOT
706
  <script type="text/javascript"> xCategories("style="); </script>
707
  EOT;
708
- }
709
 
710
  $result = apply_filters('ecwid_categories_shortcode_content', $result);
711
 
@@ -768,6 +827,7 @@ function ecwid_product_shortcode($shortcode_attributes) {
768
 
769
  $result .= '</div>';
770
 
 
771
  $result .= '<script type="text/javascript">xSingleProduct()</script>';
772
 
773
  update_option('ecwid_single_product_used', time());
@@ -775,37 +835,87 @@ function ecwid_product_shortcode($shortcode_attributes) {
775
  return ecwid_wrap_shortcode_content($result, 'product');
776
  }
777
 
778
- function ecwid_parse_escaped_fragment($escaped_fragment) {
779
- $fragment = urldecode($escaped_fragment);
780
- $return = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
781
 
782
- if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) {
783
- parse_str($matches[3], $return);
784
- $return['mode'] = $matches[2];
785
- } elseif (preg_match('!.*/(p|c)/([0-9]*)!', $fragment, $matches)) {
786
- if (count($matches) == 3 && in_array($matches[1], array('p', 'c'))) {
787
- $return = array(
788
- 'mode' => 'p' == $matches[1] ? 'product' : 'category',
789
- 'id' => $matches[2]
790
- );
791
  }
792
  }
793
 
794
- return $return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  }
796
 
797
  function ecwid_productbrowser_shortcode($shortcode_params) {
798
- global $ecwid_seo_product_title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  $store_id = get_ecwid_store_id();
800
  $list_of_views = array('list','grid','table');
801
 
802
- $ecwid_pb_categoriesperrow = get_option('ecwid_pb_categoriesperrow');
803
- $ecwid_pb_productspercolumn_grid = get_option('ecwid_pb_productspercolumn_grid');
804
- $ecwid_pb_productsperrow_grid = get_option('ecwid_pb_productsperrow_grid');
805
- $ecwid_pb_productsperpage_list = get_option('ecwid_pb_productsperpage_list');
806
- $ecwid_pb_productsperpage_table = get_option('ecwid_pb_productsperpage_table');
807
- $ecwid_pb_defaultview = get_option('ecwid_pb_defaultview');
808
- $ecwid_pb_searchview = get_option('ecwid_pb_searchview');
809
 
810
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
811
  $ecwid_default_category_id =
@@ -836,23 +946,18 @@ function ecwid_productbrowser_shortcode($shortcode_params) {
836
  $ecwid_pb_searchview = 'list';
837
  }
838
 
839
- if (empty($ecwid_mobile_catalog_link)) {
840
- $ecwid_mobile_catalog_link = "http://" . APP_ECWID_COM . "/jsp/{$store_id}/catalog";
841
- }
842
-
843
- if (empty($ecwid_default_category_id)) {
844
  $ecwid_default_category_str = '';
845
  } else {
846
  $ecwid_default_category_str = ',"defaultCategoryId='. $ecwid_default_category_id .'"';
847
  }
848
 
849
- $ecwid_open_product = '';
850
  $plain_content = '';
851
 
852
  if (ecwid_can_display_html_catalog()) {
853
  $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
854
  include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/ecwid_product_api.php';
855
- include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/EcwidCatalog.php';
856
 
857
  $page_url = get_page_link();
858
 
@@ -894,10 +999,29 @@ EOT;
894
  }
895
 
896
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
897
  function ecwid_store_activate() {
898
  $my_post = array();
899
  $content = <<<EOT
900
- <!-- Ecwid code. Please do not remove this line otherwise your Ecwid shopping cart will not work properly. --> [ecwid_minicart] [ecwid_searchbox] [ecwid_categories] [ecwid_productbrowser] <!-- Ecwid code end -->
901
  EOT;
902
  add_option("ecwid_store_page_id", '', '', 'yes');
903
  add_option("ecwid_store_page_id_auto", '', '', 'yes');
@@ -930,6 +1054,7 @@ EOT;
930
 
931
  add_option("ecwid_installation_date", time());
932
 
 
933
  // Does not affect updates, automatically turned on for new users only
934
  add_option("ecwid_advanced_theme_layout", get_option('ecwid_store_id') == ECWID_DEMO_STORE_ID ? 'Y' : 'N', 'yes');
935
 
@@ -1003,6 +1128,7 @@ function ecwid_abs_intval($value) {
1003
 
1004
  function ecwid_options_add_page() {
1005
 
 
1006
 
1007
  add_menu_page(
1008
  __('Ecwid shopping cart settings', 'ecwid-shopping-cart'),
@@ -1012,32 +1138,42 @@ function ecwid_options_add_page() {
1012
  'ecwid_general_settings_do_page'
1013
  );
1014
 
 
 
 
 
 
 
1015
  add_submenu_page(
1016
  'ecwid',
1017
- __('General settings', 'ecwid-shopping-cart'),
1018
- __('General', 'ecwid-shopping-cart'),
1019
  'manage_options',
1020
  'ecwid',
1021
  'ecwid_general_settings_do_page'
1022
  );
1023
 
1024
- add_submenu_page(
1025
- 'ecwid',
1026
- __('Appearance settings', 'ecwid-shopping-cart'),
1027
- __('Appearance', 'ecwid-shopping-cart'),
1028
- 'manage_options',
1029
- 'ecwid-appearance',
1030
- 'ecwid_appearance_settings_do_page'
1031
- );
 
 
1032
 
1033
- add_submenu_page(
1034
- 'ecwid',
1035
- __('Advanced settings', 'ecwid-shopping-cart'),
1036
- __('Advanced', 'ecwid-shopping-cart'),
1037
- 'manage_options',
1038
- 'ecwid-advanced',
1039
- 'ecwid_advanced_settings_do_page'
1040
- );
 
 
1041
  //add_options_page('Ecwid shopping cart settings', 'Ecwid shopping cart', 'manage_options', 'ecwid_options_page', 'ecwid_options_do_page');
1042
  }
1043
 
@@ -1089,7 +1225,7 @@ function ecwid_settings_api_init() {
1089
 
1090
  case 'general':
1091
  register_setting('ecwid_options_page', 'ecwid_store_id','ecwid_abs_intval' );
1092
- if (intval($_POST['ecwid_store_id']) == 0) {
1093
  Ecwid_Message_Manager::reset_hidden_messages();
1094
  }
1095
  break;
@@ -1109,23 +1245,24 @@ function ecwid_settings_api_init() {
1109
 
1110
  function ecwid_common_admin_scripts() {
1111
 
1112
- wp_register_script('ecwid-admin-js', plugins_url('ecwid-shopping-cart/js/admin.js'), array(), '', '');
1113
- wp_enqueue_script('ecwid-admin-js');
 
 
 
1114
 
1115
- wp_register_script('ecwid-modernizr-js', plugins_url('ecwid-shopping-cart/js/modernizr.js'), array(), '', '');
1116
- wp_enqueue_script('ecwid-modernizr-js');
1117
  }
1118
 
1119
  function ecwid_general_settings_do_page() {
1120
 
1121
  if (get_ecwid_store_id() == ECWID_DEMO_STORE_ID) {
1122
- require_once plugin_dir_path(__FILE__) . '/templates/general-settings-initial.php';
1123
  } else {
1124
- require_once plugin_dir_path(__FILE__) . '/templates/general-settings.php';
1125
  }
1126
  }
1127
 
1128
- function ecwid_advanced_settings_do_page() {
1129
  $categories = false;
1130
  if (ecwid_is_paid_account()) {
1131
  $api = ecwid_new_product_api();
@@ -1141,7 +1278,7 @@ function ecwid_advanced_settings_do_page() {
1141
  while (is_array($category) && isset($category['parentId'])) {
1142
  $name = '';
1143
  if (isset($by_id[$category['parentId']])) {
1144
- $name = $by_id[$category['parentId']]['name'];
1145
  } else {
1146
  $name = __('Hidden category', 'ecwid-shopping-cart');
1147
  }
@@ -1162,6 +1299,12 @@ function ecwid_advanced_settings_do_page() {
1162
  $categories = $by_id;
1163
  }
1164
 
 
 
 
 
 
 
1165
  require_once plugin_dir_path(__FILE__) . '/templates/advanced-settings.php';
1166
  }
1167
 
@@ -1680,7 +1823,41 @@ function ecwid_gather_stats()
1680
  'default_category',
1681
  'google_xml_sitemaps_used',
1682
  'ecwid_product_advisor_used',
1683
- 'ecwid_single_product_used'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1684
  );
1685
 
1686
  $usage_stats = array();
@@ -1698,17 +1875,9 @@ function ecwid_gather_stats()
1698
  $usage_stats['google_xml_sitemaps_used'] = (bool) is_plugin_active('google-sitemap-generator/sitemap.php');
1699
  $usage_stats['ecwid_product_advisor_used'] = (bool) is_plugin_active('ecwid-useful-tools/ecwid-product-advisor.php');
1700
  $usage_stats['ecwid_single_product_used'] = (bool) (get_option('ecwid_single_product_used') + 60*60*24*14 > time());
 
1701
 
1702
- $stats['usage'] = '';
1703
-
1704
- $usage = '';
1705
- foreach ($usage_params as $index => $item) {
1706
- $usage[$index] = (int)$usage_stats[$item];
1707
- }
1708
-
1709
- $stats['usage'] = $usage_version . '_' . implode('', $usage);
1710
-
1711
- return $stats;
1712
  }
1713
 
1714
  function ecwid_sidebar_widgets_init() {
@@ -1721,18 +1890,6 @@ function ecwid_sidebar_widgets_init() {
1721
 
1722
  add_action('widgets_init', 'ecwid_sidebar_widgets_init');
1723
 
1724
- function ecwid_encode_json($data) {
1725
- if(version_compare(PHP_VERSION,"5.2.0",">=")) {
1726
- return json_encode($data);
1727
- } else {
1728
- include_once(ABSPATH . 'wp-content/plugins/ecwid-shopping-cart/lib/JSON.php');
1729
- $json_parser = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
1730
- return $json_parser->encode($data);
1731
- }
1732
- }
1733
-
1734
-
1735
-
1736
  function ecwid_sso() {
1737
  $key = get_option('ecwid_sso_secret_key');
1738
  if (empty($key)) {
@@ -1753,7 +1910,7 @@ function ecwid_sso() {
1753
  )
1754
  )
1755
  );
1756
- $user_data = base64_encode(ecwid_encode_json($user_data));
1757
  $time = time();
1758
  $hmac = ecwid_hmacsha1("$user_data $time", $key);
1759
  return "<script> var ecwid_sso_profile='$user_data $hmac $time' </script>";
@@ -1800,7 +1957,6 @@ function ecwid_can_display_html_catalog()
1800
 
1801
  $profile = $api->get_profile();
1802
  if (!$profile) return;
1803
-
1804
  return $profile['closed'] != true;
1805
  }
1806
 
@@ -1838,4 +1994,35 @@ function ecwid_new_product_api()
1838
 
1839
  return $api;
1840
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1841
  ?>
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: 2.7
9
  Author URI: http://www.ecwid.com?source=wporg
10
  */
11
 
47
  add_action('admin_head', 'ecwid_send_stats');
48
  add_action('save_post', 'ecwid_save_post');
49
  add_action('init', 'ecwid_apply_theme');
50
+ add_action('get_footer', 'ecwid_admin_get_footer');
51
  } else {
52
  add_shortcode('ecwid_script', 'ecwid_script_shortcode');
53
  add_shortcode('ecwid_minicart', 'ecwid_minicart_shortcode');
54
  add_shortcode('ecwid_searchbox', 'ecwid_searchbox_shortcode');
55
  add_shortcode('ecwid_categories', 'ecwid_categories_shortcode');
56
  add_shortcode('ecwid_product', 'ecwid_product_shortcode');
57
+ add_shortcode('ecwid', 'ecwid_shortcode');
58
  add_action('init', 'ecwid_backward_compatibility');
59
  add_action('send_headers', 'ecwid_503_on_store_closed');
60
  add_action('template_redirect', 'ecwid_seo_compatibility_template_redirect');
79
 
80
  $ecwid_script_rendered = false; // controls single script.js on page
81
 
82
+ require_once plugin_dir_path(__FILE__) . '/includes/themes.php';
83
+ require_once plugin_dir_path(__FILE__) . '/includes/class-ecwid-message-manager.php';
84
+ require_once plugin_dir_path(__FILE__) . '/includes/class-ecwid-store-editor.php';
85
+
86
 
87
  $version = get_bloginfo('version');
88
 
246
  $page_id = ecwid_get_current_store_page_id();
247
 
248
  if (get_post_status($page_id) == 'publish') {
249
+ include ECWID_PLUGIN_DIR . '/includes/class-ecwid-sitemap-builder.php';
250
 
251
  $sitemap = new EcwidSitemapBuilder(ecwid_get_store_page_url(), 'build_sitemap_callback', ecwid_new_product_api());
252
 
421
  );
422
  }
423
 
424
+ function ecwid_content_has_productbrowser($content) {
425
+
426
+ $result = has_shortcode($content, 'ecwid_productbrowser');
427
+
428
+ if (!$result && has_shortcode($content, 'ecwid')) {
429
+ $shortcodes = ecwid_find_shortcodes($content, 'ecwid');
430
+ if ($shortcodes) foreach ($shortcodes as $shortcode) {
431
+
432
+ $attributes = shortcode_parse_atts($shortcode[3]);
433
+
434
+ if (isset($attributes['widgets'])) {
435
+ $widgets = preg_split('![^0-9^a-z^A-Z^-^_]!', $attributes['widgets']);
436
+ if (is_array($widgets) && in_array('productbrowser', $widgets)) {
437
+ $result = true;
438
+ }
439
+ }
440
+ }
441
+ }
442
+
443
+ return $result;
444
+ }
445
+
446
  function ecwid_page_has_productbrowser($post_id = null)
447
  {
448
+ static $results = null;
449
 
450
  if (is_null($post_id)) {
451
  $post_id = get_the_ID();
452
  }
453
 
454
+ if (!isset($results[$post_id])) {
455
+ $post_content = get_post($post_id)->post_content;
 
456
 
457
+ $results[$post_id] = ecwid_content_has_productbrowser($post_content);
458
+ $results[$post_id] = apply_filters( 'ecwid_page_has_product_browser', $results[$post_id] );
459
  }
460
 
461
  return $results[$post_id];
646
 
647
  function ecwid_wrap_shortcode_content($content, $name)
648
  {
649
+ return "<!-- Ecwid shopping cart plugin v 2.7 -->"
650
  . ecwid_get_scriptjs_code()
651
  . "<div class=\"ecwid-shopping-cart-$name\">$content</div>"
652
+ . "<!-- END Ecwid Shopping Cart v 2.7 -->";
653
  }
654
 
655
  function ecwid_get_scriptjs_code($force_lang = null) {
683
  return ecwid_wrap_shortcode_content($content, 'script');
684
  }
685
 
686
+ function ecwid_minicart_shortcode($attributes) {
687
+
688
+ $params = shortcode_atts(
689
+ array(
690
+ 'layout' => null,
691
+ 'is_ecwid_shortcode' => false
692
+ ), $attributes
693
+ );
694
+
695
+ $layout = $params['layout'];
696
+ if (!in_array($layout, array('', 'attachToCategories', 'floating', 'Mini', 'MiniAttachToProductBrowser'))) {
697
+ $layout = 'attachToCategories';
698
+ }
699
 
700
+ if ($params['is_ecwid_shortcode']) {
701
+ // it is a part of the ecwid shortcode, we need to show it anyways
702
+ $ecwid_enable_minicart = $ecwid_show_categories = true;
703
+ } else {
704
+ // it is a ecwid_minicart widget that works based on appearance settings
705
+ $ecwid_enable_minicart = get_option('ecwid_enable_minicart');
706
+ $ecwid_show_categories = get_option('ecwid_show_categories');
707
+ }
708
 
709
  $result = '';
710
+
711
+ if (!empty($ecwid_enable_minicart) && !empty($ecwid_show_categories)) {
712
+ $result = <<<EOT
713
+ <script type="text/javascript"> xMinicart("style=","layout=$layout"); </script>
714
  EOT;
715
+ }
716
 
717
  $result = apply_filters('ecwid_minicart_shortcode_content', $result);
718
 
723
  return $result;
724
  }
725
 
726
+ function ecwid_searchbox_shortcode($attributes) {
727
+
728
+ $params = shortcode_atts(
729
+ array(
730
+ 'is_ecwid_shortcode' => false
731
+ ), $attributes
732
+ );
733
+
734
+ $ecwid_show_search_box = $params['is_ecwid_shortcode'] ? true : get_option('ecwid_show_search_box');
735
 
736
+ $result = '';
737
+ if (!empty($ecwid_show_search_box)) {
738
+ $result = <<<EOT
739
  <script type="text/javascript"> xSearchPanel("style="); </script>
740
  EOT;
741
+ }
742
 
743
  $result = apply_filters('ecwid_search_shortcode_content', $result);
744
 
749
  return $result;
750
  }
751
 
752
+ function ecwid_categories_shortcode($attributes) {
753
+
754
+ $params = shortcode_atts(
755
+ array(
756
+ 'is_ecwid_shortcode' => false
757
+ ), $attributes
758
+ );
759
 
760
+ $ecwid_show_categories = $params['is_ecwid_shortcode'] ? true : get_option('ecwid_show_categories');
761
 
762
  $result = '';
763
+ if (!empty($ecwid_show_categories)) {
764
+ $result = <<<EOT
765
  <script type="text/javascript"> xCategories("style="); </script>
766
  EOT;
767
+ }
768
 
769
  $result = apply_filters('ecwid_categories_shortcode_content', $result);
770
 
827
 
828
  $result .= '</div>';
829
 
830
+ $result .= ecwid_get_product_browser_url_script();
831
  $result .= '<script type="text/javascript">xSingleProduct()</script>';
832
 
833
  update_option('ecwid_single_product_used', time());
835
  return ecwid_wrap_shortcode_content($result, 'product');
836
  }
837
 
838
+ function ecwid_shortcode($attributes)
839
+ {
840
+ $attributes = shortcode_atts(
841
+ array(
842
+ 'widgets' => 'productbrowser',
843
+ 'categories_per_row' => '3',
844
+ 'category_view' => 'grid',
845
+ 'search_view' => 'grid',
846
+ 'grid' => '3,3',
847
+ 'list' => '10',
848
+ 'table' => '20',
849
+ 'minicart_layout' => 'attachToCategories',
850
+ 'default_category_id' => 0
851
+ )
852
+ , $attributes
853
+ );
854
 
855
+ $allowed_widgets = array('productbrowser', 'search', 'categories', 'minicart');
856
+ $widgets = preg_split('![^0-9^a-z^A-Z^-^_]!', $attributes['widgets']);
857
+ foreach ($widgets as $key => $widget) {
858
+ if (!in_array($widget, $allowed_widgets)) {
859
+ unset($widgets[$key]);
 
 
 
 
860
  }
861
  }
862
 
863
+ if (empty($widgets)) {
864
+ $widgets = array('productbrowser');
865
+ }
866
+
867
+ $attributes['layout'] = $attributes['minicart_layout'];
868
+ $attributes['is_ecwid_shortcode'] = true;
869
+
870
+ $result = '';
871
+
872
+ $widgets_order = array('minicart', 'search', 'categories', 'productbrowser');
873
+ foreach ($widgets_order as $widget) {
874
+ if (in_array($widget, $widgets)) {
875
+ if ($widget == 'search') {
876
+ $widget = 'searchbox';
877
+ }
878
+
879
+ $result .= call_user_func_array('ecwid_' . $widget . '_shortcode', array($attributes));
880
+ }
881
+ }
882
+
883
+ update_option('ecwid_store_shortcode_used', time());
884
+
885
+ return $result;
886
  }
887
 
888
  function ecwid_productbrowser_shortcode($shortcode_params) {
889
+
890
+ $atts = shortcode_atts(
891
+ array(
892
+ 'categories_per_row' => false,
893
+ 'grid' => false,
894
+ 'list' => false,
895
+ 'table' => false,
896
+ 'search_view' => false,
897
+ 'category_view' => false
898
+ ), $shortcode_params
899
+ );
900
+
901
+ $grid = explode(',', $atts['grid']);
902
+ if (count($grid) == 2) {
903
+ $atts['grid_rows'] = intval($grid[0]);
904
+ $atts['grid_cols'] = intval($grid[1]);
905
+ } else {
906
+ list($atts['grid_rows'], $atts['grid_cols']) = array(false, false);
907
+ }
908
+
909
  $store_id = get_ecwid_store_id();
910
  $list_of_views = array('list','grid','table');
911
 
912
+ $ecwid_pb_categoriesperrow = $atts['categories_per_row'] ? $atts['categories_per_row'] : get_option('ecwid_pb_categoriesperrow');
913
+ $ecwid_pb_productspercolumn_grid = $atts['grid_rows'] ? $atts['grid_rows'] : get_option('ecwid_pb_productspercolumn_grid');
914
+ $ecwid_pb_productsperrow_grid = $atts['grid_cols'] ? $atts['grid_cols'] : get_option('ecwid_pb_productsperrow_grid');
915
+ $ecwid_pb_productsperpage_list = $atts['list'] ? $atts['list'] : get_option('ecwid_pb_productsperpage_list');
916
+ $ecwid_pb_productsperpage_table = $atts['table'] ? $atts['table'] : get_option('ecwid_pb_productsperpage_table');
917
+ $ecwid_pb_defaultview = $atts['category_view'] ? $atts['category_view'] : get_option('ecwid_pb_defaultview');
918
+ $ecwid_pb_searchview = $atts['search_view'] ? $atts['search_view'] : get_option('ecwid_pb_searchview');
919
 
920
  $ecwid_mobile_catalog_link = get_option('ecwid_mobile_catalog_link');
921
  $ecwid_default_category_id =
946
  $ecwid_pb_searchview = 'list';
947
  }
948
 
949
+ if (empty($ecwid_default_category_id)) {
 
 
 
 
950
  $ecwid_default_category_str = '';
951
  } else {
952
  $ecwid_default_category_str = ',"defaultCategoryId='. $ecwid_default_category_id .'"';
953
  }
954
 
 
955
  $plain_content = '';
956
 
957
  if (ecwid_can_display_html_catalog()) {
958
  $params = ecwid_parse_escaped_fragment($_GET['_escaped_fragment_']);
959
  include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/ecwid_product_api.php';
960
+ include_once WP_PLUGIN_DIR . '/ecwid-shopping-cart/lib/ecwid_catalog.php';
961
 
962
  $page_url = get_page_link();
963
 
999
  }
1000
 
1001
 
1002
+ function ecwid_parse_escaped_fragment($escaped_fragment) {
1003
+ $fragment = urldecode($escaped_fragment);
1004
+ $return = array();
1005
+
1006
+ if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) {
1007
+ parse_str($matches[3], $return);
1008
+ $return['mode'] = $matches[2];
1009
+ } elseif (preg_match('!.*/(p|c)/([0-9]*)!', $fragment, $matches)) {
1010
+ if (count($matches) == 3 && in_array($matches[1], array('p', 'c'))) {
1011
+ $return = array(
1012
+ 'mode' => 'p' == $matches[1] ? 'product' : 'category',
1013
+ 'id' => $matches[2]
1014
+ );
1015
+ }
1016
+ }
1017
+
1018
+ return $return;
1019
+ }
1020
+
1021
  function ecwid_store_activate() {
1022
  $my_post = array();
1023
  $content = <<<EOT
1024
+ <!-- Ecwid code. Please do not remove this line otherwise your Ecwid shopping cart will not work properly. --> [ecwid widgets="productbrowser search" grid="3,3" list="10" table="20" default_category_id="0" category_view="grid" search_view="grid" minicart_layout="attachToCategories" ] <!-- Ecwid code end -->
1025
  EOT;
1026
  add_option("ecwid_store_page_id", '', '', 'yes');
1027
  add_option("ecwid_store_page_id_auto", '', '', 'yes');
1054
 
1055
  add_option("ecwid_installation_date", time());
1056
 
1057
+ add_option('ecwid_show_appearance_menu', get_option('ecwid_store_id') == ECWID_DEMO_STORE_ID ? 'N' : 'Y', 'yes');
1058
  // Does not affect updates, automatically turned on for new users only
1059
  add_option("ecwid_advanced_theme_layout", get_option('ecwid_store_id') == ECWID_DEMO_STORE_ID ? 'Y' : 'N', 'yes');
1060
 
1128
 
1129
  function ecwid_options_add_page() {
1130
 
1131
+ $is_newbie = get_ecwid_store_id() == ECWID_DEMO_STORE_ID;
1132
 
1133
  add_menu_page(
1134
  __('Ecwid shopping cart settings', 'ecwid-shopping-cart'),
1138
  'ecwid_general_settings_do_page'
1139
  );
1140
 
1141
+
1142
+ if ($is_newbie) {
1143
+ $title = __('Setup', 'ecwid-shopping-cart');
1144
+ } else {
1145
+ $title = __('Dashboard', 'ecwid-shopping-cart');
1146
+ }
1147
  add_submenu_page(
1148
  'ecwid',
1149
+ $title,
1150
+ $title,
1151
  'manage_options',
1152
  'ecwid',
1153
  'ecwid_general_settings_do_page'
1154
  );
1155
 
1156
+ if (get_option('ecwid_show_appearance_menu') == 'Y') {
1157
+ add_submenu_page(
1158
+ 'ecwid',
1159
+ __('Appearance settings', 'ecwid-shopping-cart'),
1160
+ __('Appearance', 'ecwid-shopping-cart'),
1161
+ 'manage_options',
1162
+ 'ecwid-appearance',
1163
+ 'ecwid_appearance_settings_do_page'
1164
+ );
1165
+ }
1166
 
1167
+ if (!$is_newbie || $_GET['page'] == 'ecwid-advanced') {
1168
+ add_submenu_page(
1169
+ 'ecwid',
1170
+ __('Advanced settings', 'ecwid-shopping-cart'),
1171
+ __('Advanced', 'ecwid-shopping-cart'),
1172
+ 'manage_options',
1173
+ 'ecwid-advanced',
1174
+ 'ecwid_advanced_settings_do_page'
1175
+ );
1176
+ }
1177
  //add_options_page('Ecwid shopping cart settings', 'Ecwid shopping cart', 'manage_options', 'ecwid_options_page', 'ecwid_options_do_page');
1178
  }
1179
 
1225
 
1226
  case 'general':
1227
  register_setting('ecwid_options_page', 'ecwid_store_id','ecwid_abs_intval' );
1228
+ if (isset($POST['ecwid_store_id']) && intval($_POST['ecwid_store_id']) == 0) {
1229
  Ecwid_Message_Manager::reset_hidden_messages();
1230
  }
1231
  break;
1245
 
1246
  function ecwid_common_admin_scripts() {
1247
 
1248
+ wp_enqueue_script('ecwid-admin-js', plugins_url('ecwid-shopping-cart/js/admin.js'));
1249
+ wp_enqueue_script('ecwid-modernizr-js', plugins_url('ecwid-shopping-cart/js/modernizr.js'));
1250
+ }
1251
+
1252
+ function ecwid_admin_get_footer() {
1253
 
 
 
1254
  }
1255
 
1256
  function ecwid_general_settings_do_page() {
1257
 
1258
  if (get_ecwid_store_id() == ECWID_DEMO_STORE_ID) {
1259
+ require_once plugin_dir_path(__FILE__) . '/templates/setup.php';
1260
  } else {
1261
+ require_once plugin_dir_path(__FILE__) . '/templates/dashboard.php';
1262
  }
1263
  }
1264
 
1265
+ function ecwid_get_categories_for_selector() {
1266
  $categories = false;
1267
  if (ecwid_is_paid_account()) {
1268
  $api = ecwid_new_product_api();
1278
  while (is_array($category) && isset($category['parentId'])) {
1279
  $name = '';
1280
  if (isset($by_id[$category['parentId']])) {
1281
+ $name = $by_id[$category['parentId']]['name'];
1282
  } else {
1283
  $name = __('Hidden category', 'ecwid-shopping-cart');
1284
  }
1299
  $categories = $by_id;
1300
  }
1301
 
1302
+ return $categories;
1303
+ }
1304
+
1305
+ function ecwid_advanced_settings_do_page() {
1306
+ $categories = ecwid_get_categories_for_selector();
1307
+
1308
  require_once plugin_dir_path(__FILE__) . '/templates/advanced-settings.php';
1309
  }
1310
 
1823
  'default_category',
1824
  'google_xml_sitemaps_used',
1825
  'ecwid_product_advisor_used',
1826
+ 'ecwid_single_product_used',
1827
+ 'ecwid_store_shortcode_used'
1828
+ );
1829
+
1830
+ $usage_stats = ecwid_gather_usage_stats();
1831
+ $stats['usage'] = '';
1832
+
1833
+ $usage = '';
1834
+ foreach ($usage_params as $index => $item) {
1835
+ $usage[$index] = (int)$usage_stats[$item];
1836
+ }
1837
+
1838
+ $stats['usage'] = $usage_version . '_' . implode('', $usage);
1839
+
1840
+ return $stats;
1841
+ }
1842
+
1843
+ function ecwid_gather_usage_stats()
1844
+ {
1845
+ $usage_params = array(
1846
+ 'paid',
1847
+ 'display_search',
1848
+ 'horizontal_categories_enabled',
1849
+ 'minicart_enabled',
1850
+ 'search_widget',
1851
+ 'vcategories_widget',
1852
+ 'minicart_normal_widget',
1853
+ 'minicart_mini_widget',
1854
+ 'badge_widget',
1855
+ 'sso_enabled',
1856
+ 'default_category',
1857
+ 'google_xml_sitemaps_used',
1858
+ 'ecwid_product_advisor_used',
1859
+ 'ecwid_single_product_used',
1860
+ 'ecwid_store_shortcode_used'
1861
  );
1862
 
1863
  $usage_stats = array();
1875
  $usage_stats['google_xml_sitemaps_used'] = (bool) is_plugin_active('google-sitemap-generator/sitemap.php');
1876
  $usage_stats['ecwid_product_advisor_used'] = (bool) is_plugin_active('ecwid-useful-tools/ecwid-product-advisor.php');
1877
  $usage_stats['ecwid_single_product_used'] = (bool) (get_option('ecwid_single_product_used') + 60*60*24*14 > time());
1878
+ $usage_stats['ecwid_store_shortcode_used'] = (bool) (get_option('ecwid_store_shortcode_used') + 60*60*24*14 > time());
1879
 
1880
+ return $usage_stats;
 
 
 
 
 
 
 
 
 
1881
  }
1882
 
1883
  function ecwid_sidebar_widgets_init() {
1890
 
1891
  add_action('widgets_init', 'ecwid_sidebar_widgets_init');
1892
 
 
 
 
 
 
 
 
 
 
 
 
 
1893
  function ecwid_sso() {
1894
  $key = get_option('ecwid_sso_secret_key');
1895
  if (empty($key)) {
1910
  )
1911
  )
1912
  );
1913
+ $user_data = base64_encode(json_encode($user_data));
1914
  $time = time();
1915
  $hmac = ecwid_hmacsha1("$user_data $time", $key);
1916
  return "<script> var ecwid_sso_profile='$user_data $hmac $time' </script>";
1957
 
1958
  $profile = $api->get_profile();
1959
  if (!$profile) return;
 
1960
  return $profile['closed'] != true;
1961
  }
1962
 
1994
 
1995
  return $api;
1996
  }
1997
+
1998
+ function ecwid_embed_svg($name) {
1999
+ $code = file_get_contents(ECWID_PLUGIN_DIR . '/images/' . $name . '.svg');
2000
+
2001
+ echo $code;
2002
+ }
2003
+
2004
+ /*
2005
+ * Basically a copy of has_shortcode that returns the matched shortcode
2006
+ */
2007
+ function ecwid_find_shortcodes( $content, $tag ) {
2008
+
2009
+ if ( shortcode_exists( $tag ) ) {
2010
+ preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
2011
+ if ( empty( $matches ) )
2012
+ return false;
2013
+
2014
+ $result = array();
2015
+ foreach ( $matches as $shortcode ) {
2016
+ if ( $tag === $shortcode[2] ) {
2017
+ $result[] = $shortcode;
2018
+ }
2019
+ }
2020
+
2021
+ if (empty($result)) {
2022
+ $result = false;
2023
+ }
2024
+ return $result;
2025
+ }
2026
+ return false;
2027
+ }
2028
  ?>
images/add-store.svg ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 143 168" enable-background="new 0 0 143 168" xml:space="preserve">
4
+ <path class="categories" fill="#D1ECF5" d="M41,49.1H2c-1.1,0-2,0.9-2,2.1V56c0,1.1,0.9,2.1,2,2.1H41c1.1,0,2-0.9,2-2.1v-4.8C43,50,42.1,49.1,41,49.1z"></path>
5
+ <path class="categories" fill="#D1ECF5" d="M91,49H52c-1.1,0-2,0.9-2,2.1v4.8c0,1.1,0.9,2.1,2,2.1H91c1.1,0,2-0.9,2-2.1v-4.8C93,49.9,92.1,49,91,49z"></path>
6
+ <path class="categories" fill="#D1ECF5" d="M141,49H102c-1.1,0-2,0.9-2,2.1v4.8c0,1.1,0.9,2.1,2,2.1H141c1.1,0,2-0.9,2-2.1v-4.8
7
+ C143,49.9,142.1,49,141,49z"></path>
8
+
9
+ <path class="minicart" fill="#D1ECF5" d="M115.2,8.9c0.8,0,1.5-0.6,1.5-1.4c0-3.7,0.6-4.6,4.3-4.6c3.7,0,4.3,0.9,4.3,4.6c0,0.8,0.7,1.4,1.5,1.4
10
+ c0.8,0,1.4-0.6,1.4-1.4c0-2.3,0.1-7.5-7.2-7.5c-7.3,0-7.2,5.2-7.2,7.5C113.9,8.3,114.4,8.9,115.2,8.9z"></path>
11
+ <path class="minicart" fill="#D1ECF5" d="M139.7,33.2l-4.6-21.9c-0.1-0.6-0.6-1.1-1.2-1.1h-25.6c-0.6,0-1.2,0.5-1.2,1.1l-4.6,21.9
12
+ c-0.1,1,0.4,1.8,1.2,1.8h34.9C139.3,35,139.8,34.2,139.7,33.2z M114.6,16c-1.2,0-2.2-1-2.2-2.2s1-2.2,2.2-2.2s2.2,1,2.2,2.2
13
+ S115.8,16,114.6,16z M127.6,16c-1.2,0-2.2-1-2.2-2.2s1-2.2,2.2-2.2c1.2,0,2.2,1,2.2,2.2S128.8,16,127.6,16z"></path>
14
+
15
+ <path class="productbrowser" fill="#D1ECF5" d="M40.1,72H2.9C1.4,72,0,73.4,0,74.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
16
+ C43,73.4,41.6,72,40.1,72z M30.1,112.6c0,1.3,0,1.5-1.4,1.5H14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
17
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"></path>
18
+ <path class="productbrowser" fill="#D1ECF5" d="M90.1,72H52.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
19
+ C93,73.4,91.6,72,90.1,72z M80.1,112.6c0,1.3,0,1.5-1.4,1.5H64.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
20
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"></path>
21
+ <path class="productbrowser" fill="#D1ECF5" d="M140.1,72h-37.3c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
22
+ C143,73.4,141.6,72,140.1,72z M130.1,112.6c0,1.3,0,1.5-1.4,1.5h-14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
23
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"></path>
24
+ <path class="productbrowser" fill="#D1ECF5" d="M40.1,123H2.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
25
+ C43,124.4,41.6,123,40.1,123z M30.1,163.6c0,1.3,0,1.5-1.4,1.5H14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
26
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"></path>
27
+ <path class="productbrowser" fill="#D1ECF5" d="M90.1,123H52.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
28
+ C93,124.4,91.6,123,90.1,123z M80.1,163.6c0,1.3,0,1.5-1.4,1.5H64.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
29
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"></path>
30
+ <path class="productbrowser" fill="#D1ECF5" d="M140.1,123h-37.3c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
31
+ C143,124.4,141.6,123,140.1,123z M130.1,163.6c0,1.3,0,1.5-1.4,1.5h-14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
32
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"></path>
33
+
34
+ <path class="search" fill="#D1ECF5" d="M38.2,31.3c0.5,0.5,0.8,1.2,0.8,1.9c0,0.7-0.3,1.4-0.8,1.9C37.6,35.7,37,36,36.3,36c-0.8,0-1.4-0.3-1.9-0.8
35
+ L27,27.9c-2.5,1.8-5.4,2.6-8.5,2.6c-2,0-4-0.4-5.8-1.2c-1.9-0.8-3.5-1.9-4.8-3.2c-1.3-1.3-2.4-2.9-3.2-4.8c-0.8-1.9-1.2-3.8-1.2-5.8
36
+ s0.4-4,1.2-5.8c0.8-1.9,1.9-3.5,3.2-4.8c1.3-1.3,2.9-2.4,4.8-3.2c1.9-0.8,3.8-1.2,5.8-1.2s4,0.4,5.8,1.2c1.9,0.8,3.5,1.9,4.8,3.2
37
+ c1.3,1.3,2.4,2.9,3.2,4.8c0.8,1.9,1.2,3.8,1.2,5.8c0,3.1-0.9,6-2.6,8.5L38.2,31.3L38.2,31.3z M25.3,22.3c1.9-1.9,2.8-4.1,2.8-6.8
38
+ c0-2.6-0.9-4.9-2.8-6.8c-1.9-1.9-4.1-2.8-6.8-2.8c-2.6,0-4.9,0.9-6.8,2.8c-1.9,1.9-2.8,4.1-2.8,6.8c0,2.6,0.9,4.9,2.8,6.8
39
+ c1.9,1.9,4.1,2.8,6.8,2.8C21.1,25.1,23.4,24.1,25.3,22.3z"></path>
40
+ </svg>
images/categories.svg ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 143 168" enable-background="new 0 0 143 168" xml:space="preserve">
6
+ <path fill="#D1ECF5" d="M41,49.1H2c-1.1,0-2,0.9-2,2.1V56c0,1.1,0.9,2.1,2,2.1H41c1.1,0,2-0.9,2-2.1v-4.8C43,50,42.1,49.1,41,49.1z"
7
+ />
8
+ <path fill="#D1ECF5" d="M91,49H52c-1.1,0-2,0.9-2,2.1v4.8c0,1.1,0.9,2.1,2,2.1H91c1.1,0,2-0.9,2-2.1v-4.8C93,49.9,92.1,49,91,49z"/>
9
+ <path fill="#D1ECF5" d="M141,49H102c-1.1,0-2,0.9-2,2.1v4.8c0,1.1,0.9,2.1,2,2.1H141c1.1,0,2-0.9,2-2.1v-4.8
10
+ C143,49.9,142.1,49,141,49z"/>
11
+ </svg>
images/minicart.svg ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 143 168" enable-background="new 0 0 143 168" xml:space="preserve">
6
+ <g>
7
+ <path fill="#D1ECF5" d="M115.2,8.9c0.8,0,1.5-0.6,1.5-1.4c0-3.7,0.6-4.6,4.3-4.6c3.7,0,4.3,0.9,4.3,4.6c0,0.8,0.7,1.4,1.5,1.4
8
+ c0.8,0,1.4-0.6,1.4-1.4c0-2.3,0.1-7.5-7.2-7.5c-7.3,0-7.2,5.2-7.2,7.5C113.9,8.3,114.4,8.9,115.2,8.9z"/>
9
+ <path fill="#D1ECF5" d="M139.7,33.2l-4.6-21.9c-0.1-0.6-0.6-1.1-1.2-1.1h-25.6c-0.6,0-1.2,0.5-1.2,1.1l-4.6,21.9
10
+ c-0.1,1,0.4,1.8,1.2,1.8h34.9C139.3,35,139.8,34.2,139.7,33.2z M114.6,16c-1.2,0-2.2-1-2.2-2.2s1-2.2,2.2-2.2s2.2,1,2.2,2.2
11
+ S115.8,16,114.6,16z M127.6,16c-1.2,0-2.2-1-2.2-2.2s1-2.2,2.2-2.2c1.2,0,2.2,1,2.2,2.2S128.8,16,127.6,16z"/>
12
+ </g>
13
+ </svg>
images/product_browser.svg ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 143 168" enable-background="new 0 0 143 168" xml:space="preserve">
6
+ <path fill="#D1ECF5" d="M40.1,72H2.9C1.4,72,0,73.4,0,74.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
7
+ C43,73.4,41.6,72,40.1,72z M30.1,112.6c0,1.3,0,1.5-1.4,1.5H14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
8
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"/>
9
+ <path fill="#D1ECF5" d="M90.1,72H52.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
10
+ C93,73.4,91.6,72,90.1,72z M80.1,112.6c0,1.3,0,1.5-1.4,1.5H64.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
11
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"/>
12
+ <path fill="#D1ECF5" d="M140.1,72h-37.3c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9V74.9
13
+ C143,73.4,141.6,72,140.1,72z M130.1,112.6c0,1.3,0,1.5-1.4,1.5h-14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
14
+ c1.5,0,1.4,0.1,1.4,1.5V112.6z"/>
15
+ <path fill="#D1ECF5" d="M40.1,123H2.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
16
+ C43,124.4,41.6,123,40.1,123z M30.1,163.6c0,1.3,0,1.5-1.4,1.5H14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
17
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"/>
18
+ <path fill="#D1ECF5" d="M90.1,123H52.9c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
19
+ C93,124.4,91.6,123,90.1,123z M80.1,163.6c0,1.3,0,1.5-1.4,1.5H64.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
20
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"/>
21
+ <path fill="#D1ECF5" d="M140.1,123h-37.3c-1.4,0-2.9,1.4-2.9,2.9v39.2c0,1.5,1.4,2.9,2.9,2.9h37.3c1.4,0,2.9-1.4,2.9-2.9v-39.2
22
+ C143,124.4,141.6,123,140.1,123z M130.1,163.6c0,1.3,0,1.5-1.4,1.5h-14.3c-1.5,0-1.4-0.1-1.4-1.5v-4.4c0-1.3,0-1.5,1.4-1.5h14.3
23
+ c1.5,0,1.4,0.1,1.4,1.5V163.6z"/>
24
+ </svg>
images/search.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 143 168" enable-background="new 0 0 143 168" xml:space="preserve">
6
+ <path fill="#D1ECF5" d="M38.2,31.3c0.5,0.5,0.8,1.2,0.8,1.9c0,0.7-0.3,1.4-0.8,1.9C37.6,35.7,37,36,36.3,36c-0.8,0-1.4-0.3-1.9-0.8
7
+ L27,27.9c-2.5,1.8-5.4,2.6-8.5,2.6c-2,0-4-0.4-5.8-1.2c-1.9-0.8-3.5-1.9-4.8-3.2c-1.3-1.3-2.4-2.9-3.2-4.8c-0.8-1.9-1.2-3.8-1.2-5.8
8
+ s0.4-4,1.2-5.8c0.8-1.9,1.9-3.5,3.2-4.8c1.3-1.3,2.9-2.4,4.8-3.2c1.9-0.8,3.8-1.2,5.8-1.2s4,0.4,5.8,1.2c1.9,0.8,3.5,1.9,4.8,3.2
9
+ c1.3,1.3,2.4,2.9,3.2,4.8c0.8,1.9,1.2,3.8,1.2,5.8c0,3.1-0.9,6-2.6,8.5L38.2,31.3L38.2,31.3z M25.3,22.3c1.9-1.9,2.8-4.1,2.8-6.8
10
+ c0-2.6-0.9-4.9-2.8-6.8c-1.9-1.9-4.1-2.8-6.8-2.8c-2.6,0-4.9,0.9-6.8,2.8c-1.9,1.9-2.8,4.1-2.8,6.8c0,2.6,0.9,4.9,2.8,6.8
11
+ c1.9,1.9,4.1,2.8,6.8,2.8C21.1,25.1,23.4,24.1,25.3,22.3z"/>
12
+ </svg>
images/store.svg ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 26 26" enable-background="new 0 0 26 26" xml:space="preserve">
6
+ <g>
7
+ <path fill="#434343" d="M0.1,24.6c0-0.3,0.2-0.5,0.5-0.5h24.9c0.3,0,0.5,0.2,0.5,0.5v1c0,0.3-0.2,0.5-0.5,0.5H0.6
8
+ c-0.3,0-0.5-0.2-0.5-0.5V24.6z"/>
9
+ <path fill="#434343" d="M26,9c-1-2-1.4-3.9-2-7.2C24,1.6,23.6,1,23,1H3C2.4,1,2,1.6,2,1.8C2,1.8,1,8,0,9c0,1,0,3,0,3s0,0,0,0.1h0
10
+ c0,0,0.1,0.5,0.7,0.8C0.8,12.9,0.9,13,1,13v0v9C1,22.6,1.6,23,2.1,23H10v-8.3c0-0.6,0.5-1,1.1-1h4c0.5,0,1,0.4,1,1V23h8
11
+ c0.5,0,1-0.4,1-0.9v-9v0c0.8-0.1,1-0.9,1-0.9h0c0,0,0-0.1,0-0.1S26,10,26,9z M7.8,19c0,0.5-0.2,1-0.8,1H5c-0.5,0-0.8-0.5-0.8-1v-4
12
+ c0-0.6,0.3-1,0.8-1H7c0.6,0,0.8,0.4,0.8,1V19z M21.8,19c0,0.5-0.2,1-0.8,1h-2c-0.5,0-0.8-0.5-0.8-1v-4c0-0.6,0.3-1,0.8-1h2
13
+ c0.5,0,0.8,0.4,0.8,1V19z M22,2.8c0,0,1.1,5.1,1.7,6.2c-1,0-2.7,0-2.7,0l-1-6.2H22z M23.8,10l0,0.8c-0.1,0.7-0.7,1.2-1.4,1.2
14
+ c-0.8,0-1.4-0.5-1.4-1.2c0,0,0-0.8,0-0.8H23.8z M16.3,10.5l0-0.5h2.8l0,0.8C19,11.5,18.4,12,17.7,12C16.9,12,16.3,11.4,16.3,10.5
15
+ C16.3,10.6,16.3,10.5,16.3,10.5L16.3,10.5z M18,2.8c0,0,0.8,4.9,1.1,6.2c0.3,0-2.8,0-2.8,0L16,2.8H18z M12,2.8h2L14.4,9h-2.7
16
+ L12,2.8z M11.6,10h2.8l0,0.7C14.3,11.4,13.7,12,13,12c-0.7,0-1.3-0.6-1.4-1.3L11.6,10z M8,2.8h2L9.7,9c0,0-2,0-2.7,0
17
+ C7.3,7.9,8,2.8,8,2.8z M6.9,10h2.8l0,0.5h0c0,0,0,0,0,0.1c0,0.8-0.6,1.4-1.4,1.4c-0.7,0-1.3-0.5-1.4-1.2L6.9,10z M4,2.8h2L5.1,9
18
+ c0,0-2,0-2.7,0C3.2,7.6,4,2.8,4,2.8z M2.2,10H5c0,0,0,0.6,0,0.6C5,11.4,4.4,12,3.6,12c-0.7,0-1.3-0.5-1.4-1.2L2.2,10z"/>
19
+ </g>
20
+ </svg>
includes/class-ecwid-message-manager.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecwid_Message_Manager
4
+ {
5
+ protected $messages = array();
6
+
7
+ protected function Ecwid_Message_Manager()
8
+ {
9
+ $this->init_messages();
10
+ }
11
+
12
+ public static function show_messages()
13
+ {
14
+ $mm = self::get_instance();
15
+
16
+ foreach ($mm->messages as $name => $message) {
17
+ if ($mm->need_to_show_message($name)) {
18
+ $mm->show_message($name);
19
+ }
20
+ }
21
+ }
22
+
23
+ public static function show_message($name, $params = array())
24
+ {
25
+ $mm = self::get_instance();
26
+
27
+ $mm->need_to_show_message($name);
28
+
29
+ if (!isset($mm->messages[$name]) && empty($params)) {
30
+ trigger_error('Ecwid plugin error: unknown message ' . $name);
31
+ return;
32
+ }
33
+
34
+ $params = $mm->get_message_params($name, $params);
35
+
36
+ $type = $params['type'];
37
+
38
+ $title = $params['title'];
39
+ $message = $params['message'];
40
+
41
+ $primary_button = isset($params['primary_title']);
42
+ if ($primary_button) {
43
+ $primary_title = $params['primary_title'];
44
+ $primary_url = $params['primary_url'];
45
+ $primary_blank = @$params['primary_blank'];
46
+ }
47
+ $secondary_button = isset($params['secondary_title']);
48
+ if ($secondary_button) {
49
+ $secondary_title = $params['secondary_title'];
50
+ $secondary_url = $params['secondary_url'];
51
+ $secondary_blank = @$params['secondary_blank'];
52
+ }
53
+
54
+ $do_not_show_again = true == $params['hideable'];
55
+
56
+ include ECWID_PLUGIN_DIR . '/templates/admin-message.php';
57
+ }
58
+
59
+ public static function disable_message($name)
60
+ {
61
+ $messages = get_option('ecwid_disabled_messages');
62
+ $messages[$name] = true;
63
+
64
+ update_option('ecwid_disabled_messages', $messages);
65
+ }
66
+
67
+ public static function enable_message($name)
68
+ {
69
+ $messages = get_option('ecwid_disabled_messages');
70
+ if (isset($messages['name']))
71
+ unset($messages['name']);
72
+
73
+ update_option('ecwid_disabled_messages', $messages);
74
+ }
75
+
76
+ public static function reset_hidden_messages()
77
+ {
78
+ $hidden_messages = array();
79
+
80
+ $messages = self::get_default_messages();
81
+ foreach ($messages as $name => $message) {
82
+ if (isset($message['default']) && $message['default'] == 'hidden') {
83
+ $hidden_messages[$name] = true;
84
+ }
85
+ }
86
+
87
+ update_option('ecwid_disabled_messages', array());
88
+ }
89
+
90
+ protected static function get_instance()
91
+ {
92
+ static $instance = null;
93
+
94
+ if (is_null($instance)) {
95
+ $instance = new Ecwid_Message_Manager();
96
+ }
97
+
98
+ return $instance;
99
+ }
100
+
101
+ protected function init_messages()
102
+ {
103
+ $this->messages = $this->get_default_messages();
104
+
105
+ $hidden_messages = get_option('ecwid_disabled_messages');
106
+
107
+ if ( !empty( $hidden_messages ) ) {
108
+ foreach ($hidden_messages as $name => $message) {
109
+ unset ($this->messages[$name]);
110
+ }
111
+ }
112
+ }
113
+
114
+ protected function get_message_params($name, $params)
115
+ {
116
+ if (is_array($name)) {
117
+ $params = $name;
118
+ $name = '';
119
+ }
120
+
121
+ if (isset($this->messages[$name])) {
122
+ $params = array_merge(
123
+ array('type' => 'info', 'title' => '', 'message' => '', 'hideable' => false),
124
+ $this->messages[$name],
125
+ $params
126
+ );
127
+ }
128
+
129
+ if ($name == 'on_storeid_set') {
130
+ $params['primary_url'] = ecwid_get_store_page_url();
131
+ $params['secondary_url'] = 'post.php?post=' . ecwid_get_current_store_page_id() . '&action=edit';
132
+ }
133
+
134
+ if ($name == 'on_appearance_widgets') {
135
+
136
+ if (isset($_GET['from-ecwid']) && $_GET['from-ecwid'] == 'appearance') {
137
+ $admin_page = 'admin.php?page=ecwid-appearance';
138
+ } elseif (isset($_GET['from-ecwid']) && $_GET['from-ecwid'] == 'new') {
139
+ $admin_page = 'post-new.php?post_type=page';
140
+ } elseif (isset($_GET['from-ecwid']) && is_numeric($_GET['from-ecwid'])) {
141
+ $admin_page = 'post.php?post=' . $_GET['from-ecwid'] . '&action=edit';
142
+ }
143
+
144
+ $params['secondary_url'] = $admin_page;
145
+ }
146
+ $types_map = array(
147
+ 'info' => 'updated',
148
+ 'warning' => 'update-nag',
149
+ 'error' => 'error'
150
+ );
151
+ $params['type'] = $types_map[$params['type']];
152
+
153
+ return $params;
154
+ }
155
+
156
+ protected static function get_default_messages()
157
+ {
158
+ return array(
159
+ 'on_activate' => array(
160
+ 'title' => __('Greetings! Your Ecwid store is now active.', 'ecwid-shopping-cart'),
161
+ 'message' => __('Take a few simple steps to complete store setup', 'ecwid-shopping-cart'),
162
+ 'primary_title' => __('Set up Ecwid Store', 'ecwid-shopping-cart'),
163
+ 'primary_url' => 'admin.php?page=ecwid',
164
+ 'hideable' => true,
165
+ 'default' => 'disabled'
166
+ ),
167
+
168
+ 'on_storeid_set' => array(
169
+ 'title' => __('Good job! Your store is set up and you\'re ready to sell.', 'ecwid-shopping-cart'),
170
+ 'message' => __('Now you can fine-tune your store\'s appearance', 'ecwid-shopping-cart'),
171
+ 'primary_title' => __('Visit Storefront', 'ecwid-shopping-cart'),
172
+ 'primary_url' => '',
173
+ 'primary_blank' => true,
174
+ 'secondary_title' => __('Configure Appearance', 'ecwid-shopping-cart'),
175
+ 'secondary_url' => 'admin.php?page=ecwid-appearance',
176
+ 'hideable' => true
177
+ ),
178
+
179
+ 'on_no_storeid_on_setup_pages' => array(
180
+ 'type' => 'warning',
181
+ 'title' => __('Your store is almost ready!', 'ecwid-shopping-cart' ),
182
+ 'message' => __('Connect your Ecwid account with this site to complete setup and start selling', 'ecwid-shopping-cart' ),
183
+ 'primary_title' => __('Connect Your Ecwid Store', 'ecwid-shopping-cart' ),
184
+ 'primary_url' => 'admin.php?page=ecwid',
185
+ 'hideable' => true
186
+ ),
187
+
188
+ 'on_appearance_widgets' => array(
189
+ 'message' => __('To add extra functions to your store, drag and drop Ecwid store elements on your site. When you\'re done, you can get back to modifying your settings.', 'ecwid-shopping-cart' ),
190
+ 'secondary_title' => __('Back to Store Settings', 'ecwid-shopping-cart'),
191
+ 'secondary_url' => 'admin.php?page=ecwid-appearance',
192
+ 'hideable' => true
193
+ ),
194
+
195
+ 'please_vote' => array(
196
+ 'message' => sprintf(
197
+ __('Do you like your Ecwid online store? We\'d appreciate it if you add your review and vote for the plugin on Wordpress site.', 'ecwid-shopping-cart'),
198
+ 'target="_blank" href="http://wordpress.org/support/view/plugin-reviews/ecwid-shopping-cart"'
199
+ ),
200
+ 'primary_title' => __('Rate Ecwid at WordPress.org', 'ecwid-shopping-cart'),
201
+ 'primary_url' => 'http://wordpress.org/support/view/plugin-reviews/ecwid-shopping-cart',
202
+ 'hideable' => true
203
+ )
204
+ );
205
+ }
206
+
207
+ protected function need_to_show_message($name)
208
+ {
209
+ $admin_page = '';
210
+ if (function_exists('get_current_screen')) {
211
+ $screen = get_current_screen();
212
+ $admin_page = $screen->base;
213
+ }
214
+
215
+ switch ($name) {
216
+ case 'on_activate':
217
+ return $admin_page == 'plugins' && get_ecwid_store_id() == ECWID_DEMO_STORE_ID;
218
+
219
+ case 'on_storeid_set':
220
+ return get_ecwid_store_id() != ECWID_DEMO_STORE_ID && @$_GET['settings-updated'] == 'true' && $admin_page == 'toplevel_page_ecwid';
221
+
222
+ case 'on_no_storeid_on_setup_pages':
223
+ $is_newbie = get_ecwid_store_id() == ECWID_DEMO_STORE_ID;
224
+
225
+ $is_ecwid_settings = in_array($admin_page, array('ecwid-store_page_ecwid-advanced', 'ecwid-store_page_ecwid-appearance'));
226
+ $is_store_page = $admin_page == 'post' && $_GET['post'] == ecwid_get_current_store_page_id();
227
+
228
+ return $is_newbie && ($is_ecwid_settings || $is_store_page);
229
+
230
+ case 'on_appearance_widgets':
231
+ return isset($_GET['from-ecwid']) && $admin_page == 'widgets';
232
+
233
+ case 'please_vote':
234
+ $install_date = get_option('ecwid_installation_date');
235
+
236
+ $result = false;
237
+ if (!$install_date) {
238
+ add_option('ecwid_installation_date', time());
239
+ } else {
240
+ $result = ecwid_is_paid_account() && $install_date + 60*60*24*30 < time();
241
+ }
242
+
243
+ foreach ($this->messages as $_name => $message) {
244
+ if ($_name != $name && $this->need_to_show_message($_name)) {
245
+ return false;
246
+ }
247
+ }
248
+
249
+ return $result;
250
+ }
251
+ }
252
+
253
+ }
includes/class-ecwid-sitemap-builder.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname(__FILE__) . '/../lib/JSONStreamingParser/Listener.php';
4
+ require_once dirname(__FILE__) . '/../lib/JSONStreamingParser/Parser.php';
5
+
6
+
7
+ class EcwidSitemapBuilder implements JsonStreamingParser_Listener {
8
+ var $_stack;
9
+ var $_key;
10
+ var $callback;
11
+ var $base_url;
12
+ var $api;
13
+ var $type;
14
+
15
+ public function __construct($base_url, $callback, $api) {
16
+ $this->callback = $callback;
17
+ $this->base_url = $base_url;
18
+ $this->api = $api;
19
+ }
20
+
21
+ public function generate() {
22
+
23
+ foreach (array('products', 'categories') as $type) {
24
+ $this->type = $type;
25
+ $stream = $this->api->get_method_response_stream($type);
26
+ if (!is_null($stream)) {
27
+ try {
28
+ $parser = new JsonStreamingParser_Parser($stream, $this);
29
+ $parser->parse();
30
+ } catch (Exception $e) {
31
+ fclose($stream);
32
+ }
33
+ }
34
+ }
35
+
36
+ return true;
37
+ }
38
+
39
+ public function file_position($line, $char) {
40
+
41
+ }
42
+
43
+ public function start_document() {
44
+ $this->_stack = array();
45
+
46
+ $this->_key = null;
47
+ }
48
+
49
+ public function end_document() {
50
+ }
51
+
52
+ public function start_object() {
53
+ array_push($this->_stack, array());
54
+ }
55
+
56
+ public function end_object() {
57
+
58
+ $obj = array_pop($this->_stack);
59
+ if (is_array($obj) && array_key_exists('url', $obj)) {
60
+ $callback = $this->callback;
61
+
62
+ $callback(
63
+ ecwid_get_entity_url($obj, $this->type == 'products' ? 'p' : 'c'),
64
+ $this->type == 'products' ? 0.6 : 0.5,
65
+ 'weekly'
66
+ );
67
+ }
68
+ }
69
+
70
+ public function start_array() {
71
+ }
72
+
73
+ public function end_array() {
74
+ }
75
+
76
+ public function key($key) {
77
+ $this->_key = $key;
78
+ }
79
+
80
+ public function value($value) {
81
+ if ($this->_key == 'url') {
82
+ $this->_stack[0]['url'] = $value;
83
+ }
84
+ }
85
+ }
includes/class-ecwid-store-editor.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecwid_Store_Editor {
4
+ public function __construct()
5
+ {
6
+ $version = get_bloginfo('version');
7
+ if (version_compare($version, '3.5') < 0) {
8
+ return;
9
+ }
10
+
11
+ add_action('template_redirect', array($this, 'get_store_svg'));
12
+
13
+ if (!in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'))) return;
14
+
15
+ $this->init();
16
+ }
17
+
18
+ protected function init()
19
+ {
20
+ add_filter('mce_external_plugins', array($this, 'add_mce_plugin'));
21
+ add_action('media_buttons_context', array($this, 'add_editor_button'));
22
+ add_action('admin_enqueue_scripts', array($this, 'add_scripts'));
23
+ add_action('in_admin_header', array($this, 'add_popup'));
24
+ }
25
+
26
+ public function add_mce_plugin() {
27
+ $plugins = array('ecwid'); //Add any more plugins you want to load here
28
+ $plugins_array = array(
29
+ 'ecwid' => plugins_url('ecwid-shopping-cart/js/store-editor-mce.js'),
30
+ 'ecwid_common' => plugins_url('ecwid-shopping-cart/js/store-editor-common.js'),
31
+ );
32
+
33
+ return $plugins_array;
34
+ }
35
+
36
+ public function add_editor_button($context) {
37
+
38
+ $image_code = file_get_contents(ECWID_PLUGIN_DIR . 'images/store.svg');
39
+
40
+ $title = __('Add Store', 'ecwid-shopping-cart');
41
+ $button = <<<HTML
42
+ <a href="#" id="insert-ecwid-button" class="button add-ecwid ecwid_button" title="$title">
43
+ <span class="ecwid-store-icon">$image_code</span>
44
+ $title
45
+ </a>
46
+ HTML;
47
+
48
+ $title = __('Edit Store', 'ecwid-shopping-cart');
49
+ $button .= <<<HTML
50
+ <a href="#" id="update-ecwid-button" class="button update-ecwid ecwid_button" title="$title">
51
+ <span class="ecwid-store-icon">$image_code</span>
52
+ $title
53
+ </a>
54
+ HTML;
55
+
56
+ return $button;
57
+ }
58
+
59
+ public function add_scripts() {
60
+ wp_enqueue_style('ecwid-store-editor-css', plugins_url('ecwid-shopping-cart/css/store-popup.css'));
61
+ wp_enqueue_script('ecwid-store-editor-common-js', plugins_url('ecwid-shopping-cart/js/store-editor-common.js'));
62
+ wp_enqueue_script('ecwid-store-editor-page-js', plugins_url('ecwid-shopping-cart/js/store-editor-page.js'));
63
+ wp_localize_script('ecwid-store-editor-page-js', 'ecwid_i18n', array('edit_store_appearance' => __('Edit Appearance', 'ecwid-shopping-cart')));
64
+ add_editor_style(plugins_url('ecwid-shopping-cart/css/page-editor.css'));
65
+ }
66
+
67
+ public function get_store_svg() {
68
+ if (isset($_GET['file']) && $_GET['file'] == 'ecwid_store_svg.svg' && current_user_can('administrator')) {
69
+ ecwid_load_textdomain();
70
+ header('Content-type: image/svg+xml');
71
+ require_once(ECWID_PLUGIN_DIR . 'templates/store-svg.php');
72
+ die();
73
+ }
74
+ }
75
+
76
+ public function add_popup() {
77
+ $categories = ecwid_get_categories_for_selector();
78
+
79
+ require_once(ECWID_PLUGIN_DIR . 'templates/store-popup.php');
80
+ }
81
+ }
82
+
83
+ $ecwid_store_editor = new Ecwid_Store_Editor();
includes/themes.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ define( 'ECWID_THEMES_DIR', ECWID_PLUGIN_DIR . '/includes/themes' );
4
+
5
+ add_action('after_switch_theme', 'ecwid_after_switch_theme');
6
+
7
+ function ecwid_get_theme_name()
8
+ {
9
+ $version = get_bloginfo('version');
10
+
11
+ if (version_compare( $version, '3.4' ) < 0) {
12
+ $theme_name = get_template();
13
+ } else {
14
+ $theme = wp_get_theme();
15
+ $theme_name = $theme->template;
16
+ }
17
+
18
+ return $theme_name;
19
+ }
20
+
21
+ function ecwid_apply_theme($theme_name = null)
22
+ {
23
+ $themes = array('bretheon', 'responsive', 'twentyfourteen', 'pagelines', 'envision');
24
+
25
+ if (empty($theme_name)) {
26
+ $theme_name = ecwid_get_theme_name();
27
+ }
28
+
29
+ $theme_file = '';
30
+
31
+ if (in_array($theme_name, $themes)) {
32
+
33
+ $theme_file = ECWID_THEMES_DIR . '/class-ecwid-theme-' . $theme_name . '.php';
34
+ }
35
+
36
+ $theme_file = apply_filters( 'ecwid_get_theme_file', $theme_file );
37
+
38
+ if ( !empty( $theme_file ) && is_file( $theme_file ) && is_readable( $theme_file ) ) {
39
+ require_once( $theme_file );
40
+ }
41
+ }
42
+
43
+ function ecwid_after_switch_theme()
44
+ {
45
+ ecwid_apply_theme();
46
+
47
+ global $ecwid_current_theme;
48
+
49
+ update_option(
50
+ 'ecwid_advanced_theme_layout',
51
+ isset($ecwid_current_theme) && $ecwid_current_theme->has_advanced_layout ? 'Y' : 'N'
52
+ );
53
+ }
includes/themes/class-ecwid-theme-base.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ecwid_Theme_Base {
4
+
5
+ public $has_advanced_layout = false;
6
+
7
+ protected $adjust_pb_scroll = false;
8
+
9
+ public function __construct()
10
+ {
11
+ if ( $this->adjust_pb_scroll ) {
12
+ wp_enqueue_script(
13
+ 'ecwid-scroller',
14
+ plugins_url( 'ecwid-shopping-cart/js/create_scroller.js' ),
15
+ array( 'jquery' )
16
+ );
17
+ }
18
+ }
19
+
20
+ protected function need_advanced_layout()
21
+ {
22
+ return get_option('ecwid_advanced_theme_layout') == 'Y';
23
+ }
24
+ }
includes/themes/class-ecwid-theme-bretheon.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_Bretheon extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'Bretheon';
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+
13
+ add_filter( 'ecwid_page_has_product_browser', array( $this, 'has_product_browser' ) );
14
+ }
15
+
16
+ public function has_product_browser( $value )
17
+ {
18
+ if ( $value ) {
19
+ return $value;
20
+ }
21
+
22
+ $meta = get_post_meta( get_the_ID(), 'mfn-page-items' );
23
+ if ( is_array( $meta ) ) {
24
+ $meta = base64_decode( $meta[0] );
25
+
26
+ // not exactly the intended usage, but quite simple and still works
27
+ // $meta is a serialized array that has the actual content
28
+ // a right way is to walk through the structure and run has_shortcode against all fields
29
+ $result = ecwid_content_has_productbrowser($meta);
30
+ }
31
+
32
+ return $result;
33
+ }
34
+ }
35
+
36
+ $ecwid_current_theme = new Ecwid_Theme_Bretheon();
includes/themes/class-ecwid-theme-envision.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_Envision extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'Envision';
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+
13
+ add_filter( 'ecwid_page_has_product_browser', array( $this, 'has_product_browser' ) );
14
+ }
15
+
16
+ public function has_product_browser( $value )
17
+ {
18
+ if ( $value ) {
19
+ return $value;
20
+ }
21
+
22
+ $meta = serialize(get_post_meta( get_the_ID(), 'env_composer' ));
23
+ //die(print_r(serialize($meta)));
24
+
25
+ // not exactly the intended usage, but quite simple and still works
26
+ // $meta is a serialized array that has the actual content
27
+ // a right way is to walk through the structure and run has_shortcode against all fields
28
+ $result = ecwid_content_has_productbrowser($meta);
29
+
30
+ return $result;
31
+ }
32
+ }
33
+
34
+ $ecwid_current_theme = new Ecwid_Theme_Envision();
includes/themes/class-ecwid-theme-pagelines.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_Pagelines extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'Pagelines';
8
+
9
+ protected $adjust_pb_scroll = true;
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ wp_enqueue_script( 'ecwid-theme-js', plugins_url( 'ecwid-shopping-cart/js/themes/pagelines.js' ), array( 'jquery' ), false, true );
16
+ }
17
+ }
18
+
19
+ $ecwid_current_theme = new Ecwid_Theme_Pagelines();
includes/themes/class-ecwid-theme-responsive.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_Responsive extends Ecwid_Theme_Base
6
+ {
7
+ public $has_advanced_layout = true;
8
+
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+
13
+ if (!is_admin()) {
14
+
15
+ if ( $this->need_advanced_layout() ) {
16
+ wp_enqueue_style( 'ecwid-theme-adjustments' , plugins_url( 'ecwid-shopping-cart/css/themes/responsive-adjustments.css' ), array(), false, 'all' );
17
+ wp_enqueue_script( 'ecwid-theme', plugins_url( 'ecwid-shopping-cart/js/themes/responsive.js' ), array( 'jquery' ), false, true );
18
+
19
+ add_filter( 'ecwid_minicart_shortcode_content', array( $this, 'minicart_shortcode_content' ) );
20
+ add_filter( 'ecwid_search_shortcode_content', array( $this, 'search_shortcode_content' ) );
21
+ }
22
+
23
+ wp_enqueue_style( 'ecwid-open-sans' , 'http://fonts.googleapis.com/css?family=Open+Sans:400,700&subset=latin,cyrillic-ext,cyrillic,greek-ext,vietnamese,greek,latin-ext');
24
+ wp_enqueue_style( 'dashicons' );
25
+ wp_enqueue_style( 'ecwid-theme-fixes' , plugins_url( 'ecwid-shopping-cart/css/themes/responsive.css' ), array(), false, 'all' );
26
+
27
+ add_filter('body_class', array($this, 'body_class'));
28
+
29
+ } else {
30
+
31
+ add_action('ecwid_store_page_created', array($this, 'on_create_store_page'));
32
+ add_action('switch_theme', array($this, 'switch_theme'));
33
+
34
+ }
35
+
36
+ }
37
+
38
+ public function switch_theme()
39
+ {
40
+
41
+ }
42
+
43
+ public function minicart_shortcode_content( $content )
44
+ {
45
+
46
+ if ( ecwid_page_has_productbrowser() ) {
47
+ $content = '<script type="text/javascript"> xMinicart("style=","layout=Mini"); </script>';
48
+ }
49
+
50
+ return $content;
51
+ }
52
+
53
+ public function search_shortcode_content( $content ) {
54
+
55
+ $content .= '<script type="text/javascript">jQuery(document.body).addClass("ecwid-with-search"); </script>';
56
+
57
+ return $content;
58
+ }
59
+
60
+ public function body_class($classes)
61
+ {
62
+ if (get_option('ecwid_show_search_box')) {
63
+ $classes[] = 'ecwid-with-search';
64
+ }
65
+
66
+ return $classes;
67
+ }
68
+
69
+ public function on_create_store_page($page_id)
70
+ {
71
+ update_post_meta($page_id, '_wp_page_template', 'full-width-page.php');
72
+ }
73
+ }
74
+
75
+ global $ecwid_current_theme;
76
+ $ecwid_current_theme = new Ecwid_Theme_Responsive();
includes/themes/class-ecwid-theme-twentyfourteen.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once ECWID_THEMES_DIR . '/class-ecwid-theme-base.php';
4
+
5
+ class Ecwid_Theme_2014 extends Ecwid_Theme_Base
6
+ {
7
+ protected $name = 'Twenty Fourteen';
8
+
9
+ protected $adjust_pb_scroll = true;
10
+
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+
15
+ if (ecwid_page_has_productbrowser()) {
16
+ wp_enqueue_style( 'ecwid-theme', plugins_url( 'ecwid-shopping-cart/css/themes/2014.css' ), array('twentyfourteen-style') );
17
+ }
18
+ }
19
+ }
20
+
21
+ $ecwid_current_theme = new Ecwid_Theme_2014();
js/store-editor-common.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function ecwid_get_store_shortcode(content) {
2
+ var found = false;
3
+ var index = 0;
4
+ while (found = wp.shortcode.next('ecwid', content, index)) {
5
+
6
+ if (found && (!found.shortcode.attrs.named.widgets || found.shortcode.attrs.named.widgets.toLowerCase().indexOf('productbrowser') != -1)) {
7
+ break;
8
+ }
9
+ index = found.index + 1;
10
+ }
11
+
12
+ if (typeof found == 'undefined') {
13
+ found = false;
14
+ }
15
+
16
+ return found;
17
+ }
js/store-editor-mce.js ADDED
@@ -0,0 +1,593 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* global tinymce */
2
+ tinymce.PluginManager.add( 'ecwid', function( editor ) {
3
+ var toolbarActive = false;
4
+
5
+ // function parseShortcode( content ) {
6
+ // return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
7
+ // var id, cls, w, cap, img, width,
8
+ // trim = tinymce.trim;
9
+ //
10
+ // id = b.match( /id=['"]([^'"]*)['"] ?/ );
11
+ // if ( id ) {
12
+ // b = b.replace( id[0], '' );
13
+ // }
14
+ //
15
+ // cls = b.match( /align=['"]([^'"]*)['"] ?/ );
16
+ // if ( cls ) {
17
+ // b = b.replace( cls[0], '' );
18
+ // }
19
+ //
20
+ // w = b.match( /width=['"]([0-9]*)['"] ?/ );
21
+ // if ( w ) {
22
+ // b = b.replace( w[0], '' );
23
+ // }
24
+ //
25
+ // c = trim( c );
26
+ // img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
27
+ //
28
+ // if ( img && img[2] ) {
29
+ // cap = trim( img[2] );
30
+ // img = trim( img[1] );
31
+ // } else {
32
+ // // old captions shortcode style
33
+ // cap = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' );
34
+ // img = c;
35
+ // }
36
+ //
37
+ // id = ( id && id[1] ) ? id[1] : '';
38
+ // cls = ( cls && cls[1] ) ? cls[1] : 'alignnone';
39
+ //
40
+ // if ( ! w && img ) {
41
+ // w = img.match( /width=['"]([0-9]*)['"]/ );
42
+ // }
43
+ //
44
+ // if ( w && w[1] ) {
45
+ // w = w[1];
46
+ // }
47
+ //
48
+ // if ( ! w || ! cap ) {
49
+ // return c;
50
+ // }
51
+ //
52
+ // width = parseInt( w, 10 );
53
+ // if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
54
+ // width += 10;
55
+ // }
56
+ //
57
+ // return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'" style="width: '+ width +'px">' +
58
+ // '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ cap +'</dd></dl></div>';
59
+ // });
60
+ // }
61
+ //
62
+ // function getShortcode( content ) {
63
+ // return content.replace( /<div (?:id="attachment_|class="mceTemp)[^>]*>([\s\S]+?)<\/div>/g, function( a, b ) {
64
+ // var out = '';
65
+ //
66
+ // if ( b.indexOf('<img ') === -1 ) {
67
+ // // Broken caption. The user managed to drag the image out?
68
+ // // Try to return the caption text as a paragraph.
69
+ // out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
70
+ //
71
+ // if ( out && out[1] ) {
72
+ // return '<p>' + out[1] + '</p>';
73
+ // }
74
+ //
75
+ // return '';
76
+ // }
77
+ //
78
+ // out = b.replace( /<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>/gi, function( a, b, c, cap ) {
79
+ // var id, cls, w;
80
+ //
81
+ // w = c.match( /width="([0-9]*)"/ );
82
+ // w = ( w && w[1] ) ? w[1] : '';
83
+ //
84
+ // if ( ! w || ! cap ) {
85
+ // return c;
86
+ // }
87
+ //
88
+ // id = b.match( /id="([^"]*)"/ );
89
+ // id = ( id && id[1] ) ? id[1] : '';
90
+ //
91
+ // cls = b.match( /class="([^"]*)"/ );
92
+ // cls = ( cls && cls[1] ) ? cls[1] : '';
93
+ // cls = cls.match( /align[a-z]+/ ) || 'alignnone';
94
+ //
95
+ // cap = cap.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
96
+ // // no line breaks inside HTML tags
97
+ // return a.replace( /[\r\n\t]+/, ' ' );
98
+ // });
99
+ //
100
+ // // convert remaining line breaks to <br>
101
+ // cap = cap.replace( /\s*\n\s*/g, '<br />' );
102
+ //
103
+ // return '[caption id="'+ id +'" align="'+ cls +'" width="'+ w +'"]'+ c +' '+ cap +'[/caption]';
104
+ // });
105
+ //
106
+ // if ( out.indexOf('[caption') !== 0 ) {
107
+ // // the caption html seems broken, try to find the image that may be wrapped in a link
108
+ // // and may be followed by <p> with the caption text.
109
+ // out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
110
+ // }
111
+ //
112
+ // return out;
113
+ // });
114
+ // }
115
+ //
116
+ // function extractImageData( imageNode ) {
117
+ // var classes, extraClasses, metadata, captionBlock, caption, link, width, height,
118
+ // dom = editor.dom,
119
+ // isIntRegExp = /^\d+$/;
120
+ //
121
+ // // default attributes
122
+ // metadata = {
123
+ // attachment_id: false,
124
+ // size: 'custom',
125
+ // caption: '',
126
+ // align: 'none',
127
+ // extraClasses: '',
128
+ // link: false,
129
+ // linkUrl: '',
130
+ // linkClassName: '',
131
+ // linkTargetBlank: false,
132
+ // linkRel: '',
133
+ // title: ''
134
+ // };
135
+ //
136
+ // metadata.url = dom.getAttrib( imageNode, 'src' );
137
+ // metadata.alt = dom.getAttrib( imageNode, 'alt' );
138
+ // metadata.title = dom.getAttrib( imageNode, 'title' );
139
+ //
140
+ // width = dom.getAttrib( imageNode, 'width' );
141
+ // height = dom.getAttrib( imageNode, 'height' );
142
+ //
143
+ // if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) {
144
+ // width = imageNode.naturalWidth || imageNode.width;
145
+ // }
146
+ //
147
+ // if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) {
148
+ // height = imageNode.naturalHeight || imageNode.height;
149
+ // }
150
+ //
151
+ // metadata.customWidth = metadata.width = width;
152
+ // metadata.customHeight = metadata.height = height;
153
+ //
154
+ // classes = tinymce.explode( imageNode.className, ' ' );
155
+ // extraClasses = [];
156
+ //
157
+ // tinymce.each( classes, function( name ) {
158
+ //
159
+ // if ( /^wp-image/.test( name ) ) {
160
+ // metadata.attachment_id = parseInt( name.replace( 'wp-image-', '' ), 10 );
161
+ // } else if ( /^align/.test( name ) ) {
162
+ // metadata.align = name.replace( 'align', '' );
163
+ // } else if ( /^size/.test( name ) ) {
164
+ // metadata.size = name.replace( 'size-', '' );
165
+ // } else {
166
+ // extraClasses.push( name );
167
+ // }
168
+ //
169
+ // } );
170
+ //
171
+ // metadata.extraClasses = extraClasses.join( ' ' );
172
+ //
173
+ // // Extract caption
174
+ // captionBlock = dom.getParents( imageNode, '.wp-caption' );
175
+ //
176
+ // if ( captionBlock.length ) {
177
+ // captionBlock = captionBlock[0];
178
+ //
179
+ // classes = captionBlock.className.split( ' ' );
180
+ // tinymce.each( classes, function( name ) {
181
+ // if ( /^align/.test( name ) ) {
182
+ // metadata.align = name.replace( 'align', '' );
183
+ // }
184
+ // } );
185
+ //
186
+ // caption = dom.select( 'dd.wp-caption-dd', captionBlock );
187
+ // if ( caption.length ) {
188
+ // caption = caption[0];
189
+ //
190
+ // metadata.caption = editor.serializer.serialize( caption )
191
+ // .replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
192
+ // }
193
+ // }
194
+ //
195
+ // // Extract linkTo
196
+ // if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) {
197
+ // link = imageNode.parentNode;
198
+ // metadata.linkUrl = dom.getAttrib( link, 'href' );
199
+ // metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false;
200
+ // metadata.linkRel = dom.getAttrib( link, 'rel' );
201
+ // metadata.linkClassName = link.className;
202
+ // }
203
+ //
204
+ // return metadata;
205
+ // }
206
+ //
207
+ // function hasTextContent( node ) {
208
+ // return node && !! ( node.textContent || node.innerText );
209
+ // }
210
+ //
211
+ // function updateImage( imageNode, imageData ) {
212
+ // var classes, className, node, html, parent, wrap, linkNode,
213
+ // captionNode, dd, dl, id, attrs, linkAttrs, width, height,
214
+ // dom = editor.dom;
215
+ //
216
+ // classes = tinymce.explode( imageData.extraClasses, ' ' );
217
+ //
218
+ // if ( ! classes ) {
219
+ // classes = [];
220
+ // }
221
+ //
222
+ // if ( ! imageData.caption ) {
223
+ // classes.push( 'align' + imageData.align );
224
+ // }
225
+ //
226
+ // if ( imageData.attachment_id ) {
227
+ // classes.push( 'wp-image-' + imageData.attachment_id );
228
+ // if ( imageData.size && imageData.size !== 'custom' ) {
229
+ // classes.push( 'size-' + imageData.size );
230
+ // }
231
+ // }
232
+ //
233
+ // width = imageData.width;
234
+ // height = imageData.height;
235
+ //
236
+ // if ( imageData.size === 'custom' ) {
237
+ // width = imageData.customWidth;
238
+ // height = imageData.customHeight;
239
+ // }
240
+ //
241
+ // attrs = {
242
+ // src: imageData.url,
243
+ // width: width || null,
244
+ // height: height || null,
245
+ // alt: imageData.alt,
246
+ // title: imageData.title || null,
247
+ // 'class': classes.join( ' ' ) || null
248
+ // };
249
+ //
250
+ // dom.setAttribs( imageNode, attrs );
251
+ //
252
+ // linkAttrs = {
253
+ // href: imageData.linkUrl,
254
+ // rel: imageData.linkRel || null,
255
+ // target: imageData.linkTargetBlank ? '_blank': null,
256
+ // 'class': imageData.linkClassName || null
257
+ // };
258
+ //
259
+ // if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
260
+ // // Update or remove an existing link wrapped around the image
261
+ // if ( imageData.linkUrl ) {
262
+ // dom.setAttribs( imageNode.parentNode, linkAttrs );
263
+ // } else {
264
+ // dom.remove( imageNode.parentNode, true );
265
+ // }
266
+ // } else if ( imageData.linkUrl ) {
267
+ // if ( linkNode = dom.getParent( imageNode, 'a' ) ) {
268
+ // // The image is inside a link together with other nodes,
269
+ // // or is nested in another node, move it out
270
+ // dom.insertAfter( imageNode, linkNode );
271
+ // }
272
+ //
273
+ // // Add link wrapped around the image
274
+ // linkNode = dom.create( 'a', linkAttrs );
275
+ // imageNode.parentNode.insertBefore( linkNode, imageNode );
276
+ // linkNode.appendChild( imageNode );
277
+ // }
278
+ //
279
+ // captionNode = editor.dom.getParent( imageNode, '.mceTemp' );
280
+ //
281
+ // if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
282
+ // node = imageNode.parentNode;
283
+ // } else {
284
+ // node = imageNode;
285
+ // }
286
+ //
287
+ // if ( imageData.caption ) {
288
+ //
289
+ // id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null;
290
+ // className = 'wp-caption align' + ( imageData.align || 'none' );
291
+ //
292
+ // if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
293
+ // width = parseInt( width, 10 );
294
+ // width += 10;
295
+ // }
296
+ //
297
+ // if ( captionNode ) {
298
+ // dl = dom.select( 'dl.wp-caption', captionNode );
299
+ //
300
+ // if ( dl.length ) {
301
+ // dom.setAttribs( dl, {
302
+ // id: id,
303
+ // 'class': className,
304
+ // style: 'width: ' + width + 'px'
305
+ // } );
306
+ // }
307
+ //
308
+ // dd = dom.select( '.wp-caption-dd', captionNode );
309
+ //
310
+ // if ( dd.length ) {
311
+ // dom.setHTML( dd[0], imageData.caption );
312
+ // }
313
+ //
314
+ // } else {
315
+ // id = id ? 'id="'+ id +'" ' : '';
316
+ //
317
+ // // should create a new function for generating the caption markup
318
+ // html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' +
319
+ // '<dt class="wp-caption-dt">' + dom.getOuterHTML( node ) + '</dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>';
320
+ //
321
+ // if ( parent = dom.getParent( node, 'p' ) ) {
322
+ // wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
323
+ // parent.parentNode.insertBefore( wrap, parent );
324
+ // dom.remove( node );
325
+ //
326
+ // if ( dom.isEmpty( parent ) ) {
327
+ // dom.remove( parent );
328
+ // }
329
+ // } else {
330
+ // dom.setOuterHTML( node, '<div class="mceTemp">' + html + '</div>' );
331
+ // }
332
+ // }
333
+ // } else if ( captionNode ) {
334
+ // // Remove the caption wrapper and place the image in new paragraph
335
+ // parent = dom.create( 'p' );
336
+ // captionNode.parentNode.insertBefore( parent, captionNode );
337
+ // parent.appendChild( node );
338
+ // dom.remove( captionNode );
339
+ // }
340
+ //
341
+ // if ( wp.media.events ) {
342
+ // wp.media.events.trigger( 'editor:image-update', {
343
+ // editor: editor,
344
+ // metadata: imageData,
345
+ // image: imageNode
346
+ // } );
347
+ // }
348
+ //
349
+ // editor.nodeChanged();
350
+ // // Refresh the toolbar
351
+ // addToolbar( imageNode );
352
+ // }
353
+
354
+ function editStore( img ) {
355
+ ecwid_open_store_popup();
356
+ }
357
+
358
+ function removeImage( node ) {
359
+ var wrap;
360
+
361
+ if ( node.nodeName === 'DIV' && editor.dom.hasClass( node, 'ecwid-store-wrap' ) ) {
362
+ wrap = node;
363
+ } else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
364
+ wrap = editor.dom.getParent( node, 'div.ecwid-store-wrap' );
365
+ }
366
+
367
+ if ( wrap ) {
368
+ if ( wrap.nextSibling ) {
369
+ editor.selection.select( wrap.nextSibling );
370
+ } else if ( wrap.previousSibling ) {
371
+ editor.selection.select( wrap.previousSibling );
372
+ } else {
373
+ editor.selection.select( wrap.parentNode );
374
+ }
375
+
376
+ editor.selection.collapse( true );
377
+ editor.nodeChanged();
378
+ editor.dom.remove( wrap );
379
+ } else {
380
+ editor.dom.remove( node );
381
+ }
382
+ removeToolbar();
383
+
384
+ editor.dom.remove(editor.dom.select('#ecwid-edit-store-button'));
385
+ }
386
+
387
+ function addToolbar( node ) {
388
+ var rectangle, toolbarHtml, toolbar, left,
389
+ dom = editor.dom;
390
+
391
+ removeToolbar(node);
392
+
393
+ // Don't add to other images
394
+ if ( ! node || node.nodeName !== 'IMG' || node.className.indexOf('ecwid-store-editor') == -1 ) {
395
+ return;
396
+ }
397
+
398
+ dom.setAttrib( node, 'data-ecwid-store-select', 1 );
399
+ rectangle = dom.getRect( node );
400
+
401
+ toolbarHtml = '<div class="dashicons dashicons-no-alt remove" data-mce-bogus="1"></div>';
402
+
403
+ toolbar = dom.create( 'div', {
404
+ 'id': 'ecwid-store-toolbar',
405
+ 'data-mce-bogus': '1',
406
+ 'contenteditable': false
407
+ }, toolbarHtml );
408
+
409
+ if ( editor.rtl ) {
410
+ left = rectangle.x + rectangle.w - 82;
411
+ } else {
412
+ left = rectangle.x;
413
+ }
414
+
415
+ editor.getBody().appendChild( toolbar );
416
+ dom.setStyles( toolbar, {
417
+ top: rectangle.y,
418
+ left: left
419
+ });
420
+
421
+ toolbarActive = true;
422
+ }
423
+
424
+ function removeToolbar(parentNode) {
425
+
426
+ if (parentNode && editor.dom.getAttrib( parentNode, 'class') == 'ecwid-store-editor' ) {
427
+ var toolbar = editor.dom.get( 'wp-image-toolbar' );
428
+ if ( toolbar ) {
429
+ editor.dom.remove( toolbar );
430
+ }
431
+ }
432
+
433
+ var toolbar = editor.dom.get( 'ecwid-store-toolbar' );
434
+ if ( toolbar ) {
435
+ editor.dom.remove( toolbar );
436
+ }
437
+
438
+ // also remove image toolbar
439
+
440
+ editor.dom.setAttrib( editor.dom.select( 'img[data-ecwid-store-select]' ), 'data-ecwid-store-select', null );
441
+
442
+ toolbarActive = false;
443
+ }
444
+
445
+ editor.onInit.add(function(editor) {
446
+
447
+ dom = editor.dom;
448
+ dom.bind( editor.getDoc(), 'dragstart', function( event ) {
449
+ var node = editor.selection.getNode();
450
+
451
+ // Prevent dragging images out of the caption elements
452
+ if ( node.nodeName === 'IMG' && dom.getParent( node, '.wp-caption' ) ) {
453
+ event.preventDefault();
454
+ }
455
+
456
+ // Remove toolbar to avoid an orphaned toolbar when dragging an image to a new location
457
+ removeToolbar();
458
+ });
459
+ });
460
+
461
+ editor.onKeyUp.add( function( editor, event ) {
462
+ var node, wrap, P, spacer,
463
+ selection = editor.selection,
464
+ keyCode = event.keyCode,
465
+ dom = editor.dom;
466
+
467
+ if ( keyCode === 46 || keyCode === 8 ) {
468
+ checkEcwid();
469
+ }
470
+ });
471
+
472
+ editor.onKeyDown.add( function( editor, event ) {
473
+ var node, wrap, P, spacer,
474
+ selection = editor.selection,
475
+ keyCode = event.keyCode,
476
+ dom = editor.dom;
477
+
478
+ if ( keyCode === 46 || keyCode === 8 ) {
479
+ node = selection.getNode();
480
+
481
+ if ( node.nodeName === 'DIV' && dom.hasClass( node, 'ecwid-store-wrap' ) ) {
482
+ wrap = node;
483
+ } else if ( node.nodeName === 'IMG' ) {
484
+ wrap = dom.getParent( node, 'div.ecwid-store-wrap' );
485
+ }
486
+
487
+ if ( wrap ) {
488
+ dom.events.cancel( event );
489
+ removeImage( node );
490
+ editor.dom.remove(editor.dom.select('#ecwid-edit-store-button'));
491
+
492
+ return false;
493
+ }
494
+
495
+ removeToolbar();
496
+ }
497
+
498
+ // Key presses will replace the image so we need to remove the toolbar
499
+ if ( toolbarActive ) {
500
+ if ( event.ctrlKey || event.metaKey || event.altKey ||
501
+ ( keyCode < 48 && keyCode > 90 ) || keyCode > 186 ) {
502
+ return;
503
+ }
504
+
505
+ removeToolbar();
506
+ editor.dom.remove(editor.dom.select('#ecwid-edit-store-button'));
507
+
508
+ }
509
+
510
+ });
511
+
512
+ editor.onMouseDown.add( function( editor, event ) {
513
+ if ( editor.dom.getParent( event.target, '#ecwid-store-toolbar' ) ) {
514
+ if ( tinymce.Env.ie ) {
515
+ // Stop IE > 8 from making the wrapper resizable on mousedown
516
+ event.preventDefault();
517
+ }
518
+ } else if ( event.target.nodeName !== 'IMG' ) {
519
+ removeToolbar();
520
+ }
521
+ });
522
+
523
+ editor.onMouseUp.add( function( editor, event ) {
524
+ var image,
525
+ node = event.target,
526
+ dom = editor.dom;
527
+
528
+ // Don't trigger on right-click
529
+ if ( event.button && event.button > 1 ) {
530
+ return;
531
+ }
532
+
533
+ if ( node.nodeName === 'DIV' && dom.getParent( node, '#ecwid-store-toolbar' ) ) {
534
+ image = dom.select( 'img[data-ecwid-store-select]' )[0];
535
+
536
+ if ( image ) {
537
+ editor.selection.select( image );
538
+
539
+ if ( dom.hasClass( node, 'remove' ) ) {
540
+ removeImage( image );
541
+ } else if ( dom.hasClass( node, 'edit' ) ) {
542
+ editStore( image );
543
+ }
544
+ }
545
+ } else if ( node.nodeName === 'IMG' && ! editor.dom.getAttrib( node, 'data-ecwid-store-select' ) ) {
546
+ addToolbar( node );
547
+ } else if ( node.nodeName !== 'IMG' ) {
548
+ removeToolbar();
549
+ }
550
+ });
551
+
552
+ /*
553
+ editor.onCut.add( function() {
554
+ removeToolbar();
555
+
556
+ editor.dom.remove(editor.dom.select('#ecwid-edit-store-button'));
557
+ });
558
+ */
559
+
560
+ // Replace Read More/Next Page tags with images
561
+ editor.onBeforeSetContent.add( function( editor, e ) {
562
+ if ( e.content ) {
563
+
564
+ found = ecwid_get_store_shortcode(e.content);
565
+
566
+ if (!found) return;
567
+
568
+ var content = e.content;
569
+
570
+ var store = '<img height="200" width="100%" data-ecwid-shortcode="' + window.encodeURIComponent(found.content) + '" src="' + ecwid_store_svg + '" data-mce-placeholder="true" data-mce-resize="false" class="ecwid-store-editor mceItem">';
571
+
572
+ e.content = e.content.substr(0, found.index) + store + e.content.substr(found.index + found.content.length);
573
+ }
574
+ });
575
+
576
+ // Replace images with tags
577
+ editor.onPostProcess.add( function( editor, e ) {
578
+
579
+ if ( e.get ) {
580
+
581
+ return e.content = e.content.replace( /(<img [^>]*data-ecwid-shortcode=[^>]+>)/g, function( match, image ) {
582
+
583
+ var data = window.decodeURIComponent($(image).attr('data-ecwid-shortcode'));
584
+
585
+ if ( data ) {
586
+ return data;
587
+ }
588
+
589
+ return match;
590
+ });
591
+ }
592
+ });
593
+ });
js/store-editor-page.js ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ $ = jQuery;
3
+
4
+ $popup = $('#ecwid-store-popup-content');
5
+
6
+ /*
7
+ * Media buttons handlers
8
+ */
9
+ $('#update-ecwid-button,#insert-ecwid-button').click(ecwid_open_store_popup);
10
+
11
+ /*
12
+ * Close button handler
13
+ */
14
+ $('.media-modal-close', $popup).click(function() {
15
+ $popup.removeClass('open');
16
+ return false;
17
+ });
18
+
19
+
20
+ /**
21
+ * Builds params object from the wp.shortcode
22
+ *
23
+ * @param shortcode
24
+ * @returns {*}
25
+ */
26
+ buildParams = function(shortcode) {
27
+ if (!shortcode) return {};
28
+
29
+ var attributes = $.extend({}, shortcode.shortcode.attrs.named);
30
+
31
+ if ($.inArray(attributes.category_view, ['grid', 'list', 'table']) == -1) {
32
+ attributes.category_view = undefined;
33
+ }
34
+
35
+ if (!$.inArray(attributes.search_view, ['grid', 'list', 'table']) == -1) {
36
+ attributes.search_view = undefined;
37
+ }
38
+
39
+ if (!attributes.grid || attributes.grid.match(/^\d+,\d+$/) === null) {
40
+ attributes.grid = '3,3';
41
+ }
42
+
43
+ var grid = attributes.grid.match(/^(\d+),(\d+)$/);
44
+ attributes.grid_rows = grid[1];
45
+ attributes.grid_columns = grid[2];
46
+
47
+ for (var i in {'categories_per_row': 3, 'list': 10, 'table': 20, 'grid_rows': 3, 'grid_columns': 3, 'default_category_id': 0}) {
48
+ parsed = parseInt(attributes[i]);
49
+ if (isNaN(parsed) || parsed < 0) {
50
+ attributes[i] = undefined;
51
+ }
52
+ }
53
+
54
+ var widgets = attributes.widgets.split(/[^a-z^A-Z^0-9^-^_]/);
55
+
56
+ return {
57
+ 'show_search': $.inArray('search', widgets) != -1,
58
+ 'show_categories': $.inArray('categories', widgets) != -1,
59
+ 'show_minicart': $.inArray('minicart', widgets) != -1,
60
+ 'categories_per_row': attributes.categories_per_row,
61
+ 'category_view': attributes.category_view,
62
+ 'search_view': attributes.search_view,
63
+ 'list_rows': attributes.list,
64
+ 'table_rows': attributes.table,
65
+ 'grid_rows': grid[1],
66
+ 'grid_columns': grid[2],
67
+ 'default_category_id': attributes.default_category_id,
68
+ 'minicart_layout': 'attachToCategories'
69
+ };
70
+
71
+ }
72
+
73
+
74
+ /*
75
+ * Returns default parameters object
76
+ */
77
+ getDefaultParams = function() {
78
+ return {
79
+ 'show_search': false,
80
+ 'show_minicart': true,
81
+ 'show_categories': false,
82
+ 'categories_per_row': 3,
83
+ 'grid_rows': 3,
84
+ 'grid_columns': 3,
85
+ 'table_rows': 20,
86
+ 'list_rows': 10,
87
+ 'default_category_id': 0,
88
+ 'category_view': 'grid',
89
+ 'search_view': 'list',
90
+ 'minicart_layout': 'attachToCategories'
91
+ }
92
+ }
93
+
94
+ /*
95
+ * Tests whether there is a valid store shortcode
96
+ */
97
+ checkEcwid = function() {
98
+
99
+ var hasEcwid = false;
100
+ if (tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden()) {
101
+ content = tinyMCE.activeEditor.getBody();
102
+
103
+ hasEcwid = $(content).find('.ecwid-store-editor').length > 0;
104
+ } else {
105
+ hasEcwid = ecwid_get_store_shortcode(jQuery('#content').val());
106
+ }
107
+
108
+ if (hasEcwid) {
109
+ $('.wp-media-buttons').addClass('has-ecwid');
110
+ } else {
111
+ $('.wp-media-buttons').removeClass('has-ecwid');
112
+ }
113
+
114
+ if (tinymce.activeEditor && !tinymce.activeEditor.isHidden()) {
115
+ var body = tinymce.activeEditor.dom.doc.body;
116
+ var button = tinymce.activeEditor.dom.select('#ecwid-edit-store-button');
117
+
118
+ if (hasEcwid && button.length == 0) {
119
+ var button = $('<input type="button" id="ecwid-edit-store-button" contenteditable="false" data-mce-bogus="true" value="' + ecwid_i18n.edit_store_appearance + '" />')
120
+ .appendTo(body);
121
+
122
+ button.click(ecwid_open_store_popup);
123
+ } else if (!hasEcwid && button.length > 0) {
124
+ tinymce.activeEditor.dom.remove(button);
125
+ }
126
+
127
+ if (hasEcwid) {
128
+ var store = $(body).find('.ecwid-store-editor');
129
+ var button = $('#ecwid-edit-store-button', body);
130
+ button.css({
131
+ 'position': 'absolute',
132
+ 'top': '' + (store.offset().top + 168) + 'px',
133
+ 'left': '' + (store.offset().left + store.outerWidth() / 2 - button.outerWidth() / 2 - 2) + 'px'
134
+ });
135
+ }
136
+
137
+ jQuery('#wp_editbtns').css('display', 'none !important');
138
+ }
139
+ }
140
+
141
+ setInterval(checkEcwid, 1000);
142
+
143
+ $('#content-tmce').click(function() {
144
+ checkEcwid()
145
+ });
146
+ /*
147
+ * Handles media modal menus
148
+ */
149
+ $('.media-menu-item', $popup).click(function() {
150
+ $('.media-menu .media-menu-item', $popup).removeClass('active');
151
+ $(this).addClass('active');
152
+
153
+ $('.media-modal-content', $popup).attr('data-active-dialog', $(this).attr('data-content'));
154
+ $('.media-menu').removeClass('visible');
155
+ return false;
156
+ });
157
+
158
+ $('h1', $popup).click(function() {
159
+ $('.media-menu').toggleClass('visible');
160
+ })
161
+
162
+ /*
163
+ * Main button click
164
+ */
165
+ $('.button-primary', $popup).click(function() {
166
+
167
+ var result = {}, defaults = getDefaultParams();
168
+
169
+ result.widgets = 'productbrowser';
170
+ for (var i in {search:1, categories:1, minicart:1}) {
171
+ if ($('input[name=show_' + i + ']').prop('checked')) {
172
+ result.widgets += ' ' + i;
173
+ }
174
+ }
175
+
176
+ getNumber = function(name, fallback) {
177
+ var value = parseInt($('[name=' + name + ']', $popup).val());
178
+
179
+ if (isNaN(value) || value < 0) {
180
+ value = fallback;
181
+ }
182
+
183
+ return value;
184
+ }
185
+
186
+ getString = function(name, values, fallback) {
187
+ var value = $('[name=' + name + ']', $popup).val();
188
+
189
+ if ($.inArray(value, values) == -1) {
190
+ value = fallback;
191
+ }
192
+
193
+ return value;
194
+ }
195
+
196
+ result.categories_per_row = getNumber('categories_per_row', defaults.categories_per_row);
197
+ result.grid = getNumber('grid_rows', defaults.grid_rows) + ',' + getNumber('grid_columns', defaults.grid_columns);
198
+ result.list = getNumber('list_rows', defaults.list_rows);
199
+ result.table = getNumber('table_rows', defaults.table_rows);
200
+ result.default_category_id = getNumber('default_category_id', defaults.default_category_id);
201
+ result.category_view = getString('category_view', ['list', 'grid', 'table'], defaults.category_view);
202
+ result.search_view = getString('search_view', ['list', 'grid', 'table'], defaults.search_view);
203
+ result.minicart_layout = 'attachToCategories';
204
+
205
+
206
+ var existingShortcode = ecwid_get_store_shortcode(jQuery('#content').val());
207
+ var shortcode = {};
208
+ if (!existingShortcode) {
209
+ shortcode.shortcode = new wp.shortcode();
210
+ shortcode.shortcode.tag = 'ecwid';
211
+ shortcode.shortcode.type = 'single';
212
+ } else {
213
+ shortcode = existingShortcode;
214
+ }
215
+
216
+ for (var i in result) {
217
+ shortcode.shortcode.attrs.named[i] = result[i];
218
+ }
219
+
220
+ if (existingShortcode) {
221
+ $('#content').val(
222
+ $('#content').val().replace(existingShortcode.content, shortcode.shortcode.string())
223
+ );
224
+ $(tinymce.activeEditor.getBody()).find('.ecwid-store-editor').attr('data-ecwid-shortcode', shortcode.shortcode.string());
225
+ } else {
226
+
227
+ if (tinymce.activeEditor && !tinymce.activeEditor.isHidden()) {
228
+ tinymce.activeEditor.execCommand('mceInsertContent', false, shortcode.shortcode.string());
229
+ tinymce.activeEditor.execCommand('mceSetContent', false, tinymce.activeEditor.getBody().innerHTML);
230
+ } else {
231
+
232
+ getCursorPosition = function(el) {
233
+ var pos = 0;
234
+ if('selectionStart' in el) {
235
+ pos = el.selectionStart;
236
+ } else if('selection' in document) {
237
+ el.focus();
238
+ var Sel = document.selection.createRange();
239
+ var SelLength = document.selection.createRange().text.length;
240
+ Sel.moveStart('character', -el.value.length);
241
+ pos = Sel.text.length - SelLength;
242
+ }
243
+ return pos;
244
+ }
245
+
246
+ var el = $('#content');
247
+ var cursorPosition = getCursorPosition(el.get(0));
248
+
249
+ el.val(el.val().substr(0, cursorPosition) + shortcode.shortcode.string() + el.val().substr(cursorPosition));
250
+
251
+ }
252
+ }
253
+
254
+
255
+ $('#ecwid-store-popup-content').removeClass('open');
256
+ });
257
+
258
+ updatePreview = function() {
259
+ $('.store-settings input[type=checkbox]', $popup).each(function(idx, el) {
260
+ var widget = $(el).parent().attr('data-ecwid-widget');
261
+ var preview = $('.store-settings-preview svg path.' + widget, $popup);
262
+ if ($(el).prop('checked')) {
263
+ $('.store-settings-wrapper').addClass('ecwid-' + widget);
264
+ } else {
265
+ $('.store-settings-wrapper').removeClass('ecwid-' + widget);
266
+ }
267
+ });
268
+ }
269
+
270
+ $('.store-settings-wrapper label', $popup).hover(
271
+ function() {
272
+ $('.store-settings-wrapper').attr('data-ecwid-widget-hover', $(this).attr('data-ecwid-widget'));
273
+ },
274
+ function() {
275
+ $('.store-settings-wrapper').attr('data-ecwid-widget-hover', '');
276
+ }
277
+ );
278
+
279
+ $('.store-settings input[type=checkbox]', $popup).change(updatePreview);
280
+ });
281
+
282
+ ecwid_open_store_popup = function() {
283
+
284
+ var shortcode;
285
+
286
+ if (tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden()) {
287
+ tinyMCE.activeEditor.save();
288
+
289
+ var content = $(tinyMCE.activeEditor.getBody())
290
+ .find('.ecwid-store-editor')
291
+ .attr('data-ecwid-shortcode');
292
+
293
+ var shortcode = ecwid_get_store_shortcode(window.decodeURIComponent(content));
294
+ } else {
295
+ shortcode = ecwid_get_store_shortcode(jQuery('#content').val());
296
+ }
297
+
298
+ $popup.addClass('open');
299
+
300
+ params = {};
301
+ $.extend(params, getDefaultParams(), buildParams(shortcode));
302
+
303
+ for (var i in params) {
304
+ var el = $('[name=' + i + ']', $popup);
305
+ if (el.attr('type') == 'checkbox') {
306
+ el.prop('checked', params[i]);
307
+ } else {
308
+ el.val(params[i]);
309
+ }
310
+ }
311
+
312
+ // mode determines whether it is a new store or not, and active dialog is the current tab
313
+ // in other words, mode = [add-store,store-settings] and active dialog is [add-store|store-settings, appearance]
314
+ // buttons and menu items are for mode, current title and content are for dialog
315
+ var current = !shortcode ? 'add-store' : 'store-settings';
316
+ $('.media-modal-content', $popup).attr('data-mode', current);
317
+ $('.media-modal-content', $popup).attr('data-active-dialog', current);
318
+ $('.media-menu-item')
319
+ .removeClass('active')
320
+ .filter('[data-content=' + current + ']').addClass('active');
321
+
322
+
323
+ updatePreview();
324
+
325
+
326
+ tinyMCE.activeEditor.execCommand('SelectAll');
327
+ tinyMCE.activeEditor.selection.collapse();
328
+
329
+ return false;
330
+ };
js/themes/responsive.js CHANGED
@@ -35,18 +35,14 @@ function doDefaultLayout()
35
  'margin-right', $('.ecwid-minicart-mini-rolloverContainer').width() - $('.ecwid-shopping-cart-minicart').width()
36
  );
37
 
38
- if ($('.ecwid-shopping-cart-minicart').length > 0
39
- && $('.ecwid-shopping-cart-minicart').closest('.ecwid-productBrowser-auth-mini').length == 0) {
40
-
41
- if ($('.ecwid-search-placeholder').length == 0) {
42
- $('.ecwid-shopping-cart .ecwid-shopping-cart-search .ecwid-SearchPanel').after('<div class="ecwid-search-placeholder"></div>');
43
- }
44
-
45
- $('.ecwid-search-placeholder').click(function() {
46
- $('body').addClass('ecwid-search-open');
47
- $('.ecwid-shopping-cart-search .ecwid-SearchPanel-field').focus();
48
- });
49
  }
 
 
 
 
 
50
  }
51
 
52
  $('body').click(function(e) {
@@ -63,6 +59,10 @@ function doMobileLayout()
63
  'position': 'inherit',
64
  'top': 'auto'
65
  });
 
 
 
 
66
  }
67
 
68
  Ecwid.OnPageLoaded.add(function(args) {
35
  'margin-right', $('.ecwid-minicart-mini-rolloverContainer').width() - $('.ecwid-shopping-cart-minicart').width()
36
  );
37
 
38
+ if ($('.ecwid-search-placeholder').length == 0) {
39
+ $('.ecwid-shopping-cart .ecwid-shopping-cart-search .ecwid-SearchPanel').after('<div class="ecwid-search-placeholder"></div>');
 
 
 
 
 
 
 
 
 
40
  }
41
+
42
+ $('.ecwid-search-placeholder').click(function() {
43
+ $('body').addClass('ecwid-search-open');
44
+ $('.ecwid-shopping-cart-search .ecwid-SearchPanel-field').focus();
45
+ });
46
  }
47
 
48
  $('body').click(function(e) {
59
  'position': 'inherit',
60
  'top': 'auto'
61
  });
62
+ $('.ecwid-shopping-cart-search').css({
63
+ 'position': 'absolute',
64
+ 'top': $('.ecwid-productBrowser').prop('offsetTop') - 50 + 8
65
+ });
66
  }
67
 
68
  Ecwid.OnPageLoaded.add(function(args) {
languages/ecwid-shopping-cart-ru_RU.mo CHANGED
Binary file
languages/ecwid-shopping-cart-ru_RU.po CHANGED
@@ -40,7 +40,7 @@ msgid "Store"
40
  msgstr "Магазин"
41
 
42
  msgid "<strong>Ecwid shopping cart is almost ready</strong>. Please visit <a target=\"_blank\" href=\"%s\">the created page</a> to see your store with demo products. In order to finish the installation, please go to the <a href=\"admin.php?page=ecwid\"><strong>Ecwid settings</strong></a> and configure the plugin."
43
- msgstr "<strong>Эквид-магазин почти готов к использованию</strong>. Пройдите по <a target=\"_blank\" href=\"%s\">ссылке</a>, чтобы посмотреть ваш магазин с демонстрационными продуктами. Чтобы закончить установку, пожалуйста, откройте страницу <a href=\"admin.php?page=ecwid\"><strong>настроек Эквида</strong></a> и настройте плагин."
44
 
45
  msgid "Do you like your Ecwid online store? We'd appreciate it if you add your review and vote for the plugin on Wordpress site."
46
  msgstr "Вам нравится ваш Эквид-магазин? Будем благодарны, если вы оставите отзыв и проголосуете за Эквид на сайте WordPress."
@@ -54,6 +54,12 @@ msgstr "Магазин Ecwid"
54
  msgid "General settings"
55
  msgstr "Основные настройки"
56
 
 
 
 
 
 
 
57
  msgid "General"
58
  msgstr "Основные"
59
 
@@ -154,13 +160,13 @@ msgid "Ecwid Shopping Cart — Appearance settings"
154
  msgstr "Магазин Ecwid — Настройки внешнего вида"
155
 
156
  msgid "Display search box above products"
157
- msgstr "Показывать форму поиска над списком продуктов"
158
 
159
  msgid "Or you can add search box to your website's toolbar using <a href=\"%s\">WordPress native widgets</a>"
160
  msgstr "Или вы можете добавить форму поиска на ваш сайт с помощью <a href=\"%s\">виджетов WordPress</a>"
161
 
162
  msgid "Display horizontal categories above products"
163
- msgstr "Показывать горизонтальное меню категорий над списком продуктов"
164
 
165
  msgid "Or you can add vertical categories to your website's toolbar using <a href=\"%s\">WordPress native widgets</a>"
166
  msgstr "Или вы можете добавить вертикальное меню категорий на ваш сайт с помощью <a href=\"%s\">виджетов WordPress</a>"
@@ -175,7 +181,7 @@ msgid "Number of categories per row"
175
  msgstr "Количество категорий в ряд"
176
 
177
  msgid "Number of products per page"
178
- msgstr "Количество продуктов на странице"
179
 
180
  msgid "Grid view"
181
  msgstr "Вид \"сетка\""
@@ -187,10 +193,10 @@ msgid "Table view"
187
  msgstr "Вид \"таблица\""
188
 
189
  msgid "Here you can control how many products will be displayed per page. These options define maximum values. If there is not enough space to show all product columns, Ecwid will adapt the number of columns to hold all products."
190
- msgstr "Здесь вы можете задать количество отображаемых продуктов на странице. Эти цифры определяют максимальные значения. Если на странице в сетке продуктов будет недостаточно места для отображения всех столбцов, Эквид уменьшит их количество."
191
 
192
  msgid "Default view mode on product pages"
193
- msgstr "Вид страницы продуктов по умолчанию"
194
 
195
  msgid "Grid"
196
  msgstr "Сетка"
@@ -204,8 +210,8 @@ msgstr "Таблица"
204
  msgid "Default view mode on search results"
205
  msgstr "Вид страницы результатов поиска по умолчанию"
206
 
207
- msgid "Ecwid Shopping Cart — General settings"
208
- msgstr "Магазин Ecwid — Основные настройки"
209
 
210
  msgid "Thank you for choosing Ecwid to build your online store"
211
  msgstr "Спасибо вам за то, что выбрали Ecwid для своего интернет-магазина"
@@ -328,4 +334,49 @@ msgid "Back to Store Settings"
328
  msgstr "Вернуться к настройкам"
329
 
330
  msgid "Rate Ecwid at WordPress.org"
331
- msgstr "Оценить Эквид на WordPress.org"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  msgstr "Магазин"
41
 
42
  msgid "<strong>Ecwid shopping cart is almost ready</strong>. Please visit <a target=\"_blank\" href=\"%s\">the created page</a> to see your store with demo products. In order to finish the installation, please go to the <a href=\"admin.php?page=ecwid\"><strong>Ecwid settings</strong></a> and configure the plugin."
43
+ msgstr "<strong>Эквид-магазин почти готов к использованию</strong>. Пройдите по <a target=\"_blank\" href=\"%s\">ссылке</a>, чтобы посмотреть ваш магазин с демонстрационными товарами. Чтобы закончить установку, пожалуйста, откройте страницу <a href=\"admin.php?page=ecwid\"><strong>настроек Эквида</strong></a> и настройте плагин."
44
 
45
  msgid "Do you like your Ecwid online store? We'd appreciate it if you add your review and vote for the plugin on Wordpress site."
46
  msgstr "Вам нравится ваш Эквид-магазин? Будем благодарны, если вы оставите отзыв и проголосуете за Эквид на сайте WordPress."
54
  msgid "General settings"
55
  msgstr "Основные настройки"
56
 
57
+ msgid "Dashboard"
58
+ msgstr "Консоль"
59
+
60
+ msgid "Ecwid Shopping Cart — Connect"
61
+ msgstr "Магазин Ecwid — Подключение"
62
+
63
  msgid "General"
64
  msgstr "Основные"
65
 
160
  msgstr "Магазин Ecwid — Настройки внешнего вида"
161
 
162
  msgid "Display search box above products"
163
+ msgstr "Показывать форму поиска над списком товаров"
164
 
165
  msgid "Or you can add search box to your website's toolbar using <a href=\"%s\">WordPress native widgets</a>"
166
  msgstr "Или вы можете добавить форму поиска на ваш сайт с помощью <a href=\"%s\">виджетов WordPress</a>"
167
 
168
  msgid "Display horizontal categories above products"
169
+ msgstr "Показывать горизонтальное меню категорий над списком товаров"
170
 
171
  msgid "Or you can add vertical categories to your website's toolbar using <a href=\"%s\">WordPress native widgets</a>"
172
  msgstr "Или вы можете добавить вертикальное меню категорий на ваш сайт с помощью <a href=\"%s\">виджетов WordPress</a>"
181
  msgstr "Количество категорий в ряд"
182
 
183
  msgid "Number of products per page"
184
+ msgstr "Количество товаров на странице"
185
 
186
  msgid "Grid view"
187
  msgstr "Вид \"сетка\""
193
  msgstr "Вид \"таблица\""
194
 
195
  msgid "Here you can control how many products will be displayed per page. These options define maximum values. If there is not enough space to show all product columns, Ecwid will adapt the number of columns to hold all products."
196
+ msgstr "Здесь вы можете задать количество отображаемых товаров на странице. Эти цифры определяют максимальные значения. Если все столбцы в сетке товаров не будут помещаться на странице, Эквид автоматически уменьшит количество столбцов."
197
 
198
  msgid "Default view mode on product pages"
199
+ msgstr "Вид страницы товаров по умолчанию"
200
 
201
  msgid "Grid"
202
  msgstr "Сетка"
210
  msgid "Default view mode on search results"
211
  msgstr "Вид страницы результатов поиска по умолчанию"
212
 
213
+ msgid "Ecwid Shopping Cart — Dashboard"
214
+ msgstr "Магазин Ecwid — Консоль"
215
 
216
  msgid "Thank you for choosing Ecwid to build your online store"
217
  msgstr "Спасибо вам за то, что выбрали Ecwid для своего интернет-магазина"
334
  msgstr "Вернуться к настройкам"
335
 
336
  msgid "Rate Ecwid at WordPress.org"
337
+ msgstr "Оценить Эквид на WordPress.org"
338
+
339
+ msgid "Add Store"
340
+ msgstr "Добавить магазин"
341
+
342
+ msgid "Store settings"
343
+ msgstr "Настройки витрины"
344
+
345
+ msgid "Edit Store"
346
+ msgstr "Изменить магазин"
347
+
348
+ msgid "Edit store"
349
+ msgstr "Изменить магазин"
350
+
351
+ msgid "Your store will be shown here!"
352
+ msgstr "Ваш магазин будет показан тут"
353
+
354
+ msgid "Edit Appearance"
355
+ msgstr "Настроить"
356
+
357
+ msgid "Choose widgets to show"
358
+ msgstr "Включите элементы магазина"
359
+
360
+ msgid "Product catalog will be shown automatically"
361
+ msgstr "Каталог товаров появится автоматически"
362
+
363
+ msgid "Show minicart"
364
+ msgstr "Корзина"
365
+
366
+ msgid "Show search"
367
+ msgstr "Поиск"
368
+
369
+ msgid "Show horizontal categories"
370
+ msgstr "Меню категорий"
371
+
372
+ msgid "Additionally, you can add store controls to your website's toolbar using <a %s>WordPress native widgets</a>"
373
+ msgstr "Вы также можете добавить блоки магазина на сайт с помощью <a %s>виджетов WordPress</a>"
374
+
375
+ msgid "Ecwid plugin settings"
376
+ msgstr "Настройки плагина"
377
+
378
+ msgid "Insert into page"
379
+ msgstr "Добавить на страницу"
380
+
381
+ msgid "Save and close"
382
+ msgstr "Сохранить и закрыть"
lib/ecwid_catalog.php CHANGED
@@ -1,272 +1,366 @@
1
  <?php
2
 
3
- function show_ecwid($params) {
4
- $store_id = $params['store_id'];
5
- if (empty($store_id)) {
6
- $store_id = '1003'; //demo mode
 
 
 
 
 
 
 
7
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
- $list_of_views = $params['list_of_views'];
10
-
11
- if (is_array($list_of_views))
12
- foreach ($list_of_views as $k=>$v) {
13
- if (!in_array($v, array('list','grid','table'))) unset($list_of_views[$k]);
14
- }
15
-
16
- if ((!is_array($list_of_views)) || empty($list_of_views)) {
17
- $list_of_views = array('list','grid','table');
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- $ecwid_pb_categoriesperrow = $params['ecwid_pb_categoriesperrow'];
21
- if (empty($ecwid_pb_categoriesperrow)) {
22
- $ecwid_pb_categoriesperrow = 3;
23
- }
24
- $ecwid_pb_productspercolumn_grid = $params['ecwid_pb_productspercolumn_grid'];
25
- if (empty($ecwid_pb_productspercolumn_grid)) {
26
- $ecwid_pb_productspercolumn_grid = 3;
27
- }
28
- $ecwid_pb_productsperrow_grid = $params['ecwid_pb_productsperrow_grid'];
29
- if (empty($ecwid_pb_productsperrow_grid)) {
30
- $ecwid_pb_productsperrow_grid = 3;
31
- }
32
- $ecwid_pb_productsperpage_list = $params['ecwid_pb_productsperpage_list'];
33
- if (empty($ecwid_pb_productsperpage_list)) {
34
- $ecwid_pb_productsperpage_list = 10;
35
- }
36
- $ecwid_pb_productsperpage_table = $params['ecwid_pb_productsperpage_table'];
37
- if (empty($ecwid_pb_productsperpage_table)) {
38
- $ecwid_pb_productsperpage_table = 20;
39
- }
40
- $ecwid_pb_defaultview = $params['ecwid_pb_defaultview'];
41
- if (empty($ecwid_pb_defaultview) || !in_array($ecwid_pb_defaultview, $list_of_views)) {
42
- $ecwid_pb_defaultview = 'grid';
43
- }
44
- $ecwid_pb_searchview = $params['ecwid_pb_searchview'];
45
- if (empty($ecwid_pb_searchview) || !in_array($ecwid_pb_searchview, $list_of_views)) {
46
- $ecwid_pb_searchview = 'list';
47
- }
48
- $ecwid_enable_html_mode = $params['ecwid_enable_html_mode'];
49
- if (empty($ecwid_enable_html_mode)) {
50
- $ecwid_enable_html_mode = false;
51
- }
52
 
53
- $ecwid_com = "app.ecwid.com";
 
 
54
 
 
55
 
56
- $ecwid_default_category_id = $params['ecwid_default_category_id'];
57
-
58
- $ecwid_show_seo_catalog = $params['ecwid_show_seo_catalog'];
59
- if (empty($ecwid_show_seo_catalog)) {
60
- $ecwid_show_seo_catalog = false;
61
- }
62
 
63
- $ecwid_mobile_catalog_link = $params['ecwid_mobile_catalog_link'];
64
- if (empty($ecwid_mobile_catalog_link)) {
65
- $ecwid_mobile_catalog_link = "//$ecwid_com/jsp/$store_id/catalog";
66
- }
67
 
68
- $html_catalog = '';
69
- if ($ecwid_show_seo_catalog) {
70
- if (!empty($_GET['ecwid_product_id'])) {
71
- $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>';
72
- } elseif (!empty($_GET['ecwid_category_id'])) {
73
- $ecwid_default_category_id = intval($_GET['ecwid_category_id']);
74
- }
75
- $html_catalog = show_ecwid_catalog($store_id);
76
- }
77
-
78
- if (empty($html_catalog)) {
79
- $html_catalog = "Your browser does not support JavaScript.<a href=\"{$ecwid_mobile_catalog_link}\">HTML version of this store</a>";
80
- }
81
 
 
 
 
 
 
82
 
83
- if (empty($ecwid_default_category_id)) {
84
- $ecwid_default_category_str = '';
85
- } else {
86
- $ecwid_default_category_str = ',"defaultCategoryId='. $ecwid_default_category_id .'"';
87
- }
 
88
 
89
- $ecwid_is_secure_page = $params['ecwid_is_secure_page'];
90
- if (empty ($ecwid_is_secure_page)) {
91
- $ecwid_is_secure_page = false;
92
- }
93
 
94
- $protocol = "http";
95
- if ($ecwid_is_secure_page) {
96
- $protocol = "https";
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
- $ecwid_element_id = "ecwid-inline-catalog";
100
- if (!empty($params['ecwid_element_id'])) {
101
- $ecwid_element_id = $params['ecwid_element_id'];
102
- }
103
- $integration_code = <<<EOT
104
- <div>
105
- <script type="text/javascript" src="//$ecwid_com/script.js?$store_id"></script>
106
- <div id="$ecwid_element_id">$html_catalog</div>
107
- <script type="text/javascript"> xProductBrowser(
108
- "categoriesPerRow=$ecwid_pb_categoriesperrow",
109
- "views=grid($ecwid_pb_productspercolumn_grid,$ecwid_pb_productsperrow_grid) list($ecwid_pb_productsperpage_list) table($ecwid_pb_productsperpage_table)",
110
- "categoryView=$ecwid_pb_defaultview",
111
- "searchView=$ecwid_pb_searchview",
112
- "id=$ecwid_element_id",
113
- "style="$ecwid_default_category_str);</script>
114
- $ecwid_open_product
115
- </div>
116
- EOT;
117
-
118
- return $integration_code;
119
- }
120
 
121
- function show_ecwid_catalog($ecwid_store_id) {
122
- include_once "ecwid_product_api.php";
123
- $ecwid_store_id = intval($ecwid_store_id);
124
- $api = new EcwidProductApi($ecwid_store_id);
125
 
126
- $ecwid_category_id = intval($_GET['ecwid_category_id']);
127
- $ecwid_product_id = intval($_GET['ecwid_product_id']);
128
 
129
- if (!empty($ecwid_product_id)) {
130
- $params = array(
131
- array("alias" => "p", "action" => "product", "params" => array("id" => $ecwid_product_id)),
 
 
 
132
  array("alias" => "pf", "action" => "profile")
133
  );
134
- $batch_result = $api->get_batch_request($params);
135
- $product = $batch_result["p"];
136
- $profile = $batch_result["pf"];
137
- }
138
- else {
139
- if (empty($ecwid_category_id)) {
140
- $ecwid_category_id = 0;
141
  }
142
- $params = array(
143
- array("alias" => "c", "action" => "categories", "params" => array("parent" => $ecwid_category_id)),
144
- array("alias" => "p", "action" => "products", "params" => array("category" => $ecwid_category_id)),
145
- array("alias" => "pf", "action" => "profile")
146
- );
147
 
148
- $batch_result = $api->get_batch_request($params);
149
 
 
150
  $categories = $batch_result["c"];
151
- $products = $batch_result["p"];
152
- $profile = $batch_result["pf"];
153
- }
154
- $html = '';
155
-
156
- if (is_array($product)) {
157
- $html = "<div class='hproduct'>";
158
- $html .= "<h3 class='ecwid_catalog_product_name fn'>" . htmlentities($product["name"],ENT_COMPAT,'UTF-8') . "</h3>";
159
- if (!empty($product["thumbnailUrl"])) {
160
- $html .= "<div class='ecwid_catalog_product_image photo'><img src='" . $product["thumbnailUrl"] . "' alt='" . htmlentities($product["sku"],ENT_COMPAT,'UTF-8') . " " . htmlentities($product["name"],ENT_COMPAT,'UTF-8') . "'/></div>";
161
- }
162
- $html .= "<div class='ecwid_catalog_product_price price'>Price: " . $product["price"] . "&nbsp;" . $profile["currency"] . "</div>";
163
- $html .= "<div class='ecwid_catalog_product_description description'>" . $product["description"] . "</div>";
164
- $html .= "</div>";
165
- } else {
166
- if (is_array($categories)) {
167
- foreach ($categories as $category) {
168
- $category_url = ecwid_internal_construct_url($category["url"], array("ecwid_category_id" => $category["id"]));
169
  $category_name = $category["name"];
170
- $html .= "<div class='ecwid_catalog_category_name'><a href='" . htmlspecialchars($category_url) . "'>" . $category_name . "</a><br /></div>";
 
 
171
  }
172
  }
173
 
174
- if (is_array($products)) {
175
- foreach ($products as $product) {
176
- $product_url = ecwid_internal_construct_url($product["url"], array("ecwid_product_id" => $product["id"]));
177
- $product_name = $product["name"];
178
- $product_price = $product["price"] . "&nbsp;" . $profile["currency"];
179
- $html .= "<div>";
180
- $html .= "<span class='ecwid_product_name'><a href='" . htmlspecialchars($product_url) . "'>" . $product_name . "</a></span>";
181
- $html .= "&nbsp;&nbsp;<span class='ecwid_product_price'>" . $product_price . "</span>";
182
- $html .= "</div>";
 
 
 
 
 
 
183
  }
184
  }
185
 
 
186
  }
187
- return $html;
188
- }
189
 
190
- function ecwid_is_api_enabled($ecwid_store_id) {
191
- $ecwid_store_id = intval($ecwid_store_id);
192
- $api = new EcwidProductApi($ecwid_store_id);
193
- return $api->is_api_enabled();
194
- }
195
 
196
- function ecwid_zerolen() {
197
- foreach (func_get_args() as $arg) {
198
- if (strlen($arg) == 0) return true;
199
- }
200
- return false;
201
- }
 
 
 
 
 
202
 
203
- function ecwid_get_request_uri() {
204
- static $request_uri = null;
205
-
206
- if (is_null($request_uri)) {
207
- if (isset($_SERVER['REQUEST_URI'])) {
208
- $request_uri = $_SERVER['REQUEST_URI'];
209
- return $request_uri;
210
- }
211
- if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
212
- $request_uri = $_SERVER['HTTP_X_ORIGINAL_URL'];
213
- return $request_uri;
214
- } else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
215
- $request_uri = $_SERVER['HTTP_X_REWRITE_URL'];
216
- return $request_uri;
217
- }
218
-
219
- if (isset($_SERVER['PATH_INFO']) && !ecwid_zerolen($_SERVER['PATH_INFO'])) {
220
- if ($_SERVER['PATH_INFO'] == $_SERVER['PHP_SELF']) {
221
- $request_uri = $_SERVER['PHP_SELF'];
222
- } else {
223
- $request_uri = $_SERVER['PHP_SELF'] . $_SERVER['PATH_INFO'];
224
- }
225
- } else {
226
- $request_uri = $_SERVER['PHP_SELF'];
227
- }
228
- # Append query string
229
- if (isset($_SERVER['argv']) && isset($_SERVER['argv'][0]) && !ecwid_zerolen($_SERVER['argv'][0])) {
230
- $request_uri .= '?' . $_SERVER['argv'][0];
231
- } else if (isset($_SERVER['QUERY_STRING']) && !ecwid_zerolen($_SERVER['QUERY_STRING'])) {
232
- $request_uri .= '?' . $_SERVER['QUERY_STRING'];
233
- }
234
- }
235
- return $request_uri;
236
- }
237
 
238
- function ecwid_internal_construct_url($url_with_anchor, $additional_get_params) {
239
- $request_uri = parse_url(ecwid_get_request_uri());
240
- $base_url = $request_uri['path'];
241
-
242
- // extract anchor
243
- $url_fragments = parse_url($url_with_anchor);
244
- $anchor = $url_fragments["fragment"];
245
- // get params
246
- $get_params = $_GET;
247
- unset ($get_params["ecwid_category_id"]);
248
- unset ($get_params["ecwid_product_id"]);
249
- $get_params = array_merge($get_params, $additional_get_params);
250
-
251
- // add GET parameters
252
- if (count($get_params) > 0) {
253
- $base_url .= "?";
254
- $is_first = true;
255
- foreach ($get_params as $key => $value) {
256
- if (!$is_first) {
257
- $base_url .= "&";
258
  }
259
- $base_url .= $key . "=" . $value;
260
- $is_first = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  }
 
 
262
  }
263
 
264
- // add url anchor (if needed)
265
- if ($anchor != "") {
266
- $base_url .= "#" . $anchor;
 
 
 
 
 
 
 
 
 
267
  }
268
 
269
- return $base_url;
270
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
272
- ?>
 
 
1
  <?php
2
 
3
+ class EcwidCatalog
4
+ {
5
+ var $store_id = 0;
6
+ var $store_base_url = '';
7
+ var $ecwid_api = null;
8
+
9
+ public 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
+ public function get_product($id)
17
+ {
18
+ $params = array
19
+ (
20
+ array("alias" => "p", "action" => "product", "params" => array("id" => $id)),
21
+ array("alias" => "pf", "action" => "profile")
22
+ );
23
+
24
+ $batch_result = $this->ecwid_api->get_batch_request($params);
25
+ $product = $batch_result["p"];
26
+ $profile = $batch_result["pf"];
27
+
28
+ $return = $this->_l('');
29
 
30
+ if (is_array($product))
31
+ {
32
+
33
+ $return .= $this->_l('<div itemscope itemtype="http://schema.org/Product">', 1);
34
+ $return .= $this->_l('<h2 class="ecwid_catalog_product_name" itemprop="name">' . EcwidPlatform::esc_html($product["name"]) . '</h2>');
35
+ $return .= $this->_l('<p class="ecwid_catalog_product_sku" itemprop="sku">' . EcwidPlatform::esc_html($product["sku"]) . '</p>');
36
+
37
+ if (!empty($product["thumbnailUrl"]))
38
+ {
39
+ $return .= $this->_l('<div class="ecwid_catalog_product_image">', 1);
40
+ $return .= $this->_l(
41
+ sprintf(
42
+ '<img itemprop="image" src="%s" alt="%s" />',
43
+ EcwidPlatform::esc_attr($product['thumbnailUrl']),
44
+ EcwidPlatform::esc_attr($product['name'] . ' ' . $product['sku'])
45
+ )
46
+ );
47
+ $return .= $this->_l('</div>', -1);
48
+ }
49
+
50
+ if(is_array($product["categories"]))
51
+ {
52
+ foreach ($product["categories"] as $ecwid_category)
53
+ {
54
+ if($ecwid_category["defaultCategory"] == true)
55
+ {
56
+ $return .= $this->_l('<div class="ecwid_catalog_product_category">' . EcwidPlatform::esc_html($ecwid_category['name']) . '</div>');
57
+ }
58
+ }
59
+ }
60
+
61
+ $return .= $this->_l('<div class="ecwid_catalog_product_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">', 1);
62
+ $return .= $this->_l(EcwidPlatform::get_price_label() . ': <span itemprop="price">' . EcwidPlatform::esc_html($product["price"]) . '</span>');
63
 
64
+ $return .= $this->_l('<span itemprop="priceCurrency">' . EcwidPlatform::esc_html($profile['currency']) . '</span>');
65
+ if (!isset($product['quantity']) || (isset($product['quantity']) && $product['quantity'] > 0)) {
66
+ $return .= $this->_l('<link itemprop="availability" href="http://schema.org/InStock" />In stock');
67
+ }
68
+ $return .= $this->_l('</div>', -1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ $return .= $this->_l('<div class="ecwid_catalog_product_description" itemprop="description">', 1);
71
+ $return .= $this->_l($product['description']);
72
+ $return .= $this->_l('</div>', -1);
73
 
74
+ if (is_array($product['attributes']) && !empty($product['attributes'])) {
75
 
76
+ foreach ($product['attributes'] as $attribute) {
77
+ if (trim($attribute['value']) != '') {
78
+ $return .= $this->_l('<div class="ecwid_catalog_product_attribute">', 1);
 
 
 
79
 
80
+ $attr_string = EcwidPlatform::esc_html($attribute['name']) . ':';
 
 
 
81
 
82
+ if (isset($attribute['internalName']) && $attribute['internalName'] == 'Brand') {
83
+ $attr_string .= '<span itemprop="brand">' . EcwidPlatform::esc_html($attribute['value']) . '</span>';
84
+ } else {
85
+ $attr_string .= EcwidPlatform::esc_html($attribute['value']);
86
+ }
 
 
 
 
 
 
 
 
87
 
88
+ $return .= $this->_l($attr_string);
89
+ $return .= $this->_l('</div>', -1);
90
+ }
91
+ }
92
+ }
93
 
94
+ if (is_array($product["options"]))
95
+ {
96
+ $allowed_types = array('TEXTFIELD', 'DATE', 'TEXTAREA', 'SELECT', 'RADIO', 'CHECKBOX');
97
+ foreach($product["options"] as $product_options)
98
+ {
99
+ if (!in_array($product_options['type'], $allowed_types)) continue;
100
 
101
+ $return .= $this->_l('<div class="ecwid_catalog_product_options">', 1);
102
+ $return .=$this->_l('<span>' . EcwidPlatform::esc_html($product_options["name"]) . '</span>');
 
 
103
 
104
+ if($product_options["type"] == "TEXTFIELD" || $product_options["type"] == "DATE")
105
+ {
106
+ $return .=$this->_l('<input type="text" size="40" name="'. EcwidPlatform::esc_attr($product_options["name"]) . '">');
107
+ }
108
+ if($product_options["type"] == "TEXTAREA")
109
+ {
110
+ $return .=$this->_l('<textarea name="' . EcwidPlatform::esc_attr($product_options["name"]) . '></textarea>');
111
+ }
112
+ if ($product_options["type"] == "SELECT")
113
+ {
114
+ $return .= $this->_l('<select name='. $product_options["name"].'>', 1);
115
+ foreach ($product_options["choices"] as $options_param)
116
+ {
117
+ $return .= $this->_l(
118
+ sprintf(
119
+ '<option value="%s">%s (%s)</option>',
120
+ EcwidPlatform::esc_attr($options_param['text']),
121
+ EcwidPlatform::esc_html($options_param['text']),
122
+ EcwidPlatform::esc_html($options_param['priceModifier'])
123
+ )
124
+ );
125
+ }
126
+ $return .= $this->_l('</select>', -1);
127
+ }
128
+ if($product_options["type"] == "RADIO")
129
+ {
130
+ foreach ($product_options["choices"] as $options_param)
131
+ {
132
+ $return .= $this->_l(
133
+ sprintf(
134
+ '<input type="radio" name="%s" value="%s" />%s (%s)',
135
+ EcwidPlatform::esc_attr($product_options['name']),
136
+ EcwidPlatform::esc_attr($options_param['text']),
137
+ EcwidPlatform::esc_html($options_param['text']),
138
+ EcwidPlatform::esc_html($options_param['priceModifier'])
139
+ )
140
+ );
141
+ }
142
+ }
143
+ if($product_options["type"] == "CHECKBOX")
144
+ {
145
+ foreach ($product_options["choices"] as $options_param)
146
+ {
147
+ $return .= $this->_l(
148
+ sprintf(
149
+ '<input type="checkbox" name="%s" value="%s" />%s (%s)',
150
+ EcwidPlatform::esc_attr($product_options['name']),
151
+ EcwidPlatform::esc_attr($options_param['text']),
152
+ EcwidPlatform::esc_html($options_param['text']),
153
+ EcwidPlatform::esc_html($options_param['priceModifier'])
154
+ )
155
+ );
156
+ }
157
+ }
158
 
159
+ $return .= $this->_l('</div>', -1);
160
+ }
161
+ }
162
+
163
+ if (is_array($product["galleryImages"]))
164
+ {
165
+ foreach ($product["galleryImages"] as $galleryimage)
166
+ {
167
+ if (empty($galleryimage["alt"])) $galleryimage["alt"] = htmlspecialchars($product["name"]);
168
+ $return .= $this->_l(
169
+ sprintf(
170
+ '<img src="%s" alt="%s" title="%s" />',
171
+ EcwidPlatform::esc_attr($galleryimage['url']),
172
+ EcwidPlatform::esc_attr($galleryimage['alt']),
173
+ EcwidPlatform::esc_attr($galleryimage['alt'])
174
+ )
175
+ );
176
+ }
177
+ }
 
 
178
 
179
+ $return .= $this->_l("</div>", -1);
180
+ }
 
 
181
 
182
+ return $return;
183
+ }
184
 
185
+ public function get_category($id)
186
+ {
187
+ $params = array
188
+ (
189
+ array("alias" => "c", "action" => "categories", "params" => array("parent" => $id)),
190
+ array("alias" => "p", "action" => "products", "params" => array("category" => $id)),
191
  array("alias" => "pf", "action" => "profile")
192
  );
193
+ if ($id > 0) {
194
+ $params[] = array('alias' => 'category', "action" => "category", "params" => array("id" => $id));
 
 
 
 
 
195
  }
 
 
 
 
 
196
 
197
+ $batch_result = $this->ecwid_api->get_batch_request($params);
198
 
199
+ $category = $id > 0 ? $batch_result['category'] : null;
200
  $categories = $batch_result["c"];
201
+ $products = $batch_result["p"];
202
+ $profile = $batch_result["pf"];
203
+
204
+ $return = $this->_l('');
205
+
206
+ if (!is_null($category)) {
207
+ $return .= $this->_l('<h2>' . EcwidPlatform::esc_html($category['name']) . '</h2>');
208
+ $return .= $this->_l('<div>' . $category['description'] . '</div>');
209
+ }
210
+
211
+ if (is_array($categories))
212
+ {
213
+ foreach ($categories as $category)
214
+ {
215
+ $category_url = $this->get_category_url($category);
216
+
 
 
217
  $category_name = $category["name"];
218
+ $return .= $this->_l('<div class="ecwid_catalog_category_name">', 1);
219
+ $return .= $this->_l('<a href="' . EcwidPlatform::esc_attr($category_url) . '">' . EcwidPlatform::esc_html($category_name) . '</a>');
220
+ $return .= $this->_l('</div>', -1);
221
  }
222
  }
223
 
224
+ if (is_array($products))
225
+ {
226
+ foreach ($products as $product)
227
+ {
228
+
229
+ $product_url = $this->get_product_url($product);
230
+
231
+ $product_name = $product['name'];
232
+ $product_price = $product['price'] . ' ' . $profile['currency'];
233
+ $return .= $this->_l('<div>', 1);
234
+ $return .= $this->_l('<span class="ecwid_product_name">', 1);
235
+ $return .= $this->_l('<a href="' . EcwidPlatform::esc_attr($product_url) . '">' . EcwidPlatform::esc_html($product_name) . '</a>');
236
+ $return .= $this->_l('</span>', -1);
237
+ $return .= $this->_l('<span class="ecwid_product_price">' . EcwidPlatform::esc_html($product_price) . '</span>');
238
+ $return .= $this->_l('</div>', -1);
239
  }
240
  }
241
 
242
+ return $return;
243
  }
 
 
244
 
245
+ public function parse_escaped_fragment($escaped_fragment)
246
+ {
247
+ $fragment = urldecode($escaped_fragment);
248
+ $return = array();
 
249
 
250
+ if (preg_match('/^(\/~\/)([a-z]+)\/(.*)$/', $fragment, $matches)) {
251
+ parse_str($matches[3], $return);
252
+ $return['mode'] = $matches[2];
253
+ } elseif (preg_match('!.*/(p|c)/([0-9]*)!', $fragment, $matches)) {
254
+ if (count($matches) == 3 && in_array($matches[1], array('p', 'c'))) {
255
+ $return = array(
256
+ 'mode' => 'p' == $matches[1] ? 'product' : 'category',
257
+ 'id' => $matches[2]
258
+ );
259
+ }
260
+ }
261
 
262
+ return $return;
263
+ }
264
+
265
+ public function get_category_name($id)
266
+ {
267
+ $category = $this->ecwid_api->get_category($id);
268
+
269
+ $result = '';
270
+ if (is_array($category) && isset($category['name'])) {
271
+ $result = $category['name'];
272
+ }
273
+
274
+ return $result;
275
+ }
276
+
277
+ public function get_product_name($id)
278
+ {
279
+ $product = $this->ecwid_api->get_product($id);
280
+
281
+ $result = '';
282
+ if (is_array($product) && isset($product['name'])) {
283
+ $result = $product['name'];
284
+ }
285
+
286
+ return $result;
287
+ }
288
+
289
+
290
+ public function get_category_description($id)
291
+ {
292
+ $category = $this->ecwid_api->get_category($id);
 
 
 
293
 
294
+ $result = '';
295
+ if (is_array($category) && isset($category['description'])) {
296
+ $result = $category['description'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  }
298
+
299
+ return $result;
300
+ }
301
+
302
+ public function get_product_description($id)
303
+ {
304
+ $product = $this->ecwid_api->get_product($id);
305
+
306
+ $result = '';
307
+ if (is_array($product) && isset($product['description'])) {
308
+ $result = $product['description'];
309
+ }
310
+
311
+ return $result;
312
+ }
313
+
314
+ public function get_product_url($product)
315
+ {
316
+ if (is_numeric($product) && $this->ecwid_api->is_api_enabled()) {
317
+ $product = $this->ecwid_api->get_product($product);
318
+ }
319
+
320
+ return $this->get_entity_url($product, 'p');
321
+ }
322
+
323
+ public function get_category_url($category)
324
+ {
325
+ if (is_numeric($category) && $this->ecwid_api->is_api_enabled()) {
326
+ $category = $this->ecwid_api->get_category($category);
327
  }
328
+
329
+ return $this->get_entity_url($category, 'c');
330
  }
331
 
332
+ protected function get_entity_url($entity, $type) {
333
+
334
+ $link = $this->store_base_url;
335
+
336
+ if (is_numeric($entity)) {
337
+ return $link . '#!/' . $type . '/' . $entity;
338
+ } elseif (is_array($entity) && isset($entity['url'])) {
339
+ $link .= substr($entity['url'], strpos($entity['url'], '#'));
340
+ }
341
+
342
+ return $link;
343
+
344
  }
345
 
346
+ /*
347
+ * A helper function to produce indented html output.
348
+ * Indent change need to be 1 for opening tag lines and -1 for closing tag lines.
349
+ * Regular lines should omit the second parameter.
350
+ * Example:
351
+ * _l('<parent-tag>', 1);
352
+ * _l('<content-tag>content</content-tag>');
353
+ * _l('</parent-tag>', -1)
354
+ *
355
+ */
356
+ protected function _l($code, $indent_change = 0)
357
+ {
358
+ static $indent = 0;
359
+
360
+ if ($indent_change < 0) $indent -= 1;
361
+ $str = str_repeat(' ', $indent) . $code . "\n";
362
+ if ($indent_change > 0) $indent += 1;
363
 
364
+ return $str;
365
+ }
366
+ }
lib/ecwid_platform.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class EcwidPlatform {
4
+
5
+ static public function esc_attr($value)
6
+ {
7
+ return esc_attr($value);
8
+ }
9
+
10
+ static public function esc_html($value)
11
+ {
12
+ return esc_html($value);
13
+ }
14
+
15
+ static public function get_price_label()
16
+ {
17
+ return __('Price', 'ecwid-shopping-cart');
18
+ }
19
+
20
+ static public function fetch_url($url)
21
+ {
22
+ $result = wp_remote_get($url);
23
+
24
+ $return = array(
25
+ 'code' => '',
26
+ 'data' => '',
27
+ 'message' => ''
28
+ );
29
+
30
+ if (is_array($result)) {
31
+ $return = array(
32
+ 'code' => $result['response']['code'],
33
+ 'data' => $result['body']
34
+ );
35
+ } elseif (is_object($result)) {
36
+ $return = array(
37
+ 'code' => $result->get_error_code(),
38
+ 'data' => $result->get_error_data(),
39
+ 'message' => $result->get_error_message()
40
+ );
41
+ }
42
+
43
+ return $return;
44
+
45
+ }
46
+ }
lib/ecwid_product_api.php CHANGED
@@ -1,235 +1,214 @@
1
  <?php
2
 
 
 
3
  class EcwidProductApi {
4
- var $store_id = '';
5
-
6
- var $error = '';
7
-
8
- var $error_code = '';
9
-
10
- var $ECWID_PRODUCT_API_ENDPOINT = '';
11
- function __construct($store_id) {
12
- $this->ECWID_PRODUCT_API_ENDPOINT = 'http://app.ecwid.com/api/v1';
13
-
14
- $this->store_id = intval($store_id);
15
- }
16
-
17
- function EcwidProductApi($store_id) {
18
- if(version_compare(PHP_VERSION,"5.0.0","<")) {
19
- $this->__construct($store_id);
20
- }
21
- }
22
-
23
- function internal_parse_json($json) {
24
- if(version_compare(PHP_VERSION,"5.2.0",">=")) {
25
- return json_decode($json, true);
26
- }
27
- include_once('JSON.php');
28
- $json_parser = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
29
- return $json_parser->decode($json);
30
- }
31
-
32
- function internal_fetch_url_libcurl($url) {
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";
37
- $ch = curl_init();
38
-
39
- curl_setopt ($ch, CURLOPT_URL, $url);
40
- curl_setopt ($ch, CURLOPT_HEADER, 0);
41
- curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
42
- curl_setopt ($ch, CURLOPT_HTTPGET, 1);
43
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
44
-
45
- $body = curl_exec ($ch);
46
- $errno = curl_errno ($ch);
47
- $error = curl_error($ch);
48
-
49
- $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
50
- $result = array();
51
- if( $error ) {
52
- return array("code"=>"0","data"=>"libcurl error($errno): $error");
53
- }
54
-
55
- return array("code"=>$httpcode, "data"=>$body);
56
- }
57
-
58
- function process_request($url) {
59
-
60
- $result = $this->internal_fetch_url_libcurl($url);
61
- if ($result['code'] == 200) {
62
- $this->error = '';
63
- $this->error_code = '';
64
- $json = $result['data'];
65
- return $this->internal_parse_json($json);
66
- } else {
67
- $this->error = $result['data'];
68
- $this->error_code = $result['code'];
69
- return false;
70
- }
71
- }
72
-
73
- function get_all_categories() {
74
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/categories";
75
- $categories = $this->process_request($api_url);
76
- return $categories;
77
- }
78
-
79
- function get_subcategories_by_id($parent_category_id = 0) {
80
- $parent_category_id = intval($parent_category_id);
81
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/categories?parent=" .
82
- $parent_category_id;
83
- $categories = $this->process_request($api_url);
84
- return $categories;
85
- }
86
-
87
- function get_all_products() {
88
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products";
89
- $products = $this->process_request($api_url);
90
- return $products;
91
- }
92
-
93
-
94
- function get_products_by_category_id($category_id = 0) {
95
- $category_id = intval($category_id);
96
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products?category=" . $category_id;
97
- $products = $this->process_request($api_url);
98
- return $products;
99
- }
100
-
101
- function get_product($product_id) {
102
- static $cached;
103
-
104
- $product_id = intval($product_id);
105
-
106
- if (isset($cached[$product_id])) {
107
- return $cached[$product_id];
108
- }
109
-
110
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/product?id=" . $product_id;
111
- $cached[$product_id] = $this->process_request($api_url);
112
-
113
- return $cached[$product_id];
114
- }
115
-
116
- function get_category($category_id) {
117
- static $cached = array();
118
-
119
- $category_id = intval($category_id);
120
-
121
- if (isset($cached[$category_id])) {
122
- return $cached[$category_id];
123
- }
124
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
125
- $cached[$category_id] = $this->process_request($api_url);
126
-
127
- return $cached[$category_id];
128
- }
129
 
130
- function get_batch_request($params) {
131
- if (!is_array($params)) {
132
- return false;
133
- } else {
134
- $api_url = '';
135
- foreach ($params as $param) {
136
- $alias = $param["alias"];
137
- $action = $param["action"];
138
-
139
- if (isset($param['params']))
140
- $action_params = $param["params"];
141
-
142
- if (!empty($api_url))
143
- $api_url .= "&";
144
-
145
- $api_url .= ($alias . "=" . $action);
146
-
147
- // if there are the parameters - add it to url
148
- if (is_array($action_params)) {
149
- $action_param_str = "?";
150
- $is_first = true;
151
- foreach ($action_params as $action_param_name => $action_param_value) {
152
- if (!$is_first) {
153
- $action_param_str .= "&";
154
- }
155
- $action_param_str .= $action_param_name . "=" . $action_param_value;
156
- $is_first = false;
157
- }
158
- $action_param_str = urlencode($action_param_str);
159
- $api_url .= $action_param_str;
160
- }
161
- }
162
-
163
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/batch?". $api_url;
164
- $data = $this->process_request($api_url);
165
- return $data;
166
- }
167
- }
168
- function get_random_products($count) {
169
- $count = intval($count);
170
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/random_products?count=" . $count;
171
- $random_products = $this->process_request($api_url);
172
- return $random_products;
173
- }
174
-
175
- function get_profile() {
176
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
177
- $profile = $this->process_request($api_url);
178
- return $profile;
179
- }
180
-
181
- function is_api_enabled() {
182
- // quick and lightweight request
183
- $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
184
-
185
- $this->process_request($api_url);
186
- if ($this->error_code === '') {
187
- return true;
188
- } else {
189
- return false;
190
- }
191
- }
192
-
193
- function get_method_response_stream($method)
194
- {
195
- $request_url = '';
196
- switch($method) {
197
- case 'products':
198
- case 'categories':
199
- $request_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/' . $method;
200
- break;
201
- default:
202
- return false;
203
- }
204
-
205
- $stream = null;
206
-
207
- try {
208
- if (ini_get('allow_url_fopen')) {
209
- $stream = fopen($request_url, 'r');
210
- } elseif (version_compare(PHP_VERSION, '5.1.0')) {
211
-
212
- $body = '';
213
-
214
- if (defined('WP_CONTENT_DIR') && function_exists('get_temp_dir') && function_exists('wp_remote_get')) {
215
- // we are in wordpress
216
- $response = wp_remote_get($request_url);
217
- $body = $response['body'];
218
- } else {
219
- $response = internal_fetch_url_libcurl($request_url);
220
- $body = $response['data'];
221
- }
222
-
223
- $stream = fopen('php://temp', 'rw');
224
- fwrite($stream, $body);
225
- rewind($stream);
226
- }
227
- } catch (Exception $e) {
228
- $stream = null;
229
- }
230
-
231
- return $stream;
232
- }
233
- }
234
 
235
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ include_once dirname(__FILE__) . '/ecwid_platform.php';
4
+
5
  class EcwidProductApi {
6
+
7
+ var $store_id = '';
8
+
9
+ var $error = '';
10
+
11
+ var $error_code = '';
12
+
13
+ var $ECWID_PRODUCT_API_ENDPOINT = '';
14
+
15
+ function __construct($store_id) {
16
+
17
+ $this->ECWID_PRODUCT_API_ENDPOINT = 'http://app.ecwid.com/api/v1';
18
+ $this->store_id = intval($store_id);
19
+ }
20
+
21
+ function process_request($url) {
22
+
23
+ $result = false;
24
+ $fetch_result = EcwidPlatform::fetch_url($url);
25
+
26
+ if ($fetch_result['code'] == 200) {
27
+ $this->error = '';
28
+ $this->error_code = '';
29
+ $json = $fetch_result['data'];
30
+ $result = json_decode($json, true);
31
+ } else {
32
+ $this->error = $fetch_result['data'];
33
+ $this->error_code = $fetch_result['code'];
34
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ return $result;
37
+ }
38
+
39
+ function get_all_categories() {
40
+
41
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/categories';
42
+ $categories = $this->process_request($api_url);
43
+
44
+ return $categories;
45
+ }
46
+
47
+ function get_subcategories_by_id($parent_category_id = 0) {
48
+
49
+ $parent_category_id = intval($parent_category_id);
50
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/categories?parent=' . $parent_category_id;
51
+ $categories = $this->process_request($api_url);
52
+
53
+ return $categories;
54
+ }
55
+
56
+ function get_all_products() {
57
+
58
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/products';
59
+ $products = $this->process_request($api_url);
60
+
61
+ return $products;
62
+ }
63
+
64
+
65
+ function get_products_by_category_id($category_id = 0) {
66
+
67
+ $category_id = intval($category_id);
68
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/products?category=" . $category_id;
69
+ $products = $this->process_request($api_url);
70
+
71
+ return $products;
72
+ }
73
+
74
+ function get_product($product_id) {
75
+
76
+ static $cached;
77
+
78
+ $product_id = intval($product_id);
79
+
80
+ if (isset($cached[$product_id])) {
81
+ return $cached[$product_id];
82
+ }
83
+
84
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/product?id=" . $product_id;
85
+ $cached[$product_id] = $this->process_request($api_url);
86
+
87
+ return $cached[$product_id];
88
+ }
89
+
90
+ function get_category($category_id) {
91
+
92
+ static $cached = array();
93
+
94
+ $category_id = intval($category_id);
95
+
96
+ if (isset($cached[$category_id])) {
97
+ return $cached[$category_id];
98
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/category?id=" . $category_id;
101
+ $cached[$category_id] = $this->process_request($api_url);
102
+
103
+ return $cached[$category_id];
104
+ }
105
+
106
+ function get_batch_request($params) {
107
+
108
+ if (!is_array($params)) {
109
+ return false;
110
+ }
111
+
112
+ $api_url = '';
113
+ foreach ($params as $param) {
114
+
115
+ $alias = $param["alias"];
116
+ $action = $param["action"];
117
+
118
+ if (isset($param['params']))
119
+ $action_params = $param["params"];
120
+
121
+ if (!empty($api_url))
122
+ $api_url .= "&";
123
+
124
+ $api_url .= ($alias . "=" . $action);
125
+
126
+ // if there are the parameters - add it to url
127
+ if (is_array($action_params)) {
128
+
129
+ $action_param_str = "?";
130
+ $is_first = true;
131
+
132
+ foreach ($action_params as $action_param_name => $action_param_value) {
133
+ if (!$is_first) {
134
+ $action_param_str .= "&";
135
+ }
136
+ $action_param_str .= $action_param_name . "=" . $action_param_value;
137
+ $is_first = false;
138
+ }
139
+
140
+ $action_param_str = urlencode($action_param_str);
141
+ $api_url .= $action_param_str;
142
+ }
143
+
144
+ }
145
+
146
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/batch?". $api_url;
147
+ $data = $this->process_request($api_url);
148
+
149
+ return $data;
150
+ }
151
+
152
+ function get_random_products($count) {
153
+
154
+ $count = intval($count);
155
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/random_products?count=" . $count;
156
+ $random_products = $this->process_request($api_url);
157
+
158
+ return $random_products;
159
+ }
160
+
161
+ function get_profile() {
162
+
163
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
164
+ $profile = $this->process_request($api_url);
165
+
166
+ return $profile;
167
+ }
168
+
169
+ function is_api_enabled() {
170
+
171
+ // quick and lightweight request
172
+ $api_url = $this->ECWID_PRODUCT_API_ENDPOINT . "/" . $this->store_id . "/profile";
173
+
174
+ $this->process_request($api_url);
175
+
176
+ return $this->error_code === '';
177
+ }
178
+
179
+ function get_method_response_stream($method)
180
+ {
181
+
182
+ $request_url = '';
183
+ switch($method) {
184
+
185
+ case 'products':
186
+ case 'categories':
187
+ $request_url = $this->ECWID_PRODUCT_API_ENDPOINT . '/' . $this->store_id . '/' . $method;
188
+ break;
189
+ default:
190
+ return false;
191
+ }
192
+
193
+ $stream = null;
194
+
195
+ try {
196
+
197
+ if (ini_get('allow_url_fopen')) {
198
+ $stream = fopen($request_url, 'r');
199
+ } else {
200
+ $response = EcwidPlatform::fetch_url($request_url);
201
+ $body = $response['data'];
202
+ $stream = fopen('php://temp', 'rw');
203
+ fwrite($stream, $body);
204
+ rewind($stream);
205
+ }
206
+
207
+ } catch (Exception $e) {
208
+
209
+ $stream = null;
210
+ }
211
+
212
+ return $stream;
213
+ }
214
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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: 2.8
5
  Tested up to: 4.0
6
- Stable tag: 2.6
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
 
@@ -110,6 +110,13 @@ http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
110
  * [Ecwid site](http://www.ecwid.com/?source=wporg-plugin-site "Ecwid Site")
111
 
112
  == Changelog ==
 
 
 
 
 
 
 
113
  = 2.6 =
114
  - **Ecwid's new SEO URLs compatibility.** The new Ecwid clean URLs have been released a few days ago for all Ecwid users. Our WordPress plugin is already fully compatible with the new URLs. Your store pages will be better indexed by search engines and the search results will look more attractive as the links themselves will mention the product/category they lead to. Of course, Ecwid will handle all redirects, backward compatibility with the old URL scheme and avoid any duplicate issues. Enjoy the new SE-friendly URLs with no trouble.
115
  - **Improved formatting of product snippets markup.** In this update we tidied up in the product HTML representations generated for search engines and fixes a few issues in the products data markup. In particular, the price and availability tags have been re-formatted according to the Google recommendations to ensure better search engine results.
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: 2.8
5
  Tested up to: 4.0
6
+ Stable tag: 2.7
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
 
110
  * [Ecwid site](http://www.ecwid.com/?source=wporg-plugin-site "Ecwid Site")
111
 
112
  == Changelog ==
113
+ = 2.7 =
114
+ - **A brand new 'Add store' tool in WordPress editor toolbar.** Ecwid is now integrated with WordPress WYSIWYG editor: click the 'Add Store' button in the page editor toolbar, chose widgets to show, adjust the appearance and place your store on any page of your site. Now you can decide what store widgets to show and configure store appearance right in the page editor.
115
+ - **New "[ecwid]" shortcode.** The new shortcode allows you to control every aspect of your store appearance by means of tweaking the shortcode parameters right in the store page code. Display/hide the search widget, choose the minicart layout you like, display different store categories on different site pages and so on. This shortcode serves the "Add Store" button mentioned above and almost every tweak is available in the new "Add Store" window so you don't have to edit any code in most cases. Still, an advanced Wordpress user may consider using shortcodes for more flexible and quick integration.
116
+ - **Improved behavior of single product widgets.** If you put a single product widget on your site using the [ecwid_product] shortcode, you might notice that it opens a popup with the customer cart when a customer purchases the product. Now single product widgets are smarter: when the customer decides to buy a product and opens a cart page, the main store page on your site will be opened providing the customer with the built-in cart&checkout functionality. The checkout layout will fit better your site design and provide better buying experience when it's embedded into a page rather than in a popup-like window.
117
+ - **Fix for the Envision theme.** The Envision theme didn't display Ecwid widgets properly because of a custom page content generation it uses. We issued a workaround from our side to let all Envision users install and use Ecwid plugin on their sites. If you use Envision theme and want to set up an online store on your site, go ahead and install Ecwid plugin, it will work OK for you.
118
+ - **Fixes of PHP notices.** Some of Ecwid users discovered a few PHP notices (warnings) on their site referring to the Ecwid plugin. Although those didn't break anything, they could be quite annoying. We cleaned up the plugin code to get rid of those warning messages, now the plugin should work without any odd message.
119
+
120
  = 2.6 =
121
  - **Ecwid's new SEO URLs compatibility.** The new Ecwid clean URLs have been released a few days ago for all Ecwid users. Our WordPress plugin is already fully compatible with the new URLs. Your store pages will be better indexed by search engines and the search results will look more attractive as the links themselves will mention the product/category they lead to. Of course, Ecwid will handle all redirects, backward compatibility with the old URL scheme and avoid any duplicate issues. Enjoy the new SE-friendly URLs with no trouble.
122
  - **Improved formatting of product snippets markup.** In this update we tidied up in the product HTML representations generated for search engines and fixes a few issues in the products data markup. In particular, the price and availability tags have been re-formatted according to the Google recommendations to ensure better search engine results.
templates/advanced-settings.php CHANGED
@@ -8,6 +8,7 @@
8
 
9
  <fieldset>
10
 
 
11
  <div class="pure-control-group bottom-border">
12
 
13
  <?php if (ecwid_is_paid_account()): ?>
@@ -58,6 +59,9 @@
58
 
59
  <hr />
60
 
 
 
 
61
  <div class="pure-control-group last">
62
  <label for="ecwid_sso_secret_key">
63
  <?php _e('Single Sign-On Secret Key', 'ecwid-shopping-cart'); ?>
8
 
9
  <fieldset>
10
 
11
+ <?php if (get_option('ecwid_show_appearance_menu') == 'Y'): ?>
12
  <div class="pure-control-group bottom-border">
13
 
14
  <?php if (ecwid_is_paid_account()): ?>
59
 
60
  <hr />
61
 
62
+ <?php endif; ?>
63
+
64
+
65
  <div class="pure-control-group last">
66
  <label for="ecwid_sso_secret_key">
67
  <?php _e('Single Sign-On Secret Key', 'ecwid-shopping-cart'); ?>
templates/appearance-settings.php CHANGED
@@ -1,11 +1,3 @@
1
- <?php
2
- function ecwid_embed_svg($name) {
3
- $code = file_get_contents(ECWID_PLUGIN_DIR . '/images/' . $name . '.svg');
4
-
5
- echo $code;
6
- }
7
-
8
- ?>
9
  <div class="wrap">
10
  <form class="pure-form pure-form-aligned ecwid-settings appearance-settings" method="POST" action="options.php">
11
 
@@ -36,7 +28,7 @@ function ecwid_embed_svg($name) {
36
  </label>
37
  </div>
38
  <div class="note">
39
- <?php echo sprintf(__('Or you can add search box to your website\'s toolbar using <a href="%s">WordPress native widgets</a>', 'ecwid-shopping-cart'), 'widgets.php?from-ecwid-appearance'); ?>
40
  </div>
41
  </div>
42
 
 
 
 
 
 
 
 
 
1
  <div class="wrap">
2
  <form class="pure-form pure-form-aligned ecwid-settings appearance-settings" method="POST" action="options.php">
3
 
28
  </label>
29
  </div>
30
  <div class="note">
31
+ <?php echo sprintf(__('Or you can add search box to your website\'s toolbar using <a href="%s">WordPress native widgets</a>', 'ecwid-shopping-cart'), 'widgets.php?from-ecwid=appearance'); ?>
32
  </div>
33
  </div>
34
 
templates/dashboard.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+
3
+ <form method="POST" action="options.php" class="pure-form ecwid-settings general-settings" name="settings">
4
+ <h2><?php _e('Ecwid Shopping Cart — Dashboard', 'ecwid-shopping-cart'); ?></h2>
5
+ <?php settings_fields('ecwid_options_page'); ?>
6
+ <fieldset>
7
+
8
+ <input type="hidden" name="settings_section" value="general" />
9
+
10
+ <div class="greeting-box complete">
11
+ <div class="image-container">
12
+ <img class="greeting-image" src="<?php echo(esc_attr(ECWID_PLUGIN_URL)); ?>/images/store_ready.png" width="142" />
13
+ </div>
14
+
15
+ <div class="messages-container">
16
+ <?php if (array_key_exists('settings-updated', $_GET)): ?>
17
+
18
+ <div class="main-message"><?php _e('Congratulations!', 'ecwid-shopping-cart'); ?></div>
19
+ <div class="secondary-message"?><?php _e('Your Ecwid store is now connected to your WordPress website', 'ecwid-shopping-cart'); ?></div>
20
+
21
+ <?php else: ?>
22
+
23
+ <div class="main-message"><?php _e('Greetings!', 'ecwid-shopping-cart'); ?></div>
24
+ <div class="secondary-message"?><?php _e('Your Ecwid store is connected to your WordPress website', 'ecwid-shopping-cart'); ?></div>
25
+ <?php endif; ?>
26
+ </div>
27
+ </div>
28
+ <hr />
29
+ <div class="section">
30
+ <div class="left">
31
+ <span class="main-info">
32
+ <?php _e('Store ID', 'ecwid-shopping-cart'); ?>: <strong><?php echo esc_attr(get_ecwid_store_id()); ?></strong>
33
+ </span>
34
+ </div>
35
+ <div class="right two-buttons">
36
+ <a class="pure-button" target="_blank" href="https://my.ecwid.com/cp/?source=wporg#t1=&t2=Dashboard">
37
+ <?php _e('Control panel', 'ecwid-shopping-cart'); ?>
38
+ </a>
39
+ <a class="pure-button" target="_blank" href="<?php echo esc_attr(get_page_link(get_option('ecwid_store_page_id'))); ?>">
40
+ <?php _e('Visit storefront', 'ecwid-shopping-cart'); ?>
41
+ </a>
42
+ </div>
43
+ </div>
44
+
45
+ <?php if (!ecwid_is_paid_account()): ?>
46
+ <div class="section account-section">
47
+ <div class="left">
48
+ <div class="secondary-info">
49
+ <?php _e('Upgrade your account to get access to more Ecwid plugin features', 'ecwid-shopping-cart'); ?>
50
+ </div>
51
+ </div>
52
+
53
+ <div class="right">
54
+ <a class="<?php echo ECWID_MAIN_BUTTON_CLASS; ?>" target="_blank" href="http://www.ecwid.com/plans-and-pricing.html">
55
+ <?php _e('Upgrade', 'ecwid-shopping-cart'); ?>
56
+ </a>
57
+ </div>
58
+ </div>
59
+ <?php endif; ?>
60
+
61
+ <div class="note grayed-links">
62
+ <?php
63
+ echo sprintf(
64
+ __('If you want to connect another Ecwid store, you can <a %s>disconnect the current one and change Store ID</a>.', 'ecwid-shopping-cart'),
65
+ 'href="#" onClick="javascript:document.forms[\'settings\'].submit(); return false;"'
66
+ );
67
+ ?>
68
+
69
+ </div>
70
+
71
+ <hr />
72
+ <p><?php _e('Questions? Visit <a href="http://help.ecwid.com/?source=wporg">Ecwid support center</a>', 'ecwid-shopping-cart'); ?></p>
73
+ </fieldset>
74
+ </form>
75
+ </div>
templates/setup.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+
3
+ <form method="POST" action="options.php" class="pure-form ecwid-settings general-settings">
4
+ <h2><?php _e('Ecwid Shopping Cart — Connect', 'ecwid-shopping-cart'); ?></h2>
5
+ <?php settings_fields('ecwid_options_page'); ?>
6
+ <fieldset>
7
+
8
+ <input type="hidden" name="settings_section" value="general" />
9
+
10
+ <div class="greeting-box">
11
+
12
+ <div class="image-container">
13
+ <img class="greeting-image" src="<?php echo(esc_attr(ECWID_PLUGIN_URL)); ?>/images/store_inprogress.png" width="142" />
14
+ </div>
15
+
16
+ <div class="messages-container">
17
+ <div class="main-message">
18
+
19
+ <?php _e('Thank you for choosing Ecwid to build your online store', 'ecwid-shopping-cart'); ?>
20
+ </div>
21
+ <div class="secondary-message">
22
+ <?php _e('The first step towards opening your online business: <br />Let’s get started and add a store to your WordPress website in <strong>3</strong> simple steps.', 'ecwid-shopping-cart'); ?>
23
+ </div>
24
+ </div>
25
+
26
+ </div>
27
+ <hr />
28
+
29
+ <ol>
30
+ <li>
31
+ <h4><?php _e('Register at Ecwid', 'ecwid-shopping-cart'); ?></h4>
32
+ <div>
33
+ <?php _e('Create a new Ecwid account which you will use to manage your store and inventory. The registration is free.', 'ecwid-shopping-cart'); ?>
34
+ </div>
35
+ <div class="ecwid-account-buttons">
36
+ <a class="pure-button pure-button-secondary" target="_blank" href="https://my.ecwid.com/cp/?source=wporg#register">
37
+ <?php _e('Create new Ecwid account', 'ecwid-shopping-cart'); ?>
38
+ </a>
39
+ <a class="pure-button pure-button-secondary" target="_blank" href="https://my.ecwid.com/cp/?source=wporg#t1=&t2=Dashboard">
40
+ <?php _e('I already have Ecwid account, sign in', 'ecwid-shopping-cart'); ?>
41
+ </a>
42
+ </div>
43
+ <div class="note">
44
+ <?php _e('You will be able to sign up through your existing Google, Facebook or PayPal profiles as well.', 'ecwid-shopping-cart'); ?>
45
+ </div>
46
+ </li>
47
+ <li>
48
+ <h4><?php _e('Find your Store ID', 'ecwid-shopping-cart'); ?></h4>
49
+ <div>
50
+ <?php _e('Store ID is a unique identifier of any Ecwid store, it consists of several digits. You can find it on the "Dashboard" page of Ecwid control panel. Also the Store ID will be sent in the Welcome email after the registration.', 'ecwid-shopping-cart'); ?>
51
+ </div>
52
+ </li>
53
+ <li>
54
+ <h4>
55
+ <?php _e('Enter your Store ID', 'ecwid-shopping-cart'); ?>
56
+ </h4>
57
+ <div><label for="ecwid_store_id"><?php _e('Enter your Store ID here:', 'ecwid-shopping-cart'); ?></label></div>
58
+ <div class="pure-control-group store-id">
59
+ <input
60
+ id="ecwid_store_id"
61
+ name="ecwid_store_id"
62
+ type="text"
63
+ placeholder="<?php _e('Store ID', 'ecwid-shopping-cart'); ?>"
64
+ value="<?php if (get_ecwid_store_id() != 1003) echo esc_attr(get_ecwid_store_id()); ?>"
65
+ />
66
+ <button type="submit" class="<?php echo ECWID_MAIN_BUTTON_CLASS; ?>"><?php _e('Save and connect your Ecwid store to the site', 'ecwid-shopping-cart'); ?></button>
67
+ </div>
68
+
69
+ </li>
70
+ </ol>
71
+ <hr />
72
+ <p><?php _e('Questions? Visit <a href="http://help.ecwid.com/?source=wporg">Ecwid support center</a>', 'ecwid-shopping-cart'); ?></p>
73
+ </fieldset>
74
+ </form>
75
+ </div>
templates/store-popup.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ var ecwid_store_svg = '<?php echo get_site_url('', 'index.php?file=ecwid_store_svg.svg'); ?>';
3
+ </script>
4
+ <div id="ecwid-store-popup-content">
5
+ <div class="media-modal wp-core-ui">
6
+ <div class="media-modal-content">
7
+ <a class="media-modal-close" href="#" title="Close"><span class="media-modal-icon"></span></a>
8
+ <div class="media-frame wp-core-ui hide-router">
9
+ <div class="media-frame-menu">
10
+ <div class="media-menu">
11
+ <a href="#" class="media-menu-item" data-content="add-store"><?php _e('Add store', 'ecwid-shopping-cart'); ?></a>
12
+ <a href="#" class="media-menu-item" data-content="store-settings"><?php _e('Store settings', 'ecwid-shopping-cart'); ?></a>
13
+ <a href="#" class="media-menu-item" data-content="appearance"><?php _e('Appearance', 'ecwid-shopping-cart'); ?></a>
14
+ </div>
15
+ </div>
16
+
17
+ <div class="media-frame-title add-store">
18
+ <h1>
19
+ <?php _e('Add Store', 'ecwid-shopping-cart'); ?><span class="dashicons dashicons-arrow-down"></span>
20
+ </h1>
21
+ </div>
22
+
23
+ <div class="media-frame-title store-settings">
24
+ <h1>
25
+ <?php _e('Store settings', 'ecwid-shopping-cart'); ?><span class="dashicons dashicons-arrow-down"></span>
26
+ </h1>
27
+ </div>
28
+
29
+ <div class="media-frame-title appearance">
30
+ <h1>
31
+ <?php _e('Appearance', 'ecwid-shopping-cart'); ?><span class="dashicons dashicons-arrow-down"></span>
32
+ </h1>
33
+ </div>
34
+
35
+ <div class="media-frame-content ecwid-store-editor store-settings">
36
+
37
+ <div class="store-settings-wrapper">
38
+ <div class="store-settings-preview">
39
+ <?php ecwid_embed_svg('add-store'); ?>
40
+ <label for="show_search" class="ecwid-search" data-ecwid-widget="search"></label>
41
+ <label for="show_categories" class="ecwid-categories" data-ecwid-widget="categories"></label>
42
+ <label for="show_minicart" class="ecwid-minicart" data-ecwid-widget="minicart"></label>
43
+ </div>
44
+
45
+ <div class="store-settings">
46
+ <h3><?php _e('Choose widgets to show', 'ecwid-shopping-cart'); ?></h3>
47
+ <p class="note"><?php _e('Product catalog will be shown automatically', 'ecwid-shopping-cart'); ?></p>
48
+
49
+ <div class="pure-control-group">
50
+ <label data-ecwid-widget="search">
51
+ <input type="checkbox" name="show_search" id="show_search" />
52
+ <?php _e('Show search', 'ecwid-shopping-cart'); ?>
53
+ </label>
54
+ </div>
55
+
56
+ <div class="pure-control-group">
57
+ <label data-ecwid-widget="minicart">
58
+ <input type="checkbox" name="show_minicart" id="show_minicart" />
59
+ <?php _e('Show minicart', 'ecwid-shopping-cart'); ?>
60
+ </label>
61
+ </div>
62
+
63
+ <div class="pure-control-group">
64
+ <label data-ecwid-widget="categories">
65
+ <input type="checkbox" name="show_categories" id="show_categories" />
66
+ <?php _e('Show horizontal categories', 'ecwid-shopping-cart'); ?>
67
+ </label>
68
+ </div>
69
+ </div>
70
+ <div class="note">
71
+ <?php echo sprintf(
72
+ __('Additionally, you can add store controls to your website\'s toolbar using <a %s>WordPress native widgets</a>', 'ecwid-shopping-cart'),
73
+ 'href="widgets.php?from-ecwid=' . (isset($_GET['post']) ? $_GET['post'] : 'new') . '"'
74
+ );
75
+ ?>
76
+ </div>
77
+ </div>
78
+
79
+ </div>
80
+
81
+ <div class="media-frame-content ecwid-store-editor appearance">
82
+
83
+ <div class="pure-control-group pb-views">
84
+ <label class="products-per-page-label"><?php _e('Number of products per page', 'ecwid-shopping-cart'); ?></label>
85
+ <div class="ecwid-pb-view-size grid active" tabindex="1">
86
+ <div class="title"><?php _e('Grid view', 'ecwid-shopping-cart'); ?></div>
87
+ <div class="main-area">
88
+ <?php ecwid_embed_svg('grid'); ?>
89
+ </div>
90
+ <div class="right">
91
+ <div class="ruler"></div>
92
+ <input
93
+ type="text"
94
+ size="2"
95
+ name="grid_rows"
96
+ class="number"
97
+ value="<?php echo esc_attr(get_option('ecwid_pb_productspercolumn_grid')); ?>"
98
+ />
99
+ </div>
100
+ <div class="bottom">
101
+ <div class="ruler"></div>
102
+ <input
103
+ type="text"
104
+ size="2"
105
+ name="grid_columns"
106
+ class="number"
107
+ value="<?php echo esc_attr(get_option('ecwid_pb_productsperrow_grid')); ?>"
108
+ />
109
+ </div>
110
+ </div>
111
+
112
+ <div class="ecwid-pb-view-size list" tabindex="1">
113
+ <div class="title"><?php _e('List view', 'ecwid-shopping-cart'); ?></div>
114
+ <div class="main-area">
115
+ <?php ecwid_embed_svg('list'); ?>
116
+ </div>
117
+ <div class="right">
118
+ <div class="ruler"></div>
119
+ <input
120
+ type="text"
121
+ size="2"
122
+ name="list_rows"
123
+ class="number"
124
+ value="<?php echo esc_attr(get_option('ecwid_pb_productsperpage_list')); ?>" />
125
+ </div>
126
+ </div>
127
+
128
+
129
+ <div class="ecwid-pb-view-size table" tabindex="1">
130
+ <div class="title"><?php _e('Table view', 'ecwid-shopping-cart'); ?></div>
131
+ <div class="main-area">
132
+ <?php ecwid_embed_svg('table'); ?>
133
+ </div>
134
+ <div class="right">
135
+ <div class="ruler"></div>
136
+ <input
137
+ type="text"
138
+ size="2"
139
+ name="table_rows"
140
+ class="number"
141
+ value="<?php echo esc_attr(get_option('ecwid_pb_productsperpage_table')); ?>"
142
+ />
143
+ </div>
144
+ </div>
145
+ <p class="note pb-note"><?php _e('Here you can control how many products will be displayed per page. These options define maximum values. If there is not enough space to show all product columns, Ecwid will adapt the number of columns to hold all products.', 'ecwid-shopping-cart'); ?></p>
146
+ </div>
147
+
148
+ <hr class="after-pb" />
149
+
150
+ <div class="pure-control-group params-list default-category-id">
151
+
152
+ <?php if (ecwid_is_paid_account()): ?>
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_str']); ?>
170
+ </option>
171
+ <?php endforeach; ?>
172
+ </select>
173
+ </div>
174
+
175
+ <?php else: ?>
176
+
177
+ <label for="ecwid_default_category_id">
178
+ <?php _e('Default category ID', 'ecwid-shopping-cart'); ?>
179
+ </label>
180
+
181
+ <input
182
+ id="ecwid_default_category_id"
183
+ name="ecwid_default_category_id"
184
+ type="text"
185
+ placeholder="<?php _e('Default category ID', 'ecwid-shopping-cart'); ?>"
186
+ value="<?php echo esc_attr(get_option('ecwid_default_category_id')) ?>"
187
+ />
188
+ <?php endif; ?>
189
+
190
+ </div>
191
+
192
+ <div class="pure-control-group params-list">
193
+ <label for="ecwid_pb_categoriesperrow">
194
+ <?php _e('Number of categories per row', 'ecwid-shopping-cart'); ?>
195
+ </label>
196
+ <input
197
+ id="ecwid_pb_categoriesperrow"
198
+ name="categories_per_row"
199
+ type="text"
200
+ class="number"
201
+ value="<?php echo esc_attr(get_option('ecwid_pb_categoriesperrow')); ?>"
202
+ />
203
+ </div>
204
+
205
+ <div class="pure-control-group params-list">
206
+ <label for="ecwid_pb_defaultview">
207
+ <?php _e('Default view mode on product pages', 'ecwid-shopping-cart'); ?>
208
+ </label>
209
+ <select id="ecwid_pb_defaultview" name="category_view">
210
+ <option value="grid" <?php if(get_option('ecwid_pb_defaultview') == 'grid') echo 'selected="selected"' ?> >
211
+ <?php _e('Grid', 'ecwid-shopping-cart'); ?>
212
+ </option>
213
+ <option value="list" <?php if(get_option('ecwid_pb_defaultview') == 'list') echo 'selected="selected"' ?> >
214
+ <?php _e('List', 'ecwid-shopping-cart'); ?>
215
+ </option>
216
+ <option value="table" <?php if(get_option('ecwid_pb_defaultview') == 'table') echo 'selected="selected"' ?> >
217
+ <?php _e('Table', 'ecwid-shopping-cart'); ?>
218
+ </option>
219
+ </select>
220
+ </div>
221
+
222
+ <div class="pure-control-group params-list">
223
+ <label for="ecwid_pb_searchview">
224
+ <?php _e('Default view mode on search results', 'ecwid-shopping-cart'); ?>
225
+ </label>
226
+
227
+ <select id="ecwid_pb_searchview" name="search_view">
228
+ <option value="grid" <?php if(get_option('ecwid_pb_searchview') == 'grid') echo 'selected="selected"' ?> >
229
+ <?php _e('Grid', 'ecwid-shopping-cart'); ?>
230
+ </option>
231
+ <option value="list" <?php if(get_option('ecwid_pb_searchview') == 'list') echo 'selected="selected"' ?> >
232
+ <?php _e('List', 'ecwid-shopping-cart'); ?>
233
+ </option>
234
+ <option value="table" <?php if(get_option('ecwid_pb_searchview') == 'table') echo 'selected="selected"' ?> >
235
+ <?php _e('Table', 'ecwid-shopping-cart'); ?>
236
+ </option>
237
+ </select>
238
+ </div>
239
+ </div>
240
+
241
+ <div class="media-frame-toolbar">
242
+ <div class="media-toolbar">
243
+ <div class="media-toolbar-secondary">
244
+ <?php if (get_ecwid_store_id() != ECWID_DEMO_STORE_ID): ?>
245
+ <div class="store-id"><?php _e('Store ID', 'ecwid-shopping-cart'); ?>: <?php echo esc_attr(get_ecwid_store_id()); ?></div>
246
+ <?php else: ?>
247
+ <div class="store-id"><?php _e('Demo store', 'ecwid-shopping-cart'); ?></div>
248
+ <?php endif; ?>
249
+ <div class="setting-link">
250
+ <a target="_blank" href="admin.php?page=ecwid"><?php _e('Ecwid plugin settings', 'ecwid-shopping-cart'); ?>
251
+ </div>
252
+ </div>
253
+ <div class="media-toolbar-primary add-store">
254
+ <a href="#" class="button media-button button-primary button-large media-button-select"><?php _e('Insert into page'); ?></a>
255
+ </div>
256
+ <div class="media-toolbar-primary store-settings">
257
+ <a href="#" class="button media-button button-primary button-large media-button-select"><?php _e('Save and close', 'ecwid-shopping-cart'); ?></a>
258
+ </div>
259
+ </div>
260
+ </div>
261
+ </div>
262
+ </div>
263
+ </div>
264
+ <div class="media-modal-backdrop"></div>
265
+ </div>
templates/store-svg.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
3
+ echo '<?xml-stylesheet type="text/css" href="http://fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=3.9.2" ?>';
4
+ echo '<?xml-stylesheet type="text/css" href="http://localhost/2.css" ?>';
5
+ ?><!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
6
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
7
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
8
+ viewBox="0 0 500 220" enable-background="new 0 0 500 220" xml:space="preserve">
9
+
10
+ <text x="245" y="115" text-anchor="middle" fill="#050303" font-family="Open Sans,Helvetica Neue,sans-serif" font-size="20"><?php _e('Your store will be shown here!', 'ecwid-shopping-cart'); ?></text>
11
+ <text x="245" y="137" text-anchor="middle" fill="#999999" font-family="Open Sans,Helvetica Neue,sans-serif" font-size="14">
12
+ <?php if (get_ecwid_store_id() == ECWID_DEMO_STORE_ID): ?>
13
+ <?php _e('Demo Store', 'ecwid-shopping-cart'); ?>
14
+ <?php else: ?>
15
+ <?php _e('Store ID', 'ecwid-shopping-cart'); ?>: <?php echo esc_attr(get_option('ecwid_store_id')); ?>
16
+ <?php endif; ?>
17
+ </text>
18
+
19
+ <g>
20
+ <path fill="#77B644" d="M225.7,82.3c0-0.4,0.3-0.8,0.8-0.8h41.1c0.4,0,0.8,0.3,0.8,0.8v1.6c0,0.4-0.3,0.8-0.8,0.8h-41.1
21
+ c-0.4,0-0.8-0.3-0.8-0.8V82.3z"/>
22
+ <path fill="#77B644" d="M268.4,56.6c-1.6-3.3-2.4-6.5-3.3-11.9c0-0.3-0.7-1.3-1.6-1.3h-33c-0.9,0-1.6,1-1.6,1.3
23
+ c0,0-1.6,10.2-3.3,11.9c0,1.7,0,5,0,5s0,0.1,0.1,0.1h-0.1c0,0,0.1,0.8,1.2,1.3c0.1,0.1,0.3,0.2,0.5,0.2v0v14.9
24
+ c0,0.9,0.9,1.5,1.8,1.5h13V66c0-0.9,0.9-1.6,1.8-1.6h6.6c0.9,0,1.6,0.7,1.6,1.6v13.7h13.1c0.9,0,1.6-0.6,1.6-1.5V63.3v-0.1
25
+ c1.3-0.2,1.6-1.5,1.6-1.5h0c0-0.1,0-0.1,0-0.1S268.4,58.3,268.4,56.6z M238.5,73.1c0,0.9-0.4,1.6-1.3,1.6h-3.4
26
+ c-0.9,0-1.3-0.7-1.3-1.6v-6.6c0-0.9,0.4-1.6,1.3-1.6h3.4c0.9,0,1.3,0.7,1.3,1.6V73.1z M261.5,73.1c0,0.9-0.4,1.6-1.3,1.6h-3.4
27
+ c-0.9,0-1.3-0.7-1.3-1.6v-6.6c0-0.9,0.4-1.6,1.3-1.6h3.4c0.9,0,1.3,0.7,1.3,1.6V73.1z M261.8,46.4c0,0,1.8,8.4,2.8,10.2
28
+ c-1.6,0-4.5,0-4.5,0l-1.6-10.2H261.8z M264.8,58.3l0,1.3c-0.2,1.1-1.1,2-2.3,2c-1.3,0-2.3-0.8-2.3-2.1c0,0,0.1-1.2,0.1-1.2H264.8z
29
+ M252.3,59.1l0-0.9h4.7l0,1.3c-0.2,1.1-1.1,2-2.3,2c-1.3,0-2.3-1-2.3-2.3C252.4,59.2,252.4,59.2,252.3,59.1L252.3,59.1z
30
+ M255.2,46.4c0,0,1.2,8.2,1.8,10.2c0.5,0-4.6,0-4.6,0l-0.5-10.2H255.2z M245.3,46.4h3.4l0.6,10.2h-4.5L245.3,46.4z M244.7,58.3h4.6
31
+ l0,1.2c-0.1,1.2-1.1,2.1-2.3,2.1c-1.2,0-2.2-0.9-2.3-2.1L244.7,58.3z M238.7,46.4h3.3l-0.5,10.2c0,0-3.2,0-4.4,0
32
+ C237.6,54.8,238.7,46.4,238.7,46.4z M236.9,58.3h4.6l0,0.9h0c0,0,0,0.1,0,0.1c0,1.3-1,2.3-2.3,2.3c-1.2,0-2.1-0.9-2.3-2L236.9,58.3
33
+ z M232.1,46.4h3.2L234,56.6c0,0-3.3,0-4.5,0C230.8,54.3,232.1,46.4,232.1,46.4z M229.2,58.3h4.6c0,0,0,0.9,0,1c0,1.3-1,2.3-2.3,2.3
34
+ c-1.1,0-2.1-0.8-2.3-1.9L229.2,58.3z"/>
35
+ </g>
36
+ </svg>
37
+ <!--svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
38
+ viewBox="0 0 80 80" enable-background="new 0 0 80 80" xml:space="preserve">
39
+ <g>
40
+ <path fill="#77B644" d="M37.4,36.1c0-0.1,0.1-0.1,0.1-0.1h6.2c0.1,0,0.1,0.1,0.1,0.1v0.2c0,0.1-0.1,0.1-0.1,0.1h-6.2
41
+ c-0.1,0-0.1-0.1-0.1-0.1C37.4,36.4,37.4,36.1,37.4,36.1z"/>
42
+ <path fill="#77B644" d="M43.8,32.2c-0.3-0.5-0.4-1-0.5-1.8c0,0-0.1-0.2-0.3-0.2h-5c-0.1,0-0.3,0.2-0.3,0.2c0,0-0.3,1.5-0.5,1.8
43
+ c0,0.3,0,0.8,0,0.8s0,0,0,0h0c0,0,0,0.1,0.2,0.2c0,0,0,0,0.1,0v0v2.3c0,0.1,0.1,0.2,0.3,0.2h2v-2.1c0-0.1,0.1-0.3,0.3-0.3h1
44
+ c0.1,0,0.3,0.1,0.3,0.3v2.1h2c0.1,0,0.3-0.1,0.3-0.2v-2.3v0c0.2,0,0.3-0.2,0.3-0.2h0c0,0,0,0,0,0S43.8,32.5,43.8,32.2z M39.3,34.7
45
+ c0,0.1-0.1,0.3-0.2,0.3h-0.5c-0.1,0-0.2-0.1-0.2-0.3v-1c0-0.1,0.1-0.3,0.2-0.3h0.5c0.1,0,0.2,0.1,0.2,0.3V34.7z M42.8,34.7
46
+ c0,0.1-0.1,0.3-0.2,0.3h-0.5c-0.1,0-0.2-0.1-0.2-0.3v-1c0-0.1,0.1-0.3,0.2-0.3h0.5c0.1,0,0.2,0.1,0.2,0.3V34.7z M42.8,30.7
47
+ c0,0,0.3,1.3,0.4,1.5c-0.3,0-0.7,0-0.7,0l-0.3-1.5C42.3,30.7,42.8,30.7,42.8,30.7z M43.3,32.5v0.2c0,0.2-0.2,0.3-0.4,0.3
48
+ c-0.2,0-0.4-0.1-0.4-0.3c0,0,0-0.2,0-0.2S43.3,32.5,43.3,32.5z M41.4,32.6v-0.1h0.7v0.2c0,0.2-0.2,0.3-0.4,0.3
49
+ C41.6,33,41.4,32.8,41.4,32.6C41.4,32.6,41.4,32.6,41.4,32.6L41.4,32.6z M41.8,30.7c0,0,0.2,1.2,0.3,1.5c0.1,0-0.7,0-0.7,0
50
+ l-0.1-1.5C41.3,30.7,41.8,30.7,41.8,30.7z M40.3,30.7h0.5l0.1,1.5h-0.7L40.3,30.7z M40.3,32.5h0.7l0,0.2c0,0.2-0.2,0.3-0.4,0.3
51
+ s-0.3-0.1-0.4-0.3L40.3,32.5z M39.3,30.7h0.5l-0.1,1.5c0,0-0.5,0-0.7,0C39.2,32,39.3,30.7,39.3,30.7z M39.1,32.5h0.7l0,0.1h0
52
+ c0,0,0,0,0,0c0,0.2-0.2,0.4-0.4,0.4c-0.2,0-0.3-0.1-0.4-0.3L39.1,32.5z M38.4,30.7h0.5l-0.2,1.5c0,0-0.5,0-0.7,0
53
+ C38.2,31.9,38.4,30.7,38.4,30.7z M37.9,32.5h0.7v0.1c0,0.2-0.2,0.4-0.4,0.4c-0.2,0-0.3-0.1-0.3-0.3V32.5z"/>
54
+ </g>
55
+ <text transform="matrix(1 0 0 1 20.4612 40.8213)" fill="#050303" font-family="Open Sans" font-size="2.8571">Your store will be shown here!</text>
56
+ <text transform="matrix(1 0 0 1 33.9376 43.5605)" fill="#999999" font-family="Open Sans" font-size="1.4829">Store ID: xxxxxxxxx</text>
57
+ <?php if (get_ecwid_store_id() == ECWID_DEMO_STORE_ID): ?>
58
+ <?php _e('Demo Store', 'ecwid-shopping-cart'); ?>
59
+ <?php else: ?>
60
+ <?php _e('Store ID', 'ecwid-shopping-cart'); ?>: <?php echo esc_attr(get_option('ecwid_store_id')); ?>
61
+ <?php endif; ?>
62
+ </text>
63
+ </svg>
64
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
65
+ viewBox="0 0 560 181" enable-background="new 0 0 560 181" xml:space="preserve">
66
+ <g>
67
+ <path fill="#77B644" d="M242.1,72.2c0-0.8,0.6-1.4,1.4-1.4h74.3c0.8,0,1.4,0.6,1.4,1.4V75c0,0.8-0.6,1.4-1.4,1.4h-74.3
68
+ c-0.8,0-1.4-0.6-1.4-1.4V72.2z"/>
69
+ <path fill="#77B644" d="M319.4,25.6c-3-6-4.3-11.8-6-21.5c0-0.5-1.3-2.4-3-2.4h-59.7c-1.6,0-3,1.9-3,2.4c0,0-3,18.5-6,21.5
70
+ c0,3,0,9,0,9s0,0.1,0.1,0.2h-0.1c0,0,0.3,1.5,2.1,2.3c0.3,0.2,0.5,0.3,0.9,0.4v0.1v27c0,1.6,1.7,2.7,3.3,2.7h23.5V42.7
71
+ c0-1.6,1.6-3,3.2-3h11.9c1.6,0,3,1.3,3,3v24.7h23.8c1.6,0,3-1.1,3-2.7v-27v-0.1c2.4-0.4,3-2.7,3-2.7h-0.1c0-0.1,0.1-0.2,0.1-0.2
72
+ S319.4,28.6,319.4,25.6z M265.2,55.5c0,1.6-0.7,3-2.4,3h-6.2c-1.6,0-2.4-1.3-2.4-3V43.6c0-1.6,0.8-3,2.4-3h6.2c1.6,0,2.4,1.3,2.4,3
73
+ V55.5z M306.9,55.5c0,1.6-0.7,3-2.3,3h-6.1c-1.6,0-2.4-1.3-2.4-3V43.6c0-1.6,0.8-3,2.4-3h6.1c1.6,0,2.3,1.3,2.3,3V55.5z M307.4,7.2
74
+ c0,0,3.2,15.2,5.1,18.4c-3,0-8.1,0-8.1,0l-3-18.4H307.4z M312.8,28.6l0,2.3c-0.3,2.1-2,3.6-4.2,3.6c-2.3,0-4.2-1.4-4.2-3.7
75
+ c0-0.1,0.1-2.2,0.1-2.2H312.8z M290.3,30.2l0-1.6h8.5l0,2.4c-0.3,2-2,3.6-4.2,3.6c-2.3,0-4.2-1.9-4.2-4.2
76
+ C290.4,30.3,290.4,30.2,290.3,30.2L290.3,30.2z M295.4,7.2c0,0,2.2,14.8,3.2,18.4c0.9,0-8.3,0-8.3,0l-0.9-18.4H295.4z M277.5,7.2
77
+ h6.1l1.1,18.4h-8.1L277.5,7.2z M276.4,28.6h8.3l0.1,2.1c-0.2,2.2-2,3.9-4.2,3.9c-2.2,0-4-1.7-4.2-3.9L276.4,28.6z M265.6,7.2h6
78
+ l-0.9,18.4c0,0-5.8,0-8,0C263.6,22.3,265.6,7.2,265.6,7.2z M262.5,28.6h8.3l0.1,1.6h-0.1c0,0.1,0,0.1,0,0.2c0,2.3-1.9,4.2-4.2,4.2
79
+ c-2.1,0-3.9-1.6-4.2-3.6L262.5,28.6z M253.8,7.2h5.8l-2.5,18.4c0,0-5.9,0-8.1,0C251.3,21.5,253.8,7.2,253.8,7.2z M248.4,28.6h8.3
80
+ c0,0,0,1.7,0,1.7c0,2.3-1.9,4.2-4.2,4.2c-2.1,0-3.8-1.5-4.1-3.5L248.4,28.6z"/>
81
+ </g>
82
+ <text x="280" y="116" text-anchor="middle" fill="#050303" font-family="Open Sans,Helvetica Neue,sans-serif" font-size="20"><?php _e('Your store will be shown here!', 'ecwid-shopping-cart'); ?></text>
83
+ <text x="280" y="145" text-anchor="middle" fill="#999999" font-family="Open Sans,Helvetica Neue,sans-serif" font-size="14">
84
+ <?php if (get_ecwid_store_id() == ECWID_DEMO_STORE_ID): ?>
85
+ <?php _e('Demo Store', 'ecwid-shopping-cart'); ?>
86
+ <?php else: ?>
87
+ <?php _e('Store ID', 'ecwid-shopping-cart'); ?>: <?php echo esc_attr(get_option('ecwid_store_id')); ?>
88
+ <?php endif; ?>
89
+ </text>
90
+ </svg-->