| 1 |
<?php |
| 2 |
/** |
| 3 |
* Captcha provider interface. |
| 4 |
* |
| 5 |
* @package WP_Defender\Component\Captcha |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace WP_Defender\Component\Captcha; |
| 9 |
|
| 10 |
use WP_Defender\Integrations\Buddypress; |
| 11 |
use WP_Defender\Integrations\Woocommerce; |
| 12 |
|
| 13 |
/** |
| 14 |
* Interface for captcha providers. |
| 15 |
* |
| 16 |
* Defines the contract for all captcha provider implementations. |
| 17 |
*/ |
| 18 |
interface Interface_Provider { |
| 19 |
/** |
| 20 |
* Get the captcha response token from the current request. |
| 21 |
* |
| 22 |
* @return string The response token or empty string if not found. |
| 23 |
*/ |
| 24 |
public function get_response(): string; |
| 25 |
|
| 26 |
/** |
| 27 |
* Get API script URL. |
| 28 |
* |
| 29 |
* @return string |
| 30 |
*/ |
| 31 |
public function get_api_url(): string; |
| 32 |
|
| 33 |
/** |
| 34 |
* Get verification URL. |
| 35 |
* |
| 36 |
* @return string |
| 37 |
*/ |
| 38 |
public function get_verify_url(): string; |
| 39 |
|
| 40 |
/** |
| 41 |
* Get script handle name. |
| 42 |
* |
| 43 |
* @return string |
| 44 |
*/ |
| 45 |
public function get_script_handle(): string; |
| 46 |
|
| 47 |
/** |
| 48 |
* Get frontend script URL. |
| 49 |
* |
| 50 |
* @return string |
| 51 |
*/ |
| 52 |
public function get_script_url(): string; |
| 53 |
|
| 54 |
/** |
| 55 |
* Get provider name. |
| 56 |
* |
| 57 |
* @param bool $is_type Get provider name by type. |
| 58 |
* |
| 59 |
* @return string |
| 60 |
*/ |
| 61 |
public function get_name( bool $is_type = false ): string; |
| 62 |
|
| 63 |
/** |
| 64 |
* Get widget options. |
| 65 |
* |
| 66 |
* @return array |
| 67 |
*/ |
| 68 |
public function get_options(): array; |
| 69 |
|
| 70 |
/** |
| 71 |
* Render the provider widget HTML. |
| 72 |
* |
| 73 |
* @return string |
| 74 |
*/ |
| 75 |
public function render_widget(): string; |
| 76 |
|
| 77 |
/** |
| 78 |
* Get API script configuration. |
| 79 |
* |
| 80 |
* @return array |
| 81 |
*/ |
| 82 |
public function get_api_script(): array; |
| 83 |
|
| 84 |
/** |
| 85 |
* Get list of excluded requests. |
| 86 |
* |
| 87 |
* @return array |
| 88 |
*/ |
| 89 |
public function get_excluded_requests(): array; |
| 90 |
|
| 91 |
/** |
| 92 |
* Get list of duplicate script handles. |
| 93 |
* |
| 94 |
* @return array |
| 95 |
*/ |
| 96 |
public function get_duplicate_script_handles(): array; |
| 97 |
|
| 98 |
/** |
| 99 |
* Get regex pattern for duplicate scripts. |
| 100 |
* |
| 101 |
* @return string |
| 102 |
*/ |
| 103 |
public function get_duplicate_script_pattern(): string; |
| 104 |
|
| 105 |
/** |
| 106 |
* Verify a captcha response token via remote request. |
| 107 |
* |
| 108 |
* @param string $token Response token. |
| 109 |
* @param string $url Endpoint URL. |
| 110 |
* @param array $body Additional request body data. |
| 111 |
* |
| 112 |
* @return array |
| 113 |
*/ |
| 114 |
public function verify_response_token( string $token, string $url, array $body = array() ): array; |
| 115 |
|
| 116 |
/** |
| 117 |
* Get formatted error message for display. |
| 118 |
* |
| 119 |
* @return string |
| 120 |
*/ |
| 121 |
public function error_message(): string; |
| 122 |
|
| 123 |
/** |
| 124 |
* Determine whether to skip checks for this form. |
| 125 |
* |
| 126 |
* @param Woocommerce $woo WooCommerce integration. |
| 127 |
* @param Buddypress $buddypress BuddyPress integration. |
| 128 |
* |
| 129 |
* @return bool |
| 130 |
*/ |
| 131 |
public function should_skip_check( Woocommerce $woo, Buddypress $buddypress ): bool; |
| 132 |
|
| 133 |
/** |
| 134 |
* Verify response for a specific form. |
| 135 |
* |
| 136 |
* @param string $form Form identifier. |
| 137 |
* |
| 138 |
* @return bool |
| 139 |
*/ |
| 140 |
public function verify_response( string $form ): bool; |
| 141 |
|
| 142 |
/** |
| 143 |
* Build admin notice data for the captcha settings UI. |
| 144 |
* |
| 145 |
* @param bool $is_woo_activated Whether WooCommerce is active. |
| 146 |
* @param bool $is_buddypress_activated Whether BuddyPress is active. |
| 147 |
* |
| 148 |
* @return array |
| 149 |
*/ |
| 150 |
public function get_notice_data( bool $is_woo_activated, bool $is_buddypress_activated ): array; |
| 151 |
} |
| 152 |
|