| @@ -124,9 +124,9 @@ | ||
| 124 | 124 | |
| 125 | 125 | // Delete menus locations |
| 126 | 126 | if ( ! empty( $this->options['nav_menus'] ) ) { |
| 127 | 127 | foreach ( $this->options['nav_menus'] as $theme => $locations ) { |
| 128 | - foreach ( array_keys( $locations ) as $location ) { | |
| 128 | + foreach ( $locations as $location => $languages ) { | |
| 129 | 129 | unset( $this->options['nav_menus'][ $theme ][ $location ][ $lang->slug ] ); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| @@ -210,9 +210,9 @@ | ||
| 210 | 210 | |
| 211 | 211 | // Update menus locations |
| 212 | 212 | if ( ! empty( $this->options['nav_menus'] ) ) { |
| 213 | 213 | foreach ( $this->options['nav_menus'] as $theme => $locations ) { |
| 214 | - foreach ( array_keys( $locations ) as $location ) { | |
| 214 | + foreach ( $locations as $location => $languages ) { | |
| 215 | 215 | if ( ! empty( $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ] ) ) { |
| 216 | 216 | $this->options['nav_menus'][ $theme ][ $location ][ $slug ] = $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ]; |
| 217 | 217 | unset( $this->options['nav_menus'][ $theme ][ $location ][ $old_slug ] ); |
| 218 | 218 | } |
| @@ -317,12 +317,11 @@ | ||
| 317 | 317 | */ |
| 318 | 318 | public function set_language_in_mass( $type, $ids, $lang ) { |
| 319 | 319 | global $wpdb; |
| 320 | 320 | |
| 321 | - $ids = array_map( 'intval', $ids ); | |
| 322 | - $lang = $this->get_language( $lang ); | |
| 323 | - $tt_id = 'term' === $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id; | |
| 324 | - $values = array(); | |
| 321 | + $ids = array_map( 'intval', $ids ); | |
| 322 | + $lang = $this->get_language( $lang ); | |
| 323 | + $tt_id = 'term' === $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id; | |
| 325 | 324 | |
| 326 | 325 | foreach ( $ids as $id ) { |
| 327 | 326 | $values[] = $wpdb->prepare( '( %d, %d )', $id, $tt_id ); |
| 328 | 327 | } |
| @@ -334,9 +333,8 @@ | ||
| 334 | 333 | } |
| 335 | 334 | |
| 336 | 335 | if ( 'term' === $type ) { |
| 337 | 336 | clean_term_cache( $ids, 'term_language' ); |
| 338 | - $translations = array(); | |
| 339 | 337 | |
| 340 | 338 | foreach ( $ids as $id ) { |
| 341 | 339 | $translations[] = array( $lang->slug => $id ); |
| 342 | 340 | } |
| @@ -359,13 +357,9 @@ | ||
| 359 | 357 | */ |
| 360 | 358 | public function set_translation_in_mass( $type, $translations ) { |
| 361 | 359 | global $wpdb; |
| 362 | 360 | |
| 363 | - $taxonomy = $type . '_translations'; | |
| 364 | - $terms = array(); | |
| 365 | - $slugs = array(); | |
| 366 | - $description = array(); | |
| 367 | - $count = array(); | |
| 361 | + $taxonomy = $type . '_translations'; | |
| 368 | 362 | |
| 369 | 363 | foreach ( $translations as $t ) { |
| 370 | 364 | $term = uniqid( 'pll_' ); // the term name |
| 371 | 365 | $terms[] = $wpdb->prepare( '( %s, %s )', $term, $term ); |
| @@ -381,11 +375,9 @@ | ||
| 381 | 375 | } |
| 382 | 376 | |
| 383 | 377 | // Get all terms with their term_id |
| 384 | 378 | // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 385 | - $terms = $wpdb->get_results( "SELECT term_id, slug FROM {$wpdb->terms} WHERE slug IN ( " . implode( ',', $slugs ) . ' )' ); | |
| 386 | - $term_ids = array(); | |
| 387 | - $tts = array(); | |
| 379 | + $terms = $wpdb->get_results( "SELECT term_id, slug FROM {$wpdb->terms} WHERE slug IN ( " . implode( ',', $slugs ) . ' )' ); | |
| 388 | 380 | |
| 389 | 381 | // Prepare terms taxonomy relationship |
| 390 | 382 | foreach ( $terms as $term ) { |
| 391 | 383 | $term_ids[] = $term->term_id; |
| @@ -399,9 +391,8 @@ | ||
| 399 | 391 | } |
| 400 | 392 | |
| 401 | 393 | // Get all terms with term_taxonomy_id |
| 402 | 394 | $terms = get_terms( $taxonomy, array( 'hide_empty' => false ) ); |
| 403 | - $trs = array(); | |
| 404 | 395 | |
| 405 | 396 | // Prepare objects relationships |
| 406 | 397 | foreach ( $terms as $term ) { |
| 407 | 398 | $t = maybe_unserialize( $term->description ); |
| @@ -500,13 +491,9 @@ | ||
| 500 | 491 | */ |
| 501 | 492 | public function update_translations( $old_slug, $new_slug = '' ) { |
| 502 | 493 | global $wpdb; |
| 503 | 494 | |
| 504 | - $terms = get_terms( array( 'post_translations', 'term_translations' ) ); | |
| 505 | - $term_ids = array(); | |
| 506 | - $dr = array(); | |
| 507 | - $dt = array(); | |
| 508 | - $ut = array(); | |
| 495 | + $terms = get_terms( array( 'post_translations', 'term_translations' ) ); | |
| 509 | 496 | |
| 510 | 497 | foreach ( $terms as $term ) { |
| 511 | 498 | $term_ids[ $term->taxonomy ][] = $term->term_id; |
| 512 | 499 | $tr = maybe_unserialize( $term->description ); |
| @@ -575,10 +562,8 @@ | ||
| 575 | 562 | public function update_default_lang( $slug ) { |
| 576 | 563 | // The nav menus stored in theme locations should be in the default language |
| 577 | 564 | $theme = get_stylesheet(); |
| 578 | 565 | if ( ! empty( $this->options['nav_menus'][ $theme ] ) ) { |
| 579 | - $menus = array(); | |
| 580 | - | |
| 581 | 566 | foreach ( $this->options['nav_menus'][ $theme ] as $key => $loc ) { |
| 582 | 567 | $menus[ $key ] = empty( $loc[ $slug ] ) ? 0 : $loc[ $slug ]; |
| 583 | 568 | } |
| 584 | 569 | set_theme_mod( 'nav_menu_locations', $menus ); |