Version Description
Download this release
Release Info
Developer | sagarseth9 |
Plugin | WP Responsive Menu |
Version | 2.0 |
Comparing to | |
See all releases |
Version 2.0
- css/wprmenu.css +296 -0
- fonts/wprmenu.eot +0 -0
- fonts/wprmenu.svg +17 -0
- fonts/wprmenu.ttf +0 -0
- fonts/wprmenu.woff +0 -0
- functions.php +54 -0
- inc/css/wpr_optionsframework.css +287 -0
- inc/images/ico-delete.png +0 -0
- inc/includes/class-options-framework-admin.php +359 -0
- inc/includes/class-options-framework.php +121 -0
- inc/includes/class-options-interface.php +359 -0
- inc/includes/class-options-media-uploader.php +123 -0
- inc/includes/class-options-sanitization.php +385 -0
- inc/js/media-uploader.js +79 -0
- inc/js/options-custom.js +71 -0
- inc/options-framework.php +69 -0
- inc/options.php +207 -0
- index.php +2 -0
- js/jquery.sidr.js +312 -0
- js/jquery.transit.min.js +10 -0
- js/wprmenu.js +1 -0
- readme.txt +73 -0
- screenshot-1.png +0 -0
- wp-responsive-menu.php +191 -0
css/wprmenu.css
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Basic font for the plugin
|
3 |
+
*/
|
4 |
+
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,300,600);
|
5 |
+
/*
|
6 |
+
Icons from icon font - setup
|
7 |
+
*/
|
8 |
+
@font-face {
|
9 |
+
font-family: 'wprmenu';
|
10 |
+
src:url('../fonts/wprmenu.eot');
|
11 |
+
src:url('../fonts/wprmenu.eot?#iefix') format('embedded-opentype'),
|
12 |
+
url('../fonts/wprmenu.woff') format('woff'),
|
13 |
+
url('../fonts/wprmenu.ttf') format('truetype'),
|
14 |
+
url('../fonts/wprmenu.svg#wprmenu') format('svg');
|
15 |
+
font-weight: normal;
|
16 |
+
font-style: normal;
|
17 |
+
}
|
18 |
+
#wprmenu_menu .wprmenu_icon:before, #wprmenu_bar [data-icon]:before {
|
19 |
+
font-family: 'wprmenu';
|
20 |
+
speak: none;
|
21 |
+
font-weight: normal;
|
22 |
+
font-variant: normal;
|
23 |
+
text-transform: none;
|
24 |
+
line-height: 1;
|
25 |
+
-webkit-font-smoothing: antialiased;
|
26 |
+
}
|
27 |
+
#wprmenu_bar,
|
28 |
+
#wprmenu_bar *,
|
29 |
+
#wprmenu_menu,
|
30 |
+
#wprmenu_menu * {
|
31 |
+
/* reset */
|
32 |
+
margin:0;
|
33 |
+
padding:0;
|
34 |
+
-moz-box-sizing: border-box!important;
|
35 |
+
-webkit-box-sizing: border-box!important;
|
36 |
+
box-sizing: border-box!important;
|
37 |
+
font-family: 'Open Sans', sans-serif;
|
38 |
+
list-style:none;
|
39 |
+
text-align:left;
|
40 |
+
font-size:100%;
|
41 |
+
font-weight:normal;
|
42 |
+
}
|
43 |
+
#wprmenu_menu img, #wprmenu_bar img {
|
44 |
+
border:0; border:none;
|
45 |
+
}
|
46 |
+
|
47 |
+
.wprmenu_clear {
|
48 |
+
clear: both !important;
|
49 |
+
display: block !important;
|
50 |
+
height: 1px !important;
|
51 |
+
margin: -1px 0 0 !important;
|
52 |
+
width: 1px !important;
|
53 |
+
}
|
54 |
+
/*
|
55 |
+
The top Bar that shows/hides the menu
|
56 |
+
*/
|
57 |
+
#wprmenu_bar {
|
58 |
+
position:fixed;
|
59 |
+
top:0px;
|
60 |
+
left:0px;
|
61 |
+
background: #0D0D0D;
|
62 |
+
padding:10px 16px;
|
63 |
+
width:100%;
|
64 |
+
display: none;
|
65 |
+
cursor: pointer;
|
66 |
+
z-index: 98;
|
67 |
+
overflow: hidden;
|
68 |
+
height:42px;
|
69 |
+
display: none;
|
70 |
+
}
|
71 |
+
#wprmenu_bar .menu_title {
|
72 |
+
color:#f2f2f2;
|
73 |
+
font-weight: 400;
|
74 |
+
font-size: 20px;
|
75 |
+
line-height: 20px;
|
76 |
+
}
|
77 |
+
#wprmenu_bar .bar_logo {
|
78 |
+
border:0px;
|
79 |
+
border:none;
|
80 |
+
margin:0xp;
|
81 |
+
padding:0px;
|
82 |
+
margin-top: -2px;
|
83 |
+
padding-right: 8px;
|
84 |
+
width:auto;
|
85 |
+
height: 25px;
|
86 |
+
}
|
87 |
+
/* Search Box */
|
88 |
+
.wpr_search {
|
89 |
+
padding: 10px !important;
|
90 |
+
}
|
91 |
+
.wpr_search .wpr-search-field {
|
92 |
+
padding: 5px !important;
|
93 |
+
border: 1px solid #ccc;
|
94 |
+
max-width: 100%;
|
95 |
+
width: 100%;
|
96 |
+
}
|
97 |
+
/* font icon */
|
98 |
+
#wprmenu_bar .wprmenu_icon_menu {
|
99 |
+
color:#f2f2f2;
|
100 |
+
margin-right:5px;
|
101 |
+
}
|
102 |
+
/* html icon */
|
103 |
+
#wprmenu_bar .wprmenu_icon {
|
104 |
+
width: 20px;
|
105 |
+
height: 22px;
|
106 |
+
overflow: hidden;
|
107 |
+
float: left;
|
108 |
+
margin-right: 16px;
|
109 |
+
padding-top: 2px;
|
110 |
+
position: relative;
|
111 |
+
}
|
112 |
+
#wprmenu_bar .wprmenu_icon span {
|
113 |
+
-webkit-transition: all .01s ease-in-out;
|
114 |
+
-moz-transition: all .01s ease-in-out;
|
115 |
+
-o-transition: all .01s ease-in-out;
|
116 |
+
-ms-transition: all .01s ease-in-out;
|
117 |
+
transition: all .01s ease-in-out;
|
118 |
+
display: block;
|
119 |
+
position: absolute;
|
120 |
+
width: 20px;
|
121 |
+
height: 4px;
|
122 |
+
left: 0px;
|
123 |
+
background: #f2f2f2;
|
124 |
+
}
|
125 |
+
#wprmenu_bar .wprmenu_ic_1 {
|
126 |
+
top:0px;
|
127 |
+
}
|
128 |
+
#wprmenu_bar .wprmenu_ic_2 {
|
129 |
+
top:7px;
|
130 |
+
}
|
131 |
+
#wprmenu_bar .wprmenu_ic_3 {
|
132 |
+
top:14px;
|
133 |
+
}
|
134 |
+
#wprmenu_bar.menu_is_opened .wprmenu_ic_1 {
|
135 |
+
top:-10px;
|
136 |
+
}
|
137 |
+
#wprmenu_bar.menu_is_opened .wprmenu_ic_2 {
|
138 |
+
top:9px!important;
|
139 |
+
-webkit-transform: rotate(45deg);
|
140 |
+
-moz-transform: rotate(45deg);
|
141 |
+
-ms-transform: rotate(45deg);
|
142 |
+
-o-transform: rotate(45deg);
|
143 |
+
transform: rotate(45deg);
|
144 |
+
zoom:1;
|
145 |
+
}
|
146 |
+
#wprmenu_bar.menu_is_opened .wprmenu_ic_3 {
|
147 |
+
top:9px!important;
|
148 |
+
-webkit-transform: rotate(-45deg);
|
149 |
+
-moz-transform: rotate(-45deg);
|
150 |
+
-ms-transform: rotate(-45deg);
|
151 |
+
-o-transform: rotate(-45deg);
|
152 |
+
transform: rotate(-45deg);
|
153 |
+
zoom:1;
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
body { position: relative!important; }
|
159 |
+
|
160 |
+
|
161 |
+
|
162 |
+
|
163 |
+
#wprmenu_menu.top {
|
164 |
+
top:0px;
|
165 |
+
left:0px;
|
166 |
+
width:100%;
|
167 |
+
display: none;
|
168 |
+
position: relative;
|
169 |
+
}
|
170 |
+
#wprmenu_menu.left, #wprmenu_menu.right {
|
171 |
+
display: none;
|
172 |
+
position: absolute;
|
173 |
+
position: fixed;
|
174 |
+
top: 0px;
|
175 |
+
height: 100%;
|
176 |
+
z-index: 97;
|
177 |
+
overflow-x: none;
|
178 |
+
overflow-y: auto;
|
179 |
+
background: #2E2E2E;
|
180 |
+
top: 42px;
|
181 |
+
}
|
182 |
+
body.admin-bar #wprmenu_bar {
|
183 |
+
top:32px;
|
184 |
+
}
|
185 |
+
body.admin-bar #wprmenu_menu.left,
|
186 |
+
body.admin-bar #wprmenu_menu.right {
|
187 |
+
top: 74px;
|
188 |
+
}
|
189 |
+
@media only screen and (max-width: 782px) {
|
190 |
+
body.admin-bar #wprmenu_menu.left,
|
191 |
+
body.admin-bar #wprmenu_menu.right {
|
192 |
+
top: 86px;
|
193 |
+
}
|
194 |
+
body.admin-bar #wprmenu_bar {
|
195 |
+
top:46px;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
/*1st level*/
|
199 |
+
#wprmenu_menu ul {
|
200 |
+
margin:0px;
|
201 |
+
padding:0px;
|
202 |
+
display: block;
|
203 |
+
width:100%;
|
204 |
+
position: relative;
|
205 |
+
list-style: none;
|
206 |
+
}
|
207 |
+
#wprmenu_menu ul li {
|
208 |
+
display: block;
|
209 |
+
list-style: none;
|
210 |
+
}
|
211 |
+
|
212 |
+
#wprmenu_menu ul li a, #wprmenu_menu ul li a:hover {
|
213 |
+
border-bottom:1px solid #131212;
|
214 |
+
border-top:1px solid #474747;
|
215 |
+
display: block;
|
216 |
+
color:#D3D3D3;
|
217 |
+
padding: 13px 14px;
|
218 |
+
font-size:14px;
|
219 |
+
margin:0px;
|
220 |
+
text-decoration: none;
|
221 |
+
}
|
222 |
+
|
223 |
+
|
224 |
+
/*********/
|
225 |
+
#wprmenu_menu.wprmenu_levels ul li {
|
226 |
+
display: block;
|
227 |
+
overflow: hidden;
|
228 |
+
border-bottom:1px solid #131212;
|
229 |
+
border-top:1px solid #474747;
|
230 |
+
width:100%;
|
231 |
+
position: relative;
|
232 |
+
}
|
233 |
+
#wprmenu_menu.wprmenu_levels ul li a{
|
234 |
+
float: left;
|
235 |
+
border: none;
|
236 |
+
width: 100%;
|
237 |
+
}
|
238 |
+
#wprmenu_menu.wprmenu_levels a.wprmenu_parent_item {
|
239 |
+
border-left:1px solid #474747;
|
240 |
+
margin-left: 44px;
|
241 |
+
}
|
242 |
+
#wprmenu_menu .wprmenu_icon_par {
|
243 |
+
position: relative;
|
244 |
+
display: block;
|
245 |
+
color: #CFCFCF;
|
246 |
+
width: 46px;
|
247 |
+
padding: 13px 14px 10px 14px;
|
248 |
+
cursor: pointer;
|
249 |
+
float: left;
|
250 |
+
position: absolute;
|
251 |
+
top:0px;
|
252 |
+
left:0px;
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
|
257 |
+
#wprmenu_menu .wprmenu_no_border_bottom {
|
258 |
+
border-bottom: none!important;
|
259 |
+
}
|
260 |
+
|
261 |
+
#wprmenu_menu.wprmenu_levels ul li ul { border-top:1px solid #131212;}
|
262 |
+
|
263 |
+
#wprmenu_menu.wprmenu_levels ul li ul li { padding-left:44px;}
|
264 |
+
|
265 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li { padding-left:88px;}
|
266 |
+
|
267 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li { padding-left:132px;}
|
268 |
+
|
269 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li ul li { padding-left:176px;}
|
270 |
+
|
271 |
+
|
272 |
+
#wprmenu_menu.wprmenu_levels ul li ul li.wprmenu_parent_item_li { padding-left:0px;}
|
273 |
+
#wprmenu_menu.wprmenu_levels ul li ul li.wprmenu_parent_item_li .wprmenu_icon_par { margin-left:44px;}
|
274 |
+
#wprmenu_menu.wprmenu_levels ul li ul li.wprmenu_parent_item_li a.wprmenu_parent_item { margin-left: 88px;}
|
275 |
+
|
276 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li.wprmenu_parent_item_li { padding-left:0px;}
|
277 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li.wprmenu_parent_item_li .wprmenu_icon_par { margin-left:88px;}
|
278 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li.wprmenu_parent_item_li a.wprmenu_parent_item { margin-left: 132px;}
|
279 |
+
|
280 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li.wprmenu_parent_item_li { padding-left:0px;}
|
281 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li.wprmenu_parent_item_li .wprmenu_icon_par { margin-left:132px;}
|
282 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li.wprmenu_parent_item_li a.wprmenu_parent_item { margin-left: 176px;}
|
283 |
+
|
284 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li ul li.wprmenu_parent_item_li { padding-left:0px;}
|
285 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li ul li.wprmenu_parent_item_li .wprmenu_icon_par { margin-left:176px;}
|
286 |
+
#wprmenu_menu.wprmenu_levels ul li ul li ul li ul li ul li.wprmenu_parent_item_li a.wprmenu_parent_item { margin-left: 220px;}
|
287 |
+
/********/
|
288 |
+
|
289 |
+
.icon_default.wprmenu_icon_par:before {
|
290 |
+
content:"t";
|
291 |
+
}
|
292 |
+
|
293 |
+
|
294 |
+
.icon_default.wprmenu_par_opened:before {
|
295 |
+
content:"o";
|
296 |
+
}
|
fonts/wprmenu.eot
ADDED
Binary file
|
fonts/wprmenu.svg
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
+
<metadata>
|
5 |
+
This is a custom SVG font generated by IcoMoon.
|
6 |
+
<iconset grid="16"></iconset>
|
7 |
+
</metadata>
|
8 |
+
<defs>
|
9 |
+
<font id="icomoon" horiz-adv-x="512" >
|
10 |
+
<font-face units-per-em="512" ascent="480" descent="-32" />
|
11 |
+
<missing-glyph horiz-adv-x="512" />
|
12 |
+
<glyph class="hidden" unicode="" d="M0,480L 512 -32L0 -32 z" horiz-adv-x="0" />
|
13 |
+
<glyph unicode="t" d="M 96,416L 416,224L 96,32 z" />
|
14 |
+
<glyph unicode="o" d="M 448,384L 256,64L 64,384 z" />
|
15 |
+
<glyph unicode="m" d="M 32,384L 480,384L 480,288L 32,288zM 32,256L 480,256L 480,160L 32,160zM 32,128L 480,128L 480,32L 32,32z" />
|
16 |
+
<glyph unicode=" " horiz-adv-x="256" />
|
17 |
+
</font></defs></svg>
|
fonts/wprmenu.ttf
ADDED
Binary file
|
fonts/wprmenu.woff
ADDED
Binary file
|
functions.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* Loads the Options Panel
|
5 |
+
*
|
6 |
+
* If you're loading from a child theme use stylesheet_directory
|
7 |
+
* instead of template_directory
|
8 |
+
*/
|
9 |
+
|
10 |
+
define( 'WPR_OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
|
11 |
+
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
|
12 |
+
|
13 |
+
/*
|
14 |
+
* This is an example of how to add custom scripts to the options panel.
|
15 |
+
* This one shows/hides the an option when a checkbox is clicked.
|
16 |
+
*
|
17 |
+
* You can delete it if you not using that option
|
18 |
+
*/
|
19 |
+
add_action( 'optionsframework_custom_scripts', 'optionsframework_custom_scripts' );
|
20 |
+
|
21 |
+
function optionsframework_custom_scripts() { ?>
|
22 |
+
|
23 |
+
<script type="text/javascript">
|
24 |
+
jQuery(document).ready(function() {
|
25 |
+
|
26 |
+
jQuery('#example_showhidden').click(function() {
|
27 |
+
jQuery('#section-example_text_hidden').fadeToggle(400);
|
28 |
+
});
|
29 |
+
|
30 |
+
if (jQuery('#example_showhidden:checked').val() !== undefined) {
|
31 |
+
jQuery('#section-example_text_hidden').show();
|
32 |
+
}
|
33 |
+
|
34 |
+
});
|
35 |
+
</script>
|
36 |
+
|
37 |
+
<?php
|
38 |
+
}
|
39 |
+
|
40 |
+
/*
|
41 |
+
* This is an example of filtering menu parameters
|
42 |
+
*/
|
43 |
+
|
44 |
+
/*
|
45 |
+
function prefix_options_menu_filter( $menu ) {
|
46 |
+
$menu['mode'] = 'menu';
|
47 |
+
$menu['page_title'] = __( 'Hello Options', 'textdomain');
|
48 |
+
$menu['menu_title'] = __( 'Hello Options', 'textdomain');
|
49 |
+
$menu['menu_slug'] = 'hello-options';
|
50 |
+
return $menu;
|
51 |
+
}
|
52 |
+
|
53 |
+
add_filter( 'optionsframework_menu', 'prefix_options_menu_filter' );
|
54 |
+
*/
|
inc/css/wpr_optionsframework.css
ADDED
@@ -0,0 +1,287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Options Framework Admin Styles */
|
2 |
+
|
3 |
+
#wpr_optionsframework {
|
4 |
+
max-width:840px;
|
5 |
+
background:#344A5F;
|
6 |
+
color:#fff;
|
7 |
+
}
|
8 |
+
#wpr_optionsframework h3 {
|
9 |
+
cursor: default;
|
10 |
+
background-color: #14A085;
|
11 |
+
border-bottom: 1px solid #ddd;
|
12 |
+
color:#fff;
|
13 |
+
}
|
14 |
+
#wpr_optionsframework p {
|
15 |
+
margin-bottom:0;
|
16 |
+
padding-bottom:10px;
|
17 |
+
}
|
18 |
+
#wpr_optionsframework .section {
|
19 |
+
padding:10px 10px 0;
|
20 |
+
}
|
21 |
+
#wpr_optionsframework .group {
|
22 |
+
padding-bottom:40px;
|
23 |
+
}
|
24 |
+
#wpr_optionsframework .section .controls {
|
25 |
+
float: left;
|
26 |
+
min-width:350px;
|
27 |
+
width: 54%;
|
28 |
+
padding-right:2%;
|
29 |
+
}
|
30 |
+
#wpr_optionsframework .section .explain {
|
31 |
+
max-width:38%;
|
32 |
+
float: left;
|
33 |
+
font-size: 12px;
|
34 |
+
line-height:16px;
|
35 |
+
color: #ccc;
|
36 |
+
}
|
37 |
+
#wpr_optionsframework .section-checkbox .controls {
|
38 |
+
width: 98%;
|
39 |
+
}
|
40 |
+
#wpr_optionsframework .section-checkbox .explain {
|
41 |
+
max-width:94%;
|
42 |
+
}
|
43 |
+
#wpr_optionsframework .controls input[type=text] {
|
44 |
+
width:100%;
|
45 |
+
}
|
46 |
+
#wpr_optionsframework .controls input[type=text].wp-color-picker {
|
47 |
+
width: 65px;
|
48 |
+
}
|
49 |
+
#wpr_optionsframework .controls select, #wpr_optionsframework .controls textarea {
|
50 |
+
margin-bottom:10px;
|
51 |
+
width:100%;
|
52 |
+
}
|
53 |
+
#wpr_optionsframework .section-radio label, #wpr_optionsframework .section-multicheck label {
|
54 |
+
float:left;
|
55 |
+
max-width:90%;
|
56 |
+
line-height: 16px;
|
57 |
+
margin-bottom: 5px;
|
58 |
+
}
|
59 |
+
#wpr_optionsframework input.checkbox, #wpr_optionsframework input.of-radio {
|
60 |
+
margin: 0 10px 5px 0;
|
61 |
+
float:left;
|
62 |
+
clear:both;
|
63 |
+
}
|
64 |
+
#wpr_optionsframework .section-typography .controls {
|
65 |
+
float:none;
|
66 |
+
width:auto;
|
67 |
+
}
|
68 |
+
#wpr_optionsframework .section-typography .explain {
|
69 |
+
float:none;
|
70 |
+
width:auto;
|
71 |
+
}
|
72 |
+
#wpr_optionsframework .controls .of-typography-size {
|
73 |
+
width:80px;
|
74 |
+
float:left
|
75 |
+
}
|
76 |
+
#wpr_optionsframework .controls .of-typography-unit {
|
77 |
+
width:50px;
|
78 |
+
margin-left:5px;
|
79 |
+
float:left
|
80 |
+
}
|
81 |
+
#wpr_optionsframework .controls .of-typography-face {
|
82 |
+
width:100px;
|
83 |
+
margin-left:5px;
|
84 |
+
float:left
|
85 |
+
}
|
86 |
+
#wpr_optionsframework .controls .of-typography-style {
|
87 |
+
width:80px;
|
88 |
+
margin-left:5px;
|
89 |
+
margin-right:5px;
|
90 |
+
float:left
|
91 |
+
}
|
92 |
+
#wpr_optionsframework .section-typography .wp-picker-container {
|
93 |
+
margin-top:2px;
|
94 |
+
}
|
95 |
+
#wpr_optionsframework .of-background-properties {
|
96 |
+
clear:both;
|
97 |
+
margin-top: 18px;
|
98 |
+
}
|
99 |
+
#wpr_optionsframework .controls .of-background-repeat {
|
100 |
+
width:125px;
|
101 |
+
margin-right:5px;
|
102 |
+
float:left
|
103 |
+
}
|
104 |
+
#wpr_optionsframework .controls .of-background-position {
|
105 |
+
width:125px;
|
106 |
+
margin-right:5px;
|
107 |
+
float:left
|
108 |
+
}
|
109 |
+
#wpr_optionsframework .controls .of-background-attachment {
|
110 |
+
width:125px;
|
111 |
+
margin-right:5px;
|
112 |
+
float:left
|
113 |
+
}
|
114 |
+
#wpr_optionsframework .section-background .wp-picker-container {
|
115 |
+
margin-bottom:10px;
|
116 |
+
}
|
117 |
+
#wpr_optionsframework .controls .of-radio-img-img {
|
118 |
+
border:3px solid #f9f9f9;
|
119 |
+
margin:0 5px 10px 0;
|
120 |
+
display:none;
|
121 |
+
cursor:pointer;
|
122 |
+
float:left;
|
123 |
+
}
|
124 |
+
#wpr_optionsframework .controls .of-radio-img-selected {
|
125 |
+
border:3px solid #ccc
|
126 |
+
}
|
127 |
+
#wpr_optionsframework .controls .of-radio-img-img:hover {
|
128 |
+
opacity:.8;
|
129 |
+
}
|
130 |
+
#wpr_optionsframework .controls .of-border-width {
|
131 |
+
width:80px;
|
132 |
+
float:left
|
133 |
+
}
|
134 |
+
#wpr_optionsframework .controls .of-border-style {
|
135 |
+
width:120px;
|
136 |
+
float:left
|
137 |
+
}
|
138 |
+
#wpr_optionsframework .hide {
|
139 |
+
display:none;
|
140 |
+
}
|
141 |
+
#wpr_optionsframework .of-option-image {
|
142 |
+
max-width:340px;
|
143 |
+
margin:3px 0 18px 0;
|
144 |
+
}
|
145 |
+
#wpr_optionsframework .mini .controls select, #wpr_optionsframework .section .mini .controls {
|
146 |
+
width: 140px;
|
147 |
+
}
|
148 |
+
#wpr_optionsframework .mini .controls input, #wpr_optionsframework .mini .controls {
|
149 |
+
min-width:140px;
|
150 |
+
width: 140px;
|
151 |
+
}
|
152 |
+
#wpr_optionsframework .mini .explain {
|
153 |
+
max-width:74%;
|
154 |
+
}
|
155 |
+
|
156 |
+
/* Editor */
|
157 |
+
|
158 |
+
#wpr_optionsframework .section-editor .explain {
|
159 |
+
max-width: 98%;
|
160 |
+
float:none;
|
161 |
+
margin-bottom:5px;
|
162 |
+
color: #ccc;
|
163 |
+
}
|
164 |
+
|
165 |
+
/* Image Uploader */
|
166 |
+
|
167 |
+
#wpr_optionsframework .controls input.upload {
|
168 |
+
width:80%;
|
169 |
+
}
|
170 |
+
#wpr_optionsframework .screenshot {
|
171 |
+
float:left;
|
172 |
+
margin-left:1px;
|
173 |
+
position:relative;
|
174 |
+
width:344px;
|
175 |
+
margin-top:3px;
|
176 |
+
}
|
177 |
+
#wpr_optionsframework .screenshot img {
|
178 |
+
background:#fafafa;
|
179 |
+
border-color:#ccc #eee #eee #ccc;
|
180 |
+
border-style:solid;
|
181 |
+
border-width:1px;
|
182 |
+
float:left;
|
183 |
+
max-width:334px;
|
184 |
+
padding:4px;
|
185 |
+
margin-bottom:10px;
|
186 |
+
}
|
187 |
+
#wpr_optionsframework .screenshot .remove-image {
|
188 |
+
background:url("../images/ico-delete.png") no-repeat;
|
189 |
+
border:medium none;
|
190 |
+
bottom:4px;
|
191 |
+
display:block;
|
192 |
+
float:left;
|
193 |
+
height:16px;
|
194 |
+
padding:0;
|
195 |
+
position:absolute;
|
196 |
+
left:-4px;
|
197 |
+
text-indent:-9999px;
|
198 |
+
width:16px;
|
199 |
+
}
|
200 |
+
.wpr_optionsframework .button-primary {
|
201 |
+
background: #344A5F;
|
202 |
+
}
|
203 |
+
#wpr_optionsframework .screenshot .no_image .file_link {
|
204 |
+
margin-left: 20px;
|
205 |
+
}
|
206 |
+
#wpr_optionsframework .screenshot .no_image .remove-button {
|
207 |
+
bottom: 0px;
|
208 |
+
}
|
209 |
+
#wpr_optionsframework .reset-button {
|
210 |
+
float:left;
|
211 |
+
cursor:pointer;
|
212 |
+
}
|
213 |
+
|
214 |
+
/* Bottom Section */
|
215 |
+
|
216 |
+
#wpr_optionsframework-submit {
|
217 |
+
padding: 7px 10px;
|
218 |
+
border-top: 1px solid #ddd;
|
219 |
+
background-color: #14A085;
|
220 |
+
}
|
221 |
+
#wpr_optionsframework .button-primary {
|
222 |
+
float:right;
|
223 |
+
background-color: #344A5F;
|
224 |
+
}
|
225 |
+
#wpr_optionsframework .section:after {
|
226 |
+
content: "";
|
227 |
+
display: table;
|
228 |
+
}
|
229 |
+
#wpr_optionsframework .section:after {
|
230 |
+
clear: both;
|
231 |
+
}
|
232 |
+
.icons-search-input{
|
233 |
+
min-width: 100% !important;
|
234 |
+
}
|
235 |
+
#wpr_optionsframework .section#section-social .controls {
|
236 |
+
width: 100%;
|
237 |
+
}
|
238 |
+
#section-social .controls input.social_link {
|
239 |
+
width: 50%;
|
240 |
+
margin-left: 20px;
|
241 |
+
margin-right: 20px;
|
242 |
+
}
|
243 |
+
#wpr_optionsframework-wrap .nav-tab {
|
244 |
+
background: #344A5F;
|
245 |
+
color: #fff;
|
246 |
+
}
|
247 |
+
#wpr_optionsframework-wrap .nav-tab-active {
|
248 |
+
background: #14a085;
|
249 |
+
color: #fff;
|
250 |
+
}
|
251 |
+
.wpr-new-field,.wpr-new-fields {
|
252 |
+
margin: 0px 0px 20px 0px;
|
253 |
+
}
|
254 |
+
.metabox-holder {
|
255 |
+
width: 70%;
|
256 |
+
float: left;
|
257 |
+
}
|
258 |
+
.queries-holder {
|
259 |
+
width: 28%;
|
260 |
+
margin-left: 2%;
|
261 |
+
float: left;
|
262 |
+
padding-top: 1%;
|
263 |
+
font-size: 20px;
|
264 |
+
line-height: 34px;
|
265 |
+
text-align: center;
|
266 |
+
}
|
267 |
+
.wpr_help {
|
268 |
+
background: #14A085;
|
269 |
+
padding: 10px;
|
270 |
+
color: #344A5F;
|
271 |
+
}
|
272 |
+
.wpr_help a {
|
273 |
+
text-decoration: none;
|
274 |
+
color: #fff;
|
275 |
+
}
|
276 |
+
.wpr_pro a {
|
277 |
+
color: #fff;
|
278 |
+
text-decoration: none;
|
279 |
+
border-bottom: 1px dotted #fff;
|
280 |
+
margin-left: 3px;
|
281 |
+
}
|
282 |
+
|
283 |
+
.wpr_pro {
|
284 |
+
background: #000;
|
285 |
+
padding: 10px;
|
286 |
+
color: yellow;
|
287 |
+
}
|
inc/images/ico-delete.png
ADDED
Binary file
|
inc/includes/class-options-framework-admin.php
ADDED
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Options_Framework
|
4 |
+
* @author Devin Price <devin@wptheming.com>
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://wptheming.com
|
7 |
+
* @copyright 2010-2014 WP Theming
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Options_Framework_Admin {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Page hook for the options screen
|
14 |
+
*
|
15 |
+
* @since 1.7.0
|
16 |
+
* @type string
|
17 |
+
*/
|
18 |
+
protected $options_screen = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Hook in the scripts and styles
|
22 |
+
*
|
23 |
+
* @since 1.7.0
|
24 |
+
*/
|
25 |
+
public function init() {
|
26 |
+
|
27 |
+
// Gets options to load
|
28 |
+
$options = & Options_Framework::_wpr_optionsframework_options();
|
29 |
+
|
30 |
+
// Checks if options are available
|
31 |
+
if ( $options ) {
|
32 |
+
|
33 |
+
// Add the options page and menu item.
|
34 |
+
add_action( 'admin_menu', array( $this, 'add_custom_options_page' ) );
|
35 |
+
|
36 |
+
// Add the required scripts and styles
|
37 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
|
38 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
|
39 |
+
|
40 |
+
// Settings need to be registered after admin_init
|
41 |
+
add_action( 'admin_init', array( $this, 'settings_init' ) );
|
42 |
+
|
43 |
+
// Adds options menu to the admin bar
|
44 |
+
add_action( 'wp_before_admin_bar_render', array( $this, 'wpr_optionsframework_admin_bar' ) );
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Registers the settings
|
52 |
+
*
|
53 |
+
* @since 1.7.0
|
54 |
+
*/
|
55 |
+
function settings_init() {
|
56 |
+
|
57 |
+
// Load Options Framework Settings
|
58 |
+
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' );
|
59 |
+
|
60 |
+
// Registers the settings fields and callback
|
61 |
+
register_setting( 'wpr_optionsframework', $wpr_optionsframework_settings['id'], array ( $this, 'validate_options' ) );
|
62 |
+
|
63 |
+
// Displays notice after options save
|
64 |
+
add_action( 'wpr_optionsframework_after_validate', array( $this, 'save_options_notice' ) );
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
/*
|
69 |
+
* Define menu options
|
70 |
+
*
|
71 |
+
* Examples usage:
|
72 |
+
*
|
73 |
+
* add_filter( 'wpr_optionsframework_menu', function( $menu ) {
|
74 |
+
* $menu['page_title'] = 'The Options';
|
75 |
+
* $menu['menu_title'] = 'The Options';
|
76 |
+
* return $menu;
|
77 |
+
* });
|
78 |
+
*
|
79 |
+
* @since 1.7.0
|
80 |
+
*
|
81 |
+
*/
|
82 |
+
static function menu_settings() {
|
83 |
+
|
84 |
+
$menu = array(
|
85 |
+
|
86 |
+
// Modes: submenu, menu
|
87 |
+
'mode' => 'menu',
|
88 |
+
|
89 |
+
// Submenu default settings
|
90 |
+
'page_title' => __( 'Theme Options', 'textdomain'),
|
91 |
+
'menu_title' => __('Theme Options', 'textdomain'),
|
92 |
+
'capability' => 'edit_theme_options',
|
93 |
+
'menu_slug' => 'options-framework',
|
94 |
+
'parent_slug' => 'themes.php',
|
95 |
+
|
96 |
+
// Menu default settings
|
97 |
+
'icon_url' => 'dashicons-menu',
|
98 |
+
'position' => '61'
|
99 |
+
|
100 |
+
);
|
101 |
+
|
102 |
+
return apply_filters( 'wpr_optionsframework_menu', $menu );
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Add a subpage called "Theme Options" to the appearance menu.
|
107 |
+
*
|
108 |
+
* @since 1.7.0
|
109 |
+
*/
|
110 |
+
function add_custom_options_page() {
|
111 |
+
|
112 |
+
$menu = $this->menu_settings();
|
113 |
+
|
114 |
+
switch( $menu['mode'] ) {
|
115 |
+
|
116 |
+
case 'menu':
|
117 |
+
// http://codex.wordpress.org/Function_Reference/add_menu_page
|
118 |
+
$this->options_screen = add_menu_page(
|
119 |
+
$menu['page_title'],
|
120 |
+
$menu['menu_title'],
|
121 |
+
$menu['capability'],
|
122 |
+
$menu['menu_slug'],
|
123 |
+
array( $this, 'options_page' ),
|
124 |
+
$menu['icon_url'],
|
125 |
+
$menu['position']
|
126 |
+
);
|
127 |
+
break;
|
128 |
+
|
129 |
+
default:
|
130 |
+
// http://codex.wordpress.org/Function_Reference/add_submenu_page
|
131 |
+
$this->options_screen = add_submenu_page(
|
132 |
+
$menu['parent_slug'],
|
133 |
+
$menu['page_title'],
|
134 |
+
$menu['menu_title'],
|
135 |
+
$menu['capability'],
|
136 |
+
$menu['menu_slug'],
|
137 |
+
array( $this, 'options_page' ) );
|
138 |
+
break;
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Loads the required stylesheets
|
145 |
+
*
|
146 |
+
* @since 1.7.0
|
147 |
+
*/
|
148 |
+
|
149 |
+
function enqueue_admin_styles( $hook ) {
|
150 |
+
|
151 |
+
if ( $this->options_screen != $hook )
|
152 |
+
return;
|
153 |
+
|
154 |
+
wp_enqueue_style( 'wpr_optionsframework', WPR_OPTIONS_FRAMEWORK_DIRECTORY . 'css/wpr_optionsframework.css', array(), Options_Framework::VERSION );
|
155 |
+
wp_enqueue_style( 'wp-color-picker' );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Loads the required javascript
|
160 |
+
*
|
161 |
+
* @since 1.7.0
|
162 |
+
*/
|
163 |
+
function enqueue_admin_scripts( $hook ) {
|
164 |
+
|
165 |
+
if ( $this->options_screen != $hook )
|
166 |
+
return;
|
167 |
+
|
168 |
+
// Enqueue custom option panel JS
|
169 |
+
wp_enqueue_script( 'options-custom', WPR_OPTIONS_FRAMEWORK_DIRECTORY . 'js/options-custom.js', array( 'jquery','wp-color-picker' ), Options_Framework::VERSION );
|
170 |
+
|
171 |
+
// Inline scripts from options-interface.php
|
172 |
+
add_action( 'admin_head', array( $this, 'wpr_of_admin_head' ) );
|
173 |
+
}
|
174 |
+
|
175 |
+
function wpr_of_admin_head() {
|
176 |
+
// Hook to add custom scripts
|
177 |
+
do_action( 'wpr_optionsframework_custom_scripts' );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Builds out the options panel.
|
182 |
+
*
|
183 |
+
* If we were using the Settings API as it was intended we would use
|
184 |
+
* do_settings_sections here. But as we don't want the settings wrapped in a table,
|
185 |
+
* we'll call our own custom wpr_optionsframework_fields. See options-interface.php
|
186 |
+
* for specifics on how each individual field is generated.
|
187 |
+
*
|
188 |
+
* Nonces are provided using the settings_fields()
|
189 |
+
*
|
190 |
+
* @since 1.7.0
|
191 |
+
*/
|
192 |
+
function options_page() { ?>
|
193 |
+
|
194 |
+
<div id="wpr_optionsframework-wrap" class="wrap">
|
195 |
+
|
196 |
+
<?php $menu = $this->menu_settings(); ?>
|
197 |
+
<h2><?php echo esc_html( $menu['page_title'] ); ?></h2>
|
198 |
+
|
199 |
+
<h2 class="nav-tab-wrapper">
|
200 |
+
<?php echo Options_Framework_Interface::wpr_optionsframework_tabs(); ?>
|
201 |
+
</h2>
|
202 |
+
|
203 |
+
<?php settings_errors( 'options-framework' ); ?>
|
204 |
+
|
205 |
+
<div id="wpr_optionsframework-metabox" class="metabox-holder">
|
206 |
+
<div id="wpr_optionsframework" class="postbox">
|
207 |
+
<form action="options.php" method="post">
|
208 |
+
<?php settings_fields( 'wpr_optionsframework' ); ?>
|
209 |
+
<?php Options_Framework_Interface::wpr_optionsframework_fields(); /* Settings */ ?>
|
210 |
+
<div id="wpr_optionsframework-submit">
|
211 |
+
<input type="submit" class="button-primary" name="update" value="<?php esc_attr_e( 'Save Options', 'textdomain' ); ?>" />
|
212 |
+
<input type="submit" class="reset-button button-secondary" name="reset" value="<?php esc_attr_e( 'Restore Defaults', 'textdomain' ); ?>" onclick="return confirm( '<?php print esc_js( __( 'Click OK to reset. Any theme settings will be lost!', 'textdomain' ) ); ?>' );" />
|
213 |
+
<div class="clear"></div>
|
214 |
+
</div>
|
215 |
+
</form>
|
216 |
+
</div> <!-- / #container -->
|
217 |
+
</div>
|
218 |
+
<?php do_action( 'wpr_optionsframework_after' ); ?>
|
219 |
+
</div> <!-- / .wrap -->
|
220 |
+
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Validate Options.
|
226 |
+
*
|
227 |
+
* This runs after the submit/reset button has been clicked and
|
228 |
+
* validates the inputs.
|
229 |
+
*
|
230 |
+
* @uses $_POST['reset'] to restore default options
|
231 |
+
*/
|
232 |
+
function validate_options( $input ) {
|
233 |
+
|
234 |
+
/*
|
235 |
+
* Restore Defaults.
|
236 |
+
*
|
237 |
+
* In the event that the user clicked the "Restore Defaults"
|
238 |
+
* button, the options defined in the theme's options.php
|
239 |
+
* file will be added to the option for the active theme.
|
240 |
+
*/
|
241 |
+
|
242 |
+
if ( isset( $_POST['reset'] ) ) {
|
243 |
+
add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'textdomain' ), 'updated fade' );
|
244 |
+
return $this->get_default_values();
|
245 |
+
}
|
246 |
+
|
247 |
+
/*
|
248 |
+
* Update Settings
|
249 |
+
*
|
250 |
+
* This used to check for $_POST['update'], but has been updated
|
251 |
+
* to be compatible with the theme customizer introduced in WordPress 3.4
|
252 |
+
*/
|
253 |
+
|
254 |
+
$clean = array();
|
255 |
+
$options = & Options_Framework::_wpr_optionsframework_options();
|
256 |
+
foreach ( $options as $option ) {
|
257 |
+
|
258 |
+
if ( ! isset( $option['id'] ) ) {
|
259 |
+
continue;
|
260 |
+
}
|
261 |
+
|
262 |
+
if ( ! isset( $option['type'] ) ) {
|
263 |
+
continue;
|
264 |
+
}
|
265 |
+
|
266 |
+
$id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) );
|
267 |
+
|
268 |
+
// Set checkbox to false if it wasn't sent in the $_POST
|
269 |
+
if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) {
|
270 |
+
$input[$id] = false;
|
271 |
+
}
|
272 |
+
|
273 |
+
// Set each item in the multicheck to false if it wasn't sent in the $_POST
|
274 |
+
if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) {
|
275 |
+
foreach ( $option['options'] as $key => $value ) {
|
276 |
+
$input[$id][$key] = false;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
// For a value to be submitted to database it must pass through a sanitization filter
|
281 |
+
if ( has_filter( 'wpr_of_sanitize_' . $option['type'] ) ) {
|
282 |
+
$clean[$id] = apply_filters( 'wpr_of_sanitize_' . $option['type'], $input[$id], $option );
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
// Hook to run after validation
|
287 |
+
do_action( 'wpr_optionsframework_after_validate', $clean );
|
288 |
+
|
289 |
+
return $clean;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* Display message when options have been saved
|
294 |
+
*/
|
295 |
+
|
296 |
+
function save_options_notice() {
|
297 |
+
add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'textdomain' ), 'updated fade' );
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Get the default values for all the theme options
|
302 |
+
*
|
303 |
+
* Get an array of all default values as set in
|
304 |
+
* options.php. The 'id','std' and 'type' keys need
|
305 |
+
* to be defined in the configuration array. In the
|
306 |
+
* event that these keys are not present the option
|
307 |
+
* will not be included in this function's output.
|
308 |
+
*
|
309 |
+
* @return array Re-keyed options configuration array.
|
310 |
+
*
|
311 |
+
*/
|
312 |
+
|
313 |
+
function get_default_values() {
|
314 |
+
$output = array();
|
315 |
+
$config = & Options_Framework::_wpr_optionsframework_options();
|
316 |
+
foreach ( (array) $config as $option ) {
|
317 |
+
if ( ! isset( $option['id'] ) ) {
|
318 |
+
continue;
|
319 |
+
}
|
320 |
+
if ( ! isset( $option['std'] ) ) {
|
321 |
+
continue;
|
322 |
+
}
|
323 |
+
if ( ! isset( $option['type'] ) ) {
|
324 |
+
continue;
|
325 |
+
}
|
326 |
+
if ( has_filter( 'wpr_of_sanitize_' . $option['type'] ) ) {
|
327 |
+
$output[$option['id']] = apply_filters( 'wpr_of_sanitize_' . $option['type'], $option['std'], $option );
|
328 |
+
}
|
329 |
+
}
|
330 |
+
return $output;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Add options menu item to admin bar
|
335 |
+
*/
|
336 |
+
|
337 |
+
function wpr_optionsframework_admin_bar() {
|
338 |
+
|
339 |
+
$menu = $this->menu_settings();
|
340 |
+
|
341 |
+
global $wp_admin_bar;
|
342 |
+
|
343 |
+
if ( 'menu' == $menu['mode'] ) {
|
344 |
+
$href = admin_url( 'admin.php?page=' . $menu['menu_slug'] );
|
345 |
+
} else {
|
346 |
+
$href = admin_url( 'themes.php?page=' . $menu['menu_slug'] );
|
347 |
+
}
|
348 |
+
|
349 |
+
$args = array(
|
350 |
+
'parent' => 'appearance',
|
351 |
+
'id' => 'wpr_of_theme_options',
|
352 |
+
'title' => $menu['menu_title'],
|
353 |
+
'href' => $href
|
354 |
+
);
|
355 |
+
|
356 |
+
$wp_admin_bar->add_menu( apply_filters( 'wpr_optionsframework_admin_bar', $args ) );
|
357 |
+
}
|
358 |
+
|
359 |
+
}
|
inc/includes/class-options-framework.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Options_Framework
|
4 |
+
* @author Devin Price <devin@wptheming.com>
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://wptheming.com
|
7 |
+
* @copyright 2010-2014 WP Theming
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Options_Framework {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Plugin version, used for cache-busting of style and script file references.
|
14 |
+
*
|
15 |
+
* @since 1.7.0
|
16 |
+
* @type string
|
17 |
+
*/
|
18 |
+
const VERSION = '1.8.0';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Initialize the plugin.
|
22 |
+
*
|
23 |
+
* @since 1.7.0
|
24 |
+
*/
|
25 |
+
public function init() {
|
26 |
+
|
27 |
+
// Needs to run every time in case theme has been changed
|
28 |
+
add_action( 'admin_init', array( $this, 'set_theme_option' ) );
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Sets option defaults
|
34 |
+
*
|
35 |
+
* @since 1.7.0
|
36 |
+
*/
|
37 |
+
function set_theme_option() {
|
38 |
+
|
39 |
+
// Load settings
|
40 |
+
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' );
|
41 |
+
|
42 |
+
// Updates the unique option id in the database if it has changed
|
43 |
+
if ( function_exists( 'wpr_optionsframework_option_name' ) ) {
|
44 |
+
wpr_optionsframework_option_name();
|
45 |
+
}
|
46 |
+
elseif ( has_action( 'wpr_optionsframework_option_name' ) ) {
|
47 |
+
do_action( 'wpr_optionsframework_option_name' );
|
48 |
+
}
|
49 |
+
// If the developer hasn't explicitly set an option id, we'll use a default
|
50 |
+
else {
|
51 |
+
$default_themename = get_option( 'stylesheet' );
|
52 |
+
$default_themename = preg_replace( "/\W/", "_", strtolower($default_themename ) );
|
53 |
+
$default_themename = 'wpr_optionsframework_' . $default_themename;
|
54 |
+
if ( isset( $wpr_optionsframework_settings['id'] ) ) {
|
55 |
+
if ( $wpr_optionsframework_settings['id'] == $default_themename ) {
|
56 |
+
// All good, using default theme id
|
57 |
+
} else {
|
58 |
+
$wpr_optionsframework_settings['id'] = $default_themename;
|
59 |
+
update_option( 'wpr_optionsframework', $wpr_optionsframework_settings );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
else {
|
63 |
+
$wpr_optionsframework_settings['id'] = $default_themename;
|
64 |
+
update_option( 'wpr_optionsframework', $wpr_optionsframework_settings );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Wrapper for wpr_optionsframework_options()
|
72 |
+
*
|
73 |
+
* Allows for manipulating or setting options via 'wpr_of_options' filter
|
74 |
+
* For example:
|
75 |
+
*
|
76 |
+
* <code>
|
77 |
+
* add_filter( 'wpr_of_options', function( $options ) {
|
78 |
+
* $options[] = array(
|
79 |
+
* 'name' => 'Input Text Mini',
|
80 |
+
* 'desc' => 'A mini text input field.',
|
81 |
+
* 'id' => 'example_text_mini',
|
82 |
+
* 'std' => 'Default',
|
83 |
+
* 'class' => 'mini',
|
84 |
+
* 'type' => 'text'
|
85 |
+
* );
|
86 |
+
*
|
87 |
+
* return $options;
|
88 |
+
* });
|
89 |
+
* </code>
|
90 |
+
*
|
91 |
+
* Also allows for setting options via a return statement in the
|
92 |
+
* options.php file. For example (in options.php):
|
93 |
+
*
|
94 |
+
* <code>
|
95 |
+
* return array(...);
|
96 |
+
* </code>
|
97 |
+
*
|
98 |
+
* @return array (by reference)
|
99 |
+
*/
|
100 |
+
static function &_wpr_optionsframework_options() {
|
101 |
+
static $options = null;
|
102 |
+
|
103 |
+
if ( !$options ) {
|
104 |
+
// Load options from options.php file (if it exists)
|
105 |
+
|
106 |
+
$maybe_options = require_once WPR_OPTIONS_FRAMEWORK_PATH . 'options.php';;
|
107 |
+
if ( is_array( $maybe_options ) ) {
|
108 |
+
$options = $maybe_options;
|
109 |
+
}
|
110 |
+
else if ( function_exists( 'wpr_optionsframework_options' ) ) {
|
111 |
+
$options = wpr_optionsframework_options();
|
112 |
+
}
|
113 |
+
|
114 |
+
// Allow setting/manipulating options via filters
|
115 |
+
$options = apply_filters( 'wpr_of_options', $options );
|
116 |
+
}
|
117 |
+
|
118 |
+
return $options;
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
inc/includes/class-options-interface.php
ADDED
@@ -0,0 +1,359 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Options_Framework
|
4 |
+
* @author Devin Price <devin@wptheming.com>
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://wptheming.com
|
7 |
+
* @copyright 2010-2014 WP Theming
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Options_Framework_Interface {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Generates the tabs that are used in the options menu
|
14 |
+
*/
|
15 |
+
static function wpr_optionsframework_tabs() {
|
16 |
+
$counter = 0;
|
17 |
+
$options = & Options_Framework::_wpr_optionsframework_options();
|
18 |
+
$menu = '';
|
19 |
+
|
20 |
+
foreach ( $options as $value ) {
|
21 |
+
// Heading for Navigation
|
22 |
+
if ( $value['type'] == "heading" ) {
|
23 |
+
$counter++;
|
24 |
+
$class = '';
|
25 |
+
$class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
|
26 |
+
$class = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower($class) ) . '-tab';
|
27 |
+
$menu .= '<a id="options-group-'. $counter . '-tab" class="nav-tab ' . $class .'" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#options-group-'. $counter ) . '">' . esc_html( $value['name'] ) . '</a>';
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return $menu;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Generates the options fields that are used in the form.
|
36 |
+
*/
|
37 |
+
static function wpr_optionsframework_fields() {
|
38 |
+
|
39 |
+
global $allowedtags;
|
40 |
+
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' );
|
41 |
+
|
42 |
+
// Gets the unique option id
|
43 |
+
if ( isset( $wpr_optionsframework_settings['id'] ) ) {
|
44 |
+
$option_name = $wpr_optionsframework_settings['id'];
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
$option_name = 'wpr_optionsframework';
|
48 |
+
};
|
49 |
+
|
50 |
+
$settings = get_option($option_name);
|
51 |
+
$options = & Options_Framework::_wpr_optionsframework_options();
|
52 |
+
|
53 |
+
$counter = 0;
|
54 |
+
$menu = '';
|
55 |
+
|
56 |
+
foreach ( $options as $value ) {
|
57 |
+
|
58 |
+
$val = '';
|
59 |
+
$select_value = '';
|
60 |
+
$output = '';
|
61 |
+
|
62 |
+
// Wrap all options
|
63 |
+
if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
|
64 |
+
|
65 |
+
// Keep all ids lowercase with no spaces
|
66 |
+
$value['id'] = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['id']) );
|
67 |
+
|
68 |
+
$id = 'section-' . $value['id'];
|
69 |
+
|
70 |
+
$class = 'section';
|
71 |
+
if ( isset( $value['type'] ) ) {
|
72 |
+
$class .= ' section-' . $value['type'];
|
73 |
+
}
|
74 |
+
if ( isset( $value['class'] ) ) {
|
75 |
+
$class .= ' ' . $value['class'];
|
76 |
+
}
|
77 |
+
|
78 |
+
$output .= '<div id="' . esc_attr( $id ) .'" class="' . esc_attr( $class ) . '">'."\n";
|
79 |
+
if ( isset( $value['name'] ) ) {
|
80 |
+
$output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
|
81 |
+
}
|
82 |
+
if ( $value['type'] != 'editor' ) {
|
83 |
+
$output .= '<div class="option">' . "\n" . '<div class="controls">' . "\n";
|
84 |
+
}
|
85 |
+
else {
|
86 |
+
$output .= '<div class="option">' . "\n" . '<div>' . "\n";
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
// Set default value to $val
|
91 |
+
if ( isset( $value['std'] ) ) {
|
92 |
+
$val = $value['std'];
|
93 |
+
}
|
94 |
+
|
95 |
+
// If the option is already saved, override $val
|
96 |
+
if ( ( $value['type'] != 'heading' ) && ( $value['type'] != 'info') ) {
|
97 |
+
if ( isset( $settings[($value['id'])]) ) {
|
98 |
+
$val = $settings[($value['id'])];
|
99 |
+
// Striping slashes of non-array options
|
100 |
+
if ( !is_array($val) ) {
|
101 |
+
$val = stripslashes( $val );
|
102 |
+
}
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
// If there is a description save it for labels
|
107 |
+
$explain_value = '';
|
108 |
+
if ( isset( $value['desc'] ) ) {
|
109 |
+
$explain_value = $value['desc'];
|
110 |
+
}
|
111 |
+
|
112 |
+
// Set the placeholder if one exists
|
113 |
+
$placeholder = '';
|
114 |
+
if ( isset( $value['placeholder'] ) ) {
|
115 |
+
$placeholder = ' placeholder="' . esc_attr( $value['placeholder'] ) . '"';
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( has_filter( 'wpr_optionsframework_' . $value['type'] ) ) {
|
119 |
+
$output .= apply_filters( 'wpr_optionsframework_' . $value['type'], $option_name, $value, $val );
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
switch ( $value['type'] ) {
|
124 |
+
|
125 |
+
// Basic text input
|
126 |
+
case 'text':
|
127 |
+
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '"' . $placeholder . ' />';
|
128 |
+
break;
|
129 |
+
|
130 |
+
// Password input
|
131 |
+
case 'password':
|
132 |
+
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="password" value="' . esc_attr( $val ) . '" />';
|
133 |
+
break;
|
134 |
+
|
135 |
+
// Textarea
|
136 |
+
case 'textarea':
|
137 |
+
$rows = '8';
|
138 |
+
|
139 |
+
if ( isset( $value['settings']['rows'] ) ) {
|
140 |
+
$custom_rows = $value['settings']['rows'];
|
141 |
+
if ( is_numeric( $custom_rows ) ) {
|
142 |
+
$rows = $custom_rows;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
$val = stripslashes( $val );
|
147 |
+
$output .= '<textarea id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" rows="' . $rows . '"' . $placeholder . '>' . esc_textarea( $val ) . '</textarea>';
|
148 |
+
break;
|
149 |
+
|
150 |
+
// Select Box
|
151 |
+
case 'select':
|
152 |
+
$output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
|
153 |
+
|
154 |
+
foreach ($value['options'] as $key => $option ) {
|
155 |
+
$output .= '<option'. selected( $val, $key, false ) .' value="' . esc_attr( $key ) . '">' . esc_html( $option ) . '</option>';
|
156 |
+
}
|
157 |
+
$output .= '</select>';
|
158 |
+
break;
|
159 |
+
|
160 |
+
|
161 |
+
// Radio Box
|
162 |
+
case "radio":
|
163 |
+
$name = $option_name .'['. $value['id'] .']';
|
164 |
+
foreach ($value['options'] as $key => $option) {
|
165 |
+
$id = $option_name . '-' . $value['id'] .'-'. $key;
|
166 |
+
$output .= '<input class="of-input of-radio" type="radio" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" value="'. esc_attr( $key ) . '" '. checked( $val, $key, false) .' /><label for="' . esc_attr( $id ) . '">' . esc_html( $option ) . '</label>';
|
167 |
+
}
|
168 |
+
break;
|
169 |
+
|
170 |
+
// Image Selectors
|
171 |
+
case "images":
|
172 |
+
$name = $option_name .'['. $value['id'] .']';
|
173 |
+
foreach ( $value['options'] as $key => $option ) {
|
174 |
+
$selected = '';
|
175 |
+
if ( $val != '' && ($val == $key) ) {
|
176 |
+
$selected = ' of-radio-img-selected';
|
177 |
+
}
|
178 |
+
$output .= '<input type="radio" id="' . esc_attr( $value['id'] .'_'. $key) . '" class="of-radio-img-radio" value="' . esc_attr( $key ) . '" name="' . esc_attr( $name ) . '" '. checked( $val, $key, false ) .' />';
|
179 |
+
$output .= '<div class="of-radio-img-label">' . esc_html( $key ) . '</div>';
|
180 |
+
$output .= '<img src="' . esc_url( $option ) . '" alt="' . $option .'" class="of-radio-img-img' . $selected .'" onclick="document.getElementById(\''. esc_attr($value['id'] .'_'. $key) .'\').checked=true;" />';
|
181 |
+
}
|
182 |
+
break;
|
183 |
+
|
184 |
+
// Checkbox
|
185 |
+
case "checkbox":
|
186 |
+
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" '. checked( $val, 1, false) .' />';
|
187 |
+
$output .= '<label class="explain" for="' . esc_attr( $value['id'] ) . '">' . wp_kses( $explain_value, $allowedtags) . '</label>';
|
188 |
+
break;
|
189 |
+
|
190 |
+
// Multicheck
|
191 |
+
case "multicheck":
|
192 |
+
foreach ($value['options'] as $key => $option) {
|
193 |
+
$checked = '';
|
194 |
+
$label = $option;
|
195 |
+
$option = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($key));
|
196 |
+
|
197 |
+
$id = $option_name . '-' . $value['id'] . '-'. $option;
|
198 |
+
$name = $option_name . '[' . $value['id'] . '][' . $option .']';
|
199 |
+
|
200 |
+
if ( isset($val[$option]) ) {
|
201 |
+
$checked = checked($val[$option], 1, false);
|
202 |
+
}
|
203 |
+
|
204 |
+
$output .= '<input id="' . esc_attr( $id ) . '" class="checkbox of-input" type="checkbox" name="' . esc_attr( $name ) . '" ' . $checked . ' /><label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . '</label>';
|
205 |
+
}
|
206 |
+
break;
|
207 |
+
|
208 |
+
// Color picker
|
209 |
+
case "color":
|
210 |
+
$default_color = '';
|
211 |
+
if ( isset($value['std']) ) {
|
212 |
+
if ( $val != $value['std'] )
|
213 |
+
$default_color = ' data-default-color="' .$value['std'] . '" ';
|
214 |
+
}
|
215 |
+
$output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" class="of-color" type="text" value="' . esc_attr( $val ) . '"' . $default_color .' />';
|
216 |
+
|
217 |
+
break;
|
218 |
+
|
219 |
+
// Uploader
|
220 |
+
case "upload":
|
221 |
+
$output .= Options_Framework_Media_Uploader::wpr_optionsframework_uploader( $value['id'], $val, null );
|
222 |
+
|
223 |
+
break;
|
224 |
+
//Number field
|
225 |
+
case "number":
|
226 |
+
$output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="number" value="' . esc_attr( $val ) . '"' . $placeholder . ' />';
|
227 |
+
break;
|
228 |
+
|
229 |
+
// Background
|
230 |
+
case 'background':
|
231 |
+
|
232 |
+
$background = $val;
|
233 |
+
|
234 |
+
// Background Color
|
235 |
+
$default_color = '';
|
236 |
+
if ( isset( $value['std']['color'] ) ) {
|
237 |
+
if ( $val != $value['std']['color'] )
|
238 |
+
$default_color = ' data-default-color="' .$value['std']['color'] . '" ';
|
239 |
+
}
|
240 |
+
$output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-background-color" type="text" value="' . esc_attr( $background['color'] ) . '"' . $default_color .' />';
|
241 |
+
|
242 |
+
// Background Image
|
243 |
+
if ( !isset($background['image']) ) {
|
244 |
+
$background['image'] = '';
|
245 |
+
}
|
246 |
+
|
247 |
+
$output .= Options_Framework_Media_Uploader::wpr_optionsframework_uploader( $value['id'], $background['image'], null, esc_attr( $option_name . '[' . $value['id'] . '][image]' ) );
|
248 |
+
|
249 |
+
$class = 'of-background-properties';
|
250 |
+
if ( '' == $background['image'] ) {
|
251 |
+
$class .= ' hide';
|
252 |
+
}
|
253 |
+
$output .= '<div class="' . esc_attr( $class ) . '">';
|
254 |
+
|
255 |
+
// Background Repeat
|
256 |
+
$output .= '<select class="of-background of-background-repeat" name="' . esc_attr( $option_name . '[' . $value['id'] . '][repeat]' ) . '" id="' . esc_attr( $value['id'] . '_repeat' ) . '">';
|
257 |
+
$repeats = wpr_of_recognized_background_repeat();
|
258 |
+
|
259 |
+
foreach ($repeats as $key => $repeat) {
|
260 |
+
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['repeat'], $key, false ) . '>'. esc_html( $repeat ) . '</option>';
|
261 |
+
}
|
262 |
+
$output .= '</select>';
|
263 |
+
|
264 |
+
// Background Position
|
265 |
+
$output .= '<select class="of-background of-background-position" name="' . esc_attr( $option_name . '[' . $value['id'] . '][position]' ) . '" id="' . esc_attr( $value['id'] . '_position' ) . '">';
|
266 |
+
$positions = wpr_of_recognized_background_position();
|
267 |
+
|
268 |
+
foreach ($positions as $key=>$position) {
|
269 |
+
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['position'], $key, false ) . '>'. esc_html( $position ) . '</option>';
|
270 |
+
}
|
271 |
+
$output .= '</select>';
|
272 |
+
|
273 |
+
// Background Attachment
|
274 |
+
$output .= '<select class="of-background of-background-attachment" name="' . esc_attr( $option_name . '[' . $value['id'] . '][attachment]' ) . '" id="' . esc_attr( $value['id'] . '_attachment' ) . '">';
|
275 |
+
$attachments = wpr_of_recognized_background_attachment();
|
276 |
+
|
277 |
+
foreach ($attachments as $key => $attachment) {
|
278 |
+
$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $background['attachment'], $key, false ) . '>' . esc_html( $attachment ) . '</option>';
|
279 |
+
}
|
280 |
+
$output .= '</select>';
|
281 |
+
$output .= '</div>';
|
282 |
+
|
283 |
+
break;
|
284 |
+
|
285 |
+
// Editor
|
286 |
+
case 'editor':
|
287 |
+
$output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags ) . '</div>'."\n";
|
288 |
+
echo $output;
|
289 |
+
$textarea_name = esc_attr( $option_name . '[' . $value['id'] . ']' );
|
290 |
+
$default_editor_settings = array(
|
291 |
+
'textarea_name' => $textarea_name,
|
292 |
+
'media_buttons' => false,
|
293 |
+
'tinymce' => array( 'plugins' => 'wordpress' )
|
294 |
+
);
|
295 |
+
$editor_settings = array();
|
296 |
+
if ( isset( $value['settings'] ) ) {
|
297 |
+
$editor_settings = $value['settings'];
|
298 |
+
}
|
299 |
+
$editor_settings = array_merge( $default_editor_settings, $editor_settings );
|
300 |
+
wp_editor( $val, $value['id'], $editor_settings );
|
301 |
+
$output = '';
|
302 |
+
break;
|
303 |
+
|
304 |
+
// Info
|
305 |
+
case "info":
|
306 |
+
$id = '';
|
307 |
+
$class = 'section';
|
308 |
+
if ( isset( $value['id'] ) ) {
|
309 |
+
$id = 'id="' . esc_attr( $value['id'] ) . '" ';
|
310 |
+
}
|
311 |
+
if ( isset( $value['type'] ) ) {
|
312 |
+
$class .= ' section-' . $value['type'];
|
313 |
+
}
|
314 |
+
if ( isset( $value['class'] ) ) {
|
315 |
+
$class .= ' ' . $value['class'];
|
316 |
+
}
|
317 |
+
|
318 |
+
$output .= '<div ' . $id . 'class="' . esc_attr( $class ) . '">' . "\n";
|
319 |
+
if ( isset($value['name']) ) {
|
320 |
+
$output .= '<h4 class="heading">' . esc_html( $value['name'] ) . '</h4>' . "\n";
|
321 |
+
}
|
322 |
+
if ( isset( $value['desc'] ) ) {
|
323 |
+
$output .= apply_filters('wpr_of_sanitize_info', $value['desc'] ) . "\n";
|
324 |
+
}
|
325 |
+
$output .= '</div>' . "\n";
|
326 |
+
break;
|
327 |
+
|
328 |
+
// Heading for Navigation
|
329 |
+
case "heading":
|
330 |
+
$counter++;
|
331 |
+
if ( $counter >= 2 ) {
|
332 |
+
$output .= '</div>'."\n";
|
333 |
+
}
|
334 |
+
$class = '';
|
335 |
+
$class = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
|
336 |
+
$class = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($class) );
|
337 |
+
$output .= '<div id="options-group-' . $counter . '" class="group ' . $class . '">';
|
338 |
+
$output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
|
339 |
+
break;
|
340 |
+
}
|
341 |
+
|
342 |
+
if ( ( $value['type'] != "heading" ) && ( $value['type'] != "info" ) ) {
|
343 |
+
$output .= '</div>';
|
344 |
+
if ( ( $value['type'] != "checkbox" ) && ( $value['type'] != "editor" ) ) {
|
345 |
+
$output .= '<div class="explain">' . wp_kses( $explain_value, $allowedtags) . '</div>'."\n";
|
346 |
+
}
|
347 |
+
$output .= '</div></div>'."\n";
|
348 |
+
}
|
349 |
+
|
350 |
+
echo $output;
|
351 |
+
}
|
352 |
+
|
353 |
+
// Outputs closing div if there tabs
|
354 |
+
if ( Options_Framework_Interface::wpr_optionsframework_tabs() != '' ) {
|
355 |
+
echo '</div>';
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
}
|
inc/includes/class-options-media-uploader.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Options_Framework
|
4 |
+
* @author Devin Price <devin@wptheming.com>
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://wptheming.com
|
7 |
+
* @copyright 2010-2014 WP Theming
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Options_Framework_Media_Uploader {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Initialize the media uploader class
|
14 |
+
*
|
15 |
+
* @since 1.7.0
|
16 |
+
*/
|
17 |
+
public function init() {
|
18 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'wpr_optionsframework_media_scripts' ) );
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Media Uploader Using the WordPress Media Library.
|
23 |
+
*
|
24 |
+
* Parameters:
|
25 |
+
*
|
26 |
+
* string $_id - A token to identify this field (the name).
|
27 |
+
* string $_value - The value of the field, if present.
|
28 |
+
* string $_desc - An optional description of the field.
|
29 |
+
*
|
30 |
+
*/
|
31 |
+
|
32 |
+
static function wpr_optionsframework_uploader( $_id, $_value, $_desc = '', $_name = '' ) {
|
33 |
+
|
34 |
+
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' );
|
35 |
+
|
36 |
+
// Gets the unique option id
|
37 |
+
$option_name = $wpr_optionsframework_settings['id'];
|
38 |
+
|
39 |
+
$output = '';
|
40 |
+
$id = '';
|
41 |
+
$class = '';
|
42 |
+
$int = '';
|
43 |
+
$value = '';
|
44 |
+
$name = '';
|
45 |
+
|
46 |
+
$id = strip_tags( strtolower( $_id ) );
|
47 |
+
|
48 |
+
// If a value is passed and we don't have a stored value, use the value that's passed through.
|
49 |
+
if ( $_value != '' && $value == '' ) {
|
50 |
+
$value = $_value;
|
51 |
+
}
|
52 |
+
|
53 |
+
if ($_name != '') {
|
54 |
+
$name = $_name;
|
55 |
+
}
|
56 |
+
else {
|
57 |
+
$name = $option_name.'['.$id.']';
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( $value ) {
|
61 |
+
$class = ' has-file';
|
62 |
+
}
|
63 |
+
$output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" placeholder="' . __('No file chosen', 'textdomain') .'" />' . "\n";
|
64 |
+
if ( function_exists( 'wp_enqueue_media' ) ) {
|
65 |
+
if ( ( $value == '' ) ) {
|
66 |
+
$output .= '<input id="upload-' . $id . '" class="upload-button button" type="button" value="' . __( 'Upload', 'textdomain' ) . '" />' . "\n";
|
67 |
+
} else {
|
68 |
+
$output .= '<input id="remove-' . $id . '" class="remove-file button" type="button" value="' . __( 'Remove', 'textdomain' ) . '" />' . "\n";
|
69 |
+
}
|
70 |
+
} else {
|
71 |
+
$output .= '<p><i>' . __( 'Upgrade your version of WordPress for full media support.', 'textdomain' ) . '</i></p>';
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( $_desc != '' ) {
|
75 |
+
$output .= '<span class="of-metabox-desc">' . $_desc . '</span>' . "\n";
|
76 |
+
}
|
77 |
+
|
78 |
+
$output .= '<div class="screenshot" id="' . $id . '-image">' . "\n";
|
79 |
+
|
80 |
+
if ( $value != '' ) {
|
81 |
+
$remove = '<a class="remove-image">Remove</a>';
|
82 |
+
$image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value );
|
83 |
+
if ( $image ) {
|
84 |
+
$output .= '<img src="' . $value . '" alt="" />' . $remove;
|
85 |
+
} else {
|
86 |
+
$parts = explode( "/", $value );
|
87 |
+
for( $i = 0; $i < sizeof( $parts ); ++$i ) {
|
88 |
+
$title = $parts[$i];
|
89 |
+
}
|
90 |
+
|
91 |
+
// No output preview if it's not an image.
|
92 |
+
$output .= '';
|
93 |
+
|
94 |
+
// Standard generic output if it's not an image.
|
95 |
+
$title = __( 'View File', 'textdomain' );
|
96 |
+
$output .= '<div class="no-image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span></div>';
|
97 |
+
}
|
98 |
+
}
|
99 |
+
$output .= '</div>' . "\n";
|
100 |
+
return $output;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Enqueue scripts for file uploader
|
105 |
+
*/
|
106 |
+
function wpr_optionsframework_media_scripts( $hook ) {
|
107 |
+
|
108 |
+
$menu = Options_Framework_Admin::menu_settings();
|
109 |
+
|
110 |
+
if ( substr( $hook, -strlen( $menu['menu_slug'] ) ) !== $menu['menu_slug'] )
|
111 |
+
return;
|
112 |
+
|
113 |
+
if ( function_exists( 'wp_enqueue_media' ) )
|
114 |
+
wp_enqueue_media();
|
115 |
+
|
116 |
+
wp_register_script( 'of-media-uploader', WPR_OPTIONS_FRAMEWORK_DIRECTORY .'js/media-uploader.js', array( 'jquery' ), Options_Framework::VERSION );
|
117 |
+
wp_enqueue_script( 'of-media-uploader' );
|
118 |
+
wp_localize_script( 'of-media-uploader', 'wpr_optionsframework_l10n', array(
|
119 |
+
'upload' => __( 'Upload', 'textdomain' ),
|
120 |
+
'remove' => __( 'Remove', 'textdomain' )
|
121 |
+
) );
|
122 |
+
}
|
123 |
+
}
|
inc/includes/class-options-sanitization.php
ADDED
@@ -0,0 +1,385 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Options_Framework
|
4 |
+
* @author Devin Price <devin@wptheming.com>
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://wptheming.com
|
7 |
+
* @copyright 2010-2014 WP Theming
|
8 |
+
*/
|
9 |
+
|
10 |
+
/* Text */
|
11 |
+
|
12 |
+
add_filter( 'wpr_of_sanitize_text', 'sanitize_text_field' );
|
13 |
+
|
14 |
+
/* Password */
|
15 |
+
|
16 |
+
add_filter( 'wpr_of_sanitize_password', 'sanitize_text_field' );
|
17 |
+
|
18 |
+
/* Textarea */
|
19 |
+
|
20 |
+
function wpr_of_sanitize_textarea( $input) {
|
21 |
+
global $allowedposttags;
|
22 |
+
$output = wp_kses( $input, $allowedposttags);
|
23 |
+
return $output;
|
24 |
+
}
|
25 |
+
|
26 |
+
add_filter( 'wpr_of_sanitize_textarea', 'wpr_of_sanitize_textarea' );
|
27 |
+
|
28 |
+
/* Select */
|
29 |
+
|
30 |
+
add_filter( 'wpr_of_sanitize_select', 'wpr_of_sanitize_enum', 10, 2 );
|
31 |
+
|
32 |
+
/* Radio */
|
33 |
+
|
34 |
+
add_filter( 'wpr_of_sanitize_radio', 'wpr_of_sanitize_enum', 10, 2 );
|
35 |
+
|
36 |
+
/* Images */
|
37 |
+
|
38 |
+
add_filter( 'wpr_of_sanitize_images', 'wpr_of_sanitize_enum', 10, 2 );
|
39 |
+
|
40 |
+
/* Checkbox */
|
41 |
+
|
42 |
+
function wpr_of_sanitize_checkbox( $input ) {
|
43 |
+
if ( $input ) {
|
44 |
+
$output = '1';
|
45 |
+
} else {
|
46 |
+
$output = false;
|
47 |
+
}
|
48 |
+
return $output;
|
49 |
+
}
|
50 |
+
add_filter( 'wpr_of_sanitize_checkbox', 'wpr_of_sanitize_checkbox' );
|
51 |
+
|
52 |
+
/* Multicheck */
|
53 |
+
|
54 |
+
function wpr_of_sanitize_multicheck( $input, $option ) {
|
55 |
+
$output = '';
|
56 |
+
if ( is_array( $input ) ) {
|
57 |
+
foreach( $option['options'] as $key => $value ) {
|
58 |
+
$output[$key] = false;
|
59 |
+
}
|
60 |
+
foreach( $input as $key => $value ) {
|
61 |
+
if ( array_key_exists( $key, $option['options'] ) && $value ) {
|
62 |
+
$output[$key] = "1";
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
return $output;
|
67 |
+
}
|
68 |
+
add_filter( 'wpr_of_sanitize_multicheck', 'wpr_of_sanitize_multicheck', 10, 2 );
|
69 |
+
|
70 |
+
/* Color Picker */
|
71 |
+
|
72 |
+
add_filter( 'wpr_of_sanitize_color', 'wpr_of_sanitize_hex' );
|
73 |
+
|
74 |
+
/* Uploader */
|
75 |
+
|
76 |
+
function wpr_of_sanitize_upload( $input ) {
|
77 |
+
$output = '';
|
78 |
+
$filetype = wp_check_filetype( $input );
|
79 |
+
if ( $filetype["ext"] ) {
|
80 |
+
$output = esc_url( $input );
|
81 |
+
}
|
82 |
+
return $output;
|
83 |
+
}
|
84 |
+
add_filter( 'wpr_of_sanitize_upload', 'wpr_of_sanitize_upload' );
|
85 |
+
|
86 |
+
/* Editor */
|
87 |
+
|
88 |
+
function wpr_of_sanitize_editor( $input ) {
|
89 |
+
if ( current_user_can( 'unfiltered_html' ) ) {
|
90 |
+
$output = $input;
|
91 |
+
}
|
92 |
+
else {
|
93 |
+
global $allowedtags;
|
94 |
+
$output = wpautop(wp_kses( $input, $allowedtags));
|
95 |
+
}
|
96 |
+
return $output;
|
97 |
+
}
|
98 |
+
add_filter( 'wpr_of_sanitize_editor', 'wpr_of_sanitize_editor' );
|
99 |
+
|
100 |
+
/* Allowed Tags */
|
101 |
+
|
102 |
+
function wpr_of_sanitize_allowedtags( $input ) {
|
103 |
+
global $allowedtags;
|
104 |
+
$output = wpautop( wp_kses( $input, $allowedtags ) );
|
105 |
+
return $output;
|
106 |
+
}
|
107 |
+
|
108 |
+
/* Allowed Post Tags */
|
109 |
+
|
110 |
+
function wpr_of_sanitize_allowedposttags( $input ) {
|
111 |
+
global $allowedposttags;
|
112 |
+
$output = wpautop( wp_kses( $input, $allowedposttags) );
|
113 |
+
return $output;
|
114 |
+
}
|
115 |
+
add_filter( 'wpr_of_sanitize_info', 'wpr_of_sanitize_allowedposttags' );
|
116 |
+
|
117 |
+
/* Check that the key value sent is valid */
|
118 |
+
|
119 |
+
function wpr_of_sanitize_enum( $input, $option ) {
|
120 |
+
$output = '';
|
121 |
+
if ( array_key_exists( $input, $option['options'] ) ) {
|
122 |
+
$output = $input;
|
123 |
+
}
|
124 |
+
return $output;
|
125 |
+
}
|
126 |
+
|
127 |
+
/* Background */
|
128 |
+
|
129 |
+
function wpr_of_sanitize_background( $input ) {
|
130 |
+
$output = wp_parse_args( $input, array(
|
131 |
+
'color' => '',
|
132 |
+
'image' => '',
|
133 |
+
'repeat' => 'repeat',
|
134 |
+
'position' => 'top center',
|
135 |
+
'attachment' => 'scroll'
|
136 |
+
) );
|
137 |
+
|
138 |
+
$output['color'] = apply_filters( 'wpr_of_sanitize_hex', $input['color'] );
|
139 |
+
$output['image'] = apply_filters( 'wpr_of_sanitize_upload', $input['image'] );
|
140 |
+
$output['repeat'] = apply_filters( 'wpr_of_background_repeat', $input['repeat'] );
|
141 |
+
$output['position'] = apply_filters( 'wpr_of_background_position', $input['position'] );
|
142 |
+
$output['attachment'] = apply_filters( 'wpr_of_background_attachment', $input['attachment'] );
|
143 |
+
|
144 |
+
return $output;
|
145 |
+
}
|
146 |
+
add_filter( 'wpr_of_sanitize_background', 'wpr_of_sanitize_background' );
|
147 |
+
|
148 |
+
function wpr_of_sanitize_background_repeat( $value ) {
|
149 |
+
$recognized = wpr_of_recognized_background_repeat();
|
150 |
+
if ( array_key_exists( $value, $recognized ) ) {
|
151 |
+
return $value;
|
152 |
+
}
|
153 |
+
return apply_filters( 'wpr_of_default_background_repeat', current( $recognized ) );
|
154 |
+
}
|
155 |
+
add_filter( 'wpr_of_background_repeat', 'wpr_of_sanitize_background_repeat' );
|
156 |
+
|
157 |
+
function wpr_of_sanitize_background_position( $value ) {
|
158 |
+
$recognized = wpr_of_recognized_background_position();
|
159 |
+
if ( array_key_exists( $value, $recognized ) ) {
|
160 |
+
return $value;
|
161 |
+
}
|
162 |
+
return apply_filters( 'wpr_of_default_background_position', current( $recognized ) );
|
163 |
+
}
|
164 |
+
add_filter( 'wpr_of_background_position', 'wpr_of_sanitize_background_position' );
|
165 |
+
|
166 |
+
function wpr_of_sanitize_background_attachment( $value ) {
|
167 |
+
$recognized = wpr_of_recognized_background_attachment();
|
168 |
+
if ( array_key_exists( $value, $recognized ) ) {
|
169 |
+
return $value;
|
170 |
+
}
|
171 |
+
return apply_filters( 'wpr_of_default_background_attachment', current( $recognized ) );
|
172 |
+
}
|
173 |
+
add_filter( 'wpr_of_background_attachment', 'wpr_of_sanitize_background_attachment' );
|
174 |
+
|
175 |
+
|
176 |
+
/* Typography */
|
177 |
+
|
178 |
+
function wpr_of_sanitize_typography( $input, $option ) {
|
179 |
+
|
180 |
+
$output = wp_parse_args( $input, array(
|
181 |
+
'size' => '',
|
182 |
+
'face' => '',
|
183 |
+
'style' => '',
|
184 |
+
'color' => ''
|
185 |
+
) );
|
186 |
+
|
187 |
+
if ( isset( $option['options']['faces'] ) && isset( $input['face'] ) ) {
|
188 |
+
if ( !( array_key_exists( $input['face'], $option['options']['faces'] ) ) ) {
|
189 |
+
$output['face'] = '';
|
190 |
+
}
|
191 |
+
}
|
192 |
+
else {
|
193 |
+
$output['face'] = apply_filters( 'wpr_of_font_face', $output['face'] );
|
194 |
+
}
|
195 |
+
|
196 |
+
$output['size'] = apply_filters( 'wpr_of_font_size', $output['size'] );
|
197 |
+
$output['style'] = apply_filters( 'wpr_of_font_style', $output['style'] );
|
198 |
+
$output['color'] = apply_filters( 'wpr_of_sanitize_color', $output['color'] );
|
199 |
+
return $output;
|
200 |
+
}
|
201 |
+
add_filter( 'wpr_of_sanitize_typography', 'wpr_of_sanitize_typography', 10, 2 );
|
202 |
+
|
203 |
+
function wpr_of_sanitize_font_size( $value ) {
|
204 |
+
$recognized = wpr_of_recognized_font_sizes();
|
205 |
+
$value_check = preg_replace('/px/','', $value);
|
206 |
+
if ( in_array( (int) $value_check, $recognized ) ) {
|
207 |
+
return $value;
|
208 |
+
}
|
209 |
+
return apply_filters( 'wpr_of_default_font_size', $recognized );
|
210 |
+
}
|
211 |
+
add_filter( 'wpr_of_font_size', 'wpr_of_sanitize_font_size' );
|
212 |
+
|
213 |
+
|
214 |
+
function wpr_of_sanitize_font_style( $value ) {
|
215 |
+
$recognized = wpr_of_recognized_font_styles();
|
216 |
+
if ( array_key_exists( $value, $recognized ) ) {
|
217 |
+
return $value;
|
218 |
+
}
|
219 |
+
return apply_filters( 'wpr_of_default_font_style', current( $recognized ) );
|
220 |
+
}
|
221 |
+
add_filter( 'wpr_of_font_style', 'wpr_of_sanitize_font_style' );
|
222 |
+
|
223 |
+
|
224 |
+
function wpr_of_sanitize_font_face( $value ) {
|
225 |
+
$recognized = wpr_of_recognized_font_faces();
|
226 |
+
if ( array_key_exists( $value, $recognized ) ) {
|
227 |
+
return $value;
|
228 |
+
}
|
229 |
+
return apply_filters( 'wpr_of_default_font_face', current( $recognized ) );
|
230 |
+
}
|
231 |
+
add_filter( 'wpr_of_font_face', 'wpr_of_sanitize_font_face' );
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Get recognized background repeat settings
|
235 |
+
*
|
236 |
+
* @return array
|
237 |
+
*
|
238 |
+
*/
|
239 |
+
function wpr_of_recognized_background_repeat() {
|
240 |
+
$default = array(
|
241 |
+
'no-repeat' => __( 'No Repeat', 'textdomain' ),
|
242 |
+
'repeat-x' => __( 'Repeat Horizontally', 'textdomain' ),
|
243 |
+
'repeat-y' => __( 'Repeat Vertically', 'textdomain' ),
|
244 |
+
'repeat' => __( 'Repeat All', 'textdomain' ),
|
245 |
+
);
|
246 |
+
return apply_filters( 'wpr_of_recognized_background_repeat', $default );
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Get recognized background positions
|
251 |
+
*
|
252 |
+
* @return array
|
253 |
+
*
|
254 |
+
*/
|
255 |
+
function wpr_of_recognized_background_position() {
|
256 |
+
$default = array(
|
257 |
+
'top left' => __( 'Top Left', 'textdomain' ),
|
258 |
+
'top center' => __( 'Top Center', 'textdomain' ),
|
259 |
+
'top right' => __( 'Top Right', 'textdomain' ),
|
260 |
+
'center left' => __( 'Middle Left', 'textdomain' ),
|
261 |
+
'center center' => __( 'Middle Center', 'textdomain' ),
|
262 |
+
'center right' => __( 'Middle Right', 'textdomain' ),
|
263 |
+
'bottom left' => __( 'Bottom Left', 'textdomain' ),
|
264 |
+
'bottom center' => __( 'Bottom Center', 'textdomain' ),
|
265 |
+
'bottom right' => __( 'Bottom Right', 'textdomain')
|
266 |
+
);
|
267 |
+
return apply_filters( 'wpr_of_recognized_background_position', $default );
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Get recognized background attachment
|
272 |
+
*
|
273 |
+
* @return array
|
274 |
+
*
|
275 |
+
*/
|
276 |
+
function wpr_of_recognized_background_attachment() {
|
277 |
+
$default = array(
|
278 |
+
'scroll' => __( 'Scroll Normally', 'textdomain' ),
|
279 |
+
'fixed' => __( 'Fixed in Place', 'textdomain')
|
280 |
+
);
|
281 |
+
return apply_filters( 'wpr_of_recognized_background_attachment', $default );
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Sanitize a color represented in hexidecimal notation.
|
286 |
+
*
|
287 |
+
* @param string Color in hexidecimal notation. "#" may or may not be prepended to the string.
|
288 |
+
* @param string The value that this function should return if it cannot be recognized as a color.
|
289 |
+
* @return string
|
290 |
+
*
|
291 |
+
*/
|
292 |
+
|
293 |
+
function wpr_of_sanitize_hex( $hex, $default = '' ) {
|
294 |
+
if ( wpr_of_validate_hex( $hex ) ) {
|
295 |
+
return $hex;
|
296 |
+
}
|
297 |
+
return $default;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Get recognized font sizes.
|
302 |
+
*
|
303 |
+
* Returns an indexed array of all recognized font sizes.
|
304 |
+
* Values are integers and represent a range of sizes from
|
305 |
+
* smallest to largest.
|
306 |
+
*
|
307 |
+
* @return array
|
308 |
+
*/
|
309 |
+
|
310 |
+
function wpr_of_recognized_font_sizes() {
|
311 |
+
$sizes = range( 9, 71 );
|
312 |
+
$sizes = apply_filters( 'wpr_of_recognized_font_sizes', $sizes );
|
313 |
+
$sizes = array_map( 'absint', $sizes );
|
314 |
+
return $sizes;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Get recognized font faces.
|
319 |
+
*
|
320 |
+
* Returns an array of all recognized font faces.
|
321 |
+
* Keys are intended to be stored in the database
|
322 |
+
* while values are ready for display in in html.
|
323 |
+
*
|
324 |
+
* @return array
|
325 |
+
*
|
326 |
+
*/
|
327 |
+
function wpr_of_recognized_font_faces() {
|
328 |
+
$default = array(
|
329 |
+
'arial' => 'Arial',
|
330 |
+
'verdana' => 'Verdana, Geneva',
|
331 |
+
'trebuchet' => 'Trebuchet',
|
332 |
+
'georgia' => 'Georgia',
|
333 |
+
'times' => 'Times New Roman',
|
334 |
+
'tahoma' => 'Tahoma, Geneva',
|
335 |
+
'palatino' => 'Palatino',
|
336 |
+
'helvetica' => 'Helvetica*'
|
337 |
+
);
|
338 |
+
return apply_filters( 'wpr_of_recognized_font_faces', $default );
|
339 |
+
}
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Get recognized font styles.
|
343 |
+
*
|
344 |
+
* Returns an array of all recognized font styles.
|
345 |
+
* Keys are intended to be stored in the database
|
346 |
+
* while values are ready for display in in html.
|
347 |
+
*
|
348 |
+
* @return array
|
349 |
+
*
|
350 |
+
*/
|
351 |
+
function wpr_of_recognized_font_styles() {
|
352 |
+
$default = array(
|
353 |
+
'normal' => __( 'Normal', 'textdomain' ),
|
354 |
+
'italic' => __( 'Italic', 'textdomain' ),
|
355 |
+
'bold' => __( 'Bold', 'textdomain' ),
|
356 |
+
'bold italic' => __( 'Bold Italic', 'textdomain' )
|
357 |
+
);
|
358 |
+
return apply_filters( 'wpr_of_recognized_font_styles', $default );
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Is a given string a color formatted in hexidecimal notation?
|
363 |
+
*
|
364 |
+
* @param string Color in hexidecimal notation. "#" may or may not be prepended to the string.
|
365 |
+
* @return bool
|
366 |
+
*
|
367 |
+
*/
|
368 |
+
|
369 |
+
function wpr_of_validate_hex( $hex ) {
|
370 |
+
$hex = trim( $hex );
|
371 |
+
/* Strip recognized prefixes. */
|
372 |
+
if ( 0 === strpos( $hex, '#' ) ) {
|
373 |
+
$hex = substr( $hex, 1 );
|
374 |
+
}
|
375 |
+
elseif ( 0 === strpos( $hex, '%23' ) ) {
|
376 |
+
$hex = substr( $hex, 3 );
|
377 |
+
}
|
378 |
+
/* Regex match. */
|
379 |
+
if ( 0 === preg_match( '/^[0-9a-fA-F]{6}$/', $hex ) ) {
|
380 |
+
return false;
|
381 |
+
}
|
382 |
+
else {
|
383 |
+
return true;
|
384 |
+
}
|
385 |
+
}
|
inc/js/media-uploader.js
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($){
|
2 |
+
|
3 |
+
var wpr_optionsframework_upload;
|
4 |
+
var wpr_optionsframework_selector;
|
5 |
+
|
6 |
+
function wpr_optionsframework_add_file(event, selector) {
|
7 |
+
|
8 |
+
var upload = $(".uploaded-file"), frame;
|
9 |
+
var $el = $(this);
|
10 |
+
wpr_optionsframework_selector = selector;
|
11 |
+
|
12 |
+
event.preventDefault();
|
13 |
+
|
14 |
+
// If the media frame already exists, reopen it.
|
15 |
+
if ( wpr_optionsframework_upload ) {
|
16 |
+
wpr_optionsframework_upload.open();
|
17 |
+
} else {
|
18 |
+
// Create the media frame.
|
19 |
+
wpr_optionsframework_upload = wp.media.frames.wpr_optionsframework_upload = wp.media({
|
20 |
+
// Set the title of the modal.
|
21 |
+
title: $el.data('choose'),
|
22 |
+
|
23 |
+
// Customize the submit button.
|
24 |
+
button: {
|
25 |
+
// Set the text of the button.
|
26 |
+
text: $el.data('update'),
|
27 |
+
// Tell the button not to close the modal, since we're
|
28 |
+
// going to refresh the page when the image is selected.
|
29 |
+
close: false
|
30 |
+
}
|
31 |
+
});
|
32 |
+
|
33 |
+
// When an image is selected, run a callback.
|
34 |
+
wpr_optionsframework_upload.on( 'select', function() {
|
35 |
+
// Grab the selected attachment.
|
36 |
+
var attachment = wpr_optionsframework_upload.state().get('selection').first();
|
37 |
+
wpr_optionsframework_upload.close();
|
38 |
+
wpr_optionsframework_selector.find('.upload').val(attachment.attributes.url);
|
39 |
+
if ( attachment.attributes.type == 'image' ) {
|
40 |
+
wpr_optionsframework_selector.find('.screenshot').empty().hide().append('<img src="' + attachment.attributes.url + '"><a class="remove-image">Remove</a>').slideDown('fast');
|
41 |
+
}
|
42 |
+
wpr_optionsframework_selector.find('.upload-button').unbind().addClass('remove-file').removeClass('upload-button').val(wpr_optionsframework_l10n.remove);
|
43 |
+
wpr_optionsframework_selector.find('.of-background-properties').slideDown();
|
44 |
+
wpr_optionsframework_selector.find('.remove-image, .remove-file').on('click', function() {
|
45 |
+
wpr_optionsframework_remove_file( $(this).parents('.section') );
|
46 |
+
});
|
47 |
+
});
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
// Finally, open the modal.
|
52 |
+
wpr_optionsframework_upload.open();
|
53 |
+
}
|
54 |
+
|
55 |
+
function wpr_optionsframework_remove_file(selector) {
|
56 |
+
selector.find('.remove-image').hide();
|
57 |
+
selector.find('.upload').val('');
|
58 |
+
selector.find('.of-background-properties').hide();
|
59 |
+
selector.find('.screenshot').slideUp();
|
60 |
+
selector.find('.remove-file').unbind().addClass('upload-button').removeClass('remove-file').val(wpr_optionsframework_l10n.upload);
|
61 |
+
// We don't display the upload button if .upload-notice is present
|
62 |
+
// This means the user doesn't have the WordPress 3.5 Media Library Support
|
63 |
+
if ( $('.section-upload .upload-notice').length > 0 ) {
|
64 |
+
$('.upload-button').remove();
|
65 |
+
}
|
66 |
+
selector.find('.upload-button').on('click', function(event) {
|
67 |
+
wpr_optionsframework_add_file(event, $(this).parents('.section'));
|
68 |
+
});
|
69 |
+
}
|
70 |
+
|
71 |
+
$('.remove-image, .remove-file').on('click', function() {
|
72 |
+
wpr_optionsframework_remove_file( $(this).parents('.section') );
|
73 |
+
});
|
74 |
+
|
75 |
+
$('.upload-button').click( function( event ) {
|
76 |
+
wpr_optionsframework_add_file(event, $(this).parents('.section'));
|
77 |
+
});
|
78 |
+
|
79 |
+
});
|
inc/js/options-custom.js
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Custom scripts needed for the colorpicker, image button selectors,
|
3 |
+
* and navigation tabs.
|
4 |
+
*/
|
5 |
+
|
6 |
+
jQuery(document).ready(function($) {
|
7 |
+
|
8 |
+
// Loads the color pickers
|
9 |
+
$('.of-color').wpColorPicker();
|
10 |
+
|
11 |
+
// Image Options
|
12 |
+
$('.of-radio-img-img').click(function(){
|
13 |
+
$(this).parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
|
14 |
+
$(this).addClass('of-radio-img-selected');
|
15 |
+
});
|
16 |
+
|
17 |
+
$('.of-radio-img-label').hide();
|
18 |
+
$('.of-radio-img-img').show();
|
19 |
+
$('.of-radio-img-radio').hide();
|
20 |
+
|
21 |
+
// Loads tabbed sections if they exist
|
22 |
+
if ( $('.nav-tab-wrapper').length > 0 ) {
|
23 |
+
options_framework_tabs();
|
24 |
+
}
|
25 |
+
|
26 |
+
function options_framework_tabs() {
|
27 |
+
|
28 |
+
var $group = $('.group'),
|
29 |
+
$navtabs = $('.nav-tab-wrapper a'),
|
30 |
+
active_tab = '';
|
31 |
+
|
32 |
+
// Hides all the .group sections to start
|
33 |
+
$group.hide();
|
34 |
+
|
35 |
+
// Find if a selected tab is saved in localStorage
|
36 |
+
if ( typeof(localStorage) != 'undefined' ) {
|
37 |
+
active_tab = localStorage.getItem('active_tab');
|
38 |
+
}
|
39 |
+
|
40 |
+
// If active tab is saved and exists, load it's .group
|
41 |
+
if ( active_tab != '' && $(active_tab).length ) {
|
42 |
+
$(active_tab).fadeIn();
|
43 |
+
$(active_tab + '-tab').addClass('nav-tab-active');
|
44 |
+
} else {
|
45 |
+
$('.group:first').fadeIn();
|
46 |
+
$('.nav-tab-wrapper a:first').addClass('nav-tab-active');
|
47 |
+
}
|
48 |
+
|
49 |
+
// Bind tabs clicks
|
50 |
+
$navtabs.click(function(e) {
|
51 |
+
|
52 |
+
e.preventDefault();
|
53 |
+
|
54 |
+
// Remove active class from all tabs
|
55 |
+
$navtabs.removeClass('nav-tab-active');
|
56 |
+
|
57 |
+
$(this).addClass('nav-tab-active').blur();
|
58 |
+
|
59 |
+
if (typeof(localStorage) != 'undefined' ) {
|
60 |
+
localStorage.setItem('active_tab', $(this).attr('href') );
|
61 |
+
}
|
62 |
+
|
63 |
+
var selected = $(this).attr('href');
|
64 |
+
|
65 |
+
$group.hide();
|
66 |
+
$(selected).fadeIn();
|
67 |
+
|
68 |
+
});
|
69 |
+
}
|
70 |
+
|
71 |
+
});
|
inc/options-framework.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// If this file is called directly, abort.
|
4 |
+
if ( ! defined( 'WPINC' ) ) {
|
5 |
+
die;
|
6 |
+
}
|
7 |
+
|
8 |
+
// Don't load if wpr_optionsframework_init is already defined
|
9 |
+
if (is_admin() && ! function_exists( 'wpr_optionsframework_init' ) ) :
|
10 |
+
|
11 |
+
function wpr_optionsframework_init() {
|
12 |
+
|
13 |
+
// If user can't edit theme options, exit
|
14 |
+
if ( ! current_user_can( 'edit_theme_options' ) )
|
15 |
+
return;
|
16 |
+
|
17 |
+
// Loads the required Options Framework classes.
|
18 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework.php';
|
19 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-options-framework-admin.php';
|
20 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-options-interface.php';
|
21 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-options-media-uploader.php';
|
22 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-options-sanitization.php';
|
23 |
+
|
24 |
+
// Instantiate the main plugin class.
|
25 |
+
$options_framework = new Options_Framework;
|
26 |
+
$options_framework->init();
|
27 |
+
|
28 |
+
// Instantiate the options page.
|
29 |
+
$options_framework_admin = new Options_Framework_Admin;
|
30 |
+
$options_framework_admin->init();
|
31 |
+
|
32 |
+
// Instantiate the media uploader class
|
33 |
+
$options_framework_media_uploader = new Options_Framework_Media_Uploader;
|
34 |
+
$options_framework_media_uploader->init();
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
add_action( 'init', 'wpr_optionsframework_init', 20 );
|
39 |
+
|
40 |
+
endif;
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Helper function to return the theme option value.
|
45 |
+
* If no value has been saved, it returns $default.
|
46 |
+
* Needed because options are saved as serialized strings.
|
47 |
+
*
|
48 |
+
* Not in a class to support backwards compatibility in themes.
|
49 |
+
*/
|
50 |
+
|
51 |
+
if ( ! function_exists( 'wpr_of_get_option' ) ) :
|
52 |
+
|
53 |
+
function wpr_of_get_option( $name, $default = false ) {
|
54 |
+
$config = get_option( 'wpr_optionsframework' );
|
55 |
+
|
56 |
+
if ( ! isset( $config['id'] ) ) {
|
57 |
+
return $default;
|
58 |
+
}
|
59 |
+
|
60 |
+
$options = get_option( $config['id'] );
|
61 |
+
|
62 |
+
if ( isset( $options[$name] ) ) {
|
63 |
+
return $options[$name];
|
64 |
+
}
|
65 |
+
|
66 |
+
return $default;
|
67 |
+
}
|
68 |
+
|
69 |
+
endif;
|
inc/options.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A unique identifier is defined to store the options in the database and reference them from the theme.
|
4 |
+
* By default it uses the theme name, in lowercase and without spaces, but this can be changed if needed.
|
5 |
+
* If the identifier changes, it'll appear as if the options have been reset.
|
6 |
+
*/
|
7 |
+
|
8 |
+
function wpr_optionsframework_option_name() {
|
9 |
+
$wpr_optionsframework_settings = get_option( 'wpr_optionsframework' );
|
10 |
+
$wpr_optionsframework_settings['id'] = 'wprmenu_options';
|
11 |
+
update_option( 'wpr_optionsframework', $wpr_optionsframework_settings );
|
12 |
+
}
|
13 |
+
|
14 |
+
add_action( 'wpr_optionsframework_after', 'wpr_support_link' );
|
15 |
+
|
16 |
+
function wpr_support_link() { ?>
|
17 |
+
<div class="queries-holder">
|
18 |
+
<div class="wpr_pro"> Wp Responsive Menu Pro is out and it has much more features that you ever wanted.
|
19 |
+
<div>
|
20 |
+
Check out the
|
21 |
+
<a href="http://magnigenie.com/wp-responsive-menu-pro/" target="_blank">Pro Features</a> <br>
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
<div class="queries-holder">
|
26 |
+
<div class="wpr_help">Need help? No Problem.
|
27 |
+
<div>
|
28 |
+
<a href="http://magnigenie.com/support/queries/wp-responsive-menu/" target="_blank">Visit Our Support Forum</a>
|
29 |
+
</div>
|
30 |
+
</div>
|
31 |
+
</div><?php
|
32 |
+
}
|
33 |
+
|
34 |
+
add_filter( 'wpr_optionsframework_menu', 'wpr_add_responsive_menu' );
|
35 |
+
|
36 |
+
function wpr_add_responsive_menu( $menu ) {
|
37 |
+
$menu['page_title'] = 'WP Responsive Menu';
|
38 |
+
$menu['menu_title'] = 'WPR Menu';
|
39 |
+
$menu['mode'] = 'menu';
|
40 |
+
$menu['menu_slug'] = 'wp-responsive-menu';
|
41 |
+
$menu['position'] = '30';
|
42 |
+
return $menu;
|
43 |
+
}
|
44 |
+
/**
|
45 |
+
* Defines an array of options that will be used to generate the settings page and be saved in the database.
|
46 |
+
* When creating the 'id' fields, make sure to use all lowercase and no spaces.
|
47 |
+
*
|
48 |
+
* If you are making your theme translatable, you should replace 'options_framework_theme'
|
49 |
+
* with the actual text domain for your theme. Read more:
|
50 |
+
* http://codex.wordpress.org/Function_Reference/load_theme_textdomain
|
51 |
+
*/
|
52 |
+
$options = get_option('wprmenu_options');
|
53 |
+
function wpr_optionsframework_options() {
|
54 |
+
|
55 |
+
$options = array();
|
56 |
+
|
57 |
+
$options[] = array('name' => __('General Settings', 'wprmenu'),
|
58 |
+
'type' => 'heading');
|
59 |
+
|
60 |
+
$options[] = array('name' => __('Enable Mobile Navigation', 'wprmenu'),
|
61 |
+
'desc' => __('Check if you want to activate mobile navigation.', 'wprmenu'),
|
62 |
+
'id' => 'enabled',
|
63 |
+
'std' => '1',
|
64 |
+
'type' => 'checkbox');
|
65 |
+
$menus = get_terms('nav_menu',array('hide_empty'=>false));
|
66 |
+
$menu = array();
|
67 |
+
foreach( $menus as $m ) {
|
68 |
+
$menu[$m->term_id] = $m->name;
|
69 |
+
}
|
70 |
+
$options[] = array('name' => __('Select Menu', 'wprmenu'),
|
71 |
+
'desc' => __('Select the menu you want to display for mobile devices.', 'wprmenu'),
|
72 |
+
'id' => 'menu',
|
73 |
+
'std' => '',
|
74 |
+
'class' => 'mini',
|
75 |
+
'options' => $menu,
|
76 |
+
'type' => 'select');
|
77 |
+
|
78 |
+
$options[] = array('name' => __('Elements to hide in mobile:', 'wprmenu'),
|
79 |
+
'desc' => __('Enter the css class/ids for different elements you want to hide on mobile separeted by a comma(,). Example: .nav,#main-menu ', 'wprmenu'),
|
80 |
+
'id' => 'hide',
|
81 |
+
'std' => '',
|
82 |
+
'type' => 'text');
|
83 |
+
|
84 |
+
$options[] = array('name' => __('Enable Swipe', 'wprmenu'),
|
85 |
+
'desc' => __('Enable swipe gesture to open/close menus, Only applicable for left/right menu.', 'wprmenu'),
|
86 |
+
'id' => 'swipe',
|
87 |
+
'std' => 'yes',
|
88 |
+
'options' => array('yes' => 'Yes','no' => 'No'),
|
89 |
+
'type' => 'radio');
|
90 |
+
|
91 |
+
$options[] = array('name' => __(' Search Box', 'wprmenu'),
|
92 |
+
'desc' => __(' Select the position of search box or simply hide the search box if you donot need it.', 'wprmenu'),
|
93 |
+
'id' => 'search_box',
|
94 |
+
'std' => 'hide',
|
95 |
+
'options' => array('above_menu' => 'Above Menu','below_menu' => 'Below Menu', 'hide'=> 'Hide search box' ),
|
96 |
+
'type' => 'select');
|
97 |
+
|
98 |
+
$options[] = array('name' => __('Allow zoom on mobile devices', 'wprmenu'),
|
99 |
+
'desc' => __('', 'wprmenu'),
|
100 |
+
'id' => 'zooming',
|
101 |
+
'std' => 'yes',
|
102 |
+
'options' => array('yes' => 'Yes','no' => 'No'),
|
103 |
+
'type' => 'radio');
|
104 |
+
|
105 |
+
$options[] = array('name' => __('Menu Appearance', 'wprmenu'),
|
106 |
+
'type' => 'heading');
|
107 |
+
|
108 |
+
$options[] = array('name' => __('Menu Symbol Position', 'wprmenu'),
|
109 |
+
'desc' => __('Select menu icon position which will be displayed on the menu bar.', 'wprmenu'),
|
110 |
+
'id' => 'menu_symbol_pos',
|
111 |
+
'std' => 'left',
|
112 |
+
'class' => 'mini',
|
113 |
+
'options' => array('left' => 'Left','right' => 'Right'),
|
114 |
+
'type' => 'select');
|
115 |
+
|
116 |
+
$options[] = array('name' => __('Menu Text', 'wprmenu'),
|
117 |
+
'desc' => __('Entet the text you would like to display on the menu bar.', 'wprmenu'),
|
118 |
+
'id' => 'bar_title',
|
119 |
+
'std' => 'MENU',
|
120 |
+
'class' => 'mini',
|
121 |
+
'type' => 'text');
|
122 |
+
|
123 |
+
$options[] = array('name' => __('Menu Logo', 'wprmenu'),
|
124 |
+
'desc' => __('Select menu logo.', 'wprmenu'),
|
125 |
+
'id' => 'bar_logo',
|
126 |
+
'std' => '',
|
127 |
+
'type' => 'upload');
|
128 |
+
|
129 |
+
$options[] = array('name' => __('Menu Open Direction', 'wprmenu'),
|
130 |
+
'desc' => __('Select the direction from where menu will open.', 'wprmenu'),
|
131 |
+
'id' => 'position',
|
132 |
+
'std' => 'left',
|
133 |
+
'class' => 'mini',
|
134 |
+
'options' => array('left' => 'Left','right' => 'Right', 'top' => 'Top' ),
|
135 |
+
'type' => 'select');
|
136 |
+
|
137 |
+
$options[] = array('name' => __('Display menu from width (in px)', 'wprmenu'),
|
138 |
+
'desc' => __(' Enter the width (in px) below which the responsive menu will be visible on screen', 'wprmenu'),
|
139 |
+
'id' => 'from_width',
|
140 |
+
'std' => '768',
|
141 |
+
'class' => 'mini',
|
142 |
+
'type' => 'text');
|
143 |
+
|
144 |
+
$options[] = array('name' => __('Menu Width', 'wprmenu'),
|
145 |
+
'desc' => __('Enter menu width in (%) only applicable for left and right menu.', 'wprmenu'),
|
146 |
+
'id' => 'how_wide',
|
147 |
+
'std' => '80',
|
148 |
+
'class' => 'mini',
|
149 |
+
'type' => 'text');
|
150 |
+
|
151 |
+
$options[] = array('name' => __('Menu bar background color', 'wprmenu'),
|
152 |
+
'desc' => __('', 'wprmenu'),
|
153 |
+
'id' => 'bar_bgd',
|
154 |
+
'std' => '#0D0D0D',
|
155 |
+
'type' => 'color');
|
156 |
+
|
157 |
+
$options[] = array('name' => __('Menu bar text color', 'wprmenu'),
|
158 |
+
'desc' => __('', 'wprmenu'),
|
159 |
+
'id' => 'bar_color',
|
160 |
+
'std' => '#F2F2F2',
|
161 |
+
'type' => 'color');
|
162 |
+
|
163 |
+
$options[] = array('name' => __('Menu background color', 'wprmenu'),
|
164 |
+
'desc' => __('', 'wprmenu'),
|
165 |
+
'id' => 'menu_bgd',
|
166 |
+
'std' => '#2E2E2E',
|
167 |
+
'type' => 'color');
|
168 |
+
|
169 |
+
$options[] = array('name' => __('Menu text color', 'wprmenu'),
|
170 |
+
'desc' => __('', 'wprmenu'),
|
171 |
+
'id' => 'menu_color',
|
172 |
+
'std' => '#CFCFCF',
|
173 |
+
'type' => 'color');
|
174 |
+
|
175 |
+
$options[] = array('name' => __('Menu mouse over text color', 'wprmenu'),
|
176 |
+
'desc' => __('', 'wprmenu'),
|
177 |
+
'id' => 'menu_color_hover',
|
178 |
+
'std' => '#606060',
|
179 |
+
'type' => 'color');
|
180 |
+
|
181 |
+
$options[] = array('name' => __('Menu icon color', 'wprmenu'),
|
182 |
+
'desc' => __('', 'wprmenu'),
|
183 |
+
'id' => 'menu_icon_color',
|
184 |
+
'std' => '#FFFFFF',
|
185 |
+
'type' => 'color');
|
186 |
+
|
187 |
+
$options[] = array('name' => __('Menu borders(top & left) color', 'wprmenu'),
|
188 |
+
'desc' => __('', 'wprmenu'),
|
189 |
+
'id' => 'menu_border_top',
|
190 |
+
'std' => '#0D0D0D',
|
191 |
+
'type' => 'color');
|
192 |
+
|
193 |
+
$options[] = array('name' => __('Menu borders(bottom) color', 'wprmenu'),
|
194 |
+
'desc' => __('', 'wprmenu'),
|
195 |
+
'id' => 'menu_border_bottom',
|
196 |
+
'std' => '#131212',
|
197 |
+
'type' => 'color');
|
198 |
+
|
199 |
+
$options[] = array('name' => __('Enable borders for menu items', 'wprmenu'),
|
200 |
+
'desc' => __('', 'wprmenu'),
|
201 |
+
'id' => 'menu_border_bottom_show',
|
202 |
+
'std' => 'yes',
|
203 |
+
'options' => array('yes' => 'Yes','no' => 'No'),
|
204 |
+
'type' => 'radio');
|
205 |
+
|
206 |
+
return $options;
|
207 |
+
}
|
index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//silence is golden.
|
js/jquery.sidr.js
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Sidr
|
3 |
+
* https://github.com/artberri/sidr
|
4 |
+
*
|
5 |
+
* Copyright (c) 2013 Alberto Varela
|
6 |
+
* Licensed under the MIT license.
|
7 |
+
*/
|
8 |
+
|
9 |
+
;(function( $ ){
|
10 |
+
|
11 |
+
var sidrMoving = false,
|
12 |
+
sidrOpened = false;
|
13 |
+
|
14 |
+
// Private methods
|
15 |
+
var privateMethods = {
|
16 |
+
// Check for valids urls
|
17 |
+
// From : http://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-an-url
|
18 |
+
isUrl: function (str) {
|
19 |
+
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
|
20 |
+
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
|
21 |
+
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
|
22 |
+
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
|
23 |
+
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
|
24 |
+
'(\\#[-a-z\\d_]*)?$','i'); // fragment locator
|
25 |
+
if(!pattern.test(str)) {
|
26 |
+
return false;
|
27 |
+
} else {
|
28 |
+
return true;
|
29 |
+
}
|
30 |
+
},
|
31 |
+
// Loads the content into the menu bar
|
32 |
+
loadContent: function($menu, content) {
|
33 |
+
$menu.html(content);
|
34 |
+
},
|
35 |
+
// Add sidr prefixes
|
36 |
+
addPrefix: function($element) {
|
37 |
+
var elementId = $element.attr('id'),
|
38 |
+
elementClass = $element.attr('class');
|
39 |
+
|
40 |
+
if(typeof elementId === 'string' && '' !== elementId) {
|
41 |
+
$element.attr('id', elementId.replace(/([A-Za-z0-9_.\-]+)/g, 'sidr-id-$1'));
|
42 |
+
}
|
43 |
+
if(typeof elementClass === 'string' && '' !== elementClass && 'sidr-inner' !== elementClass) {
|
44 |
+
$element.attr('class', elementClass.replace(/([A-Za-z0-9_.\-]+)/g, 'sidr-class-$1'));
|
45 |
+
}
|
46 |
+
$element.removeAttr('style');
|
47 |
+
},
|
48 |
+
execute: function(action, name, callback) {
|
49 |
+
// Check arguments
|
50 |
+
if(typeof name === 'function') {
|
51 |
+
callback = name;
|
52 |
+
name = 'sidr';
|
53 |
+
}
|
54 |
+
else if(!name) {
|
55 |
+
name = 'sidr';
|
56 |
+
}
|
57 |
+
|
58 |
+
// Declaring
|
59 |
+
var $menu = $('#' + name),
|
60 |
+
$body = $($menu.data('body')),
|
61 |
+
$html = $('html'),
|
62 |
+
menuWidth = $menu.outerWidth(true),
|
63 |
+
speed = $menu.data('speed'),
|
64 |
+
side = $menu.data('side'),
|
65 |
+
displace = $menu.data('displace'),
|
66 |
+
onOpen = $menu.data('onOpen'),
|
67 |
+
onClose = $menu.data('onClose'),
|
68 |
+
bodyAnimation,
|
69 |
+
menuAnimation,
|
70 |
+
scrollTop,
|
71 |
+
bodyClass = (name === 'sidr' ? 'sidr-open' : 'sidr-open ' + name + '-open');
|
72 |
+
|
73 |
+
// Open Sidr
|
74 |
+
if('open' === action || ('toggle' === action && !$menu.is(':visible'))) {
|
75 |
+
// Check if we can open it
|
76 |
+
if( $menu.is(':visible') || sidrMoving ) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
// If another menu opened close first
|
81 |
+
if(sidrOpened !== false) {
|
82 |
+
methods.close(sidrOpened, function() {
|
83 |
+
methods.open(name);
|
84 |
+
});
|
85 |
+
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
|
89 |
+
// Lock sidr
|
90 |
+
sidrMoving = true;
|
91 |
+
|
92 |
+
// Left or right?
|
93 |
+
if(side === 'left') {
|
94 |
+
bodyAnimation = {left: menuWidth + 'px'};
|
95 |
+
menuAnimation = {left: '0px'};
|
96 |
+
}
|
97 |
+
else {
|
98 |
+
bodyAnimation = {right: menuWidth + 'px'};
|
99 |
+
menuAnimation = {right: '0px'};
|
100 |
+
}
|
101 |
+
|
102 |
+
// Prepare page if container is body
|
103 |
+
if($body.is('body')){
|
104 |
+
scrollTop = $html.scrollTop();
|
105 |
+
$html.css('overflow-x', 'hidden').scrollTop(scrollTop);
|
106 |
+
}
|
107 |
+
|
108 |
+
// Open menu
|
109 |
+
if(displace){
|
110 |
+
$body.addClass('sidr-animating').css({
|
111 |
+
width: $body.width(),
|
112 |
+
position: 'absolute'
|
113 |
+
}).animate(bodyAnimation, speed, function() {
|
114 |
+
$(this).addClass(bodyClass);
|
115 |
+
});
|
116 |
+
}
|
117 |
+
else {
|
118 |
+
setTimeout(function() {
|
119 |
+
$(this).addClass(bodyClass);
|
120 |
+
}, speed);
|
121 |
+
}
|
122 |
+
$menu.css('display', 'block').animate(menuAnimation, speed, function() {
|
123 |
+
sidrMoving = false;
|
124 |
+
sidrOpened = name;
|
125 |
+
// Callback
|
126 |
+
if(typeof callback === 'function') {
|
127 |
+
callback(name);
|
128 |
+
}
|
129 |
+
$body.removeClass('sidr-animating');
|
130 |
+
});
|
131 |
+
|
132 |
+
// onOpen callback
|
133 |
+
onOpen();
|
134 |
+
}
|
135 |
+
// Close Sidr
|
136 |
+
else {
|
137 |
+
// Check if we can close it
|
138 |
+
if( !$menu.is(':visible') || sidrMoving ) {
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
// Lock sidr
|
143 |
+
sidrMoving = true;
|
144 |
+
|
145 |
+
// Right or left menu?
|
146 |
+
if(side === 'left') {
|
147 |
+
bodyAnimation = {left: 0};
|
148 |
+
menuAnimation = {left: '-' + menuWidth + 'px'};
|
149 |
+
}
|
150 |
+
else {
|
151 |
+
bodyAnimation = {right: 0};
|
152 |
+
menuAnimation = {right: '-' + menuWidth + 'px'};
|
153 |
+
}
|
154 |
+
|
155 |
+
// Close menu
|
156 |
+
if($body.is('body')){
|
157 |
+
scrollTop = $html.scrollTop();
|
158 |
+
$html.removeAttr('style').scrollTop(scrollTop);
|
159 |
+
}
|
160 |
+
$body.addClass('sidr-animating').animate(bodyAnimation, speed).removeClass(bodyClass);
|
161 |
+
$menu.animate(menuAnimation, speed, function() {
|
162 |
+
$menu.removeAttr('style').hide();
|
163 |
+
$body.removeAttr('style');
|
164 |
+
$('html').removeAttr('style');
|
165 |
+
sidrMoving = false;
|
166 |
+
sidrOpened = false;
|
167 |
+
// Callback
|
168 |
+
if(typeof callback === 'function') {
|
169 |
+
callback(name);
|
170 |
+
}
|
171 |
+
$body.removeClass('sidr-animating');
|
172 |
+
});
|
173 |
+
|
174 |
+
// onClose callback
|
175 |
+
onClose();
|
176 |
+
}
|
177 |
+
}
|
178 |
+
};
|
179 |
+
|
180 |
+
// Sidr public methods
|
181 |
+
var methods = {
|
182 |
+
open: function(name, callback) {
|
183 |
+
privateMethods.execute('open', name, callback);
|
184 |
+
},
|
185 |
+
close: function(name, callback) {
|
186 |
+
privateMethods.execute('close', name, callback);
|
187 |
+
},
|
188 |
+
toggle: function(name, callback) {
|
189 |
+
privateMethods.execute('toggle', name, callback);
|
190 |
+
},
|
191 |
+
// I made a typo, so I mantain this method to keep backward compatibilty with 1.1.1v and previous
|
192 |
+
toogle: function(name, callback) {
|
193 |
+
privateMethods.execute('toggle', name, callback);
|
194 |
+
}
|
195 |
+
};
|
196 |
+
|
197 |
+
$.sidr = function( method ) {
|
198 |
+
|
199 |
+
if ( methods[method] ) {
|
200 |
+
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
201 |
+
}
|
202 |
+
else if ( typeof method === 'function' || typeof method === 'string' || ! method ) {
|
203 |
+
return methods.toggle.apply( this, arguments );
|
204 |
+
}
|
205 |
+
else {
|
206 |
+
$.error( 'Method ' + method + ' does not exist on jQuery.sidr' );
|
207 |
+
}
|
208 |
+
|
209 |
+
};
|
210 |
+
|
211 |
+
$.fn.sidr = function( options ) {
|
212 |
+
|
213 |
+
var settings = $.extend( {
|
214 |
+
name : 'sidr', // Name for the 'sidr'
|
215 |
+
speed : 200, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
|
216 |
+
side : 'left', // Accepts 'left' or 'right'
|
217 |
+
source : null, // Override the source of the content.
|
218 |
+
renaming : true, // The ids and classes will be prepended with a prefix when loading existent content
|
219 |
+
body : 'body', // Page container selector,
|
220 |
+
displace: true, // Displace the body content or not
|
221 |
+
onOpen : function() {}, // Callback when sidr opened
|
222 |
+
onClose : function() {} // Callback when sidr closed
|
223 |
+
}, options);
|
224 |
+
|
225 |
+
var name = settings.name,
|
226 |
+
$sideMenu = $('#' + name);
|
227 |
+
|
228 |
+
// If the side menu do not exist create it
|
229 |
+
if( $sideMenu.length === 0 ) {
|
230 |
+
$sideMenu = $('<div />')
|
231 |
+
.attr('id', name)
|
232 |
+
.appendTo($('body'));
|
233 |
+
}
|
234 |
+
|
235 |
+
// Adding styles and options
|
236 |
+
$sideMenu
|
237 |
+
.addClass('sidr')
|
238 |
+
.addClass(settings.side)
|
239 |
+
.data({
|
240 |
+
speed : settings.speed,
|
241 |
+
side : settings.side,
|
242 |
+
body : settings.body,
|
243 |
+
displace : settings.displace,
|
244 |
+
onOpen : settings.onOpen,
|
245 |
+
onClose : settings.onClose
|
246 |
+
});
|
247 |
+
|
248 |
+
// The menu content
|
249 |
+
if(typeof settings.source === 'function') {
|
250 |
+
var newContent = settings.source(name);
|
251 |
+
privateMethods.loadContent($sideMenu, newContent);
|
252 |
+
}
|
253 |
+
else if(typeof settings.source === 'string' && privateMethods.isUrl(settings.source)) {
|
254 |
+
$.get(settings.source, function(data) {
|
255 |
+
privateMethods.loadContent($sideMenu, data);
|
256 |
+
});
|
257 |
+
}
|
258 |
+
else if(typeof settings.source === 'string') {
|
259 |
+
var htmlContent = '',
|
260 |
+
selectors = settings.source.split(',');
|
261 |
+
|
262 |
+
$.each(selectors, function(index, element) {
|
263 |
+
htmlContent += '<div class="sidr-inner">' + $(element).html() + '</div>';
|
264 |
+
});
|
265 |
+
|
266 |
+
// Renaming ids and classes
|
267 |
+
if(settings.renaming) {
|
268 |
+
var $htmlContent = $('<div />').html(htmlContent);
|
269 |
+
$htmlContent.find('*').each(function(index, element) {
|
270 |
+
var $element = $(element);
|
271 |
+
privateMethods.addPrefix($element);
|
272 |
+
});
|
273 |
+
htmlContent = $htmlContent.html();
|
274 |
+
}
|
275 |
+
privateMethods.loadContent($sideMenu, htmlContent);
|
276 |
+
}
|
277 |
+
else if(settings.source !== null) {
|
278 |
+
$.error('Invalid Sidr Source');
|
279 |
+
}
|
280 |
+
|
281 |
+
return this.each(function(){
|
282 |
+
var $this = $(this),
|
283 |
+
data = $this.data('sidr');
|
284 |
+
|
285 |
+
// If the plugin hasn't been initialized yet
|
286 |
+
if ( ! data ) {
|
287 |
+
|
288 |
+
$this.data('sidr', name);
|
289 |
+
if('ontouchstart' in document.documentElement) {
|
290 |
+
$this.bind('touchstart', function(e) {
|
291 |
+
var theEvent = e.originalEvent.touches[0];
|
292 |
+
this.touched = e.timeStamp;
|
293 |
+
});
|
294 |
+
$this.bind('touchend', function(e) {
|
295 |
+
var delta = Math.abs(e.timeStamp - this.touched);
|
296 |
+
if(delta < 200) {
|
297 |
+
e.preventDefault();
|
298 |
+
methods.toggle(name);
|
299 |
+
}
|
300 |
+
});
|
301 |
+
}
|
302 |
+
else {
|
303 |
+
$this.click(function(e) {
|
304 |
+
e.preventDefault();
|
305 |
+
methods.toggle(name);
|
306 |
+
});
|
307 |
+
}
|
308 |
+
}
|
309 |
+
});
|
310 |
+
};
|
311 |
+
|
312 |
+
})( jQuery );
|
js/jquery.transit.min.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery Transit - CSS3 transitions and transformations
|
3 |
+
* (c) 2011-2012 Rico Sta. Cruz <rico@ricostacruz.com>
|
4 |
+
* MIT Licensed.
|
5 |
+
*
|
6 |
+
* http://ricostacruz.com/jquery.transit
|
7 |
+
* http://github.com/rstacruz/jquery.transit
|
8 |
+
*/
|
9 |
+
(function(k){k.transit={version:"0.9.9",propertyMap:{marginLeft:"margin",marginRight:"margin",marginBottom:"margin",marginTop:"margin",paddingLeft:"padding",paddingRight:"padding",paddingBottom:"padding",paddingTop:"padding"},enabled:true,useTransitionEnd:false};var d=document.createElement("div");var q={};function b(v){if(v in d.style){return v}var u=["Moz","Webkit","O","ms"];var r=v.charAt(0).toUpperCase()+v.substr(1);if(v in d.style){return v}for(var t=0;t<u.length;++t){var s=u[t]+r;if(s in d.style){return s}}}function e(){d.style[q.transform]="";d.style[q.transform]="rotateY(90deg)";return d.style[q.transform]!==""}var a=navigator.userAgent.toLowerCase().indexOf("chrome")>-1;q.transition=b("transition");q.transitionDelay=b("transitionDelay");q.transform=b("transform");q.transformOrigin=b("transformOrigin");q.transform3d=e();var i={transition:"transitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",msTransition:"MSTransitionEnd"};var f=q.transitionEnd=i[q.transition]||null;for(var p in q){if(q.hasOwnProperty(p)&&typeof k.support[p]==="undefined"){k.support[p]=q[p]}}d=null;k.cssEase={_default:"ease","in":"ease-in",out:"ease-out","in-out":"ease-in-out",snap:"cubic-bezier(0,1,.5,1)",easeOutCubic:"cubic-bezier(.215,.61,.355,1)",easeInOutCubic:"cubic-bezier(.645,.045,.355,1)",easeInCirc:"cubic-bezier(.6,.04,.98,.335)",easeOutCirc:"cubic-bezier(.075,.82,.165,1)",easeInOutCirc:"cubic-bezier(.785,.135,.15,.86)",easeInExpo:"cubic-bezier(.95,.05,.795,.035)",easeOutExpo:"cubic-bezier(.19,1,.22,1)",easeInOutExpo:"cubic-bezier(1,0,0,1)",easeInQuad:"cubic-bezier(.55,.085,.68,.53)",easeOutQuad:"cubic-bezier(.25,.46,.45,.94)",easeInOutQuad:"cubic-bezier(.455,.03,.515,.955)",easeInQuart:"cubic-bezier(.895,.03,.685,.22)",easeOutQuart:"cubic-bezier(.165,.84,.44,1)",easeInOutQuart:"cubic-bezier(.77,0,.175,1)",easeInQuint:"cubic-bezier(.755,.05,.855,.06)",easeOutQuint:"cubic-bezier(.23,1,.32,1)",easeInOutQuint:"cubic-bezier(.86,0,.07,1)",easeInSine:"cubic-bezier(.47,0,.745,.715)",easeOutSine:"cubic-bezier(.39,.575,.565,1)",easeInOutSine:"cubic-bezier(.445,.05,.55,.95)",easeInBack:"cubic-bezier(.6,-.28,.735,.045)",easeOutBack:"cubic-bezier(.175, .885,.32,1.275)",easeInOutBack:"cubic-bezier(.68,-.55,.265,1.55)"};k.cssHooks["transit:transform"]={get:function(r){return k(r).data("transform")||new j()},set:function(s,r){var t=r;if(!(t instanceof j)){t=new j(t)}if(q.transform==="WebkitTransform"&&!a){s.style[q.transform]=t.toString(true)}else{s.style[q.transform]=t.toString()}k(s).data("transform",t)}};k.cssHooks.transform={set:k.cssHooks["transit:transform"].set};if(k.fn.jquery<"1.8"){k.cssHooks.transformOrigin={get:function(r){return r.style[q.transformOrigin]},set:function(r,s){r.style[q.transformOrigin]=s}};k.cssHooks.transition={get:function(r){return r.style[q.transition]},set:function(r,s){r.style[q.transition]=s}}}n("scale");n("translate");n("rotate");n("rotateX");n("rotateY");n("rotate3d");n("perspective");n("skewX");n("skewY");n("x",true);n("y",true);function j(r){if(typeof r==="string"){this.parse(r)}return this}j.prototype={setFromString:function(t,s){var r=(typeof s==="string")?s.split(","):(s.constructor===Array)?s:[s];r.unshift(t);j.prototype.set.apply(this,r)},set:function(s){var r=Array.prototype.slice.apply(arguments,[1]);if(this.setter[s]){this.setter[s].apply(this,r)}else{this[s]=r.join(",")}},get:function(r){if(this.getter[r]){return this.getter[r].apply(this)}else{return this[r]||0}},setter:{rotate:function(r){this.rotate=o(r,"deg")},rotateX:function(r){this.rotateX=o(r,"deg")},rotateY:function(r){this.rotateY=o(r,"deg")},scale:function(r,s){if(s===undefined){s=r}this.scale=r+","+s},skewX:function(r){this.skewX=o(r,"deg")},skewY:function(r){this.skewY=o(r,"deg")},perspective:function(r){this.perspective=o(r,"px")},x:function(r){this.set("translate",r,null)},y:function(r){this.set("translate",null,r)},translate:function(r,s){if(this._translateX===undefined){this._translateX=0}if(this._translateY===undefined){this._translateY=0}if(r!==null&&r!==undefined){this._translateX=o(r,"px")}if(s!==null&&s!==undefined){this._translateY=o(s,"px")}this.translate=this._translateX+","+this._translateY}},getter:{x:function(){return this._translateX||0},y:function(){return this._translateY||0},scale:function(){var r=(this.scale||"1,1").split(",");if(r[0]){r[0]=parseFloat(r[0])}if(r[1]){r[1]=parseFloat(r[1])}return(r[0]===r[1])?r[0]:r},rotate3d:function(){var t=(this.rotate3d||"0,0,0,0deg").split(",");for(var r=0;r<=3;++r){if(t[r]){t[r]=parseFloat(t[r])}}if(t[3]){t[3]=o(t[3],"deg")}return t}},parse:function(s){var r=this;s.replace(/([a-zA-Z0-9]+)\((.*?)\)/g,function(t,v,u){r.setFromString(v,u)})},toString:function(t){var s=[];for(var r in this){if(this.hasOwnProperty(r)){if((!q.transform3d)&&((r==="rotateX")||(r==="rotateY")||(r==="perspective")||(r==="transformOrigin"))){continue}if(r[0]!=="_"){if(t&&(r==="scale")){s.push(r+"3d("+this[r]+",1)")}else{if(t&&(r==="translate")){s.push(r+"3d("+this[r]+",0)")}else{s.push(r+"("+this[r]+")")}}}}}return s.join(" ")}};function m(s,r,t){if(r===true){s.queue(t)}else{if(r){s.queue(r,t)}else{t()}}}function h(s){var r=[];k.each(s,function(t){t=k.camelCase(t);t=k.transit.propertyMap[t]||k.cssProps[t]||t;t=c(t);if(k.inArray(t,r)===-1){r.push(t)}});return r}function g(s,v,x,r){var t=h(s);if(k.cssEase[x]){x=k.cssEase[x]}var w=""+l(v)+" "+x;if(parseInt(r,10)>0){w+=" "+l(r)}var u=[];k.each(t,function(z,y){u.push(y+" "+w)});return u.join(", ")}k.fn.transition=k.fn.transit=function(z,s,y,C){var D=this;var u=0;var w=true;if(typeof s==="function"){C=s;s=undefined}if(typeof y==="function"){C=y;y=undefined}if(typeof z.easing!=="undefined"){y=z.easing;delete z.easing}if(typeof z.duration!=="undefined"){s=z.duration;delete z.duration}if(typeof z.complete!=="undefined"){C=z.complete;delete z.complete}if(typeof z.queue!=="undefined"){w=z.queue;delete z.queue}if(typeof z.delay!=="undefined"){u=z.delay;delete z.delay}if(typeof s==="undefined"){s=k.fx.speeds._default}if(typeof y==="undefined"){y=k.cssEase._default}s=l(s);var E=g(z,s,y,u);var B=k.transit.enabled&&q.transition;var t=B?(parseInt(s,10)+parseInt(u,10)):0;if(t===0){var A=function(F){D.css(z);if(C){C.apply(D)}if(F){F()}};m(D,w,A);return D}var x={};var r=function(H){var G=false;var F=function(){if(G){D.unbind(f,F)}if(t>0){D.each(function(){this.style[q.transition]=(x[this]||null)})}if(typeof C==="function"){C.apply(D)}if(typeof H==="function"){H()}};if((t>0)&&(f)&&(k.transit.useTransitionEnd)){G=true;D.bind(f,F)}else{window.setTimeout(F,t)}D.each(function(){if(t>0){this.style[q.transition]=E}k(this).css(z)})};var v=function(F){this.offsetWidth;r(F)};m(D,w,v);return this};function n(s,r){if(!r){k.cssNumber[s]=true}k.transit.propertyMap[s]=q.transform;k.cssHooks[s]={get:function(v){var u=k(v).css("transit:transform");return u.get(s)},set:function(v,w){var u=k(v).css("transit:transform");u.setFromString(s,w);k(v).css({"transit:transform":u})}}}function c(r){return r.replace(/([A-Z])/g,function(s){return"-"+s.toLowerCase()})}function o(s,r){if((typeof s==="string")&&(!s.match(/^[\-0-9\.]+$/))){return s}else{return""+s+r}}function l(s){var r=s;if(k.fx.speeds[r]){r=k.fx.speeds[r]}return o(r,"ms")}k.transit.getTransitionValue=g})(jQuery);
|
10 |
+
(function($){$.fn.touchwipe=function(settings){var config={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(settings)$.extend(config,settings);this.each(function(){var startX;var startY;var isMoving=false;function cancelTouch(){this.removeEventListener('touchmove',onTouchMove);startX=null;isMoving=false}function onTouchMove(e){if(config.preventDefaultEvents){e.preventDefault()}if(isMoving){var x=e.touches[0].pageX;var y=e.touches[0].pageY;var dx=startX-x;var dy=startY-y;if(Math.abs(dx)>=config.min_move_x){cancelTouch();if(dx>0){config.wipeLeft()}else{config.wipeRight()}}else if(Math.abs(dy)>=config.min_move_y){cancelTouch();if(dy>0){config.wipeDown()}else{config.wipeUp()}}}}function onTouchStart(e){if(e.touches.length==1){startX=e.touches[0].pageX;startY=e.touches[0].pageY;isMoving=true;this.addEventListener('touchmove',onTouchMove,false)}}if('ontouchstart'in document.documentElement){this.addEventListener('touchstart',onTouchStart,false)}});return this}})(jQuery);
|
js/wprmenu.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
jQuery(document).ready(function(n){function e(){n(".wprmenu_parent_item_li").each(function(){var e=n(this),i=0,t=(e.find(".wprmenu_icon_par").first(),e.find("a.wprmenu_parent_item").first());i=s.hasClass("top")?window.innerWidth:a.innerWidth(),0==e.find(".wprmenu_clear").length&&t.after('<br class="wprmenu_clear"/>')})}function i(){s.find("ul.sub-menu").each(function(){var e=n(this),i=e.parent("li").find(".wprmenu_icon_par"),t=e.parent("li");e.is(":visible")&&e.slideUp(300),i.removeClass("wprmenu_par_opened"),t.removeClass("wprmenu_no_border_bottom")})}function t(){window.scrollBy(1,1),window.scrollBy(-1,-1),m=s.width(),s.is(":visible")&&s.hasClass("left")&&(l.css({left:m}),l.scrollLeft(0))}var r=n("#wprmenu_bar"),o=(r.outerHeight(!0),wprmenu.from_width),s=n("#wprmenu_menu"),a=n("#wprmenu_menu_ul"),d=s.find("a"),l=n("body"),u=(n("html"),300),w=(n("#wpadminbar"),r.length>0&&s.length>0?!0:!1),m=s.width(),p=(window.innerHeight<l.height()?l.height():window.innerHeight,window.innerWidth<l.width()?l.width():window.innerWidth);if(w){a.find("li").first().css({"border-top":"none"}),n(document).mouseup(function(e){s.is(e.target)||0!==s.has(e.target).length||s.is(":visible")&&n.sidr("close","wprmenu_menu")}),s.find("ul.sub-menu").each(function(){var e=n(this),i=e.prev("a"),t=i.parent("li").first();i.addClass("wprmenu_parent_item"),t.addClass("wprmenu_parent_item_li");i.before('<span class="wprmenu_icon wprmenu_icon_par icon_default"></span> ').find(".wprmenu_icon_par");e.hide()}),e(),n(".wprmenu_icon_par").on("click",function(){var e=n(this),i=e.parent("li").find("ul.sub-menu").first();i.slideToggle(300),e.toggleClass("wprmenu_par_opened"),e.parent("li").first().toggleClass("wprmenu_no_border_bottom")});var c=n("meta[name=viewport]");if(c=c.length?c:n('<meta name="viewport" />').appendTo("head"),"no"==wprmenu.zooming?c.attr("content","user-scalable=no, width=device-width, maximum-scale=1, minimum-scale=1"):c.attr("content","user-scalable=yes, width=device-width, initial-scale=1.0, minimum-scale=1"),n.browser.mozilla?screen.addEventListener("orientationchange",function(){t()}):window.addEventListener("orientationchange",t,!1),s.hasClass("left")||s.hasClass("right")){var h=s.hasClass("left")?"left":"right";r.sidr({name:"wprmenu_menu",side:h,speed:u,onOpen:function(){r.addClass("menu_is_opened")},onClose:function(){r.removeClass("menu_is_opened"),i()}}),d.on("click",function(){n.sidr("close","wprmenu_menu")}),"no"!=wprmenu.swipe&&n("body").touchwipe({wipeLeft:function(){n.sidr("close","wprmenu_menu")},wipeRight:function(){n.sidr("open","wprmenu_menu")},min_move_x:60,min_move_y:60,preventDefaultEvents:!1}),n(window).resize(function(){p=window.innerWidth<l.width()?l.width():window.innerWidth,p>o&&s.is(":visible")&&n.sidr("close","wprmenu_menu")})}else s.hasClass("top")&&(l.prepend(s),r.on("click",function(){n("html, body").animate({scrollTop:0},u),i(),s.stop(!0,!1).slideToggle(u)}),d.on("click",function(e){e.preventDefault();var i=n(this).attr("href");s.slideUp(u,function(){window.location.href=i})}),n(window).resize(function(){p=window.innerWidth<l.width()?l.width():window.innerWidth,p>o&&s.is(":visible")&&(i(),s.slideUp(u,function(){}))}))}});
|
readme.txt
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== WP Responsive Menu ===
|
2 |
+
Contributors: sagarseth9
|
3 |
+
Tags: Wordpress Responsive Menu, Genesis responsive menu, Genesis Mobile Menu, Thesis Mobile Menu, Thesis Responsive Menu, Mobile Menu, Responsive Menu Plugin, WP Responsive Menu, Wordpress mobile menu
|
4 |
+
Requires at least: 3.4
|
5 |
+
Tested up to: 3.9.2
|
6 |
+
Stable tag: 2.0
|
7 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=sagar.seth9@gmail.com&item_name=WP%20Responsive%20Menu&return=http://magnigenie.com
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
WP Responsive Menu turns your WordPress menu to a highy customizable sliding responsive menu.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
WordPress Responsive Menu plugin will help you to get a cool, highly customizable mobile menu plugin. Using this plugin you can easily convert your wordpress menu to a great, elegant looking sliding menu for all mobile devices.
|
16 |
+
|
17 |
+
= Features: =
|
18 |
+
* Fully responsive and works on all type of mobile devices.
|
19 |
+
* Easily integrates with wordpress menu system.
|
20 |
+
* Easy to use admin interface.
|
21 |
+
* Easily replace your menu with responsive menu on mobile devices.
|
22 |
+
* Choose your custom colors to match your theme.
|
23 |
+
* Option to open menu from top, left and right.
|
24 |
+
* Easily add your website logo the the menu.
|
25 |
+
* Easily hide unwanted elements on mobile devices.
|
26 |
+
* Supports swipe gestures.
|
27 |
+
* Enable/Disable pinch to zoom feature.
|
28 |
+
* Works perfectly on all devices/platforms.
|
29 |
+
* Add a custom search bar to your menu.
|
30 |
+
|
31 |
+
This plugin works out of box with any theme frameworks like genesis or thesis and it also works fine with multisite setups.
|
32 |
+
|
33 |
+
= Important Notes =
|
34 |
+
If you are looking for more options then [check out the pro version](http://magnigenie.com/wp-responsive-menu-pro/) of the plugin.
|
35 |
+
|
36 |
+
This plugin is based on [sidr jquery menu plugin](https://github.com/artberri/sidr).
|
37 |
+
|
38 |
+
For Quick support please check WP Responsive menu [Support forum](http://magnigenie.com/support/queries/wp-responsive-menu/).
|
39 |
+
|
40 |
+
If you have any suggestions for a new plugin, feel free to email me at sagar@magnigenie.com.
|
41 |
+
|
42 |
+
Check out [the demo](http://magnigenie.com/wp-responsive-menu-mobile-menu-plugin-wordpress/)
|
43 |
+
|
44 |
+
== Installation ==
|
45 |
+
|
46 |
+
1. Go to your admin area and select Plugins -> Add new from the menu.
|
47 |
+
2. Search for "WP Responsive Menu".
|
48 |
+
3. Click install.
|
49 |
+
4. Click activate.
|
50 |
+
5. Go to Settings > WP Responsive Menu and start playing with the configurations.
|
51 |
+
|
52 |
+
== Screenshots ==
|
53 |
+
|
54 |
+
1. Check out [the demo](http://magnigenie.com/wp-responsive-menu-mobile-menu-plugin-wordpress/)
|
55 |
+
|
56 |
+
== ChangeLog ==
|
57 |
+
|
58 |
+
= Version 2.0 =
|
59 |
+
|
60 |
+
* Completely removed plugin settings page and used options framework for admin settings of the plugin.
|
61 |
+
* Fixed admin bar issue when user is logged in.
|
62 |
+
* Add option to disable swipe.
|
63 |
+
* Added admin option to add search box to menu.
|
64 |
+
|
65 |
+
= Version 1.0 =
|
66 |
+
|
67 |
+
* Initial public release.
|
68 |
+
|
69 |
+
== Upgrade Notice ==
|
70 |
+
|
71 |
+
= Version 2.0 =
|
72 |
+
|
73 |
+
* As I have updated the plugin options panel so there might be few settings problems. If you are having any such problem try to check the plugin settings and configure it accordingly.
|
screenshot-1.png
ADDED
Binary file
|
wp-responsive-menu.php
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: WP Responsive Menu
|
4 |
+
Plugin URI: http://magnigenie.com/wp-responsive-menu-mobile-menu-plugin-wordpress/
|
5 |
+
Description: WP Responsive menu is a mobile menu plugin which comes with 1 click installation and has lots of admin option to customize the plugin as per your needs.
|
6 |
+
Version: 2.0
|
7 |
+
Author: Nirmal Ram
|
8 |
+
Author URI: http://magnigenie.com
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* Enable Localization
|
16 |
+
*
|
17 |
+
*/
|
18 |
+
load_plugin_textdomain('wprmenu', false, basename( dirname( __FILE__ ) ) . '/lang' );
|
19 |
+
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
* Add admin settings
|
23 |
+
*
|
24 |
+
*/
|
25 |
+
define( 'WPR_OPTIONS_FRAMEWORK_DIRECTORY', plugins_url( '/inc/', __FILE__ ) );
|
26 |
+
define( 'WPR_OPTIONS_FRAMEWORK_PATH', dirname( __FILE__ ) . '/inc/' );
|
27 |
+
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
|
28 |
+
|
29 |
+
// add required js/css files
|
30 |
+
add_action( 'wp_enqueue_scripts', 'wprmenu_enqueue_scripts' );
|
31 |
+
|
32 |
+
function wprmenu_enqueue_scripts() {
|
33 |
+
$options = get_option('wprmenu_options');
|
34 |
+
wp_enqueue_style( 'wprmenu.css' , plugins_url('css/wprmenu.css', __FILE__) );
|
35 |
+
wp_enqueue_script('jquery.transit', plugins_url( '/js/jquery.transit.min.js', __FILE__ ), array( 'jquery' ));
|
36 |
+
wp_enqueue_script('sidr', plugins_url( '/js/jquery.sidr.js', __FILE__ ), array( 'jquery' ));
|
37 |
+
wp_enqueue_script('wprmenu.js', plugins_url( '/js/wprmenu.js', __FILE__ ), array( 'jquery' ));
|
38 |
+
$wpr_options = array( 'zooming' => $options['zooming'],'from_width' => $options['from_width'],'swipe' => $options['swipe'] );
|
39 |
+
wp_localize_script( 'wprmenu.js', 'wprmenu', $wpr_options );
|
40 |
+
}
|
41 |
+
|
42 |
+
function wpr_search_form() {
|
43 |
+
return '<form role="search" method="get" class="wpr-search-form" action="' . site_url() . '"><label><input type="search" class="wpr-search-field" placeholder="Search ..." value="" name="s" title="Search for:"></label></form>';
|
44 |
+
}
|
45 |
+
|
46 |
+
add_action('wp_footer', 'wprmenu_menu', 100);
|
47 |
+
function wprmenu_menu() {
|
48 |
+
$options = get_option('wprmenu_options');
|
49 |
+
if($options['enabled']) :
|
50 |
+
?>
|
51 |
+
<div id="wprmenu_bar" class="wprmenu_bar">
|
52 |
+
<div class="wprmenu_icon">
|
53 |
+
<span class="wprmenu_ic_1"></span>
|
54 |
+
<span class="wprmenu_ic_2"></span>
|
55 |
+
<span class="wprmenu_ic_3"></span>
|
56 |
+
</div>
|
57 |
+
<div class="menu_title">
|
58 |
+
<?php echo $options['bar_title'] ?>
|
59 |
+
<?php if($options['bar_logo']) echo '<img class="bar_logo" src="'.$options['bar_logo'].'"/>' ?>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
|
63 |
+
<div id="wprmenu_menu" class="wprmenu_levels <?php echo $options['position'] ?> wprmenu_custom_icons">
|
64 |
+
<?php if( $options['search_box'] == 'above_menu' ) { ?>
|
65 |
+
<div class="wpr_search">
|
66 |
+
<?php echo wpr_search_form(); ?>
|
67 |
+
</div>
|
68 |
+
<?php } ?>
|
69 |
+
<ul id="wprmenu_menu_ul">
|
70 |
+
<?php
|
71 |
+
$menus = get_terms('nav_menu',array('hide_empty'=>false));
|
72 |
+
if($menus) : foreach($menus as $m) :
|
73 |
+
if($m->term_id == $options['menu']) $menu = $m;
|
74 |
+
endforeach; endif;
|
75 |
+
if(is_object($menu)) :
|
76 |
+
wp_nav_menu( array('menu'=>$menu->name,'container'=>false,'items_wrap'=>'%3$s'));
|
77 |
+
endif;
|
78 |
+
?>
|
79 |
+
</ul>
|
80 |
+
<?php if( $options['search_box'] == 'below_menu' ) { ?>
|
81 |
+
<div class="wpr_search">
|
82 |
+
<?php echo wpr_search_form(); ?>
|
83 |
+
</div>
|
84 |
+
<?php } ?>
|
85 |
+
</div>
|
86 |
+
<?php
|
87 |
+
endif;
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
function wprmenu_header_styles() {
|
92 |
+
$options = get_option('wprmenu_options');
|
93 |
+
if($options['enabled']) :
|
94 |
+
?>
|
95 |
+
<style id="wprmenu_css" type="text/css" >
|
96 |
+
/* apply appearance settings */
|
97 |
+
#wprmenu_bar {
|
98 |
+
background: <?php echo $options["bar_bgd"] ?>;
|
99 |
+
}
|
100 |
+
#wprmenu_bar .menu_title, #wprmenu_bar .wprmenu_icon_menu {
|
101 |
+
color: <?php echo $options["bar_color"] ?>;
|
102 |
+
}
|
103 |
+
#wprmenu_menu {
|
104 |
+
background: <?php echo $options["menu_bgd"] ?>!important;
|
105 |
+
}
|
106 |
+
#wprmenu_menu.wprmenu_levels ul li {
|
107 |
+
border-bottom:1px solid <?php echo $options["menu_border_bottom"] ?>;
|
108 |
+
border-top:1px solid <?php echo $options["menu_border_top"] ?>;
|
109 |
+
}
|
110 |
+
#wprmenu_menu ul li a {
|
111 |
+
color: <?php echo $options["menu_color"] ?>;
|
112 |
+
}
|
113 |
+
#wprmenu_menu ul li a:hover {
|
114 |
+
color: <?php echo $options["menu_color_hover"] ?>;
|
115 |
+
}
|
116 |
+
#wprmenu_menu.wprmenu_levels a.wprmenu_parent_item {
|
117 |
+
border-left:1px solid <?php echo $options["menu_border_top"] ?>;
|
118 |
+
}
|
119 |
+
#wprmenu_menu .wprmenu_icon_par {
|
120 |
+
color: <?php echo $options["menu_color"] ?>;
|
121 |
+
}
|
122 |
+
#wprmenu_menu .wprmenu_icon_par:hover {
|
123 |
+
color: <?php echo $options["menu_color_hover"] ?>;
|
124 |
+
}
|
125 |
+
#wprmenu_menu.wprmenu_levels ul li ul {
|
126 |
+
border-top:1px solid <?php echo $options["menu_border_bottom"] ?>;
|
127 |
+
}
|
128 |
+
#wprmenu_bar .wprmenu_icon span {
|
129 |
+
background: <?php echo $options["menu_icon_color"] ?>;
|
130 |
+
}
|
131 |
+
<?php
|
132 |
+
//when option "hide bottom borders is on...
|
133 |
+
if($options["menu_border_bottom_show"] === 'no') { ?>
|
134 |
+
#wprmenu_menu, #wprmenu_menu ul, #wprmenu_menu li {
|
135 |
+
border-bottom:none!important;
|
136 |
+
}
|
137 |
+
#wprmenu_menu.wprmenu_levels > ul {
|
138 |
+
border-bottom:1px solid <?php echo $options["menu_border_top"] ?>!important;
|
139 |
+
}
|
140 |
+
.wprmenu_no_border_bottom {
|
141 |
+
border-bottom:none!important;
|
142 |
+
}
|
143 |
+
#wprmenu_menu.wprmenu_levels ul li ul {
|
144 |
+
border-top:none!important;
|
145 |
+
}
|
146 |
+
<?php } ?>
|
147 |
+
|
148 |
+
#wprmenu_menu.left {
|
149 |
+
width:<?php echo $options["how_wide"] ?>%;
|
150 |
+
left: -<?php echo $options["how_wide"] ?>%;
|
151 |
+
right: auto;
|
152 |
+
}
|
153 |
+
#wprmenu_menu.right {
|
154 |
+
width:<?php echo $options["how_wide"] ?>%;
|
155 |
+
right: -<?php echo $options["how_wide"] ?>%;
|
156 |
+
left: auto;
|
157 |
+
}
|
158 |
+
|
159 |
+
|
160 |
+
<?php if($options["nesting_icon"] != '') : ?>
|
161 |
+
#wprmenu_menu .wprmenu_icon:before {
|
162 |
+
font-family: 'fontawesome'!important;
|
163 |
+
}
|
164 |
+
<?php endif; ?>
|
165 |
+
|
166 |
+
<?php if($options["menu_symbol_pos"] == 'right') : ?>
|
167 |
+
#wprmenu_bar .wprmenu_icon {
|
168 |
+
float: <?php echo $options["menu_symbol_pos"] ?>!important;
|
169 |
+
margin-right:0px!important;
|
170 |
+
}
|
171 |
+
#wprmenu_bar .bar_logo {
|
172 |
+
pading-left: 0px;
|
173 |
+
}
|
174 |
+
<?php endif; ?>
|
175 |
+
/* show the bar and hide othere navigation elements */
|
176 |
+
@media only screen and (max-width: <?php echo $options["from_width"] ?>px) {
|
177 |
+
html { padding-top: 42px!important; }
|
178 |
+
#wprmenu_bar { display: block!important; }
|
179 |
+
div#wpadminbar { position: fixed; }
|
180 |
+
<?php
|
181 |
+
if( $options['hide'] != '' ) {
|
182 |
+
echo $options['hide'];
|
183 |
+
echo ' { display:none!important; }';
|
184 |
+
}
|
185 |
+
?>
|
186 |
+
}
|
187 |
+
</style>
|
188 |
+
<?php
|
189 |
+
endif;
|
190 |
+
}
|
191 |
+
add_action('wp_head', 'wprmenu_header_styles');
|