Version Description
- White listed options for increased security
- Fixed errors with checkbox and select boxes
- Improved the multicheck option and changed format
Download this release
Release Info
Developer | downstairsdev |
Plugin | Options Framework |
Version | 0.3 |
Comparing to | |
See all releases |
Version 0.3
- css/admin-style.css +316 -0
- css/colorpicker.css +177 -0
- images/colorpicker/blank.gif +0 -0
- images/colorpicker/colorpicker_background.png +0 -0
- images/colorpicker/colorpicker_hex.png +0 -0
- images/colorpicker/colorpicker_hsb_b.png +0 -0
- images/colorpicker/colorpicker_hsb_h.png +0 -0
- images/colorpicker/colorpicker_hsb_s.png +0 -0
- images/colorpicker/colorpicker_indic.gif +0 -0
- images/colorpicker/colorpicker_overlay.png +0 -0
- images/colorpicker/colorpicker_rgb_b.png +0 -0
- images/colorpicker/colorpicker_rgb_g.png +0 -0
- images/colorpicker/colorpicker_rgb_r.png +0 -0
- images/colorpicker/colorpicker_select.gif +0 -0
- images/colorpicker/colorpicker_submit.png +0 -0
- images/colorpicker/select.png +0 -0
- images/ico-delete.png +0 -0
- js/colorpicker.js +455 -0
- js/of-medialibrary-uploader.js +157 -0
- js/options-custom.js +83 -0
- options-framework.php +481 -0
- options-interface.php +315 -0
- options-medialibrary-uploader.php +283 -0
- options.php +39 -0
- readme.txt +67 -0
- screenshot-1.png +0 -0
css/admin-style.css
ADDED
@@ -0,0 +1,316 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*-------------------------------------------------------------------------------------------*/
|
2 |
+
/* OptionsFramework Admin Styles */
|
3 |
+
/*-------------------------------------------------------------------------------------------*/
|
4 |
+
|
5 |
+
.updated {
|
6 |
+
width:770px;
|
7 |
+
}
|
8 |
+
#of_container {
|
9 |
+
margin: 10px 0;
|
10 |
+
width: 785px;
|
11 |
+
position:relative;
|
12 |
+
z-index: 0
|
13 |
+
}
|
14 |
+
#of_container #header {
|
15 |
+
height: 60px;
|
16 |
+
background:#dfdfdf url("../../../../wp-admin/images/gray-grad.png") repeat-x left top;
|
17 |
+
border: 1px solid #ccc;
|
18 |
+
border-top-left-radius: 6px;
|
19 |
+
-moz-border-radius-topleft: 6px;
|
20 |
+
-webkit-border-top-left-radius: 6px;
|
21 |
+
-webkit-border-top-right-radius: 6px;
|
22 |
+
border-top-right-radius: 6px;
|
23 |
+
-moz-border-radius-topright: 6px;
|
24 |
+
}
|
25 |
+
#of_container #header .logo {
|
26 |
+
float: left;
|
27 |
+
margin:5px 20px;
|
28 |
+
}
|
29 |
+
#of_container #header .logo h2 {
|
30 |
+
font-style:normal;
|
31 |
+
font-size: 22px;
|
32 |
+
line-height: 26px;
|
33 |
+
}
|
34 |
+
#of_container #main {
|
35 |
+
background-color: #f1f1f1;
|
36 |
+
border-left: 1px solid #d8d8d8;
|
37 |
+
border-right: 1px solid #d8d8d8;
|
38 |
+
border-bottom: 1px solid #d8d8d8;
|
39 |
+
}
|
40 |
+
#of_container #of-nav {
|
41 |
+
float: left;
|
42 |
+
position: relative;
|
43 |
+
z-index: 9999;
|
44 |
+
width: 160px;
|
45 |
+
}
|
46 |
+
#of_container #of-nav li {
|
47 |
+
margin-bottom:0
|
48 |
+
}
|
49 |
+
#of_container #of-nav ul li a:link, #of-nav ul li a:visited {
|
50 |
+
display: block;
|
51 |
+
padding: 10px 10px 10px 15px;
|
52 |
+
font-family: Georgia, Serif;
|
53 |
+
font-size: 13px;
|
54 |
+
text-decoration: none;
|
55 |
+
color: #797979;
|
56 |
+
border-bottom: 1px solid #d8d8d8;
|
57 |
+
}
|
58 |
+
#of_container #of-nav ul li.current a, #of-nav ul li a:hover {
|
59 |
+
color: #21759b;
|
60 |
+
background-color: #fff;
|
61 |
+
}
|
62 |
+
#of_container #content {
|
63 |
+
float: left;
|
64 |
+
min-height: 560px;
|
65 |
+
width: 595px;
|
66 |
+
margin-left: -1px;
|
67 |
+
padding: 0 14px;
|
68 |
+
background-color: #fff;
|
69 |
+
border-left: 1px solid #d8d8d8;
|
70 |
+
}
|
71 |
+
#of_container #content .section {
|
72 |
+
margin-bottom: 10px;
|
73 |
+
}
|
74 |
+
#of_container #content .section h3.heading {
|
75 |
+
margin: 10px 0 10px 0;
|
76 |
+
padding: 7px 0px;
|
77 |
+
border-bottom: 1px solid #e7e7e7;
|
78 |
+
}
|
79 |
+
#of_container #content .section .controls {
|
80 |
+
float: left;
|
81 |
+
width: 345px;
|
82 |
+
margin: 0 15px 0 0;
|
83 |
+
}
|
84 |
+
#of_container #content .section .explain {
|
85 |
+
float: left;
|
86 |
+
width: 225px;
|
87 |
+
padding: 0 10px 0 0;
|
88 |
+
font-size: 11px;
|
89 |
+
color: #999999;
|
90 |
+
}
|
91 |
+
#of_container #content .section-checkbox .controls {
|
92 |
+
width:25px
|
93 |
+
}
|
94 |
+
#of_container #content .section-checkbox .explain {
|
95 |
+
width:540px
|
96 |
+
}
|
97 |
+
#of_container #content .section-color .controls {
|
98 |
+
width:125px
|
99 |
+
}
|
100 |
+
#of_container #content .section-color .explain {
|
101 |
+
width:440px
|
102 |
+
}
|
103 |
+
#of_container textarea, #of_container input, #of_container select {
|
104 |
+
-moz-border-radius-bottomleft:4px;
|
105 |
+
-moz-border-radius-bottomright:4px;
|
106 |
+
-moz-border-radius-topleft:4px;
|
107 |
+
-moz-border-radius-topright:4px;
|
108 |
+
border-style:solid;
|
109 |
+
border-width:1px;
|
110 |
+
}
|
111 |
+
#of_container .controls input, #of_container .controls select, #of_container .controls textarea {
|
112 |
+
margin-bottom: 10px;
|
113 |
+
background-color: #f1f1f1;
|
114 |
+
border: 1px solid;
|
115 |
+
border-color: #ccc #e6e6e6 #e6e6e6 #ccc;
|
116 |
+
width: 340px;
|
117 |
+
padding: 4px;
|
118 |
+
font-size: 12px;
|
119 |
+
}
|
120 |
+
#of_container .controls select {
|
121 |
+
padding: 0 0 0 4px;
|
122 |
+
width: 340px
|
123 |
+
}
|
124 |
+
#of_container .controls textarea {
|
125 |
+
width: 345px;
|
126 |
+
}
|
127 |
+
#of_container input[type=text] {
|
128 |
+
width: 340px;
|
129 |
+
}
|
130 |
+
#of_container input.checkbox {
|
131 |
+
width: 30px;
|
132 |
+
}
|
133 |
+
#of_container input.of-radio {
|
134 |
+
width: 30px;
|
135 |
+
}
|
136 |
+
#of_container .controls .of-color {
|
137 |
+
float:left;
|
138 |
+
width: 80px;
|
139 |
+
margin-left:5px;
|
140 |
+
}
|
141 |
+
#of_container #content .section-typography .controls {
|
142 |
+
width:425px
|
143 |
+
}
|
144 |
+
#of_container #content .section-typography .explain {
|
145 |
+
width:140px
|
146 |
+
}
|
147 |
+
#of_container .controls .of-typography-size {
|
148 |
+
width:80px;
|
149 |
+
float:left
|
150 |
+
}
|
151 |
+
#of_container .controls .of-typography-unit {
|
152 |
+
width:50px;
|
153 |
+
float:left
|
154 |
+
}
|
155 |
+
#of_container .controls .of-typography-face {
|
156 |
+
width:100px;
|
157 |
+
float:left
|
158 |
+
}
|
159 |
+
#of_container .controls .of-typography-style {
|
160 |
+
width:80px;
|
161 |
+
float:left
|
162 |
+
}
|
163 |
+
#of_container #content .section-background .controls {
|
164 |
+
width:425px
|
165 |
+
}
|
166 |
+
#of_container #content .section-background .explain {
|
167 |
+
width:140px
|
168 |
+
}
|
169 |
+
#of_container .of-background-properties {
|
170 |
+
margin-top: 18px;
|
171 |
+
}
|
172 |
+
#of_container .controls .of-background-repeat {
|
173 |
+
width:160px;
|
174 |
+
float:left
|
175 |
+
}
|
176 |
+
#of_container .controls .of-background-position {
|
177 |
+
width:125px;
|
178 |
+
float:left
|
179 |
+
}
|
180 |
+
#of_container .controls .of-background-attachment {
|
181 |
+
width:125px;
|
182 |
+
float:left
|
183 |
+
}
|
184 |
+
#of_container div.section-background .controls input.upload {
|
185 |
+
width: 240px;
|
186 |
+
}
|
187 |
+
#of_container .controls .of-radio-img-img {
|
188 |
+
border:3px solid #fff;
|
189 |
+
margin:0 5px 10px 0;
|
190 |
+
display:none;
|
191 |
+
cursor:pointer;
|
192 |
+
float:left;
|
193 |
+
}
|
194 |
+
#of_container .controls .of-radio-img-selected {
|
195 |
+
border:3px solid #ccc
|
196 |
+
}
|
197 |
+
#of_container .controls .of-radio-img-img:hover {
|
198 |
+
opacity:.8;
|
199 |
+
}
|
200 |
+
#of_container .controls .of-border-width {
|
201 |
+
width:80px;
|
202 |
+
float:left
|
203 |
+
}
|
204 |
+
#of_container .controls .of-border-style {
|
205 |
+
width:120px;
|
206 |
+
float:left
|
207 |
+
}
|
208 |
+
#of_container .group {
|
209 |
+
padding-bottom:20px
|
210 |
+
}
|
211 |
+
#of_container .group h2 {
|
212 |
+
display:none;
|
213 |
+
border-bottom:3px solid #e7e7e7
|
214 |
+
}
|
215 |
+
#of_container .controls input:focus, #of_container select:focus, #of_container textarea:focus {
|
216 |
+
background:#fff;
|
217 |
+
}
|
218 |
+
#of_container .hide {
|
219 |
+
display:none;
|
220 |
+
}
|
221 |
+
#of_container .of-option-image {
|
222 |
+
max-width:340px;
|
223 |
+
margin:3px 0 18px 0;
|
224 |
+
}
|
225 |
+
#of_container .mini .controls select, #of_container #content .section .mini .controls {
|
226 |
+
width: 70px;
|
227 |
+
}
|
228 |
+
#of_container .mini .controls input, #of_container #content .mini .controls {
|
229 |
+
width: 70px;
|
230 |
+
}
|
231 |
+
#of_container #content .mini .explain {
|
232 |
+
width:500px;
|
233 |
+
}
|
234 |
+
|
235 |
+
/* Image Uploader */
|
236 |
+
|
237 |
+
#of_container .controls input.upload {
|
238 |
+
width:280px;
|
239 |
+
padding-bottom:6px;
|
240 |
+
}
|
241 |
+
#of_container .controls input.upload_button {
|
242 |
+
float:right;
|
243 |
+
width:45px;
|
244 |
+
border-color:#BBBBBB;
|
245 |
+
cursor:pointer;
|
246 |
+
height:16px;
|
247 |
+
}
|
248 |
+
#of_container .controls input.upload_button:hover {
|
249 |
+
border-color:#666666;
|
250 |
+
color:#000;
|
251 |
+
}
|
252 |
+
#of_container .screenshot {
|
253 |
+
float:left;
|
254 |
+
margin-left:1px;
|
255 |
+
position:relative;
|
256 |
+
width:344px;
|
257 |
+
margin-top:3px;
|
258 |
+
}
|
259 |
+
#of_container .section-background .screenshot {
|
260 |
+
margin-bottom:18px;
|
261 |
+
}
|
262 |
+
#of_container .screenshot img {
|
263 |
+
-moz-border-radius:4px;
|
264 |
+
-webkit-border-radius:4px;
|
265 |
+
-border-radius:4px;
|
266 |
+
background:#FAFAFA;
|
267 |
+
border-color:#ccc #eee #eee #ccc;
|
268 |
+
border-style:solid;
|
269 |
+
border-width:1px;
|
270 |
+
float:left;
|
271 |
+
max-width:334px;
|
272 |
+
padding:4px;
|
273 |
+
}
|
274 |
+
#of_container .screenshot .mlu_remove {
|
275 |
+
background:url("../images/ico-delete.png") no-repeat;
|
276 |
+
border:medium none;
|
277 |
+
bottom:-4px;
|
278 |
+
display:block;
|
279 |
+
float:left;
|
280 |
+
height:16px;
|
281 |
+
padding:0;
|
282 |
+
position:absolute;
|
283 |
+
left:-4px;
|
284 |
+
text-indent:-9999px;
|
285 |
+
width:16px;
|
286 |
+
}
|
287 |
+
#of_container .screenshot .no_image .file_link {
|
288 |
+
margin-left: 20px;
|
289 |
+
}
|
290 |
+
#of_container .screenshot .no_image .mlu_remove {
|
291 |
+
bottom: 0px;
|
292 |
+
}
|
293 |
+
#of_container .reset-button {
|
294 |
+
float:left;
|
295 |
+
cursor:pointer;
|
296 |
+
}
|
297 |
+
|
298 |
+
/* Bottom Section */
|
299 |
+
|
300 |
+
#of_container .button-primary {
|
301 |
+
float:right;
|
302 |
+
}
|
303 |
+
#of_container .of_admin_bar {
|
304 |
+
background: #f3f3f3;
|
305 |
+
border:solid #ccc;
|
306 |
+
border-width:0px 1px 1px 1px;
|
307 |
+
padding: 10px 20px 0px 20px;
|
308 |
+
height: 35px;
|
309 |
+
text-align: right;
|
310 |
+
-moz-border-radius-bottomright: 6px;
|
311 |
+
-moz-border-radius-bottomleft: 6px;
|
312 |
+
-webkit-border-bottom-right-radius: 6px;
|
313 |
+
-webkit-border-bottom-left-radius: 6px;
|
314 |
+
border-bottom-right-radius: 6px;
|
315 |
+
border-bottom-left-radius: 6px;
|
316 |
+
}
|
css/colorpicker.css
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.colorpicker {
|
2 |
+
width: 356px;
|
3 |
+
height: 176px;
|
4 |
+
overflow: hidden;
|
5 |
+
position: absolute;
|
6 |
+
background: url(../images/colorpicker/colorpicker_background.png);
|
7 |
+
font-family: Arial, Helvetica, sans-serif;
|
8 |
+
display: none;
|
9 |
+
}
|
10 |
+
.colorpicker_color {
|
11 |
+
width: 150px;
|
12 |
+
height: 150px;
|
13 |
+
left: 14px;
|
14 |
+
top: 13px;
|
15 |
+
position: absolute;
|
16 |
+
background: #f00;
|
17 |
+
overflow: hidden;
|
18 |
+
cursor: crosshair;
|
19 |
+
}
|
20 |
+
.colorpicker_color div {
|
21 |
+
position: absolute;
|
22 |
+
top: 0;
|
23 |
+
left: 0;
|
24 |
+
width: 150px;
|
25 |
+
height: 150px;
|
26 |
+
background: url(../images/colorpicker/colorpicker_overlay.png);
|
27 |
+
}
|
28 |
+
.colorpicker_color div div {
|
29 |
+
position: absolute;
|
30 |
+
top: 0;
|
31 |
+
left: 0;
|
32 |
+
width: 11px;
|
33 |
+
height: 11px;
|
34 |
+
overflow: hidden;
|
35 |
+
background: url(../images/colorpicker/colorpicker_select.gif);
|
36 |
+
margin: -5px 0 0 -5px;
|
37 |
+
}
|
38 |
+
.colorpicker_hue {
|
39 |
+
position: absolute;
|
40 |
+
top: 13px;
|
41 |
+
left: 171px;
|
42 |
+
width: 35px;
|
43 |
+
height: 150px;
|
44 |
+
cursor: n-resize;
|
45 |
+
}
|
46 |
+
.colorpicker_hue div {
|
47 |
+
position: absolute;
|
48 |
+
width: 35px;
|
49 |
+
height: 9px;
|
50 |
+
overflow: hidden;
|
51 |
+
background: url(../images/colorpicker/colorpicker_indic.gif) left top;
|
52 |
+
margin: -4px 0 0 0;
|
53 |
+
left: 0px;
|
54 |
+
}
|
55 |
+
.colorpicker_new_color {
|
56 |
+
position: absolute;
|
57 |
+
width: 60px;
|
58 |
+
height: 30px;
|
59 |
+
left: 213px;
|
60 |
+
top: 13px;
|
61 |
+
background: #f00;
|
62 |
+
}
|
63 |
+
.colorpicker_current_color {
|
64 |
+
position: absolute;
|
65 |
+
width: 60px;
|
66 |
+
height: 30px;
|
67 |
+
left: 283px;
|
68 |
+
top: 13px;
|
69 |
+
background: #f00;
|
70 |
+
}
|
71 |
+
.colorpicker input {
|
72 |
+
background-color: transparent;
|
73 |
+
border: 1px solid transparent;
|
74 |
+
position: absolute;
|
75 |
+
font-size: 10px;
|
76 |
+
font-family: Arial, Helvetica, sans-serif;
|
77 |
+
color: #898989;
|
78 |
+
top: 4px;
|
79 |
+
right: 11px;
|
80 |
+
text-align: right;
|
81 |
+
margin: 0;
|
82 |
+
padding: 0;
|
83 |
+
height: 12px;
|
84 |
+
}
|
85 |
+
.colorpicker_hex {
|
86 |
+
position: absolute;
|
87 |
+
width: 72px;
|
88 |
+
height: 22px;
|
89 |
+
background: url(../images/colorpicker/colorpicker_hex.png) top;
|
90 |
+
left: 212px;
|
91 |
+
top: 142px;
|
92 |
+
}
|
93 |
+
.colorpicker_hex input {
|
94 |
+
right: 6px;
|
95 |
+
}
|
96 |
+
.colorpicker_field {
|
97 |
+
height: 22px;
|
98 |
+
width: 62px;
|
99 |
+
background-position: top;
|
100 |
+
position: absolute;
|
101 |
+
}
|
102 |
+
.colorpicker_field span {
|
103 |
+
position: absolute;
|
104 |
+
width: 12px;
|
105 |
+
height: 22px;
|
106 |
+
overflow: hidden;
|
107 |
+
top: 0;
|
108 |
+
right: 0;
|
109 |
+
cursor: n-resize;
|
110 |
+
}
|
111 |
+
.colorpicker_rgb_r {
|
112 |
+
background-image: url(../images/colorpicker/colorpicker_rgb_r.png);
|
113 |
+
top: 52px;
|
114 |
+
left: 212px;
|
115 |
+
}
|
116 |
+
.colorpicker_rgb_g {
|
117 |
+
background-image: url(../images/colorpicker/colorpicker_rgb_g.png);
|
118 |
+
top: 82px;
|
119 |
+
left: 212px;
|
120 |
+
}
|
121 |
+
.colorpicker_rgb_b {
|
122 |
+
background-image: url(../images/colorpicker/colorpicker_rgb_b.png);
|
123 |
+
top: 112px;
|
124 |
+
left: 212px;
|
125 |
+
}
|
126 |
+
.colorpicker_hsb_h {
|
127 |
+
background-image: url(../images/colorpicker/colorpicker_hsb_h.png);
|
128 |
+
top: 52px;
|
129 |
+
left: 282px;
|
130 |
+
}
|
131 |
+
.colorpicker_hsb_s {
|
132 |
+
background-image: url(../images/colorpicker/colorpicker_hsb_s.png);
|
133 |
+
top: 82px;
|
134 |
+
left: 282px;
|
135 |
+
}
|
136 |
+
.colorpicker_hsb_b {
|
137 |
+
background-image: url(../images/colorpicker/colorpicker_hsb_b.png);
|
138 |
+
top: 112px;
|
139 |
+
left: 282px;
|
140 |
+
}
|
141 |
+
.colorpicker_submit {
|
142 |
+
position: absolute;
|
143 |
+
width: 22px;
|
144 |
+
height: 22px;
|
145 |
+
background: url(../images/colorpicker/colorpicker_submit.png) top;
|
146 |
+
left: 322px;
|
147 |
+
top: 142px;
|
148 |
+
overflow: hidden;
|
149 |
+
}
|
150 |
+
.colorpicker_focus {
|
151 |
+
background-position: center;
|
152 |
+
}
|
153 |
+
.colorpicker_hex.colorpicker_focus {
|
154 |
+
background-position: bottom;
|
155 |
+
}
|
156 |
+
.colorpicker_submit.colorpicker_focus {
|
157 |
+
background-position: bottom;
|
158 |
+
}
|
159 |
+
.colorpicker_slider {
|
160 |
+
background-position: bottom;
|
161 |
+
}
|
162 |
+
|
163 |
+
.colorSelector {
|
164 |
+
position: relative;
|
165 |
+
width: 27px;
|
166 |
+
height: 27px;
|
167 |
+
background: url(../images/colorpicker/select.png);
|
168 |
+
float:left;
|
169 |
+
}
|
170 |
+
.colorSelector div {
|
171 |
+
position: absolute;
|
172 |
+
top: 4px;
|
173 |
+
left: 3px;
|
174 |
+
width: 21px;
|
175 |
+
height: 19px;
|
176 |
+
background: url(../images/colorpicker/select.png) center;
|
177 |
+
}
|
images/colorpicker/blank.gif
ADDED
Binary file
|
images/colorpicker/colorpicker_background.png
ADDED
Binary file
|
images/colorpicker/colorpicker_hex.png
ADDED
Binary file
|
images/colorpicker/colorpicker_hsb_b.png
ADDED
Binary file
|
images/colorpicker/colorpicker_hsb_h.png
ADDED
Binary file
|
images/colorpicker/colorpicker_hsb_s.png
ADDED
Binary file
|
images/colorpicker/colorpicker_indic.gif
ADDED
Binary file
|
images/colorpicker/colorpicker_overlay.png
ADDED
Binary file
|
images/colorpicker/colorpicker_rgb_b.png
ADDED
Binary file
|
images/colorpicker/colorpicker_rgb_g.png
ADDED
Binary file
|
images/colorpicker/colorpicker_rgb_r.png
ADDED
Binary file
|
images/colorpicker/colorpicker_select.gif
ADDED
Binary file
|
images/colorpicker/colorpicker_submit.png
ADDED
Binary file
|
images/colorpicker/select.png
ADDED
Binary file
|
images/ico-delete.png
ADDED
Binary file
|
js/colorpicker.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)
|
js/of-medialibrary-uploader.js
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*-----------------------------------------------------------------------------------*/
|
2 |
+
/* WooFramework Media Library-driven AJAX File Uploader Module
|
3 |
+
/* JavaScript Functions (2010-11-05)
|
4 |
+
/*
|
5 |
+
/* The code below is designed to work as a part of the WooFramework Media Library-driven
|
6 |
+
/* AJAX File Uploader Module. It is included only on screens where this module is used.
|
7 |
+
/*
|
8 |
+
/* Used with (very) slight modifications for Options Framework.
|
9 |
+
/*-----------------------------------------------------------------------------------*/
|
10 |
+
|
11 |
+
(function ($) {
|
12 |
+
|
13 |
+
optionsframeworkMLU = {
|
14 |
+
|
15 |
+
/*-----------------------------------------------------------------------------------*/
|
16 |
+
/* Remove file when the "remove" button is clicked.
|
17 |
+
/*-----------------------------------------------------------------------------------*/
|
18 |
+
|
19 |
+
removeFile: function () {
|
20 |
+
|
21 |
+
$('.mlu_remove').live('click', function(event) {
|
22 |
+
$(this).hide();
|
23 |
+
$(this).parents().parents().children('.upload').attr('value', '');
|
24 |
+
$(this).parents('.screenshot').slideUp();
|
25 |
+
$(this).parents('.screenshot').siblings('.of-background-properties').hide(); //remove background properties
|
26 |
+
return false;
|
27 |
+
});
|
28 |
+
|
29 |
+
// Hide the delete button on the first row
|
30 |
+
$('a.delete-inline', "#option-1").hide();
|
31 |
+
|
32 |
+
}, // End removeFile
|
33 |
+
|
34 |
+
/*-----------------------------------------------------------------------------------*/
|
35 |
+
/* Replace the default file upload field with a customised version.
|
36 |
+
/*-----------------------------------------------------------------------------------*/
|
37 |
+
|
38 |
+
recreateFileField: function () {
|
39 |
+
|
40 |
+
$('input.file').each(function(){
|
41 |
+
var uploadbutton = '<input class="upload_file_button" type="button" value="Upload" />';
|
42 |
+
$(this).wrap('<div class="file_wrap" />');
|
43 |
+
$(this).addClass('file').css('opacity', 0); //set to invisible
|
44 |
+
$(this).parent().append($('<div class="fake_file" />').append($('<input type="text" class="upload" />').attr('id',$(this).attr('id')+'_file')).val( $(this).val() ).append(uploadbutton));
|
45 |
+
|
46 |
+
$(this).bind('change', function() {
|
47 |
+
$('#'+$(this).attr('id')+'_file').val($(this).val());
|
48 |
+
});
|
49 |
+
$(this).bind('mouseout', function() {
|
50 |
+
$('#'+$(this).attr('id')+'_file').val($(this).val());
|
51 |
+
});
|
52 |
+
});
|
53 |
+
|
54 |
+
}, // End recreateFileField
|
55 |
+
|
56 |
+
/*-----------------------------------------------------------------------------------*/
|
57 |
+
/* Use a custom function when working with the Media Uploads popup.
|
58 |
+
/* Requires jQuery, Media Upload and Thickbox JavaScripts.
|
59 |
+
/*-----------------------------------------------------------------------------------*/
|
60 |
+
|
61 |
+
mediaUpload: function () {
|
62 |
+
|
63 |
+
jQuery.noConflict();
|
64 |
+
|
65 |
+
$( 'input.upload_button' ).removeAttr('style');
|
66 |
+
|
67 |
+
var formfield,
|
68 |
+
formID,
|
69 |
+
btnContent = true;
|
70 |
+
// On Click
|
71 |
+
$('input.upload_button').live("click", function () {
|
72 |
+
formfield = $(this).prev('input').attr('id');
|
73 |
+
formID = $(this).attr('rel');
|
74 |
+
|
75 |
+
// Display a custom title for each Thickbox popup.
|
76 |
+
var woo_title = '';
|
77 |
+
|
78 |
+
if ( $(this).parents('.section').find('.heading') ) { woo_title = $(this).parents('.section').find('.heading').text(); } // End IF Statement
|
79 |
+
|
80 |
+
tb_show( woo_title, 'media-upload.php?post_id='+formID+'&TB_iframe=1' );
|
81 |
+
return false;
|
82 |
+
});
|
83 |
+
|
84 |
+
window.original_send_to_editor = window.send_to_editor;
|
85 |
+
window.send_to_editor = function(html) {
|
86 |
+
|
87 |
+
if (formfield) {
|
88 |
+
|
89 |
+
// itemurl = $(html).attr('href'); // Use the URL to the main image.
|
90 |
+
|
91 |
+
if ( $(html).html(html).find('img').length > 0 ) {
|
92 |
+
|
93 |
+
itemurl = $(html).html(html).find('img').attr('src'); // Use the URL to the size selected.
|
94 |
+
|
95 |
+
} else {
|
96 |
+
|
97 |
+
// It's not an image. Get the URL to the file instead.
|
98 |
+
|
99 |
+
var htmlBits = html.split("'"); // jQuery seems to strip out XHTML when assigning the string to an object. Use alternate method.
|
100 |
+
|
101 |
+
itemurl = htmlBits[1]; // Use the URL to the file.
|
102 |
+
|
103 |
+
var itemtitle = htmlBits[2];
|
104 |
+
|
105 |
+
itemtitle = itemtitle.replace( '>', '' );
|
106 |
+
itemtitle = itemtitle.replace( '</a>', '' );
|
107 |
+
|
108 |
+
} // End IF Statement
|
109 |
+
|
110 |
+
var image = /(^.*\.jpg|jpeg|png|gif|ico*)/gi;
|
111 |
+
var document = /(^.*\.pdf|doc|docx|ppt|pptx|odt*)/gi;
|
112 |
+
var audio = /(^.*\.mp3|m4a|ogg|wav*)/gi;
|
113 |
+
var video = /(^.*\.mp4|m4v|mov|wmv|avi|mpg|ogv|3gp|3g2*)/gi;
|
114 |
+
|
115 |
+
if (itemurl.match(image)) {
|
116 |
+
btnContent = '<img src="'+itemurl+'" alt="" /><a href="#" class="mlu_remove button">Remove Image</a>';
|
117 |
+
} else {
|
118 |
+
|
119 |
+
// No output preview if it's not an image.
|
120 |
+
// btnContent = '';
|
121 |
+
// Standard generic output if it's not an image.
|
122 |
+
|
123 |
+
html = '<a href="'+itemurl+'" target="_blank" rel="external">View File</a>';
|
124 |
+
btnContent = '<div class="no_image"><span class="file_link">'+html+'</span><a href="#" class="mlu_remove button">Remove</a></div>';
|
125 |
+
}
|
126 |
+
|
127 |
+
$('#' + formfield).val(itemurl);
|
128 |
+
// $('#' + formfield).next().next('div').slideDown().html(btnContent);
|
129 |
+
$('#' + formfield).siblings('.screenshot').slideDown().html(btnContent);
|
130 |
+
$('#' + formfield).siblings('.of-background-properties').show(); //show background properties
|
131 |
+
tb_remove();
|
132 |
+
|
133 |
+
} else {
|
134 |
+
window.original_send_to_editor(html);
|
135 |
+
}
|
136 |
+
|
137 |
+
// Clear the formfield value so the other media library popups can work as they are meant to. - 2010-11-11.
|
138 |
+
formfield = '';
|
139 |
+
}
|
140 |
+
|
141 |
+
} // End mediaUpload
|
142 |
+
|
143 |
+
}; // End optionsframeworkMLU Object // Don't remove this, or the sky will fall on your head.
|
144 |
+
|
145 |
+
/*-----------------------------------------------------------------------------------*/
|
146 |
+
/* Execute the above methods in the optionsframeworkMLU object.
|
147 |
+
/*-----------------------------------------------------------------------------------*/
|
148 |
+
|
149 |
+
$(document).ready(function () {
|
150 |
+
|
151 |
+
optionsframeworkMLU.removeFile();
|
152 |
+
optionsframeworkMLU.recreateFileField();
|
153 |
+
optionsframeworkMLU.mediaUpload();
|
154 |
+
|
155 |
+
});
|
156 |
+
|
157 |
+
})(jQuery);
|
js/options-custom.js
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Prints out the inline javascript needed for the colorpicker and choosing
|
3 |
+
* the tabs in the panel.
|
4 |
+
*/
|
5 |
+
|
6 |
+
jQuery(document).ready(function($) {
|
7 |
+
|
8 |
+
// Fade out the save message
|
9 |
+
$('#message').delay(1000).fadeOut(1000);
|
10 |
+
|
11 |
+
// Color Picker
|
12 |
+
$('.colorSelector').each(function(){
|
13 |
+
var Othis = this; //cache a copy of the this variable for use inside nested function
|
14 |
+
var initialColor = $(Othis).next('input').attr('value');
|
15 |
+
$(this).ColorPicker({
|
16 |
+
color: initialColor,
|
17 |
+
onShow: function (colpkr) {
|
18 |
+
$(colpkr).fadeIn(500);
|
19 |
+
return false;
|
20 |
+
},
|
21 |
+
onHide: function (colpkr) {
|
22 |
+
$(colpkr).fadeOut(500);
|
23 |
+
return false;
|
24 |
+
},
|
25 |
+
onChange: function (hsb, hex, rgb) {
|
26 |
+
$(Othis).children('div').css('backgroundColor', '#' + hex);
|
27 |
+
$(Othis).next('input').attr('value','#' + hex);
|
28 |
+
}
|
29 |
+
});
|
30 |
+
}); //end color picker
|
31 |
+
|
32 |
+
// Switches option sections
|
33 |
+
$('.group').hide();
|
34 |
+
$('.group:first').fadeIn();
|
35 |
+
$('.group .collapsed').each(function(){
|
36 |
+
$(this).find('input:checked').parent().parent().parent().nextAll().each(
|
37 |
+
function(){
|
38 |
+
if ($(this).hasClass('last')) {
|
39 |
+
$(this).removeClass('hidden');
|
40 |
+
return false;
|
41 |
+
}
|
42 |
+
$(this).filter('.hidden').removeClass('hidden');
|
43 |
+
});
|
44 |
+
});
|
45 |
+
|
46 |
+
$('.group .collapsed input:checkbox').click(unhideHidden);
|
47 |
+
|
48 |
+
function unhideHidden(){
|
49 |
+
if ($(this).attr('checked')) {
|
50 |
+
$(this).parent().parent().parent().nextAll().removeClass('hidden');
|
51 |
+
}
|
52 |
+
else {
|
53 |
+
$(this).parent().parent().parent().nextAll().each(
|
54 |
+
function(){
|
55 |
+
if ($(this).filter('.last').length) {
|
56 |
+
$(this).addClass('hidden');
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
$(this).addClass('hidden');
|
60 |
+
});
|
61 |
+
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Image Options
|
66 |
+
$('.of-radio-img-img').click(function(){
|
67 |
+
$(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
|
68 |
+
$(this).addClass('of-radio-img-selected');
|
69 |
+
});
|
70 |
+
|
71 |
+
$('.of-radio-img-label').hide();
|
72 |
+
$('.of-radio-img-img').show();
|
73 |
+
$('.of-radio-img-radio').hide();
|
74 |
+
$('#of-nav li:first').addClass('current');
|
75 |
+
$('#of-nav li a').click(function(evt) {
|
76 |
+
$('#of-nav li').removeClass('current');
|
77 |
+
$(this).parent().addClass('current');
|
78 |
+
var clicked_group = $(this).attr('href');
|
79 |
+
$('.group').hide();
|
80 |
+
$(clicked_group).fadeIn();
|
81 |
+
evt.preventDefault();
|
82 |
+
});
|
83 |
+
});
|
options-framework.php
ADDED
@@ -0,0 +1,481 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Options Framework
|
4 |
+
Plugin URI: http://www.wptheming.com
|
5 |
+
Description: A framework for building theme options.
|
6 |
+
Version: 0.3
|
7 |
+
Author: Devin Price
|
8 |
+
Author URI: http://www.wptheming.com
|
9 |
+
License: GPLv2
|
10 |
+
*/
|
11 |
+
|
12 |
+
/*
|
13 |
+
This program is free software; you can redistribute it and/or
|
14 |
+
modify it under the terms of the GNU General Public License
|
15 |
+
as published by the Free Software Foundation; either version 2
|
16 |
+
of the License, or (at your option) any later version.
|
17 |
+
|
18 |
+
This program is distributed in the hope that it will be useful,
|
19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
GNU General Public License for more details.
|
22 |
+
|
23 |
+
You should have received a copy of the GNU General Public License
|
24 |
+
along with this program; if not, write to the Free Software
|
25 |
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
+
*/
|
27 |
+
|
28 |
+
/* Basic plugin definitions */
|
29 |
+
|
30 |
+
define('OPTIONS_FRAMEWORK_VERSION', '0.3');
|
31 |
+
define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
|
32 |
+
|
33 |
+
/* Make sure we don't expose any info if called directly */
|
34 |
+
|
35 |
+
if ( !function_exists( 'add_action' ) ) {
|
36 |
+
echo "Hi there! I'm just a little plugin, don't mind me.";
|
37 |
+
exit;
|
38 |
+
}
|
39 |
+
|
40 |
+
/* If the user can't edit theme options, no use running this plugin */
|
41 |
+
|
42 |
+
add_action('init', 'optionsframework_rolescheck' );
|
43 |
+
|
44 |
+
function optionsframework_rolescheck () {
|
45 |
+
if ( current_user_can('edit_theme_options') ) {
|
46 |
+
// If the user can edit theme options, let the fun begin!
|
47 |
+
add_action('admin_menu', 'optionsframework_add_page');
|
48 |
+
add_action('admin_init', 'optionsframework_init' );
|
49 |
+
add_action( 'admin_init', 'optionsframework_mlu_init' );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/* Register plugin activation hooks */
|
54 |
+
|
55 |
+
register_activation_hook(__FILE__,'optionsframework_activation_hook');
|
56 |
+
|
57 |
+
function optionsframework_activation_hook() {
|
58 |
+
register_uninstall_hook( __FILE__, 'optionsframework_delete_options' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/* When uninstalled, deletes options */
|
62 |
+
|
63 |
+
register_uninstall_hook( __FILE__, 'optionsframework_delete_options' );
|
64 |
+
|
65 |
+
function optionsframework_delete_options() {
|
66 |
+
|
67 |
+
$optionsframework_settings = get_option('optionsframework');
|
68 |
+
|
69 |
+
// Each theme saves its data in a seperate option, which all gets deleted
|
70 |
+
$knownoptions = $optionsframework_settings['knownoptions'];
|
71 |
+
if ($knownoptions) {
|
72 |
+
foreach ($knownoptions as $key) {
|
73 |
+
delete_option($key);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
delete_option('optionsframework');
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Creates the settings in the database by looping through the array
|
81 |
+
* we supplied in options.php. This is a neat way to do it since
|
82 |
+
* we won't have to save settings for headers, descriptions, or arguments-
|
83 |
+
* and it makes it a little easier to change and set up in my opinion.
|
84 |
+
*
|
85 |
+
* Read more about the Settings API in the WordPress codex:
|
86 |
+
* http://codex.wordpress.org/Settings_API
|
87 |
+
*
|
88 |
+
*/
|
89 |
+
|
90 |
+
function optionsframework_init() {
|
91 |
+
|
92 |
+
// Include the required files
|
93 |
+
require_once dirname( __FILE__ ) . '/options-interface.php';
|
94 |
+
require_once dirname( __FILE__ ) . '/options-medialibrary-uploader.php';
|
95 |
+
|
96 |
+
// Loads the options array from the theme
|
97 |
+
if ( $optionsfile = locate_template( array('options.php') ) ) {
|
98 |
+
require_once($optionsfile);
|
99 |
+
}
|
100 |
+
else if (file_exists( dirname( __FILE__ ) . '/options.php' ) ) {
|
101 |
+
require_once dirname( __FILE__ ) . '/options.php';
|
102 |
+
}
|
103 |
+
|
104 |
+
$optionsframework_settings = get_option('optionsframework');
|
105 |
+
|
106 |
+
// Updates the unique option id in the database if it has changed
|
107 |
+
optionsframework_option_name();
|
108 |
+
|
109 |
+
// Gets the unique id, returning a default if it isn't defined
|
110 |
+
$option_name = $optionsframework_settings['id'];
|
111 |
+
|
112 |
+
// Set the option defaults in case they have changed
|
113 |
+
optionsframework_setdefaults();
|
114 |
+
|
115 |
+
// Registers the settings fields and callback
|
116 |
+
register_setting('optionsframework', $option_name, 'optionsframework_validate' );
|
117 |
+
}
|
118 |
+
|
119 |
+
/*
|
120 |
+
* Adds default options to the database if they aren't already present.
|
121 |
+
* May update this later to load only on plugin activation, or theme
|
122 |
+
* activation since most people won't be editing the options.php
|
123 |
+
* on a regular basis.
|
124 |
+
*
|
125 |
+
* http://codex.wordpress.org/Function_Reference/add_option
|
126 |
+
*
|
127 |
+
*/
|
128 |
+
|
129 |
+
function optionsframework_setdefaults() {
|
130 |
+
|
131 |
+
$optionsframework_settings = get_option('optionsframework');
|
132 |
+
|
133 |
+
// Gets the unique option id
|
134 |
+
$option_name = $optionsframework_settings['id'];
|
135 |
+
|
136 |
+
/*
|
137 |
+
* Each theme will hopefully have a unique id, and all of its options saved
|
138 |
+
* as a separate option set. We need to track all of these option sets so
|
139 |
+
* it can be easily deleted if someone wishes to remove the plugin and
|
140 |
+
* its associated data. No need to clutter the database.
|
141 |
+
*
|
142 |
+
*/
|
143 |
+
|
144 |
+
if ( isset($optionsframework_settings['knownoptions']) ) {
|
145 |
+
$knownoptions = $optionsframework_settings['knownoptions'];
|
146 |
+
if ( !in_array($option_name, $knownoptions) ) {
|
147 |
+
array_push( $knownoptions, $option_name );
|
148 |
+
$optionsframework_settings['knownoptions'] = $knownoptions;
|
149 |
+
update_option('optionsframework', $optionsframework_settings);
|
150 |
+
}
|
151 |
+
} else {
|
152 |
+
$newoptionname = array($option_name);
|
153 |
+
$optionsframework_settings['knownoptions'] = $newoptionname;
|
154 |
+
update_option('optionsframework', $optionsframework_settings);
|
155 |
+
}
|
156 |
+
|
157 |
+
// Gets the default options data from the array in options.php
|
158 |
+
$options = optionsframework_options();
|
159 |
+
|
160 |
+
// If the options haven't been added to the database yet, they are added now
|
161 |
+
foreach ($options as $option) {
|
162 |
+
|
163 |
+
if ( ($option['type'] != 'heading') && ($option['type'] != 'info') ) {
|
164 |
+
$option_id = preg_replace("/\W/", "", strtolower($option['id']) );
|
165 |
+
|
166 |
+
// wp_filter_post_kses for strings
|
167 |
+
if (isset($option['std' ]) ) {
|
168 |
+
if ( !is_array($option['std' ]) ) {
|
169 |
+
$value = wp_filter_post_kses($option['std']);
|
170 |
+
} else {
|
171 |
+
foreach ($option['std' ] as $key => $value) {
|
172 |
+
$values[$option_id . '_' . $key] = wp_filter_post_kses($value);
|
173 |
+
$optionarray[$key] = wp_filter_post_kses($value);
|
174 |
+
}
|
175 |
+
$values[$option_id] = $optionarray;
|
176 |
+
}
|
177 |
+
} else {
|
178 |
+
$value = '';
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( isset($values) ) {
|
184 |
+
add_option($option_name, $values);
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/* Add a subpage called "Theme Options" to the appearance menu. */
|
189 |
+
|
190 |
+
if ( !function_exists( 'optionsframework_add_page' ) ) {
|
191 |
+
function optionsframework_add_page() {
|
192 |
+
|
193 |
+
$of_page = add_submenu_page('themes.php', 'Theme Options', 'Theme Options', 'edit_theme_options', 'options-framework','optionsframework_page');
|
194 |
+
|
195 |
+
// Adds actions to hook in the required css and javascript
|
196 |
+
add_action("admin_print_styles-$of_page",'optionsframework_load_styles');
|
197 |
+
add_action("admin_print_scripts-$of_page", 'optionsframework_load_scripts');
|
198 |
+
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
/* Loads the CSS */
|
203 |
+
|
204 |
+
function optionsframework_load_styles() {
|
205 |
+
wp_enqueue_style('admin-style', OPTIONS_FRAMEWORK_URL.'css/admin-style.css');
|
206 |
+
wp_enqueue_style('color-picker', OPTIONS_FRAMEWORK_URL.'css/colorpicker.css');
|
207 |
+
}
|
208 |
+
|
209 |
+
/* Loads the javascript */
|
210 |
+
|
211 |
+
function optionsframework_load_scripts() {
|
212 |
+
|
213 |
+
// Inline scripts from options-interface.php
|
214 |
+
add_action('admin_head', 'of_admin_head');
|
215 |
+
|
216 |
+
// Enqueued scripts
|
217 |
+
wp_enqueue_script('jquery-ui-core');
|
218 |
+
wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL.'js/colorpicker.js', array('jquery'));
|
219 |
+
wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL.'js/options-custom.js', array('jquery'));
|
220 |
+
}
|
221 |
+
|
222 |
+
function of_admin_head() {
|
223 |
+
|
224 |
+
// Hook to add custom scripts
|
225 |
+
do_action( 'optionsframework_custom_scripts' );
|
226 |
+
}
|
227 |
+
|
228 |
+
/*
|
229 |
+
* Builds out the options panel.
|
230 |
+
*
|
231 |
+
* If we were using the Settings API as it was likely intended we would use
|
232 |
+
* do_settings_sections here. But as we don't want the settings wrapped in a table,
|
233 |
+
* we'll call our own custom optionsframework_fields. See options-interface.php
|
234 |
+
* for specifics on how each individual field is generated.
|
235 |
+
*
|
236 |
+
* Nonces are provided using the settings_fields()
|
237 |
+
*
|
238 |
+
*/
|
239 |
+
|
240 |
+
if ( !function_exists( 'optionsframework_page' ) ) {
|
241 |
+
function optionsframework_page() {
|
242 |
+
|
243 |
+
// Get the theme name so we can display it up top
|
244 |
+
$themename = get_theme_data(STYLESHEETPATH . '/style.css');
|
245 |
+
$themename = $themename['Name'];
|
246 |
+
|
247 |
+
$optionsframework_settings = get_option('optionsframework');
|
248 |
+
|
249 |
+
// Display message when options are reset/updated
|
250 |
+
$message = '';
|
251 |
+
|
252 |
+
if ( isset($optionsframework_settings['message']) ) {
|
253 |
+
$message = $optionsframework_settings['message'];
|
254 |
+
}
|
255 |
+
|
256 |
+
if ( $message == 'reset' ) {
|
257 |
+
$message = __( 'Options reset.' );
|
258 |
+
}
|
259 |
+
if ( $message == 'update' ) {
|
260 |
+
$message = __( 'Options updated.' );
|
261 |
+
}
|
262 |
+
|
263 |
+
// Sets the option back to null, so the message doesn't display on refresh
|
264 |
+
$optionsframework_settings['message'] = '';
|
265 |
+
update_option('optionsframework',$optionsframework_settings)
|
266 |
+
?>
|
267 |
+
|
268 |
+
<div class="wrap">
|
269 |
+
<?php screen_icon( 'themes' ); ?>
|
270 |
+
<h2><?php _e('Theme Options'); ?></h2>
|
271 |
+
|
272 |
+
<?php if ($message) { ?>
|
273 |
+
<div id="message" class="updated fade"><p><strong><?php echo $message; ?></strong></p></div>
|
274 |
+
<?php } ?>
|
275 |
+
|
276 |
+
<div id="of_container">
|
277 |
+
<form action="options.php" method="post">
|
278 |
+
<?php settings_fields('optionsframework'); ?>
|
279 |
+
|
280 |
+
<div id="header">
|
281 |
+
<div class="logo">
|
282 |
+
<h2><?php echo $themename; ?></h2>
|
283 |
+
</div>
|
284 |
+
<div class="clear"></div>
|
285 |
+
</div>
|
286 |
+
<div id="main">
|
287 |
+
<?php $return = optionsframework_fields(); ?>
|
288 |
+
<div id="of-nav">
|
289 |
+
<ul>
|
290 |
+
<?php echo $return[1]; ?>
|
291 |
+
</ul>
|
292 |
+
</div>
|
293 |
+
<div id="content">
|
294 |
+
<?php echo $return[0]; /* Settings */ ?>
|
295 |
+
</div>
|
296 |
+
<div class="clear"></div>
|
297 |
+
</div>
|
298 |
+
<div class="of_admin_bar">
|
299 |
+
<input type="submit" class="button-primary" name="update" value="<?php _e( 'Save Options' ); ?>" />
|
300 |
+
</form>
|
301 |
+
|
302 |
+
<input type="submit" class="reset-button button-secondary" name="reset" value="<?php _e('Restore Defaults')?>" onclick="return confirm('Click OK to reset. Any theme settings will be lost!');"/>
|
303 |
+
</div>
|
304 |
+
<div class="clear"></div>
|
305 |
+
</div> <!-- / #container -->
|
306 |
+
</div> <!-- / .wrap -->
|
307 |
+
|
308 |
+
<?php
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
/*
|
313 |
+
* Data sanitization!
|
314 |
+
*
|
315 |
+
* This runs after the submit/reset button has been clicked and
|
316 |
+
* validates the inputs.
|
317 |
+
*
|
318 |
+
*/
|
319 |
+
|
320 |
+
if ( !function_exists( 'optionsframework_validate' ) ) {
|
321 |
+
function optionsframework_validate($input) {
|
322 |
+
|
323 |
+
$optionsframework_settings = get_option('optionsframework');
|
324 |
+
|
325 |
+
// Gets the unique option id
|
326 |
+
$option_name = $optionsframework_settings['id'];
|
327 |
+
|
328 |
+
// If the reset button was clicked
|
329 |
+
if (!empty($_REQUEST['reset'])) {
|
330 |
+
delete_option($option_name);
|
331 |
+
$optionsframework_settings['message'] = 'reset';
|
332 |
+
update_option('optionsframework', $optionsframework_settings);
|
333 |
+
header('Location: themes.php?page=options-framework');
|
334 |
+
exit;
|
335 |
+
}
|
336 |
+
|
337 |
+
else
|
338 |
+
|
339 |
+
{
|
340 |
+
|
341 |
+
if (!empty($_REQUEST['update'])) {
|
342 |
+
|
343 |
+
$clean = array();
|
344 |
+
|
345 |
+
$optionsframework_settings['message'] = 'update';
|
346 |
+
|
347 |
+
update_option('optionsframework', $optionsframework_settings);
|
348 |
+
|
349 |
+
// Get the options array we have defined in options.php
|
350 |
+
$options = optionsframework_options();
|
351 |
+
|
352 |
+
foreach ($options as $option) {
|
353 |
+
|
354 |
+
// Verify that the option has an id
|
355 |
+
if ( isset ($option['id']) ) {
|
356 |
+
|
357 |
+
// Checkbox data isn't sent if it's unchecked, so we'll default it to false
|
358 |
+
if ( ($option['type'] == 'checkbox') && !isset($input[($option['id'])]) ) {
|
359 |
+
$input[($option['id'])] = 'false';
|
360 |
+
}
|
361 |
+
|
362 |
+
// Verify that there's a value in the $input
|
363 |
+
if (isset ($input[($option['id'])]) ) {
|
364 |
+
|
365 |
+
switch ( $option['type'] ) {
|
366 |
+
|
367 |
+
// If it's a checkbox, make sure it's either true or false
|
368 |
+
case ($option['type'] == 'checkbox'):
|
369 |
+
if ( ($input[($option['id'])]) == 'true' )
|
370 |
+
$clean[($option['id'])] = 'true';
|
371 |
+
else {
|
372 |
+
$clean[($option['id'])] = 'false';
|
373 |
+
}
|
374 |
+
break;
|
375 |
+
|
376 |
+
// If it's a multicheck
|
377 |
+
case ($option['type'] == 'multicheck'):
|
378 |
+
$i = 0;
|
379 |
+
foreach ($option['options'] as $key ) {
|
380 |
+
// Make sure the key is lowercase and without spaces
|
381 |
+
$key = ereg_replace("[^A-Za-z0-9]", "", strtolower($key));
|
382 |
+
// Check that the option isn't null
|
383 |
+
if (!empty($input[($option['id']. '_' . $key)])) {
|
384 |
+
// If it's not null, make sure it's true, add it to an array
|
385 |
+
$checkboxarray[$key] = 'true';
|
386 |
+
}
|
387 |
+
else {
|
388 |
+
$checkboxarray[$key] = 'false';
|
389 |
+
}
|
390 |
+
}
|
391 |
+
// Take all the items that were checked, and set them as the main option
|
392 |
+
if (!empty($checkboxarray)) {
|
393 |
+
$clean[($option['id'])] = $checkboxarray;
|
394 |
+
}
|
395 |
+
break;
|
396 |
+
|
397 |
+
// If it's a typography option
|
398 |
+
case ($option['type'] == 'typography') :
|
399 |
+
$typography_id = $option['id'];
|
400 |
+
$clean[$typography_id] = array(
|
401 |
+
'size' => $input[$typography_id .'_size'],
|
402 |
+
'face' => $input[$typography_id .'_face'],
|
403 |
+
'style' => $input[$typography_id .'_style'],
|
404 |
+
'color' => $input[$typography_id .'_color']);
|
405 |
+
break;
|
406 |
+
|
407 |
+
// If it's a background option
|
408 |
+
case ($option['type'] == 'background') :
|
409 |
+
$background_id = $option['id'];
|
410 |
+
if ( empty($input[$background_id .'_color']) ) {
|
411 |
+
$clean[$background_id .'_color'] = '';
|
412 |
+
}
|
413 |
+
if ( empty($input[$background_id .'_image']) ) {
|
414 |
+
$clean[$background_id .'_image'] = '';
|
415 |
+
}
|
416 |
+
$clean[$background_id] = array(
|
417 |
+
'color' => $input[$background_id .'_color'],
|
418 |
+
'image' => $input[$background_id .'_image'],
|
419 |
+
'repeat' => $input[$background_id .'_repeat'],
|
420 |
+
'position' => $input[$background_id .'_position'],
|
421 |
+
'attachment' => $input[$background_id .'_attachment']);
|
422 |
+
break;
|
423 |
+
|
424 |
+
// If it's a select make sure it's in the array we supplied
|
425 |
+
case ($option['type'] == 'select') :
|
426 |
+
if ( array_key_exists( $input[($option['id'])], $option['options'] ) ) {
|
427 |
+
$clean[($option['id'])] = $input[($option['id'])];
|
428 |
+
}
|
429 |
+
break;
|
430 |
+
|
431 |
+
// For the remaining options, strip any tags that aren't allowed in posts
|
432 |
+
default:
|
433 |
+
// Cleans html characters
|
434 |
+
$input[($option['id'])] = sanitize_text_field($input[($option['id'])]);
|
435 |
+
// http://codex.wordpress.org/Function_Reference/wp_filter_post_kses
|
436 |
+
$clean[($option['id'])] = wp_filter_post_kses( $input[($option['id'])] );
|
437 |
+
}
|
438 |
+
|
439 |
+
} // end switch
|
440 |
+
|
441 |
+
} // end isset $input
|
442 |
+
|
443 |
+
} // end isset $id
|
444 |
+
|
445 |
+
} // end foreach
|
446 |
+
|
447 |
+
if ( isset($clean) ) {
|
448 |
+
return $clean; // Return validated input
|
449 |
+
}
|
450 |
+
|
451 |
+
} // end $_REQUEST['update']
|
452 |
+
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
|
457 |
+
/*
|
458 |
+
* Helper function to return the theme option value. If no value has been saved, it returns $default.
|
459 |
+
* Needed because options are saved as serialized strings.
|
460 |
+
*
|
461 |
+
*/
|
462 |
+
|
463 |
+
if ( !function_exists( 'of_get_option' ) ) {
|
464 |
+
function of_get_option($name, $default = 'false') {
|
465 |
+
|
466 |
+
$optionsframework_settings = get_option('optionsframework');
|
467 |
+
|
468 |
+
// Gets the unique option id
|
469 |
+
$option_name = $optionsframework_settings['id'];
|
470 |
+
|
471 |
+
if ( get_option($option_name) ) {
|
472 |
+
$options = get_option($option_name);
|
473 |
+
}
|
474 |
+
|
475 |
+
if ( !empty($options[$name]) ) {
|
476 |
+
return $options[$name];
|
477 |
+
} else {
|
478 |
+
return $default;
|
479 |
+
}
|
480 |
+
}
|
481 |
+
}
|
options-interface.php
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Generates the options fields that are used in the form.
|
5 |
+
*/
|
6 |
+
|
7 |
+
function optionsframework_fields() {
|
8 |
+
|
9 |
+
$optionsframework_settings = get_option('optionsframework');
|
10 |
+
|
11 |
+
// Gets the unique option id
|
12 |
+
if (isset($optionsframework_settings['id'])) {
|
13 |
+
$option_name = $optionsframework_settings['id'];
|
14 |
+
}
|
15 |
+
else {
|
16 |
+
$option_name = 'optionsframework';
|
17 |
+
};
|
18 |
+
|
19 |
+
$settings = get_option($option_name);
|
20 |
+
$options = optionsframework_options();
|
21 |
+
|
22 |
+
$counter = 0;
|
23 |
+
$menu = '';
|
24 |
+
$output = '';
|
25 |
+
foreach ($options as $value) {
|
26 |
+
|
27 |
+
$counter++;
|
28 |
+
$val = '';
|
29 |
+
$select_value = '';
|
30 |
+
|
31 |
+
// Wrap all options
|
32 |
+
if ( ($value['type'] != "heading") && ($value['type'] != "info") ) {
|
33 |
+
$class = ''; if(isset( $value['class'] )) { $class = $value['class']; }
|
34 |
+
$output .= '<div id="section-' . $value['id'] .'" class="section section-'.$value['type'].' '. $class .'">'."\n";
|
35 |
+
$output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n";
|
36 |
+
$output .= '<div class="option">'."\n" . '<div class="controls">'."\n";
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
// Set default value to $val
|
41 |
+
if ( isset($value['std']) ) {
|
42 |
+
$val = $value['std'];
|
43 |
+
}
|
44 |
+
|
45 |
+
// If the option is already saved, ovveride $val
|
46 |
+
if ( ($value['type'] != 'heading') && ($value['type'] != 'info')) {
|
47 |
+
if ( isset($settings[($value['id'])]) ) {
|
48 |
+
$val = $settings[($value['id'])];
|
49 |
+
// Striping slashes of non-array options
|
50 |
+
if (!is_array($val)) {
|
51 |
+
$val = stripslashes($val);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
switch ( $value['type'] ) {
|
57 |
+
|
58 |
+
// Basic text input
|
59 |
+
case 'text':
|
60 |
+
$output .= '<input id="'. $value['id'] .'" class="of-input" name="'.$option_name.'['.$value['id'].']" type="'. $value['type'] .'" value="'. $val .'" />';
|
61 |
+
break;
|
62 |
+
|
63 |
+
// Textarea
|
64 |
+
case 'textarea':
|
65 |
+
$cols = '8';
|
66 |
+
$ta_value = '';
|
67 |
+
|
68 |
+
if(isset($value['options'])){
|
69 |
+
$ta_options = $value['options'];
|
70 |
+
if(isset($ta_options['cols'])){
|
71 |
+
$cols = $ta_options['cols'];
|
72 |
+
} else { $cols = '8'; }
|
73 |
+
}
|
74 |
+
|
75 |
+
$val = stripslashes( $val );
|
76 |
+
|
77 |
+
$output .= '<textarea id="'. $value['id'] .'" class="of-input" name="'.$option_name.'['.$value['id'].']" cols="'. $cols .'" rows="8">'.$val.'</textarea>';
|
78 |
+
break;
|
79 |
+
|
80 |
+
// Select Box
|
81 |
+
case ($value['type'] == 'select'):
|
82 |
+
$output .= '<select class="of-input" name="'.$option_name.'['.$value['id'].']" id="'. $value['id'] .'">';
|
83 |
+
|
84 |
+
foreach ($value['options'] as $key => $option ) {
|
85 |
+
$selected = '';
|
86 |
+
if( $val != '' ) {
|
87 |
+
if ( $val == $key) { $selected = ' selected="selected"';}
|
88 |
+
}
|
89 |
+
$output .= '<option'. $selected .' value="' . $key . '">';
|
90 |
+
$output .= $option;
|
91 |
+
$output .= '</option>';
|
92 |
+
}
|
93 |
+
$output .= '</select>';
|
94 |
+
break;
|
95 |
+
|
96 |
+
|
97 |
+
// Radio Box
|
98 |
+
case "radio":
|
99 |
+
foreach ($value['options'] as $key => $option) {
|
100 |
+
$checked = '';
|
101 |
+
if($val != '') {
|
102 |
+
if ( $val == $key) { $checked = ' checked'; }
|
103 |
+
}
|
104 |
+
$output .= '<input class="of-input of-radio" type="radio" name="'.$option_name.'['.$value['id'].']" value="'. $key .'" '. $checked .' />' . $option .'<br />';
|
105 |
+
}
|
106 |
+
break;
|
107 |
+
|
108 |
+
// Checkbox
|
109 |
+
case "checkbox":
|
110 |
+
|
111 |
+
$checked = '';
|
112 |
+
|
113 |
+
if ( $val == 'true') {
|
114 |
+
$checked = 'checked="checked"';
|
115 |
+
}
|
116 |
+
|
117 |
+
$output .= '<input id="'. $value['id'] .'" class="checkbox of-input" type="checkbox" name="'.$option_name.'['.$value['id'].']" value="true" '. $checked .' />';
|
118 |
+
break;
|
119 |
+
|
120 |
+
// Multicheck
|
121 |
+
case "multicheck":
|
122 |
+
$output .= '<input id="'. $value['id'] .'" type="hidden" name="'.$option_name.'['.$value['id'].']" />';
|
123 |
+
foreach ($value['options'] as $option) {
|
124 |
+
$checkbox_name = $option;
|
125 |
+
$option = ereg_replace("[^A-Za-z0-9]", "", strtolower($option));
|
126 |
+
$checkbox_id = $option_name.'['.$value['id'].'_'. $option .']';
|
127 |
+
$checked = '';
|
128 |
+
|
129 |
+
if ( isset($settings[$option]) ) {
|
130 |
+
$saved_std = $settings[$option];
|
131 |
+
if ($saved_std == 'true') {
|
132 |
+
$checked = 'checked="checked"';
|
133 |
+
}
|
134 |
+
}
|
135 |
+
else {
|
136 |
+
if ( isset($val[$option]) ) {
|
137 |
+
if ( $val[$option] == 'true') {
|
138 |
+
$checked = 'checked="checked"';
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
$output .= '<input id="'. $checkbox_id .'" class="checkbox of-input" type="checkbox" name="'. $checkbox_id .'" value="true" '. $checked .' /><label for="'. $option .'">'. $checkbox_name .'</label><br />';
|
143 |
+
}
|
144 |
+
break;
|
145 |
+
|
146 |
+
// Color picker
|
147 |
+
case "color":
|
148 |
+
$output .= '<div id="' . $value['id'] . '_picker" class="colorSelector"><div style="background-color:'.$val.'"></div></div>';
|
149 |
+
$output .= '<input class="of-color" name="'.$option_name.'['.$value['id'].']" id="'. $value['id'] .'" type="text" value="'. $val .'" />';
|
150 |
+
break;
|
151 |
+
|
152 |
+
// Uploader
|
153 |
+
case "upload":
|
154 |
+
$output .= optionsframework_medialibrary_uploader( $value['id'], $val, null ); // New AJAX Uploader using Media Library
|
155 |
+
break;
|
156 |
+
|
157 |
+
// Typography
|
158 |
+
case 'typography':
|
159 |
+
|
160 |
+
// Set main option
|
161 |
+
$output .= '<input id="'. $value['id'] .'" type="hidden" name="'.$option_name.'['.$value['id'].']" />';
|
162 |
+
$typography_stored = $val;
|
163 |
+
|
164 |
+
// Font Size
|
165 |
+
$output .= '<select class="of-typography of-typography-size" name="'.$option_name.'['.$value['id'].'_size]" id="'. $value['id'].'_size">';
|
166 |
+
for ($i = 9; $i < 71; $i++) {
|
167 |
+
$size = $i.'px';
|
168 |
+
if ($typography_stored['size'] == $size) { $selected = ' selected="selected"'; }
|
169 |
+
$output .= '<option value="'. $i .'px" ' . selected($typography_stored['size'], $size, false) . '>'. $i .'px</option>';
|
170 |
+
}
|
171 |
+
$output .= '</select>';
|
172 |
+
|
173 |
+
// Font Face
|
174 |
+
$output .= '<select class="of-typography of-typography-face" name="'.$option_name.'['.$value['id'].'_face]" id="'. $value['id'].'_face">';
|
175 |
+
$faces = array('arial'=>'Arial',
|
176 |
+
'verdana'=>'Verdana, Geneva',
|
177 |
+
'trebuchet'=>'Trebuchet',
|
178 |
+
'georgia' =>'Georgia',
|
179 |
+
'times'=>'Times New Roman',
|
180 |
+
'tahoma'=>'Tahoma, Geneva',
|
181 |
+
'palatino'=>'Palatino',
|
182 |
+
'helvetica'=>'Helvetica*' );
|
183 |
+
|
184 |
+
foreach ($faces as $i=>$face) {
|
185 |
+
$output .= '<option value="'. $i .'" ' . selected($typography_stored['face'], $i, false) . '>'. $face .'</option>';
|
186 |
+
}
|
187 |
+
$output .= '</select>';
|
188 |
+
|
189 |
+
// Font Weight
|
190 |
+
$output .= '<select class="of-typography of-typography-style" name="'.$option_name.'['.$value['id'].'_style]" id="'. $value['id'].'_style">';
|
191 |
+
$styles = array('normal'=>'Normal',
|
192 |
+
'italic'=>'Italic',
|
193 |
+
'bold'=>'Bold',
|
194 |
+
'bold italic'=>'Bold Italic');
|
195 |
+
|
196 |
+
foreach ($styles as $i=>$style) {
|
197 |
+
$output .= '<option value="'. $i .'" ' . selected($typography_stored['style'], $i, false) . '>'. $style .'</option>';
|
198 |
+
}
|
199 |
+
$output .= '</select>';
|
200 |
+
|
201 |
+
// Font Color
|
202 |
+
$output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color:'.$typography_stored['color'].'"></div></div>';
|
203 |
+
$output .= '<input class="of-color of-typography of-typography-color" name="'.$option_name.'['.$value['id'].'_color]" id="'. $value['id'] .'_color" type="text" value="'. $typography_stored['color'] .'" />';
|
204 |
+
|
205 |
+
break;
|
206 |
+
|
207 |
+
// Background
|
208 |
+
case 'background':
|
209 |
+
|
210 |
+
//Set main option
|
211 |
+
$output .= '<input id="'. $value['id'] .'" type="hidden" name="'.$option_name.'['.$value['id'].']" />';
|
212 |
+
|
213 |
+
$background_stored = $val;
|
214 |
+
|
215 |
+
// Background Color
|
216 |
+
if (!isset($background_stored['color'])) {
|
217 |
+
$background_stored['color'] = '';
|
218 |
+
}
|
219 |
+
|
220 |
+
$output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color:'.$background_stored['color'].'"></div></div>';
|
221 |
+
$output .= '<input class="of-color of-background of-background-color" name="'.$option_name.'['.$value['id'].'_color]" id="'. $value['id'] .'_color" type="text" value="'. $background_stored['color'] .'" />';
|
222 |
+
|
223 |
+
|
224 |
+
// Background Image - New AJAX Uploader using Media Library
|
225 |
+
if (!isset($background_stored['image'])) {
|
226 |
+
$background_stored['image'] = '';
|
227 |
+
}
|
228 |
+
|
229 |
+
$output .= optionsframework_medialibrary_uploader( $value['id'] . '_image', $background_stored['image'], null );
|
230 |
+
if ($background_stored['image']=='') {$hide = ' hide ';} else { $hide=''; }
|
231 |
+
$output .= '<div class="of-background-properties' . $hide . '">';
|
232 |
+
|
233 |
+
// Background Repeat
|
234 |
+
$output .= '<select class="of-background of-background-repeat" name="'.$option_name.'['.$value['id'].'_repeat]" id="'. $value['id'].'_repeat">';
|
235 |
+
$repeats = array("no-repeat"=>"No Repeat","repeat-x"=>"Repeat Horizontally","repeat-y"=>"Repeat Vertically","repeat"=>"Repeat All");
|
236 |
+
|
237 |
+
foreach ($repeats as $i=>$repeat) {
|
238 |
+
$output .= '<option value="'. $i .'" ' . selected($background_stored['repeat'], $i, false) . '>'. $repeat .'</option>';
|
239 |
+
}
|
240 |
+
$output .= '</select>';
|
241 |
+
|
242 |
+
// Background Position
|
243 |
+
$output .= '<select class="of-background of-background-position" name="'.$option_name.'['.$value['id'].'_position]" id="'. $value['id'].'_position">';
|
244 |
+
$positions = array("top left"=>"Top Left","top center"=>"Top Center","top right"=>"Top Right","center left"=>"Middle Left","center center"=>"Middle Center","center right"=>"Middle Right","bottom left"=>"Bottom Left","bottom center"=>"Bottom Center","bottom right"=>"Bottom Right");
|
245 |
+
|
246 |
+
foreach ($positions as $i=>$position) {
|
247 |
+
$output .= '<option value="'. $i .'" ' . selected($background_stored['position'], $i, false) . '>'. $position .'</option>';
|
248 |
+
}
|
249 |
+
$output .= '</select>';
|
250 |
+
|
251 |
+
// Background Attachment
|
252 |
+
$output .= '<select class="of-background of-background-attachment" name="'.$option_name.'['.$value['id'].'_attachment]" id="'. $value['id'].'_attachment">';
|
253 |
+
$attachments = array("scroll"=>"Scroll Normally","fixed"=>"Fixed in Place");
|
254 |
+
foreach ($attachments as $i=>$attachment) {
|
255 |
+
$output .= '<option value="'. $i .'" ' . selected($background_stored['attachment'], $i, false) . '>'. $attachment .'</option>';
|
256 |
+
}
|
257 |
+
$output .= '</select>';
|
258 |
+
$output .= '</div>';
|
259 |
+
|
260 |
+
break;
|
261 |
+
|
262 |
+
// Image Selectors
|
263 |
+
case "images":
|
264 |
+
$i = 0;
|
265 |
+
|
266 |
+
foreach ($value['options'] as $key => $option) {
|
267 |
+
$i++;
|
268 |
+
$checked = '';
|
269 |
+
$selected = '';
|
270 |
+
if ($val != '') {
|
271 |
+
if ( $val == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; }
|
272 |
+
}
|
273 |
+
|
274 |
+
$output .= '<span>';
|
275 |
+
$output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="'.$key.'" name="'.$option_name.'['.$value['id'].']" '.$checked.' />';
|
276 |
+
$output .= '<div class="of-radio-img-label">'. $key .'</div>';
|
277 |
+
$output .= '<img src="'.$option.'" alt="" class="of-radio-img-img '. $selected .'" onClick="document.getElementById(\'of-radio-img-'. $value['id'] . $i.'\').checked = true;" />';
|
278 |
+
$output .= '</span>';
|
279 |
+
}
|
280 |
+
break;
|
281 |
+
|
282 |
+
// Info
|
283 |
+
case "info":
|
284 |
+
$class = ''; if(isset( $value['class'] )) { $class = $value['class']; }
|
285 |
+
$output .= '<div class="section section-'.$value['type'].' '. $class .'">'."\n";
|
286 |
+
if ( isset($value['name']) ) { $output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n"; }
|
287 |
+
if ( $value['desc'] ) { $output .= '<p>'. $value['desc'] .'</p>'."\n"; }
|
288 |
+
$output .= '<div class="clear"></div></div>'."\n";
|
289 |
+
break;
|
290 |
+
|
291 |
+
// Heading for Navigation
|
292 |
+
case "heading":
|
293 |
+
if($counter >= 2){
|
294 |
+
$output .= '</div>'."\n";
|
295 |
+
}
|
296 |
+
$jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']) );
|
297 |
+
$jquery_click_hook = "of-option-" . $jquery_click_hook;
|
298 |
+
$menu .= '<li><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'">'. $value['name'] .'</a></li>';
|
299 |
+
$output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n";
|
300 |
+
break;
|
301 |
+
}
|
302 |
+
|
303 |
+
if ( ($value['type'] != "heading") && ($value['type'] != "info") ) {
|
304 |
+
if ( $value['type'] != "checkbox" )
|
305 |
+
{
|
306 |
+
$output .= '<br/>';
|
307 |
+
}
|
308 |
+
if(!isset($value['desc'])){ $explain_value = ''; } else{ $explain_value = $value['desc']; }
|
309 |
+
$output .= '</div><div class="explain">'. $explain_value .'</div>'."\n";
|
310 |
+
$output .= '<div class="clear"> </div></div></div>'."\n";
|
311 |
+
}
|
312 |
+
}
|
313 |
+
$output .= '</div>';
|
314 |
+
return array($output,$menu);
|
315 |
+
}
|
options-medialibrary-uploader.php
ADDED
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WooThemes Media Library-driven AJAX File Uploader Module (2010-11-05)
|
5 |
+
*
|
6 |
+
* Slightly modified for use in the Options Framework.
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( is_admin() ) {
|
10 |
+
|
11 |
+
// Load additional css and js for image uploads on the Options Framework page
|
12 |
+
$of_page= 'appearance_page_options-framework';
|
13 |
+
add_action( "admin_print_styles-$of_page", 'optionsframework_mlu_css', 0 );
|
14 |
+
add_action( "admin_print_scripts-$of_page", 'optionsframework_mlu_js', 0 );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Sets up a custom post type to attach image to. This allows us to have
|
19 |
+
* individual galleries for different uploaders.
|
20 |
+
*/
|
21 |
+
|
22 |
+
if ( ! function_exists( 'optionsframework_mlu_init' ) ) {
|
23 |
+
function optionsframework_mlu_init () {
|
24 |
+
register_post_type( 'optionsframework', array(
|
25 |
+
'labels' => array(
|
26 |
+
'name' => __( 'Options Framework Internal Container' ),
|
27 |
+
),
|
28 |
+
'public' => true,
|
29 |
+
'show_ui' => false,
|
30 |
+
'capability_type' => 'post',
|
31 |
+
'hierarchical' => false,
|
32 |
+
'rewrite' => false,
|
33 |
+
'supports' => array( 'title', 'editor' ),
|
34 |
+
'query_var' => false,
|
35 |
+
'can_export' => true,
|
36 |
+
'show_in_nav_menus' => false
|
37 |
+
) );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Adds the Thickbox CSS file and specific loading and button images to the header
|
43 |
+
* on the pages where this function is called.
|
44 |
+
*/
|
45 |
+
|
46 |
+
if ( ! function_exists( 'optionsframework_mlu_css' ) ) {
|
47 |
+
|
48 |
+
function optionsframework_mlu_css () {
|
49 |
+
|
50 |
+
$_html = '';
|
51 |
+
$_html .= '<link rel="stylesheet" href="' . get_option('siteurl') . '/' . WPINC . '/js/thickbox/thickbox.css" type="text/css" media="screen" />' . "\n";
|
52 |
+
$_html .= '<script type="text/javascript">
|
53 |
+
var tb_pathToImage = "' . get_option('siteurl') . '/' . WPINC . '/js/thickbox/loadingAnimation.gif";
|
54 |
+
var tb_closeImage = "' . get_option('siteurl') . '/' . WPINC . '/js/thickbox/tb-close.png";
|
55 |
+
</script>' . "\n";
|
56 |
+
|
57 |
+
echo $_html;
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Registers and enqueues (loads) the necessary JavaScript file for working with the
|
65 |
+
* Media Library-driven AJAX File Uploader Module.
|
66 |
+
*/
|
67 |
+
|
68 |
+
if ( ! function_exists( 'optionsframework_mlu_js' ) ) {
|
69 |
+
|
70 |
+
function optionsframework_mlu_js () {
|
71 |
+
|
72 |
+
// Registers custom scripts for the Media Library AJAX uploader.
|
73 |
+
wp_register_script( 'of-medialibrary-uploader', OPTIONS_FRAMEWORK_URL .'js/of-medialibrary-uploader.js', array( 'jquery', 'thickbox' ) );
|
74 |
+
wp_enqueue_script( 'of-medialibrary-uploader' );
|
75 |
+
wp_enqueue_script( 'media-upload' );
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Media Uploader Using the WordPress Media Library.
|
82 |
+
*
|
83 |
+
* Parameters:
|
84 |
+
* - string $_id - A token to identify this field (the name).
|
85 |
+
* - string $_value - The value of the field, if present.
|
86 |
+
* - string $_mode - The display mode of the field.
|
87 |
+
* - string $_desc - An optional description of the field.
|
88 |
+
* - int $_postid - An optional post id (used in the meta boxes).
|
89 |
+
*
|
90 |
+
* Dependencies:
|
91 |
+
* - optionsframework_mlu_get_silentpost()
|
92 |
+
*/
|
93 |
+
|
94 |
+
if ( ! function_exists( 'optionsframework_medialibrary_uploader' ) ) {
|
95 |
+
|
96 |
+
function optionsframework_medialibrary_uploader( $_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0 ) {
|
97 |
+
|
98 |
+
$optionsframework_settings = get_option('optionsframework');
|
99 |
+
|
100 |
+
// Gets the unique option id
|
101 |
+
$option_name = $optionsframework_settings['id'];
|
102 |
+
|
103 |
+
$output = '';
|
104 |
+
$id = '';
|
105 |
+
$class = '';
|
106 |
+
$int = '';
|
107 |
+
$value = '';
|
108 |
+
|
109 |
+
$id = strip_tags( strtolower( $_id ) );
|
110 |
+
// Change for each field, using a "silent" post. If no post is present, one will be created.
|
111 |
+
$int = optionsframework_mlu_get_silentpost( $id );
|
112 |
+
|
113 |
+
// If a value is passed and we don't have a stored value, use the value that's passed through.
|
114 |
+
if ( $_value != '' && $value == '' ) {
|
115 |
+
$value = $_value;
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( $value ) { $class = ' has-file'; }
|
119 |
+
$output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$option_name.'['.$id.']" value="' . $value . '" />' . "\n";
|
120 |
+
$output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload' ) . '" rel="' . $int . '" />' . "\n";
|
121 |
+
|
122 |
+
if ( $_desc != '' ) {
|
123 |
+
$output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n";
|
124 |
+
}
|
125 |
+
|
126 |
+
$output .= '<div class="screenshot" id="' . $id . '_image">' . "\n";
|
127 |
+
|
128 |
+
if ( $value != '' ) {
|
129 |
+
$remove = '<a href="javascript:(void);" class="mlu_remove button">Remove</a>';
|
130 |
+
$image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value );
|
131 |
+
if ( $image ) {
|
132 |
+
$output .= '<img src="' . $value . '" alt="" />'.$remove.'';
|
133 |
+
} else {
|
134 |
+
$parts = explode( "/", $value );
|
135 |
+
for( $i = 0; $i < sizeof( $parts ); ++$i ) {
|
136 |
+
$title = $parts[$i];
|
137 |
+
}
|
138 |
+
|
139 |
+
// No output preview if it's not an image.
|
140 |
+
$output .= '';
|
141 |
+
|
142 |
+
// Standard generic output if it's not an image.
|
143 |
+
$title = __( 'View File', 'optionsframework' );
|
144 |
+
$output .= '<div class="no_image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span>' . $remove . '</div>';
|
145 |
+
}
|
146 |
+
}
|
147 |
+
$output .= '</div>' . "\n";
|
148 |
+
return $output;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Uses "silent" posts in the database to store relationships for images.
|
154 |
+
* This also creates the facility to collect galleries of, for example, logo images.
|
155 |
+
*
|
156 |
+
* Return: $_postid.
|
157 |
+
*
|
158 |
+
* If no "silent" post is present, one will be created with the type "optionsframework"
|
159 |
+
* and the post_name of "of-$_token".
|
160 |
+
*
|
161 |
+
* Example Usage:
|
162 |
+
* optionsframework_mlu_get_silentpost ( 'of_logo' );
|
163 |
+
*/
|
164 |
+
|
165 |
+
if ( ! function_exists( 'optionsframework_mlu_get_silentpost' ) ) {
|
166 |
+
|
167 |
+
function optionsframework_mlu_get_silentpost ( $_token ) {
|
168 |
+
|
169 |
+
global $wpdb;
|
170 |
+
$_id = 0;
|
171 |
+
|
172 |
+
// Check if the token is valid against a whitelist.
|
173 |
+
// $_whitelist = array( 'of_logo', 'of_custom_favicon', 'of_ad_top_image' );
|
174 |
+
// Sanitise the token.
|
175 |
+
|
176 |
+
$_token = strtolower( str_replace( ' ', '_', $_token ) );
|
177 |
+
|
178 |
+
// if ( in_array( $_token, $_whitelist ) ) {
|
179 |
+
if ( $_token ) {
|
180 |
+
|
181 |
+
// Tell the function what to look for in a post.
|
182 |
+
|
183 |
+
$_args = array( 'post_type' => 'optionsframework', 'post_name' => 'of-' . $_token, 'post_status' => 'draft', 'comment_status' => 'closed', 'ping_status' => 'closed' );
|
184 |
+
|
185 |
+
// Look in the database for a "silent" post that meets our criteria.
|
186 |
+
$query = 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_parent = 0';
|
187 |
+
foreach ( $_args as $k => $v ) {
|
188 |
+
$query .= ' AND ' . $k . ' = "' . $v . '"';
|
189 |
+
} // End FOREACH Loop
|
190 |
+
|
191 |
+
$query .= ' LIMIT 1';
|
192 |
+
$_posts = $wpdb->get_row( $query );
|
193 |
+
|
194 |
+
// If we've got a post, loop through and get it's ID.
|
195 |
+
if ( count( $_posts ) ) {
|
196 |
+
$_id = $_posts->ID;
|
197 |
+
} else {
|
198 |
+
|
199 |
+
// If no post is present, insert one.
|
200 |
+
// Prepare some additional data to go with the post insertion.
|
201 |
+
$_words = explode( '_', $_token );
|
202 |
+
$_title = join( ' ', $_words );
|
203 |
+
$_title = ucwords( $_title );
|
204 |
+
$_post_data = array( 'post_title' => $_title );
|
205 |
+
$_post_data = array_merge( $_post_data, $_args );
|
206 |
+
$_id = wp_insert_post( $_post_data );
|
207 |
+
}
|
208 |
+
}
|
209 |
+
return $_id;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Trigger code inside the Media Library popup.
|
215 |
+
*/
|
216 |
+
|
217 |
+
if ( ! function_exists( 'optionsframework_mlu_insidepopup' ) ) {
|
218 |
+
|
219 |
+
function optionsframework_mlu_insidepopup () {
|
220 |
+
|
221 |
+
if ( isset( $_REQUEST['is_optionsframework'] ) && $_REQUEST['is_optionsframework'] == 'yes' ) {
|
222 |
+
|
223 |
+
add_action( 'admin_head', 'optionsframework_mlu_js_popup' );
|
224 |
+
add_filter( 'media_upload_tabs', 'optionsframework_mlu_modify_tabs' );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( ! function_exists( 'optionsframework_mlu_js_popup' ) ) {
|
230 |
+
|
231 |
+
function optionsframework_mlu_js_popup () {
|
232 |
+
|
233 |
+
$_of_title = $_REQUEST['of_title'];
|
234 |
+
if ( ! $_of_title ) { $_of_title = 'file'; } // End IF Statement
|
235 |
+
?>
|
236 |
+
<script type="text/javascript">
|
237 |
+
<!--
|
238 |
+
jQuery(function($) {
|
239 |
+
|
240 |
+
jQuery.noConflict();
|
241 |
+
|
242 |
+
// Change the title of each tab to use the custom title text instead of "Media File".
|
243 |
+
$( 'h3.media-title' ).each ( function () {
|
244 |
+
var current_title = $( this ).html();
|
245 |
+
var new_title = current_title.replace( 'media file', '<?php echo $_of_title; ?>' );
|
246 |
+
$( this ).html( new_title );
|
247 |
+
|
248 |
+
} );
|
249 |
+
|
250 |
+
// Change the text of the "Insert into Post" buttons to read "Use this File".
|
251 |
+
$( '.savesend input.button[value*="Insert into Post"], .media-item #go_button' ).attr( 'value', 'Use this File' );
|
252 |
+
|
253 |
+
// Hide the "Insert Gallery" settings box on the "Gallery" tab.
|
254 |
+
$( 'div#gallery-settings' ).hide();
|
255 |
+
|
256 |
+
// Preserve the "is_optionsframework" parameter on the "delete" confirmation button.
|
257 |
+
$( '.savesend a.del-link' ).click ( function () {
|
258 |
+
|
259 |
+
var continueButton = $( this ).next( '.del-attachment' ).children( 'a.button[id*="del"]' );
|
260 |
+
var continueHref = continueButton.attr( 'href' );
|
261 |
+
continueHref = continueHref + '&is_optionsframework=yes';
|
262 |
+
continueButton.attr( 'href', continueHref );
|
263 |
+
|
264 |
+
} );
|
265 |
+
|
266 |
+
});
|
267 |
+
-->
|
268 |
+
</script>
|
269 |
+
<?php
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Triggered inside the Media Library popup to modify the title of the "Gallery" tab.
|
275 |
+
*/
|
276 |
+
|
277 |
+
if ( ! function_exists( 'optionsframework_mlu_modify_tabs' ) ) {
|
278 |
+
|
279 |
+
function optionsframework_mlu_modify_tabs ( $tabs ) {
|
280 |
+
$tabs['gallery'] = str_replace( __( 'Gallery', 'optionsframework' ), __( 'Previously Uploaded', 'optionsframework' ), $tabs['gallery'] );
|
281 |
+
return $tabs;
|
282 |
+
}
|
283 |
+
}
|
options.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This file should only load if options.php isn't present in the theme.
|
5 |
+
*
|
6 |
+
*/
|
7 |
+
|
8 |
+
/* Defaults the settings to 'optionsframework' */
|
9 |
+
|
10 |
+
function optionsframework_option_name() {
|
11 |
+
|
12 |
+
$optionsframework_settings = get_option('optionsframework');
|
13 |
+
$optionsframework_settings['id'] = 'optionsframework';
|
14 |
+
update_option('optionsframework', $optionsframework_settings);
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Displays a message that options aren't available in the current theme
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
|
22 |
+
function optionsframework_options() {
|
23 |
+
|
24 |
+
$options[] = array( "name" => "Theme Options",
|
25 |
+
"type" => "heading");
|
26 |
+
|
27 |
+
$options[] = array( "name" => "No Options Are Loaded",
|
28 |
+
"desc" => "Your theme doesn't appear to support the Options Framework yet.",
|
29 |
+
"type" => "info");
|
30 |
+
|
31 |
+
$options[] = array( "desc" => "If this is a mistake, make sure that the file options.php is in your theme folder and that you have the correct theme activated.",
|
32 |
+
"type" => "info");
|
33 |
+
|
34 |
+
$options[] = array( "name" => "How to Set Up Options",
|
35 |
+
"desc" => "If you are trying to set up new options for a theme, visit the <a href=\"http://wptheming.com/options-framework-plugin\" />Options Framework plugin page</a>.",
|
36 |
+
"type" => "info");
|
37 |
+
|
38 |
+
return $options;
|
39 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Options Framework ===
|
2 |
+
Contributors: Devin Price
|
3 |
+
Tags: options, theme options
|
4 |
+
Donate link:
|
5 |
+
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X238BDP4QGTV2
|
6 |
+
Requires at least: 3.0
|
7 |
+
Tested up to: 3.1
|
8 |
+
Stable tag: 0.3
|
9 |
+
License: GPLv2
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
The Options Framework Plugin makes it easy to include an options panel in any WordPress theme. It was built so that theme developers can concentrate on making the actual theme rather than spending a ton of time on creating an options panel from scratch. It's free to use in both commercial and personal projects, just like WordPress itself.
|
14 |
+
|
15 |
+
Please visit [http://wptheming.com/options-framework-plugin](http://wptheming.com/options-framework-plugin) for a full description of how to define and use the theme options.
|
16 |
+
|
17 |
+
The code is heavily based on the [WooFramework](http://www.woothemes.com/) and their option styles.
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
If your theme already has options enabled, they will show up under the apperance menu.
|
22 |
+
|
23 |
+
If your theme doesn't have options, you can define them to options.php of your theme and they will instantly show up. For more on how to do this, visit [http://wptheming.com/options-framework-plugin](http://wptheming.com/options-framework-plugin).
|
24 |
+
|
25 |
+
== Frequently Asked Questions ==
|
26 |
+
|
27 |
+
= How do I build options for my own theme? =
|
28 |
+
|
29 |
+
Download the development version from GitHub [https://github.com/devinsays/options-framework-plugin](https://github.com/devinsays/options-framework-plugin) and copy the "options-check" folder into your themes directory.
|
30 |
+
|
31 |
+
The "Options Check" theme is a blueprint for how to work with options. It includes an example of every option available in the panel and sample output in the theme.
|
32 |
+
|
33 |
+
You can also watch the video screencast I have at [http://wptheming.com/options-framework-plugin](http://wptheming.com/options-framework-plugin).
|
34 |
+
|
35 |
+
= What options are available to use? =
|
36 |
+
|
37 |
+
text
|
38 |
+
textarea
|
39 |
+
checkbox
|
40 |
+
select
|
41 |
+
radio
|
42 |
+
upload (an image uploader)
|
43 |
+
images (use images instead of radio buttons)
|
44 |
+
background (a set of options to define a background)
|
45 |
+
multicheck
|
46 |
+
color (a jquery color picker)
|
47 |
+
typography (a set of options to define typography)
|
48 |
+
|
49 |
+
== Screenshots ==
|
50 |
+
|
51 |
+
1. An example of the "Advanced Options" tag in the "Options Check" theme using this plugin.
|
52 |
+
|
53 |
+
== Changelog ==
|
54 |
+
|
55 |
+
= 0.3 =
|
56 |
+
|
57 |
+
* White listed options for increased security
|
58 |
+
* Fixed errors with checkbox and select boxes
|
59 |
+
* Improved the multicheck option and changed format
|
60 |
+
|
61 |
+
= 0.2 =
|
62 |
+
|
63 |
+
* Uploaded to the WordPress repository
|
64 |
+
|
65 |
+
= 0.1 =
|
66 |
+
|
67 |
+
* Initial release
|
screenshot-1.png
ADDED
Binary file
|