Sindbad~EG File Manager

Current Path : /home/atdotid/www/wp-content/themes/aturtoko/
Upload File :
Current File : //home/atdotid/www/wp-content/themes/aturtoko/functions.php

<?php
  // Register Nav Walker class_alias
  require_once('wp_bootstrap_navwalker.php');

  // Theme Support
  function wpb_theme_setup(){
    add_theme_support('post-thumbnails');

    // Nav Menus
    register_nav_menus(array(
      'primary' => __('Primary Menu')
    ));

    // Post Formats
    add_theme_support('post-formats', array('aside', 'gallery'));
  }

  add_action('after_setup_theme','wpb_theme_setup');

// Excerpt Length Control
function set_excerpt_length(){
  return 15;
}

add_filter('excerpt_length', 'set_excerpt_length');

function wpb_init_widgets($id){
    register_sidebar(array(
      'name'  => 'Sidebar',
      'id'    => 'sidebar',
      'before_widget' => '<div class="sidebar-module">',
      'after_widget'  => '</div>',
      'before_title'  => '<h4>',
      'after_title'   => '</h4>'
    ));
}
    
add_action('widgets_init', 'wpb_init_widgets');

add_filter('get_pagenum_link','untrailingslashit');

function template_chooser($template)   
{    
  global $wp_query;   
  $post_type = get_query_var('post_type');   
  if( $wp_query->is_search && $post_type == 'page' )   
  {
    return locate_template('search.php');  //  redirect to archive-search.php
  }   
  return $template;   
}
add_filter('template_include', 'template_chooser'); 


function wpbeginner_numeric_posts_nav() { 
 
     global $wp_query, $loop;
 if ( $loop ) {
     $total = $loop->max_num_pages;
 } else {
     $total = $wp_query->max_num_pages;
 }
 
     /** Stop execution if there's only 1 page */
     if( $total <= 1 )
         return;
 
     $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
     $max   = intval( $total );
 
     /** Add current page to the array */
     if ( $paged >= 1 )
         $links[] = $paged;
 
     /** Add the pages around the current page to the array */
     if ( $paged >= 3 ) {
         $links[] = $paged - 1;
         $links[] = $paged - 2;
     }
 
     if ( ( $paged + 2 ) <= $max ) {
         $links[] = $paged + 2;
         $links[] = $paged + 1;
     }
 
     echo '<div class="navigation"><ul class="pagination justify-content-center mt-4">' . "\n";
 
     /** Previous Post Link */
     if ( get_previous_posts_link() )
         printf( '<li class="page-item">%s</li>' . "\n", get_previous_posts_link() );
 
     /** Link to first page, plus ellipses if necessary */
     if ( ! in_array( 1, $links ) ) {
         $class = 1 == $paged ? ' class="active"' : '';
 
         printf( '<li class="page-item"%s><a class="page-link" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
 
         if ( ! in_array( 2, $links ) )
             echo '<li class="page-item">…</li>';
     }
 
     /** Link to current page, plus 2 pages in either direction if necessary */
     sort( $links );
     foreach ( (array) $links as $link ) {
         $class = $paged == $link ? ' class="active"' : '';
         printf( '<li class="page-item"%s><a class="page-link" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
     }
 
     /** Link to last page, plus ellipses if necessary */
     if ( ! in_array( $max, $links ) ) {
         if ( ! in_array( $max - 1, $links ) )
             echo '<li class="page-item">…</li>' . "\n";
 
         $class = $paged == $max ? ' class="active"' : '';
         printf( '<li class="page-item"%s><a class="page-link" href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
     }
 
     /** Next Post Link */
     if ( get_next_posts_link() )
         printf( '<li class="page-item">%s</li>' . "\n", get_next_posts_link() );
 
     echo '</ul></div>' . "\n";
 
 }
function get_crumb_array(){
	
	/*
	echo '<xmp>';
	var_export(yoast_breadcrumb('', '', false));
	echo '</xmp>';
	*/
	
	$crumb = array();
	
	//Get all preceding links before the current page
	$dom = new DOMDocument();
	$dom->loadHTML(yoast_breadcrumb('', '', false));
	$items = $dom->getElementsByTagName('a');
	
	foreach ($items as $tag)
		$crumb[] =  array('text' => $tag->nodeValue, 'href' => $tag->getAttribute('href'));			
	
	//Get the current page text and href 
	$items = new DOMXpath($dom);
	$dom = $items->query('//*[contains(@class, "breadcrumb_last")]');
	$crumb[] = array('text' => $dom->item(0)->nodeValue, 'href' => trailingslashit(home_url($wp->request)));
	return $crumb;
}
 
function crumb_nav($crumb){
	$html = '';
	if($crumb) {
		//var_dump($crumb);
		$items = count($crumb) - 1;
		$html .= '<p id="breadcrumbs" class="breadcrumbs">';
    $html .= '<span>';
    $html .= '<a href="/">Home</a>';
    $html .= ' » ';
    $html .= '<a href="/blog">Blog</a>';
    $html .= ' » ';
		foreach($crumb as $k => $v){
			if($k == $items) //If it's the last item then output the text only
				$html .= $v['text'];
			else //preceding items with URLs
				$html .= sprintf('<a href="%s">%s</a> &raquo; ', $v['href'], $v['text']);
		}
		$html .=  '</p>';
	}
	return $html;
}
function crumb_page_nav($crumb){
	$html = '';
	if($crumb) {
		//var_dump($crumb);
		$items = count($crumb) - 1;
		$html .= '<p id="breadcrumbs" class="breadcrumbs">';
    $html .= '<span">';
    $html .= '<a href="/">Home</a>';
    $html .= ' » ';
		foreach($crumb as $k => $v){
			if($k == $items) //If it's the last item then output the text only
				$html .= $v['text'];
			else //preceding items with URLs
				$html .= sprintf('<a href="%s">%s</a> &raquo; ', $v['href'], $v['text']);
		}
		$html .=  '</p>';
	}
	return $html;
}

function search_filter($query) {
  if ( !is_admin() && $query->is_main_query() ) {
    if ($query->is_search) {
      $query->set('post_type', 'post');
    }
  }
}

add_action('pre_get_posts','search_filter');
add_theme_support( 'title-tag' );

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