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/wp-conte.../plugins/accelera.../includes/vendor/css-pars...
File: parser-helper-function.php
<?php
[0] Fix | Delete
namespace AMPforWP\AMPVendor;
[1] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
class AMPFORWP_Tree_Shaking_Transient{
[5] Fix | Delete
public static function ampforwp_get_proper_transient_name($transient){
[6] Fix | Delete
global $post;
[7] Fix | Delete
if(ampforwp_is_home()){
[8] Fix | Delete
$transient = "home";
[9] Fix | Delete
}elseif(ampforwp_is_blog()){
[10] Fix | Delete
$transient = "blog";
[11] Fix | Delete
}elseif(ampforwp_is_front_page()){
[12] Fix | Delete
$transient = "post-".ampforwp_get_frontpage_id();
[13] Fix | Delete
}elseif(!empty($post) && is_object($post) && is_singular()){
[14] Fix | Delete
$transient = "post-".intval($post->ID);
[15] Fix | Delete
}elseif(is_archive()){
[16] Fix | Delete
$page_id = get_queried_object_id();
[17] Fix | Delete
$transient = "archive-".intval($page_id);
[18] Fix | Delete
}
[19] Fix | Delete
if( is_user_logged_in() ){
[20] Fix | Delete
$transient = $transient.'-admin';
[21] Fix | Delete
}
[22] Fix | Delete
return $transient;
[23] Fix | Delete
}
[24] Fix | Delete
public static function ampforwp_set_file_transient( $transient, $value, $expiration = 0 ) {
[25] Fix | Delete
[26] Fix | Delete
$transient = self::ampforwp_get_proper_transient_name($transient);
[27] Fix | Delete
$expiration = (int) $expiration;
[28] Fix | Delete
[29] Fix | Delete
$value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
[30] Fix | Delete
[31] Fix | Delete
[32] Fix | Delete
$expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
[33] Fix | Delete
[34] Fix | Delete
if ( wp_using_ext_object_cache() ) {
[35] Fix | Delete
$result = wp_cache_set( $transient, $value, 'transient', $expiration );
[36] Fix | Delete
} else {
[37] Fix | Delete
$transient_timeout = '_transient_timeout_' . $transient;
[38] Fix | Delete
$transient_option = '_transient_' . $transient;
[39] Fix | Delete
[40] Fix | Delete
/***
[41] Fix | Delete
Creating a file
[42] Fix | Delete
**/
[43] Fix | Delete
if($value){
[44] Fix | Delete
$upload_dir = wp_upload_dir();
[45] Fix | Delete
$user_dirname = $upload_dir['basedir'] . '/' . 'ampforwp-tree-shaking';
[46] Fix | Delete
if(!file_exists($user_dirname)) wp_mkdir_p($user_dirname);
[47] Fix | Delete
$content = $value;
[48] Fix | Delete
$new_file = $user_dirname."/".$transient_option.".css";
[49] Fix | Delete
$ifp = @fopen( $new_file, 'w+' );
[50] Fix | Delete
if ( ! $ifp ) {
[51] Fix | Delete
return ( array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ));
[52] Fix | Delete
}
[53] Fix | Delete
$result = @fwrite( $ifp, wp_json_encode($value) );
[54] Fix | Delete
fclose( $ifp );
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
}
[58] Fix | Delete
return $result;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
[62] Fix | Delete
public static function ampforwp_get_file_transient( $transient ) {
[63] Fix | Delete
[64] Fix | Delete
$transient = self::ampforwp_get_proper_transient_name($transient);
[65] Fix | Delete
//$value = '';
[66] Fix | Delete
$pre = apply_filters( "pre_transient_{$transient}", false, $transient );
[67] Fix | Delete
if ( false !== $pre )
[68] Fix | Delete
return $pre;
[69] Fix | Delete
[70] Fix | Delete
if ( wp_using_ext_object_cache() ) {
[71] Fix | Delete
$value = wp_cache_get( $transient, 'transient' );
[72] Fix | Delete
} else {
[73] Fix | Delete
$transient_option = '_transient_' . $transient;
[74] Fix | Delete
/*if ( ! wp_installing() ) {
[75] Fix | Delete
// If option is not in alloptions, it is not autoloaded and thus has a timeout
[76] Fix | Delete
$alloptions = wp_load_alloptions();
[77] Fix | Delete
if ( !isset( $alloptions[$transient_option] ) ) {
[78] Fix | Delete
$transient_timeout = '_transient_timeout_' . $transient;
[79] Fix | Delete
$timeout = get_option( $transient_timeout );
[80] Fix | Delete
if ( false !== $timeout && $timeout < time() ) {
[81] Fix | Delete
delete_option( $transient_option );
[82] Fix | Delete
delete_option( $transient_timeout );
[83] Fix | Delete
$value = false;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
}*/
[87] Fix | Delete
[88] Fix | Delete
if ( ! isset( $value ) ){
[89] Fix | Delete
$upload_dir = wp_upload_dir();
[90] Fix | Delete
$user_dirname = $upload_dir['basedir'] . '/' . 'ampforwp-tree-shaking';
[91] Fix | Delete
if(!file_exists($user_dirname)) wp_mkdir_p($user_dirname);
[92] Fix | Delete
$new_file = $user_dirname."/".$transient_option.".css";
[93] Fix | Delete
if(file_exists($user_dirname)){
[94] Fix | Delete
$files = glob($user_dirname . '/*');
[95] Fix | Delete
//Loop through the file list.
[96] Fix | Delete
foreach($files as $file){
[97] Fix | Delete
[98] Fix | Delete
$file_time = filectime($file);
[99] Fix | Delete
[100] Fix | Delete
$file_date = date("Y-m-d",$file_time);
[101] Fix | Delete
$datetime1 = date_create($file_date);
[102] Fix | Delete
[103] Fix | Delete
$get_current_date = date('Y-m-d');
[104] Fix | Delete
$datetime2 = date_create($get_current_date);
[105] Fix | Delete
[106] Fix | Delete
$interval = date_diff($datetime1, $datetime2);
[107] Fix | Delete
[108] Fix | Delete
$day_diff = $interval->format('%a');
[109] Fix | Delete
if($day_diff >= '30' ){
[110] Fix | Delete
//Make sure that this is a file and not a directory.
[111] Fix | Delete
if(is_file($file) && strpos($file, '_transient')!==false ){
[112] Fix | Delete
//Use the unlink function to delete the file.
[113] Fix | Delete
unlink($file);
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
}
[118] Fix | Delete
if(file_exists($new_file) && filesize($new_file)>0){
[119] Fix | Delete
$ifp = @fopen( $new_file, 'r' );
[120] Fix | Delete
$value = fread($ifp, filesize($new_file));
[121] Fix | Delete
fclose($ifp);
[122] Fix | Delete
}
[123] Fix | Delete
//$value = get_option( $transient_option );
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
$value = isset($value) ? $value : '';
[128] Fix | Delete
return apply_filters( "transient_{$transient}", json_decode($value, true), $transient );
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function