Skip to content

Commit

Permalink
refactor: views format
Browse files Browse the repository at this point in the history
  • Loading branch information
lastofpudge committed Feb 20, 2024
1 parent 86e76da commit 0c4cbc3
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
php: ['7.4', '8.3']

steps:
- name: Checkout the project
Expand Down
1 change: 1 addition & 0 deletions app/Admin/HiddenData.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function removeEmojiActions(): void
{
add_filter('emoji_svg_url', '__return_false');
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
remove_filter('the_content_feed', 'wp_staticize_emoji');
Expand Down
26 changes: 13 additions & 13 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
if (!function_exists('send_email')) {
/**
* Send a custom email.
* @param string $templateFilename
* @param array $templateData
* @param string $templateFilename
* @param array $templateData
* @return bool|null
*/
function send_email(string $templateFilename, array $templateData): ?bool
Expand All @@ -19,8 +19,8 @@ function send_email(string $templateFilename, array $templateData): ?bool

/**
* Compile an email template.
* @param string $filename
* @param array $data
* @param string $filename
* @param array $data
* @return string
*/
function compile_email_template(string $filename, array $data): string
Expand All @@ -30,8 +30,8 @@ function compile_email_template(string $filename, array $data): string

/**
* Dispatch an email.
* @param string $subject
* @param string $body
* @param string $subject
* @param string $body
* @return bool
*/
function dispatch_email(string $subject, string $body): bool
Expand All @@ -50,7 +50,7 @@ function dispatch_email(string $subject, string $body): bool
if (!function_exists('add_ajax_action')) {
/**
* Registers an AJAX action with WordPress.
* @param string $name The name of the AJAX action.
* @param string $name The name of the AJAX action.
*/
function add_ajax_action(string $name): void
{
Expand All @@ -61,9 +61,9 @@ function add_ajax_action(string $name): void

/**
* Helper function to implement AJAX action registration.
* @param string $name The name of the AJAX action.
* @param string $hook The WordPress hook to associate with the action.
* @param string $action_path Path to the PHP file that handles the action.
* @param string $name The name of the AJAX action.
* @param string $hook The WordPress hook to associate with the action.
* @param string $action_path Path to the PHP file that handles the action.
*/
function add_ajax_action_impl(string $name, string $hook, string $action_path): void
{
Expand All @@ -76,7 +76,7 @@ function add_ajax_action_impl(string $name, string $hook, string $action_path):
if (!function_exists('dd')) {
/**
* Debug function to dump and die. Outputs the given variable and stops execution.
* @param mixed $result The variable to be dumped.
* @param mixed $result The variable to be dumped.
*/
function dd(mixed $result): void
{
Expand Down Expand Up @@ -104,10 +104,10 @@ function crb_get_i18n_suffix(): string
if (!function_exists('crb_get_i18n_theme_option')) {
/**
* Retrieves a theme option value with internationalization support.
* @param string $option_name The name of the theme option.
* @param string $option_name The name of the theme option.
* @return mixed The value of the theme option for the current language.
*/
function crb_get_i18n_theme_option(string $option_name)
function crb_get_i18n_theme_option(string $option_name): mixed
{
$suffix = crb_get_i18n_suffix();
return carbon_get_theme_option($option_name . $suffix);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "theme/blank",
"type": "wp-theme",
"version": "2.0.15",
"version": "2.0.16",
"description": "Wordpress starter theme with Timber/Twig",
"license": "GPL-3.0-or-later",
"authors": [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"git-commit-msg-linter": "^5.0.0",
"laravel-mix": "^6.0.6",
"prettier": "^3.2.5",
"prettier-plugin-twig-melody": "^0.4.6",
"sass": "^1.70.0",
"sass-loader": "^14.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions resources/views/categories/category.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>

{{ fn('yoast_breadcrumb', '<nav id="breadcrumbs" class="main-breadcrumbs">','</nav>', false ) }}

{% for post in posts %}
<div class="category-post" style="padding:15px;">
<h2>
Expand All @@ -18,8 +18,8 @@
{{ post.post_date_gmt|time_ago }}
</time>
</p>
{% if post.get_thumbnail %}
<img src="{{ post.thumbnail.src }}" alt="{{ post.title }}" />
{% if post.thumbnail %}
<img src="{{ post.thumbnail.src }}" srcset="{{ post.thumbnail.srcset }}" alt="{{ post.title }}" />
{% else %}
<img src="{{ theme.path }}/resources/assets/dist/images/placeholders/no-image-default.png"
alt="" />
Expand Down
9 changes: 4 additions & 5 deletions resources/views/components/head.twig
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<meta charset="{{ site.charset }}" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta charset="{{ site.charset }}">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1.0, viewport-fit=cover" />
content="width=device-width, initial-scale=1, minimum-scale=1.0, viewport-fit=cover">
{{ fn('wp_head') }}
<link rel="stylesheet"
href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous" />
crossorigin="anonymous">
17 changes: 9 additions & 8 deletions resources/views/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
<div class="col-12">
<a class="logo-link" href="{{ site.url }}" rel="home">{{ site.name }}"</a>
</div>

<div class="col-12">
<h2>
Contact form </h2>
<form method="POST" class="contact-form js-contact-form" accept-charset="utf-8">

<form method="POST"
class="contact-form js-contact-form" accept-charset="utf-8" autocomplete="on">
<div class="form-group">
<label><input name="name" placeholder="Name" autocomplete="true" /></label>
<label><input name="name" placeholder="Name"></label>
</div>
<div class="form-group">
<label><input name="mail" type="email" placeholder="Email" /></label>
<label><input name="mail" type="email" placeholder="Email"></label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">submit</button>
Expand All @@ -23,12 +24,12 @@

<h2>
Login form </h2>
<form method="POST" class="contact-form js-login-form" accept-charset="utf-8">
<form method="POST" class="contact-form js-login-form" accept-charset="utf-8" autocomplete="on">
<div class="form-group">
<label><input name="email" placeholder="Email" autocomplete="true" /></label>
<label><input name="email" placeholder="Email"></label>
</div>
<div class="form-group">
<label><input name="password" type="password" placeholder="Password" autocomplete="true" /></label>
<label><input name="password" type="password" placeholder="Password"></label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">submit</button>
Expand All @@ -38,7 +39,7 @@
Search form </h2>
<form method="get" accept-charset="utf-8" role="search" action="{{ site.url }}">
<div class="form-group">
<label><input name="s" required /></label>
<label><input name="s" required></label>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">submit</button>
Expand Down
12 changes: 5 additions & 7 deletions resources/views/layouts/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
<body class="{{ body_class }}">
<div class="preloader-main js-preloader-main"></div>
{% include 'components/header.twig' %}
<main id="content" class="content-wrapper">
<div class="wrapper">
{% block content %}
<p>Sorry, no content</p>
{% endblock %}
</div>
</main>

<div class="wrapper">
{% block content %}
{% endblock %}
</div>

{% block modals %}
{% include 'components/modals.twig' %}
Expand Down
17 changes: 9 additions & 8 deletions resources/views/pages/list.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
{% block content %}
{% for post in posts %}
<div class="category-post" style="padding:15px;">
<h2>
<a href="{{ post.link }}">{{ post.title }}</a>
</h2>
{% if post.get_thumbnail %}
<img src="{{ post.thumbnail.src }}" alt="" />
{% endif %}
<h2>
<a href="{{ post.link }}">{{ post.title }}</a>
</h2>

{{ post.excerpt(20, false, '', true) }}
{% if post.thumbnail %}
<img src="{{ post.thumbnail.src }}" srcset="{{ post.thumbnail.srcset }}" alt="{{ post.title }}" />
{% else %}

{{ post.excerpt(20, false, '', true) }}
</div>
{% endfor %}

{% include 'components/pagination.twig' %}
{% endblock %}
9 changes: 7 additions & 2 deletions resources/views/posts/post.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

{% block content %}
<div class="post-wrap" id="post-{{ post.ID }}">
{{ fn('yoast_breadcrumb', '<nav id="breadcrumbs" class="main-breadcrumbs">','</nav>', false ) }}
{{ fn('yoast_breadcrumb', '<nav id="breadcrumbs" class="main-breadcrumbs">','</nav>', true ) }}

<h1>
{{ post.title }}
</h1>

{% if post.thumbnail.src %}
<img src="{{ post.thumbnail.src('full') }}" alt="{{ post.title }}" title="{{ post.title }}" />
<img src="{{ post.thumbnail.src }}" srcset="{{ post.thumbnail.srcset }}" alt='' />
{% endif %}

{{ post.content }}

<ul class="tag-list">
{% for term in post.terms('tags') %}
<li><a href="{{ term.link }}">{{ term.name }}</a></li>
{% endfor %}
</ul>

<p class="byline">
<span class="name">By {{ post.author.name }}</span>
<time datetime="{{ post.post_date_gmt }}">{{ post.post_date|date('F j, Y') }}</time>
</p>

{% include 'components/comments/comment_wrapper.twig' %}

{{ fn(
Expand Down
4 changes: 2 additions & 2 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
Theme Name: wp-theme
Theme URI:https://github.com/lastofpudge/wp-theme
Version: 2.0.15
Version: 2.0.16
License: GNU General Public License v3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Requires PHP: 8.0
Requires at least: 5.9
Text Domain: wp-theme
Template: wp-theme/resources
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share with others
Use it to make something cool, have fun, and share with others.
*/
Loading

0 comments on commit 0c4cbc3

Please sign in to comment.