@@ -76,8 +76,8 @@ public static function store_item( string $hash, string $data, int $lifetime, bo
7676		}
7777
7878		/* Store data */ 
79- 		self ::_create_files (
80- 			$ data  . self ::_cache_signature ( $ sig_detail  )
79+ 		self ::create_files (
80+ 			$ data  . self ::cache_signature ( $ sig_detail  )
8181		);
8282	}
8383
@@ -91,7 +91,7 @@ public static function store_item( string $hash, string $data, int $lifetime, bo
9191	 */ 
9292	public  static  function  get_item ( string  $ hash  ) {
9393		return  is_readable (
94- 			self ::_file_html ()
94+ 			self ::file_html ()
9595		);
9696	}
9797
@@ -104,8 +104,8 @@ public static function get_item( string $hash ) {
104104	 * @since 2.0 
105105	 */ 
106106	public  static  function  delete_item ( string  $ hash , string  $ url  ): void  {
107- 		self ::_clear_dir (
108- 			self ::_file_path ( $ url  )
107+ 		self ::clear_dir (
108+ 			self ::file_path ( $ url  )
109109		);
110110	}
111111
@@ -115,7 +115,7 @@ public static function delete_item( string $hash, string $url ): void {
115115	 * @since 2.0 
116116	 */ 
117117	public  static  function  clear_cache (): void  {
118- 		self ::_clear_dir (
118+ 		self ::clear_dir (
119119			CACHIFY_CACHE_DIR ,
120120			true 
121121		);
@@ -130,7 +130,7 @@ public static function clear_cache(): void {
130130	 * @since 2.0 
131131	 */ 
132132	public  static  function  print_cache ( bool  $ sig_detail , $ cache  ): void  {
133- 		$ filename  = self ::_file_html ();
133+ 		$ filename  = self ::file_html ();
134134		$ size      = is_readable ( $ filename  ) ? readfile ( $ filename  ) : false ;
135135
136136		if  ( ! empty ( $ size  ) ) {
@@ -147,7 +147,7 @@ public static function print_cache( bool $sig_detail, $cache ): void {
147147	 * @since 2.0 
148148	 */ 
149149	public  static  function  get_stats (): int  {
150- 		return  (int ) self ::_dir_size ( CACHIFY_CACHE_DIR  );
150+ 		return  (int ) self ::dir_size ( CACHIFY_CACHE_DIR  );
151151	}
152152
153153	/** 
@@ -160,7 +160,7 @@ public static function get_stats(): int {
160160	 * @since 2.0 
161161	 * @since 2.3.0 added $detail parameter 
162162	 */ 
163- 	private  static  function  _cache_signature ( bool  $ detail  ): string  {
163+ 	private  static  function  cache_signature ( bool  $ detail  ): string  {
164164		return  sprintf (
165165			"\n\n<!-- %s \n%s @ %s --> " ,
166166			'Cachify | https://cachify.pluginkollektiv.org ' ,
@@ -179,24 +179,24 @@ private static function _cache_signature( bool $detail ): string {
179179	 * 
180180	 * @since 2.0 
181181	 */ 
182- 	private  static  function  _create_files ( string  $ data  ): void  {
183- 		$ file_path  = self ::_file_path ();
182+ 	private  static  function  create_files ( string  $ data  ): void  {
183+ 		$ file_path  = self ::file_path ();
184184
185185		/* Create directory */ 
186186		if  ( ! wp_mkdir_p ( $ file_path  ) ) {
187187			trigger_error ( esc_html ( __METHOD__  . ": Unable to create directory  {$ file_path }. "  ), E_USER_WARNING  );
188188			return ;
189189		}
190190		/* Write to file */ 
191- 		self ::_create_file ( self ::_file_html ( $ file_path  ), $ data  );
191+ 		self ::create_file ( self ::file_html ( $ file_path  ), $ data  );
192192
193193		/** 
194194		 * Filter that allows to enable/disable gzip file creation 
195195		 * 
196196		 * @param bool $create_gzip_files Whether to create gzip files. Default is `true` 
197197		 */ 
198198		if  ( self ::is_gzip_enabled () ) {
199- 			self ::_create_file ( self ::_file_gzip ( $ file_path  ), gzencode ( $ data , 9  ) );
199+ 			self ::create_file ( self ::file_gzip ( $ file_path  ), gzencode ( $ data , 9  ) );
200200		}
201201	}
202202
@@ -208,7 +208,7 @@ private static function _create_files( string $data ): void {
208208	 * 
209209	 * @since 2.0 
210210	 */ 
211- 	private  static  function  _create_file ( string  $ file , string  $ data  ): void  {
211+ 	private  static  function  create_file ( string  $ file , string  $ data  ): void  {
212212		/* Writable? */ 
213213		$ handle  = @fopen ( $ file , 'wb '  );
214214		if  ( ! $ handle  ) {
@@ -237,7 +237,7 @@ private static function _create_file( string $file, string $data ): void {
237237	 * 
238238	 * @since 2.0 
239239	 */ 
240- 	private  static  function  _clear_dir ( string  $ dir , bool  $ recursive  = false  ): void  {
240+ 	private  static  function  clear_dir ( string  $ dir , bool  $ recursive  = false  ): void  {
241241		// Remove trailing slash. 
242242		$ dir  = untrailingslashit ( $ dir  );
243243
@@ -260,19 +260,19 @@ private static function _clear_dir( string $dir, bool $recursive = false ): void
260260			if  ( is_dir ( $ object  ) ) {
261261				if  ( $ recursive  ) {
262262					// Recursively clear the directory. 
263- 					self ::_clear_dir ( $ object , $ recursive  );
264- 				} elseif  ( self ::_user_can_delete ( $ object  ) && 0  === count ( glob ( trailingslashit ( $ object  ) . '* '  ) ) ) {
263+ 					self ::clear_dir ( $ object , $ recursive  );
264+ 				} elseif  ( self ::user_can_delete ( $ object  ) && 0  === count ( glob ( trailingslashit ( $ object  ) . '* '  ) ) ) {
265265					// Delete the directory, if empty. 
266266					@rmdir ( $ object  );
267267				}
268- 			} elseif  ( self ::_user_can_delete ( $ object  ) ) {
268+ 			} elseif  ( self ::user_can_delete ( $ object  ) ) {
269269				// Delete the file. 
270270				unlink ( $ object  );
271271			}
272272		}
273273
274274		// Remove directory, if empty. 
275- 		if  ( self ::_user_can_delete ( $ dir  ) && 0  === count ( glob ( trailingslashit ( $ dir  ) . '* '  ) ) ) {
275+ 		if  ( self ::user_can_delete ( $ dir  ) && 0  === count ( glob ( trailingslashit ( $ dir  ) . '* '  ) ) ) {
276276			@rmdir ( $ dir  );
277277		}
278278
@@ -289,7 +289,7 @@ private static function _clear_dir( string $dir, bool $recursive = false ): void
289289	 * 
290290	 * @since 2.0 
291291	 */ 
292- 	public  static  function  _dir_size ( string  $ dir  = '. '  ) {
292+ 	private  static  function  dir_size ( string  $ dir  = '. '  ) {
293293		/* Is directory? */ 
294294		if  ( ! is_dir ( $ dir  ) ) {
295295			return  false ;
@@ -316,7 +316,7 @@ public static function _dir_size( string $dir = '.' ) {
316316
317317			/* Directory or file */ 
318318			if  ( is_dir ( $ object  ) ) {
319- 				$ size  += self ::_dir_size ( $ object  );
319+ 				$ size  += self ::dir_size ( $ object  );
320320			} else  {
321321				$ size  += filesize ( $ object  );
322322			}
@@ -334,7 +334,7 @@ public static function _dir_size( string $dir = '.' ) {
334334	 * 
335335	 * @since 2.0 
336336	 */ 
337- 	private  static  function  _file_path ( ?string  $ path  = null  ): string  {
337+ 	private  static  function  file_path ( ?string  $ path  = null  ): string  {
338338		$ prefix  = is_ssl () ? 'https- '  : '' ;
339339
340340		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.InputNotValidated 
@@ -366,8 +366,8 @@ private static function _file_path( ?string $path = null ): string {
366366	 * 
367367	 * @since 2.0 
368368	 */ 
369- 	private  static  function  _file_html ( string  $ file_path  = ''  ): string  {
370- 		return  ( empty ( $ file_path  ) ? self ::_file_path () : $ file_path  ) . 'index.html ' ;
369+ 	private  static  function  file_html ( string  $ file_path  = ''  ): string  {
370+ 		return  ( empty ( $ file_path  ) ? self ::file_path () : $ file_path  ) . 'index.html ' ;
371371	}
372372
373373	/** 
@@ -379,8 +379,8 @@ private static function _file_html( string $file_path = '' ): string {
379379	 * 
380380	 * @since 2.0 
381381	 */ 
382- 	private  static  function  _file_gzip ( string  $ file_path  = ''  ): string  {
383- 		return  ( empty ( $ file_path  ) ? self ::_file_path () : $ file_path  ) . 'index.html.gz ' ;
382+ 	private  static  function  file_gzip ( string  $ file_path  = ''  ): string  {
383+ 		return  ( empty ( $ file_path  ) ? self ::file_path () : $ file_path  ) . 'index.html.gz ' ;
384384	}
385385
386386	/** 
@@ -390,7 +390,7 @@ private static function _file_gzip( string $file_path = '' ): string {
390390	 * 
391391	 * @return bool 
392392	 */ 
393- 	private  static  function  _user_can_delete ( string  $ file  ): bool  {
393+ 	private  static  function  user_can_delete ( string  $ file  ): bool  {
394394		if  ( ! is_file ( $ file  ) && ! is_dir ( $ file  ) ) {
395395			return  false ;
396396		}
0 commit comments