: 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' ) ) {
$fs = freemius( $VARS['id'] );
$message_header = sprintf(
/* translators: %1$s: Number of trial days; %2$s: Plan name; */
fs_text_inline( 'You are 1-click away from starting your %1$s-day free trial of the %2$s plan.', 'start-trial-prompt-header', $slug ),
'<span class="var-trial_period"></span>',
'<span class="var-plan_title"></span>'
$message_content = sprintf(
/* translators: %s: Link to freemius.com */
fs_text_inline( 'For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt in with your user and non-sensitive site information, allowing the %s to periodically send data to %s to check for version updates and to validate your trial.', 'start-trial-prompt-message', $slug ),
'<a href="%s" target="_blank" rel="noopener">%s</a>',
$modal_content_html = <<< HTML
<div class="notice notice-error inline"><p></p></div>
<h3>{$message_header}</h3>
<p>{$message_content}</p>
fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
<script type="text/javascript">
$(document).ready(function () {
var modalContentHtml = <?php echo json_encode( $modal_content_html ); ?>,
'<div class="fs-modal fs-modal-license-key-resend">'
+ ' <div class="fs-modal-dialog">'
+ ' <div class="fs-modal-header">'
+ ' <h4><?php echo esc_js( fs_text_x_inline( 'Start free trial', 'call to action', 'start-free-trial', $slug ) ) ?></h4>'
+ ' <div class="fs-modal-body">' + modalContentHtml + '</div>'
+ ' <div class="fs-modal-footer">'
+ ' <button class="button button-secondary button-close">' + <?php fs_json_encode_echo_inline( 'Cancel', 'cancel', $slug ) ?> +'</button>'
+ ' <button class="button button-primary button-connect">' + <?php fs_json_encode_echo_inline( 'Approve & Start Trial', 'approve-start-trial', $slug ) ?> +'</button>'
$modal.appendTo($('body'));
var $errorNotice = $modal.find('.notice-error');
function registerEventHandlers() {
$modal.on('click', '.button-close', function () {
$modal.on('click', '.button-connect', function (evt) {
url : <?php echo Freemius::ajax_url() ?>,
action : '<?php echo $fs->get_ajax_action( 'start_trial' ) ?>',
security : '<?php echo $fs->get_ajax_security( 'start_trial' ) ?>',
module_id: '<?php echo $fs->get_id() ?>',
beforeSend: function () {
// Disable all buttons during trial activation.
$modal.find('.button').prop('disabled', true);
$button.text(<?php fs_json_encode_echo_inline( 'Starting trial', 'starting-trial', $slug ) ?> + '...');
success : function (resultObj) {
$button.text(<?php fs_json_encode_echo_inline( 'Please wait', 'please-wait', $slug ) ?> + '...');
// Redirect to the "Account" page and sync the license.
window.location.href = resultObj.data.next_page;
$button.text(<?php fs_json_encode_echo( 'approve-start-trial', $slug ) ?>);
showError(resultObj.error);
window.openTrialConfirmationModal = function showModal(data) {
// Display the dialog box.
$modal.addClass('active');
var $modalBody = $modal.find('.fs-modal-body'),
if (data.hasOwnProperty(key)) {
$var = $modalBody.find('.var-' + key);
$('body').addClass('has-fs-modal');
$modal.removeClass('active');
$('body').removeClass('has-fs-modal');
function setLoadingMode() {
// Re-enable all buttons.
.prop('disabled', trialData)
.css({'cursor': 'wait'});
$(document.body).css({'cursor': 'wait'});
function resetLoadingMode() {
// Re-enable all buttons.
.css({'cursor': 'initial'});
$(document.body).css({'cursor': 'initial'});
function showError(msg) {
$errorNotice.find(' > p').html(msg);