: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
/* global wpforms_admin, WPFormsFormTemplates, wpforms_admin_form_templates */
* Admin Sub-page Form Templates function.
var WPFormsAdminFormTemplates = window.WPFormsAdminFormTemplates || ( function( document, window, $ ) {
* Public functions and properties.
$( '.wpforms-form-setup-content' )
.on( 'keyup', '#wpforms-setup-template-search', _.debounce( WPFormsFormTemplates.searchTemplate, 200 ) )
.on( 'click', '.wpforms-setup-templates-categories li div', WPFormsFormTemplates.selectCategory )
.on( 'click', '.wpforms-setup-templates-categories li .chevron', WPFormsFormTemplates.toggleSubcategoriesList )
.on( 'click', '.wpforms-setup-templates-subcategories li', WPFormsFormTemplates.selectSubCategory )
.on( 'click', '.wpforms-template-select', app.selectTemplate )
.on( 'click', '.wpforms-trigger-blank', app.selectBlankTemplate );
* @param {Object} event Event object.
selectTemplate( event ) {
const $button = $( this );
const spinner = '<i class="wpforms-loading-spinner wpforms-loading-white wpforms-loading-inline"></i>';
// Don't do anything for templates that trigger education modal OR addons-modal.
if ( $button.hasClass( 'education-modal' ) ) {
// User templates are applied differently for new forms.
if ( $button.data( 'template' ).match( /wpforms-user-template-(\d+)/ ) && $button.data( 'create-url' ) ) {
window.location.href = $button.data( 'create-url' );
$( '.wpforms-form-setup-content' ).find( '.wpforms-template' ).removeClass( 'active' );
$button.closest( '.wpforms-template' ).addClass( 'active' );
$button.data( 'labelOriginal', $button.html() );
// Display loading indicator.
$button.html( spinner + wpforms_admin.loading );
WPFormsFormTemplates.selectTemplateProcess( $button.data( 'template-name-raw' ), $button.data( 'template' ), $button, app.selectTemplateProcessAjax );
* @param {object} e Event object.
selectBlankTemplate: function( e ) {
app.selectTemplateProcessAjax( 'Blank Form', 'blank' );
* Select template. Create or update form AJAX call.
* @param {string} formName Name of the form.
* @param {string} template Template slug.
selectTemplateProcessAjax( formName, template ) {
action: 'wpforms_new_form',
// eslint-disable-next-line camelcase
nonce: wpforms_admin_form_templates.nonce,
const category = $( '.wpforms-setup-templates-categories li.active' ).data( 'category' );
if ( category && category !== 'all' ) {
data.category = category;
const subcategory = $( '.wpforms-setup-templates-subcategories li.active' ).data( 'subcategory' );
data.subcategory = subcategory;
$.post( wpforms_admin.ajax_url, data )
window.location.href = res.data.redirect;
if ( res.data.error_type === 'invalid_template' ) {
app.selectTemplateProcessInvalidTemplateError( res.data.message, formName );
app.selectTemplateProcessError( res.data.message );
app.selectTemplateProcessError( '' );
* Select template AJAX call error modal for invalid template using.
* @param {string} errorMessage Error message.
* @param {string} formName Name of the form.
selectTemplateProcessInvalidTemplateError( errorMessage, formName ) {
title: wpforms_admin.heads_up,
icon: 'fa fa-exclamation-circle',
text: wpforms_admin.use_default_template,
app.selectTemplateProcessAjax( formName, 'simple-contact-form-template' );
text: wpforms_admin.cancel,
WPFormsFormTemplates.selectTemplateCancel();
* Select template AJAX call error modal.
* @since 1.8.8 Replaced error message with error title.
* @param {string} errorTitle Error title.
selectTemplateProcessError( errorTitle ) {
content: wpforms_admin.error_select_template,
icon: 'fa fa-exclamation-circle',
WPFormsFormTemplates.selectTemplateCancel();
// Provide access to public functions/properties.
}( document, window, jQuery ) );
WPFormsAdminFormTemplates.init();