PluginProbe
MaxButtons – Create buttons / 6.9
MaxButtons – Create buttons v6.9
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 6.9, at classes/field.php

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