Skip to content

Commit de3dca1

Browse files
committed
Add defensive checks for Slim SEO plugin compatibility
Add null checks in UI element output() methods to prevent errors when Slim SEO processes shortcodes before WP Ultimo is fully initialized. This fixes the 'Call to a member function get_active_site_url() on null' error by returning empty string instead of attempting to access null objects. Changes: - Add defensive checks in 5 UI elements output() methods - Return empty string when site/membership objects are null - Prevents fatal errors during Slim SEO's shortcode processing Files modified: - inc/ui/class-account-summary-element.php - inc/ui/class-billing-info-element.php - inc/ui/class-current-site-element.php - inc/ui/class-invoices-element.php - inc/ui/class-limits-element.php
1 parent 49c8dbf commit de3dca1

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

inc/ui/class-account-summary-element.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ public function setup_preview(): void {
294294
*/
295295
public function output($atts, $content = null) {
296296

297+
// Defensive check - setup() may have been called but site can still be null
298+
if ( ! $this->site) {
299+
return '';
300+
}
301+
297302
$atts = array_merge($atts, $this->atts);
298303

299304
$atts['site'] = $this->site;

inc/ui/class-billing-info-element.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ public function setup_preview(): void {
272272
*/
273273
public function output($atts, $content = null) {
274274

275+
// Defensive check - setup() may have been called but membership can still be null
276+
if ( ! $this->membership) {
277+
return '';
278+
}
279+
275280
$atts['membership'] = $this->membership;
276281

277282
$atts['billing_address'] = $this->membership->get_billing_address();

inc/ui/class-current-site-element.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ public function register_scripts(): void {
352352
*/
353353
public function output($atts, $content = null) {
354354

355+
// Defensive check - setup() may have been called but site can still be null
356+
if ( ! $this->site) {
357+
return '';
358+
}
359+
355360
$actions = [
356361
'visit_site' => [
357362
'label' => __('Visit Site', 'multisite-ultimate'),

inc/ui/class-invoices-element.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ public function setup_preview(): void {
274274
*/
275275
public function output($atts, $content = null) {
276276

277+
// Defensive check - setup() may have been called but membership can still be null
278+
if ( ! $this->membership) {
279+
return '';
280+
}
281+
277282
$atts['membership'] = $this->membership;
278283

279284
return wu_get_template_contents('dashboard-widgets/invoices', $atts);

inc/ui/class-limits-element.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ public function setup_preview(): void {
240240
*/
241241
public function output($atts, $content = null) {
242242

243+
// Defensive check - setup() may have been called but site can still be null
244+
if ( ! $this->site) {
245+
return '';
246+
}
247+
243248
$post_types = get_post_types(
244249
[
245250
'public' => true,

0 commit comments

Comments
 (0)