PluginProbe
QuadMenu – Mega Menu / 1.8.9
QuadMenu – Mega Menu v1.8.9
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / ReduxCore / inc / fields / text / field_text.php

field_text.php in QuadMenu – Mega Menu 1.8.9, at lib/ReduxCore/inc/fields/text/field_text.php

93 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 if ( ! class_exists( 'ReduxFramework_text' ) ) {
9 class ReduxFramework_text {
10
11 /**
12 * Field Constructor.
13 * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
14 *
15 * @since ReduxFramework 1.0.0
16 */
17 function __construct( $field = array(), $value = '', $parent ) {
18 $this->parent = $parent;
19 $this->field = $field;
20 $this->value = $value;
21 }
22
23 /**
24 * Field Render Function.
25 * Takes the vars and outputs the HTML for the field in the settings
26 *
27 * @since ReduxFramework 1.0.0
28 */
29 function render() {
30 if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) {
31 if ( empty( $this->field['args'] ) ) {
32 $this->field['args'] = array();
33 }
34
35 $this->field['options'] = $this->parent->get_wordpress_data( $this->field['data'], $this->field['args'] );
36 $this->field['class'] .= " hasOptions ";
37 }
38
39 if ( empty( $this->value ) && ! empty( $this->field['data'] ) && ! empty( $this->field['options'] ) ) {
40 $this->value = $this->field['options'];
41 }
42
43 //if (isset($this->field['text_hint']) && is_array($this->field['text_hint'])) {
44 $qtip_title = isset( $this->field['text_hint']['title'] ) ? 'qtip-title="' . $this->field['text_hint']['title'] . '" ' : '';
45 $qtip_text = isset( $this->field['text_hint']['content'] ) ? 'qtip-content="' . $this->field['text_hint']['content'] . '" ' : '';
46 //}
47
48 $readonly = ( isset( $this->field['readonly'] ) && $this->field['readonly']) ? ' readonly="readonly"' : '';
49 $autocomplete = ( isset($this->field['autocomplete']) && $this->field['autocomplete'] == false) ? ' autocomplete="off"' : '';
50
51 if ( isset( $this->field['options'] ) && ! empty( $this->field['options'] ) ) {
52
53 $placeholder = '';
54 if ( isset( $this->field['placeholder'] ) ) {
55 $placeholder = $this->field['placeholder'];
56 }
57
58 foreach ( $this->field['options'] as $k => $v ) {
59 if ( ! empty( $placeholder ) ) {
60 $placeholder = ( is_array( $this->field['placeholder'] ) && isset( $this->field['placeholder'][ $k ] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'][ $k ] ) . '" ' : '';
61 }
62
63 echo '<div class="input_wrapper">';
64 echo '<label for="' . $this->field['id'] . '-text-' . $k . '">' . $v . '</label> ';
65 echo '<input ' . $qtip_title . $qtip_text . 'type="text" id="' . $this->field['id'] . '-text-' . $k . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '[' . $k . ']' . '" ' . $placeholder . 'value="' . esc_attr( $this->value[ $k ] ) . '" class="regular-text ' . $this->field['class'] . '"' . $readonly . $autocomplete . ' /><br />';
66 echo '</div>';
67 }
68 //foreach
69 } else {
70 $placeholder = ( isset( $this->field['placeholder'] ) && ! is_array( $this->field['placeholder'] ) ) ? ' placeholder="' . esc_attr( $this->field['placeholder'] ) . '" ' : '';
71 echo '<input ' . $qtip_title . $qtip_text . 'type="text" id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" ' . $placeholder . 'value="' . esc_attr( $this->value ) . '" class="regular-text ' . $this->field['class'] . '"' . $readonly . $autocomplete . ' />';
72 }
73 }
74
75 /**
76 * Enqueue Function.
77 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
78 *
79 * @since ReduxFramework 3.0.0
80 */
81 function enqueue() {
82 if ($this->parent->args['dev_mode']) {
83 wp_enqueue_style(
84 'redux-field-text-css',
85 ReduxFramework::$_url . 'inc/fields/text/field_text.css',
86 array(),
87 time(),
88 'all'
89 );
90 }
91 }
92 }
93 }