From 0755575d410fdecf5dd5f39ef3f6e61da5232109 Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sat, 11 Jun 2022 15:51:59 -0700
Subject: [PATCH] PHPCS

---
 external-permalinks-redux.php | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/external-permalinks-redux.php b/external-permalinks-redux.php
index ace9c2b..5b1829c 100644
--- a/external-permalinks-redux.php
+++ b/external-permalinks-redux.php
@@ -25,7 +25,7 @@
  */
 
 // Include block-editor class.
-require_once __DIR__ . '/inc/class-external-permalinks-redux-block-editor.php';
+require_once dirname( __FILE__ ) . '/inc/class-external-permalinks-redux-block-editor.php';
 
 /**
  * Class external_permalinks_redux.
@@ -123,6 +123,13 @@ class external_permalinks_redux {
 		}
 
 		foreach ( $post_types as $post_type ) {
+			if (
+				function_exists( 'use_block_editor_for_post_type' )
+				&& use_block_editor_for_post_type( $post_type )
+			) {
+				return;
+			}
+
 			$title = apply_filters( 'epr_metabox_title', '', $post_type );
 
 			if ( ! $title ) {
@@ -177,6 +184,13 @@ class external_permalinks_redux {
 	 * @param int $post_id Post ID.
 	 */
 	public function action_save_post( $post_id ) {
+		if (
+			function_exists( 'use_block_editor_for_post' )
+			&& use_block_editor_for_post( $post_id )
+		) {
+			return;
+		}
+
 		if ( isset( $_POST[ $this->meta_key_target . '_nonce' ] ) && wp_verify_nonce( sanitize_text_field( $_POST[ $this->meta_key_target . '_nonce' ] ), 'external-permalinks-redux' ) ) {
 			// Target.
 			$url = isset( $_POST[ $this->meta_key_target . '_url' ] ) ? esc_url_raw( $_POST[ $this->meta_key_target . '_url' ] ) : '';
-- 
GitLab