'; } add_action( 'admin_head', 'favicon4admin' ); /* load "login.css" for the login */ function custom_login() { echo ''; } add_action('login_head', 'custom_login'); /* add custom theme-options */ require_once(get_stylesheet_directory().'/inc/theme-options.php'); /* add twitter and wiki profile */ add_filter('user_contactmethods','scapegoat_add_twitter_contactmethod',10,1); function scapegoat_add_twitter_contactmethod( $contactmethods ) { /* Add Twitter */ $contactmethods['twitter'] = __('Twitter (without @)','scapegoat'); /* Add Wiki */ $contactmethods['wiki'] = __('Wiki (Username)','scapegoat'); return $contactmethods; } /* add custom image-sizes */ if ( function_exists( 'add_theme_support' ) ) { add_theme_support('post-thumbnails'); add_image_size('featured', 1440, 486, true); add_image_size('featured-medium', 720, 243, true); add_image_size('featured-small', 480, 320, true); } /*-----------------------------------------------------------------------------------*/ /* Navigation /*-----------------------------------------------------------------------------------*/ /* register all menus */ add_action( 'init', 'scapegoat_register_my_menus' ); function scapegoat_register_my_menus() { register_nav_menus( array( 'header' => __('Header','scapegoat'), 'footer' => __('Footer','scapegoat') ) ); } function scapegoat_fallback_menu() { wp_page_menu( array( 'show_home' => __('Start','scapegoat') ) ); } /* add css class for li with submenu */ class My_Walker_Nav_Menu extends Walker_Nav_Menu { public function display_element($el, &$children, $max_depth, $depth = 0, $args, &$output) { $id = $this->db_fields['id']; if(isset($children[$el->$id])) $el->classes[] = 'has-children'; parent::display_element($el, $children, $max_depth, $depth, $args, $output); } function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' accesskey="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; // First applying the filters. After that, underline the accesskey in the title if present... $item_title = apply_filters( 'the_title', $item->title, $item->ID ); if( ! empty( $item->xfn ) ) { $letterpos = strpos($item_title, esc_attr( $item->xfn ) ); $item_title = substr($item_title, 0, $letterpos)."".substr($item_title, $letterpos, 1)."".substr($item_title, $letterpos+1); } $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . $item_title . $args->link_after; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } /*-----------------------------------------------------------------------------------*/ /* Sidebars /*-----------------------------------------------------------------------------------*/ add_action( 'widgets_init', 'my_register_sidebars' ); function my_register_sidebars() { register_sidebar( array( 'id'=>'main-sidebar', 'name'=>__('Main-Sidebar','scapegoat'), 'description' => __('The default sidebar.','scapegoat'), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'id'=>'footer-sidebar-1', 'name'=>__('Footer-Sidebar-1','scapegoat'), 'description' => __('Widgets for the Footer-section.','scapegoat'), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'id'=>'footer-sidebar-2', 'name'=>__('Footer-Sidebar-2','scapegoat'), 'description' => __('Widgets for the Footer-section.','scapegoat'), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'id'=>'footer-sidebar-3', 'name'=>__('Footer-Sidebar-3','scapegoat'), 'description' => __('Widgets for the Footer-section.','scapegoat'), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'id'=>'footer-sidebar-4', 'name'=>__('Footer-Sidebar-4','scapegoat'), 'description' => __('Widgets for the Footer-section.','scapegoat'), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } /* Add support for custom headers */ add_theme_support( 'custom-header', array( 'width' => 1440, 'height' => 486, 'header-text' => false, 'uploads' => true ) ); function scapegoat_header_image_style() { if (get_header_image()) { echo ''; } } add_filter('wp_head', 'scapegoat_header_image_style'); /*-----------------------------------------------------------------------------------*/ /* Shortcodes /*-----------------------------------------------------------------------------------*/ /* Enable shortcodes in widget areas */ add_filter( 'widget_text', 'do_shortcode' ); /* Replace WP autop formatting */ if (!function_exists( "scapegoat_remove_wpautop")) { function scapegoat_remove_wpautop($content) { $content = do_shortcode( shortcode_unautop( $content ) ); $content = preg_replace( '#^<\/p>|^
|

$#', '', $content); return $content; } } /* Two Columns */ function scapegoat_shortcode_two_columns_one( $atts, $content = null ) { return '

' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'two_columns_one', 'scapegoat_shortcode_two_columns_one' ); function scapegoat_shortcode_two_columns_one_last( $atts, $content = null ) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'two_columns_one_last', 'scapegoat_shortcode_two_columns_one_last' ); /* Three Columns */ function scapegoat_shortcode_three_columns_one($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'three_columns_one', 'scapegoat_shortcode_three_columns_one' ); function scapegoat_shortcode_three_columns_one_last($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'three_columns_one_last', 'scapegoat_shortcode_three_columns_one_last' ); function scapegoat_shortcode_three_columns_two($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'three_columns_two', 'scapegoat_shortcode_three_columns_two' ); function scapegoat_shortcode_three_columns_two_last($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'three_columns_two_last', 'scapegoat_shortcode_three_columns_two_last' ); /* Four Columns */ function scapegoat_shortcode_four_columns_one($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_one', 'scapegoat_shortcode_four_columns_one' ); function scapegoat_shortcode_four_columns_one_last($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_one_last', 'scapegoat_shortcode_four_columns_one_last' ); function scapegoat_shortcode_four_columns_two($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_two', 'scapegoat_shortcode_four_columns_two' ); function scapegoat_shortcode_four_columns_two_last($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_two_last', 'scapegoat_shortcode_four_columns_two_last' ); function scapegoat_shortcode_four_columns_three($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_three', 'scapegoat_shortcode_four_columns_three' ); function scapegoat_shortcode_four_columns_three_last($atts, $content = null) { return '
' . scapegoat_remove_wpautop($content) . '
'; } add_shortcode( 'four_columns_three_last', 'scapegoat_shortcode_four_columns_three_last' ); /* Divide Text Shortcode */ function scapegoat_shortcode_divider($atts, $content = null) { return '
'; } add_shortcode( 'divider', 'scapegoat_shortcode_divider' ); function scapegoat_button( $atts, $content = null ) { extract(shortcode_atts(array( 'link' => '#', 'target' => '', 'color' => '', 'size' => '', 'form' => '', 'font' => '', ), $atts)); $color = ($color) ? ' '.$color. '-btn' : ''; $size = ($size) ? ' '.$size. '-btn' : ''; $form = ($form) ? ' '.$form. '-btn' : ''; $font = ($font) ? ' '.$font. '-btn' : ''; $target = ($target == 'blank') ? ' target="_blank"' : ''; $out = '' .do_shortcode($content). ''; return $out; } add_shortcode('button', 'scapegoat_button'); /* add custom caption-function */ function scapegoat_custom_caption($attr, $content = null) { /* New-style shortcode with the caption inside the shortcode with the link and image tags. */ if ( ! isset( $attr['caption'] ) ) { if ( preg_match( '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is', $content, $matches ) ) { $content = $matches[1]; $attr['caption'] = trim( $matches[2] ); } } $output = apply_filters('img_caption_shortcode', '', $attr, $content); if ( $output != '' ) return $output; extract(shortcode_atts(array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr)); if ( 1 > (int) $width || empty($caption) ) return $content; if ( $id ) $id = 'id="' . esc_attr($id) . '" '; return '
'. do_shortcode($content) .''. $caption .'
'; } add_shortcode('wp_caption', 'scapegoat_custom_caption'); add_shortcode('caption', 'scapegoat_custom_caption'); /* catch the first image */ function catch_post_image($size = 'thumbnail') { global $post; $photos = get_children( array( 'post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ); if ($photos) { $photo = array_shift($photos); $catched = wp_get_attachment_image($photo->ID, $size); return '
' . $catched . '
'; } return false; } /*-----------------------------------------------------------------------------------*/ /* Custom Excerpt /*-----------------------------------------------------------------------------------*/ function custom_wp_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ( '' == $text ) { // Retrieve the post content $text = get_the_content(''); // Delete all shortcode tags from the content $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); // MODIFY THIS. Add the allowed HTML tags separated by a comma $allowed_tags = '

,
,
'; $text = strip_tags($text, $allowed_tags); // MODIFY THIS. change the excerpt word count to any integer you like $excerpt_word_count = 55; $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); // MODIFY THIS. change the excerpt endind to something else //$excerpt_end = '[...] ' . __("more","scapegoat") .' →'; //$excerpt_end = '[...]'; $excerpt_end = '[...]'; $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if ( count($words) > $excerpt_length ) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); } remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'custom_wp_trim_excerpt'); function custom_excerpt($excerpt_length = 55, $id = false, $echo = true) { $text = ''; if($id) { $the_post = & get_post( $my_id = $id ); $text = ($the_post->post_excerpt) ? $the_post->post_excerpt : $the_post->post_content; } else { global $post; $text = ($post->post_excerpt) ? $post->post_excerpt : get_the_content(''); } $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $text = strip_tags($text); $excerpt_more = ' ' . '[...]'; $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if ( count($words) > $excerpt_length ) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); } if($echo) echo apply_filters('the_content', $text); else return $text; } function get_custom_excerpt($excerpt_length = 55, $id = false, $echo = false) { return custom_excerpt($excerpt_length, $id, $echo); } /*-----------------------------------------------------------------------------------*/ /* Current Page /*-----------------------------------------------------------------------------------*/ function current_paged( $var = '' ) { if( empty( $var ) ) { global $wp_query; if( !isset( $wp_query->max_num_pages ) ) return; $pages = $wp_query->max_num_pages; } else { global $$var; if( !is_a( $$var, 'WP_Query' ) ) return; if( !isset( $$var->max_num_pages ) || !isset( $$var ) ) return; $pages = absint( $$var->max_num_pages ); } if( $pages < 1 ) return; $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; echo __('Page ','scapegoat') . $page . __(' of ','scapegoat') . $pages; } /*-----------------------------------------------------------------------------------*/ /* Pagination /*-----------------------------------------------------------------------------------*/ function wp_pagination_navi($num_page_links = 5, $min_max_offset = 2){ global $wp_query; /* Do not show paging on single pages */ if( !is_single() ){ $current_page = intval(get_query_var('paged')); $total_pages = $wp_query->max_num_pages; $left_offset = floor(($num_page_links - 1) / 2); $right_offset = ceil(($num_page_links -1) / 2); if( empty($current_page) || $current_page == 0 ) { $current_page = 1; } // More than one page -> render pagination if ( $total_pages > 1 ) { echo ''; echo _e('Page ','scapegoat'); echo $current_page; echo _e(' of ','scapegoat'); echo $total_pages; echo ''; echo '

'; //Close pagination } } } /*-----------------------------------------------------------------------------------*/ /* Submenu /*-----------------------------------------------------------------------------------*/ function submenu() { global $post; if(!is_home()) { if ($post->post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } $children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0"); if ($children) { ?> »'; $home = __('Start','scapegoat'); $before = ''; $after = ''; if(!is_home() && !is_front_page() || is_paged()) { echo ''; } } /*-----------------------------------------------------------------------------------*/ /* Image Widget /*-----------------------------------------------------------------------------------*/ class banner extends WP_Widget { function banner() { parent::__construct( 'banner', __('Banner','scapegoat'), array( 'description' => __('A simple Widget for Images.','scapegoat') ) ); } function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if ($title) echo $before_title . $title . $after_title; if ($instance['picture'] && $instance['link']) { ?>

comment_parent < 1) { $comment_counter ++; } $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-"> comment_parent < 1) {echo '' . $comment_counter . '';} ?>
    comment_approved == '0') : ?>
    ]+/', 'scapegoat_relativeimgurl_callback', $content); } function scapegoat_relativeimgurl_callback($matches) { $link = $matches[0]; $site_link = wp_make_link_relative(home_url()); $link = preg_replace("%src=\"$site_link%i", 'src="', $link); return $link; } add_filter('the_content', 'scapegoat_relativeimgurl'); function scapegoat_relativeurl($content) { return preg_replace_callback('/]+/', 'scapegoat_relativeurl_callback', $content); } function scapegoat_relativeurl_callback($matches) { $link = $matches[0]; $site_link = wp_make_link_relative(home_url()); $link = preg_replace("%href=\"$site_link%i", 'href="', $link); return $link; } add_filter('the_content', 'scapegoat_relativeurl'); function scapegoat_relative_urls() { if (is_admin() || is_feed() || get_query_var('sitemap')) { return; } $filters = array( // 'post_link', /* we leave this for social media plugins, that expect absolute links */ 'post_type_link', 'page_link', 'attachment_link', 'get_shortlink', 'post_type_archive_link', 'get_pagenum_link', 'get_comments_pagenum_link', 'term_link', 'search_link', 'day_link', 'month_link', 'year_link', 'script_loader_src', 'style_loader_src', ); foreach ($filters as $filter) { add_filter($filter, 'scapegoat_make_link_relative'); } } add_action('template_redirect', 'scapegoat_relative_urls'); function scapegoat_make_link_relative($url) { $current_site_url = get_site_url(); if (!empty($GLOBALS['_wp_switched_stack'])) { $switched_stack = $GLOBALS['_wp_switched_stack']; $blog_id = end($switched_stack); if ($GLOBALS['blog_id'] != $blog_id) { $current_site_url = get_site_url($blog_id); } } $current_host = parse_url($current_site_url, PHP_URL_HOST); $host = parse_url($url, PHP_URL_HOST); if($current_host == $host) { $url = wp_make_link_relative($url); } return $url; }