: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this.toggleClass( 'read unread' );
if ( ! $table.hasClass( 'wpforms-entries-table-spam' ) && ! $table.hasClass( 'wpforms-entries-table-trash' ) ) {
action : 'wpforms_entry_list_read',
nonce : wpforms_admin.nonce,
entryId : $this.data( 'id' ),
formId : $this.data( 'form-id' ),
$.post( wpforms_admin.ajax_url, data );
// Confirm mass entry deletion/trash - this deletes/trashes ALL entries.
$( document ).on( 'click', '#wpforms-entries-list .form-details-actions-removeall', function( event ) {
const $page = $( this ).data( 'page' ),
$noticeData = WPFormsAdmin.getDeleteAllNoticeData( $page ),
$url = $( this ).attr( 'href' ),
$table = $( '#wpforms-entries-table' ),
filteredCount = $table.data( 'filtered-count-trash' ) && $noticeData.action === 'trash' ? parseInt( $table.data( 'filtered-count-trash' ), 10 ) : 0,
action: 'wpforms_entry_list_process_' + $noticeData.action + '_all',
form_id: $table.find( 'input[name="form_id"]' ).val(), // eslint-disable-line camelcase
date: $table.find( 'input[name="date"]' ).val(),
field: $table.find( 'select[name="search[field]"]' ).val(),
comparison: $table.find( 'select[name="search[comparison]"]' ).val(),
term: $table.find( 'input[name="search[term]"]' ).val(),
nonce: wpforms_admin.nonce,
// Trigger alert modal to confirm.
title: wpforms_admin.heads_up,
content: filteredCount && $( '#wpforms-reset-filter' ).length ? $noticeData.content.replace( '{entry_count}', filteredCount ) : $noticeData.contentAll,
icon: 'fa fa-exclamation-circle',
$.get( wpforms_admin.ajax_url, data )
.done( function( response ) {
if ( response.success ) {
window.location = ! _.isEmpty( response.data ) ? response.data : $url;
text: wpforms_admin.cancel,
// Check for new form entries using Heartbeat API.
$( document ).on( 'heartbeat-send', function( event, data ) {
var $entriesList = $( '#wpforms-entries-list' );
// Works on entry list page only.
if ( ! $entriesList.length || $entriesList.find( '.wpforms-dash-widget' ).length ) {
var last_entry_id = $entriesList.find( '#wpforms-entries-table' ).data( 'last-entry-id' );
// When entries list is filtered, there is no data param at all.
if ( typeof last_entry_id === 'undefined' ) {
data.wpforms_new_entries_entry_id = last_entry_id;
data.wpforms_new_entries_form_id = $entriesList.find( 'input[name=form_id]' ).val();
// Display entries list notification if Heartbeat API new form entries check is successful.
$( document ).on( 'heartbeat-tick', function( event, data ) {
var $entriesList = $( '#wpforms-entries-list' );
// Works on entry list page only.
if ( ! $entriesList.length ) {
if ( ! data.wpforms_new_entries_notification ) {
columnCount = $entriesList.find( '.wp-list-table thead tr' ).first().children().length;
if ( ! $entriesList.find( '.new-entries-notification' ).length ) {
$entriesList.find( '.wp-list-table thead' )
.append( '<tr class="new-entries-notification"><td colspan="' + columnCount + '"><a href=""></a></td></tr>' );
var $link = $entriesList.find( '.new-entries-notification a' );
.text( data.wpforms_new_entries_notification )
$link.css( 'display', 'block' );
$link.css( 'display', 'block' );
* Element bindings for Entries Single (Details) page.
initEntriesSingle: function() {
// Entry navigation hotkeys.
// We only want to listen on the applicable admin page.
if ( 'wpforms-entries' === WPFormsAdmin.getQueryString( 'page' ) && 'details' === WPFormsAdmin.getQueryString( 'view' ) ) {
WPFormsAdmin.entryHotkeys();
// Confirm entry deletion.
$( document ).on( 'click', '#wpforms-entries-single .wpforms-entry-delete a', function( event ) {
const url = $( this ).attr( 'href' );
// Trigger alert modal to confirm.
title: wpforms_admin.heads_up,
content: wpforms_admin.entry_delete_confirm,
icon: 'fa fa-exclamation-circle',
text: wpforms_admin.cancel,
$( document ).on( 'click', '#wpforms-entries-single .trash', function( event ) {
const url = $( this ).attr( 'href' );
// Trigger alert modal to confirm.
title: wpforms_admin.heads_up,
content: wpforms_admin.entry_trash_confirm,
icon: 'fa fa-exclamation-circle',
text: wpforms_admin.cancel,
// Open Print preview in new window.
$( document ).on( 'click', '#wpforms-entries-single .wpforms-entry-print a', function( event ) {
window.open( $( this ).attr( 'href' ) );
// Toggle displaying empty fields.
$( document ).on( 'click', '#wpforms-entries-single .wpforms-empty-field-toggle', function( event ) {
if ( wpCookies.get( 'wpforms_entry_hide_empty' ) === 'true' ) {
// User was hiding empty fields, so now display them.
wpCookies.remove( 'wpforms_entry_hide_empty' );
$( this ).text( wpforms_admin.entry_empty_fields_hide );
// User was seeing empty fields, so now hide them.
wpCookies.set( 'wpforms_entry_hide_empty', 'true', 2592000 ); // 1month.
$( this ).text( wpforms_admin.entry_empty_fields_show );
$( '.wpforms-entry-field.empty, .wpforms-edit-entry-field.empty' ).toggle();
$( document ).on( 'click', '#wpforms-entries-single .wpforms-entry-notes-new .add', function( event ) {
$( this ).hide().next( 'form' ).stop().slideToggle();
$( document ).on( 'click', '#wpforms-entries-single .wpforms-entry-notes-new .cancel', function( event ) {
$( this ).closest( 'form' ).stop().slideToggle();
$( '.wpforms-entry-notes-new .add' ).show();
$( document ).on( 'click', '#wpforms-entries-single .wpforms-entry-notes-byline .note-delete', function( event ) {
var url = $( this ).attr( 'href' );
// Trigger alert modal to confirm.
title: wpforms_admin.heads_up,
content: wpforms_admin.entry_note_delete_confirm,
icon: 'fa fa-exclamation-circle',
text: wpforms_admin.cancel,
//--------------------------------------------------------------------//
//--------------------------------------------------------------------//
* Hotkeys for Entries Single (Details) page.
* j triggers previous entry, k triggers next entry.
entryHotkeys: function() {
// eslint-disable-next-line complexity
$( document ).on( 'keydown', function( event ) {
if ( 74 === event.keyCode && ! event.metaKey && ! WPFormsAdmin.isFormTypeNode( event.target.nodeName ) ) {
// j key has been pressed outside a form element, go to the previous entry.
var prevEntry = $( '#wpforms-admin-single-navigation-prev-link' ).attr( 'href' );
if ( '#' !== prevEntry ) {
window.location.href = prevEntry;
} else if ( 75 === event.keyCode && ! event.metaKey && ! WPFormsAdmin.isFormTypeNode( event.target.nodeName ) ) {
// k key has been pressed outside a form element, go to the previous entry.
var nextEntry = $( '#wpforms-admin-single-navigation-next-link' ).attr( 'href' );
if ( '#' !== nextEntry ) {
window.location.href = nextEntry;
//--------------------------------------------------------------------//
//--------------------------------------------------------------------//
* Welcome activation page.
initWelcome: function() {
// Open modal and play How To video.
$( document ).on( 'click', '#wpforms-welcome .play-video', function( event ) {
var video = '<div class="video-container"><iframe width="1280" height="720" src="https://www.youtube-nocookie.com/embed/o2nE1P74WxQ?rel=0&showinfo=0&autoplay=1" frameborder="0" allowfullscreen></iframe></div>';
//--------------------------------------------------------------------//
//--------------------------------------------------------------------//
* Element bindings for Addons List page.
// Only run on the addons page.
if ( ! $( '#wpforms-admin-addons' ).length ) {
const $sectionAll = $( '#wpforms-addons-list-section-all' );
const $sectionInstalled = $( '#wpforms-addons-list-section-installed' );
if ( $sectionAll.length || $sectionInstalled.length ) {
let addonSearchInstalled;
if ( $sectionInstalled.length ) {
addonSearchInstalled = new List(
'wpforms-addons-list-section-installed',
valueNames: [ 'addon-link' ],
if ( $sectionAll.length ) {
addonSearchAll = new List(
'wpforms-addons-list-section-all',
valueNames: [ 'addon-link' ],
$( '#wpforms-addons-search' ).on(
WPFormsAdmin.updateAddonSearchResult( this, addonSearchAll, addonSearchInstalled );
// Toggle an addon state.
$( document ).on( 'change', '.wpforms-addons-list-item .wpforms-toggle-control input', function( event ) {
if ( $( this ).hasClass( 'disabled' ) ) {
WPFormsAdmin.addonToggleNew( $( this ) );
$( document ).on( 'click', '.wpforms-addons-list-item button', function( event ) {
if ( $( this ).hasClass( 'disabled' ) ) {
WPFormsAdmin.addonToggleNew( $( this ) );
$( document ).on( 'click', '#wpforms-admin-addons .addon-item button', function( event ) {
if ( $( this ).hasClass( 'disabled' ) ) {
WPFormsAdmin.addonToggle( $( this ) );
* Handle addons search field operations.
* @param {Object} searchField The search field html element.
* @param {Object} addonSearchAll Addons all list (uses List.js).
* @param {Object} addonSearchInstalled Addons installed list (uses List.js).
updateAddonSearchResult( searchField, addonSearchAll, addonSearchInstalled ) {
let searchTerm = $( searchField ).val();
* Replace dot and comma with space
* it is workaround for a bug in list.js library.
* Note: remove when the issue below is fixed:
* @see https://github.com/javve/list.js/issues/699
searchTerm = searchTerm.replace( /[.,]/g, ' ' );
const $noResultsMessage = $( '#wpforms-addons-no-results' );
const $sectionAll = $( '#wpforms-addons-list-section-all' );
const $sectionInstalled = $( '#wpforms-addons-list-section-installed' );
const searchResultsAll = addonSearchAll ? addonSearchAll.search( searchTerm ) : [];
const searchResultsInstalled = addonSearchInstalled ? addonSearchInstalled.search( searchTerm ) : [];
$noResultsMessage.toggle( searchResultsAll.length === 0 && searchResultsInstalled.length === 0 );
$sectionAll.toggle( searchResultsAll.length > 0 );
$sectionInstalled.toggle( searchResultsInstalled.length > 0 );
* Change plugin/addon state.
* @param {string} plugin Plugin slug or URL for download.
* @param {string} state State status activate|deactivate|install.
* @param {string} pluginType Plugin type addon or plugin.
* @param {Function} callback Callback for get result from AJAX.
* @param {Function} errorCallback Callback for get error from AJAX.
setAddonState( plugin, state, pluginType, callback, errorCallback ) {
activate: 'wpforms_activate_addon',
install: 'wpforms_install_addon',
deactivate: 'wpforms_deactivate_addon',
const action = actions[ state ];
nonce: wpforms_admin.nonce,
$.post( wpforms_admin.ajax_url, data, function( res ) {
} ).fail( function( xhr ) {
* @param {Object} $btn Button element.
// eslint-disable-next-line max-lines-per-function, complexity
const $footer = $btn.parents( '.wpforms-addons-list-item-footer' );