WPSEO_Replace_Vars::retrieve_ct_desc_custom_tax_name()
Retrieve a post/page/cpt's custom taxonomies description for use as replacement string.
Метод класса: WPSEO_Replace_Vars{}
Хуков нет.
Возвращает
Строку|null
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->retrieve_ct_desc_custom_tax_name( $var_to_replace );
- $var_to_replace(строка) (обязательный)
- The complete variable to replace which includes the name of the custom taxonomy which description is to be retrieved.
Код WPSEO_Replace_Vars::retrieve_ct_desc_custom_tax_name() WPSEO Replace Vars::retrieve ct desc custom tax name Yoast 24.9
private function retrieve_ct_desc_custom_tax_name( $var_to_replace ) { $replacement = null; if ( is_string( $var_to_replace ) && $var_to_replace !== '' ) { $tax = substr( $var_to_replace, 8 ); if ( ! empty( $this->args->ID ) ) { $terms = get_the_terms( $this->args->ID, $tax ); if ( is_array( $terms ) && $terms !== [] ) { $term = current( $terms ); $term_desc = get_term_field( 'description', $term->term_id, $tax ); if ( $term_desc !== '' ) { $replacement = wp_strip_all_tags( $term_desc ); } } } } return $replacement; }