PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.4.1
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.4.1
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / includes / class-wp-optimize-utils.php

class-wp-optimize-utils.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.4.1, at includes/class-wp-optimize-utils.php

64 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) die('Access denied.');
4
5 if (!class_exists('WP_Optimize_Utils')) :
6
7 class WP_Optimize_Utils {
8
9 /**
10 * Returns the folder path for log files
11 *
12 * @return string - Folder path for log files with trailing slash
13 */
14 public static function get_log_folder_path() {
15 $upload_dir = wp_upload_dir();
16 $upload_base = trailingslashit($upload_dir['basedir']);
17 if (!is_dir($upload_base . 'wpo/logs')) {
18 wp_mkdir_p($upload_base . 'wpo/logs');
19 }
20 return $upload_base . 'wpo/logs/';
21 }
22
23 /**
24 * Generates a log file name based on the given prefix.
25 *
26 * @param string $prefix The prefix to be added to the log file name.
27 * @return string The generated log file name.
28 */
29 public static function get_log_file_name($prefix) {
30 return $prefix . '-' . substr(md5(wp_salt()), 0, 20) . '.log';
31 }
32
33 /**
34 * Returns the file path for the log file.
35 *
36 * @param string $prefix The prefix to be added to the log file name.
37 * @return string The file path for the log file.
38 */
39 public static function get_log_file_path($prefix) {
40 return self::get_log_folder_path() . self::get_log_file_name($prefix);
41 }
42
43 /**
44 * Returns WordPress GMT offset in seconds.
45 *
46 * @return int
47 */
48 public static function get_gmt_offset() {
49 $timezone_string = get_option('timezone_string');
50
51 if (!empty($timezone_string)) {
52 $timezone = new DateTimeZone($timezone_string);
53 $gmt_offset = $timezone->getOffset(new DateTime());
54 } else {
55 $gmt_offset_option = get_option('gmt_offset');
56 $gmt_offset = (int) (3600 * $gmt_offset_option);
57 }
58
59 return $gmt_offset;
60 }
61 }
62
63 endif;
64