PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/integrations/class-woocommerce.php +23 -3 5.7.2 → 6.3.0 View file →
@@ -44,9 +44,9 @@
44 44 }
45 45
46 46 // Problem: REST_REQUEST constant is false during Store API requests, so we check the rest_route parameter instead.
47 47 $request_uri = defender_get_data_from_request( 'REQUEST_URI', 's' );
48 - if ( '' !== $request_uri && strpos( $request_uri, 'rest_route=/wc/store/v1/checkout' ) !== false ) {
48 + if ( '' !== $request_uri && str_contains( $request_uri, 'rest_route=/wc/store/v1/checkout' ) ) {
49 49 return true;
50 50 }
51 51
52 52 $post_data = defender_get_data_from_request( null, 'p' );
@@ -71,9 +71,9 @@
71 71 $my_account_page_id = wc_get_page_id( 'myaccount' );
72 72 if ( $my_account_page_id > 0 ) {
73 73 $my_account_url = get_permalink( $my_account_page_id );
74 74
75 - return strpos( $referer, $my_account_url ) === 0;
75 + return str_starts_with( $referer, $my_account_url );
76 76 }
77 77 }
78 78
79 79 return false;
@@ -87,10 +87,30 @@
87 87 */
88 88 public static function get_forms(): array {
89 89 return array(
90 90 self::WOO_LOGIN_FORM => esc_html__( 'Login', 'defender-security' ),
91 + self::WOO_LOST_PASSWORD_FORM => esc_html__( 'Lost Password', 'defender-security' ),
91 92 self::WOO_REGISTER_FORM => esc_html__( 'Registration', 'defender-security' ),
92 - self::WOO_LOST_PASSWORD_FORM => esc_html__( 'Lost Password', 'defender-security' ),
93 93 self::WOO_CHECKOUT_FORM => esc_html__( 'Checkout', 'defender-security' ),
94 94 );
95 + }
96 +
97 + /**
98 + * Detects if current request originates from WooCommerce code path.
99 + *
100 + * @return bool
101 + */
102 + public function is_woocommerce_page(): bool {
103 + if ( ! $this->is_activated() ) {
104 + return false;
105 + }
106 +
107 + $traces = debug_backtrace(); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_backtrace
108 + foreach ( $traces as $trace ) {
109 + if ( isset( $trace['file'] ) && str_contains( $trace['file'], 'woocommerce' ) ) {
110 + return true;
111 + }
112 + }
113 +
114 + return false;
95 115 }
96 116 }