Skip to content

Commit

Permalink
Fix PHP warning with empty permalink on new page/post (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
samiahmedsiddiqui authored Aug 16, 2024
1 parent b7b32cf commit 12a1a3e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
19 changes: 14 additions & 5 deletions admin/class-custom-permalinks-about.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ private function more_plugins() {
?>
</p>
<p>
<?php printf(
__(
'To support future development and to help make it even better please leave a <a href="%1$s" title="%2$s" target="_blank">5-star</a> 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'));
<?php
echo wp_kses(
__(
'To support future development and to help make it even better please leave a <a href="https://wordpress.org/support/plugin/custom-permalinks/reviews/?rate=5#new-post" title="Custom Permalinks Rating" target="_blank">5-star</a> rating with a nice message to me :)',
'custom-permalinks'
),
array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
)
);
?>
</p>
</div>
Expand Down
11 changes: 7 additions & 4 deletions includes/class-custom-permalinks-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 12a1a3e

Please sign in to comment.