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.../themes/Divi/core/componen.../cache
File: Directory.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Core_Cache_Directory {
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* @since 4.0.8
[5] Fix | Delete
* @var self
[6] Fix | Delete
*/
[7] Fix | Delete
protected static $_instance;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Whether or not we can write to the cache directory.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 4.0.8
[13] Fix | Delete
* @var bool
[14] Fix | Delete
*/
[15] Fix | Delete
public $can_write;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Absolute path to cache directory
[19] Fix | Delete
*
[20] Fix | Delete
* @since 4.0.8
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
public $path = '';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* URL for {@see self::$path}
[27] Fix | Delete
*
[28] Fix | Delete
* @since 4.0.8
[29] Fix | Delete
* @var string
[30] Fix | Delete
*/
[31] Fix | Delete
public $url = '';
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* @since 4.0.8
[35] Fix | Delete
* @var WP_Filesystem_Base
[36] Fix | Delete
*/
[37] Fix | Delete
public $wpfs;
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* ET_Core_Cache_Directory constructor.
[41] Fix | Delete
*
[42] Fix | Delete
* @since 4.0.8
[43] Fix | Delete
*/
[44] Fix | Delete
public function __construct() {
[45] Fix | Delete
if ( self::$_instance ) {
[46] Fix | Delete
et_wrong( 'Use "ET_Core_Cache_Directory::instance()" instead of "new ET_Core_Cache_Directory".' );
[47] Fix | Delete
[48] Fix | Delete
return;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
self::$_instance = $this;
[52] Fix | Delete
[53] Fix | Delete
$this->_initialize();
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Determines the cache directory path and url based on where we can write files
[58] Fix | Delete
* and whether or not the user has defined a custom path and url.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 4.0.8
[61] Fix | Delete
*/
[62] Fix | Delete
protected function _initialize() {
[63] Fix | Delete
$this->_initialize_wpfs();
[64] Fix | Delete
[65] Fix | Delete
if ( $this->_maybe_use_custom_path() ) {
[66] Fix | Delete
return;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
$uploads_dir_info = (object) wp_get_upload_dir();
[70] Fix | Delete
$path = et_()->path( WP_CONTENT_DIR, 'et-cache' );
[71] Fix | Delete
$url = content_url( 'et-cache' );
[72] Fix | Delete
[73] Fix | Delete
$can_write = $this->wpfs->is_writable( $path ) && ! is_file( $path );
[74] Fix | Delete
$can_create = ! $can_write && $this->wpfs->is_writable( WP_CONTENT_DIR );
[75] Fix | Delete
[76] Fix | Delete
if ( ! $can_write && ! $can_create && $this->wpfs->is_writable( $uploads_dir_info->basedir ) ) {
[77] Fix | Delete
// We can create our cache directory in the uploads directory
[78] Fix | Delete
$can_create = true;
[79] Fix | Delete
$path = et_()->path( $uploads_dir_info->basedir, 'et-cache' );
[80] Fix | Delete
$url = et_()->path( $uploads_dir_info->baseurl, 'et-cache' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
$this->can_write = $can_write || $can_create;
[84] Fix | Delete
$this->path = $path;
[85] Fix | Delete
$this->url = $url;
[86] Fix | Delete
[87] Fix | Delete
$this->_maybe_adjust_path_for_multisite( $uploads_dir_info );
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Absolute path to directory where we can store cache files.
[91] Fix | Delete
*
[92] Fix | Delete
* @since 4.0.8
[93] Fix | Delete
* @var string
[94] Fix | Delete
*/
[95] Fix | Delete
define( 'ET_CORE_CACHE_DIR', $this->path );
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* URL to {@see ET_CORE_CACHE_DIR}.
[99] Fix | Delete
*
[100] Fix | Delete
* @since 4.0.8
[101] Fix | Delete
* @var string
[102] Fix | Delete
*/
[103] Fix | Delete
define( 'ET_CORE_CACHE_DIR_URL', $this->url );
[104] Fix | Delete
[105] Fix | Delete
$this->can_write && et_()->ensure_directory_exists( $this->path );
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Ensures that the WP Filesystem API has been initialized.
[110] Fix | Delete
*
[111] Fix | Delete
* @since??
[112] Fix | Delete
*
[113] Fix | Delete
* @return WP_Filesystem_Base
[114] Fix | Delete
*/
[115] Fix | Delete
protected function _initialize_wpfs() {
[116] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/file.php';
[117] Fix | Delete
[118] Fix | Delete
if ( defined( 'ET_CORE_CACHE_DIR' ) && @WP_Filesystem( array(), ET_CORE_CACHE_DIR, true ) ) {
[119] Fix | Delete
// We can write to a user-specified directory
[120] Fix | Delete
return $this->wpfs = $GLOBALS['wp_filesystem'];
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
if ( @WP_Filesystem( array(), false, true ) ) {
[124] Fix | Delete
// We can write to WP_CONTENT_DIR
[125] Fix | Delete
return $this->wpfs = $GLOBALS['wp_filesystem'];
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$uploads_dir = (object) wp_get_upload_dir();
[129] Fix | Delete
[130] Fix | Delete
if ( @WP_Filesystem( array(), $uploads_dir->basedir, true ) ) {
[131] Fix | Delete
// We can write to the uploads directory
[132] Fix | Delete
return $this->wpfs = $GLOBALS['wp_filesystem'];
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
// We aren't able to write to the filesystem so let's just make sure $this->wpfs
[136] Fix | Delete
// is an instance of the filesystem base class so that calling it won't cause errors.
[137] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
[138] Fix | Delete
[139] Fix | Delete
// Write notice to log when WP_DEBUG is enabled.
[140] Fix | Delete
$nl = PHP_EOL;
[141] Fix | Delete
$msg = 'Unable to write to filesystem. Please ensure that PHP has write access to one of ';
[142] Fix | Delete
$msg .= "the following directories:{$nl}{$nl}\t- WP_CONTENT_DIR{$nl}\t- wp_upload_dir(){$nl}\t- ET_CORE_CACHE_DIR.";
[143] Fix | Delete
[144] Fix | Delete
et_debug( $msg );
[145] Fix | Delete
[146] Fix | Delete
return $this->wpfs = new WP_Filesystem_Base;
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Adjusts the path for multisite if necessary.
[151] Fix | Delete
*
[152] Fix | Delete
* @since 4.0.8
[153] Fix | Delete
*
[154] Fix | Delete
* @param stdClass $uploads_dir_info (object) wp_get_upload_dir()
[155] Fix | Delete
*/
[156] Fix | Delete
protected function _maybe_adjust_path_for_multisite( $uploads_dir_info ) {
[157] Fix | Delete
if ( et_()->starts_with( $this->path, $uploads_dir_info->basedir ) || ! is_multisite() ) {
[158] Fix | Delete
return;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
$site = get_site();
[162] Fix | Delete
$network_id = $site->site_id;
[163] Fix | Delete
$site_id = $site->blog_id;
[164] Fix | Delete
[165] Fix | Delete
$this->path = et_()->path( $this->path, $network_id, $site_id );
[166] Fix | Delete
$this->url = et_()->path( $this->url, $network_id, $site_id );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Whether or not the user has defined a custom path for the cache directory.
[171] Fix | Delete
*
[172] Fix | Delete
* @since 4.0.8
[173] Fix | Delete
*
[174] Fix | Delete
* @return bool
[175] Fix | Delete
*/
[176] Fix | Delete
protected function _maybe_use_custom_path() {
[177] Fix | Delete
if ( ! defined( 'ET_CORE_CACHE_DIR' ) ) {
[178] Fix | Delete
return false;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
$this->path = ET_CORE_CACHE_DIR;
[182] Fix | Delete
[183] Fix | Delete
if ( ! $this->can_write = $this->wpfs->is_writable( $this->path ) ) {
[184] Fix | Delete
et_wrong( 'ET_CORE_CACHE_DIR is defined but not writable.', true );
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
if ( defined( 'ET_CORE_CACHE_DIR_URL' ) ) {
[188] Fix | Delete
$this->url = ET_CORE_CACHE_DIR_URL;
[189] Fix | Delete
} else {
[190] Fix | Delete
et_wrong( 'When ET_CORE_CACHE_DIR is defined, ET_CORE_CACHE_DIR_URL must also be defined.', true );
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
return true;
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
/**
[197] Fix | Delete
* Returns the class instance.
[198] Fix | Delete
*
[199] Fix | Delete
* @since 4.0.8
[200] Fix | Delete
*
[201] Fix | Delete
* @return ET_Core_Cache_Directory
[202] Fix | Delete
*/
[203] Fix | Delete
public static function instance() {
[204] Fix | Delete
if ( ! self::$_instance ) {
[205] Fix | Delete
self::$_instance = new self;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
return self::$_instance;
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function