PluginProbe
Force Refresh / 2.10.0
Force Refresh v2.10.0
3.2.1 3.2.0 3.1.2 3.1.1 3.1.0 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.11.0 2.11.1 2.12.0 All 54 releases
force-refresh / includes / services / classes / class-debug-storage-service.php

class-debug-storage-service.php in Force Refresh 2.10.0, at includes/services/classes/class-debug-storage-service.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Our class responsible for debug storage services.
4 *
5 * @package ForceRefresh
6 */
7
8 namespace JordanLeven\Plugins\ForceRefresh\Services;
9
10 /**
11 * Class for debug storage services.
12 */
13 class Debug_Storage_Service {
14
15 const OPTION_DEBUG_ACTIVE_DATE = 'force_refresh_debug_active_date';
16
17 const DEBUG_MODE_ACTIVE_IN_HOURS = 48;
18
19 /**
20 * Method for getting the current debug mode.
21 *
22 * @return bool True if debug is active.
23 */
24 public static function debug_mode_is_active(): bool {
25 $debug_active_date = (string) get_option( self::OPTION_DEBUG_ACTIVE_DATE, '' );
26
27 if ( ! $debug_active_date ) {
28 return false;
29 }
30
31 $time_current = strtotime( current_time( 'mysql' ) );
32 $time_debug = strtotime( $debug_active_date );
33
34 $difference_in_hours = abs( $time_current - $time_debug ) / 3600;
35 return $difference_in_hours < self::DEBUG_MODE_ACTIVE_IN_HOURS;
36 }
37
38 /**
39 * Method for saving the debug mode.
40 *
41 * @param bool $debug_mode True if debug mode should be turned on.
42 *
43 * @return void
44 */
45 public static function set_debug_mode( bool $debug_mode ): void {
46 if ( $debug_mode ) {
47 $time = current_time( 'mysql' );
48 update_option(
49 self::OPTION_DEBUG_ACTIVE_DATE,
50 $time
51 );
52 } else {
53 delete_option( self::OPTION_DEBUG_ACTIVE_DATE );
54 }
55 }
56 }
57