Skip to content

Commit 8c34958

Browse files
authored
refactor: sync WordPress plugin directory (#15)
1 parent 34d961f commit 8c34958

File tree

4 files changed

+49
-14
lines changed

4 files changed

+49
-14
lines changed

assets/screenshot-1.png

-420 KB
Binary file not shown.

assets/screenshot-2.png

-120 KB
Binary file not shown.

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Stable tag: 1.0.0
1010
Enable beautiful and secure user authentication, including passwordless, social login, single sign-on, multi-factor authentication (MFA), and more.
1111

1212
== Description ==
13-
Thank you for choosing Logto! By integrating Logto into your WordPress site, you are not only enhancing the security and user experience of your site, but also enabling a unified login experience across all your applications.
13+
Thank you for choosing [Logto](https://logto.io/?ref=wpp)! By integrating Logto into your WordPress site, you are not only enhancing the security and user experience of your site, but also enabling a unified login experience across all your applications.
1414

1515
## Why Logto?
1616

src/LogtoPluginSettings.php

+48-13
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,58 @@ static function get(): self
3131
}
3232
}
3333

34+
// We have to define all properties here and assign them in the constructor because WordPress
35+
// plugin directory's SVN pre-commit hook will reject the commit if we assign the enum values
36+
// as default values on property promotion. The error message is:
37+
//
38+
// > Fatal error: Constant expression contains invalid operations in Standard input code on line 47
39+
// > Errors parsing Standard input code
40+
//
41+
// Maybe we can bring back the enum default values when WordPress SVN switches to a newer PHP
42+
// version.
43+
44+
public string $endpoint;
45+
public string $appId;
46+
public string $appSecret;
47+
public string $scope;
48+
public string $extraParams;
49+
public bool $requireVerifiedEmail;
50+
public string $requireOrganizationId;
51+
public array $roleMapping;
52+
public bool $rememberSession;
53+
public bool $syncProfile;
54+
public string $wpFormLogin;
55+
public string $usernameStrategy;
56+
3457
public function __construct(
35-
public string $endpoint = '',
36-
public string $appId = '',
37-
public string $appSecret = '',
38-
// Logto SDK includes default scopes, so no need to include them here
39-
public string $scope = UserScope::email->value . ' ' . UserScope::roles->value,
40-
public string $extraParams = '',
41-
public bool $requireVerifiedEmail = true,
42-
public string $requireOrganizationId = '',
43-
public array $roleMapping = [],
44-
public bool $rememberSession = true,
45-
public bool $syncProfile = true,
46-
public string $wpFormLogin = WpFormLogin::query->value,
47-
public string $usernameStrategy = WpUsernameStrategy::smart->value,
58+
string $endpoint = '',
59+
string $appId = '',
60+
string $appSecret = '',
61+
?string $scope = null,
62+
string $extraParams = '',
63+
bool $requireVerifiedEmail = true,
64+
string $requireOrganizationId = '',
65+
array $roleMapping = [],
66+
bool $rememberSession = true,
67+
bool $syncProfile = true,
68+
?string $wpFormLogin = null,
69+
?string $usernameStrategy = null,
4870
// Ignored
4971
...$extra
5072
) {
73+
$this->endpoint = $endpoint;
74+
$this->appId = $appId;
75+
$this->appSecret = $appSecret;
76+
// Logto SDK includes default scopes, so no need to include them here
77+
$this->scope = $scope ?? UserScope::email->value . ' ' . UserScope::roles->value;
78+
$this->extraParams = $extraParams;
79+
$this->requireVerifiedEmail = $requireVerifiedEmail;
80+
$this->requireOrganizationId = $requireOrganizationId;
81+
$this->roleMapping = $roleMapping;
82+
$this->rememberSession = $rememberSession;
83+
$this->syncProfile = $syncProfile;
84+
$this->wpFormLogin = $wpFormLogin ?? WpFormLogin::query->value;
85+
$this->usernameStrategy = $usernameStrategy ?? WpUsernameStrategy::smart->value;
5186
}
5287

5388
/**

0 commit comments

Comments
 (0)