OptionTree - Version 1.1

Version Description

  • Fixed the Undefined index: notices when WP_DEBUG is set to true
Download this release

Release Info

Developer valendesigns
Plugin Icon wp plugin OptionTree
Version 1.1
Comparing to
See all releases

Version 1.1

Files changed (70) hide show
  1. assets/css/style-classic.css +58 -0
  2. assets/css/style.css +948 -0
  3. assets/images/black_px.png +0 -0
  4. assets/images/btn.png +0 -0
  5. assets/images/colorpicker/color_bg.png +0 -0
  6. assets/images/colorpicker/color_hex.png +0 -0
  7. assets/images/colorpicker/color_hsb_b.png +0 -0
  8. assets/images/colorpicker/color_hsb_h.png +0 -0
  9. assets/images/colorpicker/color_hsb_s.png +0 -0
  10. assets/images/colorpicker/color_indicator.png +0 -0
  11. assets/images/colorpicker/color_overlay.png +0 -0
  12. assets/images/colorpicker/color_rgb_b.png +0 -0
  13. assets/images/colorpicker/color_rgb_g.png +0 -0
  14. assets/images/colorpicker/color_rgb_r.png +0 -0
  15. assets/images/colorpicker/color_select.gif +0 -0
  16. assets/images/colorpicker/color_wheel.png +0 -0
  17. assets/images/empty.gif +0 -0
  18. assets/images/header.png +0 -0
  19. assets/images/header_classic.png +0 -0
  20. assets/images/icon_add.png +0 -0
  21. assets/images/icon_arrow.png +0 -0
  22. assets/images/icon_classic.png +0 -0
  23. assets/images/icon_dark.png +0 -0
  24. assets/images/icon_delete.png +0 -0
  25. assets/images/icon_edit.png +0 -0
  26. assets/images/icon_error.png +0 -0
  27. assets/images/icon_header.png +0 -0
  28. assets/images/icon_option.png +0 -0
  29. assets/images/icon_option_classic.png +0 -0
  30. assets/images/icon_up_down.png +0 -0
  31. assets/images/logo_classic.png +0 -0
  32. assets/images/logo_dark.png +0 -0
  33. assets/images/pre_bg.gif +0 -0
  34. assets/images/pre_classic_bg.gif +0 -0
  35. assets/images/select.png +0 -0
  36. assets/images/tabs_bg.png +0 -0
  37. assets/images/tabs_bg_classic.png +0 -0
  38. assets/images/toggle_tabs.png +0 -0
  39. assets/images/white_px.png +0 -0
  40. assets/js/jquery.color.picker.js +455 -0
  41. assets/js/jquery.option.tree.js +752 -0
  42. assets/js/jquery.table.dnd.js +382 -0
  43. assets/test/test-data.txt +1 -0
  44. assets/test/test-options.xml +175 -0
  45. classes/class.admin.php +1113 -0
  46. front-end/docs.php +324 -0
  47. front-end/options.php +90 -0
  48. front-end/settings.php +264 -0
  49. functions/admin/category.php +112 -0
  50. functions/admin/checkbox.php +56 -0
  51. functions/admin/colorpicker.php +54 -0
  52. functions/admin/custom-post.php +112 -0
  53. functions/admin/export.php +70 -0
  54. functions/admin/heading.php +20 -0
  55. functions/admin/input.php +29 -0
  56. functions/admin/page.php +112 -0
  57. functions/admin/post.php +112 -0
  58. functions/admin/radio.php +56 -0
  59. functions/admin/select.php +45 -0
  60. functions/admin/tag.php +112 -0
  61. functions/admin/textarea.php +32 -0
  62. functions/admin/textblock.php +26 -0
  63. functions/admin/upload.php +50 -0
  64. functions/functions.load.php +31 -0
  65. functions/get-option-tree.php +46 -0
  66. index.php +63 -0
  67. readme.txt +46 -0
  68. screenshot-1.png +0 -0
  69. screenshot-2.png +0 -0
  70. screenshot-3.png +0 -0
assets/css/style-classic.css ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ a strong {
2
+ color: #1C6280 !important;
3
+ }
4
+ #framework_wrap #header {
5
+ background: #436d92 url(../images/header_classic.png) repeat-x left top;
6
+ border: 1px solid #1d507d;
7
+ }
8
+ #framework_wrap #header h1 {
9
+ background: url(../images/logo_classic.png) no-repeat 0 0;
10
+ }
11
+ #framework_wrap #header div.version {
12
+ color: #1a4b76;
13
+ text-shadow: 0 1px 0 #6694bd;
14
+ }
15
+ #framework_wrap #header span.icon {
16
+ background-image: url(../images/icon_option_classic.png);
17
+ }
18
+ #framework_wrap #content_wrap .info {
19
+ background: #f4f3ed;
20
+ border-bottom: 1px solid #dfdfdf;
21
+ }
22
+ #framework_wrap #content {
23
+ border-bottom: 1px solid #dfdfdf;
24
+ }
25
+ #framework_wrap #content .has-table table th {
26
+ background: #f4f3ee;
27
+ background-image: -moz-linear-gradient(top, #fdfdfc, #f4f3ee);
28
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#fdfdfc), to(#f4f3ee));
29
+ }
30
+ .has-table table .col-heading {
31
+ background: #f7f6f1;
32
+ }
33
+ tbody tr.inline-edit-option td {
34
+ background: #eaf3fa;
35
+ }
36
+ #framework_wrap #content tbody tr.inline-edit-option td h3 {
37
+ border-bottom-color: #dae1e8;
38
+ }
39
+ #framework_wrap code {
40
+ background-color: #eaf3fa;
41
+ }
42
+ #framework_wrap pre {
43
+ background: #eaf3fa;
44
+ border-bottom: 1px solid #eaf3fa;
45
+ }
46
+ #framework_wrap pre code {
47
+ background-image: url(../images/pre_classic_bg.gif);
48
+ }
49
+ .ui-tabs {
50
+ background-image: url(../images/tabs_bg_classic.png);
51
+ }
52
+ .ui-tabs .ui-tabs-nav li a {
53
+ border-bottom: 1px solid #dfdfdf;
54
+ }
55
+ .ui-tabs .ui-tabs-nav li.ui-state-hover a {
56
+ background-color: #f1f8fd;
57
+ color: #555;
58
+ }
assets/css/style.css ADDED
@@ -0,0 +1,948 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* OptionTree */
2
+ #wpwrap {
3
+ min-width: 990px;
4
+ }
5
+ strong {
6
+ color: #000;
7
+ }
8
+ .clear {
9
+ clear: both;
10
+ }
11
+ .hide,
12
+ #contextual-help-link-wrap {
13
+ display: none;
14
+ }
15
+ .left {
16
+ float: left !important;
17
+ }
18
+ .right {
19
+ float: right !important;
20
+ }
21
+ p {
22
+ padding-bottom: 14px;
23
+ }
24
+ a {
25
+ text-decoration: none;
26
+ }
27
+ a strong {
28
+ color: #21759B !important;
29
+ }
30
+ a:hover strong {
31
+ color: #d54e21 !important;
32
+ }
33
+ #framework_wrap #header .error {
34
+ display: none !important;
35
+ }
36
+ #framework_wrap {
37
+ position: relative;
38
+ width: 788px;
39
+ margin: 15px;
40
+ }
41
+ #framework_wrap #header {
42
+ -webkit-border-top-left-radius: 8px;
43
+ -webkit-border-top-right-radius: 8px;
44
+ -moz-border-radius-topleft: 8px;
45
+ -moz-border-radius-topright: 8px;
46
+ border-top-left-radius: 8px;
47
+ border-top-right-radius: 8px;
48
+ background: #6d6d6d url(../images/header.png) repeat-x left top;
49
+ border: 1px solid #555;
50
+ height: 71px;
51
+ width: 785px;
52
+ position: relative;
53
+ }
54
+ #framework_wrap #header h1 {
55
+ width: 150px;
56
+ height: 31px;
57
+ background: url(../images/logo_dark.png) no-repeat 0 0;
58
+ text-indent: -9999px;
59
+ margin: 20px 0 0 20px;
60
+ }
61
+ #framework_wrap #header span.icon {
62
+ position: absolute;
63
+ display: block;
64
+ right: 20px;
65
+ top: 18px;
66
+ height: 32px;
67
+ width: 32px;
68
+ text-indent: -9999px;
69
+ background: url(../images/icon_option.png) no-repeat left center;
70
+ }
71
+ #framework_wrap #header div.version {
72
+ text-align: left;
73
+ position: absolute;
74
+ left: 170px;
75
+ top: 32px;
76
+ font-size: 9px !important;
77
+ line-height: 10px;
78
+ color: #444;
79
+ font-style: normal;
80
+ font-family: Verdana,Arial,sans-serif;
81
+ text-transform: uppercase;
82
+ font-weight: normal;
83
+ text-shadow: 0 1px 0 #888;
84
+ letter-spacing: -0.05em;
85
+ }
86
+ #framework_wrap #content_wrap {
87
+ border: 1px solid #aaa;
88
+ border-top: none;
89
+ background: #fff;
90
+ width: 785px;
91
+ position: relative;
92
+ }
93
+ #framework_wrap #content_wrap .info {
94
+ background: #eaf2fa;
95
+ background: #f9f9f9;
96
+ height: 35px;
97
+ border-top: 1px solid #fff;
98
+ border-bottom: 1px solid #e3e3e3;
99
+ }
100
+ a.toggle_tabs {
101
+ cursor: pointer;
102
+ background: url(../images/toggle_tabs.png) no-repeat -2px -1px;
103
+ display: block;
104
+ height: 22px;
105
+ width: 21px;
106
+ float: left;
107
+ text-indent: -9999px;
108
+ margin: 5px 5px 0 19px;
109
+ border: 1px solid #bbb;
110
+ -webkit-border-radius: 4px;
111
+ -moz-border-radius: 4px;
112
+ border-radius: 4px;
113
+ }
114
+ .no-tabs a.toggle_tabs {
115
+ display: none;
116
+ }
117
+ a:hover.toggle_tabs {
118
+ border-color: #666;
119
+ }
120
+ a.off {
121
+ background-position: -2px -26px;
122
+ }
123
+ #framework_wrap #content_wrap .bottom {
124
+ border-top: 1px solid #fff !important;
125
+ border-bottom: none !important;
126
+
127
+ background: #f1f1f1;
128
+ }
129
+ #framework_wrap #content_wrap .info input.button-framework {
130
+ float: right;
131
+ margin: 5px 20px 0 0;
132
+ padding: 4px 10px;
133
+ font-size: 11px;
134
+ height: 24px;
135
+ }
136
+ #framework_wrap #content_wrap .info input.add-item {
137
+ float: left;
138
+ margin-left: 20px;
139
+ }
140
+ #framework_wrap #content_wrap .info input.reset {
141
+ margin-left: 20px;
142
+ color: #d54e45;
143
+ float: left;
144
+ }
145
+ #framework_wrap #content_wrap a.reset {
146
+ margin-right: 10px;
147
+ color: #d54e45;
148
+ }
149
+ .ajax-message {
150
+ position: absolute;
151
+ left: 300px;
152
+ top: 100px;
153
+ width: 200px;
154
+ z-index: 100;
155
+ display: none;
156
+ overflow: visible;
157
+ }
158
+ #framework_wrap #content_wrap .message {
159
+ text-align: center;
160
+ color: #444;
161
+ text-shadow: 0 1px 0 #fff;
162
+ font-size: 12px;
163
+ line-height: 16px;
164
+ padding: 20px 10px;
165
+ background: #f3f3f3;
166
+ border: 1px solid #bbb;
167
+ -webkit-border-radius: 5px;
168
+ -moz-border-radius: 5px;
169
+ border-radius: 5px;
170
+ -moz-box-shadow: 0px 2px 5px #eee;
171
+ -webkit-box-shadow: 0px 2px 5px #eee;
172
+ box-shadow: 0px 2px 5px #eee;
173
+ }
174
+ #framework_wrap #content_wrap .message span {
175
+ display: block;
176
+ height: 16px;
177
+ width: 16px;
178
+ position: absolute;
179
+ left: -8px;
180
+ top: -8px;
181
+ background: url(../images/icon_add.png) no-repeat 0 0;
182
+ }
183
+ #framework_wrap #content_wrap .message.warning span {
184
+ background-image: url(../images/icon_error.png);
185
+ }
186
+ /* Primary Form Button */
187
+ #framework_wrap input.button-framework {
188
+ cursor: pointer;
189
+ font-size: 12px;
190
+ color: #444;
191
+ text-shadow: 0 1px 0 #fff;
192
+ background: #f3f3f3 url(../images/btn.png) repeat-x 0 0;
193
+ border: 1px solid #bbb;
194
+ padding: 5px 10px;
195
+ }
196
+ #framework_wrap input:hover.button-framework {
197
+ color: #000;
198
+ border-color: #666;
199
+ }
200
+ #framework_wrap a.button-framework {
201
+ cursor: pointer;
202
+ font-size: 12px;
203
+ color: #444;
204
+ text-shadow: 0 1px 0 #fff;
205
+ background: #f3f3f3 url(../images/btn.png) repeat-x 0 0;
206
+ border: 1px solid #bbb;
207
+ padding: 3px 10px 3px 10px;
208
+ -webkit-border-radius: 4px;
209
+ -moz-border-radius: 4px;
210
+ border-radius: 4px;
211
+ text-decoration: none;
212
+ float: left;
213
+ position: relative;
214
+ left: 1px;
215
+ }
216
+ #framework_wrap div.inline-edit-save a.button-framework {
217
+ padding: 2px 10px 2px 10px;
218
+ font-size: 11px;
219
+ }
220
+ #framework_wrap a:hover.button-framework {
221
+ color: #000;
222
+ border-color: #666;
223
+ }
224
+
225
+ /* Content Inner */
226
+ #framework_wrap #content {
227
+ padding: 0;
228
+ width: 785px;
229
+ border-bottom: 1px solid #e3e3e3;
230
+ position: relative;
231
+ }
232
+ .screenshot {
233
+ float: right;
234
+ margin-left: 1px;
235
+ position: relative;
236
+ width: 344px;
237
+ }
238
+ .screenshot img {
239
+ max-width: 334px;
240
+ padding: 4px;
241
+ border: 1px solid #ccc;
242
+ background: #fafafa;
243
+ border-color: #ccc #eee #eee #ccc;
244
+ -webkit-border-radius: 4px;
245
+ -moz-border-radius: 4px;
246
+ border-radius: 4px;
247
+ float: right;
248
+ }
249
+ .screenshot a {
250
+ text-decoration: none;
251
+ padding-left: 20px;
252
+ }
253
+ .screenshot a.remove {
254
+ background: url(../images/icon_delete.png) no-repeat 0 0;
255
+ display: block;
256
+ height: 16px;
257
+ width: 16px;
258
+ position: absolute;
259
+ bottom: -4px;
260
+ right: -4px;
261
+ text-indent: -9999px;
262
+ float: left;
263
+ padding: 0;
264
+ border: none;
265
+ }
266
+ .screenshot .no_image a.remove {
267
+ left: 0;
268
+ top: 2px;
269
+ }
270
+ .option-upload .element {
271
+ padding-bottom: 5px;
272
+ }
273
+ #framework_wrap #content h2 {
274
+ margin-bottom: 10px;
275
+ border-bottom: 1px solid #e5e5e5;
276
+ }
277
+ #framework_wrap #content h3 {
278
+ border-bottom: 1px solid #eee;
279
+ margin: 0 0 15px 0;
280
+ padding-bottom: 10px;
281
+ clear: both;
282
+ font-size: 14px;
283
+ }
284
+ h3.text-title {
285
+ font: italic 20px/30px Georgia,"Times New Roman","Bitstream Charter",Times,serif !important;
286
+ }
287
+ #framework_wrap #content tbody tr.inline-edit-option td h3 {
288
+ border-bottom-color: #ddd;
289
+ }
290
+ #framework_wrap #content .block {
291
+ display: block;
292
+ overflow: hidden;
293
+ padding: 20px;
294
+ }
295
+ #framework_wrap #content p {
296
+ font-size: 11px;
297
+ color: #555;
298
+ padding-bottom: 20px;
299
+ margin: 0;
300
+ }
301
+ #framework_wrap #content table {
302
+ border: 1px solid #dfdfdf;
303
+ width: 100%;
304
+ text-align: left;
305
+ border-spacing: 0;
306
+ border-style: solid;
307
+ border-width: 1px;
308
+ font-size: 11px !important;
309
+ text-shadow: 0 1px 0 #fff;
310
+ -webkit-border-radius: 4px;
311
+ -moz-border-radius: 4px;
312
+ border-radius: 4px;
313
+ }
314
+
315
+ #framework_wrap #content .has-table table th {
316
+ background: #f1f1f1;
317
+ background-image: -moz-linear-gradient(top, #f9f9f9, #f1f1f1);
318
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f1f1f1));
319
+ }
320
+ tbody tr:hover {
321
+ cursor: pointer;
322
+ }
323
+ tbody tr.inline-edit-option {
324
+ }
325
+ tbody tr.inline-edit-option td {
326
+ background: #f1f1f1;
327
+ border-top: 1px solid #fff;
328
+ border-left: 1px solid #fff;
329
+ border-right: 1px solid #fff;
330
+ }
331
+ tbody tr:hover.inline-edit-option {
332
+ cursor: default;
333
+ }
334
+ #framework_wrap #content .has-table table #framework-settings .dragging {
335
+ background: #666 url(../images/black_px.png) repeat-x 0 0;
336
+ color: #fff;
337
+ text-shadow: 0 1px 0 #000;
338
+ }
339
+ #framework_wrap #content .has-table table #framework-settings .dragging td {
340
+ border-color: #000;
341
+ }
342
+ #framework_wrap #content .has-table table #framework-settings .dragging .col-edit {
343
+ background: url(../images/icon_up_down.png) no-repeat 63px center;
344
+ }
345
+ #framework_wrap #content .has-table table #framework-settings .dragging a.edit-inline,
346
+ #framework_wrap #content .has-table table #framework-settings .dragging a.delete-inline {
347
+ display: none;
348
+ }
349
+ .col-title {
350
+ padding-left: 10px !important;
351
+ width: 200px;
352
+ }
353
+ .col-type {
354
+ width: 60px;
355
+ }
356
+ .col-edit {
357
+ width: 45px;
358
+ padding-left: 40px !important;
359
+ padding-right: 0px !important;
360
+ }
361
+ .has-table table tr:first-child {
362
+ cursor: default;
363
+ }
364
+ .has-table table .col-heading {
365
+ background: #eaf3fa;
366
+ }
367
+ .has-table table .col-heading td:first-child {
368
+ font-weight: bold;
369
+ background: transparent url(../images/icon_header.png) no-repeat 10px 11px;
370
+ padding-left: 30px !important;
371
+ }
372
+ .has-table table thead th,
373
+ .has-table table td {
374
+ border-bottom: 1px solid #dfdfdf;
375
+ }
376
+ .has-table table tr,
377
+ .has-table table td,
378
+ .has-table table th {
379
+ padding: 10px 10px;
380
+ font-size: 11px !important;
381
+ }
382
+ .has-table table th {
383
+ padding: 6px 10px;
384
+ font-size: 11px !important;
385
+ }
386
+ .has-table table a {
387
+ text-decoration: none;
388
+ }
389
+ /* Inline Edit */
390
+ .inline-edit-option {
391
+ display: none;
392
+ }
393
+ a.edit-inline,
394
+ a.delete-inline,
395
+ a.add-option {
396
+ background: url(../images/icon_edit.png) no-repeat 0 0;
397
+ display: block;
398
+ height: 16px;
399
+ width: 16px;
400
+ text-indent: -9999px;
401
+ float: left;
402
+ margin-right: 5px;
403
+ display: block;
404
+ }
405
+ a.delete-inline {
406
+ background-image: url(../images/icon_delete.png);
407
+ }
408
+ a.add-option {
409
+ background-image: url(../images/icon_add.png);
410
+ margin-left: 21px;
411
+ }
412
+ a:hover.edit-inline {
413
+ border-color: #666;
414
+ }
415
+ a:hover.delete-inline {
416
+ border-color: #d54e45;
417
+ }
418
+ #framework_wrap #content .option {
419
+ padding-bottom: 15px;
420
+ }
421
+ #framework_wrap #content .option .section {
422
+ overflow: hidden;
423
+ font-size: 11px;
424
+ }
425
+ #framework_wrap #content .option .section .element {
426
+ float: left;
427
+ margin: 0 15px 0 0;
428
+ width: 345px;
429
+ }
430
+ #framework_wrap #content .option-checkbox .section .element {
431
+ width: 25px;
432
+ }
433
+ #framework_wrap #content .option .section .description {
434
+ color: #555;
435
+ float: left;
436
+ font-size: 11px;
437
+ padding: 2px 10px 0 0;
438
+ width: 370px;
439
+ }
440
+ div.desc-text p {
441
+ color: #555;
442
+ font-size: 11px !important;
443
+ }
444
+ #framework_wrap #content .inline-edit-option .option .section .description {
445
+ width: 325px;
446
+ padding-top: 0px;
447
+ }
448
+ #framework_wrap #content .option-checkbox .section .description {
449
+ width: 540px;
450
+ }
451
+ #framework_wrap #content label {
452
+
453
+ }
454
+ .input_wrap {
455
+ padding: 4px 10px 12px 0;
456
+ float: left;
457
+ width: 350px;
458
+ }
459
+ .input_wrap input[type="checkbox"],
460
+ .input_wrap input[type="radio"] {
461
+ float: left;
462
+ width: 20px;
463
+ margin-top: 3px;
464
+ vertical-align: bottom;
465
+ }
466
+ .input_wrap input[type="radio"] {
467
+ margin-top: 4px;
468
+ }
469
+ .input_wrap label {
470
+ float: left;
471
+ width: 325px;
472
+ }
473
+ #framework_wrap #content label input {
474
+ margin-right: 5px;
475
+ display: block;
476
+ float: left;
477
+ }
478
+ #framework_wrap #content input[type="text"],
479
+ #framework_wrap #content select,
480
+ #framework_wrap #content textarea {
481
+ background: #fafafa;
482
+ border-color: #ccc #eee #eee #ccc;
483
+ border-style: solid;
484
+ border-width: 1px;
485
+ font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif;
486
+ font-size: 12px;
487
+ margin-bottom: 9px !important;
488
+ padding: 5px;
489
+ width: 344px;
490
+ display: block;
491
+ color: #888;
492
+ resize: none;
493
+ }
494
+ #framework_wrap #content tbody tr.inline-edit-option td input[type="text"],
495
+ #framework_wrap #content tbody tr.inline-edit-option td select,
496
+ #framework_wrap #content tbody tr.inline-edit-option td textarea {
497
+ background: #fff;
498
+ }
499
+ #framework_wrap #content input[type="text"].upload {
500
+ width: 281px;
501
+ float: left;
502
+ }
503
+ #framework_wrap #content input[type="text"].cp_input {
504
+ width: 312px !important;
505
+ float: left;
506
+ }
507
+ .cp_box {
508
+ float: right;
509
+ width: 25px;
510
+ height: 25px;
511
+ position: relative;
512
+ top: 1px;
513
+ border: 1px solid #ccc;
514
+ border-color: #ccc #eee #eee #ccc;
515
+ background: #fafafa;
516
+ -webkit-border-radius: 4px;
517
+ -moz-border-radius: 4px;
518
+ border-radius: 4px;
519
+ }
520
+ .cp_box div {
521
+ width: 13px;
522
+ height: 13px;
523
+ border: 1px solid #bbb;
524
+ border-color: #eee #ccc #ccc #eee;
525
+ background: #fafafa url(../images/empty.gif);
526
+ position: absolute;
527
+ left: 5px;
528
+ top: 5px;
529
+ box-shadow: 1px 1px 0px #ccc;
530
+ -webkit-box-shadow: 1px 1px 0px #ccc;
531
+ -moz-box-shadow: 1px 1px 0px #ccc;
532
+ }
533
+ #framework_wrap #content .element small {
534
+ float: left;
535
+ font-size: 9px;
536
+ line-height: 9px;
537
+ color: #999;
538
+ position: relative;
539
+ top: -5px;
540
+ left: 2px;
541
+ }
542
+ .upload_button,
543
+ .upload_file_button,
544
+ .ob_button {
545
+ float: right;
546
+ padding: 5px;
547
+ cursor: pointer;
548
+ color: #444;
549
+ text-shadow: 0 1px 0 #fff;
550
+ background: #f3f3f3 url(../images/btn.png) repeat-x 0 0 !important;
551
+ border: 1px solid #bbb;
552
+ position: relative;
553
+ right: -1px;
554
+ height: 27px;
555
+ }
556
+ #framework_wrap #content select {
557
+ height: 28px;
558
+ padding: 4px 5px;
559
+ }
560
+ #framework_wrap #content input[type="text"]:focus,
561
+ #framework_wrap #content select:focus,
562
+ #framework_wrap #content textarea:focus,
563
+ #framework_wrap #content input[type="text"]:hover,
564
+ #framework_wrap #content select:hover,
565
+ #framework_wrap #content textarea:hover {
566
+ background: #fff;
567
+ border-color: #bbb #eee #eee #bbb;
568
+ color: #333;
569
+ }
570
+ #framework_wrap *:focus {
571
+ outline: none;
572
+ }
573
+ #framework_wrap *::-moz-focus-inner {
574
+ border: none;
575
+ }
576
+ .bottom_btn {
577
+ float: left;
578
+ width: 100%;
579
+ padding-top: 15px;
580
+ }
581
+ #framework_wrap #content .select_wrapper {
582
+ -moz-border-radius: 4px;
583
+ -webkit-border-radius: 4px;
584
+ border-radius: 4px;
585
+ font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif;
586
+ font-size: 12px;
587
+ background: #fafafa url(../images/select.png) no-repeat right center;
588
+ border-color: #ccc #eee #eee #ccc;
589
+ border-style: solid;
590
+ border-width: 1px;
591
+ float: left;
592
+ height: 26px;
593
+ width: 344px;
594
+ margin: 0;
595
+ margin-bottom: 9px !important;
596
+ width: 344px;
597
+ display: block;
598
+ color: #888;
599
+ }
600
+ #framework_wrap #content .option-type .select_wrapper {
601
+ background-color: #fff;
602
+ }
603
+ #framework_wrap #content .select_wrapper:hover {
604
+ background-color: #fff;
605
+ border-color: #bbb #eee #eee #bbb;
606
+ color: #333;
607
+ }
608
+ #framework_wrap #content select.select {
609
+ cursor: pointer;
610
+ height: 28px;
611
+ margin: 0;
612
+ -moz-opacity: 0;
613
+ filter: alpha(opacity: 0);
614
+ opacity: 0;
615
+ padding: 0;
616
+ position: relative;
617
+ width: inherit;
618
+ z-index: 4;
619
+ }
620
+ #framework_wrap #content .select_wrapper span {
621
+ height: 26px;
622
+ line-height: 26px;
623
+ position: absolute;
624
+ z-index: 2;
625
+ padding-left: 6px;
626
+ }
627
+ /* Docs */
628
+ #framework_wrap #options_tabs.docs {
629
+ font-size: 11px !important;
630
+ color: #555;
631
+ }
632
+ #framework_wrap code {
633
+ font-size: 10px;
634
+ }
635
+ #framework_wrap ul.doc_list {
636
+ font-size: 11px !important;
637
+ padding-bottom: 20px;
638
+ }
639
+ #framework_wrap .doc_list li {
640
+ padding-bottom: 0px;
641
+ line-height: 12px;
642
+ list-style: disc;
643
+ margin-left: 16px;
644
+ }
645
+ #framework_wrap code {
646
+ background-color: #f1f1f1;
647
+ color: #000;
648
+ }
649
+ #framework_wrap pre {
650
+ font-size: 13px;
651
+ padding: 0;
652
+ margin: 0;
653
+ line-height: 18px;
654
+ overflow: auto;
655
+ overflow-Y: hidden;
656
+ padding-top: 18px;
657
+ background: #f1f1f1;
658
+ border-bottom: 1px solid #f1f1f1;
659
+ margin-bottom: 20px;
660
+ color: #000;
661
+ white-space:pre-wrap;
662
+ word-wrap:break-word;
663
+ }
664
+ #framework_wrap pre code {
665
+ padding: 0 18px 18px 18px;
666
+ display: block;
667
+ background: url(../images/pre_bg.gif) repeat left top; /*--Background of lined paper--*/
668
+ }
669
+ /* Tabs */
670
+ .options_tabs {
671
+ display: none;
672
+ }
673
+ .ui-tabs {
674
+ zoom: 1;
675
+ background: url(../images/tabs_bg.png) repeat-y 0 0;
676
+ }
677
+ .ui-tabs .options_tabs {
678
+ display: block;
679
+ }
680
+ .ui-tabs-panel .description {
681
+ width: 225px !important;
682
+ }
683
+ .ui-tabs-panel .inline-edit-option .description {
684
+ width: 200px !important;
685
+ }
686
+ .ui-tabs-panel h2 {
687
+ display: none;
688
+ }
689
+ .ui-tabs .ui-tabs-nav {
690
+ list-style: none;
691
+ position: relative;
692
+ float: left;
693
+ width: 148px;
694
+ word-wrap: break-word;
695
+ }
696
+ .ui-tabs .ui-tabs-nav li {
697
+ position: relative;
698
+ float: left;
699
+ display: block;
700
+ margin: 0;
701
+ padding: 0;
702
+ overflow: visible;
703
+ }
704
+ .ui-tabs .ui-tabs-nav li a {
705
+ float: left;
706
+ text-decoration: none;
707
+ display: block;
708
+ width: 127px;
709
+ padding: 8px 10px;
710
+ border-bottom: 1px solid #e3e3e3;
711
+ color: #21759B;
712
+ text-shadow: 0 1px 0 #fff;
713
+ background-image: url(../images/white_px.png);
714
+ background-repeat: repeat-x;
715
+ background-position: 0 0;
716
+ font-size: 11px;
717
+ }
718
+ .ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
719
+ .ui-tabs .ui-tabs-nav li.ui-tabs-selected a:hover {
720
+ background: #fff;
721
+ color: #d54e45;
722
+ width: 128px;
723
+ }
724
+ .ui-tabs .ui-tabs-nav li.ui-state-disabled a,
725
+ .ui-tabs .ui-tabs-nav li.ui-state-processing a {
726
+ cursor: text;
727
+ }
728
+ .ui-tabs .ui-tabs-nav li a,
729
+ .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
730
+ cursor: pointer;
731
+ }
732
+ .ui-tabs .ui-tabs-nav li.ui-state-hover a {
733
+ background-color: #eaf2fa;
734
+ color: #555;
735
+ }
736
+ .ui-tabs .ui-tabs-panel {
737
+ display: block;
738
+ float: right;
739
+ width: 595px;
740
+ min-height: 400px;
741
+ }
742
+ .ui-tabs .ui-tabs-hide {
743
+ display: none !important;
744
+ }
745
+ .options_tabs li.ui-tabs-selected span {
746
+ position: absolute;
747
+ left: -1px;
748
+ top: 12px;
749
+ height: 9px;
750
+ width: 8px;
751
+ background: url(../images/icon_arrow.png) no-repeat 0 0;
752
+ }
753
+
754
+ /* ColorPicker */
755
+ .colorpicker {
756
+ width: 342px;
757
+ height: 170px;
758
+ overflow: hidden;
759
+ position: absolute;
760
+ background: #fafafa url(../images/colorpicker/color_bg.png);
761
+ font-family: Arial, Helvetica, sans-serif;
762
+ display: none;
763
+ border: 1px solid #ccc;
764
+ border-color: #ddd #bbb #bbb #ddd;
765
+ -moz-border-radius: 4px;
766
+ -webkit-border-radius: 4px;
767
+ border-radius: 4px;
768
+ z-index: 100;
769
+ }
770
+ .colorpicker_color {
771
+ width: 150px;
772
+ height: 150px;
773
+ left: 10px;
774
+ top: 10px;
775
+ position: absolute;
776
+ background: #f00;
777
+ overflow: hidden;
778
+ cursor: crosshair;
779
+ }
780
+ .colorpicker_color div {
781
+ position: absolute;
782
+ top: 0;
783
+ left: 0;
784
+ width: 150px;
785
+ height: 150px;
786
+ background: url(../images/colorpicker/color_overlay.png);
787
+ }
788
+ .colorpicker_color div div {
789
+ position: absolute;
790
+ top: 0;
791
+ left: 0;
792
+ width: 11px;
793
+ height: 11px;
794
+ overflow: hidden;
795
+ background: url(../images/colorpicker/color_select.gif);
796
+ margin: -5px 0 0 -5px;
797
+ }
798
+ .colorpicker_hue {
799
+ position: absolute;
800
+ top: 10px;
801
+ left: 164px;
802
+ width: 35px;
803
+ height: 150px;
804
+ cursor: n-resize;
805
+ }
806
+ .colorpicker_hue div {
807
+ position: absolute;
808
+ width: 35px;
809
+ height: 9px;
810
+ overflow: hidden;
811
+ background: url(../images/colorpicker/color_indicator.png) left top;
812
+ margin: -5px 0 0 0;
813
+ }
814
+ .colorpicker_new_color {
815
+ position: absolute;
816
+ width: 60px;
817
+ height: 30px;
818
+ right: 80px;
819
+ top: 10px;
820
+ background: #f00;
821
+ }
822
+ .colorpicker_current_color {
823
+ position: absolute;
824
+ width: 60px;
825
+ height: 30px;
826
+ right: 10px;
827
+ top: 10px;
828
+ background: #f00;
829
+ }
830
+ .colorpicker input {
831
+ background-color: transparent;
832
+ border: 1px solid transparent;
833
+ position: absolute;
834
+ font-size: 10px;
835
+ font-family: Arial, Helvetica, sans-serif;
836
+ color: #666;
837
+ top: 6px;
838
+ right: 11px;
839
+ text-align: right;
840
+ margin: 0;
841
+ padding: 0;
842
+ height: 11px;
843
+ }
844
+ .colorpicker_hex {
845
+ position: absolute;
846
+ width: 72px;
847
+ height: 22px;
848
+ background: url(../images/colorpicker/color_hex.png) top;
849
+ left: 201px;
850
+ bottom: 9px;
851
+ }
852
+ .colorpicker_hex input {
853
+ right: 6px;
854
+ }
855
+ .colorpicker_field {
856
+ height: 22px;
857
+ width: 62px;
858
+ background-position: top;
859
+ position: absolute;
860
+ }
861
+ .colorpicker_field span {
862
+ position: absolute;
863
+ width: 12px;
864
+ height: 22px;
865
+ overflow: hidden;
866
+ top: 0;
867
+ right: 0;
868
+ cursor: n-resize;
869
+ }
870
+ .colorpicker_rgb_r {
871
+ background-image: url(../images/colorpicker/color_rgb_r.png);
872
+ top: 49px;
873
+ left: 201px;
874
+ }
875
+ .colorpicker_rgb_g {
876
+ background-image: url(../images/colorpicker/color_rgb_g.png);
877
+ top: 79px;
878
+ left: 201px;
879
+ }
880
+ .colorpicker_rgb_b {
881
+ background-image: url(../images/colorpicker/color_rgb_b.png);
882
+ top: 109px;
883
+ left: 201px;
884
+ }
885
+ .colorpicker_hsb_h {
886
+ background-image: url(../images/colorpicker/color_hsb_h.png);
887
+ top: 49px;
888
+ right: 9px;
889
+ }
890
+ .colorpicker_hsb_s {
891
+ background-image: url(../images/colorpicker/color_hsb_s.png);
892
+ top: 79px;
893
+ right: 9px;
894
+ }
895
+ .colorpicker_hsb_b {
896
+ background-image: url(../images/colorpicker/color_hsb_b.png);
897
+ top: 109px;
898
+ right: 9px;
899
+ }
900
+ .colorpicker_submit {
901
+ position: absolute;
902
+ width: 16px;
903
+ height: 16px;
904
+ background: url(../images/colorpicker/color_wheel.png) top;
905
+ right: 10px;
906
+ bottom: 10px;
907
+ overflow: hidden;
908
+ }
909
+ .colorpicker_focus {
910
+ background-position: center;
911
+ }
912
+ .colorpicker_hex.colorpicker_focus {
913
+ background-position: bottom;
914
+ }
915
+ .colorpicker_submit.colorpicker_focus {
916
+ background-position: bottom;
917
+ }
918
+ .colorpicker_slider {
919
+ background-position: bottom;
920
+ }
921
+
922
+ /* file input */
923
+ div.file_wrap {
924
+ position: relative;
925
+ float: left;
926
+ width: 345px;
927
+ }
928
+ div.fake_file {
929
+ position: absolute;
930
+ top: 0px;
931
+ left: 0px;
932
+ z-index: 1;
933
+ }
934
+ div.fake_file input.upload {
935
+ margin-right: 3px;
936
+ width: 279px !important;
937
+ }
938
+ input.file {
939
+ background: none;
940
+ position: relative;
941
+ text-align: right;
942
+ float: right;
943
+ height: 28px;
944
+ -moz-opacity: 0;
945
+ filter: alpha(opacity: 0);
946
+ opacity: 0;
947
+ z-index: 2;
948
+ }
assets/images/black_px.png ADDED
Binary file
assets/images/btn.png ADDED
Binary file
assets/images/colorpicker/color_bg.png ADDED
Binary file
assets/images/colorpicker/color_hex.png ADDED
Binary file
assets/images/colorpicker/color_hsb_b.png ADDED
Binary file
assets/images/colorpicker/color_hsb_h.png ADDED
Binary file
assets/images/colorpicker/color_hsb_s.png ADDED
Binary file
assets/images/colorpicker/color_indicator.png ADDED
Binary file
assets/images/colorpicker/color_overlay.png ADDED
Binary file
assets/images/colorpicker/color_rgb_b.png ADDED
Binary file
assets/images/colorpicker/color_rgb_g.png ADDED
Binary file
assets/images/colorpicker/color_rgb_r.png ADDED
Binary file
assets/images/colorpicker/color_select.gif ADDED
Binary file
assets/images/colorpicker/color_wheel.png ADDED
Binary file
assets/images/empty.gif ADDED
Binary file
assets/images/header.png ADDED
Binary file
assets/images/header_classic.png ADDED
Binary file
assets/images/icon_add.png ADDED
Binary file
assets/images/icon_arrow.png ADDED
Binary file
assets/images/icon_classic.png ADDED
Binary file
assets/images/icon_dark.png ADDED
Binary file
assets/images/icon_delete.png ADDED
Binary file
assets/images/icon_edit.png ADDED
Binary file
assets/images/icon_error.png ADDED
Binary file
assets/images/icon_header.png ADDED
Binary file
assets/images/icon_option.png ADDED
Binary file
assets/images/icon_option_classic.png ADDED
Binary file
assets/images/icon_up_down.png ADDED
Binary file
assets/images/logo_classic.png ADDED
Binary file
assets/images/logo_dark.png ADDED
Binary file
assets/images/pre_bg.gif ADDED
Binary file
assets/images/pre_classic_bg.gif ADDED
Binary file
assets/images/select.png ADDED
Binary file
assets/images/tabs_bg.png ADDED
Binary file
assets/images/tabs_bg_classic.png ADDED
Binary file
assets/images/toggle_tabs.png ADDED
Binary file
assets/images/white_px.png ADDED
Binary file
assets/js/jquery.color.picker.js ADDED
@@ -0,0 +1,455 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Color picker
4
+ * Author: Stefan Petre www.eyecon.ro
5
+ *
6
+ * Dependencies: jQuery
7
+ *
8
+ */
9
+ (function ($) {
10
+ var ColorPicker = function () {
11
+ var
12
+ ids = {},
13
+ inAction,
14
+ charMin = 65,
15
+ visible,
16
+ tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
+ defaults = {
18
+ eventName: 'click',
19
+ onShow: function () {},
20
+ onBeforeShow: function(){},
21
+ onHide: function () {},
22
+ onChange: function () {},
23
+ onSubmit: function () {},
24
+ color: 'ff0000',
25
+ livePreview: true,
26
+ flat: false
27
+ },
28
+ fillRGBFields = function (hsb, cal) {
29
+ var rgb = HSBToRGB(hsb);
30
+ $(cal).data('colorpicker').fields
31
+ .eq(1).val(rgb.r).end()
32
+ .eq(2).val(rgb.g).end()
33
+ .eq(3).val(rgb.b).end();
34
+ },
35
+ fillHSBFields = function (hsb, cal) {
36
+ $(cal).data('colorpicker').fields
37
+ .eq(4).val(hsb.h).end()
38
+ .eq(5).val(hsb.s).end()
39
+ .eq(6).val(hsb.b).end();
40
+ },
41
+ fillHexFields = function (hsb, cal) {
42
+ $(cal).data('colorpicker').fields
43
+ .eq(0).val(HSBToHex(hsb)).end();
44
+ },
45
+ setSelector = function (hsb, cal) {
46
+ $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
+ $(cal).data('colorpicker').selectorIndic.css({
48
+ left: parseInt(150 * hsb.s/100, 10),
49
+ top: parseInt(150 * (100-hsb.b)/100, 10)
50
+ });
51
+ },
52
+ setHue = function (hsb, cal) {
53
+ $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
+ },
55
+ setCurrentColor = function (hsb, cal) {
56
+ $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
+ },
58
+ setNewColor = function (hsb, cal) {
59
+ $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
+ },
61
+ keyDown = function (ev) {
62
+ var pressedKey = ev.charCode || ev.keyCode || -1;
63
+ if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
+ return false;
65
+ }
66
+ var cal = $(this).parent().parent();
67
+ if (cal.data('colorpicker').livePreview === true) {
68
+ change.apply(this);
69
+ }
70
+ },
71
+ change = function (ev) {
72
+ var cal = $(this).parent().parent(), col;
73
+ if (this.parentNode.className.indexOf('_hex') > 0) {
74
+ cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
+ cal.data('colorpicker').color = col = fixHSB({
77
+ h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
+ s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
+ b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
+ });
81
+ } else {
82
+ cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
+ r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
+ g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
+ b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
+ }));
87
+ }
88
+ if (ev) {
89
+ fillRGBFields(col, cal.get(0));
90
+ fillHexFields(col, cal.get(0));
91
+ fillHSBFields(col, cal.get(0));
92
+ }
93
+ setSelector(col, cal.get(0));
94
+ setHue(col, cal.get(0));
95
+ setNewColor(col, cal.get(0));
96
+ cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
+ },
98
+ blur = function (ev) {
99
+ var cal = $(this).parent().parent();
100
+ cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus')
101
+ },
102
+ focus = function () {
103
+ charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
+ $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
+ $(this).parent().addClass('colorpicker_focus');
106
+ },
107
+ downIncrement = function (ev) {
108
+ var field = $(this).parent().find('input').focus();
109
+ var current = {
110
+ el: $(this).parent().addClass('colorpicker_slider'),
111
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
+ y: ev.pageY,
113
+ field: field,
114
+ val: parseInt(field.val(), 10),
115
+ preview: $(this).parent().parent().data('colorpicker').livePreview
116
+ };
117
+ $(document).bind('mouseup', current, upIncrement);
118
+ $(document).bind('mousemove', current, moveIncrement);
119
+ },
120
+ moveIncrement = function (ev) {
121
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
+ if (ev.data.preview) {
123
+ change.apply(ev.data.field.get(0), [true]);
124
+ }
125
+ return false;
126
+ },
127
+ upIncrement = function (ev) {
128
+ change.apply(ev.data.field.get(0), [true]);
129
+ ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
+ $(document).unbind('mouseup', upIncrement);
131
+ $(document).unbind('mousemove', moveIncrement);
132
+ return false;
133
+ },
134
+ downHue = function (ev) {
135
+ var current = {
136
+ cal: $(this).parent(),
137
+ y: $(this).offset().top
138
+ };
139
+ current.preview = current.cal.data('colorpicker').livePreview;
140
+ $(document).bind('mouseup', current, upHue);
141
+ $(document).bind('mousemove', current, moveHue);
142
+ },
143
+ moveHue = function (ev) {
144
+ change.apply(
145
+ ev.data.cal.data('colorpicker')
146
+ .fields
147
+ .eq(4)
148
+ .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
+ .get(0),
150
+ [ev.data.preview]
151
+ );
152
+ return false;
153
+ },
154
+ upHue = function (ev) {
155
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
+ $(document).unbind('mouseup', upHue);
158
+ $(document).unbind('mousemove', moveHue);
159
+ return false;
160
+ },
161
+ downSelector = function (ev) {
162
+ var current = {
163
+ cal: $(this).parent(),
164
+ pos: $(this).offset()
165
+ };
166
+ current.preview = current.cal.data('colorpicker').livePreview;
167
+ $(document).bind('mouseup', current, upSelector);
168
+ $(document).bind('mousemove', current, moveSelector);
169
+ },
170
+ moveSelector = function (ev) {
171
+ change.apply(
172
+ ev.data.cal.data('colorpicker')
173
+ .fields
174
+ .eq(6)
175
+ .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
+ .end()
177
+ .eq(5)
178
+ .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
+ .get(0),
180
+ [ev.data.preview]
181
+ );
182
+ return false;
183
+ },
184
+ upSelector = function (ev) {
185
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
+ $(document).unbind('mouseup', upSelector);
188
+ $(document).unbind('mousemove', moveSelector);
189
+ return false;
190
+ },
191
+ enterSubmit = function (ev) {
192
+ $(this).addClass('colorpicker_focus');
193
+ },
194
+ leaveSubmit = function (ev) {
195
+ $(this).removeClass('colorpicker_focus');
196
+ },
197
+ clickSubmit = function (ev) {
198
+ var cal = $(this).parent();
199
+ var col = cal.data('colorpicker').color;
200
+ cal.data('colorpicker').origColor = col;
201
+ setCurrentColor(col, cal.get(0));
202
+ cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col));
203
+ cal.hide();
204
+ },
205
+ show = function (ev) {
206
+ var cal = $('#' + $(this).data('colorpickerId'));
207
+ cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
208
+ var pos = $(this).offset();
209
+ var viewPort = getViewport();
210
+ var top = pos.top + this.offsetHeight;
211
+ var left = pos.left;
212
+ if (top + 176 > viewPort.t + viewPort.h) {
213
+ top -= this.offsetHeight + 176;
214
+ } else {
215
+ top += 5;
216
+ }
217
+ if (left + 356 > viewPort.l + viewPort.w) {
218
+ left -= 356;
219
+ }
220
+ cal.css({left: left + 'px', top: top + 'px'});
221
+ if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
222
+ cal.show();
223
+ }
224
+ $(document).bind('mousedown', {cal: cal}, hide);
225
+ return false;
226
+ },
227
+ hide = function (ev) {
228
+ if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
229
+ if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
230
+ ev.data.cal.hide();
231
+ }
232
+ $(document).unbind('mousedown', hide);
233
+ }
234
+ },
235
+ isChildOf = function(parentEl, el, container) {
236
+ if (parentEl == el) {
237
+ return true;
238
+ }
239
+ if (parentEl.contains) {
240
+ return parentEl.contains(el);
241
+ }
242
+ if ( parentEl.compareDocumentPosition ) {
243
+ return !!(parentEl.compareDocumentPosition(el) & 16);
244
+ }
245
+ var prEl = el.parentNode;
246
+ while(prEl && prEl != container) {
247
+ if (prEl == parentEl)
248
+ return true;
249
+ prEl = prEl.parentNode;
250
+ }
251
+ return false;
252
+ },
253
+ getViewport = function () {
254
+ var m = document.compatMode == 'CSS1Compat';
255
+ return {
256
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
257
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
258
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
259
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
260
+ };
261
+ },
262
+ fixHSB = function (hsb) {
263
+ return {
264
+ h: Math.min(360, Math.max(0, hsb.h)),
265
+ s: Math.min(100, Math.max(0, hsb.s)),
266
+ b: Math.min(100, Math.max(0, hsb.b))
267
+ };
268
+ },
269
+ fixRGB = function (rgb) {
270
+ return {
271
+ r: Math.min(255, Math.max(0, rgb.r)),
272
+ g: Math.min(255, Math.max(0, rgb.g)),
273
+ b: Math.min(255, Math.max(0, rgb.b))
274
+ };
275
+ },
276
+ fixHex = function (hex) {
277
+ var len = 6 - hex.length;
278
+ if (len > 0) {
279
+ var o = [];
280
+ for (var i=0; i<len; i++) {
281
+ o.push('0');
282
+ }
283
+ o.push(hex);
284
+ hex = o.join('');
285
+ }
286
+ return hex;
287
+ },
288
+ HexToRGB = function (hex) {
289
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
290
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
291
+ },
292
+ HexToHSB = function (hex) {
293
+ return RGBToHSB(HexToRGB(hex));
294
+ },
295
+ RGBToHSB = function (rgb) {
296
+ var hsb = {};
297
+ hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
298
+ hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
299
+ hsb.b = Math.round((hsb.b /255)*100);
300
+ if((rgb.r==rgb.g) && (rgb.g==rgb.b)) hsb.h = 0;
301
+ else if(rgb.r>=rgb.g && rgb.g>=rgb.b) hsb.h = 60*(rgb.g-rgb.b)/(rgb.r-rgb.b);
302
+ else if(rgb.g>=rgb.r && rgb.r>=rgb.b) hsb.h = 60 + 60*(rgb.g-rgb.r)/(rgb.g-rgb.b);
303
+ else if(rgb.g>=rgb.b && rgb.b>=rgb.r) hsb.h = 120 + 60*(rgb.b-rgb.r)/(rgb.g-rgb.r);
304
+ else if(rgb.b>=rgb.g && rgb.g>=rgb.r) hsb.h = 180 + 60*(rgb.b-rgb.g)/(rgb.b-rgb.r);
305
+ else if(rgb.b>=rgb.r && rgb.r>=rgb.g) hsb.h = 240 + 60*(rgb.r-rgb.g)/(rgb.b-rgb.g);
306
+ else if(rgb.r>=rgb.b && rgb.b>=rgb.g) hsb.h = 300 + 60*(rgb.r-rgb.b)/(rgb.r-rgb.g);
307
+ else hsb.h = 0;
308
+ hsb.h = Math.round(hsb.h);
309
+ return hsb;
310
+ },
311
+ HSBToRGB = function (hsb) {
312
+ var rgb = {};
313
+ var h = Math.round(hsb.h);
314
+ var s = Math.round(hsb.s*255/100);
315
+ var v = Math.round(hsb.b*255/100);
316
+ if(s == 0) {
317
+ rgb.r = rgb.g = rgb.b = v;
318
+ } else {
319
+ var t1 = v;
320
+ var t2 = (255-s)*v/255;
321
+ var t3 = (t1-t2)*(h%60)/60;
322
+ if(h==360) h = 0;
323
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
324
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
325
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
326
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
327
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
328
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
329
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
330
+ }
331
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
332
+ },
333
+ RGBToHex = function (rgb) {
334
+ var hex = [
335
+ rgb.r.toString(16),
336
+ rgb.g.toString(16),
337
+ rgb.b.toString(16)
338
+ ];
339
+ $.each(hex, function (nr, val) {
340
+ if (val.length == 1) {
341
+ hex[nr] = '0' + val;
342
+ }
343
+ });
344
+ return hex.join('');
345
+ },
346
+ HSBToHex = function (hsb) {
347
+ return RGBToHex(HSBToRGB(hsb));
348
+ };
349
+ return {
350
+ init: function (options) {
351
+ options = $.extend({}, defaults, options||{});
352
+ if (typeof options.color == 'string') {
353
+ options.color = HexToHSB(options.color);
354
+ } else if (options.color.r != undefined && options.color.g != undefined && options.color.b != undefined) {
355
+ options.color = RGBToHSB(options.color);
356
+ } else if (options.color.h != undefined && options.color.s != undefined && options.color.b != undefined) {
357
+ options.color = fixHSB(options.color);
358
+ } else {
359
+ return this;
360
+ }
361
+ options.origColor = options.color;
362
+ return this.each(function () {
363
+ if (!$(this).data('colorpickerId')) {
364
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
365
+ $(this).data('colorpickerId', id);
366
+ var cal = $(tpl).attr('id', id);
367
+ if (options.flat) {
368
+ cal.appendTo(this).show();
369
+ } else {
370
+ cal.appendTo(document.body);
371
+ }
372
+ options.fields = cal
373
+ .find('input')
374
+ .bind('keydown', keyDown)
375
+ .bind('change', change)
376
+ .bind('blur', blur)
377
+ .bind('focus', focus);
378
+ cal.find('span').bind('mousedown', downIncrement);
379
+ options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
380
+ options.selectorIndic = options.selector.find('div div');
381
+ options.hue = cal.find('div.colorpicker_hue div');
382
+ cal.find('div.colorpicker_hue').bind('mousedown', downHue);
383
+ options.newColor = cal.find('div.colorpicker_new_color');
384
+ options.currentColor = cal.find('div.colorpicker_current_color');
385
+ cal.data('colorpicker', options);
386
+ cal.find('div.colorpicker_submit')
387
+ .bind('mouseenter', enterSubmit)
388
+ .bind('mouseleave', leaveSubmit)
389
+ .bind('click', clickSubmit);
390
+ fillRGBFields(options.color, cal.get(0));
391
+ fillHSBFields(options.color, cal.get(0));
392
+ fillHexFields(options.color, cal.get(0));
393
+ setHue(options.color, cal.get(0));
394
+ setSelector(options.color, cal.get(0));
395
+ setCurrentColor(options.color, cal.get(0));
396
+ setNewColor(options.color, cal.get(0));
397
+ if (options.flat) {
398
+ cal.css({
399
+ position: 'relative',
400
+ display: 'block'
401
+ });
402
+ } else {
403
+ $(this).bind(options.eventName, show);
404
+ }
405
+ }
406
+ });
407
+ },
408
+ showPicker: function() {
409
+ return this.each( function () {
410
+ if ($(this).data('colorpickerId')) {
411
+ show.apply(this);
412
+ }
413
+ });
414
+ },
415
+ hidePicker: function() {
416
+ return this.each( function () {
417
+ if ($(this).data('colorpickerId')) {
418
+ $('#' + $(this).data('colorpickerId')).hide();
419
+ }
420
+ });
421
+ },
422
+ setColor: function(col) {
423
+ if (typeof col == 'string') {
424
+ col = HexToHSB(col);
425
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
426
+ col = RGBToHSB(col);
427
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
428
+ col = fixHSB(col);
429
+ } else {
430
+ return this;
431
+ }
432
+ return this.each(function(){
433
+ if ($(this).data('colorpickerId')) {
434
+ var cal = $('#' + $(this).data('colorpickerId'));
435
+ cal.data('colorpicker').color = col;
436
+ cal.data('colorpicker').origColor = col;
437
+ fillRGBFields(col, cal.get(0));
438
+ fillHSBFields(col, cal.get(0));
439
+ fillHexFields(col, cal.get(0));
440
+ setHue(col, cal.get(0));
441
+ setSelector(col, cal.get(0));
442
+ setCurrentColor(col, cal.get(0));
443
+ setNewColor(col, cal.get(0));
444
+ }
445
+ });
446
+ }
447
+ };
448
+ }();
449
+ $.fn.extend({
450
+ ColorPicker: ColorPicker.init,
451
+ ColorPickerHide: ColorPicker.hide,
452
+ ColorPickerShow: ColorPicker.show,
453
+ ColorPickerSetColor: ColorPicker.setColor
454
+ });
455
+ })(jQuery)
assets/js/jquery.option.tree.js ADDED
@@ -0,0 +1,752 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Author: Derek Herman
4
+ * URL: http://valendesigns.com
5
+ * Email: derek@valendesigns.com
6
+ *
7
+ */
8
+
9
+ /**
10
+ *
11
+ * Delay
12
+ *
13
+ * Creates a way to delay events
14
+ * Dependencies: jQuery
15
+ *
16
+ */
17
+ (function ($) {
18
+ $.fn.delay = function(time,func){
19
+ return this.each(function(){
20
+ setTimeout(func,time);
21
+ });
22
+ };
23
+ })(jQuery);
24
+
25
+ /**
26
+ *
27
+ * Center AJAX
28
+ *
29
+ * Creates a way to center the AJAX message
30
+ * Dependencies: jQuery
31
+ *
32
+ */
33
+ (function ($) {
34
+ $.fn.ajaxMessage = function(html){
35
+ if (html) {
36
+ return $(this).animate({"top":( $(window).height() - $(this).height() ) / 2 - 200 + $(window).scrollTop() + "px"},100).fadeIn('fast').html(html).delay(3000, function(){$('.ajax-message').fadeOut()});
37
+ } else {
38
+ return $(this).animate({"top":( $(window).height() - $(this).height() ) / 2 - 200 + $(window).scrollTop() + "px"},100).fadeIn('fast').delay(3000, function(){$('.ajax-message').fadeOut()});
39
+ }
40
+ };
41
+ })(jQuery);
42
+
43
+ /**
44
+ *
45
+ * Style File
46
+ *
47
+ * Creates a way to cover file input with a better styled version
48
+ * Dependencies: jQuery
49
+ *
50
+ */
51
+ (function ($) {
52
+ styleFile = {
53
+ init: function () {
54
+ $('input.file').each(function(){
55
+ var uploadbutton = '<input class="upload_file_button" type="button" value="Upload" />';
56
+ $(this).wrap('<div class="file_wrap" />');
57
+ $(this).addClass('file').css('opacity', 0); //set to invisible
58
+ $(this).parent().append($('<div class="fake_file" />').append($('<input type="text" class="upload" />').attr('id',$(this).attr('id')+'_file')).append(uploadbutton));
59
+
60
+ $(this).bind('change', function() {
61
+ $('#'+$(this).attr('id')+'_file').val($(this).val());;
62
+ });
63
+ $(this).bind('mouseout', function() {
64
+ $('#'+$(this).attr('id')+'_file').val($(this).val());;
65
+ });
66
+ });
67
+ }
68
+ };
69
+ $(document).ready(function () {
70
+ styleFile.init()
71
+ })
72
+ })(jQuery);
73
+
74
+ /**
75
+ *
76
+ * Style Select
77
+ *
78
+ * Replace Select text
79
+ * Dependencies: jQuery
80
+ *
81
+ */
82
+ (function ($) {
83
+ styleSelect = {
84
+ init: function () {
85
+ $('.select_wrapper').each(function () {
86
+ $(this).prepend('<span>' + $(this).find('.select option:selected').text() + '</span>');
87
+ });
88
+ $('.select').live('change', function () {
89
+ $(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
90
+ });
91
+ $('.select').bind($.browser.msie ? 'click' : 'change', function(event) {
92
+ $(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
93
+ });
94
+ }
95
+ };
96
+ $(document).ready(function () {
97
+ styleSelect.init()
98
+ })
99
+ })(jQuery);
100
+
101
+ /**
102
+ *
103
+ * Activate Tabs
104
+ *
105
+ * Tab style UI toggle
106
+ * Dependencies: jQuery, jQuery UI Core, jQuery UI Tabs
107
+ *
108
+ */
109
+ (function ($) {
110
+ activateTabs = {
111
+ init: function () {
112
+ // Activate
113
+ $("#options_tabs").tabs();
114
+ // Append Toggle Button
115
+ $('.top-info').append('<a href="" class="toggle_tabs">Tabs</a>');
116
+ // Toggle Tabs
117
+ $('.toggle_tabs').toggle(function() {
118
+ $("#options_tabs").tabs('destroy');
119
+ $(this).addClass('off');
120
+ }, function() {
121
+ $("#options_tabs").tabs();
122
+ $(this).removeClass('off');
123
+ });
124
+ }
125
+ };
126
+ $(document).ready(function () {
127
+ activateTabs.init()
128
+ })
129
+ })(jQuery);
130
+
131
+ /**
132
+ *
133
+ * Upload Option
134
+ *
135
+ * Allows window.send_to_editor to function properly using a private post_id
136
+ * Dependencies: jQuery, Media Upload, Thickbox
137
+ *
138
+ */
139
+ (function ($) {
140
+ uploadOption = {
141
+ init: function () {
142
+ var formfield,
143
+ formID,
144
+ btnContent = true;
145
+ // On Click
146
+ $('.upload_button').live("click", function () {
147
+ formfield = $(this).prev('input').attr('name');
148
+ formID = $(this).attr('rel');
149
+ tb_show('', 'media-upload.php?post_id='+formID+'&type=image&amp;TB_iframe=1');
150
+ return false;
151
+ });
152
+
153
+ window.original_send_to_editor = window.send_to_editor;
154
+ window.send_to_editor = function(html) {
155
+ if (formfield) {
156
+ itemurl = $(html).attr('href');
157
+ var image = /(^.*\.jpg|jpeg|png|gif|ico*)/gi;
158
+ var document = /(^.*\.pdf|doc|docx|ppt|pptx|odt*)/gi;
159
+ var audio = /(^.*\.mp3|m4a|ogg|wav*)/gi;
160
+ var video = /(^.*\.mp4|m4v|mov|wmv|avi|mpg|ogv|3gp|3g2*)/gi;
161
+ if (itemurl.match(image)) {
162
+ btnContent = '<img src="'+itemurl+'" alt="" /><a href="" class="remove">Remove Image</a>';
163
+ } else {
164
+ btnContent = '<div class="no_image">'+html+'<a href="" class="remove">Remove</a></div>';
165
+ }
166
+ $('#' + formfield).val(itemurl);
167
+ $('#' + formfield).next().next('div').slideDown().html(btnContent);
168
+ tb_remove();
169
+ } else {
170
+ window.original_send_to_editor(html);
171
+ }
172
+ }
173
+ }
174
+ };
175
+ $(document).ready(function () {
176
+ uploadOption.init()
177
+ })
178
+ })(jQuery);
179
+
180
+ /**
181
+ *
182
+ * Inline Edit Options
183
+ *
184
+ * Creates & Updates Options via Ajax
185
+ * Dependencies: jQuery
186
+ *
187
+ */
188
+ (function ($) {
189
+ inlineEditOption = {
190
+ init: function () {
191
+ var c = this,
192
+ d = $("tr.inline-edit-option");
193
+ $('.save-options', '#the-theme-options').live("click", function () {
194
+ inlineEditOption.save_options(this);
195
+ return false;
196
+ });
197
+ $('.reset', '#the-theme-options').live("click", function () {
198
+ var agree = confirm("Are you absolutely sure you wish to delete all of your saved Theme Option?");
199
+ if (agree) {
200
+ inlineEditOption.reset_options(this);
201
+ return false;
202
+ } else {
203
+ return false;
204
+ }
205
+ });
206
+ $('.import-data', '#import-data').live("click", function () {
207
+ inlineEditOption.import_data(this);
208
+ return false;
209
+ });
210
+ $("a.edit-inline").live("click", function (event) {
211
+ if ($("a.edit-inline").hasClass('disable')) {
212
+ event.preventDefault();
213
+ return false;
214
+ } else {
215
+ inlineEditOption.edit(this);
216
+ return false;
217
+ }
218
+ });
219
+ $("a.save").live("click", function () {
220
+ if ($("a.save").hasClass('add-save')) {
221
+ inlineEditOption.addSave(this);
222
+ return false;
223
+ } else {
224
+ inlineEditOption.editSave(this);
225
+ return false;
226
+ }
227
+ });
228
+ $("a.cancel").live("click", function () {
229
+ if ($("a.cancel").hasClass('undo-add')) {
230
+ inlineEditOption.undoAdd();
231
+ return false;
232
+ } else {
233
+ inlineEditOption.revert();
234
+ return false;
235
+ }
236
+ });
237
+ $("a.add-option").live("click", function (event) {
238
+ if ($(this).hasClass('disable')) {
239
+ event.preventDefault();
240
+ return false;
241
+ } else {
242
+ $.post(
243
+ ajaxurl,
244
+ { action:'option_tree_next_id', _ajax_nonce: $("#_ajax_nonce").val() },
245
+ function (response) {
246
+ c = parseInt(response) + 1;
247
+ inlineEditOption.add(c);
248
+ }
249
+ );
250
+ return false;
251
+ }
252
+ });
253
+ $('#framework-settings').tableDnD({
254
+ onDragClass: "dragging",
255
+ onDrop: function(table, row) {
256
+ d = {
257
+ action: "option_tree_sort",
258
+ id: $.tableDnD.serialize(),
259
+ _ajax_nonce: $("#_ajax_nonce").val()
260
+ };
261
+ $.post(ajaxurl, d, function (response) {
262
+
263
+ }, "html");
264
+ }
265
+ });
266
+ $('#upload-xml').submit(function() {
267
+ var agree = confirm("Are you sure you want to import these new settings?");
268
+ if (agree) {
269
+ return true;
270
+ }
271
+ return false;
272
+ });
273
+ $('.delete-inline').live("click", function (event) {
274
+ if ($("a.delete-inline").hasClass('disable')) {
275
+ event.preventDefault();
276
+ return false;
277
+ } else {
278
+ var agree = confirm("Are you sure you want to delete this option?");
279
+ if (agree) {
280
+ inlineEditOption.remove(this);
281
+ return false;
282
+ } else {
283
+ return false;
284
+ }
285
+ }
286
+ });
287
+ // Fade out message div
288
+ if ($('.ajax-message').hasClass('show')) {
289
+ $('.ajax-message').ajaxMessage();
290
+ }
291
+ // Remove Uploaded Image
292
+ $('.remove').live('click', function(event) {
293
+ $(this).hide();
294
+ $(this).parents().prev().prev('.upload').attr('value', '');
295
+ $(this).parents('.screenshot').slideUp();
296
+ });
297
+ // Hide the delete button on the first row
298
+ $('a.delete-inline', "#option-1").hide();
299
+ },
300
+ save_options: function (e) {
301
+ var d = {
302
+ action: "option_tree_array_save"
303
+ };
304
+ b = $(':input', '#the-theme-options').serialize();
305
+ d = b + "&" + $.param(d);
306
+ $.post(ajaxurl, d, function (r) {
307
+ if (r != -1) {
308
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Theme Options were saved</div>');
309
+ } else {
310
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>Theme Options could not be saved</div>');
311
+ }
312
+ });
313
+ return false;
314
+ },
315
+ reset_options: function () {
316
+ var d = {
317
+ action: "option_tree_array_reset",
318
+ _ajax_nonce: $("#_ajax_nonce").val()
319
+ };
320
+ $.post(ajaxurl, d, function (r) {
321
+ if (r != -1) {
322
+ $('.screenshot').hide();
323
+ $(':input','#the-theme-options')
324
+ .not(':button, :submit, :reset, :hidden')
325
+ .val('')
326
+ .removeAttr('checked')
327
+ .removeAttr('selected');
328
+ $('.select').each(function () {
329
+ $(this).prev('span').text('-- Choose One --')
330
+ });
331
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Theme Options were deleted</div>');
332
+ } else {
333
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>Theme Options could not be deleted</div>');
334
+ }
335
+ });
336
+ return false;
337
+ },
338
+ import_data: function (e) {
339
+ var d = {
340
+ action: "option_tree_import_data"
341
+ };
342
+ b = $(':input', '#import-data').serialize();
343
+ d = b + "&" + $.param(d);
344
+ $.post(ajaxurl, d, function (r) {
345
+ if (r != -1) {
346
+ $("textarea", "#import_options").val('');
347
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Your Theme Options data was successfully imported.</div>');
348
+ } else {
349
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>Your Theme Options data could not be imported.</div>');
350
+ }
351
+ });
352
+ return false;
353
+ },
354
+ remove: function (b) {
355
+ var c = true;
356
+
357
+ // Set ID
358
+ c = $(b).parents("tr:first").attr('id');
359
+ c = c.substr(c.lastIndexOf("-") + 1);
360
+
361
+ d = {
362
+ action: "option_tree_delete",
363
+ id: c,
364
+ _ajax_nonce: $("#_ajax_nonce").val()
365
+ };
366
+ $.post(ajaxurl, d, function (r) {
367
+ if (r) {
368
+ if (r == 'removed') {
369
+ $("#option-" + c).remove();
370
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Option Deleted.</div>');
371
+ } else {
372
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
373
+ }
374
+ } else {
375
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
376
+ }
377
+ });
378
+ return false;
379
+ },
380
+ add: function (c) {
381
+ var e = this,
382
+ addRow, editRow = true, temp_select;
383
+ e.revert();
384
+
385
+ // Clone the blank main row
386
+ addRow = $('#inline-add').clone(true);
387
+ addRow = $(addRow).attr('id', 'option-'+c);
388
+
389
+ // Clone the blank edit row
390
+ editRow = $('#inline-edit').clone(true);
391
+
392
+ $('a.cancel', editRow).addClass('undo-add');
393
+ $('a.save', editRow).addClass('add-save');
394
+ $('a.edit-inline').addClass('disable');
395
+ $('a.delete-inline').addClass('disable');
396
+ $('a.add-option').addClass('disable');
397
+
398
+ // Set Colspan to 4
399
+ $('td', editRow).attr('colspan', 4);
400
+
401
+ // Add Row
402
+ $("#framework-settings tr:last").after(addRow);
403
+
404
+ // Add Row and hide
405
+ $(addRow).hide().after(editRow);
406
+
407
+ $('.item-data', addRow).attr('id', 'inline_'+c);
408
+
409
+ // Show The Editor
410
+ $(editRow).attr('id', 'edit-'+c).addClass('inline-editor').show();
411
+
412
+ $('.item_title', '#edit-'+c).focus();
413
+
414
+ $('.select').each(function () {
415
+ temp_select = $(this).prev('span').text();
416
+ if (temp_select == 'Heading') {
417
+ $('.option-desc', '#edit-'+c).hide();
418
+ $('.option-options', '#edit-'+c).hide();
419
+ }
420
+ });
421
+
422
+ $('.select').live('change', function () {
423
+ temp_select = $(this).prev('span').text();
424
+ if (temp_select == 'Heading') {
425
+ $('.option-desc', '#edit-'+c).hide();
426
+ $('.option-options', '#edit-'+c).hide();
427
+ } else if (
428
+ temp_select == 'Checkbox' ||
429
+ temp_select == 'Radio' ||
430
+ temp_select == 'Select'
431
+ ) {
432
+ $('.alternative').hide();
433
+ $('.regular').show();
434
+ $('.option-desc', '#edit-'+c).show();
435
+ $('.option-options', '#edit-'+c).show();
436
+ } else {
437
+ if (temp_select == 'Textarea') {
438
+ $('.regular').hide();
439
+ $('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.');
440
+ $('.option-desc', '#edit-'+c).show();
441
+ $('.option-options', '#edit-'+c).show();
442
+ } else if (
443
+ temp_select == 'Custom Post' ||
444
+ temp_select == 'Custom Posts'
445
+ ) {
446
+ $('.regular').hide();
447
+ $('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.');
448
+ $('.option-desc', '#edit-'+c).show();
449
+ $('.option-options', '#edit-'+c).show();
450
+ } else {
451
+ $('.option-desc', '#edit-'+c).show();
452
+ $('.option-options', '#edit-'+c).hide();
453
+ }
454
+ }
455
+ });
456
+
457
+ // Scroll
458
+ $('html, body').animate({ scrollTop: 2000 }, 500);
459
+
460
+ return false;
461
+ },
462
+ undoAdd: function (b) {
463
+ var e = this,
464
+ c = true;
465
+ e.revert();
466
+ c = $("#framework-settings tr:last").attr('id');
467
+ c = c.substr(c.lastIndexOf("-") + 1);
468
+
469
+ $("a.edit-inline").removeClass('disable');
470
+ $("a.delete-inline").removeClass('disable');
471
+ $("a.add-option").removeClass('disable');
472
+ $("#option-" + c).remove();
473
+
474
+ return false;
475
+ },
476
+ addSave: function (e) {
477
+ var d, b, c, f, g, itemId;
478
+ e = $("tr.inline-editor").attr("id");
479
+ e = e.substr(e.lastIndexOf("-") + 1);
480
+ f = $("#edit-" + e);
481
+ g = $("#inline_" + e);
482
+ itemId = $.trim($("input.item_id", f).val().toLowerCase()).replace(/(\s+)/g,'_');
483
+ if (!itemId) {
484
+ itemId = $.trim($("input.item_title", f).val().toLowerCase()).replace(/(\s+)/g,'_');
485
+ }
486
+ d = {
487
+ action: "option_tree_add",
488
+ id: e,
489
+ item_id: itemId,
490
+ item_title: $("input.item_title", f).val(),
491
+ item_desc: $("textarea.item_desc", f).val(),
492
+ item_type: $("select.item_type", f).val(),
493
+ item_options: $("input.item_options", f).val()
494
+ };
495
+ b = $("#edit-" + e + " :input").serialize();
496
+ d = b + "&" + $.param(d);
497
+ $.post(ajaxurl, d, function (r) {
498
+ if (r) {
499
+ if (r == 'updated') {
500
+ inlineEditOption.afterSave(e);
501
+ $("#edit-" + e).remove();
502
+ $("#option-" + e).show();
503
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Option Added.</div>');
504
+ $('#framework-settings').tableDnD({
505
+ onDragClass: "dragging",
506
+ onDrop: function(table, row) {
507
+ d = {
508
+ action: "option_tree_sort",
509
+ id: $.tableDnD.serialize(),
510
+ _ajax_nonce: $("#_ajax_nonce").val()
511
+ };
512
+ $.post(ajaxurl, d, function (response) {
513
+
514
+ }, "html");
515
+ }
516
+ });
517
+ } else {
518
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
519
+ }
520
+ } else {
521
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
522
+ }
523
+ });
524
+ return false;
525
+ },
526
+ edit: function (b) {
527
+ var e = this,
528
+ c, editRow, rowData, item_title, item_id, item_type, item_desc, item_options = true, temp_select;
529
+ e.revert();
530
+
531
+ c = $(b).parents("tr:first").attr('id');
532
+ c = c.substr(c.lastIndexOf("-") + 1);
533
+
534
+ // Clone the blank row
535
+ editRow = $('#inline-edit').clone(true);
536
+ $('td', editRow).attr('colspan', 4);
537
+ $("#option-" + c).hide().after(editRow);
538
+
539
+ // First Option Settings
540
+ if ("#option-" + c == '#option-1') {
541
+ $('.option').hide();
542
+ $('.option-title').show().css({"paddingBottom":"1px"});
543
+ $('.description', editRow).html('First item must be a heading.');
544
+ }
545
+
546
+ // Populate the option data
547
+ rowData = $('#inline_' + c);
548
+
549
+ // Item Title
550
+ item_title = $('.item_title', rowData).text();
551
+ $('.item_title', editRow).attr('value', item_title);
552
+
553
+ // Item ID
554
+ item_id = $('.item_id', rowData).text();
555
+ $('.item_id', editRow).attr('value', item_id);
556
+
557
+ // Item Type
558
+ item_type = $('.item_type', rowData).text();
559
+ $('select[name=item_type] option[value='+item_type+']', editRow).attr('selected', true);
560
+ var temp_item_type = $('select[name=item_type] option[value='+item_type+']', editRow).text();
561
+ $('.select_wrapper span', editRow).text(temp_item_type);
562
+
563
+ // Item Description
564
+ item_desc = $('.item_desc', rowData).text();
565
+ $('.item_desc', editRow).attr('value', item_desc);
566
+
567
+ // Item Options
568
+ item_options = $('.item_options', rowData).text();
569
+ $('.item_options', editRow).attr('value', item_options);
570
+
571
+
572
+ $('.select', editRow).each(function () {
573
+ temp_select = $(this).prev('span').text();
574
+ if (temp_select == 'Heading') {
575
+ $('.option-desc', editRow).hide();
576
+ $('.option-options', editRow).hide();
577
+ } else if (
578
+ temp_select == 'Checkbox' ||
579
+ temp_select == 'Radio' ||
580
+ temp_select == 'Select'
581
+ ) {
582
+ $('.option-desc', editRow).show();
583
+ $('.option-options', editRow).show();
584
+ } else {
585
+ if (temp_select == 'Textarea') {
586
+ $('.regular').hide();
587
+ $('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.');
588
+ $('.option-desc', editRow).show();
589
+ $('.option-options', editRow).show();
590
+ } else if (
591
+ temp_select == 'Custom Post' ||
592
+ temp_select == 'Custom Posts'
593
+ ) {
594
+ $('.regular').hide();
595
+ $('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.');
596
+ $('.option-desc', editRow).show();
597
+ $('.option-options', editRow).show();
598
+ } else {
599
+ $('.option-desc', editRow).show();
600
+ $('.option-options', editRow).hide();
601
+ }
602
+ }
603
+ });
604
+
605
+ $('.select').live('change', function () {
606
+ temp_select = $(this).prev('span').text();
607
+ if (temp_select == 'Heading') {
608
+ $('.option-desc', editRow).hide();
609
+ $('.option-options', editRow).hide();
610
+ } else if (
611
+ temp_select == 'Checkbox' ||
612
+ temp_select == 'Radio' ||
613
+ temp_select == 'Select'
614
+ ) {
615
+ $('.alternative').hide();
616
+ $('.regular').show();
617
+ $('.option-desc', editRow).show();
618
+ $('.option-options', editRow).show();
619
+ } else {
620
+ if (temp_select == 'Textarea') {
621
+ $('.regular').hide();
622
+ $('.alternative').show().html('<strong>Row Count:</strong> Enter a numeric value for the number of rows in your textarea.');
623
+ $('.option-desc', editRow).show();
624
+ $('.option-options', editRow).show();
625
+ } else if (
626
+ temp_select == 'Custom Post' ||
627
+ temp_select == 'Custom Posts'
628
+ ) {
629
+ $('.regular').hide();
630
+ $('.alternative').show().html('<strong>Post Type:</strong> Enter your custom post_type.');
631
+ $('.option-desc', editRow).show();
632
+ $('.option-options', editRow).show();
633
+ } else {
634
+ $('.option-desc', editRow).show();
635
+ $('.option-options', editRow).hide();
636
+ }
637
+ }
638
+ });
639
+
640
+ // Show The Editor
641
+ $(editRow).attr('id', 'edit-'+c).addClass('inline-editor').show();
642
+
643
+ // Scroll
644
+ var target = $('#edit-'+c);
645
+ if (c > 1) {
646
+ var top = target.offset().top;
647
+ $('html,body').animate({scrollTop: top}, 500);
648
+ return false;
649
+ }
650
+
651
+ return false;
652
+ },
653
+ editSave: function (e) {
654
+ var d, b, c, f, g, itemId;
655
+ e = $("tr.inline-editor").attr("id");
656
+ e = e.substr(e.lastIndexOf("-") + 1);
657
+ f = $("#edit-" + e);
658
+ g = $("#inline_" + e);
659
+ itemId = $.trim($("input.item_id", f).val().toLowerCase()).replace(/(\s+)/g,'_');
660
+ if (!itemId) {
661
+ itemId = $.trim($("input.item_title", f).val().toLowerCase()).replace(/(\s+)/g,'_');
662
+ }
663
+ d = {
664
+ action: "option_tree_edit",
665
+ id: e,
666
+ item_id: itemId,
667
+ item_title: $("input.item_title", f).val(),
668
+ item_desc: $("textarea.item_desc", f).val(),
669
+ item_type: $("select.item_type", f).val(),
670
+ item_options: $("input.item_options", f).val()
671
+ };
672
+ b = $("#edit-" + e + " :input").serialize();
673
+ d = b + "&" + $.param(d);
674
+ $.post(ajaxurl, d, function (r) {
675
+ if (r) {
676
+ if (r == 'updated') {
677
+ inlineEditOption.afterSave(e);
678
+ $("#edit-" + e).remove();
679
+ $("#option-" + e).show();
680
+ $('.ajax-message').ajaxMessage('<div class="message"><span>&nbsp;</span>Option Saved.</div>');
681
+ } else {
682
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
683
+ }
684
+ } else {
685
+ $('.ajax-message').ajaxMessage('<div class="message warning"><span>&nbsp;</span>'+r+'</div>');
686
+ }
687
+ });
688
+ return false;
689
+ },
690
+ afterSave: function (e) {
691
+ var x, y, z,
692
+ n, m, o, p, q, r = true;
693
+ x = $("#edit-" + e);
694
+ y = $("#option-" + e);
695
+ z = $("#inline_" + e);
696
+ $('.option').show();
697
+ $('a.cancel', x).removeClass('undo-add');
698
+ $('a.save', x).removeClass('add-save');
699
+ $("a.add-option").removeClass('disable');
700
+ $('a.edit-inline').removeClass('disable');
701
+ $('a.delete-inline').removeClass('disable');
702
+ if (n = $("input.item_title", x).val()) {
703
+ if ($("select.item_type", x).val() != 'heading') {
704
+ $(y).removeClass('col-heading');
705
+ $('.col-title', y).attr('colspan', 1);
706
+ $(".col-key", y).show();
707
+ $(".col-type", y).show();
708
+ $(".col-title", y).text('- ' + n);
709
+ } else {
710
+ $(y).addClass('col-heading');
711
+ $('.col-title', y).attr('colspan', 3);
712
+ $(".col-key", y).hide();
713
+ $(".col-type", y).hide();
714
+ $(".col-title", y).text(n);
715
+ }
716
+ $(".item_title", z).text(n);
717
+ }
718
+ if (m = $.trim($("input.item_id", x).val().toLowerCase()).replace(/(\s+)/g,'_')) {
719
+ $(".col-key", y).text(m);
720
+ $(".item_id", z).text(m);
721
+ } else {
722
+ m = $.trim($("input.item_title", x).val().toLowerCase()).replace(/(\s+)/g,'_');
723
+ $(".col-key", y).text(m);
724
+ $(".item_id", z).text(m);
725
+ }
726
+ if (o = $("select.item_type option:selected", x).val()) {
727
+ $(".col-type", y).text(o);
728
+ $(".item_type", z).text(o);
729
+ }
730
+ if (p = $("textarea.item_desc", x).val()) {
731
+ $(".item_desc", z).text(p);
732
+ }
733
+ if (r = $("input.item_options", x).val()) {
734
+ $(".item_options", z).text(r);
735
+ }
736
+ },
737
+ revert: function () {
738
+ var b,
739
+ n, m, o, p, q, r = true;
740
+ if (b = $(".inline-editor").attr("id")) {
741
+ $('#'+ b).remove();
742
+ b = b.substr(b.lastIndexOf("-") + 1);
743
+ $('.option').show();
744
+ $("#option-" + b).show();
745
+ }
746
+ return false;
747
+ }
748
+ };
749
+ $(document).ready(function () {
750
+ inlineEditOption.init()
751
+ })
752
+ })(jQuery);
assets/js/jquery.table.dnd.js ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * TableDnD plug-in for JQuery, allows you to drag and drop table rows
3
+ * You can set up various options to control how the system will work
4
+ * Copyright (c) Denis Howlett <denish@isocra.com>
5
+ * Licensed like jQuery, see http://docs.jquery.com/License.
6
+ *
7
+ * Configuration options:
8
+ *
9
+ * onDragStyle
10
+ * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
11
+ * associated with a row (such as you can't assign a border--well you can, but it won't be
12
+ * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
13
+ * a map (as used in the jQuery css(...) function).
14
+ * onDropStyle
15
+ * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
16
+ * to what you can do. Also this replaces the original style, so again consider using onDragClass which
17
+ * is simply added and then removed on drop.
18
+ * onDragClass
19
+ * This class is added for the duration of the drag and then removed when the row is dropped. It is more
20
+ * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
21
+ * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
22
+ * stylesheet.
23
+ * onDrop
24
+ * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
25
+ * and the row that was dropped. You can work out the new order of the rows by using
26
+ * table.rows.
27
+ * onDragStart
28
+ * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
29
+ * table and the row which the user has started to drag.
30
+ * onAllowDrop
31
+ * Pass a function that will be called as a row is over another row. If the function returns true, allow
32
+ * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
33
+ * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
34
+ * scrollAmount
35
+ * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
36
+ * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
37
+ * FF3 beta
38
+ * dragHandle
39
+ * This is the name of a class that you assign to one or more cells in each row that is draggable. If you
40
+ * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
41
+ * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
42
+ * the whole row is draggable.
43
+ *
44
+ * Other ways to control behaviour:
45
+ *
46
+ * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
47
+ * that you don't want to be draggable.
48
+ *
49
+ * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
50
+ * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
51
+ * an ID as must all the rows.
52
+ *
53
+ * Other methods:
54
+ *
55
+ * $("...").tableDnDUpdate()
56
+ * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
57
+ * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
58
+ * The table maintains the original configuration (so you don't have to specify it again).
59
+ *
60
+ * $("...").tableDnDSerialize()
61
+ * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
62
+ * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
63
+ *
64
+ * Known problems:
65
+ * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
66
+ *
67
+ * Version 0.2: 2008-02-20 First public version
68
+ * Version 0.3: 2008-02-07 Added onDragStart option
69
+ * Made the scroll amount configurable (default is 5 as before)
70
+ * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
71
+ * Added onAllowDrop to control dropping
72
+ * Fixed a bug which meant that you couldn't set the scroll amount in both directions
73
+ * Added serialize method
74
+ * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
75
+ * draggable
76
+ * Improved the serialize method to use a default (and settable) regular expression.
77
+ * Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
78
+ */
79
+ jQuery.tableDnD = {
80
+ /** Keep hold of the current table being dragged */
81
+ currentTable : null,
82
+ /** Keep hold of the current drag object if any */
83
+ dragObject: null,
84
+ /** The current mouse offset */
85
+ mouseOffset: null,
86
+ /** Remember the old value of Y so that we don't do too much processing */
87
+ oldY: 0,
88
+
89
+ /** Actually build the structure */
90
+ build: function(options) {
91
+ // Set up the defaults if any
92
+
93
+ this.each(function() {
94
+ // This is bound to each matching table, set up the defaults and override with user options
95
+ this.tableDnDConfig = jQuery.extend({
96
+ onDragStyle: null,
97
+ onDropStyle: null,
98
+ // Add in the default class for whileDragging
99
+ onDragClass: "tDnD_whileDrag",
100
+ onDrop: null,
101
+ onDragStart: null,
102
+ scrollAmount: 5,
103
+ serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
104
+ serializeParamName: null, // If you want to specify another parameter name instead of the table ID
105
+ dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
106
+ }, options || {});
107
+ // Now make the rows draggable
108
+ jQuery.tableDnD.makeDraggable(this);
109
+ });
110
+
111
+ // Now we need to capture the mouse up and mouse move event
112
+ // We can use bind so that we don't interfere with other event handlers
113
+ jQuery(document)
114
+ .bind('mousemove', jQuery.tableDnD.mousemove)
115
+ .bind('mouseup', jQuery.tableDnD.mouseup);
116
+
117
+ // Don't break the chain
118
+ return this;
119
+ },
120
+
121
+ /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
122
+ makeDraggable: function(table) {
123
+ var config = table.tableDnDConfig;
124
+ if (table.tableDnDConfig.dragHandle) {
125
+ // We only need to add the event to the specified cells
126
+ var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
127
+ cells.each(function() {
128
+ // The cell is bound to "this"
129
+ jQuery(this).mousedown(function(ev) {
130
+ jQuery.tableDnD.dragObject = this.parentNode;
131
+ jQuery.tableDnD.currentTable = table;
132
+ jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
133
+ if (config.onDragStart) {
134
+ // Call the onDrop method if there is one
135
+ config.onDragStart(table, this);
136
+ }
137
+ return false;
138
+ });
139
+ })
140
+ } else {
141
+ // For backwards compatibility, we add the event to the whole row
142
+ var rows = jQuery("tr", table); // get all the rows as a wrapped set
143
+ rows.each(function() {
144
+ // Iterate through each row, the row is bound to "this"
145
+ var row = jQuery(this);
146
+ if (! row.hasClass("nodrag")) {
147
+ row.mousedown(function(ev) {
148
+ if (ev.target.tagName == "TD") {
149
+ jQuery.tableDnD.dragObject = this;
150
+ jQuery.tableDnD.currentTable = table;
151
+ jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
152
+ if (config.onDragStart) {
153
+ // Call the onDrop method if there is one
154
+ config.onDragStart(table, this);
155
+ }
156
+ return false;
157
+ }
158
+ }).css("cursor", "move"); // Store the tableDnD object
159
+ }
160
+ });
161
+ }
162
+ },
163
+
164
+ updateTables: function() {
165
+ this.each(function() {
166
+ // this is now bound to each matching table
167
+ if (this.tableDnDConfig) {
168
+ jQuery.tableDnD.makeDraggable(this);
169
+ }
170
+ })
171
+ },
172
+
173
+ /** Get the mouse coordinates from the event (allowing for browser differences) */
174
+ mouseCoords: function(ev){
175
+ if(ev.pageX || ev.pageY){
176
+ return {x:ev.pageX, y:ev.pageY};
177
+ }
178
+ return {
179
+ x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
180
+ y:ev.clientY + document.body.scrollTop - document.body.clientTop
181
+ };
182
+ },
183
+
184
+ /** Given a target element and a mouse event, get the mouse offset from that element.
185
+ To do this we need the element's position and the mouse position */
186
+ getMouseOffset: function(target, ev) {
187
+ ev = ev || window.event;
188
+
189
+ var docPos = this.getPosition(target);
190
+ var mousePos = this.mouseCoords(ev);
191
+ return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
192
+ },
193
+
194
+ /** Get the position of an element by going up the DOM tree and adding up all the offsets */
195
+ getPosition: function(e){
196
+ var left = 0;
197
+ var top = 0;
198
+ /** Safari fix -- thanks to Luis Chato for this! */
199
+ if (e.offsetHeight == 0) {
200
+ /** Safari 2 doesn't correctly grab the offsetTop of a table row
201
+ this is detailed here:
202
+ http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
203
+ the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
204
+ note that firefox will return a text node as a first child, so designing a more thorough
205
+ solution may need to take that into account, for now this seems to work in firefox, safari, ie */
206
+ e = e.firstChild; // a table cell
207
+ }
208
+
209
+ while (e.offsetParent){
210
+ left += e.offsetLeft;
211
+ top += e.offsetTop;
212
+ e = e.offsetParent;
213
+ }
214
+
215
+ left += e.offsetLeft;
216
+ top += e.offsetTop;
217
+
218
+ return {x:left, y:top};
219
+ },
220
+
221
+ mousemove: function(ev) {
222
+ if (jQuery.tableDnD.dragObject == null) {
223
+ return;
224
+ }
225
+
226
+ var dragObj = jQuery(jQuery.tableDnD.dragObject);
227
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
228
+ var mousePos = jQuery.tableDnD.mouseCoords(ev);
229
+ var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
230
+ //auto scroll the window
231
+ var yOffset = window.pageYOffset;
232
+ if (document.all) {
233
+ // Windows version
234
+ //yOffset=document.body.scrollTop;
235
+ if (typeof document.compatMode != 'undefined' &&
236
+ document.compatMode != 'BackCompat') {
237
+ yOffset = document.documentElement.scrollTop;
238
+ }
239
+ else if (typeof document.body != 'undefined') {
240
+ yOffset=document.body.scrollTop;
241
+ }
242
+
243
+ }
244
+
245
+ if (mousePos.y-yOffset < config.scrollAmount) {
246
+ window.scrollBy(0, -config.scrollAmount);
247
+ } else {
248
+ var windowHeight = window.innerHeight ? window.innerHeight
249
+ : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
250
+ if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
251
+ window.scrollBy(0, config.scrollAmount);
252
+ }
253
+ }
254
+
255
+
256
+ if (y != jQuery.tableDnD.oldY) {
257
+ // work out if we're going up or down...
258
+ var movingDown = y > jQuery.tableDnD.oldY;
259
+ // update the old value
260
+ jQuery.tableDnD.oldY = y;
261
+ // update the style to show we're dragging
262
+ if (config.onDragClass) {
263
+ dragObj.addClass(config.onDragClass);
264
+ } else {
265
+ dragObj.css(config.onDragStyle);
266
+ }
267
+ // If we're over a row then move the dragged row to there so that the user sees the
268
+ // effect dynamically
269
+ var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
270
+ if (currentRow) {
271
+ // TODO worry about what happens when there are multiple TBODIES
272
+ if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
273
+ jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
274
+ } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
275
+ jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
276
+ }
277
+ }
278
+ }
279
+
280
+ return false;
281
+ },
282
+
283
+ /** We're only worried about the y position really, because we can only move rows up and down */
284
+ findDropTargetRow: function(draggedRow, y) {
285
+ var rows = jQuery.tableDnD.currentTable.rows;
286
+ for (var i=0; i<rows.length; i++) {
287
+ var row = rows[i];
288
+ var rowY = this.getPosition(row).y;
289
+ var rowHeight = parseInt(row.offsetHeight)/2;
290
+ if (row.offsetHeight == 0) {
291
+ rowY = this.getPosition(row.firstChild).y;
292
+ rowHeight = parseInt(row.firstChild.offsetHeight)/2;
293
+ }
294
+ // Because we always have to insert before, we need to offset the height a bit
295
+ if ((y > rowY - rowHeight) && (y < (rowY + rowHeight + rowHeight))) {
296
+ // that's the row we're over
297
+ // If it's the same as the current row, ignore it
298
+ if (row == draggedRow) {return null;}
299
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
300
+ if (config.onAllowDrop) {
301
+ if (config.onAllowDrop(draggedRow, row)) {
302
+ return row;
303
+ } else {
304
+ return null;
305
+ }
306
+ } else {
307
+ // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
308
+ var nodrop = jQuery(row).hasClass("nodrop");
309
+ if (! nodrop) {
310
+ return row;
311
+ } else {
312
+ return null;
313
+ }
314
+ }
315
+ return row;
316
+ }
317
+ }
318
+ return null;
319
+ },
320
+
321
+ mouseup: function(e) {
322
+ if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
323
+ var droppedRow = jQuery.tableDnD.dragObject;
324
+ var config = jQuery.tableDnD.currentTable.tableDnDConfig;
325
+ // If we have a dragObject, then we need to release it,
326
+ // The row will already have been moved to the right place so we just reset stuff
327
+ if (config.onDragClass) {
328
+ jQuery(droppedRow).removeClass(config.onDragClass);
329
+ } else {
330
+ jQuery(droppedRow).css(config.onDropStyle);
331
+ }
332
+ jQuery.tableDnD.dragObject = null;
333
+ if (config.onDrop) {
334
+ // Call the onDrop method if there is one
335
+ config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
336
+ }
337
+ jQuery.tableDnD.currentTable = null; // let go of the table too
338
+ }
339
+ },
340
+
341
+ serialize: function() {
342
+ if (jQuery.tableDnD.currentTable) {
343
+ return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
344
+ } else {
345
+ return "Error: No Table id set, you need to set an id on your table and every row";
346
+ }
347
+ },
348
+
349
+ serializeTable: function(table) {
350
+ var result = "";
351
+ var tableId = table.id;
352
+ var rows = table.rows;
353
+ for (var i=0; i<rows.length; i++) {
354
+ if (result.length > 0) result += "&";
355
+ var rowId = rows[i].id;
356
+ if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
357
+ rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
358
+ }
359
+
360
+ result += tableId + '[]=' + rowId;
361
+ }
362
+ return result;
363
+ },
364
+
365
+ serializeTables: function() {
366
+ var result = "";
367
+ this.each(function() {
368
+ // this is now bound to each matching table
369
+ result += jQuery.tableDnD.serializeTable(this);
370
+ });
371
+ return result;
372
+ }
373
+
374
+ }
375
+
376
+ jQuery.fn.extend(
377
+ {
378
+ tableDnD : jQuery.tableDnD.build,
379
+ tableDnDUpdate : jQuery.tableDnD.updateTables,
380
+ tableDnDSerialize: jQuery.tableDnD.serializeTables
381
+ }
382
+ );
assets/test/test-data.txt ADDED
@@ -0,0 +1 @@
 
1
+ YToxMzp7czoxNToiZ2VuZXJhbF9kZWZhdWx0IjtzOjEyOiJUZXN0IE9wdGlvbnMiO3M6NToiaW5wdXQiO3M6MTQ6IlRoaXMgaXMgYSB0ZXMhIjtzOjg6ImNoZWNrYm94IjtzOjM6InllcyI7czo1OiJyYWRpbyI7czoyOiJubyI7czo2OiJzZWxlY3QiO3M6MDoiIjtzOjg6InRleHRhcmVhIjtzOjI1OiJKdXN0IHNvbWUgbW9yZSB0ZXN0IGRhdGEhIjtzOjY6InVwbG9hZCI7czowOiIiO3M6MTE6ImNvbG9ycGlja2VyIjtzOjA6IiI7czo4OiJjYXRlZ29yeSI7czowOiIiO3M6MzoidGFnIjtzOjA6IiI7czo0OiJwb3N0IjtzOjA6IiI7czo0OiJwYWdlIjtzOjA6IiI7czoxMToiY3VzdG9tX3Bvc3QiO3M6MDoiIjt9
assets/test/test-options.xml ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <wp_option_tree>
3
+ <row>
4
+ <id>1</id>
5
+ <item_id>general_default</item_id>
6
+ <item_title>Test Options</item_title>
7
+ <item_desc></item_desc>
8
+ <item_type>heading</item_type>
9
+ <item_options></item_options>
10
+ <item_sort>1</item_sort>
11
+ </row>
12
+ <row>
13
+ <id>2</id>
14
+ <item_id>textblock</item_id>
15
+ <item_title>Textblock</item_title>
16
+ <item_desc>&amp;lt;h3&amp;gt;Textblock&amp;lt;/h3&amp;gt;
17
+ &amp;lt;p&amp;gt;Here is a &amp;lt;strong&amp;gt;textblock&amp;lt;/strong&amp;gt; with HTML in it. You can use this space to transition to the next section or subsection within a tab on the &amp;lt;em&amp;gt;Theme Options&amp;lt;/em&amp;gt; page. It&amp;#039;s use is strictly for the admin UI and is not for the front-end of the web site.&amp;lt;/p&amp;gt;</item_desc>
18
+ <item_type>textblock</item_type>
19
+ <item_options></item_options>
20
+ <item_sort>2</item_sort>
21
+ </row>
22
+ <row>
23
+ <id>3</id>
24
+ <item_id>input</item_id>
25
+ <item_title>Input</item_title>
26
+ <item_desc>You can save a simple string here. Maybe a link to feedburner or your Twitter username.</item_desc>
27
+ <item_type>input</item_type>
28
+ <item_options></item_options>
29
+ <item_sort>3</item_sort>
30
+ </row>
31
+ <row>
32
+ <id>4</id>
33
+ <item_id>checkbox</item_id>
34
+ <item_title>Checkbox</item_title>
35
+ <item_desc>You could ask a question with a checkbox. For example, do you want to activate asynchronous Google analytics?</item_desc>
36
+ <item_type>checkbox</item_type>
37
+ <item_options>yes</item_options>
38
+ <item_sort>4</item_sort>
39
+ </row>
40
+ <row>
41
+ <id>5</id>
42
+ <item_id>radio</item_id>
43
+ <item_title>Radio</item_title>
44
+ <item_desc>You could ask a question with a radio input. For example, do you want to activate asynchronous Google analytics?</item_desc>
45
+ <item_type>radio</item_type>
46
+ <item_options>yes,no</item_options>
47
+ <item_sort>5</item_sort>
48
+ </row>
49
+ <row>
50
+ <id>6</id>
51
+ <item_id>select</item_id>
52
+ <item_title>Select</item_title>
53
+ <item_desc>Use this to list different theme styles or choose some other important setting.</item_desc>
54
+ <item_type>select</item_type>
55
+ <item_options>yes,no</item_options>
56
+ <item_sort>6</item_sort>
57
+ </row>
58
+ <row>
59
+ <id>7</id>
60
+ <item_id>textarea</item_id>
61
+ <item_title>Textarea</item_title>
62
+ <item_desc>Here users can add custom code or text for use in your theme.</item_desc>
63
+ <item_type>textarea</item_type>
64
+ <item_options>6</item_options>
65
+ <item_sort>7</item_sort>
66
+ </row>
67
+ <row>
68
+ <id>8</id>
69
+ <item_id>upload</item_id>
70
+ <item_title>Upload</item_title>
71
+ <item_desc>Here you can upload any WordPress supported media. After uploading, hit the &amp;quot;Insert into Post&amp;quot; button. One caveat of this feature is that if you upload media on one site the URL will no be correct if you import the data to a new one. You&amp;#039;ll have to re-upload the media.</item_desc>
72
+ <item_type>upload</item_type>
73
+ <item_options></item_options>
74
+ <item_sort>8</item_sort>
75
+ </row>
76
+ <row>
77
+ <id>9</id>
78
+ <item_id>colorpicker</item_id>
79
+ <item_title>Colorpicker</item_title>
80
+ <item_desc>This is a very self explanatory feature. Use it to change the color of something.</item_desc>
81
+ <item_type>colorpicker</item_type>
82
+ <item_options></item_options>
83
+ <item_sort>9</item_sort>
84
+ </row>
85
+ <row>
86
+ <id>10</id>
87
+ <item_id>category</item_id>
88
+ <item_title>Category</item_title>
89
+ <item_desc>Choose from a list of categories and save as a single category ID for use in a function or loop.</item_desc>
90
+ <item_type>category</item_type>
91
+ <item_options></item_options>
92
+ <item_sort>10</item_sort>
93
+ </row>
94
+ <row>
95
+ <id>11</id>
96
+ <item_id>categories</item_id>
97
+ <item_title>Categories</item_title>
98
+ <item_desc>Choose from a list of categories and save multiple category ID&amp;#039;s for use in a function or loop.</item_desc>
99
+ <item_type>categories</item_type>
100
+ <item_options></item_options>
101
+ <item_sort>11</item_sort>
102
+ </row>
103
+ <row>
104
+ <id>12</id>
105
+ <item_id>tag</item_id>
106
+ <item_title>Tag</item_title>
107
+ <item_desc>Choose from a list of tags and save as a single tag ID for use in a function or loop.</item_desc>
108
+ <item_type>tag</item_type>
109
+ <item_options></item_options>
110
+ <item_sort>12</item_sort>
111
+ </row>
112
+ <row>
113
+ <id>13</id>
114
+ <item_id>tags</item_id>
115
+ <item_title>Tags</item_title>
116
+ <item_desc>Choose from a list of tags and save as multiple tag ID&amp;#039;s for use in a function or loop.</item_desc>
117
+ <item_type>tags</item_type>
118
+ <item_options></item_options>
119
+ <item_sort>13</item_sort>
120
+ </row>
121
+ <row>
122
+ <id>14</id>
123
+ <item_id>post</item_id>
124
+ <item_title>Post</item_title>
125
+ <item_desc>Choose from a list of posts and save as a single post ID for use in a function or loop.</item_desc>
126
+ <item_type>post</item_type>
127
+ <item_options></item_options>
128
+ <item_sort>14</item_sort>
129
+ </row>
130
+ <row>
131
+ <id>15</id>
132
+ <item_id>posts</item_id>
133
+ <item_title>Posts</item_title>
134
+ <item_desc>Choose from a list of posts and save as multiple post ID&amp;#039;s for use in a function or loop.</item_desc>
135
+ <item_type>posts</item_type>
136
+ <item_options></item_options>
137
+ <item_sort>15</item_sort>
138
+ </row>
139
+ <row>
140
+ <id>16</id>
141
+ <item_id>page</item_id>
142
+ <item_title>Page</item_title>
143
+ <item_desc>Choose from a list of pages and save as a single page ID for use in a function or loop.</item_desc>
144
+ <item_type>page</item_type>
145
+ <item_options></item_options>
146
+ <item_sort>16</item_sort>
147
+ </row>
148
+ <row>
149
+ <id>17</id>
150
+ <item_id>pages</item_id>
151
+ <item_title>Pages</item_title>
152
+ <item_desc>Choose from a list of pages and save as multiple page ID&amp;#039;s for use in a function or loop.</item_desc>
153
+ <item_type>pages</item_type>
154
+ <item_options></item_options>
155
+ <item_sort>17</item_sort>
156
+ </row>
157
+ <row>
158
+ <id>18</id>
159
+ <item_id>custom_post</item_id>
160
+ <item_title>Custom Post</item_title>
161
+ <item_desc>Choose from a list of any post type and save as a single ID for use in a function or loop.</item_desc>
162
+ <item_type>custom_post</item_type>
163
+ <item_options>attachment</item_options>
164
+ <item_sort>18</item_sort>
165
+ </row>
166
+ <row>
167
+ <id>19</id>
168
+ <item_id>custom_posts</item_id>
169
+ <item_title>Custom Posts</item_title>
170
+ <item_desc>Choose from a list of any post type and save as multiple ID&amp;#039;s for use in a function or loop.</item_desc>
171
+ <item_type>custom_posts</item_type>
172
+ <item_options>attachment</item_options>
173
+ <item_sort>19</item_sort>
174
+ </row>
175
+ </wp_option_tree>
classes/class.admin.php ADDED
@@ -0,0 +1,1113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * OptionTree Admin
4
+ *
5
+ * @package WordPress
6
+ * @subpackage OptionTree
7
+ * @since 1.0.0
8
+ * @author Derek Herman
9
+ */
10
+ class OT_Admin
11
+ {
12
+ private $table_name = NULL;
13
+ private $version = NULL;
14
+ private $option_array = array();
15
+
16
+ function __construct()
17
+ {
18
+ global $table_prefix;
19
+
20
+ $this->table_name = $table_prefix . 'option_tree';
21
+ $this->version = OT_VERSION;
22
+ $this->option_array = $this->option_tree_data();
23
+ }
24
+
25
+ /**
26
+ * Initiate Plugin & setup main options
27
+ *
28
+ * @uses get_option()
29
+ * @uses add_option()
30
+ * @uses option_tree_activate()
31
+ * @uses wp_redirect()
32
+ * @uses admin_url()
33
+ *
34
+ * @access public
35
+ * @since 1.0.0
36
+ *
37
+ * @return bool
38
+ */
39
+ function option_tree_init()
40
+ {
41
+ // check for activation
42
+ $check = get_option( 'option_tree_activation' );
43
+
44
+ // redirect on activation
45
+ if ($check != "set")
46
+ {
47
+ // set blank option values
48
+ foreach ( $this->option_array as $value )
49
+ {
50
+ $key = $value->item_id;
51
+ $new_options[$key] = '';
52
+ }
53
+
54
+ // add theme options
55
+ add_option( 'option_tree', $new_options );
56
+ add_option( 'option_tree_activation', 'set');
57
+
58
+ // load DB activation function if updating plugin
59
+ $this->option_tree_activate();
60
+
61
+ // Redirect
62
+ wp_redirect( admin_url().'admin.php?page=option_tree_settings#import_options' );
63
+ }
64
+ return false;
65
+ }
66
+
67
+ /**
68
+ * Plugin Table Structure
69
+ *
70
+ * @access public
71
+ * @since 1.0.0
72
+ *
73
+ * @param string $type
74
+ *
75
+ * @return string
76
+ */
77
+ function option_tree_table( $type = '')
78
+ {
79
+ if ( $type == 'create' )
80
+ {
81
+ $sql = "CREATE TABLE {$this->table_name} (
82
+ id mediumint(9) NOT NULL AUTO_INCREMENT PRIMARY KEY,
83
+ item_id VARCHAR(50) NOT NULL,
84
+ item_title VARCHAR(100) NOT NULL,
85
+ item_desc LONGTEXT,
86
+ item_type VARCHAR(30) NOT NULL,
87
+ item_options VARCHAR(250) DEFAULT NULL,
88
+ item_sort mediumint(9) DEFAULT '0' NOT NULL,
89
+ UNIQUE KEY (item_id)
90
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
91
+ }
92
+ return $sql;
93
+ }
94
+
95
+ /**
96
+ * Plugin Activation
97
+ *
98
+ * @uses get_var()
99
+ * @uses get_option()
100
+ * @uses dbDelta()
101
+ * @uses option_tree_table()
102
+ * @uses option_tree_default_data()
103
+ * @uses update_option()
104
+ * @uses add_option()
105
+ *
106
+ * @access public
107
+ * @since 1.0.0
108
+ *
109
+ * @return void
110
+ */
111
+ function option_tree_activate()
112
+ {
113
+ global $wpdb;
114
+
115
+ // check for table
116
+ $new_installation = $wpdb->get_var( "show tables like '$this->table_name'" ) != $this->table_name;
117
+
118
+ // check for installed version
119
+ $installed_ver = get_option( 'option_tree_version' );
120
+
121
+ // add/update table
122
+ if ( $installed_ver != $this->version )
123
+ {
124
+ // run query
125
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
126
+ dbDelta( $this->option_tree_table( 'create' ) );
127
+ }
128
+
129
+ // new install default data
130
+ if ( $new_installation )
131
+ {
132
+ $this->option_tree_default_data();
133
+ }
134
+
135
+ // New Version Update
136
+ if ( $installed_ver != $this->version )
137
+ {
138
+ update_option( 'option_tree_version', $this->version );
139
+ }
140
+ else if ( !$installed_ver )
141
+ {
142
+ add_option( 'option_tree_version', $this->version );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Plugin Deactivation delete options
148
+ *
149
+ * @uses delete_option()
150
+ *
151
+ * @access public
152
+ * @since 1.0.0
153
+ *
154
+ * @return void
155
+ */
156
+ function option_tree_deactivate()
157
+ {
158
+ // remove activation check & version
159
+ delete_option( 'option_tree_activation' );
160
+ delete_option( 'option_tree_version' );
161
+ }
162
+
163
+ /**
164
+ * Plugin Activation Default Data
165
+ *
166
+ * @uses query()
167
+ * @uses prepare()
168
+ *
169
+ * @access public
170
+ * @since 1.0.0
171
+ *
172
+ * @return void
173
+ */
174
+ function option_tree_default_data()
175
+ {
176
+ global $wpdb;
177
+
178
+ // default data
179
+ $wpdb->query( $wpdb->prepare( "
180
+ INSERT INTO {$this->table_name}
181
+ ( item_id, item_title, item_type )
182
+ VALUES ( %s, %s, %s ) ",
183
+ array('general_default','General','heading') ) );
184
+
185
+ $wpdb->query( $wpdb->prepare( "
186
+ INSERT INTO {$this->table_name}
187
+ ( item_id, item_title, item_type )
188
+ VALUES ( %s, %s, %s ) ",
189
+ array('test_input','Test Input','input') ) );
190
+ }
191
+
192
+ /**
193
+ * Restore Table Data if empty
194
+ *
195
+ * @uses delete_option()
196
+ * @uses option_tree_activate()
197
+ * @uses wp_redirect()
198
+ * @uses admin_url()
199
+ *
200
+ * @access public
201
+ * @since 1.0.0
202
+ *
203
+ * @return void
204
+ */
205
+ function option_tree_restore_default_data()
206
+ {
207
+ global $wpdb;
208
+
209
+ // drop table
210
+ $wpdb->query( "DROP TABLE $this->table_name" );
211
+
212
+ // remove activation check
213
+ delete_option( 'option_tree_version' );
214
+
215
+ // load DB activation function
216
+ $this->option_tree_activate();
217
+
218
+ // Redirect
219
+ wp_redirect( admin_url().'admin.php?page=option_tree_settings' );
220
+ }
221
+
222
+ /**
223
+ * Add Admin Menu Items & Test Actions
224
+ *
225
+ * @uses option_tree_export_xml()
226
+ * @uses option_tree_data()
227
+ * @uses get_results()
228
+ * @uses option_tree_restore_default_data()
229
+ * @uses option_tree_activate()
230
+ * @uses get_option()
231
+ * @uses option_tree_import_xml()
232
+ * @uses get_user_option()
233
+ * @uses add_object_page()
234
+ * @uses add_submenu_page()
235
+ * @uses add_action()
236
+ *
237
+ * @access public
238
+ * @since 1.0.0
239
+ *
240
+ * @param int $param
241
+ *
242
+ * @return void
243
+ */
244
+ function option_tree_admin()
245
+ {
246
+ global $wpdb;
247
+
248
+ // export XML - run before anything else
249
+ if ( isset($_GET['action']) && $_GET['action'] == 'export' )
250
+ option_tree_export_xml( $this->option_tree_data(), $this->table_name );
251
+
252
+ // grab saved table option
253
+ $test_options = $wpdb->get_results( "SELECT * FROM {$this->table_name}" );
254
+
255
+ // restore table if needed
256
+ if ( empty( $test_options ) )
257
+ $this->option_tree_restore_default_data();
258
+
259
+ // upgrade DB automatically
260
+ $this->option_tree_activate();
261
+
262
+ // load options array
263
+ $settings = get_option( 'option_tree' );
264
+
265
+ // upload xml data
266
+ $this->option_tree_import_xml();
267
+
268
+ // set admin color
269
+ $icon = ( get_user_option( 'admin_color' ) == 'classic' ) ? OT_PLUGIN_URL.'/assets/images/icon_classic.png' : OT_PLUGIN_URL.'/assets/images/icon_dark.png';
270
+
271
+ // create menu items
272
+ add_object_page( 'OptionTree', 'OptionTree', 'level_7', 'option_tree', array( $this, 'option_tree_options_page' ), $icon);
273
+ $option_tree_options = add_submenu_page( 'option_tree', 'OptionTree', 'Theme Options', 'level_7', 'option_tree', array( $this, 'option_tree_options_page' ) );
274
+ $option_tree_docs = add_submenu_page( 'option_tree', 'OptionTree', 'Documentation', 'level_7', 'option_tree_docs', array( $this, 'option_tree_docs_page' ) );
275
+ $option_tree_settings = add_submenu_page( 'option_tree', 'OptionTree', 'Settings', 'level_10', 'option_tree_settings', array( $this, 'option_tree_settings_page' ) );
276
+
277
+ // add menu items
278
+ add_action( "admin_print_styles-$option_tree_options", array( $this, 'option_tree_load' ) );
279
+ add_action( "admin_print_styles-$option_tree_docs", array( $this, 'option_tree_load' ) );
280
+ add_action( "admin_print_styles-$option_tree_settings", array( $this, 'option_tree_load' ) );
281
+ }
282
+
283
+ /**
284
+ * Load Scripts & Styles
285
+ *
286
+ * @uses wp_enqueue_style()
287
+ * @uses get_user_option()
288
+ * @uses add_thickbox()
289
+ * @uses wp_enqueue_script()
290
+ * @uses wp_deregister_style()
291
+ *
292
+ * @access public
293
+ * @since 1.0.0
294
+ *
295
+ * @return void
296
+ */
297
+ function option_tree_load()
298
+ {
299
+ // enqueue styles
300
+ wp_enqueue_style( 'option-tree-style', OT_PLUGIN_URL.'/assets/css/style.css', false, $this->version, 'screen');
301
+
302
+ // classic admin theme styles
303
+ if ( get_user_option( 'admin_color') == 'classic' )
304
+ wp_enqueue_style( 'option-tree-style-classic', OT_PLUGIN_URL.'/assets/css/style-classic.css', array( 'option-tree-style' ), $this->version, 'screen');
305
+
306
+ // enqueue scripts
307
+ add_thickbox();
308
+ wp_enqueue_script( 'jquery-table-dnd', OT_PLUGIN_URL.'/assets/js/jquery.table.dnd.js', array('jquery'), $this->version );
309
+ wp_enqueue_script( 'jquery-color-picker', OT_PLUGIN_URL.'/assets/js/jquery.color.picker.js', array('jquery'), $this->version );
310
+ wp_enqueue_script( 'jquery-option-tree', OT_PLUGIN_URL.'/assets/js/jquery.option.tree.js', array('jquery','media-upload','thickbox','jquery-ui-core','jquery-ui-tabs','jquery-table-dnd','jquery-color-picker'), $this->version );
311
+
312
+ // remove GD star rating conflicts
313
+ wp_deregister_style( 'gdsr-jquery-ui-core' );
314
+ wp_deregister_style( 'gdsr-jquery-ui-theme' );
315
+ }
316
+
317
+ /**
318
+ * Grab the wp_option_tree table options array
319
+ *
320
+ * @uses get_results()
321
+ *
322
+ * @access public
323
+ * @since 1.0.0
324
+ *
325
+ * @return array
326
+ */
327
+ function option_tree_data()
328
+ {
329
+ global $wpdb;
330
+
331
+ // create an array of options
332
+ $db_options = $wpdb->get_results( "SELECT * FROM {$this->table_name} ORDER BY item_sort ASC" );
333
+ return $db_options;
334
+ }
335
+
336
+ /**
337
+ * Theme Options Page
338
+ *
339
+ * @uses get_option()
340
+ * @uses get_option_page_ID()
341
+ * @uses option_tree_check_post_lock()
342
+ * @uses option_tree_check_post_lock()
343
+ * @uses option_tree_notice_post_locked()
344
+ *
345
+ * @access public
346
+ * @since 1.0.0
347
+ *
348
+ * @return string
349
+ */
350
+ function option_tree_options_page()
351
+ {
352
+ // set
353
+ $ot_array = $this->option_array;
354
+
355
+ // load saved option_tree
356
+ $settings = get_option( 'option_tree' );
357
+
358
+ // private page ID
359
+ $post_id = $this->get_option_page_ID( 'media' );
360
+
361
+ // set post lock
362
+ if ( $last = $this->option_tree_check_post_lock( $post_id ) )
363
+ {
364
+ $message = $this->option_tree_notice_post_locked( $post_id );
365
+ }
366
+ else
367
+ {
368
+ $this->option_tree_set_post_lock( $post_id );
369
+ }
370
+
371
+ // Grab Options Page
372
+ include( OT_PLUGIN_DIR.'/front-end/options.php' );
373
+ }
374
+
375
+ /**
376
+ * Settings Page
377
+ *
378
+ * @uses get_option()
379
+ * @uses get_option_page_ID()
380
+ * @uses option_tree_check_post_lock()
381
+ * @uses option_tree_check_post_lock()
382
+ * @uses option_tree_notice_post_locked()
383
+ *
384
+ * @access public
385
+ * @since 1.0.0
386
+ *
387
+ * @return string
388
+ */
389
+ function option_tree_settings_page()
390
+ {
391
+ $ot_array = $this->option_array;
392
+
393
+ // Load Saved Options
394
+ $settings = get_option('option_tree');
395
+
396
+ // private page ID
397
+ $post_id = $this->get_option_page_ID( 'options' );
398
+
399
+ // set post lock
400
+ if ( $last = $this->option_tree_check_post_lock( $post_id ) )
401
+ {
402
+ $message = $this->option_tree_notice_post_locked( $post_id );
403
+ }
404
+ else
405
+ {
406
+ $this->option_tree_set_post_lock( $post_id );
407
+ }
408
+
409
+ // Get Settings Page
410
+ include( OT_PLUGIN_DIR.'/front-end/settings.php');
411
+ }
412
+
413
+ /**
414
+ * Documentation Page
415
+ *
416
+ * @access public
417
+ * @since 1.0.0
418
+ *
419
+ * @return string
420
+ */
421
+ function option_tree_docs_page()
422
+ {
423
+ // Get Settings Page
424
+ include( OT_PLUGIN_DIR.'/front-end/docs.php');
425
+ }
426
+
427
+ /**
428
+ * Save Theme Option via AJAX
429
+ *
430
+ * @uses check_ajax_referer()
431
+ * @uses update_option()
432
+ * @uses option_tree_set_post_lock()
433
+ * @uses get_option_page_ID()
434
+ *
435
+ * @access public
436
+ * @since 1.0.0
437
+ *
438
+ * @return void
439
+ */
440
+ function option_tree_array_save()
441
+ {
442
+ // Check AJAX Referer
443
+ check_ajax_referer( '_theme_options', '_ajax_nonce' );
444
+
445
+ // set option values
446
+ foreach ( $this->option_array as $value )
447
+ {
448
+ // checkbox
449
+ if (
450
+ isset( $_REQUEST['checkboxes'] ) &&
451
+ ( $value->item_type == "checkbox" ||
452
+ $value->item_type == "posts" ||
453
+ $value->item_type == "pages" ||
454
+ $value->item_type == "categories" ||
455
+ $value->item_type == "tags" ||
456
+ $value->item_type == "custom_posts"
457
+ )
458
+ )
459
+ {
460
+ foreach( $_REQUEST['checkboxes'] as $key => $val )
461
+ {
462
+ if ($key == $value->item_id)
463
+ {
464
+ $values = implode(',',$val);
465
+ $new_settings[$key] = $values;
466
+ }
467
+ }
468
+ // no checkbox values
469
+ if ( !isset( $_REQUEST['checkboxes'] ) )
470
+ {
471
+ $key = $value->item_id;
472
+ $values = null;
473
+ $new_settings[$key] = $values;
474
+ }
475
+ // radio
476
+ }
477
+ else if ( isset( $_REQUEST['radios'] ) && $value->item_type == "radio" )
478
+ {
479
+ // grab radio array()
480
+ foreach( $_REQUEST['radios'] as $key => $val)
481
+ {
482
+ if ($key == $value->item_id)
483
+ {
484
+ $values = implode(',',$val);
485
+ $new_settings[$key] = $values;
486
+ }
487
+ }
488
+ // everything else
489
+ }
490
+ else
491
+ {
492
+ $key = trim( $value->item_id );
493
+ if ( isset( $_REQUEST[$key] ) )
494
+ {
495
+ $val = $_REQUEST[$key];
496
+ $new_settings[$key] = $val;
497
+ }
498
+ }
499
+ }
500
+
501
+ // Update Theme Options
502
+ update_option( 'option_tree', $new_settings );
503
+ $this->option_tree_set_post_lock( $this->get_option_page_ID( 'media' ) );
504
+
505
+ die();
506
+
507
+ }
508
+
509
+ /**
510
+ * Reset Theme Option via AJAX
511
+ *
512
+ * @uses check_ajax_referer()
513
+ * @uses update_option()
514
+ *
515
+ * @access public
516
+ * @since 1.0.0
517
+ *
518
+ * @return void
519
+ */
520
+ function option_tree_array_reset()
521
+ {
522
+ // Check AJAX Referer
523
+ check_ajax_referer( '_theme_options', '_ajax_nonce' );
524
+
525
+ // clear option values
526
+ foreach ( $this->option_array as $value )
527
+ {
528
+ $key = $value->item_id;
529
+ $new_options[$key] = '';
530
+ }
531
+
532
+ // update theme Options
533
+ update_option( 'option_tree', $new_options );
534
+
535
+ die();
536
+ }
537
+
538
+ /**
539
+ * Insert Row into Option Setting Table via AJAX
540
+ *
541
+ * @uses check_ajax_referer()
542
+ * @uses get_results()
543
+ * @uses insert()
544
+ * @uses get_var()
545
+ *
546
+ * @access public
547
+ * @since 1.0.0
548
+ *
549
+ * @return void
550
+ */
551
+ function option_tree_add() {
552
+ global $wpdb;
553
+
554
+ // check AJAX referer
555
+ check_ajax_referer( 'inlineeditnonce', '_ajax_nonce' );
556
+
557
+ // grab fresh options array
558
+ $ot_array = $wpdb->get_results( "SELECT * FROM {$this->table_name}" );
559
+
560
+ // get form data
561
+ $id = $_POST['id'];
562
+ $item_id = htmlspecialchars(stripslashes(trim($_POST['item_id'])), ENT_QUOTES,'UTF-8',true);
563
+ $item_title = htmlspecialchars(stripslashes(trim($_POST['item_title'])), ENT_QUOTES,'UTF-8',true);
564
+ $item_desc = htmlspecialchars(stripslashes(trim($_POST['item_desc'])), ENT_QUOTES,'UTF-8',true);
565
+ $item_type = htmlspecialchars(stripslashes(trim($_POST['item_type'])), ENT_QUOTES,'UTF-8',true);
566
+ $item_options = htmlspecialchars(stripslashes(trim($_POST['item_options'])), ENT_QUOTES,'UTF-8',true);
567
+
568
+ // validate item key
569
+ foreach( $ot_array as $value )
570
+ {
571
+ if ( $item_id == $value->item_id )
572
+ {
573
+ die( "That option key is already in use." );
574
+ }
575
+ }
576
+
577
+ // verify key is alphanumeric
578
+ if ( eregi( '[^a-z0-9_]', $item_id ) )
579
+ die("You must enter a valid option key.");
580
+
581
+ // verify title
582
+ if (strlen($item_title) < 1 )
583
+ die("You must give your option a title.");
584
+
585
+ if ( $item_type == 'textarea' && !is_numeric( $item_options ) )
586
+ die("The row value must be numeric.");
587
+
588
+ // update row
589
+ $wpdb->insert( $this->table_name,
590
+ array(
591
+ 'item_id' => $item_id,
592
+ 'item_title' => $item_title,
593
+ 'item_desc' => $item_desc,
594
+ 'item_type' => $item_type,
595
+ 'item_options' => $item_options,
596
+ 'item_sort' => $id
597
+ )
598
+ );
599
+
600
+ // verify values in the DB are updated
601
+ $updated = $wpdb->get_var("
602
+ SELECT id
603
+ FROM {$this->table_name}
604
+ WHERE item_id = '$item_id'
605
+ AND item_title = '$item_title'
606
+ AND item_type = '$item_type'
607
+ AND item_options = '$item_options'
608
+ ");
609
+
610
+ // if updated
611
+ if ( $updated )
612
+ {
613
+ die('updated');
614
+ }
615
+ else
616
+ {
617
+ die("There was an error, please try again.");
618
+ }
619
+ }
620
+
621
+ /**
622
+ * Update Option Setting Table via AJAX
623
+ *
624
+ * @uses check_ajax_referer()
625
+ * @uses get_results()
626
+ * @uses update()
627
+ * @uses get_var()
628
+ *
629
+ * @access public
630
+ * @since 1.0.0
631
+ *
632
+ * @return void
633
+ */
634
+ function option_tree_edit() {
635
+ global $wpdb;
636
+
637
+ // Check AJAX Referer
638
+ check_ajax_referer( 'inlineeditnonce', '_ajax_nonce' );
639
+
640
+ // grab fresh options array
641
+ $ot_array = $wpdb->get_results( "SELECT * FROM {$this->table_name}" );
642
+
643
+ // get form data
644
+ $id = $_POST['id'];
645
+ $item_id = htmlspecialchars(stripslashes(trim($_POST['item_id'])), ENT_QUOTES,'UTF-8',true);
646
+ $item_title = htmlspecialchars(stripslashes(trim($_POST['item_title'])), ENT_QUOTES,'UTF-8',true);
647
+ $item_desc = htmlspecialchars(stripslashes(trim($_POST['item_desc'])), ENT_QUOTES,'UTF-8',true);
648
+ $item_type = htmlspecialchars(stripslashes(trim($_POST['item_type'])), ENT_QUOTES,'UTF-8',true);
649
+ $item_options = htmlspecialchars(stripslashes(trim($_POST['item_options'])), ENT_QUOTES,'UTF-8',true);
650
+
651
+ // validate item key
652
+ foreach($ot_array as $value)
653
+ {
654
+ if ( $value->item_sort == $id )
655
+ {
656
+ if ($item_id == $value->item_id && $value->item_sort != $id)
657
+ {
658
+ die("That option key is already in use.");
659
+ }
660
+ }
661
+ else if ($item_id == $value->item_id && $value->id != $id)
662
+ {
663
+ die("That option key is already in use.");
664
+ }
665
+ }
666
+
667
+ // verify key is alphanumeric
668
+ if ( eregi( '[^a-z0-9_]', $item_id ) )
669
+ die("You must enter a valid option key.");
670
+
671
+ // verify title
672
+ if ( strlen( $item_title ) < 1 )
673
+ die("You must give your option a title.");
674
+
675
+ if ( $item_type == 'textarea' && !is_numeric( $item_options ) )
676
+ die("The row value must be numeric.");
677
+
678
+ // update row
679
+ $wpdb->update( $this->table_name,
680
+ array(
681
+ 'item_id' => $item_id,
682
+ 'item_title' => $item_title,
683
+ 'item_desc' => $item_desc,
684
+ 'item_type' => $item_type,
685
+ 'item_options' => $item_options
686
+ ),
687
+ array(
688
+ 'id' => $id
689
+ )
690
+ );
691
+
692
+ // verify values in the DB are updated
693
+ $updated = $wpdb->get_var("
694
+ SELECT id
695
+ FROM {$this->table_name}
696
+ WHERE item_id = '$item_id'
697
+ AND item_title = '$item_title'
698
+ AND item_type = '$item_type'
699
+ AND item_options = '$item_options'
700
+ ");
701
+
702
+ // if updated
703
+ if ( $updated )
704
+ {
705
+ die('updated');
706
+ }
707
+ else
708
+ {
709
+ die("There was an error, please try again.");
710
+ }
711
+ }
712
+
713
+ /**
714
+ * Remove Option via AJAX
715
+ *
716
+ * @uses check_ajax_referer()
717
+ * @uses query()
718
+ *
719
+ * @access public
720
+ * @since 1.0.0
721
+ *
722
+ * @return void
723
+ */
724
+ function option_tree_delete()
725
+ {
726
+ global $wpdb;
727
+
728
+ // check AJAX referer
729
+ check_ajax_referer( 'inlineeditnonce', '_ajax_nonce' );
730
+
731
+ // grab ID
732
+ $id = $_REQUEST['id'];
733
+
734
+ // delete item
735
+ $wpdb->query("
736
+ DELETE FROM $this->table_name
737
+ WHERE id = '$id'
738
+ ");
739
+
740
+ die('removed');
741
+ }
742
+
743
+ /**
744
+ * Get Option ID via AJAX
745
+ *
746
+ * @uses check_ajax_referer()
747
+ * @uses delete_post_meta()
748
+ *
749
+ * @access public
750
+ * @since 1.0.0
751
+ *
752
+ * @return void
753
+ */
754
+ function option_tree_next_id()
755
+ {
756
+ global $wpdb;
757
+
758
+ // check AJAX referer
759
+ check_ajax_referer( 'inlineeditnonce', '_ajax_nonce' );
760
+
761
+ // get ID
762
+ $id = $wpdb->get_var( "SELECT id FROM {$this->table_name} ORDER BY id DESC LIMIT 1" );
763
+
764
+ // return ID
765
+ die($id);
766
+ }
767
+
768
+ /**
769
+ * Update Sort Order via AJAX
770
+ *
771
+ * @uses check_ajax_referer()
772
+ * @uses update()
773
+ *
774
+ * @access public
775
+ * @since 1.0.0
776
+ *
777
+ * @return void
778
+ */
779
+ function option_tree_sort() {
780
+ global $wpdb;
781
+
782
+ // check AJAX referer
783
+ check_ajax_referer( 'inlineeditnonce', '_ajax_nonce' );
784
+
785
+ // create an array of IDs
786
+ $fields = explode('&', $_REQUEST['id']);
787
+
788
+ // set order
789
+ $order = 0;
790
+
791
+ // update the sort order
792
+ foreach( $fields as $field ) {
793
+ $order++;
794
+ $key = explode('=', $field);
795
+ $id = urldecode($key[1]);
796
+ $wpdb->update( $this->table_name,
797
+ array(
798
+ 'item_sort' => $order
799
+ ),
800
+ array(
801
+ 'id' => $id
802
+ )
803
+ );
804
+ }
805
+ die();
806
+ }
807
+
808
+ /**
809
+ * Upload XML Option Data
810
+ *
811
+ * @access public
812
+ * @since 1.0.0
813
+ *
814
+ * @return void
815
+ */
816
+ function option_tree_import_xml()
817
+ {
818
+ global $wpdb;
819
+
820
+ // action == upload
821
+ if ( isset($_GET['action']) && $_GET['action'] == 'upload' )
822
+ {
823
+ // fail no file
824
+ if ( $_FILES["import"]['name'] == null )
825
+ {
826
+ header("Location: admin.php?page=option_tree_settings&nofile=true#import_options");
827
+ die();
828
+ }
829
+ // fail errors
830
+ else if ( $_FILES["import"]["error"] > 0 )
831
+ {
832
+ header("Location: admin.php?page=option_tree_settings&error=true#import_options");
833
+ die();
834
+ }
835
+ else
836
+ {
837
+ // success - it's XML
838
+ if ( preg_match( "/(.xml)$/i", $_FILES["import"]['name'] ) )
839
+ {
840
+ $rawdata = file_get_contents( $_FILES["import"]["tmp_name"] );
841
+ $new_options = new SimpleXMLElement( $rawdata );
842
+
843
+ // drop table
844
+ $wpdb->query( "DROP TABLE $this->table_name" );
845
+
846
+ // create table
847
+ $wpdb->query( $this->option_tree_table( 'create' ) );
848
+
849
+ // insert data
850
+ foreach ( $new_options->row as $value )
851
+ {
852
+ $wpdb->insert( $this->table_name,
853
+ array(
854
+ 'item_id' => $value->item_id,
855
+ 'item_title' => $value->item_title,
856
+ 'item_desc' => $value->item_desc,
857
+ 'item_type' => $value->item_type,
858
+ 'item_options' => $value->item_options
859
+ )
860
+ );
861
+ }
862
+ // success redirect
863
+ header("Location: admin.php?page=option_tree_settings&xml=true#import_options");
864
+ die();
865
+ }
866
+ // fail
867
+ else
868
+ {
869
+ // redirect
870
+ header("Location: admin.php?page=option_tree_settings&error=true#import_options");
871
+ die();
872
+ }
873
+ }
874
+ }
875
+ }
876
+
877
+ /**
878
+ * Import Option Data via AJAX
879
+ *
880
+ * @uses check_ajax_referer()
881
+ * @uses update()
882
+ *
883
+ * @access public
884
+ * @since 1.0.0
885
+ *
886
+ * @return void
887
+ */
888
+ function option_tree_import_data()
889
+ {
890
+ global $wpdb;
891
+
892
+ // check AJAX referer
893
+ check_ajax_referer( '_import_data', '_ajax_nonce' );
894
+
895
+ // Get Data
896
+ $string = $_REQUEST['import_options'];
897
+
898
+ // Unserialize The Array
899
+ $new_options = unserialize( base64_decode( $string ) );
900
+
901
+ // check if array()
902
+ if ( is_array( $new_options ) )
903
+ {
904
+ // delete old options
905
+ delete_option( 'option_tree' );
906
+
907
+ // create new options
908
+ add_option('option_tree', $new_options);
909
+
910
+ // redirect
911
+ die();
912
+ }
913
+ // failed
914
+ die(-1);
915
+ }
916
+
917
+ /**
918
+ * Returns the ID of a cutom post tpye
919
+ *
920
+ * @uses get_results()
921
+ *
922
+ * @access public
923
+ * @since 1.0.0
924
+ *
925
+ * @param string $page_title
926
+ *
927
+ * @return int
928
+ */
929
+ function get_option_page_ID( $page_title = '' )
930
+ {
931
+ global $wpdb;
932
+
933
+ return $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '{$page_title}' AND post_type = 'option-tree' AND post_status != 'trash'");
934
+ }
935
+
936
+ /**
937
+ * Register custom post type & create two posts
938
+ *
939
+ * @uses get_results()
940
+ *
941
+ * @access public
942
+ * @since 1.0.0
943
+ *
944
+ * @return void
945
+ */
946
+ function create_option_post()
947
+ {
948
+ register_post_type( 'option-tree', array(
949
+ 'labels' => array(
950
+ 'name' => __( 'Options' ),
951
+ ),
952
+ 'public' => true,
953
+ 'show_ui' => false,
954
+ 'capability_type' => 'post',
955
+ 'exclude_from_search' => true,
956
+ 'hierarchical' => false,
957
+ 'rewrite' => false,
958
+ 'supports' => array( 'title', 'editor' ),
959
+ 'can_export' => true,
960
+ 'show_in_nav_menus' => false,
961
+ ) );
962
+
963
+ // create a private page to attach media to
964
+ if ( isset($_GET['page']) && $_GET['page'] == 'option_tree' )
965
+ {
966
+ // look for custom page
967
+ $page_id = $this->get_option_page_ID( 'media' );
968
+
969
+ // no page create it
970
+ if ( ! $page_id )
971
+ {
972
+ // create post object
973
+ $_p = array();
974
+ $_p['post_title'] = 'Media';
975
+ $_p['post_status'] = 'private';
976
+ $_p['post_type'] = 'option-tree';
977
+ $_p['comment_status'] = 'closed';
978
+ $_p['ping_status'] = 'closed';
979
+
980
+ // insert the post into the database
981
+ $page_id = wp_insert_post( $_p );
982
+ }
983
+ }
984
+
985
+ // create a private page for settings page
986
+ if ( isset($_GET['page']) && $_GET['page'] == 'option_tree_settings' )
987
+ {
988
+ // look for custom page
989
+ $page_id = $this->get_option_page_ID( 'options' );
990
+
991
+ // no page create it
992
+ if ( ! $page_id )
993
+ {
994
+ // create post object
995
+ $_p = array();
996
+ $_p['post_title'] = 'Options';
997
+ $_p['post_status'] = 'private';
998
+ $_p['post_type'] = 'option-tree';
999
+ $_p['comment_status'] = 'closed';
1000
+ $_p['ping_status'] = 'closed';
1001
+
1002
+ // insert the post into the database
1003
+ $page_id = wp_insert_post( $_p );
1004
+ }
1005
+ }
1006
+ }
1007
+
1008
+ /**
1009
+ * Outputs the notice message to say that someone else is editing this post at the moment.
1010
+ *
1011
+ * @uses get_userdata()
1012
+ * @uses get_post_meta()
1013
+ * @uses esc_html()
1014
+ *
1015
+ * @access public
1016
+ * @since 1.0.0
1017
+ *
1018
+ * @param int $post_id
1019
+ *
1020
+ * @return string
1021
+ */
1022
+ function option_tree_notice_post_locked( $post_id )
1023
+ {
1024
+ if ( !$post_id )
1025
+ return false;
1026
+
1027
+ $last_user = get_userdata( get_post_meta( $post_id, '_edit_last', true ) );
1028
+ $last_user_name = $last_user ? $last_user->display_name : __('Somebody');
1029
+ $the_page = ( $_GET['page'] == 'option_tree' ) ? __('Theme Options') : __('Settings');
1030
+
1031
+ $message = sprintf( __( 'Warning: %s is currently editing the %s.' ), esc_html( $last_user_name ), $the_page );
1032
+ return '<div class="message warning"><span>&nbsp;</span>'.$message.'</div>';
1033
+ }
1034
+
1035
+ /**
1036
+ * Check to see if the post is currently being edited by another user.
1037
+ *
1038
+ * @uses get_post_meta()
1039
+ * @uses apply_filters()
1040
+ * @uses get_current_user_id()
1041
+ *
1042
+ * @access public
1043
+ * @since 1.0.0
1044
+ *
1045
+ * @param int $post_id
1046
+ *
1047
+ * @return bool
1048
+ */
1049
+ function option_tree_check_post_lock( $post_id )
1050
+ {
1051
+ if ( !$post_id )
1052
+ return false;
1053
+
1054
+ $lock = get_post_meta( $post_id, '_edit_lock', true );
1055
+ $last = get_post_meta( $post_id, '_edit_last', true );
1056
+
1057
+ $time_window = apply_filters( 'wp_check_post_lock_window', 30 );
1058
+
1059
+ if ( $lock && $lock > time() - $time_window && $last != get_current_user_id() )
1060
+ return $last;
1061
+
1062
+ return false;
1063
+ }
1064
+
1065
+ /**
1066
+ * Mark the post as currently being edited by the current user
1067
+ *
1068
+ * @uses update_post_meta()
1069
+ * @uses get_current_user_id()
1070
+ *
1071
+ * @access public
1072
+ * @since 1.0.0
1073
+ *
1074
+ * @param int $post_id
1075
+ *
1076
+ * @return bool
1077
+ */
1078
+ function option_tree_set_post_lock( $post_id )
1079
+ {
1080
+ if ( !$post_id )
1081
+ return false;
1082
+
1083
+ if ( 0 == get_current_user_id() )
1084
+ return false;
1085
+
1086
+ $now = time();
1087
+
1088
+ update_post_meta( $post_id, '_edit_lock', $now );
1089
+ update_post_meta( $post_id, '_edit_last', get_current_user_id() );
1090
+ }
1091
+
1092
+ /**
1093
+ * Remove the post lock
1094
+ *
1095
+ * @uses delete_post_meta()
1096
+ *
1097
+ * @access public
1098
+ * @since 1.0.0
1099
+ *
1100
+ * @param int $post_id
1101
+ *
1102
+ * @return bool
1103
+ */
1104
+ function option_tree_remove_post_lock( $post_id )
1105
+ {
1106
+ if ( !$post_id )
1107
+ return false;
1108
+
1109
+ delete_post_meta( $post_id, '_edit_lock' );
1110
+ delete_post_meta( $post_id, '_edit_last' );
1111
+ }
1112
+
1113
+ }
front-end/docs.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed'); ?>
2
+
3
+ <div id="framework_wrap" class="wrap">
4
+
5
+ <div id="header">
6
+ <h1>OptionTree</h1>
7
+ <span class="icon">&nbsp;</span>
8
+ <div class="version">
9
+ <?php echo OT_VERSION; ?>
10
+ </div>
11
+ </div>
12
+
13
+ <div id="content_wrap">
14
+
15
+ <div class="info top-info"></div>
16
+
17
+ <div id="content">
18
+ <div id="options_tabs" class="docs">
19
+
20
+ <ul class="options_tabs">
21
+ <li><a href="#general">Usage &amp; Examples</a><span></span></li>
22
+ <li><a href="#option_types">Option Types</a><span></span></li>
23
+ <li><a href="#settings">Creating Options</a><span></span></li>
24
+ </ul>
25
+
26
+ <div id="general" class="block">
27
+ <h2>Usage &amp; Examples</h2>
28
+ <h3>Function Reference/get_option_tree</h3>
29
+
30
+ <h3>Description</h3>
31
+ <p>Displays or returns a value from the 'option_tree' array.</p>
32
+
33
+ <h3>Usage</h3>
34
+ <p><code>&lt;?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?&gt;</code></p>
35
+
36
+ <h3>Default Usage</h3>
37
+ <pre><code>get_option_tree(
38
+ 'item_id' => '',
39
+ 'options' => '',
40
+ 'echo' => 'false',
41
+ 'is_array' => 'false',
42
+ 'offset' => -1,
43
+ );</code></pre>
44
+
45
+ <h3>Parameters</h3>
46
+ <p>
47
+ <code><strong>$item_id</strong></code>
48
+ <br />&nbsp;&nbsp;(<em>string</em>) (<em>required</em>) Enter a unique Option Key to get a returned value or array.
49
+ <br />&nbsp;&nbsp;&nbsp;&nbsp;Default: <em>None</em>
50
+ </p>
51
+ <p>
52
+ <code><strong>$options</strong></code>
53
+ <br />&nbsp;&nbsp;(<em>array</em>) (<em>optional</em>) Used to cut down on database queries in template files.
54
+ <br />&nbsp;&nbsp;&nbsp;&nbsp;Default: <em>None</em>
55
+ </p>
56
+ <p>
57
+ <code><strong>$echo</strong></code>
58
+ <br />&nbsp;&nbsp;(<em>boolean</em>) (<em>optional</em>) Echo the output.
59
+ <br />&nbsp;&nbsp;&nbsp;&nbsp;Default: FALSE
60
+ </p>
61
+ <p>
62
+ <code><strong>$is_array</strong></code>
63
+ <br />&nbsp;&nbsp;(<em>boolean</em>) (<em>optional</em>) Used to indicate the $item_id is an array of values.
64
+ <br />&nbsp;&nbsp;&nbsp;&nbsp;Default: FALSE
65
+ </p>
66
+ <p>
67
+ <code><strong>$offset</strong></code>
68
+ <br />&nbsp;&nbsp;(<em>integer</em>) (<em>optional</em>) Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).
69
+ <br />&nbsp;&nbsp;&nbsp;&nbsp;Default: -1
70
+ </p>
71
+
72
+
73
+ <h3>Examples</h3>
74
+ <p>
75
+ This example assigns the value of the <code>get_option('option_tree')</code> array to the variable <code>$theme_options</code> for use in PHP. You would then add this code to the top of your header.php file and use that variable as the <code>$options</code> variable in the <code>get_option_tree()</code> function. This helps to reduce database queries anytime you want to request multiple theme options in a template files. This is optional, but may help speed up things up.
76
+ <pre><code>&lt?php $theme_options = get_option('option_tree'); ?&gt;</code></pre>
77
+ </p>
78
+
79
+ <p>
80
+ This example returns the $item_id value.
81
+ <pre><code>&lt?php
82
+ if ( function_exists( 'get_option_tree' ) ) {
83
+ get_option_tree( 'test_option' );
84
+ }
85
+ ?&gt;</code></pre>
86
+ </p>
87
+
88
+ <p>
89
+ These examples will echo the $item_id value.
90
+ <pre><code>&lt?php
91
+ if ( function_exists( 'get_option_tree') ) {
92
+ get_option_tree( 'test_option', '', true );
93
+ }
94
+ ?&gt;
95
+
96
+ &lt?php
97
+ if ( function_exists( 'get_option_tree') ) {
98
+ echo get_option_tree( 'test_option' );
99
+ }
100
+ ?&gt;</code></pre>
101
+ </p>
102
+
103
+ <p>
104
+ This example will echo the value of $item_id by grabbing the first offset key in the array. At the moment, this will only work if the item_type is a checkbox.
105
+ <pre><code>&lt?php
106
+ if ( function_exists( 'get_option_tree' ) ) {
107
+ get_option_tree( 'test_option', '', true, true, 0 );
108
+ }
109
+ ?&gt;</code></pre>
110
+ </p>
111
+
112
+ <p>
113
+ This example assigns the value of $item_id to the variable $ids for use in PHP. As well, it uses the <code>$theme_options</code> variable I set in the first example above in my header.php file to reduce database queries. It then loops through all the array items and echos an unordered list of page links (navigation).
114
+ <pre><code>&lt?php
115
+ if ( function_exists( 'get_option_tree' ) ) {
116
+ // set an array of page id's
117
+ $ids = get_option_tree( 'list_of_page_ids', $theme_options, false, true, -1 );
118
+
119
+ // loop through id's & echo custom navigation
120
+ echo '&lt;ul&gt;';
121
+ foreach( $ids as $id ) {
122
+ echo '&lt;li&gt;&lt;a href="'.get_permalink($id).'"&gt;'.get_the_title($id).'&lt;/a&gt;&lt;/li&gt;';
123
+ }
124
+ echo '&lt;/ul&gt;';
125
+ }
126
+ ?&gt;</code></pre>
127
+ OR a more WordPress version would be:<br /><br />
128
+ <pre><code>&lt?php
129
+ if ( function_exists( 'get_option_tree' ) ) {
130
+ // set an array of page id's
131
+ $ids = get_option_tree( 'list_of_page_ids', $theme_options, false, true, -1 );
132
+
133
+ // echo custom navigation using wp_list_pages()
134
+ echo '&lt;ul&gt;';
135
+ wp_list_pages(
136
+ array(
137
+ 'include' => $ids,
138
+ 'title_li' => ''
139
+ )
140
+ );
141
+ echo '&lt;/ul&gt;';
142
+ }
143
+ ?&gt;</code></pre>
144
+ </p>
145
+
146
+ </div>
147
+
148
+ <div id="option_types" class="block">
149
+ <h2>Option Types</h2>
150
+ <h3>Overview of available Option Types.</h3>
151
+
152
+ <p>
153
+ <strong>Heading</strong>:<br />
154
+ Used only in the WordPress Admin area to logical separate Theme Options into sections for easy editing. A Heading will create a navigation menu item on the <a href="<?php echo admin_url().'admin.php?page=option_tree'; ?>"><strong>Theme Options</strong></a> page. You would NEVER use this in your themes template files.
155
+ </p>
156
+
157
+ <p>
158
+ <strong>Textblock</strong>:<br />
159
+ Used only in the WordPress Admin area. A Textblock will allow you to create &amp; display HTML on your <a href="<?php echo admin_url().'admin.php?page=option_tree'; ?>"><strong>Theme Options</strong></a> page. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would NEVER use this in your themes template files.
160
+ </p>
161
+
162
+ <p>
163
+ <strong>Input</strong>:<br />
164
+ The Input option type would be used to save a simple string value. Maybe a link to feedburner, your Twitter username, or Google Analytics ID. Any optional or required text that is of reasonably short character length.
165
+ </p>
166
+
167
+ <p>
168
+ <strong>Checkbox</strong>:<br />
169
+ A Checkbox option type could ask a question. For example, "Do you want to activate asynchronous Google analytics?" would be a simple one checkbox question. You could have more complex usages but the idea is that you can easily grab the value of the checkbox and use it in you theme. In this situation you would test if the checkbox has a value and execute a block of code if it does and do nothing if it doesn't.
170
+ </p>
171
+
172
+ <p>
173
+ <strong>Radio</strong>:<br />
174
+ A Radio option type could ask a question. For example, "Do you want to activate the custom navigation?" could require a yes or no answer with a radio option. In this situation you would test if the radio has a value of 'yes' and execute a block of code, or if it's 'no' execute a different block of code. Since a radio has to be one or the other nothing will execute if you have not saved the options yet.
175
+ </p>
176
+
177
+ <p>
178
+ <strong>Select</strong>:<br />
179
+ Could use the Select option type to list different theme styles or choose any other setting that would be chosen from a select option list.
180
+ </p>
181
+
182
+ <p>
183
+ <strong>Textarea</strong>:<br />
184
+ With the Textarea option type users can add custom code or text for use in the theme.
185
+ </p>
186
+
187
+ <p>
188
+ <strong>Upload</strong>:<br />
189
+ The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "<strong style="color:red;">Insert into Post</strong>" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You'll have to re-upload or FTP any media to your new server and change the URIs if necessary.
190
+ </p>
191
+
192
+ <p>
193
+ <strong>Colorpicker</strong>:<br />
194
+ A Colorpicker is a very self explanatory feature that saves hex HTML color codes. Use it to set/change the color of something in your theme.
195
+ </p>
196
+
197
+ <p>
198
+ <strong>Post</strong>:<br />
199
+ The Post option type is an option select list of post IDs. It will return a single post ID for use in a custom function or loop.
200
+ </p>
201
+
202
+ <p>
203
+ <strong>Posts</strong>:<br />
204
+ The Posts option type is a checkbox list of post IDs. It will return an array of multiple post IDs for use in a custom function or loop.
205
+ </p>
206
+
207
+ <p>
208
+ <strong>Page</strong>:<br />
209
+ The Page option type is an option select list of page IDs. It will return a single page ID for use in a custom function or loop.
210
+ </p>
211
+
212
+ <p>
213
+ <strong>Pages</strong>:<br />
214
+ The Pages option type is a checkbox list of page IDs. It will return an array of multiple page IDs for use in a custom function or loop.
215
+ </p>
216
+
217
+ <p>
218
+ <strong>Category</strong>:<br />
219
+ The Category type is an option select list of category IDs. It will return a single category ID for use in a custom function or loop.
220
+ </p>
221
+
222
+ <p>
223
+ <strong>Categories</strong>:<br />
224
+ The Categories option type is a checkbox list of category IDs. It will return an array of multiple category IDs for use in a custom function or loop.
225
+ </p>
226
+
227
+ <p>
228
+ <strong>Tag</strong>:<br />
229
+ The Tag option type is an option select list of tag IDs. It will return a single tag ID for use in a custom function or loop.
230
+ </p>
231
+
232
+ <p>
233
+ <strong>Tags</strong>:<br />
234
+ The Tags option type is a checkbox list of tag IDs. It will return an array of multiple tag IDs for use in a custom function or loop.
235
+ </p>
236
+
237
+ <p>
238
+ <strong>Custom Post</strong>:<br />
239
+ The Custom Post option type is an option select list of IDs from any available wordpress post type or custom post type. It will return a single ID for use in a custom function or loop. Custom Post requires the post_type you are querying when created.
240
+ </p>
241
+
242
+ <p>
243
+ <strong>Custom Posts</strong>:<br />
244
+ The Custom Posts option type is a checkbox list of IDs from any available wordpress post type or custom post type. It will return an array of multiple IDs for use in a custom function or loop. Custom Posts requires the post_type you are querying when created.
245
+ </p>
246
+
247
+ </div>
248
+
249
+ <div id="settings" class="block">
250
+ <h2>Creating Options</h2>
251
+ <h3>Overview of available Theme Option fields.</h3>
252
+
253
+ <p>
254
+ <strong>Title</strong>:<br />
255
+ The Title field should be a short but descriptive block of text 100 characters or less with no HTML.
256
+ </p>
257
+
258
+ <p>
259
+ <strong>Option Key</strong>:<br />
260
+ The Option Key field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will lowercase any text you write in this field and bridge all spaces with an underscore automatically.
261
+ </p>
262
+
263
+ <p style="padding-bottom:5px">
264
+ <strong>Option Type</strong>:<br />
265
+ You are required to choose one of the supported option types. They are:
266
+ </p>
267
+ <ul class="doc_list">
268
+ <li>Heading</li>
269
+ <li>Textblock</li>
270
+ <li>Input</li>
271
+ <li>Checkbox</li>
272
+ <li>Radio</li>
273
+ <li>Select</li>
274
+ <li>Textarea</li>
275
+ <li>Upload</li>
276
+ <li>Colorpicker</li>
277
+ <li>Post</li>
278
+ <li>Posts</li>
279
+ <li>Page</li>
280
+ <li>Pages</li>
281
+ <li>Category</li>
282
+ <li>Categories</li>
283
+ <li>Tag</li>
284
+ <li>Tags</li>
285
+ <li>Custom Post</li>
286
+ <li>Custom Posts</li>
287
+ </ul>
288
+
289
+ <p>
290
+ <strong>Description</strong>:<br />
291
+ Enter a detailed description of the option for end users to read. However, if the option type is a Textblock, enter the text you want to display (HTML is allowed).
292
+ </p>
293
+
294
+ <p>
295
+ <strong>Options</strong>:<br />
296
+ Enter a comma separated list of options in this field. For example, you could have "One,Two,Three" or just a single value like "Yes" for a checkbox.
297
+ </p>
298
+
299
+ <p>
300
+ <strong>Row Count</strong>:<br />
301
+ Enter a numeric value for the number of rows in your textarea.
302
+ </p>
303
+
304
+ <p style="padding-bottom:5px">
305
+ <strong>Post Type</strong>:<br />
306
+ Enter your custom post_type. These are the default post types available with WordPress. You can also add your own custom post_type.
307
+ </p>
308
+ <ul class="doc_list">
309
+ <li>post</li>
310
+ <li>page</li>
311
+ <li>attachment</li>
312
+ <li>any</li>
313
+ </ul>
314
+
315
+ </div>
316
+
317
+ <br class="clear" />
318
+ </div>
319
+ </div>
320
+ <div class="info bottom"></div>
321
+ </div>
322
+
323
+ </div>
324
+ <!-- [END] framework_wrap -->
front-end/options.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed'); ?>
2
+
3
+ <div id="framework_wrap" class="wrap">
4
+
5
+ <div id="header">
6
+ <h1>OptionTree</h1>
7
+ <span class="icon">&nbsp;</span>
8
+ <div class="version">
9
+ <?php echo OT_VERSION; ?>
10
+ </div>
11
+ </div>
12
+
13
+ <div id="content_wrap">
14
+
15
+ <form method="post" id="the-theme-options">
16
+
17
+ <div class="info top-info">
18
+
19
+ <input type="submit" value="<?php _e('Save All Changes') ?>" class="button-framework save-options" name="submit"/>
20
+
21
+ </div>
22
+
23
+ <div class="ajax-message<?php if ( isset( $message ) ) { echo ' show'; } ?>">
24
+
25
+ <?php if ( isset( $message ) ) { echo $message; } ?>
26
+
27
+ </div>
28
+
29
+ <div id="content">
30
+
31
+ <div id="options_tabs">
32
+
33
+ <ul class="options_tabs">
34
+ <?php
35
+ foreach ( $ot_array as $value )
36
+ {
37
+ if ( $value->item_type == 'heading' )
38
+ {
39
+ echo '<li><a href="#option_'.$value->item_id.'">' . htmlspecialchars_decode( $value->item_title ).'</a><span></span></li>';
40
+ }
41
+ }
42
+ ?>
43
+ </ul>
44
+
45
+ <?php
46
+ // set count
47
+ $count = 0;
48
+ // loop options & load corresponding function
49
+ foreach ( $ot_array as $value )
50
+ {
51
+ $count++;
52
+ if ( $value->item_type == 'upload' )
53
+ {
54
+ $int = $post_id;
55
+ }
56
+ else if ( $value->item_type == 'textarea' )
57
+ {
58
+ $int = ( is_numeric( trim( $value->item_options ) ) ) ? trim( $value->item_options ) : 8;
59
+ }
60
+ else
61
+ {
62
+ $int = $count;
63
+ }
64
+ call_user_func_array( 'option_tree_' . $value->item_type, array( $value, $settings, $int ) );
65
+ }
66
+ // close heading
67
+ echo '</div>';
68
+ ?>
69
+
70
+ <br class="clear" />
71
+
72
+ </div>
73
+
74
+ </div>
75
+
76
+ <div class="info bottom">
77
+
78
+ <input type="submit" value="<?php _e('Reset Options') ?>" class="button-framework reset" name="reset"/>
79
+ <input type="submit" value="<?php _e('Save All Changes') ?>" class="button-framework save-options" name="submit"/>
80
+
81
+ </div>
82
+
83
+ <?php wp_nonce_field( '_theme_options', '_ajax_nonce', false ); ?>
84
+
85
+ </form>
86
+
87
+ </div>
88
+
89
+ </div>
90
+ <!-- [END] framework_wrap -->
front-end/settings.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed'); ?>
2
+
3
+ <div id="framework_wrap" class="wrap">
4
+
5
+ <div id="header">
6
+ <h1>OptionTree</h1>
7
+ <span class="icon">&nbsp;</span>
8
+ <div class="version">
9
+ <?php echo OT_VERSION; ?>
10
+ </div>
11
+ </div>
12
+
13
+ <div id="content_wrap">
14
+
15
+ <div class="info top-info">
16
+ </div>
17
+
18
+ <div class="ajax-message<?php if ( isset($_GET['xml']) || isset($_GET['error']) || isset($_GET['nofile']) || isset($_GET['empty']) || isset( $message ) ) { echo ' show'; } ?>">
19
+ <?php if(isset($_GET['xml'])) { echo '<div class="message"><span>&nbsp;</span>Theme Options Created</div>'; } ?>
20
+ <?php if(isset($_GET['error'])) { echo '<div class="message warning"><span>&nbsp;</span>Wrong File Type!</div>'; } ?>
21
+ <?php if(isset($_GET['nofile'])) { echo '<div class="message warning"><span>&nbsp;</span>Please add a file.</div>'; } ?>
22
+ <?php if(isset($_GET['empty'])) { echo '<div class="message warning"><span>&nbsp;</span>An error occurred while importing your data.</div>'; } ?>
23
+ <?php if ( isset( $message ) ) { echo $message; } ?>
24
+ </div>
25
+
26
+ <div id="content">
27
+ <div id="options_tabs">
28
+ <ul class="options_tabs">
29
+ <li><a href="#tree_settings">Create</a><span></span></li>
30
+ <li><a href="#import_options">Import</a><span></span></li>
31
+ <li><a href="#export_options">Export</a><span></span></li>
32
+ </ul>
33
+
34
+ <div id="tree_settings" class="block has-table">
35
+ <form method="post" id="theme-options" class="option-tree-settings">
36
+ <h2>Create</h2>
37
+ <h3>Create the Theme Options</h3>
38
+ <p><strong style="color:red;">WARNING!</strong> If you're unsure or not completely positive that you should be editing these options, you should read the <a href="<?php echo admin_url().'admin.php?page=option_tree_docs'; ?>"><strong>Documentation</strong></a> first.</p>
39
+ <p>You can create as many Theme Options as your project requires and use them how you see fit. When you add an option here, it will be available on the <a href="<?php echo admin_url().'admin.php?page=option_tree'; ?>"><strong>Theme Options</strong></a> page for use in your theme. To break your Theme Options into sections, add a "<strong>heading</strong>" option type and a new navigation menu item will be created.</p>
40
+ <p>All of the Theme Options can be sorted and rearranged to your liking with <strong>Drag &amp; Drop</strong>. Don't worry about the order in which you create your options, you can always reorder them.</p>
41
+ <table cellspacing="0">
42
+ <thead>
43
+ <tr>
44
+ <th class="col-title">Title</th>
45
+ <th class="col-key">Key</th>
46
+ <th class="col-type">Type</th>
47
+ <th class="col-edit"><a href="javascript:;" class="add-option">Add Option</a></th>
48
+ </tr>
49
+ </thead>
50
+ <tfoot>
51
+ <tr>
52
+ <th class="col-title">Title</th>
53
+ <th class="col-key">Key</th>
54
+ <th class="col-type">Type</th>
55
+ <th class="col-edit"><a href="javascript:;" class="add-option">Add Option</a></th>
56
+ </tr>
57
+ </tfoot>
58
+ <tbody id="framework-settings" class="dragable">
59
+ <?php
60
+ $count = 0;
61
+ foreach ( $ot_array as $value ) {
62
+ $count++;
63
+ $heading = ($value->item_type == 'heading') ? true : false; ?>
64
+ <tr id="option-<?php echo $value->id; ?>" class="<?php echo ($heading) ? 'col-heading ' : ''; ?><?php echo ($count==1) ? 'nodrag nodrop' : ''; ?>">
65
+ <td class="col-title"<?php echo ($heading) ? ' colspan="3"' : ''; ?>><?php echo (!$heading) ? '&ndash; ' : ''; ?><?php echo htmlspecialchars_decode( $value->item_title ); ?></td>
66
+ <td class="col-key<?php echo ($heading) ? ' hide' : ''; ?>"><?php echo htmlspecialchars(stripslashes($value->item_id)); ?></td>
67
+ <td class="col-type<?php echo ($heading) ? ' hide' : ''; ?>"><?php echo $value->item_type; ?></td>
68
+ <td class="col-edit">
69
+ <a href="javascript:;" class="edit-inline">Edit</a>
70
+ <a href="javascript:;" class="delete-inline">Delete</a>
71
+ <div class="hidden item-data" id="inline_<?php echo $value->id; ?>">
72
+ <div class="item_title"><?php echo htmlspecialchars_decode( $value->item_title ); ?></div>
73
+ <div class="item_id"><?php echo $value->item_id; ?></div>
74
+ <div class="item_type"><?php echo $value->item_type; ?></div>
75
+ <div class="item_desc"><?php echo esc_html(stripslashes($value->item_desc)); ?></div>
76
+ <div class="item_options"><?php echo esc_html(stripslashes($value->item_options)); ?></div>
77
+ </div>
78
+ </td>
79
+ </tr>
80
+ <?php } ?>
81
+ </tbody>
82
+ </table>
83
+ <table style="display:none">
84
+ <tbody id="framework-settings-edit">
85
+ <tr id="inline-edit" class="inline-edit-option nodrop nodrag">
86
+ <td colspan="4">
87
+ <div class="option option-title">
88
+ <div class="section">
89
+ <div class="element">
90
+ <input type="text" name="item_title" class="item_title" value="" />
91
+ </div>
92
+ <div class="description">
93
+ <strong>Title:</strong> Displayed on the Theme Options page.
94
+ </div>
95
+ </div>
96
+ </div>
97
+ <div class="option option-id">
98
+ <div class="section">
99
+ <div class="element">
100
+ <input type="text" name="item_id" class="item_id" value="" />
101
+ </div>
102
+ <div class="description">
103
+ <strong>Option Key:</strong> Unique alphanumeric key, underscores are acceptable.
104
+ </div>
105
+ </div>
106
+ </div>
107
+ <div class="option option-type">
108
+ <div class="section">
109
+ <div class="element">
110
+ <div class="select_wrapper">
111
+ <select name="item_type" class="select item_type">
112
+ <?php
113
+ $types = array(
114
+ 'heading' => 'Heading',
115
+ 'textblock' => 'Textblock',
116
+ 'input' => 'Input',
117
+ 'checkbox' => 'Checkbox',
118
+ 'radio' => 'Radio',
119
+ 'select' => 'Select',
120
+ 'textarea' => 'Textarea',
121
+ 'upload' => 'Upload',
122
+ 'colorpicker' => 'Colorpicker',
123
+ 'post' => 'Post',
124
+ 'posts' => 'Posts',
125
+ 'page' => 'Page',
126
+ 'pages' => 'Pages',
127
+ 'category' => 'Category',
128
+ 'categories' => 'Categories',
129
+ 'tag' => 'Tag',
130
+ 'tags' => 'Tags',
131
+ 'custom_post' => 'Custom Post',
132
+ 'custom_posts' => 'Custom Posts'
133
+ );
134
+ foreach ( $types as $key => $value )
135
+ {
136
+ echo '<option value="'.$key.'">'.$value.'</option>';
137
+ }
138
+ ?>
139
+ </select>
140
+ </div>
141
+ </div>
142
+ <div class="description">
143
+ <strong>Option Type:</strong> Choose one of the supported option types.
144
+ </div>
145
+ </div>
146
+ </div>
147
+ <div class="option option-desc">
148
+ <div class="section">
149
+ <div class="element">
150
+ <textarea name="item_desc" class="item_desc" rows="8"></textarea>
151
+ </div>
152
+ <div class="description">
153
+ <strong>Description:</strong> Enter a detailed description of the option for end users to read. However, if the option type is a <strong>Textblock</strong>, enter the text you want to display (HTML is allowed).
154
+ </div>
155
+ </div>
156
+ </div>
157
+ <div class="option option-options">
158
+ <div class="section">
159
+ <div class="element">
160
+ <input type="text" name="item_options" class="item_options" value="" />
161
+ </div>
162
+ <div class="description">
163
+ <span class="regular"><strong>Options:</strong> Enter a comma separated list of options. For example, you could have "One,Two,Three" or just a single value like "Yes" for a checkbox.</span>
164
+ <span class="alternative" style="display:none;">&nbsp;</span>
165
+ </div>
166
+ </div>
167
+ </div>
168
+ <?php wp_nonce_field( 'inlineeditnonce', '_ajax_nonce', false ); ?>
169
+ <div class="inline-edit-save">
170
+ <a href="#" class="cancel button-framework reset">Cancel</a>
171
+ <a href="#" class="save button-framework">Save</a>
172
+ </div>
173
+ </td>
174
+ </tr>
175
+ <tr id="inline-add">
176
+ <td class="col-title"></td>
177
+ <td class="col-key"></td>
178
+ <td class="col-type"></td>
179
+ <td class="col-edit">
180
+ <a href="#" class="edit-inline">Edit</a>
181
+ <a href="#" class="delete-inline">Delete</a>
182
+ <div class="hidden item-data">
183
+ <div class="item_title"></div>
184
+ <div class="item_id"></div>
185
+ <div class="item_type"></div>
186
+ <div class="item_desc"></div>
187
+ <div class="item_options"></div>
188
+ </div>
189
+ </td>
190
+ </tr>
191
+ </tbody>
192
+ </table>
193
+ </form>
194
+ </div>
195
+
196
+ <div id="import_options" class="block">
197
+ <h2>Import</h2>
198
+
199
+ <form method="post" action="admin.php?page=option_tree_settings&action=upload" enctype="multipart/form-data" id="upload-xml">
200
+ <input type="hidden" name="action" value="upload" />
201
+ <div class="option option-upload">
202
+ <h3>Theme Options XML</h3>
203
+ <div class="section desc-text">
204
+ <p>If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file here. It's also possible that you did all your development on a local server and just need to get your live site in working condition from your own exported settings file. Either way, once you have the proper file in the input field below, click the "Import XML" button.</p>
205
+ <p>However, if you're a theme developer activating the plugin for the first time, you can get started by clicking the Developers Settings link to the left.</p>
206
+ <input name="import" type="file" class="file" />
207
+ <input type="submit" value="<?php _e('Import XML') ?>" class="ob_button right" />
208
+ </div>
209
+ </div>
210
+ </form>
211
+
212
+ <form method="post" id="import-data">
213
+ <div class="option option-input">
214
+ <h3>Theme Options Data</h3>
215
+ <div class="section">
216
+ <div class="element">
217
+ <textarea name="import_options" rows="8" id="import_options" class="import_options"></textarea>
218
+ </div>
219
+ <div class="description">
220
+ <p>Only after you've imported the Theme Options XML file should you try and update your Theme Options Data.</p>
221
+ <p>To import the values of your theme options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Data" button below.</p>
222
+ </div>
223
+ </div>
224
+ <input type="submit" value="<?php _e('Import Data') ?>" class="ob_button right import-data" />
225
+ </div>
226
+ <?php wp_nonce_field( '_import_data', '_ajax_nonce', false ); ?>
227
+ </form>
228
+
229
+ </div>
230
+
231
+ <div id="export_options" class="block">
232
+ <h2>Export</h2>
233
+ <form method="post" action="admin.php?page=option_tree_settings&action=export">
234
+ <div class="option option-input">
235
+ <h3>Theme Options XML</h3>
236
+ <div class="section desc-text">
237
+ <p>Click the Export XML button to export your Theme Options. A dialogue box will open and ask you what you want to do with the XML file, save it somewhere you can easily find it later.</p>
238
+ <input type="submit" value="Export XML" class="ob_button right" />
239
+ </div>
240
+ </div>
241
+ </form>
242
+ <div class="option option-input">
243
+ <h3>Theme Options Data</h3>
244
+ <div class="section">
245
+ <div class="element">
246
+ <textarea name="export_options" rows="8"><?php echo base64_encode(serialize($settings)); ?></textarea>
247
+ </div>
248
+ <div class="description">
249
+ Export your saved Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the <code>OptionTree->Settings->Import</code> on another web site.
250
+ </div>
251
+ </div>
252
+ </div>
253
+ </div>
254
+
255
+ <br class="clear" />
256
+ </div>
257
+ </div>
258
+ <div class="info bottom">
259
+ <input type="hidden" name="action" value="save" />
260
+ </div>
261
+ </div>
262
+
263
+ </div>
264
+ <!-- [END] framework_wrap -->
functions/admin/category.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Category Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_category( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <div class="select_wrapper">
22
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
23
+ <?php
24
+ $categories = &get_categories( array( 'hide_empty' => false ) );
25
+ if ( $categories )
26
+ {
27
+ echo '<option value="">-- Choose One --</option>';
28
+ foreach ($categories as $category)
29
+ {
30
+ $selected = '';
31
+ if ( isset( $settings[$value->item_id] ) && $settings[$value->item_id] == $category->term_id )
32
+ {
33
+ $selected = ' selected="selected"';
34
+ }
35
+ echo '<option value="'.$category->term_id.'"'.$selected.'>'.$category->name.'</option>';
36
+ }
37
+ }
38
+ else
39
+ {
40
+ echo '<option value="0">No Categories Available</option>';
41
+ }
42
+ ?>
43
+ </select>
44
+ </div>
45
+ </div>
46
+ <div class="description">
47
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ /**
55
+ * Categories Option
56
+ *
57
+ * @access public
58
+ * @since 1.0.0
59
+ *
60
+ * @param array $value
61
+ * @param array $settings
62
+ * @param int $int
63
+ *
64
+ * @return string
65
+ */
66
+ function option_tree_categories( $value, $settings, $int )
67
+ {
68
+ ?>
69
+ <div class="option option-checbox">
70
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
71
+ <div class="section">
72
+ <div class="element">
73
+ <?php
74
+ // check for settings item value
75
+ if ( isset( $settings[$value->item_id] ) )
76
+ {
77
+ $ch_values = explode(',', $settings[$value->item_id] );
78
+ }
79
+ else
80
+ {
81
+ $ch_values = array();
82
+ }
83
+
84
+ // loop through tags
85
+ $categories = &get_categories( array( 'hide_empty' => false ) );
86
+ if ( $categories )
87
+ {
88
+ $count = 0;
89
+ foreach ( $categories as $category )
90
+ {
91
+ $checked = '';
92
+ if ( in_array( $category->term_id, $ch_values ) )
93
+ {
94
+ $checked = ' checked="checked"';
95
+ }
96
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$category->term_id.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$category->name.'</label></div>';
97
+ $count++;
98
+ }
99
+ }
100
+ else
101
+ {
102
+ echo '<p>No Tags Available</p>';
103
+ }
104
+ ?>
105
+ </div>
106
+ <div class="description">
107
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <?php
112
+ }
functions/admin/checkbox.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * ColorPicker Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_checkbox( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-checbox">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <?php
22
+ // check for settings item value
23
+ if ( isset( $settings[$value->item_id] ) )
24
+ {
25
+ $ch_values = explode(',', $settings[$value->item_id] );
26
+ }
27
+ else
28
+ {
29
+ $ch_values = array();
30
+ }
31
+
32
+ $count = 0;
33
+
34
+ // create options array
35
+ $options_array = explode( ',', $value->item_options );
36
+
37
+ // loop through options array
38
+ foreach ( $options_array as $option )
39
+ {
40
+ $checked = '';
41
+ if ( in_array( trim( $option ), $ch_values) )
42
+ {
43
+ $checked = ' checked="checked"';
44
+ }
45
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.trim( $option ).'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.trim( $option ).'</label></div>';
46
+ $count++;
47
+ }
48
+ ?>
49
+ </div>
50
+ <div class="description">
51
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ <?php
56
+ }
functions/admin/colorpicker.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * ColorPicker Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_colorpicker( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-colorpicker">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <script type="text/javascript">
22
+ jQuery(document).ready(function($) {
23
+ $('#<?php echo $value->item_id; ?>').ColorPicker({
24
+ onSubmit: function(hsb, hex, rgb) {
25
+ $('#<?php echo $value->item_id; ?>').val('#'+hex);
26
+ },
27
+ onBeforeShow: function () {
28
+ $(this).ColorPickerSetColor(this.value);
29
+ return false;
30
+ },
31
+ onChange: function (hsb, hex, rgb) {
32
+ $('#cp_<?php echo $value->item_id; ?> div').css({'backgroundColor':'#'+hex, 'backgroundImage': 'none', 'borderColor':'#'+hex});
33
+ $('#cp_<?php echo $value->item_id; ?>').prev('input').attr('value', '#'+hex);
34
+ }
35
+ })
36
+ .bind('keyup', function(){
37
+ $(this).ColorPickerSetColor(this.value);
38
+ });
39
+ });
40
+ </script>
41
+ <input type="text" name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" value="<?php echo ( isset( $settings[$value->item_id] ) ) ? stripslashes( $settings[$value->item_id] ) : ''; ?>" class="cp_input" />
42
+ <div id="cp_<?php echo $value->item_id; ?>" class="cp_box">
43
+ <div style="background-color:<?php echo ( isset ($settings[$value->item_id] ) ) ? $settings[$value->item_id] : '#ffffff'; ?>;<?php if ( isset( $settings[$value->item_id] ) ) { echo 'background-image:none;border-color:' . $settings[$value->item_id] . ';'; } ?>">
44
+ </div>
45
+ </div>
46
+ <small>Click text box for color picker</small>
47
+ </div>
48
+ <div class="description">
49
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <?php
54
+ }
functions/admin/custom-post.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Custom Post Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_custom_post( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <div class="select_wrapper">
22
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
23
+ <?php
24
+ $posts = &get_posts( array( 'post_type' => trim($value->item_options) ) );
25
+ if ( $posts )
26
+ {
27
+ echo '<option value="">-- Choose One --</option>';
28
+ foreach ( $posts as $post )
29
+ {
30
+ $selected = '';
31
+ if ( isset( $settings[$value->item_id] ) && $settings[$value->item_id] == $post->ID )
32
+ {
33
+ $selected = ' selected="selected"';
34
+ }
35
+ echo '<option value="'.$post->ID.'"'.$selected.'>'.$post->post_title.'</option>';
36
+ }
37
+ }
38
+ else
39
+ {
40
+ echo '<option value="0">No Custom Posts Available</option>';
41
+ }
42
+ ?>
43
+ </select>
44
+ </div>
45
+ </div>
46
+ <div class="description">
47
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ /**
55
+ * Custom Posts Option
56
+ *
57
+ * @access public
58
+ * @since 1.0.0
59
+ *
60
+ * @param array $value
61
+ * @param array $settings
62
+ * @param int $int
63
+ *
64
+ * @return string
65
+ */
66
+ function option_tree_custom_posts( $value, $settings, $int )
67
+ {
68
+ ?>
69
+ <div class="option option-checbox">
70
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
71
+ <div class="section">
72
+ <div class="element">
73
+ <?php
74
+ // check for settings item value
75
+ if ( isset( $settings[$value->item_id] ) )
76
+ {
77
+ $ch_values = explode(',', $settings[$value->item_id] );
78
+ }
79
+ else
80
+ {
81
+ $ch_values = array();
82
+ }
83
+
84
+ // loop through tags
85
+ $posts = &get_posts( array( 'post_type' => $value->item_options ) );
86
+ if ( $posts )
87
+ {
88
+ $count = 0;
89
+ foreach ( $posts as $post )
90
+ {
91
+ $checked = '';
92
+ if ( in_array( $post->ID, $ch_values ) )
93
+ {
94
+ $checked = ' checked="checked"';
95
+ }
96
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$post->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$post->post_title.'</label></div>';
97
+ $count++;
98
+ }
99
+ }
100
+ else
101
+ {
102
+ echo '<p>No Custom Posts Available</p>';
103
+ }
104
+ ?>
105
+ </div>
106
+ <div class="description">
107
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <?php
112
+ }
functions/admin/export.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Export Table Data
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $options
9
+ * @param string $table_name
10
+ *
11
+ * @return file
12
+ */
13
+ function option_tree_export_xml( $options, $table_name )
14
+ {
15
+ global $wpdb;
16
+
17
+ // create doctype
18
+ $dom = new DomDocument("1.0");
19
+ $dom->formatOutput = true;
20
+ header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
21
+ header("Pragma: no-cache ");
22
+ header("Content-Type: text/plain");
23
+ header('Content-Disposition: attachment; filename="theme-options-'.date("Y-m-d").'.xml"');
24
+ // create root element
25
+ $root = $dom->createElement($table_name);
26
+ $root = $dom->appendChild($root);
27
+ foreach ($options as $value) {
28
+ // create root element
29
+ $child = $dom->createElement('row');
30
+ $child = $root->appendChild($child);
31
+ // ID
32
+ $item = $dom->createElement('id');
33
+ $item = $child->appendChild($item);
34
+ $text = $dom->createTextNode($value->id);
35
+ $text = $item->appendChild($text);
36
+ // Item ID
37
+ $item = $dom->createElement('item_id');
38
+ $item = $child->appendChild($item);
39
+ $text = $dom->createTextNode($value->item_id);
40
+ $text = $item->appendChild($text);
41
+ // Item Title
42
+ $item = $dom->createElement('item_title');
43
+ $item = $child->appendChild($item);
44
+ $text = $dom->createTextNode($value->item_title);
45
+ $text = $item->appendChild($text);
46
+ // Item Description
47
+ $item = $dom->createElement('item_desc');
48
+ $item = $child->appendChild($item);
49
+ $text = $dom->createTextNode($value->item_desc);
50
+ $text = $item->appendChild($text);
51
+ // Item Type
52
+ $item = $dom->createElement('item_type');
53
+ $item = $child->appendChild($item);
54
+ $text = $dom->createTextNode($value->item_type);
55
+ $text = $item->appendChild($text);
56
+ // Item Options
57
+ $item = $dom->createElement('item_options');
58
+ $item = $child->appendChild($item);
59
+ $text = $dom->createTextNode($value->item_options);
60
+ $text = $item->appendChild($text);
61
+ // Item Sort
62
+ $item = $dom->createElement('item_sort');
63
+ $item = $child->appendChild($item);
64
+ $text = $dom->createTextNode($value->item_sort);
65
+ $text = $item->appendChild($text);
66
+ }
67
+ // save and display tree
68
+ echo $dom->saveXML();
69
+ die();
70
+ }
functions/admin/heading.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Heading Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_heading( $value, $settings, $int )
15
+ {
16
+ echo ( $int > 1 ) ? '</div>' : false;
17
+ echo '<div id="option_' . $value->item_id . '" class="block">';
18
+ echo '<h2>' . htmlspecialchars_decode( $value->item_title ) . '</h2>';
19
+ echo '<input type="hidden" name="' . $value->item_id . '" value="' . htmlspecialchars_decode( $value->item_title ) . '" />';
20
+ }
functions/admin/input.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Input Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_input( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-input">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <input type="text" name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" value="<?php if ( isset($settings[$value->item_id]) ) { echo htmlspecialchars( stripslashes( $settings[$value->item_id] ), ENT_QUOTES); } ?>" />
22
+ </div>
23
+ <div class="description">
24
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ <?php
29
+ }
functions/admin/page.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Page Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_page( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <div class="select_wrapper">
22
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
23
+ <?php
24
+ $pages = &get_pages();
25
+ if ( $pages )
26
+ {
27
+ echo '<option value="">-- Choose One --</option>';
28
+ foreach ( $pages as $page )
29
+ {
30
+ $selected = '';
31
+ if ( isset( $settings[$value->item_id] ) && $settings[$value->item_id] == $page->ID )
32
+ {
33
+ $selected = ' selected="selected"';
34
+ }
35
+ echo '<option value="'.$page->ID.'"'.$selected.'>'.$page->post_title.'</option>';
36
+ }
37
+ }
38
+ else
39
+ {
40
+ echo '<option value="0">No Pages Available</option>';
41
+ }
42
+ ?>
43
+ </select>
44
+ </div>
45
+ </div>
46
+ <div class="description">
47
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ /**
55
+ * Pages Option
56
+ *
57
+ * @access public
58
+ * @since 1.0.0
59
+ *
60
+ * @param array $value
61
+ * @param array $settings
62
+ * @param int $int
63
+ *
64
+ * @return string
65
+ */
66
+ function option_tree_pages( $value, $settings, $int )
67
+ {
68
+ ?>
69
+ <div class="option option-checbox">
70
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
71
+ <div class="section">
72
+ <div class="element">
73
+ <?php
74
+ // check for settings item value
75
+ if ( isset( $settings[$value->item_id] ) )
76
+ {
77
+ $ch_values = explode(',', $settings[$value->item_id] );
78
+ }
79
+ else
80
+ {
81
+ $ch_values = array();
82
+ }
83
+
84
+ // loop through tags
85
+ $pages = &get_pages();
86
+ if ( $pages )
87
+ {
88
+ $count = 0;
89
+ foreach ( $pages as $page )
90
+ {
91
+ $checked = '';
92
+ if ( in_array( $page->ID, $ch_values ) )
93
+ {
94
+ $checked = ' checked="checked"';
95
+ }
96
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$page->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$page->post_title.'</label></div>';
97
+ $count++;
98
+ }
99
+ }
100
+ else
101
+ {
102
+ echo '<p>No Pages Available</p>';
103
+ }
104
+ ?>
105
+ </div>
106
+ <div class="description">
107
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <?php
112
+ }
functions/admin/post.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Post Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_post( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <div class="select_wrapper">
22
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
23
+ <?php
24
+ $posts = &get_posts();
25
+ if ( $posts )
26
+ {
27
+ echo '<option value="">-- Choose One --</option>';
28
+ foreach ( $posts as $post )
29
+ {
30
+ $selected = '';
31
+ if ( isset( $settings[$value->item_id] ) && $settings[$value->item_id] == $post->ID )
32
+ {
33
+ $selected = ' selected="selected"';
34
+ }
35
+ echo '<option value="'.$post->ID.'"'.$selected.'>'.$post->post_title.'</option>';
36
+ }
37
+ }
38
+ else
39
+ {
40
+ echo '<option value="0">No Pages Available</option>';
41
+ }
42
+ ?>
43
+ </select>
44
+ </div>
45
+ </div>
46
+ <div class="description">
47
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ /**
55
+ * Posts Option
56
+ *
57
+ * @access public
58
+ * @since 1.0.0
59
+ *
60
+ * @param array $value
61
+ * @param array $settings
62
+ * @param int $int
63
+ *
64
+ * @return string
65
+ */
66
+ function option_tree_posts( $value, $settings, $int )
67
+ {
68
+ ?>
69
+ <div class="option option-checbox">
70
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
71
+ <div class="section">
72
+ <div class="element">
73
+ <?php
74
+ // check for settings item value
75
+ if ( isset( $settings[$value->item_id] ) )
76
+ {
77
+ $ch_values = explode(',', $settings[$value->item_id] );
78
+ }
79
+ else
80
+ {
81
+ $ch_values = array();
82
+ }
83
+
84
+ // loop through tags
85
+ $posts = &get_posts();
86
+ if ( $posts )
87
+ {
88
+ $count = 0;
89
+ foreach ( $posts as $post )
90
+ {
91
+ $checked = '';
92
+ if ( in_array( $post->ID, $ch_values ) )
93
+ {
94
+ $checked = ' checked="checked"';
95
+ }
96
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$post->ID.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$post->post_title.'</label></div>';
97
+ $count++;
98
+ }
99
+ }
100
+ else
101
+ {
102
+ echo '<p>No Pages Available</p>';
103
+ }
104
+ ?>
105
+ </div>
106
+ <div class="description">
107
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <?php
112
+ }
functions/admin/radio.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Radio Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_radio( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-radio">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <?php
22
+ // check for settings item value
23
+ if ( isset( $settings[$value->item_id] ) )
24
+ {
25
+ $ch_values = explode(',', $settings[$value->item_id] );
26
+ }
27
+ else
28
+ {
29
+ $ch_values = array();
30
+ }
31
+
32
+ $count = 0;
33
+
34
+ // create options array
35
+ $options_array = explode( ',', $value->item_options );
36
+
37
+ // loop through options array
38
+ foreach ( $options_array as $option )
39
+ {
40
+ $checked = '';
41
+ if ( in_array( trim( $option ), $ch_values ) )
42
+ {
43
+ $checked = ' checked="checked"';
44
+ }
45
+ echo '<div class="input_wrap"><input name="radios['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="radio" value="'.trim( $option ).'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.trim( $option ).'</label></div>';
46
+ $count++;
47
+ }
48
+ ?>
49
+ </div>
50
+ <div class="description">
51
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ <?php
56
+ }
functions/admin/select.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Select Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_select( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <?php $options_array = explode( ',', $value->item_options ); ?>
22
+ <div class="select_wrapper">
23
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
24
+ <?php
25
+ echo '<option value="">-- Choose One --</option>';
26
+ foreach ( $options_array as $option )
27
+ {
28
+ $selected = '';
29
+ if ( $settings[$value->item_id] == trim( $option ) )
30
+ {
31
+ $selected = ' selected="selected"';
32
+ }
33
+ echo '<option'.$selected.'>'.trim( $option ).'</option>';
34
+ }
35
+ ?>
36
+ </select>
37
+ </div>
38
+ </div>
39
+ <div class="description">
40
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ <?php
45
+ }
functions/admin/tag.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Tag Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_tag( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-select">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <div class="select_wrapper">
22
+ <select name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" class="select">
23
+ <?php
24
+ $tags = &get_tags( array( 'hide_empty' => false ) );
25
+ if ( $tags )
26
+ {
27
+ echo '<option value="">-- Choose One --</option>';
28
+ foreach ( $tags as $tag )
29
+ {
30
+ $selected = '';
31
+ if ( isset( $settings[$value->item_id] ) && $settings[$value->item_id] == $tag->term_id )
32
+ {
33
+ $selected = ' selected="selected"';
34
+ }
35
+ echo '<option value="'.$tag->term_id.'"'.$selected.'>'.$tag->name.'</option>';
36
+ }
37
+ }
38
+ else
39
+ {
40
+ echo '<option value="0">No Tags Available</option>';
41
+ }
42
+ ?>
43
+ </select>
44
+ </div>
45
+ </div>
46
+ <div class="description">
47
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <?php
52
+ }
53
+
54
+ /**
55
+ * Tags Option
56
+ *
57
+ * @access public
58
+ * @since 1.0.0
59
+ *
60
+ * @param array $value
61
+ * @param array $settings
62
+ * @param int $int
63
+ *
64
+ * @return string
65
+ */
66
+ function option_tree_tags( $value, $settings, $int )
67
+ {
68
+ ?>
69
+ <div class="option option-checbox">
70
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
71
+ <div class="section">
72
+ <div class="element">
73
+ <?php
74
+ // check for settings item value
75
+ if ( isset( $settings[$value->item_id] ) )
76
+ {
77
+ $ch_values = explode(',', $settings[$value->item_id] );
78
+ }
79
+ else
80
+ {
81
+ $ch_values = array();
82
+ }
83
+
84
+ // loop through tags
85
+ $tags = &get_tags( array( 'hide_empty' => false ) );
86
+ if ( $tags )
87
+ {
88
+ $count = 0;
89
+ foreach ( $tags as $tag )
90
+ {
91
+ $checked = '';
92
+ if ( in_array( $tag->term_id, $ch_values ) )
93
+ {
94
+ $checked = ' checked="checked"';
95
+ }
96
+ echo '<div class="input_wrap"><input name="checkboxes['.$value->item_id.'][]" id="'.$value->item_id.'_'.$count.'" type="checkbox" value="'.$tag->term_id.'"'.$checked.' /><label for="'.$value->item_id.'_'.$count.'">'.$tag->name.'</label></div>';
97
+ $count++;
98
+ }
99
+ }
100
+ else
101
+ {
102
+ echo '<p>No Tags Available</p>';
103
+ }
104
+ ?>
105
+ </div>
106
+ <div class="description">
107
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ <?php
112
+ }
functions/admin/textarea.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Textarea Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_textarea( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-textarea">
18
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
19
+ <div class="section">
20
+ <div class="element">
21
+ <textarea name="<?php echo $value->item_id; ?>" rows="<?php echo $int; ?>"><?php
22
+ if ( isset( $settings[$value->item_id] ) )
23
+ echo $settings[$value->item_id];
24
+ ?></textarea>
25
+ </div>
26
+ <div class="description">
27
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ <?php
32
+ }
functions/admin/textblock.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Text Block Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_textblock( $value, $settings, $int )
15
+ {
16
+ ?>
17
+ <div class="option option-textblock">
18
+ <!-- <h3 class="text-title"><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3> -->
19
+ <div class="section">
20
+ <div class="text_block">
21
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <?php
26
+ }
functions/admin/upload.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Upload Option
4
+ *
5
+ * @access public
6
+ * @since 1.0.0
7
+ *
8
+ * @param array $value
9
+ * @param array $settings
10
+ * @param int $int
11
+ *
12
+ * @return string
13
+ */
14
+ function option_tree_upload( $value, $settings, $int ) { ?>
15
+ <div class="option option-upload">
16
+ <h3><?php echo htmlspecialchars_decode( $value->item_title ); ?></h3>
17
+ <div class="section">
18
+ <div class="element">
19
+ <input type="text" name="<?php echo $value->item_id; ?>" id="<?php echo $value->item_id; ?>" value="<?php if ( $settings[$value->item_id] ) { echo $settings[$value->item_id]; } ?>" class="upload<?php if ( $settings[$value->item_id] ) { echo ' has-file'; } ?>" />
20
+ <input id="upload_<?php echo $value->item_id; ?>" class="upload_button" type="button" value="Upload" rel="<?php echo $int; ?>" />
21
+ <div class="screenshot" id="<?php echo $value->item_id; ?>_image">
22
+ <?php
23
+ if ( isset( $settings[$value->item_id] ) )
24
+ {
25
+ $remove = '<a href="javascript:(void);" class="remove">Remove</a>';
26
+ $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $settings[$value->item_id] );
27
+ if ( $image )
28
+ {
29
+ echo '<img src="'.$settings[$value->item_id].'" alt="" />'.$remove.'';
30
+ }
31
+ else
32
+ {
33
+ $parts = explode( "/", $settings[$value->item_id] );
34
+ for( $i = 0; $i < sizeof($parts); ++$i )
35
+ {
36
+ $title = $parts[$i];
37
+ }
38
+ echo '<div class="no_image"><a href="'.$settings[$value->item_id].'">'.$title.'</a>'.$remove.'</div>';
39
+ }
40
+ }
41
+ ?>
42
+ </div>
43
+ </div>
44
+ <div class="description">
45
+ <?php echo htmlspecialchars_decode( $value->item_desc ); ?>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ <?php
50
+ }
functions/functions.load.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Functions Load
4
+ *
5
+ * @package WordPress
6
+ * @subpackage OptionTree
7
+ * @since 1.0.0
8
+ * @author Derek Herman
9
+ */
10
+ if ( is_admin() )
11
+ {
12
+ include( 'admin/export.php' );
13
+ include( 'admin/heading.php' );
14
+ include( 'admin/input.php' );
15
+ include( 'admin/checkbox.php' );
16
+ include( 'admin/radio.php' );
17
+ include( 'admin/select.php' );
18
+ include( 'admin/textarea.php' );
19
+ include( 'admin/upload.php' );
20
+ include( 'admin/colorpicker.php' );
21
+ include( 'admin/textblock.php' );
22
+ include( 'admin/post.php' );
23
+ include( 'admin/page.php' );
24
+ include( 'admin/category.php' );
25
+ include( 'admin/tag.php' );
26
+ include( 'admin/custom-post.php' );
27
+ }
28
+ else if ( !is_admin() )
29
+ {
30
+ include( 'get-option-tree.php' );
31
+ }
functions/get-option-tree.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('OT_VERSION')) exit('No direct script access allowed');
2
+ /**
3
+ * Displays or returns a value from the 'option_tree' array.
4
+ *
5
+ * @uses get_option()
6
+ *
7
+ * @access public
8
+ * @since 1.0.0
9
+ *
10
+ * @param string $item_id
11
+ * @param array $options
12
+ * @param bool $echo
13
+ * @param bool $is_array
14
+ * @param int $offset
15
+ *
16
+ * @return mixed
17
+ */
18
+ function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1)
19
+ {
20
+ // load saved options
21
+ if ( !$options )
22
+ $options = get_option( 'option_tree' );
23
+
24
+ // set the item
25
+ if ( !isset( $options[$item_id] ) )
26
+ return;
27
+
28
+ // single item value
29
+ $content = $options[$item_id];
30
+
31
+ // create an array of values
32
+ if ( $is_array )
33
+ {
34
+ $content = explode( ',', $content );
35
+ if ( is_numeric( $offset ) && $offset >= 0)
36
+ {
37
+ $content = htmlspecialchars_decode( trim( $content[$offset] ) );
38
+ }
39
+ }
40
+
41
+ // echo content
42
+ if ($echo)
43
+ echo $content;
44
+
45
+ return $content;
46
+ }
index.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: OptionTree
4
+ Plugin URI: http://wp.envato.com
5
+ Description: Customizable WordPress Theme Options Admin Interface
6
+ Version: 1.1
7
+ Author: Derek Herman
8
+ Author URI: http://valendesigns.com
9
+ */
10
+
11
+ /**
12
+ * Definitions
13
+ *
14
+ * @since 1.0.0
15
+ */
16
+ define( 'OT_VERSION', '1.1' );
17
+ define( 'OT_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
18
+ define( 'OT_PLUGIN_URL', WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
19
+
20
+ /**
21
+ * Required Files
22
+ *
23
+ * @since 1.0.0
24
+ */
25
+ require_once('functions/functions.load.php');
26
+ require_once('classes/class.admin.php');
27
+
28
+ /**
29
+ * Instantiate Classe
30
+ *
31
+ * @since 1.0.0
32
+ */
33
+ $ot_admin = new OT_Admin();
34
+
35
+ /**
36
+ * Wordpress Activate/Deactivate
37
+ *
38
+ * @uses register_activation_hook()
39
+ * @uses register_deactivation_hook()
40
+ *
41
+ * @since 1.0.0
42
+ */
43
+ register_activation_hook( __FILE__, array( $ot_admin, 'option_tree_activate' ) );
44
+ register_deactivation_hook( __FILE__, array( $ot_admin, 'option_tree_deactivate' ) );
45
+
46
+ /**
47
+ * Required action filters
48
+ *
49
+ * @uses add_action()
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ add_action( 'init', array( $ot_admin, 'create_option_post' ), 5 );
54
+ add_action( 'admin_init', array( $ot_admin, 'option_tree_init' ) );
55
+ add_action( 'admin_menu', array( $ot_admin, 'option_tree_admin' ) );
56
+ add_action( 'wp_ajax_option_tree_array_save', array( $ot_admin, 'option_tree_array_save' ) );
57
+ add_action( 'wp_ajax_option_tree_array_reset', array( $ot_admin, 'option_tree_array_reset' ) );
58
+ add_action( 'wp_ajax_option_tree_add', array( $ot_admin, 'option_tree_add' ) );
59
+ add_action( 'wp_ajax_option_tree_edit', array( $ot_admin, 'option_tree_edit' ) );
60
+ add_action( 'wp_ajax_option_tree_delete', array( $ot_admin, 'option_tree_delete' ) );
61
+ add_action( 'wp_ajax_option_tree_next_id', array( $ot_admin, 'option_tree_next_id' ) );
62
+ add_action( 'wp_ajax_option_tree_sort', array( $ot_admin, 'option_tree_sort' ) );
63
+ add_action( 'wp_ajax_option_tree_import_data', array( $ot_admin, 'option_tree_import_data' ) );
readme.txt ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === OptionTree ===
2
+ Contributors: valendesigns
3
+ Donate link:
4
+ Tags: admin, theme options, options, admin interface, ajax
5
+ Requires at least: 3.0
6
+ Tested up to: 3.0.1
7
+ Stable tag: 1.1
8
+
9
+ Customizable WordPress Theme Options Admin Interface
10
+
11
+ == Description ==
12
+
13
+ Theme Options are what make a WordPress Theme truly custom. OptionTree attempts to bridge the gap between developers, designers and end-users by solving the admin User Interface issues that arise when creating a custom theme. Designers shouldn't have to be limited to what they can create visually because their programming skills aren't as developed as they would like. Also, programmers shouldn't have to recreate the wheel for every new project, so in walks OptionTree.
14
+
15
+ With OptionTree you can create as many Theme Options as your project requires and use them how you see fit. When you add a option to the Settings page, it will be available on the Theme Options page for use in your theme.
16
+
17
+ Included is the ability to Import/Export all the theme options and data for packaging with custom themes or local development. With the Import/Export feature you can get a theme set up on a live server in minutes. Theme authors can now create different version of their themes and include them with the download. It makes setting up different theme styles & options easier than ever because a theme user installs the plugin and theme and either adds their own settings or imports your defaults.
18
+
19
+ OptionTree is a project sponsored by ThemeForest, the largest WordPress theme marketplace on the web, and was originally conceived to help ThemeForest authors quickly power up their themes. But it's here for the benefit of one and all, so option up folks!
20
+
21
+ == Installation ==
22
+
23
+ 1. Upload `option-tree` to the `/wp-content/plugins/` directory
24
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
25
+ 1. If included in your theme, import the XML file & data by going to `OptionTree->Settings->Import`
26
+ 1. Click the `OptionTree->Documentation` link in the WordPress admin sidebar menu for further setup assistance.
27
+
28
+ == Frequently Asked Questions ==
29
+
30
+ = Is this plugin PHP5 only? =
31
+
32
+ Yes OptionTree requires your host be running PHP5 to work correctly.
33
+
34
+ == Screenshots ==
35
+
36
+ 1. Settings
37
+ 2. Theme Options
38
+ 3. Documentation
39
+
40
+ == Changelog ==
41
+
42
+ = 1.1 =
43
+ * Fixed the Undefined index: notices when WP_DEBUG is set to true
44
+
45
+ = 1.0.0 =
46
+ * Initial version
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file