Amazon JS - Version 0.8

Version Description

  • Supported Transients API for cache (file cache is no longer in use)
  • Improved to start rendering
  • Fixed to use get_locale() instead of WPLANG
Download this release

Release Info

Developer makoto_kw
Plugin Icon 128x128 Amazon JS
Version 0.8
Comparing to
See all releases

Version 0.8

README.md ADDED
@@ -0,0 +1,39 @@
1
+ AmazonJS (WordPress Plugin)
2
+ ========
3
+
4
+ This repository is in progress and unstable version. Do not install except latest version dose not work.
5
+
6
+ You can install stable version from: [WordPress.org](http://wordpress.org/plugins/amazonjs/)
7
+
8
+ ## Development
9
+
10
+ ### Requirement
11
+
12
+ * Grunt
13
+ * Compass
14
+
15
+ ### Build css
16
+
17
+
18
+ for debug
19
+
20
+ ```
21
+ grunt debug
22
+ ```
23
+
24
+ for production
25
+
26
+ ```
27
+ grunt
28
+ ```
29
+
30
+
31
+ ### Translation
32
+
33
+ 1. Execute ``grunt update-po``
34
+ 1. Edit ``languages/amazonjs-*.po``
35
+ 1. Execute ``grunt update-mo``
36
+
37
+ ## Support
38
+
39
+ http://wordpress.org/support/plugin/amazonjs
amazonjs-aws-params.php ADDED
@@ -0,0 +1,668 @@
1
+ <?php
2
+ /**
3
+ * @param Amazonjs $amazonjs
4
+ */
5
+ function amazonjs_aws_params( Amazonjs $amazonjs ) {
6
+ $amazonjs->search_indexes = array(
7
+ 'All' => array(
8
+ 'CA' => true,
9
+ 'CN' => true,
10
+ 'DE' => true,
11
+ 'ES' => true,
12
+ 'FR' => true,
13
+ 'IT' => true,
14
+ 'JP' => true,
15
+ 'UK' => true,
16
+ 'US' => true,
17
+ 'label' => __( 'All', $amazonjs->text_domain ),
18
+ ),
19
+ 'Apparel' => array(
20
+ 'CA' => false,
21
+ 'CN' => true,
22
+ 'DE' => true,
23
+ 'ES' => false,
24
+ 'FR' => true,
25
+ 'IT' => false,
26
+ 'JP' => true,
27
+ 'UK' => true,
28
+ 'US' => true,
29
+ 'label' => __( 'Apparel', $amazonjs->text_domain ),
30
+ ),
31
+ 'Appliances' => array(
32
+ 'CA' => false,
33
+ 'CN' => true,
34
+ 'DE' => false,
35
+ 'ES' => false,
36
+ 'FR' => false,
37
+ 'IT' => false,
38
+ 'JP' => true,
39
+ 'UK' => false,
40
+ 'US' => true,
41
+ 'label' => __( 'Appliances', $amazonjs->text_domain ),
42
+ ),
43
+ 'ArtsAndCrafts' => array(
44
+ 'CA' => false,
45
+ 'CN' => false,
46
+ 'DE' => false,
47
+ 'ES' => false,
48
+ 'FR' => false,
49
+ 'IT' => false,
50
+ 'JP' => false,
51
+ 'UK' => false,
52
+ 'US' => true,
53
+ 'label' => __( 'ArtsAndCrafts', $amazonjs->text_domain ),
54
+ ),
55
+ 'Automotive' => array(
56
+ 'CA' => false,
57
+ 'CN' => true,
58
+ 'DE' => true,
59
+ 'ES' => false,
60
+ 'FR' => false,
61
+ 'IT' => false,
62
+ 'JP' => true,
63
+ 'UK' => true,
64
+ 'US' => true,
65
+ 'label' => __( 'Automotive', $amazonjs->text_domain ),
66
+ ),
67
+ 'Baby' => array(
68
+ 'CA' => true,
69
+ 'CN' => true,
70
+ 'DE' => true,
71
+ 'ES' => false,
72
+ 'FR' => true,
73
+ 'IT' => true,
74
+ 'JP' => true,
75
+ 'UK' => true,
76
+ 'US' => true,
77
+ 'label' => __( 'Baby', $amazonjs->text_domain ),
78
+ ),
79
+ 'Beauty' => array(
80
+ 'CA' => false,
81
+ 'CN' => true,
82
+ 'DE' => true,
83
+ 'ES' => false,
84
+ 'FR' => true,
85
+ 'IT' => false,
86
+ 'JP' => true,
87
+ 'UK' => true,
88
+ 'US' => true,
89
+ 'label' => __( 'Beauty', $amazonjs->text_domain ),
90
+ ),
91
+ 'Blended' => array(
92
+ 'CA' => true,
93
+ 'CN' => false,
94
+ 'DE' => true,
95
+ 'ES' => false,
96
+ 'FR' => true,
97
+ 'IT' => false,
98
+ 'JP' => true,
99
+ 'UK' => true,
100
+ 'US' => true,
101
+ 'label' => __( 'Blended', $amazonjs->text_domain ),
102
+ ),
103
+ 'Books' => array(
104
+ 'CA' => true,
105
+ 'CN' => true,
106
+ 'DE' => true,
107
+ 'ES' => true,
108
+ 'FR' => true,
109
+ 'IT' => true,
110
+ 'JP' => true,
111
+ 'UK' => true,
112
+ 'US' => true,
113
+ 'label' => __( 'Books', $amazonjs->text_domain ),
114
+ ),
115
+ 'Classical' => array(
116
+ 'CA' => true,
117
+ 'CN' => false,
118
+ 'DE' => true,
119
+ 'ES' => false,
120
+ 'FR' => true,
121
+ 'IT' => false,
122
+ 'JP' => true,
123
+ 'UK' => true,
124
+ 'US' => true,
125
+ 'label' => __( 'Classical', $amazonjs->text_domain ),
126
+ ),
127
+ 'DigitalMusic' => array(
128
+ 'CA' => false,
129
+ 'CN' => false,
130
+ 'DE' => false,
131
+ 'ES' => false,
132
+ 'FR' => false,
133
+ 'IT' => false,
134
+ 'JP' => false,
135
+ 'UK' => false,
136
+ 'US' => true,
137
+ 'label' => __( 'DigitalMusic', $amazonjs->text_domain ),
138
+ ),
139
+ 'DVD' => array(
140
+ 'CA' => true,
141
+ 'CN' => false,
142
+ 'DE' => true,
143
+ 'ES' => true,
144
+ 'FR' => true,
145
+ 'IT' => true,
146
+ 'JP' => true,
147
+ 'UK' => true,
148
+ 'US' => true,
149
+ 'label' => __( 'DVD', $amazonjs->text_domain ),
150
+ ),
151
+ 'Electronics' => array(
152
+ 'CA' => true,
153
+ 'CN' => true,
154
+ 'DE' => true,
155
+ 'ES' => true,
156
+ 'FR' => true,
157
+ 'IT' => true,
158
+ 'JP' => true,
159
+ 'UK' => true,
160
+ 'US' => true,
161
+ 'label' => __( 'Electronics', $amazonjs->text_domain ),
162
+ ),
163
+ 'ForeignBooks' => array(
164
+ 'CA' => true,
165
+ 'CN' => false,
166
+ 'DE' => true,
167
+ 'ES' => true,
168
+ 'FR' => true,
169
+ 'IT' => true,
170
+ 'JP' => true,
171
+ 'UK' => false,
172
+ 'US' => false,
173
+ 'label' => __( 'ForeignBooks', $amazonjs->text_domain ),
174
+ ),
175
+ 'Garden' => array(
176
+ 'CA' => false,
177
+ 'CN' => false,
178
+ 'DE' => false,
179
+ 'ES' => false,
180
+ 'FR' => false,
181
+ 'IT' => true,
182
+ 'JP' => false,
183
+ 'UK' => false,
184
+ 'US' => false,
185
+ 'label' => __( 'Garden', $amazonjs->text_domain ),
186
+ ),
187
+ 'GourmetFood' => array(
188
+ 'CA' => false,
189
+ 'CN' => false,
190
+ 'DE' => false,
191
+ 'ES' => false,
192
+ 'FR' => false,
193
+ 'IT' => false,
194
+ 'JP' => false,
195
+ 'UK' => false,
196
+ 'US' => true,
197
+ 'label' => __( 'GourmetFood', $amazonjs->text_domain ),
198
+ ),
199
+ 'Grocery' => array(
200
+ 'CA' => false,
201
+ 'CN' => true,
202
+ 'DE' => true,
203
+ 'ES' => false,
204
+ 'FR' => false,
205
+ 'IT' => false,
206
+ 'JP' => true,
207
+ 'UK' => true,
208
+ 'US' => true,
209
+ 'label' => __( 'Grocery', $amazonjs->text_domain ),
210
+ ),
211
+ 'HealthPersonalCare' => array(
212
+ 'CA' => false,
213
+ 'CN' => true,
214
+ 'DE' => true,
215
+ 'ES' => false,
216
+ 'FR' => true,
217
+ 'IT' => false,
218
+ 'JP' => true,
219
+ 'UK' => true,
220
+ 'US' => true,
221
+ 'label' => __( 'HealthPersonalCare', $amazonjs->text_domain ),
222
+ ),
223
+ 'Hobbies' => array(
224
+ 'CA' => false,
225
+ 'CN' => false,
226
+ 'DE' => false,
227
+ 'ES' => false,
228
+ 'FR' => false,
229
+ 'IT' => false,
230
+ 'JP' => true,
231
+ 'UK' => false,
232
+ 'US' => false,
233
+ 'label' => __( 'Hobbies', $amazonjs->text_domain ),
234
+ ),
235
+ 'Home' => array(
236
+ 'CA' => false,
237
+ 'CN' => true,
238
+ 'DE' => false,
239
+ 'ES' => false,
240
+ 'FR' => false,
241
+ 'IT' => false,
242
+ 'JP' => false,
243
+ 'UK' => false,
244
+ 'US' => false,
245
+ 'label' => __( 'Home', $amazonjs->text_domain ),
246
+ ),
247
+ 'HomeGarden' => array(
248
+ 'CA' => false,
249
+ 'CN' => false,
250
+ 'DE' => true,
251
+ 'ES' => false,
252
+ 'FR' => false,
253
+ 'IT' => false,
254
+ 'JP' => false,
255
+ 'UK' => true,
256
+ 'US' => true,
257
+ 'label' => __( 'HomeGarden', $amazonjs->text_domain ),
258
+ ),
259
+ 'HomeImprovement' => array(
260
+ 'CA' => false,
261
+ 'CN' => true,
262
+ 'DE' => true,
263
+ 'ES' => false,
264
+ 'FR' => false,
265
+ 'IT' => false,
266
+ 'JP' => true,
267
+ 'UK' => true,
268
+ 'US' => false,
269
+ 'label' => __( 'HomeImprovement', $amazonjs->text_domain ),
270
+ ),
271
+ 'Industrial' => array(
272
+ 'CA' => false,
273
+ 'CN' => false,
274
+ 'DE' => false,
275
+ 'ES' => false,
276
+ 'FR' => false,
277
+ 'IT' => false,
278
+ 'JP' => false,
279
+ 'UK' => false,
280
+ 'US' => true,
281
+ 'label' => __( 'Industrial', $amazonjs->text_domain ),
282
+ ),
283
+ 'Jewelry' => array(
284
+ 'CA' => false,
285
+ 'CN' => true,
286
+ 'DE' => true,
287
+ 'ES' => false,
288
+ 'FR' => true,
289
+ 'IT' => false,
290
+ 'JP' => true,
291
+ 'UK' => true,
292
+ 'US' => true,
293
+ 'label' => __( 'Jewelry', $amazonjs->text_domain ),
294
+ ),
295
+ 'KindleStore' => array(
296
+ 'CA' => false,
297
+ 'CN' => true,
298
+ 'DE' => true,
299
+ 'ES' => true,
300
+ 'FR' => true,
301
+ 'IT' => true,
302
+ 'JP' => true, // fixed
303
+ 'UK' => true,
304
+ 'US' => true,
305
+ 'label' => __( 'KindleStore', $amazonjs->text_domain ),
306
+ ),
307
+ 'Kitchen' => array(
308
+ 'CA' => false,
309
+ 'CN' => false,
310
+ 'DE' => true,
311
+ 'ES' => true,
312
+ 'FR' => true,
313
+ 'IT' => true,
314
+ 'JP' => true,
315
+ 'UK' => true,
316
+ 'US' => true,
317
+ 'label' => __( 'Kitchen', $amazonjs->text_domain ),
318
+ ),
319
+ 'LawnAndGarden' => array(
320
+ 'CA' => false,
321
+ 'CN' => false,
322
+ 'DE' => false,
323
+ 'ES' => false,
324
+ 'FR' => false,
325
+ 'IT' => false,
326
+ 'JP' => false,
327
+ 'UK' => false,
328
+ 'US' => true,
329
+ 'label' => __( 'LawnAndGarden', $amazonjs->text_domain ),
330
+ ),
331
+ 'Lighting' => array(
332
+ 'CA' => false,
333
+ 'CN' => false,
334
+ 'DE' => true,
335
+ 'ES' => false,
336
+ 'FR' => true,
337
+ 'IT' => true,
338
+ 'JP' => false,
339
+ 'UK' => true,
340
+ 'US' => false,
341
+ 'label' => __( 'Lighting', $amazonjs->text_domain ),
342
+ ),
343
+ 'Magazines' => array(
344
+ 'CA' => false,
345
+ 'CN' => false,
346
+ 'DE' => true,
347
+ 'ES' => false,
348
+ 'FR' => false,
349
+ 'IT' => false,
350
+ 'JP' => false,
351
+ 'UK' => false,
352
+ 'US' => true,
353
+ 'label' => __( 'Magazines', $amazonjs->text_domain ),
354
+ ),
355
+ 'Marketplace' => array(
356
+ 'CA' => false,
357
+ 'CN' => false,
358
+ 'DE' => true,
359
+ 'ES' => false,
360
+ 'FR' => false,
361
+ 'IT' => false,
362
+ 'JP' => true,
363
+ 'UK' => true,
364
+ 'US' => true,
365
+ 'label' => __( 'Marketplace', $amazonjs->text_domain ),
366
+ ),
367
+ 'Miscellaneous' => array(
368
+ 'CA' => false,
369
+ 'CN' => false,
370
+ 'DE' => false,
371
+ 'ES' => false,
372
+ 'FR' => false,
373
+ 'IT' => false,
374
+ 'JP' => false,
375
+ 'UK' => true,
376
+ 'US' => false,
377
+ 'label' => __( 'Miscellaneous', $amazonjs->text_domain ),
378
+ ),
379
+ 'MobileApps' => array(
380
+ 'CA' => false,
381
+ 'CN' => false,
382
+ 'DE' => false,
383
+ 'ES' => false,
384
+ 'FR' => false,
385
+ 'IT' => false,
386
+ 'JP' => false,
387
+ 'UK' => false,
388
+ 'US' => true,
389
+ 'label' => __( 'MobileApps', $amazonjs->text_domain ),
390
+ ),
391
+ 'MP3Downloads' => array(
392
+ 'CA' => false,
393
+ 'CN' => false,
394
+ 'DE' => true,
395
+ 'ES' => false,
396
+ 'FR' => true,
397
+ 'IT' => false,
398
+ 'JP' => true,
399
+ 'UK' => true,
400
+ 'US' => true,
401
+ 'label' => __( 'MP3Downloads', $amazonjs->text_domain ),
402
+ ),
403
+ 'Music' => array(
404
+ 'CA' => true,
405
+ 'CN' => true,
406
+ 'DE' => true,
407
+ 'ES' => true,
408
+ 'FR' => true,
409
+ 'IT' => true,
410
+ 'JP' => true,
411
+ 'UK' => true,
412
+ 'US' => true,
413
+ 'label' => __( 'Music', $amazonjs->text_domain ),
414
+ ),
415
+ 'MusicalInstruments' => array(
416
+ 'CA' => false,
417
+ 'CN' => false,
418
+ 'DE' => true,
419
+ 'ES' => false,
420
+ 'FR' => true,
421
+ 'IT' => false,
422
+ 'JP' => true,
423
+ 'UK' => true,
424
+ 'US' => true,
425
+ 'label' => __( 'MusicalInstruments', $amazonjs->text_domain ),
426
+ ),
427
+ 'MusicTracks' => array(
428
+ 'CA' => false,
429
+ 'CN' => false,
430
+ 'DE' => true,
431
+ 'ES' => false,
432
+ 'FR' => true,
433
+ 'IT' => false,
434
+ 'JP' => true,
435
+ 'UK' => true,
436
+ 'US' => true,
437
+ 'label' => __( 'MusicTracks', $amazonjs->text_domain ),
438
+ ),
439
+ 'OfficeProducts' => array(
440
+ 'CA' => false,
441
+ 'CN' => true,
442
+ 'DE' => true,
443
+ 'ES' => false,
444
+ 'FR' => true,
445
+ 'IT' => false,
446
+ 'JP' => true,
447
+ 'UK' => true,
448
+ 'US' => true,
449
+ 'label' => __( 'OfficeProducts', $amazonjs->text_domain ),
450
+ ),
451
+ 'OutdoorLiving' => array(
452
+ 'CA' => false,
453
+ 'CN' => false,
454
+ 'DE' => true,
455
+ 'ES' => false,
456
+ 'FR' => false,
457
+ 'IT' => false,
458
+ 'JP' => false,
459
+ 'UK' => true,
460
+ 'US' => true,
461
+ 'label' => __( 'OutdoorLiving', $amazonjs->text_domain ),
462
+ ),
463
+ 'Outlet' => array(
464
+ 'CA' => false,
465
+ 'CN' => false,
466
+ 'DE' => true,
467
+ 'ES' => false,
468
+ 'FR' => false,
469
+ 'IT' => false,
470
+ 'JP' => false,
471
+ 'UK' => true,
472
+ 'US' => false,
473
+ 'label' => __( 'Outlet', $amazonjs->text_domain ),
474
+ ),
475
+ 'PCHardware' => array(
476
+ 'CA' => false,
477
+ 'CN' => false,
478
+ 'DE' => true,
479
+ 'ES' => false,
480
+ 'FR' => true,
481
+ 'IT' => false,
482
+ 'JP' => false,
483
+ 'UK' => true,
484
+ 'US' => true,
485
+ 'label' => __( 'PCHardware', $amazonjs->text_domain ),
486
+ ),
487
+ 'PetSupplies' => array(
488
+ 'CA' => false,
489
+ 'CN' => false,
490
+ 'DE' => false,
491
+ 'ES' => false,
492
+ 'FR' => false,
493
+ 'IT' => false,
494
+ 'JP' => false,
495
+ 'UK' => false,
496
+ 'US' => true,
497
+ 'label' => __( 'PetSupplies', $amazonjs->text_domain ),
498
+ ),
499
+ 'Photo' => array(
500
+ 'CA' => false,
501
+ 'CN' => true,
502
+ 'DE' => true,
503
+ 'ES' => false,
504
+ 'FR' => false,
505
+ 'IT' => false,
506
+ 'JP' => false,
507
+ 'UK' => false,
508
+ 'US' => true,
509
+ 'label' => __( 'Photo', $amazonjs->text_domain ),
510
+ ),
511
+ 'Shoes' => array(
512
+ 'CA' => false,
513
+ 'CN' => true,
514
+ 'DE' => true,
515
+ 'ES' => false,
516
+ 'FR' => true,
517
+ 'IT' => true,
518
+ 'JP' => true,
519
+ 'UK' => true,
520
+ 'US' => true,
521
+ 'label' => __( 'Shoes', $amazonjs->text_domain ),
522
+ ),
523
+ 'Software' => array(
524
+ 'CA' => true,
525
+ 'CN' => true,
526
+ 'DE' => true,
527
+ 'ES' => true,
528
+ 'FR' => true,
529
+ 'IT' => true,
530
+ 'JP' => true,
531
+ 'UK' => true,
532
+ 'US' => true,
533
+ 'label' => __( 'Software', $amazonjs->text_domain ),
534
+ ),
535
+ 'SoftwareVideoGames' => array(
536
+ 'CA' => true,
537
+ 'CN' => false,
538
+ 'DE' => true,
539
+ 'ES' => false,
540
+ 'FR' => true,
541
+ 'IT' => false,
542
+ 'JP' => false,
543
+ 'UK' => true,
544
+ 'US' => false,
545
+ 'label' => __( 'SoftwareVideoGames', $amazonjs->text_domain ),
546
+ ),
547
+ 'SportingGoods' => array(
548
+ 'CA' => false,
549
+ 'CN' => true,
550
+ 'DE' => true,
551
+ 'ES' => false,
552
+ 'FR' => true,
553
+ 'IT' => false,
554
+ 'JP' => true,
555
+ 'UK' => true,
556
+ 'US' => true,
557
+ 'label' => __( 'SportingGoods', $amazonjs->text_domain ),
558
+ ),
559
+ 'Tools' => array(
560
+ 'CA' => false,
561
+ 'CN' => false,
562
+ 'DE' => true,
563
+ 'ES' => false,
564
+ 'FR' => false,
565
+ 'IT' => false,
566
+ 'JP' => false,
567
+ 'UK' => true,
568
+ 'US' => true,
569
+ 'label' => __( 'Tools', $amazonjs->text_domain ),
570
+ ),
571
+ 'Toys' => array(
572
+ 'CA' => false,
573
+ 'CN' => true,
574
+ 'DE' => true,
575
+ 'ES' => true,
576
+ 'FR' => true,
577
+ 'IT' => true,
578
+ 'JP' => true,
579
+ 'UK' => true,
580
+ 'US' => true,
581
+ 'label' => __( 'Toys', $amazonjs->text_domain ),
582
+ ),
583
+ 'UnboxVideo' => array(
584
+ 'CA' => false,
585
+ 'CN' => false,
586
+ 'DE' => false,
587
+ 'ES' => false,
588
+ 'FR' => false,
589
+ 'IT' => false,
590
+ 'JP' => false,
591
+ 'UK' => false,
592
+ 'US' => true,
593
+ 'label' => __( 'UnboxVideo', $amazonjs->text_domain ),
594
+ ),
595
+ 'VHS' => array(
596
+ 'CA' => true,
597
+ 'CN' => false,
598
+ 'DE' => true,
599
+ 'ES' => false,
600
+ 'FR' => true,
601
+ 'IT' => false,
602
+ 'JP' => true,
603
+ 'UK' => true,
604
+ 'US' => true,
605
+ 'label' => __( 'VHS', $amazonjs->text_domain ),
606
+ ),
607
+ 'Video' => array(
608
+ 'CA' => true,
609
+ 'CN' => true,
610
+ 'DE' => true,
611
+ 'ES' => false,
612
+ 'FR' => true,
613
+ 'IT' => false,
614
+ 'JP' => true,
615
+ 'UK' => true,
616
+ 'US' => true,
617
+ 'label' => __( 'Video', $amazonjs->text_domain ),
618
+ ),
619
+ 'VideoGames' => array(
620
+ 'CA' => true,
621
+ 'CN' => true,
622
+ 'DE' => true,
623
+ 'ES' => true,
624
+ 'FR' => true,
625
+ 'IT' => true,
626
+ 'JP' => true,
627
+ 'UK' => true,
628
+ 'US' => true,
629
+ 'label' => __( 'VideoGames', $amazonjs->text_domain ),
630
+ ),
631
+ 'Watches' => array(
632
+ 'CA' => false,
633
+ 'CN' => true,
634
+ 'DE' => true,
635
+ 'ES' => true,
636
+ 'FR' => true,
637
+ 'IT' => true,
638
+ 'JP' => false,
639
+ 'UK' => true,
640
+ 'US' => true,
641
+ 'label' => __( 'Watches', $amazonjs->text_domain ),
642
+ ),
643
+ 'Wireless' => array(
644
+ 'CA' => false,
645
+ 'CN' => false,
646
+ 'DE' => false,
647
+ 'ES' => false,
648
+ 'FR' => false,
649
+ 'IT' => false,
650
+ 'JP' => false,
651
+ 'UK' => false,
652
+ 'US' => true,
653
+ 'label' => __( 'Wireless', $amazonjs->text_domain ),
654
+ ),
655
+ 'WirelessAccessories' => array(
656
+ 'CA' => false,
657
+ 'CN' => false,
658
+ 'DE' => false,
659
+ 'ES' => false,
660
+ 'FR' => false,
661
+ 'IT' => false,
662
+ 'JP' => false,
663
+ 'UK' => false,
664
+ 'US' => true,
665
+ 'label' => __( 'WirelessAccessories', $amazonjs->text_domain ),
666
+ ),
667
+ );
668
+ }
amazonjs.php ADDED
@@ -0,0 +1,987 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: AmazonJS
4
+ Plugin URI: http://wordpress.org/extend/plugins/amazonjs/
5
+ Description: Easy to use interface to add an amazon product to your post and display it by using jQuery template.
6
+ Author: makoto_kw
7
+ Version: 0.8
8
+ Author URI: http://makotokw.com
9
+ Requires at least: 3.3
10
+ Tested up to: 4.5
11
+ License: GPLv2
12
+ Text Domain: amazonjs
13
+ Domain Path: /languages/
14
+ */
15
+ /*
16
+ AmazonJS depends on
17
+ jQuery tmpl
18
+ PEAR Services_JSON: Michal Migurski <mike-json@teczno.com>
19
+ */
20
+
21
+ // TODO: Fixed NoSilencedErrors.Discouraged
22
+ // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged
23
+
24
+ require_once dirname( __FILE__ ) . '/lib/json.php';
25
+
26
+ class Amazonjs
27
+ {
28
+ const VERSION = '0.8';
29
+ const AWS_VERSION = '2011-08-01';
30
+ const CACHE_LIFETIME = 86400;
31
+
32
+ public $title;
33
+ public $url;
34
+ public $option_page_url;
35
+ public $plugin_rel_file;
36
+ public $option_page_name;
37
+ public $option_name;
38
+ public $setting_sections;
39
+ public $setting_fields;
40
+ public $default_settings;
41
+ public $settings;
42
+ public $text_domain;
43
+
44
+ public $media_type = 'amazonjs';
45
+ public $countries;
46
+ public $search_indexes;
47
+ public $display_items = array();
48
+ public $simple_template;
49
+
50
+ function __construct() {
51
+ $path = __FILE__;
52
+ $dir = dirname( $path );
53
+ $slug = basename( $dir );
54
+ $this->title = 'AmazonJS';
55
+ $this->plugin_rel_file = basename( $dir ) . DIRECTORY_SEPARATOR . basename( $path );
56
+ $this->option_page_name = basename( $dir );
57
+ $this->option_name = preg_replace( '/[\-\.]/', '_', $this->option_page_name ) . '_settings';
58
+ $this->url = plugins_url( '', $path );
59
+ $this->option_page_url = admin_url() . 'options-general.php?page=' . $this->option_page_name;
60
+ $this->text_domain = $slug;
61
+ load_plugin_textdomain( $this->text_domain, false, dirname( $this->plugin_rel_file ) . '/languages' );
62
+
63
+ $this->countries = array(
64
+ 'US' => array(
65
+ 'label' => __( 'United States', $this->text_domain ),
66
+ 'domain' => 'Amazon.com',
67
+ 'baseUri' => 'http://webservices.amazon.com',
68
+ 'linkTemplate' => '<iframe src="http://rcm.amazon.com/e/cm?t=${t}&o=1&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
69
+ 'associateTagSuffix' => '-20',
70
+ ),
71
+ 'UK' => array(
72
+ 'label' => __( 'United Kingdom', $this->text_domain ),
73
+ 'domain' => 'Amazon.co.uk',
74
+ 'baseUri' => 'http://webservices.amazon.co.uk',
75
+ 'linkTemplate' => '<iframe src="http://rcm-uk.amazon.co.uk/e/cm?t=${t}&o=2&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
76
+ 'associateTagSuffix' => '-21',
77
+ ),
78
+ 'DE' => array(
79
+ 'label' => __( 'Deutschland', $this->text_domain ),
80
+ 'domain' => 'Amazon.de',
81
+ 'baseUri' => 'http://webservices.amazon.de',
82
+ 'linkTemplate' => '<iframe src="http://rcm-de.amazon.de/e/cm?t=${t}&o=3&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
83
+ 'associateTagSuffix' => '04-21',
84
+ ),
85
+ 'FR' => array(
86
+ 'label' => __( 'France', $this->text_domain ),
87
+ 'domain' => 'Amazon.fr',
88
+ 'baseUri' => 'http://webservices.amazon.fr',
89
+ 'linkTemplate' => '<iframe src="http://rcm-fr.amazon.fr/e/cm?t=${t}&o=8&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
90
+ 'associateTagSuffix' => '09-21',
91
+ ),
92
+ 'JP' => array(
93
+ 'label' => __( 'Japan', $this->text_domain ),
94
+ 'domain' => 'Amazon.co.jp',
95
+ 'baseUri' => 'http://webservices.amazon.co.jp',
96
+ 'linkTemplate' => '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=${t}&o=9&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
97
+ 'associateTagSuffix' => '-22',
98
+ ),
99
+ 'CA' => array(
100
+ 'label' => __( 'Canada', $this->text_domain ),
101
+ 'domain' => 'Amazon.ca',
102
+ 'baseUri' => 'http://webservices.amazon.ca',
103
+ 'linkTemplate' => '<iframe src="http://rcm-ca.amazon.ca/e/cm?t=${t}&o=15&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
104
+ 'associateTagSuffix' => '0c-20',
105
+ ),
106
+ 'CN' => array(
107
+ 'label' => __( 'China', $this->text_domain ),
108
+ 'domain' => 'Amazon.cn',
109
+ 'baseUri' => 'http://webservices.amazon.cn',
110
+ 'linkTemplate' => '<iframe src="http://rcm-cn.amazon.cn/e/cm?t=${t}&o=28&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
111
+ 'associateTagSuffix' => '-23',
112
+ ),
113
+ 'IT' => array(
114
+ 'label' => __( 'Italia', $this->text_domain ),
115
+ 'domain' => 'Amazon.it',
116
+ 'baseUri' => 'http://webservices.amazon.it',
117
+ 'linkTemplate' => '<iframe src="http://rcm-it.amazon.it/e/cm?t=${t}&o=29&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
118
+ 'associateTagSuffix' => '-21',
119
+ ),
120
+ 'ES' => array(
121
+ 'label' => __( 'EspaƱa', $this->text_domain ),
122
+ 'domain' => 'Amazon.es',
123
+ 'baseUri' => 'http://webservices.amazon.es',
124
+ 'linkTemplate' => '<iframe src="http://rcm-es.amazon.es/e/cm?t=${t}&o=30&p=8&l=as1&asins=${asins}&fc1=${fc1}&IS2=${IS2}&lt1=${lt1}&m=amazon&lc1=${lc1}&bc1=${bc1}&bg1=${bg1}&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>',
125
+ 'associateTagSuffix' => '-21',
126
+ ),
127
+ );
128
+ }
129
+
130
+ function clean() {
131
+ $this->delete_settings();
132
+ }
133
+
134
+ function init() {
135
+ $this->init_settings();
136
+
137
+ if ( is_admin() ) {
138
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
139
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
140
+ add_action( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
141
+ }
142
+ add_shortcode( 'amazonjs', array( $this, 'shortcode' ) );
143
+ if ( ! is_admin() ) {
144
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_styles' ) );
145
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
146
+ add_action( 'wp_footer', array( $this, 'wp_enqueue_scripts_for_footer' ), 1 );
147
+ }
148
+ }
149
+
150
+ function admin_init() {
151
+ add_action( 'media_buttons', array( $this, 'media_buttons' ), 20 );
152
+ add_action( 'media_upload_amazonjs', array( $this, 'media_upload_amazonjs' ) );
153
+ add_action( 'media_upload_amazonjs_keyword', array( $this, 'media_upload_amazonjs_keyword' ) );
154
+ add_action( 'media_upload_amazonjs_id', array( $this, 'media_upload_amazonjs_id' ) );
155
+ add_action( 'wp_ajax_amazonjs_search', array( $this, 'ajax_amazonjs_search' ) );
156
+
157
+ $page = $this->option_page_name;
158
+ register_setting( $this->option_name, $this->option_name, array( $this, 'validate_settings' ) );
159
+ if ( $this->setting_sections ) {
160
+ foreach ( $this->setting_sections as $key => $section ) {
161
+ add_settings_section( $page . '_' . $key, $section['label'], array( $this, $section['add'] ), $page );
162
+ }
163
+ }
164
+ foreach ( $this->setting_fields as $key => $field ) {
165
+ $label = ('checkbox' == $field['type']) ? '' : $field['label'];
166
+ add_settings_field(
167
+ $this->option_name . '_' . $key,
168
+ $label,
169
+ array( $this, 'add_settings_field' ),
170
+ $page,
171
+ $page . '_' . $field['section'],
172
+ array( $key, $field )
173
+ );
174
+ }
175
+ }
176
+
177
+ function admin_print_styles() {
178
+ global $wp_version;
179
+ // use dashicon
180
+ if ( version_compare( $wp_version, '3.8', '>=' ) ) {
181
+ wp_enqueue_style( 'amazonjs-options', $this->url . '/css/amazonjs-options.css', array(), self::VERSION );
182
+ }
183
+ }
184
+
185
+ function wp_enqueue_styles() {
186
+ if ( $this->settings['displayCustomerReview'] ) {
187
+ wp_enqueue_style( 'thickbox' );
188
+ }
189
+
190
+ if ( $this->settings['overrideThemeCss'] ) {
191
+ wp_enqueue_style( 'amazonjs', $this->url . '/css/amazonjs-force.css', array(), self::VERSION );
192
+ } else {
193
+ wp_enqueue_style( 'amazonjs', $this->url . '/css/amazonjs.css', array(), self::VERSION );
194
+ }
195
+ if ( $this->settings['customCss'] ) {
196
+ wp_enqueue_style( 'amazonjs-custom', get_stylesheet_directory_uri() . '/amazonjs.css' );
197
+ }
198
+ }
199
+
200
+ function wp_enqueue_scripts() {
201
+ wp_register_script( 'jquery-tmpl', $this->url . '/components/js/jquery-tmpl/jquery.tmpl.min.js', array( 'jquery' ), '1.0.0pre', true );
202
+
203
+ $depends = array( 'jquery-tmpl' );
204
+ if ( $this->settings['displayCustomerReview'] ) {
205
+ $depends[] = 'thickbox';
206
+ }
207
+ wp_register_script( 'amazonjs', $this->url . '/js/amazonjs.js', $depends, self::VERSION, true );
208
+ if ( $this->settings['customJs'] ) {
209
+ wp_register_script( 'amazonjs-custom', get_stylesheet_directory_uri() . '/amazonjs.js', array( 'amazonjs' ), self::VERSION, true );
210
+ }
211
+ }
212
+
213
+ function wp_enqueue_scripts_for_footer() {
214
+ $country_codes = array();
215
+ $items = array();
216
+ foreach ( $this->display_items as $country_code => $sub_items ) {
217
+ foreach ( $this->fetch_items( $country_code, $sub_items ) as $asin => $item ) {
218
+ $items[ $country_code . ':' . $asin ] = $item;
219
+ }
220
+ $country_codes[] = $country_code;
221
+ }
222
+
223
+ if ( count( $items ) == 0 ) {
224
+ return;
225
+ }
226
+
227
+ $this->enqueue_amazonjs_scripts( $items, $country_codes );
228
+ }
229
+
230
+ function enqueue_amazonjs_scripts( $items = array(), $country_codes = array() ) {
231
+ $wpurl = get_bloginfo( 'wpurl' );
232
+
233
+ $region = array();
234
+ foreach ( $this->countries as $code => $value ) {
235
+ if ( in_array( $code, $country_codes ) ) {
236
+ foreach ( array( 'linkTemplate' ) as $attr ) {
237
+ $region[ 'Link' . $code ] = $this->tmpl( $value[ $attr ], array( 't' => $this->settings[ 'associateTag' . $code ] ) );
238
+ }
239
+ }
240
+ }
241
+
242
+ $amazonVars = array(
243
+ 'thickboxUrl' => $wpurl . '/wp-includes/js/thickbox/',
244
+ 'regionTemplate' => $region,
245
+ 'resource' => array(
246
+ 'BookAuthor' => __( 'Author', $this->text_domain ),
247
+ 'BookPublicationDate' => __( 'PublicationDate', $this->text_domain ),
248
+ 'BookPublisher' => __( 'Publisher', $this->text_domain ),
249
+ 'NumberOfPagesValue' => __( '${NumberOfPages} pages', $this->text_domain ),
250
+ 'ListPrice' => __( 'List Price', $this->text_domain ),
251
+ 'Price' => __( 'Price', $this->text_domain ),
252
+ 'PriceUsage' => __( 'Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [amazon.com or endless.com, as applicable] at the time of purchase will apply to the purchase of this product.', $this->text_domain ),
253
+ 'PublicationDate' => __( 'Publication Date', $this->text_domain ),
254
+ 'ReleaseDate' => __( 'Release Date', $this->text_domain ),
255
+ 'SalesRank' => __( 'SalesRank', $this->text_domain ),
256
+ 'SalesRankValue' => __( '#${SalesRank}', $this->text_domain ),
257
+ 'RunningTime' => __( 'Run Time', $this->text_domain ),
258
+ 'RunningTimeValue' => __( '${RunningTime} minutes', $this->text_domain ),
259
+ 'CustomerReviewTitle' => __( '${Title} Customer Review', $this->text_domain ),
260
+ 'SeeCustomerReviews' => __( 'See Customer Reviews', $this->text_domain ),
261
+ 'PriceUpdatedat' => __( '(at ${UpdatedDate})', $this->text_domain ),
262
+ ),
263
+ 'isCustomerReviewEnabled' => ($this->settings['displayCustomerReview']) ? true : false,
264
+ 'isTrackEventEnabled' => ($this->settings['useTrackEvent']) ? true : false,
265
+ 'isFadeInEnabled' => ($this->settings['useAnimation']) ? true : false,
266
+ 'items' => array_values( $items ),
267
+
268
+ );
269
+ wp_localize_script( 'amazonjs', 'amazonjsVars', $amazonVars );
270
+
271
+ wp_enqueue_script( 'amazonjs' );
272
+ if ( $this->settings['customJs'] ) {
273
+ wp_enqueue_script( 'amazonjs-custom' );
274
+ }
275
+ }
276
+
277
+ function init_settings() {
278
+ // section
279
+ $this->setting_sections = array(
280
+ 'api' => array(
281
+ 'label' => __( 'Product Advertising API settings', $this->text_domain ),
282
+ 'add' => 'add_api_setting_section',
283
+ ),
284
+ 'associate' => array(
285
+ 'label' => __( 'Amazon Associates settings', $this->text_domain ),
286
+ 'add' => 'add_associate_setting_section',
287
+ ),
288
+ 'appearance' => array(
289
+ 'label' => __( 'Appearance settings', $this->text_domain ),
290
+ 'add' => 'add_appearance_setting_section',
291
+ ),
292
+ 'analytics' => array(
293
+ 'label' => __( 'Analytics settings', $this->text_domain ),
294
+ 'add' => 'add_analytics_setting_section',
295
+ ),
296
+ 'customize' => array(
297
+ 'label' => __( 'Customize', $this->text_domain ),
298
+ 'add' => 'add_customize_setting_section',
299
+ ),
300
+ );
301
+ // filed
302
+ $template_url = get_bloginfo( 'template_url' );
303
+ $this->setting_fields = array(
304
+ 'accessKeyId' => array(
305
+ 'label' => __( 'Access Key ID', $this->text_domain ),
306
+ 'type' => 'text',
307
+ 'size' => 60,
308
+ 'section' => 'api',
309
+ ),
310
+ 'secretAccessKey' => array(
311
+ 'label' => __( 'Secret Access Key', $this->text_domain ),
312
+ 'type' => 'text',
313
+ 'size' => 60,
314
+ 'section' => 'api',
315
+ ),
316
+ 'displayCustomerReview' => array(
317
+ 'label' => __( 'Display customer review', $this->text_domain ),
318
+ 'type' => 'checkbox',
319
+ 'section' => 'appearance',
320
+ 'description' => __( "AmazonJS will display customer review by using WordPress's Thickbox.", $this->text_domain ),
321
+ ),
322
+ 'supportDisabledJavascript' => array(
323
+ 'label' => __( 'Display official widget when disabled javascript in web browser', $this->text_domain ),
324
+ 'type' => 'checkbox',
325
+ 'section' => 'appearance',
326
+ 'description' => __( 'If set to true, AmazonJS will output html by using <code>&lt;script type=&quot;text/javascript&quot;&gt;document.write(&quot;{$indicator_html}&quot;)&lt;/script&gt;&lt;noscript&gt;{$link_html}&lt;/noscript&gt;</code>.', $this->text_domain ),
327
+ ),
328
+ 'useAnimation' => array(
329
+ 'label' => __( 'Use fadeIn animation', $this->text_domain ),
330
+ 'type' => 'checkbox',
331
+ 'section' => 'appearance',
332
+ ),
333
+ 'overrideThemeCss' => array(
334
+ 'label' => __( 'Override style of theme', $this->text_domain ),
335
+ 'type' => 'checkbox',
336
+ 'section' => 'appearance',
337
+ 'description' => __( 'If set to true, AmazonJS will override the style of the theme by using <code>!important</code> declaration.', $this->text_domain ),
338
+ ),
339
+ 'useTrackEvent' => array(
340
+ 'label' => __( 'Click Tracking by using Google Analytics', $this->text_domain ),
341
+ 'type' => 'checkbox',
342
+ 'section' => 'analytics',
343
+ 'description' => __( 'If set to true, AmazonJS will call <code>_gaq.push(["_trackEvent", "AmazonJS", "Click", "ASIN TITLE"])</code> or <code>ga("send", "event", "AmazonJS", "Click", "ASIN TITLE")</code>.', $this->text_domain ),
344
+ ),
345
+ 'customCss' => array(
346
+ 'label' => __( 'Use Custom Css', $this->text_domain ),
347
+ 'type' => 'checkbox',
348
+ 'section' => 'customize',
349
+ 'description' => '(' . $template_url . '/amazonjs.css)',
350
+ ),
351
+ 'customJs' => array(
352
+ 'label' => __( 'Use Custom Javascript', $this->text_domain ),
353
+ 'type' => 'checkbox',
354
+ 'section' => 'customize',
355
+ 'description' => '(' . $template_url . '/amazonjs.js)',
356
+ ),
357
+ );
358
+ foreach ( $this->countries as $key => $value ) {
359
+ $this->setting_fields[ 'associateTag' . $key ] = array(
360
+ 'label' => __( $value['domain'], $this->text_domain ),
361
+ 'type' => 'text',
362
+ 'size' => 30,
363
+ 'placeholder' => 'associatetag' . $value['associateTagSuffix'],
364
+ 'section' => 'associate',
365
+ );
366
+ }
367
+
368
+ $this->default_settings = array();
369
+ if ( is_array( $this->setting_fields ) ) {
370
+ foreach ( $this->setting_fields as $key => $field ) {
371
+ $this->default_settings[ $key ] = @$field['defaults'];
372
+ }
373
+ }
374
+ //delete_option($this->option_name);
375
+ $this->settings = wp_parse_args( (array) get_option( $this->option_name ), $this->default_settings );
376
+ }
377
+
378
+ function delete_settings() {
379
+ delete_option( $this->option_name );
380
+ }
381
+
382
+ function validate_settings( $settings ) {
383
+ foreach ( $this->setting_fields as $key => $field ) {
384
+ if ( 'checkbox' == $field['type'] ) {
385
+ $settings[ $key ] = ( 'on' == @$settings[ $key ] || '1' == @$settings[ $key ] );
386
+ }
387
+ }
388
+
389
+ foreach ( array( 'accessKeyId', 'secretAccessKey' ) as $key ) {
390
+ $settings[ $key ] = trim( $settings[ $key ] );
391
+ }
392
+
393
+ foreach ( $this->countries as $country_code => $value ) {
394
+ $key = 'associateTag' . $country_code;
395
+ $settings[ $key ] = trim( $settings[ $key ] );
396
+ }
397
+
398
+ return $settings;
399
+ }
400
+
401
+ function admin_menu() {
402
+ if ( function_exists( 'add_options_page' ) ) {
403
+ $page_hook_suffix = add_options_page(
404
+ __( $this->title, $this->text_domain ),
405
+ __( $this->title, $this->text_domain ),
406
+ 'manage_options',
407
+ $this->option_page_name,
408
+ array( $this, 'options_page' )
409
+ );
410
+ add_action( 'admin_print_styles-' . $page_hook_suffix, array( $this, 'admin_print_styles' ) );
411
+ }
412
+ }
413
+
414
+ function get_amazon_official_link( $asin, $country_code ) {
415
+ $tmpl = $this->countries[ $country_code ]['linkTemplate'];
416
+ $item = array(
417
+ 't' => $this->settings[ 'associateTag' . $country_code ],
418
+ 'asins' => $asin,
419
+ 'fc1' => '000000',
420
+ 'lc1' => '0000FF',
421
+ 'bc1' => '000000',
422
+ 'bg1' => 'FFFFFF',
423
+ 'IS2' => 1,
424
+ 'lt1' => '_blank',
425
+ 'f' => 'ifr',
426
+ 'm' => 'amazon',
427
+ );
428
+ return $this->tmpl( $tmpl, $item );
429
+ }
430
+
431
+ function shortcode( $atts, /** @noinspection PhpUnusedParameterInspection */ $content ) {
432
+ /**
433
+ * @var string $asin
434
+ * @var string $tmpl
435
+ * @var string $locale
436
+ * @var string $title
437
+ * @var string $imgsize
438
+ */
439
+ $defaults = array( 'asin' => '', 'tmpl' => '', 'locale' => $this->default_country_code(), 'title' => '', 'imgsize' => '' );
440
+ extract( shortcode_atts( $defaults, $atts ) );
441
+ if ( empty($asin) ) {
442
+ return '';
443
+ }
444
+ $country_code = strtoupper( $locale );
445
+ $imgsize = strtolower( $imgsize );
446
+ if ( is_feed() ) {
447
+ // use static html for rss reader
448
+ if ( $ai = $this->get_item( $country_code, $asin ) ) {
449
+ $aimg = $ai['SmallImage'];
450
+ if ( array_key_exists( 'MediumImage', $ai ) ) {
451
+ $aimg = $ai['MediumImage'];
452
+ }
453
+ return <<<EOF
454
+ <a href="{$ai['DetailPageURL']}" title="{$ai['Title']}" target="_blank">
455
+ <img src="{$aimg['src']}" width="{$aimg['width']}" height="{$aimg['height']}" alt="{$ai['Title']}"/>
456
+ {$ai['Title']}
457
+ </a>
458
+ EOF;
459
+ }
460
+ return $this->get_amazon_official_link( $asin, $country_code );
461
+ }
462
+ if ( ! isset($this->display_items[ $country_code ]) ) {
463
+ $this->display_items[ $country_code ] = array();
464
+ }
465
+ $item = (array_key_exists( $asin, $this->display_items[ $country_code ] ))
466
+ ? $this->display_items[ $country_code ][ $asin ]
467
+ : $this->display_items[ $country_code ][ $asin ] = get_site_transient("amazonjs_{$country_code}_{$asin}");
468
+ $url = '#';
469
+ if ( is_array( $item ) && array_key_exists( 'DetailPageURL', $item ) ) {
470
+ $url = $item['DetailPageURL'];
471
+ }
472
+ $indicator_html = <<<EOF
473
+ <div data-role="amazonjs" data-asin="{$asin}" data-locale="{$country_code}" data-tmpl="${tmpl}" data-img-size="${imgsize}" class="asin_{$asin}_{$country_code}_${tmpl} amazonjs_item"><div class="amazonjs_indicator"><span class="amazonjs_indicator_img"></span><a class="amazonjs_indicator_title" href="{$url}">{$title}</a><span class="amazonjs_indicator_footer"></span></div></div>
474
+ EOF;
475
+
476
+ $indicator_html = trim( $indicator_html );
477
+ if ( ! $this->settings['supportDisabledJavascript'] ) {
478
+ return $indicator_html;
479
+ }
480
+ $indicator_html = addslashes( $indicator_html );
481
+ $link_html = $this->get_amazon_official_link( $asin, $country_code );
482
+
483
+ return <<<EOF
484
+ <script type="text/javascript">document.write("{$indicator_html}")</script><noscript>{$link_html}</noscript>
485
+ EOF;
486
+ }
487
+
488
+ /**
489
+ * Gets default country code by get_locale
490
+ * @return string
491
+ */
492
+ function default_country_code() {
493
+ switch ( get_locale() ) {
494
+ case 'en_CA':
495
+ return 'CA';
496
+ case 'de_DE':
497
+ return 'DE';
498
+ case 'fr_FR':
499
+ return 'FR';
500
+ case 'ja':
501
+ return 'JP';
502
+ case 'en_GB':
503
+ return 'UK';
504
+ case 'zh_CN':
505
+ return 'CN';
506
+ case 'it_IT':
507
+ return 'IT';
508
+ case 'es_ES':
509
+ return 'ES';
510
+ }
511
+ return 'US';
512
+ }
513
+
514
+ function get_item( $country_code, $asin ) {
515
+ if ( $ai = get_site_transient( "amazonjs_{$country_code}_{$asin}" ) ) {
516
+ return $ai;
517
+ }
518
+ $items = $this->fetch_items( $country_code, array( $asin => false ) );
519
+ return @$items[ $asin ];
520
+ }
521
+
522
+ /**
523
+ * @param string $country_code
524
+ * @param array $items
525
+ * @return array
526
+ */
527
+ function fetch_items( $country_code, $items ) {
528
+ $now = time();
529
+ $item_ids = array();
530
+ foreach ( $items as $asin => $item ) {
531
+ if ( ! $item && $item['UpdatedAt'] + 86400 < $now ) {
532
+ $item_ids[] = $asin;
533
+ }
534
+ }
535
+ while ( count( $item_ids ) ) {
536
+ // fetch via 10 products
537
+ // ItemLookup ItemId: Must be a valid item ID. For more than one ID, use a comma-separated list of up to ten IDs.
538
+ $itemid = implode( ',', array_splice( $item_ids, 0, 10 ) );
539
+ $results = $this->itemlookup( $country_code, $itemid );
540
+ if ( $results && $results['success'] ) {
541
+ foreach ( $results['items'] as $item ) {
542
+ $items[ $item['ASIN'] ] = $item;
543
+ set_site_transient("amazonjs_{$country_code}_{$item['ASIN']}", $item, self::CACHE_LIFETIME);
544
+ }
545
+ }
546
+ }
547
+ return $items;
548
+ }
549
+
550
+ function tmpl( $tmpl, $item ) {
551
+ $s = $tmpl;
552
+ foreach ( $item as $key => $value ) {
553
+ $s = str_replace( '${' . $key . '}', $value, $s );
554
+ }
555
+ return $s;
556
+ }
557
+
558
+ function plugin_row_meta( $links, $file ) {
559
+ if ( $file == $this->plugin_rel_file ) {
560
+ array_push(
561
+ $links,
562
+ sprintf( '<a href="%s">%s</a>', $this->option_page_url, __( 'Settings' ) )
563
+ );
564
+ array_push(
565
+ $links,
566
+ sprintf( '<a href="https://github.com/makotokw/wp-amazonjs/releases" target="_blank">%s</a>', __( 'Old Releases', $this->text_domain ) )
567
+ );
568
+ }
569
+ return $links;
570
+ }
571
+
572
+ function add_api_setting_section() {
573
+ ?>
574
+ <p><?php _e( 'This plugin uses the Amazon Product Advertising API in order to get product infomation. Thus, you must use your Access Key ID &amp; Secret Access Key.', $this->text_domain ); ?></p>
575
+ <p><?php _e( 'You can sign up the Amazon Product Advertising API from <a href="https://affiliate-program.amazon.com/gp/advertising/api/detail/main.html" target="_blank">here</a>. Please review the <a href="http://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html" target="_blank">Product Advertising API License Agreement</a> for details.', $this->text_domain ) ?></p>
576
+ <?php
577
+ }
578
+
579
+ function add_associate_setting_section() {
580
+ ?>
581
+ <p><?php _e( 'Amazon has an affiliate program called Amazon Associates. To apply for the Associates Program, visit the <a href="https://affiliate-program.amazon.com/" target="_blank">Amazon Associates website</a> for details.', $this->text_domain ); ?></p>
582
+ <p><?php _e( 'Associate Tag has been a <strong>required and verified</strong> input parameter in all requests to the Amazon Product Advertising API since 11/1/2011.', $this->text_domain ) ?></p>
583
+ <?php
584
+ }
585
+
586
+ function add_appearance_setting_section() {
587
+ }
588
+
589
+ function add_analytics_setting_section() {
590
+ }
591
+
592
+ function add_customize_setting_section() {
593
+ }
594
+
595
+ function add_settings_field( $args = array() ) {
596
+ // not work wordpress 2.9.0 #11143
597
+ if ( empty($args) ) {
598
+ return;
599
+ }
600
+ list ($key, $field) = $args;
601
+ $id = $this->option_name . '_' . $key;
602
+ $name = $this->option_name . "[{$key}]";
603
+ $value = $this->settings[ $key ];
604
+ if ( isset($field['html']) ) {
605
+ echo '' . $field['html'] . '';
606
+ } else {
607
+ switch ( $field['type'] ) {
608
+ case 'checkbox':
609
+ ?>
610
+ <input id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>" type="checkbox" <?php checked( true, $value ); ?> value="1" />
611
+ <label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
612
+ <?php
613
+ break;
614
+ case 'radio':
615
+ $index = 1;
616
+ foreach ( $field['options'] as $v => $content ) {
617
+ $input_element_id = $id . '_' . $index;
618
+ ?>
619
+ <input id="<?php echo esc_attr( $input_element_id ); ?>" name="<?php echo esc_attr( $name ); ?>" type="radio" <?php checked( $v, $value ); ?> value="<?php echo esc_attr( $v ); ?>" />
620
+ <label for="<?php echo esc_attr( $input_element_id ); ?>"><?php echo esc_html( $content ); ?></label>
621
+ <?php
622
+ $index++;
623
+ }
624
+ break;
625
+ case 'select':
626
+ ?>
627
+ <select id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>">
628
+ <?php foreach ( $field['options'] as $option => $name ) : ?>
629
+ <option value="<?php echo esc_attr( $option ); ?>" <?php selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option>
630
+ <?php endforeach ?>
631
+ </select>
632
+ <?php
633
+ break;
634
+ case 'text':
635
+ default:
636
+ $size = @$field['size'];
637
+ $placeholder = @$field['placeholder'];
638
+ if ( $size <= 0 ) {
639
+ $size = 40;
640
+ }
641
+ if ( ! is_string( $placeholder ) ) {
642
+ $placeholder = '';
643
+ }
644
+ ?>
645
+ <input id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $name ); ?>" type="text" size="<?php echo esc_attr( $size ); ?>" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>"/>
646
+ <?php
647
+ break;
648
+ }
649
+ }
650
+ if ( @$field['description'] ) {
651
+ echo '<p class="description">' . $field['description'] . '</p>';
652
+ }
653
+ }
654
+
655
+ function media_buttons() {
656
+ global $post_ID, $temp_ID;
657
+ $iframe_ID = (int) ( 0 == $post_ID ? $temp_ID : $post_ID );
658
+ $iframe_src = 'media-upload.php?post_id=' . $iframe_ID . '&amp;type=' . $this->media_type . '&amp;tab=' . $this->media_type . '_keyword';
659
+ $label = __( 'Add Amazon Link', $this->text_domain );
660
+ ?>
661
+ <a href="<?php echo esc_attr( $iframe_src . '&amp;TB_iframe=true' ); ?>" id="add_amazon" class="button thickbox" title="<?php echo esc_attr( $label ); ?>"><img src="<?php echo esc_attr( $this->url . '/images/amazon-icon.png' ); ?>" alt="<?php echo esc_attr( $label ); ?>"/></a>
662
+ <?php
663
+ }
664
+
665
+ function media_upload_init() {
666
+ add_action( 'admin_print_styles', array( $this, 'wp_enqueue_styles' ) );
667
+
668
+ $this->wp_enqueue_scripts();
669
+ wp_enqueue_style( 'amazonjs-media-upload', $this->url . '/css/media-upload-type-amazonjs.css', array( 'amazonjs' ), self::VERSION );
670
+
671
+ $this->enqueue_amazonjs_scripts();
672
+ }
673
+
674
+ function media_upload_amazonjs() {
675
+ $this->media_upload_init();
676
+ wp_iframe( 'media_upload_type_amazonjs' );
677
+ }
678
+
679
+ function media_upload_amazonjs_keyword() {
680
+ $this->media_upload_init();
681
+ wp_iframe( 'media_upload_type_amazonjs_keyword' );
682
+ }
683
+
684
+ function media_upload_amazonjs_id() {
685
+ $this->media_upload_init();
686
+ wp_iframe( 'media_upload_type_amazonjs_id' );
687
+ }
688
+
689
+ function media_upload_tabs( /** @noinspection PhpUnusedParameterInspection */$tabs ) {
690
+ return array(
691
+ $this->media_type . '_keyword' => __( 'Keyword Search', $this->text_domain ),
692
+ $this->media_type . '_id' => __( 'Search by ASIN/URL', $this->text_domain ),
693
+ );
694
+ }
695
+
696
+ function options_page() {
697
+ ?>
698
+ <div class="wrap wrap-amazonjs">
699
+ <h2><?php echo esc_html( $this->title ); ?></h2>
700
+ <?php $this->options_page_header(); ?>
701
+ <!--suppress HtmlUnknownTarget -->
702
+ <form action="options.php" method="post">
703
+ <?php settings_fields( $this->option_name ); ?>
704
+ <?php do_settings_sections( $this->option_page_name ); ?>
705
+ <?php submit_button(); ?>
706
+ </form>
707
+ </div>
708
+ <?php
709
+ }
710
+
711
+ function options_page_header() {
712
+ ?>
713
+ <?php if ( ! function_exists( 'simplexml_load_string' ) ) : ?>
714
+ <div class="error">
715
+ <p><?php printf( __( 'Error! "simplexml_load_string" function is not found. %s requires PHP 5 and SimpleXML extension.', $this->text_domain ), $this->title ); ?></p>
716
+ </div>
717
+ <?php endif ?>
718
+ <?php
719
+ }
720
+
721
+ // amazon api
722
+ function itemlookup( $countryCode, $itemId ) {
723
+ $options = array();
724
+ $options['ItemId'] = $itemId;
725
+ $options['Operation'] = 'ItemLookup';
726
+ return $this->amazon_get( $countryCode, $options );
727
+ }
728
+
729
+ // amazon api
730
+ function itemsearch( $countryCode, $searchIndex, $keywords, $itemPage = 0 ) {
731
+ $options = array();
732
+ if ( $itemPage > 0 ) {
733
+ $options['ItemPage'] = $itemPage;
734
+ }
735
+ $options['Keywords'] = $keywords;
736
+ $options['Operation'] = 'ItemSearch';
737
+ if ( $searchIndex ) {
738
+ $options['SearchIndex'] = $searchIndex;
739
+ }
740
+ return $this->amazon_get( $countryCode, $options );
741
+ }
742
+
743
+ /**
744
+ * parse ASIN from URL
745
+ * @param string $url
746
+ * @return bool|string
747
+ */
748
+ static function parse_asin( $url ) {
749
+ if ( preg_match( '/^https?:\/\/.+\.amazon\.([^\/]+).+\/(dp|gp\/product|ASIN)\/([^\/]+)/', $url, $matches ) ) {
750
+ return $matches[3];
751
+ }
752
+ return null;
753
+ }
754
+
755
+ function ajax_amazonjs_search() {
756
+ $itemId = null;
757
+
758
+ // from http get
759
+ $itemPage = @$_GET['ItemPage'];
760
+ $id = @$_GET['ID'];
761
+ $keywords = @$_GET['Keywords'];
762
+ $searchIndex = @$_GET['SearchIndex'];
763
+ $countryCode = @$_GET['CountryCode'];
764
+
765
+ if ( ! empty($id) ) {
766
+ if ( preg_match( '/^https?:\/\//', $id ) ) {
767
+ if ( $asin = self::parse_asin( $id ) ) {
768
+ $itemId = $asin;
769
+ } else {
770
+ // url string as query keyword
771
+ $keywords = $id;
772
+ }
773
+ } else {
774
+ $itemId = $id;
775
+ }
776
+ } else if ( ! empty($keywords) ) {
777
+ if ( preg_match( '/^https?:\/\//', $keywords ) ) {
778
+ if ( $asin = self::parse_asin( $keywords ) ) {
779
+ $itemId = $asin;
780
+ }
781
+ }
782
+ }
783
+ $amazonjs = new Amazonjs();
784
+ $amazonjs->init();
785
+ if ( isset($itemId) ) {
786
+ $result = $amazonjs->itemlookup( $countryCode, $itemId );
787
+ die(json_encode( $result ));
788
+ } else {
789
+ $result = $amazonjs->itemsearch( $countryCode, $searchIndex, $keywords, $itemPage );
790
+ die(json_encode( $result ));
791
+ }
792
+ }
793
+
794
+ function amazon_get( $countryCode, $options ) {
795
+ $baseUri = $this->countries[ $countryCode ]['baseUri'];
796
+ $accessKeyId = @trim( $this->settings['accessKeyId'] );
797
+ $secretAccessKey = @trim( $this->settings['secretAccessKey'] );
798
+ $associateTag = @$this->settings[ 'associateTag' . $countryCode ];
799
+
800
+ // validate request
801
+ if ( empty($countryCode) || (empty($options['ItemId']) && empty($options['Keywords'])) || (empty($accessKeyId) || empty($secretAccessKey)) ) {
802
+ $message = __( 'Invalid Request Parameters', $this->text_domain );
803
+ return compact( 'success', 'message' );
804
+ }
805
+
806
+ $options['AWSAccessKeyId'] = $accessKeyId;
807
+ if ( ! empty($associateTag) ) {
808
+ $options['AssociateTag'] = @trim( $associateTag );
809
+ }
810
+ $options['ResponseGroup'] = 'ItemAttributes,Small,Images,OfferSummary,SalesRank,Reviews';
811
+ $options['Service'] = 'AWSECommerceService';
812
+ $options['Timestamp'] = gmdate( 'Y-m-d\TH:i:s\Z' );
813
+ $options['Version'] = self::AWS_VERSION;
814
+ ksort( $options );
815
+ $params = array();
816
+ foreach ( $options as $k => $v ) {
817
+ $params[] = $k . '=' . self::urlencode_rfc3986( $v );
818
+ }
819
+ $query = implode( '&', $params );
820
+ $urlInfo = parse_url( $baseUri );
821
+ $signature = sprintf( "GET\n%s\n/onca/xml\n%s", $urlInfo['host'], $query );
822
+ $signature = base64_encode( hash_hmac( 'sha256', $signature, $secretAccessKey, true ) );
823
+ unset($params, $urlInfo);
824
+
825
+ $url = sprintf( '%s/onca/xml?%s&Signature=%s', $baseUri, $query, self::urlencode_rfc3986( $signature ) );
826
+
827
+ $response = wp_remote_request(
828
+ $url,
829
+ array(
830
+ 'timeout' => 30,
831
+ )
832
+ );
833
+
834
+ if ( is_wp_error( $response ) ) {
835
+ $error = '';
836
+ $errors = $response->get_error_messages();
837
+ if ( is_array( $errors ) ) {
838
+ $error = implode( '<br/>', $errors );
839
+ }
840
+ $message = sprintf( __( 'Network Error: %s', $this->text_domain ), $error );
841
+ return compact( 'success', 'message' );
842
+ }
843
+
844
+ $body = wp_remote_retrieve_body( $response );
845
+ if ( empty($body) ) {
846
+ $message = sprintf( __( 'Empty Response from %s', $this->text_domain ), $url );
847
+ return compact( 'success', 'message' );
848
+ }
849
+
850
+ $fetchedAt = time();
851
+
852
+ $success = false;
853
+ /* @var $xml stdClass */
854
+ $xml = @simplexml_load_string( $body );
855
+ if ( WP_DEBUG ) {
856
+ if ( ! $xml ) {
857
+ error_log( 'amazonjs: cannot parse xml: ' . $body );
858
+ }
859
+ }
860
+
861
+ if ( $xml ) {
862
+ if ( 'True' == (string) @$xml->Items->Request->IsValid ) {
863
+ $success = true;
864
+ $items = array();
865
+ $operation = $options['Operation'];
866
+ if ( 'ItemSearch' == $operation ) {
867
+ $os = array(); // OpenSearch
868
+ $request = $xml->Items->Request->ItemSearchRequest;
869
+ $resultMap = self::to_array( $xml->Items->SearchResultsMap );
870
+ $itemsParPage = 10;
871
+ $startPage = ($request->ItemPage) ? (int) $request->ItemPage : 1;
872
+ $os['itemsPerPage'] = $itemsParPage;
873
+ $os['startIndex'] = ($startPage - 1) * $itemsParPage + 1;
874
+ $os['Query'] = array( 'searchTerms' => (string) $request->Keywords, 'startPage' => $startPage );
875
+ }
876
+ $os['totalResults'] = (int) $xml->Items->TotalResults;
877
+ $os['totalPages'] = (int) $xml->Items->TotalPages;
878
+
879
+ foreach ( $xml->Items->Item as $item ) {
880
+ $r = self::to_array( $item->ItemAttributes );
881
+ $r['ASIN'] = trim( (string) $item->ASIN );
882
+ $r['DetailPageURL'] = trim( (string) $item->DetailPageURL );
883
+ $r['SalesRank'] = (int) $item->SalesRank;
884
+ if ( $reviews = $item->CustomerReviews ) {
885
+ $r['IFrameReviewURL'] = (string) $reviews->IFrameURL;
886
+ }
887
+ $r['OfferSummary'] = self::to_array( $item->OfferSummary );
888
+ $r['SmallImage'] = self::image_element( $item->SmallImage );
889
+ $r['MediumImage'] = self::image_element( $item->MediumImage );
890
+ $r['LargeImage'] = self::image_element( $item->LargeImage );
891
+ $r['CountryCode'] = $countryCode;
892
+ $r['UpdatedAt'] = $fetchedAt;
893
+ $items[] = $r;
894
+ }
895
+ if ( 'ItemLookup' == $operation ) {
896
+ if ( 0 == $os['totalResults'] ) {
897
+ $os['totalResults'] = count( $items );
898
+ }
899
+ if ( 0 == $os['totalPages'] ) {
900
+ $os['totalPages'] = 1;
901
+ }
902
+ }
903
+ } else {
904
+ if ( $error = @$xml->Items->Request->Errors->Error ) {
905
+ $message = __( 'Amazon Product Advertising API Error', $this->text_domain );
906
+ $error_code = (string) @$error->Code;
907
+ $error_message = (string) @$error->Message;
908
+ } elseif ( $error = @$xml->Error ) {
909
+ $message = __( 'Amazon Product Advertising API Error', $this->text_domain );
910
+ $error_code = (string) @$error->Code;
911
+ $error_message = (string) @$error->Message;
912
+ } else {
913
+ $message = __( 'Cannot Parse Amazon Product Advertising API Response' );
914
+ $error_body = (string) $body;
915
+ }
916
+ }
917
+ } else {
918
+ $message = __( 'Invalid Response', $this->text_domain );
919
+ }
920
+ return compact( 'success', 'operation', 'os', 'items', 'resultMap', 'message', 'error_code' , 'error_message', 'error_body' );
921
+ }
922
+
923
+ static function to_array( $element ) {
924
+ $orgElement = $element;
925
+ if ( is_object( $element ) && 'SimpleXMLElement' == get_class( $element ) ) {
926
+ $element = get_object_vars( $element );
927
+ }
928
+ if ( is_array( $element ) ) {
929
+ $result = array();
930
+ if ( count( $element ) <= 0 ) {
931
+ return trim( strval( $orgElement ) );
932
+ }
933
+ foreach ( $element as $key => $value ) {
934
+ if ( is_string( $key ) && '@attributes' == $key ) {
935
+ continue;
936
+ }
937
+ $result[ $key ] = self::to_array( $value );
938
+ }
939
+ return $result;
940
+ } else {
941
+ return trim( strval( $element ) );
942
+ }
943
+ }
944
+
945
+ static function image_element( $element ) {
946
+ if ( $element ) {
947
+ $src = trim( (string) @$element->URL );
948
+ $width = (int) @$element->Width;
949
+ $height = (int) @$element->Height;
950
+ return compact( 'src', 'width', 'height' );
951
+ }
952
+ return null;
953
+ }
954
+
955
+ static function urlencode_rfc3986( $string ) {
956
+ return str_replace( '%7E', '~', rawurlencode( $string ) );
957
+ }
958
+ }
959
+
960
+ function media_upload_type_amazonjs() {
961
+ include dirname( __FILE__ ) . '/media-upload-type-amazonjs.php';
962
+ }
963
+
964
+ function media_upload_type_amazonjs_keyword() {
965
+ include dirname( __FILE__ ) . '/media-upload-type-amazonjs.php';
966
+ }
967
+
968
+ function media_upload_type_amazonjs_id() {
969
+ include dirname( __FILE__ ) . '/media-upload-type-amazonjs.php';
970
+ }
971
+
972
+ function amazonjs_init() {
973
+ global $amazonjs;
974
+ $amazonjs = new Amazonjs();
975
+ $amazonjs->init();
976
+ }
977
+
978
+ function amazonjs_uninstall() {
979
+ $amazonjs = new Amazonjs();
980
+ $amazonjs->clean();
981
+ unset($amazonjs);
982
+ }
983
+
984
+ add_action( 'init', 'amazonjs_init' );
985
+ if ( function_exists( 'register_uninstall_hook' ) ) {
986
+ register_uninstall_hook( __FILE__, 'amazonjs_uninstall' );
987
+ }
components/js/jquery-tmpl/jquery.tmpl.min.js ADDED
@@ -0,0 +1,10 @@
1
+ /*
2
+ * jQuery Templates Plugin 1.0.0pre
3
+ * http://github.com/jquery/jquery-tmpl
4
+ * Requires jQuery 1.4.2
5
+ *
6
+ * Copyright 2011, Software Freedom Conservancy, Inc.
7
+ * Dual licensed under the MIT or GPL Version 2 licenses.
8
+ * http://jquery.org/license
9
+ */
10
+ (function(a){var r=a.fn.domManip,d="_tmplitem",q=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,b={},f={},e,p={key:0,data:{}},i=0,c=0,l=[];function g(g,d,h,e){var c={data:e||(e===0||e===false)?e:d?d.data:{},_wrap:d?d._wrap:null,tmpl:null,parent:d||null,nodes:[],calls:u,nest:w,wrap:x,html:v,update:t};g&&a.extend(c,g,{nodes:[],parent:d});if(h){c.tmpl=h;c._ctnt=c._ctnt||c.tmpl(a,c);c.key=++i;(l.length?f:b)[i]=c}return c}a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,d){a.fn[f]=function(n){var g=[],i=a(n),k,h,m,l,j=this.length===1&&this[0].parentNode;e=b||{};if(j&&j.nodeType===11&&j.childNodes.length===1&&i.length===1){i[d](this[0]);g=this}else{for(h=0,m=i.length;h<m;h++){c=h;k=(h>0?this.clone(true):this).get();a(i[h])[d](k);g=g.concat(k)}c=0;g=this.pushStack(g,f,i.selector)}l=e;e=null;a.tmpl.complete(l);return g}});a.fn.extend({tmpl:function(d,c,b){return a.tmpl(this[0],d,c,b)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(d,m,k){if(d[0]&&a.isArray(d[0])){var g=a.makeArray(arguments),h=d[0],j=h.length,i=0,f;while(i<j&&!(f=a.data(h[i++],"tmplItem")));if(f&&c)g[2]=function(b){a.tmpl.afterManip(this,b,k)};r.apply(this,g)}else r.apply(this,arguments);c=0;!e&&a.tmpl.complete(b);return this}});a.extend({tmpl:function(d,h,e,c){var i,k=!c;if(k){c=p;d=a.template[d]||a.template(null,d);f={}}else if(!d){d=c.tmpl;b[c.key]=c;c.nodes=[];c.wrapped&&n(c,c.wrapped);return a(j(c,null,c.tmpl(a,c)))}if(!d)return[];if(typeof h==="function")h=h.call(c||{});e&&e.wrapped&&n(e,e.wrapped);i=a.isArray(h)?a.map(h,function(a){return a?g(e,c,d,a):null}):[g(e,c,d,h)];return k?a(j(c,null,i)):i},tmplItem:function(b){var c;if(b instanceof a)b=b[0];while(b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode));return c||p},template:function(c,b){if(b){if(typeof b==="string")b=o(b);else if(b instanceof a)b=b[0]||{};if(b.nodeType)b=a.data(b,"tmpl")||a.data(b,"tmpl",o(b.innerHTML));return typeof c==="string"?(a.template[c]=b):b}return c?typeof c!=="string"?a.template(null,c):a.template[c]||a.template(null,q.test(c)?c:a(c)):null},encode:function(a){return(""+a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function j(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:j(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*#x2F;,function(f,c,e,d){b=a(e).get();m(b);if(c)b=k(c).concat(b);if(d)b=b.concat(k(d))});return b?b:k(c)}function k(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,k,g,b,c,d){var j=a.tmpl.tag[k],i,e,f;if(!j)throw"Unknown template tag: "+k;i=j._default||[];if(c&&!/\w#x2F;.test(b)){b+=c;c=""}if(b){b=h(b);d=d?","+h(d)+")":c?")":"";e=c?b.indexOf(".")>-1?b+h(c):"("+b+").call($item"+d:b;f=c?e:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else f=e=i.$1||"null";g=h(g);return"');"+j[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined' && ("+b+")!=null":"true").split("$1a").join(f).split("$1").join(e).split("$2").join(g||i.$2||"")+"__.push('"})+"');}return __;")}function n(c,b){c._wrap=j(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function h(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,h;for(e=0,p=o.length;e<p;e++){if((k=o[e]).nodeType!==1)continue;j=k.getElementsByTagName("*");for(h=j.length-1;h>=0;h--)m(j[h]);m(k)}function m(j){var p,h=j,k,e,m;if(m=j.getAttribute(d)){while(h.parentNode&&(h=h.parentNode).nodeType===1&&!(p=h.getAttribute(d)));if(p!==m){h=h.parentNode?h.nodeType===11?0:h.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[h]||f[h]);e.key=++i;b[i]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;h=a.data(j.parentNode,"tmplItem");h=h?h.key:0}if(e){k=e;while(k&&k.key!=h){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery);
css/amazonjs-force.css ADDED
@@ -0,0 +1,128 @@
1
+ .amazonjs_item {
2
+ font-size: 14px;
3
+ margin: .5em 0 1em 0;
4
+ padding: 25px 10px 25px 10px;
5
+ border: 1px solid #ddd;
6
+ position: relative;
7
+ display: block;
8
+ background: white url(../images/amazonjs.png) no-repeat right bottom;
9
+ color: #333;
10
+ }
11
+ .amazonjs_item a {
12
+ color: #e47911;
13
+ text-decoration: none;
14
+ }
15
+ .amazonjs_item a:hover {
16
+ color: #996633;
17
+ }
18
+ .amazonjs_item * {
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ }
23
+ .amazonjs_item .amazonjs_indicator {
24
+ margin: 0 10px;
25
+ clear: both;
26
+ }
27
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_img {
28
+ float: left;
29
+ display: block;
30
+ width: 32px;
31
+ height: 32px;
32
+ background: transparent url(../images/ajax-loader.gif) no-repeat center;
33
+ }
34
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_title {
35
+ display: block;
36
+ line-height: 32px;
37
+ margin-left: 42px;
38
+ }
39
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_footer {
40
+ clear: both;
41
+ }
42
+ .amazonjs_item .amazonjs_image {
43
+ display: block;
44
+ float: left;
45
+ margin-right: 10px;
46
+ }
47
+ .amazonjs_item .amazonjs_info {
48
+ display: block;
49
+ }
50
+ .amazonjs_item .amazonjs_info h4 {
51
+ margin: 0 0 5px !important;
52
+ padding: 0 !important;
53
+ font-size: 1.2em !important;
54
+ font-weight: bold !important;
55
+ clear: none !important;
56
+ border: none !important;
57
+ }
58
+ .amazonjs_item .amazonjs_info ul {
59
+ list-style: none !important;
60
+ margin: 0 !important;
61
+ padding: 0 !important;
62
+ }
63
+ .amazonjs_item .amazonjs_info ul li {
64
+ list-style: none !important;
65
+ line-height: 1.5em !important;
66
+ font-size: 1em !important;
67
+ margin: 0 !important;
68
+ padding: 0 !important;
69
+ }
70
+ .amazonjs_item .amazonjs_info ul li b {
71
+ margin-right: .5em;
72
+ color: #555;
73
+ font-weight: normal;
74
+ }
75
+ .amazonjs_item .amazonjs_info .amazonjs_price {
76
+ color: #900;
77
+ }
78
+ .amazonjs_item .amazonjs_info .amazonjs_price span {
79
+ color: #666;
80
+ margin-left: .5em;
81
+ }
82
+ .amazonjs_item .amazonjs_info .amazonjs_listprice {
83
+ text-decoration: line-through;
84
+ }
85
+ .amazonjs_item .amazonjs_review {
86
+ padding: 0;
87
+ font-size: 0.7em;
88
+ position: absolute;
89
+ right: 34px;
90
+ bottom: 4px;
91
+ }
92
+ #preview .amazonjs_item .amazonjs_review {
93
+ display: none;
94
+ }
95
+ .amazonjs_item .amazonjs_footer {
96
+ clear: both;
97
+ }
98
+
99
+ .amazonjs_book .amazonjs_info ul,
100
+ .amazonjs_music .amazonjs_info ul {
101
+ margin-top: 0.5em;
102
+ }
103
+
104
+ .amazonjs_book .amazonjs_info ul li,
105
+ .amazonjs_music .amazonjs_info ul li {
106
+ line-height: 1.6em;
107
+ }
108
+
109
+ @media (max-width: 720px) {
110
+ .amazonjs_item .amazonjs_info {
111
+ margin-bottom: 10px;
112
+ }
113
+ }
114
+ @media (max-width: 480px) {
115
+ .amazonjs_item img {
116
+ width: 60px;
117
+ max-width: 60px;
118
+ }
119
+ .amazonjs_item .amazonjs_info {
120
+ margin-left: 70px !important;
121
+ }
122
+ .amazonjs_item .amazonjs_info h4 a {
123
+ font-size: 0.9em;
124
+ }
125
+ .amazonjs_item .amazonjs_info ul li {
126
+ font-size: 0.9em;
127
+ }
128
+ }
css/amazonjs-options.css ADDED
@@ -0,0 +1,6 @@
1
+ .wrap-amazonjs > h2:before {
2
+ font-family: "dashicons";
3
+ content: "\f108";
4
+ font-size: 1.2em;
5
+ vertical-align: -20%;
6
+ }
css/amazonjs.css ADDED
@@ -0,0 +1,128 @@
1
+ .amazonjs_item {
2
+ font-size: 14px;
3
+ margin: .5em 0 1em 0;
4
+ padding: 25px 10px 25px 10px;
5
+ border: 1px solid #ddd;
6
+ position: relative;
7
+ display: block;
8
+ background: white url(../images/amazonjs.png) no-repeat right bottom;
9
+ color: #333;
10
+ }
11
+ .amazonjs_item a {
12
+ color: #e47911;
13
+ text-decoration: none;
14
+ }
15
+ .amazonjs_item a:hover {
16
+ color: #996633;
17
+ }
18
+ .amazonjs_item * {
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ }
23
+ .amazonjs_item .amazonjs_indicator {
24
+ margin: 0 10px;
25
+ clear: both;
26
+ }
27
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_img {
28
+ float: left;
29
+ display: block;
30
+ width: 32px;
31
+ height: 32px;
32
+ background: transparent url(../images/ajax-loader.gif) no-repeat center;
33
+ }
34
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_title {
35
+ display: block;
36
+ line-height: 32px;
37
+ margin-left: 42px;
38
+ }
39
+ .amazonjs_item .amazonjs_indicator .amazonjs_indicator_footer {
40
+ clear: both;
41
+ }
42
+ .amazonjs_item .amazonjs_image {
43
+ display: block;
44
+ float: left;
45
+ margin-right: 10px;
46
+ }
47
+ .amazonjs_item .amazonjs_info {
48
+ display: block;
49
+ }
50
+ .amazonjs_item .amazonjs_info h4 {
51
+ margin: 0 0 5px;
52
+ padding: 0;
53
+ font-size: 1.2em;
54
+ font-weight: bold;
55
+ clear: none;
56
+ border: none;
57
+ }
58
+ .amazonjs_item .amazonjs_info ul {
59
+ list-style: none;
60
+ margin: 0;
61
+ padding: 0;
62
+ }
63
+ .amazonjs_item .amazonjs_info ul li {
64
+ list-style: none;
65
+ line-height: 1.5em;
66
+ font-size: 1em;
67
+ margin: 0;
68
+ padding: 0;
69
+ }
70
+ .amazonjs_item .amazonjs_info ul li b {
71
+ margin-right: .5em;
72
+ color: #555;
73
+ font-weight: normal;
74
+ }
75
+ .amazonjs_item .amazonjs_info .amazonjs_price {
76
+ color: #900;
77
+ }
78
+ .amazonjs_item .amazonjs_info .amazonjs_price span {
79
+ color: #666;
80
+ margin-left: .5em;
81
+ }
82
+ .amazonjs_item .amazonjs_info .amazonjs_listprice {