PluginProbe
Social Share Buttons / 1.9
Social Share Buttons v1.9
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / classes / blocks / layout-block.php

layout-block.php in Social Share Buttons 1.9, at classes/blocks/layout-block.php

479 lines 15.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 use \MaxButtons\maxField as maxField;
6 use \MaxButtons\maxUtils as maxUtils;
7
8 $collectionBlock["layout"] = array('order' => 40,
9 'class' => "layoutBlock"
10 );
11
12 class layoutBlock extends block
13 {
14 protected $blockname = "layout";
15 protected $fields = array(
16 "margin_left" => array("default" => "0px",
17 "css" => "margin-left",
18 "csspart" => "maxsocial"),
19
20 "margin_right" => array("default" => "0px",
21 "css" => "margin-right",
22 "csspart" => "maxsocial"),
23
24 "margin_top" => array("default" => "0px",
25 "css" => "margin-top",
26 "csspart" => "maxsocial"),
27
28 "margin_bottom" => array("default" => "0px",
29 "css" => "margin-bottom",
30 "csspart" => "maxsocial"),
31 "orientation" => array("default" => "auto"),
32
33 "font" => array("default" => "",
34 "css" => "font-family",
35 "csspart" => 'mb-label,mb-share-count'
36 ),
37
38 "font_label_size" => array("default" => "15px",
39 "css" => "font-size",
40 "csspart" => 'mb-label' ),
41
42 "font_label_style" => array("default" => "normal",
43 "css" => "font-style",
44 "csspart" => 'mb-label'),
45
46 "font_label_weight" => array("default" => "normal",
47 "css" => "font-weight",
48 "csspart" => 'mb-label'),
49
50 "font_label_upper" => array('default' => 'none',
51 'css' => 'text-transform',
52 'csspart' => 'mb-label',
53 ),
54
55 "font_icon_size" => array("default" => "15px",
56 "css" => "font-size",
57 "csspart" => 'mb-icon' ),
58
59 "font_icon_style" => array("default" => "normal",
60 "css" => "font-style",
61 "csspart" => 'mb-icon'),
62
63 "font_icon_weight" => array("default" => "normal",
64 "css" => "font-weight",
65 "csspart" => 'mb-icon'),
66
67 'use_background' => array('default' => 1, ),
68 'background_color' => array('default' => '#000',
69 'css' => 'background-color',
70 'csspart' => 'mb-social',
71 ),
72 'background_color_hover' => array('default' => '#000',
73 'css' => 'background-color',
74 'csspart' => 'mb-social',
75 'csspseudo' => 'hover',
76 ),
77 'color' => array('default' => '#fff',
78 'css' => 'color',
79 'csspart' => 'mb-icon,mb-share-count,mb-label'),
80 'color_hover' => array('default' => '#fff',
81 'css' => 'color',
82 'csspart' => 'mb-icon,mb-share-count,mb-label',
83 'csspseudo' => 'hover'),
84
85
86 "button_spacing" => array('default' => '5',
87 ),
88 "ignore_container" => array("default" => 1),
89
90
91 );
92
93 public function __construct()
94 {
95 parent::__construct();
96
97 if (Install::isPro())
98 add_filter('mbsocial/displaycss/', array($this, 'addWebFont') );
99
100 }
101
102 public function addWebFont($css)
103 {
104 $fonts = '';
105
106 if ( isset ($this->data[$this->blockname]['webfonts']))
107 {
108
109 $webfonts = $this->data[$this->blockname]['webfonts'];
110 $fonts .= '@import url(' . $webfonts . ');';
111
112 }
113 return $fonts . $css;
114 }
115
116 function parseCSS($css, $args)
117 {
118 $css = parent::parseCSS($css, $args);
119 $w = MBSocial()->whistle();
120
121 $hook = $this->collection->getHook();
122 $blockdata = $this->data[$this->blockname];
123
124 $network = $this->network;
125
126 // if true, use network colors
127 $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false;
128
129 if ($use_background)
130 {
131 unset ($css['mb-social']['normal']['background-color']);
132 unset ($css['mb-social']['hover']['background-color']);
133
134 $color = $network->get('color');
135
136 $css['mb-social']['normal']['background-color'] = $color;
137 $css['mb-social']['hover']['background-color'] = "darken($color, 10%)";
138 }
139
140 $css["mb-item"]["normal"]["float"] = "left";
141 $css["mb-item"]["normal"]["display"] = "inline-block";
142 $css["mb-item a"]["normal"]["cursor"] = "pointer"; // by default social share = call to action.
143 $css['mb-item a']['normal']['text-decoration'] = 'none';
144
145
146 if (isset($blockdata['button_spacing']) && $blockdata['button_spacing'] > 0)
147 {
148 $orientation = $this->collection->orientation;
149 $is_static = $w->ask('display/env/is_static');
150
151 $button_spacing = $blockdata['button_spacing'];
152
153 if ($orientation == 'horizontal')
154 {
155 $css['mb-item']['normal']['margin-right'] = $button_spacing . 'px';
156 }
157 if ($orientation == 'vertical')
158 {
159 $css['mb-item']['normal']['margin-bottom'] = $button_spacing . 'px';
160 }
161 }
162
163 return $css;
164
165 }
166
167 public function parse($itemObj, $args = array() )
168 {
169 $blockdata = $this->data[$this->blockname];
170
171 $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false;
172
173 return $itemObj;
174
175 }
176
177 function save_fields($data, $post)
178 {
179 $data = parent::save_fields($data, $post);
180 if (! isset($post["ignore_container"]) && ! is_null($post))
181 $data[$this->blockname]["ignore_container"] = 0;
182 if (! isset($post['use_background']) && ! is_null($post))
183 $data[$this->blockname]['use_background'] = 0;
184
185 if ( count ($post) == 0)
186 return $data; // don't run on default situations
187
188 // Do the font here
189 $blockdata = $this->data[$this->blockname];
190 $font = $blockdata['font'];
191 //$label_weight = $blockdata['font_label_weight'];
192 // $icon_weight = $blockdata['icon_label_weight'];
193
194 $args = array('font' => $font);
195 $webfont = patches::checkWebFonts($args);
196 $data[$this->blockname]['webfonts'] = $webfont;
197
198
199 return $data;
200
201 }
202
203 function fontModal()
204 {
205 ?>
206 <div class='maxmodal-data' id='add-fonts' data-load='window.maxFoundry.maxfonts.load' data-height='90%'>
207 <span class='title'><?php _e("Font Manager","maxbuttons-pro"); ?>
208
209 </span>
210
211 <span class='content'>
212 <p><?php printf(__("Select from %s fonts you would like to use and they will show up in the dropdown list", 'maxbuttons-pro'), '<span class="fontcount"></span>'); ?></p>
213 <div class="loading_overlay"></div>
214 <div class='loading'>
215 <img src="<?php echo MB()->get_plugin_url(true) ?>images/loading.gif">
216 <span><?php _e("Loading","maxbuttons-pro"); ?></span>
217 </div>
218 <div class="font_manager">
219 <div class='font_search'> <span><?php _e("Search","maxbuttons-pro") ?></span>
220 <input type='text' name='font_search' value='' />
221 </div>
222
223 <div class="font_wrap">
224 <div class='font_left'>
225 <ul class='items'>
226
227 </ul>
228 </div>
229 <div class='font_right '>
230 <ul class='items'>
231
232 </ul>
233 </div>
234 </div>
235 <div class='font_example'>
236 <span class='placeholder'><?php _e("Click on a font to see an example","maxbuttons-pro"); ?></span>
237 <span class='example_text'><?php _e("AaBbCcDdEeFfGgEeHh") ?></span>
238 </div>
239 </div>
240 </span>
241 <div class='controls'>
242 <div class='controls_inline'>
243 <button type='button' name='save_fonts' class='button-primary'><?php _e("Save changes", 'maxbuttons-pro'); ?></button> &nbsp;
244 <button type='button' class='button-primary modal_close'><?php _e("Close","maxbuttons-pro"); ?></button>
245 </div>
246 </div>
247 </div> <!-- maxmodal-data -->
248 <?php
249 }
250
251 function admin()
252 {
253 $admin = mbSocial()->admin();
254
255 ?>
256
257 <div class='options option-container layout' id='layoutBlock' data-refresh='previewBlock' >
258 <div class='title'><?php _e('Customization', 'mbsocial' ); ?></div>
259 <div class='inside'>
260 <?php
261
262 $colorsw = new maxField('switch');
263 $colorsw->label = __('Use solid colors','mbsocial');
264 $colorsw->id = 'use_background';
265 $colorsw->value = 1;
266 $colorsw->name = $colorsw->id;
267 $colorsw->inputclass = 'update_change';
268 $colorsw->checked = checked( $this->getValue('use_background'), 1, false);
269 $admin->addField( $colorsw, 'start', '');
270
271
272 $ispacer = new maxField('spacer');
273 $ispacer->label = __('Use Social Network Brand Colors','mbsocial');
274 $ispacer->publish = false;
275 $ispacer->output('','end');
276
277 $admin->addField($ispacer, '', 'end', false);
278
279 $bgcolor = new maxField('color') ;
280 $bgcolor->label = __('Background color', 'mbsocial');
281 $bgcolor->value = $this->getColorValue('background_color');
282 $bgcolor->id = 'background_color';
283 $bgcolor->name = $bgcolor->id;
284 $admin->addField($bgcolor, 'start', '');
285
286 $bgcolor_hover = new maxField('color');
287 $bgcolor_hover->label = __('Background Hover', 'mbsocial');
288 $bgcolor_hover->value = $this->getColorValue('background_color_hover');
289 $bgcolor_hover->id = 'background_color_hover';
290 $bgcolor_hover->name = $bgcolor_hover->id;
291 $admin->addField( $bgcolor_hover, '', 'end');
292
293 $color = new maxField('color');
294 $color->label = __('Color', 'mbsocial');
295 $color->value = $this->getColorValue('color');
296 $color->id = 'color';
297 $color->name = $color->id;
298 $admin->addField($color, 'start', '');
299
300 $color_hover = new maxField('color');
301 $color_hover->label = __('Hover', 'mbsocial');
302 $color_hover->value = $this->getColorValue('color_hover');
303 $color_hover->id = 'color_hover';
304 $color_hover->name = $color_hover->id;
305 $admin->addField( $color_hover, '', 'end');
306
307 // FONTS
308 /* $button = new maxField('generic');
309 $button->label = '';
310 $button->id = 'manage-fonts';
311 $button->name = 'button_fonts';
312 $button->content = '<div id="manage-fonts" class="button manage-fonts maxmodal" data-modal="add-fonts" title="' . __("Add additional fonts","maxbuttons-pro") . '" ><i class="dashicons dashicons-editor-spellcheck"></i>' . __('Font Manager', 'maxbuttons-pro') . '</div>';
313 $admin->addField($button, 'start', 'end');
314 */
315 $fonts = MB()->getClass('admin')->loadFonts();
316
317 $field_font = new maxField('generic');
318 $field_font->label = __('Font Family','maxbuttons');
319 $field_font->name = 'font';
320 $field_font->id = $field_font->name;
321 $field_font->value= $this->getValue('font');
322 $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
323 $admin->addField($field_font,'start', 'end');
324 ?>
325
326 <?php
327 // FONT SIZE
328 //global $maxbuttons_font_sizes;
329 //$sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
330
331 // *** LABEL SIZE *** //
332 $field_size = new maxField('number');
333 $field_size->label = __('Label Size', 'mbsocial');
334 $field_size->name = 'font_label_size';
335 $field_size->id= $field_size->name;
336 $field_size->inputclass = 'tiny';
337 $field_size->min = 8;
338 $field_size->value = maxUtils::strip_px($this->getValue('font_label_size'));
339 $admin->addField($field_size, 'start');
340
341 // Font style checkboxes
342 $fweight = new maxField('checkbox');
343 $fweight->icon = 'dashicons-editor-bold';
344 $fweight->title = __("Bold",'mbsocial');
345 $fweight->id = 'check_label_fweight';
346 $fweight->name = 'font_label_weight';
347 $fweight->value = 'bold';
348 $fweight->inputclass = 'check_button icon';
349 $fweight->checked = checked( $this->getValue('font_label_weight'), 'bold', false);
350 $admin->addField($fweight, 'group_start');
351
352 $fstyle = new maxField('checkbox');
353 $fstyle->icon = 'dashicons-editor-italic';
354 $fstyle->title = __("Italic",'mbsocial');
355 $fstyle->id = 'check_label_fstyle';
356 $fstyle->name = 'font_label_style';
357 $fstyle->value = 'italic';
358 $fstyle->inputclass = 'check_button icon';
359 $fstyle->checked = checked( $this->getValue('font_label_style'), 'italic', false);
360 $admin->addField($fstyle);
361
362 $fupper = new maxField('checkbox');
363 $fupper->icon = 'dashicons-arrow-up';
364 $fupper->title = __('Uppercase', 'mbsocial');
365 $fupper->id = 'check_label_fupper';
366 $fupper->name = 'font_label_upper';
367 $fupper->value = 'uppercase';
368 $fupper->inputclass = 'check_button icon';
369 $fupper->checked = checked ( $this->getValue('font_label_upper'), 'uppercase', false);
370
371 $admin->addField($fupper, '', array('group_end', 'end'));
372
373 // *** ICON SIZE *** //
374 $field_size = new maxField('number');
375 $field_size->label = __('Icon Size', 'mbsocial');
376 $field_size->name = 'font_icon_size';
377 $field_size->id= $field_size->name;
378 $field_size->inputclass = 'tiny';
379 $field_size->min = 8;
380 $field_size->value = maxUtils::strip_px($this->getValue('font_icon_size'));
381 $admin->addField($field_size, 'start');
382
383 // Font style checkboxes
384 $fweight = new maxField('checkbox');
385 $fweight->icon = 'dashicons-editor-bold';
386 $fweight->title = __("Bold",'mbsocial');
387 $fweight->id = 'check_icon_fweight';
388 $fweight->name = 'font_icon_weight';
389 $fweight->value = 'bold';
390 $fweight->inputclass = 'check_button icon';
391 $fweight->checked = checked( $this->getValue('font_icon_weight'), 'bold', false);
392 $admin->addField($fweight, 'group_start');
393
394 $fstyle = new maxField('checkbox');
395 $fstyle->icon = 'dashicons-editor-italic';
396 $fstyle->title = __("Italic",'mbsocial');
397 $fstyle->id = 'check_icon_fstyle';
398 $fstyle->name = 'font_icon_style';
399 $fstyle->value = 'italic';
400 $fstyle->inputclass = 'check_button icon';
401 $fstyle->checked = checked( $this->getValue('font_icon_style'), 'italic', false);
402 $admin->addField($fstyle, '', array('group_end', 'end'));
403
404
405 // Margins
406 $icon_url = MB()->get_plugin_url() . 'images/icons/' ;
407
408 $mtop = new maxField('number');
409 $mtop->publish = false;
410 $mtop->label = __('Margin top', 'mbsocial');
411 $mtop->id = 'margin_top';
412 $mtop->name = $mtop->id;
413 $mtop->min = 0;
414 $mtop->inputclass = 'tiny';
415 $mtop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Margin Top","mbsocial") . '" >';
416 $mtop->value = maxUtils::strip_px($this->getValue('margin_top'));
417
418 //$mtop->output('start');
419 $admin->addField($mtop, 'start','', false);
420
421 $mbottom = new maxField('number');
422 $mbottom->label = __('Margin Bottom', 'mbsocial');
423 $mbottom->id = 'margin_bottom';
424 $mbottom->name = $mbottom->id;
425 $mbottom->min = 0;
426 $mbottom->inputclass = 'tiny';
427 $mbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" title="' . __("Margin Bottom","mbsocial") . '" >';
428 $mbottom->value = maxUtils::strip_px($this->getValue('margin_bottom') );
429
430 $admin->addField( $mbottom, '', 'end', false );
431
432 $mleft = new maxField('number');
433 $mleft->label = __('Margin Left', 'mbsocial');
434 $mleft->id = 'margin_left';
435 $mleft->name = $mleft->id;
436 $mleft->min = 0;
437 $mleft->inputclass = 'tiny';
438 $mleft->before_input = '<img src="' . $icon_url . 'p_left.png" title="' . __("Margin Left","mbsocial") . '" >';
439 $mleft->value = maxUtils::strip_px($this->getValue('margin_left'));
440
441 $admin->addField( $mleft,'start', '', false);
442
443 $mright = new maxField('number');
444 $mright->label = __('Margin Right', 'mbsocial');
445 $mright->id = 'margin_right';
446 $mright->name = $mright->id;
447 $mright->min = 0;
448 $mright->inputclass = 'tiny';
449 $mright->before_input = '<img src="' . $icon_url . 'p_right.png" title="' . __("Margin Right","mbsocial") . '" >';
450 $mright->value = maxUtils::strip_px($this->getValue('margin_right'));
451
452 $admin->addField( $mright, '', 'end', false);
453
454 // Spacing
455
456 $spacing = new maxField('number');
457 $spacing->label = __('Button Spacing', 'mbsocial');
458 $spacing->id = 'button_spacing';
459 $spacing->name = $spacing->id;
460 $spacing->min = 0;
461 $spacing->inputclass = 'tiny';
462 $spacing->value = maxUtils::strip_px($this->getValue('button_spacing'));
463
464 $admin->addUpdate($spacing);
465 $admin->addField($spacing, 'start', 'end');
466
467 $admin->display_fields();
468 ?>
469 </div> <!-- inside -->
470 </div> <!-- option container -->
471
472
473 <?php $this->fontModal(); ?>
474
475 <?php
476 } // admin
477
478 }
479