• When the URL in plain English, then no Problem. Like (site.com/articles/article id) working very good. But (site.com/tag/?????) this type of links getting Genarate 404 error. Why? Also those links are still working when directly go from url bar, but not working, when click on them. Plz help.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello, Tahmid.

    I had the same problem.
    Experience has shown a similar phenomenon in URI encoding with Korean.
    So, not my plugin, but I checked Ajaxify’s history.js file.
    As a result, I modified it as shown below, and the problem was solved in Korean.
    Try it once.

    m.unescapeString = function (b) {
    	var c = b,
    	d;
    	for (; ; ) {
    		// d = a.unescape(c);
    		d = a.decodeURIComponent(c);
    		if (d === c)
    			break;
    		c = d
    	}
    	return c
    },

    * reference : https://docs.microsoft.com/en-us/scripting/javascript/reference/unescape-function-javascript
    * reference : https://docs.microsoft.com/en-us/scripting/javascript/reference/decodeuricomponent-function-javascript

    ps: If Ajaxfy developers see this article, please reflect them in the source.

    I’ve never worked with special characters such as Korean, Arabic or any of the non-english characters, but I’ve been using this and it’s been saving me several headaches. If you guys are willing, feel free to add to it (especially the dw_replaceChars function below!).

    // Santize file uploads
    function dw_safeFileUploads( $file ) {
    	$file['name'] = dw_url( $file['name'] );
    	return $file;
    }
    add_action('wp_handle_upload_prefilter', 'dw_safeFileUploads');
    
    // Sanitize permalinks
    function dw_cleanPermalink($url){
        $url = dw_url( $url );
        return $url;
    }
    add_filter('the_permalink', 'dw_cleanPermalink');
    
    // The grunt work
    function dw_url( $str = '' ) {
    	$str = dw_replaceChars( $str );
    	$str = strtolower($str);
    	$str = trim($str);
    	$str = preg_replace("/[\s-]+/", "-", $str);
    	$str = str_replace("_", "-",$str);
    	$str = preg_replace("/[^a-z0-9.-]/", "", $str);
    	$str = str_replace("-.", ".",$str);
    	return $str;
    }
    // Keep the replacement apart just to look cleaner
    function dw_replaceChars($str) {
    	$unwanted_array = array(
    		' '=>'-', '?'=>'S', '?'=>'s', 'D'=>'Dj', '?'=>'Z', '?'=>'z', 'C'=>'C', 'c'=>'c', 'C'=>'C', 'c'=>'c',
    		'à'=>'A', 'á'=>'A', '?'=>'A', '?'=>'A', '?'=>'A', '?'=>'A', '?'=>'A', '?'=>'C', 'è'=>'E', 'é'=>'E',
    		'ê'=>'E', '?'=>'E', 'ì'=>'I', 'í'=>'I', '?'=>'I', '?'=>'I', '?'=>'N', 'ò'=>'O', 'ó'=>'O', '?'=>'O',
    		'?'=>'O', '?'=>'O', '?'=>'O', 'ù'=>'U', 'ú'=>'U', '?'=>'U', 'ü'=>'U', 'Y'=>'Y', 'T'=>'B', '?'=>'Ss',
    		'à'=>'a', 'á'=>'a', 'a'=>'a', '?'=>'a', '?'=>'a', '?'=>'a', '?'=>'a', '?'=>'c', 'è'=>'e', 'é'=>'e',
    		'ê'=>'e', '?'=>'e', 'ì'=>'i', 'í'=>'i', '?'=>'i', '?'=>'i', 'e'=>'o', '?'=>'n', 'ò'=>'o', 'ó'=>'o',
    		'?'=>'o', '?'=>'o', '?'=>'o', '?'=>'o', 'ù'=>'u', 'ú'=>'u', '?'=>'u', 'y'=>'y', 'y'=>'y', 't'=>'b',
    		'?'=>'y', 'R'=>'R', 'r'=>'r', "'"=>'-', '"'=>'-', '’'=>'-' );
    	$str = strtr( $str, $unwanted_array );
    	return $str;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem With Unicode Language in Url’ is closed to new replies.