Skip to content

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

app/Helpers/URL.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use Syntatis\FeatureFlipper\Concerns\DontInstantiate;
88

9-
use function class_exists;
10-
use function is_numeric;
9+
use function did_action;
10+
use function is_account_page;
1111
use function is_string;
1212
use function parse_url;
1313
use function rtrim;
@@ -65,15 +65,11 @@ public static function isLogin(): bool
6565

6666
/**
6767
* WooCommerce MyAccount is a dedicated page where users can manage their
68-
* account details, view past orders, etc. When they are not loggee in
68+
* account details, view past orders, etc. When they are not logged in
6969
* this page will show the login form.
7070
*/
71-
if (class_exists('woocommerce') && ! is_user_logged_in()) {
72-
$myAccountPageId = get_option('woocommerce_myaccount_page_id');
73-
74-
if (is_numeric($myAccountPageId)) {
75-
return self::parsePath((string) get_permalink(absint($myAccountPageId))) === $urlPath;
76-
}
71+
if (did_action('woocommerce_loaded') !== 0 && ! is_user_logged_in()) {
72+
return is_account_page();
7773
}
7874

7975
return false;

phpcs.xml.dist

+1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@
7676

7777
<!-- Exclude directories -->
7878
<exclude-pattern>/tests/phpunit/bootstrap.php</exclude-pattern>
79+
<exclude-pattern>/tests/phpstan/woocommerce-stubs.php</exclude-pattern>
7980
</ruleset>

phpstan.neon.dist

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parameters:
22
level: 10
33
bootstrapFiles:
44
- dist/autoload/vendor/autoload.php
5+
- tests/phpstan/woocommerce-stubs.php
56
paths:
67
- app
78

tests/phpstan/woocommerce-stubs.php

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
/** @return bool */
4+
function is_account_page() {}

0 commit comments

Comments
 (0)