: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @copyright Copyright (c) 2015, Freemius, Inc.
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
if ( ! defined( 'ABSPATH' ) ) {
$plugin_id = $VARS['target_module_id'];
$fs = freemius( $VARS['id'] );
$action = $fs->is_tracking_allowed() ?
$title = $fs->get_plugin_title();
if ( $plugin_id != $fs->get_id() ) {
$addon = $fs->get_addon( $plugin_id );
if ( is_object( $addon ) ) {
$title = $addon->title . ' ' . fs_text_inline( 'Add-On', 'addon', $slug );
$countdown_html = sprintf(
/* translators: %s: Number of seconds */
fs_text_inline( '%s sec', 'x-sec', $slug )
sprintf( '<span class="fs-countdown">%s</span>', $sec_countdown )
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
$loader_html = fs_get_template( 'ajax-loader.php', $params );
// Pass unique auto installation URL if WP_Filesystem is needed.
$install_url = $fs->_get_sync_license_url(
array( 'auto_install' => 'true' )
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
$credentials = request_filesystem_credentials(
esc_url_raw( $install_url ),
$credentials_form = ob_get_clean();
$require_credentials = ! empty( $credentials_form );
<div class="fs-modal fs-modal-auto-install">
<div class="fs-modal-dialog">
<div class="fs-modal-header">
<h4><?php echo esc_js( fs_text_inline( 'Automatic Installation', 'auto-installation', $slug ) ) ?></h4>
<div class="fs-modal-body">
<div class="fs-notice-error" style="display: none"><p></p></div>
<?php if ( $require_credentials ) : ?>
<div id="request-filesystem-credentials-dialog">
<?php echo $credentials_form ?>
<p class="fs-installation-notice"><?php echo sprintf(
fs_esc_html_inline( 'An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now.', 'installing-in-n', $slug ),
'<a href="%s" target="_blank" rel="noopener">%s</a>',
style="display: none"><?php echo sprintf( fs_esc_html_inline( 'The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page.', 'installing-module-x', $slug ), $plugin_title ) ?></p>
<div class="fs-modal-footer">
<?php echo $loader_html ?>
class="button button-secondary button-cancel"><?php fs_esc_html_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?><?php if ( ! $require_credentials ) : ?> (<?php echo $countdown_html ?>)<?php endif ?></button>
class="button button-primary"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></button>
<script type="text/javascript">
$(document).ready(function () {
var $modal = $('.fs-modal-auto-install'),
$countdown = $modal.find('.fs-countdown'),
requireCredentials = <?php echo json_encode( $require_credentials ) ?>,
$credentialsForm = $('#request-filesystem-credentials-dialog'),
$errorNotice = $modal.find('.fs-notice-error'),
var startAutoInstall = function () {
$modal.addClass('fs-warn');
if (requireCredentials) {
$modal.find('.fs-installation-notice').hide();
$modal.find('.fs-installing').show();
$modal.find('button').hide();
$modal.find('.fs-ajax-loader').show();
action : '<?php echo $fs->get_ajax_action( 'install_premium_version' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'install_premium_version' ) ?>',
slug : '<?php echo $slug ?>',
module_id : '<?php echo $fs->get_id() ?>',
target_module_id: '<?php echo $plugin_id ?>'
if (requireCredentials) {
// Add filesystem credentials.
data.hostname = $('#hostname').val();
data.username = $('#username').val();
data.password = $('#password').val();
data.connection_type = $('input[name="connection_type"]:checked').val();
data.public_key = $('#public_key').val();
data.private_key = $('#private_key').val();
url : <?php echo Freemius::ajax_url() ?>,
success: function (resultObj) {
var reloadAccount = false;
// Reload account page to show new data.
switch (resultObj.error.code) {
case 'invalid_module_id':
case 'premium_installed':
case 'premium_version_missing':
case 'unable_to_connect_to_filesystem':
$modal.removeClass('fs-warn');
$modal.find('.fs-installing').hide();
$modal.find('.fs-ajax-loader').hide();
$modal.find('.button-cancel').html(<?php fs_json_encode_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?>);
$modal.find('button').show();
$errorNotice.find('p').text(resultObj.error.message);
$errorNotice.addClass('notice notice-alt notice-error').show();
if (requireCredentials) {
window.location = '<?php echo $fs->get_account_url() ?>';
var clearCountdown = function () {
clearInterval(countdownInterval);
countdownInterval = null;
var cancelAutoInstall = function () {
$modal.fadeOut(function () {
$body.removeClass('has-fs-modal');
var countdown = <?php echo $sec_countdown ?>,
countdownInterval = requireCredentials ? null : setInterval(function () {
$countdown.html(--countdown);
$modal.addClass('active');
$body.addClass('has-fs-modal');
$modal.find('.button-primary').click(function () {
$modal.find('.button-cancel').click(function () {
if (requireCredentials) {