function pp_pb_widget_styles_dialog_form($specific = null) { $fields = ppb_block_styling_fields(); foreach ($fields as $key => $field) { if (empty($specific)) { if ('inline-css' == $key) { continue; } } else { if ($specific != $key) { continue; } } echo "<div class='field'>"; echo "<label>" . esc_html($field['name']) . "</label>"; echo "<span>"; switch ($field['type']) { case 'color': ?> <input dialog-field="<?php echo $key; ?> " class="widget-<?php echo $key; ?> " type="text" data-style-field-type="color"/> <?php break; case 'border': ?> <input dialog-field="<?php echo $key; ?> -width" class="widget-<?php echo $key; ?> -width" type="number" min="0" max="100" step="1" value="" /> px <input dialog-field="<?php echo $key; ?> -color" class="widget-<?php echo $key; ?> -color" type="text" data-style-field-type="color"/> <?php break; case 'number': ?> <input dialog-field="<?php echo $key; ?> " class="widget-<?php echo $key; ?> " type="number" min="<?php esc_attr_e($field['min']); ?> " max="<?php esc_attr_e($field['max']); ?> " step="<?php esc_attr_e($field['step']); ?> " value="" /> <?php esc_html_e($field['unit']); ?> <?php break; case 'checkbox': ?> <input dialog-field="<?php echo $key; ?> " class="widget-<?php echo $key; ?> " type="checkbox" value="<?php esc_attr_e($field['value']); ?> " data-style-field-type="checkbox" /> <?php break; case 'textarea': ?> <input dialog-field="<?php echo $key; ?> " class="widget-<?php echo $key; ?> " type="text" data-style-field-type="text"/> <?php break; } echo "</span>"; echo '</div>'; } }
/** * Opens the content block container with styles and classes * * @param $block_info * @param $gi * @param $ci * @param $pi * @param $blocks_num * @param $post_id * * @action ppb_panels_render_content_block * @since 1.0.0 */ public function open_block($block_info, $gi, $ci, $pi, $blocks_num, $post_id) { $styleArray = $widgetStyle = isset($block_info['info']['style']) ? json_decode($block_info['info']['style'], true) : ppb_default_content_block_style(); //Classes for this content block $classes = array('panel'); if (0 == $pi) { $classes[] = 'panel-first-child'; } if ($blocks_num - 1 == $pi) { $classes[] = 'panel-last-child'; } //Id for this content block $id = 'panel-' . $post_id . '-' . $gi . '-' . $ci . '-' . $pi; $inlineStyle = ''; $widgetStyleFields = ppb_block_styling_fields(); $styleWithSelector = ''; foreach ($widgetStyleFields as $key => $field) { if ($field['type'] == 'border') { // a border field has 2 settings $key1 = $key . '-width'; $key2 = $key . '-color'; if (isset($styleArray[$key1]) && $styleArray[$key1] != '') { if (!is_array($field['css'])) { $cssArr = array($field['css']); } else { $cssArr = $field['css']; } foreach ($cssArr as $cssProperty) { $inlineStyle .= $cssProperty . '-width: ' . $styleArray[$key1] . 'px; border-style: solid;'; } } if (isset($styleArray[$key2]) && $styleArray[$key2] != '') { if (!is_array($field['css'])) { $cssArr = array($field['css']); } else { $cssArr = $field['css']; } foreach ($cssArr as $cssProperty) { $inlineStyle .= $cssProperty . '-color: ' . $styleArray[$key2] . ';'; } } } elseif ($key == 'inline-css') { if (!empty($styleArray[$key])) { $inlineStyle .= $styleArray[$key]; } } else { if (isset($styleArray[$key]) && $styleArray[$key] != '') { if (!is_array($field['css'])) { $cssArr = array($field['css']); } else { $cssArr = $field['css']; } foreach ($cssArr as $cssProperty) { if (isset($field['unit'])) { $unit = $field['unit']; } else { $unit = ''; } if (!isset($field['selector'])) { $inlineStyle .= $cssProperty . ': ' . $styleArray[$key] . $unit . ';'; } else { $styleWithSelector .= '#' . $id . ' > ' . $field['selector'] . ' { ' . $cssProperty . ': ' . $styleArray[$key] . $unit . '; }'; } } } } } if ($styleWithSelector != '') { echo "<style>\n"; echo str_replace('display', 'display:none;display', $styleWithSelector); echo "</style>\n"; } echo '<div class="' . esc_attr(implode(' ', $classes)) . '" id="' . $id . '" style="' . $inlineStyle . '" >'; }