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