PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.2.2
Defender Security – Malware Scanner, Login Security & Firewall v6.2.2
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
defender-security / src / integrations / class-buddypress.php

class-buddypress.php in Defender Security – Malware Scanner, Login Security & Firewall 6.2.2, at src/integrations/class-buddypress.php

66 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles interactions with BuddyPress plugin.
4 *
5 * @package WP_Defender\Integrations
6 */
7
8 namespace WP_Defender\Integrations;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 die;
12 }
13
14 /**
15 * Buddypress integration module.
16 *
17 * @since 3.3.0
18 */
19 class Buddypress {
20
21 public const REGISTER_FORM = 'buddypress_register', NEW_GROUP_FORM = 'buddypress_new group';
22
23 /**
24 * Check if Buddypress is activated.
25 *
26 * @return bool
27 */
28 public function is_activated(): bool {
29 return class_exists( 'buddypress' );
30 }
31
32 /**
33 * Get the Defender forms.
34 *
35 * @return array
36 */
37 public static function get_forms(): array {
38 return array(
39 self::REGISTER_FORM => esc_html__( 'Registration', 'defender-security' ),
40 self::NEW_GROUP_FORM => esc_html__( 'Add new group', 'defender-security' ),
41 );
42 }
43
44 /**
45 * Detects if the request is coming from a BuddyPress login/registration context.
46 *
47 * @return bool
48 */
49 public function is_login_context(): bool {
50 if ( ! $this->is_activated() ) {
51 return false;
52 }
53
54 // Check if this is a POST request with form data.
55 $post_data = defender_get_data_from_request( null, 'p' );
56 if ( 0 === count( $post_data ) ) {
57 return false;
58 }
59
60 // Check referer against BuddyPress root URL.
61 $referer = wp_get_referer();
62 $redirect_to = defender_get_data_from_request( 'redirect_to', 'p' );
63 return $referer === $redirect_to;
64 }
65 }
66