Skip Navigation

[Resolved] Types Cred Compatibility with Transliteration Plugin

This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by ioannisM-2 7 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#590756

Hello,

I have created a classifieds site in a non latin language. The problem is that many systems do not recognize non latin characters in permalinks and they are very bad for seo. The solution is to make use of a very simple plugin that rewrites non latin with latin characters in url.

But how could I make this plugin compatible with cred? If I create a post from admin dashboard non latin characters are automatically converted to latin characters in the url. But that does not work for the users that create classifieds from the frontend with cred form. How could make cred read the plugin before the creation of the post?

Here is the code that is contained in the plugin

function greeklish_permalinks_sanitize_title($text) {

	if ( !is_admin() ) return $text;

	

	$expressions = array(

		'/[αΑ][ιίΙΊ]/u' => 'e',

		'/[οΟΕε][ιίΙΊ]/u' => 'i',

	    '/[αΑ][υύΥΎ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'af$1',

	    '/[αΑ][υύΥΎ]/u' => 'av',

	    '/[εΕ][υύΥΎ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'ef$1',

	    '/[εΕ][υύΥΎ]/u' => 'ev',

		'/[οΟ][υύΥΎ]/u' => 'ou',

	    '/(^|\s)[μΜ][πΠ]/u' => '$1b',

	    '/[μΜ][πΠ](\s|$)/u' => 'b$1',

	    '/[μΜ][πΠ]/u' => 'b',

	    '/[νΝ][τΤ]/u' => 'nt',

	    '/[τΤ][σΣ]/u' => 'ts',

	    '/[τΤ][ζΖ]/u' => 'tz',

		'/[γΓ][γΓ]/u' => 'ng',

	    '/[γΓ][κΚ]/u' => 'gk',

	    '/[ηΗ][υΥ]([θΘκΚξΞπΠσςΣτTφΡχΧψΨ]|\s|$)/u' => 'if$1',

	    '/[ηΗ][υΥ]/u' => 'iu',

	    '/[θΘ]/u' => 'th',

	    '/[χΧ]/u' => 'ch',

	    '/[ψΨ]/u' => 'ps',

		'/[αάΑΆ]/u' => 'a',

		'/[βΒ]/u' => 'v',

		'/[γΓ]/u' => 'g',

		'/[δΔ]/u' => 'd',

		'/[εέΕΈ]/u' => 'e',

		'/[ζΖ]/u' => 'z',

		'/[ηήΗΉ]/u' => 'i',

		'/[ιίϊΙΊΪ]/u' => 'i',

		'/[κΚ]/u' => 'k',

		'/[λΛ]/u' => 'l',

		'/[μΜ]/u' => 'm',

		'/[νΝ]/u' => 'n',

		'/[ξΞ]/u' => 'x',

		'/[οόΟΌ]/u' => 'o',

		'/[πΠ]/u' => 'p',

		'/[ρΡ]/u' => 'r',

		'/[σςΣ]/u' => 's',

		'/[τΤ]/u' => 't',

		'/[υύϋΥΎΫ]/u' => 'y',

		'/[φΦ]/iu' => 'f',

		'/[ωώ]/iu' => 'o'

	);

	

	$text = preg_replace( array_keys($expressions), array_values($expressions), $text );

	return $text;

}

add_filter('sanitize_title', 'greeklish_permalinks_sanitize_title', 1);

Is there a way to make cred recognize this code?

Thank you!

#591088

Dear Ioannis,

I suggest you try with CRED action hook to update the post slug(url) as what you want, see our document:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

The post slug is the column "post_name" in database table "wp_posts",
And similar thread:
https://toolset.com/forums/topic/use-username-and-date-as-post-title-and-slug/#post-342395

#591847

Perfect, thank you Luo!!!