Restrict Widgets - Version 1.0.0

Version Description

Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Restrict Widgets
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

css/chosen.css ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @group Base */
2
+ .chzn-container {
3
+ font-size: 13px;
4
+ position: relative;
5
+ display: inline-block;
6
+ zoom: 1;
7
+ *display: inline;
8
+ }
9
+ .chzn-container .chzn-drop {
10
+ background: #fff;
11
+ border: 1px solid #aaa;
12
+ border-top: 0;
13
+ position: absolute;
14
+ top: 29px;
15
+ left: 0;
16
+ -webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
17
+ -moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
18
+ box-shadow : 0 4px 5px rgba(0,0,0,.15);
19
+ z-index: 1010;
20
+ }
21
+ /* @end */
22
+
23
+ /* @group Single Chosen */
24
+ .chzn-container-single .chzn-single {
25
+ background-color: #ffffff;
26
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0 );
27
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
28
+ background-image: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
29
+ background-image: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
30
+ background-image: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
31
+ background-image: linear-gradient(#ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
32
+ -webkit-border-radius: 5px;
33
+ -moz-border-radius : 5px;
34
+ border-radius : 5px;
35
+ -moz-background-clip : padding;
36
+ -webkit-background-clip: padding-box;
37
+ background-clip : padding-box;
38
+ border: 1px solid #aaaaaa;
39
+ -webkit-box-shadow: 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
40
+ -moz-box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
41
+ box-shadow : 0 0 3px #ffffff inset, 0 1px 1px rgba(0,0,0,0.1);
42
+ display: block;
43
+ overflow: hidden;
44
+ white-space: nowrap;
45
+ position: relative;
46
+ height: 23px;
47
+ line-height: 24px;
48
+ padding: 0 0 0 8px;
49
+ color: #444444;
50
+ text-decoration: none;
51
+ }
52
+ .chzn-container-single .chzn-default {
53
+ color: #999;
54
+ }
55
+ .chzn-container-single .chzn-single span {
56
+ margin-right: 26px;
57
+ display: block;
58
+ overflow: hidden;
59
+ white-space: nowrap;
60
+ -o-text-overflow: ellipsis;
61
+ -ms-text-overflow: ellipsis;
62
+ text-overflow: ellipsis;
63
+ }
64
+ .chzn-container-single .chzn-single abbr {
65
+ display: block;
66
+ position: absolute;
67
+ right: 26px;
68
+ top: 6px;
69
+ width: 12px;
70
+ height: 12px;
71
+ font-size: 1px;
72
+ background: url('chosen-sprite.png') -42px 1px no-repeat;
73
+ }
74
+ .chzn-container-single .chzn-single abbr:hover {
75
+ background-position: -42px -10px;
76
+ }
77
+ .chzn-container-single.chzn-disabled .chzn-single abbr:hover {
78
+ background-position: -42px -10px;
79
+ }
80
+ .chzn-container-single .chzn-single div {
81
+ position: absolute;
82
+ right: 0;
83
+ top: 0;
84
+ display: block;
85
+ height: 100%;
86
+ width: 18px;
87
+ }
88
+ .chzn-container-single .chzn-single div b {
89
+ background: url('chosen-sprite.png') no-repeat 0px 2px;
90
+ display: block;
91
+ width: 100%;
92
+ height: 100%;
93
+ }
94
+ .chzn-container-single .chzn-search {
95
+ padding: 3px 4px;
96
+ position: relative;
97
+ margin: 0;
98
+ white-space: nowrap;
99
+ z-index: 1010;
100
+ }
101
+ .chzn-container-single .chzn-search input {
102
+ background: #fff url('chosen-sprite.png') no-repeat 100% -20px;
103
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
104
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
105
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
106
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
107
+ background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
108
+ margin: 1px 0;
109
+ padding: 4px 20px 4px 5px;
110
+ outline: 0;
111
+ border: 1px solid #aaa;
112
+ font-family: sans-serif;
113
+ font-size: 1em;
114
+ }
115
+ .chzn-container-single .chzn-drop {
116
+ -webkit-border-radius: 0 0 4px 4px;
117
+ -moz-border-radius : 0 0 4px 4px;
118
+ border-radius : 0 0 4px 4px;
119
+ -moz-background-clip : padding;
120
+ -webkit-background-clip: padding-box;
121
+ background-clip : padding-box;
122
+ }
123
+ /* @end */
124
+
125
+ .chzn-container-single-nosearch .chzn-search input {
126
+ position: absolute;
127
+ left: -9000px;
128
+ }
129
+
130
+ /* @group Multi Chosen */
131
+ .chzn-container-multi .chzn-choices {
132
+ background-color: #fff;
133
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
134
+ background-image: -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
135
+ background-image: -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
136
+ background-image: -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
137
+ background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
138
+ border: 1px solid #aaa;
139
+ margin: 0;
140
+ padding: 0;
141
+ cursor: text;
142
+ overflow: hidden;
143
+ height: auto !important;
144
+ height: 1%;
145
+ position: relative;
146
+ }
147
+ .chzn-container-multi .chzn-choices li {
148
+ float: left;
149
+ list-style: none;
150
+ }
151
+ .chzn-container-multi .chzn-choices .search-field {
152
+ white-space: nowrap;
153
+ margin: 0;
154
+ padding: 0;
155
+ }
156
+ .chzn-container-multi .chzn-choices .search-field input {
157
+ color: #666;
158
+ background: transparent !important;
159
+ border: 0 !important;
160
+ font-family: sans-serif;
161
+ font-size: 100%;
162
+ height: 15px;
163
+ padding: 5px;
164
+ margin: 1px 0;
165
+ outline: 0;
166
+ -webkit-box-shadow: none;
167
+ -moz-box-shadow : none;
168
+ box-shadow : none;
169
+ }
170
+ .chzn-container-multi .chzn-choices .search-field .default {
171
+ color: #999;
172
+ }
173
+ .chzn-container-multi .chzn-choices .search-choice {
174
+ -webkit-border-radius: 3px;
175
+ -moz-border-radius : 3px;
176
+ border-radius : 3px;
177
+ -moz-background-clip : padding;
178
+ -webkit-background-clip: padding-box;
179
+ background-clip : padding-box;
180
+ background-color: #e4e4e4;
181
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
182
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
183
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
184
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
185
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
186
+ background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
187
+ -webkit-box-shadow: 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
188
+ -moz-box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
189
+ box-shadow : 0 0 2px #ffffff inset, 0 1px 0 rgba(0,0,0,0.05);
190
+ color: #333;
191
+ border: 1px solid #aaaaaa;
192
+ line-height: 13px;
193
+ padding: 3px 20px 3px 5px;
194
+ margin: 3px 0 3px 5px;
195
+ position: relative;
196
+ cursor: default;
197
+ }
198
+ .chzn-container-multi .chzn-choices .search-choice.search-choice-disabled {
199
+ background-color: #e4e4e4;
200
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee', GradientType=0 );
201
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
202
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
203
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
204
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
205
+ background-image: -ms-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
206
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
207
+ color: #666;
208
+ border: 1px solid #cccccc;
209
+ padding-right: 5px;
210
+ }
211
+ .chzn-container-multi .chzn-choices .search-choice-focus {
212
+ background: #d4d4d4;
213
+ }
214
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
215
+ display: block;
216
+ position: absolute;
217
+ right: 3px;
218
+ top: 4px;
219
+ width: 12px;
220
+ height: 12px;
221
+ font-size: 1px;
222
+ background: url('chosen-sprite.png') -42px 1px no-repeat;
223
+ }
224
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
225
+ background-position: -42px -10px;
226
+ }
227
+ .chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
228
+ background-position: -42px -10px;
229
+ }
230
+ /* @end */
231
+
232
+ /* @group Results */
233
+ .chzn-container .chzn-results {
234
+ margin: 0 4px 4px 0;
235
+ max-height: 240px;
236
+ padding: 0 0 0 4px;
237
+ position: relative;
238
+ overflow-x: hidden;
239
+ overflow-y: auto;
240
+ -webkit-overflow-scrolling: touch;
241
+ }
242
+ .chzn-container-multi .chzn-results {
243
+ margin: -1px 0 0;
244
+ padding: 0;
245
+ }
246
+ .chzn-container .chzn-results li {
247
+ display: none;
248
+ line-height: 15px;
249
+ padding: 5px 6px;
250
+ margin: 0;
251
+ list-style: none;
252
+ }
253
+ .chzn-container .chzn-results .active-result {
254
+ cursor: pointer;
255
+ display: list-item;
256
+ }
257
+ .chzn-container .chzn-results .highlighted {
258
+ background-color: #3875d7;
259
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3875d7', endColorstr='#2a62bc', GradientType=0 );
260
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
261
+ background-image: -webkit-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
262
+ background-image: -moz-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
263
+ background-image: -o-linear-gradient(top, #3875d7 20%, #2a62bc 90%);
264
+ background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
265
+ color: #fff;
266
+ }
267
+ .chzn-container .chzn-results li em {
268
+ background: #feffde;
269
+ font-style: normal;
270
+ }
271
+ .chzn-container .chzn-results .highlighted em {
272
+ background: transparent;
273
+ }
274
+ .chzn-container .chzn-results .no-results {
275
+ background: #f4f4f4;
276
+ display: list-item;
277
+ }
278
+ .chzn-container .chzn-results .group-result {
279
+ cursor: default;
280
+ color: #999;
281
+ font-weight: bold;
282
+ }
283
+ .chzn-container .chzn-results .group-option {
284
+ padding-left: 15px;
285
+ }
286
+ .chzn-container-multi .chzn-drop .result-selected {
287
+ display: none;
288
+ }
289
+ .chzn-container .chzn-results-scroll {
290
+ background: white;
291
+ margin: 0 4px;
292
+ position: absolute;
293
+ text-align: center;
294
+ width: 321px; /* This should by dynamic with js */
295
+ z-index: 1;
296
+ }
297
+ .chzn-container .chzn-results-scroll span {
298
+ display: inline-block;
299
+ height: 17px;
300
+ text-indent: -5000px;
301
+ width: 9px;
302
+ }
303
+ .chzn-container .chzn-results-scroll-down {
304
+ bottom: 0;
305
+ }
306
+ .chzn-container .chzn-results-scroll-down span {
307
+ background: url('chosen-sprite.png') no-repeat -4px -3px;
308
+ }
309
+ .chzn-container .chzn-results-scroll-up span {
310
+ background: url('chosen-sprite.png') no-repeat -22px -3px;
311
+ }
312
+ /* @end */
313
+
314
+ /* @group Active */
315
+ .chzn-container-active .chzn-single {
316
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
317
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
318
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
319
+ border: 1px solid #5897fb;
320
+ }
321
+ .chzn-container-active .chzn-single-with-drop {
322
+ border: 1px solid #aaa;
323
+ -webkit-box-shadow: 0 1px 0 #fff inset;
324
+ -moz-box-shadow : 0 1px 0 #fff inset;
325
+ box-shadow : 0 1px 0 #fff inset;
326
+ background-color: #eee;
327
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0 );
328
+ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
329
+ background-image: -webkit-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
330
+ background-image: -moz-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
331
+ background-image: -o-linear-gradient(top, #eeeeee 20%, #ffffff 80%);
332
+ background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
333
+ -webkit-border-bottom-left-radius : 0;
334
+ -webkit-border-bottom-right-radius: 0;
335
+ -moz-border-radius-bottomleft : 0;
336
+ -moz-border-radius-bottomright: 0;
337
+ border-bottom-left-radius : 0;
338
+ border-bottom-right-radius: 0;
339
+ }
340
+ .chzn-container-active .chzn-single-with-drop div {
341
+ background: transparent;
342
+ border-left: none;
343
+ }
344
+ .chzn-container-active .chzn-single-with-drop div b {
345
+ background-position: -18px 2px;
346
+ }
347
+ .chzn-container-active .chzn-choices {
348
+ -webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
349
+ -moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
350
+ box-shadow : 0 0 5px rgba(0,0,0,.3);
351
+ border: 1px solid #5897fb;
352
+ }
353
+ .chzn-container-active .chzn-choices .search-field input {
354
+ color: #111 !important;
355
+ }
356
+ /* @end */
357
+
358
+ /* @group Disabled Support */
359
+ .chzn-disabled {
360
+ cursor: default;
361
+ opacity:0.5 !important;
362
+ }
363
+ .chzn-disabled .chzn-single {
364
+ cursor: default;
365
+ }
366
+ .chzn-disabled .chzn-choices .search-choice .search-choice-close {
367
+ cursor: default;
368
+ }
369
+
370
+ /* @group Right to Left */
371
+ .chzn-rtl { text-align: right; }
372
+ .chzn-rtl .chzn-single { padding: 0 8px 0 0; overflow: visible; }
373
+ .chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; direction: rtl; }
374
+
375
+ .chzn-rtl .chzn-single div { left: 3px; right: auto; }
376
+ .chzn-rtl .chzn-single abbr {
377
+ left: 26px;
378
+ right: auto;
379
+ }
380
+ .chzn-rtl .chzn-choices .search-field input { direction: rtl; }
381
+ .chzn-rtl .chzn-choices li { float: right; }
382
+ .chzn-rtl .chzn-choices .search-choice { padding: 3px 5px 3px 19px; margin: 3px 5px 3px 0; }
383
+ .chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 4px; right: auto; }
384
+ .chzn-rtl.chzn-container-single .chzn-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
385
+ .chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 15px; }
386
+ .chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
387
+ .chzn-rtl .chzn-search input {
388
+ background: #fff url('chosen-sprite.png') no-repeat -30px -20px;
389
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 0 0, 0 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
390
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
391
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
392
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
393
+ background: url('chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
394
+ padding: 4px 5px 4px 20px;
395
+ direction: rtl;
396
+ }
397
+ .chzn-container-single.chzn-rtl .chzn-single div b {
398
+ background-position: 6px 2px;
399
+ }
400
+ .chzn-container-single.chzn-rtl .chzn-single-with-drop div b {
401
+ background-position: -12px 2px;
402
+ }
403
+ /* @end */
404
+
405
+ /* @group Retina compatibility */
406
+ @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
407
+ .chzn-rtl .chzn-search input, .chzn-container-single .chzn-single abbr, .chzn-container-single .chzn-single div b, .chzn-container-single .chzn-search input, .chzn-container-multi .chzn-choices .search-choice .search-choice-close, .chzn-container .chzn-results-scroll-down span, .chzn-container .chzn-results-scroll-up span {
408
+ background-image: url('chosen-sprite@2x.png') !important;
409
+ background-repeat: no-repeat !important;
410
+ background-size: 52px 37px !important;
411
+ }
412
+ }
413
+ /* @end */
css/style.css ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .chzn-container-multi .chzn-choices .search-choice .search-choice-close {
2
+ background: url("../images/chosen-sprite.png") no-repeat scroll -42px 1px transparent !important;
3
+ outline: none;
4
+ }
5
+ .restrict-widgets .restrict-widgets-select, .restrict-widgets .restrict-widgets-hide {
6
+ width:100%;
7
+ }
8
+ .widget .widget-inside p.restrict-widgets-display-label { margin-bottom:3px; }
9
+ .restrict-widgets-select-div { clear:both; }
10
+ .restrict-widgets-hide-div { clear:both; margin-bottom:3px; }
11
+ .restrict-widgets .chzn-container { min-width:100%; }
12
+ .restrict-widgets .chzn-container-multi .chzn-choices {
13
+ -webkit-border-radius: 3px;
14
+ -moz-border-radius : 3px;
15
+ border-radius : 3px;
16
+ }
17
+ .restrict-widgets .chzn-container-multi .chzn-choices .search-field input { height:24px; }
18
+ .restrict-widgets .chzn-choices { border:1px solid #dfdfdf; padding: 0 5px 0 2px; min-height:26px; }
19
+ .restrict-widgets .chzn-container-active .chzn-choices { border:1px solid #aaa; -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); -moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); }
20
+ .restrict-widgets .chzn-drop { min-width: 100%;}
21
+ .restrict-widgets .chzn-container-multi .chzn-choices { background:#fff; }
22
+ .restrict-widgets .chzn-container-multi .chzn-choices .search-choice {
23
+ background: -moz-linear-gradient(top, #f9f9f9 0%, #ececec 100%); /* FF3.6+ */
24
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f9f9f9), color-stop(100%,#ececec)); /* Chrome,Safari4+ */
25
+ background: -webkit-linear-gradient(top, #f9f9f9 0%,#ececec 100%); /* Chrome10+,Safari5.1+ */
26
+ background: -o-linear-gradient(top, #f9f9f9 0%,#ececec 100%); /* Opera11.10+ */
27
+ background: -ms-linear-gradient(top, #f9f9f9 0%,#ececec 100%); /* IE10+ */
28
+ background: linear-gradient(top, #f9f9f9 0%,#ececec 100%); /* W3C */
29
+ -webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset;
30
+ -moz-box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset;
31
+ box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset;
32
+ text-shadow: 0 1px 0 #fff;
33
+ border: 1px solid #bbb;
34
+ font-size:12px;
35
+ font-weight: normal;
36
+ color: #333333;
37
+ height: 18px;
38
+ line-height: 18px;
39
+ padding: 0 20px 0 8px;
40
+ }
41
+ .restrict-widgets .chzn-container-single .chzn-single div b {
42
+ background: url("../images/chosen-sprite.png") no-repeat scroll 0 2px transparent;
43
+ }
44
+ .restrict-widgets .chzn-container-multi .chzn-choices .search-choice.search-choice-disabled {
45
+ padding: 0 8px;
46
+ }
47
+ .restrict-widgets .chzn-single {
48
+ -webkit-border-radius: 3px;
49
+ -moz-border-radius: 3px;
50
+ border-radius: 3px;
51
+ border: 1px solid #dfdfdf;
52
+ background: #fff;
53
+ -webkit-box-shadow: none;
54
+ -moz-box-shadow: none;
55
+ box-shadow: none;
56
+ cursor: default;
57
+ outline: none;
58
+ }
59
+ .restrict-widgets .chzn-container-active .chzn-single { border:1px solid #aaa; -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); -moz-box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1); }
60
+
61
+ #options_available_widgets_chzn, #options_widgets_selection_chzn, #options_widgets_sidebars_chzn {
62
+ margin: 0 20px 0 0;
63
+ }
64
+ #widgets-options input[type="text"] {
65
+ line-height:20px;
66
+ }
67
+ #widgets-options select {
68
+ width: 100%;
69
+ }
70
+ #widgets-options {
71
+ margin-left: 5px;
72
+ margin-right: 340px;
73
+ }
74
+ #widgets-left #widgets-options {
75
+ margin-left: 0;
76
+ margin-right: 0;
77
+ padding-top:20px;
78
+ }
79
+ #widgets-options .widget-holder {
80
+ border-width: 0 1px 1px;
81
+ border-style: none solid solid;
82
+ -webkit-border-bottom-right-radius: 3px;
83
+ -webkit-border-bottom-left-radius: 3px;
84
+ border-bottom-right-radius: 3px;
85
+ border-bottom-left-radius: 3px;
86
+ background-color: #FCFCFC;
87
+ border-color: #DFDFDF;
88
+ padding: 10px;
89
+ }
90
+ .widget-liquid-right .widget, .inactive-sidebar .widget, .widget-liquid-right .sidebar-description {
91
+ overflow: visible !important;
92
+ }
93
+ #widgets-options table { width:100%; }
94
+ #widgets-options td.label { width:30%; vertical-align:top; line-height:12px; }
95
+ #widgets-options td.label label { padding-top:12px; font-weight:bold; color:#222; }
96
+ #widgets-options #save-widgets-options { margin: 20px 0 0 0; }
97
+
98
+ #df-credits { float:right; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-style:italic; margin:15px 0 0; display:block; }
99
+ #df-credits a { padding: 5px 0 0 7px; vertical-align:middle; }
100
+
101
+ .widgets-holder-wrap .widgets-sortables { min-height:0!important; height:auto!important; }
images/chosen-sprite.png ADDED
Binary file
images/chosen-sprite@2x.png ADDED
Binary file
images/logo-dfactory.png ADDED
Binary file
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ // Silence is golden.
js/chosen.jquery.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 0.9.11
5
+ // Full source at https://github.com/harvesthq/chosen
6
+ // Copyright (c) 2011 Harvest http://getharvest.com
7
+
8
+ // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
+ // This file is generated by `cake build`, do not edit it by hand.
10
+ (function(){var e;e=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return e.nodeName.toUpperCase()==="OPTGROUP"?this.add_group(e):this.add_option(e)},e.prototype.add_group=function(e){var t,n,r,i,s,o;t=this.parsed.length,this.parsed.push({array_index:t,group:!0,label:e.label,children:0,disabled:e.disabled}),s=e.childNodes,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],o.push(this.add_option(n,t,e.disabled));return o},e.prototype.add_option=function(e,t,n){if(e.nodeName.toUpperCase()==="OPTION")return e.text!==""?(t!=null&&(this.parsed[t].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:e.value,text:e.text,html:e.innerHTML,selected:e.selected,disabled:n===!0?n:e.disabled,group_array_index:t,classes:e.className,style:e.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1},e}(),e.select_to_array=function(t){var n,r,i,s,o;r=new e,o=t.childNodes;for(i=0,s=o.length;i<s;i++)n=o[i],r.add_node(n);return r.parsed},this.SelectParser=e}).call(this),function(){var e,t;t=this,e=function(){function e(e,t){this.form_field=e,this.options=t!=null?t:{},this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.finish_setup()}return e.prototype.set_default_values=function(){var e=this;return this.click_test_action=function(t){return e.test_active_click(t)},this.activate_action=function(t){return e.activate_field(t)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=this.options.allow_single_deselect!=null&&this.form_field.options[0]!=null&&this.form_field.options[0].text===""?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=this.options.enable_split_word_search!=null?this.options.enable_split_word_search:!0,this.search_contains=this.options.search_contains||!1,this.choices=0,this.single_backstroke_delete=this.options.single_backstroke_delete||!1,this.max_selected_options=this.options.max_selected_options||Infinity,this.inherit_select_classes=this.options.inherit_select_classes||!1},e.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||"Select Some Options":this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||"Select an Option",this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||"No results match"},e.prototype.mouse_enter=function(){return this.mouse_on_container=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},e.prototype.input_focus=function(e){var t=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return t.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},e.prototype.input_blur=function(e){var t=this;if(!this.mouse_on_container)return this.active_field=!1,setTimeout(function(){return t.blur_test()},100)},e.prototype.result_add_option=function(e){var t,n;return e.disabled?"":(e.dom_id=this.container_id+"_o_"+e.array_index,t=e.selected&&this.is_multiple?[]:["active-result"],e.selected&&t.push("result-selected"),e.group_array_index!=null&&t.push("group-option"),e.classes!==""&&t.push(e.classes),n=e.style.cssText!==""?' style="'+e.style+'"':"",'<li id="'+e.dom_id+'" class="'+t.join(" ")+'"'+n+">"+e.html+"</li>")},e.prototype.results_update_field=function(){return this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(e){return this.results_showing?this.winnow_results():this.results_show()},e.prototype.keyup_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode,this.search_field_scale();switch(t){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:e.preventDefault();if(this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},e.prototype.generate_field_id=function(){var e;return e=this.generate_random_id(),this.form_field.id=e,e},e.prototype.generate_random_char=function(){var e,t,n;return e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",n=Math.floor(Math.random()*e.length),t=e.substring(n,n+1)},e}(),t.AbstractChosen=e}.call(this),function(){var e,t,n,r,i={}.hasOwnProperty,s=function(e,t){function r(){this.constructor=e}for(var n in t)i.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};r=this,e=jQuery,e.fn.extend({chosen:function(n){var r,i,s;return s=navigator.userAgent.toLowerCase(),i=/(msie) ([\w.]+)/.exec(s)||[],r={name:i[1]||"",version:i[2]||"0"},r.name==="msie"&&(r.version==="6.0"||r.version==="7.0"&&document.documentMode===7)?this:this.each(function(r){var i;i=e(this);if(!i.hasClass("chzn-done"))return i.data("chosen",new t(this,n))})}}),t=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return s(i,t),i.prototype.setup=function(){return this.form_field_jq=e(this.form_field),this.current_value=this.form_field_jq.val(),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},i.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},i.prototype.set_up_html=function(){var t,r,i,s,o,u;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/[^\w]/g,"_"):this.generate_field_id(),this.container_id+="_chzn",t=["chzn-container"],t.push("chzn-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),this.is_rtl&&t.push("chzn-rtl"),this.f_width=this.form_field_jq.outerWidth(),i={id:this.container_id,"class":t.join(" "),style:"width: "+this.f_width+"px;",title:this.form_field.title},r=e("<div />",i),this.is_multiple?r.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'):r.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>'),this.form_field_jq.hide().after(r),this.container=e("#"+this.container_id),this.dropdown=this.container.find("div.chzn-drop").first(),s=this.container.height(),o=this.f_width-n(this.dropdown),this.dropdown.css({width:o+"px",top:s+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),u=o-n(this.search_container)-n(this.search_field),this.search_field.css({width:u+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},i.prototype.register_observers=function(){var e=this;return this.container.mousedown(function(t){return e.container_mousedown(t)}),this.container.mouseup(function(t){return e.container_mouseup(t)}),this.container.mouseenter(function(t){return e.mouse_enter(t)}),this.container.mouseleave(function(t){return e.mouse_leave(t)}),this.search_results.mouseup(function(t){return e.search_results_mouseup(t)}),this.search_results.mouseover(function(t){return e.search_results_mouseover(t)}),this.search_results.mouseout(function(t){return e.search_results_mouseout(t)}),this.form_field_jq.bind("liszt:updated",function(t){return e.results_update_field(t)}),this.form_field_jq.bind("liszt:activate",function(t){return e.activate_field(t)}),this.form_field_jq.bind("liszt:open",function(t){return e.container_mousedown(t)}),this.search_field.blur(function(t){return e.input_blur(t)}),this.search_field.keyup(function(t){return e.keyup_checker(t)}),this.search_field.keydown(function(t){return e.keydown_checker(t)}),this.search_field.focus(function(t){return e.input_focus(t)}),this.is_multiple?this.search_choices.click(function(t){return e.choices_click(t)}):this.container.click(function(e){return e.preventDefault()})},i.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},i.prototype.container_mousedown=function(t){var n;if(!this.is_disabled)return n=t!=null?e(t.target).hasClass("search-choice-close"):!1,t&&t.type==="mousedown"&&!this.results_showing&&t.preventDefault(),!this.pending_destroy_click&&!n?(this.active_field?!this.is_multiple&&t&&(e(t.target)[0]===this.selected_item[0]||e(t.target).parents("a.chzn-single").length)&&(t.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),e(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},i.prototype.container_mouseup=function(e){if(e.target.nodeName==="ABBR"&&!this.is_disabled)return this.results_reset(e)},i.prototype.blur_test=function(e){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},i.prototype.close_field=function(){return e(document).unbind("click",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},i.prototype.activate_field=function(){return this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},i.prototype.test_active_click=function(t){return e(t.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},i.prototype.results_build=function(){var e,t,n,i,s;this.parsing=!0,this.results_data=r.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.addClass("chzn-default").find("span").text(this.default_text),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),e="",s=this.results_data;for(n=0,i=s.length;n<i;n++)t=s[n],t.group?e+=this.result_add_group(t):t.empty||(e+=this.result_add_option(t),t.selected&&this.is_multiple?this.choice_build(t):t.selected&&!this.is_multiple&&(this.selected_item.removeClass("chzn-default").find("span").text(t.text),this.allow_single_deselect&&this.single_deselect_control_build()));return this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.search_results.html(e),this.parsing=!1},i.prototype.result_add_group=function(t){return t.disabled?"":(t.dom_id=this.container_id+"_g_"+t.array_index,'<li id="'+t.dom_id+'" class="group-result">'+e("<div />").text(t.label).html()+"</li>")},i.prototype.result_do_highlight=function(e){var t,n,r,i,s;if(e.length){this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClass("highlighted"),r=parseInt(this.search_results.css("maxHeight"),10),s=this.search_results.scrollTop(),i=r+s,n=this.result_highlight.position().top+this.search_results.scrollTop(),t=n+this.result_highlight.outerHeight();if(t>=i)return this.search_results.scrollTop(t-r>0?t-r:0);if(n<s)return this.search_results.scrollTop(n)}},i.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},i.prototype.results_show=function(){var e;if(!this.is_multiple)this.selected_item.addClass("chzn-single-with-drop"),this.result_single_selected&&this.result_do_highlight(this.result_single_selected);else if(this.max_selected_options<=this.choices)return this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1;return e=this.is_multiple?this.container.height():this.container.height()-1,this.form_field_jq.trigger("liszt:showing_dropdown",{chosen:this}),this.dropdown.css({top:e+"px",left:0}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results()},i.prototype.results_hide=function(){return this.is_multiple||this.selected_item.removeClass("chzn-single-with-drop"),this.result_clear_highlight(),this.form_field_jq.trigger("liszt:hiding_dropdown",{chosen:this}),this.dropdown.css({left:"-9000px"}),this.results_showing=!1},i.prototype.set_tab_index=function(e){var t;if(this.form_field_jq.attr("tabindex"))return t=this.form_field_jq.attr("tabindex"),this.form_field_jq.attr("tabindex",-1),this.search_field.attr("tabindex",t)},i.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},i.prototype.search_results_mouseup=function(t){var n;n=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first();if(n.length)return this.result_highlight=n,this.result_select(t),this.search_field.focus()},i.prototype.search_results_mouseover=function(t){var n;n=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first();if(n)return this.result_do_highlight(n)},i.prototype.search_results_mouseout=function(t){if(e(t.target).hasClass("active-result"))return this.result_clear_highlight()},i.prototype.choices_click=function(t){t.preventDefault();if(this.active_field&&!e(t.target).hasClass("search-choice")&&!this.results_showing)return this.results_show()},i.prototype.choice_build=function(t){var n,r,i,s=this;return this.is_multiple&&this.max_selected_options<=this.choices?(this.form_field_jq.trigger("liszt:maxselected",{chosen:this}),!1):(n=this.container_id+"_c_"+t.array_index,this.choices+=1,t.disabled?r='<li class="search-choice search-choice-disabled" id="'+n+'"><span>'+t.html+"</span></li>":r='<li class="search-choice" id="'+n+'"><span>'+t.html+'</span><a href="javascript:void(0)" class="search-choice-close" rel="'+t.array_index+'"></a></li>',this.search_container.before(r),i=e("#"+n).find("a").first(),i.click(function(e){return s.choice_destroy_link_click(e)}))},i.prototype.choice_destroy_link_click=function(t){return t.preventDefault(),this.is_disabled?t.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(e(t.target)))},i.prototype.choice_destroy=function(e){if(this.result_deselect(e.attr("rel")))return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),e.parents("li").first().remove(),this.search_field_scale()},i.prototype.results_reset=function(){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.is_multiple||this.selected_item.addClass("chzn-default"),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},i.prototype.results_reset_cleanup=function(){return this.current_value=this.form_field_jq.val(),this.selected_item.find("abbr").remove()},i.prototype.result_select=function(e){var t,n,r,i;if(this.result_highlight)return t=this.result_highlight,n=t.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(t):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=t,this.selected_item.removeClass("chzn-default")),t.addClass("result-selected"),i=n.substr(n.lastIndexOf("_")+1),r=this.results_data[i],r.selected=!0,this.form_field.options[r.options_index].selected=!0,this.is_multiple?this.choice_build(r):(this.selected_item.find("span").first().text(r.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!e.metaKey&&!e.ctrlKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field_jq.val()!==this.current_value)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[r.options_index].value}),this.current_value=this.form_field_jq.val(),this.search_field_scale()},i.prototype.result_activate=function(e){return e.addClass("active-result")},i.prototype.result_deactivate=function(e){return e.removeClass("active-result")},i.prototype.result_deselect=function(t){var n,r;return r=this.results_data[t],this.form_field.options[r.options_index].disabled?!1:(r.selected=!1,this.form_field.options[r.options_index].selected=!1,n=e("#"+this.container_id+"_o_"+t),n.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[r.options_index].value}),this.search_field_scale(),!0)},i.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1)return this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>')},i.prototype.winnow_results=function(){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y;this.no_results_clear(),f=0,l=this.search_field.val()===this.default_text?"":e("<div/>").text(e.trim(this.search_field.val())).html(),o=this.search_contains?"":"^",s=new RegExp(o+l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),p=new RegExp(l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),y=this.results_data;for(d=0,m=y.length;d<m;d++){n=y[d];if(!n.disabled&&!n.empty)if(n.group)e("#"+n.dom_id).css("display","none");else if(!this.is_multiple||!n.selected){t=!1,a=n.dom_id,u=e("#"+a);if(s.test(n.html))t=!0,f+=1;else if(this.enable_split_word_search&&(n.html.indexOf(" ")>=0||n.html.indexOf("[")===0)){i=n.html.replace(/\[|\]/g,"").split(" ");if(i.length)for(v=0,g=i.length;v<g;v++)r=i[v],s.test(r)&&(t=!0,f+=1)}t?(l.length?(c=n.html.search(p),h=n.html.substr(0,c+l.length)+"</em>"+n.html.substr(c+l.length),h=h.substr(0,c)+"<em>"+h.substr(c)):h=n.html,u.html(h),this.result_activate(u),n.group_array_index!=null&&e("#"+this.results_data[n.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&a===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(u))}}return f<1&&l.length?this.no_results(l):this.winnow_results_set_highlight()},i.prototype.winnow_results_clear=function(){var t,n,r,i,s;this.search_field.val(""),n=this.search_results.find("li"),s=[];for(r=0,i=n.length;r<i;r++)t=n[r],t=e(t),t.hasClass("group-result")?s.push(t.css("display","auto")):!this.is_multiple||!t.hasClass("result-selected")?s.push(this.result_activate(t)):s.push(void 0);return s},i.prototype.winnow_results_set_highlight=function(){var e,t;if(!this.result_highlight){t=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),e=t.length?t.first():this.search_results.find(".active-result").first();if(e!=null)return this.result_do_highlight(e)}},i.prototype.no_results=function(t){var n;return n=e('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),n.find("span").first().html(t),this.search_results.append(n)},i.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},i.prototype.keydown_arrow=function(){var t,n;this.result_highlight?this.results_showing&&(n=this.result_highlight.nextAll("li.active-result").first(),n&&this.result_do_highlight(n)):(t=this.search_results.find("li.active-result").first(),t&&this.result_do_highlight(e(t)));if(!this.results_showing)return this.results_show()},i.prototype.keyup_arrow=function(){var e;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return e=this.result_highlight.prevAll("li.active-result"),e.length?this.result_do_highlight(e.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},i.prototype.keydown_backstroke=function(){var e;if(this.pending_backstroke)return this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke();e=this.search_container.siblings("li.search-choice").last();if(e.length&&!e.hasClass("search-choice-disabled"))return this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")},i.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},i.prototype.keydown_checker=function(e){var t,n;t=(n=e.which)!=null?n:e.keyCode,this.search_field_scale(),t!==8&&this.pending_backstroke&&this.clear_backstroke();switch(t){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},i.prototype.search_field_scale=function(){var t,n,r,i,s,o,u,a,f;if(this.is_multiple){r=0,u=0,s="position:absolute; left: -1000px; top: -1000px; display:none;",o=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(a=0,f=o.length;a<f;a++)i=o[a],s+=i+":"+this.search_field.css(i)+";";return n=e("<div />",{style:s}),n.text(this.search_field.val()),e("body").append(n),u=n.width()+25,n.remove(),u>this.f_width-10&&(u=this.f_width-10),this.search_field.css({width:u+"px"}),t=this.container.height(),this.dropdown.css({top:t+"px"})}},i.prototype.generate_random_id=function(){var t;t="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(e("#"+t).length>0)t+=this.generate_random_char();return t},i}(AbstractChosen),r.Chosen=t,n=function(e){var t;return t=e.outerWidth()-e.width()},r.get_side_border_padding=n}.call(this);
js/restrict-widgets.js ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($)
2
+ {
3
+ $(document).ready(function ()
4
+ {
5
+
6
+ $('#widgets-left').append($('#widgets-options'));
7
+
8
+ for(i in restrict_widgets_args.restrict_widgets)
9
+ {
10
+ $("div[id*='"+restrict_widgets_args.restrict_widgets[i]+"'] div").remove();
11
+ }
12
+
13
+ for(i in restrict_widgets_args.restrict_class)
14
+ {
15
+ $("div[id*='"+restrict_widgets_args.restrict_class[i]+"-__i__']").remove();
16
+ }
17
+
18
+ for(i in restrict_widgets_args.restrict_nonclass)
19
+ {
20
+ $("div[id*='_"+restrict_widgets_args.restrict_nonclass[i]+"']").remove();
21
+ }
22
+
23
+ if(restrict_widgets_args.restrict_orphan_sidebar == 1)
24
+ {
25
+ $('.orphan-sidebar').remove();
26
+ }
27
+
28
+ $('#options-available-widgets').chosen({
29
+ placeholder_text: restrict_widgets_args.restrict_available_widgets
30
+ });
31
+ $('#options-widgets-selection').chosen({
32
+ placeholder_text: restrict_widgets_args.restrict_widgets_selection
33
+ });
34
+ $('#options-widgets-sidebars').chosen({
35
+ placeholder_text: restrict_widgets_args.restrict_sidebars
36
+ });
37
+ $('#options-widgets-roles').chosen({
38
+ placeholder_text: restrict_widgets_args.restrict_roles
39
+ });
40
+
41
+ });
42
+
43
+ $(document).on('mouseover', '#widgets-right, .inactive-sidebar', function() {
44
+
45
+ $(this).find('.restrict-widgets-hide').chosen({
46
+ allow_single_deselect: true,
47
+ disable_search: true
48
+ });
49
+ $(this).find('.restrict-widgets-select').chosen({
50
+ placeholder_text: restrict_widgets_args.placeholder_text
51
+ });
52
+
53
+ });
54
+
55
+ $(document).on('ajaxStop', function() {
56
+ $('#widgets-right .restrict-widgets-hide, .inactive-sidebar .restrict-widgets-hide').chosen({
57
+ allow_single_deselect: true,
58
+ disable_search: true
59
+ });
60
+ $('#widgets-right .restrict-widgets-select, .inactive-sidebar .restrict-widgets-select').chosen({
61
+ placeholder_text: restrict_widgets_args.placeholder_text
62
+ });
63
+ });
64
+
65
+ })(jQuery);
languages/restrict-widgets-pl_PL.mo ADDED
Binary file
languages/restrict-widgets-pl_PL.po ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Restrict Widgets\n"
4
+ "POT-Creation-Date: 2013-03-15 23:14+0100\n"
5
+ "PO-Revision-Date: 2013-03-15 23:17+0100\n"
6
+ "Last-Translator: Bartosz Arendt <info@digitalfactory.pl>\n"
7
+ "Language-Team: dFactory <info@dfactory.eu>\n"
8
+ "Language: English\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.5\n"
13
+ "X-Poedit-KeywordsList: gettext;gettext_noop;__;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../restrict-widgets.php:194
19
+ msgid "Pages"
20
+ msgstr "Strony"
21
+
22
+ #: ../restrict-widgets.php:195
23
+ msgid "Custom Post Types"
24
+ msgstr "Własne typy wpisów"
25
+
26
+ #: ../restrict-widgets.php:196
27
+ msgid "Custom Post Type Archives"
28
+ msgstr "Archiwa własnych typów wpisów"
29
+
30
+ #: ../restrict-widgets.php:197
31
+ msgid "Categories"
32
+ msgstr "Kategorie"
33
+
34
+ #: ../restrict-widgets.php:198
35
+ msgid "Taxonomies"
36
+ msgstr "Taksonomie"
37
+
38
+ #: ../restrict-widgets.php:199
39
+ msgid "Others"
40
+ msgstr "Inne"
41
+
42
+ #: ../restrict-widgets.php:200
43
+ msgid "Users"
44
+ msgstr "Użytkownicy"
45
+
46
+ #: ../restrict-widgets.php:201
47
+ msgid "Languages"
48
+ msgstr "Języki"
49
+
50
+ #: ../restrict-widgets.php:205
51
+ msgid "Front Page"
52
+ msgstr "Strona główna"
53
+
54
+ #: ../restrict-widgets.php:206
55
+ msgid "Blog Page"
56
+ msgstr "Strona z wpisami"
57
+
58
+ #: ../restrict-widgets.php:207
59
+ msgid "Single Posts"
60
+ msgstr "Pojedyncze wpisy"
61
+
62
+ #: ../restrict-widgets.php:208
63
+ msgid "Sticky Posts"
64
+ msgstr "Wpisy przyklejone"
65
+
66
+ #: ../restrict-widgets.php:209
67
+ msgid "Author Archive"
68
+ msgstr "Archiwum autora"
69
+
70
+ #: ../restrict-widgets.php:210
71
+ msgid "Date Archive"
72
+ msgstr "Archiwum daty"
73
+
74
+ #: ../restrict-widgets.php:211
75
+ msgid "404 Page"
76
+ msgstr "Strona błędów 404"
77
+
78
+ #: ../restrict-widgets.php:212
79
+ msgid "Search Page"
80
+ msgstr "Strona wyszukiwania"
81
+
82
+ #: ../restrict-widgets.php:216
83
+ msgid "Logged in users"
84
+ msgstr "Zalogowani użytkownicy"
85
+
86
+ #: ../restrict-widgets.php:217
87
+ msgid "Logged out users"
88
+ msgstr "Wylogowani użytkownicy"
89
+
90
+ #: ../restrict-widgets.php:447
91
+ msgid "Restrict widgets"
92
+ msgstr "Ograniczenia widgetów"
93
+
94
+ #: ../restrict-widgets.php:451
95
+ msgid ""
96
+ "Use this settings to manage access to widgets page and to restrict "
97
+ "availability of certain widgets, sidebars and widgets options to site "
98
+ "administrators only."
99
+ msgstr ""
100
+ "Użyj tych ustawień aby określić kto może mieć dostęp do widgetów, jakie "
101
+ "widgety, panele boczne i ustawienia widgetów są dostępne dla użytkowników a "
102
+ "jakie tylko dla administratorów."
103
+
104
+ #: ../restrict-widgets.php:454
105
+ msgid "Restrict Users"
106
+ msgstr "Ograniczenia użytkowników"
107
+
108
+ #: ../restrict-widgets.php:464
109
+ msgid "Select user roles restricted to manage widgets."
110
+ msgstr "Wybierz role użytkowników, którzy mogą zarządzać widgetami."
111
+
112
+ #: ../restrict-widgets.php:468
113
+ msgid "Restrict Sidebars"
114
+ msgstr "Ograniczenia paneli bocznych"
115
+
116
+ #: ../restrict-widgets.php:483
117
+ msgid "Select which sidebars will be restricted to admins only."
118
+ msgstr "Wybierz panele boczne, które będą dostępne tylko dla administratorów."
119
+
120
+ #: ../restrict-widgets.php:487
121
+ msgid "Restrict Widgets"
122
+ msgstr "Ograniczenia widgetów"
123
+
124
+ #: ../restrict-widgets.php:499
125
+ msgid "Select which widgets will be restricted to admins only."
126
+ msgstr "Wybierz widgety, któe będą dostępne tylko dla administratorów."
127
+
128
+ #: ../restrict-widgets.php:503
129
+ msgid "Restrict Widget Options"
130
+ msgstr "Ograniczenia opcji widgetów"
131
+
132
+ #: ../restrict-widgets.php:513
133
+ msgid "Select which widget options will be restricted to admins only."
134
+ msgstr "Wybierz które opcje widgetów, będą dostępne tylko dla administratorów."
135
+
136
+ #: ../restrict-widgets.php:517
137
+ msgid "Restrict Option Groups"
138
+ msgstr "Ograniczenia grup opcji"
139
+
140
+ #: ../restrict-widgets.php:520
141
+ msgid "Display widget options in groups"
142
+ msgstr "Wyświetl opcje widgetów w grupach"
143
+
144
+ #: ../restrict-widgets.php:524
145
+ msgid "Plugin Deactivation"
146
+ msgstr "Deaktywacja wtyczki"
147
+
148
+ #: ../restrict-widgets.php:527
149
+ msgid "Remove all plugin data on deactivation"
150
+ msgstr "Usuń wszystkie dane wtyczki podczas deaktywacji"
151
+
152
+ #: ../restrict-widgets.php:531
153
+ msgid "Save settings"
154
+ msgstr "Zapisz ustawienia"
155
+
156
+ #: ../restrict-widgets.php:532
157
+ msgid "Created by"
158
+ msgstr "Stworzone przez"
159
+
160
+ #: ../restrict-widgets.php:692 ../restrict-widgets.php:702
161
+ #, php-format
162
+ msgid "Single %s"
163
+ msgstr "Pojedyncze %s"
164
+
165
+ #: ../restrict-widgets.php:732 ../restrict-widgets.php:742
166
+ #, php-format
167
+ msgid "%s Archive"
168
+ msgstr "Archiwum %s"
169
+
170
+ #: ../restrict-widgets.php:970
171
+ msgid "Display / Hide Widget"
172
+ msgstr "Wyświetl / Ukryj widget"
173
+
174
+ #: ../restrict-widgets.php:972
175
+ msgid "Display widget on selected"
176
+ msgstr "Wyświetl widget na wybranych stronach"
177
+
178
+ #: ../restrict-widgets.php:973
179
+ msgid "Hide widget on selected"
180
+ msgstr "Ukryj widget na wybranych stronach"
181
+
182
+ #: ../restrict-widgets.php:1259 ../restrict-widgets.php:1304
183
+ msgid "Widgets"
184
+ msgstr "Widgety"
languages/restrict-widgets.pot ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Restrict Widgets\n"
4
+ "POT-Creation-Date: 2013-03-10 16:48+0100\n"
5
+ "PO-Revision-Date: 2013-03-21 10:12+0100\n"
6
+ "Last-Translator: Bartosz Arendt <info@digitalfactory.pl>\n"
7
+ "Language-Team: dFactory <info@dfactory.eu>\n"
8
+ "Language: English\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.5\n"
13
+ "X-Poedit-KeywordsList: gettext;gettext_noop;__;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../restrict-widgets.php:46
19
+ msgid "Pages"
20
+ msgstr ""
21
+
22
+ #: ../restrict-widgets.php:47
23
+ msgid "Custom Post Types"
24
+ msgstr ""
25
+
26
+ #: ../restrict-widgets.php:48
27
+ msgid "Custom Post Type Archives"
28
+ msgstr ""
29
+
30
+ #: ../restrict-widgets.php:49
31
+ msgid "Categories"
32
+ msgstr ""
33
+
34
+ #: ../restrict-widgets.php:50
35
+ msgid "Taxonomies"
36
+ msgstr ""
37
+
38
+ #: ../restrict-widgets.php:51
39
+ msgid "Others"
40
+ msgstr ""
41
+
42
+ #: ../restrict-widgets.php:52
43
+ msgid "Users"
44
+ msgstr ""
45
+
46
+ #: ../restrict-widgets.php:56
47
+ msgid "Front Page"
48
+ msgstr ""
49
+
50
+ #: ../restrict-widgets.php:57
51
+ msgid "Blog Page"
52
+ msgstr ""
53
+
54
+ #: ../restrict-widgets.php:58
55
+ msgid "Single Post"
56
+ msgstr ""
57
+
58
+ #: ../restrict-widgets.php:59
59
+ msgid "Sticky Post"
60
+ msgstr ""
61
+
62
+ #: ../restrict-widgets.php:60
63
+ msgid "Author Archive"
64
+ msgstr ""
65
+
66
+ #: ../restrict-widgets.php:61
67
+ msgid "Date Archive"
68
+ msgstr ""
69
+
70
+ #: ../restrict-widgets.php:62
71
+ msgid "404 Page"
72
+ msgstr ""
73
+
74
+ #: ../restrict-widgets.php:63
75
+ msgid "Search Page"
76
+ msgstr ""
77
+
78
+ #: ../restrict-widgets.php:67
79
+ msgid "Logged in users"
80
+ msgstr ""
81
+
82
+ #: ../restrict-widgets.php:68
83
+ msgid "Logged out users"
84
+ msgstr ""
85
+
86
+ #: ../restrict-widgets.php:300
87
+ msgid "Restrict widgets"
88
+ msgstr ""
89
+
90
+ #: ../restrict-widgets.php:304
91
+ msgid ""
92
+ "Use this settings to manage access to widgets page and to restrict "
93
+ "availability of certain widgets, sidebars and widgets options to site "
94
+ "administrators only."
95
+ msgstr ""
96
+
97
+ #: ../restrict-widgets.php:311
98
+ msgid "Restrict Users"
99
+ msgstr ""
100
+
101
+ #: ../restrict-widgets.php:320
102
+ msgid "Select user roles restricted to manage widgets."
103
+ msgstr ""
104
+
105
+ #: ../restrict-widgets.php:323
106
+ msgid "Restrict Sidebars"
107
+ msgstr ""
108
+
109
+ #: ../restrict-widgets.php:338
110
+ msgid "Select which sidebars will be restricted to admins only."
111
+ msgstr ""
112
+
113
+ #: ../restrict-widgets.php:341
114
+ msgid "Restrict Widgets"
115
+ msgstr ""
116
+
117
+ #: ../restrict-widgets.php:353
118
+ msgid "Select which widgets will be restricted to admins only."
119
+ msgstr ""
120
+
121
+ #: ../restrict-widgets.php:356
122
+ msgid "Restrict Widgets Options"
123
+ msgstr ""
124
+
125
+ #: ../restrict-widgets.php:365
126
+ msgid "Select which widgets options will be restricted to admins only."
127
+ msgstr ""
128
+
129
+ #: ../restrict-widgets.php:367
130
+ msgid "Save settings"
131
+ msgstr ""
132
+
133
+ #: ../restrict-widgets.php:464 ../restrict-widgets.php:474
134
+ msgid "Single"
135
+ msgstr ""
136
+
137
+ #: ../restrict-widgets.php:498 ../restrict-widgets.php:508
138
+ msgid "Archive"
139
+ msgstr ""
140
+
141
+ #: ../restrict-widgets.php:667
142
+ msgid "Display / Hide Widget"
143
+ msgstr ""
144
+
145
+ #: ../restrict-widgets.php:669
146
+ msgid "Display widget on selected"
147
+ msgstr ""
148
+
149
+ #: ../restrict-widgets.php:670
150
+ msgid "Show widget on selected"
151
+ msgstr ""
152
+
153
+ #: ../restrict-widgets.php:950 ../restrict-widgets.php:988
154
+ msgid "Widgets"
155
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Restrict Widgets ===
2
+ Contributors: dfactory
3
+ Tags: widget, widgets, widget-only, cms, hide, custom, restrict, manage, management, capability, capabilities, sidebar, sidebars, user, permission, permissions
4
+ Requires at least: 3.5
5
+ Tested up to: 3.5.1
6
+ Stable tag: 1.0
7
+ License: MIT License
8
+ License URI: http://opensource.org/licenses/MIT
9
+
10
+ Take full control over your widgets! Select on which pages each widget will appear on, who can manage widgets and which widgets users can use.
11
+
12
+ == Description ==
13
+
14
+ [Restrict Widgets](http://www.dfactory.eu/plugins/restrict-widgets/) is all in one solution for widget management in WordPress. It gives every widget an extra control fields that lets you control the pages that the widget will appear on. This plugin creates a new �manage_widgets� capability, that allows you to gives access to widgets page to selected WordPress user roles. You can also set which sidebars and widgets will be available to selected users, which widget options will be available and how it will be displayed.
15
+
16
+ By default, �Hide widget on selected� is enabled with no options selected, so all current widgets will continue to display on all pages.
17
+
18
+ For more information, check out plugin page at [dFactory](http://www.dfactory.eu/) or plugin [support forum](http://www.dfactory.eu/support/forum/restrict-widgets/).
19
+
20
+ = Features include: =
21
+
22
+ * Hide or display each widget on selected pages, posts, categories, custom taxonomies, custom post types, single posts, archives, special pages, for logged in or logged out users, current language and so on
23
+ * Select which user roles are restricted to manage widgets
24
+ * Select which sidebars will be restricted to admins only
25
+ * Select which widgets will be restricted to admins only
26
+ * Select which widget options will be restricted to admins only
27
+ * Choose to display or not widget options as groups
28
+ * WPML compatible
29
+ * Polylang compatible
30
+ * .pot file for translations included
31
+
32
+
33
+ == Installation ==
34
+
35
+ 1. Install Restrict Widgets either via the WordPress.org plugin directory, or by uploading the files to your server</li>
36
+ 1. Activate the plugin through the 'Plugins' menu in WordPress</li>
37
+ 1. Go to the Widgets menu and set your desired widgets options.</li>
38
+
39
+ == Frequently Asked Questions ==
40
+
41
+ No questions yet.
42
+
43
+ == Screenshots ==
44
+
45
+ 1. screenshot-1.png
46
+ 2. screenshot-2.png
47
+
48
+ == Changelog ==
49
+
50
+ = 1.0 =
51
+ Initial release
52
+
53
+ == Upgrade Notice ==
54
+
55
+ The current version of Restrict Widgets requires WordPress 3.5 or higher. If you use older version of WordPress, you need to upgrade WordPress first.
restrict-widgets.php ADDED
@@ -0,0 +1,1375 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Restrict Widgets
4
+ Description: Take full control over your widgets! Select on which pages each widget will appear on, who can manage widgets and which widgets users can use.
5
+ Version: 1.0.0
6
+ Author: dFactory
7
+ Author URI: http://www.dfactory.eu/
8
+ Plugin URI: http://www.dfactory.eu/plugins/restrict-widgets/
9
+ License: MIT License
10
+ License URI: http://opensource.org/licenses/MIT
11
+
12
+ Restrict Widgets
13
+ Copyright (C) 2013, Digital Factory - info@digitalfactory.pl
14
+
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ */
21
+
22
+
23
+ class RestrictWidgets
24
+ {
25
+ private $others = array();
26
+ private $users = array();
27
+ private $custom_post_types = array();
28
+ private $custom_post_types_archives = array();
29
+ private $categories = array();
30
+ private $taxonomies = array();
31
+ private $pages = array();
32
+ private $options = array();
33
+ private $languages = array();
34
+
35
+
36
+ public function __construct()
37
+ {
38
+ register_activation_hook(__FILE__, array(&$this, 'activation'));
39
+ register_deactivation_hook(__FILE__, array(&$this, 'deactivation'));
40
+
41
+ //actions
42
+ add_action('wp_loaded', array(&$this, 'polylang_widgets'), 6);
43
+ add_action('plugins_loaded', array(&$this, 'load_textdomain'));
44
+ add_action('admin_init', array(&$this, 'load_dynamic_data'));
45
+ add_action('widgets_init', array(&$this, 'load_other_data'), 10);
46
+ add_action('widgets_init', array(&$this, 'save_restrict_options'), 10);
47
+ add_action('widgets_init', array(&$this, 'init_restrict_widgets'), 10);
48
+ add_action('widgets_init', array(&$this, 'init_restrict_sidebars'), 11);
49
+ add_action('sidebar_admin_page', array(&$this, 'add_widgets_options_box'));
50
+ add_action('in_widget_form', array(&$this, 'display_admin_widgets_options'), 10, 3);
51
+ add_action('admin_enqueue_scripts', array(&$this, 'widgets_scripts_styles'));
52
+ add_action('admin_menu', array(&$this, 'manage_widgets_menu'));
53
+
54
+ //filters
55
+ add_filter('widget_display_callback', array(&$this, 'display_frontend_widgets'));
56
+ add_filter('widget_update_callback', array(&$this, 'update_admin_widgets_options'), 10, 3);
57
+ add_filter('user_has_cap', array(&$this, 'manage_widgets_cap'), 10, 3);
58
+ add_filter('dynamic_sidebar_params', array(&$this, 'restrict_sidebar_params'), 10, 3);
59
+ }
60
+
61
+ // Fix for Polylang - removes language switcher in widgets
62
+ public function polylang_widgets()
63
+ {
64
+ if(function_exists('pll_the_languages'));
65
+ {
66
+ global $polylang;
67
+
68
+ if(has_action('in_widget_form', array($polylang, 'in_widget_form')))
69
+ {
70
+ remove_action('in_widget_form', array($polylang, 'in_widget_form'));
71
+ }
72
+ }
73
+ }
74
+
75
+
76
+ public function load_textdomain()
77
+ {
78
+ load_plugin_textdomain('restrict-widgets', FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
79
+ }
80
+
81
+
82
+ public function restrict_sidebar_params($params)
83
+ {
84
+ if(!current_user_can('manage_options'))
85
+ {
86
+ global $wp_registered_widgets;
87
+
88
+ $option = get_option('rw_widgets_options');
89
+
90
+ if(isset($wp_registered_widgets[$params[0]['widget_id']]['callback'][0]))
91
+ {
92
+ if(in_array(get_class($wp_registered_widgets[$params[0]['widget_id']]['callback'][0]), array_keys($option['available'])))
93
+ {
94
+ $params[0]['_hide'] = 1;
95
+ }
96
+ }
97
+ }
98
+
99
+ return $params;
100
+ }
101
+
102
+
103
+ public function activation()
104
+ {
105
+ $role = get_role('administrator');
106
+ $role->add_cap('manage_widgets');
107
+
108
+ //default settings
109
+ add_option(
110
+ 'rw_widgets_options',
111
+ array(
112
+ 'available' => array(),
113
+ 'selection' => array(),
114
+ 'sidebars' => array(),
115
+ 'groups' => TRUE,
116
+ 'deactivation' => FALSE,
117
+ ),
118
+ '',
119
+ 'yes'
120
+ );
121
+ }
122
+
123
+
124
+ public function deactivation()
125
+ {
126
+ $option = get_option('rw_widgets_options');
127
+
128
+ if($option['deactivation'] === TRUE)
129
+ {
130
+ global $wp_roles, $wp_registered_widgets;
131
+
132
+ //removes roles
133
+ foreach($wp_roles->roles as $role_name => $empty)
134
+ {
135
+ $role = get_role($role_name);
136
+ $role->remove_cap('manage_widgets');
137
+ }
138
+
139
+ //clears all widgets
140
+ foreach($wp_registered_widgets as $widget)
141
+ {
142
+ if(isset($widget['params'][0]['number']) && $widget['params'][0]['number'] !== -1)
143
+ {
144
+ $option = get_option($widget['callback'][0]->option_name);
145
+ unset($option[$widget['params'][0]['number']]['rw_opt']);
146
+ update_option($widget['callback'][0]->option_name, $option);
147
+ }
148
+ }
149
+
150
+ delete_option('rw_widgets_options');
151
+ }
152
+ }
153
+
154
+
155
+ public function load_dynamic_data()
156
+ {
157
+ $this->taxonomies = get_taxonomies(
158
+ array(
159
+ '_builtin' => FALSE
160
+ ),
161
+ 'objects',
162
+ 'and'
163
+ );
164
+
165
+ $this->categories = get_categories(
166
+ array(
167
+ 'hide_empty' => FALSE
168
+ )
169
+ );
170
+
171
+ $this->custom_post_types = get_post_types(
172
+ array(
173
+ 'public' => TRUE,
174
+ '_builtin' => FALSE
175
+ ),
176
+ 'objects',
177
+ 'and'
178
+ );
179
+
180
+ $this->custom_post_types_archives = get_post_types(
181
+ array(
182
+ 'public' => TRUE,
183
+ '_builtin' => FALSE,
184
+ 'has_archive' => TRUE
185
+ ),
186
+ 'objects',
187
+ 'and'
188
+ );
189
+ }
190
+
191
+
192
+ public function load_other_data()
193
+ {
194
+ $this->options = array(
195
+ 'pages' => __('Pages', 'restrict-widgets'),
196
+ 'custom_post_types' => __('Custom Post Types', 'restrict-widgets'),
197
+ 'custom_post_types_archives' => __('Custom Post Type Archives', 'restrict-widgets'),
198
+ 'categories' => __('Categories', 'restrict-widgets'),
199
+ 'taxonomies' => __('Taxonomies', 'restrict-widgets'),
200
+ 'others' => __('Others', 'restrict-widgets'),
201
+ 'users' => __('Users', 'restrict-widgets'),
202
+ 'languages' => __('Languages', 'restrict-widgets'),
203
+ );
204
+
205
+ $this->others = array(
206
+ 'front_page' => __('Front Page', 'restrict-widgets'),
207
+ 'blog_page' => __('Blog Page', 'restrict-widgets'),
208
+ 'single_post' => __('Single Posts', 'restrict-widgets'),
209
+ 'sticky_post' => __('Sticky Posts', 'restrict-widgets'),
210
+ 'author_archive' => __('Author Archive', 'restrict-widgets'),
211
+ 'date_archive' => __('Date Archive', 'restrict-widgets'),
212
+ '404_page' => __('404 Page', 'restrict-widgets'),
213
+ 'search_page' => __('Search Page', 'restrict-widgets')
214
+ );
215
+
216
+ $this->users = array(
217
+ 'logged_in' => __('Logged in users', 'restrict-widgets'),
218
+ 'logged_out' => __('Logged out users', 'restrict-widgets'),
219
+ );
220
+
221
+ $this->pages = get_pages(
222
+ array(
223
+ 'sort_order' => 'ASC',
224
+ 'sort_column' => 'post_title',
225
+ 'number' => '',
226
+ 'post_type' => 'page',
227
+ 'post_status' => 'publish'
228
+ )
229
+ );
230
+
231
+ //Polylang support
232
+ if(function_exists('pll_the_languages'))
233
+ {
234
+ $languages = get_terms('language', array('hide_empty' => FALSE));
235
+
236
+ //we need to make WMPL style table
237
+ foreach($languages as $language)
238
+ {
239
+ $this->languages[$language->slug] = array('native_name' => $language->name);
240
+ }
241
+ }
242
+ //WMPL support
243
+ elseif(function_exists('icl_get_languages'))
244
+ {
245
+ $this->languages = icl_get_languages('skip_missing=0&orderby=native_name&order=asc');
246
+ }
247
+
248
+ else $this->languages = FALSE;
249
+ }
250
+
251
+
252
+ public function init_restrict_sidebars()
253
+ {
254
+ if(!current_user_can('manage_options') && current_user_can('edit_theme_options'))
255
+ {
256
+ $option = get_option('rw_widgets_options');
257
+
258
+ foreach(array_keys($option['sidebars']) as $sidebar_id)
259
+ {
260
+ unregister_sidebar($sidebar_id);
261
+ }
262
+ }
263
+ }
264
+
265
+
266
+ public function init_restrict_widgets()
267
+ {
268
+ /*
269
+ global $wp_registered_widgets, $wp_registered_sidebars;
270
+
271
+ if(!current_user_can('manage_options') && current_user_can('edit_theme_options'))
272
+ {
273
+ $option = get_option('rw_widgets_options');
274
+
275
+ foreach(array_keys($option['available']) as $widget_class)
276
+ {
277
+ unregister_widget($widget_class);
278
+ }
279
+ }
280
+ */
281
+ }
282
+
283
+
284
+ public function save_restrict_options()
285
+ {
286
+ //are we saving with administration privileges?
287
+ if(current_user_can('manage_options') && isset($_POST['save-widgets-options']))
288
+ {
289
+ global $wp_roles;
290
+
291
+ //what we wanna save?
292
+ $save_widgets = array(
293
+ 'available' => array(),
294
+ 'selection' => array(),
295
+ 'sidebars' => array(),
296
+ 'groups' => FALSE,
297
+ 'deactivation' => FALSE
298
+ );
299
+
300
+ //display groups?
301
+ $save_widgets['groups'] = (isset($_POST['options-widgets-groups']) ? TRUE : FALSE);
302
+
303
+ //remove plugin data?
304
+ $save_widgets['deactivation'] = (isset($_POST['options-widgets-deactivation']) ? TRUE : FALSE);
305
+
306
+ //do we have some available widgets?
307
+ if(isset($_POST['options-available-widgets']))
308
+ {
309
+ foreach($_POST['options-available-widgets'] as $widget_class)
310
+ {
311
+ $save_widgets['available'][$widget_class] = TRUE;
312
+ }
313
+ }
314
+
315
+ //do we have some specific elements?
316
+ if(isset($_POST['options-widgets-selection']))
317
+ {
318
+ $selected = $_POST['options-widgets-selection'];
319
+
320
+ //only for custom post types (archives)
321
+ foreach($selected as $element)
322
+ {
323
+ $tmp = explode('_', $element, 2);
324
+
325
+ if(in_array($tmp[0], array('cpt', 'cpta'), TRUE))
326
+ {
327
+ $save_widgets['selection'][$tmp[0] === 'cpt' ? 'custom_post_types' : 'custom_post_types_archives'][$tmp[0].'_'.sanitize_key($tmp[1])] = TRUE;
328
+ }
329
+ }
330
+
331
+ foreach($this->pages as $page)
332
+ {
333
+ if(in_array('pageid_'.$page->ID, $selected, TRUE))
334
+ {
335
+ $save_widgets['selection']['pages']['pageid_'.$page->ID] = TRUE;
336
+ }
337
+ }
338
+
339
+ foreach(get_post_types(array('public' => TRUE, '_builtin' => FALSE), 'objects', 'and') as $cpt)
340
+ {
341
+ if(in_array('cpt_'.$cpt->name, $selected, TRUE))
342
+ {
343
+ $save_widgets['selection']['custom_post_types']['cpt_'.$cpt->name] = TRUE;
344
+ }
345
+ }
346
+
347
+ foreach($this->categories as $category)
348
+ {
349
+ if(in_array('category_'.$category->cat_ID, $selected, TRUE))
350
+ {
351
+ $save_widgets['selection']['categories']['category_'.$category->cat_ID] = TRUE;
352
+ }
353
+ }
354
+
355
+ foreach($this->taxonomies as $taxonomy)
356
+ {
357
+ if(in_array('taxonomy_'.$taxonomy->name, $selected, TRUE))
358
+ {
359
+ $save_widgets['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = TRUE;
360
+ }
361
+ }
362
+
363
+ foreach($this->others as $key => $value)
364
+ {
365
+ if(in_array('others_'.$key, $selected, TRUE))
366
+ {
367
+ $save_widgets['selection']['others']['others_'.$key] = TRUE;
368
+ }
369
+ }
370
+
371
+ foreach($this->users as $key => $value)
372
+ {
373
+ if(in_array('users_'.$key, $selected, TRUE))
374
+ {
375
+ $save_widgets['selection']['users']['users_'.$key] = TRUE;
376
+ }
377
+ }
378
+ }
379
+
380
+ //do we have some sidebars?
381
+ if(isset($_POST['options-widgets-sidebars']))
382
+ {
383
+ foreach($_POST['options-widgets-sidebars'] as $sidebar)
384
+ {
385
+ $save_widgets['sidebars'][$sidebar] = TRUE;
386
+ }
387
+ }
388
+
389
+ //do we have some roles?
390
+ $roles_a = (isset($_POST['options-widgets-roles']) ? $_POST['options-widgets-roles'] : array());
391
+
392
+ foreach($wp_roles->roles as $role_name => $role_array)
393
+ {
394
+ if($role_name !== 'administrator')
395
+ {
396
+ $role = get_role($role_name);
397
+
398
+ if(in_array($role_name, $roles_a))
399
+ {
400
+ $role->add_cap('manage_widgets');
401
+ }
402
+ else
403
+ {
404
+ $role->remove_cap('manage_widgets');
405
+ }
406
+ }
407
+ }
408
+
409
+ update_option('rw_widgets_options', $save_widgets);
410
+ }
411
+ }
412
+
413
+
414
+ public function add_widgets_options_box()
415
+ {
416
+ if(!current_user_can('manage_options'))
417
+ return;
418
+
419
+ global $wp_roles, $wp_registered_widgets, $wp_registered_sidebars;
420
+
421
+ $widgets_unique = array();
422
+ $option = get_option('rw_widgets_options');
423
+
424
+ if(isset($option['groups']) === FALSE) $option['groups'] = FALSE;
425
+ if(isset($option['deactivation']) === FALSE) $option['deactivation'] = FALSE;
426
+
427
+ //we need to make a copy for sorting
428
+ $widgets = $wp_registered_widgets;
429
+ usort($widgets, array(&$this, 'sort_widgets_by_name'));
430
+
431
+ //we need to make unique array to avoid duplicated instances of widgets later
432
+ foreach($widgets as $widget)
433
+ {
434
+ if(isset($widget['callback'][0]) && is_object($widget['callback'][0]))
435
+ {
436
+ $widgets_unique[get_class($widget['callback'][0])] = $widget['name'];
437
+ }
438
+ else
439
+ {
440
+ $widgets_unique[$widget['id']] = $widget['name'];
441
+ }
442
+ }
443
+
444
+ echo '
445
+ <div id="widgets-options" class="widgets-holder-wrap restrict-widgets">
446
+ <div class="sidebar-name">
447
+ <div class="sidebar-name-arrow"><br /></div>
448
+ <h3>'.__('Restrict widgets').'</h3>
449
+ </div>
450
+ <div class="widget-holder">
451
+ <form action="" method="post">
452
+ <p class="howto">'.__('Use this settings to manage access to widgets page and to restrict availability of certain widgets, sidebars and widgets options to site administrators only.', 'restrict-widgets').'</p>
453
+ <table>
454
+ <tr>
455
+ <td class="label"><label>'.__('Restrict Users', 'restrict-widgets').'</label></td>
456
+ <td>
457
+ <select name="options-widgets-roles[]" id="options-widgets-roles" multiple="multiple">';
458
+
459
+ foreach($wp_roles->roles as $role_name => $role_array)
460
+ {
461
+ echo '<option value="'.$role_name.'" '.selected((in_array('manage_widgets', array_keys($role_array['capabilities']), TRUE) ? TRUE : FALSE), TRUE, FALSE).' '.disabled(($role_name === 'administrator' ? TRUE : FALSE), TRUE, FALSE).'>'.$role_array['name'].'</option>';
462
+ }
463
+
464
+ echo ' </select>
465
+ <p class="description">'.__('Select user roles restricted to manage widgets.', 'restrict-widgets').'</p>
466
+ </td>
467
+ </tr>
468
+ <tr>
469
+ <td class="label"><label>'.__('Restrict Sidebars', 'restrict-widgets').'</label></td>
470
+ <td>
471
+ <select name="options-widgets-sidebars[]" id="options-widgets-sidebars" multiple="multiple">';
472
+
473
+ foreach($wp_registered_sidebars as $sidebar)
474
+ {
475
+ if($sidebar['id'] !== 'wp_inactive_widgets')
476
+ {
477
+ if(isset($option['sidebars'][$sidebar['id']]) === FALSE) $option['sidebars'][$sidebar['id']] = FALSE;
478
+
479
+ echo '<option value="'.$sidebar['id'].'" '.selected($option['sidebars'][$sidebar['id']], TRUE, FALSE).'>'.$sidebar['name'].'</option>';
480
+ }
481
+ }
482
+
483
+ echo ' </select>
484
+ <p class="description">'.__('Select which sidebars will be restricted to admins only.', 'restrict-widgets').'</p>
485
+ </td>
486
+ </tr>
487
+ <tr>
488
+ <td class="label"><label>'.__('Restrict Widgets', 'restrict-widgets').'</label></td>
489
+ <td>
490
+ <select name="options-available-widgets[]" id="options-available-widgets" multiple="multiple">';
491
+
492
+ foreach(array_unique($widgets_unique) as $widget_class => $widget_name)
493
+ {
494
+ if(isset($option['available'][$widget_class]) === FALSE) $option['available'][$widget_class] = FALSE;
495
+
496
+ echo '<option value="'.$widget_class.'" '.selected($option['available'][$widget_class], TRUE, FALSE).'>'.$widget_name.'</option>';
497
+ }
498
+
499
+ echo ' </select>
500
+ <p class="description">'.__('Select which widgets will be restricted to admins only.', 'restrict-widgets').'</p>
501
+ </td>
502
+ </tr>
503
+ <tr>
504
+ <td class="label"><label>'.__('Restrict Widget Options', 'restrict-widgets').'</label></td>
505
+ <td>
506
+ <select name="options-widgets-selection[]" id="options-widgets-selection" multiple="multiple">';
507
+
508
+ foreach($this->options as $group_name => $value)
509
+ {
510
+ echo $this->getSelectionGroup($group_name, 'option', '', '', $option);
511
+ }
512
+
513
+ echo ' </select>
514
+ <p class="description">'.__('Select which widget options will be restricted to admins only.', 'restrict-widgets').'</p>
515
+ </td>
516
+ </tr>
517
+ <tr>
518
+ <td class="label"><label>'.__('Restrict Option Groups', 'restrict-widgets').'</label></td>
519
+ <td>
520
+ <input type="checkbox" name="options-widgets-groups" id="options-widgets-groups" value="1" '.checked($option['groups'], TRUE, FALSE).' />
521
+ <label for="options-widgets-groups" class="description">'.__('Display widget options in groups', 'restrict-widgets').'</label>
522
+ </td>
523
+ </tr>
524
+ <tr>
525
+ <td class="label"><label>'.__('Plugin Deactivation', 'restrict-widgets').'</label></td>
526
+ <td>
527
+ <input type="checkbox" name="options-widgets-deactivation" id="options-widgets-deactivation" value="1" '.checked($option['deactivation'], TRUE, FALSE).' />
528
+ <label for="options-widgets-deactivation" class="description">'.__('Remove all plugin data on deactivation', 'restrict-widgets').'</label>
529
+ </td>
530
+ </tr>
531
+ </table>
532
+ <input type="submit" value="'.__('Save settings', 'restrict-widgets').'" name="save-widgets-options" class="button button-primary" id="save-widgets-options" />
533
+ <p id="df-credits">'.__('Created by', 'restrict-widgets').
534
+ '<a href="http://www.dfactory.eu" target="_blank" title="dFactory - Quality plugins for WordPress"><img src="'.plugins_url('images/logo-dfactory.png' ,__FILE__).'" title="dFactory - Quality plugins for WordPress" alt="dFactory - Quality plugins for WordPress" /></a></p>
535
+ <br class="clear" />
536
+ </form>
537
+ </div>
538
+ </div>';
539
+ }
540
+
541
+
542
+ private function sort_widgets_by_name($element_a, $element_b)
543
+ {
544
+ return strnatcasecmp($element_a['name'], $element_b['name']);
545
+ }
546
+
547
+
548
+ public function widgets_scripts_styles($page)
549
+ {
550
+ if($page !== 'widgets.php')
551
+ return;
552
+
553
+ wp_enqueue_script(
554
+ 'chosen',
555
+ plugins_url('js/chosen.jquery.min.js', __FILE__),
556
+ array('jquery')
557
+ );
558
+
559
+ wp_enqueue_script(
560
+ 'restrict-widgets',
561
+ plugins_url('js/restrict-widgets.js', __FILE__),
562
+ array('jquery', 'chosen')
563
+ );
564
+
565
+ $js_widgets = $js_class = $js_nonclass = array();
566
+ $orphan_sidebar = 0;
567
+
568
+ if(!current_user_can('manage_options'))
569
+ {
570
+ global $wp_registered_widgets;
571
+
572
+ $option = get_option('rw_widgets_options');
573
+ $restrict = array_keys($option['available']);
574
+ $widgets = array();
575
+ $orphan_sidebar = 1;
576
+
577
+ foreach(wp_get_sidebars_widgets() as $sidebar)
578
+ {
579
+ foreach($sidebar as $widget)
580
+ {
581
+ $widgets[] = $widget;
582
+ }
583
+ }
584
+
585
+ foreach($widgets as $widget)
586
+ {
587
+ if(isset($wp_registered_widgets[$widget]['callback'][0]))
588
+ {
589
+ if(in_array(get_class($wp_registered_widgets[$widget]['callback'][0]), $restrict))
590
+ {
591
+ $js_widgets[] = $widget;
592
+ }
593
+ }
594
+ }
595
+
596
+ foreach($wp_registered_widgets as $widget)
597
+ {
598
+ if(isset($widget['callback'][0]) && is_object($widget['callback'][0]) && in_array(get_class($widget['callback'][0]), $restrict))
599
+ {
600
+ $js_class[] = $widget['callback'][0]->id_base;
601
+ }
602
+ elseif(in_array($widget['id'], $restrict))
603
+ {
604
+ $js_nonclass[] = $widget['id'];
605
+ }
606
+ }
607
+ }
608
+
609
+ wp_localize_script(
610
+ 'restrict-widgets',
611
+ 'restrict_widgets_args',
612
+ array(
613
+ 'placeholder_text' => esc_attr__('Select options', 'restrict-widgets'),
614
+ 'restrict_available_widgets' => esc_attr__('Select widgets', 'restrict-widgets'),
615
+ 'restrict_widgets_selection' => esc_attr__('Select widgets options', 'restrict-widgets'),
616
+ 'restrict_sidebars' => esc_attr__('Select sidebars', 'restrict-widgets'),
617
+ 'restrict_roles' => esc_attr__('Select roles', 'restrict-widgets'),
618
+ 'restrict_languages' => esc_attr__('Select languages', 'restrict-widgets'),
619
+ 'restrict_widgets' => $js_widgets,
620
+ 'restrict_class' => array_unique($js_class),
621
+ 'restrict_nonclass' => array_unique($js_nonclass),
622
+ 'restrict_orphan_sidebar' => $orphan_sidebar
623
+ )
624
+ );
625
+
626
+ wp_enqueue_style('chosen', plugins_url('css/chosen.css', __FILE__));
627
+ wp_enqueue_style('style', plugins_url('css/style.css', __FILE__));
628
+ }
629
+
630
+
631
+ private function getSelectionGroup($group_name, $type, $widget = '', $instance = '', $option = '')
632
+ {
633
+ $rw_option = get_option('rw_widgets_options');
634
+ $html = '';
635
+
636
+ switch($group_name)
637
+ {
638
+ case 'pages':
639
+ {
640
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
641
+ {
642
+ $html .= '<optgroup label="'.$this->options['pages'].'">';
643
+ }
644
+
645
+ foreach($this->pages as $page)
646
+ {
647
+ switch($type)
648
+ {
649
+ case 'option':
650
+ {
651
+ if(isset($option['selection']['pages']['pageid_'.$page->ID]) === FALSE) $option['selection']['pages']['pageid_'.$page->ID] = FALSE;
652
+
653
+ $html .= '<option value="pageid_'.$page->ID.'" '.selected($option['selection']['pages']['pageid_'.$page->ID], TRUE, FALSE).'>'.$page->post_title.'</option>';
654
+
655
+ break;
656
+ }
657
+ case 'widget':
658
+ {
659
+ if(!isset($rw_option['selection']['pages']['pageid_'.$page->ID]) || current_user_can('manage_options'))
660
+ {
661
+ if(isset($instance['rw_opt']['pageid_'.$page->ID]) === FALSE) $instance['rw_opt']['pageid_'.$page->ID] = 0;
662
+
663
+ $html .= '<option value="pageid_'.$page->ID.'" '.selected($instance['rw_opt']['pageid_'.$page->ID], TRUE, FALSE).'>'.$page->post_title.'</option>';
664
+ }
665
+
666
+ break;
667
+ }
668
+ }
669
+ }
670
+
671
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
672
+ {
673
+ $html .= '</optgroup>';
674
+ }
675
+
676
+ return $html;
677
+ }
678
+ case 'custom_post_types':
679
+ {
680
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
681
+ {
682
+ $html .= '<optgroup label="'.$this->options['custom_post_types'].'">';
683
+ }
684
+
685
+ foreach($this->custom_post_types as $cpt)
686
+ {
687
+ switch($type)
688
+ {
689
+ case 'option':
690
+ {
691
+ if(isset($option['selection']['custom_post_types']['cpt_'.$cpt->name]) === FALSE) $option['selection']['custom_post_types']['cpt_'.$cpt->name] = FALSE;
692
+
693
+ $html .= '<option value="cpt_'.$cpt->name.'" '.selected($option['selection']['custom_post_types']['cpt_'.$cpt->name], TRUE, FALSE).'>'.sprintf(__('Single %s','restrict-widgets'), $cpt->label).'</option>';
694
+
695
+ break;
696
+ }
697
+ case 'widget':
698
+ {
699
+ if(!isset($rw_option['selection']['custom_post_types']['cpt_'.$cpt->name]) || current_user_can('manage_options'))
700
+ {
701
+ if(isset($instance['rw_opt']['cpt_'.$cpt->name]) === FALSE) $instance['rw_opt']['cpt_'.$cpt->name] = 0;
702
+
703
+ $html .= '<option value="cpt_'.$cpt->name.'" '.selected($instance['rw_opt']['cpt_'.$cpt->name], TRUE, FALSE).'>'.sprintf(__('Single %s','restrict-widgets'), $cpt->label).'</option>';
704
+ }
705
+
706
+ break;
707
+ }
708
+ }
709
+ }
710
+
711
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
712
+ {
713
+ $html .= '</optgroup>';
714
+ }
715
+
716
+ return $html;
717
+ }
718
+ case 'custom_post_types_archives':
719
+ {
720
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
721
+ {
722
+ $html .= '<optgroup label="'.$this->options['custom_post_types_archives'].'">';
723
+ }
724
+
725
+ foreach($this->custom_post_types_archives as $cpta)
726
+ {
727
+ switch($type)
728
+ {
729
+ case 'option':
730
+ {
731
+ if(isset($option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) === FALSE) $option['selection']['custom_post_types_archives']['cpta_'.$cpta->name] = FALSE;
732
+
733
+ $html .= '<option value="cpta_'.$cpta->name.'" '.selected($option['selection']['custom_post_types_archives']['cpta_'.$cpta->name], TRUE, FALSE).'>'.sprintf(__('%s Archive','restrict-widgets'), $cpta->label).'</option>';
734
+
735
+ break;
736
+ }
737
+ case 'widget':
738
+ {
739
+ if(!isset($rw_option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) || current_user_can('manage_options'))
740
+ {
741
+ if(isset($instance['rw_opt']['cpta_'.$cpta->name]) === FALSE) $instance['rw_opt']['cpta_'.$cpta->name] = 0;
742
+
743
+ $html .= '<option value="cpta_'.$cpta->name.'" '.selected($instance['rw_opt']['cpta_'.$cpta->name], TRUE, FALSE).'>'.sprintf(__('%s Archive','restrict-widgets'), $cpta->label).'</option>';
744
+ }
745
+
746
+ break;
747
+ }
748
+ }
749
+ }
750
+
751
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
752
+ {
753
+ $html .= '</optgroup>';
754
+ }
755
+
756
+ return $html;
757
+ }
758
+ case 'categories':
759
+ {
760
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
761
+ {
762
+ $html .= '<optgroup label="'.$this->options['categories'].'">';
763
+ }
764
+
765
+ foreach($this->categories as $category)
766
+ {
767
+ switch($type)
768
+ {
769
+ case 'option':
770
+ {
771
+ if(isset($option['selection']['categories']['category_'.$category->cat_ID]) === FALSE) $option['selection']['categories']['category_'.$category->cat_ID] = FALSE;
772
+
773
+ $html .= '<option value="category_'.$category->cat_ID.'" '.selected($option['selection']['categories']['category_'.$category->cat_ID], TRUE, FALSE).'>'.$category->cat_name.'</option>';
774
+
775
+ break;
776
+ }
777
+ case 'widget':
778
+ {
779
+ if(!isset($rw_option['selection']['categories']['category_'.$category->cat_ID]) || current_user_can('manage_options'))
780
+ {
781
+ if(isset($instance['rw_opt']['category_'.$category->cat_ID]) === FALSE) $instance['rw_opt']['category_'.$category->cat_ID] = 0;
782
+
783
+ $html .= '<option value="category_'.$category->cat_ID.'" '.selected($instance['rw_opt']['category_'.$category->cat_ID], TRUE, FALSE).'>'.$category->cat_name.'</option>';
784
+ }
785
+
786
+ break;
787
+ }
788
+ }
789
+ }
790
+
791
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
792
+ {
793
+ $html .= '</optgroup>';
794
+ }
795
+
796
+ return $html;
797
+ }
798
+ case 'taxonomies':
799
+ {
800
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
801
+ {
802
+ $html .= '<optgroup label="'.$this->options['taxonomies'].'">';
803
+ }
804
+
805
+ foreach($this->taxonomies as $taxonomy)
806
+ {
807
+ switch($type)
808
+ {
809
+ case 'option':
810
+ {
811
+ if(isset($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) === FALSE) $option['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = FALSE;
812
+
813
+ $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name], TRUE, FALSE).'>'.$taxonomy->label.'</option>';
814
+
815
+ break;
816
+ }
817
+ case 'widget':
818
+ {
819
+ if(!isset($rw_option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) || current_user_can('manage_options'))
820
+ {
821
+ if(isset($instance['rw_opt']['taxonomy_'.$taxonomy->name]) === FALSE) $instance['rw_opt']['taxonomy_'.$taxonomy->name] = 0;
822
+
823
+ $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($instance['rw_opt']['taxonomy_'.$taxonomy->name], TRUE, FALSE).'>'.$taxonomy->label.'</option>';
824
+ }
825
+
826
+ break;
827
+ }
828
+ }
829
+ }
830
+
831
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
832
+ {
833
+ $html .= '</optgroup>';
834
+ }
835
+
836
+ return $html;
837
+ }
838
+ case 'others':
839
+ {
840
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
841
+ {
842
+ $html .= '<optgroup label="'.$this->options['others'].'">';
843
+ }
844
+
845
+ foreach($this->others as $key => $value)
846
+ {
847
+ switch($type)
848
+ {
849
+ case 'option':
850
+ {
851
+ if(isset($option['selection']['others']['others_'.$key]) === FALSE) $option['selection']['others']['others_'.$key] = FALSE;
852
+
853
+ $html .= '<option value="others_'.$key.'" '.selected($option['selection']['others']['others_'.$key], TRUE, FALSE).'>'.$value.'</option>';
854
+
855
+ break;
856
+ }
857
+ case 'widget':
858
+ {
859
+ if(!isset($rw_option['selection']['others']['others_'.$key]) || current_user_can('manage_options'))
860
+ {
861
+ if(isset($instance['rw_opt']['others_'.$key]) === FALSE) $instance['rw_opt']['others_'.$key] = 0;
862
+
863
+ $html .= '<option value="others_'.$key.'" '.selected($instance['rw_opt']['others_'.$key], TRUE, FALSE).'>'.$value.'</option>';
864
+ }
865
+
866
+ break;
867
+ }
868
+ }
869
+ }
870
+
871
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
872
+ {
873
+ $html .= '</optgroup>';
874
+ }
875
+
876
+ return $html;
877
+ }
878
+ case 'users':
879
+ {
880
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
881
+ {
882
+ $html .= '<optgroup label="'.$this->options['users'].'">';
883
+ }
884
+
885
+ foreach($this->users as $key => $value)
886
+ {
887
+ switch($type)
888
+ {
889
+ case 'option':
890
+ {
891
+ if(isset($option['selection']['users']['users_'.$key]) === FALSE) $option['selection']['users']['users_'.$key] = FALSE;
892
+
893
+ $html .= '<option value="users_'.$key.'" '.selected($option['selection']['users']['users_'.$key], TRUE, FALSE).'>'.$value.'</option>';
894
+
895
+ break;
896
+ }
897
+ case 'widget':
898
+ {
899
+ if(!isset($rw_option['selection']['users']['users_'.$key]) || current_user_can('manage_options'))
900
+ {
901
+ if(isset($instance['rw_opt']['users_'.$key]) === FALSE) $instance['rw_opt']['users_'.$key] = 0;
902
+
903
+ $html .= '<option value="users_'.$key.'" '.selected($instance['rw_opt']['users_'.$key], TRUE, FALSE).'>'.$value.'</option>';
904
+ }
905
+
906
+ break;
907
+ }
908
+ }
909
+ }
910
+
911
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
912
+ {
913
+ $html .= '</optgroup>';
914
+ }
915
+
916
+ return $html;
917
+ }
918
+ case 'languages':
919
+ {
920
+ if($this->languages !== FALSE)
921
+ {
922
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
923
+ {
924
+ $html .= '<optgroup label="'.$this->options['languages'].'">';
925
+ }
926
+
927
+ foreach($this->languages as $key => $language)
928
+ {
929
+ switch($type)
930
+ {
931
+ case 'option':
932
+ {
933
+ if(isset($option['selection']['languages']['language_'.$key]) === FALSE) $option['selection']['languages']['language_'.$key] = FALSE;
934
+
935
+ $html .= '<option value="language_'.$key.'" '.selected($option['selection']['languages']['language_'.$key], TRUE, FALSE).'>'.$language['native_name'].'</option>';
936
+
937
+ break;
938
+ }
939
+ case 'widget':
940
+ {
941
+ if(!isset($rw_option['selection']['languages']['language_'.$key]) || current_user_can('manage_options'))
942
+ {
943
+ if(isset($instance['rw_opt']['language_'.$key]) === FALSE) $instance['rw_opt']['language_'.$key] = 0;
944
+
945
+ $html .= '<option value="language_'.$key.'" '.selected($instance['rw_opt']['language_'.$key], TRUE, FALSE).'>'.$language['native_name'].'</option>';
946
+ }
947
+
948
+ break;
949
+ }
950
+ }
951
+ }
952
+
953
+ if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
954
+ {
955
+ $html .= '</optgroup>';
956
+ }
957
+
958
+ return $html;
959
+ }
960
+ }
961
+ }
962
+ }
963
+
964
+
965
+ public function display_admin_widgets_options($widget, $empty, $instance)
966
+ {
967
+ if(isset($instance['rw_opt']['widget_select']) === FALSE) $instance['rw_opt']['widget_select'] = FALSE;
968
+
969
+ echo '
970
+ <div class="restrict-widgets-hide-div restrict-widgets">
971
+ <p class="restrict-widgets-display-label">'.__('Display / Hide Widget', 'restrict-widgets').'</p>
972
+ <select name="'.$widget->get_field_name('widget_select').'" class="restrict-widgets-hide">
973
+ <option value="yes" '.selected($instance['rw_opt']['widget_select'], TRUE, FALSE).'>'.__('Display widget on selected', 'restrict-widgets').'</option>
974
+ <option value="no" '.selected($instance['rw_opt']['widget_select'], FALSE, FALSE).'>'.__('Hide widget on selected', 'restrict-widgets').'</option>
975
+ </select>
976
+ </div>
977
+ <div class="restrict-widgets-select-div restrict-widgets">
978
+ <select class="restrict-widgets-select" multiple="multiple" size="10" name="'.$widget->get_field_name('widget_multiselect').'[]">';
979
+
980
+ foreach($this->options as $option => $text)
981
+ {
982
+ echo $this->getSelectionGroup($option, 'widget', $widget, $instance);
983
+ }
984
+
985
+ echo '
986
+ </select>
987
+ </div>';
988
+ }
989
+
990
+
991
+ public function update_admin_widgets_options($instance, $new_instance)
992
+ {
993
+ $instance['rw_opt']['widget_select'] = ($new_instance['widget_select'] === 'yes' ? TRUE : FALSE);
994
+
995
+ if(is_array($new_instance['widget_multiselect']))
996
+ {
997
+ $selected = $new_instance['widget_multiselect'];
998
+
999
+ foreach($this->pages as $page)
1000
+ {
1001
+ if(in_array('pageid_'.$page->ID, $selected))
1002
+ {
1003
+ $instance['rw_opt']['pageid_'.$page->ID] = TRUE;
1004
+ }
1005
+ else
1006
+ {
1007
+ unset($instance['rw_opt']['pageid_'.$page->ID]);
1008
+ }
1009
+ }
1010
+
1011
+ foreach($this->custom_post_types as $cpt)
1012
+ {
1013
+ if(in_array('cpt_'.$cpt->name, $selected))
1014
+ {
1015
+ $instance['rw_opt']['cpt_'.$cpt->name] = TRUE;
1016
+ }
1017
+ else
1018
+ {
1019
+ unset($instance['rw_opt']['cpt_'.$cpt->name]);
1020
+ }
1021
+ }
1022
+
1023
+ foreach($this->custom_post_types_archives as $cpta)
1024
+ {
1025
+ if(in_array('cpta_'.$cpta->name, $selected))
1026
+ {
1027
+ $instance['rw_opt']['cpta_'.$cpta->name] = TRUE;
1028
+ }
1029
+ else
1030
+ {
1031
+ unset($instance['rw_opt']['cpta_'.$cpta->name]);
1032
+ }
1033
+ }
1034
+
1035
+ foreach($this->categories as $category)
1036
+ {
1037
+ if(in_array('category_'.$category->cat_ID, $selected))
1038
+ {
1039
+ $instance['rw_opt']['category_'.$category->cat_ID] = TRUE;
1040
+ }
1041
+ else
1042
+ {
1043
+ unset($instance['rw_opt']['category_'.$category->cat_ID]);
1044
+ }
1045
+ }
1046
+
1047
+ foreach($this->taxonomies as $taxonomy)
1048
+ {
1049
+ if(in_array('taxonomy_'.$taxonomy->name, $selected))
1050
+ {
1051
+ $instance['rw_opt']['taxonomy_'.$taxonomy->name] = TRUE;
1052
+ }
1053
+ else
1054
+ {
1055
+ unset($instance['rw_opt']['taxonomy_'.$taxonomy->name]);
1056
+ }
1057
+ }
1058
+
1059
+ foreach($this->others as $key => $value)
1060
+ {
1061
+ if(in_array('others_'.$key, $selected))
1062
+ {
1063
+ $instance['rw_opt']['others_'.$key] = TRUE;
1064
+ }
1065
+ else
1066
+ {
1067
+ unset($instance['rw_opt']['others_'.$key]);
1068
+ }
1069
+ }
1070
+
1071
+ foreach($this->users as $key => $value)
1072
+ {
1073
+ if(in_array('users_'.$key, $selected))
1074
+ {
1075
+ $instance['rw_opt']['users_'.$key] = TRUE;
1076
+ }
1077
+ else
1078
+ {
1079
+ unset($instance['rw_opt']['users_'.$key]);
1080
+ }
1081
+ }
1082
+
1083
+ if($this->languages !== FALSE)
1084
+ {
1085
+ foreach($this->languages as $key => $value)
1086
+ {
1087
+ if(in_array('language_'.$key, $selected))
1088
+ {
1089
+ $instance['rw_opt']['language_'.$key] = TRUE;
1090
+ }
1091
+ else
1092
+ {
1093
+ unset($instance['rw_opt']['language_'.$key]);
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+
1099
+ return $instance;
1100
+ }
1101
+
1102
+
1103
+ public function display_frontend_widgets($instance)
1104
+ {
1105
+ // var_dump($instance);
1106
+
1107
+ /*
1108
+ others_
1109
+ + front_page
1110
+ + blog_page
1111
+ + single_post
1112
+ + sticky_post
1113
+ + author_archive
1114
+ + date_archive
1115
+ + 404_page
1116
+ + search_page
1117
+
1118
+ users_
1119
+ logged_in
1120
+ logged_out
1121
+
1122
+ +cpt_
1123
+ +cpta_
1124
+ +taxonomy_
1125
+ +category_
1126
+ language_
1127
+ +pageid_
1128
+ */
1129
+
1130
+ global $wp_query;
1131
+
1132
+ $post_id = $wp_query->get_queried_object_id();
1133
+
1134
+ if(function_exists('icl_get_languages') || function_exists('pll_the_languages'))
1135
+ {
1136
+
1137
+ $post_id = icl_object_id($post_id, 'page', FALSE);
1138
+
1139
+ if(defined('ICL_LANGUAGE_CODE'))
1140
+ {
1141
+ $display = isset($instance['rw_opt']['language_'.ICL_LANGUAGE_CODE]) ? TRUE : FALSE;
1142
+ }
1143
+
1144
+ if(isset($instance['rw_opt']['widget_select']))
1145
+ {
1146
+ if (($instance['rw_opt']['widget_select'] === TRUE && $display === FALSE) || ($instance['rw_opt']['widget_select'] === FALSE && $display === TRUE))
1147
+ {
1148
+ return FALSE;
1149
+ }
1150
+ }
1151
+ }
1152
+
1153
+ if (isset($instance['rw_opt']['users_logged_in']) || isset($instance['rw_opt']['users_logged_out']))
1154
+ {
1155
+ if(is_user_logged_in())
1156
+ {
1157
+ $display = isset($instance['rw_opt']['users_logged_in']) ? TRUE : FALSE;
1158
+ }
1159
+ else
1160
+ {
1161
+ $display = isset($instance['rw_opt']['users_logged_out']) ? TRUE : FALSE;
1162
+ }
1163
+ if(isset($instance['rw_opt']['widget_select']))
1164
+ {
1165
+ if (($instance['rw_opt']['widget_select'] === TRUE && $display === FALSE) || ($instance['rw_opt']['widget_select'] === FALSE && $display === TRUE))
1166
+ {
1167
+ return FALSE;
1168
+ }
1169
+ }
1170
+ }
1171
+
1172
+ if(is_front_page())
1173
+ {
1174
+ $display = isset($instance['rw_opt']['others_front_page']) ? TRUE : FALSE;
1175
+
1176
+ if(is_home() && $display == FALSE)
1177
+ {
1178
+ $display = isset($instance['rw_opt']['others_blog_page']) ? TRUE : FALSE;
1179
+ }
1180
+ }
1181
+ elseif(is_home())
1182
+ {
1183
+ $display = isset($instance['rw_opt']['others_blog_page']) ? TRUE : FALSE;
1184
+ }
1185
+ elseif(is_page())
1186
+ {
1187
+ $display = isset($instance['rw_opt']['pageid_'.$post_id]) ? TRUE : FALSE;
1188
+ }
1189
+ elseif(is_singular())
1190
+ {
1191
+ $display = isset($instance['rw_opt']['cpt_'.get_post_type($post_id)]) ? TRUE : FALSE;
1192
+
1193
+ if(is_single() && $display == FALSE)
1194
+ {
1195
+ $display = isset($instance['rw_opt']['others_single_post']) ? TRUE : FALSE;
1196
+ }
1197
+ }
1198
+ elseif(is_category())
1199
+ {
1200
+ $display = isset($instance['rw_opt']['category_'.get_query_var('cat')]) ? TRUE : FALSE;
1201
+ }
1202
+ elseif(is_tax())
1203
+ {
1204
+ $display = isset($instance['rw_opt']['taxonomy_'.get_query_var('taxonomy')]) ? TRUE : FALSE;
1205
+ }
1206
+ elseif(is_404())
1207
+ {
1208
+ $display = isset($instance['rw_opt']['others_404_page']) ? TRUE : FALSE;
1209
+ }
1210
+ elseif(is_sticky())
1211
+ {
1212
+ $display = isset($instance['rw_opt']['others_sticky_post']) ? TRUE : FALSE;
1213
+ }
1214
+ elseif(is_search())
1215
+ {
1216
+ $display = isset($instance['rw_opt']['others_search_page']) ? TRUE : FALSE;
1217
+ }
1218
+ elseif(is_author())
1219
+ {
1220
+ $display = isset($instance['rw_opt']['others_author_archive']) ? TRUE : FALSE;
1221
+ }
1222
+ elseif(is_date())
1223
+ {
1224
+ $display = isset($instance['rw_opt']['others_date_archive']) ? TRUE : FALSE;
1225
+ }
1226
+ elseif(is_post_type_archive())
1227
+ {
1228
+ $display = isset($instance['rw_opt']['cpta_'.get_post_type($post_id)]) ? TRUE : FALSE;
1229
+ }
1230
+
1231
+ if(!isset($display))
1232
+ {
1233
+ $display = FALSE;
1234
+ }
1235
+
1236
+ if(isset($instance['rw_opt']['widget_select']))
1237
+ {
1238
+ if (($instance['rw_opt']['widget_select'] === TRUE && $display === FALSE) || ($instance['rw_opt']['widget_select'] === FALSE && $display === TRUE))
1239
+ {
1240
+ return FALSE;
1241
+ }
1242
+ }
1243
+
1244
+ return $instance;
1245
+ }
1246
+
1247
+
1248
+ /**
1249
+ * Display Appearance menu and link to widgets.php if user can manage_widgets
1250
+ */
1251
+ public function manage_widgets_menu()
1252
+ {
1253
+ global $menu, $submenu;
1254
+
1255
+ // if user can manage widgets but can't edit_theme_options, add widgets menu (appearance)
1256
+ if(current_user_can('manage_widgets') && !current_user_can('edit_theme_options'))
1257
+ {
1258
+ foreach($menu as $menu_key => $menu_values)
1259
+ {
1260
+ if(isset($menu_values[5]) && $menu_values[5] === 'menu-appearance')
1261
+ {
1262
+ // if appearance menu not exists
1263
+ if(empty($submenu[$menu_values[2]]))
1264
+ {
1265
+ $menu[$menu_key][1] = 'manage_widgets';
1266
+ $menu[$menu_key][2] = 'widgets.php';
1267
+ }
1268
+ else
1269
+ // if appearance menu exists
1270
+ {
1271
+ foreach($submenu[$menu_values[2]] as $submenu_key => $submenu_values)
1272
+ {
1273
+ $submenu[$menu_values[2]][7] = array(__('Widgets'), 'manage_widgets', 'widgets.php');
1274
+ }
1275
+ }
1276
+ }
1277
+ }
1278
+ } // if user can't manage widgets but can edit_theme_options, remove widgets from menu
1279
+ elseif(!current_user_can('manage_widgets') && current_user_can('edit_theme_options'))
1280
+ {
1281
+ foreach($menu as $menu_key => $menu_values)
1282
+ {
1283
+ if(isset($menu_values[5]) && $menu_values[5] === 'menu-appearance')
1284
+ {
1285
+ foreach($submenu[$menu_values[2]] as $submenu_key => $submenu_values)
1286
+ {
1287
+ if(isset($submenu_values[2]) && $submenu_values[2] == 'widgets.php')
1288
+ {
1289
+ $submenu[$menu_values[2]][$submenu_key][1] = 'manage_widgets';
1290
+ }
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1295
+ }
1296
+
1297
+
1298
+ /**
1299
+ * Fix for Appearance menu items on widgets.php if user can manage_widgets but can't edit theme options
1300
+ */
1301
+ public function manage_widgets_menu_fix()
1302
+ {
1303
+ global $menu, $submenu;
1304
+
1305
+ foreach($menu as $menu_key => $menu_values)
1306
+ {
1307
+ if(isset($menu_values[5]) && $menu_values[5] === 'menu-appearance')
1308
+ {
1309
+ // if appearance menu not exists
1310
+ if(empty($submenu[$menu_values[2]]))
1311
+ {
1312
+ $menu[$menu_key][1] = 'manage_widgets';
1313
+ $menu[$menu_key][2] = 'widgets.php';
1314
+ }
1315
+ else
1316
+ // if appearance menu exists
1317
+ {
1318
+ $submenu[$menu_values[2]][7] = array(__('Widgets'), 'manage_widgets', 'widgets.php');
1319
+
1320
+ // remove menus with edit_theme_options capability
1321
+ foreach($submenu[$menu_values[2]] as $submenu_key => $submenu_values)
1322
+ {
1323
+ if($submenu_values[1] == 'edit_theme_options')
1324
+ {
1325
+ unset($submenu[$menu_values[2]][$submenu_key]);
1326
+ }
1327
+ }
1328
+
1329
+ // fix if appearance menu item is only 1, remove submenu
1330
+ if(count($submenu[$menu_values[2]]) < 2)
1331
+ {
1332
+ unset($submenu[$menu_values[2]][7]);
1333
+ $menu[$menu_key][1] = 'manage_widgets';
1334
+ $menu[$menu_key][2] = 'widgets.php';
1335
+ }
1336
+ }
1337
+ }
1338
+ }
1339
+ }
1340
+
1341
+
1342
+ /**
1343
+ * Manage Widgets Capability
1344
+ */
1345
+ public function manage_widgets_cap($allcaps, $cap, $args)
1346
+ {
1347
+ global $pagenow;
1348
+
1349
+ if($pagenow === 'widgets.php' || (defined('DOING_AJAX') && DOING_AJAX))
1350
+ {
1351
+ // break if we're not asking to edit widgets
1352
+ if(('edit_theme_options' != $args[0]) || empty($allcaps['manage_widgets']))
1353
+ {
1354
+ return $allcaps;
1355
+ }
1356
+ else
1357
+ {
1358
+ // if user can't edit_theme_options but can manage_widgets
1359
+ if(empty($allcaps['edit_theme_options']))
1360
+ {
1361
+ // menu fix
1362
+ add_action('admin_menu', array(&$this, 'manage_widgets_menu_fix'), 999);
1363
+ // add cap to edit widgets
1364
+ $allcaps['edit_theme_options'] = TRUE;
1365
+ }
1366
+ }
1367
+ }
1368
+
1369
+ return $allcaps;
1370
+ }
1371
+ }
1372
+
1373
+
1374
+ $rw_in = new RestrictWidgets();
1375
+ ?>