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

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