PluginProbe
Social Share Buttons / 1.0
Social Share Buttons v1.0
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.0, at classes/blocks/style_block.php

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