PluginProbe
Polylang / 2.6.3
Polylang v2.6.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-nav-menu.php +7 -7 2.72.6.3 View file →
@@ -93,13 +93,10 @@
93 93
94 94 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
95 95 wp_enqueue_script( 'pll_nav_menu', plugins_url( '/js/nav-menu' . $suffix . '.js', POLYLANG_FILE ), array( 'jquery' ), POLYLANG_VERSION );
96 96
97 - $data = array(
98 - 'strings' => PLL_Switcher::get_switcher_options( 'menu', 'string' ), // The strings for the options
99 - 'title' => __( 'Languages', 'polylang' ), // The title
100 - 'val' => array(),
101 - );
97 + $data['strings'] = PLL_Switcher::get_switcher_options( 'menu', 'string' ); // The strings for the options
98 + $data['title'] = __( 'Languages', 'polylang' ); // The title
102 99
103 100 // Get all language switcher menu items
104 101 $items = get_posts(
105 102 array(
@@ -111,8 +108,9 @@
111 108 )
112 109 );
113 110
114 111 // The options values for the language switcher
112 + $data['val'] = array();
115 113 foreach ( $items as $item ) {
116 114 $data['val'][ $item ] = get_post_meta( $item, '_pll_menu_item', true );
117 115 }
118 116
@@ -144,9 +142,9 @@
144 142 update_post_meta( $menu_item_db_id, '_pll_menu_item', $options );
145 143 }
146 144 }
147 145 else {
148 - foreach ( array_keys( $options ) as $opt ) {
146 + foreach ( $options as $opt => $v ) {
149 147 $options[ $opt ] = empty( $_POST[ 'menu-item-' . $opt ][ $menu_item_db_id ] ) ? 0 : 1;
150 148 }
151 149 update_post_meta( $menu_item_db_id, '_pll_menu_item', $options ); // Allow us to easily identify our nav menu item
152 150 }
@@ -161,8 +159,10 @@
161 159 * @param array $locations nav menu locations
162 160 * @return array
163 161 */
164 162 public function update_nav_menu_locations( $locations ) {
163 + $default = $this->options['default_lang'];
164 +
165 165 // Extract language and menu from locations
166 166 foreach ( $locations as $loc => $menu ) {
167 167 $infos = $this->explode_location( $loc );
168 168 $this->options['nav_menus'][ $this->theme ][ $infos['location'] ][ $infos['lang'] ] = $menu;
@@ -231,9 +231,9 @@
231 231 $menus = is_array( $menus ) ? array_merge( $locations, $menus ) : $locations;
232 232 }
233 233
234 234 if ( is_array( $menus ) ) {
235 - foreach ( array_keys( $menus ) as $loc ) {
235 + foreach ( $menus as $loc => $menu ) {
236 236 foreach ( $this->model->get_languages_list() as $lang ) {
237 237 if ( ! empty( $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ] ) && term_exists( $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ], 'nav_menu' ) ) {
238 238 $menus[ $this->combine_location( $loc, $lang ) ] = $this->options['nav_menus'][ $this->theme ][ $loc ][ $lang->slug ];
239 239 }