PluginProbe
Social Share Buttons / 1.2
Social Share Buttons v1.2
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 / style_block.php

style_block.php in Social Share Buttons 1.2, at classes/blocks/style_block.php

238 lines 7.1 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\maxBlocks as maxBlocks;
7 use \MaxButtons\maxButton as maxButton;
8 use \MaxButtons\maxUtils as maxUtils;
9
10
11 $collectionBlock["style"] = array('class' => "styleBlock",
12 'order' => 30);
13
14 class styleBlock extends block
15 {
16 protected $blockname = "style";
17 protected $fields = array(
18 'mbs-style' => array('default' => 'square'), // shapes of button, sets a bunch of css
19 'mbs-width' => array('default' => '55px',
20 'css' => 'width',
21 'csspart' => 'mb-social'),
22 'mbs-height' => array('default' => '55px',
23 'css' => 'height',
24 'csspart' => 'mb-social'),
25 // 'icon_size' => array('default' => 0),
26 /* 'font_size' => array('default' => '15px',
27 'css' => 'font-size',
28 'csspart' => 'mb-label'), */
29 //'count_font_size' => array('default' => '15px'),
30 //'share_font_size' => array('default' => '15px'),
31
32
33
34 );
35
36 public $add_preview_style = false;
37
38 // public $preview_style = false;
39
40 public function set($data)
41 {
42 parent::set($data);
43 $blockdata = $this->data[$this->blockname];
44 if (isset($blockdata['mbs-style']) && ! empty($blockdata['mbs-style']) )
45 {
46 $styleObj = styles::getStyle($blockdata['mbs-style']);
47
48 if ($styleObj)
49 $this->collection->setStyle( $styleObj );
50 }
51 else // default to first style - default option
52 {
53 //$styles = styles::getStyles();
54 $def_style = $this->fields['mbs-style']['default'];
55 $style = styles::getStyle($def_style);
56 $this->collection->setStyle($style);
57
58
59 /*if (count($styles) > 0)
60 {
61 $first_ar = array_shift($styles);
62 $style_obj = array_shift($first_ar);
63 $data_style = $style_obj->name;
64 $style = styles::getStyle($data_style);
65 $this->collection->setStyle($style);
66 } */
67 }
68 }
69
70 public function parse($itemObj, $args = array() )
71 {
72 $block_data = isset($this->data[$this->blockname]) ? $this->data[$this->blockname] : array();
73 $style = $this->collection->getStyle();
74
75 if ($style->has_label)
76 {
77
78 $label = $this->network->get_label();
79 if ($label)
80 {
81
82 $anchor = $itemObj->find('.mb-social', 0);
83 if (is_object($anchor))
84 {
85 $anchor->class .= ' ';
86 $label_text = '<span class="mb-label">' . $label . '</span>';
87 $anchor->innertext .= $label_text;
88 // $itemObj->load($itemObj->save() );
89 $this->collection->getStyle()->addDisplay('label');
90 }
91 }
92 }
93
94 if ($args['preview'] == true && $this->add_preview_style)
95 {
96 $style = $this->add_preview_style;
97 }
98
99 return $itemObj;
100 }
101
102 public function ajax_get_all_styles()
103 {
104 $available_styles = styles::getStyles();
105
106 }
107
108 public function admin()
109 {
110 //wp_enqueue_style('mbsocial-buttons');
111
112 $admin = MBSocial()->admin();
113
114 $blockdata = isset($this->data[$this->blockname]) ? $this->data[$this->blockname] : array();
115
116 $data_style = isset($blockdata['mbs-style']) ? $blockdata['mbs-style'] : false; //
117
118 $icon_url = MBSocial()->get_plugin_url() . 'images/icons/';
119 $icons = array(
120 'shape_round' => 'shape_circle.png',
121 'shape_square' => 'shape_square.png',
122 // 'shape_stretch' => 'shape_stretch.png',
123 );
124
125 ?>
126 <div class='help-side'>
127 <h3><?php _e("Style Options", 'mbsocial'); ?></h3>
128 <p>Use the <strong>Presets</strong> to set multiple style options at once. This will overwrite some current settings : Shape, Width and the items under Customization. It will not change your network selections. Once you have selected a preset you can use Shape, Width and Height to customize it.</p>
129
130 <p><strong>Shapes</strong> - Choose between circle and rectangle.</p>
131
132 </div>
133
134 <div class='options option-container style' id='styleBlock' data-refresh='previewBlock' >
135 <div class='title'><?php _e('Style', 'mbsocial'); ?></div>
136 <div class='inside'>
137 <?php
138 $preset = new maxField('button');
139 $preset->id = 'open_presets';
140 $preset->name = 'preset';
141 $preset->modal = 'modal_styles';
142 $preset->inputclass = 'button button-primary maxmodal';
143 $preset->label= '&nbsp;';
144 $preset->button_label = __('Select Preset', 'mbsocial');
145
146 $admin->addField($preset, 'start', 'end', false);
147
148 $spacey = new maxField('spacer');
149 $spacey->name = 'label';
150 $spacey->label = __("Shape", 'mb-social');
151
152 $admin->addField($spacey, 'start', '', false);
153
154 $shape_round = new maxField('radio');
155 $shape_round->id = 'radio_shape_round';
156 $shape_round->name = 'mbs-style';
157 $shape_round->value = 'round';
158 $shape_round->title = __('Circle', 'mbsocial');
159 $shape_round->inputclass = 'check_button icon';
160 $shape_round->custom_icon = 'mbsocial-shape circle';
161 $shape_round->checked = checked($this->getValue('mbs-style'), $shape_round->value, false);
162
163 $admin->addField($shape_round);
164
165 $shape_square = new maxField('radio');
166 $shape_square->id = 'radio_shape_square';
167 $shape_square->name = 'mbs-style';
168 $shape_square->value = 'square';
169 $shape_square->title = __('Rectangle', 'mbsocial');
170 $shape_square->inputclass = 'check_button icon';
171 //$shape_square->image = $icon_url . $icons['shape_square'];
172 $shape_square->custom_icon = 'mbsocial-shape square';
173 $shape_square->checked = checked($this->getValue('mbs-style'), $shape_square->value, false);
174 $admin->addField($shape_square, '', 'end');
175
176 /* $shape_stretch = new maxField('radio');
177 $shape_stretch->id = 'radio_shape_stretch';
178 $shape_stretch->name = 'mbs-style';
179 $shape_stretch->title = __('Stretch', 'mbsocial');
180 $shape_stretch->value = 'stretch';
181 $shape_stretch->inputclass = 'check_button icon';
182 $shape_stretch->custom_icon = 'mbsocial-shape stretch';
183 $shape_stretch->checked = checked($this->getValue('mbs-style'), $shape_stretch->value, false);
184 $admin->addField($shape_stretch, '', 'end');
185 */
186 $width = new maxField('number');
187 $width->id = 'mbs-width';
188 $width->name = $width->id;
189 $width->label = __('Width', 'mbsocial');
190 $width->inputclass = 'tiny';
191 $width->min = 0;
192 $width->value = maxUtils::strip_px($this->getValue('mbs-width'));
193
194 $admin->addField($width, 'start');
195
196 $height = new maxField('number');
197 $height->id = 'mbs-height';
198 $height->name = $height->id;
199 $height->label = __('Height', 'mbsocial');
200 $height->inputclass = 'tiny';
201 $height->min = 0;
202 $height->value = maxUtils::strip_px($this->getValue('mbs-height'));
203
204 $admin->addField($height, '','end');
205
206
207 $admin->display_fields();
208
209 ?>
210
211 </div> <!-- inside-->
212 </div> <!-- option container -->
213
214 <div id='modal_styles' class='maxmodal-data' data-load='window.maxFoundry.maxSocial.loadPresetsPopup'>
215 <div class='title'><?php _e('Presets', 'mbsocial'); ?></div>
216
217 <div class='content'>
218 <div class='warning top-note hidden'><?php _e('By selecting a different Preset, your settings for Style and Customization will be overwritten', 'mbsocial'); ?> </div>
219 <div class='welcome top-note hidden'><?php _e('Welcome to WordPress share buttons. Get started fast by selecting a preset!','mbsocial'); ?></div>
220
221
222 <div class='style_modal style-row wrapper'>
223
224
225 </div>
226
227 </div> <!-- content -->
228
229 </div> <!-- modal -->
230
231
232
233 <?php
234 } // admin
235
236
237 } // class
238