get_metabox_field_html( $field, $field['saved'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped endforeach; ?>
get_html_field( $field ); return $html; break; case 'html_tag': $html = $this->get_html_tag( $field ); return $html; break; case 'toolbar': $html = $this->get_repeater_tools( $field ); break; case 'input': $html = $this->get_input_field( $field ); break; case 'select': $html = $this->get_select_field( $field, $saved ); break; case 'textarea': $html = $this->get_textarea_field( $field, $saved ); break; case 'file': $html = $this->get_file_field( $field, $saved ); break; case 'repeater': $html = $this->get_repeater_field( $field, $saved ); break; case 'dropzone': $html = $this->get_dropzone_field( $field, $saved ); break; case 'checkbox': return $this->get_checkbox_field( $field, $saved ); default: $method = 'get_' . $field['field_type'] . 'field'; if ( method_exists( $this, $method ) ) { $html = call_user_func( [ $this, $method ], $field, $saved ); } break; } return $this->get_field_row( $field, $html ); } public function get_field_label( $field ) { if ( ! isset( $field['label'] ) || false === $field['label'] ) { return ''; } $id = $field['id']; if ( 'file' === $field['field_type'] ) { $id .= $field['field_type']; } return '

'; } public function get_input_field( $attributes ) { if ( isset( $attributes['input_type'] ) ) { $attributes['type'] = $attributes['input_type']; unset( $attributes['input_type'] ); } $input = 'get_attribute_string( $attributes ) . '>'; return $input; } public function get_attribute_string( $attributes, $field = [] ) { if ( isset( $field['extra_attributes'] ) && is_array( $field['extra_attributes'] ) ) { $attributes = array_merge( $attributes, $field['extra_attributes'] ); } $attributes_array = []; foreach ( $attributes as $name => $value ) { $attributes_array[] = sprintf( '%s="%s"', $name, esc_attr( $value ) ); } return implode( ' ', $attributes_array ); } public function get_select_field( $field, $selected = '' ) { $input = ''; } public function get_textarea_field( $field, $html ) { $input = ''; return $input; } public function get_file_field( $field, $saved ) { $value = [ 'id' => '', 'url' => '', ]; if ( isset( $saved['id'] ) && isset( $saved['url'] ) ) { $value = $saved; } $html = ''; $html .= $this->get_input_field( [ 'type' => 'hidden', 'name' => $field['id'] . '[id]', 'value' => $value['id'], ] ); $html .= $this->get_input_field( [ 'type' => 'text', 'name' => $field['id'] . '[url]', 'value' => $value['url'], 'placeholder' => $field['description'], 'class' => 'elementor-field-input', ] ); $html .= $this->get_input_field( [ 'type' => 'button', 'class' => 'button elementor-button elementor-upload-btn', 'name' => $field['id'], 'id' => $field['id'], 'value' => '', 'data-preview_anchor' => isset( $field['preview_anchor'] ) ? $field['preview_anchor'] : 'none', 'data-mime_type' => isset( $field['mine'] ) ? $field['mine'] : '', 'data-ext' => isset( $field['ext'] ) ? $field['ext'] : '', 'data-upload_text' => esc_html__( 'Upload', 'elementor-pro' ), 'data-remove_text' => esc_html__( 'Delete', 'elementor-pro' ), 'data-box_title' => isset( $field['box_title'] ) ? $field['box_title'] : '', 'data-box_action' => isset( $field['box_action'] ) ? $field['box_action'] : '', ] ); return $html; } public function get_html_field( $field ) { return $field['raw_html']; } public function get_dropzone_field( $field ) { ob_start(); $input_attributes = [ 'type' => 'file', 'name' => $field['id'], 'id' => $field['id'], 'accept' => $field['accept'], 'class' => 'box__file', ]; if ( ! empty( $field['multiple'] ) ) { $input_attributes['multiple'] = true; } $input_html = $this->get_input_field( $input_attributes ); $field['label'] = '

' . esc_html__( 'Drag & Drop to Upload', 'elementor-pro' ) . '

'; if ( ! empty( $field['sub-label'] ) ) { $field['label'] .= '
' . $field['sub-label'] . '
'; } ?>
get_field_label( $field ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
.
'row_label_' . $js_id, 'class' => 'repeater-title hidden', ]; if ( is_array( $row_label ) ) { $label = $row_label['default']; $row_label_html_args['data-default'] = $row_label['default']; $row_label_html_args['data-selector'] = $row_label['selector']; } else { $label = $row_label; $row_label_html_args['data-default'] = $row_label; } $row_label_html = 'get_attribute_string( $row_label_html_args ) . '>' . $label . ''; ob_start(); ?> get_attribute_string( $row_label_html_args ) . '>' . $label . ''; if ( is_array( $saved ) && count( $saved ) > 0 ) { foreach ( (array) $saved as $key => $item ) { echo '
'; echo $row_label_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $this->get_repeater_tools( $field ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; // end table echo '
'; $counter++; } } echo ''; return ob_get_clean(); } public function get_checkbox_field( $field, $saved ) { Utils::print_unescaped_internal_string( $this->get_field_row( $field, '' ) ); echo '
'; foreach ( $field['options'] as $checkbox_key => $label ) { $name = $field['id'] . '_' . $checkbox_key; $checked = ! empty( $saved ) && in_array( $checkbox_key, $saved, true ) ? 'checked' : ''; echo '' . esc_html( $label ) . ''; } echo '
'; } private function get_html_tag( $field ) { $tag = isset( $field['tag'] ) ? $field['tag'] : 'div'; if ( isset( $field['close'] ) && true === $field['close'] ) { return ''; } return '<' . $tag . ' ' . $this->get_attribute_string( $field['attributes'] ) . '>'; } private function get_repeater_tools( $field ) { $confirm = isset( $field['confirm'] ) ? $field['confirm'] : esc_html__( 'Are you sure?', 'elementor-pro' ); $remove_title = isset( $field['remove_title'] ) ? $field['remove_title'] : esc_html__( 'Delete', 'elementor-pro' ); $toggle_title = isset( $field['toggle_title'] ) ? $field['toggle_title'] : esc_html__( 'Edit', 'elementor-pro' ); $close_title = isset( $field['close_title'] ) ? $field['close_title'] : esc_html__( 'Close', 'elementor-pro' ); return ' ' . $close_title . ' ' . $toggle_title . ' ' . $remove_title . ' '; } public function get_field_row( $field, $field_html ) { $description = ''; $css_id = isset( $field['id'] ) ? ' ' . $field['id'] : ''; if ( isset( $field['real_id'] ) ) { $css_id = ' ' . $field['real_id']; } $css_id .= ' elementor-field-' . $field['field_type']; return '
' . $this->get_field_label( $field ) . $field_html . $description . '
'; } public function sanitize_text_field_recursive( $data ) { if ( is_array( $data ) ) { foreach ( $data as $key => $value ) { $data[ $key ] = $this->sanitize_text_field_recursive( $value ); } return $data; } return sanitize_text_field( $data ); } public function __construct() { $this->actions(); } }