Skip to content

Commit

Permalink
only show button if it's NOT a new post
Browse files Browse the repository at this point in the history
  • Loading branch information
aurooba committed Feb 2, 2022
1 parent 1ee78ee commit 174ce43
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '5927a08a260c81ed293bd4865c530ba5');
<?php return array('dependencies' => array('wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-url'), 'version' => '935b2229ebdd9fbb6ddf86ba6eb56396');
10 changes: 8 additions & 2 deletions build/index.js

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

2 changes: 1 addition & 1 deletion build/index.js.map

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

6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import { renderToString } from "@wordpress/element";
import { addQueryArgs } from "@wordpress/url";
import { registerPlugin } from "@wordpress/plugins";

const AddNewPostButton = ({ postType }) => {
const AddNewPostButton = ({ postType, newPost }) => {
if (!postType) {
return null;
}
if (newPost) {
return null;
}

const { singleLabel, addNewLabel } = useSelect((select) => {
const { getPostTypes } = select(coreStore);
Expand Down Expand Up @@ -73,6 +76,7 @@ const AddNewPostButton = ({ postType }) => {
const AddNewPostButtonWrapped = withSelect((select) => {
return {
postType: select("core/editor").getCurrentPostType(),
newPost: select("core/editor").isCleanNewPost(),
};
})(AddNewPostButton);

Expand Down

0 comments on commit 174ce43

Please sign in to comment.