: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
vars.fieldType = undefined;
const $placeholderSortable = ui.placeholder.parent();
const $targetSortable = $( e.target );
vars.glitchChange = false;
// In some cases sortable widget display placeholder in wrong sortable instance.
// It's happens when you drag the field over/out the last column of the last Layout field.
! $sortable.is( $placeholderSortable ) &&
$sortable.hasClass( 'wpforms-field-wrap' ) &&
$placeholderSortable.hasClass( 'wpforms-layout-column' )
vars.glitchChange = true;
el.$builder.trigger( 'wpformsFieldDragChange', [ fieldId, $targetSortable ] );
if ( currentlyScrolling ) {
const scrollAreaHeight = 50,
mouseYPosition = e.clientY,
containerOffset = $scrollContainer.offset(),
containerHeight = $scrollContainer.height(),
containerBottom = containerOffset.top + containerHeight;
mouseYPosition > containerOffset.top &&
mouseYPosition < ( containerOffset.top + scrollAreaHeight )
mouseYPosition > ( containerBottom - scrollAreaHeight ) &&
mouseYPosition < containerBottom
currentlyScrolling = true;
$scrollContainer.animate(
scrollTop: operator + ( containerHeight / 3 ) + 'px',
currentlyScrolling = false;
* Initialize draggable fields buttons.
el.$addFieldsButtons.draggable( {
connectToSortable: '.wpforms-field-wrap, .wpforms-layout-column',
appendTo: '#wpforms-panel-fields',
const $el = $( '<div class="wpforms-field-drag-out wpforms-field-drag">' );
vars.fieldType = $this.data( 'field-type' );
return $el.html( $this.html() );
const event = WPFormsUtils.triggerEvent(
'wpformsFieldAddDragStart',
// Allow callbacks on `wpformsFieldAddDragStart` to cancel dragging the field
// by triggering `event.preventDefault()`.
if ( event.isDefaultPrevented() ) {
const event = WPFormsUtils.triggerEvent(
'wpformsFieldAddDragStop',
// Allow callbacks on `wpformsFieldAddDragStop` to cancel dragging the field
// by triggering `event.preventDefault()`.
if ( event.isDefaultPrevented() ) {
* Revert moving the field to the column.
* @param {jQuery} $field Field object.
revertMoveFieldToColumn( $field ) {
const isNewField = $field.data( 'field-id' ) === undefined;
// Restore existing field on the previous position.
$field = $field.detach();
const $fieldInStartPosition = vars.$sortableStart
.find( '> .wpforms-field' )
.eq( vars.startPosition );
.removeClass( 'wpforms-field-dragging' )
.removeClass( 'wpforms-field-drag-over' )
if ( $fieldInStartPosition.length ) {
$fieldInStartPosition.before( $field );
vars.$sortableStart.append( $field );
* Layout field functions holder.
* Position field in the column inside the Layout Field.
* @param {number} fieldId Field ID.
* @param {number} position The new position of the field inside the column.
* @param {jQuery} $sortable Sortable column container.
positionFieldInColumn( fieldId, position, $sortable ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
WPForms.Admin.Builder.FieldLayout.positionFieldInColumn( fieldId, position, $sortable );
* Receive field to column inside the Layout Field.
* @param {number} fieldId Field ID.
* @param {number} position Field position inside the column.
* @param {jQuery} $sortable Sortable column container.
receiveFieldToColumn( fieldId, position, $sortable ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
WPForms.Admin.Builder.FieldLayout.receiveFieldToColumn( fieldId, position, $sortable );
* Update field options according to the position of the field.
* Event `wpformsFieldOptionTabToggle` handler.
* @param {Event} e Event.
* @param {number} fieldId Field id.
fieldOptionsUpdate( e, fieldId ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
WPForms.Admin.Builder.FieldLayout.fieldOptionsUpdate( e, fieldId );
* Reorder fields options of the fields in columns.
* It is not critical, but it's better to keep some order in the `fields` data array.
* @param {jQuery} $layoutField Layout field object.
reorderLayoutFieldsOptions( $layoutField ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
WPForms.Admin.Builder.FieldLayout.reorderLayoutFieldsOptions( $layoutField );
* Whether the field type is allowed to be in column.
* @param {string} fieldType Field type to check.
* @param {jQuery} $targetColumn Target column element.
* @return {boolean} True if allowed.
isFieldAllowedInColum( fieldType, $targetColumn ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
const isAllowed = WPForms.Admin.Builder.FieldLayout.isFieldAllowedInColum( fieldType, $targetColumn );
* Allows developers to determine whether the field is allowed to be dragged in column.
* @param {boolean} isAllowed Whether the field is allowed to be placed in the column.
* @param {string} fieldType Field type.
* @param {jQuery} $targetColumn Target column element.
* @return {boolean} True if allowed.
return wp.hooks.applyFilters( 'wpforms.LayoutField.isFieldAllowedDragInColumn', isAllowed, fieldType, $targetColumn );
* Determine whether the field type is a layout-based field.
* @param {string} fieldType Field type to check.
* @return {boolean} True if it is the Layout-based field.
isLayoutBasedField( fieldType ) {
if ( ! WPForms.Admin.Builder.FieldLayout ) {
return WPForms.Admin.Builder.FieldLayout.isLayoutBasedField( fieldType );
// Provide access to public functions/properties.
}( document, window, jQuery ) );
WPForms.Admin.Builder.DragFields.init();