| @@ -19,36 +19,13 @@ | ||
| 19 | 19 | public function __construct( &$polylang ) { |
| 20 | 20 | $this->model = &$polylang->model; |
| 21 | 21 | $this->options = &$polylang->options; |
| 22 | 22 | |
| 23 | - $this->theme = get_option( 'stylesheet' ); | |
| 24 | - | |
| 25 | - add_filter( 'wp_setup_nav_menu_item', array( $this, 'wp_setup_nav_menu_item' ) ); | |
| 26 | - | |
| 27 | 23 | // Integration with WP customizer |
| 28 | 24 | add_action( 'customize_register', array( $this, 'create_nav_menu_locations' ), 5 ); |
| 29 | - | |
| 30 | - // Filter _wp_auto_add_pages_to_menu by language | |
| 31 | - add_action( 'transition_post_status', array( $this, 'auto_add_pages_to_menu' ), 5, 3 ); // before _wp_auto_add_pages_to_menu | |
| 32 | 25 | } |
| 33 | 26 | |
| 34 | 27 | /** |
| 35 | - * Assigns the title and label to the language switcher menu items | |
| 36 | - * | |
| 37 | - * @since 2.6 | |
| 38 | - * | |
| 39 | - * @param object $item Menu item. | |
| 40 | - * @return object | |
| 41 | - */ | |
| 42 | - public function wp_setup_nav_menu_item( $item ) { | |
| 43 | - if ( '#pll_switcher' === $item->url ) { | |
| 44 | - $item->post_title = __( 'Languages', 'polylang' ); | |
| 45 | - $item->type_label = __( 'Language switcher', 'polylang' ); | |
| 46 | - } | |
| 47 | - return $item; | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | 28 | * Create temporary nav menu locations ( one per location and per language ) for all non-default language |
| 52 | 29 | * to do only one time |
| 53 | 30 | * |
| 54 | 31 | * @since 1.2 |
| @@ -56,10 +33,8 @@ | ||
| 56 | 33 | public function create_nav_menu_locations() { |
| 57 | 34 | static $once; |
| 58 | 35 | global $_wp_registered_nav_menus; |
| 59 | 36 | |
| 60 | - $arr = array(); | |
| 61 | - | |
| 62 | 37 | if ( isset( $_wp_registered_nav_menus ) && ! $once ) { |
| 63 | 38 | foreach ( $_wp_registered_nav_menus as $loc => $name ) { |
| 64 | 39 | foreach ( $this->model->get_languages_list() as $lang ) { |
| 65 | 40 | $arr[ $this->combine_location( $loc, $lang ) ] = $name . ' ' . $lang->name; |
| @@ -99,50 +74,6 @@ | ||
| 99 | 74 | if ( 1 == count( $infos ) ) { |
| 100 | 75 | $infos[] = $this->options['default_lang']; |
| 101 | 76 | } |
| 102 | 77 | return array_combine( array( 'location', 'lang' ), $infos ); |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Filters the option nav_menu_options for auto added pages to menu | |
| 107 | - * | |
| 108 | - * @since 0.9.4 | |
| 109 | - * | |
| 110 | - * @param array $options | |
| 111 | - * @return array Modified options | |
| 112 | - */ | |
| 113 | - public function nav_menu_options( $options ) { | |
| 114 | - $options['auto_add'] = array_intersect( $options['auto_add'], $this->auto_add_menus ); | |
| 115 | - return $options; | |
| 116 | - } | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * Filters _wp_auto_add_pages_to_menu by language | |
| 120 | - * | |
| 121 | - * @since 0.9.4 | |
| 122 | - * | |
| 123 | - * @param string $new_status Transition to this post status. | |
| 124 | - * @param string $old_status Previous post status. | |
| 125 | - * @param object $post Post data. | |
| 126 | - */ | |
| 127 | - public function auto_add_pages_to_menu( $new_status, $old_status, $post ) { | |
| 128 | - if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type || ! empty( $post->post_parent ) ) { | |
| 129 | - return; | |
| 130 | - } | |
| 131 | - | |
| 132 | - if ( ! empty( $this->options['nav_menus'][ $this->theme ] ) ) { | |
| 133 | - $this->auto_add_menus = array(); | |
| 134 | - | |
| 135 | - $lang = $this->model->post->get_language( $post->ID ); | |
| 136 | - $lang = empty( $lang ) ? $this->options['default_lang'] : $lang->slug; // If the page has no language yet, the default language will be assigned | |
| 137 | - | |
| 138 | - // Get all the menus in the page language | |
| 139 | - foreach ( $this->options['nav_menus'][ $this->theme ] as $loc ) { | |
| 140 | - if ( ! empty( $loc[ $lang ] ) ) { | |
| 141 | - $this->auto_add_menus[] = $loc[ $lang ]; | |
| 142 | - } | |
| 143 | - } | |
| 144 | - | |
| 145 | - add_filter( 'option_nav_menu_options', array( $this, 'nav_menu_options' ) ); | |
| 146 | - } | |
| 147 | 78 | } |
| 148 | 79 | } |