Sacconi69

3 filtri lingue con eccezioni, ma non va

Oct 3rd, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. // NUOVO FILTRO LINK ETICHETTA DEL MENU' TEDESCO
  2.  
  3. add_filter('wp_setup_nav_menu_item', 'sac_de_menu_link', 20, 1 );
  4. function sac_de_menu_link( $item_post ) {
  5. if ('DEUTSCH' == $item_post->title && ! is_admin()) {
  6.  
  7. $item_post->url = get_site_url ( null, $_SERVER['REQUEST_URI'] );
  8.  
  9. if ( in_array( $_SERVER['REQUEST_URI'], ['/contatti/','/contact/',] )) $item_post->url = get_site_url( null, '/kontakt/');
  10.  
  11. $item_post->url= str_replace ( "://test", "://de.test", $item_post->url );
  12.  
  13. $item_post->url= str_replace ( "://en.test", "://de.test", $item_post->url );
  14.  
  15. }
  16. return $item_post;
  17. }
  18.  
  19. // NUOVO FILTRO INGLESE
  20.  
  21. add_filter('wp_setup_nav_menu_item', 'sac_en_menu_link', 20, 1 );
  22. function sac_en_menu_link( $item_post ) {
  23. if ('ENGLISH' == $item_post->title ) {
  24. $item_post->url = get_site_url( null, $_SERVER['REQUEST_URI']);
  25.  
  26. if ( in_array( $_SERVER['REQUEST_URI'], ['/contatti/','/kontakt/',] )) $item_post->url = get_site_url( null, '/contact/');
  27.  
  28. $item_post->url= str_replace ( "://de.test", "://en.test", $item_post->url );
  29.  
  30. $item_post->url= str_replace ( "://test", "://en.test", $item_post->url );
  31.  
  32. }
  33. return $item_post;
  34. }
  35.  
  36.  
  37. // NUOVO FILTRO LINK MENU' ITALIANO
  38.  
  39. // FILTRO LINK MENU' ITALIANO
  40.  
  41. add_filter('wp_setup_nav_menu_item', 'sac_it_menu_link', 40, 1 );
  42. function sac_it_menu_link( $item_post ) {
  43. if ('ITALIANO' == $item_post->title ) {
  44. $item_post->url = get_site_url( null, $_SERVER['REQUEST_URI']);
  45.  
  46. if ( in_array( $_SERVER['REQUEST_URI'], ['/contact/','/kontakt/',] )) $item_post->url = get_site_url( null, '/contatti/');
  47.  
  48.  
  49. $item_post->url= str_replace ( "://de.test", "://test", $item_post->url );
  50.  
  51. $item_post->url= str_replace ( "://en.test", "://test", $item_post->url );
  52.  
  53. }
  54. return $item_post;
  55. }
  56.  
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment