From ae93de89d0732c03524813c97eaf2337020b1e3a Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Sat, 15 Jun 2024 14:27:14 +0530 Subject: [PATCH 1/4] Fix strpos first arg null warning in php 8.1 --- includes/settings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/settings.php b/includes/settings.php index afee92722..31ea9826b 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -125,7 +125,8 @@ 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 ( 0 === strpos( $parent_base, 'distributor' ) ) { if ( Utils\is_development_version() ) { ?>
From d520ab43051d4de5fcc6356be53131b135dd35c4 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Sat, 15 Jun 2024 21:39:07 +0530 Subject: [PATCH 2/4] Follow react rules of hooks --- assets/js/gutenberg-plugin.js | 36 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/assets/js/gutenberg-plugin.js b/assets/js/gutenberg-plugin.js index 2fe6800c2..e8adfac90 100644 --- a/assets/js/gutenberg-plugin.js +++ b/assets/js/gutenberg-plugin.js @@ -153,24 +153,34 @@ const DistributorIcon = () => ( * 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. 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 -- permission checks are needed. const postStatus = useSelect( ( select ) => select( 'core/editor' ).getCurrentPostAttribute( 'status' ) ); + // eslint-disable-next-line @wordpress/no-unused-vars-before-return + const distributorTopMenu = document.querySelector( + '#wp-admin-bar-distributor' + ); + + // eslint-disable-next-line no-shadow -- permission checks are needed. + 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 && @@ -179,14 +189,6 @@ const DistributorPlugin = () => { return null; } - const distributorTopMenu = document.querySelector( - '#wp-admin-bar-distributor' - ); - - // eslint-disable-next-line no-shadow, react-hooks/rules-of-hooks -- permission checks are needed. - const post = useSelect( ( select ) => - select( 'core/editor' ).getCurrentPost() - ); // Make the post title and status available to the top menu. dt.postTitle = post.title; dt.postStatus = post.status; From 045da70e377ebf94e19083db0520a683de19f3b6 Mon Sep 17 00:00:00 2001 From: Faisal Alvi Date: Wed, 3 Jul 2024 17:00:33 +0530 Subject: [PATCH 3/4] Update includes/settings.php Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- includes/settings.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/settings.php b/includes/settings.php index 31ea9826b..1acd0df39 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -125,7 +125,10 @@ function update_notice( $plugin_file, $plugin_data, $status ) { * @since 1.2 */ function maybe_notice() { - $parent_base = get_current_screen()->parent_base ?? ''; + $parent_base = get_current_screen()->parent_base; + if ( ! $parent_base ) { + return; + } if ( 0 === strpos( $parent_base, 'distributor' ) ) { if ( Utils\is_development_version() ) { ?> From d0bf34a4bb6283cb63f2ab286a9d6c2f2ad75fdb Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Sun, 14 Jul 2024 21:21:45 +0530 Subject: [PATCH 4/4] fix documentation --- assets/js/gutenberg-plugin.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/js/gutenberg-plugin.js b/assets/js/gutenberg-plugin.js index e8adfac90..8b1448222 100644 --- a/assets/js/gutenberg-plugin.js +++ b/assets/js/gutenberg-plugin.js @@ -153,12 +153,12 @@ const DistributorIcon = () => ( * Add the Distributor panel to Gutenberg */ const DistributorPlugin = () => { - // 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 -- permission checks are needed. + // eslint-disable-next-line no-shadow const postStatus = useSelect( ( select ) => select( 'core/editor' ).getCurrentPostAttribute( 'status' ) ); @@ -168,12 +168,12 @@ const DistributorPlugin = () => { '#wp-admin-bar-distributor' ); - // eslint-disable-next-line no-shadow -- permission checks are needed. + // eslint-disable-next-line no-shadow const post = useSelect( ( select ) => select( 'core/editor' ).getCurrentPost() ); - // Ensure the user has proper permissions + // Ensure the user has proper permissions. if ( dtGutenberg.noPermissions && 1 === parseInt( dtGutenberg.noPermissions ) @@ -181,7 +181,7 @@ const DistributorPlugin = () => { return null; } - // Ensure we are on a supported post type + // Ensure we are on a supported post type. if ( dtGutenberg.supportedPostTypes && dtGutenberg.supportedPostTypes[ postType ] === undefined @@ -193,7 +193,7 @@ const DistributorPlugin = () => { 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 )