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.../pagebuil.../inc
File: amppb_save_data.php
<?php
[0] Fix | Delete
// Exit if accessed directly
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
/* Save post meta on the 'save_post' hook. */
[5] Fix | Delete
add_action( 'save_post', 'amppb_save_post', 10, 2 );
[6] Fix | Delete
/**
[7] Fix | Delete
* Save Page Builder Data When Saving Page
[8] Fix | Delete
*/
[9] Fix | Delete
function ampforwp_isjson($string) {
[10] Fix | Delete
json_decode($string);
[11] Fix | Delete
return (json_last_error() == JSON_ERROR_NONE);
[12] Fix | Delete
}
[13] Fix | Delete
function amppb_save_post( $post_id, $post ){
[14] Fix | Delete
[15] Fix | Delete
/* Stripslashes Submitted Data */
[16] Fix | Delete
$request = stripslashes_deep( $_POST );
[17] Fix | Delete
[18] Fix | Delete
/* Verify/validate */
[19] Fix | Delete
if ( ! isset( $request['amppb_nonce'] ) || ! wp_verify_nonce( $request['amppb_nonce'], 'amppb_nonce_action' ) ){
[20] Fix | Delete
return $post_id;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
[24] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[25] Fix | Delete
return $post_id;
[26] Fix | Delete
}
[27] Fix | Delete
/* Do not save on autosave */
[28] Fix | Delete
if ( defined('DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
[29] Fix | Delete
return $post_id;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/* == Save, Delete, or Update Page Builder Data == */
[33] Fix | Delete
[34] Fix | Delete
$ampforwp_pagebuilder_enable = isset( $request['ampforwp_page_builder_enable'] ) ? sanitize_text_field($request['ampforwp_page_builder_enable']) : null;
[35] Fix | Delete
update_post_meta( $post_id, 'ampforwp_page_builder_enable', $ampforwp_pagebuilder_enable );
[36] Fix | Delete
[37] Fix | Delete
/* Get (old) saved page builder data */
[38] Fix | Delete
$saved_data = get_post_meta( $post_id, 'amp-page-builder', true );
[39] Fix | Delete
[40] Fix | Delete
/* Get new submitted data and sanitize it. */
[41] Fix | Delete
$submitted_data = isset( $request['amp-page-builder'] ) && ampforwp_isjson($request['amp-page-builder']) ? $request['amp-page-builder'] : null;
[42] Fix | Delete
[43] Fix | Delete
[44] Fix | Delete
$submitted_data = json_decode($submitted_data,true);
[45] Fix | Delete
//Script
[46] Fix | Delete
preg_match_all("/<script(?:(?!src).)*>(.*?)<\/script>/",$submitted_data['settingdata']['scripts_data'], $outremove, PREG_SET_ORDER);
[47] Fix | Delete
if($outremove && count($outremove)>0){
[48] Fix | Delete
foreach($outremove as $unwanted){
[49] Fix | Delete
$submitted_data['settingdata']['scripts_data'] = str_replace($unwanted[0], '', $submitted_data['settingdata']['scripts_data']);
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
//Style
[54] Fix | Delete
$submitted_data['settingdata']['style_data']=strip_tags($submitted_data['settingdata']['style_data']);
[55] Fix | Delete
$submitted_data = wp_json_encode($submitted_data);
[56] Fix | Delete
[57] Fix | Delete
$submitted_data = wp_slash($submitted_data);
[58] Fix | Delete
[59] Fix | Delete
/* New data submitted, No previous data, create it */
[60] Fix | Delete
if ( $submitted_data && '' == $saved_data ){
[61] Fix | Delete
add_post_meta( $post_id, 'amp-page-builder', $submitted_data, true );
[62] Fix | Delete
}
[63] Fix | Delete
/* New data submitted, but it's different data than previously stored data, update it */
[64] Fix | Delete
elseif( $submitted_data ){
[65] Fix | Delete
update_post_meta( $post_id, 'amp-page-builder', $submitted_data );
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/* New data submitted is empty, but there's old data available, delete it. */
[69] Fix | Delete
elseif ( empty( $submitted_data ) && $saved_data ){
[70] Fix | Delete
delete_post_meta( $post_id, 'amp-page-builder' );
[71] Fix | Delete
}
[72] Fix | Delete
}
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function