PluginProbe
Social Share Buttons / 1.5
Social Share Buttons v1.5
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.5, at classes/blocks/layout-block.php

480 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
186 if ( count ($post) == 0)
187 return $data; // don't run on default situations
188
189 // Do the font here
190 $blockdata = $this->data[$this->blockname];
191 $font = $blockdata['font'];
192 //$label_weight = $blockdata['font_label_weight'];
193 // $icon_weight = $blockdata['icon_label_weight'];
194
195 $args = array('font' => $font);
196 $webfont = patches::checkWebFonts($args);
197 $data[$this->blockname]['webfonts'] = $webfont;
198
199
200 return $data;
201
202 }
203
204 function fontModal()
205 {
206 ?>
207 <div class='maxmodal-data' id='add-fonts' data-load='window.maxFoundry.maxfonts.load' data-height='90%'>
208 <span class='title'><?php _e("Font Manager","maxbuttons-pro"); ?>
209
210 </span>
211
212 <span class='content'>
213 <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>
214 <div class="loading_overlay"></div>
215 <div class='loading'>
216 <img src="<?php echo MB()->get_plugin_url(true) ?>images/loading.gif">
217 <span><?php _e("Loading","maxbuttons-pro"); ?></span>
218 </div>
219 <div class="font_manager">
220 <div class='font_search'> <span><?php _e("Search","maxbuttons-pro") ?></span>
221 <input type='text' name='font_search' value='' />
222 </div>
223
224 <div class="font_wrap">
225 <div class='font_left'>
226 <ul class='items'>
227
228 </ul>
229 </div>
230 <div class='font_right '>
231 <ul class='items'>
232
233 </ul>
234 </div>
235 </div>
236 <div class='font_example'>
237 <span class='placeholder'><?php _e("Click on a font to see an example","maxbuttons-pro"); ?></span>
238 <span class='example_text'><?php _e("AaBbCcDdEeFfGgEeHh") ?></span>
239 </div>
240 </div>
241 </span>
242 <div class='controls'>
243 <div class='controls_inline'>
244 <button type='button' name='save_fonts' class='button-primary'><?php _e("Save changes", 'maxbuttons-pro'); ?></button> &nbsp;
245 <button type='button' class='button-primary modal_close'><?php _e("Close","maxbuttons-pro"); ?></button>
246 </div>
247 </div>
248 </div> <!-- maxmodal-data -->
249 <?php
250 }
251
252 function admin()
253 {
254 $admin = mbSocial()->admin();
255
256 ?>
257
258 <div class='options option-container layout' id='layoutBlock' data-refresh='previewBlock' >
259 <div class='title'><?php _e('Customization', 'mbsocial' ); ?></div>
260 <div class='inside'>
261 <?php
262
263 $colorsw = new maxField('switch');
264 $colorsw->label = __('Use solid colors','mbsocial');
265 $colorsw->id = 'use_background';
266 $colorsw->value = 1;
267 $colorsw->name = $colorsw->id;
268 $colorsw->inputclass = 'update_change';
269 $colorsw->checked = checked( $this->getValue('use_background'), 1, false);
270 $admin->addField( $colorsw, 'start', '');
271
272
273 $ispacer = new maxField('spacer');
274 $ispacer->label = __('Use Social Network Brand Colors','mbsocial');
275 $ispacer->publish = false;
276 $ispacer->output('','end');
277
278 $admin->addField($ispacer, '', 'end', false);
279
280 $bgcolor = new maxField('color') ;
281 $bgcolor->label = __('Background color', 'mbsocial');
282 $bgcolor->value = $this->getColorValue('background_color');
283 $bgcolor->id = 'background_color';
284 $bgcolor->name = $bgcolor->id;
285 $admin->addField($bgcolor, 'start', '');
286
287 $bgcolor_hover = new maxField('color');
288 $bgcolor_hover->label = __('Background Hover', 'mbsocial');
289 $bgcolor_hover->value = $this->getColorValue('background_color_hover');
290 $bgcolor_hover->id = 'background_color_hover';
291 $bgcolor_hover->name = $bgcolor_hover->id;
292 $admin->addField( $bgcolor_hover, '', 'end');
293
294 $color = new maxField('color');
295 $color->label = __('Color', 'mbsocial');
296 $color->value = $this->getColorValue('color');
297 $color->id = 'color';
298 $color->name = $color->id;
299 $admin->addField($color, 'start', '');
300
301 $color_hover = new maxField('color');
302 $color_hover->label = __('Hover', 'mbsocial');
303 $color_hover->value = $this->getColorValue('color_hover');
304 $color_hover->id = 'color_hover';
305 $color_hover->name = $color_hover->id;
306 $admin->addField( $color_hover, '', 'end');
307
308 // FONTS
309 /* $button = new maxField('generic');
310 $button->label = '';
311 $button->id = 'manage-fonts';
312 $button->name = 'button_fonts';
313 $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>';
314 $admin->addField($button, 'start', 'end');
315 */
316 $fonts = MB()->getClass('admin')->loadFonts();
317
318 $field_font = new maxField('generic');
319 $field_font->label = __('Font Family','maxbuttons');
320 $field_font->name = 'font';
321 $field_font->id = $field_font->name;
322 $field_font->value= $this->getValue('font');
323 $field_font->content = maxUtils::selectify($field_font->name, $fonts, $field_font->value);
324 $admin->addField($field_font,'start', 'end');
325 ?>
326
327 <?php
328 // FONT SIZE
329 //global $maxbuttons_font_sizes;
330 $sizes = apply_filters('mb/editor/fontsizes', maxUtils::generate_font_sizes(10,50) );
331
332 // *** LABEL SIZE *** //
333 $field_size = new maxField('number');
334 $field_size->label = __('Label Size', 'mbsocial');
335 $field_size->name = 'font_label_size';
336 $field_size->id= $field_size->name;
337 $field_size->inputclass = 'tiny';
338 $field_size->min = 8;
339 $field_size->value = maxUtils::strip_px($this->getValue('font_label_size'));
340 $admin->addField($field_size, 'start');
341
342 // Font style checkboxes
343 $fweight = new maxField('checkbox');
344 $fweight->icon = 'dashicons-editor-bold';
345 $fweight->title = __("Bold",'mbsocial');
346 $fweight->id = 'check_label_fweight';
347 $fweight->name = 'font_label_weight';
348 $fweight->value = 'bold';
349 $fweight->inputclass = 'check_button icon';
350 $fweight->checked = checked( $this->getValue('font_label_weight'), 'bold', false);
351 $admin->addField($fweight, 'group_start');
352
353 $fstyle = new maxField('checkbox');
354 $fstyle->icon = 'dashicons-editor-italic';
355 $fstyle->title = __("Italic",'mbsocial');
356 $fstyle->id = 'check_label_fstyle';
357 $fstyle->name = 'font_label_style';
358 $fstyle->value = 'italic';
359 $fstyle->inputclass = 'check_button icon';
360 $fstyle->checked = checked( $this->getValue('font_label_style'), 'italic', false);
361 $admin->addField($fstyle);
362
363 $fupper = new maxField('checkbox');
364 $fupper->icon = 'dashicons-arrow-up';
365 $fupper->title = __('Uppercase', 'mbsocial');
366 $fupper->id = 'check_label_fupper';
367 $fupper->name = 'font_label_upper';
368 $fupper->value = 'uppercase';
369 $fupper->inputclass = 'check_button icon';
370 $fupper->checked = checked ( $this->getValue('font_label_upper'), 'uppercase', false);
371
372 $admin->addField($fupper, '', array('group_end', 'end'));
373
374 // *** ICON SIZE *** //
375 $field_size = new maxField('number');
376 $field_size->label = __('Icon Size', 'mbsocial');
377 $field_size->name = 'font_icon_size';
378 $field_size->id= $field_size->name;
379 $field_size->inputclass = 'tiny';
380 $field_size->min = 8;
381 $field_size->value = maxUtils::strip_px($this->getValue('font_icon_size'));
382 $admin->addField($field_size, 'start');
383
384 // Font style checkboxes
385 $fweight = new maxField('checkbox');
386 $fweight->icon = 'dashicons-editor-bold';
387 $fweight->title = __("Bold",'mbsocial');
388 $fweight->id = 'check_icon_fweight';
389 $fweight->name = 'font_icon_weight';
390 $fweight->value = 'bold';
391 $fweight->inputclass = 'check_button icon';
392 $fweight->checked = checked( $this->getValue('font_icon_weight'), 'bold', false);
393 $admin->addField($fweight, 'group_start');
394
395 $fstyle = new maxField('checkbox');
396 $fstyle->icon = 'dashicons-editor-italic';
397 $fstyle->title = __("Italic",'mbsocial');
398 $fstyle->id = 'check_icon_fstyle';
399 $fstyle->name = 'font_icon_style';
400 $fstyle->value = 'italic';
401 $fstyle->inputclass = 'check_button icon';
402 $fstyle->checked = checked( $this->getValue('font_icon_style'), 'italic', false);
403 $admin->addField($fstyle, '', array('group_end', 'end'));
404
405
406 // Margins
407 $icon_url = MB()->get_plugin_url() . 'images/icons/' ;
408
409 $mtop = new maxField('number');
410 $mtop->publish = false;
411 $mtop->label = __('Margin top', 'mbsocial');
412 $mtop->id = 'margin_top';
413 $mtop->name = $mtop->id;
414 $mtop->min = 0;
415 $mtop->inputclass = 'tiny';
416 $mtop->before_input = '<img src="' . $icon_url . 'p_top.png" title="' . __("Margin Top","mbsocial") . '" >';
417 $mtop->value = maxUtils::strip_px($this->getValue('margin_top'));
418
419 //$mtop->output('start');
420 $admin->addField($mtop, 'start','', false);
421
422 $mbottom = new maxField('number');
423 $mbottom->label = __('Margin Bottom', 'mbsocial');
424 $mbottom->id = 'margin_bottom';
425 $mbottom->name = $mbottom->id;
426 $mbottom->min = 0;
427 $mbottom->inputclass = 'tiny';
428 $mbottom->before_input = '<img src="' . $icon_url . 'p_bottom.png" title="' . __("Margin Bottom","mbsocial") . '" >';
429 $mbottom->value = maxUtils::strip_px($this->getValue('margin_bottom') );
430
431 $admin->addField( $mbottom, '', 'end', false );
432
433 $mleft = new maxField('number');
434 $mleft->label = __('Margin Left', 'mbsocial');
435 $mleft->id = 'margin_left';
436 $mleft->name = $mleft->id;
437 $mleft->min = 0;
438 $mleft->inputclass = 'tiny';
439 $mleft->before_input = '<img src="' . $icon_url . 'p_left.png" title="' . __("Margin Left","mbsocial") . '" >';
440 $mleft->value = maxUtils::strip_px($this->getValue('margin_left'));
441
442 $admin->addField( $mleft,'start', '', false);
443
444 $mright = new maxField('number');
445 $mright->label = __('Margin Right', 'mbsocial');
446 $mright->id = 'margin_right';
447 $mright->name = $mright->id;
448 $mright->min = 0;
449 $mright->inputclass = 'tiny';
450 $mright->before_input = '<img src="' . $icon_url . 'p_right.png" title="' . __("Margin Right","mbsocial") . '" >';
451 $mright->value = maxUtils::strip_px($this->getValue('margin_right'));
452
453 $admin->addField( $mright, '', 'end', false);
454
455 // Spacing
456
457 $spacing = new maxField('number');
458 $spacing->label = __('Button Spacing', 'mbsocial');
459 $spacing->id = 'button_spacing';
460 $spacing->name = $spacing->id;
461 $spacing->min = 0;
462 $spacing->inputclass = 'tiny';
463 $spacing->value = maxUtils::strip_px($this->getValue('button_spacing'));
464
465 $admin->addUpdate($spacing);
466 $admin->addField($spacing, 'start', 'end');
467
468 $admin->display_fields();
469 ?>
470 </div> <!-- inside -->
471 </div> <!-- option container -->
472
473
474 <?php $this->fontModal(); ?>
475
476 <?php
477 } // admin
478
479 }
480