| 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/arni/includes/classes/ |
Upload File : |
<?php
class wordpress {
public $menu;
public $site;
public $user;
public $page;
public $meta;
public $archive;
public $class;
public function __construct() {
global $post;
$this->class = ( object ) array(
'archives' => new wordpressArchives(),
'product' => new products(),
);
$this->site = ( object ) array(
'url' => get_site_url(),
'title' => get_bloginfo()
);
$this->user = ( object ) array(
'login' => is_user_logged_in() ? 1 : 0,
'is_admin' => current_user_can('administrator') ? true : false
);
tpl_settings();
tpl_remove_defaults();
}
public function wp_get_menu_array( $current_menu ) {
global $wp_query;
$array_menu = wp_get_nav_menu_items( $current_menu );
$menu = array();
foreach ( $array_menu as $m ) {
if ( empty( $m->menu_item_parent ) ) {
$menuClasses[ $m->object_id ] = array();
if( $m->object_id == $wp_query->get_queried_object_id() || get_main_page_id() == $m->object_id || (
get_option('page_for_posts') == $m->object_id && get_post_type() == "post" && ( is_archive() || is_single() )
)) $menuClasses[ $m->object_id ][] = "item-active";
$menuClasses[ $m->object_id ][] = "item-" . $m->object_id;
$menu[ $m->ID ] = array();
$menu[ $m->ID ]['ID'] = $m->object_id;
$menu[ $m->ID ]['title'] = $m->title;
$menu[ $m->ID ]['seo_title'] = $m->attr_title;
$menu[ $m->ID ]['url'] = $m->url;
$menu[ $m->ID ]['classes'] = implode( ' ', $menuClasses[ $m->object_id ] );
$menu[ $m->ID ]['children'] = array();
}
}
$submenu = array();
foreach ( $array_menu as $m ) {
if ( $m->menu_item_parent ) {
$menuClasses[ $m->object_id ] = array();
if( $m->object_id == $wp_query->get_queried_object_id() || get_main_page_id() == $m->object_id ) $menuClasses[ $m->object_id ][] = "item-active";
$menuClasses[ $m->object_id ][] = "item-" . $m->object_id;
$submenu[ $m->ID ] = array();
$submenu[ $m->ID ]['ID'] = $m->object_id;
$submenu[ $m->ID ]['title'] = $m->title;
$submenu[ $m->ID ]['seo_title'] = $m->attr_title;
$submenu[ $m->ID ]['url'] = $m->url;
$submenu[ $m->ID ]['classes'] = implode( ' ', $menuClasses[ $m->object_id ] );
$menu[ $m->menu_item_parent ]['children'][ $m->ID ] = $submenu[ $m->ID ];
}
}
return json_decode( json_encode( $menu ) );
}
public function wp_menu( $name = "primary" ) {
// Menü aus dem WordPress Framework beziehen
if( $locations = get_nav_menu_locations() ) :
return $this->wp_get_menu_array( wp_get_nav_menu_object( $locations[ $name ] ) );
else:
return array();
endif;
}
public function get_nav_items( $id, $parent = 0 ) {
global $wp_query;
$items = wp_get_nav_menu_items( $id );
$frontPageID = get_option( 'page_on_front' );
$isFrontPage = is_front_page();
//if($parent > 0) return array($id, $parent);
$menu = $classes = array();
if( $items ) {
foreach( $items as $key => $item ) {
// Dazugehörige Menüpunkte laden
//$children = $this->get_nav_items( $item->object_id, $id );
if( $item->object_id == $wp_query->get_queried_object_id() || get_main_page_id() == $item->object_id ) $classes[ $key ][] = "item-active";
$classes[ $key ][] = "item-" . $item->object_id;
$menu[] = ( object ) array(
'test' => $item,
'ID' => $item->ID,
'title' => $item->title,
'seo_title' => $item->attr_title,
'url' => $item->url,
'classes' => implode( ' ', $classes[ $key ] ),
'parent' => $this->get_nav_items( $item->ID, $item->menu_item_parent ),
);
}
}
return $menu;
}
public function get_area( $areaName ) { ob_start(); dynamic_sidebar( $areaName ); $content = ob_get_contents(); ob_end_clean(); return $content; }
public function is_front_page() { return is_front_page(); }
public function is_archive( $archive ) { return is_post_type_archive( $archive ); }
public function is_page() { return is_page(); }
public function wp_content( $content = false ) {
global $post;
global $markdown;
if( $content )
$return = $content;
else if ( is_front_page() && is_home() ) :
$return = $post->post_content;
elseif ( is_front_page()) :
$return = $post->post_content;
elseif ( is_home()) :
$return = get_the_content( get_option('page_for_posts', true) );
else :
$return = $post->post_content;
endif;
wp_reset_query();
$return = str_replace(array("http://www.baby-ratgeber.net"), "https://www.baby-ratgeber.net", apply_filters( 'the_content', $return ) );
return str_replace(array('<ul>','<ol>'), array('<ul class="arni-list-article">','<ol class="arni-list-article">'), $return );
}
public function wp_title() {
global $post;
wp_reset_query();
if ( is_front_page() && is_home() ) {
$return = $post->post_title;
} elseif ( is_front_page()){
$return = $post->post_title;
} elseif ( is_home() ){
$return = get_the_title( get_option('page_for_posts', true) );
} elseif ( is_archive() ){
$return = get_the_archive_title();
} else {
$return = $post->post_title;
}
return $return;
}
public function wp_thumbnail($output = false, $classes = false) {
global $post;
$imgURL = get_the_post_thumbnail_url( get_the_ID() );
if( $output && $imgURL ) {
return '<img src="' . $imgURL . '" class="' . $classes . '" />';
} else {
return $imgURL;
}
}
public function wp_post() { global $post; return $post; }
public function get_children() { global $post; return $this->wp_posts( $post->post_type, array( 'post_parent' => is_front_page() ? 0 : $post->ID ) ); }
/*public function cookie_note() {
global $smarty;
if( isset( $this->page->configuration->site_configuration->show_cookie_note ) && $this->page->configuration->site_configuration->show_cookie_note == 1) {
$content = $smarty->fetch("functions/privacy/cookies.tpl");
} else {
$content = false;
}
return $content;
}*/
public function wp_head() {
global $smarty;
global $meta;
global $wp_query;
global $post;
ob_start();
wp_head();
$wp_head = ob_get_contents();
ob_end_clean();
//echo "<pre>";
//print_r($wp_query);
//echo "</pre>";
$tmpPageID = is_home() ? get_option( 'page_for_posts' ) : get_the_ID();
$this->page = ( object ) array(
'ID' => $tmpPageID,
'title' => get_the_title( $tmpPageID ),
'configuration' => ( object ) array(
'site_configuration' => $meta->get( "site_configuration" ),
'site_api' => $meta->get( "site_api" )
),
'paged' => ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ),
'wp_query' => $wp_query
);
$this->meta = $meta->get( FALSE, $this->page->ID );
$smarty->assign('options', $this->meta);
if( isset( $this->page->configuration->use_google_analytics ) && $this->page->configuration->use_google_analytics == 1 ) {
$wp_head.="\n" . $smarty->fetch("functions/google/analytics.tpl");
}
return str_replace("\n", "\n\t\t", $wp_head);
}
public function wp_posts( $postType = "post", $additional = 10 ) {
global $query_string;
//query_posts( $query_string . '&order=ASC' );
wp_reset_query();
$args = array( 'post_type' => $postType, 'order' => 'ASC', 'paged' => $this->page->paged );
if( ( is_bool( $additional ) && !$additional ) || !is_array( $additional ) ) {
$addArgs['posts_per_page'] = $additional;
} else {
//$addArgs['posts_per_page'] = get_option(' posts_per_page' );
$addArgs['posts_per_page'] = $additional;
$addArgs = array_merge( $addArgs, $args );
}
//$query = get_posts( array_merge( $args, $addArgs ) );
$query = new WP_Query( $query_string );
//print_r($query);
return $query->posts;
//$wpreq = new WP_Query($args);
//print_r($query);
//return $wpreq->query();
}
public function get_footer( $pageID = false ) {
global $post;
global $meta;
wp_reset_query();
if( get_post_type() == "post" && !$pageID ) {
$pageID = get_option( 'page_for_posts' );
} else {
$pageID = ( $pageID ? $pageID : get_the_ID() );
}
$pageData = $meta->value( false, $pageID );
//print_r($pageData);
if( isset( $pageData->page_footer_status ) && $pageData->page_footer_status == 1 ) {
return ( object ) array('ID' => $pageID, 'footer' => $meta->value( false, $pageID ) );
} else {
$parentIDs = array_merge(get_post_ancestors( $pageID ), array( get_option( 'page_on_front' ) ) );
/*echo "<pre>";
print_r($parentIDs);
echo "</pre>";*/
foreach( $parentIDs as $parent ) {
$getParent[ $parent ] = ( object ) array('ID' => $parent, 'footer' => $meta->value( false, $parent ) );
if( isset( $getParent[ $parent ]->footer->page_footer_status ) && $getParent[ $parent ]->footer->page_footer_status == 1 ) return ( object ) $getParent[ $parent ];
}
}
}
public function the_breadcrumb() {
global $meta;
global $post;
global $wp_query;
global $wp_locale;
$items = array();
$frontPageID = get_option( 'page_on_front' );
$options[ $frontPageID ] = $meta->get('seo_breadcrumb', $frontPageID);
$metaTitle = $meta->value('title') ? $meta->value('title') : 'Home';
$metaTag = $meta->value('html_tag') ? $meta->value('html_tag') : get_bloginfo();
$items[] = (object) array('ID' => $frontPageID, 'link' => get_option('home'), 'title' => $metaTitle, 'html_tag' => $metaTag, 'post' => $post);
if ( (!is_home() && !is_front_page()) || is_archive() || get_post_type( get_the_ID() ) == "post" ) {
if ( is_archive() || is_category() || is_single() || get_post_type( get_the_ID() ) == "post" || get_query_var('year') ) {
if( is_archive() ) {
$postType = get_post_type_object( get_post_type( ) );
$items[] = (object) array('ID' => get_post_type(), 'link' => get_post_type_archive_link( get_post_type() ), 'title' => 'Blog', 'html_tag' => $meta->value('breadcrumb_tag', get_option( 'page_for_posts' )), 'subElements' => $this->class->archives->hso_get_archives(false, true));
// Jahresarchiv listen
if( get_query_var('year') ) {
$items[] = (object) array('ID' => get_query_var('year') . '_' . get_post_type(), 'link' => get_year_link( get_query_var('year') ), 'title' => get_query_var('year'), 'html_tag' => $postType->labels->name . '-Archiv aus dem Jahr ' . get_query_var('year'), 'type' => 'year', 'subElements' => $this->class->archives->hso_get_archives(get_query_var('year'), get_query_var('monthnum')));
}
//echo "<pre>";
//print_r($wp_query->query_vars);
//echo "</pre>";
if( get_query_var('monthnum') ) {
$items[] = (object) array('ID' => get_query_var('year') . '_' . get_query_var('monthnum') . '_' . get_post_type(), 'link' => get_month_link( get_query_var('year'), get_query_var('monthnum') ), 'title' => $wp_locale->get_month( get_query_var('monthnum') ), 'html_tag' => $postType->labels->name . '-Archiv ' . $wp_locale->get_month( get_query_var('monthnum') ) . ' ' . get_query_var('year'), 'type' => 'month');
} else {
//$items[] = (object) array('ID' => get_query_var('year') . '_' . get_post_type(), 'link' => get_post_type_archive_link( get_post_type() ), 'title' => 'Übersicht', 'html_tag' => 'Beiträge aus dem Jahr ' . get_query_var('year'));
}
}
else if( is_category() ) {
$options[ get_the_ID() ] = $meta->get('seo_breadcrumb', get_the_ID());
$metaTitle = @$meta->custom->breadcrumb_title ? $meta->custom->breadcrumb_title : get_cat_name();
$metaTag = @$meta->custom->breadcrumb_tag ? $meta->custom->breadcrumb_tag : get_cat_name();
//$metaTitle = '#';
//$metaTag = '#';
$items[] = (object) array('ID' => get_the_ID(), 'link' => get_category_link( get_the_ID() ), 'title' => $category, 'html_tag' => $metaTag);
}
//$items[] = ( object ) array('ID' => get_post_type(), 'link' => get_the_permalink(), 'title' => 'Test', 'html_tag' => 'Element');
if ( is_single() || get_post_type( get_the_ID() ) == "post" || get_the_ID() == get_option( 'page_for_posts' )) {
$postTypeLink = get_post_type_archive_link( get_post_type() );
if( ! is_singular( array( 'attachment' ) ) && !get_query_var('year') ){
$postType = get_post_type_object( get_post_type() );
$pageID = url_to_postid( get_post_type_archive_link( get_post_type() ) );
if(get_post_type() == "post") {
$pageID = get_option( 'page_for_posts' );
} else {
$pageID = $pageID;
}
$options[ $pageID ] = $meta->get('seo_breadcrumb', get_option( 'page_for_posts' ));
//echo "<pre>";
//print_r(array( get_term_by( 'slug', $wp_query->query['help'], 'help' ), $wp_query));
//echo "</pre>";
$aSubelements = array();
switch( get_post_type() ) {
case "post" :
$metaTitle = "Blog";
$metaTag = $meta->value('breadcrumb_tag', get_option( 'page_for_posts' ));
break;
case "products" :
$metaTitle = "Produkte";
$metaTag = "Produkte";
break;
case "faq" :
$metaTitle = "FAQs";
$metaTag = "Fragen & Antworten";
$postTypeLink = str_replace('%help%/', FALSE, get_post_type_archive_link( get_post_type() ) );
$aSubelements = $this->class->archives->arni_get_custom_tag('help');
break;
default :
$metaTitle = "Blog";
$metaTag = $meta->value('breadcrumb_tag', get_option( 'page_for_posts' ));
break;
}
$items[] = ( object ) array('ID' => get_the_ID(), 'link' => $postTypeLink, 'title' => $metaTitle, 'html_tag' => $metaTag, 'subElements' => ( get_post_type() == "post" ? $this->class->archives->hso_get_archives() : $aSubelements ) );
$taxonomieHLP = wp_get_post_terms( get_the_ID(), 'help' );
if( $taxonomieHLP && !empty( $taxonomieHLP ) ) {
foreach( $taxonomieHLP as $tey => $vey ) {
// Falls mehr als 1 Kategorie, dann die letzte Kategorie ausgeben
if( count( $taxonomieHLP ) >= 1 && ( $tey+1 ) == count( $taxonomieHLP ) ) {
$metaTitle = $vey->name;
$metaTag = $vey->name;
$postTypeLink = get_term_link( $vey->term_id );
$items[] = ( object ) array('ID' => $vey->term_id, 'link' => $postTypeLink, 'title' => $metaTitle, 'html_tag' => $metaTag, 'subElements' => array() );
}
//echo "<pre>";
//print_r($vey);
//echo "</pre>";
}
}
}
if( !is_single() && !is_archive() ) {
$items[] = (object) array('ID' => get_option( 'page_for_posts' ), 'link' => get_post_type_archive_link( get_post_type() ), 'title' => 'Übersicht', 'html_tag' => $metaTag);
}
if( get_the_ID() == get_option( 'page_for_posts' ) || is_single() ) {
$options[ get_the_ID() ] = $meta->get('seo_breadcrumb', get_the_ID());
$metaTitle = @$meta->custom->breadcrumb_title ? $meta->custom->breadcrumb_title : get_the_title();
$metaTag = @$meta->custom->breadcrumb_tag ? $meta->custom->breadcrumb_tag : get_the_title();
$items[] = ( object ) array('ID' => get_the_ID(), 'link' => get_the_permalink(), 'title' => $metaTitle, 'html_tag' => $metaTag);
}
}
} elseif ( is_page() ) {
$post = get_post();
//$items[] = $post;
if( $post->post_parent > 0 ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ( $parent_id ) {
$post = get_post( $parent_id );
$options[ $parent_id ] = $meta->get('seo_breadcrumb', $parent_id);
$metaTitle = $meta->value('breadcrumb_title', $post->ID) ? $meta->value('breadcrumb_title', $post->ID) : get_the_title( $post->ID );
$metaTag = $meta->value('breadcrumb_tag', $post->ID) ? $meta->value('breadcrumb_tag', $post->ID) : get_the_title( $post->ID );
$breadcrumbs[] = ( object ) array('ID' => $post->ID, 'link' => get_the_permalink( $post->ID ), 'title' => $metaTitle, 'html_tag' => $metaTag, 'subElements' => $this->get_subpages( $post->ID, false, $wp_query->queried_object->ID ) );
$parent_id = $post->post_parent;
}
$breadcrumbs = array_reverse( $breadcrumbs );
$items = array_merge($items, $breadcrumbs);
unset( $breadcrumbs );
}
$options[ $wp_query->queried_object->ID ] = $meta->get('seo_breadcrumb', $wp_query->queried_object->ID);
$metaTitle = $meta->value('breadcrumb_title', $wp_query->queried_object->ID) ? $meta->value('breadcrumb_title', $wp_query->queried_object->ID) : get_the_title( $wp_query->queried_object->ID );
$metaTag = $meta->value('breadcrumb_tag', $wp_query->queried_object->ID) ? $meta->value('breadcrumb_tag', $wp_query->queried_object->ID) : get_the_title( $wp_query->queried_object->ID );
$items[] = ( object ) array('ID' => get_the_ID(), 'link' => get_the_permalink( $wp_query->queried_object->ID ), 'title' => $metaTitle, 'html_tag' => $metaTag );
} elseif ( is_archive() ) {
$options[ get_the_ID() ] = $meta->get('seo_breadcrumb', get_the_ID());
$metaTitle = $meta->value('breadcrumb_title', get_the_ID()) ? $meta->value('breadcrumb_title', get_the_ID()) : get_the_title();
$metaTag = $meta->value('breadcrumb_tag', get_the_ID()) ? $meta->value('breadcrumb_tag', get_the_ID()) : get_the_title();
$items[] = ( object ) array('ID' => get_the_ID(), 'link' => get_the_permalink(), 'title' => $metaTitle, 'html_tag' => $metaTag);
}
}
//echo "<pre>" . print_r( get_post_meta( get_the_ID(), '_aioseop_menulabel', true ) ) . "</pre>";
/*elseif (is_tag()) {single_tag_title();}
elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
echo '</ul>';*/
return $items;
}
public function get_subpages( $iPageID = false, $sub = true, $ignore = false ) {
global $meta;
// Page ID herausfinden, falls nicht gesetzt
$iPageID = $iPageID === false ? get_the_ID() : $iPageID;
$subPages = get_pages( array(
'hierarchical' => 0,
'parent' => $iPageID,
'sort_order' => 'ASC',
'sort_column' => 'menu_order'
) );
$parentList = get_post_ancestors( $ignore );
$aResult = array();
foreach( $subPages as $k => $v ) {
// Seite ignorieren
if( $v->ID != $ignore && ( !$parentList || ( $parentList && !in_array( $v->ID, $parentList ) ) ) ) {
$aResult[ $k ] = ( object ) array_merge(
( array ) $v,
array(
'permalink' => get_the_permalink( $v->ID ),
'thumbnail' => get_the_post_thumbnail_url( $v->ID ),
'subtitle' => get_post_meta( $v->ID, '_aioseop_menulabel', true ),
'subtitleatr' => get_post_meta( $v->ID, '_aioseop_titleatr', true ),
'breadcrumb_title' => $meta->value("breadcrumb_title", $v->ID) ? $meta->value("breadcrumb_title", $v->ID) : ( get_post_meta( $v->ID, '_aioseop_menulabel', true ) ? get_post_meta( $v->ID, '_aioseop_menulabel', true ) : get_the_title( $v->ID )),
'breadcrumb_tag' => $meta->value("breadcrumb_tag", $v->ID) ? $meta->value("breadcrumb_tag", $v->ID) : ( get_post_meta( $v->ID, '_aioseop_titleatr', true ) ? get_post_meta( $v->ID, '_aioseop_titleatr', true ) : get_the_title( $v->ID )),
'secondary' => get_post_meta( $v->ID, '_secondary_html_995', true ),
'subpages' => ( $sub ? $this->get_subpages( $v->ID, false ) : false ),
'metas' => get_post_meta( $v->ID ),
'is_tree' => get_post_ancestors( $ignore )
)
);
}
}
//echo "<pre>";
//print_r($aResult);
//echo "</pre>";
//usort($aResult, "cmp");
return $aResult;
}
}