Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/breadcrumbs.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");

/*
 * Simple Breadcrumbs for Video Posts Only
 *
*/
function mwp_simple_breadcrumbs() {
	?>
	<div class="breadcrumbs">
		<span class="trail-begin"><a href="<?php echo esc_url(home_url('/')); ?>" title="<?php bloginfo('name'); ?>" rel="home"><?php _e( 'Home', MWP_TEXT_DOMAIN ); ?></a></span>
		<span class="sep"><?php $sep = ' &#187; '; echo $sep; ?></span>
		<?php
		$categories = get_the_category();
		$sep_string = ' &#187; '; 
		$separator 	= '<span class="sep">'.$sep_string.'</span>';
		$toEnd 		= count($categories);
		foreach ($categories as $category) {
			if (0 === --$toEnd) {
				echo '<span class="trail-end"><a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a></span>';
			} else {
				echo '<span class="trail-end"><a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a></span>'.$separator;
			}
		} ?>
	</div>
	<?php
}
/**
 * Breadcrumb Microdata
 *
 * Author: Nitin Yawalkar
 * Converted to Microdata : Mouad Achemli
 * Source : https://wordpress.org/plugins/rdfa-breadcrumb/
 * License: GPL2
 *
*/
function mwp_micro_breadcrumb() {
	/*
	if (is_rtl()) {
		$sep = '&#47;';
	} else {
		$sep = '&#92;';
	}
	*/
	$args = array(
		'prefix' 		=> '',
		'suffix' 		=> '',
		'title' 		=> '',
		'home_title' 	=> __( 'Home', MWP_TEXT_DOMAIN ),
		'separator'		=> '&#187;',
		//'separator'		=> $sep,
		'front_page' 	=> false,
		'show_blog' 	=> false,
		'singular_post_taxonomy' => 'category',
		'echo' 			=> true
	);
	if ( is_front_page() && !$args['front_page'] )
		return apply_filters( 'mwp_micro_breadcrumb', false );
	$title = ( !empty( $args['title'] ) ? '<span class="breadcrumbs-title">' . $args['title'] . '</span>': '' );
	$separator = ( !empty( $args['separator'] ) ) ? "<span class='separator'>{$args['separator']}</span>" : "<span class='separator'>/</span>";
	$items = mwp_micro_breadcrumb_get_items( $args );
	$breadcrumbs = '<div class="breadcrumb breadcrumbs">';
	$breadcrumbs .= $args['prefix'];
	$breadcrumbs .= $title;
	$breadcrumbs .= join( " {$separator} ", $items );
	$breadcrumbs .= $args['suffix'];
	$breadcrumbs .= '</div>';
	$breadcrumbs = apply_filters( 'mwp_micro_breadcrumb', $breadcrumbs );
	if ( !$args['echo'] )
		return $breadcrumbs;
	else
		echo $breadcrumbs;
}
function mwp_micro_breadcrumb_get_items( $args ) {
	
	if (mwp_option('seo-breadcrumb') == 1) {
		$breadcrumb_vocabilare = "";
		$itemprop_url = "";
		$itemprop_title = "";
	} else {
		$breadcrumb_vocabilare = " itemscope itemtype='http://data-vocabulary.org/Breadcrumb'";
		$itemprop_url = "itemprop='url'";
		$itemprop_title = " itemprop='title'";
	}
	global $wp_query;
	$item = array();
	if ( is_front_page() ) {
		$item['last'] = $args['home_title'];
	}
	if ( !is_front_page() )
		$item[] = '<span '.$breadcrumb_vocabilare.'><a '.$itemprop_url.' href="'. home_url( '/' ) .'" class="home"><span'.$itemprop_title.'>' . $args['home_title'] . '</span></a></span>';
	if ( is_home() ) {
		$home_page = get_page( $wp_query->get_queried_object_id() );
		$item = array_merge( $item, mwp_micro_breadcrumb_get_parents( $home_page->post_parent ) );
		$item['last'] = get_the_title( $home_page->ID );
	}
	elseif ( is_singular() ) {
		$post = $wp_query->get_queried_object();
		$post_id = (int) $wp_query->get_queried_object_id();
		$post_type = $post->post_type;
		$post_type_object = get_post_type_object( $post_type );
		if ( 'post' === $wp_query->post->post_type && $args['show_blog'] ) {
			$item[] = '<span '.$breadcrumb_vocabilare.'><a '.$itemprop_url.' href="' . get_permalink( get_option( 'page_for_posts' ) ) . '"><span'.$itemprop_title.'>' . get_the_title( get_option( 'page_for_posts' ) ) . '</span></a></span>';
		}
		if ( 'page' !== $wp_query->post->post_type ) {
			if ( function_exists( 'get_post_type_archive_link' ) && !empty( $post_type_object->has_archive ) )
				$item[] = '<span '.$breadcrumb_vocabilare.'><a '.$itemprop_url.' href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '"><span'.$itemprop_title.'>' . $post_type_object->labels->name . '</span></a></span>';
			if ( isset( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) && is_taxonomy_hierarchical( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) ) {
				$terms = wp_get_object_terms( $post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"] );
				$item = array_merge( $item, mwp_micro_breadcrumb_get_term_parents( $terms[0], $args["singular_{$wp_query->post->post_type}_taxonomy"] ) );
			}
			elseif ( isset( $args["singular_{$wp_query->post->post_type}_taxonomy"] ) )
				$item[] = get_the_term_list( $post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"], '', ', ', '' );
		}
		if ( ( is_post_type_hierarchical( $wp_query->post->post_type ) || 'attachment' === $wp_query->post->post_type ) && $parents = mwp_micro_breadcrumb_get_parents( $wp_query->post->post_parent ) ) {
			$item = array_merge( $item, $parents );
		}
		//$item['last'] = get_the_title();
	}
	else if ( is_archive() ) {
		if ( is_category() || is_tag() || is_tax() ) {
			$term = $wp_query->get_queried_object();
			$taxonomy = get_taxonomy( $term->taxonomy );
			if ( ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent ) && $parents = mwp_micro_breadcrumb_get_term_parents( $term->parent, $term->taxonomy ) )
				$item = array_merge( $item, $parents );
				$item['last'] = $term->name;
		}
		else if ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
			$post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
			$item['last'] = $post_type_object->labels->name;
		}
		else if ( is_date() ) {
			if ( is_day() )
				$item['last'] = __( 'Archives for ', MWP_TEXT_DOMAIN ) . get_the_time( 'F j, Y' );

			elseif ( is_month() )
				$item['last'] = __( 'Archives for ', MWP_TEXT_DOMAIN ) . single_month_title( ' ', false );

			elseif ( is_year() )
				$item['last'] = __( 'Archives for ', MWP_TEXT_DOMAIN ) . get_the_time( 'Y' );
		}
		else if ( is_author() )
			$item['last'] = get_the_author_meta( 'display_name', $wp_query->post->post_author );
	}
	else if ( is_search() )
		$item['last'] = __( 'Search results for "', MWP_TEXT_DOMAIN ) . stripslashes( strip_tags( get_search_query() ) ) . '"';
	else if ( is_404() )
		$item['last'] = __( 'Page Not Found', MWP_TEXT_DOMAIN );
	return apply_filters( 'mwp_micro_breadcrumb_items', $item );
}
function mwp_micro_breadcrumb_get_parents( $post_id = '', $separator = '/' ) {
	
	if (mwp_option('seo-breadcrumb') == 1) {
		$breadcrumb_vocabilare = "";
		$itemprop_url = "";
		$itemprop_title = "";
	} else {
		$breadcrumb_vocabilare = " itemscope itemtype='http://data-vocabulary.org/Breadcrumb'";
		$itemprop_url = "itemprop='url'";
		$itemprop_title = " itemprop='title'";
	}
	
	$parents = array();
	if ( $post_id == 0 )
		return $parents;
	while ( $post_id ) {
		$page = get_page( $post_id );
		$parents[]  = '<span '.$breadcrumb_vocabilare.'><a '.$itemprop_url.' href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '"><span'.$itemprop_title.'>' . get_the_title( $post_id ) . '</span></a></span>';
		$post_id = $page->post_parent;
	}
	if ( $parents )
		$parents = array_reverse( $parents );
	return $parents;
}
function mwp_micro_breadcrumb_get_term_parents( $parent_id = '', $taxonomy = '', $separator = '/' ) {
	
	if (mwp_option('seo-breadcrumb') == 1) {
		$breadcrumb_vocabilare = "";
		$itemprop_url = "";
		$itemprop_title = "";
	} else {
		$breadcrumb_vocabilare = " itemscope itemtype='http://data-vocabulary.org/Breadcrumb'";
		$itemprop_url = "itemprop='url'";
		$itemprop_title = " itemprop='title'";
	}
	
	$html = array();
	$parents = array();
	if ( empty( $parent_id ) || empty( $taxonomy ) )
		return $parents;
	while ( $parent_id ) {
		$parent = get_term( $parent_id, $taxonomy );
		$parents[] = '<span '.$breadcrumb_vocabilare.'><a '.$itemprop_url.' href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '"><span'.$itemprop_title.'>' . $parent->name . '</span></a></span>';
		$parent_id = $parent->parent;
	}
	if ( $parents )
		$parents = array_reverse( $parents );
	return $parents;
}
/**
 * Implements threaded awareness for {@see paged_walk()}.
 * 
 * @link http://wordpress.stackexchange.com/questions/20506
 * @uses Walker
 */
if ( mwp_option( 'single-comments-ajax') == 1) { 
	class Walker_Comment_Paged_Threaded extends Walker_Comment {
		function get_total_children( $ID, $child_elements = array() ) {
			if ( empty( $ID ) || empty( $child_elements[ $ID ] ) )
				return 0;
			$count = count( $child_elements[ $ID ] );
			$id_field = $this->db_fields['id'];
			foreach ( $child_elements[ $ID ] as $child ) {
				if ( ! empty( $child_elements[ $child->$id_field ] ) )
					$count = $count + $this->get_total_children( $child->$id_field, $child_elements );
			}
			return $count;
		}
		function get_top_and_child_elements( $elements ){
			$parent_field = $this->db_fields['parent'];
			$top_elements =
			$child_elements = array();
			foreach ( $elements as $e ) {
				if ( 0 == $e->$parent_field )
					$top_elements[] = $e;
				else
					$child_elements[ $e->$parent_field ][] = $e;
			}
			return array( $top_elements, $child_elements );
		}
		function get_number_of_root_elements( $elements ){
			$per_page = ( int ) get_query_var( 'comments_per_page' );
			if ( 0 === $per_page )
				$per_page = ( int ) get_option( 'comments_per_page' );
			if ( 0 === $per_page )
				$per_page = 1;

			list( $top_elements, $child_elements ) = $this->get_top_and_child_elements( $elements );
			$page_starts = $this->get_element_page_starts( $per_page, $top_elements, $child_elements );

			return count( $page_starts ) * $per_page;
		}
		function get_element_page_starts( $per_page, $top_elements, $child_elements ){
			$id_field = $this->db_fields['id'];
			$page_starts = array( 1 => 0 );
			$stack_count = 0;
			foreach ( $top_elements as $k => $e ) {
				$stack_count = ++$stack_count + $this->get_total_children( $e->$id_field, $child_elements );
				if ( $stack_count < $per_page )
					continue; 
				if ( isset( $top_elements[$k + 1] ) )
					$page_starts[] = $k + 1;

				$stack_count = 0;
			}
			return $page_starts;
		}
		function paged_walk( $elements, $max_depth, $page_num, $per_page ){
			if ( empty( $elements ) || $max_depth < -1 )
				return '';
			$args = array_slice( func_get_args(), 4 );
			$output = '';
			$id_field = $this->db_fields['id'];
			$parent_field = $this->db_fields['parent'];
			$count = -1;
			if ( -1 == $max_depth )
				$total_top = count( $elements );
			if ( $page_num < 1 || $per_page < 0 ) {
				$paging = false;
				$start = 0;
				if ( -1 == $max_depth )
					$end = $total_top;
				$this->max_pages = 1;
			} else {
				$paging = true;
				$start = ( ( int )$page_num - 1 ) * ( int )$per_page;
				$end = $start + $per_page;
				if ( -1 == $max_depth )
					$this->max_pages = ceil( $total_top / $per_page );
			}
			if ( -1 == $max_depth ) {
				if ( ! empty( $args[0]['reverse_top_level'] ) ) {
					$elements = array_reverse( $elements );
					$oldstart = $start;
					$start = $total_top - $end;
					$end = $total_top - $oldstart;
				}
				$empty_array = array();
				foreach ( $elements as $e ) {
					$count++;
					if ( $count < $start )
						continue;
					if ( $count >= $end )
						break;
					$this->display_element( $e, $empty_array, 1, 0, $args, $output );
				}
				return $output;
			}
			list( $top_elements, $child_elements ) = $this->get_top_and_child_elements( $elements );
			$total_top = count( $top_elements );
			if ( $paging && count( $elements ) > $per_page ) {
				$page_starts = $this->get_element_page_starts( $per_page, $top_elements, $child_elements );
				$this->max_pages = count( $page_starts );
				if ( isset( $page_starts[$page_num] ) ) {
					$start = $page_starts[$page_num];
					if ( isset( $page_starts[$page_num + 1] ) )
						$end = $page_starts[$page_num + 1];
					else
						$end = $total_top;
				} else {
					$start = $total_top;
					$end = $start + $per_page;
				}
			} else {
				$start = 0;
				$end = $total_top;
			}
			if ( ! empty( $args[0]['reverse_top_level'] ) )
				$top_elements = array_reverse( $top_elements );
			if ( ! empty( $args[0]['reverse_children'] ) ) {
				foreach ( $child_elements as $parent => $children )
					$child_elements[$parent] = array_reverse( $children );
			}
			foreach ( $top_elements as $k => $e ) {
				if ( $end >= $total_top && $k < $start )
					$this->unset_children( $e, $child_elements );
				if ( $k < $start )
					continue;
				if ( $k >= $end )
					break;
				$this->display_element( $e, $child_elements, $max_depth, 0, $args, $output );
			}
			if ( $end >= $total_top && count( $child_elements ) > 0 ) {
				$empty_array = array();
				foreach ( $child_elements as $orphans )
					foreach ( $orphans as $op )
						$this->display_element( $op, $empty_array, 1, 0, $args, $output );
			}
			return $output;
		}
	}
}

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