This commit is contained in:
2023-01-26 21:14:40 +00:00
parent 7bd647a7a0
commit a293155787
28 changed files with 666 additions and 501 deletions

View File

@@ -1,128 +1,99 @@
defaults: &defaults version: 2.1
working_directory: ~/tmp/windycoys orbs:
docker: node: circleci/node@5.1
- image: circleci/node:10.15 aws-s3: circleci/aws-s3@3.1
semver-tags: &semver-tags
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
develop: &develop
filters:
branches:
only: develop
other-branches: &other-branches
filters:
branches:
ignore:
- master
- develop
version: 2
jobs: jobs:
install: build_and_test:
<<: *defaults executor: node/default
steps: steps:
- attach_workspace:
at: ~/tmp/windycoys
- checkout - checkout
- run: - node/install-packages:
name: Install dependencies pkg-manager: npm
command: npm install
- persist_to_workspace:
root: .
paths: .
test:
<<: *defaults
steps:
- attach_workspace:
at: ~/tmp/windycoys
- run: - run:
name: Run tests name: Run tests
command: npm test command: npm run lint
build:
<<: *defaults
environment:
NODE_ENV: production
steps:
- attach_workspace:
at: ~/tmp/windycoys
- run: - run:
name: Build CSS and JavaScript name: Build app
command: npm run build command: npm run build
- run:
name: Generate timestamp
command: bash build/generate_timestamp.sh
- persist_to_workspace: - persist_to_workspace:
root: . root: ~/project
paths: . paths:
deploy-prod: - .
<<: *defaults deploy:
executor: node/default
steps: steps:
- attach_workspace: - attach_workspace:
at: ~/tmp/windycoys at: ~/project
- run: - run:
name: Install rsync name: Known Hosts
command: sudo apt install -y rsync command: |
mkdir ~/.ssh || :
echo -e $KNOWN_HOSTS > ~/.ssh/known_hosts
- run: - run:
name: Deploy theme name: Clean
command: bash build/deploy.sh prod command: sh build/clean.sh
- run: - run:
name: Purge Cloudflare cache name: Deploy
command: bash build/purge_cache.sh command: sh build/deploy.sh
deploy-develop: backup_to_s3:
<<: *defaults docker:
- image: 'cimg/python:3.10'
steps: steps:
- attach_workspace: - checkout
at: ~/tmp/windycoys
- run: - run:
name: Install rsync name: Known Hosts
command: sudo apt install -y rsync command: |
mkdir ~/.ssh || :
echo -e $KNOWN_HOSTS > ~/.ssh/known_hosts
- run: - run:
name: Deploy theme name: Prepare filename
command: bash build/deploy.sh develop command: |
filename=windycoys-$(date +'%Y-%m-%dT%H-%M-%S').tgz
echo "export filename='$filename'" >> $BASH_ENV
- run: - run:
name: Purge Cloudflare cache name: Prepare backups
command: bash build/purge_cache.sh command: |
ssh $SSH_USER@$SSH_IP "bash -c '\
source windycoys/.env
rm -rf windycoys/backup
mkdir -p windycoys/backup/data
scp -r windycoys/wp-content windycoys/backup/data/
docker exec -t $DOCKER_DB_NAME /usr/bin/mysqldump \
-uroot --password=$DB_ROOT_PASSWORD \
$DB_NAME | gzip -9 > windycoys/backup/data/database.sql.gz
/usr/bin/tar zcf windycoys/backup/windycoys.tgz windycoys/backup/data'"
- run:
name: Copy backup
command: |
scp $SSH_USER@$SSH_IP:~/windycoys/backup/windycoys.tgz ./
mv windycoys.tgz $filename
- aws-s3/copy:
aws-region: AWS_REGION
aws-access-key-id: AWS_ACCESS_KEY_ID
aws-secret-access-key: AWS_SECRET_ACCESS_KEY
from: '$filename'
to: 's3://$AWS_S3_BUCKET_NAME'
workflows: workflows:
version: 2 test_my_app:
test:
jobs: jobs:
- install: *other-branches - build_and_test:
- test: filters:
<<: *other-branches branches:
only: main
- deploy:
requires: requires:
- install - build_and_test
develop: filters:
branches:
only: main
backup:
triggers:
- schedule:
cron: "0 2 * * 1"
filters:
branches:
only:
- next
jobs: jobs:
- install: *develop - backup_to_s3
- test:
<<: *develop
requires:
- install
- build:
<<: *develop
requires:
- test
- deploy-develop:
<<: *develop
requires:
- build
prod:
jobs:
- install: *semver-tags
- test:
<<: *semver-tags
requires:
- install
- build:
<<: *semver-tags
requires:
- test
- deploy-prod:
<<: *semver-tags
requires:
- build

17
build/backup.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/env sh
source .env
rm -rf ~/windycoys/backup
rm -f ~/windycoys/windycoys-*.tgz
mkdir -p ~/windycoys/backup
scp -r ~/windycoys/wp-content ~/windycoys/backup/
docker exec -it $DOCKER_DB_NAME /usr/bin/mysqldump -uroot -p"$DB_ROOT_PASSWORD" $DB_NAME | gzip -9 > ~/windycoys/backup/database.sql.gz
ls -l ~/windycoys/backup/
datetime=$(date +'%Y-%m-%dT%H-%M-%S')
file=windycoys-$datetime.tgz
/usr/bin/tar zcf ~/windycoys/$file ~/windycoys/backup
rm -rf ~/windycoys/backup

8
build/clean.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env sh
# Test environment variables are set
[ -z "$SSH_IP" ] && { echo >&2 "Error: SSH_IP is missing. Aborting."; exit 1; }
[ -z "$SSH_USER" ] && { echo >&2 "Error: SSH_USER is missing. Aborting."; exit 1; }
# Deploy theme
ssh $SSH_USER@$SSH_IP rm -r ~/windycoys/dist/*

View File

@@ -1,10 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env sh
# Ensure target is defined # Test environment variables are set
[ -z "$1" ] && { echo >&2 "Error: Build target not defined. Aborting."; exit 1; }
# Test rsync is installed and ENV variables are set
hash rsync 2>/dev/null || { echo >&2 "Error: rsync is not installed. Aborting."; exit 1; }
[ -z "$SSH_IP" ] && { echo >&2 "Error: SSH_IP is missing. Aborting."; exit 1; } [ -z "$SSH_IP" ] && { echo >&2 "Error: SSH_IP is missing. Aborting."; exit 1; }
[ -z "$SSH_USER" ] && { echo >&2 "Error: SSH_USER is missing. Aborting."; exit 1; } [ -z "$SSH_USER" ] && { echo >&2 "Error: SSH_USER is missing. Aborting."; exit 1; }

View File

@@ -16,7 +16,7 @@
"build:ts": "cross-env NODE_ENV=production webpack", "build:ts": "cross-env NODE_ENV=production webpack",
"lint": "run-p lint:*", "lint": "run-p lint:*",
"lint:eslint": "eslint src --ext .ts", "lint:eslint": "eslint src --ext .ts",
"postinstall": "run-p browser-sync", "postinstallf": "run-p browser-sync",
"serve": "docker-compose -f build/docker-compose.dev.yml up --force-recreate 2>/dev/null", "serve": "docker-compose -f build/docker-compose.dev.yml up --force-recreate 2>/dev/null",
"start": "run-p serve watch", "start": "run-p serve watch",
"test": "jest", "test": "jest",

View File

@@ -1,18 +1,18 @@
<?php get_header(); ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo"> <section class="page__logo">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<section class="page__content"> <section class="page__content">
<h1 class="title">404 - Page not found</h1> <h1 class="title">404 - Page not found</h1>
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a> <a class="link" href="<?php echo get_site_url(); ?>/">Go back home</a>
</section> </section>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,48 +1,61 @@
<?php <?php
class Windycoys_Walker_Comments extends Walker_Comment { class Windycoys_Walker_Comments extends Walker_Comment
function start_lvl(&$output, $depth = 0, $args = Array()) { {
function start_lvl(&$output, $depth = 0, $args = [])
{
$output .= '<ol class="comments__list comments__list--sub-list">'; $output .= '<ol class="comments__list comments__list--sub-list">';
} }
function end_lvl(&$output, $depth = 0, $args = Array()) { function end_lvl(&$output, $depth = 0, $args = [])
$output .= '</ol>'; {
$output .= "</ol>";
} }
function start_el(&$output, $comment, $depth = 0 , $args = Array(), $id = 0) { function start_el(&$output, $comment, $depth = 0, $args = [], $id = 0)
{
$id = $comment->comment_ID; $id = $comment->comment_ID;
$post_id = $comment->comment_post_ID; $post_id = $comment->comment_post_ID;
$reply_link = get_permalink($post_id) . '?replytocom='.$id.'#respond'; $reply_link = get_permalink($post_id) . "?replytocom=" . $id . "#respond";
$author_email = $comment->comment_author_email; $author_email = $comment->comment_author_email;
$author = $comment->comment_author; $author = $comment->comment_author;
$avatar = get_avatar($comment, 128); $avatar = get_avatar($comment, 128);
$date = get_comment_date(get_option('date_format'), $id).' at '.get_comment_date(get_option('time_format'), $id); $date =
get_comment_date(get_option("date_format"), $id) .
" at " .
get_comment_date(get_option("time_format"), $id);
$content = $comment->comment_content; $content = $comment->comment_content;
$output .= '<li class="comments__item">'; $output .= '<li class="comments__item">';
$output .= '<div class="comment">'; $output .= '<div class="comment">';
$output .= '<div class="comment__head">'; $output .= '<div class="comment__head">';
$output .= sprintf('<div class="comment__avatar has-silhouette">%s</div>', $avatar); $output .= sprintf(
'<div class="comment__avatar has-silhouette">%s</div>',
$avatar
);
$output .= '<div class="comment__metadata">'; $output .= '<div class="comment__metadata">';
$output .= sprintf('<span class="comment__author">%s</span>', $author); $output .= sprintf('<span class="comment__author">%s</span>', $author);
$output .= sprintf('<span class="comment__date">%s</span>', $date); $output .= sprintf('<span class="comment__date">%s</span>', $date);
$output .= '</div></div>'; $output .= "</div></div>";
$output .= sprintf('<div class="comment__body">%s</div>', $content); $output .= sprintf('<div class="comment__body">%s</div>', $content);
$output .= '<div class="comment__foot">'; $output .= '<div class="comment__foot">';
$output .= sprintf('<a class="comment__reply" data-comment-author="%s" ' . $output .= sprintf(
'<a class="comment__reply" data-comment-author="%s" ' .
'data-comment-id="%s" href="%s">', 'data-comment-id="%s" href="%s">',
$author, $author,
$id, $id,
$reply_link $reply_link
); );
$output .= '<span class="comment__reply-icon">'; $output .= '<span class="comment__reply-icon">';
$output .= '<svg class="icon icon--extra-small"><use href="#icon-reply"></use></svg></span>'; $output .=
'<svg class="icon icon--extra-small"><use href="#icon-reply"></use></svg></span>';
$output .= '<span class="comment__reply-text">Reply</span></a>'; $output .= '<span class="comment__reply-text">Reply</span></a>';
$output .= '<div class="comment__inline-reply"></div>'; $output .= '<div class="comment__inline-reply"></div>';
$output .= '</div></div>'; $output .= "</div></div>";
} }
function end_el(&$output, $comment, $depth = 0, $args = Array()) { function end_el(&$output, $comment, $depth = 0, $args = [])
$output .= '</li>'; {
$output .= "</li>";
} }
} }

View File

@@ -1,27 +1,35 @@
<?php <?php
class Windycoys_Walker_Navigation extends Walker_Nav_Menu { class Windycoys_Walker_Navigation extends Walker_Nav_Menu
function start_lvl(&$output, $depth = 0, $args = Array()) { {
function start_lvl(&$output, $depth = 0, $args = [])
{
$output .= '<ul class="nav__list" role="menu">'; $output .= '<ul class="nav__list" role="menu">';
} }
function end_lvl(&$output, $depth = 0, $args = Array()) { function end_lvl(&$output, $depth = 0, $args = [])
$output .= '</ul>'; {
$output .= "</ul>";
} }
function start_el(&$output, $item, $depth = 0, $args = Array(), $id = 0) { function start_el(&$output, $item, $depth = 0, $args = [], $id = 0)
{
$title = $item->title; $title = $item->title;
$url = $item->url; $url = $item->url;
if ($title && $url) { if ($title && $url) {
$output .= '<li class="nav__list-item" role="none">'; $output .= '<li class="nav__list-item" role="none">';
$output .= sprintf('<a class="nav__link" href="%s" role="menuitem">', $url); $output .= sprintf(
'<a class="nav__link" href="%s" role="menuitem">',
$url
);
$output .= $title; $output .= $title;
$output .= '</a>'; $output .= "</a>";
} }
} }
function end_el(&$output, $item, $depth = 0, $args = Array()) { function end_el(&$output, $item, $depth = 0, $args = [])
$output .= '</li>'; {
$output .= "</li>";
} }
} }

View File

@@ -1,50 +1,83 @@
<?php <?php
require get_template_directory() . '/classes/walker.comments.php'; require get_template_directory() . "/classes/walker.comments.php";
$form_settings = array( $form_settings = [
"class_form" => 'comment-respond__form', "class_form" => "comment-respond__form",
"class_submit" => 'comment-respond__submit', "class_submit" => "comment-respond__submit",
"comment_field" => '<div class="comment-respond__item comment-respond__item--large"><label class="comment-respond__label" for="comment">Comment</label><textarea class="comment-respond__input" id="comment" name="comment" cols="25" rows="8" aria-required="true"></textarea></div>', "comment_field" =>
"logged_in_as" => '<p class="comment-respond__text">' . sprintf( __( 'Logged in as <a class="link" href="%1$s">%2$s</a>. <a class="link" href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>', '<div class="comment-respond__item comment-respond__item--large"><label class="comment-respond__label" for="comment">Comment</label><textarea class="comment-respond__input" id="comment" name="comment" cols="25" rows="8" aria-required="true"></textarea></div>',
"title_reply_before" => '<h3 id="reply-title" class="comment-respond__title">', "logged_in_as" =>
'<p class="comment-respond__text">' .
sprintf(
__(
'Logged in as <a class="link" href="%1$s">%2$s</a>. <a class="link" href="%3$s" title="Log out of this account">Log out?</a>'
),
admin_url("profile.php"),
$user_identity,
wp_logout_url(apply_filters("the_permalink", get_permalink()))
) .
"</p>",
"title_reply_before" =>
'<h3 id="reply-title" class="comment-respond__title">',
"title_reply" => '<span class="comment-respond__title-text">Reply</span>', "title_reply" => '<span class="comment-respond__title-text">Reply</span>',
"cancel_reply_before" => '<span class="comment-respond__cancel">', "cancel_reply_before" => '<span class="comment-respond__cancel">',
"cancel_reply_after" => '</span>', "cancel_reply_after" => "</span>",
"comment_notes_before" => '<p class="comment-respond__notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>', "comment_notes_before" =>
"fields" => array( '<p class="comment-respond__notes">' .
"author" => '<div class="comment-respond__item"><label class="comment-respond__label" for="author">' . __( 'Name', 'domainreference' ) . ( $req ? '<span class="comment-respond__required">*</span>' : '' ) . '</label>' . '<input class="comment-respond__input" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="60" aria-required="true" /></div>', __("Your email address will not be published.") .
"email" => '<div class="comment-respond__item"><label class="comment-respond__label" for="email">' . __( 'Email', 'domainreference' ) . ( $req ? '<span class="comment-respond__required">*</span>' : '' ) . '</label>' . '<input class="comment-respond__input" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="60" aria-required="true" /></div>', ($req ? $required_text : "") .
"url" => '<div class="comment-respond__item"><label class="comment-respond__label" for="url">' . __( 'Website', 'domainreference' ) . '</label>' . '<input class="comment-respond__input" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div>', "</p>",
"cookies" => '<div class="comment-respond__item comment-respond__item--large"><input class="comment-respond__checkbox" id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"/><label class="comment-respond__checkbox-label" for="wp-comment-cookies-consent">Save my name, email, and website in this browser for the next time I comment.</label></div>', "fields" => [
), "author" =>
); '<div class="comment-respond__item"><label class="comment-respond__label" for="author">' .
__("Name", "domainreference") .
($req ? '<span class="comment-respond__required">*</span>' : "") .
"</label>" .
'<input class="comment-respond__input" id="author" name="author" type="text" value="' .
esc_attr($commenter["comment_author"]) .
'" size="60" aria-required="true" /></div>',
"email" =>
'<div class="comment-respond__item"><label class="comment-respond__label" for="email">' .
__("Email", "domainreference") .
($req ? '<span class="comment-respond__required">*</span>' : "") .
"</label>" .
'<input class="comment-respond__input" id="email" name="email" type="text" value="' .
esc_attr($commenter["comment_author_email"]) .
'" size="60" aria-required="true" /></div>',
"url" =>
'<div class="comment-respond__item"><label class="comment-respond__label" for="url">' .
__("Website", "domainreference") .
"</label>" .
'<input class="comment-respond__input" id="url" name="url" type="text" value="' .
esc_attr($commenter["comment_author_url"]) .
'" size="30" /></div>',
"cookies" =>
'<div class="comment-respond__item comment-respond__item--large"><input class="comment-respond__checkbox" id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"/><label class="comment-respond__checkbox-label" for="wp-comment-cookies-consent">Save my name, email, and website in this browser for the next time I comment.</label></div>',
],
];
?> ?>
<div class="comments" id="comments"> <div class="comments" id="comments">
<div class="comments__head"> <div class="comments__head">
<h2 class="comments__title"> <h2 class="comments__title">
<?php <?php if (comments_open()):
if (comments_open()) : if (have_comments()):
if (have_comments()) : echo "Join the conversation";
echo 'Join the conversation';
else: else:
echo 'Leave a comment'; echo "Leave a comment";
endif; endif;
else: else:
echo 'Comments are closed'; echo "Comments are closed";
endif; endif; ?>
?>
</h2> </h2>
</div> </div>
<div class="comments__body"> <div class="comments__body">
<ol class="comments__list"> <ol class="comments__list">
<?php <?php wp_list_comments([
wp_list_comments(array(
"walker" => new Windycoys_Walker_Comments(), "walker" => new Windycoys_Walker_Comments(),
)); ]); ?>
?>
</ol> </ol>
</div> </div>
<div class="comments__foot"> <div class="comments__foot">
<?php comment_form($form_settings) ?> <?php comment_form($form_settings); ?>
</div> </div>
</div> </div>

View File

@@ -1,12 +1,12 @@
<?php <?php
$js_url = get_template_directory_uri() . '/bundle.js'; $js_url = get_template_directory_uri() . "/bundle.js";
$deploy_timestamp = windycoys_get_deploy_timestamp(); $deploy_timestamp = windycoys_get_deploy_timestamp();
if ($deploy_timestamp) { if ($deploy_timestamp) {
$js_url .= '?t=' . $deploy_timestamp; $js_url .= "?t=" . $deploy_timestamp;
} }
?> ?>
<div id="fb-root"></div> <div id="fb-root"></div>
<script type="text/javascript" src="<?php echo $js_url ?>"></script> <script type="text/javascript" src="<?php echo $js_url; ?>"></script>
<script type="text/javascript"> <script type="text/javascript">
(function(d, s, id) { (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0]; var js, fjs = d.getElementsByTagName(s)[0];

View File

@@ -1,58 +1,62 @@
<?php get_header() ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo is-fixed"> <section class="page__logo is-fixed">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<section class="page__content page__content--centered-md"> <section class="page__content page__content--centered-md">
<h1 class="title">Latest articles</h1> <h1 class="title">Latest articles</h1>
<div class="page__columns"> <div class="page__columns">
<?php <?php
$posts = get_posts(array( $posts = get_posts([
"numberposts" => 4, "numberposts" => 4,
)); ]);
foreach ($posts as $post) { foreach ($posts as $post) {
$date = strtotime($post->post_date); $date = strtotime($post->post_date);
$year = date('Y', $date); $year = date("Y", $date);
$month = date('F', $date); $month = date("F", $date);
$day = date('jS', $date); $day = date("jS", $date);
$date = get_the_date(get_option('date_format'), $post->ID).' at '.get_the_date(get_option('time_format'), $post->ID); $date =
$content = (strlen($post->post_excerpt) === 0) ? get_the_date(get_option("date_format"), $post->ID) .
strip_tags(substr($post->post_content, 0, 200)).' [...]' : " at " .
$post->post_excerpt; get_the_date(get_option("time_format"), $post->ID);
$content =
strlen($post->post_excerpt) === 0
? strip_tags(substr($post->post_content, 0, 200)) . " [...]"
: $post->post_excerpt;
$words = count(explode(" ", $post->post_content)); $words = count(explode(" ", $post->post_content));
$excerpt = array( $excerpt = [
"title" => $post->post_title, "title" => $post->post_title,
"url" => get_permalink($post->ID), "url" => get_permalink($post->ID),
"content" => $content, "content" => $content,
"author" => get_the_author_meta('nickname', $post->post_author), "author" => get_the_author_meta("nickname", $post->post_author),
"comments" => $post->comment_count, "comments" => $post->comment_count,
"words" => $words, "words" => $words,
"date" => $date, "date" => $date,
); ];
echo '<div class="page__cell">'; echo '<div class="page__cell">';
get_template_part('partials/excerpt'); get_template_part("partials/excerpt");
echo '</div>'; echo "</div>";
} }
?> ?>
</div> </div>
<h2 class="title">Podcasts</h2> <h2 class="title">Podcasts</h2>
<div class="page__columns"> <div class="page__columns">
<div class="page__cell"> <div class="page__cell">
<?php $podcast = windycoys_get_podcast_meta('xin') ?> <?php $podcast = windycoys_get_podcast_meta("xin"); ?>
<?php get_template_part('partials/podcast') ?> <?php get_template_part("partials/podcast"); ?>
</div> </div>
<div class="page__cell"> <div class="page__cell">
<?php $podcast = windycoys_get_podcast_meta('tfc') ?> <?php $podcast = windycoys_get_podcast_meta("tfc"); ?>
<?php get_template_part('partials/podcast') ?> <?php get_template_part("partials/podcast"); ?>
</div> </div>
</div> </div>
</section> </section>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,50 +1,61 @@
<?php <?php
function windycoys_the_tags() { function windycoys_the_tags()
{
$tags = get_the_tags(); $tags = get_the_tags();
if (!$tags) return false; if (!$tags) {
return false;
}
// Suppress NewsNow tag // Suppress NewsNow tag
foreach($tags as $key=>$tag) { foreach ($tags as $key => $tag) {
if($tag->name === "newsnow") { if ($tag->name === "newsnow") {
unset($tags[$key]); unset($tags[$key]);
} }
} }
if ($tags) { if ($tags) {
foreach($tags as $key=>$tag) { foreach ($tags as $key => $tag) {
echo '<a class="metadata__tag-link" href="' . echo '<a class="metadata__tag-link" href="' .
home_url() . '/tag/' . $tag->name . '" rel="tag">' . home_url() .
$tag->name . '</a>'; "/tag/" .
$tag->name .
'" rel="tag">' .
$tag->name .
"</a>";
if ($key < count($tags) - 1) { if ($key < count($tags) - 1) {
echo ', '; echo ", ";
} }
} }
} }
} }
function windycoys_get_twitter_share_url() { function windycoys_get_twitter_share_url()
$url = 'https://twitter.com/intent/tweet?text='; {
$url = "https://twitter.com/intent/tweet?text=";
$title = get_the_title(); $title = get_the_title();
$link = get_the_permalink(); $link = get_the_permalink();
return $url . urlencode($title . ' : ' . $link); return $url . urlencode($title . " : " . $link);
} }
function windycoys_search_posts_per_page($query) { function windycoys_search_posts_per_page($query)
{
if ($query->is_search) { if ($query->is_search) {
$query->set( 'posts_per_page', '10' ); $query->set("posts_per_page", "10");
} }
return $query; return $query;
} }
add_filter('pre_get_posts', 'windycoys_search_posts_per_page'); add_filter("pre_get_posts", "windycoys_search_posts_per_page");
function windycoys_get_deploy_timestamp() { function windycoys_get_deploy_timestamp()
if (file_exists(__DIR__ . '/.timestamp')) { {
$timestamp = file_get_contents(__DIR__ . '/.timestamp'); if (file_exists(__DIR__ . "/.timestamp")) {
$timestamp = file_get_contents(__DIR__ . "/.timestamp");
return $timestamp; return $timestamp;
} }
return false; return false;
} }
function windycoys_create_podcasts_table() { function windycoys_create_podcasts_table()
{
global $wpdb; global $wpdb;
$charset_collate = $wpdb->get_charset_collate(); $charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE windycoys_podcasts ( $sql = "CREATE TABLE windycoys_podcasts (
@@ -54,143 +65,170 @@ function windycoys_create_podcasts_table() {
content longtext DEFAULT '' NOT NULL, content longtext DEFAULT '' NOT NULL,
PRIMARY KEY (id) PRIMARY KEY (id)
) $charset_collate;"; ) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); require_once ABSPATH . "wp-admin/includes/upgrade.php";
dbDelta($sql); dbDelta($sql);
$wpdb->insert('windycoys_podcasts', array( $wpdb->insert("windycoys_podcasts", [
'podcast_id' => 'tfc', "podcast_id" => "tfc",
'last_update' => 0, "last_update" => 0,
'content' => '{}' "content" => "{}",
)); ]);
$wpdb->insert('windycoys_podcasts', array( $wpdb->insert("windycoys_podcasts", [
'podcast_id' => 'xin', "podcast_id" => "xin",
'last_update' => 0, "last_update" => 0,
'content' => '{}' "content" => "{}",
)); ]);
} }
function windycoys_fetch_podcast_meta($id) { function windycoys_fetch_podcast_meta($id)
{
global $wpdb; global $wpdb;
$urls = array( $urls = [
"tfc" => 'https://rss.acast.com/thefightingcock', "tfc" => "https://rss.acast.com/thefightingcock",
"xin" => 'https://rss.acast.com/theextrainch', "xin" => "https://rss.acast.com/theextrainch",
); ];
$feed = file_get_contents($urls[$id]); $feed = file_get_contents($urls[$id]);
$feed = str_replace('<media:', '<', $feed); $feed = str_replace("<media:", "<", $feed);
$feed = str_replace('</media:', '</', $feed); $feed = str_replace("</media:", "</", $feed);
$feed = str_replace('<itunes:', '<', $feed); $feed = str_replace("<itunes:", "<", $feed);
$feed = str_replace('</itunes:', '</', $feed); $feed = str_replace("</itunes:", "</", $feed);
$now = time(); $now = time();
$wpdb->update("windycoys_podcasts", $wpdb->update(
array('last_update' => $now, 'content' => $feed), "windycoys_podcasts",
array('podcast_id'=>$id) ["last_update" => $now, "content" => $feed],
["podcast_id" => $id]
); );
return $feed; return $feed;
} }
function windycoys_refresh_podcast_meta($id) { function windycoys_refresh_podcast_meta($id)
{
global $wpdb; global $wpdb;
$now = time(); $now = time();
$res = $wpdb->get_row('SELECT * FROM windycoys_podcasts WHERE $res = $wpdb->get_row(
podcast_id = "' . $id .'"'); 'SELECT * FROM windycoys_podcasts WHERE
podcast_id = "' .
$id .
'"'
);
if (!$res) { if (!$res) {
windycoys_create_podcasts_table(); windycoys_create_podcasts_table();
} }
if ($res->last_update + 300 < $now) { if ($res->last_update + 300 < $now) {
return array( return [
"from_cache" => false, "from_cache" => false,
"data" => windycoys_fetch_podcast_meta($id), "data" => windycoys_fetch_podcast_meta($id),
); ];
} }
return array( return [
"from_cache" => true, "from_cache" => true,
"data" => $res->content, "data" => $res->content,
); ];
} }
function windycoys_get_episodes_url($id) { function windycoys_get_episodes_url($id)
$urls = array( {
"tfc" => 'https://play.acast.com/s/thefightingcock', $urls = [
"xin" => 'https://play.acast.com/s/theextrainch', "tfc" => "https://play.acast.com/s/thefightingcock",
); "xin" => "https://play.acast.com/s/theextrainch",
];
return $urls[$id]; return $urls[$id];
} }
function windycoys_get_podcast_meta($id) { function windycoys_get_podcast_meta($id)
{
$res = windycoys_refresh_podcast_meta($id); $res = windycoys_refresh_podcast_meta($id);
$rss = simplexml_load_string($res['data']); $rss = simplexml_load_string($res["data"]);
$item = $rss->channel->item; $item = $rss->channel->item;
$date = strtotime((String) $item->pubDate); $date = strtotime((string) $item->pubDate);
return array( return [
"id" => $id, "id" => $id,
"from_cache" => $res['from_cache'], "from_cache" => $res["from_cache"],
"podcast_title" => (String) $rss->channel->title, "podcast_title" => (string) $rss->channel->title,
"podcast_description" => (String) $rss->channel->description, "podcast_description" => (string) $rss->channel->description,
"podcast_episodes" => windycoys_get_episodes_url($id), "podcast_episodes" => windycoys_get_episodes_url($id),
"artwork_url" => (String) $rss->channel->image->url, "artwork_url" => (string) $rss->channel->image->url,
"title" => (String) $item->title, "title" => (string) $item->title,
"description" => (String) $item->description, "description" => (string) $item->description,
"image" => (String) $item->image['href'], "image" => (string) $item->image["href"],
"date" => date(get_option('date_format'), $date).' at '.date(get_option('time_format'), $date), "date" =>
"length" => (String) $item->duration, date(get_option("date_format"), $date) .
"url" => (String) $item->link, " at " .
"audio" => (String) $item->enclosure['url'], date(get_option("time_format"), $date),
); "length" => (string) $item->duration,
"url" => (string) $item->link,
"audio" => (string) $item->enclosure["url"],
];
} }
function windycoys_get_read_time($words) { function windycoys_get_read_time($words)
{
$wpm = 250; $wpm = 250;
$mins = ceil($words / $wpm); $mins = ceil($words / $wpm);
return $mins; return $mins;
} }
function windycoys_is_ie() { function windycoys_is_ie()
{
$ua = htmlentities($_SERVER["HTTP_USER_AGENT"], ENT_QUOTES, "UTF-8"); $ua = htmlentities($_SERVER["HTTP_USER_AGENT"], ENT_QUOTES, "UTF-8");
if (preg_match("~MSIE|Internet Explorer~i", $ua) || (strpos($ua, "Trident/7.0") !== false && strpos($ua, "rv:11.0") !== false)) { if (
preg_match("~MSIE|Internet Explorer~i", $ua) ||
(strpos($ua, "Trident/7.0") !== false && strpos($ua, "rv:11.0") !== false)
) {
return true; return true;
} }
return false; return false;
} }
function windycoys_first_sentence($string) { function windycoys_first_sentence($string)
$sentence = preg_split( '/(\.|!|\?)\s/', $string, 2, PREG_SPLIT_DELIM_CAPTURE ); {
return $sentence['0'] . $sentence['1']; $sentence = preg_split("/(\.|!|\?)\s/", $string, 2, PREG_SPLIT_DELIM_CAPTURE);
return $sentence["0"] . $sentence["1"];
} }
function windycoys_get_description($post_id) { function windycoys_get_description($post_id)
{
if (get_post_type() == "post") { if (get_post_type() == "post") {
$post = get_post($post_id); $post = get_post($post_id);
$content = (strlen($post->post_excerpt) === 0) ? $content =
strip_tags(windycoys_first_sentence($post->post_content)) : strlen($post->post_excerpt) === 0
$post->post_excerpt; ? strip_tags(windycoys_first_sentence($post->post_content))
: $post->post_excerpt;
return $content; return $content;
} else { } else {
return get_bloginfo('description'); return get_bloginfo("description");
} }
} }
function windycoys_jetpack_custom_image($media, $post_id, $args) { function windycoys_jetpack_custom_image($media, $post_id, $args)
{
if ($media) { if ($media) {
return $media; return $media;
} else { } else {
$url = get_template_directory_uri() . '/images/icon.png'; $url = get_template_directory_uri() . "/images/icon.png";
$permalink = get_permalink($post_id); $permalink = get_permalink($post_id);
return array( return [
array( [
"type" => 'image', "type" => "image",
"from" => 'custom_fallback', "from" => "custom_fallback",
"src" => esc_url($url), "src" => esc_url($url),
"href" => $permalink, "href" => $permalink,
) ],
); ];
} }
} }
add_filter('jetpack_images_get_images', 'windycoys_jetpack_custom_image', 10, 3); add_filter(
"jetpack_images_get_images",
"windycoys_jetpack_custom_image",
10,
3
);
function windycoys_strip_scripts(&$scripts) { function windycoys_strip_scripts(&$scripts)
if(!is_admin()){ {
$scripts->remove('jquery'); if (!is_admin()) {
$scripts->remove("jquery");
} }
} }
add_filter('wp_default_scripts', 'windycoys_strip_scripts'); add_filter("wp_default_scripts", "windycoys_strip_scripts");

View File

@@ -1,26 +1,33 @@
<?php <?php
$css_url = get_template_directory_uri() . '/style.css'; $css_url = get_template_directory_uri() . "/style.css";
$deploy_timestamp = windycoys_get_deploy_timestamp(); $deploy_timestamp = windycoys_get_deploy_timestamp();
if ($deploy_timestamp) { if ($deploy_timestamp) {
$css_url .= '?t=' . $deploy_timestamp; $css_url .= "?t=" . $deploy_timestamp;
} }
$manifest = get_template_directory_uri() . '/manifest.json'; $manifest = get_template_directory_uri() . "/manifest.json";
?> ?>
<!doctype html> <!doctype html>
<html <?php language_attributes(); ?>> <html <?php language_attributes(); ?>>
<head> <head>
<meta charset="<?php bloginfo('charset'); ?>"> <meta charset="<?php bloginfo("charset"); ?>">
<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' &laquo; '; } ?> <?php bloginfo('name'); ?></title> <title><?php
<meta name="description" content="<?php echo windycoys_get_description(get_the_id()) ?>"> wp_title("");
if (wp_title("", false)) {
echo " &laquo; ";
}
?> <?php bloginfo("name"); ?></title>
<meta name="description" content="<?php echo windycoys_get_description(
get_the_id()
); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#201f42"> <meta name="theme-color" content="#201f42">
<?php wp_head(); ?> <?php wp_head(); ?>
<link rel="me" href="https://twitter.com/WindyCOYS"> <link rel="me" href="https://twitter.com/WindyCOYS">
<link rel="icon" type="image/png" href="<?php echo get_template_directory_uri() ?>/images/icon_48.png"> <link rel="icon" type="image/png" href="<?php echo get_template_directory_uri(); ?>/images/icon_48.png">
<link rel="manifest" href="<?php echo $manifest ?>"> <link rel="manifest" href="<?php echo $manifest; ?>">
<link rel="stylesheet" href="<?php echo $css_url ?>"> <link rel="stylesheet" href="<?php echo $css_url; ?>">
<link href="//fonts.googleapis.com/css?family=Open+Sans|Raleway:700" rel="stylesheet"> <link href="//fonts.googleapis.com/css?family=Open+Sans|Raleway:700" rel="stylesheet">
<?php if (windycoys_is_ie()) : ?> <?php if (windycoys_is_ie()): ?>
<style type="text/css">.is-fixed .logo,.is-fixed .metadata{position: static;}</style> <style type="text/css">.is-fixed .logo,.is-fixed .metadata{position: static;}</style>
<?php endif; ?> <?php endif; ?>
</head> </head>

View File

@@ -1,17 +1,23 @@
<?php get_header() ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo"> <section class="page__logo">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<?php $index = 0; while ( have_posts() ) : the_post(); $index++; ?> <?php
<section class="page__article<?php echo ($index === 1 ? ' is-first' : '') ?>"> $index = 0;
while (have_posts()):
the_post();
$index++;
?>
<section class="page__article<?php echo $index === 1 ? " is-first" : ""; ?>">
<article class="article"> <article class="article">
<div class="article__date"> <div class="article__date">
<svg class="icon icon--extra-small"> <svg class="icon icon--extra-small">
<use href="#icon-calendar"></use> <use href="#icon-calendar"></use>
</svg> </svg>
<span class="article__date-text"> <span class="article__date-text">
<?php the_time(get_option('date_format')) ?> <?php the_time(get_option("date_format")); ?>
</span> </span>
</div> </div>
<div class="article__content"> <div class="article__content">
@@ -21,24 +27,31 @@
</a> </a>
</h1> </h1>
<div class="content"> <div class="content">
<?php the_content(__('Continue reading <span class="meta-nav">&raquo;</span>', 'windycoys')); ?> <?php the_content(
__(
'Continue reading <span class="meta-nav">&raquo;</span>',
"windycoys"
)
); ?>
</div> </div>
</div> </div>
</article> </article>
</section> </section>
<section class="page__metadata"> <section class="page__metadata">
<?php get_template_part('partials/metadata') ?> <?php get_template_part("partials/metadata"); ?>
</section> </section>
<?php endwhile; ?> <?php
endwhile;
?>
<section class="page__pagination"> <section class="page__pagination">
<?php get_template_part('partials/pagination') ?> <?php get_template_part("partials/pagination"); ?>
</section> </section>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,7 +1,9 @@
<?php get_header(); the_post(); ?> <?php get_header();
the_post();
?>
<main class="page"> <main class="page">
<section class="page__logo is-fixed"> <section class="page__logo is-fixed">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<section class="page__content"> <section class="page__content">
<h1 class="title"> <h1 class="title">
@@ -12,14 +14,14 @@
<div class="content"> <div class="content">
<?php the_content(); ?> <?php the_content(); ?>
</div> </div>
<?php get_template_part('partials/archive') ?> <?php get_template_part("partials/archive"); ?>
</section> </section>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,9 +1,11 @@
<?php get_header(); ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo"> <section class="page__logo">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<?php if (have_posts()): while (have_posts()) : the_post(); ?> <?php if (have_posts()):
while (have_posts()):
the_post(); ?>
<section class="page__content"> <section class="page__content">
<h1 class="title"> <h1 class="title">
<?php the_title(); ?> <?php the_title(); ?>
@@ -12,19 +14,23 @@
<?php the_content(); ?> <?php the_content(); ?>
</div> </div>
</section> </section>
<?php endwhile; ?> <?php
<?php else: ?> endwhile; ?>
<?php
else:
?>
<section class="page__content"> <section class="page__content">
<h1 class="title">Sorry, there is no article to display</h1> <h1 class="title">Sorry, there is no article to display</h1>
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a> <a class="link" href="<?php echo get_site_url(); ?>/">Go back home</a>
</section> </section>
<?php endif; ?> <?php
endif; ?>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,54 +1,56 @@
<?php <?php
$posts = get_posts(array( $posts = get_posts([
"numberposts" => -1, "numberposts" => -1,
"order" => 'ASC', "order" => "ASC",
)); ]);
$archive = array(); $archive = [];
foreach ($posts as $post) { foreach ($posts as $post) {
$date = strtotime($post->post_date); $date = strtotime($post->post_date);
$year = date('Y', $date); $year = date("Y", $date);
$month = date('F', $date); $month = date("F", $date);
$day = date('jS', $date); $day = date("jS", $date);
$url = get_permalink($post->ID); $url = get_permalink($post->ID);
$comments = $post->comment_count === '1' ? '1 comment' : $post->comment_count . ' comments'; $comments =
if ($post->post_status === 'publish') { $post->comment_count === "1"
$archive[$year][$month][] = array( ? "1 comment"
: $post->comment_count . " comments";
if ($post->post_status === "publish") {
$archive[$year][$month][] = [
"title" => $post->post_title, "title" => $post->post_title,
"slug" => $post->post_name, "slug" => $post->post_name,
"author" => $post->post_author, "author" => $post->post_author,
"day" => $day, "day" => $day,
"url" => $url, "url" => $url,
"comments" => $comments, "comments" => $comments,
); ];
} }
} }
?> ?>
<div class="archive"> <div class="archive">
<ol class="archive__list"> <ol class="archive__list">
<?php foreach ($archive as $year => $yearData) : ?> <?php foreach ($archive as $year => $yearData): ?>
<li class="archive__item"> <li class="archive__item">
<h2 class="archive__heading"> <h2 class="archive__heading">
<?php echo $year ?> <?php echo $year; ?>
</h2> </h2>
<ol class="archive__list archive__list--sub-list"> <ol class="archive__list archive__list--sub-list">
<?php foreach ($yearData as $month => $monthData) : ?> <?php foreach ($yearData as $month => $monthData): ?>
<li class="archive__item"> <li class="archive__item">
<h3 class="archive__subheading"> <h3 class="archive__subheading">
<?php echo $month ?> <?php echo $month; ?>
</h3> </h3>
<ol class="archive__list archive__list--sub-list"> <ol class="archive__list archive__list--sub-list">
<?php foreach ($monthData as $post) : ?> <?php foreach ($monthData as $post): ?>
<li class="archive__item"> <li class="archive__item">
<span class="archive__date"> <span class="archive__date">
<?php echo $post['day'] ?> <?php echo $post["day"]; ?>
</span> </span>
<a class="link" href="<?php echo $post['url'] ?>"> <a class="link" href="<?php echo $post["url"]; ?>">
<?php echo $post['title'] ?> <?php echo $post["title"]; ?>
</a> </a>
<span class="archive__comments"> <span class="archive__comments">
(<?php echo $post['comments'] ?>) (<?php echo $post["comments"]; ?>)
</span> </span>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>

View File

@@ -21,6 +21,6 @@
</a> </a>
</div> </div>
<div class="social__item"> <div class="social__item">
<?php echo do_shortcode('[paypal-donation]'); ?> <?php echo do_shortcode("[paypal-donation]"); ?>
</div> </div>
</div> </div>

View File

@@ -1,21 +1,22 @@
<?php <?php
global $excerpt; global $excerpt; ?>
?>
<div class="excerpt"> <div class="excerpt">
<div class="excerpt__head"> <div class="excerpt__head">
<div class="excerpt__title"> <div class="excerpt__title">
<a class="link" href="<?php echo $excerpt['url'] ?>"> <a class="link" href="<?php echo $excerpt["url"]; ?>">
<?php echo $excerpt['title'] ?> <?php echo $excerpt["title"]; ?>
</a> </a>
</div> </div>
</div> </div>
<div class="excerpt__body"> <div class="excerpt__body">
<?php echo str_replace( <?php echo str_replace(
'[...]', "[...]",
'<a class="link" href="' . $excerpt['url'] . '" aria-label="Read full article">' '<a class="link" href="' .
. '<svg class="icon icon--extra-extra-small"><use href="#icon-arrow-double-right"></use></a>', $excerpt["url"] .
$excerpt['content']); '" aria-label="Read full article">' .
?> '<svg class="icon icon--extra-extra-small"><use href="#icon-arrow-double-right"></use></a>',
$excerpt["content"]
); ?>
</div> </div>
<div class="excerpt__foot"> <div class="excerpt__foot">
<ul class="excerpt__list"> <ul class="excerpt__list">
@@ -25,16 +26,18 @@ global $excerpt;
<use href="#icon-profile"></use> <use href="#icon-profile"></use>
</svg> </svg>
</span> </span>
<span class="excerpt__text"><?php echo $excerpt['author'] ?></span> <span class="excerpt__text"><?php echo $excerpt["author"]; ?></span>
</li> </li>
<?php if ($excerpt['words']) : ?> <?php if ($excerpt["words"]): ?>
<li class="excerpt__list-item"> <li class="excerpt__list-item">
<span class="excerpt__icon"> <span class="excerpt__icon">
<svg class="icon icon--extra-small" aria-hidden="true"> <svg class="icon icon--extra-small" aria-hidden="true">
<use href="#icon-clock"></use> <use href="#icon-clock"></use>
</svg> </svg>
</span> </span>
<span class="excerpt__text"><?php echo windycoys_get_read_time($excerpt['words']) ?> minute read</span> <span class="excerpt__text"><?php echo windycoys_get_read_time(
$excerpt["words"]
); ?> minute read</span>
</li> </li>
<?php endif; ?> <?php endif; ?>
<li class="excerpt__list-item"> <li class="excerpt__list-item">
@@ -43,10 +46,10 @@ global $excerpt;
<use href="#icon-calendar"></use> <use href="#icon-calendar"></use>
</svg> </svg>
</span> </span>
<span class="excerpt__text"><?php echo $excerpt['date'] ?></span> <span class="excerpt__text"><?php echo $excerpt["date"]; ?></span>
</li> </li>
<li class="excerpt__list-item"> <li class="excerpt__list-item">
<a class="excerpt__list-link" href="<?php the_permalink() ?>#comments"> <a class="excerpt__list-link" href="<?php the_permalink(); ?>#comments">
<span class="excerpt__icon"> <span class="excerpt__icon">
<svg class="icon icon--extra-small" aria-hidden="true"> <svg class="icon icon--extra-small" aria-hidden="true">
<use href="#icon-comments"></use> <use href="#icon-comments"></use>
@@ -54,8 +57,8 @@ global $excerpt;
</span> </span>
<span class="excerpt__text"> <span class="excerpt__text">
<?php <?php
$number = $excerpt['comments']; $number = $excerpt["comments"];
echo $number === '1' ? '1 comment' : $number . ' comments'; echo $number === "1" ? "1 comment" : $number . " comments";
?> ?>
</span> </span>
</a> </a>

View File

@@ -1,12 +1,14 @@
<footer class="footer"> <footer class="footer">
<div class="footer__head"> <div class="footer__head">
<p class="footer__text">&copy; <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p> <p class="footer__text">&copy; <?php echo date("Y"); ?> <?php bloginfo(
"name"
); ?></p>
</div> </div>
<div class="footer__body"> <div class="footer__body">
<a href="https://www.newsnow.co.uk/h/Sport/Football/Premier+League/Tottenham+Hotspur" title="Click here for more Tottenham Hotspur news from NewsNow"> <a href="https://www.newsnow.co.uk/h/Sport/Football/Premier+League/Tottenham+Hotspur" title="Click here for more Tottenham Hotspur news from NewsNow">
<img src="<?php echo get_template_directory_uri() ?>/images/newsnow_sw.gif" alt="As featured on NewsNow: Tottenham Hotspur news"> <img src="<?php echo get_template_directory_uri(); ?>/images/newsnow_sw.gif" alt="As featured on NewsNow: Tottenham Hotspur news">
</a> </a>
</div> </div>
<?php get_template_part('icons') ?> <?php get_template_part("icons"); ?>
</footer> </footer>
<?php wp_footer() ?> <?php wp_footer(); ?>

View File

@@ -7,12 +7,12 @@
</svg> </svg>
</span> </span>
<span class="metadata__text"> <span class="metadata__text">
<?php the_time(get_option('date_format')) ?> <?php the_time(get_option("date_format")); ?>
</span> </span>
</li> </li>
<?php if (is_user_logged_in()): ?> <?php if (is_user_logged_in()): ?>
<li class="metadata__list-item"> <li class="metadata__list-item">
<a class="metadata__link" href="<?php echo get_edit_post_link() ?>"> <a class="metadata__link" href="<?php echo get_edit_post_link(); ?>">
<span class="metadata__icon"> <span class="metadata__icon">
<svg class="icon icon--small" aria-hidden="true"> <svg class="icon icon--small" aria-hidden="true">
<use href="#icon-edit"></use> <use href="#icon-edit"></use>
@@ -25,7 +25,7 @@
</li> </li>
<?php endif; ?> <?php endif; ?>
<li class="metadata__list-item"> <li class="metadata__list-item">
<a class="metadata__link" href="<?php the_permalink() ?>#comments"> <a class="metadata__link" href="<?php the_permalink(); ?>#comments">
<span class="metadata__icon"> <span class="metadata__icon">
<svg class="icon icon--small" aria-hidden="true"> <svg class="icon icon--small" aria-hidden="true">
<use href="#icon-comments"></use> <use href="#icon-comments"></use>
@@ -43,13 +43,13 @@
</svg> </svg>
</span> </span>
<span class="metadata__text"> <span class="metadata__text">
<?php windycoys_the_tags() ?> <?php windycoys_the_tags(); ?>
</span> </span>
</div> </div>
<li class="metadata__list-item"> <li class="metadata__list-item">
<div <div
class="fb-share-button" class="fb-share-button"
data-href="<?php echo get_the_permalink() ?>" data-href="<?php echo get_the_permalink(); ?>"
data-layout="box_count" data-layout="box_count"
data-size="small" data-size="small"
data-mobile-iframe="false" data-mobile-iframe="false"
@@ -66,8 +66,8 @@
<li class="metadata__list-item"> <li class="metadata__list-item">
<a <a
class="twitter-share-button" class="twitter-share-button"
href="<?php echo windycoys_get_twitter_share_url() ?>" href="<?php echo windycoys_get_twitter_share_url(); ?>"
data-url="<?php echo get_the_permalink() ?>" data-url="<?php echo get_the_permalink(); ?>"
> >
Tweet Tweet
</a> </a>

View File

@@ -1,13 +1,13 @@
<?php <?php
require get_template_directory() . '/classes/walker.navigation.php'; require get_template_directory() . "/classes/walker.navigation.php";
$menu = wp_nav_menu(array( $menu = wp_nav_menu([
'echo' => false, "echo" => false,
'menu' => 'navigation', "menu" => "navigation",
'container_class' => 'nav__menu', "container_class" => "nav__menu",
'menu_class' => 'nav__list', "menu_class" => "nav__list",
'walker' => new Windycoys_Walker_Navigation(), "walker" => new Windycoys_Walker_Navigation(),
)); ]);
$menu = str_replace( $menu = str_replace(
'ul id="menu-navigation" class="nav__list"', 'ul id="menu-navigation" class="nav__list"',
@@ -21,11 +21,13 @@ $menu = str_replace(
<span class="menu__line"></span> <span class="menu__line"></span>
<span class="menu__text">Open menu</span> <span class="menu__text">Open menu</span>
</button> </button>
<nav class="nav<?php echo is_user_logged_in() ? ' logged-in' : '' ?>" aria-label="Main Navigation"> <nav class="nav<?php echo is_user_logged_in()
? " logged-in"
: ""; ?>" aria-label="Main Navigation">
<div class="nav__content"> <div class="nav__content">
<div class="nav__head"> <div class="nav__head">
<h2 class="nav__title"> <h2 class="nav__title">
<a class="nav__title-link" href="<?php get_site_url() ?>/" aria-label="Back Home" tabindex="-1"> <a class="nav__title-link" href="<?php get_site_url(); ?>/" aria-label="Back Home" tabindex="-1">
<span class="nav__title-link-icon"> <span class="nav__title-link-icon">
<svg class="icon icon--extra-large"> <svg class="icon icon--extra-large">
<use href="#icon-windy"></use> <use href="#icon-windy"></use>
@@ -36,7 +38,7 @@ $menu = str_replace(
</h2> </h2>
</div> </div>
<div class="nav__body"> <div class="nav__body">
<?php echo $menu ?> <?php echo $menu; ?>
</div> </div>
<div class="nav__foot"> <div class="nav__foot">
<div class="nav__social"> <div class="nav__social">
@@ -52,7 +54,7 @@ $menu = str_replace(
</a> </a>
</div> </div>
<div class="nav__search"> <div class="nav__search">
<?php get_search_form() ?> <?php get_search_form(); ?>
</div> </div>
<button class="nav__close"> <button class="nav__close">
<span class="nav__close-bar"></span> <span class="nav__close-bar"></span>

View File

@@ -2,52 +2,57 @@
global $wp; global $wp;
$url = home_url($wp->request); $url = home_url($wp->request);
$base_url = substr($url, 0, strpos($url, "page/")); $base_url = substr($url, 0, strpos($url, "page/"));
$current = get_query_var('paged'); $current = get_query_var("paged");
$total = $wp_query->max_num_pages; $total = $wp_query->max_num_pages;
$links = paginate_links(array( $links = paginate_links([
"type" => 'array', "type" => "array",
"prev_next" => false, "prev_next" => false,
"current" => $current, "current" => $current,
"end_size" => 2, "end_size" => 2,
)); ]);
function get_previous_url($base_url, $page) { function get_previous_url($base_url, $page)
$qs = $_SERVER['QUERY_STRING']; {
$url = $base_url . 'page/' . ($page - 1); $qs = $_SERVER["QUERY_STRING"];
$url = $base_url . "page/" . ($page - 1);
if ($qs) { if ($qs) {
$url .= '/?' . $qs; $url .= "/?" . $qs;
} }
return $url; return $url;
} }
function get_next_url($base_url, $page) { function get_next_url($base_url, $page)
$qs = $_SERVER['QUERY_STRING']; {
$url = $base_url . 'page/'; $qs = $_SERVER["QUERY_STRING"];
$url = $base_url . "page/";
if ($page === 0) { if ($page === 0) {
$url .= '2'; $url .= "2";
} else { } else {
$url .= ($page + 1); $url .= $page + 1;
} }
if ($qs) { if ($qs) {
$url .= '/?' . $qs; $url .= "/?" . $qs;
} }
return $url; return $url;
} }
function format_link($link) { function format_link($link)
if (strpos($link, 'page-numbers dots')) { {
if (strpos($link, "page-numbers dots")) {
return '<span class="pagination__dots"><svg class="icon icon--extra-small"><use href="#icon-ellipsis"></use></svg></span>'; return '<span class="pagination__dots"><svg class="icon icon--extra-small"><use href="#icon-ellipsis"></use></svg></span>';
} }
$link = str_replace('page-numbers current', 'pagination__current', $link); $link = str_replace("page-numbers current", "pagination__current", $link);
$link = str_replace('page-numbers', 'link', $link); $link = str_replace("page-numbers", "link", $link);
return $link; return $link;
} }
if (count($links) > 1) : if (count($links) > 1): ?>
?>
<div class="pagination"> <div class="pagination">
<?php if ($current > 1) : ?> <?php if ($current > 1): ?>
<div class="pagination__previous"> <div class="pagination__previous">
<a class="pagination__link" href="<?php echo get_previous_url($base_url, $current) ?>" aria-label="Previous page"> <a class="pagination__link" href="<?php echo get_previous_url(
$base_url,
$current
); ?>" aria-label="Previous page">
<svg class="icon icon--small"> <svg class="icon icon--small">
<use href="#icon-chevron-left"></use> <use href="#icon-chevron-left"></use>
</svg> </svg>
@@ -56,16 +61,19 @@ if (count($links) > 1) :
<?php endif; ?> <?php endif; ?>
<nav class="pagination__content" role="navigation" aria-label="Pagination navigation"> <nav class="pagination__content" role="navigation" aria-label="Pagination navigation">
<ul class="pagination__list"> <ul class="pagination__list">
<?php foreach($links as $link) { ?> <?php foreach ($links as $link) { ?>
<li class="pagination__item"> <li class="pagination__item">
<?php echo format_link($link) ?> <?php echo format_link($link); ?>
</li> </li>
<?php } ?> <?php } ?>
</ul> </ul>
</nav> </nav>
<?php if ($current < $total) : ?> <?php if ($current < $total): ?>
<div class="pagination__next"> <div class="pagination__next">
<a class="pagination__link" href="<?php echo get_next_url($base_url, $current) ?>" aria-label="Next page"> <a class="pagination__link" href="<?php echo get_next_url(
$base_url,
$current
); ?>" aria-label="Next page">
<svg class="icon icon--small"> <svg class="icon icon--small">
<use href="#icon-chevron-right"></use> <use href="#icon-chevron-right"></use>
</svg> </svg>

View File

@@ -1,37 +1,39 @@
<?php <?php
global $podcast; global $podcast;
$artwork = get_template_directory_uri().'/images/'.$podcast['id'].'.png'; $artwork = get_template_directory_uri() . "/images/" . $podcast["id"] . ".png";
?> ?>
<div class="excerpt"> <div class="excerpt">
<div class="excerpt__head"> <div class="excerpt__head">
<img <img
class="excerpt__image" class="excerpt__image"
title="<?php echo $podcast['podcast_title'] ?>" title="<?php echo $podcast["podcast_title"]; ?>"
src="<?php echo $artwork ?>"> src="<?php echo $artwork; ?>">
<h3 class="excerpt__title"> <h3 class="excerpt__title">
<a class="link" href="<?php echo $podcast['url'] ?>"> <a class="link" href="<?php echo $podcast["url"]; ?>">
<?php echo $podcast['title'] ?> <?php echo $podcast["title"]; ?>
</a> </a>
</h3> </h3>
</div> </div>
<div class="excerpt__body"> <div class="excerpt__body">
<?php echo $podcast['description'] ?> <?php echo $podcast["description"]; ?>
</div> </div>
<div class="excerpt__foot"> <div class="excerpt__foot">
<audio class="excerpt__audio" src="<?php echo $podcast['audio'] ?>" controls="true"> <audio class="excerpt__audio" src="<?php echo $podcast[
"audio"
]; ?>" controls="true">
Your browser does not support the <code>audio</code> element. Your browser does not support the <code>audio</code> element.
</audio> </audio>
<ul class="excerpt__links"> <ul class="excerpt__links">
<li class="excerpt__link"> <li class="excerpt__link">
<a <a
class="link" class="link"
href="<?php echo $podcast['audio'] ?>" href="<?php echo $podcast["audio"]; ?>"
title="Download the MP3"> title="Download the MP3">
Download MP3 Download MP3
</a> </a>
</li> </li>
<li class="excerpt__link"> <li class="excerpt__link">
<a class="link" href="<?php echo $podcast['podcast_episodes'] ?>"> <a class="link" href="<?php echo $podcast["podcast_episodes"]; ?>">
More episodes More episodes
</a> </a>
</li> </li>
@@ -43,7 +45,7 @@ $artwork = get_template_directory_uri().'/images/'.$podcast['id'].'.png';
<use href="#icon-calendar"></use> <use href="#icon-calendar"></use>
</svg> </svg>
</span> </span>
<span class="excerpt__text"><?php echo $podcast['date'] ?></span> <span class="excerpt__text"><?php echo $podcast["date"]; ?></span>
</li> </li>
</ul> </ul>
</div> </div>

View File

@@ -1,52 +1,62 @@
<?php <?php
global $wp_query; global $wp_query;
get_header(); get_header();
$query = $_GET['s']; $query = $_GET["s"];
$results = $wp_query->found_posts; $results = $wp_query->found_posts;
?> ?>
<main class="page"> <main class="page">
<section class="page__logo is-fixed"> <section class="page__logo is-fixed">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<section class="page__content"> <section class="page__content">
<?php if ($results === 0) : ?> <?php if ($results === 0): ?>
<h1 class="title">Sorry, no results found.</h1> <h1 class="title">Sorry, no results found.</h1>
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a> <a class="link" href="<?php echo get_site_url(); ?>/">Go back home</a>
<?php else : ?> <?php else: ?>
<h1 class="title"> <h1 class="title">
<?php <?php echo $results .
echo $results.' result'.($results !== '1' ? 's' : '').' matching "' . $query . '" found.'; " result" .
?> ($results !== "1" ? "s" : "") .
' matching "' .
$query .
'" found.'; ?>
</h1> </h1>
<?php endif; ?> <?php endif; ?>
<ol> <ol>
<?php if (have_posts()): while (have_posts()) : the_post(); ?> <?php if (have_posts()):
while (have_posts()):
the_post(); ?>
<li> <li>
<?php <?php
$excerpt = array( $excerpt = [
"title" => get_the_title(), "title" => get_the_title(),
"url" => get_the_permalink(), "url" => get_the_permalink(),
"content" => get_the_excerpt(), "content" => get_the_excerpt(),
"author" => get_the_author_meta('nickname'), "author" => get_the_author_meta("nickname"),
"comments" => get_comments_number(), "comments" => get_comments_number(),
"date" => get_the_date(get_option('date_format'), $id) . ' at ' . get_the_date(get_option('time_format'), $id), "date" =>
get_the_date(get_option("date_format"), $id) .
" at " .
get_the_date(get_option("time_format"), $id),
"words" => count(explode(" ", $post->post_content)), "words" => count(explode(" ", $post->post_content)),
); ];
get_template_part('partials/excerpt') get_template_part("partials/excerpt");
?> ?>
</li> </li>
<?php endwhile; endif; ?> <?php
endwhile;
endif; ?>
</ol> </ol>
</section> </section>
<section class="page__pagination"> <section class="page__pagination">
<?php get_template_part('partials/pagination') ?> <?php get_template_part("partials/pagination"); ?>
</section> </section>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,4 +1,4 @@
<form id="searchform" role="search" method="get" action="<?php echo get_site_url()?>"> <form id="searchform" role="search" method="get" action="<?php echo get_site_url(); ?>">
<div class="search"> <div class="search">
<label class="search__label" for="searchinput"> <label class="search__label" for="searchinput">
Search Search

View File

@@ -1,9 +1,11 @@
<?php get_header(); ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo is-fixed"> <section class="page__logo is-fixed">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<?php if (have_posts()): while (have_posts()) : the_post(); ?> <?php if (have_posts()):
while (have_posts()):
the_post(); ?>
<section class="page__article is-first"> <section class="page__article is-first">
<article class="article"> <article class="article">
<div class="article__date"> <div class="article__date">
@@ -13,7 +15,7 @@
</svg> </svg>
</span> </span>
<span class="article__date-text"> <span class="article__date-text">
<?php the_time(get_option('date_format')) ?> <?php the_time(get_option("date_format")); ?>
</span> </span>
</div> </div>
<div class="article__content"> <div class="article__content">
@@ -21,30 +23,39 @@
<?php the_title(); ?> <?php the_title(); ?>
</h1> </h1>
<div class="content"> <div class="content">
<?php the_content(__('Continue reading <span class="meta-nav">&raquo;</span>', 'windycoys')); ?> <?php the_content(
__(
'Continue reading <span class="meta-nav">&raquo;</span>',
"windycoys"
)
); ?>
</div> </div>
</div> </div>
</article> </article>
</section> </section>
<section class="page__metadata is-fixed"> <section class="page__metadata is-fixed">
<?php get_template_part('partials/metadata') ?> <?php get_template_part("partials/metadata"); ?>
</section> </section>
<section class="page__comments"> <section class="page__comments">
<?php comments_template() ?> <?php comments_template(); ?>
</section> </section>
<?php endwhile; ?> <?php
<?php else: ?> endwhile; ?>
<?php
else:
?>
<section class="page__content"> <section class="page__content">
<h1 class="title">Sorry, there is no article to display</h1> <h1 class="title">Sorry, there is no article to display</h1>
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a> <a class="link" href="<?php echo get_site_url(); ?>/">Go back home</a>
</section> </section>
<?php endif; ?> <?php
endif; ?>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>

View File

@@ -1,7 +1,7 @@
<?php get_header() ?> <?php get_header(); ?>
<main class="page"> <main class="page">
<section class="page__logo is-fixed"> <section class="page__logo is-fixed">
<?php get_template_part('partials/logo') ?> <?php get_template_part("partials/logo"); ?>
</section> </section>
<section class="page__content"> <section class="page__content">
<h1 class="title"> <h1 class="title">
@@ -11,43 +11,52 @@
</svg> </svg>
</span> </span>
<span class="title__text"> <span class="title__text">
<?php echo single_tag_title() ?> <?php echo single_tag_title(); ?>
</span> </span>
</h1> </h1>
<ol> <ol>
<?php if (have_posts()): while (have_posts()) : the_post(); ?> <?php if (have_posts()):
while (have_posts()):
the_post(); ?>
<li> <li>
<?php <?php
$excerpt = array( $excerpt = [
"title" => get_the_title(), "title" => get_the_title(),
"url" => get_the_permalink(), "url" => get_the_permalink(),
"content" => get_the_excerpt(), "content" => get_the_excerpt(),
"author" => get_the_author_meta('nickname'), "author" => get_the_author_meta("nickname"),
"comments" => get_comments_number(), "comments" => get_comments_number(),
"date" => get_the_date(get_option('date_format'), $id) . ' at ' . get_the_date(get_option('time_format'), $id), "date" =>
get_the_date(get_option("date_format"), $id) .
" at " .
get_the_date(get_option("time_format"), $id),
"words" => count(explode(" ", $post->post_content)), "words" => count(explode(" ", $post->post_content)),
); ];
get_template_part('partials/excerpt'); get_template_part("partials/excerpt");
?> ?>
</li> </li>
<?php endwhile; ?> <?php
endwhile; ?>
</ol> </ol>
</section> </section>
<section class="page__pagination"> <section class="page__pagination">
<?php get_template_part('partials/pagination') ?> <?php get_template_part("partials/pagination"); ?>
</section> </section>
<?php else: ?> <?php
else:
?>
<section class="page__content"> <section class="page__content">
<h1 class="title">Sorry, no results found.</h1> <h1 class="title">Sorry, no results found.</h1>
<a class="link" href="<?php echo get_site_url() ?>/">Go back home</a> <a class="link" href="<?php echo get_site_url(); ?>/">Go back home</a>
</section> </section>
<?php endif; ?> <?php
endif; ?>
<section class="page__banner"> <section class="page__banner">
<?php get_template_part('partials/banner') ?> <?php get_template_part("partials/banner"); ?>
</section> </section>
<section class="page__footer"> <section class="page__footer">
<?php get_template_part('partials/footer') ?> <?php get_template_part("partials/footer"); ?>
</section> </section>
</main> </main>
<?php get_template_part('partials/navigation') ?> <?php get_template_part("partials/navigation"); ?>
<?php get_footer() ?> <?php get_footer(); ?>