PluginProbe
DecaLog / 3.4.0
DecaLog v3.4.0
3.0.2 3.1.0 3.10.0 3.2.0 3.3.0 3.4.0 3.4.1 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.6.3 3.7.0 3.7.1 3.8.0 3.9.0 3.9.1 4.0.0 4.1.0 4.2.0 4.3.0 4.3.1 4.4.0 4.5.0 All 75 releases
decalog / decalog.php

decalog.php in DecaLog 3.4.0, at decalog.php

176 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main plugin file.
4 *
5 * @package Bootstrap
6 * @author Pierre Lannoy <https://pierre.lannoy.fr/>.
7 * @since 1.0.0
8 *
9 * @wordpress-plugin
10 * Plugin Name: DecaLog
11 * Plugin URI: https://perfops.one/decalog
12 * Description: Capture and log events, metrics and traces on your site. Make WordPress observable – finally!
13 * Version: 3.4.0
14 * Requires at least: 5.2
15 * Requires PHP: 7.2
16 * Author: Pierre Lannoy / PerfOps One
17 * Author URI: https://perfops.one
18 * License: GPLv3
19 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
20 * Text Domain: decalog
21 * Network: true
22 * Domain Path: /languages
23 */
24
25 // If this file is called directly, abort.
26 if ( ! defined( 'WPINC' ) ) {
27 die;
28 }
29
30 require_once __DIR__ . '/init.php';
31 require_once __DIR__ . '/functions.php';
32 require_once __DIR__ . '/includes/system/class-option.php';
33 require_once __DIR__ . '/includes/system/class-environment.php';
34 require_once __DIR__ . '/autoload.php';
35 require_once __DIR__ . '/includes/libraries/class-libraries.php';
36 require_once __DIR__ . '/includes/libraries/autoload.php';
37 require_once __DIR__ . '/includes/libraries/guzzlehttp/Promise/functions_include.php';
38 require_once __DIR__ . '/includes/libraries/guzzlehttp/Psr7/functions_include.php';
39 require_once __DIR__ . '/includes/libraries/guzzlehttp/functions_include.php';
40
41 /**
42 * Copy the file responsible to early initialization in mu-plugins and drop-ins dir.
43 *
44 * @since 2.4.0
45 */
46 function decalog_check_earlyloading() {
47 if ( (bool) get_site_option( 'decalog_earlyloading', true ) ) {
48 if ( defined( 'DECALOG_EARLY_INIT' ) && defined( 'DECALOG_BOOTSTRAPPED' ) && DECALOG_BOOTSTRAPPED && DECALOG_EARLY_INIT ) {
49 return;
50 }
51 if ( ! defined( 'DECALOG_EARLY_INIT' ) ) {
52 $target = WPMU_PLUGIN_DIR . '/_decalog_loader.php';
53 $source = __DIR__ . '/assets/_decalog_loader.php';
54 if ( ! file_exists( $target ) ) {
55 if ( ! file_exists( WPMU_PLUGIN_DIR ) ) {
56 // phpcs:ignore
57 @mkdir( WPMU_PLUGIN_DIR );
58 }
59 if ( ! file_exists( WPMU_PLUGIN_DIR ) ) {
60 define( 'DECALOG_EARLY_INIT_WPMUDIR_ERROR', true );
61 }
62 if ( file_exists( $source ) ) {
63 // phpcs:ignore
64 @copy( $source, $target );
65 // phpcs:ignore
66 @chmod( $target, 0644 );
67 }
68 if ( ! file_exists( $target ) ) {
69 define( 'DECALOG_EARLY_INIT_COPY_ERROR', true );
70 }
71 } else {
72 define( 'DECALOG_EARLY_INIT_ERROR', true );
73 }
74 }
75 if ( ! defined( 'DECALOG_BOOTSTRAPPED' ) ) {
76 $target = WP_CONTENT_DIR . '/fatal-error-handler.php';
77 $source = __DIR__ . '/assets/fatal-error-handler.php';
78 if ( ! file_exists( $target ) ) {
79 if ( file_exists( $source ) ) {
80 // phpcs:ignore
81 @copy( $source, $target );
82 // phpcs:ignore
83 @chmod( $target, 0644 );
84 }
85 if ( ! file_exists( $target ) ) {
86 define( 'DECALOG_BOOTSTRAP_COPY_ERROR', true );
87 }
88 } else {
89 define( 'DECALOG_BOOTSTRAP_ALREADY_EXISTS_ERROR', true );
90 }
91 }
92 } else {
93 $file = WPMU_PLUGIN_DIR . '/_decalog_loader.php';
94 if ( file_exists( $file ) ) {
95 // phpcs:ignore
96 @unlink( $file );
97 }
98 if ( defined( 'DECALOG_BOOTSTRAPPED' ) ) {
99 $file = WP_CONTENT_DIR . '/fatal-error-handler.php';
100 if ( file_exists( $file ) ) {
101 // phpcs:ignore
102 @unlink( $file );
103 }
104 }
105 }
106 }
107
108 /**
109 * Removes the file responsible to early initialization in mu-plugins and drop-ins dir.
110 *
111 * @since 3.0.0
112 */
113 function decalog_reset_earlyloading() {
114 $target = WPMU_PLUGIN_DIR . '/_decalog_loader.php';
115 if ( file_exists( $target ) ) {
116 // phpcs:ignore
117 @unlink( $target );
118 }
119 if ( defined( 'DECALOG_BOOTSTRAPPED' ) ) {
120 $target = WP_CONTENT_DIR . '/fatal-error-handler.php';
121 if ( file_exists( $target ) ) {
122 // phpcs:ignore
123 @unlink( $target );
124 }
125 }
126 }
127
128 /**
129 * The code that runs during plugin activation.
130 *
131 * @since 1.0.0
132 */
133 function decalog_activate() {
134 decalog_reset_earlyloading();
135 Decalog\Plugin\Activator::activate();
136 }
137
138 /**
139 * The code that runs during plugin deactivation.
140 *
141 * @since 1.0.0
142 */
143 function decalog_deactivate() {
144 decalog_reset_earlyloading();
145 Decalog\Plugin\Deactivator::deactivate();
146 }
147
148 /**
149 * The code that runs during plugin uninstallation.
150 *
151 * @since 1.0.0
152 */
153 function decalog_uninstall() {
154 decalog_reset_earlyloading();
155 Decalog\Plugin\Uninstaller::uninstall();
156 }
157
158 /**
159 * Begins execution of the plugin.
160 *
161 * @since 1.0.0
162 */
163 function decalog_run() {
164 require_once __DIR__ . '/includes/features/class-wpcli.php';
165 decalog_check_earlyloading();
166 $plugin = new Decalog\Plugin\Core();
167 $plugin->run();
168 }
169 if ( ! defined( 'DECALOG_MAX_SHUTDOWN_PRIORITY' ) ) {
170 define( 'DECALOG_MAX_SHUTDOWN_PRIORITY', PHP_INT_MAX - 1000 );
171 }
172 register_activation_hook( __FILE__, 'decalog_activate' );
173 register_deactivation_hook( __FILE__, 'decalog_deactivate' );
174 register_uninstall_hook( __FILE__, 'decalog_uninstall' );
175 decalog_run();
176