0,
'height' => 0,
'default-image' => $defaultoptions['logo'],
'uploads' => true,
'random-default' => false,
'flex-height' => true,
'flex-width' => true,
'header-text' => false,
'suggested-height' => $defaultoptions['logo-height'],
'suggested-width' => $defaultoptions['logo-width'],
'max-width' => 350,
);
add_theme_support( 'custom-header', $args );
$args = array(
'default-color' => $defaultoptions['background-header-color'],
'default-image' => $defaultoptions['background-header-image'],
'background_repeat' => 'repeat-x',
'default-position-x' => 'left',
'wp-head-callback' => 'piratenkleider_custom_background_cb',
);
/**
* piratenkleider custom background callback.
*
*/
function piratenkleider_custom_background_cb() {
global $defaultoptions;
global $options;
// $background is the saved custom image, or the default image.
$background = set_url_scheme( get_background_image() );
// $color is the saved custom color.
// A default has to be specified in style.css. It will not be printed here.
$color = get_theme_mod( 'background_color' );
if ( ! $background && ! $color )
return;
$style = $color ? "background-color: #$color;" : '';
if ( $background ) {
$image = " background-image: url('$background');";
if ($background == $defaultoptions['background-header-image']) {
$style .= $image;
} else {
$repeat = get_theme_mod( 'background_repeat', 'repeat-x' );
if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
$repeat = 'repeat-x';
$repeat = " background-repeat: $repeat;";
$positionx = get_theme_mod( 'background_position_x', 'left' );
if ( ! in_array( $positionx, array( 'center', 'right', 'left' ) ) )
$positionx = 'left';
$positiony = get_theme_mod( 'background_position_y', 'top' );
if ( ! in_array( $positiony, array( 'top', 'bottom' ) ) )
$positiony = 'top';
$position = " background-position: $positionx $positiony;";
$attachment = get_theme_mod( 'background_attachment', 'scroll' );
if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
$attachment = 'scroll';
$attachment = " background-attachment: $attachment;";
$style .= $image . $repeat . $position . $attachment;
}
}
echo '';
}
add_theme_support( 'custom-background', $args );
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions
}
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'bigslider', $options[ 'bigslider-thumb-width'], $options['bigslider-thumb-height'], $options['bigslider-thumb-crop'] );
add_image_size( 'highslider', $options[ 'highslider-width'], $options['highslider-height'], $options['highslider-crop'] );
add_image_size( 'teaser-thumb', $options['teaser-thumbnail_width'], $options['teaser-thumbnail_height'], $options['teaser-thumbnail_crop'] );
add_image_size( 'linktipp-thumb', $options['linktipp-thumbnail_width'], $options['linktipp-thumbnail_height'], $options['linktipp-thumbnail_crop'] );
add_image_size( 'person-thumb', $options['person-thumbnail_width'], $options['person-thumbnail_height'], $options['person-thumbnail_crop'] );
add_image_size( $options['sidebar-thumbnail_name'], $options['sidebar-thumbnail_width'], $options['sidebar-thumbnail_height'], $options['sidebar-thumbnail_crop'] );
add_image_size( $options['bannerlink_name'], $options['bannerlink-width'] );
if ($options['feed-addthumbnail']) {
add_image_size( $options['feed-thumb-sizename'], $options['feed-thumb-width'], $options['feed-thumb-height'], $options['feed-thumb-crop'] );
}
}
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Main navigation', 'piratenkleider' ),
'top' => __( 'Website Menu', 'piratenkleider' ),
'sub' => __( 'Tecnical navigation', 'piratenkleider' ),
) );
if ($options['login_errors']==0) {
/** Abschalten von Fehlermeldungen auf der Loginseite */
add_filter('login_errors', create_function('$a', "return null;"));
}
/** Entfernen der Wordpressversionsnr im Header */
remove_action('wp_head', 'wp_generator');
/* Zulassen von Shortcodes in Widgets */
add_filter('widget_text', 'do_shortcode');
if ($options['yt-alternativeembed']) {
/* Filter fuer YouTube Embed mit nocookie: */
wp_embed_register_handler( 'ytnocookie', '#https?://www\.youtube\-nocookie\.com/embed/([a-z0-9\-_]+)#i', 'wp_embed_handler_ytnocookie' );
wp_embed_register_handler( 'ytnormal', '#https?://www\.youtube\.com/watch\?v=([a-z0-9\-_]+)#i', 'wp_embed_handler_ytnocookie' );
wp_embed_register_handler( 'ytnormal2', '#https?://www\.youtube\.com/watch\?feature=player_embedded&v=([a-z0-9\-_]+)#i', 'wp_embed_handler_ytnocookie' );
}
function wp_embed_handler_ytnocookie( $matches, $attr, $url, $rawattr ) {
global $defaultoptions;
$relvideo = '';
if ($defaultoptions['yt-norel']==1) {
$relvideo = '?rel=0';
}
$embed = sprintf(
'
',
get_template_directory_uri(),
esc_attr($matches[1]),
$defaultoptions['yt-content-width'],
$defaultoptions['yt-content-height'],
$relvideo
);
return apply_filters( 'embed_ytnocookie', $embed, $matches, $attr, $url, $rawattr );
}
if (isset($options['feed-overwriteauthorstring']) && (strlen(trim($options['feed-overwriteauthorstring']))>1 )) {
add_filter( 'the_author', 'feed_author' );
function feed_author($name) {
global $options;
if( is_feed() && !is_admin()) {
return $options['feed-overwriteauthorstring'];
} else {
return $name;
}
}
}
}
endif;
add_action( 'after_setup_theme', 'piratenkleider_setup' );
require( get_template_directory() . '/inc/widgets.php' );
function piratenkleider_scripts() {
global $options;
global $defaultoptions;
$userstyle = 0;
if ( !is_admin() ) {
$userstyle = 0;
if ((isset($options['aktiv-stylefile']) && ($options['aktiv-stylefile'] > 0) && (wp_get_attachment_url($options['aktiv-stylefile'])) )
&& (isset($options['stylefile-position'])) && ($options['stylefile-position']>0)) {
$userstyle = 1;
}
if (($userstyle==1) && ($options['stylefile-position']==1)) {
wp_enqueue_style( 'stylefile', wp_get_attachment_url($options['aktiv-stylefile']));
}
if (($userstyle==0) || (($userstyle==1) && ($options['stylefile-position']<3))) {
if ((isset($options['aktiv-alternativestyle'])) && ($options['aktiv-alternativestyle'] != 'style.css')) {
wp_enqueue_style( 'alternativestyle', get_template_directory_uri().'/css/'.$options['aktiv-alternativestyle'] );
} else {
$theme = wp_get_theme();
wp_register_style( 'piratenkleider', get_bloginfo( 'stylesheet_url' ), false, $theme['Version'] );
wp_enqueue_style( 'piratenkleider' );
}
}
if (($userstyle==1) && ($options['stylefile-position'] > 1)) {
wp_enqueue_style( 'stylefile', wp_get_attachment_url($options['aktiv-stylefile']));
}
if (($userstyle==0) || (($userstyle==1) && ($options['stylefile-position']!=4))) {
if ((isset($options['css-colorfile'])) && (strlen(trim($options['css-colorfile']))>2)) {
wp_enqueue_style( 'color', get_template_directory_uri().'/css/'.$options['css-colorfile'] );
}
if ((isset($options['aktiv-linkicons'])) && ($options['aktiv-linkicons']==1)) {
wp_enqueue_style( 'basemod_linkicons', $defaultoptions['src-linkicons-css'] );
}
if ( is_singular() ) {
$nosidebar = get_post_meta( get_the_ID(), 'piratenkleider_nosidebar', true );
$custom_fields = get_post_custom();
if ( ( !empty( $nosidebar ) && $nosidebar==1)
|| ((isset($custom_fields['fullsize'])) && ($custom_fields['fullsize'][0] == true))) {
wp_enqueue_style( 'basemod_sidebarbottom', $defaultoptions['src-basemod_sidebarbottom'] );
}
}
if ((isset($options['position_sidebarbottom'])) && ($options['position_sidebarbottom'] ==1)) {
wp_enqueue_style( 'basemod_sidebarbottom', $defaultoptions['src-basemod_sidebarbottom'] );
}
}
if ((isset($options['aktiv-hamburger'])) && ($options['aktiv-hamburger']==1)) {
wp_enqueue_style( 'hamburger', $defaultoptions['src-hamburger-css'] );
wp_enqueue_script( 'hamburger', $defaultoptions['src-hamburger-js'], array('jquery', 'jquery-ui-core'), $defaultoptions['js-version'] );
}
wp_enqueue_script( 'layoutjs', $defaultoptions['src-layoutjs'], array('jquery'), $defaultoptions['js-version'] );
if (is_singular() && ($options['aktiv-commentreplylink']==1) && get_option( 'thread_comments' )) {
wp_enqueue_script(
'comment-reply',
$defaultoptions['src-comment-reply'],
false,
$defaultoptions['js-version']
);
}
}
}
add_action('wp_enqueue_scripts', 'piratenkleider_scripts');
function piratenkleider_dequeue_fonts() {
wp_dequeue_style( 'twentytwelve-fonts' );
}
add_action( 'wp_enqueue_scripts', 'piratenkleider_dequeue_fonts', 11 );
function piratenkleider_addfonts() {
global $options;
global $default_fonts;
$output = "";
$setfont = "";
if ((isset($options['fonts-content'])) && ($options['fonts-content'] != 'none')) {
$setfont = $options['fonts-content'];
$seturl=0;
if (isset($default_fonts[$setfont]['webfont'])
&& ($default_fonts[$setfont]['webfont']==1)) {
$output .= '@font-face { font-family: FontPiratenkleiderDefault; local: '.$setfont.'; src: ';
if (isset($default_fonts[$setfont]['eot'])) {
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['eot'].') format("embedded-opentype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['ttf'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['ttf'].') format("truetype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['woff'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['woff'].') format("woff")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['svg'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['svg'].') format("svg")';
} $output .= ";}\n";
$output .= "body,.defaultfont,.teaserlinks ul li a span { font-family: FontPiratenkleiderDefault; }\n";
} else {
$output .= 'body,.defaultfont,.teaserlinks ul li a span { font-family: '.$default_fonts[$setfont]['family'].'; }';
$output .= "\n";
}
}
if ((isset($options['fonts-headers'])) && ($options['fonts-headers'] != 'none')) {
$setfont = $options['fonts-headers'];
$seturl=0;
if (isset($default_fonts[$setfont]['webfont'])
&& ($default_fonts[$setfont]['webfont']==1)) {
$output .= '@font-face { font-family: FontPiratenkleiderHeadlines; local: '.$setfont.'; src: ';
if (isset($default_fonts[$setfont]['eot'])) {
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['eot'].') format("embedded-opentype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['ttf'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['ttf'].') format("truetype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['woff'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['woff'].') format("woff")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['svg'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['svg'].') format("svg")';
} $output .= ";}\n";
$output .= "h1,h2,h3,h4,h5,h6,.headlinefont,.tagcloud,.post-nav a,.first-startpage-widget-area li a { font-family: FontPiratenkleiderHeadlines; }\n";
} else {
$output .= 'h1,h2,h3,h4,h5,h6,.headlinefont,.tagcloud,.post-nav a,.first-startpage-widget-area li a { font-family: '.$default_fonts[$setfont]['family'].'; }';
$output .= "\n";
}
}
if ((isset($options['fonts-menuheaders'])) && ($options['fonts-menuheaders'] != 'none')) {
$setfont = $options['fonts-menuheaders'];
$seturl=0;
if (isset($default_fonts[$setfont]['webfont'])
&& ($default_fonts[$setfont]['webfont']==1)) {
$output .= '@font-face { font-family: FontPiratenkleiderMenuHeadlines; local: '.$setfont.'; src: ';
if (isset($default_fonts[$setfont]['eot'])) {
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['eot'].') format("embedded-opentype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['ttf'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['ttf'].') format("truetype")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['woff'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['woff'].') format("woff")';
$seturl = 1;
}
if (isset($default_fonts[$setfont]['svg'])) {
if ($seturl==1) $output .= ", ";
$output .= 'url('.get_template_directory_uri().$default_fonts[$setfont]['svg'].') format("svg")';
}
$output .= ";}\n";
$output .= ".menufont, .nav-main ul.menu li a,.cifont,.sticker ul li,.teaserlinks ul li a { font-family: FontPiratenkleiderMenuHeadlines; }\n";
} else {
$output .= '.menufont,.nav-main ul.menu li a,.cifont,.sticker ul li,.teaserlinks ul li a { font-family: '.$default_fonts[$setfont]['family'].'; }';
$output .= "\n";
}
}
$out = '';
if ((isset($output)) && (strlen($output)>1)) {
$out = "\n";
}
echo $out;
}
add_action('wp_head', 'piratenkleider_addfonts');
function piratenkleider_addaltbodybackground() {
global $options;
if ((isset($options['alt-body-background'])) && (isset($options['alt-body-background_id'])) && $options['alt-body-background_id']>0) {
if (isset($options['alt-body-background-orix'])) {
$orix = $options['alt-body-background-orix'];
}
if (isset($options['alt-body-background-oriy'])) {
$oriy = $options['alt-body-background-oriy'];
}
if (isset($options['alt-body-background-repeat'])) {
$repeat = $options['alt-body-background-repeat'];
}
$out = "\n";
echo $out;
}
}
add_action('wp_head', 'piratenkleider_addaltbodybackground');
function piratenkleider_addmetatags() {
global $options;
$output = "";
$output .= ''."\n";
$output .= ''."\n";
if ((isset( $options['meta-description'] )) && ( strlen(trim($options['meta-description']))>1 )) {
$output .= ''."\n";
}
if ((isset( $options['meta-author'] )) && ( strlen(trim($options['meta-author']))>1 )) {
$output .= ''."\n";
}
if ((isset( $options['meta-verify-v1'] )) && ( strlen(trim($options['meta-verify-v1']))>1 )) {
$output .= ''."\n";
}
$tags = '';
if ($options['aktiv-autokeywords']) {
$posttags = get_the_tags();
$csv_tags = '';
if ($posttags) {
foreach($posttags as $tag) {
$csv_tags .= $tag->name . ',';
}
$tags = substr( $csv_tags,0,-1);
}
}
if ((isset($options['meta-keywords'])) && (strlen(trim($options['meta-keywords']))>1 )) {
if (strlen($tags) > 0) {
$tags = $options['meta-keywords'].','.$tags;
} else {
$tags = $options['meta-keywords'];
}
}
if ((strlen(trim($tags))>2 )) {
if (strlen(trim($tags))>$options['meta-maxlengthvalue']) {
$tags = substr($tags,0,strpos($tags,",",$options['meta-maxlengthvalue']));
}
$output .= ''."\n";
}
echo $output;
}
add_action('wp_head', 'piratenkleider_addmetatags',1);
/* Open Graph and Social Media Support */
function piratenkleider_load_open_graph() {
global $post;
global $options;
if ($options['open_graph-active']!=true) {
return;
}
// Standard-Grafik fuer Seiten ohne Beitragsbild
$default_site_logo = wp_make_link_relative(get_header_image());
// Wenn Startseite
if ( is_front_page() ) { // Alternativ is_home
echo ''."\n";
echo ''."\n";
echo ''."\n";
echo ''."\n";
if (!empty($options['meta-description'])) {
echo ''."\n";
}
echo ''."\n";
echo ''."\n";
echo ''."\n";
if (!empty($options['open_graph-twitterhandle'])) {
echo ''."\n";
}
if (!empty($options['meta-description'])) {
echo ''."\n";
} else {
echo ''."\n";
}
}
// Wenn Einzelansicht von Seite, Beitrag oder Custom Post Type
elseif ( is_singular() ) {
echo ''."\n";
echo ''."\n";
echo ''."\n";
$thumbnail ='';
if ( has_post_thumbnail( $post->ID ) ) {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
echo ''."\n";
} else {
echo ''."\n";
}
echo '';
echo ''."\n";
echo ''."\n";
echo ''."\n";
echo ''."\n";
echo ''."\n";
if ( has_post_thumbnail( $post->ID ) ) {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
echo ''."\n";
}
if (!empty($options['open_graph-twitterhandle'])) {
echo ''."\n";
}
echo ''."\n";
}
}
add_action( 'wp_head', 'piratenkleider_load_open_graph' );
function get_piratenkleider_home_url() {
if (is_ssl()) {
return esc_url( home_url( '/', 'https' ) );
}
return esc_url( home_url( '/' ) );
}
/* Anonymize IP */
function getAnonymIp( $ip, $strongness = 2 ) {
if ($strongness==2) {
if( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ){
/* IPv4 - Strong BSI Norm: last two oktetts to 0 */
return preg_replace('/[0-9]+.[0-9]+\z/', '0.0', $ip);
} else {
/* IPv6 */
return preg_replace('/[a-z0-9]*:[a-z0-9]*:[a-z0-9]*:[a-z0-9]*:[a-z0-9]*\z/', '0:0:0:0:0', $ip);
}
} elseif ($strongness==1) {
if( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ){
/* Weak BSI Norm: last two oktetts to 0 */
return preg_replace('/[0-9]+\z/', '0', $ip);
} else {
/* IPv6 */
return preg_replace('/[a-z0-9]*:[a-z0-9]*:[a-z0-9]*:[a-z0-9]*\z/', '0:0:0:0', $ip);
}
} elseif ($strongness==0) {
/* No anonymizing */
return $ip;
} else {
if( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ){
/* IPv4 - Strong BSI Norm: last two oktetts to 0 */
return preg_replace('/[0-9]+.[0-9]+\z/', '0.0', $ip);
} else {
/* IPv6 */
return preg_replace('/[a-z0-9]*:[a-z0-9]*:[a-z0-9]*:[a-z0-9]*:[a-z0-9]*\z/', '0:0:0:0:0', $ip);
}
}
}
function feed_lifetime_cb( ) {
global $options;
return $options['feed_cache_lifetime'];
}
add_filter( 'wp_feed_cache_transient_lifetime' , 'feed_lifetime_cb' );
function piratenkleider_avatar ($avatar_defaults) {
global $defaultoptions;
$myavatar = $defaultoptions['src-default-avatar'];
$avatar_defaults[$myavatar] = "Piratenkleider";
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'piratenkleider_avatar' );
/* Refuse spam-comments on media */
function filter_media_comment_status( $open, $post_id ) {
$post = get_post( $post_id );
if( $post->post_type == 'attachment' ) {
return false;
}
return $open;
}
add_filter( 'comments_open', 'filter_media_comment_status', 10 , 2 );
/* Format list for Tagclouds also in widgets */
function edit_args_tag_cloud_widget($args) {
$args = array('format' => 'list');
return $args;
}
add_filter('widget_tag_cloud_args','edit_args_tag_cloud_widget');
if ( ! function_exists( 'get_piratenkleider_options' ) ) :
/*
* Erstes Bild aus einem Artikel auslesen, wenn dies vorhanden ist
*/
function get_piratenkleider_options( $field ){
global $defaultoptions;
if (!isset($field)) {
$field = 'piratenkleider_theme_options';
}
$orig = get_option($field);
if (!is_array($orig)) {
$orig=array();
}
$alloptions = array_merge( $defaultoptions, $orig );
return $alloptions;
}
endif;
function piratenkleider_initoptions() {
global $defaultoptions;
global $default_toplink_liste;
// $doupdate = 0;
$oldoptions = get_option('piratenkleider_theme_options');
if (isset($oldoptions) && (is_array($oldoptions))) {
$newoptions = array_merge($defaultoptions,$oldoptions);
} else {
$newoptions = $defaultoptions;
$newoptions['toplinkliste'] = $default_toplink_liste;
}
// if ($doupdate==1) {
// update_option('piratenkleider_theme_options', $newoptions);
// }
return $newoptions;
}
if ( ! function_exists( 'piratenkleider_get_image_attributs' ) ) :
function piratenkleider_get_image_attributs($id=0) {
$precopyright = __('Image:','piratenkleider').' ';
if ($id==0) return;
$meta = get_post_meta( $id );
if (!isset($meta)) {
return;
}
$result = array();
if (isset($meta['_wp_attachment_image_alt'][0])) {
$result['alt'] = trim(strip_tags($meta['_wp_attachment_image_alt'][0]));
} else {
$result['alt'] = "";
}
if (isset($meta['_wp_attachment_metadata']) && is_array($meta['_wp_attachment_metadata'])) {
$data = unserialize($meta['_wp_attachment_metadata'][0]);
if (isset($data['image_meta']) && is_array($data['image_meta']) && isset($data['image_meta']['copyright'])) {
$result['copyright'] = trim(strip_tags($data['image_meta']['copyright']));
}
}
$attachment = get_post($id);
$result['beschriftung'] = $result['beschreibung'] = $result['title'] = '';
if (isset($attachment) ) {
if (isset($attachment->post_excerpt)) {
$result['beschriftung'] = trim(strip_tags( $attachment->post_excerpt ));
}
if (isset($attachment->post_content)) {
$result['beschreibung'] = trim(strip_tags( $attachment->post_content ));
}
if (isset($attachment->post_title)) {
$result['title'] = trim(strip_tags( $attachment->post_title )); // Finally, use the title
}
}
$displayinfo = $result['beschriftung'];
if (empty($displayinfo) && !empty($result['copyright'])) $displayinfo = $precopyright.$result['copyright'];
if (empty($displayinfo)) $displayinfo = $result['alt'];
$result['credits'] = $displayinfo;
return $result;
}
endif;
if ( ! function_exists( 'piratenkleider_filter_wp_title' ) ) :
/*
* Sets the title
*/
function piratenkleider_filter_wp_title( $title, $separator ) {
// Don't affect wp_title() calls in feeds.
if ( is_feed() )
return $title;
global $paged, $page;
if ( is_search() ) {
$title = sprintf( __( 'Search results for %s', 'piratenkleider' ), '"' . get_search_query() . '"' );
if ( $paged >= 2 )
$title .= " $separator " . sprintf( __( 'Page %s', 'piratenkleider' ), $paged );
$title .= " $separator " . get_bloginfo( 'name', 'display' );
return $title;
}
$title .= get_bloginfo( 'name', 'display' );
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $separator " . $site_description;
if ( $paged >= 2 || $page >= 2 )
$title .= " $separator " . sprintf( __( 'Page %s', 'piratenkleider' ), max( $paged, $page ) );
return $title;
}
endif;
add_filter( 'wp_title', 'piratenkleider_filter_wp_title', 10, 2 );
function piratenkleider_excerpt_length( $length ) {
global $defaultoptions;
return $defaultoptions['teaser_maxlength'];
}
add_filter( 'excerpt_length', 'piratenkleider_excerpt_length' );
function piratenkleider_continue_reading_link() {
return ' ' . __( 'Continue reading →', 'piratenkleider' ) . '';
}
function piratenkleider_auto_excerpt_more( $more ) {
return ' …' . piratenkleider_continue_reading_link();
}
add_filter( 'excerpt_more', 'piratenkleider_auto_excerpt_more' );
function piratenkleider_custom_excerpt_more( $output ) {
if ( has_excerpt() && ! is_attachment() ) {
$output .= piratenkleider_continue_reading_link();
}
return $output;
}
add_filter( 'get_the_excerpt', 'piratenkleider_custom_excerpt_more' );
function piratenkleider_remove_gallery_css( $css ) {
return preg_replace( "##s", '', $css );
}
add_filter( 'gallery_style', 'piratenkleider_remove_gallery_css' );
function honor_ssl_for_attachments($url) {
$http = site_url(FALSE, 'http');
$https = site_url(FALSE, 'https');
return is_ssl() ? str_replace($http, $https, $url) : $url;
}
add_filter('wp_get_attachment_url', 'honor_ssl_for_attachments');
if ( ! function_exists( 'piratenkleider_comment' ) ) :
/**
* Template for comments and pingbacks.
*/
function piratenkleider_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
global $defaultoptions;
global $options;
switch ( $comment->comment_type ) :
case '' :
?>
id="li-comment-">
user_id > 0 && $user = get_userdata($comment->user_id) ) {
$addclass= 'class="byuser"';
} ?>
widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
add_action( 'widgets_init', 'piratenkleider_remove_recent_comments_style' );
if ( ! function_exists( 'piratenkleider_post_teaser' ) ) :
/**
* Erstellung eines Artikelteasers
*/
function piratenkleider_post_teaser($titleup = 1, $showdatebox = 1, $showdateline = 0, $teaserlength = 200, $thumbfallback = 1, $usefloating = 0, $titlenum = 2) {
global $options;
global $post;
$post_id = $post->ID;
$sizeclass='';
$out = '';
if ('linktipps'== get_post_type() ) {
$out = linktipp_display($post);
return $out;
}
$leftbox = '';
$sizeclass = 'p3-column withthumb';
if (($showdatebox>0) && ($showdatebox<5)) {
// Generate Thumb/Pic or Video first to find out which class we need
$leftbox .= '';
$sizeclass = 'p3-column withthumb';
$thumbnailcode = '';
$firstpic = '';
$firstvideo = '';
if (has_post_thumbnail()) {
$thumbnailcode = get_the_post_thumbnail($post->ID, 'teaser-thumb');
}
$firstpic = get_piratenkleider_firstpicture();
$firstvideo = get_piratenkleider_firstvideo();
$fallbackimg = '

';
if ($showdatebox==1) {
if (!isset($output)) { $output = $thumbnailcode;}
if (!isset($output)) { $output = $firstpic;}
if ((!isset($output)) && (isset($firstvideo))) { $output = $firstvideo; $sizeclass = 'p3-column withvideo'; }
if (!isset($output)) { $output = $fallbackimg;}
if ((isset($output)) && ( strlen(trim($output))<10 )) {$output = $fallbackimg;}
} elseif ($showdatebox==2) {
if (!isset($output)) { $output = $firstpic;}
if (!isset($output)) { $output = $thumbnailcode;}
if ((!isset($output)) && (isset($firstvideo))) { $output = $firstvideo; $sizeclass = 'p3-column withvideo'; }
if (!isset($output)) { $output = $fallbackimg;}
if ((isset($output)) && ( strlen(trim($output))<10 )) {$output = $fallbackimg;}
} elseif ($showdatebox==3) {
if ((!isset($output)) && (isset($firstvideo))) { $output = $firstvideo; $sizeclass = 'p3-column withvideo'; }
if (!isset($output)) { $output = $thumbnailcode;}
if (!isset($output)) { $output = $firstpic;}
if (!isset($output)) { $output = $fallbackimg;}
if ((isset($output)) && ( strlen(trim($output))<10 )) {$output = $fallbackimg;}
} elseif ($showdatebox==4) {
if ((!isset($output)) && (isset($firstvideo))) { $output = $firstvideo; $sizeclass = 'p3-column withvideo'; }
if (!isset($output)) { $output = $firstpic;}
if (!isset($output)) { $output = $thumbnailcode;}
if (!isset($output)) { $output = $fallbackimg;}
if ((isset($output)) && ( strlen(trim($output))<10 )) {$output = $fallbackimg;}
} else {
$output = $fallbackimg;
}
$leftbox .= $output;
$leftbox .= '
';
} else {
$sizeclass = 'p3-column';
}
if ($usefloating==1) {
$sizeclass .= " usefloating";
}
$out .= '';
$titlenum = (int) $titlenum;
if (($titlenum<1) || ($titlenum>6)) {
$titlenum = 2;
}
$htmltitlestart = '';
$htmltitleend = '';
$subtitle = get_post_meta( $post->ID, 'piratenkleider_subtitle', true );
if ($titleup==1) {
$out .= '';
if ($subtitle) {
$out .= ''.$subtitle."
\n";
}
$out .= $htmltitlestart;
$out .= '';
$out .= get_the_title();
$out .= ''.$htmltitleend.'';
$out .= "\n";
$out .= '';
}
if ($showdatebox<5) {
$out .= '
';
if ($showdatebox==0) {
$num_comments = get_comments_number();
if (($num_comments>0) || ( $options['zeige_commentbubble_null'])) {
$out .= '\n";
}
$out .= '
';
$out .= ''.get_the_time('j.').'';
$out .= ''.get_the_time('m.').'';
$out .= ''.get_the_time('Y').'';
$out .= "
\n";
} else {
$out .= $leftbox;
}
$out .= "
\n";
$out .= '
';
$out .= '';
} else {
$out .= '
';
}
if ($titleup==0) {
$out .= '';
if ($subtitle) {
$out .= ''.$subtitle."
\n";
}
$out .= $htmltitlestart;
$out .= '';
$out .= get_the_title();
$out .= "".$htmltitleend."\n";
}
if (($showdatebox!=0) && ($showdateline==1)) {
$out .= '';
$out .= piratenkleider_post_pubdateinfo(0);
$out .= "
\n";
}
$out .= get_piratenkleider_custom_excerpt($teaserlength,1,1,$options['continuelink']);
if ($showdatebox<5) {
$out .= " \n";
$out .= '
';
}
$out .= "\n";
if ($titleup==1) { $out .= '
'; }
$out .= "\n";
return $out;
}
endif;
if ( ! function_exists( 'piratenkleider_category_teaser' ) ) :
/**
* Erstellung eines Artikelteasers
*/
function piratenkleider_category_teaser() {
global $options;
global $post;
$out = $output = '';
$leftbox = $thumbnailcode = $firstpic = $output = '';
$leftbox .= '';
if (has_post_thumbnail()) {
$output = get_the_post_thumbnail($post->ID, 'teaser-thumb');
if (strlen($output)<1) {
$output = '

';
}
} else {
$output = '

';
}
$leftbox .= $output;
$leftbox .= '
';
$out .= '';
$out .= '';
$out .= "\n";
$out .= '';
$out .= $leftbox;
$out .= '
';
$out .= '';
$out .= piratenkleider_post_pubdateinfo(0);
$out .= "
\n";
$out .= get_piratenkleider_custom_excerpt($options['categoryindex-teaserlength'],1,1,$options['continuelink']);
$out .= '
';
$out .= "\n";
$out .= '
';
$out .= "\n";
return $out;
}
endif;
if ( ! function_exists( 'piratenkleider_search_teaser' ) ) :
/**
* Suchausgabe
*/
function piratenkleider_search_teaser($teaserlength = 250, $withthumb = 1, $aslist = 1, $search = '') {
global $options;
global $post;
$out = $output = '';
$leftbox = $thumbnailcode = $firstpic = $output = '';
if ($withthumb==1) {
$leftbox .= '';
if (has_post_thumbnail()) {
$output = get_the_post_thumbnail($post->ID, 'teaser-thumb');
if (strlen($output)<1) {
$output = '

';
}
} else {
$output = '

';
}
$leftbox .= $output;
$leftbox .= '
';
}
if ($aslist==1) {
$out .= '';
} else {
$out .= '';
}
$out .= '
';
$out .= "\n";
$out .= '
';
$out .= $leftbox;
$excerpt = get_piratenkleider_custom_excerpt($teaserlength, 1, 1, 2);
if (trim($search) !== '') {
$keys = array_diff(explode(" ", $search), array(''));
$excerpt = preg_replace('/('.implode('|', $keys) .')/iu',
'
\0',
$excerpt);
}
$out .= $excerpt;
$out .= '
';
$out .= ''.__('Created at:','piratenkleider').' '.piratenkleider_post_pubdateinfo(0).'. ';
$typ =get_post_type();
if ($typ == 'post') {
$out .= ''.__('Type: Entry','piratenkleider').'. ';
} elseif ($typ=='page') {
$out .= ''.__('Type: Page','piratenkleider').'. ';
}
$out .= "
\n";
$out .= '
';
if ($aslist==1) {
$out .= "\n";
} else {
$out .= "
\n";
}
return $out;
}
endif;
if ( ! function_exists( 'piratenkleider_post_datumsbox' ) ) :
/**
* Erstellung der Datumsbox
*/
function piratenkleider_post_datumsbox() {
global $options;
$out = '';
$num_comments = get_comments_number();
if (($num_comments>0) || ( $options['zeige_commentbubble_null'])) {
$out .= '\n";
}
$out .= '
';
$out .= '';
$out .= "
\n";
$out .= '
';
return $out;
}
endif;
if ( ! function_exists( 'piratenkleider_post_pubdateinfo' ) ) :
/**
* Fusszeile unter Artikeln: Veröffentlichungsdatum
*/
function piratenkleider_post_pubdateinfo($withtext = 1) {
$out = '';
if ($withtext==1) {
$out .= '';
$out .= __('Publiced at', 'piratenkleider' );
$out .= ' ';
}
$out .= '';
$out .= get_the_date();
$out .= "\n";
return $out;
}
endif;
if ( ! function_exists( 'piratenkleider_post_autorinfo' ) ) :
/**
* Fusszeile unter Artikeln: Autorinfo
*/
function piratenkleider_post_autorinfo() {
$out = ' '.__('Author','piratenkleider').': ';
$out .= '';
$out .= get_the_author_meta('display_name');
$out .= '';
echo $out;
}
endif;
if ( ! function_exists( 'piratenkleider_post_taxonominfo' ) ) :
/**
* Fusszeile unter Artikeln: Taxonomie
*/
function piratenkleider_post_taxonominfo() {
$tag_list = get_the_tag_list( '', ', ' );
if ( $tag_list ) {
$posted_in = __( 'Category: %1$s. Tags: %2$s.
Permalink for this entry.', 'piratenkleider' );
} elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
$posted_in = __( 'Category: %1$s.
Permalink for this entry.', 'piratenkleider' );
} else {
$posted_in = __( 'Permalink for this entry.', 'piratenkleider' );
}
// Prints the string, replacing the placeholders.
printf(
' '.$posted_in,
get_the_category_list( ', ' ),
$tag_list,
get_permalink(),
the_title_attribute( 'echo=0' )
);
}
endif;
// this function initializes the iframe elements
// maybe wont work on multisite installations. please use plugins instead.
function piratenkleider_change_mce_options($initArray) {
$ext = 'iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]';
if ( isset( $initArray['extended_valid_elements'] ) ) {
$initArray['extended_valid_elements'] .= ',' . $ext;
} else {
$initArray['extended_valid_elements'] = $ext;
}
// maybe; set tiny paramter verify_html
$initArray['verify_html'] = false;
return $initArray;
}
add_filter('tiny_mce_before_init', 'piratenkleider_change_mce_options');
class Piratenkleider_Menu_Walker extends Walker_Nav_Menu {
public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
{
if ( '-' === $item->title ) {
$item_output = '