From 12a1a3e835fa66508ae855911421beea6fdfbf68 Mon Sep 17 00:00:00 2001 From: Sami Ahmed Siddiqui Date: Fri, 16 Aug 2024 13:28:23 +0500 Subject: [PATCH] Fix PHP warning with empty permalink on new page/post (#87) --- admin/class-custom-permalinks-about.php | 19 ++++++++++++++----- includes/class-custom-permalinks-form.php | 11 +++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/admin/class-custom-permalinks-about.php b/admin/class-custom-permalinks-about.php index bdf0a74..eb75955 100644 --- a/admin/class-custom-permalinks-about.php +++ b/admin/class-custom-permalinks-about.php @@ -54,11 +54,20 @@ private function more_plugins() { ?>

- 5-star rating with a nice message to me :)', - 'custom-permalinks' - ),'https://wordpress.org/support/plugin/custom-permalinks/reviews/?rate=5#new-post',__('Custom Permalinks Rating', 'custom-permalinks')); + 5-star rating with a nice message to me :)', + 'custom-permalinks' + ), + array( + 'a' => array( + 'href' => array(), + 'title' => array(), + 'target' => array(), + ), + ) + ); ?>

diff --git a/includes/class-custom-permalinks-form.php b/includes/class-custom-permalinks-form.php index 29fcb22..c3d68d9 100644 --- a/includes/class-custom-permalinks-form.php +++ b/includes/class-custom-permalinks-form.php @@ -754,12 +754,15 @@ private function get_permalink_form( $original = $this->check_conflicts( $original ); } - if ( $permalink ) { - $post_slug = htmlspecialchars( urldecode( $permalink ) ); + $original_encoded_url = ''; + if ( $original ) { $original_encoded_url = htmlspecialchars( urldecode( $original ) ); + } + + if ( $permalink ) { + $post_slug = htmlspecialchars( urldecode( $permalink ) ); } else { - $post_slug = htmlspecialchars( urldecode( $original ) ); - $original_encoded_url = $post_slug; + $post_slug = $original_encoded_url; } wp_enqueue_script(