: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
el.$fieldContextMenu.css( {
left: leftPosition + 'px',
el.$fieldContextMenu.fadeIn( 150 );
* Check menu items visibility.
* @param {Object} $field jQuery object.
checkMenuItemsVisibility( $field ) {
const fieldId = $field.data( 'field-id' );
const shouldHideHandlers = {
edit: () => app.shouldHideEdit( $field ),
duplicate: () => app.shouldHideDuplicate( $field ),
delete: () => app.shouldHideDelete( $field ),
required: () => app.shouldHideRequired( fieldId ),
label: () => app.shouldHideLabel( fieldId ),
'smart-logic': () => app.shouldHideSmartLogic( fieldId ),
'field-size': () => app.shouldHideFieldSize( fieldId, $field ),
el.$contextMenuItem.each( function() {
const action = $item.data( 'action' );
const handler = shouldHideHandlers[ action ];
* @param {Object} $field Field object.
* @return {boolean} True when should hide.
shouldHideEdit( $field ) {
return $field.hasClass( 'internal-information-not-editable' );
* Check duplicate visibility.
* @param {Object} $field Field object.
* @return {boolean} True when should hide.
shouldHideDuplicate( $field ) {
const $duplicate = $field.find( '.wpforms-field-duplicate' );
return $duplicate.length === 0 || $duplicate.css( 'display' ) === 'none';
* Check delete visibility.
* @param {Object} $field Field object.
* @return {boolean} True when should hide.
shouldHideDelete( $field ) {
const $delete = $field.find( '.wpforms-field-delete' );
return $delete.length === 0 || $delete.css( 'display' ) === 'none';
* Check the required visibility.
* @param {string} fieldId Field ID.
* @return {boolean} True when should hide.
shouldHideRequired( fieldId ) {
return $( `#wpforms-field-option-${ fieldId }-required[type="checkbox"]` ).length === 0;
* Check label visibility.
* @param {string} fieldId Field ID.
* @return {boolean} True when should hide.
shouldHideLabel( fieldId ) {
const $label = $( `#wpforms-field-option-${ fieldId }-label_hide[type="checkbox"]` );
return $label.length === 0 || $label.parents( '.wpforms-field-option-row' ).hasClass( 'wpforms-disabled' );
* Check field size visibility.
* @param {string} fieldId Field ID.
* @param {Object} $field Field object.
* @return {boolean} True when should hide.
shouldHideFieldSize( fieldId, $field ) {
const isFieldInColumn = $field.closest( '.wpforms-layout-column' ).length > 0;
const isRepeaterField = $field.closest( '.wpforms-field-repeater' ).length > 0;
const $size = $( `#wpforms-field-option-${ fieldId }-size` );
return $size.length === 0 || isFieldInColumn || isRepeaterField || $size.parent().hasClass( 'wpforms-hidden' );
* Check smart logic visibility.
* @param {string} fieldId Field ID.
* @return {boolean} True when should hide.
shouldHideSmartLogic( fieldId ) {
return $( `#wpforms-field-option-conditionals-${ fieldId }` ).length === 0 && $( `#wpforms-field-option-${ fieldId } .wpforms-field-option-group-conditionals .education-modal` ).length === 0;
* Check divider visibility.
checkDividerVisibility() {
el.$contextMenuDivider.each( function() {
const $divider = $( this );
const visibility = $divider.data( 'visibility' ) ?? '';
visibility.split( ',' ).forEach( function( item ) {
if ( $( '.wpforms-context-menu-list-item[data-action="' + item.trim() + '"]' ).css( 'display' ) !== 'none' ) {
el.$fieldContextMenu.fadeOut( 150 );
el.$contextMenuItem.show();
* @param {Object} e Event object.
if ( $( e.target ).closest( app.selectors.contextMenu ).length ) {
* Maybe open the sidebar.
// If the sidebar is already open, do nothing.
if ( ! el.$sidebarToggle.parent().hasClass( 'wpforms-panel-sidebar-closed' ) ) {
el.$sidebarToggle.trigger( 'click' );
// Provide access to public functions/properties.
}( document, window, jQuery ) );
WPForms.Admin.Builder.ContextMenu.init();