: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
* Dual licensed under the MIT and GPL licenses:
* copyright Copyright (c) 2017, Merlin WP of Inventionn LLC
* http://www.opensource.org/licenses/mit-license.php
* Licensed GPLv3 for open source use
* Thanks to Merlin WP Team, Richard Tabor, from ThemeBeans.com for some excellent contributions!
* Better WordPress Theme Onboarding
* The following code is a derivative work from the
* Envato WordPress Theme Setup Wizard by David Baker.
* @link https://merlinwp.com/
* @author Richard Tabor, from ThemeBeans.com
* @copyright Copyright (c) 2017, Merlin WP of Inventionn LLC
* @license Licensed GPLv3 for open source use
$redux_builder_amp = (array) get_option('redux_builder_amp');
if(isset($redux_builder_amp['opt-media']['url']) && $redux_builder_amp['opt-media']['url']!=""){
$ampLogo = '<br/><br/><img src="'.esc_url($redux_builder_amp['opt-media']['url']).'" class="amp_install_logo_preview" />';
$ampforwp_install_config = array(
'installer_dir' => 'install',
'plugin_title' => ucfirst( 'AMPforWP Installer' ),
'installerpage' => 'ampforwptourinstaller',
'title'=> esc_html__('Welcome','accelerated-mobile-pages'),
'description'=>esc_html__('Welcome','This wizard will set up AMP on your website, install plugin, and import content. It is optional & should take only a few minutes.','accelerated-mobile-pages'),
'title'=>esc_html__('Upload Logo','accelerated-mobile-pages'),
'description'=>esc_html__('Recommend logo size is: 190x36','accelerated-mobile-pages'),
'fields'=>'<li class="amp_install_center">
<input type="hidden" value="" class="regular-text process_custom_images" id="process_custom_images" name="opt-media" value="">
<button type="button" class="set_custom_images merlin__button merlin__button--blue">Set Logo</button>
'title'=>esc_html__('Select Pages','accelerated-mobile-pages'),
'description'=>esc_html__('Where you would like to enable AMP.','accelerated-mobile-pages'),
'fields'=>'<li class="merlin__drawer--import-content__list-item status status--pending">
<input type="checkbox" class="checkbox" name="amp-on-off-for-all-posts" id="amp-on-posts" '.(ampforwp_get_setting('amp-on-off-for-all-posts')? 'checked': '').'>
<label for="amp-on-posts">
<i></i><span>Posts</span></label>
<li class="merlin__drawer--import-content__list-item status">
<input type="checkbox" name="amp-on-off-for-all-pages" class="checkbox" id="amp-on-pages" value="1" '.(ampforwp_get_setting('amp-on-off-for-all-pages')? 'checked': '').'>
<label for="amp-on-pages">
<i></i><span>Pages</span></label>
<li class="merlin__drawer--import-content__list-item status">
<input type="checkbox" name="ampforwp-homepage-on-off-support" class="checkbox" id="amp-on-home" value="1" '.(ampforwp_get_setting('ampforwp-homepage-on-off-support')? 'checked': '').'>
<label for="amp-on-home">
<i></i><span>Homepage</span></label>
<li class="merlin__drawer--import-content__list-item status">
<input type="checkbox" name="ampforwp-archive-support" class="checkbox" id="ampforwp-archive-support" value="1" '.(ampforwp_get_setting('ampforwp-archive-support')? 'checked': '').'>
<label for="ampforwp-archive-support">
<i></i><span>Category & Tags</span></label>
'title'=>esc_html__('Setup Analytics','accelerated-mobile-pages'),
'description'=>esc_html__('Enter your Google Analytics Tracking code','accelerated-mobile-pages'),
'fields'=>'<li class="amp_install_center">
<input type="hidden" name="amp-analytics-select-option" value="1">
<input type="text" name="ga-feild" id="ga-feild" value="'.(ampforwp_get_setting('ga-feild')? $redux_builder_amp['ga-feild'] : '').'">
<label for="ga-feild"></label>
'title'=>esc_html__('Select Design','accelerated-mobile-pages'),
'fields'=>'<li class="amp_install_center"><select name="amp-design-selector" id="ampforwp-design-select">
<option value="1" '.(ampforwp_get_setting('amp-design-selector')==1? 'selected' : '').'>Design One</option>
<option value="2" '.(ampforwp_get_setting('amp-design-selector')==2? 'selected' : '').'>Design Two</option>
<option value="3" '.(ampforwp_get_setting('amp-design-selector')==3? 'selected' : '').'>Design Three</option>
<option value="4" '.(ampforwp_get_setting('amp-design-selector')==4? 'selected' : '').'>Swift</option>
<img src="'.AMPFORWP_PLUGIN_DIR_URI.'/images/design-1.png" width="150" height="200" class="amp_install_theme_preview" id="design-1" style="'.(ampforwp_get_setting('amp-design-selector')==1 ? '': 'display:none' ).'">
<img src="'.AMPFORWP_PLUGIN_DIR_URI.'/images/design-2.png" width="150" height="200" class="amp_install_theme_preview" id="design-2" style="'.(ampforwp_get_setting('amp-design-selector')==2 ? '': 'display:none' ).'">
<img src="'.AMPFORWP_PLUGIN_DIR_URI.'/images/design-3.png" width="150" height="200" class="amp_install_theme_preview" id="design-3" style="'.(ampforwp_get_setting('amp-design-selector')==3 ? '': 'display:none' ).'">
<img src="'.AMPFORWP_PLUGIN_DIR_URI.'/images/swift.png" width="150" height="200" class="amp_install_theme_preview" id="design-4" style="'.(ampforwp_get_setting('amp-design-selector')==4 ? '': 'display:none' ).'">
'title'=>esc_html__('Enjoy','accelerated-mobile-pages'),
'description'=>esc_html__('Navigate to ','accelerated-mobile-pages'),
add_action( 'admin_menu', 'ampforwp_add_admin_menu' );
add_action( 'admin_init', 'ampforwp_installer_init');
add_action( 'admin_footer', 'ampforwp_svg_sprite');
add_action( 'wp_ajax_ampforwp_save_installer', 'ampforwp_save_steps_data', 10, 0 );
function ampforwp_add_admin_menu(){
global $ampforwp_install_config;
ampforwp_installer_init();
function ampforwp_installer_init(){
// Exit if the user does not have proper permissions
if(! current_user_can( 'manage_options' ) ) {
global $ampforwp_install_config;
ampforwp_instller_admin_init();
function ampforwp_instller_admin_init(){
if(isset($_GET['ampforwp_install'], $_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], '_wpnonce') && $_GET['ampforwp_install']=='1'){
function ampforwp_steps_call(){
global $ampforwp_install_config;
if ( !wp_verify_nonce($_GET['_wpnonce'], '_wpnonce') || empty( $_GET['page'] ) || $ampforwp_install_config['installerpage'] !== $_GET['page'] ) {
$step = isset( $_GET['step'] ) ? sanitize_text_field( wp_unslash(sanitize_key( $_GET['step'] ) ) ) : $ampforwp_install_config['start_steps'] ;
$title = $ampforwp_install_config['steps'][$step]['title'];
$ampforwp_install_config['current_step']['step_id'] = $step;
// Use minified libraries if dev mode is turned on.
wp_enqueue_style( 'ampforwp_install', esc_url(AMPFORWP_PLUGIN_DIR_URI. $ampforwp_install_config['installer_dir']. '/assets/css/merlin' . $suffix . '.css') , array( 'wp-admin' ), '0.1');
wp_enqueue_script( 'ampforwp_install', esc_url(AMPFORWP_PLUGIN_DIR_URI. $ampforwp_install_config['installer_dir']. '/assets/js/merlin' . $suffix . '.js') , array( 'jquery-core' ), '0.1' );
wp_localize_script( 'ampforwp_install', 'ampforwp_install_params', array(
'ajaxurl' => esc_url(admin_url( 'admin-ajax.php' )),
'wpnonce' => wp_create_nonce( 'ampforwp_install_nonce' ),
'pluginurl' => esc_url(AMPFORWP_PLUGIN_DIR_URI),
ampforwp_install_header(); ?>
<div class="merlin__wrapper">
<div class="amp_install_wizard"><?php echo esc_html__('AMP Installation Wizard','accelerated-mobile-pages'); ?></div>
<div class="merlin__content merlin__content--<?php echo esc_attr( strtolower( $title ) ); ?>">
ampforwp_show_steps_body();
<?php step_output_bottom_dots(); ?>
<?php echo sprintf( '<a class="return-to-dashboard" href="%s">%s</a>', esc_url( admin_url( 'admin.php?page=amp_options' ) ), esc_html__( 'Return to dashboard','accelerated-mobile-pages' ) ); ?>
<?php ampforwp_install_footer();
function ampforwp_show_steps_body(){
global $ampforwp_install_config;
if($ampforwp_install_config['total_steps']==$ampforwp_install_config['current_step']['step_id']){
call_user_func('ampforwp_finish_page');
if(function_exists('step'.$ampforwp_install_config['current_step']['step_id'])){
call_user_func('step'.$ampforwp_install_config['current_step']['step_id']);
call_user_func('ampforwp_finish_page');
global $ampforwp_install_config;
$stepDetails = $ampforwp_install_config['steps'][$ampforwp_install_config['current_step']['step_id']];
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<svg class="icon icon--checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="icon--checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="icon--checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
<h1><?php echo esc_html__($stepDetails['title'],'accelerated-mobile-pages'); ?></h1>
<p><?php echo esc_html__( 'This Installation Wizard helps you to setup the necessary options for AMP. It is optional & should take only a few minutes.' ,'accelerated-mobile-pages'); ?></p>
<footer class="merlin__content__footer">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=amp_options' ) ); ?>" class="merlin__button merlin__button--skip"><?php echo esc_html__( 'Cancel','accelerated-mobile-pages' ); ?></a>
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--next merlin__button--proceed merlin__button--colorchange"><?php echo esc_html__( 'Start','accelerated-mobile-pages' ); ?></a>
<?php wp_nonce_field( 'ampforwp_install_nonce' ); ?>
global $ampforwp_install_config;
$stepDetails = $ampforwp_install_config['steps'][$ampforwp_install_config['current_step']['step_id']];
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<svg class="icon icon--checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="icon--checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="icon--checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
<h1><?php echo esc_html__($stepDetails['title'],'accelerated-mobile-pages'); ?></h1>
<p><?php echo isset($stepDetails['description'])? esc_html__($stepDetails['description'],'accelerated-mobile-pages') : ''; ?></p>
<form action="" method="post">
<ul class="merlin__drawer--import-content">
echo $stepDetails['fields']; // escaped above
<footer class="merlin__content__footer">
<?php ampforwp_skip_button(); ?>
<a id="skip" href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--skip merlin__button--proceed"><?php echo esc_html__( 'Skip','accelerated-mobile-pages' ); ?></a>
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--next button-next" data-callback="save_logo">
<span class="merlin__button--loading__text"><?php echo esc_html__( 'Save' ,'accelerated-mobile-pages'); ?></span><?php echo ampforwp_loading_spinner(); ?>
<?php wp_nonce_field( 'ampforwp_install_nonce' ); ?>
global $ampforwp_install_config;
$stepDetails = $ampforwp_install_config['steps'][$ampforwp_install_config['current_step']['step_id']];
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<svg class="icon icon--checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="icon--checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="icon--checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
<h1><?php echo esc_html__($stepDetails['title'],'accelerated-mobile-pages'); ?></h1>
<p><?php echo isset($stepDetails['description'])? esc_html__($stepDetails['description'],'accelerated-mobile-pages') : ''; ?></p>
<form action="" method="post">
<ul class="merlin__drawer--import-content">
echo $stepDetails['fields']; // escaped above
<footer class="merlin__content__footer">
<?php ampforwp_skip_button(); ?>
<a id="skip" href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--skip merlin__button--proceed"><?php echo esc_html__( 'Skip','accelerated-mobile-pages' ); ?></a>
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--next button-next" data-callback="save_logo">
<span class="merlin__button--loading__text"><?php echo esc_html__( 'Save','accelerated-mobile-pages' ); ?></span><?php echo ampforwp_loading_spinner(); ?>
<?php wp_nonce_field( 'ampforwp_install_nonce' ); ?>
global $ampforwp_install_config;
$stepDetails = $ampforwp_install_config['steps'][$ampforwp_install_config['current_step']['step_id']];
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<svg class="icon icon--checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="icon--checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="icon--checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
<h1><?php echo esc_html__($stepDetails['title'],'accelerated-mobile-pages'); ?></h1>
<p><?php echo isset($stepDetails['description'])? esc_html__($stepDetails['description'],'accelerated-mobile-pages') : ''; ?></p>
<form action="" method="post">
<ul class="merlin__drawer--import-content">
echo $stepDetails['fields']; // escaped above
<footer class="merlin__content__footer">
<?php ampforwp_skip_button(); ?>
<a id="skip" href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--skip merlin__button--proceed"><?php echo esc_html__( 'Skip','accelerated-mobile-pages' ); ?></a>
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--next button-next" data-callback="save_logo">
<span class="merlin__button--loading__text"><?php echo esc_html__( 'Save','accelerated-mobile-pages' ); ?></span><?php echo ampforwp_loading_spinner(); ?>
<?php wp_nonce_field( 'ampforwp_install_nonce' ); ?>
global $ampforwp_install_config;
$stepDetails = $ampforwp_install_config['steps'][$ampforwp_install_config['current_step']['step_id']];
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<svg class="icon icon--checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="icon--checkmark__circle" cx="26" cy="26" r="25" fill="none"/><path class="icon--checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
<h1><?php echo esc_html__($stepDetails['title'],'accelerated-mobile-pages'); ?></h1>
<p><?php echo isset($stepDetails['description'])? esc_html__($stepDetails['description'],'accelerated-mobile-pages') : ''; ?></p>
<form action="" method="post">
<ul class="merlin__drawer--import-content">
echo $stepDetails['fields']; // escaped above
<footer class="merlin__content__footer">
<?php ampforwp_skip_button(); ?>
<a id="skip" href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--skip merlin__button--proceed"><?php echo esc_html__( 'Skip','accelerated-mobile-pages' ); ?></a>
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--next button-next" data-callback="save_logo">
<span class="merlin__button--loading__text"><?php echo esc_html__( 'Save','accelerated-mobile-pages' ); ?></span><?php echo ampforwp_loading_spinner(); ?>
<?php wp_nonce_field( 'ampforwp_install_nonce' ); ?>
function ampforwp_save_steps_data(){
if(!wp_verify_nonce( $_REQUEST['wpnonce'], 'ampforwp_install_nonce' ) ) {
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
// Exit if the user does not have proper permissions
if(! current_user_can( 'manage_options' ) ) {
$redux_builder_amp = get_option('redux_builder_amp');
if($redux_builder_amp!=''){
foreach($_POST as $postKey=>$postValue){
if($postKey=='opt-media' && $postValue!=""){
$postValue = json_decode(stripcslashes($postValue),true);
$redux_builder_amp[$postKey] = sanitize_text_field($postValue);
}elseif(isset($redux_builder_amp[$postKey]) && $postValue!=""){
$redux_builder_amp[$postKey] = sanitize_text_field($postValue);
update_option('redux_builder_amp',$redux_builder_amp);
'message' => "Stored Successfully",
function ampforwp_skip_button(){
<a href="<?php echo esc_url( ampforwp_step_next_link() ); ?>" class="merlin__button merlin__button--skip"><?php echo esc_html__( 'Skip','accelerated-mobile-pages' ); ?></a>
function ampforwp_finish_page() {
global $ampforwp_install_config;
$plugin_title = $ampforwp_install_config['plugin_title'];
// Strings passed in from the config file.
$allowed_html_array = array(
update_option( 'ampforwp_installer_completed', time() ); ?>
<div class="merlin__content--transition">
<div class="amp_branding"></div>
<h1><?php echo esc_html__( 'Setup Done. Have fun!','accelerated-mobile-pages' ); ?></h1>
<p><?php echo wp_kses( 'Basic Setup has been done. Navigate to AMP options panel to access all the options.','ampforwp_install' ); ?></p>
<footer class="merlin__content__footer merlin__content__footer--fullwidth">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=amp_options' ) ); ?>" class="merlin__button merlin__button--blue merlin__button--fullwidth merlin__button--popin"><?php echo esc_html__( 'Let\'s Go','accelerated-mobile-pages' ); ?></a>
<ul class="merlin__drawer merlin__drawer--extras">
<li><?php //echo wp_kses( $link_1, $allowed_html_array ); ?></li>
<li><?php //echo wp_kses( $link_2, $allowed_html_array ); ?></li>
<li><?php //echo wp_kses( $link_3, $allowed_html_array ); ?></li>