actions_registrar->get();
foreach ( $actions as $action ) {
$new_element_data = $action->on_export( $element );
if ( null !== $new_element_data ) {
$element = $new_element_data;
}
}
return $element;
}
public static function get_button_sizes() {
return [
'xs' => esc_html__( 'Extra Small', 'elementor-pro' ),
'sm' => esc_html__( 'Small', 'elementor-pro' ),
'md' => esc_html__( 'Medium', 'elementor-pro' ),
'lg' => esc_html__( 'Large', 'elementor-pro' ),
'xl' => esc_html__( 'Extra Large', 'elementor-pro' ),
];
}
protected function make_textarea_field( $item, $item_index ) {
$this->add_render_attribute( 'textarea' . $item_index, [
'class' => [
'elementor-field-textual',
'elementor-field',
esc_attr( $item['css_classes'] ),
'elementor-size-' . $item['input_size'],
],
'name' => $this->get_attribute_name( $item ),
'id' => $this->get_attribute_id( $item ),
'rows' => $item['rows'],
] );
if ( $item['placeholder'] ) {
$this->add_render_attribute( 'textarea' . $item_index, 'placeholder', $item['placeholder'] );
}
if ( $item['required'] ) {
$this->add_required_attribute( 'textarea' . $item_index );
}
$value = empty( $item['field_value'] ) ? '' : $item['field_value'];
return '';
}
protected function make_select_field( $item, $i ) {
$this->add_render_attribute(
[
'select-wrapper' . $i => [
'class' => [
'elementor-field',
'elementor-select-wrapper',
'remove-before',
esc_attr( $item['css_classes'] ),
],
],
'select' . $i => [
'name' => $this->get_attribute_name( $item ) . ( ! empty( $item['allow_multiple'] ) ? '[]' : '' ),
'id' => $this->get_attribute_id( $item ),
'class' => [
'elementor-field-textual',
'elementor-size-' . $item['input_size'],
],
],
]
);
if ( $item['required'] ) {
$this->add_required_attribute( 'select' . $i );
}
if ( $item['allow_multiple'] ) {
$this->add_render_attribute( 'select' . $i, 'multiple' );
if ( ! empty( $item['select_size'] ) ) {
$this->add_render_attribute( 'select' . $i, 'size', $item['select_size'] );
}
}
$options = preg_split( "/\\r\\n|\\r|\\n/", $item['field_options'] );
if ( ! $options ) {
return '';
}
ob_start();
?>
print_render_attribute_string( 'select-wrapper' . $i ); ?>>
'eicons',
'value' => 'eicon-caret-down',
'position' => 'right',
];
Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] );
}
?>
';
foreach ( $options as $key => $option ) {
$element_id = esc_attr( $item['custom_id'] ) . $key;
$html_id = $this->get_attribute_id( $item ) . '-' . $key;
$option_label = $option;
$option_value = $option;
if ( false !== strpos( $option, '|' ) ) {
list( $option_label, $option_value ) = explode( '|', $option );
}
$this->add_render_attribute(
$element_id,
[
'type' => $type,
'value' => $option_value,
'id' => $html_id,
'name' => $this->get_attribute_name( $item ) . ( ( 'checkbox' === $type && count( $options ) > 1 ) ? '[]' : '' ),
]
);
if ( ! empty( $item['field_value'] ) && $option_value === $item['field_value'] ) {
$this->add_render_attribute( $element_id, 'checked', 'checked' );
}
if ( $item['required'] && 'radio' === $type ) {
$this->add_required_attribute( $element_id );
}
$html .= 'get_render_attribute_string( $element_id ) . '> ';
}
$html .= '';
}
return $html;
}
protected function form_fields_render_attributes( $i, $instance, $item ) {
$this->add_render_attribute(
[
'field-group' . $i => [
'class' => [
'elementor-field-type-' . $item['field_type'],
'elementor-field-group',
'elementor-column',
'elementor-field-group-' . $item['custom_id'],
],
],
'input' . $i => [
'type' => $item['field_type'],
'name' => $this->get_attribute_name( $item ),
'id' => $this->get_attribute_id( $item ),
'class' => [
'elementor-field',
'elementor-size-' . $item['input_size'],
empty( $item['css_classes'] ) ? '' : esc_attr( $item['css_classes'] ),
],
],
'label' . $i => [
'for' => $this->get_attribute_id( $item ),
'class' => 'elementor-field-label',
],
]
);
if ( empty( $item['width'] ) ) {
$item['width'] = '100';
}
$this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-col-' . $item['width'] );
if ( ! empty( $item['width_tablet'] ) ) {
$this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-md-' . $item['width_tablet'] );
}
if ( $item['allow_multiple'] ) {
$this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-field-type-' . $item['field_type'] . '-multiple' );
}
if ( ! empty( $item['width_mobile'] ) ) {
$this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-sm-' . $item['width_mobile'] );
}
// Allow zero as placeholder.
if ( ! Utils::is_empty( $item['placeholder'] ) ) {
$this->add_render_attribute( 'input' . $i, 'placeholder', $item['placeholder'] );
}
if ( ! empty( $item['field_value'] ) ) {
$this->add_render_attribute( 'input' . $i, 'value', $item['field_value'] );
}
if ( ! $instance['show_labels'] ) {
$this->add_render_attribute( 'label' . $i, 'class', 'elementor-screen-only' );
}
if ( ! empty( $item['required'] ) ) {
$class = 'elementor-field-required';
if ( ! empty( $instance['mark_required'] ) ) {
$class .= ' elementor-mark-required';
}
$this->add_render_attribute( 'field-group' . $i, 'class', $class );
$this->add_required_attribute( 'input' . $i );
}
}
public function render_plain_content() {}
public function get_attribute_name( $item ) {
return "form_fields[{$item['custom_id']}]";
}
public function get_attribute_id( $item ) {
return 'form-field-' . esc_attr( $item['custom_id'] );
}
private function add_required_attribute( $element ) {
$this->add_render_attribute( $element, 'required', 'required' );
$this->add_render_attribute( $element, 'aria-required', 'true' );
}
}