Skip to content

Commit

Permalink
Improve solution for #625
Browse files Browse the repository at this point in the history
  • Loading branch information
andergmartins committed Dec 15, 2023
1 parent 42eaa71 commit 170eadd
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 126 deletions.
2 changes: 1 addition & 1 deletion assets/js/classic-editor.js.map

Large diffs are not rendered by default.

35 changes: 13 additions & 22 deletions assets/js/quick-edit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/quick-edit.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions assets/js/settings-post-types.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/js/settings-post-types.js.map

Large diffs are not rendered by default.

76 changes: 33 additions & 43 deletions assets/jsx/bulk-edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,52 +65,42 @@ inlineEditPost.setBulk = function (id) {
});
}

const saveButton = document.querySelector('#bulk_edit');
if (saveButton) {
saveButton.onclick = function() {
setTimeout(() => {
root.unmount();
}, delayToUnmountAfterSaving);
};
}

const container = document.getElementById("publishpress-future-bulk-edit");
const component = (
<FutureActionPanelBulkEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>
);

if (createRoot) {
createRoot(container).render(
<FutureActionPanelBulkEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>
);
} else {
render(
<FutureActionPanelBulkEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>,
container
);
}
const root = createRoot(container);

inlineEditPost.revert = function () {
root.unmount();
root.render(component);

// Call the original WP revert function.
wpInlineEditRevert.apply(this, arguments);
};
const saveButton = document.querySelector('#bulk_edit');
if (saveButton) {
saveButton.onclick = function() {
setTimeout(() => {
root.unmount();
}, delayToUnmountAfterSaving);
};
}

inlineEditPost.revert = function () {
root.unmount();

// Call the original WP revert function.
wpInlineEditRevert.apply(this, arguments);
};
} else {
render(component, container);
}
};
39 changes: 14 additions & 25 deletions assets/jsx/classic-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,22 @@ if (! isGutenbergEnabled()) {
}

const container = document.getElementById("publishpress-future-classic-editor");
const component = (
<FutureActionPanelClassicEditor
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
/>
);

if (createRoot) {
createRoot(container).render(
<FutureActionPanelClassicEditor
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
/>
);
createRoot(container).render(component);
} else {
render(
<FutureActionPanelClassicEditor
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
/>,
container
);
render(component, container);
}
}
42 changes: 15 additions & 27 deletions assets/jsx/quick-edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ inlineEditPost.edit = function (button, id) {
}

const container = document.getElementById("publishpress-future-quick-edit");
const component = (
<FutureActionPanelQuickEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>
);

if (createRoot) {
const root = createRoot(container);
Expand All @@ -92,19 +105,7 @@ inlineEditPost.edit = function (button, id) {
};
}

root.render(
<FutureActionPanelQuickEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>
);
root.render(component);

inlineEditPost.revert = function () {
root.unmount();
Expand All @@ -113,19 +114,6 @@ inlineEditPost.edit = function (button, id) {
wpInlineEditRevert.apply(this, arguments);
};
} else {
render(
<FutureActionPanelQuickEdit
storeName={storeName}
postType={postType}
isNewPost={isNewPost}
actionsSelectOptions={actionsSelectOptions}
is12Hour={is12Hour}
startOfWeek={startOfWeek}
strings={strings}
taxonomyName={taxonomyName}
nonce={nonce}
/>,
container
);
render(component, container);
}
};
6 changes: 3 additions & 3 deletions assets/jsx/settings-post-types.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ const SettingsFormPanel = (props) => {
};

const container = document.getElementById("publishpress-future-settings-post-types");

const component = (<SettingsFormPanel />);
if (createRoot) {
createRoot(container).render(<SettingsFormPanel />);
createRoot(container).render(component);
} else {
render(<SettingsFormPanel />, container);
render(component, container);
}
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ Yes, the PublishPress Future plugin allows you to schedule automatic changes to
* FIXED: Fix classic meta box when using Classic Editor plugin with the classic editor as default, #624;
* FIXED: Fix default date for new posts, #623;
* FIXED: Fix the quick edit form and future action column for pages, #618;
* FIXED: Fix support for WP before 6.4, #625;

= [3.1.5] - 14 Dec, 2023 =

Expand Down

0 comments on commit 170eadd

Please sign in to comment.