<?php
/**
* The Term Class
*
* @since 0.9.0
* @package RankMath
* @subpackage RankMath\Core
* @author Rank Math <support@rankmath.com>
*/
namespace RankMath;
use WP_Term;
defined( 'ABSPATH' ) || exit;
/**
* Term class.
*/
class Term extends Metadata {
/**
* Type of object metadata is for
*
* @var string
*/
protected $meta_type = 'term';
/**
* Retrieve Term instance.
*
* @param mixed $term Term to get either (string) term name, (int) term ID or (object) term.
* @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for
* disambiguating potentially shared terms.
* @return Term|false Term object, false otherwise.
*/
public static function get( $term = 0, $taxonomy = null ) {
$term = self::get_term_id( $term, $taxonomy );
if ( empty( $term ) ) {
return null;
}
if ( isset( self::$objects[ $term ] ) && 'term' === self::$objects[ $term ]->meta_type ) {
return self::$objects[ $term ];
}
$_term = new self( WP_Term::get_instance( $term, $taxonomy ) );
$_term->object_id = $term;
self::$objects[ $term ] = $_term;
return $_term;
}
/**
* Get term ID.
*
* @param mixed $term Term to get either (string) term name, (int) term ID or (object) term.
* @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for
* disambiguating potentially shared terms.
*/
private static function get_term_id( $term = 0, $taxonomy = null ) {
if ( is_string( $term ) ) {
$term = get_term_by( 'slug', $term, $taxonomy );
} elseif ( is_int( $term ) && 0 === absint( $term ) ) {
$term = $GLOBALS['wp_query']->get_queried_object();
}
if ( is_object( $term ) && isset( $term->term_id ) ) {
return $term->term_id;
}
return false;
}
/**
* Get term meta value.
*
* @param string $key Meta key.
* @param mixed $term Term name, term ID, or term object.
* @param string $taxonomy Optional. Limit matched terms to those matching `$taxonomy`. Only used for
* disambiguating potentially shared terms.
* @param string $default_value Default value to use when metadata does not exists.
* @return mixed
*/
public static function get_meta( $key, $term = 0, $taxonomy = null, $default_value = '' ) {
$term = self::get( $term, $taxonomy );
if ( is_null( $term ) || ! $term->is_found() ) {
return $default_value;
}
return $term->get_metadata( $key, $default_value );
}
/**
* Check if the current query is for multiple terms (e.g. /term-1,term-2/).
*
* @return bool
*/
public static function is_multiple_terms_query() {
global $wp_query;
if ( ! is_tax() && ! is_tag() && ! is_category() ) {
return false;
}
$term = get_queried_object();
$queried_terms = $wp_query->tax_query->queried_terms;
if ( empty( $queried_terms[ $term->taxonomy ]['terms'] ) ) {
return false;
}
return count( $queried_terms[ $term->taxonomy ]['terms'] ) > 1;
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| 3rdparty/ | 2026-07-21 14:14 | 568.06 KB | 76129f60960:kunden | dxwrx-r--r | |
| abilities/ | 2026-07-21 14:14 | 135.66 KB | 76129f60960:kunden | dxwrx-r--r | |
| admin/ | 2026-07-21 14:14 | 567.8 KB | 76129f60960:kunden | dxwrx-r--r | |
| cli/ | 2026-07-21 14:14 | 836 B | 76129f60960:kunden | dxwrx-r--r | |
| frontend/ | 2026-07-21 14:14 | 105.79 KB | 76129f60960:kunden | dxwrx-r--r | |
| helpers/ | 2026-07-21 14:14 | 138.04 KB | 76129f60960:kunden | dxwrx-r--r | |
| metaboxes/ | 2026-07-21 14:14 | 28 B | 76129f60960:kunden | dxwrx-r--r | |
| module/ | 2026-07-21 14:14 | 29.13 KB | 76129f60960:kunden | dxwrx-r--r | |
| modules/ | 2026-07-21 14:14 | 4.47 MB | 76129f60960:kunden | dxwrx-r--r | |
| opengraph/ | 2026-07-21 14:14 | 56.01 KB | 76129f60960:kunden | dxwrx-r--r | |
| replace-variables/ | 2026-07-21 14:14 | 69.13 KB | 76129f60960:kunden | dxwrx-r--r | |
| rest/ | 2026-07-21 14:14 | 56.29 KB | 76129f60960:kunden | dxwrx-r--r | |
| settings/ | 2026-07-21 14:14 | 69.92 KB | 76129f60960:kunden | dxwrx-r--r | |
| traits/ | 2026-07-21 14:14 | 12.61 KB | 76129f60960:kunden | dxwrx-r--r | |
| updates/ | 2026-07-21 14:14 | 19.48 KB | 76129f60960:kunden | dxwrx-r--r | |
| class-auto-updater.php | 2026-07-21 14:14 | 2.23 KB | 76129f60960:kunden | -xw-x----- | |
| class-cmb2.php | 2026-07-21 14:14 | 11.38 KB | 76129f60960:kunden | -xw-x----- | |
| class-common.php | 2026-07-21 14:14 | 7.02 KB | 76129f60960:kunden | -xw-x----- | |
| class-compatibility.php | 2026-07-21 14:14 | 2.52 KB | 76129f60960:kunden | -xw-x----- | |
| class-data-encryption.php | 2026-07-21 14:14 | 4.07 KB | 76129f60960:kunden | -xw-x----- | |
| class-defaults.php | 2026-07-21 14:14 | 1.13 KB | 76129f60960:kunden | -xw-x----- | |
| class-frontend-seo-score.php | 2026-07-21 14:14 | 9.78 KB | 76129f60960:kunden | -xw-x----- | |
| class-helper.php | 2026-07-21 14:14 | 11.3 KB | 76129f60960:kunden | -xw-x----- | |
| class-installer.php | 2026-07-21 14:14 | 23.4 KB | 76129f60960:kunden | -xw-x----- | |
| class-json-manager.php | 2026-07-21 14:14 | 2.78 KB | 76129f60960:kunden | -xw-x----- | |
| class-kb.php | 2026-07-21 14:14 | 12.72 KB | 76129f60960:kunden | -xw-x----- | |
| class-metadata.php | 2026-07-21 14:14 | 3.49 KB | 76129f60960:kunden | -xw-x----- | |
| class-post.php | 2026-07-21 14:14 | 4.68 KB | 76129f60960:kunden | -xw-x----- | |
| class-rewrite.php | 2026-07-21 14:14 | 9.57 KB | 76129f60960:kunden | -xw-x----- | |
| class-settings.php | 2026-07-21 14:14 | 3.41 KB | 76129f60960:kunden | -xw-x----- | |
| class-term.php | 2026-07-21 14:14 | 3.04 KB | 76129f60960:kunden | -xw-x----- | |
| class-thumbnail-overlay.php | 2026-07-21 14:14 | 7.89 KB | 76129f60960:kunden | -xw-x----- | |
| class-tracking.php | 2026-07-21 14:14 | 12.61 KB | 76129f60960:kunden | -xw-x----- | |
| class-update-email.php | 2026-07-21 14:14 | 5.27 KB | 76129f60960:kunden | -xw-x----- | |
| class-updates.php | 2026-07-21 14:14 | 2.62 KB | 76129f60960:kunden | -xw-x----- | |
| class-user.php | 2026-07-21 14:14 | 1.55 KB | 76129f60960:kunden | -xw-x----- | |
| index.php | 2026-07-21 14:14 | 28 B | 76129f60960:kunden | -xw-x----- | |
| interface-runner.php | 2026-07-21 14:14 | 380 B | 76129f60960:kunden | -xw-x----- | |
| template-tags.php | 2026-07-21 14:14 | 2.03 KB | 76129f60960:kunden | -xw-x----- | |