40, 'class' => "layoutBlock" ); class layoutBlock extends block { protected $blockname = "layout"; protected $fields = array( "margin_left" => array("default" => "0px", "css" => "margin-left", "csspart" => "maxcollection"), "margin_right" => array("default" => "0px", "css" => "margin-right", "csspart" => "maxcollection"), "margin_top" => array("default" => "0px", "css" => "margin-top", "csspart" => "maxcollection"), "margin_bottom" => array("default" => "0px", "css" => "margin-bottom", "csspart" => "maxcollection"), "orientation" => array("default" => "auto"), /*"item_margin_right" => array("default" => "0px", "css" => "margin-right", "csspart" => "mb-collection-item", ), "item_margin_bottom" => array("default" => "0px", "css" => "margin-bottom", "csspart" => "mb-collection-item", ), */ 'size' => array('default' => 100), 'use_background' => array('default' => 1, ), 'background_color' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'maxbutton-social', ), 'background_color_hover' => array('default' => '#000', 'css' => 'background-color', 'csspart' => 'maxbutton-social', 'csspseudo' => 'hover', ), 'color' => array('default' => '#fff', 'css' => 'color', 'csspart' => 'mb-icon,mb-share-count,mb-label'), 'color_hover' => array('default' => '#fff', 'css' => 'color', 'csspart' => 'mb-icon,mb-share-count,mb-label', 'csspseudo' => 'hover'), "button_spacing" => array('default' => '5', ), "ignore_container" => array("default" => 1), /* "static_position_ver" => array("default" => "Auto", ), "static_position_hor" => array("default" => "Auto", ), */ ); /*public function map_fields($map) { $map = parent::map_fields($map); $map["orientation"]["func"] = "updatePlacement"; return $map; } */ /* function parseButtons($buttons) { // searches the cache for the container statement ending with -container or -center and tries to remove then // not very optimal code, but this is a way to maintain cache loading while altering css. if ($this->data["ignore_container"] == 0) return $buttons; // ignore container off . foreach($buttons as $button) { $cache = $button->getCache(); // chops all css statements in a different line preg_match_all('/([^{]+)\s*\{\s*([^}]+)\s*}/i',$cache, $matches); foreach($matches[0] as $cssline) { // tries to find the last part of the statement from - to { preg_match_all('/.([^-])*{/i', $cssline, $item); $item = trim(str_replace("{","",$item[0][0])); if ($item == '-center' || $item == '-container') { $cache = str_replace($cssline,'',$cache); } } //([^{]+)\s*\{\s*([^}]+)\s*} { split } // match last thing .([^-])*{ $button->setCache($cache); $data = $button->get(); $container = isset($data["container"]) ? $data["container"] : array(); foreach($container as $key => $value) { if ($key != 'container_enabled' && $key != 'container_center_div_wrap') // causes container to be removed otherwise $container[$key] = ''; } $button->setdata("container", $container); } return $buttons; } */ function parseCSS($css, $args) { $css = parent::parseCSS($css, $args); $hook = $this->collection->getHook(); $blockdata = $this->data[$this->blockname]; // if true, use network colors $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false; if ($use_background) { unset ($css['maxbutton-social']['normal']['background-color']); unset ($css['maxbutton-social']['hover']['background-color']); } $css['mb-icon.svg path']['normal']['color'] = '#fff'; $css['mb-icon.svg path']['hover']['color'] = '#ff0000'; $css["collection-item"]["normal"]["float"] = "left"; $css["collection-item"]["normal"]["display"] = "inline-block"; $css["collection-item a"]["normal"]["cursor"] = "pointer"; // by default social share = call to action. if ($blockdata['button_spacing'] > 0) { $orientation = $this->collection->orientation; $button_spacing = $blockdata['button_spacing']; if ($orientation == 'horizontal') { $css['collection-item']['normal']['margin-right'] = $button_spacing . 'px'; } if ($orientation == 'vertical') { $css['collection-item']['normal']['margin-bottom'] = $button_spacing . 'px'; } } return $css; } public function parse($itemObj, $args = array() ) { $blockdata = $this->data[$this->blockname]; $use_background = isset($blockdata['use_background']) ? $blockdata['use_background'] : false; if ($use_background) { $item = $itemObj->find('.collection-item',0); $item->class .= ' social-colors'; } return $itemObj; } function save_fields($data, $post) { $data = parent::save_fields($data, $post); if (! isset($post["ignore_container"]) && ! is_null($post)) $data[$this->blockname]["ignore_container"] = 0; if (! isset($post['use_background']) && ! is_null($post)) $data[$this->blockname]['use_background'] = 0; return $data; } function admin() { $admin = mbSocial()->admin(); ?>
label = __('Size', 'mbsocial'); $size->id = 'size'; $size->name = $size->id; $size->min = 25; $size->max = 200; $size->min_label = $size->min . '%'; $size->max_label = $size->max . '%'; $size->value = maxBlocks::getValue('size'); $admin->addField($size, 'start', 'end'); */ $colorsw = new maxField('switch'); $colorsw->label = __('Use solid colors','mbsocial'); $colorsw->id = 'use_background'; $colorsw->value = 1; $colorsw->name = $colorsw->id; $colorsw->inputclass = 'update_change'; $colorsw->checked = checked( maxBlocks::getValue('use_background'), 1, false); $admin->addUpdate($colorsw); $admin->addField( $colorsw, 'start', ''); $ispacer = new maxField('spacer'); $ispacer->label = __('Use Social Network Brand Colors','mbsocial'); $ispacer->publish = false; $ispacer->output('','end'); $admin->addField($ispacer, '', 'end'); $bgcolor = new maxField('color') ; $bgcolor->label = __('Background color', 'mbsocial'); $bgcolor->value = maxBlocks::getColorValue('background_color'); $bgcolor->id = 'background_color'; $bgcolor->name = $bgcolor->id; $admin->addUpdate($bgcolor); $admin->addField($bgcolor, 'start', ''); $bgcolor_hover = new maxField('color'); $bgcolor_hover->label = __('Background Hover', 'mbsocial'); $bgcolor_hover->value = maxBlocks::getColorValue('background_color_hover'); $bgcolor_hover->id = 'background_color_hover'; $bgcolor_hover->name = $bgcolor_hover->id; $admin->addUpdate($bgcolor_hover); $admin->addField( $bgcolor_hover, '', 'end'); $color = new maxField('color'); $color->label = __('Color', 'mbsocial'); $color->value = maxBlocks::getColorValue('color'); $color->id = 'color'; $color->name = $color->id; $admin->addUpdate($color); $admin->addField($color, 'start', ''); $color_hover = new maxField('color'); $color_hover->label = __('Hover', 'mbsocial'); $color_hover->value = maxBlocks::getColorValue('color_hover'); $color_hover->id = 'color_hover'; $color_hover->name = $color_hover->id; $admin->addUpdate($color_hover); $admin->addField( $color_hover, '', 'end'); // Margins $icon_url = MB()->get_plugin_url() . 'images/icons/' ; $mtop = new maxField('number'); $mtop->publish = false; $mtop->label = __('Margin top', 'mbsocial'); $mtop->id = 'margin_top'; $mtop->name = $mtop->id; $mtop->min = 0; $mtop->inputclass = 'tiny'; $mtop->before_input = ''; $mtop->value = maxUtils::strip_px(maxBlocks::getValue('margin_top')); //$mtop->output('start'); $admin->addField($mtop, 'start',''); $mbottom = new maxField('number'); $mbottom->label = __('Margin Bottom', 'mbsocial'); $mbottom->id = 'margin_bottom'; $mbottom->name = $mbottom->id; $mbottom->min = 0; $mbottom->inputclass = 'tiny'; $mbottom->before_input = ''; $mbottom->value = maxUtils::strip_px(maxBlocks::getValue('margin_bottom') ); $admin->addField( $mbottom, '', 'end' ); $mleft = new maxField('number'); $mleft->label = __('Margin Left', 'mbsocial'); $mleft->id = 'margin_left'; $mleft->name = $mleft->id; $mleft->min = 0; $mleft->inputclass = 'tiny'; $mleft->before_input = ''; $mleft->value = maxUtils::strip_px(maxBlocks::getValue('margin_left')); $admin->addField( $mleft,'start', ''); $mright = new maxField('number'); $mright->label = __('Margin Right', 'mbsocial'); $mright->id = 'margin_right'; $mright->name = $mright->id; $mright->min = 0; $mright->inputclass = 'tiny'; $mright->before_input = ''; $mright->value = maxUtils::strip_px(maxBlocks::getValue('margin_right')); $admin->addField( $mright, '', 'end'); // Spacing $spacing = new maxField('number'); $spacing->label = __('Button Spacing', 'mbsocial'); $spacing->id = 'button_spacing'; $spacing->name = $spacing->id; $spacing->min = 0; $spacing->inputclass = 'tiny'; $spacing->value = maxUtils::strip_px(maxBlocks::getValue('button_spacing')); $admin->addUpdate($spacing); $admin->addField($spacing, 'start', 'end'); $admin->display_fields(); ?>