PluginProbe
Debug Log Manager – Conveniently Monitor and Inspect Errors / 2.1.4
Debug Log Manager – Conveniently Monitor and Inspect Errors v2.1.4
2.5.2 2.5.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.3.1 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.8.0 1.8.2 1.8.3 1.8.4 All 49 releases
debug-log-manager / classes / class-activation.php

class-activation.php in Debug Log Manager – Conveniently Monitor and Inspect Errors 2.1.4, at classes/class-activation.php

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace DLM\Classes;
4
5 /**
6 * Plugin Activation
7 *
8 * @since 1.0.0
9 */
10 class Activation {
11
12 /**
13 * Code that runs on plugin activation
14 *
15 * @since 1.0.0
16 */
17 public function activate() {
18
19 // Create option to store logger status
20
21 $option_value = array(
22 'status' => 'disabled',
23 'on' => date( 'Y-m-d H:i:s' ),
24 );
25
26 update_option( 'debug_log_manager', $option_value, false );
27
28 // Create option to store auto-refresh feature status
29
30 $autorefresh_status = 'disabled';
31
32 update_option( 'debug_log_manager_autorefresh', $autorefresh_status, false );
33
34 // Create debug.log file in custom location for use in WP_DEBUG_LOG constant
35
36 $uploads_path = wp_upload_dir()['basedir'] . '/debug-log-manager';
37
38 $plain_domain = str_replace( array( ".", "-" ), "", sanitize_text_field( $_SERVER['SERVER_NAME'] ) ); // e.g. wwwgooglecom
39
40 $unique_key = date( 'YmdHi' );
41
42 $debug_log_file_path = $uploads_path . '/' . $plain_domain . '_' . $unique_key .'_debug.log';
43
44 $debug_log_file_path_in_option = get_option( 'debug_log_manager_file_path' );
45
46 if ( $debug_log_file_path_in_option === false ) {
47
48 update_option( 'debug_log_manager_file_path', $debug_log_file_path, false );
49
50 $debug_log_file_path_in_option = get_option( 'debug_log_manager_file_path' );
51
52 }
53
54 if ( ! is_dir( $uploads_path ) ) {
55 mkdir( $uploads_path ); // create directory in /uploads folder
56 }
57
58 if ( ! is_file( $debug_log_file_path_in_option ) ) {
59 file_put_contents( $debug_log_file_path_in_option, '' ); // create empty log file
60 } else {}
61
62 }
63
64 }