css; } protected function mainCSS() { // defaults for collection ( whole block ) // button defaults // style for maxbutton-social (button) $this->addCSS( array( 'width' => $this->width . 'px', 'height' => $this->height . 'px', 'color' => 'transparent', ) ); // icon $this->addCSS( array( 'font-size' => '20px', 'line-height' => '20px', // 'margin' => 0, // 'padding' => 0, ), '', 'mb-icon' ); // share count $this->addCSS ( array ( 'font-size' => '20px', 'line-height' => '20px', 'display' => 'none', ), '', 'mb-share-count' ); // label $this->addCSS( array ( 'display' => 'none', 'font-size' => '15px', ), '', 'mb-label' ); } /* Total element is counting all shares and displays some label */ protected function totalCSS() { // total main element $this->addFlex('maxbutton-social-total'); $this->addCSS ( array( 'width' => $this->width * 2 . 'px', 'height' => $this->height . 'px', 'font-size' => '16px', ), '', 'maxbutton-social-total' ); $this->addCSS ( array ( // 'display' => 'inline-block' ), '', 'mb-totals' ); $this->addCSS ( array( //'float' => 'left', 'font-size' => '20px', 'width' => '45%', 'text-align' => 'left', //'height' => 'inherit', ), '', 'mb-icon-total'); $this->addCSS ( array ( // *sigh* 'font-size' => '35px', //'height' => 'auto', 'vertical-align' => 'top', ), '', 'mb-icon-total-icon', 'before' ); $this->addCSS ( array ( //'float' => 'right', 'clear' => 'right', 'text-align' => 'center', // 'width' => '45%', 'text-transform' => 'uppercase', 'font-size' => '13px', ), '', 'mb-label-total'); $this->addCSS ( array ( //'float' => 'right', 'text-align' => 'center', 'font-size' => '25px', ), '', 'mb-count-total'); } /* Add flexbox definition to element */ public function addFlex($element = 'mb-icon-wrapper') { // add flex to icon wrapper $this->addCSS( array( 'display' => 'flex', 'justify-content' => 'center', 'align-items' => 'center', 'height' => '100%', ), '', $element ); } public function addCSS($name, $value = '', $element = 'maxbutton-social', $pseudo = 'normal') { if (! isset($this->css[$element][$pseudo])) $this->css[$element][$pseudo] = array(); if ( is_array($name)) { foreach ($name as $n => $v) { $this->css[$element][$pseudo][$n] = $v; } } else $this->css[$element][$pseudo][$name] = $value; } /* Function that runs before the CSS output is collected from the styles to be brought to the CSSParser. Load with env. details will allow for relevant changes */ public function prepareCSS($args) { $default_args = array( 'orientation' => 'horizontal', 'is_static' => false, 'is_post' => false, 'is_mobile' => false, 'is_tablet' => false, ); $args = wp_parse_args($args, $default_args); $this->mainCSS(); $this->totalCSS(); if ($args['orientation'] == 'vertical') { $this->addCSS(array( 'width' => $this->width . 'px', 'height' => $this->height . 'px', 'flex-direction' => 'column' ), '', 'maxbutton-social-total' ); $this->addCSS('display', 'none', 'mb-icon-total'); $this->addCSS('width', 'auto', 'mb-label-total'); } } /* Function for changes to CSS ( eg styling exceptions ) after blocks generated CSS */ public function preParse($css) { return $css; } // for now argument is network only,might add to options here later // This is the basis for style bases icon library swapping public function renderIcon($network) { $icon = $network->get('icon'); $icon_type = $network->get('icon_type'); $network_name = $network->get_nice_name(); switch($icon_type) { case 'fa': case 'nucleo': $output = " "; break; case 'svg': $output = "" . $network_name . ""; break; default: $output = ''; break; } return apply_filters('mbsocial/rendericon', $output, $this, $network); } // function to plug into when the style is set active in a collection. Can be used to hook into style specific layout options. public function setActive() { } } // class