Sindbad~EG File Manager

Current Path : /home/xiedrke/entrepot/wp-content/plugins/realpress/app/Helpers/
Upload File :
Current File : /home/xiedrke/entrepot/wp-content/plugins/realpress/app/Helpers/BreadCrumb.php

<?php

namespace RealPress\Helpers;

use RealPress\Models\PropertyMetaModel;

class BreadCrumb {
	/**
	 * @return array
	 */
	public static function get_breadcrumb() {
		$breadcrumb[] = array(
			'title' => esc_html_x( 'Home', 'breadcrumb', 'realpress' ),
			'link'  => apply_filters( 'realpress/filter/breadcrumb/home-url', home_url() ),
		);

		if ( is_singular( REALPRESS_PROPERTY_CPT ) ) {
			$taxonomy = apply_filters(
				'realpress/filter/breadcrumb/single_property_breadcrumb',
				'realpress-type'
			);

			$terms = PropertyMetaModel::instance( get_the_ID() )->get_property_terms(
				$taxonomy,
				array( 'orderby' => 'parent' )
			);

			if ( ! empty( $terms ) ) {
				$term      = $terms[0];
				$term_name = $term->name;
				$term_link = get_term_link( $term );

				$breadcrumb[] = array(
					'title' => $term_name,
					'link'  => $term_link,
				);
				$child_terms  = PropertyMetaModel::instance( get_the_ID() )->get_property_terms(
					$taxonomy,
					array(
						'orderby' => 'parent',
						'parent'  => $term->term_id,
					)
				);
				if ( ! empty( $child_terms ) ) {
					$child_term = $child_terms[0];
					$term_name  = $child_term->name;
					$term_link  = get_term_link( $child_term );

					$breadcrumb[] = array(
						'title' => $term_name,
						'link'  => $term_link,
					);
				}
			}
			$breadcrumb [] = array(
				'title' => get_the_title(),
			);
		} elseif ( Page::is_property_taxonomy_archive() ) {
			$taxonomy        = get_queried_object()->taxonomy;
			$term_id         = get_queried_object()->term_id;
			$term            = get_term_by( 'id', $term_id, $taxonomy );
			$term_id_parents = array();
			if ( ! empty( $term ) ) {
				$term_id_parent = $term->parent;
				while ( $term_id_parent ) {
					$term_id_parents[] = $term_id_parent;
					$new_parent        = get_term_by( 'id', $term_id_parent, $taxonomy );
					$term_id_parent    = $new_parent->parent;
				}
				if ( ! empty( $term_id_parents ) ) {
					$term_id_parents = array_reverse( $term_id_parents );

					foreach ( $term_id_parents as $term_id_parent ) {
						$parent       = get_term_by( 'id', $term_id_parent, $taxonomy );
						$breadcrumb[] = array(
							'title' => $parent->name,
							'link'  => get_term_link( $parent ),
						);
					}
				}
			}
			$breadcrumb[] = array(
				'title' => $term->name,
			);
		} elseif ( Page::is_agent_detail_page() ) {
			$agent_list_page_id = Settings::get_page_id( 'agent_list_page' );
			$breadcrumb[]       = array(
				'title' => get_the_title( $agent_list_page_id ),
				'link'  => get_permalink( $agent_list_page_id ),
			);
			$author             = get_user_by( 'slug', get_query_var( 'author_name' ) );
			$breadcrumb[]       = array(
				'title' => $author->display_name,
			);
		} elseif ( Page::is_property_archive_page() ) {
			$breadcrumb[] = array(
				'title' => post_type_archive_title( '', false ),
			);
		} elseif ( is_page() ) {
			$breadcrumb[] = array(
				'title' => get_the_title(),
			);
		}

		return $breadcrumb;
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists