PluginProbe
MaxButtons – Create buttons / 7.13.1
MaxButtons – Create buttons v7.13.1
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 7.13.1, at blocks/advanced.php

217 lines 6.0 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["external_css"]) && $data["external_css"] == 1)
77 {
78 $anchor->class .= ' external-css ' ;
79 }
80
81 return $domObj;
82
83 }
84
85 public function post_parse_button($domObj, $mode = 'normal')
86 {
87 $data = $this->data[$this->blockname];
88 $button_id = $this->data["id"];
89 $anchor = $domObj->find("a",0);
90
91 if (isset($data["extra_classes"]) && trim($data["extra_classes"]) != '')
92 {
93 $extra = trim($data["extra_classes"]);
94 $anchor->class .= ' ' . $extra;
95 }
96
97 return $domObj;
98 }
99
100
101 public function admin_fields()
102 {
103 $data = $this->data[$this->blockname];
104 $admin = MB()->getClass('admin');
105
106 $start_block = new maxField('block_start');
107 $start_block->name = __('advanced', 'maxbuttons');
108 $start_block->label = __('Advanced', 'maxbuttons');
109 $admin->addField($start_block);
110
111 $imp = new maxField('switch');
112 $imp->note = __('Adding !important to the button styles can help avoid potential conflicts with your theme styles.', 'maxbuttons') ;
113 $imp->id = 'important_css';
114 $imp->name = $imp->id;
115 $imp->value = 1;
116 $imp->label = __('Use !Important', 'maxbuttons');
117 $imp->checked = checked(maxBlocks::getValue('important_css'), 1, false);
118 //$imp->value = maxBlocks::getValue('important_css');
119 //$imp->output('start','end');
120
121 $admin->addField($imp, 'start', 'end');
122
123 $class = new maxField();
124 $class->id = 'extra_classes';
125 $class->name = $class->id;
126 $class->label = __("Extra classes","maxbuttons");
127 $class->value = maxBlocks::getValue($class->id);
128 $class->note = __("Useful for custom code or other plugins who target classes", "maxbuttons");
129 $class->help = "<p class='shortcode'>Shortcode attribute : extraclass </p> <p>Using attribute will add classes, not replace them </p> ";
130 //$class->output('start','end');
131
132 $admin->addField($class, 'start', 'end');
133
134 $rel = new maxField();
135 $rel->id = 'custom_rel';
136 $rel->name = $rel->id;
137 $rel->label = __("Custom Rel Tag","maxbuttons");
138 $rel->value = maxBlocks::getValue($rel->id);
139 $rel->note = __("Useful when button is targeting lightbox and/or popup plugins that use this method", "maxbuttons");
140 //$rel->output('start','end');
141
142 $admin->addField($rel, 'start', 'end');
143
144 // do_action('mb-after-advanced');
145
146 $nocss = new maxField('switch');
147 $nocss->note = __('Enabling the "Use External CSS" will stop loading any button styling. You will need to put the button style manually', '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(maxBlocks::getValue($nocss->id), 1, false);
153 //$nocss->output('start','');
154 $admin->addField($nocss, 'start');
155
156 $nospace = new maxField('spacer');
157 $nospace->content = __("Warning: This will remove all styling of the buttons!","maxbuttons");
158 // $nospace->output('','end');
159 $admin->addField($nospace, '', 'end');
160
161 $viewcss = new maxField('button');
162 $viewcss->id = 'view_css_modal';
163 $viewcss->name = $viewcss->id;
164 $viewcss->label = '&nbsp;';
165 $viewcss->button_label = __('View CSS', 'maxbuttons');
166 $viewcss->inputclass = 'maxmodal';
167 $viewcss->modal = 'view-css';
168
169 $admin->addField($viewcss, 'start', 'end');
170 ?>
171
172
173 <?php
174
175 $this->sidebar();
176 $endblock = new maxField('block_end');
177 $admin->addField($endblock);
178
179 ?>
180
181 <div id="view-css" class="maxmodal-data" >
182 <h3 class="title"><?php _e("External CSS","maxbuttons"); ?></h3>
183 <div class="content">
184 <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>
185
186 <textarea id="maxbutton-css" readonly="readonly">
187 <?php
188 if (isset($this->data["id"]) && $this->data['id'] > 0)
189 {
190 $id = $this->data["id"];
191 $b = MB()->getClass('button');
192
193 $b->set($id);
194 $b->parse_button();
195 $b->parse_css("preview");
196
197 echo $b->getparsedCSS();
198
199 }
200 else
201 { _e("Please save the button first","maxbuttons"); }
202
203 ?></textarea>
204 </div>
205 <div class='controls'>
206 <p><a class='button-primary modal_close' href='javascript:void(0);'><?php _e("Close","maxbuttons"); ?></a>
207 </p>
208 </div>
209 </div>
210
211 <?php
212 } // admin_fields
213
214 } // class
215
216 ?>
217