YITH WooCommerce Ajax Search - Version 1.0.0

Version Description

  • Initial release

=

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

README.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === YITH WooCommerce Ajax Search ===
2
+
3
+ Contributors: yithemes
4
+ Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop
5
+ Requires at least: 3.5.1
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.0.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ YITH WooCommerce Ajax Search allows your users to search products in real time.
12
+
13
+ == Description ==
14
+
15
+ = Improve the user experience, improve your sales =
16
+
17
+ YITH WooCommerce Ajax Search is a really easy-to-use plugin. You just need to install it and it's ready to work.
18
+ It creates a simple search box in which, when you start to type your keyword, the plugin will suggest you the products that matching your searching criteria.
19
+ It is very useful to provide assistance to your users while they are trying to search any products in your website.
20
+
21
+ Did you ever forget the name of a product? Just start to write your keyphrase. A list with useful suggestion will be shown to you, and the more you write, the more accurate it will be. At that point, you'll only need to choose what you need.
22
+
23
+ It works just like Google Suggest, but on your website, using your database.
24
+
25
+ Working demo is available here:
26
+
27
+ **[LIVE DEMO](http://demo.yithemes.com/sistina/)**
28
+
29
+
30
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_search/).
31
+
32
+
33
+ = Installation =
34
+
35
+ Once you have installed the plugin, you just need to activate the plugin in order to enable it.
36
+
37
+ = Configuration =
38
+
39
+ YITH WooCommerce Ajax Search will add a new tab called "Ajax Search" below the Woocommerce -> Settings menu. Here you are able to configure all the plugin settings.
40
+
41
+ = Developer =
42
+
43
+ Are you a developer? Want to customize the templates or the style of the plugin? Read on the [documentation](http://yithemes.com/docs-plugins/yith_ajax_search/) and discover how to do that.
44
+
45
+ = Support =
46
+
47
+ Hi there, we have good news here: all our plugins are released for free. Wow!
48
+ Already knew it, right?! Great, but maybe you do not know that: if you're looking for how to install the plugins or how to use them within your Wordpress installations, which is the right way to ask support?
49
+ That's the way:
50
+
51
+ * Register on http://yithemes.com
52
+ * Go to Support > Get Support
53
+
54
+ Here we provide support, not on wordpress.org were, usually we do not read topics. It's better to follow us or write on our forum!
55
+
56
+ == Installation ==
57
+
58
+ 1. Unzip the downloaded zip file.
59
+ 2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
60
+ 3. Activate `YITH WooCommerce Ajax Search` from Plugins page
61
+
62
+ == Frequently Asked Questions ==
63
+
64
+ = How can I change the minimum number of characters? =
65
+ In WooCommerce->Settings->Ajax Search page, you can choose the minumum size of the search before to trigger autosuggest.
66
+
67
+
68
+ == Screenshots ==
69
+
70
+ 1. The plugin at work displaying the ajax search results
71
+ 2. The Ajax Search settings page
72
+
73
+ == Changelog ==
74
+
75
+ = 1.0.0 =
76
+
77
+ * Initial release
78
+
79
+ == Suggestions ==
80
+
81
+ If you have suggestions about how to improve YITH WooCommerce Zoom Magnifier, you can [write us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle them into YITH Zoom WooCommerce Magnifier.
82
+
83
+ == Translators ==
84
+
85
+ = Available Languages =
86
+ * English (Default)
87
+ * Italiano
88
+
89
+ If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
90
+ [use](http://yithemes.com/contact/ "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Zoom Magnfier Languages.
91
+
92
+ == Documentation ==
93
+
94
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_search/).
95
+
96
+ == Upgrade notice ==
97
+
98
+ = 1.0.0 =
99
+
100
+ Initial release
assets/css/admin.css ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Admin style
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Search
6
+ * @version 1.0.0
7
+ */
8
+
9
+ .yith_woocommerce_slider {
10
+ width: 300px;
11
+ float: left
12
+ }
13
+ .yith_woocommerce_slider_value {
14
+ margin-top: -5px;
15
+ margin-left: 10px;
16
+ width: 50px;
17
+ float: left;
18
+ text-align: center;
19
+ font-weight: bold;
20
+ }
21
+
22
+ .yith_banner {
23
+ margin-top: 10px;
24
+ }
assets/css/yith_wcas_ajax_search.css ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Frontend style
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Search
6
+ * @version 1.0.0
7
+ */
8
+
9
+ /* search autocomplete */
10
+ .autocomplete-suggestions {
11
+ padding-top: 10px;
12
+ padding-bottom: 10px;
13
+ background: #fff;
14
+ border: 1px solid #ccc;
15
+
16
+ -moz-border-radius: 3px;
17
+ -webkit-border-radius: 3px;
18
+ border-radius: 3px;
19
+
20
+ -moz-box-sizing: border-box;
21
+ box-sizing: border-box;
22
+ }
23
+ .autocomplete-suggestion {
24
+ background: #fff;
25
+ padding-left: 15px;
26
+ cursor: pointer;
27
+ text-align: left;
28
+ line-height: 25px;
29
+ font-size: 12px;
30
+ }
31
+
32
+ .autocomplete-suggestion:hover {
33
+ background-color: #efefef;
34
+ }
assets/js/devbridge-jquery-autocomplete.js ADDED
@@ -0,0 +1,735 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Ajax Autocomplete for jQuery, version 1.2.7
3
+ * (c) 2013 Tomas Kirda
4
+ *
5
+ * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
6
+ * For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
7
+ *
8
+ */
9
+
10
+ /*jslint browser: true, white: true, plusplus: true */
11
+ /*global define, window, document, jQuery */
12
+
13
+ // Expose plugin as an AMD module if AMD loader is present:
14
+ (function (factory) {
15
+ 'use strict';
16
+ if (typeof define === 'function' && define.amd) {
17
+ // AMD. Register as an anonymous module.
18
+ define(['jquery'], factory);
19
+ } else {
20
+ // Browser globals
21
+ factory(jQuery);
22
+ }
23
+ }(function ($) {
24
+ 'use strict';
25
+
26
+ var
27
+ utils = (function () {
28
+ return {
29
+ escapeRegExChars: function (value) {
30
+ return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
31
+ },
32
+ createNode: function (html) {
33
+ var div = document.createElement('div');
34
+ div.innerHTML = html;
35
+ return div.firstChild;
36
+ }
37
+ };
38
+ }()),
39
+
40
+ keys = {
41
+ ESC: 27,
42
+ TAB: 9,
43
+ RETURN: 13,
44
+ LEFT: 37,
45
+ UP: 38,
46
+ RIGHT: 39,
47
+ DOWN: 40
48
+ };
49
+
50
+ function Autocomplete(el, options) {
51
+ var noop = function () { },
52
+ that = this,
53
+ defaults = {
54
+ autoSelectFirst: false,
55
+ appendTo: 'body',
56
+ serviceUrl: null,
57
+ lookup: null,
58
+ onSelect: null,
59
+ width: 'auto',
60
+ minChars: 1,
61
+ maxHeight: 300,
62
+ deferRequestBy: 0,
63
+ params: {},
64
+ formatResult: Autocomplete.formatResult,
65
+ delimiter: null,
66
+ zIndex: 9999,
67
+ type: 'GET',
68
+ noCache: false,
69
+ onSearchStart: noop,
70
+ onSearchComplete: noop,
71
+ containerClass: 'autocomplete-suggestions',
72
+ tabDisabled: false,
73
+ dataType: 'text',
74
+ currentRequest: null,
75
+ lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
76
+ return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
77
+ },
78
+ paramName: 'query',
79
+ transformResult: function (response) {
80
+ return typeof response === 'string' ? $.parseJSON(response) : response;
81
+ }
82
+ };
83
+
84
+ // Shared variables:
85
+ that.element = el;
86
+ that.el = $(el);
87
+ that.suggestions = [];
88
+ that.badQueries = [];
89
+ that.selectedIndex = -1;
90
+ that.currentValue = that.element.value;
91
+ that.intervalId = 0;
92
+ that.cachedResponse = [];
93
+ that.onChangeInterval = null;
94
+ that.onChange = null;
95
+ that.isLocal = false;
96
+ that.suggestionsContainer = null;
97
+ that.options = $.extend({}, defaults, options);
98
+ that.classes = {
99
+ selected: 'autocomplete-selected',
100
+ suggestion: 'autocomplete-suggestion'
101
+ };
102
+ that.hint = null;
103
+ that.hintValue = '';
104
+ that.selection = null;
105
+
106
+ // Initialize and set options:
107
+ that.initialize();
108
+ that.setOptions(options);
109
+ }
110
+
111
+ Autocomplete.utils = utils;
112
+
113
+ $.Autocomplete = Autocomplete;
114
+
115
+ Autocomplete.formatResult = function (suggestion, currentValue) {
116
+ var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
117
+
118
+ return suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
119
+ };
120
+
121
+ Autocomplete.prototype = {
122
+
123
+ killerFn: null,
124
+
125
+ initialize: function () {
126
+ var that = this,
127
+ suggestionSelector = '.' + that.classes.suggestion,
128
+ selected = that.classes.selected,
129
+ options = that.options,
130
+ container;
131
+
132
+ // Remove autocomplete attribute to prevent native suggestions:
133
+ that.element.setAttribute('autocomplete', 'off');
134
+
135
+ that.killerFn = function (e) {
136
+ if ($(e.target).closest('.' + that.options.containerClass).length === 0) {
137
+ that.killSuggestions();
138
+ that.disableKillerFn();
139
+ }
140
+ };
141
+
142
+ that.suggestionsContainer = Autocomplete.utils.createNode('<div class="' + options.containerClass + '" style="position: absolute; display: none;"></div>');
143
+
144
+ container = $(that.suggestionsContainer);
145
+
146
+ container.appendTo(options.appendTo);
147
+
148
+ // Only set width if it was provided:
149
+ if (options.width !== 'auto') {
150
+ container.width(options.width);
151
+ }
152
+
153
+ // Listen for mouse over event on suggestions list:
154
+ container.on('mouseover.autocomplete', suggestionSelector, function () {
155
+ that.activate($(this).data('index'));
156
+ });
157
+
158
+ // Deselect active element when mouse leaves suggestions container:
159
+ container.on('mouseout.autocomplete', function () {
160
+ that.selectedIndex = -1;
161
+ container.children('.' + selected).removeClass(selected);
162
+ });
163
+
164
+ // Listen for click event on suggestions list:
165
+ container.on('click.autocomplete', suggestionSelector, function () {
166
+ that.select($(this).data('index'));
167
+ });
168
+
169
+ that.fixPosition();
170
+
171
+ that.fixPositionCapture = function () {
172
+ if (that.visible) {
173
+ that.fixPosition();
174
+ }
175
+ };
176
+
177
+ $(window).on('resize', that.fixPositionCapture);
178
+
179
+ that.el.on('keydown.autocomplete', function (e) { that.onKeyPress(e); });
180
+ that.el.on('keyup.autocomplete', function (e) { that.onKeyUp(e); });
181
+ that.el.on('blur.autocomplete', function () { that.onBlur(); });
182
+ that.el.on('focus.autocomplete', function () { that.fixPosition(); });
183
+ that.el.on('change.autocomplete', function (e) { that.onKeyUp(e); });
184
+ },
185
+
186
+ onBlur: function () {
187
+ this.enableKillerFn();
188
+ },
189
+
190
+ setOptions: function (suppliedOptions) {
191
+ var that = this,
192
+ options = that.options;
193
+
194
+ $.extend(options, suppliedOptions);
195
+
196
+ that.isLocal = $.isArray(options.lookup);
197
+
198
+ if (that.isLocal) {
199
+ options.lookup = that.verifySuggestionsFormat(options.lookup);
200
+ }
201
+
202
+ // Adjust height, width and z-index:
203
+ $(that.suggestionsContainer).css({
204
+ 'max-height': options.maxHeight + 'px',
205
+ 'width': options.width + 'px',
206
+ 'z-index': options.zIndex
207
+ });
208
+ },
209
+
210
+ clearCache: function () {
211
+ this.cachedResponse = [];
212
+ this.badQueries = [];
213
+ },
214
+
215
+ clear: function () {
216
+ this.clearCache();
217
+ this.currentValue = '';
218
+ this.suggestions = [];
219
+ },
220
+
221
+ disable: function () {
222
+ this.disabled = true;
223
+ },
224
+
225
+ enable: function () {
226
+ this.disabled = false;
227
+ },
228
+
229
+ fixPosition: function () {
230
+ var that = this,
231
+ offset;
232
+
233
+ // Don't adjsut position if custom container has been specified:
234
+ if (that.options.appendTo !== 'body') {
235
+ return;
236
+ }
237
+
238
+ offset = that.el.offset();
239
+
240
+ $(that.suggestionsContainer).css({
241
+ top: (offset.top + that.el.outerHeight()) + 'px',
242
+ left: offset.left + 'px'
243
+ });
244
+ },
245
+
246
+ enableKillerFn: function () {
247
+ var that = this;
248
+ $(document).on('click.autocomplete', that.killerFn);
249
+ },
250
+
251
+ disableKillerFn: function () {
252
+ var that = this;
253
+ $(document).off('click.autocomplete', that.killerFn);
254
+ },
255
+
256
+ killSuggestions: function () {
257
+ var that = this;
258
+ that.stopKillSuggestions();
259
+ that.intervalId = window.setInterval(function () {
260
+ that.hide();
261
+ that.stopKillSuggestions();
262
+ }, 300);
263
+ },
264
+
265
+ stopKillSuggestions: function () {
266
+ window.clearInterval(this.intervalId);
267
+ },
268
+
269
+ isCursorAtEnd: function () {
270
+ var that = this,
271
+ valLength = that.el.val().length,
272
+ selectionStart = that.element.selectionStart,
273
+ range;
274
+
275
+ if (typeof selectionStart === 'number') {
276
+ return selectionStart === valLength;
277
+ }
278
+ if (document.selection) {
279
+ range = document.selection.createRange();
280
+ range.moveStart('character', -valLength);
281
+ return valLength === range.text.length;
282
+ }
283
+ return true;
284
+ },
285
+
286
+ onKeyPress: function (e) {
287
+ var that = this;
288
+
289
+ // If suggestions are hidden and user presses arrow down, display suggestions:
290
+ if (!that.disabled && !that.visible && e.which === keys.DOWN && that.currentValue) {
291
+ that.suggest();
292
+ return;
293
+ }
294
+
295
+ if (that.disabled || !that.visible) {
296
+ return;
297
+ }
298
+
299
+ switch (e.which) {
300
+ case keys.ESC:
301
+ that.el.val(that.currentValue);
302
+ that.hide();
303
+ break;
304
+ case keys.RIGHT:
305
+ if (that.hint && that.options.onHint && that.isCursorAtEnd()) {
306
+ that.selectHint();
307
+ break;
308
+ }
309
+ return;
310
+ case keys.TAB:
311
+ if (that.hint && that.options.onHint) {
312
+ that.selectHint();
313
+ return;
314
+ }
315
+ // Fall through to RETURN
316
+ case keys.RETURN:
317
+ if (that.selectedIndex === -1) {
318
+ that.hide();
319
+ return;
320
+ }
321
+ that.select(that.selectedIndex);
322
+ if (e.which === keys.TAB && that.options.tabDisabled === false) {
323
+ return;
324
+ }
325
+ break;
326
+ case keys.UP:
327
+ that.moveUp();
328
+ break;
329
+ case keys.DOWN:
330
+ that.moveDown();
331
+ break;
332
+ default:
333
+ return;
334
+ }
335
+
336
+ // Cancel event if function did not return:
337
+ e.stopImmediatePropagation();
338
+ e.preventDefault();
339
+ },
340
+
341
+ onKeyUp: function (e) {
342
+ var that = this;
343
+
344
+ if (that.disabled) {
345
+ return;
346
+ }
347
+
348
+ switch (e.which) {
349
+ case keys.UP:
350
+ case keys.DOWN:
351
+ return;
352
+ }
353
+
354
+ clearInterval(that.onChangeInterval);
355
+
356
+ if (that.currentValue !== that.el.val()) {
357
+ that.findBestHint();
358
+ if (that.options.deferRequestBy > 0) {
359
+ // Defer lookup in case when value changes very quickly:
360
+ that.onChangeInterval = setInterval(function () {
361
+ that.onValueChange();
362
+ }, that.options.deferRequestBy);
363
+ } else {
364
+ that.onValueChange();
365
+ }
366
+ }
367
+ },
368
+
369
+ onValueChange: function () {
370
+ var that = this,
371
+ q;
372
+
373
+ if (that.selection) {
374
+ that.selection = null;
375
+ (that.options.onInvalidateSelection || $.noop)();
376
+ }
377
+
378
+ clearInterval(that.onChangeInterval);
379
+ that.currentValue = that.el.val();
380
+
381
+ q = that.getQuery(that.currentValue);
382
+ that.selectedIndex = -1;
383
+
384
+ if (q.length < that.options.minChars) {
385
+ that.hide();
386
+ } else {
387
+ that.getSuggestions(q);
388
+ }
389
+ },
390
+
391
+ getQuery: function (value) {
392
+ var delimiter = this.options.delimiter,
393
+ parts;
394
+
395
+ if (!delimiter) {
396
+ return $.trim(value);
397
+ }
398
+ parts = value.split(delimiter);
399
+ return $.trim(parts[parts.length - 1]);
400
+ },
401
+
402
+ getSuggestionsLocal: function (query) {
403
+ var that = this,
404
+ queryLowerCase = query.toLowerCase(),
405
+ filter = that.options.lookupFilter;
406
+
407
+ return {
408
+ suggestions: $.grep(that.options.lookup, function (suggestion) {
409
+ return filter(suggestion, query, queryLowerCase);
410
+ })
411
+ };
412
+ },
413
+
414
+ getSuggestions: function (q) {
415
+ var response,
416
+ that = this,
417
+ options = that.options,
418
+ serviceUrl = options.serviceUrl;
419
+
420
+ response = that.isLocal ? that.getSuggestionsLocal(q) : that.cachedResponse[q];
421
+
422
+ if (response && $.isArray(response.suggestions)) {
423
+ that.suggestions = response.suggestions;
424
+ that.suggest();
425
+ } else if (!that.isBadQuery(q)) {
426
+ options.params[options.paramName] = q;
427
+ if (options.onSearchStart.call(that.element, options.params) === false) {
428
+ return;
429
+ }
430
+ if ($.isFunction(options.serviceUrl)) {
431
+ serviceUrl = options.serviceUrl.call(that.element, q);
432
+ }
433
+ if(this.currentRequest != null) {
434
+ this.currentRequest.abort();
435
+ }
436
+ this.currentRequest = $.ajax({
437
+ url: serviceUrl,
438
+ data: options.ignoreParams ? null : options.params,
439
+ type: options.type,
440
+ dataType: options.dataType
441
+ }).done(function (data) {
442
+ that.processResponse(data, q);
443
+ options.onSearchComplete.call(that.element, q);
444
+ });
445
+ }
446
+ },
447
+
448
+ isBadQuery: function (q) {
449
+ var badQueries = this.badQueries,
450
+ i = badQueries.length;
451
+
452
+ while (i--) {
453
+ if (q.indexOf(badQueries[i]) === 0) {
454
+ return true;
455
+ }
456
+ }
457
+
458
+ return false;
459
+ },
460
+
461
+ hide: function () {
462
+ var that = this;
463
+ that.visible = false;
464
+ that.selectedIndex = -1;
465
+ $(that.suggestionsContainer).hide();
466
+ that.signalHint(null);
467
+ },
468
+
469
+ suggest: function () {
470
+ if (this.suggestions.length === 0) {
471
+ this.hide();
472
+ return;
473
+ }
474
+
475
+ var that = this,
476
+ formatResult = that.options.formatResult,
477
+ value = that.getQuery(that.currentValue),
478
+ className = that.classes.suggestion,
479
+ classSelected = that.classes.selected,
480
+ container = $(that.suggestionsContainer),
481
+ html = '',
482
+ width;
483
+
484
+ // Build suggestions inner HTML:
485
+ $.each(that.suggestions, function (i, suggestion) {
486
+ html += '<div class="' + className + '" data-index="' + i + '">' + formatResult(suggestion, value) + '</div>';
487
+ });
488
+
489
+ // If width is auto, adjust width before displaying suggestions,
490
+ // because if instance was created before input had width, it will be zero.
491
+ // Also it adjusts if input width has changed.
492
+ // -2px to account for suggestions border.
493
+ if (that.options.width === 'auto') {
494
+ width = that.el.outerWidth() - 2;
495
+ container.width(width > 0 ? width : 300);
496
+ }
497
+
498
+ container.html(html).show();
499
+ that.visible = true;
500
+
501
+ // Select first value by default:
502
+ if (that.options.autoSelectFirst) {
503
+ that.selectedIndex = 0;
504
+ container.children().first().addClass(classSelected);
505
+ }
506
+
507
+ that.findBestHint();
508
+ },
509
+
510
+ findBestHint: function () {
511
+ var that = this,
512
+ value = that.el.val().toLowerCase(),
513
+ bestMatch = null;
514
+
515
+ if (!value) {
516
+ return;
517
+ }
518
+
519
+ $.each(that.suggestions, function (i, suggestion) {
520
+ var foundMatch = suggestion.value.toLowerCase().indexOf(value) === 0;
521
+ if (foundMatch) {
522
+ bestMatch = suggestion;
523
+ }
524
+ return !foundMatch;
525
+ });
526
+
527
+ that.signalHint(bestMatch);
528
+ },
529
+
530
+ signalHint: function (suggestion) {
531
+ var hintValue = '',
532
+ that = this;
533
+ if (suggestion) {
534
+ hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
535
+ }
536
+ if (that.hintValue !== hintValue) {
537
+ that.hintValue = hintValue;
538
+ that.hint = suggestion;
539
+ (this.options.onHint || $.noop)(hintValue);
540
+ }
541
+ },
542
+
543
+ verifySuggestionsFormat: function (suggestions) {
544
+ // If suggestions is string array, convert them to supported format:
545
+ if (suggestions.length && typeof suggestions[0] === 'string') {
546
+ return $.map(suggestions, function (value) {
547
+ return { value: value, data: null };
548
+ });
549
+ }
550
+
551
+ return suggestions;
552
+ },
553
+
554
+ processResponse: function (response, originalQuery) {
555
+ var that = this,
556
+ options = that.options,
557
+ result = options.transformResult(response, originalQuery);
558
+
559
+ result.suggestions = that.verifySuggestionsFormat(result.suggestions);
560
+
561
+ // Cache results if cache is not disabled:
562
+ if (!options.noCache) {
563
+ that.cachedResponse[result[options.paramName]] = result;
564
+ if (result.suggestions.length === 0) {
565
+ that.badQueries.push(result[options.paramName]);
566
+ }
567
+ }
568
+
569
+ // Display suggestions only if returned query matches current value:
570
+ if (originalQuery === that.getQuery(that.currentValue)) {
571
+ that.suggestions = result.suggestions;
572
+ that.suggest();
573
+ }
574
+ },
575
+
576
+ activate: function (index) {
577
+ var that = this,
578
+ activeItem,
579
+ selected = that.classes.selected,
580
+ container = $(that.suggestionsContainer),
581
+ children = container.children();
582
+
583
+ container.children('.' + selected).removeClass(selected);
584
+
585
+ that.selectedIndex = index;
586
+
587
+ if (that.selectedIndex !== -1 && children.length > that.selectedIndex) {
588
+ activeItem = children.get(that.selectedIndex);
589
+ $(activeItem).addClass(selected);
590
+ return activeItem;
591
+ }
592
+
593
+ return null;
594
+ },
595
+
596
+ selectHint: function () {
597
+ var that = this,
598
+ i = $.inArray(that.hint, that.suggestions);
599
+
600
+ that.select(i);
601
+ },
602
+
603
+ select: function (i) {
604
+ var that = this;
605
+ that.hide();
606
+ that.onSelect(i);
607
+ },
608
+
609
+ moveUp: function () {
610
+ var that = this;
611
+
612
+ if (that.selectedIndex === -1) {
613
+ return;
614
+ }
615
+
616
+ if (that.selectedIndex === 0) {
617
+ $(that.suggestionsContainer).children().first().removeClass(that.classes.selected);
618
+ that.selectedIndex = -1;
619
+ that.el.val(that.currentValue);
620
+ that.findBestHint();
621
+ return;
622
+ }
623
+
624
+ that.adjustScroll(that.selectedIndex - 1);
625
+ },
626
+
627
+ moveDown: function () {
628
+ var that = this;
629
+
630
+ if (that.selectedIndex === (that.suggestions.length - 1)) {
631
+ return;
632
+ }
633
+
634
+ that.adjustScroll(that.selectedIndex + 1);
635
+ },
636
+
637
+ adjustScroll: function (index) {
638
+ var that = this,
639
+ activeItem = that.activate(index),
640
+ offsetTop,
641
+ upperBound,
642
+ lowerBound,
643
+ heightDelta = 25;
644
+
645
+ if (!activeItem) {
646
+ return;
647
+ }
648
+
649
+ offsetTop = activeItem.offsetTop;
650
+ upperBound = $(that.suggestionsContainer).scrollTop();
651
+ lowerBound = upperBound + that.options.maxHeight - heightDelta;
652
+
653
+ if (offsetTop < upperBound) {
654
+ $(that.suggestionsContainer).scrollTop(offsetTop);
655
+ } else if (offsetTop > lowerBound) {
656
+ $(that.suggestionsContainer).scrollTop(offsetTop - that.options.maxHeight + heightDelta);
657
+ }
658
+
659
+ that.el.val(that.getValue(that.suggestions[index].value));
660
+ that.signalHint(null);
661
+ },
662
+
663
+ onSelect: function (index) {
664
+ var that = this,
665
+ onSelectCallback = that.options.onSelect,
666
+ suggestion = that.suggestions[index];
667
+
668
+ that.currentValue = that.getValue(suggestion.value);
669
+ that.el.val(that.currentValue);
670
+ that.signalHint(null);
671
+ that.suggestions = [];
672
+ that.selection = suggestion;
673
+
674
+ if ($.isFunction(onSelectCallback)) {
675
+ onSelectCallback.call(that.element, suggestion);
676
+ }
677
+ },
678
+
679
+ getValue: function (value) {
680
+ var that = this,
681
+ delimiter = that.options.delimiter,
682
+ currentValue,
683
+ parts;
684
+
685
+ if (!delimiter) {
686
+ return value;
687
+ }
688
+
689
+ currentValue = that.currentValue;
690
+ parts = currentValue.split(delimiter);
691
+
692
+ if (parts.length === 1) {
693
+ return value;
694
+ }
695
+
696
+ return currentValue.substr(0, currentValue.length - parts[parts.length - 1].length) + value;
697
+ },
698
+
699
+ dispose: function () {
700
+ var that = this;
701
+ that.el.off('.autocomplete').removeData('autocomplete');
702
+ that.disableKillerFn();
703
+ $(window).off('resize', that.fixPositionCapture);
704
+ $(that.suggestionsContainer).remove();
705
+ }
706
+ };
707
+
708
+ // Create chainable jQuery plugin:
709
+ $.fn.autocomplete = function (options, args) {
710
+ var dataKey = 'autocomplete';
711
+ // If function invoked without argument return
712
+ // instance of the first matched element:
713
+ if (arguments.length === 0) {
714
+ return this.first().data(dataKey);
715
+ }
716
+
717
+ return this.each(function () {
718
+ var inputElement = $(this),
719
+ instance = inputElement.data(dataKey);
720
+
721
+ if (typeof options === 'string') {
722
+ if (instance && typeof instance[options] === 'function') {
723
+ instance[options](args);
724
+ }
725
+ } else {
726
+ // If instance already exists, destroy it:
727
+ if (instance && instance.dispose) {
728
+ instance.dispose();
729
+ }
730
+ instance = new Autocomplete(this, options);
731
+ inputElement.data(dataKey, instance);
732
+ }
733
+ });
734
+ };
735
+ }));
assets/js/devbridge-jquery-autocomplete.min.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Ajax Autocomplete for jQuery, version 1.2.7
3
+ * (c) 2013 Tomas Kirda
4
+ *
5
+ * Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
6
+ * For details, see the web site: http://www.devbridge.com/projects/autocomplete/jquery/
7
+ *
8
+ */
9
+ (function(e){"function"===typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function g(a,b){var c=function(){},c={autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:g.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:c,onSearchComplete:c,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,lookupFilter:function(a,
10
+ b,c){return-1!==a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(a){return"string"===typeof a?e.parseJSON(a):a}};this.element=a;this.el=e(a);this.suggestions=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.element.value;this.intervalId=0;this.cachedResponse=[];this.onChange=this.onChangeInterval=null;this.isLocal=!1;this.suggestionsContainer=null;this.options=e.extend({},c,b);this.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"};
11
+ this.hint=null;this.hintValue="";this.selection=null;this.initialize();this.setOptions(b)}var k=function(){return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");b.innerHTML=a;return b.firstChild}}}();g.utils=k;e.Autocomplete=g;g.formatResult=function(a,b){var c="("+k.escapeRegExChars(b)+")";return a.value.replace(RegExp(c,"gi"),"<strong>$1</strong>")};g.prototype={killerFn:null,initialize:function(){var a=
12
+ this,b="."+a.classes.suggestion,c=a.classes.selected,d=a.options,f;a.element.setAttribute("autocomplete","off");a.killerFn=function(b){0===e(b.target).closest("."+a.options.containerClass).length&&(a.killSuggestions(),a.disableKillerFn())};a.suggestionsContainer=g.utils.createNode('<div class="'+d.containerClass+'" style="position: absolute; display: none;"></div>');f=e(a.suggestionsContainer);f.appendTo(d.appendTo);"auto"!==d.width&&f.width(d.width);f.on("mouseover.autocomplete",b,function(){a.activate(e(this).data("index"))});
13
+ f.on("mouseout.autocomplete",function(){a.selectedIndex=-1;f.children("."+c).removeClass(c)});f.on("click.autocomplete",b,function(){a.select(e(this).data("index"))});a.fixPosition();a.fixPositionCapture=function(){a.visible&&a.fixPosition()};e(window).on("resize",a.fixPositionCapture);a.el.on("keydown.autocomplete",function(b){a.onKeyPress(b)});a.el.on("keyup.autocomplete",function(b){a.onKeyUp(b)});a.el.on("blur.autocomplete",function(){a.onBlur()});a.el.on("focus.autocomplete",function(){a.fixPosition()});
14
+ a.el.on("change.autocomplete",function(b){a.onKeyUp(b)})},onBlur:function(){this.enableKillerFn()},setOptions:function(a){var b=this.options;e.extend(b,a);if(this.isLocal=e.isArray(b.lookup))b.lookup=this.verifySuggestionsFormat(b.lookup);e(this.suggestionsContainer).css({"max-height":b.maxHeight+"px",width:b.width+"px","z-index":b.zIndex})},clearCache:function(){this.cachedResponse=[];this.badQueries=[]},clear:function(){this.clearCache();this.currentValue="";this.suggestions=[]},disable:function(){this.disabled=
15
+ !0},enable:function(){this.disabled=!1},fixPosition:function(){var a;"body"===this.options.appendTo&&(a=this.el.offset(),e(this.suggestionsContainer).css({top:a.top+this.el.outerHeight()+"px",left:a.left+"px"}))},enableKillerFn:function(){e(document).on("click.autocomplete",this.killerFn)},disableKillerFn:function(){e(document).off("click.autocomplete",this.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions();a.intervalId=window.setInterval(function(){a.hide();a.stopKillSuggestions()},
16
+ 300)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var a=this.el.val().length,b=this.element.selectionStart;return"number"===typeof b?b===a:document.selection?(b=document.selection.createRange(),b.moveStart("character",-a),a===b.text.length):!0},onKeyPress:function(a){if(!this.disabled&&!this.visible&&40===a.which&&this.currentValue)this.suggest();else if(!this.disabled&&this.visible){switch(a.which){case 27:this.el.val(this.currentValue);this.hide();
17
+ break;case 39:if(this.hint&&this.options.onHint&&this.isCursorAtEnd()){this.selectHint();break}return;case 9:if(this.hint&&this.options.onHint){this.selectHint();return}case 13:if(-1===this.selectedIndex){this.hide();return}this.select(this.selectedIndex);if(9===a.which&&!1===this.options.tabDisabled)return;break;case 38:this.moveUp();break;case 40:this.moveDown();break;default:return}a.stopImmediatePropagation();a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case 38:case 40:return}clearInterval(b.onChangeInterval);
18
+ if(b.currentValue!==b.el.val())if(b.findBestHint(),0<b.options.deferRequestBy)b.onChangeInterval=setInterval(function(){b.onValueChange()},b.options.deferRequestBy);else b.onValueChange()}},onValueChange:function(){var a;this.selection&&(this.selection=null,(this.options.onInvalidateSelection||e.noop)());clearInterval(this.onChangeInterval);this.currentValue=this.el.val();a=this.getQuery(this.currentValue);this.selectedIndex=-1;a.length<this.options.minChars?this.hide():this.getSuggestions(a)},getQuery:function(a){var b=
19
+ this.options.delimiter;if(!b)return e.trim(a);a=a.split(b);return e.trim(a[a.length-1])},getSuggestionsLocal:function(a){var b=a.toLowerCase(),c=this.options.lookupFilter;return{suggestions:e.grep(this.options.lookup,function(d){return c(d,a,b)})}},getSuggestions:function(a){var b,c=this,d=c.options,f=d.serviceUrl;(b=c.isLocal?c.getSuggestionsLocal(a):c.cachedResponse[a])&&e.isArray(b.suggestions)?(c.suggestions=b.suggestions,c.suggest()):c.isBadQuery(a)||(d.params[d.paramName]=a,!1!==d.onSearchStart.call(c.element,
20
+ d.params)&&(e.isFunction(d.serviceUrl)&&(f=d.serviceUrl.call(c.element,a)),null!=this.currentRequest&&this.currentRequest.abort(),this.currentRequest=e.ajax({url:f,data:d.ignoreParams?null:d.params,type:d.type,dataType:d.dataType}).done(function(b){c.processResponse(b,a);d.onSearchComplete.call(c.element,a)})))},isBadQuery:function(a){for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){this.visible=!1;this.selectedIndex=-1;e(this.suggestionsContainer).hide();
21
+ this.signalHint(null)},suggest:function(){if(0===this.suggestions.length)this.hide();else{var a=this.options.formatResult,b=this.getQuery(this.currentValue),c=this.classes.suggestion,d=this.classes.selected,f=e(this.suggestionsContainer),g="",h;e.each(this.suggestions,function(d,e){g+='<div class="'+c+'" data-index="'+d+'">'+a(e,b)+"</div>"});"auto"===this.options.width&&(h=this.el.outerWidth()-2,f.width(0<h?h:300));f.html(g).show();this.visible=!0;this.options.autoSelectFirst&&(this.selectedIndex=
22
+ 0,f.children().first().addClass(d));this.findBestHint()}},findBestHint:function(){var a=this.el.val().toLowerCase(),b=null;a&&(e.each(this.suggestions,function(c,d){var e=0===d.value.toLowerCase().indexOf(a);e&&(b=d);return!e}),this.signalHint(b))},signalHint:function(a){var b="";a&&(b=this.currentValue+a.value.substr(this.currentValue.length));this.hintValue!==b&&(this.hintValue=b,this.hint=a,(this.options.onHint||e.noop)(b))},verifySuggestionsFormat:function(a){return a.length&&"string"===typeof a[0]?
23
+ e.map(a,function(a){return{value:a,data:null}}):a},processResponse:function(a,b){var c=this.options,d=c.transformResult(a,b);d.suggestions=this.verifySuggestionsFormat(d.suggestions);c.noCache||(this.cachedResponse[d[c.paramName]]=d,0===d.suggestions.length&&this.badQueries.push(d[c.paramName]));b===this.getQuery(this.currentValue)&&(this.suggestions=d.suggestions,this.suggest())},activate:function(a){var b=this.classes.selected,c=e(this.suggestionsContainer),d=c.children();c.children("."+b).removeClass(b);
24
+ this.selectedIndex=a;return-1!==this.selectedIndex&&d.length>this.selectedIndex?(a=d.get(this.selectedIndex),e(a).addClass(b),a):null},selectHint:function(){var a=e.inArray(this.hint,this.suggestions);this.select(a)},select:function(a){this.hide();this.onSelect(a)},moveUp:function(){-1!==this.selectedIndex&&(0===this.selectedIndex?(e(this.suggestionsContainer).children().first().removeClass(this.classes.selected),this.selectedIndex=-1,this.el.val(this.currentValue),this.findBestHint()):this.adjustScroll(this.selectedIndex-
25
+ 1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(a){var b=this.activate(a),c,d;b&&(b=b.offsetTop,c=e(this.suggestionsContainer).scrollTop(),d=c+this.options.maxHeight-25,b<c?e(this.suggestionsContainer).scrollTop(b):b>d&&e(this.suggestionsContainer).scrollTop(b-this.options.maxHeight+25),this.el.val(this.getValue(this.suggestions[a].value)),this.signalHint(null))},onSelect:function(a){var b=this.options.onSelect;
26
+ a=this.suggestions[a];this.currentValue=this.getValue(a.value);this.el.val(this.currentValue);this.signalHint(null);this.suggestions=[];this.selection=a;e.isFunction(b)&&b.call(this.element,a)},getValue:function(a){var b=this.options.delimiter,c;if(!b)return a;c=this.currentValue;b=c.split(b);return 1===b.length?a:c.substr(0,c.length-b[b.length-1].length)+a},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete");this.disableKillerFn();e(window).off("resize",this.fixPositionCapture);
27
+ e(this.suggestionsContainer).remove()}};e.fn.autocomplete=function(a,b){return 0===arguments.length?this.first().data("autocomplete"):this.each(function(){var c=e(this),d=c.data("autocomplete");if("string"===typeof a){if(d&&"function"===typeof d[a])d[a](b)}else d&&d.dispose&&d.dispose(),d=new g(this,a),c.data("autocomplete",d)})}});
assets/js/frontend.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * frontend.js
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Search
6
+ * @version 1.0.0
7
+ */
8
+ jQuery(document).ready(function($){
9
+
10
+ });
assets/js/frontend.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * frontend.js
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Search
6
+ * @version 1.0.0
7
+ */
8
+ jQuery(document).ready(function($){
9
+
10
+ });
class.yith-wcas-admin.php ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAS_Admin' ) ) {
13
+ /**
14
+ * Admin class.
15
+ * The class manage all the admin behaviors.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ class YITH_WCAS_Admin {
20
+ /**
21
+ * Plugin options
22
+ *
23
+ * @var array
24
+ * @access public
25
+ * @since 1.0.0
26
+ */
27
+ public $options = array();
28
+
29
+ /**
30
+ * Plugin version
31
+ *
32
+ * @var string
33
+ * @since 1.0.0
34
+ */
35
+ public $version;
36
+
37
+ /**
38
+ * Various links
39
+ *
40
+ * @var string
41
+ * @access public
42
+ * @since 1.0.0
43
+ */
44
+ public $banner_url = 'http://cdn.yithemes.com/plugins/yith_magnifier.php?url';
45
+ public $banner_img = 'http://cdn.yithemes.com/plugins/yith_magnifier.php';
46
+ public $doc_url = 'http://yithemes.com/docs-plugins/yith_ajax_search/';
47
+
48
+ /**
49
+ * Constructor
50
+ *
51
+ * @access public
52
+ * @since 1.0.0
53
+ */
54
+ public function __construct( $version ) {
55
+
56
+ $this->options = $this->_initOptions();
57
+ $this->version = $version;
58
+
59
+ //Actions
60
+ add_action( 'init', array( $this, 'init' ) );
61
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
62
+ add_filter( 'plugin_action_links_' . plugin_basename( dirname(__FILE__) . '/init.php' ), array( $this, 'action_links' ) );
63
+
64
+
65
+ add_action( 'woocommerce_settings_tabs_yith_wcas', array( $this, 'print_plugin_options' ) );
66
+ add_action( 'woocommerce_update_options_yith_wcas', array( $this, 'update_options' ) );
67
+
68
+
69
+ add_action( 'woocommerce_admin_field_banner', array( $this, 'admin_fields_banner' ) );
70
+
71
+
72
+ if ( !has_action('woocommerce_admin_field_slider')) add_action( 'woocommerce_admin_field_slider', array( $this, 'admin_fields_slider' ) );
73
+ if ( !has_action('woocommerce_admin_field_picker')) add_action( 'woocommerce_admin_field_picker', array( $this, 'admin_fields_picker' ) );
74
+ add_action( 'woocommerce_update_option_slider', array( $this, 'admin_update_option' ) );
75
+ add_action( 'woocommerce_update_option_picker', array( $this, 'admin_update_option' ) );
76
+
77
+
78
+ //Filters
79
+ add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_tab_woocommerce' ) );
80
+ //add_filter( 'woocommerce_catalog_settings', array( $this, 'add_catalog_image_size' ) );
81
+
82
+ //Apply filters
83
+ $this->banner_url = apply_filters('yith_wcas_banner_url', $this->banner_url);
84
+
85
+ // YITH WCAS Loaded
86
+ do_action( 'yith_wcas_loaded' );
87
+ }
88
+
89
+
90
+ /**
91
+ * Init method:
92
+ * - default options
93
+ *
94
+ * @access public
95
+ * @since 1.0.0
96
+ */
97
+ public function init() {
98
+ $this->_default_options();
99
+ }
100
+
101
+
102
+ /**
103
+ * Update plugin options.
104
+ *
105
+ * @return void
106
+ * @since 1.0.0
107
+ */
108
+ public function update_options() {
109
+ foreach( $this->options as $option ) {
110
+ woocommerce_update_options( $option );
111
+ }
112
+ }
113
+
114
+
115
+ /**
116
+ * Add Magnifier's tab to Woocommerce -> Settings page
117
+ *
118
+ * @access public
119
+ * @param array $tabs
120
+ *
121
+ * @return array
122
+ */
123
+ public function add_tab_woocommerce($tabs) {
124
+ $tabs['yith_wcas'] = __('Ajax Search', 'yit');
125
+
126
+ return $tabs;
127
+ }
128
+
129
+
130
+ /**
131
+ * Add Zoom Image size to Woocommerce -> Catalog
132
+ *
133
+ * @access public
134
+ * @param array $settings
135
+ *
136
+ * @return array
137
+
138
+ public function add_catalog_image_size( $settings ) {
139
+ $tmp = $settings[ count($settings)-1 ];
140
+ unset( $settings[ count($settings)-1 ] );
141
+
142
+ $settings[] = array(
143
+ 'name' => __( 'Catalog Zoom Images', 'yit' ),
144
+ 'desc' => __('The size of images used within the magnifier box', 'yit'),
145
+ 'id' => 'woocommerce_magnifier_image',
146
+ 'css' => '',
147
+ 'type' => 'image_width',
148
+ 'default' => array(
149
+ 'width' => 600,
150
+ 'height' => 600,
151
+ 'crop' => true
152
+ ),
153
+ 'std' => array(
154
+ 'width' => 600,
155
+ 'height' => 600,
156
+ 'crop' => true
157
+ ),
158
+ 'desc_tip' => true
159
+ );
160
+ $settings[] = $tmp;
161
+ return $settings;
162
+ }
163
+ */
164
+
165
+ /**
166
+ * Print all plugin options.
167
+ *
168
+ * @return void
169
+ * @since 1.0.0
170
+ */
171
+ public function print_plugin_options() {
172
+ $links = apply_filters( 'yith_wcas_tab_links', array(
173
+ '<a href="#yith_wcas_general">' . __( 'General Settings', 'yit' ) . '</a>',
174
+ //'<a href="#yith_wcas_magnifier">' . __( 'Magnifier', 'yit' ) . '</a>',
175
+ //'<a href="#yith_wcas_slider">' . __( 'Slider', 'yit' ) . '</a>'
176
+ ) );
177
+
178
+ $this->_printBanner();
179
+ ?>
180
+
181
+ <div class="subsubsub_section">
182
+ <ul class="subsubsub">
183
+ <li>
184
+ <?php echo implode( ' | </li><li>', $links ) ?>
185
+ </li>
186
+ </ul>
187
+ <br class="clear" />
188
+
189
+ <?php
190
+ $option_theme = apply_filters('yith_wcas_options_theme_plugin', $this->options );
191
+ foreach( $option_theme as $id => $tab ) : ?>
192
+ <!-- tab #<?php echo $id ?> -->
193
+ <div class="section" id="yith_wcas_<?php echo $id ?>">
194
+ <?php woocommerce_admin_fields( $option_theme[$id] ) ?>
195
+ </div>
196
+ <?php endforeach ?>
197
+ </div>
198
+ <?php
199
+ }
200
+
201
+
202
+ /**
203
+ * Initialize the options
204
+ *
205
+ * @access protected
206
+ * @return array
207
+ * @since 1.0.0
208
+ */
209
+ protected function _initOptions() {
210
+ $options = array(
211
+ 'general' => array(
212
+ array(
213
+ 'name' => __( 'General Settings', 'yit' ),
214
+ 'type' => 'title',
215
+ 'desc' => '',
216
+ 'id' => 'yith_wcas_general'
217
+ ),
218
+
219
+ array(
220
+ 'name' => __( 'Search input label', 'yit' ),
221
+ 'desc' => __( 'Label for Search input field.', 'yit' ),
222
+ 'id' => 'yith_wcas_search_input_label',
223
+ 'std' => __( 'Search for products', 'yit' ),
224
+ 'default' => __( 'Search for products', 'yit' ),
225
+ 'desc_tip' => true,
226
+ 'type' => 'text',
227
+ ),
228
+
229
+ array(
230
+ 'name' => __( 'Search submit label', 'yit' ),
231
+ 'desc' => __( 'Label for Search submit field.', 'yit' ),
232
+ 'id' => 'yith_wcas_search_submit_label',
233
+ 'std' => __( 'Search', 'yit' ),
234
+ 'default' => __( 'Search', 'yit' ),
235
+ 'desc_tip' => true,
236
+ 'type' => 'text',
237
+ ),
238
+
239
+ array(
240
+ 'name' => __( 'Minimum number of characters', 'yit' ),
241
+ 'desc' => __( 'Minimum number of characters required to trigger autosuggest.', 'yit' ),
242
+ 'id' => 'yith_wcas_min_chars',
243
+ 'std' => '3',
244
+ 'default' => '3',
245
+ 'css' => 'width:50px;',
246
+ 'desc_tip' => true,
247
+ 'type' => 'number',
248
+ 'custom_attributes' => array(
249
+ 'min' => 1,
250
+ 'max' => 10,
251
+ 'step' => 1
252
+ )
253
+ ),
254
+
255
+ array(
256
+ 'name' => __( 'Maximum number of results', 'yit' ),
257
+ 'desc' => __( 'Maximum number of results showed within the autosuggest box.', 'yit' ),
258
+ 'id' => 'yith_wcas_posts_per_page',
259
+ 'std' => '3',
260
+ 'default' => '3',
261
+ 'css' => 'width:50px;',
262
+ 'desc_tip' => true,
263
+ 'type' => 'number',
264
+ 'custom_attributes' => array(
265
+ 'min' => 1,
266
+ 'max' => 15,
267
+ 'step' => 1
268
+ )
269
+ ),
270
+
271
+ array( 'type' => 'sectionend', 'id' => 'yith_wcas_general_end' )
272
+ ),
273
+ );
274
+
275
+ return apply_filters('yith_wcas_tab_options', $options);
276
+ }
277
+
278
+
279
+ /**
280
+ * Default options
281
+ *
282
+ * Sets up the default options used on the settings page
283
+ *
284
+ * @access protected
285
+ * @return void
286
+ * @since 1.0.0
287
+ */
288
+ protected function _default_options() {
289
+ foreach ($this->options as $section) {
290
+ foreach ( $section as $value ) {
291
+ if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
292
+ if ( $value['type'] == 'image_width' ) {
293
+ add_option($value['id'].'_width', $value['std']);
294
+ add_option($value['id'].'_height', $value['std']);
295
+ } else {
296
+ add_option($value['id'], $value['std']);
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+
303
+
304
+ /**
305
+ * Create new Woocommerce admin field: slider
306
+ *
307
+ * @access public
308
+ * @param array $value
309
+ * @return void
310
+ * @since 1.0.0
311
+ */
312
+ public function admin_fields_slider( $value ) {
313
+ $slider_value = ( get_option( $value['id'] ) !== false && get_option( $value['id'] ) !== null ) ?
314
+ esc_attr( stripslashes( get_option($value['id'] ) ) ) :
315
+ esc_attr( $value['std'] );
316
+
317
+ ?><tr valign="top">
318
+ <th scope="row" class="titledesc">
319
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo $value['name']; ?></label>
320
+ </th>
321
+ <td class="forminp">
322
+ <div id="<?php echo esc_attr( $value['id'] ); ?>_slider" class="yith_woocommerce_slider" style="width: 300px; float: left;"></div>
323
+ <div id="<?php echo esc_attr( $value['id'] ); ?>_value" class="yith_woocommerce_slider_value ui-state-default ui-corner-all"><?php echo $slider_value ?></div>
324
+ <input name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'] ); ?>" type="hidden" value="<?php echo $slider_value ?>" /> <?php echo $value['desc']; ?></td>
325
+ </tr>
326
+
327
+
328
+
329
+ <script>
330
+ jQuery(document).ready(function($){
331
+ $('#<?php echo esc_attr( $value['id'] ); ?>_slider').slider({
332
+ min: <?php echo $value['min'] ?>,
333
+ max: <?php echo $value['max'] ?>,
334
+ step: <?php echo $value['step'] ?>,
335
+ value: <?php echo $slider_value ?>,
336
+ slide: function( event, ui ) {
337
+ $( "#<?php echo esc_attr( $value['id'] ); ?>" ).val( ui.value );
338
+ $( "#<?php echo esc_attr( $value['id'] ); ?>_value" ).text( ui.value );
339
+ }
340
+ });
341
+ });
342
+ </script>
343
+
344
+ <?php
345
+ }
346
+
347
+
348
+ /**
349
+ * Create new Woocommerce admin field: picker
350
+ *
351
+ * @access public
352
+ * @param array $value
353
+ * @return void
354
+ * @since 1.0.0
355
+ */
356
+ public function admin_fields_picker( $value ) {
357
+ $picker_value = ( get_option( $value['id'] ) !== false && get_option( $value['id'] ) !== null ) ?
358
+ esc_attr( stripslashes( get_option($value['id'] ) ) ) :
359
+ esc_attr( $value['std'] );
360
+
361
+ ?><tr valign="top">
362
+ <th scope="row" class="titledesc">
363
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo $value['name']; ?></label>
364
+ </th>
365
+ <td class="forminp">
366
+ <div class="color_box"><strong><?php echo $value['name']; ?></strong>
367
+ <input name="<?php echo esc_attr( $value['id'] ) ?>" id="<?php echo esc_attr( $value['id'] ) ?>" type="text" value="<?php echo $picker_value ?>" class="colorpick" /> <div id="colorPickerDiv_<?php echo esc_attr( $value['id'] ) ?>" class="colorpickdiv"></div>
368
+ </div> <?php echo $value['desc']; ?></td>
369
+ </tr>
370
+ <?php
371
+ }
372
+
373
+ /**
374
+ * Save the admin field: slider
375
+ *
376
+ * @access public
377
+ * @param mixed $value
378
+ * @return void
379
+ * @since 1.0.0
380
+ */
381
+ public function admin_update_option($value) {
382
+ update_option( $value['id'], woocommerce_clean($_POST[$value['id']]) );
383
+ }
384
+
385
+ /**
386
+ * Enqueue admin styles and scripts
387
+ *
388
+ * @access public
389
+ * @return void
390
+ * @since 1.0.0
391
+ */
392
+ public function enqueue_styles_scripts() {
393
+ wp_enqueue_script( 'jquery-ui' );
394
+ wp_enqueue_script( 'jquery-ui-core' );
395
+ wp_enqueue_script( 'jquery-ui-mouse' );
396
+ wp_enqueue_script( 'jquery-ui-slider' );
397
+
398
+ wp_enqueue_style( 'yith_wcas_admin', YITH_WCAS_URL . 'assets/css/admin.css' );
399
+ }
400
+
401
+
402
+ /**
403
+ * Print the banner
404
+ *
405
+ * @access protected
406
+ * @return void
407
+ * @since 1.0.0
408
+ */
409
+ protected function _printBanner() {
410
+ ?>
411
+ <div class="yith_banner">
412
+ <a href="<?php echo $this->banner_url ?>" target="_blank">
413
+ <img src="<?php echo $this->banner_img ?>" alt="" />
414
+ </a>
415
+ </div>
416
+ <?php
417
+ }
418
+
419
+
420
+ /**
421
+ * action_links function.
422
+ *
423
+ * @access public
424
+ * @param mixed $links
425
+ * @return void
426
+ */
427
+ public function action_links( $links ) {
428
+
429
+ $plugin_links = array(
430
+ '<a href="' . admin_url( 'admin.php?page=woocommerce_settings&tab=yith_wcas' ) . '">' . __( 'Settings', 'yit' ) . '</a>',
431
+ '<a href="' . $this->doc_url . '">' . __( 'Docs', 'yit' ) . '</a>',
432
+ );
433
+
434
+ return array_merge( $plugin_links, $links );
435
+ }
436
+ }
437
+ }
class.yith-wcas-frontend.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Frontend class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAS_Frontend' ) ) {
13
+ /**
14
+ * Admin class.
15
+ * The class manage all the Frontend behaviors.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ class YITH_WCAS_Frontend {
20
+ /**
21
+ * Plugin version
22
+ *
23
+ * @var string
24
+ * @since 1.0.0
25
+ */
26
+ public $version;
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @access public
32
+ * @since 1.0.0
33
+ */
34
+ public function __construct( $version ) {
35
+ $this->version = $version;
36
+
37
+ //custom styles and javascripts
38
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
39
+ }
40
+
41
+ /**
42
+ * Enqueue styles and scripts
43
+ *
44
+ * @access public
45
+ * @return void
46
+ * @since 1.0.0
47
+ */
48
+ public function enqueue_styles_scripts() {
49
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
+ wp_register_script('yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
51
+
52
+ $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
53
+ wp_enqueue_style( 'yith_wcas_frontend', $css );
54
+ }
55
+ }
56
+ }
class.yith-wcas.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Main class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAS' ) ) {
13
+ /**
14
+ * WooCommerce Magnifier
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YITH_WCAS {
19
+ /**
20
+ * Plugin version
21
+ *
22
+ * @var string
23
+ * @since 1.0.0
24
+ */
25
+ public $version = '1.0.0';
26
+
27
+ /**
28
+ * Plugin object
29
+ *
30
+ * @var string
31
+ * @since 1.0.0
32
+ */
33
+ public $obj = null;
34
+
35
+ /**
36
+ * Constructor
37
+ *
38
+ * @return mixed|YITH_WCAS_Admin|YITH_WCAS_Frontend
39
+ * @since 1.0.0
40
+ */
41
+ public function __construct() {
42
+
43
+ // actions
44
+ add_action( 'init', array( $this, 'init' ) );
45
+ add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
46
+ add_action( 'wp_ajax_yith_ajax_search_products', array( $this, 'ajax_search_products') );
47
+ add_action( 'wp_ajax_nopriv_yith_ajax_search_products', array( $this, 'ajax_search_products') );
48
+
49
+ //register shortcode
50
+ add_shortcode( 'yith_woocommerce_ajax_search', array( $this, 'add_woo_ajax_search_shortcode') );
51
+
52
+ if( is_admin() ) {
53
+ $this->obj = new YITH_WCAS_Admin( $this->version );
54
+ } else {
55
+ $this->obj = new YITH_WCAS_Frontend( $this->version );
56
+ }
57
+
58
+ return $this->obj;
59
+ }
60
+
61
+
62
+ /**
63
+ * Init method:
64
+ * - default options
65
+ *
66
+ * @access public
67
+ * @since 1.0.0
68
+ */
69
+ public function init() {}
70
+
71
+ /**
72
+ * Load template for [yith_woocommerce_ajax_search] shortcode
73
+ *
74
+ * @access public
75
+ * @param $args array
76
+ * @return void
77
+ * @since 1.0.0
78
+ */
79
+ public function add_woo_ajax_search_shortcode( $args = array() ) {
80
+ $args = shortcode_atts( array(), $args );
81
+
82
+ woocommerce_get_template( 'yith-woocommerce-ajax-search.php', $args, '', YITH_WCAS_DIR . 'templates/' );
83
+ }
84
+
85
+ /**
86
+ * Load and register widgets
87
+ *
88
+ * @access public
89
+ * @since 1.0.0
90
+ */
91
+ public function registerWidgets() {
92
+ register_widget( 'YITH_WCAS_Ajax_Search_Widget' );
93
+ }
94
+
95
+
96
+ /**
97
+ * Perform jax search products
98
+ */
99
+ public function ajax_search_products() {
100
+ global $woocommerce;
101
+
102
+ $search_keyword = esc_attr($_REQUEST['query']);
103
+ $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
104
+ $products = array();
105
+
106
+ $args = array(
107
+ 's' => apply_filters('yith_wcas_ajax_search_products_search_query', $search_keyword),
108
+ 'post_type' => 'product',
109
+ 'post_status' => 'publish',
110
+ 'ignore_sticky_posts' => 1,
111
+ 'orderby' => $ordering_args['orderby'],
112
+ 'order' => $ordering_args['order'],
113
+ 'posts_per_page' => apply_filters('yith_wcas_ajax_search_products_posts_per_page', get_option('yith_wcas_posts_per_page')),
114
+ 'meta_query' => array(
115
+ array(
116
+ 'key' => '_visibility',
117
+ 'value' => array('catalog', 'visible'),
118
+ 'compare' => 'IN'
119
+ )
120
+ )
121
+ );
122
+ $products_query = new WP_Query( $args );
123
+
124
+ if ( $products_query->have_posts() ) {
125
+ while ( $products_query->have_posts() ) {
126
+ $products_query->the_post();
127
+
128
+ $products[] = array(
129
+ 'id' => get_the_ID(),
130
+ 'value' => get_the_title(),
131
+ 'url' => get_permalink()
132
+ );
133
+ }
134
+ } else {
135
+ $products[] = array(
136
+ 'id' => -1,
137
+ 'value' => __('No results', 'yit'),
138
+ 'url' => ''
139
+ );
140
+ }
141
+ wp_reset_postdata();
142
+
143
+
144
+ $products = array(
145
+ 'suggestions' => $products
146
+ );
147
+
148
+
149
+ echo json_encode( $products );
150
+ die();
151
+ }
152
+ }
153
+ }
functions.yith-wcas.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Functions
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
init.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: YITH WooCommerce Ajax Search
4
+ * Plugin URI: http://yithemes.com/
5
+ * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
+ * Version: 1.0.0
7
+ * Author: Your Inspiration Themes
8
+ * Author URI: http://yithemes.com/
9
+ * Text Domain: yit
10
+ * Domain Path: /languages/
11
+ *
12
+ * @author Your Inspiration Themes
13
+ * @package YITH WooCommerce Ajax Search
14
+ * @version 1.0.0
15
+ */
16
+ /* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
+
18
+ This program is free software; you can redistribute it and/or modify
19
+ it under the terms of the GNU General Public License, version 2, as
20
+ published by the Free Software Foundation.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program; if not, write to the Free Software
29
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
+ */
31
+ if ( !defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
32
+
33
+ function yith_ajax_search_constructor() {
34
+ global $woocommerce;
35
+ if ( ! isset( $woocommerce ) ) return;
36
+
37
+ /**
38
+ * Required functions
39
+ */
40
+ if( !defined('YITH_FUNCTIONS') ) {
41
+ require_once( 'yit-common/yit-functions.php' );
42
+ }
43
+
44
+ load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
45
+
46
+ define( 'YITH_WCAS', true );
47
+ define( 'YITH_WCAS_URL', plugin_dir_url( __FILE__ ) );
48
+ define( 'YITH_WCAS_DIR', plugin_dir_path( __FILE__ ) );
49
+
50
+ // Load required classes and functions
51
+ require_once('functions.yith-wcas.php');
52
+ require_once('class.yith-wcas-admin.php');
53
+ require_once('class.yith-wcas-frontend.php');
54
+ require_once('widgets/class.yith-wcas-ajax-search.php');
55
+ require_once('class.yith-wcas.php');
56
+
57
+ // Let's start the game!
58
+ global $yith_wcas;
59
+ $yith_wcas = new YITH_WCAS();
60
+ }
61
+ add_action( 'plugins_loaded', 'yith_ajax_search_constructor' );
languages/default.po ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Search\n"
4
+ "POT-Creation-Date: 2013-07-29 18:57+0100\n"
5
+ "PO-Revision-Date: 2013-07-29 18:57+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.5\n"
12
+ "X-Poedit-KeywordsList: __;_e;_x\n"
13
+ "X-Poedit-Basepath: ./\n"
14
+ "X-Poedit-SearchPath-0: ..\n"
15
+
16
+ #: ../class.yith-wcas-admin.php:124
17
+ msgid "Ajax Search"
18
+ msgstr ""
19
+
20
+ #: ../class.yith-wcas-admin.php:173 ../class.yith-wcas-admin.php:213
21
+ msgid "General Settings"
22
+ msgstr ""
23
+
24
+ #: ../class.yith-wcas-admin.php:220
25
+ msgid "Search input label"
26
+ msgstr ""
27
+
28
+ #: ../class.yith-wcas-admin.php:221
29
+ msgid "Label for Search input field."
30
+ msgstr ""
31
+
32
+ #: ../class.yith-wcas-admin.php:223 ../class.yith-wcas-admin.php:224
33
+ msgid "Search for products"
34
+ msgstr ""
35
+
36
+ #: ../class.yith-wcas-admin.php:230
37
+ msgid "Search submit label"
38
+ msgstr ""
39
+
40
+ #: ../class.yith-wcas-admin.php:231
41
+ msgid "Label for Search submit field."
42
+ msgstr ""
43
+
44
+ #: ../class.yith-wcas-admin.php:233 ../class.yith-wcas-admin.php:234
45
+ msgid "Search"
46
+ msgstr ""
47
+
48
+ #: ../class.yith-wcas-admin.php:240
49
+ msgid "Minimum number of characters"
50
+ msgstr ""
51
+
52
+ #: ../class.yith-wcas-admin.php:241
53
+ msgid "Minimum number of characters required to trigger autosuggest."
54
+ msgstr ""
55
+
56
+ #: ../class.yith-wcas-admin.php:256
57
+ msgid "Maximum number of results"
58
+ msgstr ""
59
+
60
+ #: ../class.yith-wcas-admin.php:257
61
+ msgid "Maximum number of results showed within the autosuggest box."
62
+ msgstr ""
63
+
64
+ #: ../class.yith-wcas-admin.php:430
65
+ msgid "Settings"
66
+ msgstr ""
67
+
68
+ #: ../class.yith-wcas-admin.php:431
69
+ msgid "Docs"
70
+ msgstr ""
71
+
72
+ #: ../class.yith-wcas.php:137
73
+ msgid "No results"
74
+ msgstr ""
75
+
76
+ #: ../templates/yith-woocommerce-ajax-search.php:20
77
+ msgid "Search for:"
78
+ msgstr ""
79
+
80
+ #: ../widgets/class.yith-wcas-ajax-search.php:29
81
+ msgid "An Ajax Search box for products only."
82
+ msgstr ""
83
+
84
+ #: ../widgets/class.yith-wcas-ajax-search.php:31
85
+ msgid "YITH WooCommerce Ajax Product Search"
86
+ msgstr ""
87
+
88
+ #: ../widgets/class.yith-wcas-ajax-search.php:90
89
+ msgid "Title:"
90
+ msgstr ""
91
+
92
+ #: ../yit-common/yith-panel.php:396
93
+ msgid "Select a date"
94
+ msgstr ""
95
+
96
+ #: ../yit-common/yith-panel.php:397
97
+ msgid "Hours"
98
+ msgstr ""
99
+
100
+ #: ../yit-common/yith-panel.php:398 ../yit-common/yith-panel.php:399
101
+ msgid "Minutes"
102
+ msgstr ""
103
+
104
+ #: ../yit-common/yith-panel.php:407
105
+ msgid "Upload"
106
+ msgstr ""
107
+
108
+ #: ../yit-common/yith-panel.php:434
109
+ msgid "px"
110
+ msgstr ""
111
+
112
+ #: ../yit-common/yith-panel.php:435
113
+ msgid "em"
114
+ msgstr ""
115
+
116
+ #: ../yit-common/yith-panel.php:436
117
+ msgid "pt"
118
+ msgstr ""
119
+
120
+ #: ../yit-common/yith-panel.php:437
121
+ msgid "rem"
122
+ msgstr ""
123
+
124
+ #: ../yit-common/yith-panel.php:447
125
+ msgid "Select a font family"
126
+ msgstr ""
127
+
128
+ #: ../yit-common/yith-panel.php:455
129
+ msgid "Regular"
130
+ msgstr ""
131
+
132
+ #: ../yit-common/yith-panel.php:456
133
+ msgid "Bold"
134
+ msgstr ""
135
+
136
+ #: ../yit-common/yith-panel.php:457
137
+ msgid "Extra bold"
138
+ msgstr ""
139
+
140
+ #: ../yit-common/yith-panel.php:458
141
+ msgid "Italic"
142
+ msgstr ""
143
+
144
+ #: ../yit-common/yith-panel.php:459
145
+ msgid "Italic bold"
146
+ msgstr ""
147
+
148
+ #: ../yit-common/yith-panel.php:471
149
+ msgid "Click to preview"
150
+ msgstr ""
languages/yit-it_IT.mo ADDED
Binary file
languages/yit-it_IT.po ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Search\n"
4
+ "POT-Creation-Date: 2013-07-29 18:44+0100\n"
5
+ "PO-Revision-Date: 2013-07-29 18:55+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.5\n"
12
+ "X-Poedit-KeywordsList: __;_e;_x\n"
13
+ "X-Poedit-Basepath: ./\n"
14
+ "X-Poedit-SearchPath-0: ..\n"
15
+
16
+ #: ../class.yith-wcas-admin.php:124
17
+ msgid "Ajax Search"
18
+ msgstr "Ajax Search"
19
+
20
+ #: ../class.yith-wcas-admin.php:173 ../class.yith-wcas-admin.php:213
21
+ msgid "General Settings"
22
+ msgstr "Impostazioni Generali"
23
+
24
+ #: ../class.yith-wcas-admin.php:220
25
+ msgid "Search input label"
26
+ msgstr "Etichetta campo di ricerca"
27
+
28
+ #: ../class.yith-wcas-admin.php:221
29
+ msgid "Label for Search input field."
30
+ msgstr "Etichetta per il campo di ricerca"
31
+
32
+ #: ../class.yith-wcas-admin.php:223 ../class.yith-wcas-admin.php:224
33
+ msgid "Search for products"
34
+ msgstr "Cerca prodotto"
35
+
36
+ #: ../class.yith-wcas-admin.php:230
37
+ msgid "Search submit label"
38
+ msgstr "Etichetta campo di submit"
39
+
40
+ #: ../class.yith-wcas-admin.php:231
41
+ msgid "Label for Search submit field."
42
+ msgstr "Etichetta per il campo di submit"
43
+
44
+ #: ../class.yith-wcas-admin.php:233 ../class.yith-wcas-admin.php:234
45
+ msgid "Search"
46
+ msgstr "Cerca"
47
+
48
+ #: ../class.yith-wcas-admin.php:240
49
+ msgid "Minimum number of characters"
50
+ msgstr "Numero minimo di caratteri"
51
+
52
+ #: ../class.yith-wcas-admin.php:241
53
+ msgid "Minimum number of characters required to trigger autosuggest."
54
+ msgstr "Numero minimo di caratteri richiesti per avviare la ricerca"
55
+
56
+ #: ../class.yith-wcas-admin.php:256
57
+ msgid "Maximum number of results"
58
+ msgstr "Numero massimo di risultati"
59
+
60
+ #: ../class.yith-wcas-admin.php:257
61
+ msgid "Maximum number of results showed within the autosuggest box."
62
+ msgstr "Numero massimo di risultati mostrati nel box di ricerca"
63
+
64
+ #: ../class.yith-wcas-admin.php:430
65
+ msgid "Settings"
66
+ msgstr "Impostazioni"
67
+
68
+ #: ../class.yith-wcas-admin.php:431
69
+ msgid "Docs"
70
+ msgstr "Documentazione"
71
+
72
+ #: ../class.yith-wcas.php:137
73
+ msgid "No results"
74
+ msgstr "Nessun risultato"
75
+
76
+ #: ../templates/yith-woocommerce-ajax-search.php:20
77
+ msgid "Search for:"
78
+ msgstr "Cerca:"
79
+
80
+ #: ../widgets/class.yith-wcas-ajax-search.php:29
81
+ msgid "An Ajax Search box for products only."
82
+ msgstr "Un filtro di ricerca Ajax per i prodotti di WooCommmerce."
83
+
84
+ #: ../widgets/class.yith-wcas-ajax-search.php:31
85
+ msgid "YITH WooCommerce Ajax Product Search"
86
+ msgstr "YITH WooCommerce Ajax Product Search"
87
+
88
+ #: ../widgets/class.yith-wcas-ajax-search.php:90
89
+ msgid "Title:"
90
+ msgstr "Titolo:"
91
+
92
+ #: ../yit-common/yith-panel.php:396
93
+ msgid "Select a date"
94
+ msgstr "Seleziona una data"
95
+
96
+ #: ../yit-common/yith-panel.php:397
97
+ msgid "Hours"
98
+ msgstr "Ore"
99
+
100
+ #: ../yit-common/yith-panel.php:398 ../yit-common/yith-panel.php:399
101
+ msgid "Minutes"
102
+ msgstr "Minuti"
103
+
104
+ #: ../yit-common/yith-panel.php:407
105
+ msgid "Upload"
106
+ msgstr "Upload"
107
+
108
+ #: ../yit-common/yith-panel.php:434
109
+ msgid "px"
110
+ msgstr "px"
111
+
112
+ #: ../yit-common/yith-panel.php:435
113
+ msgid "em"
114
+ msgstr "em"
115
+
116
+ #: ../yit-common/yith-panel.php:436
117
+ msgid "pt"
118
+ msgstr "pt"
119
+
120
+ #: ../yit-common/yith-panel.php:437
121
+ msgid "rem"
122
+ msgstr "rem"
123
+
124
+ #: ../yit-common/yith-panel.php:447
125
+ msgid "Select a font family"
126
+ msgstr "Seleziona un font"
127
+
128
+ #: ../yit-common/yith-panel.php:455
129
+ msgid "Regular"
130
+ msgstr "Regular"
131
+
132
+ #: ../yit-common/yith-panel.php:456
133
+ msgid "Bold"
134
+ msgstr "Bold"
135
+
136
+ #: ../yit-common/yith-panel.php:457
137
+ msgid "Extra bold"
138
+ msgstr "Extra bold"
139
+
140
+ #: ../yit-common/yith-panel.php:458
141
+ msgid "Italic"
142
+ msgstr "Italic"
143
+
144
+ #: ../yit-common/yith-panel.php:459
145
+ msgid "Italic bold"
146
+ msgstr "Italic bold"
147
+
148
+ #: ../yit-common/yith-panel.php:471
149
+ msgid "Click to preview"
150
+ msgstr "Clicca per anteprima"
languages/yit.pot ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Search\n"
4
+ "POT-Creation-Date: 2013-07-29 18:57+0100\n"
5
+ "PO-Revision-Date: 2013-07-29 18:58+0100\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.5\n"
12
+ "X-Poedit-KeywordsList: __;_e;_x\n"
13
+
14
+ #: ../class.yith-wcas-admin.php:124
15
+ msgid "Ajax Search"
16
+ msgstr ""
17
+
18
+ #: ../class.yith-wcas-admin.php:173 ../class.yith-wcas-admin.php:213
19
+ msgid "General Settings"
20
+ msgstr ""
21
+
22
+ #: ../class.yith-wcas-admin.php:220
23
+ msgid "Search input label"
24
+ msgstr ""
25
+
26
+ #: ../class.yith-wcas-admin.php:221
27
+ msgid "Label for Search input field."
28
+ msgstr ""
29
+
30
+ #: ../class.yith-wcas-admin.php:223 ../class.yith-wcas-admin.php:224
31
+ msgid "Search for products"
32
+ msgstr ""
33
+
34
+ #: ../class.yith-wcas-admin.php:230
35
+ msgid "Search submit label"
36
+ msgstr ""
37
+
38
+ #: ../class.yith-wcas-admin.php:231
39
+ msgid "Label for Search submit field."
40
+ msgstr ""
41
+
42
+ #: ../class.yith-wcas-admin.php:233 ../class.yith-wcas-admin.php:234
43
+ msgid "Search"
44
+ msgstr ""
45
+
46
+ #: ../class.yith-wcas-admin.php:240
47
+ msgid "Minimum number of characters"
48
+ msgstr ""
49
+
50
+ #: ../class.yith-wcas-admin.php:241
51
+ msgid "Minimum number of characters required to trigger autosuggest."
52
+ msgstr ""
53
+
54
+ #: ../class.yith-wcas-admin.php:256
55
+ msgid "Maximum number of results"
56
+ msgstr ""
57
+
58
+ #: ../class.yith-wcas-admin.php:257
59
+ msgid "Maximum number of results showed within the autosuggest box."
60
+ msgstr ""
61
+
62
+ #: ../class.yith-wcas-admin.php:430
63
+ msgid "Settings"
64
+ msgstr ""
65
+
66
+ #: ../class.yith-wcas-admin.php:431
67
+ msgid "Docs"
68
+ msgstr ""
69
+
70
+ #: ../class.yith-wcas.php:137
71
+ msgid "No results"
72
+ msgstr ""
73
+
74
+ #: ../templates/yith-woocommerce-ajax-search.php:20
75
+ msgid "Search for:"
76
+ msgstr ""
77
+
78
+ #: ../widgets/class.yith-wcas-ajax-search.php:29
79
+ msgid "An Ajax Search box for products only."
80
+ msgstr ""
81
+
82
+ #: ../widgets/class.yith-wcas-ajax-search.php:31
83
+ msgid "YITH WooCommerce Ajax Product Search"
84
+ msgstr ""
85
+
86
+ #: ../widgets/class.yith-wcas-ajax-search.php:90
87
+ msgid "Title:"
88
+ msgstr ""
89
+
90
+ #: ../yit-common/yith-panel.php:396
91
+ msgid "Select a date"
92
+ msgstr ""
93
+
94
+ #: ../yit-common/yith-panel.php:397
95
+ msgid "Hours"
96
+ msgstr ""
97
+
98
+ #: ../yit-common/yith-panel.php:398 ../yit-common/yith-panel.php:399
99
+ msgid "Minutes"
100
+ msgstr ""
101
+
102
+ #: ../yit-common/yith-panel.php:407
103
+ msgid "Upload"
104
+ msgstr ""
105
+
106
+ #: ../yit-common/yith-panel.php:434
107
+ msgid "px"
108
+ msgstr ""
109
+
110
+ #: ../yit-common/yith-panel.php:435
111
+ msgid "em"
112
+ msgstr ""
113
+
114
+ #: ../yit-common/yith-panel.php:436
115
+ msgid "pt"
116
+ msgstr ""
117
+
118
+ #: ../yit-common/yith-panel.php:437
119
+ msgid "rem"
120
+ msgstr ""
121
+
122
+ #: ../yit-common/yith-panel.php:447
123
+ msgid "Select a font family"
124
+ msgstr ""
125
+
126
+ #: ../yit-common/yith-panel.php:455
127
+ msgid "Regular"
128
+ msgstr ""
129
+
130
+ #: ../yit-common/yith-panel.php:456
131
+ msgid "Bold"
132
+ msgstr ""
133
+
134
+ #: ../yit-common/yith-panel.php:457
135
+ msgid "Extra bold"
136
+ msgstr ""
137
+
138
+ #: ../yit-common/yith-panel.php:458
139
+ msgid "Italic"
140
+ msgstr ""
141
+
142
+ #: ../yit-common/yith-panel.php:459
143
+ msgid "Italic bold"
144
+ msgstr ""
145
+
146
+ #: ../yit-common/yith-panel.php:471
147
+ msgid "Click to preview"
148
+ msgstr ""
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
templates/yith-woocommerce-ajax-search.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * YITH WooCommerce Ajax Search template
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
+
12
+
13
+ wp_enqueue_script('yith_wcas_jquery-autocomplete' );
14
+
15
+ ?>
16
+
17
+ <div class="yith-ajaxsearchform-container">
18
+ <form role="search" method="get" id="yith-ajaxsearchform" action="<?php echo esc_url( home_url( '/' ) ) ?>">
19
+ <div>
20
+ <label class="screen-reader-text" for="yith-s"><?php _e( 'Search for:', 'yit' ) ?></label>
21
+ <input type="search" value="<?php echo get_search_query() ?>" name="s" id="yith-s" placeholder="<?php echo get_option('yith_wcas_search_input_label') ?>" />
22
+ <input type="submit" id="yith-searchsubmit" value="<?php echo get_option('yith_wcas_search_submit_label') ?>" />
23
+ <input type="hidden" name="post_type" value="product" />
24
+ </div>
25
+ </form>
26
+ </div>
27
+ <script type="text/javascript">
28
+ jQuery(function($){
29
+ var search_loader_url = <?php echo apply_filters('yith_wcas_ajax_search_icon', 'woocommerce_params.ajax_loader_url') ?>;
30
+
31
+ $('#yith-s').autocomplete({
32
+ minChars: <?php echo get_option('yith_wcas_min_chars') * 1; ?>,
33
+ appendTo: '.yith-ajaxsearchform-container',
34
+ serviceUrl: woocommerce_params.ajax_url + '?action=yith_ajax_search_products',
35
+ onSearchStart: function(){
36
+ $(this).css('background', 'url('+search_loader_url+') no-repeat right center');
37
+ },
38
+ onSearchComplete: function(){
39
+ $(this).css('background', 'transparent');
40
+ },
41
+ onSelect: function (suggestion) {
42
+ if( suggestion.id != -1 ) {
43
+ window.location.href = suggestion.url;
44
+ }
45
+ }
46
+ });
47
+ });
48
+ </script>
uninstall.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uninstall plugin
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ // If uninstall not called from WordPress exit
11
+ if( !defined( 'WP_UNINSTALL_PLUGIN' ) )
12
+ { exit; }
13
+
14
+ global $wpdb;
15
+
widgets/class.yith-wcas-ajax-search.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ajax Search Widget
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAS_Ajax_Search_Widget' ) ) {
13
+ /**
14
+ * YITH WooCommerce Ajax Navigation Widget
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YITH_WCAS_Ajax_Search_Widget extends WP_Widget {
19
+ /**
20
+ * constructor
21
+ *
22
+ * @access public
23
+ * @return void
24
+ */
25
+ function YITH_WCAS_Ajax_Search_Widget() {
26
+
27
+ /* Widget variable settings. */
28
+ $this->woo_widget_cssclass = 'woocommerce widget_product_search yith_woocommerce_ajax_search';
29
+ $this->woo_widget_description = __( 'An Ajax Search box for products only.', 'yit' );
30
+ $this->woo_widget_idbase = 'yith_woocommerce_ajax_search';
31
+ $this->woo_widget_name = __( 'YITH WooCommerce Ajax Product Search', 'yit' );
32
+
33
+ /* Widget settings. */
34
+ $widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
35
+
36
+ /* Create the widget. */
37
+ $this->WP_Widget('yith_woocommerce_ajax_search', $this->woo_widget_name, $widget_ops);
38
+ }
39
+
40
+
41
+ /**
42
+ * widget function.
43
+ *
44
+ * @see WP_Widget
45
+ * @access public
46
+ * @param array $args
47
+ * @param array $instance
48
+ * @return void
49
+ */
50
+ function widget( $args, $instance ) {
51
+ extract($args);
52
+
53
+ $title = $instance['title'];
54
+ $title = apply_filters('widget_title', $title, $instance, $this->id_base);
55
+
56
+ echo $before_widget;
57
+
58
+ if ($title) echo $before_title . $title . $after_title;
59
+
60
+ echo do_shortcode('[yith_woocommerce_ajax_search]');
61
+
62
+ echo $after_widget;
63
+ }
64
+
65
+ /**
66
+ * update function.
67
+ *
68
+ * @see WP_Widget->update
69
+ * @access public
70
+ * @param array $new_instance
71
+ * @param array $old_instance
72
+ * @return array
73
+ */
74
+ function update( $new_instance, $old_instance ) {
75
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
76
+ return $instance;
77
+ }
78
+
79
+ /**
80
+ * form function.
81
+ *
82
+ * @see WP_Widget->form
83
+ * @access public
84
+ * @param array $instance
85
+ * @return void
86
+ */
87
+ function form( $instance ) {
88
+ global $wpdb;
89
+ ?>
90
+ <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'woocommerce' ) ?></label>
91
+ <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php if (isset ( $instance['title'])) {echo esc_attr( $instance['title'] );} ?>" /></p>
92
+ <?php
93
+ }
94
+ }
95
+ }
yit-common/assets/css/yith-panel.css ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* typography */
2
+ .typography_container {
3
+ padding-bottom:0px;
4
+ }
5
+ .typography_container .option {
6
+ width: 100%;
7
+ }
8
+ .typography_container input {
9
+ float:left;
10
+ margin-right:14px;
11
+ }
12
+
13
+ .typography_container .select-wrapper {
14
+ float: left;
15
+ width: 150px;
16
+ margin-right: 10px;
17
+ margin-bottom: 0px !important;
18
+ }
19
+ .typography_container .select-wrapper.font-unit {
20
+ width: 61px;
21
+ }
22
+ .typography_container .ui-spinner-buttons {
23
+ top: 0px !important;
24
+ }
25
+ .typography_container .select-wrapper.font-style {
26
+ width: 93px;
27
+ }
28
+ .typography_container .select-wrapper select {
29
+ width:100%;
30
+ }
31
+
32
+ .typography_container .font-preview {
33
+ border: 1px dashed #ddd;
34
+ -webkit-border-radius: 10px;
35
+ -moz-border-radius: 10px;
36
+ border-radius: 10px;
37
+ margin: 10px 0;
38
+ padding: 20px;
39
+ position: relative;
40
+ }
41
+ .typography_container .font-preview .refresh_container {
42
+ background: rgba(255,255,255,0.82);
43
+ -webkit-border-radius: 10px;
44
+ -moz-border-radius: 10px;
45
+ border-radius: 10px;
46
+ position: absolute;
47
+ left: 0;
48
+ top: 0;
49
+ width: 100%;
50
+ height: 100%;
51
+ z-index: 0;
52
+ }
53
+ .typography_container button.refresh {
54
+ /*background: #F2F2F2 url(../images/white-grad.png) repeat-x scroll left top;*/
55
+ border: 1px solid #BBB;
56
+ -webkit-border-radius: 11px;
57
+ border-radius: 11px;
58
+ -moz-box-sizing: content-box;
59
+ -webkit-box-sizing: content-box;
60
+ box-sizing: content-box;
61
+ color: #464646;
62
+ cursor: pointer;
63
+ font-size: 12px!important;
64
+ line-height: 6px;
65
+ margin: -16px 0px 0px -105px;
66
+ padding: 3px 19px;
67
+ position: absolute;
68
+ text-shadow: rgba(255, 255, 255, 1) 0 1px 0;
69
+ text-decoration: none;
70
+ top: 50%;
71
+ left: 50%;
72
+ width: auto;
73
+ height: 18px;
74
+ }
75
+ .typography_container button.refresh img {
76
+ margin-right: 5px;
77
+ vertical-align: middle;
78
+ }
yit-common/assets/js/google_fonts.json ADDED
@@ -0,0 +1 @@
 
1
+ {"items":["ABeeZee","Abel","Abril Fatface","Aclonica","Acme","Actor","Adamina","Advent Pro","Aguafina Script","Akronim","Aladin","Aldrich","Alef","Alegreya","Alegreya SC","Alex Brush","Alfa Slab One","Alice","Alike","Alike Angular","Allan","Allerta","Allerta Stencil","Allura","Almendra","Almendra Display","Almendra SC","Amarante","Amaranth","Amatic SC","Amethysta","Anaheim","Andada","Andika","Angkor","Annie Use Your Telescope","Anonymous Pro","Antic","Antic Didone","Antic Slab","Anton","Arapey","Arbutus","Arbutus Slab","Architects Daughter","Archivo Black","Archivo Narrow","Arimo","Arizonia","Armata","Artifika","Arvo","Asap","Asset","Astloch","Asul","Atomic Age","Aubrey","Audiowide","Autour One","Average","Average Sans","Averia Gruesa Libre","Averia Libre","Averia Sans Libre","Averia Serif Libre","Bad Script","Balthazar","Bangers","Basic","Battambang","Baumans","Bayon","Belgrano","Belleza","BenchNine","Bentham","Berkshire Swash","Bevan","Bigelow Rules","Bigshot One","Bilbo","Bilbo Swash Caps","Bitter","Black Ops One","Bokor","Bonbon","Boogaloo","Bowlby One","Bowlby One SC","Brawler","Bree Serif","Bubblegum Sans","Bubbler One","Buda:300","Buenard","Butcherman","Butterfly Kids","Cabin","Cabin Condensed","Cabin Sketch","Caesar Dressing","Cagliostro","Calligraffitti","Cambo","Candal","Cantarell","Cantata One","Cantora One","Capriola","Cardo","Carme","Carrois Gothic","Carrois Gothic SC","Carter One","Caudex","Cedarville Cursive","Ceviche One","Changa One","Chango","Chau Philomene One","Chela One","Chelsea Market","Chenla","Cherry Cream Soda","Cherry Swash","Chewy","Chicle","Chivo","Cinzel","Cinzel Decorative","Clicker Script","Coda","Coda Caption:800","Codystar","Combo","Comfortaa","Coming Soon","Concert One","Condiment","Content","Contrail One","Convergence","Cookie","Copse","Corben","Courgette","Cousine","Coustard","Covered By Your Grace","Crafty Girls","Creepster","Crete Round","Crimson Text","Croissant One","Crushed","Cuprum","Cutive","Cutive Mono","Damion","Dancing Script","Dangrek","Dawning of a New Day","Days One","Delius","Delius Swash Caps","Delius Unicase","Della Respira","Denk One","Devonshire","Didact Gothic","Diplomata","Diplomata SC","Domine","Donegal One","Doppio One","Dorsa","Dosis","Dr Sugiyama","Droid Sans","Droid Sans Mono","Droid Serif","Duru Sans","Dynalight","EB Garamond","Eagle Lake","Eater","Economica","Electrolize","Elsie","Elsie Swash Caps","Emblema One","Emilys Candy","Engagement","Englebert","Enriqueta","Erica One","Esteban","Euphoria Script","Ewert","Exo","Expletus Sans","Fanwood Text","Fascinate","Fascinate Inline","Faster One","Fasthand","Federant","Federo","Felipa","Fenix","Finger Paint","Fjalla One","Fjord One","Flamenco","Flavors","Fondamento","Fontdiner Swanky","Forum","Francois One","Freckle Face","Fredericka the Great","Fredoka One","Freehand","Fresca","Frijole","Fruktur","Fugaz One","GFS Didot","GFS Neohellenic","Gabriela","Gafata","Galdeano","Galindo","Gentium Basic","Gentium Book Basic","Geo","Geostar","Geostar Fill","Germania One","Gilda Display","Give You Glory","Glass Antiqua","Glegoo","Gloria Hallelujah","Goblin One","Gochi Hand","Gorditas","Goudy Bookletter 1911","Graduate","Grand Hotel","Gravitas One","Great Vibes","Griffy","Gruppo","Gudea","Habibi","Hammersmith One","Hanalei","Hanalei Fill","Handlee","Hanuman","Happy Monkey","Headland One","Henny Penny","Herr Von Muellerhoff","Holtwood One SC","Homemade Apple","Homenaje","IM Fell DW Pica","IM Fell DW Pica SC","IM Fell Double Pica","IM Fell Double Pica SC","IM Fell English","IM Fell English SC","IM Fell French Canon","IM Fell French Canon SC","IM Fell Great Primer","IM Fell Great Primer SC","Iceberg","Iceland","Imprima","Inconsolata","Inder","Indie Flower","Inika","Irish Grover","Istok Web","Italiana","Italianno","Jacques Francois","Jacques Francois Shadow","Jim Nightshade","Jockey One","Jolly Lodger","Josefin Sans","Josefin Slab","Joti One","Judson","Julee","Julius Sans One","Junge","Jura","Just Another Hand","Just Me Again Down Here","Kameron","Karla","Kaushan Script","Kavoon","Keania One","Kelly Slab","Kenia","Khmer","Kite One","Knewave","Kotta One","Koulen","Kranky","Kreon","Kristi","Krona One","La Belle Aurore","Lancelot","Lato","League Script","Leckerli One","Ledger","Lekton","Lemon","Libre Baskerville","Life Savers","Lilita One","Limelight","Linden Hill","Lobster","Lobster Two","Londrina Outline","Londrina Shadow","Londrina Sketch","Londrina Solid","Lora","Love Ya Like A Sister","Loved by the King","Lovers Quarrel","Luckiest Guy","Lusitana","Lustria","Macondo","Macondo Swash Caps","Magra","Maiden Orange","Mako","Marcellus","Marcellus SC","Marck Script","Margarine","Marko One","Marmelad","Marvel","Mate","Mate SC","Maven Pro","McLaren","Meddon","MedievalSharp","Medula One","Megrim","Meie Script","Merienda","Merienda One","Merriweather","Merriweather Sans","Metal","Metal Mania","Metamorphous","Metrophobic","Michroma","Milonga","Miltonian","Miltonian Tattoo","Miniver","Miss Fajardose","Modern Antiqua","Molengo","Molle:italic","Monda","Monofett","Monoton","Monsieur La Doulaise","Montaga","Montez","Montserrat","Montserrat Alternates","Montserrat Subrayada","Moul","Moulpali","Mountains of Christmas","Mouse Memoirs","Mr Bedfort","Mr Dafoe","Mr De Haviland","Mrs Saint Delafield","Mrs Sheppards","Muli","Mystery Quest","Neucha","Neuton","New Rocker","News Cycle","Niconne","Nixie One","Nobile","Nokora","Norican","Nosifer","Nothing You Could Do","Noticia Text","Noto Sans","Noto Serif","Nova Cut","Nova Flat","Nova Mono","Nova Oval","Nova Round","Nova Script","Nova Slim","Nova Square","Numans","Nunito","Odor Mean Chey","Offside","Old Standard TT","Oldenburg","Oleo Script","Oleo Script Swash Caps","Open Sans","Open Sans Condensed:300","Open Sans Condensed:300italic","Open Sans Condensed:700","Oranienbaum","Orbitron","Oregano","Orienta","Original Surfer","Oswald","Over the Rainbow","Overlock","Overlock SC","Ovo","Oxygen","Oxygen Mono","PT Mono","PT Sans","PT Sans Caption","PT Sans Narrow","PT Serif","PT Serif Caption","Pacifico","Paprika","Parisienne","Passero One","Passion One","Patrick Hand","Patrick Hand SC","Patua One","Paytone One","Peralta","Permanent Marker","Petit Formal Script","Petrona","Philosopher","Piedra","Pinyon Script","Pirata One","Plaster","Play","Playball","Playfair Display","Playfair Display SC","Podkova","Poiret One","Poller One","Poly","Pompiere","Pontano Sans","Port Lligat Sans","Port Lligat Slab","Prata","Preahvihear","Press Start 2P","Princess Sofia","Prociono","Prosto One","Puritan","Purple Purse","Quando","Quantico","Quattrocento","Quattrocento Sans","Questrial","Quicksand","Quintessential","Qwigley","Racing Sans One","Radley","Raleway","Raleway Dots","Rambla","Rammetto One","Ranchers","Rancho","Rationale","Redressed","Reenie Beanie","Revalia","Ribeye","Ribeye Marrow","Righteous","Risque","Roboto","Roboto Condensed","Roboto Slab","Rochester","Rock Salt","Rokkitt","Romanesco","Ropa Sans","Rosario","Rosarivo","Rouge Script","Ruda","Rufina","Ruge Boogie","Ruluko","Rum Raisin","Ruslan Display","Russo One","Ruthie","Rye","Sacramento","Sail","Salsa","Sanchez","Sancreek","Sansita One","Sarina","Satisfy","Scada","Schoolbell","Seaweed Script","Sevillana","Seymour One","Shadows Into Light","Shadows Into Light Two","Shanti","Share","Share Tech","Share Tech Mono","Shojumaru","Short Stack","Siemreap","Sigmar One","Signika","Signika Negative","Simonetta","Sintony","Sirin Stencil","Six Caps","Skranji","Slackey","Smokum","Smythe","Sniglet:800","Snippet","Snowburst One","Sofadi One","Sofia","Sonsie One","Sorts Mill Goudy","Source Code Pro","Source Sans Pro","Special Elite","Spicy Rice","Spinnaker","Spirax","Squada One","Stalemate","Stalinist One","Stardos Stencil","Stint Ultra Condensed","Stint Ultra Expanded","Stoke","Strait","Sue Ellen Francisco","Sunshiney","Supermercado One","Suwannaphum","Swanky and Moo Moo","Syncopate","Tangerine","Taprom","Tauri","Telex","Tenor Sans","Text Me One","The Girl Next Door","Tienne","Tinos","Titan One","Titillium Web","Trade Winds","Trocchi","Trochut","Trykker","Tulpen One","Ubuntu","Ubuntu Condensed","Ubuntu Mono","Ultra","Uncial Antiqua","Underdog","Unica One","UnifrakturCook:700","UnifrakturMaguntia","Unkempt","Unlock","Unna","VT323","Vampiro One","Varela","Varela Round","Vast Shadow","Vibur","Vidaloka","Viga","Voces","Volkhov","Vollkorn","Voltaire","Waiting for the Sunrise","Wallpoet","Walter Turncoat","Warnes","Wellfleet","Wendy One","Wire One","Yanone Kaffeesatz","Yellowtail","Yeseva One","Yesteryear","Zeyada"]}
yit-common/assets/js/yith-panel.js ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($){
2
+
3
+ //image uploader
4
+ var _custom_media = true,
5
+ _orig_send_attachment = wp.media.editor.send.attachment;
6
+
7
+ $('.uploader .button').click(function(e) {
8
+ var send_attachment_bkp = wp.media.editor.send.attachment;
9
+ var button = $(this);
10
+ var id = button.attr('id').replace('_button', '');
11
+ _custom_media = true;
12
+ wp.media.editor.send.attachment = function(props, attachment){
13
+ if ( _custom_media ) {
14
+ $("#"+id).val(attachment.url);
15
+ } else {
16
+ return _orig_send_attachment.apply( this, [props, attachment] );
17
+ };
18
+ }
19
+
20
+ wp.media.editor.open(button);
21
+ return false;
22
+ });
23
+
24
+ $('.add_media').on('click', function(){
25
+ _custom_media = false;
26
+ });
27
+
28
+ //color-picker
29
+ $('.panel-colorpicker').wpColorPicker({
30
+ change: function(event, ui){
31
+ $('#'+event.target.id).parents('.typography_container').find('.font-preview > p').css('color', ui.color.toString());
32
+ }
33
+ });
34
+
35
+ //typography
36
+ $('.typography_container').yit_panel_typography();
37
+
38
+ //datepicker
39
+ $('.panel-datepicker').datepicker({
40
+ showOtherMonths: true,
41
+ selectOtherMonths: true,
42
+ numberOfMonths: 2,
43
+ minDate: 0
44
+ });
45
+
46
+ //skin
47
+ $('select.skin').on('change', function(){
48
+ var img_path = $(this).data('path');
49
+ $(this).siblings('.skin-preview').html('<img src="'+ img_path + $(this).val() + '.jpg' +'" alt="preview" />');
50
+ }).change();
51
+ });
52
+
53
+ // typography
54
+ (function( window, $, undefined ) {
55
+
56
+ $.yit_panel_typography = function( options, element ) {
57
+ this.element = $( element );
58
+ this._init( options );
59
+ };
60
+
61
+ $.yit_panel_typography.defaults = {
62
+ elements : {
63
+ size: '.typography_size',
64
+ unit: '.typography_unit',
65
+ family: '.typography_family',
66
+ style: '.typography_style',
67
+ color: '.typography_color',
68
+ preview: '.font-preview p',
69
+ refresh: '.refresh'
70
+ }
71
+ };
72
+
73
+ $.yit_panel_typography.prototype = {
74
+ _init : function( options ) {
75
+ this.options = $.extend( true, {}, $.yit_panel_typography.defaults, options );
76
+
77
+ //init the options string
78
+ if( yit_family_string == '' ) {
79
+ //web fonts
80
+ var web_fonts = $.parseJSON(yit_web_fonts);
81
+ yit_family_string += '<optgroup label="Web Fonts">';
82
+ $.each(web_fonts.items, function(i,v){
83
+ yit_family_string += '<option>' + v + '</option>';
84
+ });
85
+ yit_family_string += '</optgroup>';
86
+
87
+ //google fonts
88
+ var google_fonts = $.parseJSON(yit_google_fonts);
89
+ yit_family_string += '<optgroup label="Google Fonts">';
90
+ $.each(google_fonts.items, function(i,v){
91
+ yit_family_string += '<option>' + v + '</option>';
92
+ });
93
+ yit_family_string += '</optgroup>';
94
+ }
95
+
96
+ this._loadElements();
97
+ this._initEvents();
98
+ },
99
+
100
+ _loadElements : function() {
101
+ var elements = this.options.elements;
102
+ var container = this.element;
103
+
104
+ for( var el in elements) {
105
+ elements[el] = container.find( elements[el] );
106
+ }
107
+ },
108
+
109
+ _initEvents : function() {
110
+ var elements = this.options.elements;
111
+ var self = this;
112
+
113
+ //refresh
114
+ var refresh = elements.refresh;
115
+ refresh.on('click', function(e){
116
+ e.preventDefault();
117
+
118
+ $(this).parent().fadeOut( 'slow' );
119
+
120
+ //Set current value, before trigger change event
121
+
122
+ //Color
123
+ elements.preview.css( 'color', elements.color.val() );
124
+
125
+ //Font size
126
+ var size = elements.size.val();
127
+ var unit = elements.unit.val();
128
+
129
+ elements.preview.css( 'font-size', size + unit );
130
+ elements.preview.css( 'line-height', ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit );
131
+
132
+ //Font style
133
+ var style = elements.style.val();
134
+
135
+ if( style == 'italic' ) {
136
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
137
+ } else if( style == 'bold' ) {
138
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
139
+ } else if( style == 'extra-bold' ) {
140
+ elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
141
+ } else if( style == 'bold-italic' ) {
142
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
143
+ } else {
144
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
145
+ }
146
+
147
+ //Font Family
148
+ var group = elements.family.find( 'option:selected' ).parent().attr( 'label' );
149
+
150
+ if( group == 'Web fonts' ) {
151
+ //Web font
152
+ elements.preview.css( 'font-family', elements.family.val() );
153
+ } else {
154
+ //Google font
155
+ WebFontConfig = {
156
+ google: {
157
+ families: [ elements.family.find('option:selected' ).text() ] },
158
+ fontactive: function( fontFamily, fontDescription ) {
159
+ elements.preview.css( 'font-family', fontFamily );
160
+ }
161
+ };
162
+
163
+ (function() {
164
+ var wf = document.createElement('script');
165
+ wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
166
+ '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
167
+ wf.type = 'text/javascript';
168
+ wf.async = 'true';
169
+
170
+ var s = document.getElementsByTagName('script')[0];
171
+ s.parentNode.insertBefore(wf, s);
172
+ })();
173
+ }
174
+ });
175
+
176
+ //font size, font unit
177
+ $([elements.size, elements.unit]).each(function(){
178
+ $(this).on('change', function(){
179
+ if( elements.refresh.is( ':visible' ) ) { return; }
180
+
181
+ var size = elements.size.val();
182
+ var unit = elements.unit.val();
183
+
184
+ elements.preview.css({
185
+ 'font-size' : size + unit,
186
+ 'line-height' : ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit
187
+ }).trigger( 'resize' );
188
+ });
189
+ });
190
+
191
+ //font family
192
+ var family = elements.family;
193
+ family.on('mousedown', function(e){
194
+ var t = $(this);
195
+ if(t.data('instance') == false) {
196
+ var currentElement = {
197
+ 'value' : t.val(),
198
+ 'text' : t.find('option:selected').text()
199
+ };
200
+
201
+ t.html(yit_family_string)
202
+ .find('option')
203
+ .filter(function(){
204
+ return $(this).text() == currentElement.text;
205
+ }).attr('selected', true);
206
+
207
+ t.data('instance', 'true');
208
+ }
209
+ });
210
+ family.on('change', function(){
211
+ if( elements.refresh.is( ':visible' ) ) { return; }
212
+
213
+ var group = $( this ).find( 'option:selected' ).parent().attr( 'label' );
214
+
215
+ if( group == 'Web fonts' ) {
216
+ //Web font
217
+ elements.preview.css( 'font-family', $( this ).val() );
218
+ } else {
219
+ //Google font
220
+ WebFontConfig = {
221
+ google: {
222
+ families: [ $( this ).val() ]
223
+ },
224
+ fontactive: function( fontFamily, fontDescription ) {
225
+ elements.preview.css( 'font-family', fontFamily );
226
+ }
227
+ };
228
+
229
+ (function() {
230
+ var wf = document.createElement('script');
231
+ wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
232
+ '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
233
+ wf.type = 'text/javascript';
234
+ wf.async = 'true';
235
+
236
+ var s = document.getElementsByTagName('script')[0];
237
+ s.parentNode.insertBefore(wf, s);
238
+ })();
239
+ }
240
+
241
+ elements.preview.trigger( 'resize' );
242
+ });
243
+
244
+ elements.style.on('change', function(){
245
+ if( elements.refresh.is( ':visible' ) ) { return; }
246
+
247
+ var style = $( this ).val();
248
+
249
+ if( style == 'italic' ) {
250
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
251
+ } else if( style == 'bold' ) {
252
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
253
+ } else if( style == 'extra-bold' ) {
254
+ elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
255
+ } else if( style == 'bold-italic' ) {
256
+ elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
257
+ } else {
258
+ elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
259
+ }
260
+
261
+ elements.preview.trigger( 'resize' );
262
+ });
263
+
264
+ //preview
265
+ elements.preview.resize(function(){
266
+ var box = $(this).parents('.yit-box');
267
+ $(this).parents('form').height( box.height() );
268
+ });
269
+ }
270
+ };
271
+
272
+ $.fn.yit_panel_typography = function( options ) {
273
+ if ( typeof options === 'string' ) {
274
+ var args = Array.prototype.slice.call( arguments, 1 );
275
+
276
+ this.each(function() {
277
+ var instance = $.data( this, 'yit_panel_typography' );
278
+ if ( !instance ) {
279
+ console.error( "cannot call methods on yit_checkout prior to initialization; " +
280
+ "attempted to call method '" + options + "'" );
281
+ return;
282
+ }
283
+ if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
284
+ console.error( "no such method '" + options + "' for yit_panel_typography instance" );
285
+ return;
286
+ }
287
+ instance[ options ].apply( instance, args );
288
+ });
289
+ }
290
+ else {
291
+ this.each(function() {
292
+ var instance = $.data( this, 'yit_panel_typography' );
293
+ if ( !instance ) {
294
+ $.data( this, 'yit_panel_typography', new $.yit_panel_typography( options, this ) );
295
+ }
296
+ });
297
+ }
298
+ return this;
299
+ };
300
+
301
+
302
+ })( window, jQuery );
yit-common/google_fonts.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google font management
4
+ */
5
+
6
+ $yith_google_fonts = new Google_Font();
7
+
8
+ class Google_Font {
9
+
10
+ /**
11
+ * @var array The google fonts to include in the page
12
+ */
13
+ public $google_fonts = array();
14
+
15
+ /**
16
+ * Generate the url for the google fonts
17
+ */
18
+ public function google_fonts_url() {
19
+ $base_url = 'http://fonts.googleapis.com/css?family=';
20
+ $fonts = array();
21
+
22
+ if ( empty( $this->google_fonts ) ) return;
23
+
24
+ foreach ( $this->google_fonts as $font => $variants ) {
25
+ $fonts[] = urlencode( $font . ':' . implode( ',', $variants ) );
26
+ }
27
+
28
+ return $base_url . implode( '|', $fonts );
29
+ }
30
+
31
+ /**
32
+ * Add a new google font in queue
33
+ *
34
+ * @param $font The name of google font
35
+ * @param array $variants The variatns for the google font to add
36
+ */
37
+ public function add_google_font( $font, $variants = array() ) {
38
+ if ( ! is_array( $variants ) ) $variants = array( $variants );
39
+
40
+ foreach ( $variants as $variant ) {
41
+ if ( ! isset( $this->google_fonts[$font] ) ) $this->google_fonts[$font] = array( 300, 400 );
42
+ if ( ! in_array( $variant, $this->google_fonts[$font] ) ) $this->google_fonts[$font][] = $variant;
43
+ }
44
+ }
45
+ }
46
+
47
+ if ( ! function_exists( 'yith_add_google_font' ) ) {
48
+ /**
49
+ * Add a new google font in queue
50
+ *
51
+ * @param $font The name of google font
52
+ * @param array $variant The variatns for the google font to add
53
+ */
54
+ function yith_add_google_font( $font, $variant = array() ) {
55
+ global $yith_google_fonts;
56
+ $yith_google_fonts->add_google_font( $font, $variant );
57
+ }
58
+ }
59
+
60
+ if ( ! function_exists( 'yith_google_fonts_url' ) ) {
61
+ /**
62
+ * @return string The url with the google fonts to load
63
+ */
64
+ function yith_google_fonts_url() {
65
+ global $yith_google_fonts;
66
+ return $yith_google_fonts->google_fonts_url();
67
+ }
68
+ }
yit-common/yit-functions.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Your Inspiration Themes common functions
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @version 0.0.1
7
+ */
8
+
9
+ if( !defined('YITH_FUNCTIONS')) {
10
+ define( 'YITH_FUNCTIONS', true);
11
+ }
12
+
13
+ if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
14
+ /**
15
+ * WC Detection
16
+ */
17
+ function yit_is_woocommerce_active() {
18
+ $active_plugins = (array) get_option( 'active_plugins', array() );
19
+
20
+ if ( is_multisite() ) {
21
+ $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
22
+ }
23
+
24
+ $woo = yit_get_plugin_basename_from_slug( 'woocommerce' );
25
+ return in_array( $woo, $active_plugins ) || array_key_exists( $woo, $active_plugins );
26
+ }
27
+ }
28
+
29
+ if( ! function_exists( 'yit_get_plugin_basename_from_slug' ) ) {
30
+ /**
31
+ * Helper function to extract the file path of the plugin file from the
32
+ * plugin slug, if the plugin is installed.
33
+ *
34
+ * @param string $slug Plugin slug (typically folder name) as provided by the developer
35
+ * @return string Either file path for plugin if installed, or just the plugin slug
36
+ */
37
+ function yit_get_plugin_basename_from_slug( $slug ) {
38
+ include_once ABSPATH . '/wp-admin/includes/plugin.php';
39
+
40
+ $keys = array_keys( get_plugins() );
41
+
42
+ foreach ( $keys as $key ) {
43
+ if ( preg_match( '|^' . $slug .'|', $key ) )
44
+ return $key;
45
+ }
46
+
47
+ return $slug;
48
+ }
49
+ }
50
+
51
+ if( ! function_exists( 'yith_debug') ) {
52
+ /**
53
+ * Debug helper function. This is a wrapper for var_dump() that adds
54
+ * the <pre /> tags, cleans up newlines and indents, and runs
55
+ * htmlentities() before output.
56
+ *
57
+ * @param mixed $var The variable to dump.
58
+ * @param mixed $var2 The second variable to dump
59
+ * @param ...
60
+ * @return string
61
+ */
62
+ function yith_debug() {
63
+ $args = func_get_args();
64
+ if( !empty( $args ) ) {
65
+ foreach( $args as $k=>$arg ) {
66
+ // var_dump the variable into a buffer and keep the output
67
+ ob_start();
68
+ var_dump($arg);
69
+ $output = ob_get_clean();
70
+
71
+ // neaten the newlines and indents
72
+ $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
73
+
74
+ if(!extension_loaded('xdebug')) {
75
+ $output = htmlspecialchars($output, ENT_QUOTES);
76
+ }
77
+
78
+ $output = '<pre class="yit-debug">'
79
+ . '<strong>$param_' . ($k+1) . ": </strong>"
80
+ . $output
81
+ . '</pre>';
82
+ echo $output;
83
+ }
84
+ } else {
85
+ trigger_error("yit_debug() expects at least 1 parameter, 0 given.", E_USER_WARNING);
86
+ }
87
+
88
+ return $args;
89
+ }
90
+ }
91
+
92
+
93
+ if( ! function_exists('yit_get_options_from_prefix') ) {
94
+ /**
95
+ * Returns an array of all options that starts with a prefix
96
+ *
97
+ * @param string $prefix
98
+ * @return array
99
+ */
100
+ function yit_get_options_from_prefix( $prefix ) {
101
+ if( !$prefix ) return array();
102
+
103
+ global $wpdb;
104
+
105
+ $sql = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'";
106
+ $options = $wpdb->get_col( $sql );
107
+ $return = array();
108
+
109
+ foreach( $options as $option ) {
110
+ $return[$option] = get_option( $option );
111
+ }
112
+
113
+ return $return;
114
+ }
115
+ }
116
+
117
+ if( !function_exists('yit_wp_roles') ) {
118
+ /**
119
+ * Returns the roles of the site.
120
+ *
121
+ * @return array
122
+ * @since 1.0.0
123
+ */
124
+ function yit_wp_roles() {
125
+ global $wp_roles;
126
+
127
+ if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
128
+
129
+ $roles = array();
130
+ foreach( $wp_roles->roles as $k=>$role ) {
131
+ $roles[$k] = $role['name'];
132
+ }
133
+
134
+ return $roles;
135
+ }
136
+ }
137
+
138
+ if( !function_exists('yit_user_roles') ) {
139
+ /**
140
+ * Returns the roles of the user
141
+ *
142
+ * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
143
+ * @return array()
144
+ * @since 1.0.0
145
+ */
146
+ function yit_user_roles( $user_id = null ) {
147
+ if ( is_numeric( $user_id ) )
148
+ $user = get_userdata( $user_id );
149
+ else
150
+ $user = wp_get_current_user();
151
+
152
+ if ( empty( $user ) )
153
+ return false;
154
+
155
+ return (array) $user->roles;
156
+ }
157
+ }
158
+
159
+
160
+ // ADMIN
161
+ if( !function_exists('yit_typo_option_to_css') ) {
162
+ /**
163
+ * Change the typography option saved in database to attributes for css
164
+ *
165
+ * @param array $option The option as saved in the database
166
+ * @return string
167
+ * @since 1.0.0
168
+ */
169
+ function yit_typo_option_to_css( $option ) {
170
+ $attrs = $variant = array();
171
+
172
+ extract( $option );
173
+ $attrs[] = "color: $color;";
174
+ $attrs[] = "font-size: {$size}{$unit};";
175
+ $attrs[] = "font-family: '{$family}';";
176
+ switch ( $style ) {
177
+ case 'regular':
178
+ $attrs[] = 'font-weight: 400;';
179
+ $attrs[] = 'font-style: normal;';
180
+ $variant = 400;
181
+ break;
182
+ case 'bold':
183
+ $attrs[] = 'font-weight: 700;';
184
+ $attrs[] = 'font-style: normal;';
185
+ $variant = 700;
186
+ break;
187
+ case 'extra-bold':
188
+ $attrs[] = 'font-weight: 800;';
189
+ $attrs[] = 'font-style: normal;';
190
+ $variant = 800;
191
+ break;
192
+ case 'italic':
193
+ $attrs[] = 'font-weight: 400;';
194
+ $attrs[] = 'font-style: italic;';
195
+ $variant = 400;
196
+ break;
197
+ case 'bold-italic':
198
+ $attrs[] = 'font-weight: 700;';
199
+ $attrs[] = 'font-style: italic;';
200
+ $variant = 700;
201
+ break;
202
+ }
203
+
204
+ yith_add_google_font( $family, $variant );
205
+
206
+ return implode( "\n", $attrs ) . "\n";
207
+ }
208
+ }
209
+
210
+
211
+ if( !function_exists('yit_curPageURL') ) {
212
+ /**
213
+ * Retrieve the current complete url
214
+ *
215
+ * @since 1.0
216
+ */
217
+ function yit_curPageURL() {
218
+ $pageURL = 'http';
219
+ if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" )
220
+ $pageURL .= "s";
221
+
222
+ $pageURL .= "://";
223
+
224
+ if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" )
225
+ $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
226
+ else
227
+ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
228
+
229
+ return $pageURL;
230
+ }
231
+ }
yit-common/yith-panel.php ADDED
@@ -0,0 +1,514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Your Inspiration Themes Panel
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @version 0.1.0
7
+ */
8
+
9
+ if( !class_exists('YITH_Panel') ) {
10
+ /*
11
+ * The class manages the theme options for the Plugin
12
+ */
13
+ class YITH_Panel {
14
+
15
+ /**
16
+ * Class version
17
+ *
18
+ * @var string
19
+ */
20
+ public $version = '0.1.0';
21
+
22
+ /**
23
+ * Parameters for add_submenu_page
24
+ *
25
+ * add_submenu_page(
26
+ * 'themes.php', // The file name of a standard WordPress admin page
27
+ * 'Theme Options', // The text to be displayed in the title tags of the page when the menu is selected
28
+ * 'Theme Options', // The text to be used for the menu
29
+ * 'administrator', // The capability (or role) required for this menu to be displayed to the user.
30
+ * 'theme-options', // The slug name to refer to this menu by (should be unique for this menu).
31
+ * 'theme_options_display_page' // The function to be called to output the content for this page.
32
+ * );
33
+ *
34
+ * @access protected
35
+ */
36
+ protected $_submenu = array();
37
+
38
+ /**
39
+ * Initial Options definition:
40
+ * 'tab' => array(
41
+ * 'label',
42
+ * 'sections' => array(
43
+ * 'fields' => array(
44
+ * 'option1',
45
+ * 'option2',
46
+ * ...
47
+ * )
48
+ * )
49
+ * )
50
+ *
51
+ * @var array
52
+ * @access public
53
+ */
54
+ public $options = array();
55
+
56
+ /**
57
+ * Options group name
58
+ *
59
+ * @var string
60
+ * @access public
61
+ */
62
+ public $option_group = 'panel_group';
63
+
64
+ /**
65
+ * Option name
66
+ *
67
+ * @var string
68
+ * @access public
69
+ */
70
+ public $option_name = 'panel_options';
71
+
72
+ /**
73
+ * Banner links
74
+ *
75
+ * @var string
76
+ * @access public
77
+ */
78
+ public $banner_url = 'http://yithemes.com/?ap_id=plugin';
79
+ public $banner_img = '';
80
+
81
+ /**
82
+ * Constructor
83
+ *
84
+ * @param array $submenu Parameters for add_submenu_page
85
+ * @param array $options Array of plugin options
86
+ *
87
+ */
88
+ public function __construct( $submenu, $options, $banner = array(), $option_group = false, $option_name = false ) {
89
+ $this->_submenu = apply_filters('yith_panel_submenu', $submenu);
90
+ $this->options = apply_filters('yith_panel_options', $options);
91
+
92
+ if( !empty($banner) ) {
93
+ $this->banner_url = $banner['url'];
94
+ $this->banner_img = $banner['img'];
95
+ }
96
+
97
+ if( $option_group ) {
98
+ $this->option_group = $option_group;
99
+ }
100
+
101
+ if( $option_name ) {
102
+ $this->option_name = $option_name;
103
+ }
104
+
105
+ //add new menu item
106
+ //register new settings option group
107
+ //include js and css files
108
+ //print browser
109
+ add_action( 'admin_menu', array( $this, 'add_submenu_page') );
110
+ add_action( 'admin_init', array( $this, 'panel_register_setting') );
111
+ add_action( 'admin_enqueue_scripts', array( $this, 'panel_enqueue') );
112
+
113
+ // add the typography javascript vars
114
+ add_action( 'yith_panel_after_panel', array( $this, 'js_typo_vars' ) );
115
+ }
116
+
117
+ /**
118
+ * Create new submenu page
119
+ *
120
+ * @return void
121
+ * @access public
122
+ * @link http://codex.wordpress.org/Function_Reference/add_submenu_page
123
+ */
124
+ public function add_submenu_page() {
125
+ $submenu = $this->_submenu;
126
+ add_submenu_page(
127
+ $submenu[0],
128
+ $submenu[1],
129
+ $submenu[2],
130
+ $submenu[3],
131
+ $submenu[4],
132
+ array( $this, isset($submenu[5]) ? $submenu[5] : 'display_panel_page' )
133
+ );
134
+ }
135
+
136
+ /**
137
+ * Print the Panel page
138
+ *
139
+ * @return void
140
+ * @access public
141
+ */
142
+ public function display_panel_page() {
143
+ // Create a header in the default WordPress 'wrap' container
144
+ $page = $this->_get_tab();
145
+ ?>
146
+ <div id="icon-themes" class="icon32"><br /></div>
147
+ <h2 class="nav-tab-wrapper">
148
+ <?php foreach( $this->options as $k=>$tab ): ?>
149
+ <a class="nav-tab<?php if( $page == $k ): ?> nav-tab-active<?php endif ?>" href="<?php echo add_query_arg('panel_page', $k) ?>"><?php echo $tab['label'] ?></a>
150
+ <?php endforeach ?>
151
+ <?php do_action('yith_panel_after_tabs'); ?>
152
+ </h2>
153
+
154
+ <div class="wrap">
155
+ <?php $this->printBanner() ?>
156
+ <?php do_action('yith_panel_before_panel'); ?>
157
+ <form action="options.php" method="post">
158
+
159
+ <?php do_settings_sections( $this->option_name ); ?>
160
+ <?php settings_fields( $this->option_group ) ?>
161
+
162
+ <p class="submit">
163
+ <input type="hidden" name="panel_page" value="<?php echo $page ?>" />
164
+ <input class="button-primary" type="submit" name="save_options" value="Save Options" />
165
+ </p>
166
+ </form>
167
+ <?php do_action('yith_panel_after_panel'); ?>
168
+ </div>
169
+ <?php
170
+ }
171
+
172
+ /**
173
+ * Add the vars for the typography options
174
+ */
175
+ public function js_typo_vars() {
176
+ global $yith_panel_if_typography;
177
+ if ( ! isset( $yith_panel_if_typography ) || ! $yith_panel_if_typography ) return;
178
+
179
+ $web_fonts = array(
180
+ "Arial",
181
+ "Arial Black",
182
+ "Comic Sans MS",
183
+ "Courier New",
184
+ "Georgia",
185
+ "Impact",
186
+ "Lucida Console",
187
+ "Lucida Sans Unicode",
188
+ "Thaoma",
189
+ "Trebuchet MS",
190
+ "Verdana"
191
+ );
192
+
193
+ // http://niubbys.altervista.org/google_fonts.php
194
+ $google_fonts = file_get_contents( dirname(__FILE__) . '/assets/js/google_fonts.json' );
195
+ ?>
196
+ <script type="text/javascript">
197
+ var yit_google_fonts = '<?php echo $google_fonts ?>',
198
+ yit_web_fonts = '{"items":<?php echo json_encode( $web_fonts ) ?>}',
199
+ yit_family_string = '';
200
+ </script>
201
+ <?php
202
+ }
203
+
204
+ /**
205
+ * Register a new settings option group
206
+ *
207
+ * @return void
208
+ * @access public
209
+ * @link http://codex.wordpress.org/Function_Reference/register_setting
210
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_section
211
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_field
212
+ */
213
+ public function panel_register_setting() {
214
+ $page = $this->_get_tab();
215
+ $tab = isset( $this->options[$page] ) ? $this->options[$page] : array();
216
+
217
+ if( !empty($tab['sections']) ) {
218
+ //add sections and fields
219
+ foreach( $tab['sections'] as $section_name => $section) {
220
+ //add the section
221
+ add_settings_section(
222
+ $section_name,
223
+ $section['title'],
224
+ array( $this, 'panel_section_content'),
225
+ $this->option_name
226
+ );
227
+
228
+ //add the fields
229
+ foreach( $section['fields'] as $option_name => $option ) {
230
+ $option['id'] = $option_name;
231
+ $option['label_for'] = $option_name;
232
+
233
+ //register settings group
234
+ register_setting(
235
+ $this->option_group,
236
+ $option_name,
237
+ array( $this, 'panel_sanitize')
238
+ );
239
+
240
+ add_settings_field(
241
+ $option_name,
242
+ $option['title'],
243
+ array( $this, 'panel_field_content' ),
244
+ $this->option_name,
245
+ $section_name,
246
+ $option
247
+ );
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Display sections content
255
+ *
256
+ * @return void
257
+ * @access public
258
+ */
259
+ public function panel_section_content( $section ) {
260
+ $page = $this->_get_tab();
261
+ if( isset( $this->options[$page]['sections'][ $section['id'] ]['description'] )) {
262
+ echo "<p class='section-description'>" . $this->options[$page]['sections'][ $section['id'] ]['description'] . "</p>";
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Sanitize the option's value
268
+ *
269
+ * @param array $input
270
+ * @return array
271
+ * @access public
272
+ */
273
+ public function panel_sanitize( $input ) {
274
+ return apply_filters('yith_panel_sanitize', $input);
275
+ }
276
+
277
+ /**
278
+ * Get the active tab. If the page isn't provided, the function
279
+ * will return the first tab name
280
+ *
281
+ * @return string
282
+ * @access protected
283
+ */
284
+ public function _get_tab() {
285
+ if( isset($_POST['panel_page']) && $_POST['panel_page'] != '' ) {
286
+ return $_POST['panel_page'];
287
+ } elseif( isset($_GET['panel_page']) && $_GET['panel_page'] != '' ) {
288
+ return $_GET['panel_page'];
289
+ } else {
290
+ $tabs = array_keys( $this->options );
291
+ return $tabs[0];
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Enqueue scripts and styles
297
+ *
298
+ * @return void
299
+ * @access public
300
+ */
301
+ public function panel_enqueue( $hook ) {
302
+ global $pagenow;
303
+
304
+ if( $pagenow == $this->_submenu[0] && isset( $_GET['page'] ) && $_GET['page'] == $this->_submenu[4] ) {
305
+ wp_enqueue_style( 'wp-color-picker' );
306
+ wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css' );
307
+ wp_enqueue_script( 'jquery-ui-datepicker' );
308
+
309
+ wp_enqueue_style( 'yith-panel-css', plugin_dir_url( __FILE__ ) . 'assets/css/yith-panel.css', array('wp-color-picker'), $this->version );
310
+ wp_enqueue_script( 'yith-panel-js', plugin_dir_url( __FILE__ ) . 'assets/js/yith-panel.js', array( 'jquery', 'wp-color-picker' ), $this->version, true );
311
+
312
+ wp_enqueue_media();
313
+
314
+ do_action( 'yith_panel_enqueue' );
315
+ }
316
+ }
317
+
318
+
319
+ /**
320
+ * Display field content
321
+ *
322
+ * @return void
323
+ * @access public
324
+ */
325
+ public function panel_field_content( $field ) {
326
+ $value = get_option( $field['id'], isset($field['std']) ? $field['std'] : '' );
327
+ $id = $field['id'];
328
+ $name = $field['id'];
329
+
330
+ $echo = '';
331
+
332
+ switch( $field['type'] ) {
333
+ case 'text':
334
+ $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' />";
335
+
336
+ if( isset($field['description']) && $field['description'] != '' ) {
337
+ $echo .= "<p class='description'>{$field['description']}</p>";
338
+ }
339
+ break;
340
+
341
+ case 'textarea': $echo = "<textarea name='{$name}' id='{$id}' class='large-text code' rows='10' cols='50'>{$value}</textarea>";
342
+ if( isset($field['description']) && $field['description'] != '' ) {
343
+ $echo .= "<p class='description'>{$field['description']}</p>";
344
+ }
345
+ break;
346
+
347
+ case 'checkbox': $echo = "<input type='checkbox' id='{$id}' name='{$name}' value='1' ". checked($value, true, false) ." />";
348
+ if( isset($field['description']) && $field['description'] != '' ) {
349
+ $echo .= " <label for='{$id}'><span class='description'>{$field['description']}</span></label>";
350
+ }
351
+ break;
352
+
353
+ case 'select': $echo = "<select name='{$name}' id='{$id}'>";
354
+ foreach( $field['options'] as $v=>$label ) {
355
+ $echo .= "<option value='{$v}'". selected($value, $v, false) .">{$label}</option>";
356
+ }
357
+ $echo .= "</select>";
358
+ if( isset($field['description']) && $field['description'] != '' ) {
359
+ $echo .= "<p class='description'>{$field['description']}</p>";
360
+ }
361
+ break;
362
+
363
+ case 'skin': $echo = "<select name='{$name}' id='{$id}' class='skin' data-path='{$field['path']}'>";
364
+ foreach( $field['options'] as $v=>$label ) {
365
+ $echo .= "<option value='{$v}'". selected($value, $v, false) .">{$label}</option>";
366
+ }
367
+ $echo .= "</select>";
368
+ if( isset($field['description']) && $field['description'] != '' ) {
369
+ $echo .= "<p class='description'>{$field['description']}</p><div class='skin-preview'></div>";
370
+ }
371
+ break;
372
+
373
+ case 'number':
374
+ $mms = '';
375
+ if( isset( $field['min'] ) ) {
376
+ $mms .= " min='{$field['min']}'";
377
+ }
378
+
379
+ if( isset( $field['max'] ) ) {
380
+ $mms .= " max='{$field['max']}'";
381
+ }
382
+
383
+ if( isset( $field['step'] ) ) {
384
+ $mms .= " step='{$field['step']}'";
385
+ }
386
+
387
+ $echo = "<input type='number' id='{$id}' name='{$name}' value='{$value}' class='small-text' {$mms} />";
388
+ if( isset($field['description']) && $field['description'] != '' ) {
389
+ $echo .= "<p class='description'>{$field['description']}</p>";
390
+ }
391
+ break;
392
+
393
+ case 'colorpicker':
394
+ $std = isset( $field['std'] ) ? $field['std'] : '';
395
+
396
+ $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='medium-text code panel-colorpicker' data-default-color='{$std}' />";
397
+ if( isset($field['description']) && $field['description'] != '' ) {
398
+ $echo .= "<p class='description'>{$field['description']}</p>";
399
+ }
400
+ break;
401
+
402
+ case 'datepicker':
403
+ $std = isset( $field['std'] ) ? $field['std'] : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
404
+ $value = ! empty( $value ) ? $value : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
405
+
406
+ $echo = "<input type='text' id='{$id}_date' name='{$name}[date]' value='{$value['date']}' class='medium-text code panel-datepicker' colorpicker='" . __( 'Select a date', 'yit' ) . "' /> - ";
407
+ $echo .= "<input type='text' id='{$id}_hh' name='{$name}[hh]' value='{$value['hh']}' class='small-text code' colorpicker='" . __( 'Hours', 'yit' ) . "' /> : ";
408
+ $echo .= "<input type='text' id='{$id}_mm' name='{$name}[mm]' value='{$value['mm']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' /> : ";
409
+ $echo .= "<input type='text' id='{$id}_ss' name='{$name}[ss]' value='{$value['ss']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' />";
410
+ if( isset($field['description']) && $field['description'] != '' ) {
411
+ $echo .= "<p class='description'>{$field['description']}</p>";
412
+ }
413
+ break;
414
+
415
+ case 'upload':
416
+ $echo = '<div class="uploader">';
417
+ $echo .= " <input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' /> <input type='button' name='' id='{$id}_button' class='button' value='". __('Upload', 'yit') ."'>";
418
+ $echo .= '</div>';
419
+ if( isset($field['description']) && $field['description'] != '' ) {
420
+ $echo .= "<p class='description'>{$field['description']}</p>";
421
+ }
422
+ break;
423
+
424
+ case 'checkboxes':
425
+ $echo = '<div class="checkboxes">';
426
+ foreach ( $field['options'] as $check_value => $check_label ) {
427
+ $echo .= "<label><input type='checkbox' id='{$id}_{$check_value}' name='{$name}[]' value='$check_value' ". checked( in_array( $check_value, $value ), true, false) ." /> {$check_label}</label><br />";
428
+ }
429
+
430
+ $echo .= " <p class='description'>{$field['description']}</p>";
431
+ break;
432
+
433
+ case 'typography': $value = wp_parse_args( $value, $field['std'] ); ?>
434
+ <div class="typography_container typography">
435
+ <div class="option">
436
+ <!-- Size -->
437
+ <div class="spinner_container">
438
+ <input class="typography_size number small-text" type="number" name="<?php echo $name ?>[size]" id="<?php echo $id ?>-size" value="<?php echo $value['size'] ?>" data-min="<?php if(isset( $field['min'] )) echo $field['min'] ?>" data-max="<?php if(isset( $field['max'] )) echo $field['max'] ?>" />
439
+ </div>
440
+
441
+ <!-- Unit -->
442
+ <div class="select-wrapper font-unit">
443
+ <select class="typography_unit" name="<?php echo $name ?>[unit]" id="<?php echo $id ?>-unit">
444
+ <option value="px" <?php selected( $value['unit'], 'px' ) ?>><?php _e( 'px', 'yit' ) ?></option>
445
+ <option value="em" <?php selected( $value['unit'], 'em' ) ?>><?php _e( 'em', 'yit' ) ?></option>
446
+ <option value="pt" <?php selected( $value['unit'], 'pt' ) ?>><?php _e( 'pt', 'yit' ) ?></option>
447
+ <option value="rem" <?php selected( $value['unit'], 'rem' ) ?>><?php _e( 'rem', 'yit' ) ?></option>
448
+ </select>
449
+ </div>
450
+
451
+ <!-- Family -->
452
+ <div class="select-wrapper font-family">
453
+ <select class="typography_family" name="<?php echo $name ?>[family]" id="<?php echo $id ?>-family" data-instance="false">
454
+ <?php if( $value['family'] ): ?>
455
+ <option value="<?php echo stripslashes( $value['family'] ) ?>"><?php echo $value['family'] ?></option>
456
+ <?php else: ?>
457
+ <option value=""><?php _e('Select a font family', 'yit') ?></option>
458
+ <?php endif ?>
459
+ </select>
460
+ </div>
461
+
462
+ <!-- Style -->
463
+ <div class="select-wrapper font-style">
464
+ <select class="typography_style" name="<?php echo $name ?>[style]" id="<?php echo $id ?>-style">
465
+ <option value="regular" <?php selected( $value['style'], 'regular' ) ?>><?php _e( 'Regular', 'yit' ) ?></option>
466
+ <option value="bold" <?php selected( $value['style'], 'bold' ) ?>><?php _e( 'Bold', 'yit' ) ?></option>
467
+ <option value="extra-bold" <?php selected( $value['style'], 'extra-bold' ) ?>><?php _e( 'Extra bold', 'yit' ) ?></option>
468
+ <option value="italic" <?php selected( $value['style'], 'italic' ) ?>><?php _e( 'Italic', 'yit' ) ?></option>
469
+ <option value="bold-italic" <?php selected( $value['style'], 'bold-italic' ) ?>><?php _e( 'Italic bold', 'yit' ) ?></option>
470
+ </select>
471
+ </div>
472
+
473
+ <!-- Color -->
474
+ <input type='text' id='<?php echo $id ?>-color' name='<?php echo $name ?>[color]' value='<?php echo $value['color'] ?>' class='medium-text code panel-colorpicker typography_color' data-default-color='<?php echo $field['std']['color'] ?>' />
475
+
476
+ </div>
477
+ <div class="clear"></div>
478
+ <div class="font-preview">
479
+ <p>The quick brown fox jumps over the lazy dog</p>
480
+ <!-- Refresh -->
481
+ <div class="refresh_container"><button class="refresh"><?php _e( 'Click to preview', 'yit' ) ?></button></div>
482
+ </div>
483
+ </div>
484
+ <?php
485
+ global $yith_panel_if_typography;
486
+ $yith_panel_if_typography = true;
487
+ break;
488
+
489
+ default:
490
+ do_action('yith_panel_field_' . $field['type']);
491
+ break;
492
+ }
493
+
494
+ echo $echo;
495
+ }
496
+
497
+ /**
498
+ * Print the banner
499
+ *
500
+ * @access protected
501
+ * @return void
502
+ */
503
+ public function printBanner() {
504
+ if( !$this->banner_url || !$this->banner_img ) return;
505
+ ?>
506
+ <div class="yith_banner">
507
+ <a href="<?php echo $this->banner_url ?>" target="_blank">
508
+ <img src="<?php echo $this->banner_img ?>" alt="" />
509
+ </a>
510
+ </div>
511
+ <?php
512
+ }
513
+ }
514
+ }