PluginProbe
MaxButtons – Create buttons / 7.13.1
MaxButtons – Create buttons v7.13.1
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / classes / field.php

field.php in MaxButtons – Create buttons 7.13.1, at classes/field.php

130 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MaxButtons;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 class maxField
6 {
7
8 /* Static class variables */
9 static $templates = '';
10 static $position = 0;
11
12 /* Field data */
13 public $id;
14 public $name;
15 public $value = '';
16
17 /* Layout options */
18 public $note;
19 public $label;
20 public $title;
21 public $default;
22 public $help;
23 public $error;
24 public $warning;
25
26 // Specific options */
27 public $placeholder = ''; // text / textarea
28 public $icon; // checkbox-icon
29 public $checked = ''; // checkbox / radio
30 public $input_class = ''; // inputs
31 public $before_input; // text
32 public $content = ''; // generic / spacer
33 public $min; // number
34
35 /* Border radius */
36 public $radius_tl;
37 public $radius_tr;
38 public $radius_bl, $radius_br;
39
40 // conditionals
41 public $start_conditional; // conditional defined in start.tpl / row start
42 public $start_cond_type = 'show'; // show / has conditional
43 public $conditional;
44
45 //public
46
47
48 /* Template */
49 public $template;
50 public $main_class = 'option'; // row class - start template
51 public $esc_function = 'esc_attr'; // escape function to run over the value
52
53 /* Publish brake */
54 public $publish = true;
55 public $output = '';
56
57 public function __construct($template = 'text', $args = array() )
58 {
59 self::$position++;
60 $this->template = $template;
61
62 foreach($args as $item => $value)
63 {
64 $this->{$item} = $value;
65
66 }
67 }
68
69 static function setTemplates($templates)
70 {
71 self::$templates = apply_filters('mb/editor/templates', $templates);
72
73 }
74
75
76 public function setDefault($default)
77 {
78 $this->default = __('Default:','maxbuttons') . ' ' . $default;
79
80 }
81
82 /** Output field interface
83 *
84 * @param $start_tpl Prepend a template before this field ( e.g. row defition )
85 * @param $end_tpl Append a template after this field
86 */
87
88 public function output($start_tpl = '', $end_tpl = '')
89 {
90 if ($this->esc_function)
91 {
92 $this->value = call_user_func($this->esc_function, $this->value);
93 }
94
95 $output = '';
96 if ($start_tpl != '')
97 {
98 $start_tpl = self::$templates[$start_tpl];
99 $output .= simpleTemplate::parse($start_tpl['path'], $this);
100 }
101
102 $template = self::$templates[$this->template]; // template name;
103 //do_action('mb/editor/before-field-' . $this->id, $this);
104
105 $output .= simpleTemplate::parse($template['path'], $this);
106
107
108 if ($end_tpl != '')
109 {
110 if (! is_array($end_tpl))
111 $end_tpl = array($end_tpl);
112
113 foreach($end_tpl as $tpl)
114 {
115 $tpl = self::$templates[$tpl];
116 $output .= simpleTemplate::parse($tpl['path'], $this);
117 }
118 }
119
120 if ($this->publish)
121 echo $output;
122 //do_action('mb/editor/after-field-'. $this->id); // hook for extra fields.
123
124 $this->output = $output;
125 return $output;
126 }
127
128
129 }
130