: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class MultipleChoiceButton
private $buttonsData = array();
private $savedValue = '';
private $template = array();
private $buttonPosition = 'right';
private $fields = array();
* RadioButtons constructor.
public function __construct($buttonsData, $savedValue)
$this->setButtonsData($buttonsData);
$this->setSavedValue($savedValue);
public function __toString()
public function setButtonsData($buttonsData)
$this->buttonsData = $buttonsData;
public function getButtonsData()
return $this->buttonsData;
* Radio buttons saved value
* @param string $savedValue
public function setSavedValue($savedValue)
$this->savedValue = $savedValue;
public function getSavedValue()
return $this->savedValue;
public function setTemplate($template)
$this->template = $template;
public function getTemplate()
* @param string $buttonPosition
public function setButtonPosition($buttonPosition)
$this->buttonPosition = $buttonPosition;
public function getButtonPosition()
return $this->buttonPosition;
public function setFields($fields)
public function getFields()
private function prepareBuild()
$buttonsData = $this->getButtonsData();
if (!empty($buttonsData['template'])) {
$this->setTemplate($buttonsData['template']);
if (!empty($buttonsData['buttonPosition'])) {
$this->setButtonPosition($buttonsData['buttonPosition']);
if (!empty($buttonsData['fields'])) {
$this->setFields($buttonsData['fields']);
$allowed_html = AdminHelper::allowed_html_tags();
<?php echo wp_kses($this->renderFields(), $allowed_html);?>
$content = ob_get_contents();
private function renderFields()
$fields = $this->getFields();
$template = $this->getTemplate();
$buttonPosition = $this->getButtonPosition();
if (!empty($template['groupWrapperAttr'])) {
$groupAttrStr = $this->createAttrs($template['groupWrapperAttr']);
foreach ($fields as $field) {
$labelView = $this->createNewBrandSelectTitle($field);
$radioButton = $this->createNewBrandLabel($field);
$buttonsView .= "<div $groupAttrStr>";
$buttonsView .= $labelView.$radioButton;
$buttonsView .= '</div>';
return '<div class="subForm dimensionForm">'.$buttonsView.'</div>';
private function createNewBrandLabel($field)
$template = $this->getTemplate();
$savedValue = $this->getSavedValue();
if (empty($field['label'])) {
if (!empty($field['attr']['value'])) {
$value = $field['attr']['value'];
if (!empty($field['attr']['class'])) {
$classList = $field['attr']['class'];
$labelData = $field['label'];
if (!empty($template['labelAttr'])) {
$parentAttrsStr = $this->createAttrs($template['labelAttr']);
if (!empty($field['attr']['name'])) {
$inputName = $field['attr']['name'];
if (!empty($field['attr']['data-attr-href'])) {
$inputDataAttr = $field['attr']['data-attr-href'];
if (is_array($savedValue) && in_array($value, $savedValue)) {
else if (!is_array($savedValue) && $savedValue == $value) {
if (isset($field['label']['info'])) {
$info = '<div class="question-mark">B</div>';
$info .= '<div class="sgpb-info-wrapper">';
$info .= '<span class="infoSelectRepeat samefontStyle sgpb-info-text" style="display: none;">';
$info .= $field['label']['info'];
$label .= '<label class="control control__radio sgpb-choice-option-wrapper">';
$label .= '<input value="'.$value.'" class="sgpb-radio-input '.$classList.'" type="radio" name="'.$inputName.'" '.$checked.' data-attr-href="'.$inputDataAttr.'">';
$label .= '<div class="control__indicator"></div>';
private function createNewBrandSelectTitle($field)
$template = $this->getTemplate();
if (empty($field['label'])) {
$labelData = $field['label'];
if (!empty($template['labelAttr'])) {
$parentAttrsStr = $this->createAttrs($template['labelAttr']);
if (!empty($labelData['name'])) {
$labelName = $labelData['name'];
$title = "<span $parentAttrsStr>";
private function createRadioButton($field)
$template = $this->getTemplate();
$savedValue = $this->getSavedValue();
if (!empty($template['fieldWrapperAttr'])) {
$parentAttrsStr = $this->createAttrs($template['fieldWrapperAttr']);
if (!empty($field['attr'])) {
if (!empty($field['attr']['value'])) {
$value = $field['attr']['value'];
$inputAttrStr = $this->createAttrs($field['attr']);
if (is_array($savedValue) && in_array($value, $savedValue)) {
else if (!is_array($savedValue) && $savedValue == $value) {
if (isset($field['label']['info'])) {
$info = '<div class="question-mark">B</div>';
$info = '<div class="sgpb-info-wrapper">';
$info = '<span class="infoSelectRepeat samefontStyle sgpb-info-text" style="display: none;">';
$info .= $field['label']['info'];
$label = "<div $parentAttrsStr>";
$label .= "<input $inputAttrStr $checked >";
private function createLabel($field)
$template = $this->getTemplate();
if (!empty($field['attr']['id'])) {
$checkBoxFor = $field['attr']['id'];
if (empty($field['label'])) {
$labelData = $field['label'];
if (!empty($template['labelAttr'])) {
$parentAttrsStr = $this->createAttrs($template['labelAttr']);
if (!empty($labelData['name'])) {
$labelName = $labelData['name'];
$label = "<div $parentAttrsStr>";
$label .= "<label for=\"$checkBoxFor\">$labelName</label>";
* @return string $attrStr
private function createAttrs($attrs)
foreach ($attrs as $attrKey => $attrValue) {
$attrStr .= $attrKey.'="'.$attrValue.'" ';