PluginProbe
Polylang / 2.9
Polylang v2.9
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 | include/model.php +37 -7 2.72.9 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Setups the language and translations model based on WordPress taxonomies
5 8 *
@@ -101,15 +104,8 @@
101 104 $languages[ $k ] = new PLL_Language( $v );
102 105 }
103 106 }
104 107
105 - // Custom flags
106 - if ( ! PLL_ADMIN ) {
107 - foreach ( $languages as $language ) {
108 - $language->set_custom_flag();
109 - }
110 - }
111 -
112 108 /**
113 109 * Filter the list of languages *after* it is stored in the persistent cache
114 110 * /!\ this filter is fired *before* the $polylang object is available
115 111 *
@@ -442,8 +438,42 @@
442 438
443 439 // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
444 440 return $wpdb->get_var( $select . $join . $where );
445 441 }
442 +
443 + /**
444 + * Checks if a term slug exists in a given language, taxonomy, hierarchy
445 + *
446 + * @since 1.9
447 + * @since 2.8 Moved from PLL_Share_Term_Slug::term_exists() to PLL_Model::term_exists_by_slug()
448 + *
449 + * @param string $slug The term slug to test.
450 + * @param string|object $language The language slug or object.
451 + * @param string $taxonomy Optional taxonomy name.
452 + * @param int $parent Optional parent term id.
453 + * @return null|int The term_id of the found term.
454 + */
455 + public function term_exists_by_slug( $slug, $language, $taxonomy = '', $parent = 0 ) {
456 + global $wpdb;
457 +
458 + $select = "SELECT t.term_id FROM {$wpdb->terms} AS t";
459 + $join = " INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id";
460 + $join .= $this->term->join_clause();
461 + $where = $wpdb->prepare( ' WHERE t.slug = %s', $slug );
462 + $where .= $this->term->where_clause( $this->get_language( $language ) );
463 +
464 + if ( ! empty( $taxonomy ) ) {
465 + $where .= $wpdb->prepare( ' AND tt.taxonomy = %s', $taxonomy );
466 + }
467 +
468 + if ( $parent > 0 ) {
469 + $where .= $wpdb->prepare( ' AND tt.parent = %d', $parent );
470 + }
471 +
472 + // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
473 + return $wpdb->get_var( $select . $join . $where );
474 + }
475 +
446 476
447 477 /**
448 478 * Gets the number of posts per language in a date, author or post type archive.
449 479 *