Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../includes
File: modules-upgrade.php
<?php
[0] Fix | Delete
// Exit if accessed directly.
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) exit;
[2] Fix | Delete
add_action('wp_ajax_ampforwp_enable_modules_upgread', 'ampforwp_enable_modules_upgread');
[3] Fix | Delete
function ampforwp_enable_modules_upgread(){
[4] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
[5] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[6] Fix | Delete
exit();
[7] Fix | Delete
}
[8] Fix | Delete
// Exit if the user does not have proper permissions
[9] Fix | Delete
if(! current_user_can( 'install_plugins' ) ) {
[10] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
[11] Fix | Delete
exit();
[12] Fix | Delete
}
[13] Fix | Delete
$plugins = array();
[14] Fix | Delete
$redirectSettingsUrl = '';
[15] Fix | Delete
$currentActivateModule = sanitize_text_field( wp_unslash($_REQUEST['activate']));
[16] Fix | Delete
switch($currentActivateModule){
[17] Fix | Delete
case 'pwa':
[18] Fix | Delete
$nonceUrl = add_query_arg(
[19] Fix | Delete
array(
[20] Fix | Delete
'action' => 'activate',
[21] Fix | Delete
'plugin' => 'pwa-for-wp',
[22] Fix | Delete
'plugin_status' => 'all',
[23] Fix | Delete
'paged' => '1',
[24] Fix | Delete
'_wpnonce' => wp_create_nonce( 'activate-plugin_pwa-for-wp' ),
[25] Fix | Delete
),
[26] Fix | Delete
esc_url(network_admin_url( 'plugins.php' ))
[27] Fix | Delete
);
[28] Fix | Delete
$plugins[] = array(
[29] Fix | Delete
'name' => 'pwa-for-wp',
[30] Fix | Delete
'path_' => 'https://downloads.wordpress.org/plugin/pwa-for-wp.zip',
[31] Fix | Delete
'path' => $nonceUrl,
[32] Fix | Delete
'install' => 'pwa-for-wp/pwa-for-wp.php',
[33] Fix | Delete
);
[34] Fix | Delete
$redirectSettingsUrl = admin_url('admin.php?page=pwaforwp&reference=ampforwp');
[35] Fix | Delete
break;
[36] Fix | Delete
case 'structure_data':
[37] Fix | Delete
$nonceUrl = add_query_arg(
[38] Fix | Delete
array(
[39] Fix | Delete
'action' => 'activate',
[40] Fix | Delete
'plugin' => 'schema-and-structured-data-for-wp',
[41] Fix | Delete
'plugin_status' => 'all',
[42] Fix | Delete
'paged' => '1',
[43] Fix | Delete
'_wpnonce' => wp_create_nonce( 'schema-and-structured-data-for-wp' ),
[44] Fix | Delete
),
[45] Fix | Delete
network_admin_url( 'plugins.php' )
[46] Fix | Delete
);
[47] Fix | Delete
$plugins[] = array(
[48] Fix | Delete
'name' => 'schema-and-structured-data-for-wp',
[49] Fix | Delete
'path_' => 'https://downloads.wordpress.org/plugin/schema-and-structured-data-for-wp.zip',
[50] Fix | Delete
'path' => add_query_arg(
[51] Fix | Delete
array(
[52] Fix | Delete
'action' => 'activate',
[53] Fix | Delete
'plugin' => 'schema-and-structured-data-for-wp',
[54] Fix | Delete
'plugin_status' => 'all',
[55] Fix | Delete
'paged' => '1',
[56] Fix | Delete
'_wpnonce' => $nonceUrl,
[57] Fix | Delete
)
[58] Fix | Delete
),
[59] Fix | Delete
'install' => 'schema-and-structured-data-for-wp/structured-data-for-wp.php',
[60] Fix | Delete
);
[61] Fix | Delete
$redirectSettingsUrl = admin_url('admin.php?page=structured_data_options&tab=general&reference=ampforwp');
[62] Fix | Delete
break;
[63] Fix | Delete
case 'adsforwp':
[64] Fix | Delete
$nonceUrl = add_query_arg(
[65] Fix | Delete
array(
[66] Fix | Delete
'action' => 'activate',
[67] Fix | Delete
'plugin' => 'ads-for-wp',
[68] Fix | Delete
'plugin_status' => 'all',
[69] Fix | Delete
'paged' => '1',
[70] Fix | Delete
'_wpnonce' => wp_create_nonce( 'ads-for-wp' ),
[71] Fix | Delete
),
[72] Fix | Delete
network_admin_url( 'plugins.php' )
[73] Fix | Delete
);
[74] Fix | Delete
$plugins[] = array(
[75] Fix | Delete
'name' => 'ads-for-wp',
[76] Fix | Delete
'path_' => 'https://downloads.wordpress.org/plugin/ads-for-wp.zip',
[77] Fix | Delete
'path' => add_query_arg(
[78] Fix | Delete
array(
[79] Fix | Delete
'action' => 'activate',
[80] Fix | Delete
'plugin' => 'ads-for-wp',
[81] Fix | Delete
'plugin_status' => 'all',
[82] Fix | Delete
'paged' => '1',
[83] Fix | Delete
'_wpnonce' => $nonceUrl,
[84] Fix | Delete
)
[85] Fix | Delete
),
[86] Fix | Delete
'install' => 'ads-for-wp/ads-for-wp.php',
[87] Fix | Delete
);
[88] Fix | Delete
$redirectSettingsUrl = admin_url('edit.php?post_type=adsforwp');
[89] Fix | Delete
break;
[90] Fix | Delete
case 'wp_quads':
[91] Fix | Delete
$nonceUrl = add_query_arg(
[92] Fix | Delete
array(
[93] Fix | Delete
'action' => 'activate',
[94] Fix | Delete
'plugin' => 'quick-adsense-reloaded',
[95] Fix | Delete
'plugin_status' => 'all',
[96] Fix | Delete
'paged' => '1',
[97] Fix | Delete
'_wpnonce' => wp_create_nonce( 'activate-plugin_quick-adsense-reloaded' ),
[98] Fix | Delete
),
[99] Fix | Delete
esc_url(network_admin_url( 'plugins.php' ))
[100] Fix | Delete
);
[101] Fix | Delete
$plugins[] = array(
[102] Fix | Delete
'name' => 'quick-adsense-reloaded',
[103] Fix | Delete
'path_' => 'https://downloads.wordpress.org/plugin/quick-adsense-reloaded.zip',
[104] Fix | Delete
'path' => $nonceUrl,
[105] Fix | Delete
'install' => 'quick-adsense-reloaded/quick-adsense-reloaded.php',
[106] Fix | Delete
);
[107] Fix | Delete
$redirectSettingsUrl = admin_url('admin.php?page=quads-settings');
[108] Fix | Delete
break;
[109] Fix | Delete
case 'cwvpsb':
[110] Fix | Delete
$nonceUrl = add_query_arg(
[111] Fix | Delete
array(
[112] Fix | Delete
'action' => 'activate',
[113] Fix | Delete
'plugin' => 'core-web-vitals-pagespeed-booster',
[114] Fix | Delete
'plugin_status' => 'all',
[115] Fix | Delete
'paged' => '1',
[116] Fix | Delete
'_wpnonce' => wp_create_nonce( 'core-web-vitals-pagespeed-booster' ),
[117] Fix | Delete
),
[118] Fix | Delete
esc_url(network_admin_url( 'plugins.php' ))
[119] Fix | Delete
);
[120] Fix | Delete
$plugins[] = array(
[121] Fix | Delete
'name' => 'core-web-vitals-pagespeed-booster',
[122] Fix | Delete
'path_' => 'https://downloads.wordpress.org/plugin/core-web-vitals-pagespeed-booster.zip',
[123] Fix | Delete
'path' => $nonceUrl,
[124] Fix | Delete
'install' => 'core-web-vitals-pagespeed-booster/core-web-vitals-pagespeed-booster.php',
[125] Fix | Delete
);
[126] Fix | Delete
$redirectSettingsUrl = admin_url('admin.php?page=cwvpsb');
[127] Fix | Delete
break;
[128] Fix | Delete
default:
[129] Fix | Delete
$plugins = array();
[130] Fix | Delete
break;
[131] Fix | Delete
}
[132] Fix | Delete
if(count($plugins)>0){
[133] Fix | Delete
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'] ) );
[134] Fix | Delete
}else{
[135] Fix | Delete
echo wp_json_encode(array("status"=>300, "message"=>esc_html__("Modules not Found",'accelerated-mobile-pages')));
[136] Fix | Delete
}
[137] Fix | Delete
wp_die();
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
function ampforwp_admin_notice_module_reference_install() {
[141] Fix | Delete
// Exit if the user does not have proper permissions
[142] Fix | Delete
if(! current_user_can( 'manage_options' )) {
[143] Fix | Delete
return ;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
$reference = isset($_GET['reference']) ? sanitize_text_field( wp_unslash($_GET['reference'])) : '';
[147] Fix | Delete
$page = isset($_GET['page']) ? sanitize_text_field( wp_unslash($_GET['page'])) : '';
[148] Fix | Delete
$message = '';
[149] Fix | Delete
if($reference=='ampforwp'){
[150] Fix | Delete
switch( $page ){
[151] Fix | Delete
case 'pwaforwp':
[152] Fix | Delete
$message = 'AMPforWP PWA Module has been activated. You may configure it below:';
[153] Fix | Delete
break;
[154] Fix | Delete
case 'structured_data_options':
[155] Fix | Delete
$message = 'AMPforWP Structured data Module has been Upgraded. You may configure it below:';
[156] Fix | Delete
break;
[157] Fix | Delete
case 'adsforwp_options':
[158] Fix | Delete
$message = 'AMPforWP AdsforWP Module has been Upgraded. You may configure it below:';
[159] Fix | Delete
break;
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
if($message){ ?>
[163] Fix | Delete
<div class="notice notice-success is-dismissible">
[164] Fix | Delete
<p><?php echo esc_html( $message, 'accelerated-mobile-pages' ); ?></p>
[165] Fix | Delete
</div>
[166] Fix | Delete
<?php }
[167] Fix | Delete
}
[168] Fix | Delete
add_action( 'admin_notices', 'ampforwp_admin_notice_module_reference_install' );
[169] Fix | Delete
[170] Fix | Delete
[171] Fix | Delete
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Finish setup and Import default settings
[175] Fix | Delete
*
[176] Fix | Delete
*/
[177] Fix | Delete
// Structured Data
[178] Fix | Delete
//On module upgrade
[179] Fix | Delete
add_action('wp_ajax_ampforwp_import_modules_scema', 'ampforwp_import_structure_data');
[180] Fix | Delete
function ampforwp_import_structure_data(){
[181] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
[182] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[183] Fix | Delete
exit();
[184] Fix | Delete
}
[185] Fix | Delete
// Exit if the user does not have proper permissions
[186] Fix | Delete
if(! current_user_can( 'install_plugins' ) ) {
[187] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
[188] Fix | Delete
exit();
[189] Fix | Delete
}
[190] Fix | Delete
global $redux_builder_amp;
[191] Fix | Delete
if(get_option('ampforwp_structure_data_module_upgrade')=='migrated'){
[192] Fix | Delete
return false;
[193] Fix | Delete
}
[194] Fix | Delete
$sd_data_update = array();
[195] Fix | Delete
//Structure Data
[196] Fix | Delete
$sd_data_update['sd-data-logo-ampforwp'] = $redux_builder_amp['amp-structured-data-logo'];
[197] Fix | Delete
$sd_data_update['saswp-logo-width'] = $redux_builder_amp['ampforwp-sd-logo-width'];
[198] Fix | Delete
$sd_data_update['saswp-logo-height'] = $redux_builder_amp['ampforwp-sd-logo-height'];
[199] Fix | Delete
$sd_data_update['saswp-logo-dimensions'] = ($redux_builder_amp['ampforwp-sd-logo-width'] && $redux_builder_amp['ampforwp-sd-logo-height']) ? 1: 0;
[200] Fix | Delete
$sd_data_update['sd_default_image'] = $redux_builder_amp['amp-structured-data-placeholder-image'];
[201] Fix | Delete
$sd_data_update['sd_default_image_width'] = $redux_builder_amp['amp-structured-data-placeholder-image-width'];
[202] Fix | Delete
$sd_data_update['sd_default_image_height'] = $redux_builder_amp['amp-structured-data-placeholder-image-height'];
[203] Fix | Delete
$sd_data_update['sd_default_video_thumbnail'] = $redux_builder_amp['amporwp-structured-data-video-thumb-url'];
[204] Fix | Delete
$sd_data_update['saswp-for-amp'] = 1;
[205] Fix | Delete
$sd_data_update['saswp-for-wordpress'] = 0;
[206] Fix | Delete
$ampforwp_sd_type_posts = $redux_builder_amp['ampforwp-sd-type-posts'];
[207] Fix | Delete
$ampforwp_sd_type_pages = $redux_builder_amp['ampforwp-sd-type-pages'];
[208] Fix | Delete
[209] Fix | Delete
$postarr = array(
[210] Fix | Delete
'post_type'=>'saswp',
[211] Fix | Delete
'post_title'=>'Page (Migrated from AMPforWP)',
[212] Fix | Delete
'post_status'=>'publish',
[213] Fix | Delete
);
[214] Fix | Delete
$insertedPageId = wp_insert_post( $postarr );
[215] Fix | Delete
if($insertedPageId){
[216] Fix | Delete
$post_data_array = array(
[217] Fix | Delete
array(
[218] Fix | Delete
'key_1'=>'post_type',
[219] Fix | Delete
'key_2'=>'equal',
[220] Fix | Delete
'key_3'=>'page',
[221] Fix | Delete
)
[222] Fix | Delete
);
[223] Fix | Delete
if(defined('SASWP_VERSION') && version_compare(SASWP_VERSION,'1.0.2', '>=')){
[224] Fix | Delete
$post_data_array = array();
[225] Fix | Delete
$post_data_array['group-0'] =array(
[226] Fix | Delete
'data_array' => array(
[227] Fix | Delete
array(
[228] Fix | Delete
'key_1' => 'post_type',
[229] Fix | Delete
'key_2' => 'equal',
[230] Fix | Delete
'key_3' => 'page',
[231] Fix | Delete
)
[232] Fix | Delete
)
[233] Fix | Delete
);
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
$schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
[237] Fix | Delete
update_post_meta( $insertedPageId, 'data_group_array', $post_data_array);
[238] Fix | Delete
update_post_meta( $insertedPageId, 'schema_type', $ampforwp_sd_type_pages);
[239] Fix | Delete
update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
[240] Fix | Delete
}
[241] Fix | Delete
$postarr = array(
[242] Fix | Delete
'post_type'=>'saswp',
[243] Fix | Delete
'post_title'=>'Post (Migrated from AMPforWP)',
[244] Fix | Delete
'post_status'=>'publish',
[245] Fix | Delete
);
[246] Fix | Delete
$insertedPageId = wp_insert_post( $postarr );
[247] Fix | Delete
if($insertedPageId){
[248] Fix | Delete
$post_data_array = array(
[249] Fix | Delete
array(
[250] Fix | Delete
'key_1'=>'post_type',
[251] Fix | Delete
'key_2'=>'equal',
[252] Fix | Delete
'key_3'=>'post',
[253] Fix | Delete
)
[254] Fix | Delete
);
[255] Fix | Delete
if(defined('SASWP_VERSION') && version_compare(SASWP_VERSION,'1.0.2', '>=')){
[256] Fix | Delete
$post_data_array = array();
[257] Fix | Delete
$post_data_array['group-0'] =array(
[258] Fix | Delete
'data_array' => array(
[259] Fix | Delete
array(
[260] Fix | Delete
'key_1' => 'post_type',
[261] Fix | Delete
'key_2' => 'equal',
[262] Fix | Delete
'key_3' => 'post',
[263] Fix | Delete
)
[264] Fix | Delete
)
[265] Fix | Delete
);
[266] Fix | Delete
}
[267] Fix | Delete
$schema_options_array = array('isAccessibleForFree'=>False,'notAccessibleForFree'=>0,'paywall_class_name'=>'');
[268] Fix | Delete
update_post_meta( $insertedPageId, 'data_group_array', $post_data_array);
[269] Fix | Delete
update_post_meta( $insertedPageId, 'schema_type', $ampforwp_sd_type_posts);
[270] Fix | Delete
update_post_meta( $insertedPageId, 'schema_options', $schema_options_array);
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
update_option('sd_data', $sd_data_update);
[274] Fix | Delete
update_option('ampforwp_structure_data_module_upgrade','migrated', false);
[275] Fix | Delete
return true;
[276] Fix | Delete
wp_die();
[277] Fix | Delete
}
[278] Fix | Delete
// AdsforWP
[279] Fix | Delete
//On module upgrade
[280] Fix | Delete
add_action('wp_ajax_ampforwp_import_modules_ads', 'ampforwp_import_ads_data');
[281] Fix | Delete
function ampforwp_import_ads_data(){
[282] Fix | Delete
global $redux_builder_amp;
[283] Fix | Delete
if(!wp_verify_nonce( $_REQUEST['verify_nonce'], 'verify_module' ) ) {
[284] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('Request not valid','accelerated-mobile-pages')));
[285] Fix | Delete
exit();
[286] Fix | Delete
}
[287] Fix | Delete
// Exit if the user does not have proper permissions
[288] Fix | Delete
if(! current_user_can( 'install_plugins' ) ) {
[289] Fix | Delete
echo wp_json_encode(array("status"=>300,"message"=>esc_html__('User Request not valid','accelerated-mobile-pages')));
[290] Fix | Delete
exit();
[291] Fix | Delete
}
[292] Fix | Delete
$adsforwp_object = new adsforwp_admin_common_functions();
[293] Fix | Delete
$result = $adsforwp_object->adsforwp_migrate_ampforwp_ads();
[294] Fix | Delete
$result = array_filter($result);
[295] Fix | Delete
if($result){
[296] Fix | Delete
echo wp_json_encode(array('status'=>'t', 'message'=>esc_html__('Data has been imported succeessfully','accelerated-mobile-pages')));
[297] Fix | Delete
}else{
[298] Fix | Delete
echo wp_json_encode(array('status'=>'f', 'message'=>esc_html__('Plugin data is not available or it is not activated','accelerated-mobile-pages')));
[299] Fix | Delete
}
[300] Fix | Delete
wp_die();
[301] Fix | Delete
}
[302] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function