This commit is contained in:
2026-04-26 23:47:49 +02:00
parent 1b95f03d1e
commit b073e009d8
5288 changed files with 1112699 additions and 55536 deletions

View File

@@ -0,0 +1,57 @@
import { PluginPostStatusInfo } from "@wordpress/edit-post";
import { CheckboxControl } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { useSelect, useDispatch } from "@wordpress/data";
import { store as editorStore } from "@wordpress/editor";
import CopyUrl from "./CopyUrl";
import Check from "./Check";
import CONSTANTS from "./constants";
const { META_ENABLED, META_KEY } = CONSTANTS;
import "./styles.scss";
const PostStatusSettings = () => {
const { sharingEnabled, existingKey } = useSelect((select) => {
const { getEditedPostAttribute } = select(editorStore);
const meta = getEditedPostAttribute("meta");
return {
sharingEnabled: meta[META_ENABLED],
existingKey: meta[META_KEY],
};
});
const { editPost } = useDispatch(editorStore);
const onChangeEnabled = (value) => {
if (value) {
editPost({
meta: { [META_ENABLED]: true, [META_KEY]: existingKey || window.sppp.newKey || "" },
});
} else {
editPost({
meta: { [META_ENABLED]: false, [META_KEY]: "" },
});
}
};
return (
<PluginPostStatusInfo className="sppp">
<Check>
<div className="sppp__checkbox">
<CheckboxControl
label={__("Share post via secret URL", "sharable-password-protected-posts")}
checked={sharingEnabled}
onChange={onChangeEnabled}
/>
</div>
{sharingEnabled && (
<div className="sppp__link">
<CopyUrl />
</div>
)}
</Check>
</PluginPostStatusInfo>
);
};
export default PostStatusSettings;