: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
/* global wpforms_pluginlanding, wpforms_admin */
var WPFormsPagesAnalytics = window.WPFormsPagesAnalytics || ( function( document, window, $ ) {
* Public functions and properties.
$stepInstall: $( 'section.step-install' ),
$stepInstallNum: $( 'section.step-install .num img' ),
$stepSetup: $( 'section.step-setup' ),
$stepSetupNum: $( 'section.step-setup .num img' ),
$stepAddon: $( 'section.step-addon' ),
$stepAddonNum: $( 'section.step-addon .num img' ),
// Step 'Install' button click.
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
// Step 'Setup' button click.
el.$stepSetup.on( 'click', 'button', app.gotoURL );
// Step 'Addon' button click.
el.$stepAddon.on( 'click', 'button', app.gotoURL );
* Step 'Install' button click.
stepInstallClick: function() {
action = $btn.attr( 'data-action' ),
plugin = $btn.attr( 'data-plugin' ),
if ( $btn.hasClass( 'disabled' ) ) {
ajaxAction = 'wpforms_activate_addon';
$btn.text( wpforms_pluginlanding.activating );
ajaxAction = 'wpforms_install_addon';
$btn.text( wpforms_pluginlanding.installing );
window.location.href = $btn.attr( 'data-url' );
$btn.addClass( 'disabled' );
app.showSpinner( el.$stepInstallNum );
nonce : wpforms_admin.nonce,
$.post( wpforms_admin.ajax_url, data )
app.stepInstallDone( res, $btn, action );
app.hideSpinner( el.$stepInstallNum );
* Done part of the step 'Install'.
* @param {object} res Result of $.post() query.
* @param {jQuery} $btn Button.
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
stepInstallDone: function( res, $btn, action ) {
var success = 'install' === action ? res.success && res.data.is_activated : res.success;
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
app.stepInstallPluginStatus();
var activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
url = ! activationFail ? wpforms_pluginlanding.mi_manual_install_url : wpforms_pluginlanding.mi_manual_activate_url,
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
$btn.after( '<p class="error">' + msg + '</p>' );
* Callback for step 'Install' completion.
stepInstallPluginStatus: function() {
action: 'wpforms_analytics_page_check_plugin_status',
nonce : wpforms_admin.nonce,
$.post( wpforms_admin.ajax_url, data ).done( app.stepInstallPluginStatusDone );
* Done part of the callback for step 'Install' completion.
* @param {object} res Result of $.post() query.
stepInstallPluginStatusDone: function( res ) {
el.$stepSetup.removeClass( 'grey' );
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
if ( res.data.setup_status > 0 ) {
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
el.$stepAddon.removeClass( 'grey' );
el.$stepAddon.find( 'button' ).attr( 'data-url', res.data.step3_button_url ).removeClass( 'grey disabled' ).addClass( 'button-primary' );
if ( res.data.license_level === 'pro' ) {
var buttonText = res.data.addon_installed > 0 ? wpforms_pluginlanding.activate_now : wpforms_pluginlanding.install_now;
el.$stepAddon.find( 'button' ).text( buttonText );
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
* Go to URL by click on the button.
if ( $btn.hasClass( 'disabled' ) ) {
window.location.href = $btn.attr( 'data-url' );
* @param {jQuery} $el Section number image jQuery object.
showSpinner: function( $el ) {
$el.siblings( '.loader' ).removeClass( 'hidden' );
* @param {jQuery} $el Section number image jQuery object.
hideSpinner: function( $el ) {
$el.siblings( '.loader' ).addClass( 'hidden' );
// Provide access to public functions/properties.
}( document, window, jQuery ) );
WPFormsPagesAnalytics.init();