Skip to content

Commit

Permalink
Merge branch 'develop' into feature/397
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 authored Jul 14, 2024
2 parents c53d6da + 61331d1 commit 8e1e2cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
42 changes: 22 additions & 20 deletions assets/js/gutenberg-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,45 +284,47 @@ const DistributorTitle = () => {
* Add the Distributor panel to Gutenberg
*/
const DistributorPlugin = () => {
// Ensure the user has proper permissions
if (
dtGutenberg.noPermissions &&
1 === parseInt( dtGutenberg.noPermissions )
) {
return null;
}

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
// eslint-disable-next-line no-shadow
const postType = useSelect( ( select ) =>
select( 'core/editor' ).getCurrentPostType()
);

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
// eslint-disable-next-line no-shadow
const postStatus = useSelect( ( select ) =>
select( 'core/editor' ).getCurrentPostAttribute( 'status' )
);

// Ensure we are on a supported post type
if (
dtGutenberg.supportedPostTypes &&
dtGutenberg.supportedPostTypes[ postType ] === undefined
) {
return null;
}

// eslint-disable-next-line @wordpress/no-unused-vars-before-return
const distributorTopMenu = document.querySelector(
'#wp-admin-bar-distributor'
);

// eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed.
// eslint-disable-next-line no-shadow
const post = useSelect( ( select ) =>
select( 'core/editor' ).getCurrentPost()
);

// Ensure the user has proper permissions.
if (
dtGutenberg.noPermissions &&
1 === parseInt( dtGutenberg.noPermissions )
) {
return null;
}

// Ensure we are on a supported post type.
if (
dtGutenberg.supportedPostTypes &&
dtGutenberg.supportedPostTypes[ postType ] === undefined
) {
return null;
}

// Make the post title and status available to the top menu.
dt.postTitle = post.title;
dt.postStatus = post.status;

// If we are on a non-supported post status, change what we show
// If we are on a non-supported post status, change what we show.
if (
dtGutenberg.supportedPostStati &&
! dtGutenberg.supportedPostStati.includes( postStatus )
Expand Down
6 changes: 5 additions & 1 deletion includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ function update_notice( $plugin_file, $plugin_data, $status ) {
* @since 1.2
*/
function maybe_notice() {
if ( 0 === strpos( get_current_screen()->parent_base, 'distributor' ) ) {
$parent_base = get_current_screen()->parent_base;
if ( ! $parent_base ) {
return;
}
if ( 0 === strpos( $parent_base, 'distributor' ) ) {
if ( Utils\is_development_version() ) {
?>
<div class="notice notice-warning">
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Distributor ===
Contributors: 10up
Tags: content, distribution, syndication, management
Tested up to: 6.5
Tested up to: 6.6
Stable tag: 2.0.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down

0 comments on commit 8e1e2cd

Please sign in to comment.