0

I am inserting the post titles in UNICODE, but i dont want to save in unicode UTF8 characters. Instead, i want to use my title convert function before slug auto-creation: like this:

function my_convert($string)
{
$string = str_replace('ჲ','a',$string);
$string = str_replace('ძ','b',$string);
..............
.............
return $string;
}
0

My solution using 3 combined hooks wp_insert_post_data, wp_ajax_sample-permalink,name_save_pre

  //==================DISABLE GEORGIAN + Russian SLUGS for POSTS================
    //disable slug on any update
    add_filter('wp_insert_post_data', 'myappend_slug', 3); function myappend_slug($data) {  
        $data['post_name']= slug_modify($data['post_name']);return $data; 
    }
    add_action( 'wp_ajax_sample-permalink', 'MyajaxSamplePermalink',1);         function MyajaxSamplePermalink($data) {
        // check that we're dealing with a product, and editing the slug
        $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
        $post_name = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
        $new_title = isset($_POST['new_title'])? $_POST['new_title'] : null;
        $chosen = (isset($post_name) ? $post_name : $new_title );
        $_POST['new_slug'] = slug_modify($chosen);
    }
    add_filter('name_save_pre', 'MyfilterNameSavePre');     function MyfilterNameSavePre($post_name) {
        // check that we're dealing with a product, and editing the slug
        $post_id = isset($_POST['post_ID']) ? intval($_POST['post_ID']) : 0;
        $new_slug = isset($_POST['post_name']) ? $_POST['post_name'] : 0;
        if ($post_id) { $post_name = slug_modify($new_slug); }
        return $post_name;
    }

            function slug_modify($slg) {return myFILTERRRRRRR($slg);}
  • Please also accept this answer to prevent the question haunting the site every now and then. – tfrommen Jan 1 '14 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.