PluginProbe
MaxButtons – Create buttons / 6.25
MaxButtons – Create buttons v6.25
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 / blocks / advanced.php

advanced.php in MaxButtons – Create buttons 6.25, at blocks/advanced.php

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