| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web20/web/wp-content/themes/old_backup/ |
Upload File : |
<?php
//include the taxonomie-meta class file
require_once(get_template_directory() . "/include/Tax-meta-class/Tax-meta-class.php");
require_once(get_template_directory() . "/include/post-types.php");
require_once(get_template_directory() . "/include/shortcodes.php");
//require_once(get_template_directory() . "/include/mobile.class.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/classes/mysql.class.php");
add_image_size('affiliate-thumb', 200, 180, array('center', 'center')); // (cropped)
function get_adsense_bar($atts) {
$a = shortcode_atts( array(
'div' => "0"
), $atts );
$detect = new Mobile_Detect;
if(!$detect->isMobile()) {
$sAdContent = '
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1943906092680535"
data-ad-slot="6956316878"
data-ad-format="link"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
';
} else {
$sAdContent = '
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:200px;height:90px"
data-ad-client="ca-pub-1943906092680535"
data-ad-slot="4539404077"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
';
}
if($a['div'] == 1) {
return '<div class="ad-bar">' . $sAdContent . '</div>';
} else {
return $sAdContent;
}
}
function get_main_page_id() {
global $post;
$page_ancestors = end($post->ancestors);
if(!empty($page_ancestors)){
$child_of = $page_ancestors;
}else{
$child_of = $post->ID;
}
return $child_of;
}
/*
* configure taxonomy custom fields
*/
$config = array(
'id' => 'amazon_meta_box', // meta box id, unique per meta box
'title' => 'Zugehörigkeiten', // meta box title
'pages' => array('category'), // taxonomy name, accept categories, post_tag and custom taxonomies
'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional
'fields' => array(), // list of meta fields (can be added by field arrays)
'local_images' => false, // Use local or hosted images (meta box images for add/remove)
'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
$my_meta = new Tax_Meta_Class($config);
$repeater_fields[] = $my_meta->addTaxonomy('re_taxonomy_field_id',array('taxonomy' => 'post_tag'),array('name'=> 'Zugehörigkeit '), true);
/*
* Then just add the fields to the repeater block
*/
//repeater block
$my_meta->addRepeaterBlock('re_',array('inline' => true, 'name' => 'Wiki Zusammenhänge','fields' => $repeater_fields));
$my_meta->Finish();
$config_tag = array(
'id' => 'amazon_tag_meta_box', // meta box id, unique per meta box
'title' => 'Affiliate', // meta box title
'pages' => array('post_tag'), // taxonomy name, accept categories, post_tag and custom taxonomies
'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional
'fields' => array(), // list of meta fields (can be added by field arrays)
'local_images' => false, // Use local or hosted images (meta box images for add/remove)
'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false).
);
$my_meta_tag = new Tax_Meta_Class($config_tag);
$my_meta_tag->addText('amazon_search',array('name'=> 'Amazon Such Text'));
$repeater_tag_fields[] = $my_meta->addText('re_affiliate_description',array('name' => 'Text'), true);
$repeater_tag_fields[] = $my_meta->addText('re_affiliate_link',array('name' => 'URL'), true);
$my_meta_tag->addRepeaterBlock('re_',array('inline' => true, 'name' => 'Affiliate Links','fields' => $repeater_tag_fields));
$my_meta_tag->Finish();
add_theme_support('post-thumbnails');
add_image_size('content_thumb', 300, 300);
register_nav_menu( 'primary', 'Primary Menu' );
//if(function_exists('register_sidebar')) register_sidebars(3);
function lim_widgets_init() {
register_sidebar( array(
'name' => 'Startseite 1',
'id' => 'startpage-1',
'description' => 'Startseite 1',
'before_widget' => '<div id="%1$s" class="col-md-3 widget %2$s"><div class="box-padding">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => 'Startseite 2',
'id' => 'startpage-2',
'description' => 'Startseite 2',
'before_widget' => '<div id="%1$s" class="col-md-6 widget %2$s"><div class="box-padding">',
'after_widget' => '</div></div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'lim_widgets_init' );
function random_category($args) {
extract($args);
echo $before_widget;
get_template_part( 'loop', 'random' );
echo $after_widget;
}
// register the custom widgets
$my_class = array('classname' => 'random_category');
wp_register_sidebar_widget('random_category', __('Produkte'), 'random_category', $my_class);
function add_query_vars_filter( $vars ){
$vars[] = "shop";
return $vars;
}
add_filter( 'query_vars', 'add_query_vars_filter' );
// Amazon Produktbilder (Entscheidung Cache oder nicht)
function get_amazon_image($sAsin) {
$pFile = "/cache/products/".$sAsin.".jpg";
if(is_file($_SERVER['DOCUMENT_ROOT'].$pFile)) {
return $pFile;
} else {
return "/produktbilder/".$sAsin.".jpg";
}
}
// Change the columns for the edit CPT screen
function change_columns( $cols ) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = _x('Produkt', 'column name');
$new_columns['asin'] = __('ASIN', 'trans');
$new_columns['amazon_status'] = __('Produktstatus', 'trans');
$new_columns['categories'] = __('Kategorie');
$new_columns['tags'] = __('Wiki');
return $new_columns;
}
//add_filter( "manage_produkte_posts_columns", "change_columns" );
function custom_columns( $column, $post_id ) {
$cpt_asin = get_post_meta( $post_id, 'offer_asa', true);
switch ( $column ) {
case "asin":
echo '<a href="http://www.amazon.de/exec/obidos/ASIN/'.$cpt_asin.'/babyratgebernet-21" target="_blank" title="Artikel bei Amazon ansehen" rel="nofollow">'.$cpt_asin.'</a>';
break;
case "amazon_status":
/*$cpt_status = asa_check($cpt_asin);
echo empty($cpt_status) ? "offline" : "online";
echo "<pre>";
print_r($cpt_status);
echo "</pre>";*/
break;
}
}
//add_action( "manage_produkte_posts_custom_column", "custom_columns", 10, 2 );
// Make these columns sortable
function sortable_columns() {
return array(
'title' => 'title',
'asin' => 'asin',
'amazon_status' => 'amazon_status',
'categories' => 'categories',
'tags' => 'tags',
);
}
//add_filter( "manage_edit-produkte_sortable_columns", "sortable_columns" );
/*
Plugin Name: Products Plugin
Plugin URI: http://clivern.com/
Description: Register URL rules for our products
Version: 1.0
Author: Clivern
Author URI: http://clivern.com
License: MIT
*/
function products_plugin_activate() {
products_plugin_rules();
flush_rewrite_rules();
}
function products_plugin_deactivate() {
flush_rewrite_rules();
}
function products_plugin_rules() {
add_rewrite_rule('thema/shop/([^/]*)/', 'index.php?category_name=$matches[1]&shop_value=view', 'top');
}
function products_plugin_query_vars($vars) {
$vars[] = 'category_name';
$vars[] = 'shop_value';
return $vars;
}
//register activation function
register_activation_hook(__FILE__, 'products_plugin_activate');
//register deactivation function
register_deactivation_hook(__FILE__, 'products_plugin_deactivate');
//add rewrite rules in case another plugin flushes rules
add_action('init', 'products_plugin_rules');
//add plugin query vars (product_id) to wordpress
add_filter('query_vars', 'products_plugin_query_vars');
function tag_cloud_attribute_rebuild($match) {
$a = "<a href='%s' class='%s' title='%s Wiki' style='%s'>%s</a>";
return sprintf(
$a,
$match[1],
$match[2],
$match[5],
$match[4],
$match[5]
);
}
function wpse_78546_pagenum_link( $link ) {
global $page;
$aLink = explode('/', $link);
$iLink = (count($aLink)-2);
$sLink = $aLink[$iLink];
$sLink = preg_replace( '~/page/(\d+)/?~', '/?page=\1', $link );
//echo $sLink;
$sLink = str_replace("/".$page, '', $sLink);
//echo ;
return $sLink;
}
function wpbeginner_numeric_posts_nav($products = false) {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class="navigation"><ul>' . "\n";
$sProductSearch = ($products !== false && !isset($_GET['type']) && is_search() ? "&type=shop" : false);
/** Previous Post Link */
if ( get_previous_posts_link() ) {
$class = false;
printf( '<li%s><a href="%s'.$sProductSearch.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $paged-1 ) ), '« Vorherige Seite' );
}
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
if($products == "baby_shop") {
$pagenumLink = str_replace('4/', '', get_pagenum_link( 1 ));
} else {
$pagenumLink = get_pagenum_link(1);
}
printf( '<li%s><a href="%s'.$sProductSearch.'">%s</a></li>' . "\n", $class, esc_url( $pagenumLink ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s><a href="%s'.$sProductSearch.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s><a href="%s'.$sProductSearch.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() ) {
$class = false;
printf( '<li%s><a href="%s'.$sProductSearch.'">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $paged+1 ) ), 'Nächste Seite »' );
}
echo '</ul></div>' . "\n";
}
// Theme-Options-Panel includieren
if( !function_exists('optionsframework_init') ) {
define('OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/');
require_once(get_template_directory() . '/inc/options-framework.php');
}
//function to call and print shortened post title
function the_title_shorten($len,$rep='...') {
$title = the_title('','',false);
$shortened_title = textLimit($title, $len, $rep);
return utf8_encode(utf8_decode($shortened_title));
}
//shorten without cutting full words (Thank You Serzh 'http://us2.php.net/manual/en/function.substr.php#83585')
function textLimit($string, $length, $replacer) {
if(strlen($string) > $length)
return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
return $string;
}
function rip_tags($string) {
// ----- remove HTML TAGs -----
$string = preg_replace ('/<[^>]*>/', ' ', $string);
// ----- remove control characters -----
$string = str_replace("\r", '', $string); // --- replace with empty space
$string = str_replace("\n", ' ', $string); // --- replace with space
$string = str_replace("\t", ' ', $string); // --- replace with space
// ----- remove multiple spaces -----
$string = trim(preg_replace('/ {2,}/', ' ', $string));
return $string;
}
// Adminbar im Frontend entfernen
add_filter('show_admin_bar', '__return_false');
// breadcrumb
function nav_breadcrumb() {
}
function format_asa_price($price) {
$aSearch = array('EUR ', ',');
$aReplace = array('', '');
return intval(str_replace($aSearch, $aReplace, $price));
}
add_filter( 'custom_post_type_onomies_attach_to_post_type_property_include_post_type', 'my_website_attach_to_post_type_property_include_post_type', 1, 3 );
function my_website_attach_to_post_type_property_include_post_type( $include_post_type, $post_type, $post_type_being_edited ) {
if ( $post_type_being_edited == 'post' && in_array( $post_type, array( 'post', 'produkte' ) ) )
return false;
return $include_post_type;
}
function count_tags($category_id) {
$aCatPosts = get_posts(array('post_type' => array('post'), 'category' => $category_id));
$aTagsPost = wp_list_pluck( $aCatPosts, 'ID' );
// Tags zu dem Content
$tag_output_args = array('orderby' => 'count', 'order' => 'DESC');
$tag_output = wp_get_object_terms($aTagsPost, 'post_tag', $tag_output_args);
$aTerms = array();
if(!empty($tag_output)) {
foreach($tag_output as $keyCheck => $valueCheck) {
if(!isset($aTerms[$valueCheck->term_id])) $aTerms[$valueCheck->term_id] = $valueCheck;
}
}
return $aTerms;
}
// URL Rewrite
function re_rewrite_rules() {
//global $wp_rewrite;
// $wp_rewrite->author_base = $author_slug;
//$wp_rewrite->author_base = 'autor';
//$wp_rewrite->search_base = 'buscar';
//$wp_rewrite->comments_base = 'comentarios';
////$wp_rewrite->pagination_base = 'seite';
//$wp_rewrite->flush_rules();
}
//add_action('init', 're_rewrite_rules');
// Print Terms
function __print($aArray) {
if(is_user_logged_in()) {
echo "<pre>";
print_r($aArray);
echo "</pre>";
}
}
// Sortierung
function sort_on_field(&$objects, $on, $order = 'ASC') {
$comparer = ($order === 'DESC')
? "return -strcmp(\$a->{$on},\$b->{$on});"
: "return strcmp(\$a->{$on},\$b->{$on});";
usort($objects, create_function('$a,$b', $comparer));
}
/**
* reduziert einen String auf die
* ersten Worte
*
* @param str $str
* @param int $count (Default 10)
* @return str
*/
function getFirstWords( $str, $count = 10 ) {
$str = trim( $str );
$str = preg_replace("/ +/", ' ', $str);
# Jedes Wort ein Arrayelement
$array = explode( ' ', $str );
# Array in $count große Teile teilen
$array = array_chunk( $array, $count );
/**
* Falls der String weniger Worte hatte als $count
* geben wir den String unverändert zurück
*/
if ( empty( $array[ 1 ] ) )
return $str;
/**
* andernfalls entfernen wir eventuelle Kommas am ende
* und fügen ein Auslassungszeichen an
*/
return rtrim( implode( ' ', $array[ 0 ] ), ',;-' );
}
function edit_product_content($content, $title = true) {
if($title == true) { // Array bei Änderung des Produkttitels
$aSearchSpec = array(', ', '"', ',');
$aReplaceSpec = array(' - ', '', ' ');
} else { // Array bei Änderung der Produktbeschreibung
$aSearchSpec = array('(ca.', ' . ', '"');
$aReplaceSpec = array(' (ca', '', '"');
}
$aSearchMain = array('inkl. ', 'inkl.');
$aReplaceMain = array('inklusive ', 'inklusive ');
$aSearch = array_merge($aSearchSpec, $aSearchMain);
$aReplace = array_merge($aReplaceSpec, $aReplaceMain);
if(is_array($content)) { // Inhalt der Liste von Produkteigenschaften verändern
$aContent = array();
foreach($content as $k => $v) {
$aContent[] = preg_replace("/ +/", ' ', str_replace($aSearch, $aReplace, $v));
} $content = $aContent;
} else { // Produkttitel verändern
$content = preg_replace("/ +/", ' ', str_replace($aSearch, $aReplace, $content));
}
return $content;
}
// Rewrite Rules hinzufügen
function add_addresses_rewrite() {
global $wp;
// Drogenberatungsstellen
$wp->add_query_var('page_view');
$wp->add_query_var('address_city');
$wp->add_query_var('address_id');
$wp->add_query_var('address_name');
add_rewrite_rule( 'suchtberatung/([^/]+)/?$', 'index.php?address_city=$matches[1]&page_view=address_city', 'top' );
add_rewrite_rule( 'suchtberatung/([^/]+)/([^/]+)_([^/]+)/?$', 'index.php?address_city=$matches[1]&address_id=$matches[2]&address_name=$matches[3]&page_view=address_view', 'top' );
} add_action( 'init', 'add_addresses_rewrite' );
// Templates zur Rewrite Rule hinzufügen
function prefix_url_rewrite_templates() {
$page_view = get_query_var('page_view');
// Custom Template
if($page_view) {
// City Overview
if($page_view == "address_city") {
add_filter('template_include', function() {
return get_template_directory() . '/page-suchtberatung.php';
});
}
// Address Single View
else if($page_view == "address_view") {
add_filter('template_include', function() {
return get_template_directory() . '/single-suchtberatung.php';
});
}
}
} add_action( 'template_redirect', 'prefix_url_rewrite_templates' );
/*function my_custom_title( $title ) {
global $wp_query;
$db = new mysql();
return 'test';
if(get_query_var('address_id')) {
//die();
$sAddressId = get_query_var('address_id');
$sAddressCity = get_query_var('address_city');
$sAddressName = get_query_var('address_name');
$db->where('address_id', $sAddressId);
$db->where('address_rewrite_name', $sAddressName);
$db->where('address_rewrite_city', $sAddressCity);
$aAddresses = $db->get('sucht_addresses');
return sprintf($aAddresses[0]['address_name'] . " - ", $title, get_bloginfo('name'));
}
else if (is_404()) return sprintf("404 - Seite nicht gefunden - ", $title, get_bloginfo('name'));
else { return sprintf($title, $title, get_bloginfo('name')); }
} add_filter('wp_title', 'my_custom_title');*/
add_filter('wp_title', 'filter_pagetitle', 10);
function filter_pagetitle($title) {
//check if its a blog post
if (!is_single() && !is_archive())
//return $title;
//if you get here then its a blog post so change the title
global $wp_query;
global $post;
if($post->post_type == "drogenpolitik" && is_single()) {
return 'Drogenpolitik in ' . $post->post_title . ' / ';
}
if (isset($wp_query->post->post_title)){
return $wp_query->post->post_title . ' / ';
}
//if wordpress can't find the title return the default
return $title;
}
function f_rand($min=0,$max=1,$mul=1000000){
if ($min>$max) return false;
return mt_rand($min*$mul,$max*$mul)/$mul;
}
function get_offer_bar($iPageID) {
global $post;
?>
<div class="shop-top-navigation row content">
<div class="col-sm-3 offer-item<?php if($iPageID == 70) echo " active"; ?>">
<a href="<?php echo get_site_url(); ?>/drogentest/alkoholtester/" title="Alkoholtester kaufen">
Alkoholtest
</a>
</div>
<div class="col-sm-3 offer-item<?php if($iPageID == 72) echo " active"; ?>">
<a href="<?php echo get_site_url(); ?>/drogentest/urintest/" title="Urinteststreifen Drogen kaufen">
Urintest
</a>
</div>
<div class="col-sm-3 offer-item<?php if($iPageID == 74) echo " active"; ?>">
<a href="<?php echo get_site_url(); ?>/drogentest/speicheltest/" title="Speicheltest Drogen kaufen">
Speicheltest
</a>
</div>
<div class="col-sm-3 offer-item<?php if($iPageID == 76) echo " active"; ?>">
<a href="<?php echo get_site_url(); ?>/drogentest/wischtest/" title="Wischtest Drogen kaufen">
Wischtest
</a>
</div>
</div>
<?php } ?>