Advertisement
xpeed

unicode issue

Jul 3rd, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. function xs_main($id, $name = true) {
  2.     if (function_exists('icl_object_id')) {
  3.         $id = icl_object_id($id, 'page', true, 'en');
  4.     }
  5.  
  6.     if ($name === true) {
  7.         $post = get_post($id);
  8.         return xsslug($post->post_name);
  9.     } else {
  10.         return $id;
  11.     }
  12. }
  13. function xsslug($input){
  14.     $string = html_entity_decode($input,ENT_COMPAT,"UTF-8");
  15.     $oldLocale = setlocale(LC_CTYPE, '0');  
  16.     setlocale(LC_CTYPE, 'en_US.UTF-8');
  17.     $string = iconv("UTF-8","ASCII//TRANSLIT",$string);
  18.     setlocale(LC_CTYPE, $oldLocale);
  19.     return strtolower(preg_replace('/[^a-zA-Z0-9]+/','',$string));
  20.  
  21. }
  22.  
  23.  
  24.  
  25.  
  26. content-intro.php#
  27. line 14: <section id="section-<?php echo xs_main($post->ID, false); ?>">
  28.  
  29.  
  30. one-page.php#
  31. line 44: <!--BEGIN-<?php echo xs_main($post->ID); ?> // Post ID: <?php echo xs_main($post->ID, false); ?> -->
  32.  
  33.  
  34. walkermenu#
  35. line 87: $atts['href'] = $prefx . 'section-' . xs_main($item->object_id, false);
  36. line 102: $atts['href'] = $prefx . 'section-' . xs_main($item->object_id, false);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement