$attributes Block attributes. * @since 0.0.2 */ public function __construct( $attributes ) { $this->set_properties( $attributes ); $this->set_input_label( __( 'Multi Choice', 'sureforms' ) ); $this->set_error_msg( $attributes, 'srfm_multi_choice_block_required_text' ); $this->slug = 'multi-choice'; $this->single_selection = isset( $attributes['singleSelection'] ) ? $attributes['singleSelection'] : false; $this->choice_width = isset( $attributes['choiceWidth'] ) ? $attributes['choiceWidth'] : ''; $this->vertical_layout = isset( $attributes['verticalLayout'] ) ? $attributes['verticalLayout'] : false; $this->option_type = ! empty( $attributes['optionType'] ) && in_array( $attributes['optionType'], [ 'icon', 'image' ], true ) ? $attributes['optionType'] : 'icon'; $this->type_attr = $this->single_selection ? 'radio' : 'checkbox'; $this->svg_type = $this->single_selection ? 'circle' : 'square'; $this->name_attr = $this->single_selection ? 'name="srfm-input-' . esc_attr( $this->slug ) . '-' . esc_attr( $this->block_id ) . '"' : ''; $this->choice_width_attr = $this->choice_width ? 'srfm-choice-width-' . str_replace( '.', '-', $this->choice_width ) : ''; $this->set_markup_properties(); } /** * Data attribute markup for min and max value * * @since 0.0.13 * @return string */ protected function data_attribute_markup() { $data_attr = ''; if ( $this->single_selection ) { return ''; } if ( $this->min_selection ) { $data_attr .= 'data-min-selection="' . esc_attr( $this->min_selection ) . '"'; } if ( $this->max_selection ) { $data_attr .= 'data-max-selection="' . esc_attr( $this->max_selection ) . '"'; } return $data_attr; } /** * Render the sureforms Multichoice classic styling * * @since 0.0.2 * @return string|boolean */ public function markup() { $check_svg = Helper::fetch_svg( $this->svg_type . '-checked', 'srfm-' . $this->slug . '-icon' ); $unchecked_svg = Helper::fetch_svg( $this->svg_type . '-unchecked', 'srfm-' . $this->slug . '-icon-unchecked' ); ob_start(); ?>