n/disable_primary_term', false ) ) { return $terms; } $post_id = empty( $post_id ) ? $GLOBALS['post']->ID : $post_id; // Get Primary Term. $primary = absint( Helper::get_post_meta( "primary_{$taxonomy}", $post_id ) ); if ( ! $primary ) { return $terms; } $primary_term = null; foreach ( $terms as $index => $term ) { if ( $primary === $term->term_id ) { $primary_term = $term; unset( $terms[ $index ] ); array_unshift( $terms, $primary_term ); break; } } return $terms; } /** * Hide rank math meta keys * * @param bool $is_protected Whether the key is considered protected. * @param string $meta_key Meta key. * * @return bool */ public function hide_rank_math_meta( $is_protected, $meta_key ) { return Str::starts_with( 'rank_math_', $meta_key ) ? true : $is_protected; } /** * Filters the permalink for a post of a custom post type. * * @param string $post_link The post's permalink. * @param WP_Post $post The post in question. * @param object $taxonomy The post taxonomy. */ private function sanitize_post_type_link( &$post_link, $post, $taxonomy ) { $find = "%{$taxonomy}%"; if ( ! Str::contains( $find, $post_link ) ) { return; } $primary_term = $this->get_primary_term( $taxonomy, $post->ID ); if ( false !== $primary_term ) { // Get the hierarchical terms. $parents = $this->get_hierarchical_link( $primary_term ); // Replace the placeholder rewrite tag with hierarchical terms. $post_link = str_replace( $find, $parents, $post_link ); } } /** * Get chain of hierarchical links. * * @param WP_Term|WP_Error $term The term in question. * * @return string */ private function get_hierarchical_link( $term ) { if ( is_wp_error( $term ) ) { return $term->slug; } $chain = []; $name = $term->slug; if ( $term->parent && ( $term->parent !== $term->term_id ) ) { $chain[] = $this->get_hierarchical_link( get_term( $term->parent, $term->taxonomy ) ); } $chain[] = $name; return implode( '/', $chain ); } /** * Get primary term of the post. * * @param string $taxonomy Taxonomy name. * @param int $post_id Post ID. * * @return object|false Primary term on success, false if there are no terms, WP_Error on failure. */ private function get_primary_term( $taxonomy, $post_id ) { // Early Bail if Primary taxonomy is not enabled on the site. $post_type = get_post_type( $post_id ); if ( empty( $post_type ) || ! Helper::get_settings( 'titles.pt_' . $post_type . '_primary_taxonomy', false ) ) { return false; } $primary = Helper::get_post_meta( "primary_{$taxonomy}", $post_id ); if ( ! $primary ) { return false; } // Early Bail if Primary term is not assigned to the post. $terms = wp_get_post_terms( $post_id, $taxonomy, [ 'fields' => 'ids' ] ); if ( empty( $terms ) || ! in_array( absint( $primary ), $terms, true ) ) { return false; } $primary = get_term( $primary, $taxonomy ); return is_wp_error( $primary ) || empty( $primary ) ? false : $primary; } }
Fatal error: Uncaught Error: Class "RankMath\Common" not found in /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php:301 Stack trace: #0 /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php(185): RankMath->instantiate() #1 /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php(164): RankMath->setup() #2 /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php(539): RankMath::get() #3 /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php(543): rank_math() #4 /htdocs/emploitogo.info/wp-settings.php(589): include_once('/htdocs/emploit...') #5 /htdocs/emploitogo.info/wp-config.php(112): require_once('/htdocs/emploit...') #6 /htdocs/emploitogo.info/wp-load.php(50): require_once('/htdocs/emploit...') #7 /htdocs/emploitogo.info/wp-blog-header.php(13): require_once('/htdocs/emploit...') #8 /htdocs/emploitogo.info/index.php(17): require('/htdocs/emploit...') #9 {main} thrown in /htdocs/emploitogo.info/wp-content/plugins/seo-by-rank-math/rank-math.php on line 301