PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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-model.php +8 -81 3.0.33.1.4 View file →
@@ -51,13 +51,8 @@
51 51 if ( ! isset( $this->options['default_lang'] ) ) {
52 52 // If this is the first language created, set it as default language
53 53 $this->options['default_lang'] = $args['slug'];
54 54 update_option( 'polylang', $this->options );
55 -
56 - // And assign default language to default category
57 - $this->term->set_language( (int) get_option( 'default_category' ), (int) $r['term_id'] );
58 - } elseif ( empty( $args['no_default_cat'] ) ) {
59 - $this->create_default_category( $args['slug'] );
60 55 }
61 56
62 57 // Init a mo_id for this language
63 58 $mo = new PLL_MO();
@@ -436,79 +431,8 @@
436 431 clean_term_cache( $term_ids, $taxonomy );
437 432 }
438 433
439 434 /**
440 - * Returns untranslated posts and terms ids ( used in settings ).
441 - *
442 - * @since 0.9
443 - * @since 2.2.6 Add the $limit argument.
444 - *
445 - * @param int $limit Max number of posts or terms to return. Defaults to -1 (no limit).
446 - * @return array {
447 - * Objects without language.
448 - *
449 - * @type int[] $posts Array of post ids.
450 - * @type int[] $terms Array of term ids.
451 - * }
452 - */
453 - public function get_objects_with_no_lang( $limit = -1 ) {
454 - global $wpdb;
455 -
456 - /**
457 - * Filters the max number of posts or terms to return when searching objects with no language.
458 - * This filter can be used to decrease the memory usage in case the number of objects
459 - * without language is too big. Using a negative value is equivalent to have no limit.
460 - *
461 - * @since 2.2.6
462 - *
463 - * @param int $limit Max number of posts or terms to retrieve from the database.
464 - */
465 - $limit = (int) apply_filters( 'get_objects_with_no_lang_limit', $limit );
466 -
467 - $posts = get_posts(
468 - array(
469 - 'numberposts' => $limit,
470 - 'nopaging' => $limit <= 0,
471 - 'post_type' => $this->get_translated_post_types(),
472 - 'post_status' => 'any',
473 - 'fields' => 'ids',
474 - 'tax_query' => array(
475 - array(
476 - 'taxonomy' => 'language',
477 - 'terms' => $this->get_languages_list( array( 'fields' => 'term_id' ) ),
478 - 'operator' => 'NOT IN',
479 - ),
480 - ),
481 - )
482 - );
483 -
484 - // PHPCS:disable WordPress.DB.PreparedSQL
485 - $terms = $wpdb->get_col(
486 - sprintf(
487 - "SELECT {$wpdb->term_taxonomy}.term_id FROM {$wpdb->term_taxonomy}
488 - WHERE taxonomy IN ('%s')
489 - AND {$wpdb->term_taxonomy}.term_id NOT IN (
490 - SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN (%s)
491 - )
492 - %s",
493 - implode( "','", array_map( 'esc_sql', $this->get_translated_taxonomies() ) ),
494 - implode( ',', array_map( 'intval', $this->get_languages_list( array( 'fields' => 'tl_term_taxonomy_id' ) ) ) ),
495 - $limit > 0 ? "LIMIT {$limit}" : ''
496 - )
497 - );
498 - // PHPCS:enable
499 -
500 - /**
501 - * Filters the list of untranslated posts ids and terms ids
502 - *
503 - * @since 0.9
504 - *
505 - * @param array|false $objects false if no ids found, list of post and/or term ids otherwise.
506 - */
507 - return apply_filters( 'pll_get_objects_with_no_lang', empty( $posts ) && empty( $terms ) ? false : array( 'posts' => $posts, 'terms' => $terms ) );
508 - }
509 -
510 - /**
511 435 * Updates the translations when a language slug has been modified in settings
512 436 * or deletes them when a language is removed.
513 437 *
514 438 * @since 0.5
@@ -605,13 +529,16 @@
605 529 }
606 530 set_theme_mod( 'nav_menu_locations', $menus );
607 531 }
608 532
609 - // The default category should be in the default language
610 - $default_cats = $this->term->get_translations( get_option( 'default_category' ) );
611 - if ( isset( $default_cats[ $slug ] ) ) {
612 - update_option( 'default_category', $default_cats[ $slug ] );
613 - }
533 + /**
534 + * Fires when a default language is updated.
535 + *
536 + * @since 3.1
537 + *
538 + * @param string $slug Slug.
539 + */
540 + do_action( 'pll_update_default_lang', $slug );
614 541
615 542 // Update options
616 543 $this->options['default_lang'] = $slug;
617 544 update_option( 'polylang', $this->options );