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 | blocks/advanced.php +111 -104 6.46.28 View file →
@@ -1,186 +1,193 @@
1 1 <?php
2 +namespace MaxButtons;
2 3 defined('ABSPATH') or die('No direct access permitted');
3 -$blockClass["advanced"] = "advancedBlock";
4 -$blockOrder[80][] = "advanced";
4 +$blockClass["advanced"] = "advancedBlock";
5 +$blockOrder[80][] = "advanced";
5 6
6 -use MaxButtons\maxBlocks as maxBlocks;
7 -use MaxButtons\maxField as maxField;
8 7
9 -class advancedBlock extends maxBlock
8 +class advancedBlock extends maxBlock
10 9 {
11 - protected $blockname = "advanced";
10 + protected $blockname = "advanced";
12 11 protected $fields = array("important_css" => array("default" => "0"),
13 - "custom_rel" => array('default' => ''),
14 - "extra_classes" => array('default' => ''),
12 + "custom_rel" => array('default' => ''),
13 + "extra_classes" => array('default' => ''),
15 14 "external_css" => array("default" => "0"),
16 -
17 15
18 -
19 - );
20 -
16 +
17 +
18 + );
19 +
21 20 public function __construct()
22 21 {
23 - parent::__construct();
24 - add_filter('mb-css-blocks', array($this, 'parse_css_advanced'), 1001, 2); // run once
22 + parent::__construct();
23 + add_filter('mb/button/rawcss', array($this, 'parse_css_advanced'), 1001, 2); // run once
25 24 //add_filter('mb-css-blocks', array($this, 'preview_external_css'), 100 )
26 25 }
27 -
26 +
28 27 public function parse_css($css, $mode = 'normal')
29 28 {
30 29 $css = parent::parse_css($css);
31 - $data = $this->data[$this->blockname];
32 -
30 + $data = $this->data[$this->blockname];
31 +
33 32 if (isset($data["important_css"]) && $data["important_css"] == 1)
34 33 {
35 - $css["settings"]["important"] = 1;
36 - }
34 + $css["settings"]["important"] = 1;
35 + }
37 36
38 - return $css;
37 + return $css;
39 38 }
40 -
39 +
41 40 public function parse_css_advanced($css, $mode)
42 41 {
43 - $data = $this->data[$this->blockname];
44 - if (isset($data["external_css"]) && $data["external_css"] == 1 && $mode == 'normal')
42 + $data = $this->data[$this->blockname];
43 +
44 + if (isset($data["external_css"]) && $data["external_css"] == 1 && $mode == 'normal')
45 45 {
46 -
46 +
47 47 return array(
48 - "normal" => array(),
48 + "normal" => array(),
49 49 "hover" => array());
50 50 }
51 51
52 52 return $css;
53 53 }
54 -
54 +
55 55 public function parse_button($domObj, $mode = 'normal')
56 56 {
57 -
58 - $data = $this->data[$this->blockname];
59 -
60 - $button_id = $this->data["id"];
61 -
62 - $anchor = $domObj->find("a",0);
63 -
57 +
58 + $data = $this->data[$this->blockname];
59 +
60 + $button_id = $this->data["id"];
61 +
62 + $anchor = $domObj->find("a",0);
63 +
64 64 if (isset($data["custom_rel"]) && trim($data["custom_rel"]) != '')
65 65 {
66 - $rel = '';
66 + $rel = '';
67 67 $custom_rel = trim($data["custom_rel"]);
68 - if (isset($anchor->rel) && $anchor->rel != '')
68 + if (isset($anchor->rel) && $anchor->rel != '')
69 69 {
70 70 $anchor->rel .= ' ';
71 71 }
72 -
72 +
73 73 $anchor->rel .= $custom_rel;
74 74 }
75 -
76 - if (isset($data["extra_classes"]) && trim($data["extra_classes"]) != '')
75 +
76 + if (isset($data["extra_classes"]) && trim($data["extra_classes"]) != '')
77 77 {
78 - $extra = trim($data["extra_classes"]);
79 - $anchor->class .= ' ' . $extra;
80 -
78 + $extra = trim($data["extra_classes"]);
79 + $anchor->class .= ' ' . $extra;
80 +
81 81 }
82 -
83 -
84 - return $domObj;
85 -
82 +
83 + if (isset($data["external_css"]) && $data["external_css"] == 1)
84 + {
85 + $anchor->class .= ' external-css ' ;
86 + }
87 +
88 + return $domObj;
89 +
86 90 }
87 -
88 - public function admin_fields()
91 +
92 + public function admin_fields()
89 93 {
90 - $data = $this->data[$this->blockname];
94 + $data = $this->data[$this->blockname];
95 + $admin = MB()->getClass('admin');
91 96
92 97 foreach($this->fields as $field => $options)
93 - {
94 - $default = (isset($options["default"])) ? $options["default"] : '';
98 + {
99 + $default = (isset($options["default"])) ? $options["default"] : '';
95 100 $$field = (isset($data[$field])) ? $data[$field] : $default;
96 - ${$field . "_default"} = $default;
97 -
98 - global $maxbuttons_container_alignments;
101 + ${$field . "_default"} = $default;
102 +
103 + global $maxbuttons_container_alignments;
99 104 }
100 -
101 -
102 -?>
103 -
105 +?>
106 +
104 107 <div class="option-container mb_tab">
105 108 <div class="title"><?php _e('Advanced', 'maxbuttons') ?></div>
106 109 <div class="inside advanced">
107 -
108 - <?php
109 -
110 - $fspacer = new maxField('spacer');
111 - $fspacer->label = __('Use !Important', 'maxbuttons');
112 - $fspacer->name = '';
113 - $fspacer->note = __('Adding !important to the button styles can help avoid potential conflicts with your theme styles.', 'maxbuttons') ;
114 - $fspacer->output('start');
115 -
116 - $imp = new maxField('checkbox');
117 - $imp->id = 'important_css';
110 +
111 + <?php
112 +
113 + $imp = new maxField('switch');
114 + $imp->note = __('Adding !important to the button styles can help avoid potential conflicts with your theme styles.', 'maxbuttons') ;
115 + $imp->id = 'important_css';
118 116 $imp->name = $imp->id;
119 - $imp->value = 1;
117 + $imp->value = 1;
118 + $imp->label = __('Use !Important', 'maxbuttons');
120 119 $imp->checked = checked(maxBlocks::getValue('important_css'), 1, false);
121 120 //$imp->value = maxBlocks::getValue('important_css');
122 - $imp->output('','end');
123 -
124 - $class = new maxField();
125 - $class->id = 'extra_classes';
126 - $class->name = $class->id;
121 + //$imp->output('start','end');
122 +
123 + $admin->addField($imp, 'start', 'end');
124 +
125 + $class = new maxField();
126 + $class->id = 'extra_classes';
127 + $class->name = $class->id;
127 128 $class->label = __("Extra classes","maxbuttons");
128 - $class->value = maxBlocks::getValue($class->id);
129 + $class->value = maxBlocks::getValue($class->id);
129 130 $class->note = __("Useful for custom code or other plugins who target classes", "maxbuttons");
130 - $class->output('start','end');
131 -
132 - $rel = new maxField();
131 + //$class->output('start','end');
132 +
133 + $admin->addField($class, 'start', 'end');
134 +
135 + $rel = new maxField();
133 136 $rel->id = 'custom_rel';
134 - $rel->name = $rel->id;
137 + $rel->name = $rel->id;
135 138 $rel->label = __("Custom Rel Tag","maxbuttons");
136 - $rel->value = maxBlocks::getValue($rel->id);
139 + $rel->value = maxBlocks::getValue($rel->id);
137 140 $rel->note = __("Useful when button is targeting lightbox and/or popup plugins that use this method", "maxbuttons");
138 - $rel->output('start','end');
139 -
140 - do_action('mb-after-advanced');
141 -
142 - ?>
141 + //$rel->output('start','end');
143 142
143 + $admin->addField($rel, 'start', 'end');
144 144
145 -
146 - <div class="option-design">
147 - <p class="note"><?php _e('By default, the CSS styles for the button are rendered within a &lt;style&gt; block in the HTML body. Enabling the "Use External CSS" option allows you to put the CSS code for the button into your theme stylesheet instead.', 'maxbuttons') ?>
148 -
149 - </p>
150 - <label for='external_css'><?php _e('Use External CSS', 'maxbuttons') ?></label>
151 - <div class="input checkbox"><input type="checkbox" id="external_css" name="external_css" value="1" <?php checked($external_css,1) ?>> <?php _e("Warning: This will remove all styling of the buttons!","maxbuttons"); ?> </div>
152 - <div class="clear"></div>
153 - </div>
145 + // do_action('mb-after-advanced');
154 146
155 -
147 + $admin->display_fields();
148 +
149 + $nocss = new maxField('switch');
150 + $nocss->note = __('By default, the CSS styles for the button are rendered within a &lt;style&gt; block in the HTML body. Enabling the "Use External CSS" option allows you to put the CSS code for the button into your theme stylesheet instead.', 'maxbuttons');
151 + $nocss->label = __('Use External CSS', 'maxbuttons');
152 + $nocss->id = 'external_css';
153 + $nocss->value = 1;
154 + $nocss->name = $nocss->id;
155 + $nocss->checked = checked($external_css, 1, false);
156 + $nocss->output('start','');
157 +
158 + $nospace = new maxField('spacer');
159 + $nospace->content = __("Warning: This will remove all styling of the buttons!","maxbuttons");
160 + $nospace->output('','end');
161 + ?>
162 +
156 163 <div class="option-design">
157 164 <div class="label">&nbsp;</div>
158 165 <div class="input"><a id="view_css_modal" name="view_css" href="javascript:void(0)" class="button maxmodal" data-modal="view-css"><?php _e('View CSS', 'maxbuttons') ?></a></div>
159 166 <div class="clear"></div>
160 -
161 - <div id="view-css" class="maxmodal-data" >
167 +
168 + <div id="view-css" class="maxmodal-data" >
162 169 <h3 class="title"><?php _e("External CSS","maxbuttons"); ?></h3>
163 170 <div class="content">
164 171 <p><?php _e('If the "Use External CSS" option is enabled for this button, copy and paste the CSS code below into your theme stylesheet.', 'maxbuttons') ?></p>
165 -
172 +
166 173 <textarea id="maxbutton-css" readonly="readonly">
167 - <?php
174 + <?php
168 175 if (isset($this->data["id"]) && $this->data['id'] > 0)
169 176 {
170 177 $id = $this->data["id"];
171 - $b = new maxButton();
178 + $b = new maxButton();
172 179
173 180 $b->set($id);
174 181 $b->parse_button();
175 - $b->parse_css("preview");
182 + $b->parse_css("preview");
176 183
177 184 echo $b->getparsedCSS();
178 -
185 +
179 186 }
180 187 else
181 188 { _e("Please save the button first","maxbuttons"); }
182 -
189 +
183 190 ?></textarea>
184 191 </div>
185 192 <div class='controls'>
186 193 <p><a class='button-primary modal_close' href='javascript:void(0);'><?php _e("Close","maxbuttons"); ?></a>
@@ -191,9 +198,9 @@
191 198 </div>
192 199 </div>
193 200 </div>
194 201
195 -<?php
202 +<?php
196 203 } // admin_fields
197 204
198 205 } // class
199 206