-
-
Notifications
You must be signed in to change notification settings - Fork 77
fix: expose sovereign tenant extension hooks #1278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,44 +131,20 @@ public function init(): void { | |
| add_action('save_post', [$this, 'handle_compat_mode_setting']); | ||
| } | ||
|
|
||
| /* | ||
| * In sovereign tenant context, redirect checkout URLs to the main site. | ||
| */ | ||
| if (wu_is_sovereign_tenant()) { | ||
| add_filter('post_type_link', [$this, 'redirect_checkout_urls_in_sovereign_context'], 10, 2); | ||
| add_filter('page_link', [$this, 'redirect_checkout_urls_in_sovereign_context'], 10, 2); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the main site checkout URL. | ||
| * | ||
| * Used to redirect sovereign tenants to the main site for checkout. | ||
| * | ||
| * @since 2.5.2 | ||
| * @return string The main site checkout URL. | ||
| */ | ||
| public function get_main_site_checkout_url(): string { | ||
|
|
||
| $main_site = get_blog_details(get_network()->site_id); | ||
|
|
||
| if (! $main_site) { | ||
| return network_site_url('/register/'); | ||
| } | ||
|
|
||
| return trailingslashit($main_site->siteurl) . 'register/'; | ||
| add_filter('post_type_link', [$this, 'filter_checkout_urls'], 10, 2); | ||
| add_filter('page_link', [$this, 'filter_checkout_urls'], 10, 2); | ||
|
Comment on lines
+134
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result:
Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="inc/checkout/class-checkout-pages.php"
if [ ! -f "$FILE" ]; then
echo "Missing file: $FILE" >&2
exit 1
fi
echo "==> $FILE (lines 110-190)"
nl -ba "$FILE" | sed -n '110,190p'Repository: Ultimate-Multisite/ultimate-multisite Length of output: 201 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="inc/checkout/class-checkout-pages.php"
awk 'NR>=110 && NR<=190 {printf "%d\t%s\n", NR, $0}' "$FILE"Repository: Ultimate-Multisite/ultimate-multisite Length of output: 2541 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="inc/checkout/class-checkout-pages.php"
rg -n "function\s+get_signup_pages\s*\(" "$FILE"Repository: Ultimate-Multisite/ultimate-multisite Length of output: 123 🏁 Script executed: #!/bin/bash
set -euo pipefail
FILE="inc/checkout/class-checkout-pages.php"
awk 'NR>=960 && NR<=1040 {printf "%d\t%s\n", NR, $0}' "$FILE"Repository: Ultimate-Multisite/ultimate-multisite Length of output: 2502 Fix
💡 Suggested fix public function filter_checkout_urls($permalink, $post) {
+ if (is_numeric($post)) {
+ $post = get_post((int) $post);
+ }
if (! is_a($post, '\WP_Post')) {
return $permalink;
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /** | ||
| * Redirects checkout URLs to the main site in sovereign tenant context. | ||
| * Filters checkout URLs. | ||
| * | ||
| * @since 2.5.2 | ||
| * | ||
| * @param string $permalink The post permalink. | ||
| * @param \WP_Post $post The post object. | ||
| * @return string The modified permalink. | ||
| */ | ||
| public function redirect_checkout_urls_in_sovereign_context($permalink, $post) { | ||
| public function filter_checkout_urls($permalink, $post) { | ||
|
|
||
| if (! is_a($post, '\WP_Post')) { | ||
| return $permalink; | ||
|
|
@@ -178,7 +154,7 @@ public function redirect_checkout_urls_in_sovereign_context($permalink, $post) { | |
|
|
||
| // Check if this post is a checkout-related page | ||
| if (in_array($post->ID, array_filter($signup_pages), true)) { | ||
| return $this->get_main_site_checkout_url(); | ||
| return apply_filters('wu_checkout_pages_checkout_url', $permalink, $post, $this); | ||
| } | ||
|
|
||
| return $permalink; | ||
|
|
@@ -599,8 +575,6 @@ protected function rewrite_subsite_aware_login_url($url) { | |
| public function rewrite_new_user_notification_email($email, $user, $blogname) { | ||
| unset($user, $blogname); | ||
|
|
||
| unset($user, $blogname); | ||
|
|
||
| if (empty($email['message']) || ! is_array($email)) { | ||
| return $email; | ||
| } | ||
|
|
@@ -634,8 +608,6 @@ function ($matches) { | |
| public function rewrite_password_notification_email($defaults, $key, $user_login, $user_data) { | ||
| unset($key, $user_login, $user_data); | ||
|
|
||
| unset($key, $user_login, $user_data); | ||
|
|
||
| if (empty($defaults['message']) || ! is_array($defaults)) { | ||
| return $defaults; | ||
| } | ||
|
|
@@ -669,8 +641,6 @@ function ($matches) { | |
| public function rewrite_email_change_content($email_text, $new_user_email) { | ||
| unset($new_user_email); | ||
|
|
||
| unset($new_user_email); | ||
|
|
||
| if (empty($email_text) || ! is_string($email_text)) { | ||
| return $email_text; | ||
| } | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped carts still validate as usable.
If this filter returns
true, the constructor exits with$this->errorsempty and no cart state built.Cart::is_valid()will still returntrue, soCheckout::process_order()can keep going with a zero-item cart instead of stopping the flow.💡 Suggested fix
As per coding guidelines, "Use WP_Error for validation/operation failures instead of exceptions; check return values with is_wp_error()".
📝 Committable suggestion
🤖 Prompt for AI Agents