Thursday, November 2, 2017

phpMyPassion

How To Remove Case Sensitiveness Issue From Post Link In WordPress?


I found the issue of case sensitiveness in post link. So I thought why shouldn't I share the solution by writing a article.

Usually, when we update the the post in WordPress the post link has become automatically in lower case later as below.


Above screenshots shows post link is in small and capital letters combination. if we update the post, the link is automatically become in small letters as below screenshot.


This is happening due to Function senitize_title( ) existed in wp-includes/formatting.php file.
The structure of the this function is as below.

function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
$raw_title = $title;
if ( 'save' == $context )
$title = remove_accents($title);
/**
* Filters a sanitized title string.
*
* @since 1.2.0
*
* @param string $title     Sanitized title.
* @param string $raw_title The title prior to sanitization.
* @param string $context   The context for which the title is being sanitized.
*/
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
if ( '' === $title || false === $title )
$title = $fallback_title;
return $title;
}

senitize_title() function is return title in lower case as shown in the code. So we have to return $raw_title to remove the issue of case sensitiveness. 

Replace the function senitize_title() with following code.. 

function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
$raw_title = $title;
if ( 'save' == $context )
$title = remove_accents($title);
/**
* Filters a sanitized title string.
*
* @since 1.2.0
*
* @param string $title     Sanitized title.
* @param string $raw_title The title prior to sanitization.
* @param string $context   The context for which the title is being sanitized.
*/
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
if ( '' === $title || false === $title )
$title = $fallback_title;
return $raw_title;
}


About Author -

Hi, I am Anil.

Welcome to my eponymous blog! I am passionate about PHP programming. Here you will find a hug of information on web development, web design, PHP and Latest technology.

Subscribe to this Blog via Email :