Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 740 lines (651 sloc) 30.057 kb
9573951 @korbinian first
authored
1 <?php
2 /**
3 * TwentyTen functions and definitions
4 *
5 * Sets up the theme and provides some helper functions. Some helper functions
6 * are used in the theme as custom template tags. Others are attached to action and
7 * filter hooks in WordPress to change core functionality.
8 *
9 * The first function, twentyten_setup(), sets up the theme by registering support
10 * for various features in WordPress, such as post thumbnails, navigation menus, and the like.
11 *
12 * When using a child theme (see http://codex.wordpress.org/Theme_Development and
13 * http://codex.wordpress.org/Child_Themes), you can override certain functions
14 * (those wrapped in a function_exists() call) by defining them first in your child theme's
15 * functions.php file. The child theme's functions.php file is included before the parent
16 * theme's file, so the child theme functions would be used.
17 *
18 * Functions that are not pluggable (not wrapped in function_exists()) are instead attached
19 * to a filter or action hook. The hook can be removed by using remove_action() or
20 * remove_filter() and you can attach your own function to the hook.
21 *
22 * We can remove the parent theme's hook only after it is attached, which means we need to
23 * wait until setting up the child theme:
24 *
25 * <code>
26 * add_action( 'after_setup_theme', 'my_child_theme_setup' );
27 * function my_child_theme_setup() {
28 * // We are providing our own filter for excerpt_length (or using the unfiltered value)
29 * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
30 * ...
31 * }
32 * </code>
33 *
34 * For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
35 *
36 * @package WordPress
37 * @subpackage Starkers
38 * @since Starkers 3.0
39 */
40
41 /**
42 * Set the content width based on the theme's design and stylesheet.
43 *
44 * Used to set the width of images and content. Should be equal to the width the theme
45 * is designed for, generally via the style.css stylesheet.
46 */
47 if ( ! isset( $content_width ) )
48 $content_width = 640;
49
50 /** Tell WordPress to run twentyten_setup() when the 'after_setup_theme' hook is run. */
51 add_action( 'after_setup_theme', 'twentyten_setup' );
52
53 if ( ! function_exists( 'twentyten_setup' ) ):
54 /**
55 * Sets up theme defaults and registers support for various WordPress features.
56 *
57 * Note that this function is hooked into the after_setup_theme hook, which runs
58 * before the init hook. The init hook is too late for some features, such as indicating
59 * support post thumbnails.
60 *
61 * To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's
62 * functions.php file.
63 *
64 * @uses add_theme_support() To add support for post thumbnails and automatic feed links.
65 * @uses register_nav_menus() To add support for navigation menus.
66 * @uses add_custom_background() To add support for a custom background.
67 * @uses add_editor_style() To style the visual editor.
68 * @uses load_theme_textdomain() For translation/localization support.
69 * @uses add_custom_image_header() To add support for a custom header.
70 * @uses register_default_headers() To register the default custom header images provided with the theme.
71 * @uses set_post_thumbnail_size() To set a custom post thumbnail size.
72 *
73 * @since Twenty Ten 1.0
74 */
75 function twentyten_setup() {
76
77 // This theme styles the visual editor with editor-style.css to match the theme style.
78 add_editor_style();
79
80 // This theme uses post thumbnails
81 add_theme_support( 'post-thumbnails' );
82
83 // Add default posts and comments RSS feed links to head
84 add_theme_support( 'automatic-feed-links' );
85
86 // Make theme available for translation
87 // Translations can be filed in the /languages/ directory
88 load_theme_textdomain( 'twentyten', TEMPLATEPATH . '/languages' );
89
90 $locale = get_locale();
91 $locale_file = TEMPLATEPATH . "/languages/$locale.php";
92 if ( is_readable( $locale_file ) )
93 require_once( $locale_file );
94
95 // This theme uses wp_nav_menu() in one location.
96 register_nav_menus( array(
97 'primary' => __( 'Primary Navigation', 'twentyten' ),
98 'top' => __( 'Topnavigation', 'twentyten' ),
99 'sub' => __( 'Subnavigation', 'twentyten' ),
100 ) );
101
102 // This theme allows users to set a custom background
103 add_custom_background();
104
105 // Your changeable header business starts here
106 define( 'HEADER_TEXTCOLOR', '' );
107 // No CSS, just IMG call. The %s is a placeholder for the theme template directory URI.
108 define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
109
110 // The height and width of your custom header. You can hook into the theme's own filters to change these values.
111 // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
112 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 960 ) );
113 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 240 ) );
114
115 // We'll be using post thumbnails for custom header images on posts and pages.
116 // We want them to be 940 pixels wide by 198 pixels tall.
117 // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
118 set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
119
120 // Don't support text inside the header image.
121 define( 'NO_HEADER_TEXT', true );
122 define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 980 ) );
123 define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 300 ) );
124 // Add a way for the custom header to be styled in the admin panel that controls
125 // custom headers. See twentyten_admin_header_style(), below.
126 add_custom_image_header( '', 'twentyten_admin_header_style' );
127
128 // ... and thus ends the changeable header business.
129
130 // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
131 register_default_headers( array(
132 'berries' => array(
133 'url' => '%s/images/headers/starkers.png',
134 'thumbnail_url' => '%s/images/headers/starkers-thumbnail.png',
135 /* translators: header image description */
136 'description' => __( 'Starkers', 'twentyten' )
137 )
138 ) );
139 }
140 endif;
141
142 if ( ! function_exists( 'twentyten_admin_header_style' ) ) :
143 /**
144 * Styles the header image displayed on the Appearance > Header admin panel.
145 *
146 * Referenced via add_custom_image_header() in twentyten_setup().
147 *
148 * @since Twenty Ten 1.0
149 */
150 function twentyten_admin_header_style() {
151 ?>
152 <style type="text/css">
153 /* Shows the same border as on front end */
154 #headimg {
155 border-bottom: 1px solid #000;
156 border-top: 4px solid #000;
157 }
158 /* If NO_HEADER_TEXT is false, you would style the text with these selectors:
159 #headimg #name { }
160 #headimg #desc { }
161 */
162 </style>
163 <?php
164 }
165 endif;
166
167 /**
168 * Makes some changes to the <title> tag, by filtering the output of wp_title().
169 *
170 * If we have a site description and we're viewing the home page or a blog posts
171 * page (when using a static front page), then we will add the site description.
172 *
173 * If we're viewing a search result, then we're going to recreate the title entirely.
174 * We're going to add page numbers to all titles as well, to the middle of a search
175 * result title and the end of all other titles.
176 *
177 * The site title also gets added to all titles.
178 *
179 * @since Twenty Ten 1.0
180 *
181 * @param string $title Title generated by wp_title()
182 * @param string $separator The separator passed to wp_title(). Twenty Ten uses a
183 * vertical bar, "|", as a separator in header.php.
184 * @return string The new title, ready for the <title> tag.
185 */
186 function twentyten_filter_wp_title( $title, $separator ) {
187 // Don't affect wp_title() calls in feeds.
188 if ( is_feed() )
189 return $title;
190
191 // The $paged global variable contains the page number of a listing of posts.
192 // The $page global variable contains the page number of a single post that is paged.
193 // We'll display whichever one applies, if we're not looking at the first page.
194 global $paged, $page;
195
196 if ( is_search() ) {
197 // If we're a search, let's start over:
198 $title = sprintf( __( 'Suchergebnisse für %s', 'twentyten' ), '"' . get_search_query() . '"' );
199 // Add a page number if we're on page 2 or more:
200 if ( $paged >= 2 )
201 $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), $paged );
202 // Add the site name to the end:
203 $title .= " $separator " . get_bloginfo( 'name', 'display' );
204 // We're done. Let's send the new title back to wp_title():
205 return $title;
206 }
207
208 // Otherwise, let's start by adding the site name to the end:
209 $title .= get_bloginfo( 'name', 'display' );
210
211 // If we have a site description and we're on the home/front page, add the description:
212 $site_description = get_bloginfo( 'description', 'display' );
213 if ( $site_description && ( is_home() || is_front_page() ) )
214 $title .= " $separator " . $site_description;
215
216 // Add a page number if necessary:
217 if ( $paged >= 2 || $page >= 2 )
218 $title .= " $separator " . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) );
219
220 // Return the new title to wp_title():
221 return $title;
222 }
223 add_filter( 'wp_title', 'twentyten_filter_wp_title', 10, 2 );
224
225 /**
226 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
227 *
228 * To override this in a child theme, remove the filter and optionally add
229 * your own function tied to the wp_page_menu_args filter hook.
230 *
231 * @since Twenty Ten 1.0
232 */
233 function twentyten_page_menu_args( $args ) {
234 $args['show_home'] = true;
235 return $args;
236 }
237 add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
238
239 /**
240 * Sets the post excerpt length to 40 characters.
241 *
242 * To override this length in a child theme, remove the filter and add your own
243 * function tied to the excerpt_length filter hook.
244 *
245 * @since Twenty Ten 1.0
246 * @return int
247 */
248 function twentyten_excerpt_length( $length ) {
249 return 40;
250 }
251 add_filter( 'excerpt_length', 'twentyten_excerpt_length' );
252
253 /**
254 * Returns a "Continue Reading" link for excerpts
255 *
256 * @since Twenty Ten 1.0
257 * @return string "Continue Reading" link
258 */
259 function twentyten_continue_reading_link() {
260 return ' <a href="'. get_permalink() . '">' . __( 'Weiterlesen <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
261 }
262
263 /**
264 * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and twentyten_continue_reading_link().
265 *
266 * To override this in a child theme, remove the filter and add your own
267 * function tied to the excerpt_more filter hook.
268 *
269 * @since Twenty Ten 1.0
270 * @return string An ellipsis
271 */
272 function twentyten_auto_excerpt_more( $more ) {
273 return ' &hellip;' . twentyten_continue_reading_link();
274 }
275 add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
276
277 /**
278 * Adds a pretty "Continue Reading" link to custom post excerpts.
279 *
280 * To override this link in a child theme, remove the filter and add your own
281 * function tied to the get_the_excerpt filter hook.
282 *
283 * @since Twenty Ten 1.0
284 * @return string Excerpt with a pretty "Continue Reading" link
285 */
286 function twentyten_custom_excerpt_more( $output ) {
287 if ( has_excerpt() && ! is_attachment() ) {
288 $output .= twentyten_continue_reading_link();
289 }
290 return $output;
291 }
292 add_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
293
294 /**
295 * Remove inline styles printed when the gallery shortcode is used.
296 *
297 * Galleries are styled by the theme in Twenty Ten's style.css.
298 *
299 * @since Twenty Ten 1.0
300 * @return string The gallery style filter, with the styles themselves removed.
301 */
302 function twentyten_remove_gallery_css( $css ) {
303 return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
304 }
305 add_filter( 'gallery_style', 'twentyten_remove_gallery_css' );
306
307 if ( ! function_exists( 'twentyten_comment' ) ) :
308 /**
309 * Template for comments and pingbacks.
310 *
311 * To override this walker in a child theme without modifying the comments template
312 * simply create your own twentyten_comment(), and that function will be used instead.
313 *
314 * Used as a callback by wp_list_comments() for displaying the comments.
315 *
316 * @since Twenty Ten 1.0
317 */
318 function twentyten_comment( $comment, $args, $depth ) {
319 $GLOBALS['comment'] = $comment;
320 switch ( $comment->comment_type ) :
321 case '' :
322 ?>
323 <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
324 <div id="comment-<?php comment_ID(); ?>">
325 <div class="comment-details">
326 <div class="comment-author vcard">
327
328 <?php printf( __( '%s <span class="says">meinte am</span>', 'twentyten' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
329 </div><!-- .comment-author .vcard -->
330 <?php if ( $comment->comment_approved == '0' ) : ?>
331 <em><?php _e( 'Dein Kommentar wartet auf die Freischaltung.', 'twentyten' ); ?></em>
332 <br />
333 <?php endif; ?>
334
335 <div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
336 <?php
337 /* translators: 1: date, 2: time */
338 printf( __( '%1$s um %2$s', 'twentyten' ), get_comment_date(), get_comment_time() ); ?></a> Folgendes:<?php edit_comment_link( __( '(Edit)', 'twentyten' ), ' ' );
339 ?>
340 </div><!-- .comment-meta .commentmetadata -->
341 </div>
342
343 <div class="comment-body"><?php comment_text(); ?></div>
344
345 <div class="reply">
346 <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
347 </div><!-- .reply -->
348 </div><!-- #comment-## -->
349
350 <?php
351 break;
352 case 'pingback' :
353 case 'trackback' :
354 ?>
355 <li class="post pingback">
356 <p><?php _e( 'Pingback:', 'twentyten' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __('(Edit)', 'twentyten'), ' ' ); ?></p>
357 <?php
358 break;
359 endswitch;
360 }
361 endif;
362
363 /**
364 * Register widgetized areas, including two sidebars and four widget-ready columns in the footer.
365 *
366 * To override twentyten_widgets_init() in a child theme, remove the action hook and add your own
367 * function tied to the init hook.
368 *
369 * @since Twenty Ten 1.0
370 * @uses register_sidebar
371 */
372 function twentyten_widgets_init() {
373
374 // Area 1, located in the Header.
375 register_sidebar( array(
376 'name' => __( 'Sticker Widget Area', 'twentyten' ),
377 'id' => 'sticker-widget-area',
378 'description' => __( 'sticker widget area', 'twentyten' ),
379 'before_widget' => '<div class="widget">',
380 'after_widget' => '</div>',
381 'before_title' => '<h3 class="widget-title">',
382 'after_title' => '</h3>',
383 ) );
384
385
386 // Area 3, located in the Teaser.
387 register_sidebar( array(
388 'name' => __( 'First Teaser Widget Area', 'twentyten' ),
389 'id' => 'first-teaser-widget-area',
390 'description' => __( 'The first teaser widget area', 'twentyten' ),
391 'before_widget' => '<div class="widget">',
392 'after_widget' => '</div>',
393 'before_title' => '<h3 class="widget-title">',
394 'after_title' => '</h3>',
395 ) );
396
397 // Area 4, located in the Teaser.
398 register_sidebar( array(
399 'name' => __( 'Second Teaser Widget Area', 'twentyten' ),
400 'id' => 'second-teaser-widget-area',
401 'description' => __( 'The second teaser widget area', 'twentyten' ),
402 'before_widget' => '<div class="widget">',
403 'after_widget' => '</div>',
404 'before_title' => '<h3 class="widget-title">',
405 'after_title' => '</h3>',
406 ) );
407
408 // Area 5, located in the sidebar.
409 register_sidebar( array(
410 'name' => __( 'Sidebar Widget Area', 'twentyten' ),
411 'id' => 'sidebar-widget-area',
412 'description' => __( 'The sidebar widget area', 'twentyten' ),
413 'before_widget' => '<div class="widget">',
414 'after_widget' => '</div>',
415 'before_title' => '<h3 class="widget-title">',
416 'after_title' => '</h3>',
417 ) );
418
419 // Area 5, located in the Startpage.
420 register_sidebar( array(
421 'name' => __( 'First Startpage Widget Area', 'twentyten' ),
422 'id' => 'first-startpage-widget-area',
423 'description' => __( 'The first startpage widget area', 'twentyten' ),
424 'before_widget' => '<div class="widget">',
425 'after_widget' => '</div>',
426 'before_title' => '<h3 class="widget-title">',
427 'after_title' => '</h3>',
428 ) );
429
430 register_sidebar( array(
431 'name' => __( 'Second Startpage Widget Area', 'twentyten' ),
432 'id' => 'second-startpage-widget-area',
433 'description' => __( 'The second startpage widget area', 'twentyten' ),
434 'before_widget' => '<div class="widget">',
435 'after_widget' => '</div>',
436 'before_title' => '<h3 class="widget-title">',
437 'after_title' => '</h3>',
438 ) );
439
440
441
442
443 // Area 6, located in the Subcontent. Empty by default.
444 register_sidebar( array(
445 'name' => __( 'First Subcontent Widget Area', 'twentyten' ),
446 'id' => 'first-subcontent-widget-area',
447 'description' => __( 'The first subcontent widget area', 'twentyten' ),
448 'before_widget' => '<div class="widget">',
449 'after_widget' => '</div>',
450 'before_title' => '<h3 class="widget-title">',
451 'after_title' => '</h3>',
452 ) );
453
454 // Area 7, located in the Subcontent. Empty by default.
455 register_sidebar( array(
456 'name' => __( 'Second Subcontent Widget Area', 'twentyten' ),
457 'id' => 'second-subcontent-widget-area',
458 'description' => __( 'The second subcontent widget area', 'twentyten' ),
459 'before_widget' => '<div class="widget">',
460 'after_widget' => '</div>',
461 'before_title' => '<h3 class="widget-title">',
462 'after_title' => '</h3>',
463 ) );
464
465 // Area 8, located in the Subcontent. Empty by default.
466 register_sidebar( array(
467 'name' => __( 'Third Subcontent Widget Area', 'twentyten' ),
468 'id' => 'third-subcontent-widget-area',
469 'description' => __( 'The third subcontent widget area', 'twentyten' ),
470 'before_widget' => '<div class="widget">',
471 'after_widget' => '</div>',
472 'before_title' => '<h3 class="widget-title">',
473 'after_title' => '</h3>',
474 ) );
475
476 // Area 9, located in the footer. Empty by default.
477 register_sidebar( array(
478 'name' => __( 'First Footer Widget Area', 'twentyten' ),
479 'id' => 'first-footer-widget-area',
480 'description' => __( 'The first footer widget area', 'twentyten' ),
481 'before_widget' => '<div class="widget">',
482 'after_widget' => '</div>',
483 'before_title' => '<h3 class="widget-title">',
484 'after_title' => '</h3>',
485 ) );
486
487 // Area 9, located in the footer. Empty by default.
488 register_sidebar( array(
489 'name' => __( 'Second Footer Widget Area', 'twentyten' ),
490 'id' => 'second-footer-widget-area',
491 'description' => __( 'The second footer widget area', 'twentyten' ),
492 'before_widget' => '<div class="widget">',
493 'after_widget' => '</div>',
494 'before_title' => '<h3 class="widget-title">',
495 'after_title' => '</h3>',
496 ) );
497
498 }
499 /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */
500 add_action( 'widgets_init', 'twentyten_widgets_init' );
501
502 /**
503 * Removes the default styles that are packaged with the Recent Comments widget.
504 *
505 * To override this in a child theme, remove the filter and optionally add your own
506 * function tied to the widgets_init action hook.
507 *
508 * @since Twenty Ten 1.0
509 */
510 function twentyten_remove_recent_comments_style() {
511 global $wp_widget_factory;
512 remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
513 }
514 add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
515
516 if ( ! function_exists( 'twentyten_posted_on' ) ) :
517 /**
518 * Prints HTML with meta information for the current post—date/time and author.
519 *
520 * @since Twenty Ten 1.0
521 */
522 function twentyten_posted_on() {
523 printf( __( '<span class="%1$s">Veröffentlicht am</span> %2$s <span class="meta-sep"></span>', 'twentyten' ),
524 'meta-prep meta-prep-author',
525 sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
526 get_permalink(),
527 esc_attr( get_the_time() ),
528 get_the_date()
529 ),
530 sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span> ',
531 get_author_posts_url( get_the_author_meta( 'ID' ) ),
532 sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
533 get_the_author()
534 )
535 );
536 }
537 endif;
538
539 if ( ! function_exists( 'twentyten_posted_in' ) ) :
540 /**
541 * Prints HTML with meta information for the current post (category, tags and permalink).
542 *
543 * @since Twenty Ten 1.0
544 */
545 function twentyten_posted_in() {
546 // Retrieves tag list of current post, separated by commas.
547 $tag_list = get_the_tag_list( '', ', ' );
548 if ( $tag_list ) {
549 $posted_in = __( 'unter %1$s und eingeordnet unter %2$s. Hier der permanente <a href="%3$s" title="Permalink to %4$s" rel="bookmark">Link</a> zu diesem Artikel.', 'twentyten' );
550 } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
551 $posted_in = __( 'unter %1$s. Hier der permanente <a href="%3$s" title="Permalink to %4$s" rel="bookmark">Link</a> zu diesem Artikel.', 'twentyten' );
552 } else {
553 $posted_in = __( 'Hier der permanente <a href="%3$s" title="Permalink to %4$s" rel="bookmark">Link</a> zu diesem Artikel.', 'twentyten' );
554 }
555
556 // Prints the string, replacing the placeholders.
557 printf(
558 $posted_in,
559 get_the_category_list( ', ' ),
560 $tag_list,
561 get_permalink(),
562 the_title_attribute( 'echo=0' )
563 );
564 }
565 endif;
566
567 add_theme_support( 'post-thumbnails' );
568
569 function wpse38241_setup_menu()
570 {
571 register_nav_menu( 'main-menu', 'Main Menu' );
572 }
573 add_action( 'after_setup_theme', 'wpse38241_setup_menu' );
574
575
576 /**
577 * Replaces items with '-' as title with li class="menu_separator"
578 *
579 * @author Thomas Scholz (toscho)
580 */
581 class My_Walker_Nav_Menu extends Walker_Nav_Menu
582 {
583 /**
584 * Start the element output.
585 *
586 * @param string $output Passed by reference. Used to append additional content.
587 * @param object $item Menu item data object.
588 * @param int $depth Depth of menu item. May be used for padding.
589 * @param array $args Additional strings.
590 * @return void
591 */
592 public function start_el( &$output, $item, $depth, $args )
593 {
594 if ( '-' === $item->title )
595 {
596 // you may remove the <hr> here and use plain CSS.
597 $output .= '<li class="menu_separator"><hr>';
598 }
599 else
600 {
601 parent::start_el( &$output, $item, $depth, $args );
602 }
603 }
604 /* Klasse has_children einfuegen */
605 public function display_element($el, &$children, $max_depth, $depth = 0, $args, &$output){
606 $id = $this->db_fields['id'];
607
608 if(isset($children[$el->$id]))
609 $el->classes[] = 'has_children';
610
611 parent::display_element($el, $children, $max_depth, $depth, $args, $output);
612 }
613 }
614
615 function get_custom_excerpt($string, $length){
616 $excerpt = $string;
617 $excerpt = strip_shortcodes($excerpt);
618 $excerpt = strip_tags($excerpt);
619 $the_str = substr($excerpt, 0, $length);
620 return $the_str;
621 }
622
623 function short_title($after = '', $length) {
624 $mytitle = explode(' ', get_the_title(), $length);
625 if (count($mytitle)>=$length) {
626 array_pop($mytitle);
627 $mytitle = implode(" ",$mytitle). $after;
628 } else {
629 $mytitle = implode(" ",$mytitle);
630 }
631 return $mytitle;
632 }
633
634 function dimox_breadcrumbs() {
635
636 $delimiter = '/';
637 $home = 'Startseite'; // text for the 'Home' link
638 $before = '<span class="current">'; // tag before the current crumb
639 $after = '</span>'; // tag after the current crumb
640
641 if ( !is_home() && !is_front_page() || is_paged() ) {
642
643 echo '<div id="crumbs">';
644
645 global $post;
646 $homeLink = get_bloginfo('url');
647 echo '<a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' ';
648
649 if ( is_category() ) {
650 global $wp_query;
651 $cat_obj = $wp_query->get_queried_object();
652 $thisCat = $cat_obj->term_id;
653 $thisCat = get_category($thisCat);
654 $parentCat = get_category($thisCat->parent);
655 if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' '));
656 echo $before . 'Kategorie "' . single_cat_title('', false) . '"' . $after;
657
658 } elseif ( is_day() ) {
659 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
660 echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
661 echo $before . get_the_time('d') . $after;
662
663 } elseif ( is_month() ) {
664 echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
665 echo $before . get_the_time('F') . $after;
666
667 } elseif ( is_year() ) {
668 echo $before . get_the_time('Y') . $after;
669
670 } elseif ( is_single() && !is_attachment() ) {
671 if ( get_post_type() != 'post' ) {
672 $post_type = get_post_type_object(get_post_type());
673 $slug = $post_type->rewrite;
674 echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a> ' . $delimiter . ' ';
675 echo $before . get_the_title() . $after;
676 } else {
677 $cat = get_the_category(); $cat = $cat[0];
678 echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
679 echo $before . get_the_title() . $after;
680 }
681
682 } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
683 $post_type = get_post_type_object(get_post_type());
684 echo $before . $post_type->labels->singular_name . $after;
685
686 } elseif ( is_attachment() ) {
687 $parent = get_post($post->post_parent);
688 $cat = get_the_category($parent->ID); $cat = $cat[0];
689 echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
690 echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter . ' ';
691 echo $before . get_the_title() . $after;
692
693 } elseif ( is_page() && !$post->post_parent ) {
694 echo $before . get_the_title() . $after;
695
696 } elseif ( is_page() && $post->post_parent ) {
697 $parent_id = $post->post_parent;
698 $breadcrumbs = array();
699 while ($parent_id) {
700 $page = get_page($parent_id);
701 $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
702 $parent_id = $page->post_parent;
703 }
704 $breadcrumbs = array_reverse($breadcrumbs);
705 foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' ';
706 echo $before . get_the_title() . $after;
707
708 } elseif ( is_search() ) {
709 echo $before . 'Suchergebnisse für "' . get_search_query() . '"' . $after;
710
711 } elseif ( is_tag() ) {
712 echo $before . 'Artikel mit Schlagwort "' . single_tag_title('', false) . '"' . $after;
713
714 } elseif ( is_author() ) {
715 global $author;
716 $userdata = get_userdata($author);
717 echo $before . 'Artikel von ' . $userdata->display_name . $after;
718
719 } elseif ( is_404() ) {
720 echo $before . 'Fehler 404' . $after;
721 }
722
723 if ( get_query_var('paged') ) {
724 if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
725 echo __('Page') . ' ' . get_query_var('paged');
726 if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
727 }
728
729 echo '</div>';
730
731 }
732 }
733
734 if( !is_admin()){
735 wp_deregister_script('jquery');
736 wp_register_script('jquery', ("/wp-content/themes/piratenkleider/js/jquery.min.js"), false, '1.3.2');
737 wp_enqueue_script('jquery');
738
739 }
Something went wrong with that request. Please try again.