File "single.php"
Full Path: /home/ozbarhaber/public_html/wp-content/themes/anka/single.php
File size: 2.79 KB
MIME-type: text/x-php
Charset: utf-8
<?php if(!defined('ABSPATH')) exit; ?>
<?php
switch (get_post_meta(get_the_ID(), "galleryType", true)) {
case 'type1':
$galleryRedirect = false;
break;
case 'type2':
$galleryRedirect = true;
break;
default:
if(xoption("galleryType") == "type1") {
$galleryRedirect = false;
} else {
$galleryRedirect = true;
}
break;
}
$attachmentIDs = "";
$hasPostGallery = false;
if (function_exists("has_block")) {
$galleryPost = get_post(get_the_ID());
$galleryContent = $galleryPost->post_content;
$galleryDump = parse_blocks($galleryContent);
foreach ($galleryDump as $block) {
if($block['blockName'] == "core/gallery") {
$text = $block['innerHTML'];
preg_match_all('@data-id="(.*?)"@si', $text, $content);
if(is_array($content[1])) $attachmentIDs = $content[1];
}
}
}
if(!is_array($attachmentIDs)) {
$gallery = get_post_gallery( get_the_ID(), false );
if($gallery) {
$attachmentIDs = explode(',', $gallery['ids']);
}
}
if(is_array($attachmentIDs)) $hasPostGallery = true;
if(xoption('skipToGallery') && $galleryRedirect && $hasPostGallery) :
$isAjax = isset($_GET['ajax']) ? true : false;
if($isAjax) {
?>
<div id="single">
<div class="haberSingle" style="margin:0; padding:0; border:0">
<div id="infiniteImage"></div>
<script>
window.location.replace("<?php the_permalink() ?>");
</script>
</div>
</div>
<?php
die();
} else {
header('Location:' . get_the_permalink($attachmentIDs[0]));
die();
}
endif;
?>
<?php get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
$singlePart = "normal";
foreach(get_the_category() as $category) {
if($category->term_id == xoption('photoCategory') || safir_top_category($category->term_id) == xoption('photoCategory')) { $singlePart = 'photo'; }
if($category->term_id == xoption('videoCategory') || safir_top_category($category->term_id) == xoption('videoCategory')) { $singlePart = 'video'; }
if($category->term_id == xoption('articleCategory') || safir_top_category($category->term_id) == xoption('articleCategory')) { $singlePart = 'article'; }
}
?>
<div id="main">
<div class="innerContainer pad">
<?php
switch ($singlePart) {
case 'normal':
get_template_part('single-normal');
safir_sidebar('single');
break;
case 'photo':
case 'video':
get_template_part('single-normal');
safir_sidebar($singlePart);
break;
case 'article':
get_template_part('single-article');
safir_sidebar('article');
break;
}
?>
</div>
</div>
<?php
endwhile;
?>
<div class="nav-links" style="display: none;">
<?php if ( $x = get_previous_post_link('<div class="text">%link</div>')): ?>
<div class="prev container"><?php echo $x; ?></div>
<?php endif; ?>
</div>
<?php get_footer(); ?>