| @@ -10,12 +10,13 @@ | ||
| 10 | 10 | |
| 11 | 11 | namespace Parsely\Metadata; |
| 12 | 12 | |
| 13 | 13 | use Parsely\Parsely; |
| 14 | -use Parsely\Utils\Utils; | |
| 15 | 14 | use WP_Post; |
| 16 | 15 | use WP_User; |
| 17 | 16 | |
| 17 | +use function Parsely\Utils\get_default_category; | |
| 18 | + | |
| 18 | 19 | /** |
| 19 | 20 | * Abstract class that implements modular builders for Metadata. |
| 20 | 21 | * |
| 21 | 22 | * It should be extended in subclasses that implement a particular page view to render |
| @@ -364,9 +365,9 @@ | ||
| 364 | 365 | $taxonomy_dropdown_choice = get_the_terms( $post_obj->ID, $parsely_options['custom_taxonomy_section'] ); |
| 365 | 366 | // Get top-level taxonomy name for chosen taxonomy and assign to $parent_name; it will be used |
| 366 | 367 | // as the category value if 'use_top_level_cats' option is checked. |
| 367 | 368 | // Assign as the default category name if no value is checked for the chosen taxonomy. |
| 368 | - $category_name = get_cat_name( Utils::get_default_category() ); | |
| 369 | + $category_name = get_cat_name( get_default_category() ); | |
| 369 | 370 | if ( false !== $taxonomy_dropdown_choice && ! is_wp_error( $taxonomy_dropdown_choice ) ) { |
| 370 | 371 | if ( $parsely_options['use_top_level_cats'] ) { |
| 371 | 372 | $first_term = array_shift( $taxonomy_dropdown_choice ); |
| 372 | 373 | if ( null !== $first_term ) { |
| @@ -410,9 +411,9 @@ | ||
| 410 | 411 | */ |
| 411 | 412 | private function get_top_level_term( int $term_id, string $taxonomy_name ) { |
| 412 | 413 | $parent = get_term_by( 'id', $term_id, $taxonomy_name ); |
| 413 | 414 | |
| 414 | - while ( false !== $parent && 0 !== $parent->parent ) { | |
| 415 | + while ( false !== $parent && isset( $parent->parent ) && 0 !== $parent->parent ) { | |
| 415 | 416 | $parent = get_term_by( 'id', $parent->parent, $taxonomy_name ); |
| 416 | 417 | } |
| 417 | 418 | |
| 418 | 419 | return $parent->name ?? false; |
| @@ -643,9 +644,9 @@ | ||
| 643 | 644 | $tags = explode( '/', $last_tag ); |
| 644 | 645 | } |
| 645 | 646 | |
| 646 | 647 | // Remove default category name from tags if needed. |
| 647 | - $default_category_name = get_cat_name( Utils::get_default_category() ); | |
| 648 | + $default_category_name = get_cat_name( get_default_category() ); | |
| 648 | 649 | return array_diff( $tags, array( $default_category_name ) ); |
| 649 | 650 | } |
| 650 | 651 | |
| 651 | 652 | /** |