Sacconi69

nuovi filtri link menù

Oct 1st, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 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. $item_post->url= str_replace ( "://test", "://de.test", $item_post->url );
  10.  
  11. $item_post->url= str_replace ( "://en.test", "://de.test", $item_post->url );
  12.  
  13. }
  14. return $item_post;
  15. }
  16.  
  17. // NUOVO FILTRO INGLESE
  18.  
  19. add_filter('wp_setup_nav_menu_item', 'sac_en_menu_link', 20, 1 );
  20. function sac_en_menu_link( $item_post ) {
  21. if ('ENGLISH' == $item_post->title ) {
  22. $item_post->url = get_site_url( null, $_SERVER['REQUEST_URI']);
  23.  
  24. $item_post->url= str_replace ( "://de.test", "://en.test", $item_post->url );
  25.  
  26. $item_post->url= str_replace ( "://test", "://en.test", $item_post->url );
  27.  
  28. }
  29. return $item_post;
  30. }
  31.  
  32.  
  33. // NUOVO FILTRO LINK MENU' ITALIANO
  34.  
  35.  
  36. add_filter('wp_setup_nav_menu_item', 'sac_it_menu_link', 40, 1 );
  37. function sac_it_menu_link( $item_post ) {
  38. if ('ITALIANO' == $item_post->title ) {
  39. $item_post->url = get_site_url( null, $_SERVER['REQUEST_URI']);
  40.  
  41. $item_post->url= str_replace ( "://de.test", "://test", $item_post->url );
  42.  
  43. $item_post->url= str_replace ( "://en.test", "://test", $item_post->url );
  44.  
  45. }
  46. return $item_post;
  47. }
  48.  
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment