Add attachments in message form, from a wordpress wiget

0

I use the dokan plugin for creating the marketplace (within the Wordpress platform). This plugin grants a Message Form Widget it already automatically sends to the e-mail of the store that the customer is visiting. The problem I wanted to add to the file attachment option (jpg, png, doc, docx and pdf). The Widget code is attached.

<?php
/**
 * Dokan Store Contact Seller Widget
 *
 * @since 1.0
 *
 * @package dokan
 */
class Dokan_Store_Contact_Form extends WP_Widget {

    /**
     * Constructor
     *
     * @return void
     */
    public function __construct() {
        $widget_ops = array( 'classname' => 'dokan-store-contact', 'description' => __( 'Dokan Vendor Contact Form', 'dokan-lite' ) );
        parent::__construct( 'dokan-store-contact-widget', __( 'Dokan: Store Contact Form', 'dokan-lite' ), $widget_ops );
    }

    /**
     * Outputs the HTML for this widget.
     *
     * @param array  An array of standard parameters for widgets in this theme
     * @param array  An array of settings for this widget instance
     *
     * @return void Echoes it's output
     **/
    function widget( $args, $instance ) {

        if ( dokan_is_store_page() || is_product() ) {
            extract( $args, EXTR_SKIP );
            $title      = apply_filters( 'widget_title', $instance['title'] );

            if ( is_product() ) {
                global $post;
                $seller_id = get_post_field( 'post_author', $post->ID );
            }

            if ( dokan_is_store_page() ) {
                $seller_id  = (int) get_query_var( 'author' );
            }

            if ( empty( $seller_id ) ) {
                return;
            }

            $store_info = dokan_get_store_info( $seller_id );

            echo $before_widget;

            if ( ! empty( $title ) ) {
                echo $args['before_title'] . $title . $args['after_title'];
            }

            dokan_get_template_part( 'widgets/store-contact-form', '', array(
                'seller_id' => $seller_id,
                'store_info' => $store_info,
            ) );

            echo $after_widget;
        }
    }

    /**
     * Deals with the settings when they are saved by the admin. Here is
     * where any validation should be dealt with.
     *
     * @param array  An array of new settings as submitted by the admin
     * @param array  An array of the previous settings
     *
     * @return array The validated and (if necessary) amended settings
     */
    function update( $new_instance, $old_instance ) {

        // update logic goes here
        $updated_instance = $new_instance;
        return $updated_instance;
    }

    /**
     * Displays the form for this widget on the Widgets page of the WP Admin area.
     *
     * @param array  An array of the current settings for this widget
     *
     * @return void Echoes it's output
     */
    function form( $instance ) {
        $instance = wp_parse_args( (array) $instance, array(
            'title' => __( 'Contact Vendor', 'dokan-lite' ),
        ) );

        $title = $instance['title'];
        ?>
        <p>
            <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'dokan-lite' ); ?></label>
            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
        </p>
        <?php
    }
}
    
asked by anonymous 01.12.2018 / 04:44

0 answers