| 1 |
<?php |
| 2 |
defined('ABSPATH') or die('No direct access permitted'); |
| 3 |
$blockClass["border"] = "borderBlock"; |
| 4 |
$blockOrder[30][] = "border"; |
| 5 |
|
| 6 |
use MaxButtons\maxBlocks as maxBlocks; |
| 7 |
use MaxButtons\maxField as maxField; |
| 8 |
|
| 9 |
class borderBlock extends maxBlock |
| 10 |
{ |
| 11 |
protected $blockname = "border"; |
| 12 |
protected $fields = array("radius_top_left" => |
| 13 |
array("default" => "4px", |
| 14 |
"css" => "border-top-left-radius" |
| 15 |
), |
| 16 |
"radius_top_right" => array("default" => "4px", |
| 17 |
"css" => "border-top-right-radius" |
| 18 |
), |
| 19 |
"radius_bottom_left" => array("default" => "4px", |
| 20 |
"css" => "border-bottom-left-radius" |
| 21 |
), |
| 22 |
"radius_bottom_right" => array("default" => "4px", |
| 23 |
"css" => "border-bottom-right-radius" |
| 24 |
), |
| 25 |
"border_style" => array("default" => "solid", |
| 26 |
"css" => "border-style" |
| 27 |
), |
| 28 |
"border_width" => array("default" => "2px", |
| 29 |
"css" => "border-width" |
| 30 |
), |
| 31 |
"box_shadow_offset_left" => array("default" => "0px", |
| 32 |
"css" => "box-shadow-offset-left", |
| 33 |
"csspseudo" => "normal,hover" |
| 34 |
), |
| 35 |
"box_shadow_offset_top" => array("default" => "0px", |
| 36 |
"css" => "box-shadow-offset-top", |
| 37 |
"csspseudo" => "normal,hover"), |
| 38 |
"box_shadow_width" => array("default" => "2px", |
| 39 |
"css" => "box-shadow-width", |
| 40 |
"csspseudo" => "normal,hover"), |
| 41 |
'box_shadow_spread' => array('default' => '0px', |
| 42 |
'css' => 'box-shadow-spread', |
| 43 |
'csspseudo' => 'normal,hover'), |
| 44 |
|
| 45 |
); |
| 46 |
|
| 47 |
|
| 48 |
function __construct() |
| 49 |
{ |
| 50 |
parent::__construct(); |
| 51 |
$this->fields = apply_filters($this->blockname. "-block-fields",$this->fields); |
| 52 |
$this->data[$this->blockname] = array(); //empty init |
| 53 |
} |
| 54 |
|
| 55 |
public function map_fields($map) |
| 56 |
{ |
| 57 |
$map = parent::map_fields($map); |
| 58 |
$map["box_shadow_offset_left"]["func"] = "updateBoxShadow"; |
| 59 |
$map["box_shadow_offset_top"]["func"] = "updateBoxShadow"; |
| 60 |
$map["box_shadow_width"]["func"] = "updateBoxShadow"; |
| 61 |
$map["box_shadow_spread"]["func"] = "updateBoxShadow"; |
| 62 |
|
| 63 |
$map["radius_top_left"]["func"] = "updateRadius"; |
| 64 |
$map["radius_top_right"]["func"] = "updateRadius"; |
| 65 |
$map["radius_bottom_left"]["func"] = "updateRadius"; |
| 66 |
$map["radius_bottom_right"]["func"] = "updateRadius"; |
| 67 |
|
| 68 |
|
| 69 |
return $map; |
| 70 |
} |
| 71 |
|
| 72 |
public function admin_fields() |
| 73 |
{ |
| 74 |
$data = $this->data[$this->blockname]; |
| 75 |
foreach($this->fields as $field => $options) |
| 76 |
{ |
| 77 |
$default = (isset($options["default"])) ? $options["default"] : ''; |
| 78 |
$$field = (isset($data[$field])) ? $data[$field] : $default; |
| 79 |
${$field . "_default"} = $default; |
| 80 |
} |
| 81 |
|
| 82 |
$maxbuttons_border_styles = array( |
| 83 |
'' => '', |
| 84 |
'dashed' => __('dashed','maxbuttons'), |
| 85 |
'dotted' => __('dotted','maxbuttons'), |
| 86 |
'double' => __('double','maxbuttons'), |
| 87 |
'groove' => __('groove','maxbuttons'), |
| 88 |
'inset' => __('inset','maxbuttons'), |
| 89 |
'outset' => __('outset','maxbuttons'), |
| 90 |
'ridge' => __('ridge','maxbuttons'), |
| 91 |
'solid' => __('solid','maxbuttons') |
| 92 |
); |
| 93 |
?> |
| 94 |
<div class="option-container mb_tab"> |
| 95 |
<div class="title"><?php _e('Border', 'maxbuttons') ?></div> |
| 96 |
<div class="inside"> |
| 97 |
|
| 98 |
|
| 99 |
<?php |
| 100 |
// Spacer |
| 101 |
$fspacer = new maxField('spacer'); |
| 102 |
$fspacer->label = __('Radius','maxbuttons'); |
| 103 |
$fspacer->name = 'radius'; |
| 104 |
$fspacer->output('start'); |
| 105 |
|
| 106 |
// Radius left top |
| 107 |
$radius_tleft = new maxField('number'); |
| 108 |
//$radius_tleft->label = __('Top Left', 'maxbuttons'); |
| 109 |
//$radius_tleft->label = '<span class="dashicons dashicons-arrow-left-alt2 rotate-right"></span>'; |
| 110 |
$radius_tleft->value = maxUtils::strip_px(maxBlocks::getValue('radius_top_left')); |
| 111 |
$radius_tleft->id = 'radius_top_left'; |
| 112 |
$radius_tleft->name = $radius_tleft->id; |
| 113 |
$radius_tleft->min = 0; |
| 114 |
$radius_tleft->inputclass = 'tiny'; |
| 115 |
$radius_tleft->publish = false; |
| 116 |
$rtl = $radius_tleft->output(''); |
| 117 |
|
| 118 |
// Radius right top |
| 119 |
$radius_tright = new maxField('number'); |
| 120 |
//$radius_tright->label = __('Top Right', 'maxbuttons'); |
| 121 |
//$radius_tright->label = '<span class="dashicons dashicons-arrow-right-alt2 rotate-left"></span>'; |
| 122 |
$radius_tright->value = maxUtils::strip_px(maxBlocks::getValue('radius_top_right')); |
| 123 |
$radius_tright->id = 'radius_top_right'; |
| 124 |
$radius_tright->name = $radius_tright->id; |
| 125 |
$radius_tright->min = 0; |
| 126 |
$radius_tright->inputclass = 'tiny'; |
| 127 |
$radius_tright->publish = false; |
| 128 |
$rtr = $radius_tright->output('', ''); |
| 129 |
|
| 130 |
|
| 131 |
// Radius bottom left |
| 132 |
$radius_bleft = new maxField('number'); |
| 133 |
//$radius_bleft->label = __('Bottom Left', 'maxbuttons'); |
| 134 |
//$radius_bleft->label = '<span class="dashicons dashicons-arrow-left-alt2 rotate-left"></span>'; |
| 135 |
$radius_bleft->value = maxUtils::strip_px(maxBlocks::getValue('radius_bottom_left')); |
| 136 |
$radius_bleft->id = 'radius_bottom_left'; |
| 137 |
$radius_bleft->name = $radius_bleft->id; |
| 138 |
$radius_bleft->min = 0; |
| 139 |
$radius_bleft->inputclass = 'tiny'; |
| 140 |
$radius_bleft->publish = false; |
| 141 |
$rbl = $radius_bleft->output(''); |
| 142 |
|
| 143 |
// Radius bottom right |
| 144 |
$radius_bright = new maxField('number'); |
| 145 |
//$radius_bright->label = __('Bottom Right', 'maxbuttons'); |
| 146 |
//$radius_bright->label = '<span class="dashicons dashicons-arrow-right-alt2 rotate-right"></span>'; |
| 147 |
$radius_bright->value = maxUtils::strip_px(maxBlocks::getValue('radius_bottom_right')); |
| 148 |
$radius_bright->id = 'radius_bottom_right'; |
| 149 |
$radius_bright->name = $radius_bright->id; |
| 150 |
$radius_bright->min = 0; |
| 151 |
$radius_bright->inputclass = 'tiny'; |
| 152 |
$radius_bright->publish = false; |
| 153 |
$rbr = $radius_bright->output('', ''); |
| 154 |
|
| 155 |
// If all same, lock the corners for simultanious change. |
| 156 |
if ($radius_tleft->value == $radius_tright->value && |
| 157 |
$radius_tright->value == $radius_bleft->value && |
| 158 |
$radius_bleft->value = $radius_bright->value) |
| 159 |
{ |
| 160 |
$lock = 'lock'; |
| 161 |
} |
| 162 |
else |
| 163 |
$lock = 'unlock'; |
| 164 |
|
| 165 |
$radius = new maxField('radius'); |
| 166 |
$radius->radius_tl = $rtl; |
| 167 |
$radius->label_tl = __('Top Left','maxbuttons'); |
| 168 |
$radius->radius_tr = $rtr; |
| 169 |
$radius->label_tr = __('Top Right','maxbuttons'); |
| 170 |
$radius->radius_bl = $rbl; |
| 171 |
$radius->label_bl = __('Bottom Left','maxbuttons'); |
| 172 |
$radius->radius_br = $rbr; |
| 173 |
$radius->label_br = __('Bottom Right','maxbuttons'); |
| 174 |
$radius->lock = $lock; |
| 175 |
$radius->output('','end'); |
| 176 |
|
| 177 |
// Border style |
| 178 |
$bstyle = new maxField('generic'); |
| 179 |
$bstyle->label = __('Style','maxbuttons'); |
| 180 |
$bstyle->name = 'border_style'; |
| 181 |
$bstyle->id = $bstyle->name; |
| 182 |
$bstyle->value= maxBlocks::getValue('border_style'); |
| 183 |
$bstyle->setDefault(maxBlocks::getDefault('border_style')); |
| 184 |
$bstyle->content = maxUtils::selectify($bstyle->name, $maxbuttons_border_styles, $bstyle->value); |
| 185 |
$bstyle->output('start', 'end'); |
| 186 |
|
| 187 |
// Border width |
| 188 |
$bwidth = new maxField('number'); |
| 189 |
$bwidth->label = __('Width', 'maxbuttons'); |
| 190 |
$bwidth->name = 'border_width'; |
| 191 |
$bwidth->id = $bwidth->name; |
| 192 |
$bwidth->value = maxUtils::strip_px( maxBlocks::getValue('border_width') ); |
| 193 |
$bwidth->min = 0; |
| 194 |
$bwidth->inputclass = 'tiny'; |
| 195 |
$bwidth->output('start','end'); |
| 196 |
|
| 197 |
// Border Color |
| 198 |
$bcolor = new maxField('color'); |
| 199 |
$bcolor->id = 'border_color'; |
| 200 |
$bcolor->name = $bcolor->id; |
| 201 |
$bcolor->value = maxBlocks::getColorValue('border_color'); |
| 202 |
$bcolor->label = __('Border Color','maxbuttons'); |
| 203 |
$bcolor->copycolor = true; |
| 204 |
$bcolor->bindto = 'border_color_hover'; |
| 205 |
$bcolor->copypos = 'right'; |
| 206 |
$bcolor->output('start'); |
| 207 |
|
| 208 |
// Border Color Hover |
| 209 |
$bcolor_hover = new maxField('color'); |
| 210 |
$bcolor_hover->id = 'border_color_hover'; |
| 211 |
$bcolor_hover->name = $bcolor_hover->id; |
| 212 |
$bcolor_hover->value = maxBlocks::getColorValue('border_color_hover'); |
| 213 |
$bcolor_hover->label = __('Hover','maxbuttons'); |
| 214 |
$bcolor_hover->copycolor = true; |
| 215 |
$bcolor_hover->bindto = 'border_color'; |
| 216 |
$bcolor_hover->copypos = 'left'; |
| 217 |
$bcolor_hover->output('','end'); |
| 218 |
|
| 219 |
// Shadow offset left |
| 220 |
$bshadow = new maxField('number'); |
| 221 |
$bshadow->label = __('Shadow Offset Left','maxbuttons'); |
| 222 |
$bshadow->name = 'box_shadow_offset_left'; |
| 223 |
$bshadow->id = $bshadow->name; |
| 224 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_offset_left') ); |
| 225 |
$bshadow->inputclass = 'tiny'; |
| 226 |
$bshadow->output('start'); |
| 227 |
|
| 228 |
// Shadow offset top |
| 229 |
$bshadow = new maxField('number'); |
| 230 |
$bshadow->label = __('Shadow Offset Top','maxbuttons'); |
| 231 |
$bshadow->name = 'box_shadow_offset_top'; |
| 232 |
$bshadow->id = $bshadow->name; |
| 233 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_offset_top') ); |
| 234 |
$bshadow->inputclass = 'tiny'; |
| 235 |
$bshadow->output('','end'); |
| 236 |
|
| 237 |
// Shadow width |
| 238 |
$bshadow = new maxField('number'); |
| 239 |
$bshadow->label = __('Shadow Blur','maxbuttons'); |
| 240 |
$bshadow->name = 'box_shadow_width'; |
| 241 |
$bshadow->id = $bshadow->name; |
| 242 |
$bshadow->value = maxUtils::strip_px( maxBlocks::getValue('box_shadow_width') ); |
| 243 |
$bshadow->inputclass = 'tiny'; |
| 244 |
$bshadow->output('start',''); |
| 245 |
|
| 246 |
$bspread = new maxField('number'); |
| 247 |
$bspread->label = __('Shadow Spread', 'maxbuttons'); |
| 248 |
$bspread->value = maxUtils::strip_px(maxBlocks::getValue('box_shadow_spread')); |
| 249 |
$bspread->id = 'box_shadow_spread'; |
| 250 |
$bspread->name = $bspread->id; |
| 251 |
$bspread->inputclass = 'tiny'; |
| 252 |
$bspread->output('','end'); |
| 253 |
|
| 254 |
// Border Shadow Color |
| 255 |
$scolor = new maxField('color'); |
| 256 |
$scolor->id = 'box_shadow_color'; |
| 257 |
$scolor->name = $scolor->id; |
| 258 |
$scolor->value = maxBlocks::getColorValue('box_shadow_color'); |
| 259 |
$scolor->label = __('Border Shadow Color','maxbuttons'); |
| 260 |
$scolor->copycolor = true; |
| 261 |
$scolor->bindto = 'box_shadow_color_hover'; |
| 262 |
$scolor->copypos = 'right'; |
| 263 |
$scolor->output('start'); |
| 264 |
|
| 265 |
// Border Shadow Color Hover |
| 266 |
$scolor_hover = new maxField('color'); |
| 267 |
$scolor_hover->id = 'box_shadow_color_hover'; |
| 268 |
$scolor_hover->name = $scolor_hover->id; |
| 269 |
$scolor_hover->value = maxBlocks::getColorValue('box_shadow_color_hover'); |
| 270 |
$scolor_hover->label = __('Hover','maxbuttons'); |
| 271 |
$scolor_hover->copycolor = true; |
| 272 |
$scolor_hover->bindto = 'box_shadow_color'; |
| 273 |
$scolor_hover->copypos = 'left'; |
| 274 |
$scolor_hover->output('','end'); |
| 275 |
|
| 276 |
?> |
| 277 |
|
| 278 |
</div> |
| 279 |
</div> |
| 280 |
<?php |
| 281 |
} // admin fields |
| 282 |
|
| 283 |
} // class |
| 284 |
|
| 285 |
?> |
| 286 |
|