Locations and verification
Validate Build / validate-build (push) Failing after 35s

This commit is contained in:
Cooper Dalrymple
2026-06-04 17:05:42 -05:00
parent 471e5dd053
commit e8b8fc1871
11 changed files with 538 additions and 13 deletions
+30 -12
View File
@@ -23,7 +23,7 @@ final class Settings {
public const LOCATION_LOGIN_PAGE = 'login_page';
public const LOCATION_REGISTRATION_PAGE = 'registration_page';
public const LOCATION_LOST_PASSWORD_PAGE = 'lost_password_page';
public const LOCATION_LOST_PASSWORD_FORM = 'lost_password_page';
public const LOCATION_LOGIN_FORM = 'login_form';
public const LOCATION_COMMENT_FORM = 'comment_form';
public const LOCATION_POST_PASSWORD_FORM = 'post_password_form';
@@ -43,8 +43,18 @@ final class Settings {
return in_array($value, (array) self::get($name));
}
public static function get_instance_url():string {
return !empty($value = (string) self::get('instance_url')) ? $value : self::DEFAULT_INSTANCE_URL;
public static function get_instance_url(string $path = ''):string {
$url = (string) self::get('instance_url');
if (empty($url)) $url = self::DEFAULT_INSTANCE_URL;
if (!wp_http_validate_url($url)) return '';
if (!empty($path)) {
$url = sprintf(
'%s/%s',
untrailingslashit(Settings::get_instance_url()),
$path
);
}
return $url;
}
public static function get_site_key():string {
@@ -55,32 +65,40 @@ final class Settings {
return (string) self::get('secret_key');
}
public static function is_connected():bool {
return !empty(self::get_site_key()) && !empty(self::get_secret_key());
}
public static function get_form_locations():array {
return (array) self::get('form_locations');
}
public static function is_form_location_enabled(string $name):bool {
return in_array($name, self::get_form_locations());
}
public static function is_login_page_enabled():bool {
return in_array(self::LOCATION_LOGIN_PAGE, self::get_form_locations());
return self::is_form_location_enabled(self::LOCATION_LOGIN_PAGE);
}
public static function is_registration_page_enabled():bool {
return in_array(self::LOCATION_REGISTRATION_PAGE, self::get_form_locations());
return self::is_form_location_enabled(self::LOCATION_REGISTRATION_PAGE);
}
public static function is_lost_password_page_enabled():bool {
return in_array(self::LOCATION_LOST_PASSWORD_PAGE, self::get_form_locations());
public static function is_lost_password_form_enabled():bool {
return self::is_form_location_enabled(self::LOCATION_LOST_PASSWORD_FORM);
}
public static function is_login_form_enabled():bool {
return in_array(self::LOCATION_LOGIN_FORM, self::get_form_locations());
return self::is_form_location_enabled(self::LOCATION_LOGIN_FORM);
}
public static function is_comment_form_enabled():bool {
return in_array(self::LOCATION_COMMENT_FORM, self::get_form_locations());
return self::is_form_location_enabled(self::LOCATION_COMMENT_FORM);
}
public static function is_post_password_form_enabled():bool {
return in_array(self::LOCATION_POST_PASSWORD_FORM, self::get_form_locations());
return self::is_form_location_enabled(self::LOCATION_POST_PASSWORD_FORM);
}
public function menu() {
@@ -156,8 +174,8 @@ final class Settings {
'options' => [
self::LOCATION_LOGIN_PAGE => Plugin::__('Login page'),
self::LOCATION_REGISTRATION_PAGE => Plugin::__('Registration page'),
self::LOCATION_LOST_PASSWORD_PAGE => Plugin::__('Lost password page'),
self::LOCATION_LOGIN_FORM => Plugin::__('Custom login form'),
self::LOCATION_LOST_PASSWORD_FORM => Plugin::__('Lost password page'),
self::LOCATION_LOGIN_FORM => Plugin::__('Custom login form (requires Login Page)'),
self::LOCATION_COMMENT_FORM => Plugin::__('Comment form'),
self::LOCATION_POST_PASSWORD_FORM => Plugin::__('Password-protected posts and pages'),
],