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

Toggle Distributor controls when post status changes #1022

Merged
merged 9 commits into from
Mar 8, 2023
4 changes: 4 additions & 0 deletions assets/css/push.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ $mediaSmallScreen : "min-width: 480px";
$mediaMediumScreen : "min-width: 768px";
$mediaGutenbergSmallScreen : "max-width: 782px";

#wp-admin-bar-distributor.hide {
display: none;
}

#distributor-push-wrapper,
#wpadminbar #wp-admin-bar-distributor-placeholder > .ab-item {
display: none;
Expand Down
6 changes: 6 additions & 0 deletions assets/js/gutenberg-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,16 @@ const DistributorPlugin = () => {
return null;
}

const distributorTopMenu = document.querySelector(
'#wp-admin-bar-distributor'
);

// If we are on a non-supported post status, change what we show
if (
dtGutenberg.supportedPostStati &&
! dtGutenberg.supportedPostStati.includes( postStatus )
) {
distributorTopMenu.classList.add( 'hide' );
peterwilsoncc marked this conversation as resolved.
Show resolved Hide resolved
return (
<PluginDocumentSettingPanel
title={ __( 'Distributor', 'distributor' ) }
Expand All @@ -196,6 +201,7 @@ const DistributorPlugin = () => {
);
}

distributorTopMenu.classList.remove( 'hide' );
peterwilsoncc marked this conversation as resolved.
Show resolved Hide resolved
return (
<PluginDocumentSettingPanel
title={ __( 'Distributor', 'distributor' ) }
Expand Down
4 changes: 0 additions & 4 deletions includes/push-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ function syndicatable() {
return;
}

if ( ! in_array( $post->post_status, \Distributor\Utils\distributable_post_statuses(), true ) ) {
return false;
}

peterwilsoncc marked this conversation as resolved.
Show resolved Hide resolved
if ( ! in_array( get_post_type(), $distributable_post_types, true ) || ( ! empty( $_GET['post_type'] ) && 'dt_ext_connection' === $_GET['post_type'] ) ) { // @codingStandardsIgnoreLine Nonce not required
return false;
}
peterwilsoncc marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"scripts": {
"build": "wp-scripts build",
"watch": "wp-scripts build --watch",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The start script on line 54 already does this (wp-scripts start being an alias).

Did you add this because watch is a more common name than start? I've been considering the same because it's a more common name.

Copy link
Contributor Author

@ggutenberg ggutenberg Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize start does the same thing. I did a search in package.json for the word watch and couldn't find anything, so I added it.

Do you want me to remove this or alias it to npm run start?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to remove this or alias it to npm run start?

Let's remove it for now. I'll review our other open-source plugins for the common names, whether it be dev, watch or something else.

"build:docs": "rm -rf docs-built && jsdoc -c hookdoc-conf.json distributor.php includes",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
Expand Down