Guest User

Untitled

a guest
Feb 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.04 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.     Functions
  5.    
  6.     Establishes the core iFeature functions.
  7.    
  8.     Copyright (C) 2011 CyberChimps
  9. */
  10.  
  11. $options = get_option('ifeature');
  12.  
  13. /* Begin custom excerpt functions. */  
  14.  
  15. /* Localization */
  16.        
  17.     load_theme_textdomain( 'ifeature', TEMPLATEPATH . '/languages' );
  18.  
  19.         $locale = get_locale();
  20.         $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  21.         if ( is_readable( $locale_file ) )
  22.             require_once( $locale_file );
  23.  
  24. /* Begin breadcrumb function. */   
  25.  
  26. function ifeature_breadcrumbs() {
  27.  
  28.   $delimiter = '&raquo;';
  29.   $home = 'Home'; // text for the 'Home' link
  30.   $before = '<span class="current">'; // tag before the current crumb
  31.   $after = '</span>'; // tag after the current crumb
  32.  
  33.   if ( !is_home() && !is_front_page() || is_paged() ) {
  34.  
  35.     echo '<div id="crumbs">';
  36.  
  37.     global $post;
  38.     $homeLink = home_url();
  39.     echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
  40.  
  41.     if ( is_category() ) {
  42.       global $wp_query;
  43.       $cat_obj = $wp_query->get_queried_object();
  44.       $thisCat = $cat_obj->term_id;
  45.       $thisCat = get_category($thisCat);
  46.       $parentCat = get_category($thisCat->parent);
  47.       if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
  48.       echo $before . 'Archive for category "' . single_cat_title('', false) . '"' . $after;
  49.  
  50.     } elseif ( is_day() ) {
  51.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  52.       echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
  53.       echo $before . get_the_time('d') . $after;
  54.  
  55.     } elseif ( is_month() ) {
  56.       echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
  57.       echo $before . get_the_time('F') . $after;
  58.  
  59.     } elseif ( is_year() ) {
  60.       echo $before . get_the_time('Y') . $after;
  61.  
  62.     } elseif ( is_single() && !is_attachment() ) {
  63.       if ( get_post_type() != 'post' ) {
  64.         $post_type = get_post_type_object(get_post_type());
  65.         $slug = $post_type->rewrite;
  66.         echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
  67.         echo $before . get_the_title() . $after;
  68.       } else {
  69.         $cat = get_the_category(); $cat = $cat[0];
  70.         echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  71.         echo $before . get_the_title() . $after;
  72.       }
  73.  
  74.     } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
  75.       $post_type = get_post_type_object(get_post_type());
  76.       echo $before . $post_type->labels->singular_name . $after;
  77.  
  78.     } elseif ( is_attachment() ) {
  79.       $parent = get_post($post->post_parent);
  80.       $cat = get_the_category($parent->ID); $cat = $cat[0];
  81.       echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
  82.       echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
  83.       echo $before . get_the_title() . $after;
  84.  
  85.     } elseif ( is_page() && !$post->post_parent ) {
  86.       echo $before . get_the_title() . $after;
  87.  
  88.     } elseif ( is_page() && $post->post_parent ) {
  89.       $parent_id  = $post->post_parent;
  90.       $breadcrumbs = array();
  91.       while ($parent_id) {
  92.         $page = get_page($parent_id);
  93.         $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
  94.         $parent_id  = $page->post_parent;
  95.       }
  96.       $breadcrumbs = array_reverse($breadcrumbs);
  97.       foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
  98.       echo $before . get_the_title() . $after;
  99.  
  100.     } elseif ( is_search() ) {
  101.       echo $before . 'Search results for "' . get_search_query() . '"' . $after;
  102.  
  103.     } elseif ( is_tag() ) {
  104.       echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after;
  105.  
  106.     } elseif ( is_author() ) {
  107.        global $author;
  108.       $userdata = get_userdata($author);
  109.       echo $before . 'Articles posted by ' . $userdata->display_name . $after;
  110.  
  111.     } elseif ( is_404() ) {
  112.       echo $before . 'Error 404' . $after;
  113.     }
  114.  
  115.     if ( get_query_var('paged') ) {
  116.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
  117.       echo __( 'Page', 'ifeature') . ' ' . get_query_var('paged');
  118.       if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
  119.     }
  120.  
  121.     echo '</div>';
  122.  
  123.   }
  124. } // end ifeature_breadcrumbs()
  125.  
  126.  
  127. function ifeature_new_excerpt_more($more) {
  128.  
  129.     global $options;
  130.    
  131.         if ($options['if_excerpt_link_text'] == '') {
  132.             $linktext = '(Read More...)';
  133.         }
  134.    
  135.         else {
  136.             $linktext = $options['if_excerpt_link_text'];
  137.         }
  138.    
  139.     global $post;
  140.     return '<a href="'. get_permalink($post->ID) . '"> <br /><br /> '.$linktext.'</a>';
  141. }
  142. add_filter('excerpt_more', 'ifeature_new_excerpt_more');
  143.  
  144. function ifeature_new_excerpt_length($length) {
  145.  
  146.     global $options;
  147.    
  148.         if ($options['if_excerpt_length'] == '') {
  149.             $length = '55';
  150.         }
  151.    
  152.         else {
  153.             $length = $options['if_excerpt_length'];
  154.         }
  155.  
  156.     return $length;
  157. }
  158. add_filter('excerpt_length', 'ifeature_new_excerpt_length');
  159.  
  160. /* End excerpt functions. */
  161.  
  162. /* Add auto-feed links support. */ 
  163.     add_theme_support('automatic-feed-links');
  164.    
  165. /* Add post-thumb support. */
  166.  
  167.     global $options;
  168.    
  169.     if($options['if_featured_image_height'] == "") {
  170.             $featureheight = '100';
  171.     }      
  172.    
  173.     else {
  174.         $featureheight = $options['if_featured_image_height'];
  175.        
  176.     }
  177.    
  178.         if ($options['if_featured_image_width'] == "") {
  179.             $featurewidth = '100';
  180.     }      
  181.    
  182.     else {
  183.         $featurewidth = $options['if_featured_image_width'];
  184.     }
  185.     add_theme_support( 'post-thumbnails' );
  186.     set_post_thumbnail_size( $featureheight, $featurewidth, true );
  187.  
  188. // This theme allows users to set a custom background
  189. add_custom_background();
  190.    
  191. // This theme styles the visual editor with editor-style.css to match the theme style.
  192. add_editor_style();
  193.  
  194. /**
  195. * Attach CSS3PIE behavior to elements
  196. * Add elements here that need PIE applied
  197. */  
  198. function ifeature_render_ie_pie() { ?>
  199. <style type="text/css" media="screen">
  200. #header li a, .postmetadata, .post_container, .wp-caption, .sidebar-widget-style, .sidebar-widget-title {
  201.   behavior: url('<?php echo get_template_directory_uri(); ?>/library/pie/PIE.htc');
  202. }
  203. </style>
  204. <?php
  205. }
  206.  
  207. add_action('wp_head', 'ifeature_render_ie_pie', 8);
  208.  
  209. // + 1 Button
  210.  
  211. function ifeature_plusone(){
  212.    
  213.     $path =  get_template_directory_uri() ."/library/js/";
  214.  
  215.     $script = "
  216.        
  217.         <script type=\"text/javascript\" src=\"".$path."plusone.js\"></script>
  218.         ";
  219.    
  220.     echo $script;
  221. }
  222. add_action('wp_head', 'ifeature_plusone');
  223.  
  224.    
  225. // Load jQuery
  226. if ( !is_admin() )
  227. {
  228.   function ifeature_frontend_scripts()
  229.   {
  230.     wp_enqueue_script('jquery');
  231.   }
  232.   add_action('wp_enqueue_scripts', 'ifeature_frontend_scripts');
  233.  
  234. }
  235. // Nivo Slider
  236.  
  237. function ifeature_add_nivoslider(){
  238.      
  239.     $path =  get_template_directory_uri() ."/library/ns/";
  240.  
  241.     $script = "
  242.        
  243.         <script type=\"text/javascript\" src=\"".$path."jquery.nivo.slider.js\"></script>
  244.         ";
  245.    
  246.     echo $script;
  247. }
  248. add_action('wp_head', 'ifeature_add_nivoslider');
  249.  
  250.  
  251.     // Register superfish scripts
  252.    
  253. function ifeature_add_scripts() {
  254.  
  255.     if (!is_admin()) { // Add the scripts, but not to the wp-admin section.
  256.     // Adjust the below path to where scripts dir is, if you must.
  257.     $scriptdir = get_template_directory_uri() ."/library/sf/";
  258.  
  259.     // Register the Superfish javascript files
  260.     wp_register_script( 'superfish', $scriptdir.'sf.js', false, '1.4.8');
  261.     wp_register_script( 'sf-menu', $scriptdir.'sf-menu.js');
  262.     // Now the superfish CSS
  263.    
  264.     //load the scripts and style.
  265.     wp_enqueue_style('superfish-css');
  266.     wp_enqueue_script('superfish');
  267.     wp_enqueue_script('sf-menu');
  268.     } // end the !is_admin function
  269. } //end add_our_scripts function
  270.  
  271. //Add our function to the wp_head. You can also use wp_print_scripts.
  272. add_action( 'wp_head', 'ifeature_add_scripts',0);
  273.    
  274.     // Register menu names
  275.    
  276.     function ifeature_register_menus() {
  277.     register_nav_menus(
  278.     array( 'header-menu' =>  'Header Menu' , 'footer-menu' =>  'Footer Menu' )
  279.   );
  280. }
  281.     add_action( 'init', 'ifeature_register_menus' );
  282.    
  283.     // Menu fallback
  284.    
  285.     function ifeature_menu_fallback() {
  286.     global $post; ?>
  287.    
  288.     <ul id="menu-nav" class="sf-menu">
  289.     <?php wp_list_pages( 'title_li=&sort_column=menu_order&depth=3'); ?>
  290.     </ul><?php
  291. }
  292.  
  293.     //Register Widgetized Sidebar and Footer
  294.  
  295. function ifeature_widgets_init() {    
  296.     register_sidebar(array(
  297.         'name' => 'Sidebar Widgets',
  298.         'id'   => 'sidebar-widgets',
  299.         'description'   => 'These are widgets for the sidebar.',
  300.         'before_widget' => '<div id="%1$s" class="sidebar-widget-style">',
  301.         'after_widget'  => '</div>',
  302.         'before_title'  => '<h2 class="sidebar-widget-title">',
  303.         'after_title'   => '</h2>'
  304.     ));
  305.    
  306.     register_sidebar(array(
  307.         'name' => 'Footer',
  308.         'id'   => 'footer-widgets',
  309.         'description'   => 'These are widgets for the footer.',
  310.         'before_widget' => '<div class="footer-widgets">',
  311.         'after_widget' => '</div>',
  312.         'before_title' => '<h3 class="footer-widget-title">',
  313.         'after_title' => '</h3>',
  314.     ));
  315. }
  316. add_action( 'widgets_init', 'ifeature_widgets_init' );
  317.    
  318. if ( ! isset( $content_width ) ) $content_width = 640;
  319.  
  320. //Add link to theme settings in Admin bar
  321.  
  322. function ifeature_admin_link() {
  323.  
  324.     global $wp_admin_bar;
  325.  
  326.     $wp_admin_bar->add_menu( array( 'id' => 'iFeature', 'title' => 'iFeature Settings', 'href' => admin_url('themes.php?page=theme_options')  ) );
  327.  
  328. }
  329. add_action( 'admin_bar_menu', 'ifeature_admin_link', 113 );
  330.    
  331. //iFeature theme options file
  332.    
  333. require_once ( get_template_directory() . '/library/options/options.php' );
  334. require_once ( get_template_directory() . '/library/options/options-themes.php' );
  335. require_once ( get_template_directory() . '/library/options/meta-box.php' );
  336. ?>
Add Comment
Please, Sign In to add comment