SHARE
TWEET

Untitled

a guest Apr 22nd, 2017 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php //Functions ;
  2. define('WEBLIZAR_TEMPLATE_DIR_URI',get_template_directory_uri());  
  3. define('WEBLIZAR_TEMPLATE_DIR',get_template_directory());
  4. define('WEBLIZAR_THEME_FUNCTIONS_PATH',WEBLIZAR_TEMPLATE_DIR.'/functions');
  5.  
  6. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/menu/weblizar_menu_walker.php');
  7. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/weblizar-js-css/weblizar_js_css.php');
  8. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/custom-post-type.php');  
  9. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/metabox.php');
  10. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/taxonomies.php');
  11. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/resize_image/resize_image.php');
  12. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/comment-list/comment-function.php');  
  13. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/wl-footer-contact-widgets.php');
  14. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/wl-footer-recent-posts.php');
  15. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/custom/flickr-widget.php');
  16. require( WEBLIZAR_THEME_FUNCTIONS_PATH . '/shortcodes/shortcodes.php');
  17. require(WEBLIZAR_TEMPLATE_DIR . '/theme-options/theme-update-checker.php'); //THEMEUPDATOR
  18. //require('update_notifier.php');
  19.    //wp title tag starts here
  20.    function weblizar_head( $title, $sep )
  21.    {   global $paged, $page;      
  22.       if ( is_feed() )
  23.          return $title;
  24.       // Add the site name.
  25.       $title .= get_bloginfo( 'name' );
  26.       // Add the site description for the home/front page.
  27.       $site_description = get_bloginfo( 'description' );
  28.       if ( $site_description && ( is_home() || is_front_page() ) )
  29.          $title = "$title $sep $site_description";
  30.       // Add a page number if necessary.
  31.       if ( $paged >= 2 || $page >= 2 )
  32.          $title = "$title $sep " . sprintf( _e( 'Page', 'weblizar' ), max( $paged, $page ) );
  33.       return $title;
  34.    }  
  35.    add_filter( 'wp_title', 'weblizar_head', 10, 2);
  36.    
  37.    add_action( 'after_setup_theme', 'weblizar_setup' );    
  38.    function weblizar_setup()
  39.    {
  40.    
  41.       // Load text domain for translation-ready
  42.       load_theme_textdomain( 'weblizar', WEBLIZAR_THEME_FUNCTIONS_PATH . '/lang' );  
  43.       // This theme uses wp_nav_menu() in one location.
  44.       register_nav_menu( 'primary', __( 'Primary Menu', 'weblizar' ) ); //Navigation
  45.       // theme support    
  46.       $args = array('default-color' => '000000',);
  47.       add_theme_support( 'custom-background', $args);
  48.       add_theme_support( 'automatic-feed-links');
  49.       add_theme_support( 'post-thumbnails' ); //supports featured image
  50.      
  51.       // This theme supports a variety of post formats.
  52.       add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status') );
  53.       global $content_width;
  54.       //content width
  55.       if ( ! isset( $content_width ) ) $content_width = 720; //px
  56.      
  57.       require_once('weblizar-default-settings.php'); //default settings
  58.       require( WEBLIZAR_TEMPLATE_DIR . '/theme-options/option-panel.php' ); // for Custom Menus  
  59.      
  60.       // setup admin pannel defual data for index page      
  61.       $weblizar_default_theme_settings = weblizar_default_settings();  
  62.      
  63.       $weblizar_saved_theme_settings = get_option('weblizar_GL_pro'); // get existing option data      
  64.       if($weblizar_saved_theme_settings) {
  65.          $weblizar_saved_theme_settings = array_merge($weblizar_default_theme_settings, $weblizar_saved_theme_settings);
  66.          update_option('weblizar_GL_pro', $weblizar_saved_theme_settings);   // Set existing and new option data        
  67.       } else {
  68.          add_option('weblizar_GL_pro', $weblizar_default_theme_settings);  // set New option data
  69.       }
  70.    }
  71.       // Read more tag to formatting in blog page
  72.    function weblizar_content_more($more)
  73.    {  global $post;                    
  74.       return '<div class="blog-post-details-item blog-read-more"><a href="'.get_permalink().'">Continue Reading....</a></div>';
  75.    }  
  76.    add_filter( 'the_content_more_link', 'weblizar_content_more' );
  77.    
  78.    // Remove read-more form front blog section  
  79.    function change_excerpt_more( $more ) {    return '';    }
  80.    add_filter('excerpt_more', 'change_excerpt_more');
  81.    
  82.    add_action( 'widgets_init', 'wl_widgets_init');//REGISTER sIDEBAR aND fOOTER wIDGETS
  83.       function wl_widgets_init() {
  84.       /*sidebar*/
  85.       register_sidebar( array(
  86.             'name' => __( 'Sidebar', 'weblizar' ),
  87.             'id' => 'sidebar-primary',
  88.             'description' => __( 'The primary widget area', 'weblizar' ),
  89.             'before_widget' => '<div class="sidebar-block" >',
  90.             'after_widget' => '</div>',
  91.             'before_title' => '<h3 class="h3-sidebar-title sidebar-title">',
  92.             'after_title' => '</h3>',
  93.          ) );
  94.  
  95.       register_sidebar( array(
  96.             'name' => __( 'Footer Widget Area', 'weblizar' ),
  97.             'id' => 'footer-widget-area',
  98.             'description' => __( 'footer widget area', 'weblizar' ),
  99.             'before_widget' => '<div class="col-md-3 col-sm-3 footer-col">',
  100.             'after_widget' => '</div>',
  101.             'before_title' => '<div class="footer-title">',
  102.             'after_title' => '</div>',
  103.          ) );
  104.       }
  105.       /* Breadcrumbs  */
  106.    function weblizar_breadcrumbs() {
  107.     $delimiter = '';
  108.     $home = 'Home'; // text for the 'Home' link
  109.     $before = '<li>'; // tag before the current crumb
  110.     $after = '</li>'; // tag after the current crumb
  111.     echo '<div class="breadcrumb-container"><ol class="breadcrumb">';
  112.     global $post;
  113.     $homeLink = home_url();
  114.     echo '<li><a href="' . $homeLink . '"><i class="icon-home"></i>' . $home . '</a></li>' . $delimiter . ' ';
  115.     if (is_category()) {
  116.         global $wp_query;
  117.         $cat_obj = $wp_query->get_queried_object();
  118.         $thisCat = $cat_obj->term_id;
  119.         $thisCat = get_category($thisCat);
  120.         $parentCat = get_category($thisCat->parent);
  121.         if ($thisCat->parent != 0)
  122.             echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
  123.         echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
  124.     } elseif (is_day()) {
  125.         echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
  126.         echo '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' ';
  127.         echo $before . get_the_time('d') . $after;
  128.     } elseif (is_month()) {
  129.         echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
  130.         echo $before . get_the_time('F') . $after;
  131.     } elseif (is_year()) {
  132.         echo $before . get_the_time('Y') . $after;
  133.     } elseif (is_single() && !is_attachment()) {
  134.         if (get_post_type() != 'post') {
  135.             $post_type = get_post_type_object(get_post_type());
  136.             $slug = $post_type->rewrite;
  137.             echo '<li><a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li> ' . $delimiter . ' ';
  138.             echo $before . get_the_title() . $after;
  139.         } else {
  140.             $cat = get_the_category();
  141.             $cat = $cat[0];
  142.             //echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  143.             echo $before . get_the_title() . $after;
  144.         }
  145.     } elseif (!is_single() && !is_page() && get_post_type() != 'post') {
  146.         $post_type = get_post_type_object(get_post_type());
  147.         echo $before . $post_type->labels->singular_name . $after;
  148.     } elseif (is_attachment()) {
  149.         $parent = get_post($post->post_parent);
  150.         $cat = get_the_category($parent->ID);
  151.         $cat = $cat[0];
  152.         echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  153.         echo '<li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li> ' . $delimiter . ' ';
  154.         echo $before . get_the_title() . $after;
  155.     } elseif (is_page() && !$post->post_parent) {
  156.         echo $before . get_the_title() . $after;
  157.     } elseif (is_page() && $post->post_parent) {
  158.         $parent_id = $post->post_parent;
  159.         $breadcrumbs = array();
  160.         while ($parent_id) {
  161.             $page = get_page($parent_id);
  162.             $breadcrumbs[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
  163.             $parent_id = $page->post_parent;
  164.         }
  165.         $breadcrumbs = array_reverse($breadcrumbs);
  166.         foreach ($breadcrumbs as $crumb)
  167.             echo $crumb . ' ' . $delimiter . ' ';
  168.         echo $before . get_the_title() . $after;
  169.     } elseif (is_search()) {
  170.         echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  171.     } elseif (is_tag()) {
  172.         echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  173.     } elseif (is_author()) {
  174.         global $author;
  175.         $userdata = get_userdata($author);
  176.         echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  177.     } elseif (is_404()) {
  178.         echo $before . 'Error 404' . $after;
  179.     }
  180.     if (get_query_var('paged')) {
  181.         if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
  182.             echo ' (';
  183.         echo __('Page', 'weblizar') . ' ' . get_query_var('paged');
  184.         if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
  185.             echo ')';
  186.     }
  187.     echo '</ol></div>';
  188. }
  189.  
  190.       //PAGINATION
  191.       function kriesi_pagination($pages = '', $range = 2)
  192. {  
  193.      $showitems = ($range * 2)+1;  
  194.  
  195.      global $paged;
  196.      if(empty($paged)) $paged = 1;
  197.  
  198.      if($pages == '')
  199.      {
  200.          global $wp_query;
  201.          $pages = $wp_query->max_num_pages;
  202.          if(!$pages)
  203.          {
  204.              $pages = 1;
  205.          }
  206.      }  
  207.  
  208.      if(1 != $pages)
  209.      {
  210.          echo "<div class='pagination'><a href='".get_pagenum_link($paged - 1)."' class='prev'>&laquo; </a>";
  211.          if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo;</a>";
  212.          if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>";
  213.  
  214.          for ($i=1; $i <= $pages; $i++)
  215.          {
  216.              if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
  217.              {
  218.                 echo ($paged == $i)? "<a class='current'>".$i."</a>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
  219.              }
  220.          }
  221.  
  222.          if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>";  
  223.          if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>&raquo;</a>";
  224.          echo " <a href='".get_pagenum_link($paged + 1)."' class='next'>&raquo;</a></div>\n";
  225.      }
  226. }
  227.  
  228. //excerpt_length
  229. function custom_excerpt_length( $length ) {
  230.    return 110;
  231.    }
  232. add_filter( 'excerpt_length', 'custom_excerpt_length' );
  233. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top