??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/pgtankstorage.sg/wp-content/plugins/polylang/src/term-slug.php
⬅ Kembali
<?php
/**
* @package Polylang
*/
/**
* Class for handling term slugs.
*
* @since 3.7
*/
class PLL_Term_Slug {
/**
* @var PLL_Model
*/
private $model;
/**
* @var string
*/
private $slug;
/**
* @var string
*/
private $taxonomy;
/**
* @var string
*/
private $name;
/**
* @var int
*/
private $term_id;
/**
* @var PLL_Language
*/
private $lang;
/**
* @var int
*/
private $parent;
/**
* Constructor.
*
* @since 3.7
*
* @param PLL_Model $model Instance of PLL_Model.
* @param string $slug The term slug.
* @param string $taxonomy The term taxonomy.
* @param string $name The term name.
* @param int $term_id The term ID if exists, or 0 if there's no need to know that we are editing an existing term.
*/
public function __construct( PLL_Model $model, string $slug, string $taxonomy, string $name, int $term_id = 0 ) {
$this->model = $model;
$this->slug = $slug;
$this->taxonomy = $taxonomy;
$this->name = $name;
$this->term_id = $term_id;
}
/**
* Tells if the suffix can be added or not.
*
* @since 3.7
*
* @return bool True if the suffix can be added, false otherwise.
*/
private function can_add_suffix() {
/**
* Filters the subsequently inserted term language.
*
* @since 3.3
*
* @param PLL_Language|null $lang Found language object, null otherwise.
* @param string $taxonomy Term taxonomy.
* @param string $slug Term slug.
*/
$lang = apply_filters( 'pll_inserted_term_language', null, $this->taxonomy, $this->slug );
if ( ! $lang instanceof PLL_Language ) {
return false;
}
$this->lang = $lang;
$this->parent = 0;
if ( is_taxonomy_hierarchical( $this->taxonomy ) ) {
/**
* Filters the subsequently inserted term parent.
*
* @since 3.3
*
* @param int $parent Parent term ID, 0 if none.
* @param string $taxonomy Term taxonomy.
* @param string $slug Term slug.
*/
$this->parent = apply_filters( 'pll_inserted_term_parent', 0, $this->taxonomy, $this->slug );
$this->slug .= $this->maybe_get_parent_suffix();
}
if ( ! $this->slug ) {
if ( $this->model->term_exists( $this->name, $this->taxonomy, $this->parent, $this->lang ) ) {
// Returns the current empty slug if the term exists with the same name and an empty slug.
// Same as WP does when providing a term with a name that already exists and no slug.
return false;
} else {
$this->slug = sanitize_title( $this->name );
}
}
// Check if the slug exists globally, excluding the current term if we're editing.
$args = array(
'slug' => $this->slug,
'taxonomy' => $this->taxonomy,
'hide_empty' => false,
'fields' => 'ids',
'lang' => '', // Disable Polylang language filter.
'update_term_meta_cache' => false, // Don't need term meta.
);
$terms = get_terms( $args );
// Return true if the slug is already used by another term (excluding the term being edited).
return is_array( $terms ) && ! empty( array_diff( $terms, array( $this->term_id ) ) );
}
/**
* Returns the parent suffix for the slug only if parent slug is the same as the given one.
* Recursively appends the parents slugs like WordPress does.
*
* @since 3.3
* @since 3.7 Moved from `PLL_Share_Term_Slug` to `PLL_Term_Slug`.
*
* @return string Parents slugs if they are the same as the child slug, empty string otherwise.
*/
private function maybe_get_parent_suffix() {
$parent_suffix = '';
$the_parent = get_term( $this->parent, $this->taxonomy );
if ( ! $the_parent instanceof WP_Term || $the_parent->slug !== $this->slug ) {
return $parent_suffix;
}
/**
* Mostly copied from {@see wp_unique_term_slug()}.
*/
while ( ! empty( $the_parent ) ) {
$parent_term = get_term( $the_parent, $this->taxonomy );
if ( ! $parent_term instanceof WP_Term ) {
break;
}
$parent_suffix .= '-' . $parent_term->slug;
if ( ! term_exists( $this->slug . $parent_suffix ) ) {
break;
}
$the_parent = $parent_term->parent;
}
return $parent_suffix;
}
/**
* Returns the term slug, suffixed or not.
*
* @since 3.7
*
* @param string $separator The separator for the slug suffix.
* @return string The slug with or without suffix.
*/
public function get_suffixed_slug( string $separator ): string {
if ( ! $this->can_add_suffix() ) {
return $this->slug;
}
$term_id = (int) $this->model->term_exists_by_slug( $this->slug, $this->lang, $this->taxonomy, $this->parent );
// If no term exists in the given language with that slug, it can be created, or if we are editing the existing term.
if ( ! $term_id || $this->term_id === $term_id ) {
return $this->slug . $separator . $this->lang->slug;
}
// Different term exists in same language: no suffix, WordPress will handle uniqueness.
return $this->slug;
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
📁 Capabilities
dir
—
2026-06-17 21:10
📁 Model
dir
—
2026-06-17 21:10
📁 Options
dir
—
2026-06-17 21:10
📁 admin
dir
—
2026-06-17 21:10
📁 frontend
dir
—
2026-06-17 21:10
📁 install
dir
—
2026-06-17 21:10
📁 integrations
dir
—
2026-06-17 21:10
📁 modules
dir
—
2026-06-17 21:10
📁 settings
dir
—
2026-06-17 21:10
🐘 api.php
php
21.8 KB
2026-06-17 21:10
🐘 base.php
php
6.1 KB
2026-06-17 21:10
🐘 cache.php
php
2.4 KB
2026-06-17 21:10
🐘 class-polylang.php
php
8.3 KB
2026-06-17 21:10
🐘 constant-functions.php
php
1.8 KB
2026-06-17 21:10
🐘 cookie.php
php
3 KB
2026-06-17 21:10
🐘 crud-posts.php
php
14.7 KB
2026-06-17 21:10
🐘 crud-terms.php
php
8.8 KB
2026-06-17 21:10
🐘 default-term.php
php
6.4 KB
2026-06-17 21:10
🐘 filter-rest-routes.php
php
5 KB
2026-06-17 21:10
🐘 filters-links.php
php
5.6 KB
2026-06-17 21:10
🐘 filters-sanitization.php
php
3.2 KB
2026-06-17 21:10
🐘 filters-widgets-options.php
php
2.6 KB
2026-06-17 21:10
🐘 filters.php
php
12.9 KB
2026-06-17 21:10
🐘 format-util.php
php
3 KB
2026-06-17 21:10
🐘 functions.php
php
5.1 KB
2026-06-17 21:10
🐘 language-deprecated.php
php
7.1 KB
2026-06-17 21:10
🐘 language-factory.php
php
9.4 KB
2026-06-17 21:10
🐘 language.php
php
18.1 KB
2026-06-17 21:10
🐘 license.php
php
9.4 KB
2026-06-17 21:10
🐘 links-abstract-domain.php
php
3.2 KB
2026-06-17 21:10
🐘 links-default.php
php
3 KB
2026-06-17 21:10
🐘 links-directory.php
php
9.5 KB
2026-06-17 21:10
🐘 links-domain.php
php
2.9 KB
2026-06-17 21:10
🐘 links-model.php
php
6.5 KB
2026-06-17 21:10
🐘 links-permalinks.php
php
5.6 KB
2026-06-17 21:10
🐘 links-subdomain.php
php
2.2 KB
2026-06-17 21:10
🐘 links.php
php
1.4 KB
2026-06-17 21:10
🐘 mo.php
php
3.4 KB
2026-06-17 21:10
🐘 model.php
php
23 KB
2026-06-17 21:10
🐘 nav-menu.php
php
4.5 KB
2026-06-17 21:10
🐘 olt-manager.php
php
3 KB
2026-06-17 21:10
🐘 query.php
php
7.7 KB
2026-06-17 21:10
🐘 rest-request.php
php
4.2 KB
2026-06-17 21:10
🐘 static-pages.php
php
6.3 KB
2026-06-17 21:10
🐘 switcher.php
php
11 KB
2026-06-17 21:10
🐘 term-slug.php
php
4.9 KB
2026-06-17 21:10
🐘 translatable-object-with-types-interface.php
php
1 KB
2026-06-17 21:10
🐘 translatable-object-with-types-trait.php
php
2 KB
2026-06-17 21:10
🐘 translatable-object.php
php
17.6 KB
2026-06-17 21:10
🐘 translatable-objects.php
php
3.7 KB
2026-06-17 21:10
🐘 translate-option.php
php
13.1 KB
2026-06-17 21:10
🐘 translated-object.php
php
18.9 KB
2026-06-17 21:10
🐘 translated-post.php
php
17.2 KB
2026-06-17 21:10
🐘 translated-term.php
php
14.8 KB
2026-06-17 21:10
🐘 walker-dropdown.php
php
3.8 KB
2026-06-17 21:10
🐘 walker-list.php
php
2.5 KB
2026-06-17 21:10
🐘 walker.php
php
2.4 KB
2026-06-17 21:10
🐘 widget-calendar.php
php
11.6 KB
2026-06-17 21:10
🐘 widget-languages.php
php
5.3 KB
2026-06-17 21:10