Commit 270e7372 authored by Jakob Moser's avatar Jakob Moser
Browse files

Merge branch '11-optimize-and-unify-php' into 'master'

Optimize and unify PHP, part 2

See merge request !22
parents d9b5c5cc 9c96cb11
Loading
Loading
Loading
Loading

components/article.php

0 → 100644
+50 −0
Original line number Diff line number Diff line
<article>
    <?php if(has_post_thumbnail()) {
        // A header configured specifically for this article
        $url = get_the_post_thumbnail_url();
    } elseif(!$args["hide_default_header_image"]) {
        // Fall back to the default header (which can be configured site-wide, so we can't hardcode the URL)
        $url = get_header_image();
    } else {
        $url = null;
    }

    if($url !== null) {
        $style = "style=\"background-image:url('$url')\"";
    } else {
        $style = "";
    } ?>

    <header <?php echo $style; ?>>
        <?php if($args["link_title"]): ?>
            <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
        <?php else: ?>
            <h1><?php the_title(); ?></h1>
        <?php endif; ?>
    </header>
    <div class="content">
        <?php if($args["show_only_excerpt"]) {
            the_excerpt();
        } else {
            the_content(); 
        } ?>
    </div>
    <footer>
        <?php if($args["show_author"]): ?>
            <div class="author"><?php the_author_meta('display_name'); ?></div>
        <?php endif; ?>

        <?php if($args["show_published_date"]): ?>
            <div class="published date"><span class="label">Veröffentlicht: </span><time><?php the_date(); ?></time></div>
        <?php endif; ?>

        <?php if($args["show_modified_date"]):
            $different = "";
            if($args["show_published_date"] && get_the_modified_date() !== get_the_date()) {
                $different = "different";
            }
        ?>
            <div class="modified date <?php echo $different; ?>"><span class="label">Zuletzt geändert: </span><time><?php the_modified_date(); ?></time></div>
        <?php endif; ?>
    </footer>
</article>
+22 −36
Original line number Diff line number Diff line
@@ -14,61 +14,47 @@ get_header();
?>
<aside class="levitating list-meta">
    <h1>
        <?php
            if ( is_category() ) {
        <?php if(is_category()) {
            single_cat_title();
        } elseif(is_archive()) {
                single_month_title(' ');
            single_month_title(" ");
        } else {
            echo "Blog";
            }
        ?>
        } ?>
    </h1>
    <br>

    <h2>Kategorien</h2>
    <br>
    <ul class="categories seamless box-links">
        <?php wp_list_categories(array('title_li'=>'')); ?>
        <?php wp_list_categories(array("title_li"=>"")); ?>
    </ul>
    <br>
    <br>

    <h2>Archiv</h2>
    <br>
    <select onchange="document.location.href=this.options[this.selectedIndex].value;">
        <option>nach Monat</option>
        <?php wp_get_archives(array('format'=>'option')); ?>
        <?php wp_get_archives(array("format"=>"option")); ?>
    </select>
    <br>
    <br>
    <a href="<?php bloginfo('rss2_url'); ?>" class="rss">

    <a href="<?php bloginfo("rss2_url"); ?>" class="rss">
        zum RSS-Feed
    </a>
</aside>

<main class="list">
    <?php while ( have_posts() ) : the_post(); ?>
        <article>
            <header
                <?php if ( has_post_thumbnail($post->ID) ) : ?>
                style="background-image:url('<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>');"
                <?php endif; ?>
            >
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
            </header>

            <div class="content">
                <?php the_excerpt(); ?>
            </div>

            <footer>
                <div class="published date"><time><?php the_date(); ?></time></div>
            </footer>
        </article>
    <?php endwhile; ?>
    <?php while (have_posts()) {
        the_post();
        get_template_part("components/article", null, array(
            "show_author" => false,
            "show_published_date" => true,
            "show_modified_date" => false,
            "show_only_excerpt" => true,
            "link_title" => true,
            "hide_default_header_image" => true
        ));
    } ?>

    <div class="pagination">
        <div class="older-posts"><?php next_posts_link( '« Ältere Posts' ); ?></div>
        <div class="newer-posts"><?php previous_posts_link( 'Neuere Posts »' ); ?></div>
        <div class="older-posts"><?php next_posts_link("« Ältere Posts"); ?></div>
        <div class="newer-posts"><?php previous_posts_link("Neuere Posts »"); ?></div>
    </div>
</main>
<?php get_footer(); ?>
+8 −18
Original line number Diff line number Diff line
@@ -22,23 +22,13 @@
get_header();
?>
<main>
    <?php the_post(); ?>
    <article>
        <header style="background-image:url('<?php if(has_post_thumbnail()) {
                // A header configured specifically for this page
                the_post_thumbnail_url();
            } else {
                // Fall back to the default header (which can be configured site-wide, so we can't hardcode the URL)
                header_image();
            } ?>')">
            <h1><?php the_title(); ?></h1>
        </header>
        <div class="content">
            <?php the_content(); ?>
        </div>
        <footer>
            <div class="modified date">Zuletzt geändert: <time><?php the_modified_date(); ?></time></div>
        </footer>
    </article>
    <?php
        the_post();
        get_template_part("components/article", null, array(
            "show_author" => false,
            "show_published_date" => false,
            "show_modified_date" => true
        ));
    ?>
</main>
<?php get_footer(); ?>
+8 −20
Original line number Diff line number Diff line
@@ -20,25 +20,13 @@
get_header();
?>
<main>
    <?php the_post(); ?>
    <article>
        <header style="background-image:url('<?php if(has_post_thumbnail()) {
                // A header configured specifically for this post
                the_post_thumbnail_url();
            } else {
                // Fall back to the default header (which can be configured site-wide, so we can't hardcode the URL)
                header_image();
            } ?>')">
            <h1><?php the_title(); ?></h1>
        </header>
        <div class="content">
            <?php the_content(); ?>
        </div>
        <footer>
            <div class="author"><?php the_author_meta('display_name'); ?></div>
            <div class="published date">Veröffentlicht: <time><?php the_date(); ?></time></div>
            <div class="modified date <?php if(get_the_modified_date() !== get_the_date()) { echo 'different'; } ?>">Zuletzt geändert: <time><?php the_modified_date(); ?></time></div>
        </footer>
    </article>
    <?php 
        the_post();
        get_template_part("components/article", null, array(
            "show_author" => true,
            "show_published_date" => true,
            "show_modified_date" => true
        ));
    ?>
</main>
<?php get_footer(); ?>
+9 −0
Original line number Diff line number Diff line
@@ -614,6 +614,10 @@ main.list footer .date {
    opacity: 0.5;
}

main.list footer .date .label {
    display: none;
}

main.list article .content {
    position: relative;
    z-index: 1;
@@ -639,6 +643,10 @@ main.list article > header h1 {
    left: 1.1em;
}

.list-meta > h2 {
    margin: 1em 0;
}

.list-meta > h1::before {
    display: inline-block;
    width: 1em;
@@ -662,6 +670,7 @@ main.list article > header h1 {
    font-size: 0.8em;
    color: #8d8d8d;
    text-align: right;
    margin-top: 2em;
}

.list-meta .categories li a {