: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
add_action('wp_ajax_ampforwp_enable_modules_upgread', 'ampforwp_enable_modules_upgread');
function ampforwp_enable_modules_upgread(){
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
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( 'install_plugins' ) ) {
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
$redirectSettingsUrl = '';
$currentActivateModule = sanitize_text_field( wp_unslash($_REQUEST['activate']));
switch($currentActivateModule){
$nonceUrl = add_query_arg(
'plugin' => 'pwa-for-wp',
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'activate-plugin_pwa-for-wp' ),
esc_url(network_admin_url( 'plugins.php' ))
'path_' => 'https://downloads.wordpress.org/plugin/pwa-for-wp.zip',
'install' => 'pwa-for-wp/pwa-for-wp.php',
$redirectSettingsUrl = admin_url('admin.php?page=pwaforwp&reference=ampforwp');
$nonceUrl = add_query_arg(
'plugin' => 'schema-and-structured-data-for-wp',
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'schema-and-structured-data-for-wp' ),
network_admin_url( 'plugins.php' )
'name' => 'schema-and-structured-data-for-wp',
'path_' => 'https://downloads.wordpress.org/plugin/schema-and-structured-data-for-wp.zip',
'plugin' => 'schema-and-structured-data-for-wp',
'plugin_status' => 'all',
'install' => 'schema-and-structured-data-for-wp/structured-data-for-wp.php',
$redirectSettingsUrl = admin_url('admin.php?page=structured_data_options&tab=general&reference=ampforwp');
$nonceUrl = add_query_arg(
'plugin' => 'ads-for-wp',
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'ads-for-wp' ),
network_admin_url( 'plugins.php' )
'path_' => 'https://downloads.wordpress.org/plugin/ads-for-wp.zip',
'plugin' => 'ads-for-wp',
'plugin_status' => 'all',
'install' => 'ads-for-wp/ads-for-wp.php',
$redirectSettingsUrl = admin_url('edit.php?post_type=adsforwp');
$nonceUrl = add_query_arg(
'plugin' => 'quick-adsense-reloaded',
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'activate-plugin_quick-adsense-reloaded' ),
esc_url(network_admin_url( 'plugins.php' ))
'name' => 'quick-adsense-reloaded',
'path_' => 'https://downloads.wordpress.org/plugin/quick-adsense-reloaded.zip',
'install' => 'quick-adsense-reloaded/quick-adsense-reloaded.php',
$redirectSettingsUrl = admin_url('admin.php?page=quads-settings');
$nonceUrl = add_query_arg(
'plugin' => 'core-web-vitals-pagespeed-booster',
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'core-web-vitals-pagespeed-booster' ),
esc_url(network_admin_url( 'plugins.php' ))
'name' => 'core-web-vitals-pagespeed-booster',
'path_' => 'https://downloads.wordpress.org/plugin/core-web-vitals-pagespeed-booster.zip',
'install' => 'core-web-vitals-pagespeed-booster/core-web-vitals-pagespeed-booster.php',
$redirectSettingsUrl = admin_url('admin.php?page=cwvpsb');
echo wp_json_encode( array( "status"=>200, "message"=>esc_html__("Module successfully Added",'accelerated-mobile-pages'),'redirect_url'=>esc_url($redirectSettingsUrl) , "slug"=>$plugins[0]['name'], 'path'=> $plugins[0]['path'] ) );
echo wp_json_encode(array("status"=>300, "message"=>esc_html__("Modules not Found",'accelerated-mobile-pages')));
function ampforwp_admin_notice_module_reference_install() {
// Exit if the user does not have proper permissions
if(! current_user_can( 'manage_options' )) {
$reference = isset($_GET['reference']) ? sanitize_text_field( wp_unslash($_GET['reference'])) : '';
$page = isset($_GET['page']) ? sanitize_text_field( wp_unslash($_GET['page'])) : '';
if($reference=='ampforwp'){
$message = 'AMPforWP PWA Module has been activated. You may configure it below:';
case 'structured_data_options':
$message = 'AMPforWP Structured data Module has been Upgraded. You may configure it below:';
$message = 'AMPforWP AdsforWP Module has been Upgraded. You may configure it below:';
<div class="notice notice-success is-dismissible">
<p><?php echo esc_html( $message, 'accelerated-mobile-pages' ); ?></p>
add_action( 'admin_notices', 'ampforwp_admin_notice_module_reference_install' );
* Finish setup and Import default settings
add_action('wp_ajax_ampforwp_import_modules_scema', 'ampforwp_import_structure_data');
function ampforwp_import_structure_data(){
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
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( 'install_plugins' ) ) {
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
global $redux_builder_amp;
if(get_option('ampforwp_structure_data_module_upgrade')=='migrated'){
$sd_data_update = array();
$sd_data_update['sd-data-logo-ampforwp'] = $redux_builder_amp['amp-structured-data-logo'];
$sd_data_update['saswp-logo-width'] = $redux_builder_amp['ampforwp-sd-logo-width'];
$sd_data_update['saswp-logo-height'] = $redux_builder_amp['ampforwp-sd-logo-height'];
$sd_data_update['saswp-logo-dimensions'] = ($redux_builder_amp['ampforwp-sd-logo-width'] && $redux_builder_amp['ampforwp-sd-logo-height']) ? 1: 0;
$sd_data_update['sd_default_image'] = $redux_builder_amp['amp-structured-data-placeholder-image'];
$sd_data_update['sd_default_image_width'] = $redux_builder_amp['amp-structured-data-placeholder-image-width'];
$sd_data_update['sd_default_image_height'] = $redux_builder_amp['amp-structured-data-placeholder-image-height'];
$sd_data_update['sd_default_video_thumbnail'] = $redux_builder_amp['amporwp-structured-data-video-thumb-url'];
$sd_data_update['saswp-for-amp'] = 1;
$sd_data_update['saswp-for-wordpress'] = 0;
$ampforwp_sd_type_posts = $redux_builder_amp['ampforwp-sd-type-posts'];
$ampforwp_sd_type_pages = $redux_builder_amp['ampforwp-sd-type-pages'];
'post_title'=>'Page (Migrated from AMPforWP)',
'post_status'=>'publish',
$insertedPageId = wp_insert_post( $postarr );
$post_data_array = array(
if(defined('SASWP_VERSION') && version_compare(SASWP_VERSION,'1.0.2', '>=')){
$post_data_array = array();
$post_data_array['group-0'] =array(
$schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
update_post_meta( $insertedPageId, 'data_group_array', $post_data_array);
update_post_meta( $insertedPageId, 'schema_type', $ampforwp_sd_type_pages);
update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
'post_title'=>'Post (Migrated from AMPforWP)',
'post_status'=>'publish',
$insertedPageId = wp_insert_post( $postarr );
$post_data_array = array(
if(defined('SASWP_VERSION') && version_compare(SASWP_VERSION,'1.0.2', '>=')){
$post_data_array = array();
$post_data_array['group-0'] =array(
$schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
update_post_meta( $insertedPageId, 'data_group_array', $post_data_array);
update_post_meta( $insertedPageId, 'schema_type', $ampforwp_sd_type_posts);
update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
update_option('sd_data', $sd_data_update);
update_option('ampforwp_structure_data_module_upgrade','migrated', false);
add_action('wp_ajax_ampforwp_import_modules_ads', 'ampforwp_import_ads_data');
function ampforwp_import_ads_data(){
global $redux_builder_amp;
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
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( 'install_plugins' ) ) {
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
$adsforwp_object = new adsforwp_admin_common_functions();
$result = $adsforwp_object->adsforwp_migrate_ampforwp_ads();
$result = array_filter($result);
echo wp_json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','accelerated-mobile-pages')));
echo wp_json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','accelerated-mobile-pages')));