PluginProbe
MaxButtons – Create buttons / 6.6
MaxButtons – Create buttons v6.6
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.6, at blocks/advanced.php

209 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') or die('No direct access permitted');
3 $blockClass["advanced"] = "advancedBlock";
4 $blockOrder[80][] = "advanced";
5
6 use MaxButtons\maxBlocks as maxBlocks;
7 use MaxButtons\maxField as maxField;
8
9 class advancedBlock extends maxBlock
10 {
11 protected $blockname = "advanced";
12 protected $fields = array("important_css" => array("default" => "0"),
13 "custom_rel" => array('default' => ''),
14 "extra_classes" => array('default' => ''),
15 "external_css" => array("default" => "0"),
16
17
18
19 );
20
21 public function __construct()
22 {
23 parent::__construct();
24 add_filter('mb-css-blocks', array($this, 'parse_css_advanced'), 1001, 2); // run once
25 //add_filter('mb-css-blocks', array($this, 'preview_external_css'), 100 )
26 }
27
28 public function parse_css($css, $mode = 'normal')
29 {
30 $css = parent::parse_css($css);
31 $data = $this->data[$this->blockname];
32
33 if (isset($data["important_css"]) && $data["important_css"] == 1)
34 {
35 $css["settings"]["important"] = 1;
36 }
37
38 return $css;
39 }
40
41 public function parse_css_advanced($css, $mode)
42 {
43 $data = $this->data[$this->blockname];
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
84 return $domObj;
85
86 }
87
88 public function admin_fields()
89 {
90 $data = $this->data[$this->blockname];
91
92 foreach($this->fields as $field => $options)
93 {
94 $default = (isset($options["default"])) ? $options["default"] : '';
95 $$field = (isset($data[$field])) ? $data[$field] : $default;
96 ${$field . "_default"} = $default;
97
98 global $maxbuttons_container_alignments;
99 }
100
101
102 ?>
103
104 <div class="option-container mb_tab">
105 <div class="title"><?php _e('Advanced', 'maxbuttons') ?></div>
106 <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
117 $imp = new maxField('switch');
118 $imp->note = __('Adding !important to the button styles can help avoid potential conflicts with your theme styles.', 'maxbuttons') ;
119 $imp->id = 'important_css';
120 $imp->name = $imp->id;
121 $imp->value = 1;
122 $imp->label = __('Use !Important', 'maxbuttons');
123 $imp->checked = checked(maxBlocks::getValue('important_css'), 1, false);
124 //$imp->value = maxBlocks::getValue('important_css');
125 $imp->output('start','end');
126
127 $class = new maxField();
128 $class->id = 'extra_classes';
129 $class->name = $class->id;
130 $class->label = __("Extra classes","maxbuttons");
131 $class->value = maxBlocks::getValue($class->id);
132 $class->note = __("Useful for custom code or other plugins who target classes", "maxbuttons");
133 $class->output('start','end');
134
135 $rel = new maxField();
136 $rel->id = 'custom_rel';
137 $rel->name = $rel->id;
138 $rel->label = __("Custom Rel Tag","maxbuttons");
139 $rel->value = maxBlocks::getValue($rel->id);
140 $rel->note = __("Useful when button is targeting lightbox and/or popup plugins that use this method", "maxbuttons");
141 $rel->output('start','end');
142
143 do_action('mb-after-advanced');
144
145
146 $nocss = new maxField('switch');
147 $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');
148 $nocss->label = __('Use External CSS', 'maxbuttons');
149 $nocss->id = 'external_css';
150 $nocss->value = 1;
151 $nocss->name = $nocss->id;
152 $nocss->checked = checked($external_css, 1, false);
153 $nocss->output('start','');
154
155 $nospace = new maxField('spacer');
156 $nospace->content = __("Warning: This will remove all styling of the buttons!","maxbuttons");
157 $nospace->output('','end');
158 ?>
159
160
161
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