PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
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 / component / two-factor / two-factor-provider.php

two-factor-provider.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/component/two-factor/two-factor-provider.php

93 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare( strict_types = 1 );
3
4 namespace WP_Defender\Component\Two_Factor;
5
6 use Calotes\Base\Component;
7 use WP_Defender\Model\Setting\Two_Fa as Two_Fa_Model;
8
9 abstract class Two_Factor_Provider extends Component {
10
11 /**
12 * @var string
13 */
14 protected static $slug;
15
16 /**
17 * Use for cache.
18 *
19 * @var Two_Fa_Model
20 */
21 public $model;
22
23 /**
24 * @return string
25 */
26 abstract public function get_label();
27
28 /**
29 * @return string
30 */
31 abstract public function get_login_label();
32
33 /**
34 * @since 2.8.1
35 * @return string
36 */
37 abstract public function get_user_label();
38
39 /**
40 * @return string
41 */
42 abstract public function get_description();
43
44 /**
45 * @param WP_User $user WP_User object of the logged-in user.
46 *
47 * @return boolean
48 */
49 abstract public function is_available_for_user( \WP_User $user );
50
51 abstract public function authentication_form();
52
53 /**
54 * @param WP_User $user
55 */
56 abstract public function validate_authentication( \WP_User $user );
57
58 /**
59 * Safe way to get cached model.
60 *
61 * @return Two_Fa_Model
62 */
63 protected function get_model(): Two_Fa_Model {
64 if ( is_object( $this->model ) ) {
65 return $this->model;
66 }
67
68 $this->model = wd_di()->get( Two_Fa_Model::class );
69
70 return $this->model;
71 }
72
73 protected function get_controller(): \WP_Defender\Controller\Two_Factor {
74 return wd_di()->get( \WP_Defender\Controller\Two_Factor::class );
75 }
76
77 protected function get_component(): \WP_Defender\Component\Two_Fa {
78 return wd_di()->get( \WP_Defender\Component\Two_Fa::class );
79 }
80
81 protected function get_url( $action ): string {
82 $controller = $this->get_controller();
83 $routes = $controller->dump_routes_and_nonces();
84
85 return admin_url( 'admin-ajax.php' ) . sprintf(
86 '?action=%s&route=%s&_def_nonce=%s',
87 defender_base_action(),
88 $controller->check_route( $routes['routes'][ $action ] ),
89 $routes['nonces'][ $action ]
90 );
91 }
92 }
93