Skip to content

Commit 0fa7a09

Browse files
committed
Protecting against Sugar Calendar deactivation
1 parent 9ea2594 commit 0fa7a09

5 files changed

Lines changed: 27 additions & 4 deletions

File tree

themes/osi/archive-sc_event.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
*
77
* @package osi
88
*/
9+
10+
if ( ! class_exists( 'Sugar_Calendar\\Requirements_Check' ) ) {
11+
add_action('init', function() {
12+
wp_safe_redirect( home_url() );
13+
exit;
14+
});
15+
}
16+
917
$display_type = isset( $_GET['event-display'] ) ? sanitize_text_field( wp_unslash( $_GET['event-display'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1018
$event_post_type_slug = sugar_calendar_get_event_post_type_id();
1119

themes/osi/functions.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,9 @@ function osi_add_block_editor_assets() {
329329
/**
330330
* Load the Sugar Calendar compatibility file.
331331
*/
332-
require get_template_directory() . '/inc/sugar-calendar.php';
333-
332+
if ( class_exists( 'Sugar_Calendar\\Requirements_Check' ) ) {
333+
require get_template_directory() . '/inc/sugar-calendar.php';
334+
}
334335
/**
335336
* Register the "Footer - Above credits" sidebar.
336337
*

themes/osi/inc/sugar-calendar.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
exit;
99
}
1010

11+
if ( ! class_exists( 'Sugar_Calendar\\Requirements_Check' ) ) {
12+
exit;
13+
}
14+
1115
use Sugar_Calendar\AddOn\Ticketing\Common\Functions as Functions;
1216
use Sugar_Calendar\AddOn\Ticketing\Frontend\Single as Single;
1317

themes/osi/template-parts/content-press-mentions.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
<?php get_template_part( 'template-parts/header-featured-image' ); ?>
1414

1515
<div class="entry-content post--content">
16-
<?php if ( get_post_type() !== sugar_calendar_get_event_post_type_id() ) { ?>
16+
<?php
17+
$sugar_cal_post_type_id = 'placeholder';
18+
if ( class_exists( 'Sugar_Calendar\\Requirements_Check' ) ) {
19+
$sugar_cal_post_type_id = sugar_calendar_get_event_post_type_id();
20+
}
21+
if ( $sugar_cal_post_type_id !== get_post_type() ) { ?>
1722

1823
<div class="entry-meta post--byline">
1924
<?php osi_posted_on(); ?>

themes/osi/template-parts/content.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
<?php get_template_part( 'template-parts/header-featured-image' ); ?>
1414

1515
<div class="entry-content post--content">
16-
<?php if ( get_post_type() !== sugar_calendar_get_event_post_type_id() ) { ?>
16+
<?php
17+
$sugar_cal_post_type_id = 'placeholder';
18+
if ( class_exists( 'Sugar_Calendar\\Requirements_Check' ) ) {
19+
$sugar_cal_post_type_id = sugar_calendar_get_event_post_type_id();
20+
}
21+
if ( $sugar_cal_post_type_id !== get_post_type() ) { ?>
1722

1823
<div class="entry-meta post--byline">
1924
<?php osi_posted_on(); ?>

0 commit comments

Comments
 (0)