Skip to content
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

Issue/227 - Add widgets.php to Legacy loader #228

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sugar-calendar/includes/themes/legacy/events-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
* @param null $category
* @param int $number
* @param array $show
* @param string $order
*
* @return string
*/
function sc_get_events_list( $display = 'upcoming', $category = null, $number = 5, $show = array(), $order = '' ) {

// Get today, to query before/after
$today = sugar_calendar_get_request_time( 'mysql' );
$now = sugar_calendar_get_request_time( 'mysql' );

// Mutate order to uppercase if not empty
if ( ! empty( $order ) ) {
Expand All @@ -51,7 +52,7 @@ function sc_get_events_list( $display = 'upcoming', $category = null, $number =
'number' => $number,
'end_query' => array(
'inclusive' => true,
'after' => $today
'after' => $now
)
);

Expand All @@ -65,7 +66,7 @@ function sc_get_events_list( $display = 'upcoming', $category = null, $number =
'number' => $number,
'end_query' => array(
'inclusive' => true,
'before' => $today
'before' => $now
)
);

Expand Down
22 changes: 18 additions & 4 deletions sugar-calendar/sugar-calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,24 @@ private function include_admin() {
// Legacy
require_once SC_PLUGIN_DIR . 'includes/admin/settings.php';

// Maybe include front-end on AJAX or add/edit post page to load
// shortcodes, widgets, and more...
if ( wp_doing_ajax() || ( ! empty( $GLOBALS['pagenow'] ) && ( 'post.php' === $GLOBALS['pagenow'] ) ) ) {
// Maybe include front-end on AJAX, add/edit post page, or widgets, to
// load all shortcodes, widgets, assets, etc...
if (

// Admin AJAX
wp_doing_ajax()

||

// Specific admin pages
(
! empty( $GLOBALS['pagenow'] )

&&

in_array( $GLOBALS['pagenow'], array( 'post.php', 'widgets.php' ), true )
)
) {
$this->include_frontend();
}
}
Expand All @@ -417,7 +432,6 @@ private function include_frontend() {
require_once SC_PLUGIN_DIR . 'includes/themes/legacy/calendar.php';
require_once SC_PLUGIN_DIR . 'includes/themes/legacy/event-display.php';
require_once SC_PLUGIN_DIR . 'includes/themes/legacy/events-list.php';
require_once SC_PLUGIN_DIR . 'includes/themes/legacy/scripts.php';
}

/**
Expand Down