Skip to content

Commit

Permalink
Improve solution for #1506 and restoring support for WP 6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Dec 15, 2023
1 parent c06848d commit c1649a9
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 39 deletions.
56 changes: 31 additions & 25 deletions modules/calendar/lib/async-calendar/js/index.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import AsyncCalendar from "./AsyncCalendar";
import { getDateWithNoTimezoneOffset, getDateInstanceFromString } from "./Functions";
import { createRoot } from "@wp.element";
import { createRoot } from "&wp.element";
import { render } from "&ReactDOM";

jQuery(() => {
const container = document.getElementById('publishpress-calendar-wrap');
const root = createRoot(container);

root.render(
const component = (
<AsyncCalendar
firstDateToDisplay={getDateWithNoTimezoneOffset(publishpressCalendarParams.firstDateToDisplay)}
weekStartsOnSunday={parseInt(publishpressCalendarParams.weekStartsOnSunday) === 1}
numberOfWeeksToDisplay={publishpressCalendarParams.numberOfWeeksToDisplay}
todayDate={getDateInstanceFromString(publishpressCalendarParams.todayDate)}
dateFormat={publishpressCalendarParams.dateFormat}
timeFormat={publishpressCalendarParams.timeFormat}
theme={publishpressCalendarParams.theme}
statusesToDisplayTime={publishpressCalendarParams.statusesToDisplayTime}
maxVisibleItems={publishpressCalendarParams.maxVisibleItems}
ajaxUrl={publishpressCalendarParams.ajaxUrl}
actionGetData={'publishpress_calendar_get_data'}
actionMoveItem={'publishpress_calendar_move_item'}
actionGetPostTypeFields={'publishpress_calendar_get_post_type_fields'}
nonce={publishpressCalendarParams.nonce}
statuses={publishpressCalendarParams.statuses}
postTypes={publishpressCalendarParams.postTypes}
postTypesCanCreate={publishpressCalendarParams.postTypesCanCreate}
userCanAddPosts={publishpressCalendarParams.userCanAddPosts}
items={publishpressCalendarParams.items}
allowAddingMultipleAuthors={publishpressCalendarParams.allowAddingMultipleAuthors}
requestFilter={publishpressCalendarParams.requestFilter}
strings={publishpressCalendarParams.strings} />
firstDateToDisplay={getDateWithNoTimezoneOffset(publishpressCalendarParams.firstDateToDisplay)}
weekStartsOnSunday={parseInt(publishpressCalendarParams.weekStartsOnSunday) === 1}
numberOfWeeksToDisplay={publishpressCalendarParams.numberOfWeeksToDisplay}
todayDate={getDateInstanceFromString(publishpressCalendarParams.todayDate)}
dateFormat={publishpressCalendarParams.dateFormat}
timeFormat={publishpressCalendarParams.timeFormat}
theme={publishpressCalendarParams.theme}
statusesToDisplayTime={publishpressCalendarParams.statusesToDisplayTime}
maxVisibleItems={publishpressCalendarParams.maxVisibleItems}
ajaxUrl={publishpressCalendarParams.ajaxUrl}
actionGetData={'publishpress_calendar_get_data'}
actionMoveItem={'publishpress_calendar_move_item'}
actionGetPostTypeFields={'publishpress_calendar_get_post_type_fields'}
nonce={publishpressCalendarParams.nonce}
statuses={publishpressCalendarParams.statuses}
postTypes={publishpressCalendarParams.postTypes}
postTypesCanCreate={publishpressCalendarParams.postTypesCanCreate}
userCanAddPosts={publishpressCalendarParams.userCanAddPosts}
items={publishpressCalendarParams.items}
allowAddingMultipleAuthors={publishpressCalendarParams.allowAddingMultipleAuthors}
requestFilter={publishpressCalendarParams.requestFilter}
strings={publishpressCalendarParams.strings} />
);

if (createRoot) {
createRoot(container).render(component);
} else {
render(component);
}
});
35 changes: 23 additions & 12 deletions modules/calendar/lib/async-calendar/js/index.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit c1649a9

Please sign in to comment.