class-affiliate.php
1 year ago
class-email-signup.php
1 year ago
class-help.php
1 year ago
class-polylang.php
1 year ago
class-review-box.php
1 year ago
class-upgrade-box.php
1 year ago
class-wpml.php
1 year ago
folders.class.php
1 year ago
form.class.php
1 year ago
form.fields.php
1 year ago
import.export.class.php
1 year ago
media.replace.php
1 year ago
notifications.class.php
1 year ago
plugins.class.php
1 year ago
svg.class.php
1 year ago
tree.class.php
1 year ago
form.fields.php
99 lines
| 1 | <?php |
| 2 | class Fldr_Form_Fields { |
| 3 | public function __construct() { |
| 4 | add_action( 'folders_field_prefix_settings', array( $this, 'field_prefix_settings' ), 10, 2 ); |
| 5 | add_action( 'folders_field_label', array( $this, 'field_label' ), 10, 1 ); |
| 6 | add_action( 'folders_field_input', array( $this, 'field_input' ), 10, 4 ); |
| 7 | add_action( 'folders_field_label_postfix', array( $this, 'field_label_postfix' ), 10, 1 ); |
| 8 | add_action( 'folders_field_tooltip', array( $this, 'field_tooltip' ), 10, 1 ); |
| 9 | } |
| 10 | |
| 11 | public function field_prefix_settings($field, $value = 'no') { |
| 12 | |
| 13 | } |
| 14 | |
| 15 | public function field_label($field) { |
| 16 | if($field['type'] == 'input') { ?> |
| 17 | <div class="form-label"> |
| 18 | <label class="folder-label" for="<?php echo esc_attr($field['id']) ?>"><?php esc_attr($field['label']) ?></label> |
| 19 | </div> |
| 20 | <?php } |
| 21 | } |
| 22 | |
| 23 | public function field_input($field, $value = '', $is_valid = false, $upgrade_url = '') { |
| 24 | $disabled = (!$is_valid && $field['is_pro'])?'disabled':''; |
| 25 | $value = (!$is_valid && $field['is_pro'])?'':$value; |
| 26 | if($field['type'] == 'input') { ?> |
| 27 | <div class="form-input"> |
| 28 | <input id="<?php echo esc_attr($field['id']) ?>" type="text" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($value) ?>" /> |
| 29 | </div> |
| 30 | <?php } elseif($field['type'] == 'timeout') { ?> |
| 31 | <div class="form-input"> |
| 32 | <label class="folder-label" for="<?php echo esc_attr($field['id']) ?>"><?php echo esc_attr($field['label']) ?></label> |
| 33 | <div class="seconds-box"> |
| 34 | <input id="<?php echo esc_attr($field['id']) ?>" type="number" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($value) ?>" /> |
| 35 | </div> |
| 36 | </div> |
| 37 | <?php } elseif($field['type'] == 'upload_size') { ?> |
| 38 | <div class="form-input"> |
| 39 | <label class="folder-label" for="<?php echo esc_attr($field['id']) ?>"><?php echo esc_attr($field['label']) ?></label> |
| 40 | <div class="mb-box"> |
| 41 | <input id="<?php echo esc_attr($field['id']) ?>" type="number" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($value) ?>" /> |
| 42 | </div> |
| 43 | </div> |
| 44 | <?php } elseif($field['type'] == 'checkbox') { ?> |
| 45 | <div class="form-label <?php echo esc_attr($field['label_class'])?> "> |
| 46 | <input class="sr-only" <?php checked($value, $field['value']) ?> type="hidden" name="<?php echo esc_attr($field['name']) ?>" value="off"> |
| 47 | <?php if($field['is_pro'] && !$is_valid) { ?> |
| 48 | <a class="inline-flex upgrade-box-link" href="<?php echo esc_url($upgrade_url) ?>" target="_blank" > |
| 49 | <label class="switch-label" for=""> |
| 50 | <?php } else {?> |
| 51 | <label class="switch-label" for="<?php echo esc_attr($field['id']) ?>"> |
| 52 | <?php } ?> |
| 53 | <input <?php echo esc_attr($disabled) ?> type="checkbox" id="<?php echo esc_attr($field['id']) ?>" class="sr-only" <?php checked($value, $field['value']) ?> name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>"> |
| 54 | <span class="form-switch"></span> |
| 55 | <?php echo esc_attr($field['label']) ?> |
| 56 | <?php do_action('folders_field_tooltip', $field); ?> |
| 57 | <?php do_action('folders_field_label_prefix', $field); ?> |
| 58 | <?php if($field['is_pro'] && !$is_valid) { ?> |
| 59 | <button type="button" class="upgrade-link">Upgrade to Pro</button> |
| 60 | <?php } ?> |
| 61 | </label> |
| 62 | <?php if($field['is_pro'] && !$is_valid) { ?> |
| 63 | </a> |
| 64 | <?php } ?> |
| 65 | <?php do_action('folders_field_label_postfix', $field); ?> |
| 66 | </div> |
| 67 | <?php } |
| 68 | } |
| 69 | |
| 70 | public function field_label_postfix($field) { |
| 71 | if($field['id'] == 'use_shortcuts') { ?> |
| 72 | <a href="#" class="view-shortcodes inline-flex" >( |
| 73 | <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> |
| 74 | <path stroke-linecap="round" stroke-linejoin="round" d="M13 10V3L4 14h7v7l9-11h-7z"/> |
| 75 | </svg> |
| 76 | <span><?php esc_html_e('View shortcuts', 'folders'); ?></span>) |
| 77 | </a> |
| 78 | <?php } |
| 79 | } |
| 80 | |
| 81 | public function field_tooltip($field) { |
| 82 | if($field['has_tooltip'] && !empty($field['tooltip'])) { |
| 83 | if(isset($field['tooltip_image']) && !empty($field['tooltip_image'])) { ?> |
| 84 | <span class="html-tooltip dynamic"> |
| 85 | <span class="dashicons dashicons-editor-help"></span> |
| 86 | <span class="tooltip-text top" style=""> |
| 87 | <?php echo esc_attr($field['tooltip']) ?> |
| 88 | <img src="<?php echo esc_url($field['tooltip_image']) ?>"> |
| 89 | </span> |
| 90 | </span> |
| 91 | <?php } else { ?> |
| 92 | <span class="folder-tooltip" data-title="<?php echo esc_attr($field['tooltip']) ?>"> |
| 93 | <span class="dashicons dashicons-editor-help"></span> |
| 94 | </span> |
| 95 | <?php } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | new Fldr_Form_Fields(); |