| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class for Presets. |
| 5 |
* |
| 6 |
* @since 1.0.0 |
| 7 |
* @access public |
| 8 |
*/ |
| 9 |
class LoginPress_Presets extends WP_Customize_Control { |
| 10 |
|
| 11 |
/** |
| 12 |
* The type of customize control being rendered. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
* @access public |
| 16 |
* @var string |
| 17 |
*/ |
| 18 |
public $type = 'checkbox-multiple'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Enqueue scripts/styles. |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
* @access public |
| 25 |
* @return void |
| 26 |
*/ |
| 27 |
public function enqueue() { |
| 28 |
// wp_enqueue_script( 'jt-customize-controls', plugins_url( '/customize-controls.js' , __FILE__ ), array( 'jquery' ) ); |
| 29 |
// wp_enqueue_script( 'jquery-ui-button' ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Displays the control content. |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* @access public |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function render_content() { |
| 40 |
|
| 41 |
|
| 42 |
if ( empty( $this->choices ) ) |
| 43 |
return; |
| 44 |
$name = 'loginpress_preset-' . $this->id; ?> |
| 45 |
|
| 46 |
<span class="customize-control-title"> |
| 47 |
<?php echo esc_attr( $this->label ); ?> |
| 48 |
<?php if ( ! empty( $this->description ) ) : ?> |
| 49 |
<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span> |
| 50 |
<?php endif; ?> |
| 51 |
</span> |
| 52 |
|
| 53 |
<?php $multi_values = !is_array( $this->value() ) ? explode( ',', $this->value() ) : $this->value(); ?> |
| 54 |
|
| 55 |
|
| 56 |
<div id="input_<?php echo $this->id; ?>" class="image"> |
| 57 |
|
| 58 |
<?php foreach ( $this->choices as $val ) : ?> |
| 59 |
|
| 60 |
<?php $_disbaled = isset( $val['pro'] ) ? 'disabled' : ''; ?> |
| 61 |
<div class="loginpress_thumbnail"> |
| 62 |
<input <?php echo $_disbaled ?> class="image-select" type="radio" value="<?php echo esc_attr( $val['id'] ); ?>" id="<?php echo $this->id . $val['id']; ?>" name="<?php echo esc_attr( $name ); ?>" <?php checked( $this->value(), $val['id'] ); ?> /> |
| 63 |
<label for="<?php echo $this->id . $val['id']; ?>"> |
| 64 |
<div class="loginpress_thumbnail_img"> |
| 65 |
<img src="<?php echo $val['thumbnail']; ?>" alt="<?php echo esc_attr( $val['id'] ); ?>" title="<?php echo esc_attr( $val['id'] ); ?>"> |
| 66 |
</div> <!-- .img --> |
| 67 |
<h3><?php echo $val['name'] ?></h3> |
| 68 |
</label> |
| 69 |
<a href="http://www.wpbrigade.com" target="_blank" class="no-available"> |
| 70 |
<span>Available For Pro</span> |
| 71 |
</a> |
| 72 |
<!-- </input> --> |
| 73 |
</div> <!-- .loginpress_thumbnail --> |
| 74 |
|
| 75 |
<?php endforeach; ?> |
| 76 |
</div> |
| 77 |
|
| 78 |
<input name='presets_hidden' type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( implode( ',', $multi_values ) ); ?>" /> |
| 79 |
<?php } |
| 80 |
|
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
function loginpress_presets_control_css() { |
| 85 |
?> |
| 86 |
<style> |
| 87 |
.customize-control-checkbox-multiple .image.ui-buttonset input[type=radio] { |
| 88 |
height: auto; |
| 89 |
} |
| 90 |
.customize-control-checkbox-multiple .image.ui-buttonset label { |
| 91 |
display: inline-block; |
| 92 |
margin-right: 5px; |
| 93 |
margin-bottom: 5px; |
| 94 |
} |
| 95 |
.customize-control-checkbox-multiple .image.ui-buttonset label.ui-state-active { |
| 96 |
background: none; |
| 97 |
} |
| 98 |
.customize-control-checkbox-multiple .customize-control-radio-buttonset label { |
| 99 |
padding: 5px 10px; |
| 100 |
background: #f7f7f7; |
| 101 |
border-left: 1px solid #dedede; |
| 102 |
line-height: 35px; |
| 103 |
} |
| 104 |
.customize-control-checkbox-multiple label img { |
| 105 |
border: 1px solid #bbb; |
| 106 |
opacity: 0.5; |
| 107 |
} |
| 108 |
#customize-controls .customize-control-checkbox-multiple label img { |
| 109 |
max-width: 250px; |
| 110 |
height: auto; |
| 111 |
width: 100%; |
| 112 |
margin-bottom: 0; |
| 113 |
border: 0; |
| 114 |
display: block; |
| 115 |
} |
| 116 |
.customize-control-checkbox-multiple label.ui-state-active img { |
| 117 |
background: #dedede; |
| 118 |
border-color: #000; |
| 119 |
opacity: 1; |
| 120 |
margin-bottom: 0; |
| 121 |
} |
| 122 |
.customize-control-checkbox-multiple label.ui-state-hover img { |
| 123 |
opacity: 0.9; |
| 124 |
border-color: #999; |
| 125 |
} |
| 126 |
.customize-control-radio-buttonset label.ui-corner-left { |
| 127 |
border-radius: 3px 0 0 3px; |
| 128 |
border-left: 0; |
| 129 |
} |
| 130 |
.customize-control-radio-buttonset label.ui-corner-right { |
| 131 |
border-radius: 0 3px 3px 0; |
| 132 |
} |
| 133 |
#customize-control-customize_presets_settings input[type=radio]{ |
| 134 |
display: none; |
| 135 |
} |
| 136 |
#customize-control-customize_presets_settings label{ |
| 137 |
display: block; |
| 138 |
position: relative; |
| 139 |
width: 100%; |
| 140 |
} |
| 141 |
#customize-control-customize_presets_settings .loginpress_thumbnail{ |
| 142 |
width: calc(50% - 10px); |
| 143 |
margin-bottom: 10px; |
| 144 |
position: relative; |
| 145 |
} |
| 146 |
#customize-control-customize_presets_settings .loginpress_thumbnail:nth-child(odd){ |
| 147 |
float: left; |
| 148 |
} |
| 149 |
#customize-control-customize_presets_settings .loginpress_thumbnail:nth-child(even){ |
| 150 |
float: right; |
| 151 |
} |
| 152 |
#customize-control-customize_presets_settings .image:after{ |
| 153 |
content: ''; |
| 154 |
display: table; |
| 155 |
clear: both; |
| 156 |
} |
| 157 |
#customize-control-customize_presets_settings h3{ |
| 158 |
margin: 0; |
| 159 |
font: 400 14px 'Open Sans', Arial, Helvetica, sans-serif; |
| 160 |
line-height: 1.1; |
| 161 |
padding: 3px; |
| 162 |
text-align: center; |
| 163 |
background: #eee; |
| 164 |
color: #777777; |
| 165 |
} |
| 166 |
#customize-control-customize_presets_settings label .loginpress_thumbnail_img:after { |
| 167 |
content: ''; |
| 168 |
width: 20px; |
| 169 |
height: 20px; |
| 170 |
border-radius: 50%; |
| 171 |
background: #2EB150; |
| 172 |
position: absolute; |
| 173 |
top: -5px; |
| 174 |
left: -5px; |
| 175 |
border-radius: 50%; |
| 176 |
visibility: hidden; |
| 177 |
} |
| 178 |
#customize-control-customize_presets_settings label .loginpress_thumbnail_img:before { |
| 179 |
height: 6px; |
| 180 |
width: 3px; |
| 181 |
-webkit-transform-origin: left top; |
| 182 |
-moz-transform-origin: left top; |
| 183 |
-ms-transform-origin: left top; |
| 184 |
-o-transform-origin: left top; |
| 185 |
transform-origin: left top; |
| 186 |
border-right: 3px solid white; |
| 187 |
border-top: 3px solid white; |
| 188 |
border-radius: 2.5px !important; |
| 189 |
content: ''; |
| 190 |
position: absolute; |
| 191 |
z-index: 2; |
| 192 |
opacity: 0; |
| 193 |
margin-top: 0px; |
| 194 |
margin-left: -7px; |
| 195 |
top: 5px; |
| 196 |
left: 4px; |
| 197 |
} |
| 198 |
#customize-control-customize_presets_settings .loginpress_thumbnail_img{ |
| 199 |
display: block; |
| 200 |
position: relative; |
| 201 |
} |
| 202 |
#customize-control-customize_presets_settings input[type="radio"]:checked + label .loginpress_thumbnail_img:before { |
| 203 |
-webkit-animation-delay: 100ms; |
| 204 |
-moz-animation-delay: 100ms; |
| 205 |
animation-delay: 100ms; |
| 206 |
-webkit-animation-duration: 1s; |
| 207 |
-moz-animation-duration: 1s; |
| 208 |
animation-duration: 1s; |
| 209 |
-webkit-animation-timing-function: ease; |
| 210 |
-moz-animation-timing-function: ease; |
| 211 |
animation-timing-function: ease; |
| 212 |
-webkit-animation-name: checkmark; |
| 213 |
-moz-animation-name: checkmark; |
| 214 |
animation-name: checkmark; |
| 215 |
-webkit-transform: scaleX(-1) rotate(135deg); |
| 216 |
-moz-transform: scaleX(-1) rotate(135deg); |
| 217 |
-ms-transform: scaleX(-1) rotate(135deg); |
| 218 |
-o-transform: scaleX(-1) rotate(135deg); |
| 219 |
transform: scaleX(-1) rotate(135deg); |
| 220 |
-webkit-animation-fill-mode: forwards; |
| 221 |
-moz-animation-fill-mode: forwards; |
| 222 |
animation-fill-mode: forwards; |
| 223 |
z-index: 2; |
| 224 |
} |
| 225 |
#customize-control-customize_presets_settings input[type="radio"]:checked + label .loginpress_thumbnail_img:after{ |
| 226 |
visibility: visible; |
| 227 |
} |
| 228 |
/*#customize-control-customize_presets_settings input[type="radio"]:disabled + label .loginpress_thumbnail_img:before{ |
| 229 |
visibility: hidden; |
| 230 |
} |
| 231 |
#customize-control-customize_presets_settings input[type="radio"]:disabled + label .loginpress_thumbnail_img:after{ |
| 232 |
visibility: hidden; |
| 233 |
}*/ |
| 234 |
#customize-control-customize_presets_settings img{ |
| 235 |
margin-bottom: 0; |
| 236 |
} |
| 237 |
#customize-control-customize_presets_settings input[type="radio"]:checked + label img{ |
| 238 |
opacity: 1; |
| 239 |
} |
| 240 |
.no-available{ |
| 241 |
top: 0; |
| 242 |
left: 0; |
| 243 |
background: rgba(0, 0, 0, 0.7); |
| 244 |
content: ''; |
| 245 |
position: absolute; |
| 246 |
bottom: 0; |
| 247 |
right: 0; |
| 248 |
z-index: 100; |
| 249 |
padding: 20px; |
| 250 |
text-align: center; |
| 251 |
color: #fff; |
| 252 |
-webkit-transition:all 0.3s ease-in-out; |
| 253 |
-moz-transition:all 0.3s ease-in-out; |
| 254 |
-ms-transition:all 0.3s ease-in-out; |
| 255 |
transition:all 0.3s ease-in-out; |
| 256 |
opacity: 0; |
| 257 |
visibility: hidden; |
| 258 |
-webkit-transform: scale(.5); |
| 259 |
-moz-transform: scale(.5); |
| 260 |
-ms-transform: scale(.5); |
| 261 |
transform: scale(.5); |
| 262 |
text-decoration: none !important; |
| 263 |
} |
| 264 |
#customize-control-customize_presets_settings .loginpress_thumbnail:hover input[type="radio"]:disabled ~ .no-available{ |
| 265 |
opacity: 1; |
| 266 |
visibility: visible; |
| 267 |
color: #fff; |
| 268 |
-webkit-transform: scale(1); |
| 269 |
-moz-transform: scale(1); |
| 270 |
-ms-transform: scale(1); |
| 271 |
transform: scale(1); |
| 272 |
} |
| 273 |
|
| 274 |
@-webkit-keyframes checkmark { |
| 275 |
0% { |
| 276 |
height: 0; |
| 277 |
width: 0; |
| 278 |
opacity: 1; |
| 279 |
} |
| 280 |
20% { |
| 281 |
height: 0; |
| 282 |
width: 5px; |
| 283 |
opacity: 1; |
| 284 |
} |
| 285 |
40% { |
| 286 |
height: 10px; |
| 287 |
width: 5px; |
| 288 |
opacity: 1; |
| 289 |
} |
| 290 |
100% { |
| 291 |
height: 10px; |
| 292 |
width: 5px; |
| 293 |
opacity: 1; |
| 294 |
} |
| 295 |
} |
| 296 |
@-moz-keyframes checkmark { |
| 297 |
0% { |
| 298 |
height: 0; |
| 299 |
width: 0; |
| 300 |
opacity: 1; |
| 301 |
} |
| 302 |
20% { |
| 303 |
height: 0; |
| 304 |
width: 5px; |
| 305 |
opacity: 1; |
| 306 |
} |
| 307 |
40% { |
| 308 |
height: 10px; |
| 309 |
width: 5px; |
| 310 |
opacity: 1; |
| 311 |
} |
| 312 |
100% { |
| 313 |
height: 10px; |
| 314 |
width: 5px; |
| 315 |
opacity: 1; |
| 316 |
} |
| 317 |
} |
| 318 |
@keyframes checkmark { |
| 319 |
0% { |
| 320 |
height: 0; |
| 321 |
width: 0; |
| 322 |
opacity: 1; |
| 323 |
} |
| 324 |
20% { |
| 325 |
height: 0; |
| 326 |
width: 5px; |
| 327 |
opacity: 1; |
| 328 |
} |
| 329 |
40% { |
| 330 |
height: 10px; |
| 331 |
width: 5px; |
| 332 |
opacity: 1; |
| 333 |
} |
| 334 |
100% { |
| 335 |
height: 10px; |
| 336 |
width: 5px; |
| 337 |
opacity: 1; |
| 338 |
} |
| 339 |
} |
| 340 |
|
| 341 |
</style> |
| 342 |
<?php |
| 343 |
} |
| 344 |
add_action( 'customize_controls_print_styles', 'loginpress_presets_control_css' ); |
| 345 |
?> |
| 346 |
|