PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
jetpack / jetpack_vendor / automattic / jetpack-waf / src / class-waf-constants.php

class-waf-constants.php in Jetpack – WP Security, Backup, Speed, & Growth 16.2, at jetpack_vendor/automattic/jetpack-waf/src/class-waf-constants.php

128 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class use to define the constants used by the WAF
4 *
5 * @package automattic/jetpack-waf
6 */
7
8 namespace Automattic\Jetpack\Waf;
9
10 use Automattic\Jetpack\Status\Host;
11
12 /**
13 * Defines our constants.
14 */
15 class Waf_Constants {
16 /**
17 * Initializes the constants required for generating the bootstrap, if they have not been initialized yet.
18 *
19 * @return void
20 */
21 public static function initialize_bootstrap_constants() {
22 self::define_waf_directory();
23 self::define_wpconfig_path();
24 self::define_killswitch();
25 self::define_entrypoint();
26 }
27
28 /**
29 * Compatiblity patch for cases where an outdated Waf_Constants class has been autoloaded by
30 * the standalone bootstrap execution at the beginning of the current request.
31 */
32 public static function initialize_constants() {
33 self::initialize_bootstrap_constants();
34 }
35
36 /**
37 * Set the path to the WAF directory if it has not been set.
38 *
39 * @return void
40 */
41 public static function define_waf_directory() {
42 if ( ! defined( 'JETPACK_WAF_DIR' ) ) {
43 define( 'JETPACK_WAF_DIR', trailingslashit( WP_CONTENT_DIR ) . 'jetpack-waf' );
44 }
45 }
46
47 /**
48 * Set the path to the wp-config.php file if it has not been set.
49 *
50 * @return void
51 */
52 public static function define_wpconfig_path() {
53 if ( ! defined( 'JETPACK_WAF_WPCONFIG' ) ) {
54 define( 'JETPACK_WAF_WPCONFIG', trailingslashit( WP_CONTENT_DIR ) . '../wp-config.php' );
55 }
56 }
57
58 /**
59 * Set the killswitch definition if it has not been set.
60 *
61 * @return void
62 */
63 public static function define_killswitch() {
64 if ( ! defined( 'DISABLE_JETPACK_WAF' ) ) {
65 $is_wpcom = defined( 'IS_WPCOM' ) && IS_WPCOM;
66 $is_atomic = ( new Host() )->is_atomic_platform();
67 $is_atomic_on_jn = defined( 'IS_ATOMIC_JN' ) ?? IS_ATOMIC_JN;
68 define( 'DISABLE_JETPACK_WAF', $is_wpcom || ( $is_atomic && ! $is_atomic_on_jn ) );
69 }
70 }
71
72 /**
73 * Set the mode definition if it has not been set.
74 *
75 * @return void
76 */
77 public static function define_mode() {
78 if ( ! defined( 'JETPACK_WAF_MODE' ) ) {
79 $mode_option = get_option( Waf_Runner::MODE_OPTION_NAME );
80 define( 'JETPACK_WAF_MODE', $mode_option );
81 }
82 }
83
84 /**
85 * Set the entrypoint definition if it has not been set.
86 */
87 public static function define_entrypoint() {
88 if ( ! defined( 'JETPACK_WAF_ENTRYPOINT' ) ) {
89 define( 'JETPACK_WAF_ENTRYPOINT', 'rules/rules.php' );
90 }
91 }
92
93 /**
94 * Set the share data definition if it has not been set.
95 *
96 * @return void
97 */
98 public static function define_share_data() {
99 if ( ! defined( 'JETPACK_WAF_SHARE_DATA' ) ) {
100 $share_data_option = false;
101 if ( function_exists( 'get_option' ) ) {
102 $share_data_option = get_option( Waf_Runner::SHARE_DATA_OPTION_NAME, false );
103 }
104
105 define( 'JETPACK_WAF_SHARE_DATA', $share_data_option );
106 }
107 if ( ! defined( 'JETPACK_WAF_SHARE_DEBUG_DATA' ) ) {
108 $share_debug_data_option = false;
109 if ( function_exists( 'get_option' ) ) {
110 $share_debug_data_option = get_option( Waf_Runner::SHARE_DEBUG_DATA_OPTION_NAME, false );
111 }
112
113 define( 'JETPACK_WAF_SHARE_DEBUG_DATA', $share_debug_data_option );
114 }
115 }
116
117 /**
118 * Set the brute force protection's API host definition if it has not been set.
119 *
120 * @return void
121 */
122 public static function define_brute_force_api_host() {
123 if ( ! defined( 'JETPACK_PROTECT__API_HOST' ) ) {
124 define( 'JETPACK_PROTECT__API_HOST', 'https://api.bruteprotect.com/' );
125 }
126 }
127 }
128