jQuery(function ($) {

    const $wp_inline_edit = inlineEditPost.edit;

    inlineEditPost.edit = function (id) {

        $wp_inline_edit.apply(this, arguments);

        const postId = (typeof id === 'object') ? this.getId(id) : id;
        const $row = $('#edit-' + postId);
        const $data = $('#plantshop-wc-inline_' + postId + '');

        if (!$data.length) return;

        $data.children().each((i, e) => {
            const fieldClass = $(e).attr('class');
            const fieldValue = $(e).html();

            if (fieldClass === 'plot_description') {

                $row.find('textarea.' + fieldClass).val(fieldValue.trim());

            } else {

                $row.find('input.' + fieldClass).val(fieldValue.trim());

            }

        });

    };

});
