-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration with WPS Hide Login plugin.
- Loading branch information
1 parent
88b9bac
commit a34be2e
Showing
4 changed files
with
79 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Base trait file. | ||
* | ||
* @package hcaptcha-wp | ||
*/ | ||
|
||
// phpcs:disable Generic.Commenting.DocComment.MissingShort | ||
/** @noinspection PhpUndefinedClassInspection */ | ||
/** @noinspection PhpUndefinedNamespaceInspection */ | ||
// phpcs:enable Generic.Commenting.DocComment.MissingShort | ||
|
||
namespace HCaptcha\WP; | ||
|
||
use WPS\WPS_Hide_Login\Plugin; | ||
|
||
/** | ||
* Base trait. | ||
*/ | ||
trait Base { | ||
/** | ||
* Get login URL. | ||
* | ||
* @return string | ||
*/ | ||
private function get_login_url(): string { | ||
if ( class_exists( Plugin::class ) ) { | ||
// Integration with WPS Hide Login plugin. | ||
return wp_parse_url( Plugin::get_instance()->new_login_url(), PHP_URL_PATH ); | ||
} | ||
|
||
return '/wp-login.php'; | ||
} | ||
|
||
/** | ||
* Check if the current request is the login URL. | ||
* | ||
* @return bool | ||
*/ | ||
private function is_login_url(): bool { | ||
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? | ||
filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : | ||
''; | ||
|
||
$request_uri = wp_parse_url( $request_uri, PHP_URL_PATH ); | ||
|
||
return false !== strpos( $request_uri, $this->get_login_url() ); | ||
} | ||
|
||
/** | ||
* Get action. | ||
* | ||
* @return string | ||
*/ | ||
private function get_action(): string { | ||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
return isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; | ||
} | ||
|
||
/** | ||
* Whether the current request is the login action. | ||
* | ||
* @return bool | ||
*/ | ||
private function is_login_action(): bool { | ||
return self::WP_LOGIN_ACTION === $this->get_action(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters