resources
7 years ago
ajax-customers.php
6 years ago
ajax-posts.php
7 years ago
ajax-products.php
8 years ago
ajax-terms.php
7 years ago
buttons.php
8 years ago
checkbox-array.php
6 years ago
checkbox.php
8 years ago
colorpicker.php
5 years ago
country-select.php
6 years ago
custom.php
7 years ago
customtabs.php
8 years ago
date-format.php
6 years ago
datepicker.php
6 years ago
dimensions.php
5 years ago
hidden.php
8 years ago
html.php
8 years ago
icons.php
8 years ago
image-gallery.php
8 years ago
inline-fields.php
5 years ago
list-table.php
6 years ago
multi-colorpicker.php
6 years ago
multi-select.php
6 years ago
number.php
8 years ago
onoff.php
6 years ago
password.php
6 years ago
preview.php
8 years ago
radio.php
5 years ago
select-buttons.php
6 years ago
select-images.php
6 years ago
select-mailchimp.php
8 years ago
select.php
5 years ago
sep.php
8 years ago
sidebarlist.php
8 years ago
sidebars.php
8 years ago
simple-text.php
8 years ago
slider.php
8 years ago
text-array.php
8 years ago
text-button.php
8 years ago
text.php
6 years ago
textarea-codemirror.php
8 years ago
textarea-editor.php
5 years ago
textarea.php
6 years ago
title.php
6 years ago
toggle-element-fixed.php
5 years ago
toggle-element.php
5 years ago
upload.php
6 years ago
toggle-element-fixed.php
77 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | $defaults = array( |
| 7 | 'id' => '', |
| 8 | 'name' => '', |
| 9 | 'class' => '', |
| 10 | 'custom_attributes' => '', |
| 11 | 'elements' => [], |
| 12 | 'onoff_field' => true, |
| 13 | 'save_single_options' => false, |
| 14 | |
| 15 | ); |
| 16 | $field = wp_parse_args( $field, $defaults ); |
| 17 | |
| 18 | extract( $field ); |
| 19 | |
| 20 | empty( $name ) && $name = $id; |
| 21 | $value = get_option( $name, [] ); |
| 22 | ?> |
| 23 | <div class="yith-toggle_fixed_wrapper" id="<?php echo $id ?>" > |
| 24 | <div class="yith-toggle-elements"> |
| 25 | <div id="<?php echo $id; ?>" class="yith-toggle-row fixed <?php echo ! empty( $subtitle ) ? 'with-subtitle' : ''; ?> <?php echo $class; ?>" <?php echo $custom_attributes; ?>> |
| 26 | <div class="yith-toggle-title"> |
| 27 | <h3> |
| 28 | <span class="title"><?php echo $title ?></span> |
| 29 | <?php if ( ! empty( $subtitle ) ): ?> |
| 30 | <span class="subtitle"><?php echo $subtitle; ?></span> |
| 31 | <?php endif; ?> |
| 32 | </h3> |
| 33 | <span class="yith-toggle"><span class="yith-icon yith-icon-arrow_right ui-sortable-handle"></span></span> |
| 34 | <?php |
| 35 | // add on off field if needed |
| 36 | if( ! empty( $onoff_field ) ) : ?> |
| 37 | <span class="yith-toggle-onoff"> |
| 38 | <?php yith_plugin_fw_get_field( [ |
| 39 | 'type' => 'onoff', |
| 40 | 'name' => "{$name}[enabled]", |
| 41 | 'id' => "{$id}_enabled", |
| 42 | 'value' => isset( $value['enabled'] ) ? $value['enabled'] : 'no', |
| 43 | ], true ); |
| 44 | ?> |
| 45 | </span> |
| 46 | <?php endif; ?> |
| 47 | </div> |
| 48 | <div class="yith-toggle-content"> |
| 49 | <?php foreach ( $elements as $element ): |
| 50 | // build correct name and id |
| 51 | $field_id = $element['id']; |
| 52 | $element['name'] = false === $save_single_options ? "{$name}[{$field_id}]" : $field_id; |
| 53 | $element['id'] = "{$id}_{$field_id}"; |
| 54 | // get value |
| 55 | $element['value'] = ''; |
| 56 | if( false === $save_single_options ){ |
| 57 | $element['value'] = isset( $value[ $field_id ] ) ? $value[ $field_id ] : ( isset( $element['default'] ) ? $element['default'] : '' ); |
| 58 | } |
| 59 | |
| 60 | else { |
| 61 | $element['value'] = get_option( $field_id, $element['default'] ); |
| 62 | } |
| 63 | ?> |
| 64 | <div class="yith-toggle-content-row <?php echo $element['type'] ?>"> |
| 65 | <label for="<?php echo $element['id']; ?>"><?php echo $element['title']; ?></label> |
| 66 | <div class="yith-plugin-fw-option-with-description"> |
| 67 | <?php yith_plugin_fw_get_field( $element, true ); ?> |
| 68 | <span class="description"><?php echo ! empty( $element['desc'] ) ? $element['desc'] : ''; ?></span> |
| 69 | </div> |
| 70 | </div> |
| 71 | <?php endforeach; |
| 72 | ?> |
| 73 | </div> |
| 74 | </div> |
| 75 | </div> |
| 76 | </div> |
| 77 |