Restrict Widgets - Version 1.2.5

Version Description

  • Tweak: UI improvements
  • Tweak: jQuery chosen updated to 1.2.0
Download this release

Release Info

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

Code changes from version 1.2.4 to 1.2.5

Files changed (7) hide show
  1. css/admin.css +9 -66
  2. css/chosen.css +17 -17
  3. css/chosen.min.css +3 -0
  4. js/admin.js +7 -12
  5. js/chosen.jquery.min.js +2 -10
  6. readme.txt +9 -5
  7. restrict-widgets.php +269 -269
css/admin.css CHANGED
@@ -1,66 +1,9 @@
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-left #widgets-options {
65
  margin-left: 0;
66
  margin-right: 0;
@@ -77,20 +20,20 @@
77
  line-height:20px;
78
  }
79
  #widgets-options select {
80
- width: 100%;
81
- -webkit-box-sizing : border-box;‌​
82
- -moz-box-sizing : border-box;
83
- box-sizing : border-box;
84
  }
85
  .widget-liquid-right .widget, .inactive-sidebar .widget, .widget-liquid-right .sidebar-description {
86
  overflow: visible !important;
87
  }
88
  #widgets-options table { width:100%; }
89
- #widgets-options .label { width:30%; vertical-align:top; line-height:12px; font-weight:bold; color:#222; }
 
90
  #widgets-options #save-widgets-options { margin: 20px 0 0 0; }
91
- #widgets-options form .description { font-style: italic; }
 
92
 
93
  #df-credits { float:right; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-style:italic; margin:15px 0 0; display:block; }
94
- #df-credits a { padding: 5px 0 0 7px; vertical-align:middle; }
95
-
96
- .widgets-holder-wrap .widgets-sortables { min-height:0!important; height:auto!important; }
 
 
 
 
1
  .restrict-widgets .restrict-widgets-select, .restrict-widgets .restrict-widgets-hide {
2
  width:100%;
3
  }
4
  .widget .widget-inside p.restrict-widgets-display-label { margin-bottom:3px; }
5
  .restrict-widgets-select-div { clear:both; }
6
  .restrict-widgets-hide-div { clear:both; margin-bottom:3px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  #widgets-left #widgets-options {
8
  margin-left: 0;
9
  margin-right: 0;
20
  line-height:20px;
21
  }
22
  #widgets-options select {
23
+ width: 100% !important;
24
+ -webkit-box-sizing: border-box;‌​
25
+ -moz-box-sizing: border-box;
26
+ box-sizing: border-box;
27
  }
28
  .widget-liquid-right .widget, .inactive-sidebar .widget, .widget-liquid-right .sidebar-description {
29
  overflow: visible !important;
30
  }
31
  #widgets-options table { width:100%; }
32
+ #widgets-options label { vertical-align:top; margin: 10px 0; display: inline-block; font-weight:bold; }
33
+ #widgets-options label .description { font-weight: normal; }
34
  #widgets-options #save-widgets-options { margin: 20px 0 0 0; }
35
+ #widgets-options form .description { font-style: italic; padding: 0; }
36
+ .widgets-holder-wrap .widgets-sortables { min-height:0!important; height:auto!important; }
37
 
38
  #df-credits { float:right; font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif; font-style:italic; margin:15px 0 0; display:block; }
39
+ #df-credits a { padding: 5px 0 0 7px; vertical-align:middle; }
 
 
css/chosen.css CHANGED
@@ -69,7 +69,7 @@
69
  width: 12px;
70
  height: 12px;
71
  font-size: 1px;
72
- background: url('../images/chosen-sprite.png') -42px 1px no-repeat;
73
  }
74
  .chzn-container-single .chzn-single abbr:hover {
75
  background-position: -42px -10px;
@@ -86,7 +86,7 @@
86
  width: 18px;
87
  }
88
  .chzn-container-single .chzn-single div b {
89
- background: url('../images/chosen-sprite.png') no-repeat 0px 2px;
90
  display: block;
91
  width: 100%;
92
  height: 100%;
@@ -99,12 +99,12 @@
99
  z-index: 1010;
100
  }
101
  .chzn-container-single .chzn-search input {
102
- background: #fff url('../images/chosen-sprite.png') no-repeat 100% -20px;
103
- background: url('../images/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('../images/chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
105
- background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
106
- background: url('../images/chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
107
- background: url('../images/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;
@@ -219,7 +219,7 @@
219
  width: 12px;
220
  height: 12px;
221
  font-size: 1px;
222
- background: url('../images/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;
@@ -304,10 +304,10 @@
304
  bottom: 0;
305
  }
306
  .chzn-container .chzn-results-scroll-down span {
307
- background: url('../images/chosen-sprite.png') no-repeat -4px -3px;
308
  }
309
  .chzn-container .chzn-results-scroll-up span {
310
- background: url('../images/chosen-sprite.png') no-repeat -22px -3px;
311
  }
312
  /* @end */
313
 
@@ -385,12 +385,12 @@
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('../images/chosen-sprite.png') no-repeat -30px -20px;
389
- background: url('../images/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('../images/chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
391
- background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
392
- background: url('../images/chosen-sprite.png') no-repeat -30px -20px, -o-linear-gradient(top, #eeeeee 1%, #ffffff 15%);
393
- background: url('../images/chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
394
  padding: 4px 5px 4px 20px;
395
  direction: rtl;
396
  }
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;
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%;
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;
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;
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
 
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
  }
css/chosen.min.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /* Chosen v1.2.0 | (c) 2011-2014 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+
3
+ .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;zoom:1;*display:inline;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:25px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(../images/chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(../images/chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(../images/chosen-sprite.png) no-repeat 100% -20px;background:url(../images/chosen-sprite.png) no-repeat 100% -20px;font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{color:#444;position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px;word-wrap:break-word;-webkit-touch-callout:none}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{color:#777;display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;margin:0;padding:0 5px;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:0;height:25px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#999;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 5px 3px 0;padding:3px 20px 3px 5px;border:1px solid #aaa;max-width:100%;border-radius:3px;background-color:#eee;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-size:100% 19px;background-repeat:repeat-x;background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice span{word-wrap:break-word}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(../images/chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#222!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(../images/chosen-sprite.png) no-repeat -30px -20px;background:url(../images/chosen-sprite.png) no-repeat -30px -20px;direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min-resolution:144dpi){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(../images/chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
js/admin.js CHANGED
@@ -23,21 +23,16 @@ jQuery(document).ready(function ($) {
23
  $('#options-widgets-sidebars').chosen({placeholder_text: rwArgs.restrict_sidebars});
24
  $('#options-widgets-roles').chosen({placeholder_text: rwArgs.restrict_roles});
25
 
26
- $(document).on('mouseover', '#widgets-right, .inactive-sidebar', function() {
27
- $(this).find('.restrict-widgets-hide').chosen({
28
- allow_single_deselect: true,
29
- disable_search: true
30
- });
31
-
32
- $(this).find('.restrict-widgets-select').chosen({placeholder_text: rwArgs.placeholder_text});
33
- });
34
-
35
- $(document).on('ajaxStop', function() {
36
  $('#widgets-right .restrict-widgets-hide, .inactive-sidebar .restrict-widgets-hide').chosen({
37
  allow_single_deselect: true,
38
- disable_search: true
 
39
  });
40
 
41
- $('#widgets-right .restrict-widgets-select, .inactive-sidebar .restrict-widgets-select').chosen({placeholder_text: rwArgs.placeholder_text});
 
 
 
42
  });
43
  });
23
  $('#options-widgets-sidebars').chosen({placeholder_text: rwArgs.restrict_sidebars});
24
  $('#options-widgets-roles').chosen({placeholder_text: rwArgs.restrict_roles});
25
 
26
+ $(document).on('ready ajaxStop ajaxStart', function() {
 
 
 
 
 
 
 
 
 
27
  $('#widgets-right .restrict-widgets-hide, .inactive-sidebar .restrict-widgets-hide').chosen({
28
  allow_single_deselect: true,
29
+ disable_search: true,
30
+ width: '100%'
31
  });
32
 
33
+ $('#widgets-right .restrict-widgets-select, .inactive-sidebar .restrict-widgets-select').chosen({
34
+ placeholder_text: rwArgs.placeholder_text,
35
+ width: '100%'
36
+ });
37
  });
38
  });
js/chosen.jquery.min.js CHANGED
@@ -1,10 +1,2 @@
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);
1
+ /* Chosen v1.2.0 | (c) 2011-2014 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ !function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===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=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,this.outerHTML(c)):"":""},AbstractChosen.prototype.result_add_group=function(a){var b;return a.search_match||a.group_match?a.active_options>0?(b=document.createElement("li"),b.className="group-result",b.innerHTML=a.search_text,this.outerHTML(b)):"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.text,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+"</em>"+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+"<em>"+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);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()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d instanceof Chosen?d.destroy():d instanceof Chosen||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-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.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){a.container_mousedown(b)}),this.container.bind("touchend.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=a.originalEvent.deltaY||-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<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"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+b.html+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dfactory
3
  Donate link: http://www.dfactory.eu/
4
  Tags: widget, widgets, widget-only, cms, conditional tags, conditional, widget logic, widget context, restrict, manage, management, capability, capabilities, sidebar, sidebars, user, permission, permissions
5
  Requires at least: 3.8
6
- Tested up to: 4.0
7
- Stable tag: 1.2.4
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
@@ -56,6 +56,10 @@ No questions yet.
56
 
57
  == Changelog ==
58
 
 
 
 
 
59
  = 1.2.4 =
60
  * Tweak: Widget options interface adjustments
61
  * Tweak: Confirmed WP 4.0 compatibility
@@ -106,6 +110,6 @@ Initial release
106
 
107
  == Upgrade Notice ==
108
 
109
- = 1.2.4 =
110
- * Tweak: Widget options interface adjustments
111
- * Tweak: Confirmed WP 4.0 compatibility
3
  Donate link: http://www.dfactory.eu/
4
  Tags: widget, widgets, widget-only, cms, conditional tags, conditional, widget logic, widget context, restrict, manage, management, capability, capabilities, sidebar, sidebars, user, permission, permissions
5
  Requires at least: 3.8
6
+ Tested up to: 4.1
7
+ Stable tag: 1.2.5
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
56
 
57
  == Changelog ==
58
 
59
+ = 1.2.5 =
60
+ * Tweak: UI improvements
61
+ * Tweak: jQuery chosen updated to 1.2.0
62
+
63
  = 1.2.4 =
64
  * Tweak: Widget options interface adjustments
65
  * Tweak: Confirmed WP 4.0 compatibility
110
 
111
  == Upgrade Notice ==
112
 
113
+ = 1.2.5 =
114
+ * Tweak: UI improvements
115
+ * Tweak: jQuery chosen updated to 1.2.0
restrict-widgets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Restrict Widgets
4
  Description: All in one solution for widget management in WordPress. Allows you to hide or display widgets on specified pages and restrict access for users.
5
- Version: 1.2.4
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/restrict-widgets/
@@ -44,9 +44,9 @@ class Restrict_Widgets
44
  private $hidden_widget = '';
45
  private $checked_widget = '';
46
  private $widgets = array();
47
- private $bbpress_active = FALSE;
48
- private $polylang_active = FALSE;
49
- private $wpml_active = FALSE;
50
 
51
 
52
  public function __construct()
@@ -120,8 +120,8 @@ class Restrict_Widgets
120
  'available' => array(),
121
  'selection' => array(),
122
  'sidebars' => array(),
123
- 'groups' => TRUE,
124
- 'deactivation' => FALSE,
125
  ),
126
  '',
127
  'no'
@@ -141,7 +141,7 @@ class Restrict_Widgets
141
  $current_blog_id = get_current_blog_id();
142
  $blogs_ids = $wpdb->get_col($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs, ''));
143
 
144
- if(($activated_blogs = get_site_option('restrict_widgets_activated_blogs', FALSE, FALSE)) === FALSE)
145
  $activated_blogs = array();
146
 
147
  foreach($blogs_ids as $blog_id)
@@ -149,7 +149,7 @@ class Restrict_Widgets
149
  switch_to_blog($blog_id);
150
  $this->deactivate_single();
151
 
152
- if(in_array((int)$blog_id, $activated_blogs, TRUE))
153
  unset($activated_blogs[array_search($blog_id, $activated_blogs)]);
154
  }
155
 
@@ -168,7 +168,7 @@ class Restrict_Widgets
168
  {
169
  $option = get_option('rw_widgets_options');
170
 
171
- if($option['deactivation'] === TRUE)
172
  {
173
  global $wp_roles, $wp_registered_widgets;
174
 
@@ -196,7 +196,7 @@ class Restrict_Widgets
196
 
197
 
198
  /**
199
- * Fix for is_active_sidebar (all hidden widgets on sidebar = FALSE)
200
  */
201
  public function restrict_sidebar_widgets()
202
  {
@@ -204,7 +204,7 @@ class Restrict_Widgets
204
  {
205
  $options = get_option('rw_widgets_options');
206
 
207
- if(isset($options['sidebar']) && $options['sidebar'] === TRUE)
208
  {
209
  global $wp_registered_widgets, $_wp_sidebars_widgets;
210
 
@@ -232,7 +232,7 @@ class Restrict_Widgets
232
  {
233
  foreach($instance as $widget_id => $widget)
234
  {
235
- $this->widgets[substr($widget_id, 7)] = $this->restrict_widget($widget, FALSE, array('widget_id' => substr($widget_id, 7)));
236
  }
237
  }
238
 
@@ -248,7 +248,7 @@ class Restrict_Widgets
248
  {
249
  foreach($s_widgets as $widget)
250
  {
251
- if($this->widgets[$widget] === FALSE && ($widget_key = array_search($widget, $_wp_sidebars_widgets[$sidebar])) !== FALSE)
252
  unset($_wp_sidebars_widgets[$sidebar][$widget_key]);
253
  }
254
  }
@@ -265,7 +265,7 @@ class Restrict_Widgets
265
  */
266
  public function polylang_widgets()
267
  {
268
- if($this->polylang_active === TRUE)
269
  {
270
  global $polylang;
271
 
@@ -280,16 +280,16 @@ class Restrict_Widgets
280
  */
281
  public function load_textdomain()
282
  {
283
- load_plugin_textdomain('restrict-widgets', FALSE, RESTRICT_WIDGETS_REL_PATH.'languages/');
284
 
285
  if(class_exists('bbPress'))
286
- $this->bbpress_active = TRUE;
287
 
288
  if(class_exists('Polylang'))
289
- $this->polylang_active = TRUE;
290
 
291
  if(class_exists('SitePress'))
292
- $this->wpml_active = TRUE;
293
  }
294
 
295
 
@@ -369,7 +369,7 @@ class Restrict_Widgets
369
  {
370
  $this->taxonomies = get_taxonomies(
371
  array(
372
- '_builtin' => FALSE
373
  ),
374
  'objects',
375
  'and'
@@ -377,14 +377,14 @@ class Restrict_Widgets
377
 
378
  $this->categories = get_categories(
379
  array(
380
- 'hide_empty' => FALSE
381
  )
382
  );
383
 
384
  $this->custom_post_types = get_post_types(
385
  array(
386
- 'public' => TRUE,
387
- '_builtin' => FALSE
388
  ),
389
  'objects',
390
  'and'
@@ -392,9 +392,9 @@ class Restrict_Widgets
392
 
393
  $this->custom_post_types_archives = get_post_types(
394
  array(
395
- 'public' => TRUE,
396
- '_builtin' => FALSE,
397
- 'has_archive' => TRUE
398
  ),
399
  'objects',
400
  'and'
@@ -417,7 +417,7 @@ class Restrict_Widgets
417
  );
418
 
419
  //bbPress support
420
- if($this->bbpress_active === TRUE)
421
  {
422
  $this->bbpress = array(
423
  'search' => __('Search', 'restrict-widgets'),
@@ -464,9 +464,9 @@ class Restrict_Widgets
464
  );
465
 
466
  //Polylang support
467
- if($this->polylang_active === TRUE)
468
  {
469
- $languages = get_terms('language', array('hide_empty' => FALSE));
470
 
471
  //we need to make WMPL style table
472
  foreach($languages as $language)
@@ -475,10 +475,10 @@ class Restrict_Widgets
475
  }
476
  }
477
  //WMPL support
478
- elseif($this->wpml_active === TRUE)
479
  $this->languages = icl_get_languages('skip_missing=0&orderby=native_name&order=asc');
480
  else
481
- $this->languages = FALSE;
482
  }
483
 
484
 
@@ -514,26 +514,26 @@ class Restrict_Widgets
514
  'available' => array(),
515
  'selection' => array(),
516
  'sidebars' => array(),
517
- 'groups' => FALSE,
518
- 'sidebar' => FALSE,
519
- 'deactivation' => FALSE
520
  );
521
 
522
  //display groups?
523
- $save_widgets['groups'] = (isset($_POST['options-widgets-groups']) ? TRUE : FALSE);
524
 
525
  //modify is_active_sidebar?
526
- $save_widgets['sidebar'] = (isset($_POST['options-widgets-sidebar']) ? TRUE : FALSE);
527
 
528
  //remove plugin data?
529
- $save_widgets['deactivation'] = (isset($_POST['options-widgets-deactivation']) ? TRUE : FALSE);
530
 
531
  //do we have some available widgets?
532
  if(isset($_POST['options-available-widgets']))
533
  {
534
  foreach($_POST['options-available-widgets'] as $widget_class)
535
  {
536
- $save_widgets['available'][$widget_class] = TRUE;
537
  }
538
  }
539
 
@@ -547,58 +547,58 @@ class Restrict_Widgets
547
  {
548
  $tmp = explode('_', $element, 2);
549
 
550
- if(in_array($tmp[0], array('cpt', 'cpta'), TRUE))
551
- $save_widgets['selection'][$tmp[0] === 'cpt' ? 'custom_post_types' : 'custom_post_types_archives'][$tmp[0].'_'.sanitize_key($tmp[1])] = TRUE;
552
  }
553
 
554
  foreach($this->pages as $page)
555
  {
556
- if(in_array('pageid_'.$page->ID, $selected, TRUE))
557
- $save_widgets['selection']['pages']['pageid_'.$page->ID] = TRUE;
558
  }
559
 
560
  foreach($this->custom_post_types as $cpt)
561
  {
562
- if(in_array('cpt_'.$cpt->name, $selected, TRUE))
563
- $save_widgets['selection']['custom_post_types']['cpt_'.$cpt->name] = TRUE;
564
  }
565
 
566
  foreach($this->categories as $category)
567
  {
568
- if(in_array('category_'.$category->cat_ID, $selected, TRUE))
569
- $save_widgets['selection']['categories']['category_'.$category->cat_ID] = TRUE;
570
  }
571
 
572
  foreach($this->taxonomies as $taxonomy)
573
  {
574
- if(in_array('taxonomy_'.$taxonomy->name, $selected, TRUE))
575
- $save_widgets['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = TRUE;
576
  }
577
 
578
  foreach($this->others as $key => $value)
579
  {
580
- if(in_array('others_'.$key, $selected, TRUE))
581
- $save_widgets['selection']['others']['others_'.$key] = TRUE;
582
  }
583
 
584
  foreach($this->users as $key => $value)
585
  {
586
- if(in_array('users_'.$key, $selected, TRUE))
587
- $save_widgets['selection']['users']['users_'.$key] = TRUE;
588
  }
589
 
590
  foreach($this->devices as $key => $value)
591
  {
592
- if(in_array('devices_'.$key, $selected, TRUE))
593
- $save_widgets['selection']['devices']['devices_'.$key] = TRUE;
594
  }
595
 
596
- if($this->bbpress_active === TRUE)
597
  {
598
  foreach($this->bbpress as $key => $value)
599
  {
600
- if(in_array('bbpress_'.$key, $selected, TRUE))
601
- $save_widgets['selection']['bbpress']['bbpress_'.$key] = TRUE;
602
  }
603
  }
604
  }
@@ -608,7 +608,7 @@ class Restrict_Widgets
608
  {
609
  foreach($_POST['options-widgets-sidebars'] as $sidebar)
610
  {
611
- $save_widgets['sidebars'][$sidebar] = TRUE;
612
  }
613
  }
614
 
@@ -646,8 +646,8 @@ class Restrict_Widgets
646
  $widgets_unique = array();
647
  $option = get_option('rw_widgets_options');
648
 
649
- if(isset($option['groups']) === FALSE) $option['groups'] = FALSE;
650
- if(isset($option['deactivation']) === FALSE) $option['deactivation'] = FALSE;
651
 
652
  //we need to make a copy for sorting
653
  $widgets = $wp_registered_widgets;
@@ -673,28 +673,28 @@ class Restrict_Widgets
673
  </div>
674
  <form action="" method="post">
675
 
676
- <label class="label">'.__('Restrict Users', 'restrict-widgets').'</label><br />
677
  <select name="options-widgets-roles[]" id="options-widgets-roles" multiple="multiple">';
678
 
679
  foreach($wp_roles->roles as $role_name => $role_array)
680
  {
681
- 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>';
682
  }
683
 
684
  echo '
685
  </select>
686
 
687
- <label class="label">'.__('Restrict Sidebars', 'restrict-widgets').'</label><br />
688
  <select name="options-widgets-sidebars[]" id="options-widgets-sidebars" multiple="multiple">';
689
 
690
  foreach($wp_registered_sidebars as $sidebar)
691
  {
692
  if($sidebar['id'] !== 'wp_inactive_widgets')
693
  {
694
- if(isset($option['sidebars'][$sidebar['id']]) === FALSE)
695
- $option['sidebars'][$sidebar['id']] = FALSE;
696
 
697
- echo '<option value="'.$sidebar['id'].'" '.selected($option['sidebars'][$sidebar['id']], TRUE, FALSE).'>'.$sidebar['name'].'</option>';
698
  }
699
  }
700
 
@@ -703,22 +703,22 @@ class Restrict_Widgets
703
  <p class="description">'.__('Select which sidebars will be restricted to admins only.', 'restrict-widgets').'</p>';
704
 
705
  echo '
706
- <label class="label">'.__('Restrict Widgets', 'restrict-widgets').'</label><br />
707
  <select name="options-available-widgets[]" id="options-available-widgets" multiple="multiple">';
708
 
709
  foreach(array_unique($widgets_unique) as $widget_class => $widget_name)
710
  {
711
- if(isset($option['available'][$widget_class]) === FALSE)
712
- $option['available'][$widget_class] = FALSE;
713
 
714
- echo '<option value="'.$widget_class.'" '.selected($option['available'][$widget_class], TRUE, FALSE).'>'.$widget_name.'</option>';
715
  }
716
 
717
  echo '
718
  </select>
719
  <p class="description">'.__('Select which widgets will be restricted to admins only.', 'restrict-widgets').'</p>
720
 
721
- <label class="label">'.__('Restrict Widget Options', 'restrict-widgets').'</label><br />
722
  <select name="options-widgets-selection[]" id="options-widgets-selection" multiple="multiple">';
723
 
724
  foreach($this->options as $group_name => $value)
@@ -731,27 +731,27 @@ class Restrict_Widgets
731
  <p class="description">'.__('Select which widget options will be restricted to admins only.', 'restrict-widgets').'</p>
732
  <table>
733
  <tr>
734
- <td class="label"><label>'.__('Restrict Option Groups', 'restrict-widgets').'</label></td>
735
  <td>
736
  <label for="options-widgets-groups">
737
- <input type="checkbox" name="options-widgets-groups" id="options-widgets-groups" value="1" '.checked($option['groups'], TRUE, FALSE).' />
738
- '.__('Display widget options in groups', 'restrict-widgets').'</label>
739
  </td>
740
  </tr>
741
  <tr>
742
- <td class="label"><label>'.__('Modify is_active_sidebar()', 'restrict-widgets').'</label></td>
743
  <td>
744
  <label for="options-widgets-sidebar">
745
- <input type="checkbox" name="options-widgets-sidebar" id="options-widgets-sidebar" value="1" '.checked($option['sidebar'], TRUE, FALSE).' />
746
- '.__('By default is_active_sidebar() function returns TRUE even if no widget is displayed in a sidebar. Check this if you want is_active_sidebar() to recognize Restrict Widgets display settings.', 'restrict-widgets').'</label>
747
  </td>
748
  </tr>
749
  <tr>
750
- <td class="label"><label>'.__('Plugin Deactivation', 'restrict-widgets').'</label></td>
751
  <td>
752
  <label for="options-widgets-deactivation">
753
- <input type="checkbox" name="options-widgets-deactivation" id="options-widgets-deactivation" value="1" '.checked($option['deactivation'], TRUE, FALSE).' />
754
- '.__('Remove all plugin data on deactivation', 'restrict-widgets').'</label>
755
  </td>
756
  </tr>
757
  </table>
@@ -858,7 +858,7 @@ class Restrict_Widgets
858
 
859
  wp_enqueue_style(
860
  'chosen',
861
- RESTRICT_WIDGETS_URL.'/css/chosen.css'
862
  );
863
 
864
  wp_enqueue_style(
@@ -880,7 +880,7 @@ class Restrict_Widgets
880
  {
881
  case 'pages':
882
  {
883
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
884
  $html .= '<optgroup label="'.$this->options['pages'].'">';
885
 
886
  foreach($this->pages as $page)
@@ -889,10 +889,10 @@ class Restrict_Widgets
889
  {
890
  case 'option':
891
  {
892
- if(isset($option['selection']['pages']['pageid_'.$page->ID]) === FALSE)
893
- $option['selection']['pages']['pageid_'.$page->ID] = FALSE;
894
 
895
- $html .= '<option value="pageid_'.$page->ID.'" '.selected($option['selection']['pages']['pageid_'.$page->ID], TRUE, FALSE).'>'.$page->post_title.'</option>';
896
 
897
  break;
898
  }
@@ -900,10 +900,10 @@ class Restrict_Widgets
900
  {
901
  if(!isset($rw_option['selection']['pages']['pageid_'.$page->ID]) || current_user_can('manage_options'))
902
  {
903
- if(isset($instance['rw_opt']['pageid_'.$page->ID]) === FALSE)
904
  $instance['rw_opt']['pageid_'.$page->ID] = 0;
905
 
906
- $html .= '<option value="pageid_'.$page->ID.'" '.selected($instance['rw_opt']['pageid_'.$page->ID], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $page->post_title, 'page').'</option>';
907
  }
908
 
909
  break;
@@ -911,14 +911,14 @@ class Restrict_Widgets
911
  }
912
  }
913
 
914
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
915
  $html .= '</optgroup>';
916
 
917
  return $html;
918
  }
919
  case 'custom_post_types':
920
  {
921
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
922
  $html .= '<optgroup label="'.$this->options['custom_post_types'].'">';
923
 
924
  foreach($this->custom_post_types as $cpt)
@@ -927,10 +927,10 @@ class Restrict_Widgets
927
  {
928
  case 'option':
929
  {
930
- if(isset($option['selection']['custom_post_types']['cpt_'.$cpt->name]) === FALSE)
931
- $option['selection']['custom_post_types']['cpt_'.$cpt->name] = FALSE;
932
 
933
- $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>';
934
 
935
  break;
936
  }
@@ -938,10 +938,10 @@ class Restrict_Widgets
938
  {
939
  if(!isset($rw_option['selection']['custom_post_types']['cpt_'.$cpt->name]) || current_user_can('manage_options'))
940
  {
941
- if(isset($instance['rw_opt']['cpt_'.$cpt->name]) === FALSE)
942
  $instance['rw_opt']['cpt_'.$cpt->name] = 0;
943
 
944
- $html .= '<option value="cpt_'.$cpt->name.'" '.selected($instance['rw_opt']['cpt_'.$cpt->name], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', sprintf(__('Single %s','restrict-widgets'), $cpt->label), 'custom_post_type').'</option>';
945
  }
946
 
947
  break;
@@ -949,14 +949,14 @@ class Restrict_Widgets
949
  }
950
  }
951
 
952
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
953
  $html .= '</optgroup>';
954
 
955
  return $html;
956
  }
957
  case 'custom_post_types_archives':
958
  {
959
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
960
  $html .= '<optgroup label="'.$this->options['custom_post_types_archives'].'">';
961
 
962
  foreach($this->custom_post_types_archives as $cpta)
@@ -965,10 +965,10 @@ class Restrict_Widgets
965
  {
966
  case 'option':
967
  {
968
- if(isset($option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) === FALSE)
969
- $option['selection']['custom_post_types_archives']['cpta_'.$cpta->name] = FALSE;
970
 
971
- $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>';
972
 
973
  break;
974
  }
@@ -976,10 +976,10 @@ class Restrict_Widgets
976
  {
977
  if(!isset($rw_option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) || current_user_can('manage_options'))
978
  {
979
- if(isset($instance['rw_opt']['cpta_'.$cpta->name]) === FALSE)
980
  $instance['rw_opt']['cpta_'.$cpta->name] = 0;
981
 
982
- $html .= '<option value="cpta_'.$cpta->name.'" '.selected($instance['rw_opt']['cpta_'.$cpta->name], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', sprintf(__('%s Archive','restrict-widgets'), $cpta->label), 'custom_post_type_archive').'</option>';
983
  }
984
 
985
  break;
@@ -987,14 +987,14 @@ class Restrict_Widgets
987
  }
988
  }
989
 
990
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
991
  $html .= '</optgroup>';
992
 
993
  return $html;
994
  }
995
  case 'categories':
996
  {
997
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
998
  $html .= '<optgroup label="'.$this->options['categories'].'">';
999
 
1000
  foreach($this->categories as $category)
@@ -1003,10 +1003,10 @@ class Restrict_Widgets
1003
  {
1004
  case 'option':
1005
  {
1006
- if(isset($option['selection']['categories']['category_'.$category->cat_ID]) === FALSE)
1007
- $option['selection']['categories']['category_'.$category->cat_ID] = FALSE;
1008
 
1009
- $html .= '<option value="category_'.$category->cat_ID.'" '.selected($option['selection']['categories']['category_'.$category->cat_ID], TRUE, FALSE).'>'.$category->cat_name.'</option>';
1010
 
1011
  break;
1012
  }
@@ -1014,10 +1014,10 @@ class Restrict_Widgets
1014
  {
1015
  if(!isset($rw_option['selection']['categories']['category_'.$category->cat_ID]) || current_user_can('manage_options'))
1016
  {
1017
- if(isset($instance['rw_opt']['category_'.$category->cat_ID]) === FALSE)
1018
  $instance['rw_opt']['category_'.$category->cat_ID] = 0;
1019
 
1020
- $html .= '<option value="category_'.$category->cat_ID.'" '.selected($instance['rw_opt']['category_'.$category->cat_ID], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $category->cat_name, 'category').'</option>';
1021
  }
1022
 
1023
  break;
@@ -1025,14 +1025,14 @@ class Restrict_Widgets
1025
  }
1026
  }
1027
 
1028
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1029
  $html .= '</optgroup>';
1030
 
1031
  return $html;
1032
  }
1033
  case 'taxonomies':
1034
  {
1035
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1036
  $html .= '<optgroup label="'.$this->options['taxonomies'].'">';
1037
 
1038
  foreach($this->taxonomies as $taxonomy)
@@ -1041,10 +1041,10 @@ class Restrict_Widgets
1041
  {
1042
  case 'option':
1043
  {
1044
- if(isset($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) === FALSE)
1045
- $option['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = FALSE;
1046
 
1047
- $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name], TRUE, FALSE).'>'.$taxonomy->label.'</option>';
1048
 
1049
  break;
1050
  }
@@ -1052,10 +1052,10 @@ class Restrict_Widgets
1052
  {
1053
  if(!isset($rw_option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) || current_user_can('manage_options'))
1054
  {
1055
- if(isset($instance['rw_opt']['taxonomy_'.$taxonomy->name]) === FALSE)
1056
  $instance['rw_opt']['taxonomy_'.$taxonomy->name] = 0;
1057
 
1058
- $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($instance['rw_opt']['taxonomy_'.$taxonomy->name], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $taxonomy->label, 'taxonomy').'</option>';
1059
  }
1060
 
1061
  break;
@@ -1063,14 +1063,14 @@ class Restrict_Widgets
1063
  }
1064
  }
1065
 
1066
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1067
  $html .= '</optgroup>';
1068
 
1069
  return $html;
1070
  }
1071
  case 'others':
1072
  {
1073
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1074
  $html .= '<optgroup label="'.$this->options['others'].'">';
1075
 
1076
  foreach($this->others as $key => $value)
@@ -1079,10 +1079,10 @@ class Restrict_Widgets
1079
  {
1080
  case 'option':
1081
  {
1082
- if(isset($option['selection']['others']['others_'.$key]) === FALSE)
1083
- $option['selection']['others']['others_'.$key] = FALSE;
1084
 
1085
- $html .= '<option value="others_'.$key.'" '.selected($option['selection']['others']['others_'.$key], TRUE, FALSE).'>'.$value.'</option>';
1086
 
1087
  break;
1088
  }
@@ -1090,10 +1090,10 @@ class Restrict_Widgets
1090
  {
1091
  if(!isset($rw_option['selection']['others']['others_'.$key]) || current_user_can('manage_options'))
1092
  {
1093
- if(isset($instance['rw_opt']['others_'.$key]) === FALSE)
1094
  $instance['rw_opt']['others_'.$key] = 0;
1095
 
1096
- $html .= '<option value="others_'.$key.'" '.selected($instance['rw_opt']['others_'.$key], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $value, 'other').'</option>';
1097
  }
1098
 
1099
  break;
@@ -1101,14 +1101,14 @@ class Restrict_Widgets
1101
  }
1102
  }
1103
 
1104
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1105
  $html .= '</optgroup>';
1106
 
1107
  return $html;
1108
  }
1109
  case 'devices':
1110
  {
1111
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1112
  $html .= '<optgroup label="'.$this->options['devices'].'">';
1113
 
1114
  foreach($this->devices as $key => $value)
@@ -1117,10 +1117,10 @@ class Restrict_Widgets
1117
  {
1118
  case 'option':
1119
  {
1120
- if(isset($option['selection']['devices']['devices_'.$key]) === FALSE)
1121
- $option['selection']['devices']['devices_'.$key] = FALSE;
1122
 
1123
- $html .= '<option value="devices_'.$key.'" '.selected($option['selection']['devices']['devices_'.$key], TRUE, FALSE).'>'.$value.'</option>';
1124
 
1125
  break;
1126
  }
@@ -1128,10 +1128,10 @@ class Restrict_Widgets
1128
  {
1129
  if(!isset($rw_option['selection']['devices']['devices_'.$key]) || current_user_can('manage_options'))
1130
  {
1131
- if(isset($instance['rw_opt']['devices_'.$key]) === FALSE)
1132
  $instance['rw_opt']['devices_'.$key] = 0;
1133
 
1134
- $html .= '<option value="devices_'.$key.'" '.selected($instance['rw_opt']['devices_'.$key], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $value, 'device').'</option>';
1135
  }
1136
 
1137
  break;
@@ -1139,17 +1139,17 @@ class Restrict_Widgets
1139
  }
1140
  }
1141
 
1142
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1143
  $html .= '</optgroup>';
1144
 
1145
  return $html;
1146
  }
1147
  case 'bbpress':
1148
  {
1149
- if($this->bbpress_active === FALSE)
1150
  return $html;
1151
 
1152
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1153
  $html .= '<optgroup label="'.$this->options['bbpress'].'">';
1154
 
1155
  foreach($this->bbpress as $key => $value)
@@ -1158,10 +1158,10 @@ class Restrict_Widgets
1158
  {
1159
  case 'option':
1160
  {
1161
- if(isset($option['selection']['bbpress']['bbpress_'.$key]) === FALSE)
1162
- $option['selection']['bbpress']['bbpress_'.$key] = FALSE;
1163
 
1164
- $html .= '<option value="bbpress_'.$key.'" '.selected($option['selection']['bbpress']['bbpress_'.$key], TRUE, FALSE).'>'.$value.'</option>';
1165
 
1166
  break;
1167
  }
@@ -1169,10 +1169,10 @@ class Restrict_Widgets
1169
  {
1170
  if(!isset($rw_option['selection']['bbpress']['bbpress_'.$key]) || current_user_can('manage_options'))
1171
  {
1172
- if(isset($instance['rw_opt']['bbpress_'.$key]) === FALSE)
1173
  $instance['rw_opt']['bbpress_'.$key] = 0;
1174
 
1175
- $html .= '<option value="bbpress_'.$key.'" '.selected($instance['rw_opt']['bbpress_'.$key], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $value, 'bbpress').'</option>';
1176
  }
1177
 
1178
  break;
@@ -1180,14 +1180,14 @@ class Restrict_Widgets
1180
  }
1181
  }
1182
 
1183
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1184
  $html .= '</optgroup>';
1185
 
1186
  return $html;
1187
  }
1188
  case 'users':
1189
  {
1190
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1191
  $html .= '<optgroup label="'.$this->options['users'].'">';
1192
 
1193
  foreach($this->users as $key => $value)
@@ -1196,10 +1196,10 @@ class Restrict_Widgets
1196
  {
1197
  case 'option':
1198
  {
1199
- if(isset($option['selection']['users']['users_'.$key]) === FALSE)
1200
- $option['selection']['users']['users_'.$key] = FALSE;
1201
 
1202
- $html .= '<option value="users_'.$key.'" '.selected($option['selection']['users']['users_'.$key], TRUE, FALSE).'>'.$value.'</option>';
1203
 
1204
  break;
1205
  }
@@ -1207,10 +1207,10 @@ class Restrict_Widgets
1207
  {
1208
  if(!isset($rw_option['selection']['users']['users_'.$key]) || current_user_can('manage_options'))
1209
  {
1210
- if(isset($instance['rw_opt']['users_'.$key]) === FALSE)
1211
  $instance['rw_opt']['users_'.$key] = 0;
1212
 
1213
- $html .= '<option value="users_'.$key.'" '.selected($instance['rw_opt']['users_'.$key], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $value, 'user').'</option>';
1214
  }
1215
 
1216
  break;
@@ -1218,17 +1218,17 @@ class Restrict_Widgets
1218
  }
1219
  }
1220
 
1221
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1222
  $html .= '</optgroup>';
1223
 
1224
  return $html;
1225
  }
1226
  case 'languages':
1227
  {
1228
- if($this->languages === FALSE)
1229
  return $html;
1230
 
1231
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1232
  $html .= '<optgroup label="'.$this->options['languages'].'">';
1233
 
1234
  foreach($this->languages as $key => $language)
@@ -1237,10 +1237,10 @@ class Restrict_Widgets
1237
  {
1238
  case 'option':
1239
  {
1240
- if(isset($option['selection']['languages']['language_'.$key]) === FALSE)
1241
- $option['selection']['languages']['language_'.$key] = FALSE;
1242
 
1243
- $html .= '<option value="language_'.$key.'" '.selected($option['selection']['languages']['language_'.$key], TRUE, FALSE).'>'.$language['native_name'].'</option>';
1244
 
1245
  break;
1246
  }
@@ -1248,10 +1248,10 @@ class Restrict_Widgets
1248
  {
1249
  if(!isset($rw_option['selection']['languages']['language_'.$key]) || current_user_can('manage_options'))
1250
  {
1251
- if(isset($instance['rw_opt']['language_'.$key]) === FALSE)
1252
  $instance['rw_opt']['language_'.$key] = 0;
1253
 
1254
- $html .= '<option value="language_'.$key.'" '.selected($instance['rw_opt']['language_'.$key], TRUE, FALSE).'>'.apply_filters('rw_option_display_name', $language['native_name'], 'language').'</option>';
1255
  }
1256
 
1257
  break;
@@ -1259,7 +1259,7 @@ class Restrict_Widgets
1259
  }
1260
  }
1261
 
1262
- if(($rw_option['groups'] === TRUE && $type === 'widget') || current_user_can('manage_options'))
1263
  $html .= '</optgroup>';
1264
 
1265
  return $html;
@@ -1273,19 +1273,19 @@ class Restrict_Widgets
1273
  */
1274
  public function display_admin_widgets_options($widget, $empty, $instance)
1275
  {
1276
- if(isset($instance['rw_opt']['widget_select']) === FALSE)
1277
- $instance['rw_opt']['widget_select'] = FALSE;
1278
 
1279
  echo '
1280
  <div class="restrict-widgets-hide-div restrict-widgets">
1281
  <p class="restrict-widgets-display-label">'.__('Display / Hide Widget', 'restrict-widgets').'</p>
1282
- <select name="'.$widget->get_field_name('widget_select').'" class="restrict-widgets-hide">
1283
- <option value="yes" '.selected($instance['rw_opt']['widget_select'], TRUE, FALSE).'>'.__('Display widget on selected', 'restrict-widgets').'</option>
1284
- <option value="no" '.selected($instance['rw_opt']['widget_select'], FALSE, FALSE).'>'.__('Hide widget on selected', 'restrict-widgets').'</option>
1285
  </select>
1286
  </div>
1287
  <div class="restrict-widgets-select-div restrict-widgets">
1288
- <select class="restrict-widgets-select" multiple="multiple" size="10" name="'.$widget->get_field_name('widget_multiselect').'[]">';
1289
 
1290
  foreach($this->options as $option => $text)
1291
  {
@@ -1311,7 +1311,7 @@ class Restrict_Widgets
1311
  foreach($this->pages as $page)
1312
  {
1313
  if(in_array('pageid_'.$page->ID, $selected))
1314
- $instance['rw_opt']['pageid_'.$page->ID] = TRUE;
1315
  else
1316
  unset($instance['rw_opt']['pageid_'.$page->ID]);
1317
  }
@@ -1320,7 +1320,7 @@ class Restrict_Widgets
1320
  foreach($this->custom_post_types as $cpt)
1321
  {
1322
  if(in_array('cpt_'.$cpt->name, $selected))
1323
- $instance['rw_opt']['cpt_'.$cpt->name] = TRUE;
1324
  else
1325
  unset($instance['rw_opt']['cpt_'.$cpt->name]);
1326
  }
@@ -1329,7 +1329,7 @@ class Restrict_Widgets
1329
  foreach($this->custom_post_types_archives as $cpta)
1330
  {
1331
  if(in_array('cpta_'.$cpta->name, $selected))
1332
- $instance['rw_opt']['cpta_'.$cpta->name] = TRUE;
1333
  else
1334
  unset($instance['rw_opt']['cpta_'.$cpta->name]);
1335
  }
@@ -1338,7 +1338,7 @@ class Restrict_Widgets
1338
  foreach($this->categories as $category)
1339
  {
1340
  if(in_array('category_'.$category->cat_ID, $selected))
1341
- $instance['rw_opt']['category_'.$category->cat_ID] = TRUE;
1342
  else
1343
  unset($instance['rw_opt']['category_'.$category->cat_ID]);
1344
  }
@@ -1347,7 +1347,7 @@ class Restrict_Widgets
1347
  foreach($this->taxonomies as $taxonomy)
1348
  {
1349
  if(in_array('taxonomy_'.$taxonomy->name, $selected))
1350
- $instance['rw_opt']['taxonomy_'.$taxonomy->name] = TRUE;
1351
  else
1352
  unset($instance['rw_opt']['taxonomy_'.$taxonomy->name]);
1353
  }
@@ -1356,7 +1356,7 @@ class Restrict_Widgets
1356
  foreach($this->others as $key => $value)
1357
  {
1358
  if(in_array('others_'.$key, $selected))
1359
- $instance['rw_opt']['others_'.$key] = TRUE;
1360
  else
1361
  unset($instance['rw_opt']['others_'.$key]);
1362
  }
@@ -1365,18 +1365,18 @@ class Restrict_Widgets
1365
  foreach($this->devices as $key => $value)
1366
  {
1367
  if(in_array('devices_'.$key, $selected))
1368
- $instance['rw_opt']['devices_'.$key] = TRUE;
1369
  else
1370
  unset($instance['rw_opt']['devices_'.$key]);
1371
  }
1372
 
1373
  //bbpress
1374
- if($this->bbpress_active === TRUE)
1375
  {
1376
  foreach($this->bbpress as $key => $value)
1377
  {
1378
  if(in_array('bbpress_'.$key, $selected))
1379
- $instance['rw_opt']['bbpress_'.$key] = TRUE;
1380
  else
1381
  unset($instance['rw_opt']['bbpress_'.$key]);
1382
  }
@@ -1386,18 +1386,18 @@ class Restrict_Widgets
1386
  foreach($this->users as $key => $value)
1387
  {
1388
  if(in_array('users_'.$key, $selected))
1389
- $instance['rw_opt']['users_'.$key] = TRUE;
1390
  else
1391
  unset($instance['rw_opt']['users_'.$key]);
1392
  }
1393
 
1394
  //languages
1395
- if($this->languages !== FALSE)
1396
  {
1397
  foreach($this->languages as $key => $value)
1398
  {
1399
  if(in_array('language_'.$key, $selected))
1400
- $instance['rw_opt']['language_'.$key] = TRUE;
1401
  else
1402
  unset($instance['rw_opt']['language_'.$key]);
1403
  }
@@ -1407,7 +1407,7 @@ class Restrict_Widgets
1407
  else unset($instance['rw_opt']);
1408
 
1409
  //widget_multiselect
1410
- $instance['rw_opt']['widget_select'] = ($new_instance['widget_select'] === 'yes' ? TRUE : FALSE);
1411
 
1412
  return $instance;
1413
  }
@@ -1431,11 +1431,11 @@ class Restrict_Widgets
1431
  $array = array('users');
1432
 
1433
  if(in_array($action[0], $array))
1434
- return FALSE;
1435
  }
1436
  }
1437
 
1438
- return TRUE;
1439
  }
1440
 
1441
 
@@ -1444,31 +1444,31 @@ class Restrict_Widgets
1444
  */
1445
  public function display_frontend_widgets($instance, $class, $args)
1446
  {
1447
- return $this->restrict_widget($instance, TRUE, $args);
1448
  }
1449
 
1450
 
1451
  /**
1452
  * Displays or hides specific widget
1453
  */
1454
- private function restrict_widget($instance, $filter = TRUE, $args = array())
1455
  {
1456
  global $wp_query;
1457
 
1458
  $display_lang = $display_user = $display_device = $display_main = '';
1459
- $empty_lang = $empty_user = $empty_device = $empty_main = TRUE;
1460
- $return = FALSE;
1461
 
1462
  $post_id = $wp_query->get_queried_object_id();
1463
 
1464
- $display_type = isset($instance['rw_opt']['widget_select']) ? $instance['rw_opt']['widget_select'] : FALSE;
1465
 
1466
  //languages
1467
- if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'lang') === FALSE)
1468
  {
1469
- if($this->polylang_active === TRUE || $this->wpml_active === TRUE)
1470
  {
1471
- $empty_lang = FALSE;
1472
 
1473
  //fix for WPML
1474
  if(function_exists('icl_object_id'))
@@ -1476,137 +1476,137 @@ class Restrict_Widgets
1476
  global $sitepress;
1477
 
1478
  if(isset($sitepress))
1479
- $post_id = icl_object_id($post_id, 'page', TRUE, $sitepress->get_default_language());
1480
  else
1481
- $post_id = icl_object_id($post_id, 'page', FALSE);
1482
  }
1483
 
1484
- $found_lang = (defined('ICL_LANGUAGE_CODE') && isset($instance['rw_opt']['language_'.ICL_LANGUAGE_CODE]) ? TRUE : FALSE);
1485
 
1486
- if($display_type === TRUE)
1487
  {
1488
- if($found_lang === TRUE)
1489
- $display_lang = TRUE;
1490
  else
1491
  {
1492
- $return = TRUE;
1493
- $display_lang = FALSE;
1494
  }
1495
  }
1496
  else
1497
- $display_lang = ($found_lang === TRUE ? FALSE : TRUE);
1498
  }
1499
  else
1500
- $display_lang = TRUE;
1501
  }
1502
  else
1503
- $display_lang = TRUE;
1504
 
1505
  //users
1506
- if($return === FALSE)
1507
  {
1508
- if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'user') === FALSE)
1509
  {
1510
- $empty_user = FALSE;
1511
 
1512
  if(is_user_logged_in())
1513
  {
1514
  if(isset($instance['rw_opt']['users_logged_in'], $instance['rw_opt']['users_logged_out']) || isset($instance['rw_opt']['users_logged_in']))
1515
- $found_user = TRUE;
1516
  elseif(isset($instance['rw_opt']['users_logged_out']))
1517
- $found_user = FALSE;
1518
  }
1519
  else
1520
  {
1521
  if(isset($instance['rw_opt']['users_logged_out'], $instance['rw_opt']['users_logged_in']) || isset($instance['rw_opt']['users_logged_out']))
1522
- $found_user = TRUE;
1523
  elseif(isset($instance['rw_opt']['users_logged_in']))
1524
- $found_user = FALSE;
1525
  }
1526
 
1527
- if($display_type === TRUE)
1528
  {
1529
- if($found_user === TRUE)
1530
- $display_user = TRUE;
1531
  else
1532
  {
1533
- $return = TRUE;
1534
- $display_user = FALSE;
1535
  }
1536
  }
1537
  else
1538
- $display_user = ($found_user === TRUE ? FALSE : TRUE);
1539
  }
1540
  else
1541
- $display_user = TRUE;
1542
  }
1543
 
1544
  //devices
1545
- if($return === FALSE)
1546
  {
1547
- if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'device') === FALSE)
1548
  {
1549
- $empty_device = FALSE;
1550
 
1551
  if(wp_is_mobile())
1552
  {
1553
  if(isset($instance['rw_opt']['devices_mobile'], $instance['rw_opt']['devices_desktop']) || isset($instance['rw_opt']['devices_mobile']))
1554
- $found_device = TRUE;
1555
  elseif(isset($instance['rw_opt']['devices_desktop']))
1556
- $found_device = FALSE;
1557
  }
1558
  else
1559
  {
1560
  if(isset($instance['rw_opt']['devices_desktop'], $instance['rw_opt']['devices_mobile']) || isset($instance['rw_opt']['devices_desktop']))
1561
- $found_device = TRUE;
1562
  elseif(isset($instance['rw_opt']['devices_mobile']))
1563
- $found_device = FALSE;
1564
  }
1565
 
1566
- if($display_type === TRUE)
1567
  {
1568
- if($found_device === TRUE)
1569
- $display_device = TRUE;
1570
  else
1571
  {
1572
- $return = TRUE;
1573
- $display_device = FALSE;
1574
  }
1575
  }
1576
  else
1577
- $display_device = ($found_device === TRUE ? FALSE : TRUE);
1578
  }
1579
  else
1580
- $display_device = TRUE;
1581
  }
1582
 
1583
  //rest
1584
- if($return === FALSE)
1585
  {
1586
- if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'main') === FALSE)
1587
  {
1588
- $empty_main = FALSE;
1589
 
1590
  if(is_front_page())
1591
  {
1592
- $found_main = isset($instance['rw_opt']['others_front_page']) ? TRUE : FALSE;
1593
 
1594
- if(is_home() && $found_main == FALSE)
1595
- $found_main = isset($instance['rw_opt']['others_blog_page']) ? TRUE : FALSE;
1596
  }
1597
  elseif(is_home())
1598
- $found_main = isset($instance['rw_opt']['others_blog_page']) ? TRUE : FALSE;
1599
  elseif(is_page())
1600
- $found_main = isset($instance['rw_opt']['pageid_'.$post_id]) ? TRUE : FALSE;
1601
  elseif(is_singular())
1602
  {
1603
- $found_main = isset($instance['rw_opt']['cpt_'.get_post_type($post_id)]) ? TRUE : FALSE;
1604
 
1605
- if(is_single() && $found_main == FALSE)
1606
- $found_main = isset($instance['rw_opt']['others_single_post']) ? TRUE : FALSE;
1607
  }
1608
  elseif(is_category())
1609
- $found_main = isset($instance['rw_opt']['category_'.get_query_var('cat')]) ? TRUE : FALSE;
1610
  elseif(is_tag())
1611
  {
1612
  if(($object = get_queried_object()) !== NULL && isset($object->taxonomy) && $object->taxonomy === 'post_tag')
@@ -1614,77 +1614,77 @@ class Restrict_Widgets
1614
  else
1615
  $tag = '';
1616
 
1617
- $found_main = isset($instance['rw_opt']['taxonomy_'.$tag]) ? TRUE : FALSE;
1618
  }
1619
  elseif(is_tax())
1620
- $found_main = isset($instance['rw_opt']['taxonomy_'.get_query_var('taxonomy')]) ? TRUE : FALSE;
1621
  elseif(is_404())
1622
- $found_main = isset($instance['rw_opt']['others_404_page']) ? TRUE : FALSE;
1623
  elseif(is_sticky())
1624
- $found_main = isset($instance['rw_opt']['others_sticky_post']) ? TRUE : FALSE;
1625
  elseif(is_search())
1626
- $found_main = isset($instance['rw_opt']['others_search_page']) ? TRUE : FALSE;
1627
  elseif(is_author())
1628
- $found_main = isset($instance['rw_opt']['others_author_archive']) ? TRUE : FALSE;
1629
  elseif(is_date())
1630
- $found_main = isset($instance['rw_opt']['others_date_archive']) ? TRUE : FALSE;
1631
  elseif(is_post_type_archive())
1632
- $found_main = isset($instance['rw_opt']['cpta_'.get_post_type($post_id)]) ? TRUE : FALSE;
1633
  elseif(function_exists('bbp_is_search') && bbp_is_search())
1634
- $found_main = isset($instance['rw_opt']['bbpress_search']) ? TRUE : FALSE;
1635
  elseif(function_exists('bbp_is_single_user') && bbp_is_single_user())
1636
- $found_main = isset($instance['rw_opt']['bbpress_single_user']) ? TRUE : FALSE;
1637
  elseif(function_exists('bbp_is_topic_tag') && bbp_is_topic_tag())
1638
- $found_main = isset($instance['rw_opt']['bbpress_topic_tag']) ? TRUE : FALSE;
1639
 
1640
- $display_main = ($display_type === TRUE ? ($found_main === TRUE ? TRUE : FALSE) : ($found_main === TRUE ? FALSE : TRUE));
1641
  }
1642
  else
1643
- $display_main = TRUE;
1644
  }
1645
 
1646
- if($filter === FALSE)
1647
- $instance = TRUE;
1648
 
1649
- if($display_type === TRUE)
1650
- $final_return = ($display_lang === TRUE && $display_user === TRUE && $display_device === TRUE && $display_main === TRUE ? $instance : FALSE);
1651
  else
1652
  $final_return = (
1653
  (
1654
  //4
1655
- ($empty_lang === FALSE && $empty_user === FALSE && $empty_device === FALSE && $empty_main === FALSE && $display_lang === FALSE && $display_user === FALSE && $display_device === FALSE && $display_main === FALSE) ||
1656
 
1657
  //3
1658
- ($empty_lang === FALSE && $empty_user === FALSE && $empty_device === FALSE && $display_lang === FALSE && $display_user === FALSE && $display_device === FALSE) ||
1659
- ($empty_lang === FALSE && $empty_user === FALSE && $empty_main === FALSE && $display_lang === FALSE && $display_user === FALSE && $display_main === FALSE) ||
1660
- ($empty_lang === FALSE && $empty_device === FALSE && $empty_main === FALSE && $display_lang === FALSE && $display_device === FALSE && $display_main === FALSE) ||
1661
- ($empty_user === FALSE && $empty_device === FALSE && $empty_main === FALSE && $display_user === FALSE && $display_device === FALSE && $display_main === FALSE) ||
1662
 
1663
  //2
1664
- ($empty_lang === FALSE && $empty_user === FALSE && $display_lang === FALSE && $display_user === FALSE) ||
1665
- ($empty_lang === FALSE && $empty_device === FALSE && $display_lang === FALSE && $display_device === FALSE) ||
1666
- ($empty_lang === FALSE && $empty_main === FALSE && $display_lang === FALSE && $display_main === FALSE) ||
1667
- ($empty_user === FALSE && $empty_device === FALSE && $display_user === FALSE && $display_device === FALSE) ||
1668
- ($empty_user === FALSE && $empty_main === FALSE && $display_user === FALSE && $display_main === FALSE) ||
1669
- ($empty_device === FALSE && $empty_main === FALSE && $display_device === FALSE && $display_main === FALSE) ||
1670
 
1671
  //1
1672
- ($empty_lang === FALSE && $display_lang === FALSE) ||
1673
- ($empty_user === FALSE && $display_user === FALSE) ||
1674
- ($empty_device === FALSE && $display_device === FALSE) ||
1675
- ($empty_main === FALSE && $display_main === FALSE)
1676
  )
1677
- ? FALSE : $instance
1678
  );
1679
 
1680
  //filter true or false
1681
- if($filter === TRUE)
1682
  $final_return = apply_filters_ref_array('rw_display_widget', array($final_return, $instance));
1683
 
1684
  //if true return instance
1685
- $final_return = ($final_return === FALSE) ? FALSE : $instance;
1686
 
1687
- //display: return $instance, hide: return FALSE
1688
  return $final_return;
1689
  }
1690
 
@@ -1803,7 +1803,7 @@ class Restrict_Widgets
1803
  add_action('admin_menu', array(&$this, 'manage_widgets_menu_fix'), 999);
1804
 
1805
  //add cap to edit widgets
1806
- $allcaps['edit_theme_options'] = TRUE;
1807
  }
1808
  }
1809
  }
2
  /*
3
  Plugin Name: Restrict Widgets
4
  Description: All in one solution for widget management in WordPress. Allows you to hide or display widgets on specified pages and restrict access for users.
5
+ Version: 1.2.5
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/restrict-widgets/
44
  private $hidden_widget = '';
45
  private $checked_widget = '';
46
  private $widgets = array();
47
+ private $bbpress_active = false;
48
+ private $polylang_active = false;
49
+ private $wpml_active = false;
50
 
51
 
52
  public function __construct()
120
  'available' => array(),
121
  'selection' => array(),
122
  'sidebars' => array(),
123
+ 'groups' => true,
124
+ 'deactivation' => false,
125
  ),
126
  '',
127
  'no'
141
  $current_blog_id = get_current_blog_id();
142
  $blogs_ids = $wpdb->get_col($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs, ''));
143
 
144
+ if(($activated_blogs = get_site_option('restrict_widgets_activated_blogs', false, false)) === false)
145
  $activated_blogs = array();
146
 
147
  foreach($blogs_ids as $blog_id)
149
  switch_to_blog($blog_id);
150
  $this->deactivate_single();
151
 
152
+ if(in_array((int)$blog_id, $activated_blogs, true))
153
  unset($activated_blogs[array_search($blog_id, $activated_blogs)]);
154
  }
155
 
168
  {
169
  $option = get_option('rw_widgets_options');
170
 
171
+ if($option['deactivation'] === true)
172
  {
173
  global $wp_roles, $wp_registered_widgets;
174
 
196
 
197
 
198
  /**
199
+ * Fix for is_active_sidebar (all hidden widgets on sidebar = false)
200
  */
201
  public function restrict_sidebar_widgets()
202
  {
204
  {
205
  $options = get_option('rw_widgets_options');
206
 
207
+ if(isset($options['sidebar']) && $options['sidebar'] === true)
208
  {
209
  global $wp_registered_widgets, $_wp_sidebars_widgets;
210
 
232
  {
233
  foreach($instance as $widget_id => $widget)
234
  {
235
+ $this->widgets[substr($widget_id, 7)] = $this->restrict_widget($widget, false, array('widget_id' => substr($widget_id, 7)));
236
  }
237
  }
238
 
248
  {
249
  foreach($s_widgets as $widget)
250
  {
251
+ if($this->widgets[$widget] === false && ($widget_key = array_search($widget, $_wp_sidebars_widgets[$sidebar])) !== false)
252
  unset($_wp_sidebars_widgets[$sidebar][$widget_key]);
253
  }
254
  }
265
  */
266
  public function polylang_widgets()
267
  {
268
+ if($this->polylang_active === true)
269
  {
270
  global $polylang;
271
 
280
  */
281
  public function load_textdomain()
282
  {
283
+ load_plugin_textdomain('restrict-widgets', false, RESTRICT_WIDGETS_REL_PATH.'languages/');
284
 
285
  if(class_exists('bbPress'))
286
+ $this->bbpress_active = true;
287
 
288
  if(class_exists('Polylang'))
289
+ $this->polylang_active = true;
290
 
291
  if(class_exists('SitePress'))
292
+ $this->wpml_active = true;
293
  }
294
 
295
 
369
  {
370
  $this->taxonomies = get_taxonomies(
371
  array(
372
+ '_builtin' => false
373
  ),
374
  'objects',
375
  'and'
377
 
378
  $this->categories = get_categories(
379
  array(
380
+ 'hide_empty' => false
381
  )
382
  );
383
 
384
  $this->custom_post_types = get_post_types(
385
  array(
386
+ 'public' => true,
387
+ '_builtin' => false
388
  ),
389
  'objects',
390
  'and'
392
 
393
  $this->custom_post_types_archives = get_post_types(
394
  array(
395
+ 'public' => true,
396
+ '_builtin' => false,
397
+ 'has_archive' => true
398
  ),
399
  'objects',
400
  'and'
417
  );
418
 
419
  //bbPress support
420
+ if($this->bbpress_active === true)
421
  {
422
  $this->bbpress = array(
423
  'search' => __('Search', 'restrict-widgets'),
464
  );
465
 
466
  //Polylang support
467
+ if($this->polylang_active === true)
468
  {
469
+ $languages = get_terms('language', array('hide_empty' => false));
470
 
471
  //we need to make WMPL style table
472
  foreach($languages as $language)
475
  }
476
  }
477
  //WMPL support
478
+ elseif($this->wpml_active === true)
479
  $this->languages = icl_get_languages('skip_missing=0&orderby=native_name&order=asc');
480
  else
481
+ $this->languages = false;
482
  }
483
 
484
 
514
  'available' => array(),
515
  'selection' => array(),
516
  'sidebars' => array(),
517
+ 'groups' => false,
518
+ 'sidebar' => false,
519
+ 'deactivation' => false
520
  );
521
 
522
  //display groups?
523
+ $save_widgets['groups'] = (isset($_POST['options-widgets-groups']) ? true : false);
524
 
525
  //modify is_active_sidebar?
526
+ $save_widgets['sidebar'] = (isset($_POST['options-widgets-sidebar']) ? true : false);
527
 
528
  //remove plugin data?
529
+ $save_widgets['deactivation'] = (isset($_POST['options-widgets-deactivation']) ? true : false);
530
 
531
  //do we have some available widgets?
532
  if(isset($_POST['options-available-widgets']))
533
  {
534
  foreach($_POST['options-available-widgets'] as $widget_class)
535
  {
536
+ $save_widgets['available'][$widget_class] = true;
537
  }
538
  }
539
 
547
  {
548
  $tmp = explode('_', $element, 2);
549
 
550
+ if(in_array($tmp[0], array('cpt', 'cpta'), true))
551
+ $save_widgets['selection'][$tmp[0] === 'cpt' ? 'custom_post_types' : 'custom_post_types_archives'][$tmp[0].'_'.sanitize_key($tmp[1])] = true;
552
  }
553
 
554
  foreach($this->pages as $page)
555
  {
556
+ if(in_array('pageid_'.$page->ID, $selected, true))
557
+ $save_widgets['selection']['pages']['pageid_'.$page->ID] = true;
558
  }
559
 
560
  foreach($this->custom_post_types as $cpt)
561
  {
562
+ if(in_array('cpt_'.$cpt->name, $selected, true))
563
+ $save_widgets['selection']['custom_post_types']['cpt_'.$cpt->name] = true;
564
  }
565
 
566
  foreach($this->categories as $category)
567
  {
568
+ if(in_array('category_'.$category->cat_ID, $selected, true))
569
+ $save_widgets['selection']['categories']['category_'.$category->cat_ID] = true;
570
  }
571
 
572
  foreach($this->taxonomies as $taxonomy)
573
  {
574
+ if(in_array('taxonomy_'.$taxonomy->name, $selected, true))
575
+ $save_widgets['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = true;
576
  }
577
 
578
  foreach($this->others as $key => $value)
579
  {
580
+ if(in_array('others_'.$key, $selected, true))
581
+ $save_widgets['selection']['others']['others_'.$key] = true;
582
  }
583
 
584
  foreach($this->users as $key => $value)
585
  {
586
+ if(in_array('users_'.$key, $selected, true))
587
+ $save_widgets['selection']['users']['users_'.$key] = true;
588
  }
589
 
590
  foreach($this->devices as $key => $value)
591
  {
592
+ if(in_array('devices_'.$key, $selected, true))
593
+ $save_widgets['selection']['devices']['devices_'.$key] = true;
594
  }
595
 
596
+ if($this->bbpress_active === true)
597
  {
598
  foreach($this->bbpress as $key => $value)
599
  {
600
+ if(in_array('bbpress_'.$key, $selected, true))
601
+ $save_widgets['selection']['bbpress']['bbpress_'.$key] = true;
602
  }
603
  }
604
  }
608
  {
609
  foreach($_POST['options-widgets-sidebars'] as $sidebar)
610
  {
611
+ $save_widgets['sidebars'][$sidebar] = true;
612
  }
613
  }
614
 
646
  $widgets_unique = array();
647
  $option = get_option('rw_widgets_options');
648
 
649
+ if(isset($option['groups']) === false) $option['groups'] = false;
650
+ if(isset($option['deactivation']) === false) $option['deactivation'] = false;
651
 
652
  //we need to make a copy for sorting
653
  $widgets = $wp_registered_widgets;
673
  </div>
674
  <form action="" method="post">
675
 
676
+ <label>'.__('Restrict Users', 'restrict-widgets').'</label><br />
677
  <select name="options-widgets-roles[]" id="options-widgets-roles" multiple="multiple">';
678
 
679
  foreach($wp_roles->roles as $role_name => $role_array)
680
  {
681
+ 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>';
682
  }
683
 
684
  echo '
685
  </select>
686
 
687
+ <label>'.__('Restrict Sidebars', 'restrict-widgets').'</label><br />
688
  <select name="options-widgets-sidebars[]" id="options-widgets-sidebars" multiple="multiple">';
689
 
690
  foreach($wp_registered_sidebars as $sidebar)
691
  {
692
  if($sidebar['id'] !== 'wp_inactive_widgets')
693
  {
694
+ if(isset($option['sidebars'][$sidebar['id']]) === false)
695
+ $option['sidebars'][$sidebar['id']] = false;
696
 
697
+ echo '<option value="'.$sidebar['id'].'" '.selected($option['sidebars'][$sidebar['id']], true, false).'>'.$sidebar['name'].'</option>';
698
  }
699
  }
700
 
703
  <p class="description">'.__('Select which sidebars will be restricted to admins only.', 'restrict-widgets').'</p>';
704
 
705
  echo '
706
+ <label>'.__('Restrict Widgets', 'restrict-widgets').'</label><br />
707
  <select name="options-available-widgets[]" id="options-available-widgets" multiple="multiple">';
708
 
709
  foreach(array_unique($widgets_unique) as $widget_class => $widget_name)
710
  {
711
+ if(isset($option['available'][$widget_class]) === false)
712
+ $option['available'][$widget_class] = false;
713
 
714
+ echo '<option value="'.$widget_class.'" '.selected($option['available'][$widget_class], true, false).'>'.$widget_name.'</option>';
715
  }
716
 
717
  echo '
718
  </select>
719
  <p class="description">'.__('Select which widgets will be restricted to admins only.', 'restrict-widgets').'</p>
720
 
721
+ <label>'.__('Restrict Widget Options', 'restrict-widgets').'</label><br />
722
  <select name="options-widgets-selection[]" id="options-widgets-selection" multiple="multiple">';
723
 
724
  foreach($this->options as $group_name => $value)
731
  <p class="description">'.__('Select which widget options will be restricted to admins only.', 'restrict-widgets').'</p>
732
  <table>
733
  <tr>
734
+ <td><label>'.__('Restrict Option Groups', 'restrict-widgets').'</label></td>
735
  <td>
736
  <label for="options-widgets-groups">
737
+ <input type="checkbox" name="options-widgets-groups" id="options-widgets-groups" value="1" '.checked($option['groups'], true, false).' />
738
+ <span class="description">'.__('Display widget options in groups', 'restrict-widgets').'</span></label>
739
  </td>
740
  </tr>
741
  <tr>
742
+ <td><label>'.__('Modify is_active_sidebar()', 'restrict-widgets').'</label></td>
743
  <td>
744
  <label for="options-widgets-sidebar">
745
+ <input type="checkbox" name="options-widgets-sidebar" id="options-widgets-sidebar" value="1" '.checked(isset($option['sidebar']) ? $option['sidebar'] : false, true, false).' />
746
+ <span class="description">'.__('By default is_active_sidebar() function returns true even if no widget is displayed in a sidebar. Check this if you want is_active_sidebar() to recognize Restrict Widgets display settings.', 'restrict-widgets').'</span></label>
747
  </td>
748
  </tr>
749
  <tr>
750
+ <td><label>'.__('Plugin Deactivation', 'restrict-widgets').'</label></td>
751
  <td>
752
  <label for="options-widgets-deactivation">
753
+ <input type="checkbox" name="options-widgets-deactivation" id="options-widgets-deactivation" value="1" '.checked($option['deactivation'], true, false).' />
754
+ <span class="description">'.__('Remove all plugin data on deactivation', 'restrict-widgets').'</span></label>
755
  </td>
756
  </tr>
757
  </table>
858
 
859
  wp_enqueue_style(
860
  'chosen',
861
+ RESTRICT_WIDGETS_URL.'/css/chosen.min.css'
862
  );
863
 
864
  wp_enqueue_style(
880
  {
881
  case 'pages':
882
  {
883
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
884
  $html .= '<optgroup label="'.$this->options['pages'].'">';
885
 
886
  foreach($this->pages as $page)
889
  {
890
  case 'option':
891
  {
892
+ if(isset($option['selection']['pages']['pageid_'.$page->ID]) === false)
893
+ $option['selection']['pages']['pageid_'.$page->ID] = false;
894
 
895
+ $html .= '<option value="pageid_'.$page->ID.'" '.selected($option['selection']['pages']['pageid_'.$page->ID], true, false).'>'.$page->post_title.'</option>';
896
 
897
  break;
898
  }
900
  {
901
  if(!isset($rw_option['selection']['pages']['pageid_'.$page->ID]) || current_user_can('manage_options'))
902
  {
903
+ if(isset($instance['rw_opt']['pageid_'.$page->ID]) === false)
904
  $instance['rw_opt']['pageid_'.$page->ID] = 0;
905
 
906
+ $html .= '<option value="pageid_'.$page->ID.'" '.selected($instance['rw_opt']['pageid_'.$page->ID], true, false).'>'.apply_filters('rw_option_display_name', $page->post_title, 'page').'</option>';
907
  }
908
 
909
  break;
911
  }
912
  }
913
 
914
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
915
  $html .= '</optgroup>';
916
 
917
  return $html;
918
  }
919
  case 'custom_post_types':
920
  {
921
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
922
  $html .= '<optgroup label="'.$this->options['custom_post_types'].'">';
923
 
924
  foreach($this->custom_post_types as $cpt)
927
  {
928
  case 'option':
929
  {
930
+ if(isset($option['selection']['custom_post_types']['cpt_'.$cpt->name]) === false)
931
+ $option['selection']['custom_post_types']['cpt_'.$cpt->name] = false;
932
 
933
+ $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>';
934
 
935
  break;
936
  }
938
  {
939
  if(!isset($rw_option['selection']['custom_post_types']['cpt_'.$cpt->name]) || current_user_can('manage_options'))
940
  {
941
+ if(isset($instance['rw_opt']['cpt_'.$cpt->name]) === false)
942
  $instance['rw_opt']['cpt_'.$cpt->name] = 0;
943
 
944
+ $html .= '<option value="cpt_'.$cpt->name.'" '.selected($instance['rw_opt']['cpt_'.$cpt->name], true, false).'>'.apply_filters('rw_option_display_name', sprintf(__('Single %s','restrict-widgets'), $cpt->label), 'custom_post_type').'</option>';
945
  }
946
 
947
  break;
949
  }
950
  }
951
 
952
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
953
  $html .= '</optgroup>';
954
 
955
  return $html;
956
  }
957
  case 'custom_post_types_archives':
958
  {
959
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
960
  $html .= '<optgroup label="'.$this->options['custom_post_types_archives'].'">';
961
 
962
  foreach($this->custom_post_types_archives as $cpta)
965
  {
966
  case 'option':
967
  {
968
+ if(isset($option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) === false)
969
+ $option['selection']['custom_post_types_archives']['cpta_'.$cpta->name] = false;
970
 
971
+ $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>';
972
 
973
  break;
974
  }
976
  {
977
  if(!isset($rw_option['selection']['custom_post_types_archives']['cpta_'.$cpta->name]) || current_user_can('manage_options'))
978
  {
979
+ if(isset($instance['rw_opt']['cpta_'.$cpta->name]) === false)
980
  $instance['rw_opt']['cpta_'.$cpta->name] = 0;
981
 
982
+ $html .= '<option value="cpta_'.$cpta->name.'" '.selected($instance['rw_opt']['cpta_'.$cpta->name], true, false).'>'.apply_filters('rw_option_display_name', sprintf(__('%s Archive','restrict-widgets'), $cpta->label), 'custom_post_type_archive').'</option>';
983
  }
984
 
985
  break;
987
  }
988
  }
989
 
990
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
991
  $html .= '</optgroup>';
992
 
993
  return $html;
994
  }
995
  case 'categories':
996
  {
997
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
998
  $html .= '<optgroup label="'.$this->options['categories'].'">';
999
 
1000
  foreach($this->categories as $category)
1003
  {
1004
  case 'option':
1005
  {
1006
+ if(isset($option['selection']['categories']['category_'.$category->cat_ID]) === false)
1007
+ $option['selection']['categories']['category_'.$category->cat_ID] = false;
1008
 
1009
+ $html .= '<option value="category_'.$category->cat_ID.'" '.selected($option['selection']['categories']['category_'.$category->cat_ID], true, false).'>'.$category->cat_name.'</option>';
1010
 
1011
  break;
1012
  }
1014
  {
1015
  if(!isset($rw_option['selection']['categories']['category_'.$category->cat_ID]) || current_user_can('manage_options'))
1016
  {
1017
+ if(isset($instance['rw_opt']['category_'.$category->cat_ID]) === false)
1018
  $instance['rw_opt']['category_'.$category->cat_ID] = 0;
1019
 
1020
+ $html .= '<option value="category_'.$category->cat_ID.'" '.selected($instance['rw_opt']['category_'.$category->cat_ID], true, false).'>'.apply_filters('rw_option_display_name', $category->cat_name, 'category').'</option>';
1021
  }
1022
 
1023
  break;
1025
  }
1026
  }
1027
 
1028
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1029
  $html .= '</optgroup>';
1030
 
1031
  return $html;
1032
  }
1033
  case 'taxonomies':
1034
  {
1035
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1036
  $html .= '<optgroup label="'.$this->options['taxonomies'].'">';
1037
 
1038
  foreach($this->taxonomies as $taxonomy)
1041
  {
1042
  case 'option':
1043
  {
1044
+ if(isset($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) === false)
1045
+ $option['selection']['taxonomies']['taxonomy_'.$taxonomy->name] = false;
1046
 
1047
+ $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($option['selection']['taxonomies']['taxonomy_'.$taxonomy->name], true, false).'>'.$taxonomy->label.'</option>';
1048
 
1049
  break;
1050
  }
1052
  {
1053
  if(!isset($rw_option['selection']['taxonomies']['taxonomy_'.$taxonomy->name]) || current_user_can('manage_options'))
1054
  {
1055
+ if(isset($instance['rw_opt']['taxonomy_'.$taxonomy->name]) === false)
1056
  $instance['rw_opt']['taxonomy_'.$taxonomy->name] = 0;
1057
 
1058
+ $html .= '<option value="taxonomy_'.$taxonomy->name.'" '.selected($instance['rw_opt']['taxonomy_'.$taxonomy->name], true, false).'>'.apply_filters('rw_option_display_name', $taxonomy->label, 'taxonomy').'</option>';
1059
  }
1060
 
1061
  break;
1063
  }
1064
  }
1065
 
1066
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1067
  $html .= '</optgroup>';
1068
 
1069
  return $html;
1070
  }
1071
  case 'others':
1072
  {
1073
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1074
  $html .= '<optgroup label="'.$this->options['others'].'">';
1075
 
1076
  foreach($this->others as $key => $value)
1079
  {
1080
  case 'option':
1081
  {
1082
+ if(isset($option['selection']['others']['others_'.$key]) === false)
1083
+ $option['selection']['others']['others_'.$key] = false;
1084
 
1085
+ $html .= '<option value="others_'.$key.'" '.selected($option['selection']['others']['others_'.$key], true, false).'>'.$value.'</option>';
1086
 
1087
  break;
1088
  }
1090
  {
1091
  if(!isset($rw_option['selection']['others']['others_'.$key]) || current_user_can('manage_options'))
1092
  {
1093
+ if(isset($instance['rw_opt']['others_'.$key]) === false)
1094
  $instance['rw_opt']['others_'.$key] = 0;
1095
 
1096
+ $html .= '<option value="others_'.$key.'" '.selected($instance['rw_opt']['others_'.$key], true, false).'>'.apply_filters('rw_option_display_name', $value, 'other').'</option>';
1097
  }
1098
 
1099
  break;
1101
  }
1102
  }
1103
 
1104
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1105
  $html .= '</optgroup>';
1106
 
1107
  return $html;
1108
  }
1109
  case 'devices':
1110
  {
1111
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1112
  $html .= '<optgroup label="'.$this->options['devices'].'">';
1113
 
1114
  foreach($this->devices as $key => $value)
1117
  {
1118
  case 'option':
1119
  {
1120
+ if(isset($option['selection']['devices']['devices_'.$key]) === false)
1121
+ $option['selection']['devices']['devices_'.$key] = false;
1122
 
1123
+ $html .= '<option value="devices_'.$key.'" '.selected($option['selection']['devices']['devices_'.$key], true, false).'>'.$value.'</option>';
1124
 
1125
  break;
1126
  }
1128
  {
1129
  if(!isset($rw_option['selection']['devices']['devices_'.$key]) || current_user_can('manage_options'))
1130
  {
1131
+ if(isset($instance['rw_opt']['devices_'.$key]) === false)
1132
  $instance['rw_opt']['devices_'.$key] = 0;
1133
 
1134
+ $html .= '<option value="devices_'.$key.'" '.selected($instance['rw_opt']['devices_'.$key], true, false).'>'.apply_filters('rw_option_display_name', $value, 'device').'</option>';
1135
  }
1136
 
1137
  break;
1139
  }
1140
  }
1141
 
1142
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1143
  $html .= '</optgroup>';
1144
 
1145
  return $html;
1146
  }
1147
  case 'bbpress':
1148
  {
1149
+ if($this->bbpress_active === false)
1150
  return $html;
1151
 
1152
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1153
  $html .= '<optgroup label="'.$this->options['bbpress'].'">';
1154
 
1155
  foreach($this->bbpress as $key => $value)
1158
  {
1159
  case 'option':
1160
  {
1161
+ if(isset($option['selection']['bbpress']['bbpress_'.$key]) === false)
1162
+ $option['selection']['bbpress']['bbpress_'.$key] = false;
1163
 
1164
+ $html .= '<option value="bbpress_'.$key.'" '.selected($option['selection']['bbpress']['bbpress_'.$key], true, false).'>'.$value.'</option>';
1165
 
1166
  break;
1167
  }
1169
  {
1170
  if(!isset($rw_option['selection']['bbpress']['bbpress_'.$key]) || current_user_can('manage_options'))
1171
  {
1172
+ if(isset($instance['rw_opt']['bbpress_'.$key]) === false)
1173
  $instance['rw_opt']['bbpress_'.$key] = 0;
1174
 
1175
+ $html .= '<option value="bbpress_'.$key.'" '.selected($instance['rw_opt']['bbpress_'.$key], true, false).'>'.apply_filters('rw_option_display_name', $value, 'bbpress').'</option>';
1176
  }
1177
 
1178
  break;
1180
  }
1181
  }
1182
 
1183
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1184
  $html .= '</optgroup>';
1185
 
1186
  return $html;
1187
  }
1188
  case 'users':
1189
  {
1190
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1191
  $html .= '<optgroup label="'.$this->options['users'].'">';
1192
 
1193
  foreach($this->users as $key => $value)
1196
  {
1197
  case 'option':
1198
  {
1199
+ if(isset($option['selection']['users']['users_'.$key]) === false)
1200
+ $option['selection']['users']['users_'.$key] = false;
1201
 
1202
+ $html .= '<option value="users_'.$key.'" '.selected($option['selection']['users']['users_'.$key], true, false).'>'.$value.'</option>';
1203
 
1204
  break;
1205
  }
1207
  {
1208
  if(!isset($rw_option['selection']['users']['users_'.$key]) || current_user_can('manage_options'))
1209
  {
1210
+ if(isset($instance['rw_opt']['users_'.$key]) === false)
1211
  $instance['rw_opt']['users_'.$key] = 0;
1212
 
1213
+ $html .= '<option value="users_'.$key.'" '.selected($instance['rw_opt']['users_'.$key], true, false).'>'.apply_filters('rw_option_display_name', $value, 'user').'</option>';
1214
  }
1215
 
1216
  break;
1218
  }
1219
  }
1220
 
1221
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1222
  $html .= '</optgroup>';
1223
 
1224
  return $html;
1225
  }
1226
  case 'languages':
1227
  {
1228
+ if($this->languages === false)
1229
  return $html;
1230
 
1231
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1232
  $html .= '<optgroup label="'.$this->options['languages'].'">';
1233
 
1234
  foreach($this->languages as $key => $language)
1237
  {
1238
  case 'option':
1239
  {
1240
+ if(isset($option['selection']['languages']['language_'.$key]) === false)
1241
+ $option['selection']['languages']['language_'.$key] = false;
1242
 
1243
+ $html .= '<option value="language_'.$key.'" '.selected($option['selection']['languages']['language_'.$key], true, false).'>'.$language['native_name'].'</option>';
1244
 
1245
  break;
1246
  }
1248
  {
1249
  if(!isset($rw_option['selection']['languages']['language_'.$key]) || current_user_can('manage_options'))
1250
  {
1251
+ if(isset($instance['rw_opt']['language_'.$key]) === false)
1252
  $instance['rw_opt']['language_'.$key] = 0;
1253
 
1254
+ $html .= '<option value="language_'.$key.'" '.selected($instance['rw_opt']['language_'.$key], true, false).'>'.apply_filters('rw_option_display_name', $language['native_name'], 'language').'</option>';
1255
  }
1256
 
1257
  break;
1259
  }
1260
  }
1261
 
1262
+ if(($rw_option['groups'] === true && $type === 'widget') || current_user_can('manage_options'))
1263
  $html .= '</optgroup>';
1264
 
1265
  return $html;
1273
  */
1274
  public function display_admin_widgets_options($widget, $empty, $instance)
1275
  {
1276
+ if(isset($instance['rw_opt']['widget_select']) === false)
1277
+ $instance['rw_opt']['widget_select'] = false;
1278
 
1279
  echo '
1280
  <div class="restrict-widgets-hide-div restrict-widgets">
1281
  <p class="restrict-widgets-display-label">'.__('Display / Hide Widget', 'restrict-widgets').'</p>
1282
+ <select name="'.$widget->get_field_name('widget_select').'" class="restrict-widgets-hide chosen-select">
1283
+ <option value="yes" '.selected($instance['rw_opt']['widget_select'], true, false).'>'.__('Display widget on selected', 'restrict-widgets').'</option>
1284
+ <option value="no" '.selected($instance['rw_opt']['widget_select'], false, false).'>'.__('Hide widget on selected', 'restrict-widgets').'</option>
1285
  </select>
1286
  </div>
1287
  <div class="restrict-widgets-select-div restrict-widgets">
1288
+ <select class="restrict-widgets-select chosen-select" multiple="multiple" size="10" name="'.$widget->get_field_name('widget_multiselect').'[]">';
1289
 
1290
  foreach($this->options as $option => $text)
1291
  {
1311
  foreach($this->pages as $page)
1312
  {
1313
  if(in_array('pageid_'.$page->ID, $selected))
1314
+ $instance['rw_opt']['pageid_'.$page->ID] = true;
1315
  else
1316
  unset($instance['rw_opt']['pageid_'.$page->ID]);
1317
  }
1320
  foreach($this->custom_post_types as $cpt)
1321
  {
1322
  if(in_array('cpt_'.$cpt->name, $selected))
1323
+ $instance['rw_opt']['cpt_'.$cpt->name] = true;
1324
  else
1325
  unset($instance['rw_opt']['cpt_'.$cpt->name]);
1326
  }
1329
  foreach($this->custom_post_types_archives as $cpta)
1330
  {
1331
  if(in_array('cpta_'.$cpta->name, $selected))
1332
+ $instance['rw_opt']['cpta_'.$cpta->name] = true;
1333
  else
1334
  unset($instance['rw_opt']['cpta_'.$cpta->name]);
1335
  }
1338
  foreach($this->categories as $category)
1339
  {
1340
  if(in_array('category_'.$category->cat_ID, $selected))
1341
+ $instance['rw_opt']['category_'.$category->cat_ID] = true;
1342
  else
1343
  unset($instance['rw_opt']['category_'.$category->cat_ID]);
1344
  }
1347
  foreach($this->taxonomies as $taxonomy)
1348
  {
1349
  if(in_array('taxonomy_'.$taxonomy->name, $selected))
1350
+ $instance['rw_opt']['taxonomy_'.$taxonomy->name] = true;
1351
  else
1352
  unset($instance['rw_opt']['taxonomy_'.$taxonomy->name]);
1353
  }
1356
  foreach($this->others as $key => $value)
1357
  {
1358
  if(in_array('others_'.$key, $selected))
1359
+ $instance['rw_opt']['others_'.$key] = true;
1360
  else
1361
  unset($instance['rw_opt']['others_'.$key]);
1362
  }
1365
  foreach($this->devices as $key => $value)
1366
  {
1367
  if(in_array('devices_'.$key, $selected))
1368
+ $instance['rw_opt']['devices_'.$key] = true;
1369
  else
1370
  unset($instance['rw_opt']['devices_'.$key]);
1371
  }
1372
 
1373
  //bbpress
1374
+ if($this->bbpress_active === true)
1375
  {
1376
  foreach($this->bbpress as $key => $value)
1377
  {
1378
  if(in_array('bbpress_'.$key, $selected))
1379
+ $instance['rw_opt']['bbpress_'.$key] = true;
1380
  else
1381
  unset($instance['rw_opt']['bbpress_'.$key]);
1382
  }
1386
  foreach($this->users as $key => $value)
1387
  {
1388
  if(in_array('users_'.$key, $selected))
1389
+ $instance['rw_opt']['users_'.$key] = true;
1390
  else
1391
  unset($instance['rw_opt']['users_'.$key]);
1392
  }
1393
 
1394
  //languages
1395
+ if($this->languages !== false)
1396
  {
1397
  foreach($this->languages as $key => $value)
1398
  {
1399
  if(in_array('language_'.$key, $selected))
1400
+ $instance['rw_opt']['language_'.$key] = true;
1401
  else
1402
  unset($instance['rw_opt']['language_'.$key]);
1403
  }
1407
  else unset($instance['rw_opt']);
1408
 
1409
  //widget_multiselect
1410
+ $instance['rw_opt']['widget_select'] = ($new_instance['widget_select'] === 'yes' ? true : false);
1411
 
1412
  return $instance;
1413
  }
1431
  $array = array('users');
1432
 
1433
  if(in_array($action[0], $array))
1434
+ return false;
1435
  }
1436
  }
1437
 
1438
+ return true;
1439
  }
1440
 
1441
 
1444
  */
1445
  public function display_frontend_widgets($instance, $class, $args)
1446
  {
1447
+ return $this->restrict_widget($instance, true, $args);
1448
  }
1449
 
1450
 
1451
  /**
1452
  * Displays or hides specific widget
1453
  */
1454
+ private function restrict_widget($instance, $filter = true, $args = array())
1455
  {
1456
  global $wp_query;
1457
 
1458
  $display_lang = $display_user = $display_device = $display_main = '';
1459
+ $empty_lang = $empty_user = $empty_device = $empty_main = true;
1460
+ $return = false;
1461
 
1462
  $post_id = $wp_query->get_queried_object_id();
1463
 
1464
+ $display_type = isset($instance['rw_opt']['widget_select']) ? $instance['rw_opt']['widget_select'] : false;
1465
 
1466
  //languages
1467
+ if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'lang') === false)
1468
  {
1469
+ if($this->polylang_active === true || $this->wpml_active === true)
1470
  {
1471
+ $empty_lang = false;
1472
 
1473
  //fix for WPML
1474
  if(function_exists('icl_object_id'))
1476
  global $sitepress;
1477
 
1478
  if(isset($sitepress))
1479
+ $post_id = icl_object_id($post_id, 'page', true, $sitepress->get_default_language());
1480
  else
1481
+ $post_id = icl_object_id($post_id, 'page', false);
1482
  }
1483
 
1484
+ $found_lang = (defined('ICL_LANGUAGE_CODE') && isset($instance['rw_opt']['language_'.ICL_LANGUAGE_CODE]) ? true : false);
1485
 
1486
+ if($display_type === true)
1487
  {
1488
+ if($found_lang === true)
1489
+ $display_lang = true;
1490
  else
1491
  {
1492
+ $return = true;
1493
+ $display_lang = false;
1494
  }
1495
  }
1496
  else
1497
+ $display_lang = ($found_lang === true ? false : true);
1498
  }
1499
  else
1500
+ $display_lang = true;
1501
  }
1502
  else
1503
+ $display_lang = true;
1504
 
1505
  //users
1506
+ if($return === false)
1507
  {
1508
+ if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'user') === false)
1509
  {
1510
+ $empty_user = false;
1511
 
1512
  if(is_user_logged_in())
1513
  {
1514
  if(isset($instance['rw_opt']['users_logged_in'], $instance['rw_opt']['users_logged_out']) || isset($instance['rw_opt']['users_logged_in']))
1515
+ $found_user = true;
1516
  elseif(isset($instance['rw_opt']['users_logged_out']))
1517
+ $found_user = false;
1518
  }
1519
  else
1520
  {
1521
  if(isset($instance['rw_opt']['users_logged_out'], $instance['rw_opt']['users_logged_in']) || isset($instance['rw_opt']['users_logged_out']))
1522
+ $found_user = true;
1523
  elseif(isset($instance['rw_opt']['users_logged_in']))
1524
+ $found_user = false;
1525
  }
1526
 
1527
+ if($display_type === true)
1528
  {
1529
+ if($found_user === true)
1530
+ $display_user = true;
1531
  else
1532
  {
1533
+ $return = true;
1534
+ $display_user = false;
1535
  }
1536
  }
1537
  else
1538
+ $display_user = ($found_user === true ? false : true);
1539
  }
1540
  else
1541
+ $display_user = true;
1542
  }
1543
 
1544
  //devices
1545
+ if($return === false)
1546
  {
1547
+ if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'device') === false)
1548
  {
1549
+ $empty_device = false;
1550
 
1551
  if(wp_is_mobile())
1552
  {
1553
  if(isset($instance['rw_opt']['devices_mobile'], $instance['rw_opt']['devices_desktop']) || isset($instance['rw_opt']['devices_mobile']))
1554
+ $found_device = true;
1555
  elseif(isset($instance['rw_opt']['devices_desktop']))
1556
+ $found_device = false;
1557
  }
1558
  else
1559
  {
1560
  if(isset($instance['rw_opt']['devices_desktop'], $instance['rw_opt']['devices_mobile']) || isset($instance['rw_opt']['devices_desktop']))
1561
+ $found_device = true;
1562
  elseif(isset($instance['rw_opt']['devices_mobile']))
1563
+ $found_device = false;
1564
  }
1565
 
1566
+ if($display_type === true)
1567
  {
1568
+ if($found_device === true)
1569
+ $display_device = true;
1570
  else
1571
  {
1572
+ $return = true;
1573
+ $display_device = false;
1574
  }
1575
  }
1576
  else
1577
+ $display_device = ($found_device === true ? false : true);
1578
  }
1579
  else
1580
+ $display_device = true;
1581
  }
1582
 
1583
  //rest
1584
+ if($return === false)
1585
  {
1586
+ if(isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'main') === false)
1587
  {
1588
+ $empty_main = false;
1589
 
1590
  if(is_front_page())
1591
  {
1592
+ $found_main = isset($instance['rw_opt']['others_front_page']) ? true : false;
1593
 
1594
+ if(is_home() && $found_main == false)
1595
+ $found_main = isset($instance['rw_opt']['others_blog_page']) ? true : false;
1596
  }
1597
  elseif(is_home())
1598
+ $found_main = isset($instance['rw_opt']['others_blog_page']) ? true : false;
1599
  elseif(is_page())
1600
+ $found_main = isset($instance['rw_opt']['pageid_'.$post_id]) ? true : false;
1601
  elseif(is_singular())
1602
  {
1603
+ $found_main = isset($instance['rw_opt']['cpt_'.get_post_type($post_id)]) ? true : false;
1604
 
1605
+ if(is_single() && $found_main == false)
1606
+ $found_main = isset($instance['rw_opt']['others_single_post']) ? true : false;
1607
  }
1608
  elseif(is_category())
1609
+ $found_main = isset($instance['rw_opt']['category_'.get_query_var('cat')]) ? true : false;
1610
  elseif(is_tag())
1611
  {
1612
  if(($object = get_queried_object()) !== NULL && isset($object->taxonomy) && $object->taxonomy === 'post_tag')
1614
  else
1615
  $tag = '';
1616
 
1617
+ $found_main = isset($instance['rw_opt']['taxonomy_'.$tag]) ? true : false;
1618
  }
1619
  elseif(is_tax())
1620
+ $found_main = isset($instance['rw_opt']['taxonomy_'.get_query_var('taxonomy')]) ? true : false;
1621
  elseif(is_404())
1622
+ $found_main = isset($instance['rw_opt']['others_404_page']) ? true : false;
1623
  elseif(is_sticky())
1624
+ $found_main = isset($instance['rw_opt']['others_sticky_post']) ? true : false;
1625
  elseif(is_search())
1626
+ $found_main = isset($instance['rw_opt']['others_search_page']) ? true : false;
1627
  elseif(is_author())
1628
+ $found_main = isset($instance['rw_opt']['others_author_archive']) ? true : false;
1629
  elseif(is_date())
1630
+ $found_main = isset($instance['rw_opt']['others_date_archive']) ? true : false;
1631
  elseif(is_post_type_archive())
1632
+ $found_main = isset($instance['rw_opt']['cpta_'.get_post_type($post_id)]) ? true : false;
1633
  elseif(function_exists('bbp_is_search') && bbp_is_search())
1634
+ $found_main = isset($instance['rw_opt']['bbpress_search']) ? true : false;
1635
  elseif(function_exists('bbp_is_single_user') && bbp_is_single_user())
1636
+ $found_main = isset($instance['rw_opt']['bbpress_single_user']) ? true : false;
1637
  elseif(function_exists('bbp_is_topic_tag') && bbp_is_topic_tag())
1638
+ $found_main = isset($instance['rw_opt']['bbpress_topic_tag']) ? true : false;
1639
 
1640
+ $display_main = ($display_type === true ? ($found_main === true ? true : false) : ($found_main === true ? false : true));
1641
  }
1642
  else
1643
+ $display_main = true;
1644
  }
1645
 
1646
+ if($filter === false)
1647
+ $instance = true;
1648
 
1649
+ if($display_type === true)
1650
+ $final_return = ($display_lang === true && $display_user === true && $display_device === true && $display_main === true ? $instance : false);
1651
  else
1652
  $final_return = (
1653
  (
1654
  //4
1655
+ ($empty_lang === false && $empty_user === false && $empty_device === false && $empty_main === false && $display_lang === false && $display_user === false && $display_device === false && $display_main === false) ||
1656
 
1657
  //3
1658
+ ($empty_lang === false && $empty_user === false && $empty_device === false && $display_lang === false && $display_user === false && $display_device === false) ||
1659
+ ($empty_lang === false && $empty_user === false && $empty_main === false && $display_lang === false && $display_user === false && $display_main === false) ||
1660
+ ($empty_lang === false && $empty_device === false && $empty_main === false && $display_lang === false && $display_device === false && $display_main === false) ||
1661
+ ($empty_user === false && $empty_device === false && $empty_main === false && $display_user === false && $display_device === false && $display_main === false) ||
1662
 
1663
  //2
1664
+ ($empty_lang === false && $empty_user === false && $display_lang === false && $display_user === false) ||
1665
+ ($empty_lang === false && $empty_device === false && $display_lang === false && $display_device === false) ||
1666
+ ($empty_lang === false && $empty_main === false && $display_lang === false && $display_main === false) ||
1667
+ ($empty_user === false && $empty_device === false && $display_user === false && $display_device === false) ||
1668
+ ($empty_user === false && $empty_main === false && $display_user === false && $display_main === false) ||
1669
+ ($empty_device === false && $empty_main === false && $display_device === false && $display_main === false) ||
1670
 
1671
  //1
1672
+ ($empty_lang === false && $display_lang === false) ||
1673
+ ($empty_user === false && $display_user === false) ||
1674
+ ($empty_device === false && $display_device === false) ||
1675
+ ($empty_main === false && $display_main === false)
1676
  )
1677
+ ? false : $instance
1678
  );
1679
 
1680
  //filter true or false
1681
+ if($filter === true)
1682
  $final_return = apply_filters_ref_array('rw_display_widget', array($final_return, $instance));
1683
 
1684
  //if true return instance
1685
+ $final_return = ($final_return === false) ? false : $instance;
1686
 
1687
+ //display: return $instance, hide: return false
1688
  return $final_return;
1689
  }
1690
 
1803
  add_action('admin_menu', array(&$this, 'manage_widgets_menu_fix'), 999);
1804
 
1805
  //add cap to edit widgets
1806
+ $allcaps['edit_theme_options'] = true;
1807
  }
1808
  }
1809
  }